diff --git a/.gitignore b/.gitignore index f85fc969b1..9fa6f71cc7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ # -andrewrk zig-cache/ +/release/ +/debug/ /build/ /build-*/ /docgen_tmp/ diff --git a/CMakeLists.txt b/CMakeLists.txt index ea61fd95c0..6e89d87ca9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,8 +25,8 @@ project(zig C CXX) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) set(ZIG_VERSION_MAJOR 0) -set(ZIG_VERSION_MINOR 7) -set(ZIG_VERSION_PATCH 1) +set(ZIG_VERSION_MINOR 8) +set(ZIG_VERSION_PATCH 0) set(ZIG_VERSION "" CACHE STRING "Override Zig version string. Default is to find out with git.") if("${ZIG_VERSION}" STREQUAL "") @@ -34,18 +34,31 @@ if("${ZIG_VERSION}" STREQUAL "") find_program(GIT_EXE NAMES git) if(GIT_EXE) execute_process( - COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} name-rev HEAD --tags --name-only --no-undefined --always + COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} describe --match *.*.* --tags RESULT_VARIABLE EXIT_STATUS - OUTPUT_VARIABLE ZIG_GIT_REV + OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) if(EXIT_STATUS EQUAL "0") - if(ZIG_GIT_REV MATCHES "\\^0$") - if(NOT("${ZIG_GIT_REV}" STREQUAL "${ZIG_VERSION}^0")) - message("WARNING: Tag does not match configured Zig version") + if(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)$") + # Tagged release version. + set(GIT_TAG ${CMAKE_MATCH_1}) + if(NOT GIT_TAG VERSION_EQUAL ZIG_VERSION) + message(SEND_ERROR "Zig version (${ZIG_VERSION}) does not match Git tag (${GIT_TAG}).") endif() + elseif(GIT_DESCRIBE MATCHES "^v?([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-g(.+)$") + # Untagged pre-release. The Zig version is updated to include the number of commits + # since the last tagged version and the commit hash. The version is formatted in + # accordance with the https://semver.org specification. + set(GIT_TAG ${CMAKE_MATCH_1}) + set(GIT_COMMITS_AFTER_TAG ${CMAKE_MATCH_2}) + set(GIT_COMMIT ${CMAKE_MATCH_3}) + if(NOT ZIG_VERSION VERSION_GREATER GIT_TAG) + message(SEND_ERROR "Zig version (${ZIG_VERSION}) must be greater than tagged ancestor (${GIT_TAG}).") + endif() + set(ZIG_VERSION "${ZIG_VERSION}-dev.${GIT_COMMITS_AFTER_TAG}+${GIT_COMMIT}") else() - set(ZIG_VERSION "${ZIG_VERSION}+${ZIG_GIT_REV}") + message(WARNING "Failed to parse version from output of `git describe`.") endif() endif() endif() @@ -75,6 +88,8 @@ set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for" set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries for") set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary") set(ZIG_PREFER_LLVM_CONFIG off CACHE BOOL "(when cross compiling) use llvm-config to find target llvm dependencies if needed") +set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread") +set(ZIG_OMIT_STAGE2 off CACHE BOOL "omit the stage2 backend from stage1") find_package(llvm) find_package(clang) @@ -319,7 +334,6 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/atomic/int.zig" "${CMAKE_SOURCE_DIR}/lib/std/atomic/queue.zig" "${CMAKE_SOURCE_DIR}/lib/std/atomic/stack.zig" - "${CMAKE_SOURCE_DIR}/lib/std/auto_reset_event.zig" "${CMAKE_SOURCE_DIR}/lib/std/base64.zig" "${CMAKE_SOURCE_DIR}/lib/std/buf_map.zig" "${CMAKE_SOURCE_DIR}/lib/std/builtin.zig" @@ -356,13 +370,14 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/heap.zig" "${CMAKE_SOURCE_DIR}/lib/std/heap/arena_allocator.zig" "${CMAKE_SOURCE_DIR}/lib/std/io.zig" - "${CMAKE_SOURCE_DIR}/lib/std/io/auto_indenting_stream.zig" "${CMAKE_SOURCE_DIR}/lib/std/io/buffered_atomic_file.zig" "${CMAKE_SOURCE_DIR}/lib/std/io/buffered_writer.zig" "${CMAKE_SOURCE_DIR}/lib/std/io/change_detection_stream.zig" + "${CMAKE_SOURCE_DIR}/lib/std/io/counting_reader.zig" "${CMAKE_SOURCE_DIR}/lib/std/io/counting_writer.zig" - "${CMAKE_SOURCE_DIR}/lib/std/io/find_byte_out_stream.zig" + "${CMAKE_SOURCE_DIR}/lib/std/io/find_byte_writer.zig" "${CMAKE_SOURCE_DIR}/lib/std/io/fixed_buffer_stream.zig" + "${CMAKE_SOURCE_DIR}/lib/std/io/limited_reader.zig" "${CMAKE_SOURCE_DIR}/lib/std/io/reader.zig" "${CMAKE_SOURCE_DIR}/lib/std/io/seekable_stream.zig" "${CMAKE_SOURCE_DIR}/lib/std/io/writer.zig" @@ -392,7 +407,7 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/meta.zig" "${CMAKE_SOURCE_DIR}/lib/std/meta/trailer_flags.zig" "${CMAKE_SOURCE_DIR}/lib/std/meta/trait.zig" - "${CMAKE_SOURCE_DIR}/lib/std/mutex.zig" + "${CMAKE_SOURCE_DIR}/lib/std/multi_array_list.zig" "${CMAKE_SOURCE_DIR}/lib/std/os.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/bits.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux.zig" @@ -408,11 +423,10 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/os/windows/bits.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig" "${CMAKE_SOURCE_DIR}/lib/std/os/windows/win32error.zig" + "${CMAKE_SOURCE_DIR}/lib/std/Progress.zig" "${CMAKE_SOURCE_DIR}/lib/std/pdb.zig" "${CMAKE_SOURCE_DIR}/lib/std/process.zig" - "${CMAKE_SOURCE_DIR}/lib/std/progress.zig" "${CMAKE_SOURCE_DIR}/lib/std/rand.zig" - "${CMAKE_SOURCE_DIR}/lib/std/reset_event.zig" "${CMAKE_SOURCE_DIR}/lib/std/sort.zig" "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt.zig" "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/addXf3.zig" @@ -476,7 +490,6 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/udivmodti4.zig" "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/udivti3.zig" "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/umodti3.zig" - "${CMAKE_SOURCE_DIR}/lib/std/spinlock.zig" "${CMAKE_SOURCE_DIR}/lib/std/start.zig" "${CMAKE_SOURCE_DIR}/lib/std/std.zig" "${CMAKE_SOURCE_DIR}/lib/std/target.zig" @@ -495,7 +508,11 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/lib/std/target/systemz.zig" "${CMAKE_SOURCE_DIR}/lib/std/target/wasm.zig" "${CMAKE_SOURCE_DIR}/lib/std/target/x86.zig" - "${CMAKE_SOURCE_DIR}/lib/std/thread.zig" + "${CMAKE_SOURCE_DIR}/lib/std/Thread.zig" + "${CMAKE_SOURCE_DIR}/lib/std/Thread/AutoResetEvent.zig" + "${CMAKE_SOURCE_DIR}/lib/std/Thread/Mutex.zig" + "${CMAKE_SOURCE_DIR}/lib/std/Thread/ResetEvent.zig" + "${CMAKE_SOURCE_DIR}/lib/std/Thread/StaticResetEvent.zig" "${CMAKE_SOURCE_DIR}/lib/std/time.zig" "${CMAKE_SOURCE_DIR}/lib/std/unicode.zig" "${CMAKE_SOURCE_DIR}/lib/std/zig.zig" @@ -513,7 +530,9 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/src/Module.zig" "${CMAKE_SOURCE_DIR}/src/Package.zig" "${CMAKE_SOURCE_DIR}/src/RangeSet.zig" + "${CMAKE_SOURCE_DIR}/src/ThreadPool.zig" "${CMAKE_SOURCE_DIR}/src/TypedValue.zig" + "${CMAKE_SOURCE_DIR}/src/WaitGroup.zig" "${CMAKE_SOURCE_DIR}/src/astgen.zig" "${CMAKE_SOURCE_DIR}/src/clang.zig" "${CMAKE_SOURCE_DIR}/src/clang_options.zig" @@ -523,6 +542,7 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/src/codegen/arm.zig" "${CMAKE_SOURCE_DIR}/src/codegen/c.zig" "${CMAKE_SOURCE_DIR}/src/codegen/llvm.zig" + "${CMAKE_SOURCE_DIR}/src/codegen/llvm/bindings.zig" "${CMAKE_SOURCE_DIR}/src/codegen/riscv64.zig" "${CMAKE_SOURCE_DIR}/src/codegen/spu-mk2.zig" "${CMAKE_SOURCE_DIR}/src/codegen/wasm.zig" @@ -532,6 +552,7 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/src/ir.zig" "${CMAKE_SOURCE_DIR}/src/libc_installation.zig" "${CMAKE_SOURCE_DIR}/src/libcxx.zig" + "${CMAKE_SOURCE_DIR}/src/libtsan.zig" "${CMAKE_SOURCE_DIR}/src/libunwind.zig" "${CMAKE_SOURCE_DIR}/src/link.zig" "${CMAKE_SOURCE_DIR}/src/link/C.zig" @@ -540,10 +561,9 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/src/link/MachO.zig" "${CMAKE_SOURCE_DIR}/src/link/MachO/Trie.zig" "${CMAKE_SOURCE_DIR}/src/link/Wasm.zig" - "${CMAKE_SOURCE_DIR}/src/link/cbe.h" + "${CMAKE_SOURCE_DIR}/src/link/C/zig.h" "${CMAKE_SOURCE_DIR}/src/link/msdos-stub.bin" "${CMAKE_SOURCE_DIR}/src/liveness.zig" - "${CMAKE_SOURCE_DIR}/src/llvm.zig" "${CMAKE_SOURCE_DIR}/src/main.zig" "${CMAKE_SOURCE_DIR}/src/mingw.zig" "${CMAKE_SOURCE_DIR}/src/musl.zig" @@ -553,6 +573,7 @@ set(ZIG_STAGE2_SOURCES "${CMAKE_SOURCE_DIR}/src/target.zig" "${CMAKE_SOURCE_DIR}/src/tracy.zig" "${CMAKE_SOURCE_DIR}/src/translate_c.zig" + "${CMAKE_SOURCE_DIR}/src/translate_c/ast.zig" "${CMAKE_SOURCE_DIR}/src/type.zig" "${CMAKE_SOURCE_DIR}/src/value.zig" "${CMAKE_SOURCE_DIR}/src/windows_sdk.zig" @@ -568,6 +589,12 @@ if(MSVC) endif() endif() +if(ZIG_OMIT_STAGE2) + set(ZIG_OMIT_STAGE2_BOOL "true") +else() + set(ZIG_OMIT_STAGE2_BOOL "false") +endif() + configure_file ( "${CMAKE_SOURCE_DIR}/src/stage1/config.h.in" "${ZIG_CONFIG_H_OUT}" @@ -713,6 +740,11 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") else() set(ZIG1_RELEASE_ARG -OReleaseFast --strip) endif() +if(ZIG_SINGLE_THREADED) + set(ZIG1_SINGLE_THREADED_ARG "--single-threaded") +else() + set(ZIG1_SINGLE_THREADED_ARG "") +endif() set(BUILD_ZIG1_ARGS "src/stage1.zig" @@ -722,6 +754,7 @@ set(BUILD_ZIG1_ARGS --override-lib-dir "${CMAKE_SOURCE_DIR}/lib" "-femit-bin=${ZIG1_OBJECT}" "${ZIG1_RELEASE_ARG}" + "${ZIG1_SINGLE_THREADED_ARG}" -lc --pkg-begin build_options "${ZIG_CONFIG_ZIG_OUT}" --pkg-end diff --git a/README.md b/README.md index 5eedcdab8b..e98eebf29f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A general-purpose programming language and toolchain for maintaining ## Resources - * [Introduction](https://ziglang.org/#Introduction) + * [Introduction](https://ziglang.org/learn/#introduction) * [Download & Documentation](https://ziglang.org/download) * [Chapter 0 - Getting Started | ZigLearn.org](https://ziglearn.org/) * [Community](https://github.com/ziglang/zig/wiki/Community) diff --git a/build.zig b/build.zig index b6dfbf547f..92e03603c5 100644 --- a/build.zig +++ b/build.zig @@ -11,7 +11,7 @@ const fs = std.fs; const InstallDirectoryOptions = std.build.InstallDirectoryOptions; const assert = std.debug.assert; -const zig_version = std.builtin.Version{ .major = 0, .minor = 7, .patch = 1 }; +const zig_version = std.builtin.Version{ .major = 0, .minor = 8, .patch = 0 }; pub fn build(b: *Builder) !void { b.setPreferredReleaseMode(.ReleaseFast); @@ -77,10 +77,12 @@ pub fn build(b: *Builder) !void { const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source"); const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse enable_llvm; + const strip = b.option(bool, "strip", "Omit debug information") orelse false; const main_file = if (is_stage1) "src/stage1.zig" else "src/main.zig"; var exe = b.addExecutable("zig", main_file); + exe.strip = strip; exe.install(); exe.setBuildMode(mode); exe.setTarget(target); @@ -91,6 +93,7 @@ pub fn build(b: *Builder) !void { exe.addBuildOption(bool, "have_llvm", enable_llvm); if (enable_llvm) { const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); + if (is_stage1) { exe.addIncludeDir("src"); exe.addIncludeDir("deps/SoftFloat-3e/source/include"); @@ -109,28 +112,8 @@ pub fn build(b: *Builder) !void { softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" }); exe.linkLibrary(softfloat); - const exe_cflags = [_][]const u8{ - "-std=c++14", - "-D__STDC_CONSTANT_MACROS", - "-D__STDC_FORMAT_MACROS", - "-D__STDC_LIMIT_MACROS", - "-D_GNU_SOURCE", - "-fvisibility-inlines-hidden", - "-fno-exceptions", - "-fno-rtti", - "-Werror=type-limits", - "-Wno-missing-braces", - "-Wno-comment", - }; exe.addCSourceFiles(&stage1_sources, &exe_cflags); exe.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" }); - if (cmake_cfg == null) { - // We need this because otherwise zig_clang_cc1_main.cpp ends up pulling - // in a dependency on llvm::cfg::Update::dump() which is - // unavailable when LLVM is compiled in Release mode. - const zig_cpp_cflags = exe_cflags ++ [_][]const u8{"-DNDEBUG=1"}; - exe.addCSourceFiles(&zig_cpp_sources, &zig_cpp_cflags); - } } if (cmake_cfg) |cfg| { // Inside this code path, we have to coordinate with system packaged LLVM, Clang, and LLD. @@ -139,79 +122,13 @@ pub fn build(b: *Builder) !void { if (cfg.cmake_prefix_path.len > 0) { b.addSearchPrefix(cfg.cmake_prefix_path); } - exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{ - cfg.cmake_binary_dir, - "zigcpp", - b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }), - }) catch unreachable); - assert(cfg.lld_include_dir.len != 0); - exe.addIncludeDir(cfg.lld_include_dir); - addCMakeLibraryList(exe, cfg.clang_libraries); - addCMakeLibraryList(exe, cfg.lld_libraries); - addCMakeLibraryList(exe, cfg.llvm_libraries); - const need_cpp_includes = tracy != null; - - // System -lc++ must be used because in this code path we are attempting to link - // against system-provided LLVM, Clang, LLD. - if (exe.target.getOsTag() == .linux) { - // First we try to static link against gcc libstdc++. If that doesn't work, - // we fall back to -lc++ and cross our fingers. - addCxxKnownPath(b, cfg, exe, "libstdc++.a", "", need_cpp_includes) catch |err| switch (err) { - error.RequiredLibraryNotFound => { - exe.linkSystemLibrary("c++"); - }, - else => |e| return e, - }; - - exe.linkSystemLibrary("pthread"); - } else if (exe.target.isFreeBSD()) { - try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes); - exe.linkSystemLibrary("pthread"); - } else if (exe.target.getOsTag() == .openbsd) { - try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes); - try addCxxKnownPath(b, cfg, exe, "libc++abi.a", null, need_cpp_includes); - } else if (exe.target.isDarwin()) { - if (addCxxKnownPath(b, cfg, exe, "libgcc_eh.a", "", need_cpp_includes)) { - // Compiler is GCC. - try addCxxKnownPath(b, cfg, exe, "libstdc++.a", null, need_cpp_includes); - exe.linkSystemLibrary("pthread"); - // TODO LLD cannot perform this link. - // Set ZIG_SYSTEM_LINKER_HACK env var to use system linker ld instead. - // See https://github.com/ziglang/zig/issues/1535 - } else |err| switch (err) { - error.RequiredLibraryNotFound => { - // System compiler, not gcc. - exe.linkSystemLibrary("c++"); - }, - else => |e| return e, - } - } - - if (cfg.dia_guids_lib.len != 0) { - exe.addObjectFile(cfg.dia_guids_lib); - } + try addCmakeCfgOptionsToExe(b, cfg, tracy, exe); + try addCmakeCfgOptionsToExe(b, cfg, tracy, test_stage2); } else { // Here we are -Denable-llvm but no cmake integration. - for (clang_libs) |lib_name| { - exe.linkSystemLibrary(lib_name); - } - - for (lld_libs) |lib_name| { - exe.linkSystemLibrary(lib_name); - } - - for (llvm_libs) |lib_name| { - exe.linkSystemLibrary(lib_name); - } - - // This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries. - exe.linkSystemLibrary("c++"); - - if (target.getOs().tag == .windows) { - exe.linkSystemLibrary("version"); - exe.linkSystemLibrary("uuid"); - } + try addStaticLlvmOptionsToExe(exe); + try addStaticLlvmOptionsToExe(test_stage2); } } if (link_libc) { @@ -219,44 +136,55 @@ pub fn build(b: *Builder) !void { test_stage2.linkLibC(); } - const log_scopes = b.option([]const []const u8, "log", "Which log scopes to enable") orelse &[0][]const u8{}; - const zir_dumps = b.option([]const []const u8, "dump-zir", "Which functions to dump ZIR for before codegen") orelse &[0][]const u8{}; + const enable_logging = b.option(bool, "log", "Whether to enable logging") orelse false; const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git."); const version = if (opt_version_string) |version| version else v: { - const version_string = b.fmt("{}.{}.{}", .{ zig_version.major, zig_version.minor, zig_version.patch }); + const version_string = b.fmt("{d}.{d}.{d}", .{ zig_version.major, zig_version.minor, zig_version.patch }); var code: u8 = undefined; - const git_sha_untrimmed = b.execAllowFail(&[_][]const u8{ - "git", "-C", b.build_root, "name-rev", "HEAD", - "--tags", "--name-only", "--no-undefined", "--always", + const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{ + "git", "-C", b.build_root, "describe", "--match", "*.*.*", "--tags", }, &code, .Ignore) catch { break :v version_string; }; - const git_sha_trimmed = mem.trim(u8, git_sha_untrimmed, " \n\r"); - // Detect dirty changes. - const diff_untrimmed = b.execAllowFail(&[_][]const u8{ - "git", "-C", b.build_root, "diff", "HEAD", - }, &code, .Ignore) catch |err| { - std.debug.print("Error executing git diff: {}", .{err}); - std.process.exit(1); - }; - const trimmed_diff = mem.trim(u8, diff_untrimmed, " \n\r"); - const dirty_suffix = if (trimmed_diff.len == 0) "" else s: { - const dirty_hash = std.hash.Wyhash.hash(0, trimmed_diff); - break :s b.fmt("dirty{x}", .{@truncate(u32, dirty_hash)}); - }; + const git_describe = mem.trim(u8, git_describe_untrimmed, " \n\r"); - // This will look like e.g. "0.7.0^0" for a tag commit. - if (mem.endsWith(u8, git_sha_trimmed, "^0")) { - const git_ver_string = git_sha_trimmed[0 .. git_sha_trimmed.len - 2]; - if (!mem.eql(u8, git_ver_string, version_string)) { - std.debug.print("Expected git tag '{}', found '{}'\n", .{ version_string, git_ver_string }); - std.process.exit(1); - } - break :v b.fmt("{}{}", .{ version_string, dirty_suffix }); - } else { - break :v b.fmt("{}+{}{}", .{ version_string, git_sha_trimmed, dirty_suffix }); + switch (mem.count(u8, git_describe, "-")) { + 0 => { + // Tagged release version (e.g. 0.7.0). + if (!mem.eql(u8, git_describe, version_string)) { + std.debug.print("Zig version '{s}' does not match Git tag '{s}'\n", .{ version_string, git_describe }); + std.process.exit(1); + } + break :v version_string; + }, + 2 => { + // Untagged development build (e.g. 0.7.0-684-gbbe2cca1a). + var it = mem.split(git_describe, "-"); + const tagged_ancestor = it.next() orelse unreachable; + const commit_height = it.next() orelse unreachable; + const commit_id = it.next() orelse unreachable; + + const ancestor_ver = try std.builtin.Version.parse(tagged_ancestor); + if (zig_version.order(ancestor_ver) != .gt) { + std.debug.print("Zig version '{}' must be greater than tagged ancestor '{}'\n", .{ zig_version, ancestor_ver }); + std.process.exit(1); + } + + // Check that the commit hash is prefixed with a 'g' (a Git convention). + if (commit_id.len < 1 or commit_id[0] != 'g') { + std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe}); + break :v version_string; + } + + // The version is reformatted in accordance with the https://semver.org specification. + break :v b.fmt("{s}-dev.{s}+{s}", .{ version_string, commit_height, commit_id[1..] }); + }, + else => { + std.debug.print("Unexpected `git describe` output: {s}\n", .{git_describe}); + break :v version_string; + }, } }; exe.addBuildOption([:0]const u8, "version", try b.allocator.dupeZ(u8, version)); @@ -264,10 +192,10 @@ pub fn build(b: *Builder) !void { const semver = try std.SemanticVersion.parse(version); exe.addBuildOption(std.SemanticVersion, "semver", semver); - exe.addBuildOption([]const []const u8, "log_scopes", log_scopes); - exe.addBuildOption([]const []const u8, "zir_dumps", zir_dumps); + exe.addBuildOption(bool, "enable_logging", enable_logging); exe.addBuildOption(bool, "enable_tracy", tracy != null); exe.addBuildOption(bool, "is_stage1", is_stage1); + exe.addBuildOption(bool, "omit_stage2", false); if (tracy) |tracy_path| { const client_cpp = fs.path.join( b.allocator, @@ -290,6 +218,7 @@ pub fn build(b: *Builder) !void { test_stage2.addBuildOption(bool, "skip_non_native", skip_non_native); test_stage2.addBuildOption(bool, "is_stage1", is_stage1); + test_stage2.addBuildOption(bool, "omit_stage2", false); test_stage2.addBuildOption(bool, "have_llvm", enable_llvm); test_stage2.addBuildOption(bool, "enable_qemu", is_qemu_enabled); test_stage2.addBuildOption(bool, "enable_wine", is_wine_enabled); @@ -347,6 +276,112 @@ pub fn build(b: *Builder) !void { test_step.dependOn(docs_step); } +const exe_cflags = [_][]const u8{ + "-std=c++14", + "-D__STDC_CONSTANT_MACROS", + "-D__STDC_FORMAT_MACROS", + "-D__STDC_LIMIT_MACROS", + "-D_GNU_SOURCE", + "-fvisibility-inlines-hidden", + "-fno-exceptions", + "-fno-rtti", + "-Werror=type-limits", + "-Wno-missing-braces", + "-Wno-comment", +}; + +fn addCmakeCfgOptionsToExe( + b: *Builder, + cfg: CMakeConfig, + tracy: ?[]const u8, + exe: *std.build.LibExeObjStep, +) !void { + exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{ + cfg.cmake_binary_dir, + "zigcpp", + b.fmt("{s}{s}{s}", .{ exe.target.libPrefix(), "zigcpp", exe.target.staticLibSuffix() }), + }) catch unreachable); + assert(cfg.lld_include_dir.len != 0); + exe.addIncludeDir(cfg.lld_include_dir); + addCMakeLibraryList(exe, cfg.clang_libraries); + addCMakeLibraryList(exe, cfg.lld_libraries); + addCMakeLibraryList(exe, cfg.llvm_libraries); + + const need_cpp_includes = tracy != null; + + // System -lc++ must be used because in this code path we are attempting to link + // against system-provided LLVM, Clang, LLD. + if (exe.target.getOsTag() == .linux) { + // First we try to static link against gcc libstdc++. If that doesn't work, + // we fall back to -lc++ and cross our fingers. + addCxxKnownPath(b, cfg, exe, "libstdc++.a", "", need_cpp_includes) catch |err| switch (err) { + error.RequiredLibraryNotFound => { + exe.linkSystemLibrary("c++"); + }, + else => |e| return e, + }; + + exe.linkSystemLibrary("pthread"); + } else if (exe.target.isFreeBSD()) { + try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes); + exe.linkSystemLibrary("pthread"); + } else if (exe.target.getOsTag() == .openbsd) { + try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes); + try addCxxKnownPath(b, cfg, exe, "libc++abi.a", null, need_cpp_includes); + } else if (exe.target.isDarwin()) { + if (addCxxKnownPath(b, cfg, exe, "libgcc_eh.a", "", need_cpp_includes)) { + // Compiler is GCC. + try addCxxKnownPath(b, cfg, exe, "libstdc++.a", null, need_cpp_includes); + exe.linkSystemLibrary("pthread"); + // TODO LLD cannot perform this link. + // Set ZIG_SYSTEM_LINKER_HACK env var to use system linker ld instead. + // See https://github.com/ziglang/zig/issues/1535 + } else |err| switch (err) { + error.RequiredLibraryNotFound => { + // System compiler, not gcc. + exe.linkSystemLibrary("c++"); + }, + else => |e| return e, + } + } + + if (cfg.dia_guids_lib.len != 0) { + exe.addObjectFile(cfg.dia_guids_lib); + } +} + +fn addStaticLlvmOptionsToExe( + exe: *std.build.LibExeObjStep, +) !void { + // Adds the Zig C++ sources which both stage1 and stage2 need. + // + // We need this because otherwise zig_clang_cc1_main.cpp ends up pulling + // in a dependency on llvm::cfg::Update::dump() which is + // unavailable when LLVM is compiled in Release mode. + const zig_cpp_cflags = exe_cflags ++ [_][]const u8{"-DNDEBUG=1"}; + exe.addCSourceFiles(&zig_cpp_sources, &zig_cpp_cflags); + + for (clang_libs) |lib_name| { + exe.linkSystemLibrary(lib_name); + } + + for (lld_libs) |lib_name| { + exe.linkSystemLibrary(lib_name); + } + + for (llvm_libs) |lib_name| { + exe.linkSystemLibrary(lib_name); + } + + // This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries. + exe.linkSystemLibrary("c++"); + + if (exe.target.getOs().tag == .windows) { + exe.linkSystemLibrary("version"); + exe.linkSystemLibrary("uuid"); + } +} + fn addCxxKnownPath( b: *Builder, ctx: CMakeConfig, @@ -357,14 +392,14 @@ fn addCxxKnownPath( ) !void { const path_padded = try b.exec(&[_][]const u8{ ctx.cxx_compiler, - b.fmt("-print-file-name={}", .{objname}), + b.fmt("-print-file-name={s}", .{objname}), }); const path_unpadded = mem.tokenize(path_padded, "\r\n").next().?; if (mem.eql(u8, path_unpadded, objname)) { if (errtxt) |msg| { - warn("{}", .{msg}); + warn("{s}", .{msg}); } else { - warn("Unable to determine path to {}\n", .{objname}); + warn("Unable to determine path to {s}\n", .{objname}); } return error.RequiredLibraryNotFound; } diff --git a/ci/azure/linux_script b/ci/azure/linux_script index bf338ce22f..e96a16b41b 100755 --- a/ci/azure/linux_script +++ b/ci/azure/linux_script @@ -3,76 +3,104 @@ set -x set -e -# This parameters we wait at most 2mins, it should be enough to sort out any -# transient error. -CMD_MAX_RETRY=12 -CMD_WAIT_TIME=10s +sudo apt-get update -q +sudo apt-get install -y cmake s3cmd tidy -# Execute the given command and, in case of failure, try to execute it again -# after sleeping for CMD_WAIT_TIME. -# We give up after retrying CMD_MAX_RETRY times. -retry() { - for i in $(seq 1 "$CMD_MAX_RETRY"); do - eval "$@" && return - echo "command \"$@\" failed, retrying..." - sleep ${CMD_WAIT_TIME} - done +ZIGDIR="$(pwd)" +ARCH="$(uname -m)" +TARGET="$ARCH-linux-musl" +CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.0-dev.859+f1ef0a80f" +PREFIX="$HOME/$CACHE_BASENAME" +MCPU="baseline" +JOBS="-j$(nproc)" - echo "command \"$@\" failed, giving up..." - exit 1 -} +rm -rf $PREFIX +cd $HOME -BUILDDIR="$(pwd)" - -sudo sh -c 'echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main" >> /etc/apt/sources.list' -retry 'wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -' -retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - -sudo apt-get remove -y llvm-* -sudo rm -rf /usr/local/* - -retry sudo apt-get update -q -retry sudo apt-get install -y \ - libxml2-dev libclang-11-dev llvm-11 llvm-11-dev liblld-11-dev cmake s3cmd \ - gcc-7 g++-7 ninja-build tidy \ +wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz" +tar xf "$CACHE_BASENAME.tar.xz" QEMUBASE="qemu-linux-x86_64-5.2.0" -wget -nv https://ziglang.org/deps/$QEMUBASE.tar.xz -tar xf $QEMUBASE.tar.xz -PATH=$PWD/$QEMUBASE/bin:$PATH +wget -nv "https://ziglang.org/deps/$QEMUBASE.tar.xz" +tar xf "$QEMUBASE.tar.xz" +export PATH="$(pwd)/$QEMUBASE/bin:$PATH" WASMTIME="wasmtime-v0.20.0-x86_64-linux" -wget -nv https://github.com/bytecodealliance/wasmtime/releases/download/v0.20.0/$WASMTIME.tar.xz -tar xf $WASMTIME.tar.xz -PATH=$PWD/$WASMTIME:$PATH +wget -nv "https://github.com/bytecodealliance/wasmtime/releases/download/v0.20.0/$WASMTIME.tar.xz" +tar xf "$WASMTIME.tar.xz" +export PATH="$(pwd)/$WASMTIME:$PATH" + +ZIG="$PREFIX/bin/zig" +export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" +export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" + +cd $ZIGDIR # Make the `zig version` number consistent. # This will affect the cmake command below. git config core.abbrev 9 +git fetch --unshallow || true +git fetch --tags -export CC=gcc-7 -export CXX=g++-7 mkdir build cd build -cmake .. -DCMAKE_BUILD_TYPE=Release -GNinja -ninja install -./zig build test -Denable-qemu -Denable-wasmtime +cmake .. \ + -DCMAKE_INSTALL_PREFIX="$(pwd)/release" \ + -DCMAKE_PREFIX_PATH="$PREFIX" \ + -DCMAKE_BUILD_TYPE=Release \ + -DZIG_TARGET_TRIPLE="$TARGET" \ + -DZIG_TARGET_MCPU="$MCPU" \ + -DZIG_STATIC=ON -# look for HTML errors +# Now cmake will use zig as the C/C++ compiler. We reset the environment variables +# so that installation and testing do not get affected by them. +unset CC +unset CXX + +make $JOBS install + +# Here we rebuild zig but this time using the Zig binary we just now produced to +# build zig1.o rather than relying on the one built with stage0. See +# https://github.com/ziglang/zig/issues/6830 for more details. +cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig" +make $JOBS install + +release/bin/zig build test -Denable-qemu -Denable-wasmtime + +# Look for HTML errors. tidy -qe ../zig-cache/langref.html -VERSION="$(./zig version)" - if [ "${BUILD_REASON}" != "PullRequest" ]; then - ARTIFACTSDIR="$BUILDDIR/artifacts" - mkdir "$ARTIFACTSDIR" - docker run -i --mount type=bind,source="$ARTIFACTSDIR",target=/z ziglang/static-base:llvm11-x86_64-1 -j2 $BUILD_SOURCEVERSION - TARBALL="$(ls $ARTIFACTSDIR)" - mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg" - s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$ARTIFACTSDIR/$TARBALL" s3://ziglang.org/builds/ + # Produce the experimental std lib documentation. + mkdir -p release/docs/std + release/bin/zig test ../lib/std/std.zig \ + --override-lib-dir ../lib \ + -femit-docs=release/docs/std \ + -fno-emit-bin - SHASUM=$(sha256sum $ARTIFACTSDIR/$TARBALL | cut '-d ' -f1) - BYTESIZE=$(wc -c < $ARTIFACTSDIR/$TARBALL) + mv ../LICENSE release/ + mv ../zig-cache/langref.html release/docs/ + + # Remove the unnecessary bin dir in $prefix/bin/zig + mv release/bin/zig release/ + rmdir release/bin + + # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig + mv release/lib/zig release/lib2 + rmdir release/lib + mv release/lib2 release/lib + + VERSION=$(release/zig version) + DIRNAME="zig-linux-$ARCH-$VERSION" + TARBALL="$DIRNAME.tar.xz" + mv release "$DIRNAME" + tar cfJ "$TARBALL" "$DIRNAME" + + mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg" + s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/ + + SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1) + BYTESIZE=$(wc -c < $TARBALL) JSONFILE="linux-$GITBRANCH.json" touch $JSONFILE @@ -81,7 +109,7 @@ if [ "${BUILD_REASON}" != "PullRequest" ]; then echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE" - s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-linux-$VERSION.json" + s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json" # `set -x` causes these variables to be mangled. # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html diff --git a/ci/azure/macos_script b/ci/azure/macos_script index cb14b7f119..b83f9c940b 100755 --- a/ci/azure/macos_script +++ b/ci/azure/macos_script @@ -28,6 +28,8 @@ cd $ZIGDIR # Make the `zig version` number consistent. # This will affect the cmake command below. git config core.abbrev 9 +git fetch --unshallow || true +git fetch --tags mkdir build cd build diff --git a/ci/azure/pipelines.yml b/ci/azure/pipelines.yml index 0d5213c135..a6e8e768fb 100644 --- a/ci/azure/pipelines.yml +++ b/ci/azure/pipelines.yml @@ -31,7 +31,7 @@ jobs: timeoutInMinutes: 360 steps: - powershell: | - (New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2020-11-09/msys2-base-x86_64-20201109.sfx.exe", "sfx.exe") + (New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2021-01-05/msys2-base-x86_64-20210105.sfx.exe", "sfx.exe") .\sfx.exe -y -o\ del sfx.exe displayName: Download/Extract/Install MSYS2 diff --git a/ci/azure/windows_msvc_script.bat b/ci/azure/windows_msvc_script.bat index efc68e5d2d..9d28eccd0b 100644 --- a/ci/azure/windows_msvc_script.bat +++ b/ci/azure/windows_msvc_script.bat @@ -18,14 +18,17 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliar REM Make the `zig version` number consistent. REM This will affect the cmake command below. git.exe config core.abbrev 9 +git.exe fetch --unshallow +git.exe fetch --tags mkdir %ZIGBUILDDIR% cd %ZIGBUILDDIR% -cmake.exe .. -Thost=x64 -G"Visual Studio 16 2019" -A x64 "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release || exit /b +cmake.exe .. -Thost=x64 -G"Visual Studio 16 2019" -A x64 "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release -DZIG_OMIT_STAGE2=ON || exit /b msbuild /maxcpucount /p:Configuration=Release INSTALL.vcxproj || exit /b "%ZIGINSTALLDIR%\bin\zig.exe" build test-behavior -Dskip-non-native || exit /b -"%ZIGINSTALLDIR%\bin\zig.exe" build test-stage2 -Dskip-non-native || exit /b +REM Disabled to prevent OOM +REM "%ZIGINSTALLDIR%\bin\zig.exe" build test-stage2 -Dskip-non-native || exit /b "%ZIGINSTALLDIR%\bin\zig.exe" build test-fmt -Dskip-non-native || exit /b "%ZIGINSTALLDIR%\bin\zig.exe" build test-std -Dskip-non-native || exit /b "%ZIGINSTALLDIR%\bin\zig.exe" build test-compiler-rt -Dskip-non-native || exit /b diff --git a/ci/drone/linux_script b/ci/drone/linux_script index fdc1704fb7..dbe13f6f19 100755 --- a/ci/drone/linux_script +++ b/ci/drone/linux_script @@ -14,13 +14,15 @@ pip3 install s3cmd # Make the `zig version` number consistent. # This will affect the cmake command below. git config core.abbrev 9 +git fetch --unshallow || true +git fetch --tags mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$DISTDIR" -DZIG_STATIC=ON -DCMAKE_PREFIX_PATH=/deps/local -GNinja samu install -./zig build test -Dskip-release -Dskip-non-native +./zig build test -Dskip-release -Dskip-non-native -Dskip-compile-errors if [ -z "$DRONE_PULL_REQUEST" ]; then mv ../LICENSE "$DISTDIR/" diff --git a/ci/srht/freebsd_script b/ci/srht/freebsd_script index 58d087e2bc..337d715b7c 100755 --- a/ci/srht/freebsd_script +++ b/ci/srht/freebsd_script @@ -4,7 +4,7 @@ set -x set -e sudo pkg update -fq -sudo pkg install -y cmake py27-s3cmd wget curl jq +sudo pkg install -y cmake py37-s3cmd wget curl jq ZIGDIR="$(pwd)" CACHE_BASENAME="llvm+clang+lld-11.0.0-x86_64-freebsd-release" @@ -20,6 +20,8 @@ cd $ZIGDIR # Make the `zig version` number consistent. # This will affect the cmake command below. git config core.abbrev 9 +git fetch --unshallow || true +git fetch --tags # SourceHut reports that it is a terminal that supports escape codes, but it # is a filthy liar. Here we tell Zig to not try to send any terminal escape diff --git a/ci/srht/index.html b/ci/srht/index.html new file mode 100644 index 0000000000..353aaf01de --- /dev/null +++ b/ci/srht/index.html @@ -0,0 +1,731 @@ + + + + + Releases ⚡ The Zig Programming Language + + + + +
+ +
+ +
+

Releases

+

You can also + install Zig from a package manager. +

+

+ There is a JSON version of this page. +

+ +

master

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameKindSizeSha256
{{SRC_TARBALL}}Source{{SRC_BYTESIZE}}{{SRC_SHASUM}}
{{X86_64_LINUX_TARBALL}}Binary{{X86_64_LINUX_BYTESIZE}}{{X86_64_LINUX_SHASUM}}
{{AARCH64_LINUX_TARBALL}}Binary{{AARCH64_LINUX_BYTESIZE}}{{AARCH64_LINUX_SHASUM}}
{{X86_64_WINDOWS_TARBALL}}Binary{{X86_64_WINDOWS_BYTESIZE}}{{X86_64_WINDOWS_SHASUM}}
{{X86_64_MACOS_TARBALL}}Binary{{X86_64_MACOS_BYTESIZE}}{{X86_64_MACOS_SHASUM}}
{{X86_64_FREEBSD_TARBALL}}Binary{{X86_64_FREEBSD_BYTESIZE}}{{X86_64_FREEBSD_SHASUM}}
+ +

0.7.1

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameKindSizeSha256
zig-0.7.1.tar.xzSource11MiB2db3b944ab368d955b48743d9f7c963b8f96de1a441ba5a35e197237cc6dae44
zig-bootstrap-0.7.1.tar.xzSource39MiB040f27c1fae4b0cac0a2782aecdb691f6a2f8e89db6a6ed35024c31c304fd9b2
zig-freebsd-x86_64-0.7.1.tar.xzBinary38MiBe73c1dca35791a3183fdd5ecde0443ebbe180942efceafe651886034fb8def09
zig-linux-aarch64-0.7.1.tar.xzBinary33MiB48ec90eba407e4587ddef7eecef25fec7e13587eb98e3b83c5f2f5fff2a5cbe7
zig-linux-armv7a-0.7.1.tar.xzBinary35MiB5a0662e07b4c4968665e1f97558f8591f6facec45d2e0ff5715e661743107ceb
zig-linux-i386-0.7.1.tar.xzBinary38MiB4882e052e5f83690bd0334bb4fc1702b5403cb3a3d2aa63fd7d6043d8afecba3
zig-linux-riscv64-0.7.1.tar.xzBinary36MiB187294bfd35983348c3fe042901b42e67e7e36ab7f77a5f969d21c0051f4d21f
zig-linux-x86_64-0.7.1.tar.xzBinary37MiB18c7b9b200600f8bcde1cd8d7f1f578cbc3676241ce36d771937ce19a8159b8d
zig-macos-x86_64-0.7.1.tar.xzBinary35MiB845cb17562978af0cf67e3993f4e33330525eaf01ead9386df9105111e3bc519
zig-windows-i386-0.7.1.zipBinary52MiBa1b9a7421e13153e07fd2e2c93ff29aad64d83105b8fcdafa633dbe689caf1c0
zig-windows-x86_64-0.7.1.zipBinary53MiB4818a8a65b4672bc52c0ae7f14d014e0eb8caf10f12c0745176820384cea296a
+ +

0.7.0

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameKindSizeSha256
zig-0.7.0.tar.xzSource11MiB0efd2cf6c3b05723db80e9cf193bc55150bba84ca41f855a90f53fc756445f83
zig-bootstrap-0.7.0.tar.xzSource39MiBf073beaf5c53c8c57c0d374cbfcb332ef92ad703173edba0d9e0f2ed28401b72
zig-freebsd-x86_64-0.7.0.tar.xzBinary34MiBa0c926272ee4ae720034b4a6a1dc98399d76156dd84182554740f0ca8a41fc99
zig-linux-aarch64-0.7.0.tar.xzBinary32MiBf89933bac87d44be82325754ff88423020c81c7032a6fc41cfeb81e982eeab9b
zig-linux-armv7a-0.7.0.tar.xzBinary34MiB011c267e25a96ee160505a560c441daa045359a9d50e13ab1bada9d75c95db2d
zig-linux-i386-0.7.0.tar.xzBinary37MiB4bb2072cd363bcb1cbeb4872ff5cbc1f683b02d0cc1f90c46e3ea7422ce53222
zig-linux-riscv64-0.7.0.tar.xzBinary36MiB40dff81faa6f232ac40abbf88b9371f3cc932b6e09c423b94387c9ea580cb7be
zig-linux-x86_64-0.7.0.tar.xzBinary36MiBe619b1c6094c095b932767f527aee2507f847ea981513ff8a08aab0fd730e0ac
zig-macos-aarch64-0.7.0.tar.xzBinary33MiB338238035734db74ea4f30e500a4893bf741d38305c10952d5e39fa05bdb057d
zig-macos-x86_64-0.7.0.tar.xzBinary35MiB94063f9a311cbbf7a2e0a12295e09437182cf950f18cb0eb30ea9893f3677f24
zig-windows-i386-0.7.0.zipBinary51MiBb1e520aacbfbd645ff3521b3eb4d44166d9a0288b8725e4b001f8b50a425eb2e
zig-windows-x86_64-0.7.0.zipBinary52MiB965f56c0a36f9cda2125e3a348bc654f7f155e2804c3667d231775ec228f8553
+ +

0.6.0

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameKindSizeSha256
zig-0.6.0.tar.xzSource9.9MiB5d167dc19354282dd35dd17b38e99e1763713b9be8a4ba9e9e69284e059e7204
zig-bootstrap-0.6.0.tar.xzSource36.7MiB5e0e4dc878b3dd0c1852a442b174f0732e8c07869a8fcd226b71a93b89b381ab
zig-freebsd-x86_64-0.6.0.tar.xzBinary36MiB190ff79c1eb56805a315d7c7a51082e32f62926250c0702b36760c225e1634a3
zig-linux-aarch64-0.6.0.tar.xzBinary36MiBe7520efd42cfa02be48c2e430d08fe1f3cbb999d21d9f0d3ffd0febb976b2f41
zig-linux-armv6kz-0.6.0.tar.xzBinary38MiB36b6493b3fed43eb1f0000e765798ad31a6bb7d7fd3f553ac1c3761dbc919b82
zig-linux-armv7a-0.6.0.tar.xzBinary38MiB946969abe357def95ca9cbbfcebfcf2d90cf967bcd3f48ee87662e32d91d8f35
zig-linux-i386-0.6.0.tar.xzBinary43MiBa97a2f9ae21575743cdd763c1917d49400d83fc562ef64582b18bade43eb24ce
zig-linux-riscv64-0.6.0.tar.xzBinary41MiB68ddee43f7503c8ae5f26a921f3602c34719a02ed2241f528c0b8b888cc14b38
zig-linux-x86_64-0.6.0.tar.xzBinary43MiB08fd3c757963630645441c2772362e9c2294020c44f14fce1b89f45de0dc1253
zig-macos-x86_64-0.6.0.tar.xzBinary41MiB17270360e87ddc49f737e760047b2fac49f1570a824a306119b1194ac4093895
zig-windows-i386-0.6.0.zipBinary58MiB3b0a02618743e92175990dc6d1a787bb95ff62c4cda016f1c14c7786f575f8ca
zig-windows-x86_64-0.6.0.zipBinary47MiBc3b897832523e1026e10b2d8d55d7f895185c0a27a63681f3a23219c3f1c38f4
+ +

0.5.0

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameKindSizeSha256
zig-0.5.0.tar.xzSource10.4MiB55ae16960f152bcb9cf98b4f8570902d0e559a141abf927f0d3555b7cc838a31
zig-linux-x86_64-0.5.0.tar.xzBinary39.0MiB43e8f8a8b8556edd373ddf9c1ef3ca6cf852d4d09fe07d5736d12fefedd2b4f7
zig-windows-x86_64-0.5.0.zipBinary42.8MiB58141323db8d84a5af62746be5f9140bc161ee760ef33dc91a887bf9ac021976
zig-macos-x86_64-0.5.0.tar.xzBinary36.1MiB28702cc05745c7c0bd450487d5f4091bf0a1ad279b35eb9a640ce3e3a15b300d
zig-freebsd-x86_64-0.5.0.tar.xzBinary32.1MiB9e1f4d36c3d584c0aa01f20eb4cd0a0eef3eee5af23e483b8414de55feab6ab6
+ +

0.4.0

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameKindSizeSha256
zig-0.4.0.tar.xzSource5.1MiBfec1f3f6b359a3d942e0a7f9157b3b30cde83927627a0e1ea95c54de3c526cfc
zig-linux-x86_64-0.4.0.tar.xzBinary31.4MiBfb1954e2fb556a01f8079a08130e88f70084e08978ff853bb2b1986d8c39d84e
zig-windows-x86_64-0.4.0.zipBinary34.1MiBfbc3dd205e064c263063f69f600bedb18e3d0aa2efa747a63ef6cafb6d73f127
zig-macos-x86_64-0.4.0.tar.xzBinary29.4MiB67c932982484d017c5111e54af9f33f15e8e05c6bc5346a55e04052159c964a8
zig-freebsd-x86_64-0.4.0.tar.xzBinary26.0MiB3d557c91ac36d8262eb1733bb5f261c95944f9b635e43386e3d00a3272818c30
+ +

0.3.0

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameKindSizeSha256
zig-0.3.0.tar.xzSource2.2MiBd70af604f3a8622f3393d93abb3e056bf60351e32d121e6fa4fe03d8d41e1f5a
zig-linux-x86_64-0.3.0.tar.xzBinary24.0MiBb378d0aae30cb54f28494e7bc4efbc9bfb6326f47bfb302e8b5287af777b2f3c
zig-windows-x86_64-0.3.0.zipBinary21.5MiBbb568c03950958f8bb3472139c3ab5ed74547c8c694ab50f404c202faf51baf4
zig-macos-x86_64-0.3.0.tar.xzBinary22.6MiB19dec1f1943ab7be26823376d466f7e456143deb34e17502778a949034dc2e7e
+ +

0.2.0

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameKindSizeSha256
zig-0.2.0.tar.xzSource1.9MiB29c9beb172737f4d5019b88ceae829ae8bc6512fb4386cfbf895ae2b42aa6965
zig-linux-x86_64-0.2.0.tar.xzBinary23.5MiB209c6fb745d42474c0a73d6f291c7ae3a38b6a1b6b641eea285a7f840cc1a890
zig-win64-0.2.0.zipBinary20.6MiB4f8a2979941a1f081ec8e545cca0b72608c0db1c5a3fd377a94db40649dcd3d4
+ +

0.1.1

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FilenameKindSizeSha256
zig-0.1.1.tar.xzSource1.62MiBffca0cfb263485287e19cc997b08701fcd5f24b700345bcdc3dd8074f5a104e0
zig-win64-0.1.1.zipBinary19.3MiB6fc88bef531af7e567fe30bf60da1487b86833cbee84c7a2f3e317030aa5b660
+
+ + diff --git a/ci/srht/index.json b/ci/srht/index.json new file mode 100644 index 0000000000..a5e89c084d --- /dev/null +++ b/ci/srht/index.json @@ -0,0 +1,351 @@ +{ + "master": { + "version": "{{MASTER_VERSION}}", + "date": "{{MASTER_DATE}}", + "docs": "https://ziglang.org/documentation/master/", + "stdDocs": "https://ziglang.org/documentation/master/std/", + "src": { + "tarball": "https://ziglang.org/builds/{{SRC_TARBALL}}", + "shasum": "{{SRC_SHASUM}}", + "size": "{{SRC_BYTESIZE}}" + }, + "x86_64-freebsd": { + "tarball": "https://ziglang.org/builds/{{X86_64_FREEBSD_TARBALL}}", + "shasum": "{{X86_64_FREEBSD_SHASUM}}", + "size": "{{X86_64_FREEBSD_BYTESIZE}}" + }, + "x86_64-macos": { + "tarball": "https://ziglang.org/builds/{{X86_64_MACOS_TARBALL}}", + "shasum": "{{X86_64_MACOS_SHASUM}}", + "size": "{{X86_64_MACOS_BYTESIZE}}" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/builds/{{X86_64_WINDOWS_TARBALL}}", + "shasum": "{{X86_64_WINDOWS_SHASUM}}", + "size": "{{X86_64_WINDOWS_BYTESIZE}}" + }, + "x86_64-linux": { + "tarball": "https://ziglang.org/builds/{{X86_64_LINUX_TARBALL}}", + "shasum": "{{X86_64_LINUX_SHASUM}}", + "size": "{{X86_64_LINUX_BYTESIZE}}" + }, + "aarch64-linux": { + "tarball": "https://ziglang.org/builds/{{AARCH64_LINUX_TARBALL}}", + "shasum": "{{AARCH64_LINUX_SHASUM}}", + "size": "{{AARCH64_LINUX_BYTESIZE}}" + } + }, + "0.7.1": { + "date": "2020-12-13", + "docs": "https://ziglang.org/documentation/0.7.1/", + "stdDocs": "https://ziglang.org/documentation/0.7.1/std/", + "notes": "https://ziglang.org/download/0.7.1/release-notes.html", + "src": { + "tarball": "https://ziglang.org/download/0.7.1/zig-0.7.1.tar.xz", + "shasum": "2db3b944ab368d955b48743d9f7c963b8f96de1a441ba5a35e197237cc6dae44", + "size": "10711824" + }, + "bootstrap": { + "tarball": "https://ziglang.org/download/0.7.1/zig-bootstrap-0.7.1.tar.xz", + "shasum": "040f27c1fae4b0cac0a2782aecdb691f6a2f8e89db6a6ed35024c31c304fd9b2", + "size": "40232612" + }, + "x86_64-freebsd": { + "tarball": "https://ziglang.org/download/0.7.1/zig-freebsd-x86_64-0.7.1.tar.xz", + "shasum": "e73c1dca35791a3183fdd5ecde0443ebbe180942efceafe651886034fb8def09", + "size": "39066808" + }, + "aarch64-linux": { + "tarball": "https://ziglang.org/download/0.7.1/zig-linux-aarch64-0.7.1.tar.xz", + "shasum": "48ec90eba407e4587ddef7eecef25fec7e13587eb98e3b83c5f2f5fff2a5cbe7", + "size": "33780552" + }, + "armv7a-linux": { + "tarball": "https://ziglang.org/download/0.7.1/zig-linux-armv7a-0.7.1.tar.xz", + "shasum": "5a0662e07b4c4968665e1f97558f8591f6facec45d2e0ff5715e661743107ceb", + "size": "35813504" + }, + "i386-linux": { + "tarball": "https://ziglang.org/download/0.7.1/zig-linux-i386-0.7.1.tar.xz", + "shasum": "4882e052e5f83690bd0334bb4fc1702b5403cb3a3d2aa63fd7d6043d8afecba3", + "size": "39230912" + }, + "riscv64-linux": { + "tarball": "https://ziglang.org/download/0.7.1/zig-linux-riscv64-0.7.1.tar.xz", + "shasum": "187294bfd35983348c3fe042901b42e67e7e36ab7f77a5f969d21c0051f4d21f", + "size": "37454812" + }, + "x86_64-linux": { + "tarball": "https://ziglang.org/download/0.7.1/zig-linux-x86_64-0.7.1.tar.xz", + "shasum": "18c7b9b200600f8bcde1cd8d7f1f578cbc3676241ce36d771937ce19a8159b8d", + "size": "37848176" + }, + "x86_64-macos": { + "tarball": "https://ziglang.org/download/0.7.1/zig-macos-x86_64-0.7.1.tar.xz", + "shasum": "845cb17562978af0cf67e3993f4e33330525eaf01ead9386df9105111e3bc519", + "size": "36211076" + }, + "i386-windows": { + "tarball": "https://ziglang.org/download/0.7.1/zig-windows-i386-0.7.1.zip", + "shasum": "a1b9a7421e13153e07fd2e2c93ff29aad64d83105b8fcdafa633dbe689caf1c0", + "size": "54374983" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/download/0.7.1/zig-windows-x86_64-0.7.1.zip", + "shasum": "4818a8a65b4672bc52c0ae7f14d014e0eb8caf10f12c0745176820384cea296a", + "size": "54909997" + } + }, + "0.7.0": { + "date": "2020-11-08", + "docs": "https://ziglang.org/documentation/0.7.0/", + "stdDocs": "https://ziglang.org/documentation/0.7.0/std/", + "notes": "https://ziglang.org/download/0.7.0/release-notes.html", + "src": { + "tarball": "https://ziglang.org/download/0.7.0/zig-0.7.0.tar.xz", + "shasum": "0efd2cf6c3b05723db80e9cf193bc55150bba84ca41f855a90f53fc756445f83", + "size": "10683920" + }, + "bootstrap": { + "tarball": "https://ziglang.org/download/0.7.0/zig-bootstrap-0.7.0.tar.xz", + "shasum": "f073beaf5c53c8c57c0d374cbfcb332ef92ad703173edba0d9e0f2ed28401b72", + "size": "40200436" + }, + "x86_64-freebsd": { + "tarball": "https://ziglang.org/download/0.7.0/zig-freebsd-x86_64-0.7.0.tar.xz", + "shasum": "a0c926272ee4ae720034b4a6a1dc98399d76156dd84182554740f0ca8a41fc99", + "size": "34798992" + }, + "aarch64-linux": { + "tarball": "https://ziglang.org/download/0.7.0/zig-linux-aarch64-0.7.0.tar.xz", + "shasum": "f89933bac87d44be82325754ff88423020c81c7032a6fc41cfeb81e982eeab9b", + "size": "33096140" + }, + "armv7a-linux": { + "tarball": "https://ziglang.org/download/0.7.0/zig-linux-armv7a-0.7.0.tar.xz", + "shasum": "011c267e25a96ee160505a560c441daa045359a9d50e13ab1bada9d75c95db2d", + "size": "35157584" + }, + "i386-linux": { + "tarball": "https://ziglang.org/download/0.7.0/zig-linux-i386-0.7.0.tar.xz", + "shasum": "4bb2072cd363bcb1cbeb4872ff5cbc1f683b02d0cc1f90c46e3ea7422ce53222", + "size": "38530596" + }, + "riscv64-linux": { + "tarball": "https://ziglang.org/download/0.7.0/zig-linux-riscv64-0.7.0.tar.xz", + "shasum": "40dff81faa6f232ac40abbf88b9371f3cc932b6e09c423b94387c9ea580cb7be", + "size": "36759992" + }, + "x86_64-linux": { + "tarball": "https://ziglang.org/download/0.7.0/zig-linux-x86_64-0.7.0.tar.xz", + "shasum": "e619b1c6094c095b932767f527aee2507f847ea981513ff8a08aab0fd730e0ac", + "size": "37154432" + }, + "aarch64-macos": { + "tarball": "https://ziglang.org/download/0.7.0/zig-macos-aarch64-0.7.0.tar.xz", + "shasum": "338238035734db74ea4f30e500a4893bf741d38305c10952d5e39fa05bdb057d", + "size": "33739424" + }, + "x86_64-macos": { + "tarball": "https://ziglang.org/download/0.7.0/zig-macos-x86_64-0.7.0.tar.xz", + "shasum": "94063f9a311cbbf7a2e0a12295e09437182cf950f18cb0eb30ea9893f3677f24", + "size": "35258328" + }, + "i386-windows": { + "tarball": "https://ziglang.org/download/0.7.0/zig-windows-i386-0.7.0.zip", + "shasum": "b1e520aacbfbd645ff3521b3eb4d44166d9a0288b8725e4b001f8b50a425eb2e", + "size": "53390517" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/download/0.7.0/zig-windows-x86_64-0.7.0.zip", + "shasum": "965f56c0a36f9cda2125e3a348bc654f7f155e2804c3667d231775ec228f8553", + "size": "53943784" + } + }, + "0.6.0": { + "date": "2020-04-13", + "docs": "https://ziglang.org/documentation/0.6.0/", + "stdDocs": "https://ziglang.org/documentation/0.6.0/std/", + "notes": "https://ziglang.org/download/0.6.0/release-notes.html", + "src": { + "tarball": "https://ziglang.org/download/0.6.0/zig-0.6.0.tar.xz", + "shasum": "5d167dc19354282dd35dd17b38e99e1763713b9be8a4ba9e9e69284e059e7204", + "size": "10349552" + }, + "bootstrap": { + "tarball": "https://ziglang.org/download/0.6.0/zig-bootstrap-0.6.0.tar.xz", + "shasum": "5e0e4dc878b3dd0c1852a442b174f0732e8c07869a8fcd226b71a93b89b381ab", + "size": "38469948" + }, + "x86_64-freebsd": { + "tarball": "https://ziglang.org/download/0.6.0/zig-freebsd-x86_64-0.6.0.tar.xz", + "shasum": "190ff79c1eb56805a315d7c7a51082e32f62926250c0702b36760c225e1634a3", + "size": "36974604" + }, + "aarch64-linux": { + "tarball": "https://ziglang.org/download/0.6.0/zig-linux-aarch64-0.6.0.tar.xz", + "shasum": "e7520efd42cfa02be48c2e430d08fe1f3cbb999d21d9f0d3ffd0febb976b2f41", + "size": "37090044" + }, + "armv6kz-linux": { + "tarball": "https://ziglang.org/download/0.6.0/zig-linux-armv6kz-0.6.0.tar.xz", + "shasum": "36b6493b3fed43eb1f0000e765798ad31a6bb7d7fd3f553ac1c3761dbc919b82", + "size": "39133452" + }, + "armv7a-linux": { + "tarball": "https://ziglang.org/download/0.6.0/zig-linux-armv7a-0.6.0.tar.xz", + "shasum": "946969abe357def95ca9cbbfcebfcf2d90cf967bcd3f48ee87662e32d91d8f35", + "size": "39143748" + }, + "i386-linux": { + "tarball": "https://ziglang.org/download/0.6.0/zig-linux-i386-0.6.0.tar.xz", + "shasum": "a97a2f9ae21575743cdd763c1917d49400d83fc562ef64582b18bade43eb24ce", + "size": "44877640" + }, + "riscv64-linux": { + "tarball": "https://ziglang.org/download/0.6.0/zig-linux-riscv64-0.6.0.tar.xz", + "shasum": "68ddee43f7503c8ae5f26a921f3602c34719a02ed2241f528c0b8b888cc14b38", + "size": "41993144" + }, + "x86_64-linux": { + "tarball": "https://ziglang.org/download/0.6.0/zig-linux-x86_64-0.6.0.tar.xz", + "shasum": "08fd3c757963630645441c2772362e9c2294020c44f14fce1b89f45de0dc1253", + "size": "44766320" + }, + "x86_64-macos": { + "tarball": "https://ziglang.org/download/0.6.0/zig-macos-x86_64-0.6.0.tar.xz", + "shasum": "17270360e87ddc49f737e760047b2fac49f1570a824a306119b1194ac4093895", + "size": "42573184" + }, + "i386-windows": { + "tarball": "https://ziglang.org/download/0.6.0/zig-windows-i386-0.6.0.zip", + "shasum": "3b0a02618743e92175990dc6d1a787bb95ff62c4cda016f1c14c7786f575f8ca", + "size": "60446431" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/download/0.6.0/zig-windows-x86_64-0.6.0.zip", + "shasum": "c3b897832523e1026e10b2d8d55d7f895185c0a27a63681f3a23219c3f1c38f4", + "size": "49065511" + } + }, + "0.5.0": { + "date": "2019-09-30", + "docs": "https://ziglang.org/documentation/0.5.0/", + "notes": "https://ziglang.org/download/0.5.0/release-notes.html", + "src": { + "tarball": "https://ziglang.org/download/0.5.0/zig-0.5.0.tar.xz", + "shasum": "55ae16960f152bcb9cf98b4f8570902d0e559a141abf927f0d3555b7cc838a31", + "size": "10956132" + }, + "x86_64-freebsd": { + "tarball": "https://ziglang.org/download/0.5.0/zig-freebsd-x86_64-0.5.0.tar.xz", + "shasum": "9e1f4d36c3d584c0aa01f20eb4cd0a0eef3eee5af23e483b8414de55feab6ab6", + "size": "33650744" + }, + "x86_64-macos": { + "tarball": "https://ziglang.org/download/0.5.0/zig-macos-x86_64-0.5.0.tar.xz", + "shasum": "28702cc05745c7c0bd450487d5f4091bf0a1ad279b35eb9a640ce3e3a15b300d", + "size": "37898664" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/download/0.5.0/zig-windows-x86_64-0.5.0.zip", + "shasum": "58141323db8d84a5af62746be5f9140bc161ee760ef33dc91a887bf9ac021976", + "size": "44871804" + }, + "x86_64-linux": { + "tarball": "https://ziglang.org/download/0.5.0/zig-linux-x86_64-0.5.0.tar.xz", + "shasum": "43e8f8a8b8556edd373ddf9c1ef3ca6cf852d4d09fe07d5736d12fefedd2b4f7", + "size": "40895068" + } + }, + "0.4.0": { + "date": "2019-04-08", + "docs": "https://ziglang.org/documentation/0.4.0/", + "notes": "https://ziglang.org/download/0.4.0/release-notes.html", + "src": { + "tarball": "https://ziglang.org/download/0.4.0/zig-0.4.0.tar.xz", + "shasum": "fec1f3f6b359a3d942e0a7f9157b3b30cde83927627a0e1ea95c54de3c526cfc", + "size": "5348776" + }, + "x86_64-freebsd": { + "tarball": "https://ziglang.org/download/0.4.0/zig-freebsd-x86_64-0.4.0.tar.xz", + "shasum": "3d557c91ac36d8262eb1733bb5f261c95944f9b635e43386e3d00a3272818c30", + "size": "27269672" + }, + "x86_64-macos": { + "tarball": "https://ziglang.org/download/0.4.0/zig-macos-x86_64-0.4.0.tar.xz", + "shasum": "67c932982484d017c5111e54af9f33f15e8e05c6bc5346a55e04052159c964a8", + "size": "30841504" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/download/0.4.0/zig-windows-x86_64-0.4.0.zip", + "shasum": "fbc3dd205e064c263063f69f600bedb18e3d0aa2efa747a63ef6cafb6d73f127", + "size": "35800101" + }, + "x86_64-linux": { + "tarball": "https://ziglang.org/download/0.4.0/zig-linux-x86_64-0.4.0.tar.xz", + "shasum": "fb1954e2fb556a01f8079a08130e88f70084e08978ff853bb2b1986d8c39d84e", + "size": "32876100" + } + }, + "0.3.0": { + "date": "2018-09-28", + "docs": "https://ziglang.org/documentation/0.3.0/", + "notes": "https://ziglang.org/download/0.3.0/release-notes.html", + "src": { + "tarball": "https://ziglang.org/download/0.3.0/zig-0.3.0.tar.xz", + "shasum": "d70af604f3a8622f3393d93abb3e056bf60351e32d121e6fa4fe03d8d41e1f5a", + "size": "2335592" + }, + "x86_64-macos": { + "tarball": "https://ziglang.org/download/0.3.0/zig-macos-x86_64-0.3.0.tar.xz", + "shasum": "19dec1f1943ab7be26823376d466f7e456143deb34e17502778a949034dc2e7e", + "size": "23712696" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/download/0.3.0/zig-windows-x86_64-0.3.0.zip", + "shasum": "bb568c03950958f8bb3472139c3ab5ed74547c8c694ab50f404c202faf51baf4", + "size": "22524425" + }, + "x86_64-linux": { + "tarball": "https://ziglang.org/download/0.3.0/zig-linux-x86_64-0.3.0.tar.xz", + "shasum": "b378d0aae30cb54f28494e7bc4efbc9bfb6326f47bfb302e8b5287af777b2f3c", + "size": "25209304" + } + }, + "0.2.0": { + "date": "2018-03-15", + "docs": "https://ziglang.org/documentation/0.2.0/", + "notes": "https://ziglang.org/download/0.2.0/release-notes.html", + "src": { + "tarball": "https://ziglang.org/download/0.2.0/zig-0.2.0.tar.xz", + "shasum": "29c9beb172737f4d5019b88ceae829ae8bc6512fb4386cfbf895ae2b42aa6965", + "size": "1940832" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/download/0.2.0/zig-win64-0.2.0.zip", + "shasum": "4f8a2979941a1f081ec8e545cca0b72608c0db1c5a3fd377a94db40649dcd3d4", + "size": "21076274" + }, + "x86_64-linux": { + "tarball": "https://ziglang.org/download/0.2.0/zig-linux-x86_64-0.2.0.tar.xz", + "shasum": "209c6fb745d42474c0a73d6f291c7ae3a38b6a1b6b641eea285a7f840cc1a890", + "size": "22551928" + } + }, + "0.1.1": { + "date": "2017-10-17", + "docs": "https://ziglang.org/documentation/0.1.1/", + "notes": "https://ziglang.org/download/0.1.1/release-notes.html", + "src": { + "tarball": "https://ziglang.org/download/0.1.1/zig-0.1.1.tar.xz", + "shasum": "ffca0cfb263485287e19cc997b08701fcd5f24b700345bcdc3dd8074f5a104e0", + "size": "1659716" + }, + "x86_64-windows": { + "tarball": "https://ziglang.org/download/0.1.1/zig-win64-0.1.1.zip", + "shasum": "6fc88bef531af7e567fe30bf60da1487b86833cbee84c7a2f3e317030aa5b660", + "size": "19757776" + } + } +} diff --git a/ci/srht/on_master_success b/ci/srht/on_master_success index 691c18a054..460cda8826 100755 --- a/ci/srht/on_master_success +++ b/ci/srht/on_master_success @@ -24,6 +24,7 @@ packages: - xz secrets: - 51bfddf5-86a6-4e01-8576-358c72a4a0a4 + - 8d5f230b-78d9-4e7c-b583-8cbb1b15807c sources: - https://github.com/ziglang/zig tasks: diff --git a/ci/srht/update-download-page.zig b/ci/srht/update-download-page.zig new file mode 100644 index 0000000000..0fb1f3913c --- /dev/null +++ b/ci/srht/update-download-page.zig @@ -0,0 +1,103 @@ +const std = @import("std"); +const path = std.fs.path; +const mem = std.mem; + +pub fn main() !void { + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); + defer arena.deinit(); + + const allocator = &arena.allocator; + + const out_dir = "out"; + try std.fs.cwd().makePath(out_dir); + { + const out_file = out_dir ++ path.sep_str ++ "index.html"; + const in_file = "index.html"; + try render(allocator, in_file, out_file, .html); + } + { + const out_file = out_dir ++ path.sep_str ++ "index.json"; + const in_file = "index.json"; + try render(allocator, in_file, out_file, .plain); + } +} + +fn render( + allocator: *mem.Allocator, + in_file: []const u8, + out_file: []const u8, + fmt: enum { + html, + plain, + }, +) !void { + const in_contents = try std.fs.cwd().readFileAlloc(allocator, in_file, 1 * 1024 * 1024); + + var vars = try std.process.getEnvMap(allocator); + + var buffer = std.ArrayList(u8).init(allocator); + defer buffer.deinit(); + + const State = enum { + Start, + OpenBrace, + VarName, + EndBrace, + }; + const writer = buffer.writer(); + var state = State.Start; + var var_name_start: usize = undefined; + var line: usize = 1; + for (in_contents) |byte, index| { + switch (state) { + State.Start => switch (byte) { + '{' => { + state = State.OpenBrace; + }, + else => try writer.writeByte(byte), + }, + State.OpenBrace => switch (byte) { + '{' => { + state = State.VarName; + var_name_start = index + 1; + }, + else => { + try writer.writeByte('{'); + try writer.writeByte(byte); + state = State.Start; + }, + }, + State.VarName => switch (byte) { + '}' => { + const var_name = in_contents[var_name_start..index]; + if (vars.get(var_name)) |value| { + const trimmed = mem.trim(u8, value, " \r\n"); + if (fmt == .html and mem.endsWith(u8, var_name, "BYTESIZE")) { + try writer.print("{Bi:.1}", .{try std.fmt.parseInt(u64, trimmed, 10)}); + } else { + try writer.writeAll(trimmed); + } + } else { + std.debug.warn("line {d}: missing variable: {s}\n", .{ line, var_name }); + try writer.writeAll("(missing)"); + } + state = State.EndBrace; + }, + else => {}, + }, + State.EndBrace => switch (byte) { + '}' => { + state = State.Start; + }, + else => { + std.debug.warn("line {d}: invalid byte: '0x{x}'", .{ line, byte }); + std.process.exit(1); + }, + }, + } + if (byte == '\n') { + line += 1; + } + } + try std.fs.cwd().writeFile(out_file, buffer.items); +} diff --git a/ci/srht/update_download_page b/ci/srht/update_download_page index 77436a3772..01fa62b911 100755 --- a/ci/srht/update_download_page +++ b/ci/srht/update_download_page @@ -28,14 +28,23 @@ curl --fail -I "$X86_64_FREEBSD_JSON_URL" >/dev/null || exit 0 pip3 install s3cmd --user S3CMD="$HOME/.local/bin/s3cmd" +# This is the user when pushing to the website repo. +git config --global user.email "ziggy@ziglang.org" +git config --global user.name "Ziggy" + +# Refresh this with `ssh-keyscan github.com` from a trusted Internet connection. +# We hard code the public key here to detect man-in-the-middle attacks. +echo "github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts + +# We don't want the .git folder inside the tarball. rm -rf .git cd "$HOME" wget "https://ziglang.org/builds/$NATIVE_TARBALL" tar xf "$NATIVE_TARBALL" -ZIGDIR=$(basename $NATIVE_TARBALL .tar.xz) +ZIGDIR="$(pwd)/$(basename $NATIVE_TARBALL .tar.xz)" ZIG="$ZIGDIR/zig" -LANGREF="$ZIGDIR/langref.html" +LANGREF="$ZIGDIR/docs/langref.html" SRCTARBALLDIR="zig-$VERSION" export SRC_TARBALL="$SRCTARBALLDIR.tar.xz" mv "$SRCDIR" "$SRCTARBALLDIR" @@ -68,13 +77,29 @@ export X86_64_FREEBSD_TARBALL="$(echo "$X86_64_FREEBSD_JSON" | jq .tarball -r)" export X86_64_FREEBSD_BYTESIZE="$(echo "$X86_64_FREEBSD_JSON" | jq .size -r)" export X86_64_FREEBSD_SHASUM="$(echo "$X86_64_FREEBSD_JSON" | jq .shasum -r)" -git clone https://github.com/ziglang/www.ziglang.org --depth 1 -cd www.ziglang.org export MASTER_DATE="$(date +%Y-%m-%d)" export MASTER_VERSION="$VERSION" -"../$ZIG" run update-download-page.zig -$S3CMD put -P --no-mime-magic --add-header="cache-control: public, max-age=31536000, immutable" "../$SRC_TARBALL" s3://ziglang.org/builds/ -$S3CMD put -P --no-mime-magic "../$LANGREF" s3://ziglang.org/documentation/master/index.html --add-header="Cache-Control: max-age=0, must-revalidate" -$S3CMD put -P --no-mime-magic www/download/index.html s3://ziglang.org/download/index.html --add-header="Cache-Control: max-age=0, must-revalidate" -$S3CMD put -P --no-mime-magic www/download/index.json s3://ziglang.org/download/index.json --add-header="Cache-Control: max-age=0, must-revalidate" +cd "$SRCTARBALLDIR/ci/srht" +"$ZIG" run update-download-page.zig +CIDIR="$(pwd)" + +# Create index.json and index.html and update the website repo. +cd "$HOME" +git clone git@github.com:ziglang/www.ziglang.org.git +cd www.ziglang.org +WWWDIR="$(pwd)" + +$S3CMD put -P --no-mime-magic --add-header="cache-control: public, max-age=31536000, immutable" "$HOME/$SRC_TARBALL" s3://ziglang.org/builds/ + +cd "$WWWDIR" +cp "$CIDIR/out/index.json" data/releases.json +mkdir -p content/documentation/master/std +cp "$LANGREF" content/documentation/master/index.html +cp "$ZIGDIR/docs/std/index.html" content/documentation/master/std/index.html +cp "$ZIGDIR/docs/std/data.js" content/documentation/master/std/data.js +cp "$ZIGDIR/docs/std/main.js" content/documentation/master/std/main.js +git add data/releases.json +git add content/ +git commit -m "CI: update releases and docs" +git push origin master diff --git a/doc/docgen.zig b/doc/docgen.zig index 4a69426755..4f06b63c2c 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -40,9 +40,9 @@ pub fn main() !void { var out_file = try fs.cwd().createFile(out_file_name, .{}); defer out_file.close(); - const input_file_bytes = try in_file.inStream().readAllAlloc(allocator, max_doc_file_size); + const input_file_bytes = try in_file.reader().readAllAlloc(allocator, max_doc_file_size); - var buffered_out_stream = io.bufferedOutStream(out_file.outStream()); + var buffered_writer = io.bufferedWriter(out_file.writer()); var tokenizer = Tokenizer.init(in_file_name, input_file_bytes); var toc = try genToc(allocator, &tokenizer); @@ -50,8 +50,8 @@ pub fn main() !void { try fs.cwd().makePath(tmp_dir_name); defer fs.cwd().deleteTree(tmp_dir_name) catch {}; - try genHtml(allocator, &tokenizer, &toc, buffered_out_stream.outStream(), zig_exe); - try buffered_out_stream.flush(); + try genHtml(allocator, &tokenizer, &toc, buffered_writer.writer(), zig_exe); + try buffered_writer.flush(); } const Token = struct { @@ -215,9 +215,9 @@ const Tokenizer = struct { fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: anytype) anyerror { const loc = tokenizer.getTokenLocation(token); const args_prefix = .{ tokenizer.source_file_name, loc.line + 1, loc.column + 1 }; - print("{}:{}:{}: error: " ++ fmt ++ "\n", args_prefix ++ args); + print("{s}:{d}:{d}: error: " ++ fmt ++ "\n", args_prefix ++ args); if (loc.line_start <= loc.line_end) { - print("{}\n", .{tokenizer.buffer[loc.line_start..loc.line_end]}); + print("{s}\n", .{tokenizer.buffer[loc.line_start..loc.line_end]}); { var i: usize = 0; while (i < loc.column) : (i += 1) { @@ -238,7 +238,7 @@ fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, arg fn assertToken(tokenizer: *Tokenizer, token: Token, id: Token.Id) !void { if (token.id != id) { - return parseError(tokenizer, token, "expected {}, found {}", .{ @tagName(id), @tagName(token.id) }); + return parseError(tokenizer, token, "expected {s}, found {s}", .{ @tagName(id), @tagName(token.id) }); } } @@ -325,7 +325,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { var toc_buf = std.ArrayList(u8).init(allocator); defer toc_buf.deinit(); - var toc = toc_buf.outStream(); + var toc = toc_buf.writer(); var nodes = std.ArrayList(Node).init(allocator); defer nodes.deinit(); @@ -374,7 +374,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { return parseError( tokenizer, bracket_tok, - "unrecognized header_open param: {}", + "unrecognized header_open param: {s}", .{param}, ); } @@ -394,7 +394,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { }, }); if (try urls.fetchPut(urlized, tag_token)) |entry| { - parseError(tokenizer, tag_token, "duplicate header url: #{}", .{urlized}) catch {}; + parseError(tokenizer, tag_token, "duplicate header url: #{s}", .{urlized}) catch {}; parseError(tokenizer, entry.value, "other tag here", .{}) catch {}; return error.ParseError; } @@ -411,7 +411,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { } last_columns = columns; try toc.writeByteNTimes(' ', 4 + header_stack_size * 4); - try toc.print("
  • {}", .{ urlized, urlized, content }); + try toc.print("
  • {s}", .{ urlized, urlized, content }); } else if (mem.eql(u8, tag_name, "header_close")) { if (header_stack_size == 0) { return parseError(tokenizer, tag_token, "unbalanced close header", .{}); @@ -515,7 +515,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { code_kind_id = Code.Id{ .Obj = null }; is_inline = true; } else { - return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {}", .{code_kind_str}); + return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {s}", .{code_kind_str}); } var mode: builtin.Mode = .Debug; @@ -559,7 +559,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { return parseError( tokenizer, end_code_tag, - "invalid token inside code_begin: {}", + "invalid token inside code_begin: {s}", .{end_tag_name}, ); } @@ -590,14 +590,14 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { return parseError( tokenizer, end_syntax_tag, - "invalid token inside syntax: {}", + "invalid token inside syntax: {s}", .{end_tag_name}, ); } _ = try eatToken(tokenizer, Token.Id.BracketClose); try nodes.append(Node{ .Syntax = content_tok }); } else { - return parseError(tokenizer, tag_token, "unrecognized tag name: {}", .{tag_name}); + return parseError(tokenizer, tag_token, "unrecognized tag name: {s}", .{tag_name}); } }, else => return parseError(tokenizer, token, "invalid token", .{}), @@ -615,7 +615,7 @@ fn urlize(allocator: *mem.Allocator, input: []const u8) ![]u8 { var buf = std.ArrayList(u8).init(allocator); defer buf.deinit(); - const out = buf.outStream(); + const out = buf.writer(); for (input) |c| { switch (c) { 'a'...'z', 'A'...'Z', '_', '-', '0'...'9' => { @@ -634,7 +634,7 @@ fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 { var buf = std.ArrayList(u8).init(allocator); defer buf.deinit(); - const out = buf.outStream(); + const out = buf.writer(); try writeEscaped(out, input); return buf.toOwnedSlice(); } @@ -680,7 +680,7 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 { var buf = std.ArrayList(u8).init(allocator); defer buf.deinit(); - var out = buf.outStream(); + var out = buf.writer(); var number_start_index: usize = undefined; var first_number: usize = undefined; var second_number: usize = undefined; @@ -744,7 +744,7 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 { try out.writeAll(""); } if (first_number != 0 or second_number != 0) { - try out.print("", .{ first_number, second_number }); + try out.print("", .{ first_number, second_number }); open_span_count += 1; } }, @@ -781,106 +781,119 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: anytype, source_token: next_tok_is_fn = false; const token = tokenizer.next(); - try writeEscaped(out, src[index..token.loc.start]); - switch (token.id) { - .Eof => break, + if (mem.indexOf(u8, src[index..token.loc.start], "//")) |comment_start_off| { + // render one comment + const comment_start = index + comment_start_off; + const comment_end_off = mem.indexOf(u8, src[comment_start .. token.loc.start], "\n"); + const comment_end = if (comment_end_off) |o| comment_start + o else token.loc.start; - .Keyword_align, - .Keyword_and, - .Keyword_asm, - .Keyword_async, - .Keyword_await, - .Keyword_break, - .Keyword_catch, - .Keyword_comptime, - .Keyword_const, - .Keyword_continue, - .Keyword_defer, - .Keyword_else, - .Keyword_enum, - .Keyword_errdefer, - .Keyword_error, - .Keyword_export, - .Keyword_extern, - .Keyword_for, - .Keyword_if, - .Keyword_inline, - .Keyword_noalias, - .Keyword_noinline, - .Keyword_nosuspend, - .Keyword_opaque, - .Keyword_or, - .Keyword_orelse, - .Keyword_packed, - .Keyword_anyframe, - .Keyword_pub, - .Keyword_resume, - .Keyword_return, - .Keyword_linksection, - .Keyword_callconv, - .Keyword_struct, - .Keyword_suspend, - .Keyword_switch, - .Keyword_test, - .Keyword_threadlocal, - .Keyword_try, - .Keyword_union, - .Keyword_unreachable, - .Keyword_usingnamespace, - .Keyword_var, - .Keyword_volatile, - .Keyword_allowzero, - .Keyword_while, - .Keyword_anytype, + try writeEscaped(out, src[index..comment_start]); + try out.writeAll(""); + try writeEscaped(out, src[comment_start .. comment_end]); + try out.writeAll(""); + index = comment_end; + tokenizer.index = index; + continue; + } + + try writeEscaped(out, src[index..token.loc.start]); + switch (token.tag) { + .eof => break, + + .keyword_align, + .keyword_and, + .keyword_asm, + .keyword_async, + .keyword_await, + .keyword_break, + .keyword_catch, + .keyword_comptime, + .keyword_const, + .keyword_continue, + .keyword_defer, + .keyword_else, + .keyword_enum, + .keyword_errdefer, + .keyword_error, + .keyword_export, + .keyword_extern, + .keyword_for, + .keyword_if, + .keyword_inline, + .keyword_noalias, + .keyword_noinline, + .keyword_nosuspend, + .keyword_opaque, + .keyword_or, + .keyword_orelse, + .keyword_packed, + .keyword_anyframe, + .keyword_pub, + .keyword_resume, + .keyword_return, + .keyword_linksection, + .keyword_callconv, + .keyword_struct, + .keyword_suspend, + .keyword_switch, + .keyword_test, + .keyword_threadlocal, + .keyword_try, + .keyword_union, + .keyword_unreachable, + .keyword_usingnamespace, + .keyword_var, + .keyword_volatile, + .keyword_allowzero, + .keyword_while, + .keyword_anytype, => { try out.writeAll(""); try writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll(""); }, - .Keyword_fn => { + .keyword_fn => { try out.writeAll(""); try writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll(""); next_tok_is_fn = true; }, - .Keyword_undefined, - .Keyword_null, - .Keyword_true, - .Keyword_false, + .keyword_undefined, + .keyword_null, + .keyword_true, + .keyword_false, => { try out.writeAll(""); try writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll(""); }, - .StringLiteral, - .MultilineStringLiteralLine, - .CharLiteral, + .string_literal, + .multiline_string_literal_line, + .char_literal, => { try out.writeAll(""); try writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll(""); }, - .Builtin => { + .builtin => { try out.writeAll(""); try writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll(""); }, - .LineComment, - .DocComment, - .ContainerDocComment, - .ShebangLine, + .doc_comment, + .container_doc_comment, => { try out.writeAll(""); try writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll(""); }, - .Identifier => { + .identifier => { if (prev_tok_was_fn) { try out.writeAll(""); try writeEscaped(out, src[token.loc.start..token.loc.end]); @@ -908,71 +921,71 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: anytype, source_token: } }, - .IntegerLiteral, - .FloatLiteral, + .integer_literal, + .float_literal, => { try out.writeAll(""); try writeEscaped(out, src[token.loc.start..token.loc.end]); try out.writeAll(""); }, - .Bang, - .Pipe, - .PipePipe, - .PipeEqual, - .Equal, - .EqualEqual, - .EqualAngleBracketRight, - .BangEqual, - .LParen, - .RParen, - .Semicolon, - .Percent, - .PercentEqual, - .LBrace, - .RBrace, - .LBracket, - .RBracket, - .Period, - .PeriodAsterisk, - .Ellipsis2, - .Ellipsis3, - .Caret, - .CaretEqual, - .Plus, - .PlusPlus, - .PlusEqual, - .PlusPercent, - .PlusPercentEqual, - .Minus, - .MinusEqual, - .MinusPercent, - .MinusPercentEqual, - .Asterisk, - .AsteriskEqual, - .AsteriskAsterisk, - .AsteriskPercent, - .AsteriskPercentEqual, - .Arrow, - .Colon, - .Slash, - .SlashEqual, - .Comma, - .Ampersand, - .AmpersandEqual, - .QuestionMark, - .AngleBracketLeft, - .AngleBracketLeftEqual, - .AngleBracketAngleBracketLeft, - .AngleBracketAngleBracketLeftEqual, - .AngleBracketRight, - .AngleBracketRightEqual, - .AngleBracketAngleBracketRight, - .AngleBracketAngleBracketRightEqual, - .Tilde, + .bang, + .pipe, + .pipe_pipe, + .pipe_equal, + .equal, + .equal_equal, + .equal_angle_bracket_right, + .bang_equal, + .l_paren, + .r_paren, + .semicolon, + .percent, + .percent_equal, + .l_brace, + .r_brace, + .l_bracket, + .r_bracket, + .period, + .period_asterisk, + .ellipsis2, + .ellipsis3, + .caret, + .caret_equal, + .plus, + .plus_plus, + .plus_equal, + .plus_percent, + .plus_percent_equal, + .minus, + .minus_equal, + .minus_percent, + .minus_percent_equal, + .asterisk, + .asterisk_equal, + .asterisk_asterisk, + .asterisk_percent, + .asterisk_percent_equal, + .arrow, + .colon, + .slash, + .slash_equal, + .comma, + .ampersand, + .ampersand_equal, + .question_mark, + .angle_bracket_left, + .angle_bracket_left_equal, + .angle_bracket_angle_bracket_left, + .angle_bracket_angle_bracket_left_equal, + .angle_bracket_right, + .angle_bracket_right_equal, + .angle_bracket_angle_bracket_right, + .angle_bracket_angle_bracket_right_equal, + .tilde, => try writeEscaped(out, src[token.loc.start..token.loc.end]), - .Invalid, .Invalid_ampersands, .Invalid_periodasterisks => return parseError( + .invalid, .invalid_ampersands, .invalid_periodasterisks => return parseError( docgen_tokenizer, source_token, "syntax error", @@ -1004,9 +1017,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any }, .Link => |info| { if (!toc.urls.contains(info.url)) { - return parseError(tokenizer, info.token, "url not found: {}", .{info.url}); + return parseError(tokenizer, info.token, "url not found: {s}", .{info.url}); } - try out.print("{}", .{ info.url, info.name }); + try out.print("{s}", .{ info.url, info.name }); }, .Nav => { try out.writeAll(toc.toc); @@ -1018,7 +1031,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any }, .HeaderOpen => |info| { try out.print( - "{} §\n", + "{s} §\n", .{ info.n, info.url, info.url, info.name, info.url, info.n }, ); }, @@ -1027,9 +1040,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any for (items) |item| { const url = try urlize(allocator, item.name); if (!toc.urls.contains(url)) { - return parseError(tokenizer, item.token, "url not found: {}", .{url}); + return parseError(tokenizer, item.token, "url not found: {s}", .{url}); } - try out.print("
  • {}
  • \n", .{ url, item.name }); + try out.print("
  • {s}
  • \n", .{ url, item.name }); } try out.writeAll("\n"); }, @@ -1043,12 +1056,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any const raw_source = tokenizer.buffer[code.source_token.start..code.source_token.end]; const trimmed_raw_source = mem.trim(u8, raw_source, " \n"); if (!code.is_inline) { - try out.print("

    {}.zig

    ", .{code.name}); + try out.print("

    {s}.zig

    ", .{code.name}); } try out.writeAll("
    ");
                     try tokenizeAndPrint(tokenizer, out, code.source_token);
                     try out.writeAll("
    "); - const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", .{code.name}); + const name_plus_ext = try std.fmt.allocPrint(allocator, "{s}.zig", .{code.name}); const tmp_source_file_name = try fs.path.join( allocator, &[_][]const u8{ tmp_dir_name, name_plus_ext }, @@ -1057,7 +1070,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any switch (code.id) { Code.Id.Exe => |expected_outcome| code_block: { - const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", .{ code.name, exe_ext }); + const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, exe_ext }); var build_args = std.ArrayList([]const u8).init(allocator); defer build_args.deinit(); try build_args.appendSlice(&[_][]const u8{ @@ -1066,7 +1079,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any "--color", "on", "--enable-cache", tmp_source_file_name, }); - try out.print("
    $ zig build-exe {}.zig", .{code.name});
    +                        try out.print("
    $ zig build-exe {s}.zig", .{code.name});
                             switch (code.mode) {
                                 .Debug => {},
                                 else => {
    @@ -1075,7 +1088,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
                                 },
                             }
                             for (code.link_objects) |link_object| {
    -                            const name_with_ext = try std.fmt.allocPrint(allocator, "{}{}", .{ link_object, obj_ext });
    +                            const name_with_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ link_object, obj_ext });
                                 const full_path_object = try fs.path.join(
                                     allocator,
                                     &[_][]const u8{ tmp_dir_name, name_with_ext },
    @@ -1093,7 +1106,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
                             if (code.target_str) |triple| {
                                 try build_args.appendSlice(&[_][]const u8{ "-target", triple });
                                 if (!code.is_inline) {
    -                                try out.print(" -target {}", .{triple});
    +                                try out.print(" -target {s}", .{triple});
                                 }
                             }
                             if (expected_outcome == .BuildFail) {
    @@ -1106,20 +1119,20 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
                                 switch (result.term) {
                                     .Exited => |exit_code| {
                                         if (exit_code == 0) {
    -                                        print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
    +                                        print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr});
                                             dumpArgs(build_args.items);
                                             return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{});
                                         }
                                     },
                                     else => {
    -                                    print("{}\nThe following command crashed:\n", .{result.stderr});
    +                                    print("{s}\nThe following command crashed:\n", .{result.stderr});
                                         dumpArgs(build_args.items);
                                         return parseError(tokenizer, code.source_token, "example compile crashed", .{});
                                     },
                                 }
                                 const escaped_stderr = try escapeHtml(allocator, result.stderr);
                                 const colored_stderr = try termColor(allocator, escaped_stderr);
    -                            try out.print("\n{}
    \n", .{colored_stderr}); + try out.print("\n{s}
    \n", .{colored_stderr}); break :code_block; } const exec_result = exec(allocator, &env_map, build_args.items) catch @@ -1138,7 +1151,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any } const path_to_exe_dir = mem.trim(u8, exec_result.stdout, " \r\n"); - const path_to_exe_basename = try std.fmt.allocPrint(allocator, "{}{}", .{ + const path_to_exe_basename = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, target.exeFileExt(), }); @@ -1160,7 +1173,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any switch (result.term) { .Exited => |exit_code| { if (exit_code == 0) { - print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); + print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr}); dumpArgs(run_args); return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{}); } @@ -1179,7 +1192,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any const colored_stderr = try termColor(allocator, escaped_stderr); const colored_stdout = try termColor(allocator, escaped_stdout); - try out.print("\n$ ./{}\n{}{}", .{ code.name, colored_stdout, colored_stderr }); + try out.print("\n$ ./{s}\n{s}{s}", .{ code.name, colored_stdout, colored_stderr }); if (exited_with_signal) { try out.print("(process terminated by signal)", .{}); } @@ -1190,7 +1203,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any defer test_args.deinit(); try test_args.appendSlice(&[_][]const u8{ zig_exe, "test", tmp_source_file_name }); - try out.print("
    $ zig test {}.zig", .{code.name});
    +                        try out.print("
    $ zig test {s}.zig", .{code.name});
                             switch (code.mode) {
                                 .Debug => {},
                                 else => {
    @@ -1204,12 +1217,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
                             }
                             if (code.target_str) |triple| {
                                 try test_args.appendSlice(&[_][]const u8{ "-target", triple });
    -                            try out.print(" -target {}", .{triple});
    +                            try out.print(" -target {s}", .{triple});
                             }
                             const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{});
                             const escaped_stderr = try escapeHtml(allocator, result.stderr);
                             const escaped_stdout = try escapeHtml(allocator, result.stdout);
    -                        try out.print("\n{}{}
    \n", .{ escaped_stderr, escaped_stdout }); + try out.print("\n{s}{s}
    \n", .{ escaped_stderr, escaped_stdout }); }, Code.Id.TestError => |error_match| { var test_args = std.ArrayList([]const u8).init(allocator); @@ -1222,7 +1235,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any "on", tmp_source_file_name, }); - try out.print("
    $ zig test {}.zig", .{code.name});
    +                        try out.print("
    $ zig test {s}.zig", .{code.name});
                             switch (code.mode) {
                                 .Debug => {},
                                 else => {
    @@ -1239,24 +1252,24 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
                             switch (result.term) {
                                 .Exited => |exit_code| {
                                     if (exit_code == 0) {
    -                                    print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
    +                                    print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr});
                                         dumpArgs(test_args.items);
                                         return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{});
                                     }
                                 },
                                 else => {
    -                                print("{}\nThe following command crashed:\n", .{result.stderr});
    +                                print("{s}\nThe following command crashed:\n", .{result.stderr});
                                     dumpArgs(test_args.items);
                                     return parseError(tokenizer, code.source_token, "example compile crashed", .{});
                                 },
                             }
                             if (mem.indexOf(u8, result.stderr, error_match) == null) {
    -                            print("{}\nExpected to find '{}' in stderr\n", .{ result.stderr, error_match });
    +                            print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
                                 return parseError(tokenizer, code.source_token, "example did not have expected compile error", .{});
                             }
                             const escaped_stderr = try escapeHtml(allocator, result.stderr);
                             const colored_stderr = try termColor(allocator, escaped_stderr);
    -                        try out.print("\n{}
    \n", .{colored_stderr}); + try out.print("\n{s}
    \n", .{colored_stderr}); }, Code.Id.TestSafety => |error_match| { @@ -1294,31 +1307,31 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any switch (result.term) { .Exited => |exit_code| { if (exit_code == 0) { - print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); + print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr}); dumpArgs(test_args.items); return parseError(tokenizer, code.source_token, "example test incorrectly succeeded", .{}); } }, else => { - print("{}\nThe following command crashed:\n", .{result.stderr}); + print("{s}\nThe following command crashed:\n", .{result.stderr}); dumpArgs(test_args.items); return parseError(tokenizer, code.source_token, "example compile crashed", .{}); }, } if (mem.indexOf(u8, result.stderr, error_match) == null) { - print("{}\nExpected to find '{}' in stderr\n", .{ result.stderr, error_match }); + print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match }); return parseError(tokenizer, code.source_token, "example did not have expected runtime safety error message", .{}); } const escaped_stderr = try escapeHtml(allocator, result.stderr); const colored_stderr = try termColor(allocator, escaped_stderr); - try out.print("
    $ zig test {}.zig{}\n{}
    \n", .{ + try out.print("
    $ zig test {s}.zig{s}\n{s}
    \n", .{ code.name, mode_arg, colored_stderr, }); }, Code.Id.Obj => |maybe_error_match| { - const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{}{}", .{ code.name, obj_ext }); + const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{s}{s}", .{ code.name, obj_ext }); const tmp_obj_file_name = try fs.path.join( allocator, &[_][]const u8{ tmp_dir_name, name_plus_obj_ext }, @@ -1326,7 +1339,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any var build_args = std.ArrayList([]const u8).init(allocator); defer build_args.deinit(); - const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{}.h", .{code.name}); + const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{s}.h", .{code.name}); const output_h_file_name = try fs.path.join( allocator, &[_][]const u8{ tmp_dir_name, name_plus_h_ext }, @@ -1345,7 +1358,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any }), }); if (!code.is_inline) { - try out.print("
    $ zig build-obj {}.zig", .{code.name});
    +                            try out.print("
    $ zig build-obj {s}.zig", .{code.name});
                             }
     
                             switch (code.mode) {
    @@ -1360,7 +1373,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
     
                             if (code.target_str) |triple| {
                                 try build_args.appendSlice(&[_][]const u8{ "-target", triple });
    -                            try out.print(" -target {}", .{triple});
    +                            try out.print(" -target {s}", .{triple});
                             }
     
                             if (maybe_error_match) |error_match| {
    @@ -1373,24 +1386,24 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
                                 switch (result.term) {
                                     .Exited => |exit_code| {
                                         if (exit_code == 0) {
    -                                        print("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
    +                                        print("{s}\nThe following command incorrectly succeeded:\n", .{result.stderr});
                                             dumpArgs(build_args.items);
                                             return parseError(tokenizer, code.source_token, "example build incorrectly succeeded", .{});
                                         }
                                     },
                                     else => {
    -                                    print("{}\nThe following command crashed:\n", .{result.stderr});
    +                                    print("{s}\nThe following command crashed:\n", .{result.stderr});
                                         dumpArgs(build_args.items);
                                         return parseError(tokenizer, code.source_token, "example compile crashed", .{});
                                     },
                                 }
                                 if (mem.indexOf(u8, result.stderr, error_match) == null) {
    -                                print("{}\nExpected to find '{}' in stderr\n", .{ result.stderr, error_match });
    +                                print("{s}\nExpected to find '{s}' in stderr\n", .{ result.stderr, error_match });
                                     return parseError(tokenizer, code.source_token, "example did not have expected compile error message", .{});
                                 }
                                 const escaped_stderr = try escapeHtml(allocator, result.stderr);
                                 const colored_stderr = try termColor(allocator, escaped_stderr);
    -                            try out.print("\n{}", .{colored_stderr});
    +                            try out.print("\n{s}", .{colored_stderr});
                             } else {
                                 _ = exec(allocator, &env_map, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{});
                             }
    @@ -1416,7 +1429,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
                                     tmp_dir_name, fs.path.sep_str, bin_basename,
                                 }),
                             });
    -                        try out.print("
    $ zig build-lib {}.zig", .{code.name});
    +                        try out.print("
    $ zig build-lib {s}.zig", .{code.name});
                             switch (code.mode) {
                                 .Debug => {},
                                 else => {
    @@ -1426,12 +1439,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: any
                             }
                             if (code.target_str) |triple| {
                                 try test_args.appendSlice(&[_][]const u8{ "-target", triple });
    -                            try out.print(" -target {}", .{triple});
    +                            try out.print(" -target {s}", .{triple});
                             }
                             const result = exec(allocator, &env_map, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{});
                             const escaped_stderr = try escapeHtml(allocator, result.stderr);
                             const escaped_stdout = try escapeHtml(allocator, result.stdout);
    -                        try out.print("\n{}{}
    \n", .{ escaped_stderr, escaped_stdout }); + try out.print("\n{s}{s}
    \n", .{ escaped_stderr, escaped_stdout }); }, } print("OK\n", .{}); @@ -1450,13 +1463,13 @@ fn exec(allocator: *mem.Allocator, env_map: *std.BufMap, args: []const []const u switch (result.term) { .Exited => |exit_code| { if (exit_code != 0) { - print("{}\nThe following command exited with code {}:\n", .{ result.stderr, exit_code }); + print("{s}\nThe following command exited with code {}:\n", .{ result.stderr, exit_code }); dumpArgs(args); return error.ChildExitError; } }, else => { - print("{}\nThe following command crashed:\n", .{result.stderr}); + print("{s}\nThe following command crashed:\n", .{result.stderr}); dumpArgs(args); return error.ChildCrashed; }, @@ -1471,7 +1484,7 @@ fn getBuiltinCode(allocator: *mem.Allocator, env_map: *std.BufMap, zig_exe: []co fn dumpArgs(args: []const []const u8) void { for (args) |arg| - print("{} ", .{arg}) + print("{s} ", .{arg}) else print("\n", .{}); } diff --git a/doc/langref.html.in b/doc/langref.html.in index f380f72e6d..e49609fdbf 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -236,7 +236,7 @@ const std = @import("std"); pub fn main() !void { const stdout = std.io.getStdOut().writer(); - try stdout.print("Hello, {}!\n", .{"world"}); + try stdout.print("Hello, {s}!\n", .{"world"}); } {#code_end#}

    @@ -308,9 +308,9 @@ pub fn main() !void { multiple arguments passed to a function, they are separated by commas ,.

    - The two arguments passed to the stdout.print() function, "Hello, {}!\n" + The two arguments passed to the stdout.print() function, "Hello, {s}!\n" and .{"world"}, are evaluated at {#link|compile-time|comptime#}. The code sample is - purposely written to show how to perform {#link|string|String Literals and Character Literals#} + purposely written to show how to perform {#link|string|String Literals and Unicode Code Point Literals#} substitution in the print function. The curly-braces inside of the first argument are substituted with the compile-time known value inside of the second argument (known as an {#link|anonymous struct literal|Anonymous Struct Literals#}). The \n @@ -435,7 +435,7 @@ pub fn main() void { var optional_value: ?[]const u8 = null; assert(optional_value == null); - print("\noptional 1\ntype: {}\nvalue: {}\n", .{ + print("\noptional 1\ntype: {s}\nvalue: {s}\n", .{ @typeName(@TypeOf(optional_value)), optional_value, }); @@ -443,7 +443,7 @@ pub fn main() void { optional_value = "hi"; assert(optional_value != null); - print("\noptional 2\ntype: {}\nvalue: {}\n", .{ + print("\noptional 2\ntype: {s}\nvalue: {s}\n", .{ @typeName(@TypeOf(optional_value)), optional_value, }); @@ -451,14 +451,14 @@ pub fn main() void { // error union var number_or_error: anyerror!i32 = error.ArgNotFound; - print("\nerror union 1\ntype: {}\nvalue: {}\n", .{ + print("\nerror union 1\ntype: {s}\nvalue: {}\n", .{ @typeName(@TypeOf(number_or_error)), number_or_error, }); number_or_error = 1234; - print("\nerror union 2\ntype: {}\nvalue: {}\n", .{ + print("\nerror union 2\ntype: {s}\nvalue: {}\n", .{ @typeName(@TypeOf(number_or_error)), number_or_error, }); @@ -682,18 +682,31 @@ pub fn main() void { {#see_also|Optionals|undefined#} {#header_close#} - {#header_open|String Literals and Character Literals#} + {#header_open|String Literals and Unicode Code Point Literals#}

    - String literals are single-item constant {#link|Pointers#} to null-terminated UTF-8 encoded byte arrays. + String literals are single-item constant {#link|Pointers#} to null-terminated byte arrays. The type of string literals encodes both the length, and the fact that they are null-terminated, and thus they can be {#link|coerced|Type Coercion#} to both {#link|Slices#} and {#link|Null-Terminated Pointers|Sentinel-Terminated Pointers#}. Dereferencing string literals converts them to {#link|Arrays#}.

    - Character literals have type {#syntax#}comptime_int{#endsyntax#}, the same as + The encoding of a string in Zig is de-facto assumed to be UTF-8. + Because Zig source code is {#link|UTF-8 encoded|Source Encoding#}, any non-ASCII bytes appearing within a string literal + in source code carry their UTF-8 meaning into the content of the string in the Zig program; + the bytes are not modified by the compiler. + However, it is possible to embbed non-UTF-8 bytes into a string literal using \xNN notation. +

    +

    + Unicode code point literals have type {#syntax#}comptime_int{#endsyntax#}, the same as {#link|Integer Literals#}. All {#link|Escape Sequences#} are valid in both string literals - and character literals. + and Unicode code point literals. +

    +

    + In many other programming languages, a Unicode code point literal is called a "character literal". + However, there is no precise technical definition of a "character" + in recent versions of the Unicode specification (as of Unicode 13.0). + In Zig, a Unicode code point literal corresponds to the Unicode definition of a code point.

    {#code_begin|test#} const expect = @import("std").testing.expect; @@ -709,6 +722,7 @@ test "string literals" { expect('\u{1f4a9}' == 128169); expect('💯' == 128175); expect(mem.eql(u8, "hello", "h\x65llo")); + expect("\xff"[0] == 0xff); // non-UTF-8 strings are possible with \xNN notation. } {#code_end#} {#see_also|Arrays|Zig Test|Source Encoding#} @@ -749,11 +763,11 @@ test "string literals" { \xNN - hexadecimal 8-bit character code (2 digits) + hexadecimal 8-bit byte value (2 digits) \u{NNNNNN} - hexadecimal Unicode character code UTF-8 encoded (1 or more digits) + hexadecimal Unicode code point UTF-8 encoded (1 or more digits) @@ -1300,10 +1314,10 @@ a /= b{#endsyntax#}
  • Can cause {#link|overflow|Default Operations#} for integers.
  • Can cause {#link|Division by Zero#} for integers.
  • Can cause {#link|Division by Zero#} for floats in {#link|FloatMode.Optimized Mode|Floating Point Operations#}.
  • -
  • For non-compile-time-known signed integers, must use +
  • Signed integer operands must be comptime-known and positive. In other cases, use {#link|@divTrunc#}, {#link|@divFloor#}, or - {#link|@divExact#} instead of {#syntax#}/{#endsyntax#}. + {#link|@divExact#} instead.
  • Invokes {#link|Peer Type Resolution#} for the operands.
  • @@ -1325,9 +1339,9 @@ a %= b{#endsyntax#}
    • Can cause {#link|Division by Zero#} for integers.
    • Can cause {#link|Division by Zero#} for floats in {#link|FloatMode.Optimized Mode|Floating Point Operations#}.
    • -
    • For non-compile-time-known signed integers, must use +
    • Signed or floating-point operands must be comptime-known and positive. In other cases, use {#link|@rem#} or - {#link|@mod#} instead of {#syntax#}%{#endsyntax#}. + {#link|@mod#} instead.
    • Invokes {#link|Peer Type Resolution#} for the operands.
    @@ -2328,10 +2342,10 @@ const mem = std.mem; const fmt = std.fmt; test "using slices for strings" { - // Zig has no concept of strings. String literals are const pointers to - // arrays of u8, and by convention parameters that are "strings" are - // expected to be UTF-8 encoded slices of u8. - // Here we coerce [5]u8 to []const u8 + // Zig has no concept of strings. String literals are const pointers + // to null-terminated arrays of u8, and by convention parameters + // that are "strings" are expected to be UTF-8 encoded slices of u8. + // Here we coerce *const [5:0]u8 and *const [6:0]u8 to []const u8 const hello: []const u8 = "hello"; const world: []const u8 = "世界"; @@ -2339,7 +2353,7 @@ test "using slices for strings" { // You can use slice syntax on an array to convert an array into a slice. const all_together_slice = all_together[0..]; // String concatenation example. - const hello_world = try fmt.bufPrint(all_together_slice, "{} {}", .{ hello, world }); + const hello_world = try fmt.bufPrint(all_together_slice, "{s} {s}", .{ hello, world }); // Generally, you can use UTF-8 and not worry about whether something is a // string. If you don't need to deal with individual characters, no need @@ -2772,9 +2786,9 @@ const std = @import("std"); pub fn main() void { const Foo = struct {}; - std.debug.print("variable: {}\n", .{@typeName(Foo)}); - std.debug.print("anonymous: {}\n", .{@typeName(struct {})}); - std.debug.print("function: {}\n", .{@typeName(List(i32))}); + std.debug.print("variable: {s}\n", .{@typeName(Foo)}); + std.debug.print("anonymous: {s}\n", .{@typeName(struct {})}); + std.debug.print("function: {s}\n", .{@typeName(List(i32))}); } fn List(comptime T: type) type { @@ -2909,15 +2923,15 @@ test "enum variant switch" { expect(mem.eql(u8, what_is_it, "this is a number")); } -// @TagType can be used to access the integer tag type of an enum. +// @typeInfo can be used to access the integer tag type of an enum. const Small = enum { one, two, three, four, }; -test "@TagType" { - expect(@TagType(Small) == u2); +test "std.meta.Tag" { + expect(@typeInfo(Small).Enum.tag_type == u2); } // @typeInfo tells us the field count and the fields names: @@ -3092,8 +3106,7 @@ test "simple union" { {#header_open|Tagged union#}

    Unions can be declared with an enum tag type. This turns the union into a tagged union, which makes it eligible - to use with {#link|switch#} expressions. One can use {#link|@TagType#} to - obtain the enum type from the union type. + to use with {#link|switch#} expressions. Tagged unions coerce to their tag type: {#link|Type Coercion: unions and enums#}.

    {#code_begin|test#} @@ -3119,8 +3132,8 @@ test "switch on tagged union" { } } -test "@TagType" { - expect(@TagType(ComplexType) == ComplexTypeTag); +test "get tag type" { + expect(std.meta.Tag(ComplexType) == ComplexTypeTag); } test "coerce to enum" { @@ -4241,9 +4254,9 @@ fn _start() callconv(.Naked) noreturn { abort(); } -// The inline specifier forces a function to be inlined at all call sites. +// The inline calling convention forces a function to be inlined at all call sites. // If the function cannot be inlined, it is a compile-time error. -inline fn shiftLeftOne(a: u32) u32 { +fn shiftLeftOne(a: u32) callconv(.Inline) u32 { return a << 1; } @@ -6110,7 +6123,7 @@ const a_number: i32 = 1234; const a_string = "foobar"; pub fn main() void { - print("here is a string: '{}' here is a number: {}\n", .{a_string, a_number}); + print("here is a string: '{s}' here is a number: {}\n", .{a_string, a_number}); } {#code_end#} @@ -6120,7 +6133,7 @@ pub fn main() void { {#code_begin|syntax#} /// Calls print and then flushes the buffer. -pub fn printf(self: *OutStream, comptime format: []const u8, args: anytype) anyerror!void { +pub fn printf(self: *Writer, comptime format: []const u8, args: anytype) anyerror!void { const State = enum { start, open_brace, @@ -6192,7 +6205,7 @@ pub fn printf(self: *OutStream, comptime format: []const u8, args: anytype) anye and emits a function that actually looks like this:

    {#code_begin|syntax#} -pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void { +pub fn printf(self: *Writer, arg0: i32, arg1: []const u8) !void { try self.write("here is a string: '"); try self.printValue(arg0); try self.write("' here is a number: "); @@ -6206,7 +6219,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void { on the type:

    {#code_begin|syntax#} -pub fn printValue(self: *OutStream, value: anytype) !void { +pub fn printValue(self: *Writer, value: anytype) !void { switch (@typeInfo(@TypeOf(value))) { .Int => { return self.printInt(T, value); @@ -6230,7 +6243,7 @@ const a_number: i32 = 1234; const a_string = "foobar"; test "printf too many arguments" { - print("here is a string: '{}' here is a number: {}\n", .{ + print("here is a string: '{s}' here is a number: {}\n", .{ a_string, a_number, a_number, @@ -6249,7 +6262,7 @@ const print = @import("std").debug.print; const a_number: i32 = 1234; const a_string = "foobar"; -const fmt = "here is a string: '{}' here is a number: {}\n"; +const fmt = "here is a string: '{s}' here is a number: {}\n"; pub fn main() void { print(fmt, .{a_string, a_number}); @@ -6720,8 +6733,8 @@ fn amain() !void { const download_text = try await download_frame; defer allocator.free(download_text); - std.debug.print("download_text: {}\n", .{download_text}); - std.debug.print("file_text: {}\n", .{file_text}); + std.debug.print("download_text: {s}\n", .{download_text}); + std.debug.print("file_text: {s}\n", .{file_text}); } var global_download_frame: anyframe = undefined; @@ -6790,8 +6803,8 @@ fn amain() !void { const download_text = try await download_frame; defer allocator.free(download_text); - std.debug.print("download_text: {}\n", .{download_text}); - std.debug.print("file_text: {}\n", .{file_text}); + std.debug.print("download_text: {s}\n", .{download_text}); + std.debug.print("file_text: {s}\n", .{file_text}); } fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 { @@ -7415,7 +7428,7 @@ test "main" { This function returns a compile time constant pointer to null-terminated, fixed-size array with length equal to the byte count of the file given by {#syntax#}path{#endsyntax#}. The contents of the array are the contents of the file. - This is equivalent to a {#link|string literal|String Literals and Character Literals#} + This is equivalent to a {#link|string literal|String Literals and Unicode Code Point Literals#} with the file contents.

    @@ -7534,19 +7547,21 @@ export fn @"A function name that is a complete sentence."() void {} {#header_open|@field#}

    {#syntax#}@field(lhs: anytype, comptime field_name: []const u8) (field){#endsyntax#}
    -

    Performs field access by a compile-time string. +

    Performs field access by a compile-time string. Works on both fields and declarations.

    {#code_begin|test#} const std = @import("std"); const Point = struct { x: u32, - y: u32 + y: u32, + + pub var z: u32 = 1; }; test "field access by string" { const expect = std.testing.expect; - var p = Point {.x = 0, .y = 0}; + var p = Point{ .x = 0, .y = 0 }; @field(p, "x") = 4; @field(p, "y") = @field(p, "x") + 1; @@ -7554,6 +7569,15 @@ test "field access by string" { expect(@field(p, "x") == 4); expect(@field(p, "y") == 5); } + +test "decl access by string" { + const expect = std.testing.expect; + + expect(@field(Point, "z") == 1); + + @field(Point, "z") = 2; + expect(@field(Point, "z") == 2); +} {#code_end#} {#header_close#} @@ -7740,7 +7764,7 @@ test "@hasDecl" { {#header_close#} {#header_open|@intToEnum#} -
    {#syntax#}@intToEnum(comptime DestType: type, int_value: @TagType(DestType)) DestType{#endsyntax#}
    +
    {#syntax#}@intToEnum(comptime DestType: type, int_value: std.meta.Tag(DestType)) DestType{#endsyntax#}

    Converts an integer into an {#link|enum#} value.

    @@ -8435,16 +8459,6 @@ fn doTheTest() void {

    {#header_close#} - {#header_open|@TagType#} -
    {#syntax#}@TagType(T: type) type{#endsyntax#}
    -

    - For an enum, returns the integer type that is used to store the enumeration value. -

    -

    - For a union, returns the enum type that is used to store the tag value. -

    - {#header_close#} - {#header_open|@This#}
    {#syntax#}@This() type{#endsyntax#}

    @@ -8848,7 +8862,7 @@ pub fn main() !void { var byte: u8 = 255; byte = if (math.add(u8, byte, 1)) |result| result else |err| { - print("unable to add one: {}\n", .{@errorName(err)}); + print("unable to add one: {s}\n", .{@errorName(err)}); return err; }; @@ -9078,7 +9092,7 @@ pub fn main() void { if (result) |number| { print("got number: {}\n", .{number}); } else |err| { - print("got error: {}\n", .{@errorName(err)}); + print("got error: {s}\n", .{@errorName(err)}); } } @@ -9135,7 +9149,7 @@ const Foo = enum { pub fn main() void { var a: u2 = 3; var b = @intToEnum(Foo, a); - std.debug.print("value: {}\n", .{@tagName(b)}); + std.debug.print("value: {s}\n", .{@tagName(b)}); } {#code_end#} {#header_close#} @@ -10025,7 +10039,7 @@ pub fn main() !void { defer std.process.argsFree(gpa, args); for (args) |arg, i| { - std.debug.print("{}: {}\n", .{ i, arg }); + std.debug.print("{}: {s}\n", .{ i, arg }); } } {#code_end#} diff --git a/lib/libc/include/aarch64-linux-musl/bits/alltypes.h b/lib/libc/include/aarch64-linux-musl/bits/alltypes.h index fd60fe3a0f..0a0a8c75c0 100644 --- a/lib/libc/include/aarch64-linux-musl/bits/alltypes.h +++ b/lib/libc/include/aarch64-linux-musl/bits/alltypes.h @@ -365,6 +365,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/aarch64-linux-musl/bits/hwcap.h b/lib/libc/include/aarch64-linux-musl/bits/hwcap.h index 83abee2665..80a088ef35 100644 --- a/lib/libc/include/aarch64-linux-musl/bits/hwcap.h +++ b/lib/libc/include/aarch64-linux-musl/bits/hwcap.h @@ -37,4 +37,14 @@ #define HWCAP2_SVEPMULL (1 << 3) #define HWCAP2_SVEBITPERM (1 << 4) #define HWCAP2_SVESHA3 (1 << 5) -#define HWCAP2_SVESM4 (1 << 6) \ No newline at end of file +#define HWCAP2_SVESM4 (1 << 6) +#define HWCAP2_FLAGM2 (1 << 7) +#define HWCAP2_FRINT (1 << 8) +#define HWCAP2_SVEI8MM (1 << 9) +#define HWCAP2_SVEF32MM (1 << 10) +#define HWCAP2_SVEF64MM (1 << 11) +#define HWCAP2_SVEBF16 (1 << 12) +#define HWCAP2_I8MM (1 << 13) +#define HWCAP2_BF16 (1 << 14) +#define HWCAP2_DGH (1 << 15) +#define HWCAP2_RNG (1 << 16) \ No newline at end of file diff --git a/lib/libc/include/aarch64-linux-musl/bits/signal.h b/lib/libc/include/aarch64-linux-musl/bits/signal.h index cd13558bad..d3fc2bccff 100644 --- a/lib/libc/include/aarch64-linux-musl/bits/signal.h +++ b/lib/libc/include/aarch64-linux-musl/bits/signal.h @@ -11,7 +11,7 @@ typedef unsigned long greg_t; typedef unsigned long gregset_t[34]; typedef struct { - long double vregs[32]; + __uint128_t vregs[32]; unsigned int fpsr; unsigned int fpcr; } fpregset_t; @@ -34,7 +34,7 @@ struct fpsimd_context { struct _aarch64_ctx head; unsigned int fpsr; unsigned int fpcr; - long double vregs[32]; + __uint128_t vregs[32]; }; struct esr_context { struct _aarch64_ctx head; diff --git a/lib/libc/include/aarch64-linux-musl/bits/syscall.h b/lib/libc/include/aarch64-linux-musl/bits/syscall.h index 72392b874f..b15eb8bfd0 100644 --- a/lib/libc/include/aarch64-linux-musl/bits/syscall.h +++ b/lib/libc/include/aarch64-linux-musl/bits/syscall.h @@ -289,6 +289,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define SYS_io_setup 0 #define SYS_io_destroy 1 @@ -580,4 +584,8 @@ #define SYS_fsmount 432 #define SYS_fspick 433 #define SYS_pidfd_open 434 -#define SYS_clone3 435 \ No newline at end of file +#define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 \ No newline at end of file diff --git a/lib/libc/include/aarch64-linux-musl/bits/user.h b/lib/libc/include/aarch64-linux-musl/bits/user.h index 2bd9dd5863..8f012a5512 100644 --- a/lib/libc/include/aarch64-linux-musl/bits/user.h +++ b/lib/libc/include/aarch64-linux-musl/bits/user.h @@ -6,7 +6,7 @@ struct user_regs_struct { }; struct user_fpsimd_struct { - long double vregs[32]; + __uint128_t vregs[32]; unsigned int fpsr; unsigned int fpcr; }; diff --git a/lib/libc/include/aarch64-macos-gnu/Availability.h b/lib/libc/include/aarch64-macos-gnu/Availability.h new file mode 100644 index 0000000000..f636f9e5cd --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/Availability.h @@ -0,0 +1,482 @@ +/* + * Copyright (c) 2007-2016 by 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 __AVAILABILITY__ +#define __AVAILABILITY__ + /* + These macros are for use in OS header files. They enable function prototypes + and Objective-C methods to be tagged with the OS version in which they + were first available; and, if applicable, the OS version in which they + became deprecated. + + The desktop Mac OS X and iOS each have different version numbers. + The __OSX_AVAILABLE_STARTING() macro allows you to specify both the desktop + and iOS version numbers. For instance: + __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0) + means the function/method was first available on Mac OS X 10.2 on the desktop + and first available in iOS 2.0 on the iPhone. + + If a function is available on one platform, but not the other a _NA (not + applicable) parameter is used. For instance: + __OSX_AVAILABLE_STARTING(__MAC_10_3,__IPHONE_NA) + means that the function/method was first available on Mac OS X 10.3, and it + currently not implemented on the iPhone. + + At some point, a function/method may be deprecated. That means Apple + recommends applications stop using the function, either because there is a + better replacement or the functionality is being phased out. Deprecated + functions/methods can be tagged with a __OSX_AVAILABLE_BUT_DEPRECATED() + macro which specifies the OS version where the function became available + as well as the OS version in which it became deprecated. For instance: + __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5,__IPHONE_NA,__IPHONE_NA) + means that the function/method was introduced in Mac OS X 10.0, then + became deprecated beginning in Mac OS X 10.5. On iOS the function + has never been available. + + For these macros to function properly, a program must specify the OS version range + it is targeting. The min OS version is specified as an option to the compiler: + -mmacosx-version-min=10.x when building for Mac OS X, and -miphoneos-version-min=y.z + when building for the iPhone. The upper bound for the OS version is rarely needed, + but it can be set on the command line via: -D__MAC_OS_X_VERSION_MAX_ALLOWED=10x0 for + Mac OS X and __IPHONE_OS_VERSION_MAX_ALLOWED = y0z00 for iOS. + + Examples: + + A function available in Mac OS X 10.5 and later, but not on the phone: + + extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); + + + An Objective-C method in Mac OS X 10.5 and later, but not on the phone: + + @interface MyClass : NSObject + -(void) mymacmethod __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA); + @end + + + An enum available on the phone, but not available on Mac OS X: + + #if __IPHONE_OS_VERSION_MIN_REQUIRED + enum { myEnum = 1 }; + #endif + Note: this works when targeting the Mac OS X platform because + __IPHONE_OS_VERSION_MIN_REQUIRED is undefined which evaluates to zero. + + + An enum with values added in different iPhoneOS versions: + + enum { + myX = 1, // Usable on iPhoneOS 2.1 and later + myY = 2, // Usable on iPhoneOS 3.0 and later + myZ = 3, // Usable on iPhoneOS 3.0 and later + ... + Note: you do not want to use #if with enumeration values + when a client needs to see all values at compile time + and use runtime logic to only use the viable values. + + + It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one + source base that can be compiled to target a range of OS versions. It is best + to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. + That is because you might get compiled on an old OS that does not define a later + OS version macro, and in the C preprocessor undefined values evaluate to zero + in expresssions, which could cause the #if expression to evaluate in an unexpected + way. + + #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + // code only compiled when targeting Mac OS X and not iPhone + // note use of 1050 instead of __MAC_10_5 + #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 + // code in here might run on pre-Leopard OS + #else + // code here can assume Leopard or later + #endif + #endif + + +*/ + +/* + * __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 -D__API_TO_BE_DEPRECATED=10.12 + * (iOS) + * clang -D__API_TO_BE_DEPRECATED=11.0 + */ + +#ifndef __API_TO_BE_DEPRECATED +#define __API_TO_BE_DEPRECATED 100000 +#endif + +#include +#include + +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED + #define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_ios + #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \ + __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep + #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \ + __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep##_MSG(_msg) + +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + + #if defined(__has_builtin) + #if __has_builtin(__is_target_arch) + #if __has_builtin(__is_target_vendor) + #if __has_builtin(__is_target_os) + #if __has_builtin(__is_target_environment) + #if __has_builtin(__is_target_variant_os) + #if __has_builtin(__is_target_variant_environment) + #if (__is_target_arch(x86_64) && __is_target_vendor(apple) && ((__is_target_os(ios) && __is_target_environment(macabi)) || (__is_target_variant_os(ios) && __is_target_variant_environment(macabi)))) + #define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx __AVAILABILITY_INTERNAL##_ios + #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \ + __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep + #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \ + __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep##_MSG(_msg) __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep##_MSG(_msg) + #endif /* # if __is_target_arch... */ + #endif /* #if __has_builtin(__is_target_variant_environment) */ + #endif /* #if __has_builtin(__is_target_variant_os) */ + #endif /* #if __has_builtin(__is_target_environment) */ + #endif /* #if __has_builtin(__is_target_os) */ + #endif /* #if __has_builtin(__is_target_vendor) */ + #endif /* #if __has_builtin(__is_target_arch) */ + #endif /* #if defined(__has_builtin) */ + + #ifndef __OSX_AVAILABLE_STARTING + #if defined(__has_attribute) && defined(__has_feature) + #if __has_attribute(availability) + #define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx + #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \ + __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep + #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \ + __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep##_MSG(_msg) + #else + #define __OSX_AVAILABLE_STARTING(_osx, _ios) + #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) + #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) + #endif + #else + #define __OSX_AVAILABLE_STARTING(_osx, _ios) + #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) + #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) + #endif +#endif /* __OSX_AVAILABLE_STARTING */ + +#else + #define __OSX_AVAILABLE_STARTING(_osx, _ios) + #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) + #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) +#endif + + +#if defined(__has_feature) + #if __has_feature(attribute_availability_with_message) + #define __OS_AVAILABILITY(_target, _availability) __attribute__((availability(_target,_availability))) + #define __OS_AVAILABILITY_MSG(_target, _availability, _msg) __attribute__((availability(_target,_availability,message=_msg))) + #elif __has_feature(attribute_availability) + #define __OS_AVAILABILITY(_target, _availability) __attribute__((availability(_target,_availability))) + #define __OS_AVAILABILITY_MSG(_target, _availability, _msg) __attribute__((availability(_target,_availability))) + #else + #define __OS_AVAILABILITY(_target, _availability) + #define __OS_AVAILABILITY_MSG(_target, _availability, _msg) + #endif +#else + #define __OS_AVAILABILITY(_target, _availability) + #define __OS_AVAILABILITY_MSG(_target, _availability, _msg) +#endif + + +/* for use to document app extension usage */ +#if defined(__has_feature) + #if __has_feature(attribute_availability_app_extension) + #define __OSX_EXTENSION_UNAVAILABLE(_msg) __OS_AVAILABILITY_MSG(macosx_app_extension,unavailable,_msg) + #define __IOS_EXTENSION_UNAVAILABLE(_msg) __OS_AVAILABILITY_MSG(ios_app_extension,unavailable,_msg) + #else + #define __OSX_EXTENSION_UNAVAILABLE(_msg) + #define __IOS_EXTENSION_UNAVAILABLE(_msg) + #endif +#else + #define __OSX_EXTENSION_UNAVAILABLE(_msg) + #define __IOS_EXTENSION_UNAVAILABLE(_msg) +#endif + +#define __OS_EXTENSION_UNAVAILABLE(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg) __IOS_EXTENSION_UNAVAILABLE(_msg) + + + +/* for use marking APIs available info for Mac OSX */ +#if defined(__has_attribute) + #if __has_attribute(availability) + #define __OSX_UNAVAILABLE __OS_AVAILABILITY(macosx,unavailable) + #define __OSX_AVAILABLE(_vers) __OS_AVAILABILITY(macosx,introduced=_vers) + #define __OSX_DEPRECATED(_start, _dep, _msg) __OSX_AVAILABLE(_start) __OS_AVAILABILITY_MSG(macosx,deprecated=_dep,_msg) + #endif +#endif + +#ifndef __OSX_UNAVAILABLE + #define __OSX_UNAVAILABLE +#endif + +#ifndef __OSX_AVAILABLE + #define __OSX_AVAILABLE(_vers) +#endif + +#ifndef __OSX_DEPRECATED + #define __OSX_DEPRECATED(_start, _dep, _msg) +#endif + + +/* for use marking APIs available info for iOS */ +#if defined(__has_attribute) + #if __has_attribute(availability) + #define __IOS_UNAVAILABLE __OS_AVAILABILITY(ios,unavailable) + #define __IOS_PROHIBITED __OS_AVAILABILITY(ios,unavailable) + #define __IOS_AVAILABLE(_vers) __OS_AVAILABILITY(ios,introduced=_vers) + #define __IOS_DEPRECATED(_start, _dep, _msg) __IOS_AVAILABLE(_start) __OS_AVAILABILITY_MSG(ios,deprecated=_dep,_msg) + #endif +#endif + +#ifndef __IOS_UNAVAILABLE + #define __IOS_UNAVAILABLE +#endif + +#ifndef __IOS_PROHIBITED + #define __IOS_PROHIBITED +#endif + +#ifndef __IOS_AVAILABLE + #define __IOS_AVAILABLE(_vers) +#endif + +#ifndef __IOS_DEPRECATED + #define __IOS_DEPRECATED(_start, _dep, _msg) +#endif + + +/* for use marking APIs available info for tvOS */ +#if defined(__has_feature) + #if __has_feature(attribute_availability_tvos) + #define __TVOS_UNAVAILABLE __OS_AVAILABILITY(tvos,unavailable) + #define __TVOS_PROHIBITED __OS_AVAILABILITY(tvos,unavailable) + #define __TVOS_AVAILABLE(_vers) __OS_AVAILABILITY(tvos,introduced=_vers) + #define __TVOS_DEPRECATED(_start, _dep, _msg) __TVOS_AVAILABLE(_start) __OS_AVAILABILITY_MSG(tvos,deprecated=_dep,_msg) + #endif +#endif + +#ifndef __TVOS_UNAVAILABLE + #define __TVOS_UNAVAILABLE +#endif + +#ifndef __TVOS_PROHIBITED + #define __TVOS_PROHIBITED +#endif + +#ifndef __TVOS_AVAILABLE + #define __TVOS_AVAILABLE(_vers) +#endif + +#ifndef __TVOS_DEPRECATED + #define __TVOS_DEPRECATED(_start, _dep, _msg) +#endif + + +/* for use marking APIs available info for Watch OS */ +#if defined(__has_feature) + #if __has_feature(attribute_availability_watchos) + #define __WATCHOS_UNAVAILABLE __OS_AVAILABILITY(watchos,unavailable) + #define __WATCHOS_PROHIBITED __OS_AVAILABILITY(watchos,unavailable) + #define __WATCHOS_AVAILABLE(_vers) __OS_AVAILABILITY(watchos,introduced=_vers) + #define __WATCHOS_DEPRECATED(_start, _dep, _msg) __WATCHOS_AVAILABLE(_start) __OS_AVAILABILITY_MSG(watchos,deprecated=_dep,_msg) + #endif +#endif + +#ifndef __WATCHOS_UNAVAILABLE + #define __WATCHOS_UNAVAILABLE +#endif + +#ifndef __WATCHOS_PROHIBITED + #define __WATCHOS_PROHIBITED +#endif + +#ifndef __WATCHOS_AVAILABLE + #define __WATCHOS_AVAILABLE(_vers) +#endif + +#ifndef __WATCHOS_DEPRECATED + #define __WATCHOS_DEPRECATED(_start, _dep, _msg) +#endif + + +/* for use marking APIs unavailable for swift */ +#if defined(__has_feature) + #if __has_feature(attribute_availability_swift) + #define __SWIFT_UNAVAILABLE __OS_AVAILABILITY(swift,unavailable) + #define __SWIFT_UNAVAILABLE_MSG(_msg) __OS_AVAILABILITY_MSG(swift,unavailable,_msg) + #endif +#endif + +#ifndef __SWIFT_UNAVAILABLE + #define __SWIFT_UNAVAILABLE +#endif + +#ifndef __SWIFT_UNAVAILABLE_MSG + #define __SWIFT_UNAVAILABLE_MSG(_msg) +#endif + +/* + Macros for defining which versions/platform a given symbol can be used. + + @see http://clang.llvm.org/docs/AttributeReference.html#availability + + * Note that these macros are only compatible with clang compilers that + * support the following target selection options: + * + * -mmacosx-version-min + * -miphoneos-version-min + * -mwatchos-version-min + * -mtvos-version-min + */ + +#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)) + * __API_AVAILABLE(driverkit(19.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 /* __AVAILABILITY__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/AvailabilityInternal.h b/lib/libc/include/aarch64-macos-gnu/AvailabilityInternal.h new file mode 100644 index 0000000000..56de12636a --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/AvailabilityInternal.h @@ -0,0 +1,4675 @@ +/* + * Copyright (c) 2007-2016 by 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@ + */ + +/* + File: AvailabilityInternal.h + + Contains: implementation details of __OSX_AVAILABLE_* macros from + +*/ +#ifndef __AVAILABILITY_INTERNAL__ +#define __AVAILABILITY_INTERNAL__ + +#if __has_include() + #include +#endif + +#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED + #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + /* compiler for Mac OS X sets __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ */ + #define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + #endif +#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED*/ + +#ifndef __IPHONE_OS_VERSION_MIN_REQUIRED + #ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ + /* compiler sets __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ when -miphoneos-version-min is used */ + #define __IPHONE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ + /* set to 1 when RC_FALLBACK_PLATFORM=iphoneos */ + #elif 0 + #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_14_0 + #endif +#endif /* __IPHONE_OS_VERSION_MIN_REQUIRED */ + +#ifndef __TV_OS_VERSION_MIN_REQUIRED + #ifdef __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ + /* compiler sets __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ when -mtvos-version-min is used */ + #define __TV_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ + #define __TV_OS_VERSION_MAX_ALLOWED __TVOS_14_2 + /* for compatibility with existing code. New code should use platform specific checks */ + #define __IPHONE_OS_VERSION_MIN_REQUIRED 90000 + #endif +#endif + +#ifndef __WATCH_OS_VERSION_MIN_REQUIRED + #ifdef __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ + /* compiler sets __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ when -mwatchos-version-min is used */ + #define __WATCH_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ + #define __WATCH_OS_VERSION_MAX_ALLOWED __WATCHOS_7_1 + /* for compatibility with existing code. New code should use platform specific checks */ + #define __IPHONE_OS_VERSION_MIN_REQUIRED 90000 + #endif +#endif + +#ifndef __BRIDGE_OS_VERSION_MIN_REQUIRED + #ifdef __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ + + #define __BRIDGE_OS_VERSION_MIN_REQUIRED __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ + #define __BRIDGE_OS_VERSION_MAX_ALLOWED 50000 + /* for compatibility with existing code. New code should use platform specific checks */ + #define __IPHONE_OS_VERSION_MIN_REQUIRED 110000 + #endif +#endif + +#ifndef __DRIVERKIT_VERSION_MIN_REQUIRED + #ifdef __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ + #define __DRIVERKIT_VERSION_MIN_REQUIRED __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ + #endif +#endif + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED + /* make sure a default max version is set */ + #ifndef __MAC_OS_X_VERSION_MAX_ALLOWED + #define __MAC_OS_X_VERSION_MAX_ALLOWED __MAC_11_0 + #endif +#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */ + +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED + /* make sure a default max version is set */ + #ifndef __IPHONE_OS_VERSION_MAX_ALLOWED + #define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_14_2 + #endif + /* make sure a valid min is set */ + #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_2_0 + #undef __IPHONE_OS_VERSION_MIN_REQUIRED + #define __IPHONE_OS_VERSION_MIN_REQUIRED __IPHONE_2_0 + #endif +#endif + +#define __AVAILABILITY_INTERNAL_DEPRECATED __attribute__((deprecated)) +#ifdef __has_feature + #if __has_feature(attribute_deprecated_with_message) + #define __AVAILABILITY_INTERNAL_DEPRECATED_MSG(_msg) __attribute__((deprecated(_msg))) + #else + #define __AVAILABILITY_INTERNAL_DEPRECATED_MSG(_msg) __attribute__((deprecated)) + #endif +#elif defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))) + #define __AVAILABILITY_INTERNAL_DEPRECATED_MSG(_msg) __attribute__((deprecated(_msg))) +#else + #define __AVAILABILITY_INTERNAL_DEPRECATED_MSG(_msg) __attribute__((deprecated)) +#endif +#define __AVAILABILITY_INTERNAL_UNAVAILABLE __attribute__((unavailable)) +#define __AVAILABILITY_INTERNAL_WEAK_IMPORT __attribute__((weak_import)) +#define __AVAILABILITY_INTERNAL_REGULAR + +#if defined(__has_builtin) + #if __has_builtin(__is_target_arch) + #if __has_builtin(__is_target_vendor) + #if __has_builtin(__is_target_os) + #if __has_builtin(__is_target_environment) + #if __has_builtin(__is_target_variant_os) + #if __has_builtin(__is_target_variant_environment) + #if (__is_target_arch(x86_64) && __is_target_vendor(apple) && ((__is_target_os(ios) && __is_target_environment(macabi)) || (__is_target_variant_os(ios) && __is_target_variant_environment(macabi)))) + #define __ENABLE_LEGACY_IPHONE_AVAILABILITY 1 + #define __ENABLE_LEGACY_MAC_AVAILABILITY 1 + #endif /* # if __is_target_arch... */ + #endif /* #if __has_builtin(__is_target_variant_environment) */ + #endif /* #if __has_builtin(__is_target_variant_os) */ + #endif /* #if __has_builtin(__is_target_environment) */ + #endif /* #if __has_builtin(__is_target_os) */ + #endif /* #if __has_builtin(__is_target_vendor) */ + #endif /* #if __has_builtin(__is_target_arch) */ +#endif /* #if defined(__has_builtin) */ + +#ifndef __ENABLE_LEGACY_IPHONE_AVAILABILITY + #ifdef __IPHONE_OS_VERSION_MIN_REQUIRED + #define __ENABLE_LEGACY_IPHONE_AVAILABILITY 1 + #elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) + #define __ENABLE_LEGACY_MAC_AVAILABILITY 1 + #endif +#endif /* __ENABLE_LEGACY_IPHONE_AVAILABILITY */ + +#ifdef __ENABLE_LEGACY_IPHONE_AVAILABILITY + #if defined(__has_attribute) && defined(__has_feature) + #if __has_attribute(availability) + /* use better attributes if possible */ + #define __AVAILABILITY_INTERNAL__IPHONE_2_0 __attribute__((availability(ios,introduced=2.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=2.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=2.0,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=2.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=2.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_11_0 __attribute__((availability(ios,introduced=2.0,deprecated=11.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_2_0 __attribute__((availability(ios,introduced=2.0,deprecated=2.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_2_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=2.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_2_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=2.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_2_1 __attribute__((availability(ios,introduced=2.0,deprecated=2.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_2_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=2.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_2_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_2_2 __attribute__((availability(ios,introduced=2.0,deprecated=2.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_2_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=2.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_2_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=2.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_3_0 __attribute__((availability(ios,introduced=2.0,deprecated=3.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_3_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=3.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_3_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_3_1 __attribute__((availability(ios,introduced=2.0,deprecated=3.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=3.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=3.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_3_2 __attribute__((availability(ios,introduced=2.0,deprecated=3.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=3.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=3.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_0 __attribute__((availability(ios,introduced=2.0,deprecated=4.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=4.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=4.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_1 __attribute__((availability(ios,introduced=2.0,deprecated=4.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=4.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=4.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_2 __attribute__((availability(ios,introduced=2.0,deprecated=4.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=4.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=4.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=2.0,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=2.0,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=2.0,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=2.0,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=2.0,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=2.0,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=2.0,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=2.0,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=2.0,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=2.0,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=2.0,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=2.0,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=2.0,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=2.0,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=2.0,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=2.0,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=2.0,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_NA __attribute__((availability(ios,introduced=2.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_2_0_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=2.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1 __attribute__((availability(ios,introduced=2.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=2.1,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=2.1,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=2.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=2.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_2_1 __attribute__((availability(ios,introduced=2.1,deprecated=2.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_2_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=2.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_2_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=2.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_2_2 __attribute__((availability(ios,introduced=2.1,deprecated=2.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_2_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=2.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_2_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=2.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_3_0 __attribute__((availability(ios,introduced=2.1,deprecated=3.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_3_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=3.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_3_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=3.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_3_1 __attribute__((availability(ios,introduced=2.1,deprecated=3.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=3.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=3.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_3_2 __attribute__((availability(ios,introduced=2.1,deprecated=3.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=3.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=3.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_0 __attribute__((availability(ios,introduced=2.1,deprecated=4.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=4.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=4.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_1 __attribute__((availability(ios,introduced=2.1,deprecated=4.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=4.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=4.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_2 __attribute__((availability(ios,introduced=2.1,deprecated=4.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=4.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=4.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=2.1,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=2.1,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=2.1,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=2.1,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=2.1,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=2.1,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=2.1,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=2.1,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=2.1,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=2.1,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=2.1,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=2.1,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=2.1,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=2.1,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=2.1,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=2.1,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=2.1,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_NA __attribute__((availability(ios,introduced=2.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_2_1_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=2.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2 __attribute__((availability(ios,introduced=2.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=2.2,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=2.2,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=2.2,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=2.2,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_2_2 __attribute__((availability(ios,introduced=2.2,deprecated=2.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_2_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=2.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_2_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=2.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_3_0 __attribute__((availability(ios,introduced=2.2,deprecated=3.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_3_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=3.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_3_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=3.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_3_1 __attribute__((availability(ios,introduced=2.2,deprecated=3.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=3.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=3.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_3_2 __attribute__((availability(ios,introduced=2.2,deprecated=3.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=3.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=3.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_0 __attribute__((availability(ios,introduced=2.2,deprecated=4.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=4.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=4.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_1 __attribute__((availability(ios,introduced=2.2,deprecated=4.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=4.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=4.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_2 __attribute__((availability(ios,introduced=2.2,deprecated=4.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=4.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=4.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=2.2,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=2.2,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=2.2,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=2.2,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=2.2,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=2.2,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=2.2,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=2.2,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=2.2,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=2.2,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=2.2,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=2.2,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=2.2,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=2.2,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=2.2,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=2.2,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=2.2,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_NA __attribute__((availability(ios,introduced=2.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_2_2_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=2.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0 __attribute__((availability(ios,introduced=3.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=3.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=3.0,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=3.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=3.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_3_0 __attribute__((availability(ios,introduced=3.0,deprecated=3.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_3_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=3.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_3_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=3.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_3_1 __attribute__((availability(ios,introduced=3.0,deprecated=3.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=3.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=3.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_3_2 __attribute__((availability(ios,introduced=3.0,deprecated=3.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=3.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=3.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_0 __attribute__((availability(ios,introduced=3.0,deprecated=4.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=4.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=4.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_1 __attribute__((availability(ios,introduced=3.0,deprecated=4.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=4.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=4.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_2 __attribute__((availability(ios,introduced=3.0,deprecated=4.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=4.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=4.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=3.0,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=3.0,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=3.0,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=3.0,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=3.0,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=3.0,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=3.0,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=3.0,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=3.0,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=3.0,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=3.0,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=3.0,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=3.0,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=3.0,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=3.0,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=3.0,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=3.0,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_NA __attribute__((availability(ios,introduced=3.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_3_0_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=3.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1 __attribute__((availability(ios,introduced=3.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=3.1,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=3.1,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=3.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=3.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_3_1 __attribute__((availability(ios,introduced=3.1,deprecated=3.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=3.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_3_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=3.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_3_2 __attribute__((availability(ios,introduced=3.1,deprecated=3.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=3.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=3.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_0 __attribute__((availability(ios,introduced=3.1,deprecated=4.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=4.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=4.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_1 __attribute__((availability(ios,introduced=3.1,deprecated=4.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=4.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=4.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_2 __attribute__((availability(ios,introduced=3.1,deprecated=4.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=4.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=4.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=3.1,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=3.1,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=3.1,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=3.1,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=3.1,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=3.1,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=3.1,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=3.1,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=3.1,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=3.1,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=3.1,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=3.1,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=3.1,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=3.1,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=3.1,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=3.1,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=3.1,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_NA __attribute__((availability(ios,introduced=3.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_3_1_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=3.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2 __attribute__((availability(ios,introduced=3.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=3.2,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=3.2,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=3.2,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=3.2,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_3_2 __attribute__((availability(ios,introduced=3.2,deprecated=3.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=3.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_3_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=3.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_0 __attribute__((availability(ios,introduced=3.2,deprecated=4.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=4.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=4.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_1 __attribute__((availability(ios,introduced=3.2,deprecated=4.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=4.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=4.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_2 __attribute__((availability(ios,introduced=3.2,deprecated=4.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=4.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=4.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=3.2,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=3.2,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=3.2,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=3.2,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=3.2,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=3.2,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=3.2,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=3.2,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=3.2,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=3.2,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=3.2,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=3.2,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=3.2,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=3.2,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=3.2,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=3.2,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=3.2,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_NA __attribute__((availability(ios,introduced=3.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_3_2_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=3.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0 __attribute__((availability(ios,introduced=4.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=4.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=4.0,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=4.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=4.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_12_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=12.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_12_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=12.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_0 __attribute__((availability(ios,introduced=4.0,deprecated=4.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_1 __attribute__((availability(ios,introduced=4.0,deprecated=4.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_2 __attribute__((availability(ios,introduced=4.0,deprecated=4.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=4.0,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=4.0,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=4.0,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=4.0,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=4.0,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=4.0,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=4.0,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=4.0,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=4.0,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=4.0,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=4.0,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=4.0,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=4.0,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=4.0,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=4.0,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=4.0,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_NA __attribute__((availability(ios,introduced=4.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=4.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1 __attribute__((availability(ios,introduced=4.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=4.1,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=4.1,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=4.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=4.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_4_1 __attribute__((availability(ios,introduced=4.1,deprecated=4.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=4.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_4_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=4.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_4_2 __attribute__((availability(ios,introduced=4.1,deprecated=4.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=4.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=4.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=4.1,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=4.1,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=4.1,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=4.1,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=4.1,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=4.1,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=4.1,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=4.1,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=4.1,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=4.1,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=4.1,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=4.1,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=4.1,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=4.1,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=4.1,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=4.1,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=4.1,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_NA __attribute__((availability(ios,introduced=4.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_1_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=4.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2 __attribute__((availability(ios,introduced=4.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=4.2,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=4.2,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=4.2,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=4.2,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_4_2 __attribute__((availability(ios,introduced=4.2,deprecated=4.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=4.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_4_2_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=4.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=4.2,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=4.2,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=4.2,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=4.2,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=4.2,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=4.2,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=4.2,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=4.2,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=4.2,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=4.2,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=4.2,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=4.2,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=4.2,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=4.2,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=4.2,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=4.2,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=4.2,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_NA __attribute__((availability(ios,introduced=4.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_2_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=4.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3 __attribute__((availability(ios,introduced=4.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=4.3,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=4.3,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=4.3,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=4.3,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_4_3 __attribute__((availability(ios,introduced=4.3,deprecated=4.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=4.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_4_3_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=4.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=4.3,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=4.3,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=4.3,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=4.3,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=4.3,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=4.3,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=4.3,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=4.3,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=4.3,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=4.3,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=4.3,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=4.3,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=4.3,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=4.3,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=4.3,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=4.3,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_NA __attribute__((availability(ios,introduced=4.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=4.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0 __attribute__((availability(ios,introduced=5.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=5.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=5.0,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=5.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=5.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_11_0 __attribute__((availability(ios,introduced=5.0,deprecated=11.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_5_0 __attribute__((availability(ios,introduced=5.0,deprecated=5.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=5.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_5_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=5.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=5.0,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=5.0,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=5.0,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=5.0,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=5.0,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=5.0,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=5.0,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=5.0,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=5.0,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=5.0,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=5.0,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=5.0,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=5.0,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=5.0,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=5.0,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_NA __attribute__((availability(ios,introduced=5.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=5.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1 __attribute__((availability(ios,introduced=5.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=5.1,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=5.1,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=5.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=5.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_5_1 __attribute__((availability(ios,introduced=5.1,deprecated=5.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=5.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_5_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=5.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=5.1,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=5.1,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=5.1,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=5.1,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=5.1,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=5.1,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=5.1,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=5.1,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=5.1,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=5.1,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=5.1,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=5.1,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=5.1,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=5.1,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_NA __attribute__((availability(ios,introduced=5.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_5_1_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=5.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0 __attribute__((availability(ios,introduced=6.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=6.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=6.0,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=6.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=6.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_6_0 __attribute__((availability(ios,introduced=6.0,deprecated=6.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=6.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_6_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=6.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=6.0,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=6.0,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=6.0,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=6.0,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=6.0,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=6.0,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=6.0,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=6.0,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=6.0,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=6.0,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=6.0,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=6.0,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=6.0,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_NA __attribute__((availability(ios,introduced=6.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=6.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1 __attribute__((availability(ios,introduced=6.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=6.1,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=6.1,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=6.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=6.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_6_1 __attribute__((availability(ios,introduced=6.1,deprecated=6.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=6.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_6_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=6.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=6.1,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=6.1,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=6.1,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=6.1,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=6.1,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=6.1,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=6.1,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=6.1,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=6.1,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=6.1,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=6.1,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=6.1,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_NA __attribute__((availability(ios,introduced=6.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_6_1_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=6.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0 __attribute__((availability(ios,introduced=7.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=7.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=7.0,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=7.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=7.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_11_0 __attribute__((availability(ios,introduced=7.0,deprecated=11.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_11_3 __attribute__((availability(ios,introduced=7.0,deprecated=11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_12_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=12.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_12_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=12.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_7_0 __attribute__((availability(ios,introduced=7.0,deprecated=7.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=7.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_7_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=7.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=7.0,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=7.0,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=7.0,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=7.0,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=7.0,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=7.0,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=7.0,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=7.0,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=7.0,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=7.0,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=7.0,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_NA __attribute__((availability(ios,introduced=7.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_7_0_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=7.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1 __attribute__((availability(ios,introduced=7.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=7.1,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=7.1,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=7.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=7.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_7_1 __attribute__((availability(ios,introduced=7.1,deprecated=7.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=7.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_7_1_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=7.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=7.1,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=7.1,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=7.1,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=7.1,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=7.1,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=7.1,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=7.1,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=7.1,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=7.1,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=7.1,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_NA __attribute__((availability(ios,introduced=7.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_7_1_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=7.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0 __attribute__((availability(ios,introduced=8.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=8.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=8.0,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=8.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=8.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_11_0_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_11_0_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=11))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_11_3 __attribute__((availability(ios,introduced=8.0,deprecated=11.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_12_0 __attribute__((availability(ios,introduced=8.0,deprecated=12.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_0 __attribute__((availability(ios,introduced=8.0,deprecated=8.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_0_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=8.0,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=8.0,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=8.0,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=8.0,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=8.0,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=8.0,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=8.0,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=8.0,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.0,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_NA __attribute__((availability(ios,introduced=8.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_0_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=8.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1 __attribute__((availability(ios,introduced=8.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=8.1,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=8.1,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=8.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=8.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_1 __attribute__((availability(ios,introduced=8.1,deprecated=8.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=8.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_1_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=8.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=8.1,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=8.1,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=8.1,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=8.1,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=8.1,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=8.1,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=8.1,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.1,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_NA __attribute__((availability(ios,introduced=8.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_1_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=8.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2 __attribute__((availability(ios,introduced=8.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=8.2,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=8.2,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=8.2,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=8.2,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_8_2 __attribute__((availability(ios,introduced=8.2,deprecated=8.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=8.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_8_2_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=8.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=8.2,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=8.2,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=8.2,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=8.2,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=8.2,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=8.2,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.2,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_NA __attribute__((availability(ios,introduced=8.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_2_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=8.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3 __attribute__((availability(ios,introduced=8.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=8.3,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=8.3,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=8.3,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=8.3,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_8_3 __attribute__((availability(ios,introduced=8.3,deprecated=8.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=8.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_8_3_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=8.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=8.3,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=8.3,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=8.3,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=8.3,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=8.3,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.3,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_NA __attribute__((availability(ios,introduced=8.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_3_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=8.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4 __attribute__((availability(ios,introduced=8.4))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=8.4,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=8.4,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=8.4,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=8.4,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_8_4 __attribute__((availability(ios,introduced=8.4,deprecated=8.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=8.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_8_4_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=8.4))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=8.4,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=8.4,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=8.4,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=8.4,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=8.4,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_NA __attribute__((availability(ios,introduced=8.4))) + #define __AVAILABILITY_INTERNAL__IPHONE_8_4_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=8.4))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0 __attribute__((availability(ios,introduced=9.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=9.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=9.0,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=9.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=9.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_0 __attribute__((availability(ios,introduced=9.0,deprecated=9.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=9.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_0_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=9.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=9.0,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=9.0,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=9.0,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=9.0,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_NA __attribute__((availability(ios,introduced=9.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_0_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=9.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1 __attribute__((availability(ios,introduced=9.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=9.1,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=9.1,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=9.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=9.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_9_1 __attribute__((availability(ios,introduced=9.1,deprecated=9.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=9.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_9_1_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=9.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=9.1,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=9.1,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=9.1,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_NA __attribute__((availability(ios,introduced=9.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_1_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=9.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_2 __attribute__((availability(ios,introduced=9.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=9.2,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=9.2,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=9.2,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=9.2,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_9_2 __attribute__((availability(ios,introduced=9.2,deprecated=9.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=9.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_9_2_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=9.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=9.2,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=9.2,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_NA __attribute__((availability(ios,introduced=9.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_2_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=9.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_3 __attribute__((availability(ios,introduced=9.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=9.3,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=9.3,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=9.3,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=9.3,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_9_3 __attribute__((availability(ios,introduced=9.3,deprecated=9.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=9.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_9_3_MSG(_msg) __attribute__((availability(ios,introduced=9.3,deprecated=9.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_NA __attribute__((availability(ios,introduced=9.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_9_3_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=9.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_0 __attribute__((availability(ios,introduced=10.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_0 __attribute__((availability(ios,introduced=10.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=10.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_0_MSG(_msg) __attribute__((availability(ios,introduced=10.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=10.0,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=10.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=10.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=10.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=10.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=10.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=10.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=10.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=10.0,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_11_0 __attribute__((availability(ios,introduced=10.0,deprecated=11.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_12_0 __attribute__((availability(ios,introduced=10.0,deprecated=12.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_NA __attribute__((availability(ios,introduced=10.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_0_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=10.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_1 __attribute__((availability(ios,introduced=10.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_10_1 __attribute__((availability(ios,introduced=10.1,deprecated=10.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=10.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_10_1_MSG(_msg) __attribute__((availability(ios,introduced=10.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=10.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=10.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=10.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=10.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=10.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=10.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_NA __attribute__((availability(ios,introduced=10.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_1_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=10.1))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_2 __attribute__((availability(ios,introduced=10.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_2_DEP__IPHONE_10_2 __attribute__((availability(ios,introduced=10.2,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=10.2,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_2_DEP__IPHONE_10_2_MSG(_msg) __attribute__((availability(ios,introduced=10.2,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_2_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=10.2,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=10.2,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_2_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=10.2,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_2_DEP__IPHONE_NA __attribute__((availability(ios,introduced=10.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_2_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=10.2))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_3 __attribute__((availability(ios,introduced=10.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_3_DEP__IPHONE_10_3 __attribute__((availability(ios,introduced=10.3,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_10_3_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=10.3,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_10_3_DEP__IPHONE_10_3_MSG(_msg) __attribute__((availability(ios,introduced=10.3,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__IPHONE_10_3_DEP__IPHONE_NA __attribute__((availability(ios,introduced=10.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_10_3_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,introduced=10.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_11 __attribute__((availability(ios,introduced=11))) + #define __AVAILABILITY_INTERNAL__IPHONE_11_0 __attribute__((availability(ios,introduced=11.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_11_3 __attribute__((availability(ios,introduced=11.3))) + #define __AVAILABILITY_INTERNAL__IPHONE_12_0 __attribute__((availability(ios,introduced=12.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_13_0 __attribute__((availability(ios,introduced=13.0))) + + #define __AVAILABILITY_INTERNAL__IPHONE_NA __attribute__((availability(ios,unavailable))) + #define __AVAILABILITY_INTERNAL__IPHONE_NA__IPHONE_NA __attribute__((availability(ios,unavailable))) + #define __AVAILABILITY_INTERNAL__IPHONE_NA_DEP__IPHONE_NA __attribute__((availability(ios,unavailable))) + #define __AVAILABILITY_INTERNAL__IPHONE_NA_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,unavailable))) + + #if __has_builtin(__is_target_arch) + #if __has_builtin(__is_target_vendor) + #if __has_builtin(__is_target_os) + #if __has_builtin(__is_target_environment) + #if __has_builtin(__is_target_variant_os) + #if __has_builtin(__is_target_variant_environment) + #if ((__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi)) + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION __attribute__((availability(ios,introduced=4.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION __attribute__((availability(ios,unavailable))) + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION_MSG(_msg) __attribute__((availability(ios,unavailable))) + #endif + #endif /* #if __has_builtin(__is_target_variant_environment) */ + #endif /* #if __has_builtin(__is_target_variant_os) */ + #endif /* #if __has_builtin(__is_target_environment) */ + #endif /* #if __has_builtin(__is_target_os) */ + #endif /* #if __has_builtin(__is_target_vendor) */ + #endif /* #if __has_builtin(__is_target_arch) */ + + #ifndef __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION __attribute__((availability(ios,introduced=4.0))) + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION __attribute__((availability(ios,introduced=4.0,deprecated=4.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION_MSG(_msg) __attribute__((availability(ios,introduced=4.0,deprecated=4.0))) + #endif + #endif /* __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION */ + #endif + #endif +#endif + +#if __ENABLE_LEGACY_MAC_AVAILABILITY + #if defined(__has_attribute) && defined(__has_feature) + #if __has_attribute(availability) + /* use better attributes if possible */ + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.1,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.1,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.1,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.1,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.1,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.1,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.1,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.1,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.1,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.1,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.1,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.1,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.12))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_2 __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_3 __attribute__((availability(macosx,introduced=10.1,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_4 __attribute__((availability(macosx,introduced=10.1,deprecated=10.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_5 __attribute__((availability(macosx,introduced=10.1,deprecated=10.5))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.5,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.5))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_6 __attribute__((availability(macosx,introduced=10.1,deprecated=10.6))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.6,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.6))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_7 __attribute__((availability(macosx,introduced=10.1,deprecated=10.7))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.7,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.7))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_8 __attribute__((availability(macosx,introduced=10.1,deprecated=10.8))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.8,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.8))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.1,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.1,deprecated=10.9))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_2 __attribute__((availability(macosx,introduced=10.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.2,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.2,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.2,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.2,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.2,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.2,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.2,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.2,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.2,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.2,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.2,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.2,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_13 __attribute__((availability(macosx,introduced=10.2,deprecated=10.13))) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_2 __attribute__((availability(macosx,introduced=10.2,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_3 __attribute__((availability(macosx,introduced=10.2,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_4 __attribute__((availability(macosx,introduced=10.2,deprecated=10.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_5 __attribute__((availability(macosx,introduced=10.2,deprecated=10.5))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.5,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.5))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_6 __attribute__((availability(macosx,introduced=10.2,deprecated=10.6))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.6,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.6))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_7 __attribute__((availability(macosx,introduced=10.2,deprecated=10.7))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.7,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.7))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_8 __attribute__((availability(macosx,introduced=10.2,deprecated=10.8))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.8,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.8))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.2,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.2,deprecated=10.9))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_3 __attribute__((availability(macosx,introduced=10.3))) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.3,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.3,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.3,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.3,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.3,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.3,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.3,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.3,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.3,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.3,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.3,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.3,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_13 __attribute__((availability(macosx,introduced=10.3,deprecated=10.13))) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_3 __attribute__((availability(macosx,introduced=10.3,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_4 __attribute__((availability(macosx,introduced=10.3,deprecated=10.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_5 __attribute__((availability(macosx,introduced=10.3,deprecated=10.5))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.5,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.5))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_6 __attribute__((availability(macosx,introduced=10.3,deprecated=10.6))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.6,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.6))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_7 __attribute__((availability(macosx,introduced=10.3,deprecated=10.7))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.7,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.7))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_8 __attribute__((availability(macosx,introduced=10.3,deprecated=10.8))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.8,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.8))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.3,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.3,deprecated=10.9))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.3))) + #define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.3))) + #define __AVAILABILITY_INTERNAL__MAC_10_4 __attribute__((availability(macosx,introduced=10.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.4,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.4,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.4,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.4,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.4,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.4,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.4,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.4,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.4,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.4,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.4,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.4,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_13 __attribute__((availability(macosx,introduced=10.4,deprecated=10.13))) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_4 __attribute__((availability(macosx,introduced=10.4,deprecated=10.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_5 __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_6 __attribute__((availability(macosx,introduced=10.4,deprecated=10.6))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.6,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.6))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_7 __attribute__((availability(macosx,introduced=10.4,deprecated=10.7))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.7,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.7))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_8 __attribute__((availability(macosx,introduced=10.4,deprecated=10.8))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.8,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.8))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.4,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.4,deprecated=10.9))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_5 __attribute__((availability(macosx,introduced=10.5))) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEPRECATED__MAC_10_7 __attribute__((availability(macosx,introduced=10.5.DEPRECATED..MAC.10.7))) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.5,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.5,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.5,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.5,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.5,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.5,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.5,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.5,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.5,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.5,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.5,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.5,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_5 __attribute__((availability(macosx,introduced=10.5,deprecated=10.5))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.5,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.5))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_6 __attribute__((availability(macosx,introduced=10.5,deprecated=10.6))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.6,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.6))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_7 __attribute__((availability(macosx,introduced=10.5,deprecated=10.7))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.7,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.7))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_8 __attribute__((availability(macosx,introduced=10.5,deprecated=10.8))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.8,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.8))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.5,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.5,deprecated=10.9))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.5))) + #define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.5))) + #define __AVAILABILITY_INTERNAL__MAC_10_6 __attribute__((availability(macosx,introduced=10.6))) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.6,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.6,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.6,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.6,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.6,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.6,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.6,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.6,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.6,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.6,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.6,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.6,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13 __attribute__((availability(macosx,introduced=10.6,deprecated=10.13))) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_6 __attribute__((availability(macosx,introduced=10.6,deprecated=10.6))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.6,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.6))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_7 __attribute__((availability(macosx,introduced=10.6,deprecated=10.7))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.7,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.7))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_8 __attribute__((availability(macosx,introduced=10.6,deprecated=10.8))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.8,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.8))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.6,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.6,deprecated=10.9))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.6))) + #define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.6))) + #define __AVAILABILITY_INTERNAL__MAC_10_7 __attribute__((availability(macosx,introduced=10.7))) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.7,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.7,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.7,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.7,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.7,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.7,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.7,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.7,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.7,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.7,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.7,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.7,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_13_2 __attribute__((availability(macosx,introduced=10.7,deprecated=10.13.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_7 __attribute__((availability(macosx,introduced=10.7,deprecated=10.7))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.7,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.7))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_8 __attribute__((availability(macosx,introduced=10.7,deprecated=10.8))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.8,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.8))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.7,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.7,deprecated=10.9))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.7))) + #define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.7))) + #define __AVAILABILITY_INTERNAL__MAC_10_8 __attribute__((availability(macosx,introduced=10.8))) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.8,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.8,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.8,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.8,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.8,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.8,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.8,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.8,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.8,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.8,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.8,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.8,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_13 __attribute__((availability(macosx,introduced=10.8,deprecated=10.13))) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_8 __attribute__((availability(macosx,introduced=10.8,deprecated=10.8))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.8,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.8))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.8,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.8,deprecated=10.9))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.8))) + #define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.8))) + #define __AVAILABILITY_INTERNAL__MAC_10_9 __attribute__((availability(macosx,introduced=10.9))) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.9,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.9,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.9,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.9,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.9,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.9,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.9,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.9,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.9,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.9,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.9,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.9,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_13 __attribute__((availability(macosx,introduced=10.9,deprecated=10.13))) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_14 __attribute__((availability(macosx,introduced=10.9,deprecated=10.14))) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.9,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.9,deprecated=10.9))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.9))) + #define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.9))) + #define __AVAILABILITY_INTERNAL__MAC_10_0 __attribute__((availability(macosx,introduced=10.0))) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 __attribute__((availability(macosx,introduced=10.0,deprecated=10.0))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.0,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.0))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.0,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.0,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.0,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.0,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.0,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.0,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.0,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.0,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.0,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.0,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.0,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.0,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_13 __attribute__((availability(macosx,introduced=10.0,deprecated=10.13))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_2 __attribute__((availability(macosx,introduced=10.0,deprecated=10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_3 __attribute__((availability(macosx,introduced=10.0,deprecated=10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_4 __attribute__((availability(macosx,introduced=10.0,deprecated=10.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_5 __attribute__((availability(macosx,introduced=10.0,deprecated=10.5))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.5,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_5_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.5))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_6 __attribute__((availability(macosx,introduced=10.0,deprecated=10.6))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.6,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_6_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.6))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_7 __attribute__((availability(macosx,introduced=10.0,deprecated=10.7))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.7,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_7_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.7))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_8 __attribute__((availability(macosx,introduced=10.0,deprecated=10.8))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.8,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_8_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.8))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_9 __attribute__((availability(macosx,introduced=10.0,deprecated=10.9))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.9,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_9_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.9))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_13_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.13,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_13_MSG(_msg) __attribute__((availability(macosx,introduced=10.0,deprecated=10.13))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.0))) + #define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.0))) + #define __AVAILABILITY_INTERNAL__MAC_10_1 __attribute__((availability(macosx,introduced=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_10 __attribute__((availability(macosx,introduced=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.10.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.10.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.10.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_2_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.10.3))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.10.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.10.3))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_3_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.10.3))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.10,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10 __attribute__((availability(macosx,introduced=10.10,deprecated=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_2 __attribute__((availability(macosx,introduced=10.10,deprecated=10.10.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.10.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.10.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_3 __attribute__((availability(macosx,introduced=10.10,deprecated=10.10.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.10.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.10.3))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.10,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_10_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.10))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.10,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.10,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.10,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.10,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.10,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.10,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.10,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.10,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_13 __attribute__((availability(macosx,introduced=10.10,deprecated=10.13))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_13_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.13,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_13_MSG(_msg) __attribute__((availability(macosx,introduced=10.10,deprecated=10.13))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_13_4 __attribute__((availability(macosx,introduced=10.10,deprecated=10.13.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.10))) + #define __AVAILABILITY_INTERNAL__MAC_10_11 __attribute__((availability(macosx,introduced=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.11.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.11.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.11.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_2_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.11.3))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.11.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.11.3))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_3_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.3))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.11.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.11.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.11.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_4_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.11.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_1 __attribute__((availability(macosx,introduced=10.11,deprecated=10.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11 __attribute__((availability(macosx,introduced=10.11,deprecated=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_2 __attribute__((availability(macosx,introduced=10.11,deprecated=10.11.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.11.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.11.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_3 __attribute__((availability(macosx,introduced=10.11,deprecated=10.11.3))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.11.3,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_3_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.11.3))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_4 __attribute__((availability(macosx,introduced=10.11,deprecated=10.11.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.11.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.11.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.11,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.11))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.11,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.11,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.11,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.11,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.11,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.11))) + #define __AVAILABILITY_INTERNAL__MAC_10_12 __attribute__((availability(macosx,introduced=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.12.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.12.1,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.1,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.1,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.12.1,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.1,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.1,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.12.1,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.1,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.1,deprecated=10.12.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.12.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_1_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.1))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.12.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.12.2,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.2,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.2,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.12.2,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.2,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.2,deprecated=10.12.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.12.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_2_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.2))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.12.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_4_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.12.4,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_4_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.4,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_4_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.4,deprecated=10.12.4))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_4_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.12.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_4_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.12.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12 __attribute__((availability(macosx,introduced=10.12,deprecated=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_1 __attribute__((availability(macosx,introduced=10.12,deprecated=10.12.1))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.12.1,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_1_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.12.1))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_2 __attribute__((availability(macosx,introduced=10.12,deprecated=10.12.2))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.12.2,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_2_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.12.2))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_4 __attribute__((availability(macosx,introduced=10.12,deprecated=10.12.4))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.12.4,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_4_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.12.4))) + #endif + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.12,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_12_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.12))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_13 __attribute__((availability(macosx,introduced=10.12,deprecated=10.13))) + #if __has_feature(attribute_availability_with_message) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_13_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.13,message=_msg))) + #else + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_13_MSG(_msg) __attribute__((availability(macosx,introduced=10.12,deprecated=10.13))) + #endif + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_13_4 __attribute__((availability(macosx,introduced=10.12,deprecated=10.13.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_10_14 __attribute__((availability(macosx,introduced=10.12,deprecated=10.14))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_NA __attribute__((availability(macosx,introduced=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_12_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,introduced=10.12))) + #define __AVAILABILITY_INTERNAL__MAC_10_13 __attribute__((availability(macosx,introduced=10.13))) + #define __AVAILABILITY_INTERNAL__MAC_10_13_4 __attribute__((availability(macosx,introduced=10.13.4))) + #define __AVAILABILITY_INTERNAL__MAC_10_14 __attribute__((availability(macosx,introduced=10.14))) + #define __AVAILABILITY_INTERNAL__MAC_10_14_DEP__MAC_10_14 __attribute__((availability(macosx,introduced=10.14,deprecated=10.14))) + #define __AVAILABILITY_INTERNAL__MAC_10_15 __attribute__((availability(macosx,introduced=10.15))) + + #define __AVAILABILITY_INTERNAL__MAC_NA __attribute__((availability(macosx,unavailable))) + #define __AVAILABILITY_INTERNAL__MAC_NA_DEP__MAC_NA __attribute__((availability(macosx,unavailable))) + #define __AVAILABILITY_INTERNAL__MAC_NA_DEP__MAC_NA_MSG(_msg) __attribute__((availability(macosx,unavailable))) + + #define __AVAILABILITY_INTERNAL__IPHONE_NA __attribute__((availability(ios,unavailable))) + #define __AVAILABILITY_INTERNAL__IPHONE_NA__IPHONE_NA __attribute__((availability(ios,unavailable))) + #define __AVAILABILITY_INTERNAL__IPHONE_NA_DEP__IPHONE_NA __attribute__((availability(ios,unavailable))) + #define __AVAILABILITY_INTERNAL__IPHONE_NA_DEP__IPHONE_NA_MSG(_msg) __attribute__((availability(ios,unavailable))) + + #ifndef __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION __attribute__((availability(ios,unavailable))) + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION __attribute__((availability(ios,unavailable))) + #define __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION_DEP__IPHONE_COMPAT_VERSION_MSG(_msg) __attribute__((availability(ios,unavailable))) + #endif /* __AVAILABILITY_INTERNAL__IPHONE_COMPAT_VERSION */ + #endif + #endif +#endif /* __ENABLE_LEGACY_MAC_AVAILABILITY */ + +/* + Macros for defining which versions/platform a given symbol can be used. + + @see http://clang.llvm.org/docs/AttributeReference.html#availability + */ + +#if defined(__has_feature) && defined(__has_attribute) + #if __has_attribute(availability) + + + #define __API_AVAILABLE_PLATFORM_macos(x) macos,introduced=x + #define __API_AVAILABLE_PLATFORM_macosx(x) macosx,introduced=x + #define __API_AVAILABLE_PLATFORM_ios(x) ios,introduced=x + #define __API_AVAILABLE_PLATFORM_watchos(x) watchos,introduced=x + #define __API_AVAILABLE_PLATFORM_tvos(x) tvos,introduced=x + + #define __API_AVAILABLE_PLATFORM_macCatalyst(x) macCatalyst,introduced=x + #define __API_AVAILABLE_PLATFORM_macCatalyst(x) macCatalyst,introduced=x + #ifndef __API_AVAILABLE_PLATFORM_uikitformac + #define __API_AVAILABLE_PLATFORM_uikitformac(x) uikitformac,introduced=x + #endif + #define __API_AVAILABLE_PLATFORM_driverkit(x) driverkit,introduced=x + + #if defined(__has_attribute) + #if __has_attribute(availability) + #define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x))) + #else + #define __API_A(x) + #endif + #else + #define __API_A(x) + #endif + + #define __API_AVAILABLE1(x) __API_A(x) + #define __API_AVAILABLE2(x,y) __API_A(x) __API_A(y) + #define __API_AVAILABLE3(x,y,z) __API_A(x) __API_A(y) __API_A(z) + #define __API_AVAILABLE4(x,y,z,t) __API_A(x) __API_A(y) __API_A(z) __API_A(t) + #define __API_AVAILABLE5(x,y,z,t,b) __API_A(x) __API_A(y) __API_A(z) __API_A(t) __API_A(b) + #define __API_AVAILABLE6(x,y,z,t,b,m) __API_A(x) __API_A(y) __API_A(z) __API_A(t) __API_A(b) __API_A(m) + #define __API_AVAILABLE7(x,y,z,t,b,m,d) __API_A(x) __API_A(y) __API_A(z) __API_A(t) __API_A(b) __API_A(m) __API_A(d) + #define __API_AVAILABLE_GET_MACRO(_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME + + #define __API_APPLY_TO any(record, enum, enum_constant, function, objc_method, objc_category, objc_protocol, objc_interface, objc_property, type_alias, variable, field) + #define __API_RANGE_STRINGIFY(x) __API_RANGE_STRINGIFY2(x) + #define __API_RANGE_STRINGIFY2(x) #x + + #define __API_A_BEGIN(x) _Pragma(__API_RANGE_STRINGIFY (clang attribute (__attribute__((availability(__API_AVAILABLE_PLATFORM_##x))), apply_to = __API_APPLY_TO))) + + #define __API_AVAILABLE_BEGIN1(a) __API_A_BEGIN(a) + #define __API_AVAILABLE_BEGIN2(a,b) __API_A_BEGIN(a) __API_A_BEGIN(b) + #define __API_AVAILABLE_BEGIN3(a,b,c) __API_A_BEGIN(a) __API_A_BEGIN(b) __API_A_BEGIN(c) + #define __API_AVAILABLE_BEGIN4(a,b,c,d) __API_A_BEGIN(a) __API_A_BEGIN(b) __API_A_BEGIN(c) __API_A_BEGIN(d) + #define __API_AVAILABLE_BEGIN5(a,b,c,d,e) __API_A_BEGIN(a) __API_A_BEGIN(b) __API_A_BEGIN(c) __API_A_BEGIN(d) __API_A_BEGIN(e) + #define __API_AVAILABLE_BEGIN6(a,b,c,d,e,f) __API_A_BEGIN(a) __API_A_BEGIN(b) __API_A_BEGIN(c) __API_A_BEGIN(d) __API_A_BEGIN(e) __API_A_BEGIN(f) + #define __API_AVAILABLE_BEGIN7(a,b,c,d,e,f,g) __API_A_BEGIN(a) __API_A_BEGIN(b) __API_A_BEGIN(c) __API_A_BEGIN(d) __API_A_BEGIN(e) __API_A_BEGIN(f) __API_A_BEGIN(g) + #define __API_AVAILABLE_BEGIN_GET_MACRO(_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME + + + #define __API_DEPRECATED_PLATFORM_macos(x,y) macos,introduced=x,deprecated=y + #define __API_DEPRECATED_PLATFORM_macosx(x,y) macosx,introduced=x,deprecated=y + #define __API_DEPRECATED_PLATFORM_ios(x,y) ios,introduced=x,deprecated=y + #define __API_DEPRECATED_PLATFORM_watchos(x,y) watchos,introduced=x,deprecated=y + #define __API_DEPRECATED_PLATFORM_tvos(x,y) tvos,introduced=x,deprecated=y + + #define __API_DEPRECATED_PLATFORM_macCatalyst(x,y) macCatalyst,introduced=x,deprecated=y + #define __API_DEPRECATED_PLATFORM_macCatalyst(x,y) macCatalyst,introduced=x,deprecated=y + #ifndef __API_DEPRECATED_PLATFORM_uikitformac + #define __API_DEPRECATED_PLATFORM_uikitformac(x) uikitformac,introduced=x,deprecated=y + #endif + #define __API_DEPRECATED_PLATFORM_driverkit(x,y) driverkit,introduced=x,deprecated=y + + #if defined(__has_attribute) + #if __has_attribute(availability) + #define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg))) + #else + #define __API_D(msg,x) + #endif + #else + #define __API_D(msg,x) + #endif + + #define __API_DEPRECATED_MSG2(msg,x) __API_D(msg,x) + #define __API_DEPRECATED_MSG3(msg,x,y) __API_D(msg,x) __API_D(msg,y) + #define __API_DEPRECATED_MSG4(msg,x,y,z) __API_DEPRECATED_MSG3(msg,x,y) __API_D(msg,z) + #define __API_DEPRECATED_MSG5(msg,x,y,z,t) __API_DEPRECATED_MSG4(msg,x,y,z) __API_D(msg,t) + #define __API_DEPRECATED_MSG6(msg,x,y,z,t,b) __API_DEPRECATED_MSG5(msg,x,y,z,t) __API_D(msg,b) + #define __API_DEPRECATED_MSG7(msg,x,y,z,t,b,m) __API_DEPRECATED_MSG6(msg,x,y,z,t,b) __API_D(msg,m) + #define __API_DEPRECATED_MSG8(msg,x,y,z,t,b,m,d) __API_DEPRECATED_MSG7(msg,x,y,z,t,b,m) __API_D(msg,d) + #define __API_DEPRECATED_MSG_GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME + + #define __API_D_BEGIN(msg, x) _Pragma(__API_RANGE_STRINGIFY (clang attribute (__attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg))), apply_to = __API_APPLY_TO))) + + #define __API_DEPRECATED_BEGIN_MSG2(msg,a) __API_D_BEGIN(msg,a) + #define __API_DEPRECATED_BEGIN_MSG3(msg,a,b) __API_D_BEGIN(msg,a) __API_D_BEGIN(msg,b) + #define __API_DEPRECATED_BEGIN_MSG4(msg,a,b,c) __API_D_BEGIN(msg,a) __API_D_BEGIN(msg,b) __API_D_BEGIN(msg,c) + #define __API_DEPRECATED_BEGIN_MSG5(msg,a,b,c,d) __API_D_BEGIN(msg,a) __API_D_BEGIN(msg,b) __API_D_BEGIN(msg,c) __API_D_BEGIN(msg,d) + #define __API_DEPRECATED_BEGIN_MSG6(msg,a,b,c,d,e) __API_D_BEGIN(msg,a) __API_D_BEGIN(msg,b) __API_D_BEGIN(msg,c) __API_D_BEGIN(msg,d) __API_D_BEGIN(msg,e) + #define __API_DEPRECATED_BEGIN_MSG7(msg,a,b,c,d,e,f) __API_D_BEGIN(msg,a) __API_D_BEGIN(msg,b) __API_D_BEGIN(msg,c) __API_D_BEGIN(msg,d) __API_D_BEGIN(msg,e) __API_D_BEGIN(msg,f) + #define __API_DEPRECATED_BEGIN_MSG8(msg,a,b,c,d,e,f,g) __API_D_BEGIN(msg,a) __API_D_BEGIN(msg,b) __API_D_BEGIN(msg,c) __API_D_BEGIN(msg,d) __API_D_BEGIN(msg,e) __API_D_BEGIN(msg,f) __API_D_BEGIN(msg,g) + #define __API_DEPRECATED_BEGIN_MSG_GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME + + #if __has_feature(attribute_availability_with_replacement) + #define __API_R(rep,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,replacement=rep))) + #else + #define __API_R(rep,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x))) + #endif + + #define __API_DEPRECATED_REP2(rep,x) __API_R(rep,x) + #define __API_DEPRECATED_REP3(rep,x,y) __API_R(rep,x) __API_R(rep,y) + #define __API_DEPRECATED_REP4(rep,x,y,z) __API_DEPRECATED_REP3(rep,x,y) __API_R(rep,z) + #define __API_DEPRECATED_REP5(rep,x,y,z,t) __API_DEPRECATED_REP4(rep,x,y,z) __API_R(rep,t) + #define __API_DEPRECATED_REP6(rep,x,y,z,t,b) __API_DEPRECATED_REP5(rep,x,y,z,t) __API_R(rep,b) + #define __API_DEPRECATED_REP7(rep,x,y,z,t,b,m) __API_DEPRECATED_REP6(rep,x,y,z,t,b) __API_R(rep,m) + #define __API_DEPRECATED_REP8(rep,x,y,z,t,b,m,d) __API_DEPRECATED_REP7(rep,x,y,z,t,b,m) __API_R(rep,d) + #define __API_DEPRECATED_REP_GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME + + #if __has_feature(attribute_availability_with_replacement) + #define __API_R_BEGIN(rep,x) _Pragma(__API_RANGE_STRINGIFY (clang attribute (__attribute__((availability(__API_DEPRECATED_PLATFORM_##x,replacement=rep))), apply_to = __API_APPLY_TO))) + #else + #define __API_R_BEGIN(rep,x) _Pragma(__API_RANGE_STRINGIFY (clang attribute (__attribute__((availability(__API_DEPRECATED_PLATFORM_##x))), apply_to = __API_APPLY_TO))) + #endif + + #define __API_DEPRECATED_BEGIN_REP2(rep,a) __API_R_BEGIN(rep,a) + #define __API_DEPRECATED_BEGIN_REP3(rep,a,b) __API_R_BEGIN(rep,a) __API_R_BEGIN(rep,b) + #define __API_DEPRECATED_BEGIN_REP4(rep,a,b,c) __API_R_BEGIN(rep,a) __API_R_BEGIN(rep,b) __API_R_BEGIN(rep,c) + #define __API_DEPRECATED_BEGIN_REP5(rep,a,b,c,d) __API_R_BEGIN(rep,a) __API_R_BEGIN(rep,b) __API_R_BEGIN(rep,c) __API_R_BEGIN(rep,d) + #define __API_DEPRECATED_BEGIN_REP6(rep,a,b,c,d,e) __API_R_BEGIN(rep,a) __API_R_BEGIN(rep,b) __API_R_BEGIN(rep,c) __API_R_BEGIN(rep,d) __API_R_BEGIN(rep,e) + #define __API_DEPRECATED_BEGIN_REP7(rep,a,b,c,d,e,f) __API_R_BEGIN(rep,a) __API_R_BEGIN(rep,b) __API_R_BEGIN(rep,c) __API_R_BEGIN(rep,d) __API_R_BEGIN(rep,e) __API_R_BEGIN(rep,f) + #define __API_DEPRECATED_BEGIN_REP8(rep,a,b,c,d,e,f,g) __API_R_BEGIN(rep,a) __API_R_BEGIN(rep,b) __API_R_BEGIN(rep,c) __API_R_BEGIN(rep,d) __API_R_BEGIN(rep,e) __API_R_BEGIN(rep,f) __API_R_BEGIN(rep,g) + #define __API_DEPRECATED_BEGIN_REP_GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME + + /* + * 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_PLATFORM_macos macos,unavailable + #define __API_UNAVAILABLE_PLATFORM_macosx macosx,unavailable + #define __API_UNAVAILABLE_PLATFORM_ios ios,unavailable + #define __API_UNAVAILABLE_PLATFORM_watchos watchos,unavailable + #define __API_UNAVAILABLE_PLATFORM_tvos tvos,unavailable + + #define __API_UNAVAILABLE_PLATFORM_macCatalyst macCatalyst,unavailable + #define __API_UNAVAILABLE_PLATFORM_macCatalyst macCatalyst,unavailable + #ifndef __API_UNAVAILABLE_PLATFORM_uikitformac + #define __API_UNAVAILABLE_PLATFORM_uikitformac(x) uikitformac,unavailable + #endif + #define __API_UNAVAILABLE_PLATFORM_driverkit driverkit,unavailable + + #if defined(__has_attribute) + #if __has_attribute(availability) + #define __API_U(x) __attribute__((availability(__API_UNAVAILABLE_PLATFORM_##x))) + #else + #define __API_U(x) + #endif + #else + #define __API_U(x) + #endif + + #define __API_UNAVAILABLE1(x) __API_U(x) + #define __API_UNAVAILABLE2(x,y) __API_U(x) __API_U(y) + #define __API_UNAVAILABLE3(x,y,z) __API_UNAVAILABLE2(x,y) __API_U(z) + #define __API_UNAVAILABLE4(x,y,z,t) __API_UNAVAILABLE3(x,y,z) __API_U(t) + #define __API_UNAVAILABLE5(x,y,z,t,b) __API_UNAVAILABLE4(x,y,z,t) __API_U(b) + #define __API_UNAVAILABLE6(x,y,z,t,b,m) __API_UNAVAILABLE5(x,y,z,t,b) __API_U(m) + #define __API_UNAVAILABLE7(x,y,z,t,b,m,d) __API_UNAVAILABLE6(x,y,z,t,b,m) __API_U(d) + #define __API_UNAVAILABLE_GET_MACRO(_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME + + #define __API_U_BEGIN(x) _Pragma(__API_RANGE_STRINGIFY (clang attribute (__attribute__((availability(__API_UNAVAILABLE_PLATFORM_##x))), apply_to = __API_APPLY_TO))) + + #define __API_UNAVAILABLE_BEGIN1(a) __API_U_BEGIN(a) + #define __API_UNAVAILABLE_BEGIN2(a,b) __API_U_BEGIN(a) __API_U_BEGIN(b) + #define __API_UNAVAILABLE_BEGIN3(a,b,c) __API_U_BEGIN(a) __API_U_BEGIN(b) __API_U_BEGIN(c) + #define __API_UNAVAILABLE_BEGIN4(a,b,c,d) __API_U_BEGIN(a) __API_U_BEGIN(b) __API_U_BEGIN(c) __API_U_BEGIN(d) + #define __API_UNAVAILABLE_BEGIN5(a,b,c,d,e) __API_U_BEGIN(a) __API_U_BEGIN(b) __API_U_BEGIN(c) __API_U_BEGIN(d) __API_U_BEGIN(e) + #define __API_UNAVAILABLE_BEGIN6(a,b,c,d,e,f) __API_U_BEGIN(a) __API_U_BEGIN(b) __API_U_BEGIN(c) __API_U_BEGIN(d) __API_U_BEGIN(e) __API_U_BEGIN(f) + #define __API_UNAVAILABLE_BEGIN7(a,b,c,d,e,f) __API_U_BEGIN(a) __API_U_BEGIN(b) __API_U_BEGIN(c) __API_U_BEGIN(d) __API_U_BEGIN(e) __API_U_BEGIN(f) __API_U_BEGIN(g) + #define __API_UNAVAILABLE_BEGIN_GET_MACRO(_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME + #else + + /* + * Evaluate to nothing for compilers that don't support availability. + */ + + #define __API_AVAILABLE_GET_MACRO(...) + #define __API_AVAILABLE_BEGIN_GET_MACRO(...) + #define __API_DEPRECATED_MSG_GET_MACRO(...) + #define __API_DEPRECATED_REP_GET_MACRO(...) + #define __API_DEPRECATED_BEGIN_MSG_GET_MACRO(...) + #define __API_DEPRECATED_BEGIN_REP_GET_MACRO + #define __API_UNAVAILABLE_GET_MACRO(...) + #define __API_UNAVAILABLE_BEGIN_GET_MACRO(...) + #endif /* __has_attribute(availability) */ +#else + + /* + * Evaluate to nothing for compilers that don't support clang language extensions. + */ + + #define __API_AVAILABLE_GET_MACRO(...) + #define __API_AVAILABLE_BEGIN_GET_MACRO(...) + #define __API_DEPRECATED_MSG_GET_MACRO(...) + #define __API_DEPRECATED_REP_GET_MACRO(...) + #define __API_DEPRECATED_BEGIN_MSG_GET_MACRO(...) + #define __API_DEPRECATED_BEGIN_REP_GET_MACRO + #define __API_UNAVAILABLE_GET_MACRO(...) + #define __API_UNAVAILABLE_BEGIN_GET_MACRO(...) +#endif /* #if defined(__has_feature) && defined(__has_attribute) */ + +/* + * Swift compiler version + * Allows for project-agnostic “epochs” for frameworks imported into Swift via the Clang importer, like #if _compiler_version for Swift + * Example: + * + * #if __swift_compiler_version_at_least(800, 2, 20) + * - (nonnull NSString *)description; + * #else + * - (NSString *)description; + * #endif + */ + +#ifdef __SWIFT_COMPILER_VERSION + #define __swift_compiler_version_at_least_impl(X, Y, Z, a, b, ...) \ + __SWIFT_COMPILER_VERSION >= ((X * UINT64_C(1000) * 1000 * 1000) + (Z * 1000 * 1000) + (a * 1000) + b) + #define __swift_compiler_version_at_least(...) __swift_compiler_version_at_least_impl(__VA_ARGS__, 0, 0, 0, 0) +#else + #define __swift_compiler_version_at_least(...) 1 +#endif + +/* + * If __SPI_AVAILABLE has not been defined elsewhere, disable it. + */ + +#ifndef __SPI_AVAILABLE + #define __SPI_AVAILABLE(...) +#endif + +#endif /* __AVAILABILITY_INTERNAL__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/AvailabilityMacros.h b/lib/libc/include/aarch64-macos-gnu/AvailabilityMacros.h new file mode 100644 index 0000000000..bd044a2a03 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/AvailabilityMacros.h @@ -0,0 +1,4013 @@ +/* + * Copyright (c) 2001-2010 by 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@ + */ + +/* + File: AvailabilityMacros.h + + More Info: See the SDK Compatibility Guide + + Contains: Autoconfiguration of AVAILABLE_ macros for Mac OS X + + This header enables a developer to specify build time + constraints on what Mac OS X versions the resulting + application will be run. There are two bounds a developer + can specify: + + MAC_OS_X_VERSION_MIN_REQUIRED + MAC_OS_X_VERSION_MAX_ALLOWED + + The lower bound controls which calls to OS functions will + be weak-importing (allowed to be unresolved at launch time). + The upper bound controls which OS functionality, if used, + will result in a compiler error because that functionality is + not available on any OS in the specifed range. + + For example, suppose an application is compiled with: + + MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_2 + MAC_OS_X_VERSION_MAX_ALLOWED = MAC_OS_X_VERSION_10_3 + + and an OS header contains: + + extern void funcA(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; + extern void funcB(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2; + extern void funcC(void) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3; + extern void funcD(void) AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER; + extern void funcE(void) AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER; + extern void funcF(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; + extern void funcG(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER; + + typedef long TypeA DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER; + typedef long TypeB DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER; + typedef long TypeC DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER; + typedef long TypeD DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER; + typedef long TypeE DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER; + + Any application code which uses these declarations will get the following: + + compile link run + ------- ------ ------- + funcA: normal normal normal + funcB: warning normal normal + funcC: normal normal normal + funcD: normal normal normal + funcE: normal normal normal + funcF: normal weak on 10.3 normal, on 10.2 (&funcF == NULL) + funcG: error error n/a + typeA: warning + typeB: warning + typeC: warning + typeD: normal + typeE: normal + + +*/ +#ifndef __AVAILABILITYMACROS__ +#define __AVAILABILITYMACROS__ + +/* + * Set up standard Mac OS X versions + */ +#define MAC_OS_X_VERSION_10_0 1000 +#define MAC_OS_X_VERSION_10_1 1010 +#define MAC_OS_X_VERSION_10_2 1020 +#define MAC_OS_X_VERSION_10_3 1030 +#define MAC_OS_X_VERSION_10_4 1040 +#define MAC_OS_X_VERSION_10_5 1050 +#define MAC_OS_X_VERSION_10_6 1060 +#define MAC_OS_X_VERSION_10_7 1070 +#define MAC_OS_X_VERSION_10_8 1080 +#define MAC_OS_X_VERSION_10_9 1090 +#define MAC_OS_X_VERSION_10_10 101000 +#define MAC_OS_X_VERSION_10_10_2 101002 +#define MAC_OS_X_VERSION_10_10_3 101003 +#define MAC_OS_X_VERSION_10_11 101100 +#define MAC_OS_X_VERSION_10_11_2 101102 +#define MAC_OS_X_VERSION_10_11_3 101103 +#define MAC_OS_X_VERSION_10_11_4 101104 +#define MAC_OS_X_VERSION_10_12 101200 +#define MAC_OS_X_VERSION_10_12_1 101201 +#define MAC_OS_X_VERSION_10_12_2 101202 +#define MAC_OS_X_VERSION_10_12_4 101204 +#define MAC_OS_X_VERSION_10_13 101300 +#define MAC_OS_X_VERSION_10_13_1 101301 +#define MAC_OS_X_VERSION_10_13_2 101302 +#define MAC_OS_X_VERSION_10_13_4 101304 +#define MAC_OS_X_VERSION_10_14 101400 +#define MAC_OS_X_VERSION_10_14_1 101401 +#define MAC_OS_X_VERSION_10_14_4 101404 +#define MAC_OS_X_VERSION_10_15 101500 +#define MAC_OS_VERSION_11_0 110000 + +/* + * If min OS not specified, assume 10.4 for intel + * Note: compiler driver may set _ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED_ based on MACOSX_DEPLOYMENT_TARGET environment variable + */ +#ifndef MAC_OS_X_VERSION_MIN_REQUIRED + #ifdef __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + #if (__i386__ || __x86_64__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < MAC_OS_X_VERSION_10_4) + #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid. + #endif + #define MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + #else + #if __i386__ || __x86_64__ + #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 + #elif __arm__ || __arm64__ + #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_5 + #else + #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_1 + #endif + #endif +#endif + +/* + * if max OS not specified, assume larger of (10.15, min) + */ +#ifndef MAC_OS_X_VERSION_MAX_ALLOWED + #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_VERSION_11_0 + #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_MIN_REQUIRED + #else + #define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_VERSION_11_0 + #endif +#endif + +/* + * Error on bad values + */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_MIN_REQUIRED + #error MAC_OS_X_VERSION_MAX_ALLOWED must be >= MAC_OS_X_VERSION_MIN_REQUIRED +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_0 + #error MAC_OS_X_VERSION_MIN_REQUIRED must be >= MAC_OS_X_VERSION_10_0 +#endif + +/* + * only certain compilers support __attribute__((weak_import)) + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1020) + #define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import)) +#elif defined(__MWERKS__) && (__MWERKS__ >= 0x3205) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1020) && !defined(__INTEL__) + #define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import)) +#else + #define WEAK_IMPORT_ATTRIBUTE +#endif + +/* + * only certain compilers support __attribute__((deprecated)) + */ +#if defined(__has_feature) && defined(__has_attribute) + #if __has_attribute(deprecated) + #define DEPRECATED_ATTRIBUTE __attribute__((deprecated)) + #if __has_feature(attribute_deprecated_with_message) + #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s))) + #else + #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated)) + #endif + #else + #define DEPRECATED_ATTRIBUTE + #define DEPRECATED_MSG_ATTRIBUTE(s) + #endif +#elif defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) + #define DEPRECATED_ATTRIBUTE __attribute__((deprecated)) + #if (__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) + #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated(s))) + #else + #define DEPRECATED_MSG_ATTRIBUTE(s) __attribute__((deprecated)) + #endif +#else + #define DEPRECATED_ATTRIBUTE + #define DEPRECATED_MSG_ATTRIBUTE(s) +#endif + +/* + * only certain compilers support __attribute__((unavailable)) + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) + #define UNAVAILABLE_ATTRIBUTE __attribute__((unavailable)) +#else + #define UNAVAILABLE_ATTRIBUTE +#endif + + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER + * + * Used on functions introduced in Mac OS X 10.0 + */ +#define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED + * + * Used on functions introduced in Mac OS X 10.0, + * and deprecated in Mac OS X 10.0 + */ +#define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER + * + * Used on types deprecated in Mac OS X 10.0 + */ +#define DEPRECATED_IN_MAC_OS_X_VERSION_10_0_AND_LATER DEPRECATED_ATTRIBUTE + +#ifndef __AVAILABILITY_MACROS_USES_AVAILABILITY + #ifdef __has_attribute + #if __has_attribute(availability) + #include + #define __AVAILABILITY_MACROS_USES_AVAILABILITY 1 + #endif + #endif +#endif + +#if TARGET_OS_OSX +#define __IPHONE_COMPAT_VERSION __IPHONE_NA +#elif TARGET_OS_MACCATALYST +#define __IPHONE_COMPAT_VERSION __IPHONE_NA +#else +#define __IPHONE_COMPAT_VERSION __IPHONE_4_0 +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_1, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.1, + * and deprecated in Mac OS X 10.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_1 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.2, + * and deprecated in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_2 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.3, + * and deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_3 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_4, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.4, + * and deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_4 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.5, + * and deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.6, + * and deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_6 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.7, + * and deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_7 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.13 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY +#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_13, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 DEPRECATED_ATTRIBUTE +#else +#define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_13 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.8, + * and deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.9, + * and deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.10, + * and deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_10_2, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.10.2, + * and deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_2 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_10_3, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.10.3, + * and deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_10_3 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.11, + * and deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11_2, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.11.2, + * and deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.11.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_2 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11_3, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.11.3, + * and deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.11.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_11_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_3 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_3 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_11_4, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.11.4, + * and deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.11.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_11_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_11_4 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.12, + * and deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 + * + * Used on declarations introduced in Mac OS X 10.11.4, + * but later deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12 AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.12.1, + * and deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_1, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.11.4, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 + * + * Used on declarations introduced in Mac OS X 10.12, + * but later deprecated in Mac OS X 10.12.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_1 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_1 AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12_2, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.12.2, + * and deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.11.4, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.12, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 + * + * Used on declarations introduced in Mac OS X 10.12.1, + * but later deprecated in Mac OS X 10.12.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_1, __MAC_10_12_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_2 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_2 AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_12_4, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED + * + * Used on declarations introduced in Mac OS X 10.12.4, + * and deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_4, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER_BUT_DEPRECATED AVAILABLE_MAC_OS_X_VERSION_10_12_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.0, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.1, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_1, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.2, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.3, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.4, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.5, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.6, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_6, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.7, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_7, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.8, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_8, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.9, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_9, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.10, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.10.2, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_10_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.10.3, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_10_3, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_10_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.11, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.11.2, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_11_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.11.3, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_3, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_11_3_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.11.4, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_11_4, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_11_4_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.12, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.12.1, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_1, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_12_1_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 + * + * Used on declarations introduced in Mac OS X 10.12.2, + * but later deprecated in Mac OS X 10.12.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_12_2, __MAC_10_12_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12_4 + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 DEPRECATED_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_12_4 AVAILABLE_MAC_OS_X_VERSION_10_12_2_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.13 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_13, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13 + #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13 + #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.14 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_14, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_14 + #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_14 + #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_14_AND_LATER +#endif + +/* + * AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER + * + * Used on declarations introduced in Mac OS X 10.15 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER __OSX_AVAILABLE_STARTING(__MAC_10_15, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_15 + #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER UNAVAILABLE_ATTRIBUTE +#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_15 + #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER WEAK_IMPORT_ATTRIBUTE +#else + #define AVAILABLE_MAC_OS_X_VERSION_10_15_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER + * + * Used on types deprecated in Mac OS X 10.1 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_1, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_1 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_1_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER + * + * Used on types deprecated in Mac OS X 10.2 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_2, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_2 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_2_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER + * + * Used on types deprecated in Mac OS X 10.3 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_3, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_3_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER + * + * Used on types deprecated in Mac OS X 10.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_4_AND_LATER +#endif + + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER + * + * Used on types deprecated in Mac OS X 10.5 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_5, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER + * + * Used on types deprecated in Mac OS X 10.6 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_6_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER + * + * Used on types deprecated in Mac OS X 10.7 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER + * + * Used on types deprecated in Mac OS X 10.8 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_8_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER + * + * Used on types deprecated in Mac OS X 10.9 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_9_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER + * + * Used on types deprecated in Mac OS X 10.10 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_10, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_10_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER + * + * Used on types deprecated in Mac OS X 10.11 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_11, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_11_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER + * + * Used on types deprecated in Mac OS X 10.12 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_12, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_12_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER + * + * Used on types deprecated in Mac OS X 10.13 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_13, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_13_AND_LATER +#endif + +/* + * DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER + * + * Used on types deprecated in Mac OS X 10.14.4 + */ +#if __AVAILABILITY_MACROS_USES_AVAILABILITY + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_14_4, __IPHONE_COMPAT_VERSION, __IPHONE_COMPAT_VERSION) +#elif MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_14_4 + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER DEPRECATED_ATTRIBUTE +#else + #define DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER +#endif + +#endif /* __AVAILABILITYMACROS__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/AvailabilityVersions.h b/lib/libc/include/aarch64-macos-gnu/AvailabilityVersions.h new file mode 100644 index 0000000000..265379fb61 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/AvailabilityVersions.h @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2019 by 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 __AVAILABILITY_VERSIONS__ +#define __AVAILABILITY_VERSIONS__ + +#define __MAC_10_0 1000 +#define __MAC_10_1 1010 +#define __MAC_10_2 1020 +#define __MAC_10_3 1030 +#define __MAC_10_4 1040 +#define __MAC_10_5 1050 +#define __MAC_10_6 1060 +#define __MAC_10_7 1070 +#define __MAC_10_8 1080 +#define __MAC_10_9 1090 +#define __MAC_10_10 101000 +#define __MAC_10_10_2 101002 +#define __MAC_10_10_3 101003 +#define __MAC_10_11 101100 +#define __MAC_10_11_2 101102 +#define __MAC_10_11_3 101103 +#define __MAC_10_11_4 101104 +#define __MAC_10_12 101200 +#define __MAC_10_12_1 101201 +#define __MAC_10_12_2 101202 +#define __MAC_10_12_4 101204 +#define __MAC_10_13 101300 +#define __MAC_10_13_1 101301 +#define __MAC_10_13_2 101302 +#define __MAC_10_13_4 101304 +#define __MAC_10_14 101400 +#define __MAC_10_14_1 101401 +#define __MAC_10_14_4 101404 +#define __MAC_10_14_6 101406 +#define __MAC_10_15 101500 +#define __MAC_10_15_1 101501 +#define __MAC_10_15_4 101504 +#define __MAC_10_16 101600 +#define __MAC_11_0 110000 +/* __MAC_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ + +#define __IPHONE_2_0 20000 +#define __IPHONE_2_1 20100 +#define __IPHONE_2_2 20200 +#define __IPHONE_3_0 30000 +#define __IPHONE_3_1 30100 +#define __IPHONE_3_2 30200 +#define __IPHONE_4_0 40000 +#define __IPHONE_4_1 40100 +#define __IPHONE_4_2 40200 +#define __IPHONE_4_3 40300 +#define __IPHONE_5_0 50000 +#define __IPHONE_5_1 50100 +#define __IPHONE_6_0 60000 +#define __IPHONE_6_1 60100 +#define __IPHONE_7_0 70000 +#define __IPHONE_7_1 70100 +#define __IPHONE_8_0 80000 +#define __IPHONE_8_1 80100 +#define __IPHONE_8_2 80200 +#define __IPHONE_8_3 80300 +#define __IPHONE_8_4 80400 +#define __IPHONE_9_0 90000 +#define __IPHONE_9_1 90100 +#define __IPHONE_9_2 90200 +#define __IPHONE_9_3 90300 +#define __IPHONE_10_0 100000 +#define __IPHONE_10_1 100100 +#define __IPHONE_10_2 100200 +#define __IPHONE_10_3 100300 +#define __IPHONE_11_0 110000 +#define __IPHONE_11_1 110100 +#define __IPHONE_11_2 110200 +#define __IPHONE_11_3 110300 +#define __IPHONE_11_4 110400 +#define __IPHONE_12_0 120000 +#define __IPHONE_12_1 120100 +#define __IPHONE_12_2 120200 +#define __IPHONE_12_3 120300 +#define __IPHONE_12_4 120400 +#define __IPHONE_13_0 130000 +#define __IPHONE_13_1 130100 +#define __IPHONE_13_2 130200 +#define __IPHONE_13_3 130300 +#define __IPHONE_13_4 130400 +#define __IPHONE_13_5 130500 +#define __IPHONE_13_6 130600 +#define __IPHONE_13_7 130700 +#define __IPHONE_14_0 140000 +#define __IPHONE_14_1 140100 +#define __IPHONE_14_2 140200 +/* __IPHONE_NA is not defined to a value but is used as a token by macros to indicate that the API is unavailable */ + +#define __TVOS_9_0 90000 +#define __TVOS_9_1 90100 +#define __TVOS_9_2 90200 +#define __TVOS_10_0 100000 +#define __TVOS_10_0_1 100001 +#define __TVOS_10_1 100100 +#define __TVOS_10_2 100200 +#define __TVOS_11_0 110000 +#define __TVOS_11_1 110100 +#define __TVOS_11_2 110200 +#define __TVOS_11_3 110300 +#define __TVOS_11_4 110400 +#define __TVOS_12_0 120000 +#define __TVOS_12_1 120100 +#define __TVOS_12_2 120200 +#define __TVOS_12_3 120300 +#define __TVOS_12_4 120400 +#define __TVOS_13_0 130000 +#define __TVOS_13_2 130200 +#define __TVOS_13_3 130300 +#define __TVOS_13_4 130400 +#define __TVOS_14_0 140000 +#define __TVOS_14_1 140100 +#define __TVOS_14_2 140200 + +#define __WATCHOS_1_0 10000 +#define __WATCHOS_2_0 20000 +#define __WATCHOS_2_1 20100 +#define __WATCHOS_2_2 20200 +#define __WATCHOS_3_0 30000 +#define __WATCHOS_3_1 30100 +#define __WATCHOS_3_1_1 30101 +#define __WATCHOS_3_2 30200 +#define __WATCHOS_4_0 40000 +#define __WATCHOS_4_1 40100 +#define __WATCHOS_4_2 40200 +#define __WATCHOS_4_3 40300 +#define __WATCHOS_5_0 50000 +#define __WATCHOS_5_1 50100 +#define __WATCHOS_5_2 50200 +#define __WATCHOS_5_3 50300 +#define __WATCHOS_6_0 60000 +#define __WATCHOS_6_1 60100 +#define __WATCHOS_6_2 60200 +#define __WATCHOS_7_0 70000 +#define __WATCHOS_7_1 70100 + +/* + * Set up standard Mac OS X versions + */ + +#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) + +#define MAC_OS_X_VERSION_10_0 1000 +#define MAC_OS_X_VERSION_10_1 1010 +#define MAC_OS_X_VERSION_10_2 1020 +#define MAC_OS_X_VERSION_10_3 1030 +#define MAC_OS_X_VERSION_10_4 1040 +#define MAC_OS_X_VERSION_10_5 1050 +#define MAC_OS_X_VERSION_10_6 1060 +#define MAC_OS_X_VERSION_10_7 1070 +#define MAC_OS_X_VERSION_10_8 1080 +#define MAC_OS_X_VERSION_10_9 1090 +#define MAC_OS_X_VERSION_10_10 101000 +#define MAC_OS_X_VERSION_10_10_2 101002 +#define MAC_OS_X_VERSION_10_10_3 101003 +#define MAC_OS_X_VERSION_10_11 101100 +#define MAC_OS_X_VERSION_10_11_2 101102 +#define MAC_OS_X_VERSION_10_11_3 101103 +#define MAC_OS_X_VERSION_10_11_4 101104 +#define MAC_OS_X_VERSION_10_12 101200 +#define MAC_OS_X_VERSION_10_12_1 101201 +#define MAC_OS_X_VERSION_10_12_2 101202 +#define MAC_OS_X_VERSION_10_12_4 101204 +#define MAC_OS_X_VERSION_10_13 101300 +#define MAC_OS_X_VERSION_10_13_1 101301 +#define MAC_OS_X_VERSION_10_13_2 101302 +#define MAC_OS_X_VERSION_10_13_4 101304 +#define MAC_OS_X_VERSION_10_14 101400 +#define MAC_OS_X_VERSION_10_14_1 101401 +#define MAC_OS_X_VERSION_10_14_4 101404 +#define MAC_OS_X_VERSION_10_14_6 101406 +#define MAC_OS_X_VERSION_10_15 101500 +#define MAC_OS_X_VERSION_10_15_1 101501 +#define MAC_OS_X_VERSION_10_16 101600 +#define MAC_OS_VERSION_11_0 110000 + +#endif /* #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) */ + +#define __DRIVERKIT_19_0 190000 +#define __DRIVERKIT_20_0 200000 + +#endif /* __AVAILABILITY_VERSIONS__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/TargetConditionals.h b/lib/libc/include/aarch64-macos-gnu/TargetConditionals.h new file mode 100644 index 0000000000..e0a993f0ec --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/TargetConditionals.h @@ -0,0 +1,508 @@ +/* + * Copyright (c) 2000-2014 by 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@ + */ + +/* + File: TargetConditionals.h + + Contains: Autoconfiguration of TARGET_ conditionals for Mac OS X and iPhone + + Note: TargetConditionals.h in 3.4 Universal Interfaces works + with all compilers. This header only recognizes compilers + known to run on Mac OS X. + +*/ + +#ifndef __TARGETCONDITIONALS__ +#define __TARGETCONDITIONALS__ + +/* + * + * TARGET_CPU_* + * These conditionals specify which microprocessor instruction set is being + * generated. At most one of these is true, the rest are false. + * + * TARGET_CPU_PPC - Compiler is generating PowerPC instructions for 32-bit mode + * TARGET_CPU_PPC64 - Compiler is generating PowerPC instructions for 64-bit mode + * TARGET_CPU_68K - Compiler is generating 680x0 instructions + * TARGET_CPU_X86 - Compiler is generating x86 instructions for 32-bit mode + * TARGET_CPU_X86_64 - Compiler is generating x86 instructions for 64-bit mode + * TARGET_CPU_ARM - Compiler is generating ARM instructions for 32-bit mode + * TARGET_CPU_ARM64 - Compiler is generating ARM instructions for 64-bit mode + * TARGET_CPU_MIPS - Compiler is generating MIPS instructions + * TARGET_CPU_SPARC - Compiler is generating Sparc instructions + * TARGET_CPU_ALPHA - Compiler is generating Dec Alpha instructions + * + * + * TARGET_OS_* + * These conditionals specify in which Operating System the generated code will + * run. Indention is used to show which conditionals are evolutionary subclasses. + * + * The MAC/WIN32/UNIX conditionals are mutually exclusive. + * The IOS/TV/WATCH conditionals are mutually exclusive. + * + * + * TARGET_OS_WIN32 - Generated code will run under 32-bit Windows + * TARGET_OS_UNIX - Generated code will run under some Unix (not OSX) + * TARGET_OS_MAC - Generated code will run under Mac OS X variant + * TARGET_OS_OSX - Generated code will run under OS X devices + * TARGET_OS_IPHONE - Generated code for firmware, devices, or simulator + * TARGET_OS_IOS - Generated code will run under iOS + * TARGET_OS_TV - Generated code will run under Apple TV OS + * TARGET_OS_WATCH - Generated code will run under Apple Watch OS + * TARGET_OS_BRIDGE - Generated code will run under Bridge devices + * TARGET_OS_MACCATALYST - Generated code will run under macOS + * TARGET_OS_SIMULATOR - Generated code will run under a simulator + * + * TARGET_OS_EMBEDDED - DEPRECATED: Use TARGET_OS_IPHONE and/or TARGET_OS_SIMULATOR instead + * TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR + * TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH + * + * +---------------------------------------------------------------------+ + * | TARGET_OS_MAC | + * | +---+ +-----------------------------------------------+ +---------+ | + * | | | | TARGET_OS_IPHONE | | | | + * | | | | +---------------+ +----+ +-------+ +--------+ | | | | + * | | | | | IOS | | | | | | | | | | | + * | |OSX| | |+-------------+| | TV | | WATCH | | BRIDGE | | |DRIVERKIT| | + * | | | | || MACCATALYST || | | | | | | | | | | + * | | | | |+-------------+| | | | | | | | | | | + * | | | | +---------------+ +----+ +-------+ +--------+ | | | | + * | +---+ +-----------------------------------------------+ +---------+ | + * +---------------------------------------------------------------------+ + * + * TARGET_RT_* + * These conditionals specify in which runtime the generated code will + * run. This is needed when the OS and CPU support more than one runtime + * (e.g. Mac OS X supports CFM and mach-o). + * + * TARGET_RT_LITTLE_ENDIAN - Generated code uses little endian format for integers + * TARGET_RT_BIG_ENDIAN - Generated code uses big endian format for integers + * TARGET_RT_64_BIT - Generated code uses 64-bit pointers + * TARGET_RT_MAC_CFM - TARGET_OS_MAC is true and CFM68K or PowerPC CFM (TVectors) are used + * TARGET_RT_MAC_MACHO - TARGET_OS_MAC is true and Mach-O/dlyd runtime is used + */ + + /* + * TARGET_OS conditionals can be enabled via clang preprocessor extensions: + * + * __is_target_arch + * __is_target_vendor + * __is_target_os + * __is_target_environment + * + * “-target=x86_64-apple-ios12-macabi” + * TARGET_OS_MAC=1 + * TARGET_OS_IPHONE=1 + * TARGET_OS_IOS=1 + * TARGET_OS_MACCATALYST=1 + * + * “-target=x86_64-apple-ios12-simulator” + * TARGET_OS_MAC=1 + * TARGET_OS_IPHONE=1 + * TARGET_OS_IOS=1 + * TARGET_OS_SIMULATOR=1 + * + * DYNAMIC_TARGETS_ENABLED indicates that the core TARGET_OS macros were enabled via clang preprocessor extensions. + * If this value is not set, the macro enablements will fall back to the static behavior. + * It is disabled by default. + */ + +#if defined(__has_builtin) + #if __has_builtin(__is_target_arch) + #if __has_builtin(__is_target_vendor) + #if __has_builtin(__is_target_os) + #if __has_builtin(__is_target_environment) + + /* “-target=x86_64-apple-ios12-macabi” */ + /* “-target=arm64-apple-ios12-macabi” */ + /* “-target=arm64e-apple-ios12-macabi” */ + #if (__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(macabi) + #define TARGET_OS_OSX 0 + #define TARGET_OS_IPHONE 1 + #define TARGET_OS_IOS 1 + #define TARGET_OS_WATCH 0 + + #define TARGET_OS_TV 0 + #define TARGET_OS_SIMULATOR 0 + #define TARGET_OS_EMBEDDED 0 + #define TARGET_OS_RTKIT 0 + #define TARGET_OS_MACCATALYST 1 + #define TARGET_OS_MACCATALYST 1 + #ifndef TARGET_OS_UIKITFORMAC + #define TARGET_OS_UIKITFORMAC 1 + #endif + #define TARGET_OS_DRIVERKIT 0 + #define DYNAMIC_TARGETS_ENABLED 1 + #endif + + /* “-target=x86_64-apple-ios12-simulator” */ + #if __is_target_arch(x86_64) && __is_target_vendor(apple) && __is_target_os(ios) && __is_target_environment(simulator) + #define TARGET_OS_OSX 0 + #define TARGET_OS_IPHONE 1 + #define TARGET_OS_IOS 1 + #define TARGET_OS_WATCH 0 + + #define TARGET_OS_TV 0 + #define TARGET_OS_SIMULATOR 1 + #define TARGET_OS_EMBEDDED 0 + #define TARGET_OS_RTKIT 0 + #define TARGET_OS_MACCATALYST 0 + #define TARGET_OS_MACCATALYST 0 + #ifndef TARGET_OS_UIKITFORMAC + #define TARGET_OS_UIKITFORMAC 0 + #endif + #define TARGET_OS_DRIVERKIT 0 + #define DYNAMIC_TARGETS_ENABLED 1 + #endif + + /* -target=x86_64-apple-driverkit19.0 */ + /* -target=arm64-apple-driverkit19.0 */ + /* -target=arm64e-apple-driverkit19.0 */ + #if (__is_target_arch(x86_64) || __is_target_arch(arm64) || __is_target_arch(arm64e)) && __is_target_vendor(apple) && __is_target_os(driverkit) + #define TARGET_OS_OSX 0 + #define TARGET_OS_IPHONE 0 + #define TARGET_OS_IOS 0 + #define TARGET_OS_WATCH 0 + + #define TARGET_OS_TV 0 + #define TARGET_OS_SIMULATOR 0 + #define TARGET_OS_EMBEDDED 0 + #define TARGET_OS_RTKIT 0 + #define TARGET_OS_MACCATALYST 0 + #define TARGET_OS_MACCATALYST 0 + #ifndef TARGET_OS_UIKITFORMAC + #define TARGET_OS_UIKITFORMAC 0 + #endif + #define TARGET_OS_DRIVERKIT 1 + #define DYNAMIC_TARGETS_ENABLED 1 + #endif + + #endif /* #if __has_builtin(__is_target_environment) */ + #endif /* #if __has_builtin(__is_target_os) */ + #endif /* #if __has_builtin(__is_target_vendor) */ + #endif /* #if __has_builtin(__is_target_arch) */ +#endif /* #if defined(__has_builtin) */ + + +#ifndef DYNAMIC_TARGETS_ENABLED + #define DYNAMIC_TARGETS_ENABLED 0 +#endif /* DYNAMIC_TARGETS_ENABLED */ + +/* + * gcc based compiler used on Mac OS X + */ +#if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__MACOS_CLASSIC__) ) + #define TARGET_OS_MAC 1 + #define TARGET_OS_WIN32 0 + #define TARGET_OS_UNIX 0 + + #if !DYNAMIC_TARGETS_ENABLED + #define TARGET_OS_OSX 1 + #define TARGET_OS_IPHONE 0 + #define TARGET_OS_IOS 0 + #define TARGET_OS_WATCH 0 + + #define TARGET_OS_TV 0 + #define TARGET_OS_MACCATALYST 0 + #define TARGET_OS_MACCATALYST 0 + #ifndef TARGET_OS_UIKITFORMAC + #define TARGET_OS_UIKITFORMAC 0 + #endif + #define TARGET_OS_SIMULATOR 0 + #define TARGET_OS_EMBEDDED 0 + #define TARGET_OS_RTKIT 0 + #define TARGET_OS_DRIVERKIT 0 + #endif + + #define TARGET_IPHONE_SIMULATOR TARGET_OS_SIMULATOR /* deprecated */ + #define TARGET_OS_NANO TARGET_OS_WATCH /* deprecated */ + + #define TARGET_ABI_USES_IOS_VALUES (!TARGET_CPU_X86_64 || (TARGET_OS_IPHONE && !TARGET_OS_MACCATALYST)) + #if defined(__ppc__) + #define TARGET_CPU_PPC 1 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #define TARGET_RT_LITTLE_ENDIAN 0 + #define TARGET_RT_BIG_ENDIAN 1 + #define TARGET_RT_64_BIT 0 + #ifdef __MACOS_CLASSIC__ + #define TARGET_RT_MAC_CFM 1 + #define TARGET_RT_MAC_MACHO 0 + #else + #define TARGET_RT_MAC_CFM 0 + #define TARGET_RT_MAC_MACHO 1 + #endif + #elif defined(__ppc64__) + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 1 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #define TARGET_RT_LITTLE_ENDIAN 0 + #define TARGET_RT_BIG_ENDIAN 1 + #define TARGET_RT_64_BIT 1 + #define TARGET_RT_MAC_CFM 0 + #define TARGET_RT_MAC_MACHO 1 + #elif defined(__i386__) + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 1 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #define TARGET_RT_MAC_CFM 0 + #define TARGET_RT_MAC_MACHO 1 + #define TARGET_RT_LITTLE_ENDIAN 1 + #define TARGET_RT_BIG_ENDIAN 0 + #define TARGET_RT_64_BIT 0 + #elif defined(__x86_64__) + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 1 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #define TARGET_RT_MAC_CFM 0 + #define TARGET_RT_MAC_MACHO 1 + #define TARGET_RT_LITTLE_ENDIAN 1 + #define TARGET_RT_BIG_ENDIAN 0 + #define TARGET_RT_64_BIT 1 + #elif defined(__arm__) + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_ARM 1 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #define TARGET_RT_MAC_CFM 0 + #define TARGET_RT_MAC_MACHO 1 + #define TARGET_RT_LITTLE_ENDIAN 1 + #define TARGET_RT_BIG_ENDIAN 0 + #define TARGET_RT_64_BIT 0 + #elif defined(__arm64__) + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 1 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #define TARGET_RT_MAC_CFM 0 + #define TARGET_RT_MAC_MACHO 1 + #define TARGET_RT_LITTLE_ENDIAN 1 + #define TARGET_RT_BIG_ENDIAN 0 + #if __LP64__ + #define TARGET_RT_64_BIT 1 + #else + #define TARGET_RT_64_BIT 0 + #endif + #else + #error unrecognized GNU C compiler + #endif + + + +/* + * CodeWarrior compiler from Metrowerks/Motorola + */ +#elif defined(__MWERKS__) + #define TARGET_OS_MAC 1 + #define TARGET_OS_WIN32 0 + #define TARGET_OS_UNIX 0 + #define TARGET_OS_EMBEDDED 0 + #if defined(__POWERPC__) + #define TARGET_CPU_PPC 1 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #define TARGET_RT_LITTLE_ENDIAN 0 + #define TARGET_RT_BIG_ENDIAN 1 + #elif defined(__INTEL__) + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 1 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #define TARGET_RT_LITTLE_ENDIAN 1 + #define TARGET_RT_BIG_ENDIAN 0 + #else + #error unknown Metrowerks CPU type + #endif + #define TARGET_RT_64_BIT 0 + #ifdef __MACH__ + #define TARGET_RT_MAC_CFM 0 + #define TARGET_RT_MAC_MACHO 1 + #else + #define TARGET_RT_MAC_CFM 1 + #define TARGET_RT_MAC_MACHO 0 + #endif + +/* + * unknown compiler + */ +#else + #if defined(TARGET_CPU_PPC) && TARGET_CPU_PPC + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #elif defined(TARGET_CPU_PPC64) && TARGET_CPU_PPC64 + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #elif defined(TARGET_CPU_X86) && TARGET_CPU_X86 + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #elif defined(TARGET_CPU_X86_64) && TARGET_CPU_X86_64 + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #elif defined(TARGET_CPU_ARM) && TARGET_CPU_ARM + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #elif defined(TARGET_CPU_ARM64) && TARGET_CPU_ARM64 + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_PPC64 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_X86_64 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #else + /* + NOTE: If your compiler errors out here then support for your compiler + has not yet been added to TargetConditionals.h. + + TargetConditionals.h is designed to be plug-and-play. It auto detects + which compiler is being run and configures the TARGET_ conditionals + appropriately. + + The short term work around is to set the TARGET_CPU_ and TARGET_OS_ + on the command line to the compiler (e.g. -DTARGET_CPU_MIPS=1 -DTARGET_OS_UNIX=1) + + The long term solution is to add a new case to this file which + auto detects your compiler and sets up the TARGET_ conditionals. + Then submit the changes to Apple Computer. + */ + #error TargetConditionals.h: unknown compiler (see comment above) + #define TARGET_CPU_PPC 0 + #define TARGET_CPU_68K 0 + #define TARGET_CPU_X86 0 + #define TARGET_CPU_ARM 0 + #define TARGET_CPU_ARM64 0 + #define TARGET_CPU_MIPS 0 + #define TARGET_CPU_SPARC 0 + #define TARGET_CPU_ALPHA 0 + #endif + #define TARGET_OS_MAC 1 + #define TARGET_OS_WIN32 0 + #define TARGET_OS_UNIX 0 + #define TARGET_OS_EMBEDDED 0 + #if TARGET_CPU_PPC || TARGET_CPU_PPC64 + #define TARGET_RT_BIG_ENDIAN 1 + #define TARGET_RT_LITTLE_ENDIAN 0 + #else + #define TARGET_RT_BIG_ENDIAN 0 + #define TARGET_RT_LITTLE_ENDIAN 1 + #endif + #if TARGET_CPU_PPC64 || TARGET_CPU_X86_64 + #define TARGET_RT_64_BIT 1 + #else + #define TARGET_RT_64_BIT 0 + #endif + #ifdef __MACH__ + #define TARGET_RT_MAC_MACHO 1 + #define TARGET_RT_MAC_CFM 0 + #else + #define TARGET_RT_MAC_MACHO 0 + #define TARGET_RT_MAC_CFM 1 + #endif + +#endif + +#endif /* __TARGETCONDITIONALS__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/_ctermid.h b/lib/libc/include/aarch64-macos-gnu/_ctermid.h new file mode 100644 index 0000000000..defba5353b --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/_ctermid.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2000, 2002-2006, 2008-2010, 2012, 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 _CTERMID_H_ +#define _CTERMID_H_ + +#include + +__BEGIN_DECLS + +char *ctermid(char *); + +__END_DECLS + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/_limits.h b/lib/libc/include/aarch64-macos-gnu/arm/_limits.h new file mode 100644 index 0000000000..dd9eb5c2be --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/_limits.h @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2004-2007 Apple Inc. All rights reserved. + */ +#ifndef _ARM__LIMITS_H_ +#define _ARM__LIMITS_H_ + +#define __DARWIN_CLK_TCK 100 /* ticks per second */ + +#endif /* _ARM__LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/_mcontext.h b/lib/libc/include/aarch64-macos-gnu/arm/_mcontext.h new file mode 100644 index 0000000000..72253cfbac --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/_mcontext.h @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef __ARM_MCONTEXT_H_ +#define __ARM_MCONTEXT_H_ + +#include /* __DARWIN_UNIX03 */ +#include +#include + +#ifndef _STRUCT_MCONTEXT32 +#if __DARWIN_UNIX03 +#define _STRUCT_MCONTEXT32 struct __darwin_mcontext32 +_STRUCT_MCONTEXT32 +{ + _STRUCT_ARM_EXCEPTION_STATE __es; + _STRUCT_ARM_THREAD_STATE __ss; + _STRUCT_ARM_VFP_STATE __fs; +}; + +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_MCONTEXT32 struct mcontext32 +_STRUCT_MCONTEXT32 +{ + _STRUCT_ARM_EXCEPTION_STATE es; + _STRUCT_ARM_THREAD_STATE ss; + _STRUCT_ARM_VFP_STATE fs; +}; + +#endif /* __DARWIN_UNIX03 */ +#endif /* _STRUCT_MCONTEXT32 */ + + +#ifndef _STRUCT_MCONTEXT64 +#if __DARWIN_UNIX03 +#define _STRUCT_MCONTEXT64 struct __darwin_mcontext64 +_STRUCT_MCONTEXT64 +{ + _STRUCT_ARM_EXCEPTION_STATE64 __es; + _STRUCT_ARM_THREAD_STATE64 __ss; + _STRUCT_ARM_NEON_STATE64 __ns; +}; + +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_MCONTEXT64 struct mcontext64 +_STRUCT_MCONTEXT64 +{ + _STRUCT_ARM_EXCEPTION_STATE64 es; + _STRUCT_ARM_THREAD_STATE64 ss; + _STRUCT_ARM_NEON_STATE64 ns; +}; +#endif /* __DARWIN_UNIX03 */ +#endif /* _STRUCT_MCONTEXT32 */ + +#ifndef _MCONTEXT_T +#define _MCONTEXT_T +#if defined(__arm64__) +typedef _STRUCT_MCONTEXT64 *mcontext_t; +#define _STRUCT_MCONTEXT _STRUCT_MCONTEXT64 +#else +typedef _STRUCT_MCONTEXT32 *mcontext_t; +#define _STRUCT_MCONTEXT _STRUCT_MCONTEXT32 +#endif +#endif /* _MCONTEXT_T */ + +#endif /* __ARM_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/_param.h b/lib/libc/include/aarch64-macos-gnu/arm/_param.h new file mode 100644 index 0000000000..81c5bf53cf --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/_param.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2006-2007 Apple Inc. All rights reserved. + */ + +#ifndef _ARM__PARAM_H_ +#define _ARM__PARAM_H_ + +#include + +/* + * Round p (pointer or byte index) up to a correctly-aligned value for all + * data types (int, long, ...). The result is unsigned int and must be + * cast to any desired pointer type. + */ +#define __DARWIN_ALIGNBYTES (sizeof(__darwin_size_t) - 1) +#define __DARWIN_ALIGN(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES) + +#define __DARWIN_ALIGNBYTES32 (sizeof(__uint32_t) - 1) +#define __DARWIN_ALIGN32(p) ((__darwin_size_t)((__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32) + + +#endif /* _ARM__PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/_types.h b/lib/libc/include/aarch64-macos-gnu/arm/_types.h new file mode 100644 index 0000000000..d6c4de8fac --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/_types.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + */ +#ifndef _BSD_ARM__TYPES_H_ +#define _BSD_ARM__TYPES_H_ + +/* + * This header file contains integer types. It's intended to also contain + * flotaing point and other arithmetic types, as needed, later. + */ + +#ifdef __GNUC__ +typedef __signed char __int8_t; +#else /* !__GNUC__ */ +typedef char __int8_t; +#endif /* !__GNUC__ */ +typedef unsigned char __uint8_t; +typedef short __int16_t; +typedef unsigned short __uint16_t; +typedef int __int32_t; +typedef unsigned int __uint32_t; +typedef long long __int64_t; +typedef unsigned long long __uint64_t; + +typedef long __darwin_intptr_t; +typedef unsigned int __darwin_natural_t; + +/* + * The rune type below is declared to be an ``int'' instead of the more natural + * ``unsigned long'' or ``long''. Two things are happening here. It is not + * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, + * it looks like 10646 will be a 31 bit standard. This means that if your + * ints cannot hold 32 bits, you will be in trouble. The reason an int was + * chosen over a long is that the is*() and to*() routines take ints (says + * ANSI C), but they use __darwin_ct_rune_t instead of int. By changing it + * here, you lose a bit of ANSI conformance, but your programs will still + * work. + * + * NOTE: rune_t is not covered by ANSI nor other standards, and should not + * be instantiated outside of lib/libc/locale. Use wchar_t. wchar_t and + * rune_t must be the same type. Also wint_t must be no narrower than + * wchar_t, and should also be able to hold all members of the largest + * character set plus one extra value (WEOF). wint_t must be at least 16 bits. + */ + +typedef int __darwin_ct_rune_t; /* ct_rune_t */ + +/* + * mbstate_t is an opaque object to keep conversion state, during multibyte + * stream conversions. The content must not be referenced by user programs. + */ +typedef union { + char __mbstate8[128]; + long long _mbstateL; /* for alignment */ +} __mbstate_t; + +typedef __mbstate_t __darwin_mbstate_t; /* mbstate_t */ + +#if defined(__PTRDIFF_TYPE__) +typedef __PTRDIFF_TYPE__ __darwin_ptrdiff_t; /* ptr1 - ptr2 */ +#elif defined(__LP64__) +typedef long __darwin_ptrdiff_t; /* ptr1 - ptr2 */ +#else +typedef int __darwin_ptrdiff_t; /* ptr1 - ptr2 */ +#endif /* __GNUC__ */ + +#if defined(__SIZE_TYPE__) +typedef __SIZE_TYPE__ __darwin_size_t; /* sizeof() */ +#else +typedef unsigned long __darwin_size_t; /* sizeof() */ +#endif + +#if (__GNUC__ > 2) +typedef __builtin_va_list __darwin_va_list; /* va_list */ +#else +typedef void * __darwin_va_list; /* va_list */ +#endif + +#if defined(__WCHAR_TYPE__) +typedef __WCHAR_TYPE__ __darwin_wchar_t; /* wchar_t */ +#else +typedef __darwin_ct_rune_t __darwin_wchar_t; /* wchar_t */ +#endif + +typedef __darwin_wchar_t __darwin_rune_t; /* rune_t */ + +#if defined(__WINT_TYPE__) +typedef __WINT_TYPE__ __darwin_wint_t; /* wint_t */ +#else +typedef __darwin_ct_rune_t __darwin_wint_t; /* wint_t */ +#endif + +typedef unsigned long __darwin_clock_t; /* clock() */ +typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */ +typedef long __darwin_ssize_t; /* byte count or error */ +typedef long __darwin_time_t; /* time() */ + +#endif /* _BSD_ARM__TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/arch.h b/lib/libc/include/aarch64-macos-gnu/arm/arch.h new file mode 100644 index 0000000000..e93e87bf06 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/arch.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _ARM_ARCH_H +#define _ARM_ARCH_H + +/* Collect the __ARM_ARCH_*__ compiler flags into something easier to use. */ +#if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7S__) || defined (__ARM_ARCH_7F__) || defined (__ARM_ARCH_7K__) +#define _ARM_ARCH_7 +#endif + +#if defined (_ARM_ARCH_7) || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__) +#define _ARM_ARCH_6K +#endif + +#if defined (_ARM_ARCH_7) || defined (__ARM_ARCH_6Z__) || defined (__ARM_ARCH_6ZK__) +#define _ARM_ARCH_6Z +#endif + +#if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) || \ + defined (_ARM_ARCH_6Z) || defined (_ARM_ARCH_6K) +#define _ARM_ARCH_6 +#endif + +#if defined (_ARM_ARCH_6) || defined (__ARM_ARCH_5E__) || \ + defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5TEJ__) +#define _ARM_ARCH_5E +#endif + +#if defined (_ARM_ARCH_5E) || defined (__ARM_ARCH_5__) || \ + defined (__ARM_ARCH_5T__) +#define _ARM_ARCH_5 +#endif + +#if defined (_ARM_ARCH_5) || defined (__ARM_ARCH_4T__) +#define _ARM_ARCH_4T +#endif + +#if defined (_ARM_ARCH_4T) || defined (__ARM_ARCH_4__) +#define _ARM_ARCH_4 +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/endian.h b/lib/libc/include/aarch64-macos-gnu/arm/endian.h new file mode 100644 index 0000000000..d05874ecf4 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/endian.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + */ +/* + * Copyright 1995 NeXT Computer, Inc. All rights reserved. + */ +/* + * Copyright (c) 1987, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)endian.h 8.1 (Berkeley) 6/11/93 + */ + +#ifndef _ARM__ENDIAN_H_ +#define _ARM__ENDIAN_H_ + +#include +/* + * Define _NOQUAD if the compiler does NOT support 64-bit integers. + */ +/* #define _NOQUAD */ + +/* + * Define the order of 32-bit words in 64-bit words. + */ +#define _QUAD_HIGHWORD 1 +#define _QUAD_LOWWORD 0 + +/* + * Definitions for byte order, according to byte significance from low + * address to high. + */ +#define __DARWIN_LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ +#define __DARWIN_BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ +#define __DARWIN_PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ + +#define __DARWIN_BYTE_ORDER __DARWIN_LITTLE_ENDIAN + +#if defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) + +#define LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN +#define BIG_ENDIAN __DARWIN_BIG_ENDIAN +#define PDP_ENDIAN __DARWIN_PDP_ENDIAN + +#define BYTE_ORDER __DARWIN_BYTE_ORDER + +#include + +#endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ +#endif /* !_ARM__ENDIAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/limits.h b/lib/libc/include/aarch64-macos-gnu/arm/limits.h new file mode 100644 index 0000000000..f889c48b6a --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/limits.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + */ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)limits.h 8.3 (Berkeley) 1/4/94 + */ + +#ifndef _ARM_LIMITS_H_ +#define _ARM_LIMITS_H_ + +#include +#include + +#define CHAR_BIT 8 /* number of bits in a char */ +#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */ + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#define CLK_TCK __DARWIN_CLK_TCK /* ticks per second */ +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * According to ANSI (section 2.2.4.2), the values below must be usable by + * #if preprocessing directives. Additionally, the expression must have the + * same type as would an expression that is an object of the corresponding + * type converted according to the integral promotions. The subtraction for + * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an + * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). + * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values + * are written as hex so that GCC will be quiet about large integer constants. + */ +#define SCHAR_MAX 127 /* min value for a signed char */ +#define SCHAR_MIN (-128) /* max value for a signed char */ + +#define UCHAR_MAX 255 /* max value for an unsigned char */ +#define CHAR_MAX 127 /* max value for a char */ +#define CHAR_MIN (-128) /* min value for a char */ + +#define USHRT_MAX 65535 /* max value for an unsigned short */ +#define SHRT_MAX 32767 /* max value for a short */ +#define SHRT_MIN (-32768) /* min value for a short */ + +#define UINT_MAX 0xffffffff /* max value for an unsigned int */ +#define INT_MAX 2147483647 /* max value for an int */ +#define INT_MIN (-2147483647-1) /* min value for an int */ + +#ifdef __LP64__ +#define ULONG_MAX 0xffffffffffffffffUL /* max unsigned long */ +#define LONG_MAX 0x7fffffffffffffffL /* max signed long */ +#define LONG_MIN (-0x7fffffffffffffffL-1) /* min signed long */ +#else /* !__LP64__ */ +#define ULONG_MAX 0xffffffffUL /* max unsigned long */ +#define LONG_MAX 2147483647L /* max signed long */ +#define LONG_MIN (-2147483647L-1) /* min signed long */ +#endif /* __LP64__ */ + +#define ULLONG_MAX 0xffffffffffffffffULL /* max unsigned long long */ +#define LLONG_MAX 0x7fffffffffffffffLL /* max signed long long */ +#define LLONG_MIN (-0x7fffffffffffffffLL-1) /* min signed long long */ + +#if !defined(_ANSI_SOURCE) +#ifdef __LP64__ +#define LONG_BIT 64 +#else /* !__LP64__ */ +#define LONG_BIT 32 +#endif /* __LP64__ */ +#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ +#define WORD_BIT 32 + +#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) +#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */ + +#define UQUAD_MAX ULLONG_MAX +#define QUAD_MAX LLONG_MAX +#define QUAD_MIN LLONG_MIN + +#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */ +#endif /* !_ANSI_SOURCE */ + +#endif /* _ARM_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/param.h b/lib/libc/include/aarch64-macos-gnu/arm/param.h new file mode 100644 index 0000000000..e70f68f9c3 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/param.h @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2000-2010 Apple Inc. All rights reserved. + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)param.h 8.1 (Berkeley) 4/4/95 + */ + +/* + * Machine dependent constants for ARM + */ + +#ifndef _ARM_PARAM_H_ +#define _ARM_PARAM_H_ + +#include + +/* + * Round p (pointer or byte index) up to a correctly-aligned value for all + * data types (int, long, ...). The result is unsigned int and must be + * cast to any desired pointer type. + */ +#define ALIGNBYTES __DARWIN_ALIGNBYTES +#define ALIGN(p) __DARWIN_ALIGN(p) + +#define NBPG 4096 /* bytes/page */ +#define PGOFSET (NBPG-1) /* byte offset into page */ +#define PGSHIFT 12 /* LOG2(NBPG) */ + +#define DEV_BSIZE 512 +#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ +#define BLKDEV_IOSIZE 2048 +#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ + +#define CLSIZE 1 +#define CLSIZELOG2 0 + +/* + * Constants related to network buffer management. + * MCLBYTES must be no larger than CLBYTES (the software page size), and, + * on machines that exchange pages of input or output buffers with mbuf + * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple + * of the hardware page size. + */ +#define MSIZESHIFT 8 /* 256 */ +#define MSIZE (1 << MSIZESHIFT) /* size of an mbuf */ +#define MCLSHIFT 11 /* 2048 */ +#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */ +#define MBIGCLSHIFT 12 /* 4096 */ +#define MBIGCLBYTES (1 << MBIGCLSHIFT) /* size of a big cluster */ +#define M16KCLSHIFT 14 /* 16384 */ +#define M16KCLBYTES (1 << M16KCLSHIFT) /* size of a jumbo cluster */ + +#define MCLOFSET (MCLBYTES - 1) +#ifndef NMBCLUSTERS +#define NMBCLUSTERS CONFIG_NMBCLUSTERS /* cl map size */ +#endif + +/* + * Some macros for units conversion + */ +/* Core clicks (NeXT_page_size bytes) to segments and vice versa */ +#define ctos(x) (x) +#define stoc(x) (x) + +/* Core clicks (4096 bytes) to disk blocks */ +#define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) +#define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) +#define dtob(x) ((x)<>PGSHIFT) + +#ifdef __APPLE__ +#define btodb(bytes, devBlockSize) \ + ((unsigned)(bytes) / devBlockSize) +#define dbtob(db, devBlockSize) \ + ((unsigned)(db) * devBlockSize) +#else +#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ + ((unsigned)(bytes) >> DEV_BSHIFT) +#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ + ((unsigned)(db) << DEV_BSHIFT) +#endif + +/* + * Map a ``block device block'' to a file system block. + * This should be device dependent, and will be if we + * add an entry to cdevsw/bdevsw for that purpose. + * For now though just use DEV_BSIZE. + */ +#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) + +/* + * Macros to decode (and encode) processor status word. + */ +#define STATUS_WORD(rpl, ipl) (((ipl) << 8) | (rpl)) +#define USERMODE(x) (((x) & 3) == 3) +#define BASEPRI(x) (((x) & (255 << 8)) == 0) + + +#if defined(KERNEL) || defined(STANDALONE) +#define DELAY(n) delay(n) + +#else /* defined(KERNEL) || defined(STANDALONE) */ +#define DELAY(n) { int N = (n); while (--N > 0); } +#endif /* defined(KERNEL) || defined(STANDALONE) */ + +#endif /* _ARM_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/signal.h b/lib/libc/include/aarch64-macos-gnu/arm/signal.h new file mode 100644 index 0000000000..80d2564826 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/signal.h @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2000-2009 Apple, Inc. All rights reserved. + */ +/* + * Copyright (c) 1992 NeXT Computer, Inc. + * + */ + +#ifndef _ARM_SIGNAL_ +#define _ARM_SIGNAL_ 1 + +#include + +#ifndef _ANSI_SOURCE +typedef int sig_atomic_t; +#endif /* ! _ANSI_SOURCE */ + +#endif /* _ARM_SIGNAL_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/arm/types.h b/lib/libc/include/aarch64-macos-gnu/arm/types.h new file mode 100644 index 0000000000..9a6c23bb9a --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/arm/types.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2000-2008 Apple Inc. All rights reserved. + */ +/* + * Copyright 1995 NeXT Computer, Inc. All rights reserved. + */ +/* + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)types.h 8.3 (Berkeley) 1/5/94 + */ + +#ifndef _MACHTYPES_H_ +#define _MACHTYPES_H_ + +#ifndef __ASSEMBLER__ +#include +#include +/* + * Basic integral types. Omit the typedef if + * not possible for a machine/compiler combination. + */ +#include +#include +#include +#include + +#include +#include +#include +#include + +#if __LP64__ +typedef int64_t register_t; +#else +typedef int32_t register_t; +#endif + +#include +#include + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +/* These types are used for reserving the largest possible size. */ +#ifdef __arm64__ +typedef u_int64_t user_addr_t; +typedef u_int64_t user_size_t; +typedef int64_t user_ssize_t; +typedef int64_t user_long_t; +typedef u_int64_t user_ulong_t; +typedef int64_t user_time_t; +typedef int64_t user_off_t; +#else +typedef u_int32_t user_addr_t; +typedef u_int32_t user_size_t; +typedef int32_t user_ssize_t; +typedef int32_t user_long_t; +typedef u_int32_t user_ulong_t; +typedef int32_t user_time_t; +typedef int64_t user_off_t; +#endif + +#define USER_ADDR_NULL ((user_addr_t) 0) +#define CAST_USER_ADDR_T(a_ptr) ((user_addr_t)((uintptr_t)(a_ptr))) + + +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* This defines the size of syscall arguments after copying into the kernel: */ +#if defined(__arm__) +typedef u_int32_t syscall_arg_t; +#elif defined(__arm64__) +typedef u_int64_t syscall_arg_t; +#else +#error Unknown architecture. +#endif + +#endif /* __ASSEMBLER__ */ +#endif /* _MACHTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/bsm/audit.h b/lib/libc/include/aarch64-macos-gnu/bsm/audit.h new file mode 100644 index 0000000000..e6be5e8dab --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/bsm/audit.h @@ -0,0 +1,391 @@ +/*- + * Copyright (c) 2005-2009 Apple Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $P4: //depot/projects/trustedbsd/openbsm/sys/bsm/audit.h#10 $ + */ + +#ifndef _BSM_AUDIT_H +#define _BSM_AUDIT_H + +#include +#include + +#define AUDIT_RECORD_MAGIC 0x828a0f1b +#define MAX_AUDIT_RECORDS 20 +#define MAXAUDITDATA (0x8000 - 1) +#define MAX_AUDIT_RECORD_SIZE MAXAUDITDATA +#define MIN_AUDIT_FILE_SIZE (512 * 1024) + +/* + * Minimum noumber of free blocks on the filesystem containing the audit + * log necessary to avoid a hard log rotation. DO NOT SET THIS VALUE TO 0 + * as the kernel does an unsigned compare, plus we want to leave a few blocks + * free so userspace can terminate the log, etc. + */ +#define AUDIT_HARD_LIMIT_FREE_BLOCKS 4 + +/* + * Triggers for the audit daemon. + */ +#define AUDIT_TRIGGER_MIN 1 +#define AUDIT_TRIGGER_LOW_SPACE 1 /* Below low watermark. */ +#define AUDIT_TRIGGER_ROTATE_KERNEL 2 /* Kernel requests rotate. */ +#define AUDIT_TRIGGER_READ_FILE 3 /* Re-read config file. */ +#define AUDIT_TRIGGER_CLOSE_AND_DIE 4 /* Terminate audit. */ +#define AUDIT_TRIGGER_NO_SPACE 5 /* Below min free space. */ +#define AUDIT_TRIGGER_ROTATE_USER 6 /* User requests rotate. */ +#define AUDIT_TRIGGER_INITIALIZE 7 /* User initialize of auditd. */ +#define AUDIT_TRIGGER_EXPIRE_TRAILS 8 /* User expiration of trails. */ +#define AUDIT_TRIGGER_MAX 8 + +/* + * The special device filename (FreeBSD). + */ +#define AUDITDEV_FILENAME "audit" +#define AUDIT_TRIGGER_FILE ("/dev/" AUDITDEV_FILENAME) + +/* + * Pre-defined audit IDs + */ +#define AU_DEFAUDITID (uid_t)(-1) +#define AU_DEFAUDITSID 0 +#define AU_ASSIGN_ASID -1 + +/* + * IPC types. + */ +#define AT_IPC_MSG ((unsigned char)1) /* Message IPC id. */ +#define AT_IPC_SEM ((unsigned char)2) /* Semaphore IPC id. */ +#define AT_IPC_SHM ((unsigned char)3) /* Shared mem IPC id. */ + +/* + * Audit conditions. + */ +#define AUC_UNSET 0 +#define AUC_AUDITING 1 +#define AUC_NOAUDIT 2 +#define AUC_DISABLED -1 + +/* + * auditon(2) commands. + */ +#define A_OLDGETPOLICY 2 +#define A_OLDSETPOLICY 3 +#define A_GETKMASK 4 +#define A_SETKMASK 5 +#define A_OLDGETQCTRL 6 +#define A_OLDSETQCTRL 7 +#define A_GETCWD 8 +#define A_GETCAR 9 +#define A_GETSTAT 12 +#define A_SETSTAT 13 +#define A_SETUMASK 14 +#define A_SETSMASK 15 +#define A_OLDGETCOND 20 +#define A_OLDSETCOND 21 +#define A_GETCLASS 22 +#define A_SETCLASS 23 +#define A_GETPINFO 24 +#define A_SETPMASK 25 +#define A_SETFSIZE 26 +#define A_GETFSIZE 27 +#define A_GETPINFO_ADDR 28 +#define A_GETKAUDIT 29 +#define A_SETKAUDIT 30 +#define A_SENDTRIGGER 31 +#define A_GETSINFO_ADDR 32 +#define A_GETPOLICY 33 +#define A_SETPOLICY 34 +#define A_GETQCTRL 35 +#define A_SETQCTRL 36 +#define A_GETCOND 37 +#define A_SETCOND 38 +#define A_GETSFLAGS 39 +#define A_SETSFLAGS 40 +#define A_GETCTLMODE 41 +#define A_SETCTLMODE 42 +#define A_GETEXPAFTER 43 +#define A_SETEXPAFTER 44 + +/* + * Audit policy controls. + */ +#define AUDIT_CNT 0x0001 +#define AUDIT_AHLT 0x0002 +#define AUDIT_ARGV 0x0004 +#define AUDIT_ARGE 0x0008 +#define AUDIT_SEQ 0x0010 +#define AUDIT_WINDATA 0x0020 +#define AUDIT_USER 0x0040 +#define AUDIT_GROUP 0x0080 +#define AUDIT_TRAIL 0x0100 +#define AUDIT_PATH 0x0200 +#define AUDIT_SCNT 0x0400 +#define AUDIT_PUBLIC 0x0800 +#define AUDIT_ZONENAME 0x1000 +#define AUDIT_PERZONE 0x2000 + +/* + * Default audit queue control parameters. + */ +#define AQ_HIWATER 100 +#define AQ_MAXHIGH 10000 +#define AQ_LOWATER 10 +#define AQ_BUFSZ MAXAUDITDATA +#define AQ_MAXBUFSZ 1048576 + +/* + * Default minimum percentage free space on file system. + */ +#define AU_FS_MINFREE 20 + +/* + * Type definitions used indicating the length of variable length addresses + * in tokens containing addresses, such as header fields. + */ +#define AU_IPv4 4 +#define AU_IPv6 16 + +/* + * Reserved audit class mask indicating which classes are unable to have + * events added or removed by unentitled processes. + */ +#define AU_CLASS_MASK_RESERVED 0x10000000 + +/* + * Audit control modes + */ +#define AUDIT_CTLMODE_NORMAL ((unsigned char)1) +#define AUDIT_CTLMODE_EXTERNAL ((unsigned char)2) + +/* + * Audit file expire_after op modes + */ +#define AUDIT_EXPIRE_OP_AND ((unsigned char)0) +#define AUDIT_EXPIRE_OP_OR ((unsigned char)1) + +__BEGIN_DECLS + +typedef uid_t au_id_t; +typedef pid_t au_asid_t; +typedef u_int16_t au_event_t; +typedef u_int16_t au_emod_t; +typedef u_int32_t au_class_t; +typedef u_int64_t au_asflgs_t __attribute__ ((aligned(8))); +typedef unsigned char au_ctlmode_t; + +struct au_tid { + dev_t port; + u_int32_t machine; +}; +typedef struct au_tid au_tid_t; + +struct au_tid_addr { + dev_t at_port; + u_int32_t at_type; + u_int32_t at_addr[4]; +}; +typedef struct au_tid_addr au_tid_addr_t; + +struct au_mask { + unsigned int am_success; /* Success bits. */ + unsigned int am_failure; /* Failure bits. */ +}; +typedef struct au_mask au_mask_t; + +struct auditinfo { + au_id_t ai_auid; /* Audit user ID. */ + au_mask_t ai_mask; /* Audit masks. */ + au_tid_t ai_termid; /* Terminal ID. */ + au_asid_t ai_asid; /* Audit session ID. */ +}; +typedef struct auditinfo auditinfo_t; + +struct auditinfo_addr { + au_id_t ai_auid; /* Audit user ID. */ + au_mask_t ai_mask; /* Audit masks. */ + au_tid_addr_t ai_termid; /* Terminal ID. */ + au_asid_t ai_asid; /* Audit session ID. */ + au_asflgs_t ai_flags; /* Audit session flags. */ +}; +typedef struct auditinfo_addr auditinfo_addr_t; + +struct auditpinfo { + pid_t ap_pid; /* ID of target process. */ + au_id_t ap_auid; /* Audit user ID. */ + au_mask_t ap_mask; /* Audit masks. */ + au_tid_t ap_termid; /* Terminal ID. */ + au_asid_t ap_asid; /* Audit session ID. */ +}; +typedef struct auditpinfo auditpinfo_t; + +struct auditpinfo_addr { + pid_t ap_pid; /* ID of target process. */ + au_id_t ap_auid; /* Audit user ID. */ + au_mask_t ap_mask; /* Audit masks. */ + au_tid_addr_t ap_termid; /* Terminal ID. */ + au_asid_t ap_asid; /* Audit session ID. */ + au_asflgs_t ap_flags; /* Audit session flags. */ +}; +typedef struct auditpinfo_addr auditpinfo_addr_t; + +struct au_session { + auditinfo_addr_t *as_aia_p; /* Ptr to full audit info. */ + au_mask_t as_mask; /* Process Audit Masks. */ +}; +typedef struct au_session au_session_t; + +struct au_expire_after { + time_t age; /* Age after which trail files should be expired */ + size_t size; /* Aggregate trail size when files should be expired */ + unsigned char op_type; /* Operator used with the above values to determine when files should be expired */ +}; +typedef struct au_expire_after au_expire_after_t; + +/* + * Contents of token_t are opaque outside of libbsm. + */ +typedef struct au_token token_t; + +/* + * Kernel audit queue control parameters: + * Default: Maximum: + * aq_hiwater: AQ_HIWATER (100) AQ_MAXHIGH (10000) + * aq_lowater: AQ_LOWATER (10) +#define __AUDIT_API_DEPRECATED __API_DEPRECATED("audit is deprecated", macos(10.4, 11.0)) +#else +#define __AUDIT_API_DEPRECATED +#endif + +/* + * Audit system calls. + */ +#if !defined(_KERNEL) && !defined(KERNEL) +int audit(const void *, int) +__AUDIT_API_DEPRECATED; +int auditon(int, void *, int) +__AUDIT_API_DEPRECATED; +int auditctl(const char *) +__AUDIT_API_DEPRECATED; +int getauid(au_id_t *); +int setauid(const au_id_t *); +int getaudit_addr(struct auditinfo_addr *, int); +int setaudit_addr(const struct auditinfo_addr *, int); + +#if defined(__APPLE__) +#include + +/* + * getaudit()/setaudit() are deprecated and have been replaced with + * wrappers to the getaudit_addr()/setaudit_addr() syscalls above. + */ + +int getaudit(struct auditinfo *) +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, + __IPHONE_2_0, __IPHONE_6_0); +int setaudit(const struct auditinfo *) +__OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_8, + __IPHONE_2_0, __IPHONE_6_0); +#else + +int getaudit(struct auditinfo *) +__AUDIT_API_DEPRECATED; +int setaudit(const struct auditinfo *) +__AUDIT_API_DEPRECATED; +#endif /* !__APPLE__ */ + +#ifdef __APPLE_API_PRIVATE +#include +mach_port_name_t audit_session_self(void); +au_asid_t audit_session_join(mach_port_name_t port); +int audit_session_port(au_asid_t asid, mach_port_name_t *portname); +#endif /* __APPLE_API_PRIVATE */ + +#endif /* defined(_KERNEL) || defined(KERNEL) */ + +__END_DECLS + +#endif /* !_BSM_AUDIT_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/dispatch/block.h b/lib/libc/include/aarch64-macos-gnu/dispatch/block.h new file mode 100644 index 0000000000..f4b9b9ead4 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/dispatch/block.h @@ -0,0 +1,428 @@ +/* + * Copyright (c) 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 __DISPATCH_BLOCK__ +#define __DISPATCH_BLOCK__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +#ifdef __BLOCKS__ + +/*! + * @group Dispatch block objects + */ + +DISPATCH_ASSUME_NONNULL_BEGIN + +__BEGIN_DECLS + +/*! + * @typedef dispatch_block_flags_t + * Flags to pass to the dispatch_block_create* functions. + * + * @const DISPATCH_BLOCK_BARRIER + * Flag indicating that a dispatch block object should act as a barrier block + * when submitted to a DISPATCH_QUEUE_CONCURRENT queue. + * See dispatch_barrier_async() for details. + * This flag has no effect when the dispatch block object is invoked directly. + * + * @const DISPATCH_BLOCK_DETACHED + * Flag indicating that a dispatch block object should execute disassociated + * from current execution context attributes such as os_activity_t + * and properties of the current IPC request (if any). With regard to QoS class, + * the behavior is the same as for DISPATCH_BLOCK_NO_QOS. If invoked directly, + * the block object will remove the other attributes from the calling thread for + * the duration of the block body (before applying attributes assigned to the + * block object, if any). If submitted to a queue, the block object will be + * executed with the attributes of the queue (or any attributes specifically + * assigned to the block object). + * + * @const DISPATCH_BLOCK_ASSIGN_CURRENT + * Flag indicating that a dispatch block object should be assigned the execution + * context attributes that are current at the time the block object is created. + * This applies to attributes such as QOS class, os_activity_t and properties of + * the current IPC request (if any). If invoked directly, the block object will + * apply these attributes to the calling thread for the duration of the block + * body. If the block object is submitted to a queue, this flag replaces the + * default behavior of associating the submitted block instance with the + * execution context attributes that are current at the time of submission. + * If a specific QOS class is assigned with DISPATCH_BLOCK_NO_QOS_CLASS or + * dispatch_block_create_with_qos_class(), that QOS class takes precedence over + * the QOS class assignment indicated by this flag. + * + * @const DISPATCH_BLOCK_NO_QOS_CLASS + * Flag indicating that a dispatch block object should be not be assigned a QOS + * class. If invoked directly, the block object will be executed with the QOS + * class of the calling thread. If the block object is submitted to a queue, + * this replaces the default behavior of associating the submitted block + * instance with the QOS class current at the time of submission. + * This flag is ignored if a specific QOS class is assigned with + * dispatch_block_create_with_qos_class(). + * + * @const DISPATCH_BLOCK_INHERIT_QOS_CLASS + * Flag indicating that execution of a dispatch block object submitted to a + * queue should prefer the QOS class assigned to the queue over the QOS class + * assigned to the block (resp. associated with the block at the time of + * submission). The latter will only be used if the queue in question does not + * have an assigned QOS class, as long as doing so does not result in a QOS + * class lower than the QOS class inherited from the queue's target queue. + * This flag is the default when a dispatch block object is submitted to a queue + * for asynchronous execution and has no effect when the dispatch block object + * is invoked directly. It is ignored if DISPATCH_BLOCK_ENFORCE_QOS_CLASS is + * also passed. + * + * @const DISPATCH_BLOCK_ENFORCE_QOS_CLASS + * Flag indicating that execution of a dispatch block object submitted to a + * queue should prefer the QOS class assigned to the block (resp. associated + * with the block at the time of submission) over the QOS class assigned to the + * queue, as long as doing so will not result in a lower QOS class. + * This flag is the default when a dispatch block object is submitted to a queue + * for synchronous execution or when the dispatch block object is invoked + * directly. + */ +DISPATCH_OPTIONS(dispatch_block_flags, unsigned long, + DISPATCH_BLOCK_BARRIER + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x1, + DISPATCH_BLOCK_DETACHED + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x2, + DISPATCH_BLOCK_ASSIGN_CURRENT + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x4, + DISPATCH_BLOCK_NO_QOS_CLASS + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x8, + DISPATCH_BLOCK_INHERIT_QOS_CLASS + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x10, + DISPATCH_BLOCK_ENFORCE_QOS_CLASS + DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x20, +); + +/*! + * @function dispatch_block_create + * + * @abstract + * Create a new dispatch block object on the heap from an existing block and + * the given flags. + * + * @discussion + * The provided block is Block_copy'ed to the heap and retained by the newly + * created dispatch block object. + * + * The returned dispatch block object is intended to be submitted to a dispatch + * queue with dispatch_async() and related functions, but may also be invoked + * directly. Both operations can be performed an arbitrary number of times but + * only the first completed execution of a dispatch block object can be waited + * on with dispatch_block_wait() or observed with dispatch_block_notify(). + * + * If the returned dispatch block object is submitted to a dispatch queue, the + * submitted block instance will be associated with the QOS class current at the + * time of submission, unless one of the following flags assigned a specific QOS + * class (or no QOS class) at the time of block creation: + * - DISPATCH_BLOCK_ASSIGN_CURRENT + * - DISPATCH_BLOCK_NO_QOS_CLASS + * - DISPATCH_BLOCK_DETACHED + * The QOS class the block object will be executed with also depends on the QOS + * class assigned to the queue and which of the following flags was specified or + * defaulted to: + * - DISPATCH_BLOCK_INHERIT_QOS_CLASS (default for asynchronous execution) + * - DISPATCH_BLOCK_ENFORCE_QOS_CLASS (default for synchronous execution) + * See description of dispatch_block_flags_t for details. + * + * If the returned dispatch block object is submitted directly to a serial queue + * and is configured to execute with a specific QOS class, the system will make + * a best effort to apply the necessary QOS overrides to ensure that blocks + * submitted earlier to the serial queue are executed at that same QOS class or + * higher. + * + * @param flags + * Configuration flags for the block object. + * Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t + * results in NULL being returned. + * + * @param block + * The block to create the dispatch block object from. + * + * @result + * The newly created dispatch block object, or NULL. + * When not building with Objective-C ARC, must be released with a -[release] + * message or the Block_release() function. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_RETURNS_RETAINED_BLOCK +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_block_t +dispatch_block_create(dispatch_block_flags_t flags, dispatch_block_t block); + +/*! + * @function dispatch_block_create_with_qos_class + * + * @abstract + * Create a new dispatch block object on the heap from an existing block and + * the given flags, and assign it the specified QOS class and relative priority. + * + * @discussion + * The provided block is Block_copy'ed to the heap and retained by the newly + * created dispatch block object. + * + * The returned dispatch block object is intended to be submitted to a dispatch + * queue with dispatch_async() and related functions, but may also be invoked + * directly. Both operations can be performed an arbitrary number of times but + * only the first completed execution of a dispatch block object can be waited + * on with dispatch_block_wait() or observed with dispatch_block_notify(). + * + * If invoked directly, the returned dispatch block object will be executed with + * the assigned QOS class as long as that does not result in a lower QOS class + * than what is current on the calling thread. + * + * If the returned dispatch block object is submitted to a dispatch queue, the + * QOS class it will be executed with depends on the QOS class assigned to the + * block, the QOS class assigned to the queue and which of the following flags + * was specified or defaulted to: + * - DISPATCH_BLOCK_INHERIT_QOS_CLASS: default for asynchronous execution + * - DISPATCH_BLOCK_ENFORCE_QOS_CLASS: default for synchronous execution + * See description of dispatch_block_flags_t for details. + * + * If the returned dispatch block object is submitted directly to a serial queue + * and is configured to execute with a specific QOS class, the system will make + * a best effort to apply the necessary QOS overrides to ensure that blocks + * submitted earlier to the serial queue are executed at that same QOS class or + * higher. + * + * @param flags + * Configuration flags for the new block object. + * Passing a value that is not a bitwise OR of flags from dispatch_block_flags_t + * results in NULL being returned. + * + * @param qos_class + * A QOS class value: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * - QOS_CLASS_UNSPECIFIED + * Passing QOS_CLASS_UNSPECIFIED is equivalent to specifying the + * DISPATCH_BLOCK_NO_QOS_CLASS flag. Passing any other value results in NULL + * being returned. + * + * @param relative_priority + * A relative priority within the QOS class. This value is a negative + * offset from the maximum supported scheduler priority for the given class. + * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY + * results in NULL being returned. + * + * @param block + * The block to create the dispatch block object from. + * + * @result + * The newly created dispatch block object, or NULL. + * When not building with Objective-C ARC, must be released with a -[release] + * message or the Block_release() function. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL4 DISPATCH_RETURNS_RETAINED_BLOCK +DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_block_t +dispatch_block_create_with_qos_class(dispatch_block_flags_t flags, + dispatch_qos_class_t qos_class, int relative_priority, + dispatch_block_t block); + +/*! + * @function dispatch_block_perform + * + * @abstract + * Create, synchronously execute and release a dispatch block object from the + * specified block and flags. + * + * @discussion + * Behaves identically to the sequence + * + * dispatch_block_t b = dispatch_block_create(flags, block); + * b(); + * Block_release(b); + * + * but may be implemented more efficiently internally by not requiring a copy + * to the heap of the specified block or the allocation of a new block object. + * + * @param flags + * Configuration flags for the temporary block object. + * The result of passing a value that is not a bitwise OR of flags from + * dispatch_block_flags_t is undefined. + * + * @param block + * The block to create the temporary block object from. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW +void +dispatch_block_perform(dispatch_block_flags_t flags, + DISPATCH_NOESCAPE dispatch_block_t block); + +/*! + * @function dispatch_block_wait + * + * @abstract + * Wait synchronously until execution of the specified dispatch block object has + * completed or until the specified timeout has elapsed. + * + * @discussion + * This function will return immediately if execution of the block object has + * already completed. + * + * It is not possible to wait for multiple executions of the same block object + * with this interface; use dispatch_group_wait() for that purpose. A single + * dispatch block object may either be waited on once and executed once, + * or it may be executed any number of times. The behavior of any other + * combination is undefined. Submission to a dispatch queue counts as an + * execution, even if cancellation (dispatch_block_cancel) means the block's + * code never runs. + * + * The result of calling this function from multiple threads simultaneously + * with the same dispatch block object is undefined, but note that doing so + * would violate the rules described in the previous paragraph. + * + * If this function returns indicating that the specified timeout has elapsed, + * then that invocation does not count as the one allowed wait. + * + * If at the time this function is called, the specified dispatch block object + * has been submitted directly to a serial queue, the system will make a best + * effort to apply the necessary QOS overrides to ensure that the block and any + * blocks submitted earlier to that serial queue are executed at the QOS class + * (or higher) of the thread calling dispatch_block_wait(). + * + * @param block + * The dispatch block object to wait on. + * The result of passing NULL or a block object not returned by one of the + * dispatch_block_create* functions is undefined. + * + * @param timeout + * When to timeout (see dispatch_time). As a convenience, there are the + * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants. + * + * @result + * Returns zero on success (the dispatch block object completed within the + * specified timeout) or non-zero on error (i.e. timed out). + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +intptr_t +dispatch_block_wait(dispatch_block_t block, dispatch_time_t timeout); + +/*! + * @function dispatch_block_notify + * + * @abstract + * Schedule a notification block to be submitted to a queue when the execution + * of a specified dispatch block object has completed. + * + * @discussion + * This function will submit the notification block immediately if execution of + * the observed block object has already completed. + * + * It is not possible to be notified of multiple executions of the same block + * object with this interface, use dispatch_group_notify() for that purpose. + * + * A single dispatch block object may either be observed one or more times + * and executed once, or it may be executed any number of times. The behavior + * of any other combination is undefined. Submission to a dispatch queue + * counts as an execution, even if cancellation (dispatch_block_cancel) means + * the block's code never runs. + * + * If multiple notification blocks are scheduled for a single block object, + * there is no defined order in which the notification blocks will be submitted + * to their associated queues. + * + * @param block + * The dispatch block object to observe. + * The result of passing NULL or a block object not returned by one of the + * dispatch_block_create* functions is undefined. + * + * @param queue + * The queue to which the supplied notification block will be submitted when + * the observed block completes. + * + * @param notification_block + * The notification block to submit when the observed block object completes. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_block_notify(dispatch_block_t block, dispatch_queue_t queue, + dispatch_block_t notification_block); + +/*! + * @function dispatch_block_cancel + * + * @abstract + * Asynchronously cancel the specified dispatch block object. + * + * @discussion + * Cancellation causes any future execution of the dispatch block object to + * return immediately, but does not affect any execution of the block object + * that is already in progress. + * + * Release of any resources associated with the block object will be delayed + * until execution of the block object is next attempted (or any execution + * already in progress completes). + * + * NOTE: care needs to be taken to ensure that a block object that may be + * canceled does not capture any resources that require execution of the + * block body in order to be released (e.g. memory allocated with + * malloc(3) that the block body calls free(3) on). Such resources will + * be leaked if the block body is never executed due to cancellation. + * + * @param block + * The dispatch block object to cancel. + * The result of passing NULL or a block object not returned by one of the + * dispatch_block_create* functions is undefined. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_block_cancel(dispatch_block_t block); + +/*! + * @function dispatch_block_testcancel + * + * @abstract + * Tests whether the given dispatch block object has been canceled. + * + * @param block + * The dispatch block object to test. + * The result of passing NULL or a block object not returned by one of the + * dispatch_block_create* functions is undefined. + * + * @result + * Non-zero if canceled and zero if not canceled. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +intptr_t +dispatch_block_testcancel(dispatch_block_t block); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif // __BLOCKS__ + +#endif // __DISPATCH_BLOCK__ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/dispatch/dispatch.h b/lib/libc/include/aarch64-macos-gnu/dispatch/dispatch.h new file mode 100644 index 0000000000..34274a7a0f --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/dispatch/dispatch.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2008-2013 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 __DISPATCH_PUBLIC__ +#define __DISPATCH_PUBLIC__ + +#ifdef __APPLE__ +#include +#include +#include +#include +#elif defined(_WIN32) +#include +#elif defined(__unix__) +#include +#endif + +#include +#include +#include +#include +#include +#include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#include +#endif +#include +#if defined(_WIN32) +#include +#endif + +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__has_feature) +#if __has_feature(modules) +#if !defined(__arm__) +#include // for off_t (to match Glibc.modulemap) +#endif +#endif +#endif + +#define DISPATCH_API_VERSION 20181008 + +#ifndef __DISPATCH_INDIRECT__ +#define __DISPATCH_INDIRECT__ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#undef __DISPATCH_INDIRECT__ + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/dispatch/group.h b/lib/libc/include/aarch64-macos-gnu/dispatch/group.h new file mode 100644 index 0000000000..549da4b3fc --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/dispatch/group.h @@ -0,0 +1,279 @@ +/* + * Copyright (c) 2008-2013 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 __DISPATCH_GROUP__ +#define __DISPATCH_GROUP__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @typedef dispatch_group_t + * @abstract + * A group of blocks submitted to queues for asynchronous invocation. + */ +DISPATCH_DECL(dispatch_group); + +__BEGIN_DECLS + +/*! + * @function dispatch_group_create + * + * @abstract + * Creates new group with which blocks may be associated. + * + * @discussion + * This function creates a new group with which blocks may be associated. + * The dispatch group may be used to wait for the completion of the blocks it + * references. The group object memory is freed with dispatch_release(). + * + * @result + * The newly created group, or NULL on failure. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_group_t +dispatch_group_create(void); + +/*! + * @function dispatch_group_async + * + * @abstract + * Submits a block to a dispatch queue and associates the block with the given + * dispatch group. + * + * @discussion + * Submits a block to a dispatch queue and associates the block with the given + * dispatch group. The dispatch group may be used to wait for the completion + * of the blocks it references. + * + * @param group + * A dispatch group to associate with the submitted block. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The dispatch queue to which the block will be submitted for asynchronous + * invocation. + * + * @param block + * The block to perform asynchronously. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_group_async(dispatch_group_t group, + dispatch_queue_t queue, + dispatch_block_t block); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_group_async_f + * + * @abstract + * Submits a function to a dispatch queue and associates the block with the + * given dispatch group. + * + * @discussion + * See dispatch_group_async() for details. + * + * @param group + * A dispatch group to associate with the submitted function. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The dispatch queue to which the function will be submitted for asynchronous + * invocation. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_group_async_f(). + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_NONNULL4 +DISPATCH_NOTHROW +void +dispatch_group_async_f(dispatch_group_t group, + dispatch_queue_t queue, + void *_Nullable context, + dispatch_function_t work); + +/*! + * @function dispatch_group_wait + * + * @abstract + * Wait synchronously until all the blocks associated with a group have + * completed or until the specified timeout has elapsed. + * + * @discussion + * This function waits for the completion of the blocks associated with the + * given dispatch group, and returns after all blocks have completed or when + * the specified timeout has elapsed. + * + * This function will return immediately if there are no blocks associated + * with the dispatch group (i.e. the group is empty). + * + * The result of calling this function from multiple threads simultaneously + * with the same dispatch group is undefined. + * + * After the successful return of this function, the dispatch group is empty. + * It may either be released with dispatch_release() or re-used for additional + * blocks. See dispatch_group_async() for more information. + * + * @param group + * The dispatch group to wait on. + * The result of passing NULL in this parameter is undefined. + * + * @param timeout + * When to timeout (see dispatch_time). As a convenience, there are the + * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants. + * + * @result + * Returns zero on success (all blocks associated with the group completed + * within the specified timeout) or non-zero on error (i.e. timed out). + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +intptr_t +dispatch_group_wait(dispatch_group_t group, dispatch_time_t timeout); + +/*! + * @function dispatch_group_notify + * + * @abstract + * Schedule a block to be submitted to a queue when all the blocks associated + * with a group have completed. + * + * @discussion + * This function schedules a notification block to be submitted to the specified + * queue once all blocks associated with the dispatch group have completed. + * + * If no blocks are associated with the dispatch group (i.e. the group is empty) + * then the notification block will be submitted immediately. + * + * The group will be empty at the time the notification block is submitted to + * the target queue. The group may either be released with dispatch_release() + * or reused for additional operations. + * See dispatch_group_async() for more information. + * + * @param group + * The dispatch group to observe. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The queue to which the supplied block will be submitted when the group + * completes. + * + * @param block + * The block to submit when the group completes. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_group_notify(dispatch_group_t group, + dispatch_queue_t queue, + dispatch_block_t block); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_group_notify_f + * + * @abstract + * Schedule a function to be submitted to a queue when all the blocks + * associated with a group have completed. + * + * @discussion + * See dispatch_group_notify() for details. + * + * @param group + * The dispatch group to observe. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_group_notify_f(). + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL2 DISPATCH_NONNULL4 +DISPATCH_NOTHROW +void +dispatch_group_notify_f(dispatch_group_t group, + dispatch_queue_t queue, + void *_Nullable context, + dispatch_function_t work); + +/*! + * @function dispatch_group_enter + * + * @abstract + * Manually indicate a block has entered the group + * + * @discussion + * Calling this function indicates another block has joined the group through + * a means other than dispatch_group_async(). Calls to this function must be + * balanced with dispatch_group_leave(). + * + * @param group + * The dispatch group to update. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_group_enter(dispatch_group_t group); + +/*! + * @function dispatch_group_leave + * + * @abstract + * Manually indicate a block in the group has completed + * + * @discussion + * Calling this function indicates block has completed and left the dispatch + * group by a means other than dispatch_group_async(). + * + * @param group + * The dispatch group to update. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_group_leave(dispatch_group_t group); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/dispatch/object.h b/lib/libc/include/aarch64-macos-gnu/dispatch/object.h new file mode 100644 index 0000000000..c658773f09 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/dispatch/object.h @@ -0,0 +1,606 @@ +/* + * Copyright (c) 2008-2012 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 __DISPATCH_OBJECT__ +#define __DISPATCH_OBJECT__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +#if __has_include() +#include +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @typedef dispatch_object_t + * + * @abstract + * Abstract base type for all dispatch objects. + * The details of the type definition are language-specific. + * + * @discussion + * Dispatch objects are reference counted via calls to dispatch_retain() and + * dispatch_release(). + */ + +#if OS_OBJECT_USE_OBJC +/* + * By default, dispatch 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. + * See for details. + */ +OS_OBJECT_DECL_CLASS(dispatch_object); + +#if OS_OBJECT_SWIFT3 +#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS_SWIFT(name, dispatch_object) +#define DISPATCH_DECL_SUBCLASS(name, base) OS_OBJECT_DECL_SUBCLASS_SWIFT(name, base) +#else // OS_OBJECT_SWIFT3 +#define DISPATCH_DECL(name) OS_OBJECT_DECL_SUBCLASS(name, dispatch_object) +#define DISPATCH_DECL_SUBCLASS(name, base) OS_OBJECT_DECL_SUBCLASS(name, base) + +DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +_dispatch_object_validate(dispatch_object_t object) +{ + void *isa = *(void *volatile*)(OS_OBJECT_BRIDGE void*)object; + (void)isa; +} +#endif // OS_OBJECT_SWIFT3 + +#define DISPATCH_GLOBAL_OBJECT(type, object) ((OS_OBJECT_BRIDGE type)&(object)) +#define DISPATCH_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED +#elif defined(__cplusplus) && !defined(__DISPATCH_BUILDING_DISPATCH__) +/* + * Dispatch objects are NOT C++ objects. Nevertheless, we can at least keep C++ + * aware of type compatibility. + */ +typedef struct dispatch_object_s { +private: + dispatch_object_s(); + ~dispatch_object_s(); + dispatch_object_s(const dispatch_object_s &); + void operator=(const dispatch_object_s &); +} *dispatch_object_t; +#define DISPATCH_DECL(name) \ + typedef struct name##_s : public dispatch_object_s {} *name##_t +#define DISPATCH_DECL_SUBCLASS(name, base) \ + typedef struct name##_s : public base##_s {} *name##_t +#define DISPATCH_GLOBAL_OBJECT(type, object) (static_cast(&(object))) +#define DISPATCH_RETURNS_RETAINED +#else /* Plain C */ +typedef union { + struct _os_object_s *_os_obj; + struct dispatch_object_s *_do; + struct dispatch_queue_s *_dq; + struct dispatch_queue_attr_s *_dqa; + struct dispatch_group_s *_dg; + struct dispatch_source_s *_ds; + struct dispatch_channel_s *_dch; + struct dispatch_mach_s *_dm; + struct dispatch_mach_msg_s *_dmsg; + struct dispatch_semaphore_s *_dsema; + struct dispatch_data_s *_ddata; + struct dispatch_io_s *_dchannel; +} dispatch_object_t DISPATCH_TRANSPARENT_UNION; +#define DISPATCH_DECL(name) typedef struct name##_s *name##_t +#define DISPATCH_DECL_SUBCLASS(name, base) typedef base##_t name##_t +#define DISPATCH_GLOBAL_OBJECT(type, object) ((type)&(object)) +#define DISPATCH_RETURNS_RETAINED +#endif + +#if OS_OBJECT_SWIFT3 && OS_OBJECT_USE_OBJC +#define DISPATCH_SOURCE_TYPE_DECL(name) \ + DISPATCH_EXPORT struct dispatch_source_type_s \ + _dispatch_source_type_##name; \ + OS_OBJECT_DECL_PROTOCOL(dispatch_source_##name, ); \ + OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL( \ + dispatch_source, dispatch_source_##name) +#define DISPATCH_SOURCE_DECL(name) \ + DISPATCH_DECL(name); \ + OS_OBJECT_DECL_PROTOCOL(name, ); \ + OS_OBJECT_CLASS_IMPLEMENTS_PROTOCOL(name, name) +#ifndef DISPATCH_DATA_DECL +#define DISPATCH_DATA_DECL(name) OS_OBJECT_DECL_SWIFT(name) +#endif // DISPATCH_DATA_DECL +#else +#define DISPATCH_SOURCE_DECL(name) \ + DISPATCH_DECL(name); +#define DISPATCH_DATA_DECL(name) DISPATCH_DECL(name) +#define DISPATCH_SOURCE_TYPE_DECL(name) \ + DISPATCH_EXPORT const struct dispatch_source_type_s \ + _dispatch_source_type_##name +#endif + +#ifdef __BLOCKS__ +/*! + * @typedef dispatch_block_t + * + * @abstract + * The type of blocks submitted to dispatch queues, which take no arguments + * and have no return 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: + * + * dispatch_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 (^dispatch_block_t)(void); +#endif // __BLOCKS__ + +__BEGIN_DECLS + +/*! + * @typedef dispatch_qos_class_t + * Alias for qos_class_t type. + */ +#if __has_include() +typedef qos_class_t dispatch_qos_class_t; +#else +typedef unsigned int dispatch_qos_class_t; +#endif + +/*! + * @function dispatch_retain + * + * @abstract + * Increment the reference count of a dispatch object. + * + * @discussion + * Calls to dispatch_retain() must be balanced with calls to + * dispatch_release(). + * + * @param object + * The object to retain. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +DISPATCH_SWIFT_UNAVAILABLE("Can't be used with ARC") +void +dispatch_retain(dispatch_object_t object); +#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE +#undef dispatch_retain +#define dispatch_retain(object) \ + __extension__({ dispatch_object_t _o = (object); \ + _dispatch_object_validate(_o); (void)[_o retain]; }) +#endif + +/*! + * @function dispatch_release + * + * @abstract + * Decrement the reference count of a dispatch object. + * + * @discussion + * A dispatch object is asynchronously deallocated once all references are + * released (i.e. the reference count becomes zero). The system does not + * guarantee that a given client is the last or only reference to a given + * object. + * + * @param object + * The object to release. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +DISPATCH_SWIFT_UNAVAILABLE("Can't be used with ARC") +void +dispatch_release(dispatch_object_t object); +#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE +#undef dispatch_release +#define dispatch_release(object) \ + __extension__({ dispatch_object_t _o = (object); \ + _dispatch_object_validate(_o); [_o release]; }) +#endif + +/*! + * @function dispatch_get_context + * + * @abstract + * Returns the application defined context of the object. + * + * @param object + * The result of passing NULL in this parameter is undefined. + * + * @result + * The context of the object; may be NULL. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_PURE DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +void *_Nullable +dispatch_get_context(dispatch_object_t object); + +/*! + * @function dispatch_set_context + * + * @abstract + * Associates an application defined context with the object. + * + * @param object + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The new client defined context for the object. This may be NULL. + * + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW +void +dispatch_set_context(dispatch_object_t object, void *_Nullable context); + +/*! + * @function dispatch_set_finalizer_f + * + * @abstract + * Set the finalizer function for a dispatch object. + * + * @param object + * The dispatch object to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param finalizer + * The finalizer function pointer. + * + * @discussion + * A dispatch object's finalizer will be invoked on the object's target queue + * after all references to the object have been released. This finalizer may be + * used by the application to release any resources associated with the object, + * such as freeing the object's context. + * The context parameter passed to the finalizer function is the current + * context of the dispatch object at the time the finalizer call is made. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW +void +dispatch_set_finalizer_f(dispatch_object_t object, + dispatch_function_t _Nullable finalizer); + +/*! + * @function dispatch_activate + * + * @abstract + * Activates the specified dispatch object. + * + * @discussion + * Dispatch objects such as queues and sources may be created in an inactive + * state. Objects in this state have to be activated before any blocks + * associated with them will be invoked. + * + * The target queue of inactive objects can be changed using + * dispatch_set_target_queue(). Change of target queue is no longer permitted + * once an initially inactive object has been activated. + * + * Calling dispatch_activate() on an active object has no effect. + * Releasing the last reference count on an inactive object is undefined. + * + * @param object + * The object to be activated. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_activate(dispatch_object_t object); + +/*! + * @function dispatch_suspend + * + * @abstract + * Suspends the invocation of blocks on a dispatch object. + * + * @discussion + * A suspended object will not invoke any blocks associated with it. The + * suspension of an object will occur after any running block associated with + * the object completes. + * + * Calls to dispatch_suspend() must be balanced with calls + * to dispatch_resume(). + * + * @param object + * The object to be suspended. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_suspend(dispatch_object_t object); + +/*! + * @function dispatch_resume + * + * @abstract + * Resumes the invocation of blocks on a dispatch object. + * + * @discussion + * Dispatch objects can be suspended with dispatch_suspend(), which increments + * an internal suspension count. dispatch_resume() is the inverse operation, + * and consumes suspension counts. When the last suspension count is consumed, + * blocks associated with the object will be invoked again. + * + * For backward compatibility reasons, dispatch_resume() on an inactive and not + * otherwise suspended dispatch source object has the same effect as calling + * dispatch_activate(). For new code, using dispatch_activate() is preferred. + * + * If the specified object has zero suspension count and is not an inactive + * source, this function will result in an assertion and the process being + * terminated. + * + * @param object + * The object to be resumed. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_resume(dispatch_object_t object); + +/*! + * @function dispatch_set_qos_class_floor + * + * @abstract + * Sets the QOS class floor on a dispatch queue, source or workloop. + * + * @discussion + * The QOS class of workitems submitted to this object asynchronously will be + * elevated to at least the specified QOS class floor. The QOS of the workitem + * will be used if higher than the floor even when the workitem has been created + * without "ENFORCE" semantics. + * + * Setting the QOS class floor is equivalent to the QOS effects of configuring + * a queue whose target queue has a QoS class set to the same value. + * + * @param object + * A dispatch queue, workloop, or source to configure. + * The object must be inactive. + * + * Passing another object type or an object that has been activated is undefined + * and will cause the process to be terminated. + * + * @param qos_class + * A QOS class value: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * Passing any other value is undefined. + * + * @param relative_priority + * A relative priority within the QOS class. This value is a negative + * offset from the maximum supported scheduler priority for the given class. + * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY + * is undefined. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW +void +dispatch_set_qos_class_floor(dispatch_object_t object, + dispatch_qos_class_t qos_class, int relative_priority); + +#ifdef __BLOCKS__ +/*! + * @function dispatch_wait + * + * @abstract + * Wait synchronously for an object or until the specified timeout has elapsed. + * + * @discussion + * Type-generic macro that maps to dispatch_block_wait, dispatch_group_wait or + * dispatch_semaphore_wait, depending on the type of the first argument. + * See documentation for these functions for more details. + * This function is unavailable for any other object type. + * + * @param object + * The object to wait on. + * The result of passing NULL in this parameter is undefined. + * + * @param timeout + * When to timeout (see dispatch_time). As a convenience, there are the + * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants. + * + * @result + * Returns zero on success or non-zero on error (i.e. timed out). + */ +DISPATCH_UNAVAILABLE +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +intptr_t +dispatch_wait(void *object, dispatch_time_t timeout); +#if __has_extension(c_generic_selections) +#define dispatch_wait(object, timeout) \ + _Generic((object), \ + dispatch_block_t:dispatch_block_wait, \ + dispatch_group_t:dispatch_group_wait, \ + dispatch_semaphore_t:dispatch_semaphore_wait \ + )((object),(timeout)) +#endif + +/*! + * @function dispatch_notify + * + * @abstract + * Schedule a notification block to be submitted to a queue when the execution + * of a specified object has completed. + * + * @discussion + * Type-generic macro that maps to dispatch_block_notify or + * dispatch_group_notify, depending on the type of the first argument. + * See documentation for these functions for more details. + * This function is unavailable for any other object type. + * + * @param object + * The object to observe. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The queue to which the supplied notification block will be submitted when + * the observed object completes. + * + * @param notification_block + * The block to submit when the observed object completes. + */ +DISPATCH_UNAVAILABLE +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_notify(void *object, dispatch_object_t queue, + dispatch_block_t notification_block); +#if __has_extension(c_generic_selections) +#define dispatch_notify(object, queue, notification_block) \ + _Generic((object), \ + dispatch_block_t:dispatch_block_notify, \ + dispatch_group_t:dispatch_group_notify \ + )((object),(queue), (notification_block)) +#endif + +/*! + * @function dispatch_cancel + * + * @abstract + * Cancel the specified object. + * + * @discussion + * Type-generic macro that maps to dispatch_block_cancel or + * dispatch_source_cancel, depending on the type of the first argument. + * See documentation for these functions for more details. + * This function is unavailable for any other object type. + * + * @param object + * The object to cancel. + * The result of passing NULL in this parameter is undefined. + */ +DISPATCH_UNAVAILABLE +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_cancel(void *object); +#if __has_extension(c_generic_selections) +#define dispatch_cancel(object) \ + _Generic((object), \ + dispatch_block_t:dispatch_block_cancel, \ + dispatch_source_t:dispatch_source_cancel \ + )((object)) +#endif + +/*! + * @function dispatch_testcancel + * + * @abstract + * Test whether the specified object has been canceled + * + * @discussion + * Type-generic macro that maps to dispatch_block_testcancel or + * dispatch_source_testcancel, depending on the type of the first argument. + * See documentation for these functions for more details. + * This function is unavailable for any other object type. + * + * @param object + * The object to test. + * The result of passing NULL in this parameter is undefined. + * + * @result + * Non-zero if canceled and zero if not canceled. + */ +DISPATCH_UNAVAILABLE +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +intptr_t +dispatch_testcancel(void *object); +#if __has_extension(c_generic_selections) +#define dispatch_testcancel(object) \ + _Generic((object), \ + dispatch_block_t:dispatch_block_testcancel, \ + dispatch_source_t:dispatch_source_testcancel \ + )((object)) +#endif +#endif // __BLOCKS__ + +/*! + * @function dispatch_debug + * + * @abstract + * Programmatically log debug information about a dispatch object. + * + * @discussion + * Programmatically log debug information about a dispatch object. By default, + * the log output is sent to syslog at notice level. In the debug version of + * the library, the log output is sent to a file in /var/tmp. + * The log output destination can be configured via the LIBDISPATCH_LOG + * environment variable, valid values are: YES, NO, syslog, stderr, file. + * + * This function is deprecated and will be removed in a future release. + * Objective-C callers may use -debugDescription instead. + * + * @param object + * The object to introspect. + * + * @param message + * The message to log above and beyond the introspection. + */ +API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW DISPATCH_COLD +__attribute__((__format__(printf,2,3))) +void +dispatch_debug(dispatch_object_t object, const char *message, ...); + +API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW DISPATCH_COLD +__attribute__((__format__(printf,2,0))) +void +dispatch_debugv(dispatch_object_t object, const char *message, va_list ap); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/dispatch/queue.h b/lib/libc/include/aarch64-macos-gnu/dispatch/queue.h new file mode 100644 index 0000000000..f4f8ab673e --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/dispatch/queue.h @@ -0,0 +1,1674 @@ +/* + * Copyright (c) 2008-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 __DISPATCH_QUEUE__ +#define __DISPATCH_QUEUE__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @header + * + * Dispatch is an abstract model for expressing concurrency via simple but + * powerful API. + * + * At the core, dispatch provides serial FIFO queues to which blocks may be + * submitted. Blocks submitted to these dispatch queues are invoked on a pool + * of threads fully managed by the system. No guarantee is made regarding + * which thread a block will be invoked on; however, it is guaranteed that only + * one block submitted to the FIFO dispatch queue will be invoked at a time. + * + * When multiple queues have blocks to be processed, the system is free to + * allocate additional threads to invoke the blocks concurrently. When the + * queues become empty, these threads are automatically released. + */ + +/*! + * @typedef dispatch_queue_t + * + * @abstract + * Dispatch queues invoke workitems submitted to them. + * + * @discussion + * Dispatch queues come in many flavors, the most common one being the dispatch + * serial queue (See dispatch_queue_serial_t). + * + * The system manages a pool of threads which process dispatch queues and invoke + * workitems submitted to them. + * + * Conceptually a dispatch queue may have its own thread of execution, and + * interaction between queues is highly asynchronous. + * + * Dispatch queues are reference counted via calls to dispatch_retain() and + * dispatch_release(). Pending workitems submitted to a queue also hold a + * reference to the queue until they have finished. Once all references to a + * queue have been released, the queue will be deallocated by the system. + */ +DISPATCH_DECL(dispatch_queue); + +/*! + * @typedef dispatch_queue_global_t + * + * @abstract + * Dispatch global concurrent queues are an abstraction around the system thread + * pool which invokes workitems that are submitted to dispatch queues. + * + * @discussion + * Dispatch global concurrent queues provide buckets of priorities on top of the + * thread pool the system manages. The system will decide how many threads + * to allocate to this pool depending on demand and system load. In particular, + * the system tries to maintain a good level of concurrency for this resource, + * and will create new threads when too many existing worker threads block in + * system calls. + * + * The global concurrent queues are a shared resource and as such it is the + * responsiblity of every user of this resource to not submit an unbounded + * amount of work to this pool, especially work that may block, as this can + * cause the system to spawn very large numbers of threads (aka. thread + * explosion). + * + * Work items submitted to the global concurrent queues have no ordering + * guarantee with respect to the order of submission, and workitems submitted + * to these queues may be invoked concurrently. + * + * Dispatch global concurrent queues are well-known global objects that are + * returned by dispatch_get_global_queue(). These objects cannot be modified. + * Calls to dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc., + * will have no effect when used with queues of this type. + */ +DISPATCH_DECL_SUBCLASS(dispatch_queue_global, dispatch_queue); + +/*! + * @typedef dispatch_queue_serial_t + * + * @abstract + * Dispatch serial queues invoke workitems submitted to them serially in FIFO + * order. + * + * @discussion + * Dispatch serial queues are lightweight objects to which workitems may be + * submitted to be invoked in FIFO order. A serial queue will only invoke one + * workitem at a time, but independent serial queues may each invoke their work + * items concurrently with respect to each other. + * + * Serial queues can target each other (See dispatch_set_target_queue()). The + * serial queue at the bottom of a queue hierarchy provides an exclusion + * context: at most one workitem submitted to any of the queues in such + * a hiearchy will run at any given time. + * + * Such hierarchies provide a natural construct to organize an application + * subsystem around. + * + * Serial queues are created by passing a dispatch queue attribute derived from + * DISPATCH_QUEUE_SERIAL to dispatch_queue_create_with_target(). + */ +DISPATCH_DECL_SUBCLASS(dispatch_queue_serial, dispatch_queue); + +/*! + * @typedef dispatch_queue_main_t + * + * @abstract + * The type of the default queue that is bound to the main thread. + * + * @discussion + * The main queue is a serial queue (See dispatch_queue_serial_t) which is bound + * to the main thread of an application. + * + * In order to invoke workitems submitted to the main queue, the application + * must call dispatch_main(), NSApplicationMain(), or use a CFRunLoop on the + * main thread. + * + * The main queue is a well known global object that is made automatically on + * behalf of the main thread during process initialization and is returned by + * dispatch_get_main_queue(). This object cannot be modified. Calls to + * dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc., will + * have no effect when used on the main queue. + */ +DISPATCH_DECL_SUBCLASS(dispatch_queue_main, dispatch_queue_serial); + +/*! + * @typedef dispatch_queue_concurrent_t + * + * @abstract + * Dispatch concurrent queues invoke workitems submitted to them concurrently, + * and admit a notion of barrier workitems. + * + * @discussion + * Dispatch concurrent queues are lightweight objects to which regular and + * barrier workitems may be submited. Barrier workitems are invoked in + * exclusion of any other kind of workitem in FIFO order. + * + * Regular workitems can be invoked concurrently for the same concurrent queue, + * in any order. However, regular workitems will not be invoked before any + * barrier workitem submited ahead of them has been invoked. + * + * In other words, if a serial queue is equivalent to a mutex in the Dispatch + * world, a concurrent queue is equivalent to a reader-writer lock, where + * regular items are readers and barriers are writers. + * + * Concurrent queues are created by passing a dispatch queue attribute derived + * from DISPATCH_QUEUE_CONCURRENT to dispatch_queue_create_with_target(). + * + * Caveat: + * Dispatch concurrent queues at this time do not implement priority inversion + * avoidance when lower priority regular workitems (readers) are being invoked + * and are preventing a higher priority barrier (writer) from being invoked. + */ +DISPATCH_DECL_SUBCLASS(dispatch_queue_concurrent, dispatch_queue); + +__BEGIN_DECLS + +/*! + * @function dispatch_async + * + * @abstract + * Submits a block for asynchronous execution on a dispatch queue. + * + * @discussion + * The dispatch_async() function is the fundamental mechanism for submitting + * blocks to a dispatch queue. + * + * Calls to dispatch_async() always return immediately after the block has + * been submitted, and never wait for the block to be invoked. + * + * The target queue determines whether the block will be invoked serially or + * concurrently with respect to other blocks submitted to that same queue. + * Serial queues are processed concurrently with respect to each other. + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The system will hold a reference on the target queue until the block + * has finished. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to submit to the target dispatch queue. This function performs + * Block_copy() and Block_release() on behalf of callers. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_async(dispatch_queue_t queue, dispatch_block_t block); +#endif + +/*! + * @function dispatch_async_f + * + * @abstract + * Submits a function for asynchronous execution on a dispatch queue. + * + * @discussion + * See dispatch_async() for details. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The system will hold a reference on the target queue until the function + * has returned. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_async_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_async_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @function dispatch_sync + * + * @abstract + * Submits a block for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a workitem to a dispatch queue like dispatch_async(), however + * dispatch_sync() will not return until the workitem has finished. + * + * Work items submitted to a queue with dispatch_sync() do not observe certain + * queue attributes of that queue when invoked (such as autorelease frequency + * and QOS class). + * + * Calls to dispatch_sync() targeting the current queue will result + * in dead-lock. Use of dispatch_sync() is also subject to the same + * multi-party dead-lock problems that may result from the use of a mutex. + * Use of dispatch_async() is preferred. + * + * Unlike dispatch_async(), no retain is performed on the target queue. Because + * calls to this function are synchronous, the dispatch_sync() "borrows" the + * reference of the caller. + * + * As an optimization, dispatch_sync() invokes the workitem on the thread which + * submitted the workitem, except when the passed queue is the main queue or + * a queue targetting it (See dispatch_queue_main_t, + * dispatch_set_target_queue()). + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to be invoked on the target dispatch queue. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_sync(dispatch_queue_t queue, DISPATCH_NOESCAPE dispatch_block_t block); +#endif + +/*! + * @function dispatch_sync_f + * + * @abstract + * Submits a function for synchronous execution on a dispatch queue. + * + * @discussion + * See dispatch_sync() for details. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_sync_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_sync_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @function dispatch_async_and_wait + * + * @abstract + * Submits a block for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a workitem to a dispatch queue like dispatch_async(), however + * dispatch_async_and_wait() will not return until the workitem has finished. + * + * Like functions of the dispatch_sync family, dispatch_async_and_wait() is + * subject to dead-lock (See dispatch_sync() for details). + * + * However, dispatch_async_and_wait() differs from functions of the + * dispatch_sync family in two fundamental ways: how it respects queue + * attributes and how it chooses the execution context invoking the workitem. + * + * Differences with dispatch_sync() + * + * Work items submitted to a queue with dispatch_async_and_wait() observe all + * queue attributes of that queue when invoked (inluding autorelease frequency + * or QOS class). + * + * When the runtime has brought up a thread to invoke the asynchronous workitems + * already submitted to the specified queue, that servicing thread will also be + * used to execute synchronous work submitted to the queue with + * dispatch_async_and_wait(). + * + * However, if the runtime has not brought up a thread to service the specified + * queue (because it has no workitems enqueued, or only synchronous workitems), + * then dispatch_async_and_wait() will invoke the workitem on the calling thread, + * similar to the behaviour of functions in the dispatch_sync family. + * + * As an exception, if the queue the work is submitted to doesn't target + * a global concurrent queue (for example because it targets the main queue), + * then the workitem will never be invoked by the thread calling + * dispatch_async_and_wait(). + * + * In other words, dispatch_async_and_wait() is similar to submitting + * a dispatch_block_create()d workitem to a queue and then waiting on it, as + * shown in the code example below. However, dispatch_async_and_wait() is + * significantly more efficient when a new thread is not required to execute + * the workitem (as it will use the stack of the submitting thread instead of + * requiring heap allocations). + * + * + * dispatch_block_t b = dispatch_block_create(0, block); + * dispatch_async(queue, b); + * dispatch_block_wait(b, DISPATCH_TIME_FOREVER); + * Block_release(b); + * + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to be invoked on the target dispatch queue. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_async_and_wait(dispatch_queue_t queue, + DISPATCH_NOESCAPE dispatch_block_t block); +#endif + +/*! + * @function dispatch_async_and_wait_f + * + * @abstract + * Submits a function for synchronous execution on a dispatch queue. + * + * @discussion + * See dispatch_async_and_wait() for details. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_async_and_wait_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_async_and_wait_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + + +#if defined(__APPLE__) && \ + (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \ + __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ + __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9) +#define DISPATCH_APPLY_AUTO_AVAILABLE 0 +#define DISPATCH_APPLY_QUEUE_ARG_NULLABILITY _Nonnull +#else +#define DISPATCH_APPLY_AUTO_AVAILABLE 1 +#define DISPATCH_APPLY_QUEUE_ARG_NULLABILITY _Nullable +#endif + +/*! + * @constant DISPATCH_APPLY_AUTO + * + * @abstract + * Constant to pass to dispatch_apply() or dispatch_apply_f() to request that + * the system automatically use worker threads that match the configuration of + * the current thread as closely as possible. + * + * @discussion + * When submitting a block for parallel invocation, passing this constant as the + * queue argument will automatically use the global concurrent queue that + * matches the Quality of Service of the caller most closely. + * + * No assumptions should be made about which global concurrent queue will + * actually be used. + * + * Using this constant deploys backward to macOS 10.9, iOS 7.0 and any tvOS or + * watchOS version. + */ +#if DISPATCH_APPLY_AUTO_AVAILABLE +#define DISPATCH_APPLY_AUTO ((dispatch_queue_t _Nonnull)0) +#endif + +/*! + * @function dispatch_apply + * + * @abstract + * Submits a block to a dispatch queue for parallel invocation. + * + * @discussion + * Submits a block to a dispatch queue for parallel invocation. This function + * waits for the task block to complete before returning. If the specified queue + * is concurrent, the block may be invoked concurrently, and it must therefore + * be reentrant safe. + * + * Each invocation of the block will be passed the current index of iteration. + * + * @param iterations + * The number of iterations to perform. + * + * @param queue + * The dispatch queue to which the block is submitted. + * The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use + * a queue appropriate for the calling thread. + * + * @param block + * The block to be invoked the specified number of iterations. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_apply(size_t iterations, + dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue, + DISPATCH_NOESCAPE void (^block)(size_t)); +#endif + +/*! + * @function dispatch_apply_f + * + * @abstract + * Submits a function to a dispatch queue for parallel invocation. + * + * @discussion + * See dispatch_apply() for details. + * + * @param iterations + * The number of iterations to perform. + * + * @param queue + * The dispatch queue to which the function is submitted. + * The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use + * a queue appropriate for the calling thread. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the specified queue. The first + * parameter passed to this function is the context provided to + * dispatch_apply_f(). The second parameter passed to this function is the + * current index of iteration. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL4 DISPATCH_NOTHROW +void +dispatch_apply_f(size_t iterations, + dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue, + void *_Nullable context, void (*work)(void *_Nullable, size_t)); + +/*! + * @function dispatch_get_current_queue + * + * @abstract + * Returns the queue on which the currently executing block is running. + * + * @discussion + * Returns the queue on which the currently executing block is running. + * + * When dispatch_get_current_queue() is called outside of the context of a + * submitted block, it will return the default concurrent queue. + * + * Recommended for debugging and logging purposes only: + * The code must not make any assumptions about the queue returned, unless it + * is one of the global queues or a queue the code has itself created. + * The code must not assume that synchronous execution onto a queue is safe + * from deadlock if that queue is not the one returned by + * dispatch_get_current_queue(). + * + * When dispatch_get_current_queue() is called on the main thread, it may + * or may not return the same value as dispatch_get_main_queue(). Comparing + * the two is not a valid way to test whether code is executing on the + * main thread (see dispatch_assert_queue() and dispatch_assert_queue_not()). + * + * This function is deprecated and will be removed in a future release. + * + * @result + * Returns the current queue. + */ +API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0)) +DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_queue_t +dispatch_get_current_queue(void); + +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT +struct dispatch_queue_s _dispatch_main_q; + +/*! + * @function dispatch_get_main_queue + * + * @abstract + * Returns the default queue that is bound to the main thread. + * + * @discussion + * In order to invoke blocks submitted to the main queue, the application must + * call dispatch_main(), NSApplicationMain(), or use a CFRunLoop on the main + * thread. + * + * The main queue is meant to be used in application context to interact with + * the main thread and the main runloop. + * + * Because the main queue doesn't behave entirely like a regular serial queue, + * it may have unwanted side-effects when used in processes that are not UI apps + * (daemons). For such processes, the main queue should be avoided. + * + * @see dispatch_queue_main_t + * + * @result + * Returns the main queue. This queue is created automatically on behalf of + * the main thread before main() is called. + */ +DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_CONST DISPATCH_NOTHROW +dispatch_queue_main_t +dispatch_get_main_queue(void) +{ + return DISPATCH_GLOBAL_OBJECT(dispatch_queue_main_t, _dispatch_main_q); +} + +/*! + * @typedef dispatch_queue_priority_t + * Type of dispatch_queue_priority + * + * @constant DISPATCH_QUEUE_PRIORITY_HIGH + * Items dispatched to the queue will run at high priority, + * i.e. the queue will be scheduled for execution before + * any default priority or low priority queue. + * + * @constant DISPATCH_QUEUE_PRIORITY_DEFAULT + * Items dispatched to the queue will run at the default + * priority, i.e. the queue will be scheduled for execution + * after all high priority queues have been scheduled, but + * before any low priority queues have been scheduled. + * + * @constant DISPATCH_QUEUE_PRIORITY_LOW + * Items dispatched to the queue will run at low priority, + * i.e. the queue will be scheduled for execution after all + * default priority and high priority queues have been + * scheduled. + * + * @constant DISPATCH_QUEUE_PRIORITY_BACKGROUND + * Items dispatched to the queue will run at background priority, i.e. the queue + * will be scheduled for execution after all higher priority queues have been + * scheduled and the system will run items on this queue on a thread with + * background status as per setpriority(2) (i.e. disk I/O is throttled and the + * thread's scheduling priority is set to lowest value). + */ +#define DISPATCH_QUEUE_PRIORITY_HIGH 2 +#define DISPATCH_QUEUE_PRIORITY_DEFAULT 0 +#define DISPATCH_QUEUE_PRIORITY_LOW (-2) +#define DISPATCH_QUEUE_PRIORITY_BACKGROUND INT16_MIN + +typedef long dispatch_queue_priority_t; + +/*! + * @function dispatch_get_global_queue + * + * @abstract + * Returns a well-known global concurrent queue of a given quality of service + * class. + * + * @discussion + * See dispatch_queue_global_t. + * + * @param identifier + * A quality of service class defined in qos_class_t or a priority defined in + * dispatch_queue_priority_t. + * + * It is recommended to use quality of service class values to identify the + * well-known global concurrent queues: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * + * The global concurrent queues may still be identified by their priority, + * which map to the following QOS classes: + * - DISPATCH_QUEUE_PRIORITY_HIGH: QOS_CLASS_USER_INITIATED + * - DISPATCH_QUEUE_PRIORITY_DEFAULT: QOS_CLASS_DEFAULT + * - DISPATCH_QUEUE_PRIORITY_LOW: QOS_CLASS_UTILITY + * - DISPATCH_QUEUE_PRIORITY_BACKGROUND: QOS_CLASS_BACKGROUND + * + * @param flags + * Reserved for future use. Passing any value other than zero may result in + * a NULL return value. + * + * @result + * Returns the requested global queue or NULL if the requested global queue + * does not exist. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW +dispatch_queue_global_t +dispatch_get_global_queue(intptr_t identifier, uintptr_t flags); + +/*! + * @typedef dispatch_queue_attr_t + * + * @abstract + * Attribute for dispatch queues. + */ +DISPATCH_DECL(dispatch_queue_attr); + +/*! + * @const DISPATCH_QUEUE_SERIAL + * + * @discussion + * An attribute that can be used to create a dispatch queue that invokes blocks + * serially in FIFO order. + * + * See dispatch_queue_serial_t. + */ +#define DISPATCH_QUEUE_SERIAL NULL + +/*! + * @const DISPATCH_QUEUE_SERIAL_INACTIVE + * + * @discussion + * An attribute that can be used to create a dispatch queue that invokes blocks + * serially in FIFO order, and that is initially inactive. + * + * See dispatch_queue_attr_make_initially_inactive(). + */ +#define DISPATCH_QUEUE_SERIAL_INACTIVE \ + dispatch_queue_attr_make_initially_inactive(DISPATCH_QUEUE_SERIAL) + +/*! + * @const DISPATCH_QUEUE_CONCURRENT + * + * @discussion + * An attribute that can be used to create a dispatch queue that may invoke + * blocks concurrently and supports barrier blocks submitted with the dispatch + * barrier API. + * + * See dispatch_queue_concurrent_t. + */ +#define DISPATCH_QUEUE_CONCURRENT \ + DISPATCH_GLOBAL_OBJECT(dispatch_queue_attr_t, \ + _dispatch_queue_attr_concurrent) +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT +struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent; + +/*! + * @const DISPATCH_QUEUE_CONCURRENT_INACTIVE + * + * @discussion + * An attribute that can be used to create a dispatch queue that may invoke + * blocks concurrently and supports barrier blocks submitted with the dispatch + * barrier API, and that is initially inactive. + * + * See dispatch_queue_attr_make_initially_inactive(). + */ +#define DISPATCH_QUEUE_CONCURRENT_INACTIVE \ + dispatch_queue_attr_make_initially_inactive(DISPATCH_QUEUE_CONCURRENT) + +/*! + * @function dispatch_queue_attr_make_initially_inactive + * + * @abstract + * Returns an attribute value which may be provided to dispatch_queue_create() + * or dispatch_queue_create_with_target(), in order to make the created queue + * initially inactive. + * + * @discussion + * Dispatch queues may be created in an inactive state. Queues in this state + * have to be activated before any blocks associated with them will be invoked. + * + * A queue in inactive state cannot be deallocated, dispatch_activate() must be + * called before the last reference to a queue created with this attribute is + * released. + * + * The target queue of a queue in inactive state can be changed using + * dispatch_set_target_queue(). Change of target queue is no longer permitted + * once an initially inactive queue has been activated. + * + * @param attr + * A queue attribute value to be combined with the initially inactive attribute. + * + * @return + * Returns an attribute value which may be provided to dispatch_queue_create() + * and dispatch_queue_create_with_target(). + * The new value combines the attributes specified by the 'attr' parameter with + * the initially inactive attribute. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW +dispatch_queue_attr_t +dispatch_queue_attr_make_initially_inactive( + dispatch_queue_attr_t _Nullable attr); + +/*! + * @const DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL + * + * @discussion + * A dispatch queue created with this attribute invokes blocks serially in FIFO + * order, and surrounds execution of any block submitted asynchronously to it + * with the equivalent of a individual Objective-C @autoreleasepool + * scope. + * + * See dispatch_queue_attr_make_with_autorelease_frequency(). + */ +#define DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL \ + dispatch_queue_attr_make_with_autorelease_frequency(\ + DISPATCH_QUEUE_SERIAL, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM) + +/*! + * @const DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL + * + * @discussion + * A dispatch queue created with this attribute may invokes blocks concurrently + * and supports barrier blocks submitted with the dispatch barrier API. It also + * surrounds execution of any block submitted asynchronously to it with the + * equivalent of a individual Objective-C @autoreleasepool + * + * See dispatch_queue_attr_make_with_autorelease_frequency(). + */ +#define DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL \ + dispatch_queue_attr_make_with_autorelease_frequency(\ + DISPATCH_QUEUE_CONCURRENT, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM) + +/*! + * @typedef dispatch_autorelease_frequency_t + * Values to pass to the dispatch_queue_attr_make_with_autorelease_frequency() + * function. + * + * @const DISPATCH_AUTORELEASE_FREQUENCY_INHERIT + * Dispatch queues with this autorelease frequency inherit the behavior from + * their target queue. This is the default behavior for manually created queues. + * + * @const DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM + * Dispatch queues with this autorelease frequency push and pop an autorelease + * pool around the execution of every block that was submitted to it + * asynchronously. + * @see dispatch_queue_attr_make_with_autorelease_frequency(). + * + * @const DISPATCH_AUTORELEASE_FREQUENCY_NEVER + * Dispatch queues with this autorelease frequency never set up an individual + * autorelease pool around the execution of a block that is submitted to it + * asynchronously. This is the behavior of the global concurrent queues. + */ +DISPATCH_ENUM(dispatch_autorelease_frequency, unsigned long, + DISPATCH_AUTORELEASE_FREQUENCY_INHERIT DISPATCH_ENUM_API_AVAILABLE( + macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 0, + DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM DISPATCH_ENUM_API_AVAILABLE( + macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 1, + DISPATCH_AUTORELEASE_FREQUENCY_NEVER DISPATCH_ENUM_API_AVAILABLE( + macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 2, +); + +/*! + * @function dispatch_queue_attr_make_with_autorelease_frequency + * + * @abstract + * Returns a dispatch queue attribute value with the autorelease frequency + * set to the specified value. + * + * @discussion + * When a queue uses the per-workitem autorelease frequency (either directly + * or inherithed from its target queue), any block submitted asynchronously to + * this queue (via dispatch_async(), dispatch_barrier_async(), + * dispatch_group_notify(), etc...) is executed as if surrounded by a individual + * Objective-C @autoreleasepool scope. + * + * Autorelease frequency has no effect on blocks that are submitted + * synchronously to a queue (via dispatch_sync(), dispatch_barrier_sync()). + * + * The global concurrent queues have the DISPATCH_AUTORELEASE_FREQUENCY_NEVER + * behavior. Manually created dispatch queues use + * DISPATCH_AUTORELEASE_FREQUENCY_INHERIT by default. + * + * Queues created with this attribute cannot change target queues after having + * been activated. See dispatch_set_target_queue() and dispatch_activate(). + * + * @param attr + * A queue attribute value to be combined with the specified autorelease + * frequency or NULL. + * + * @param frequency + * The requested autorelease frequency. + * + * @return + * Returns an attribute value which may be provided to dispatch_queue_create() + * or NULL if an invalid autorelease frequency was requested. + * This new value combines the attributes specified by the 'attr' parameter and + * the chosen autorelease frequency. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW +dispatch_queue_attr_t +dispatch_queue_attr_make_with_autorelease_frequency( + dispatch_queue_attr_t _Nullable attr, + dispatch_autorelease_frequency_t frequency); + +/*! + * @function dispatch_queue_attr_make_with_qos_class + * + * @abstract + * Returns an attribute value which may be provided to dispatch_queue_create() + * or dispatch_queue_create_with_target(), in order to assign a QOS class and + * relative priority to the queue. + * + * @discussion + * When specified in this manner, the QOS class and relative priority take + * precedence over those inherited from the dispatch queue's target queue (if + * any) as long that does not result in a lower QOS class and relative priority. + * + * The global queue priorities map to the following QOS classes: + * - DISPATCH_QUEUE_PRIORITY_HIGH: QOS_CLASS_USER_INITIATED + * - DISPATCH_QUEUE_PRIORITY_DEFAULT: QOS_CLASS_DEFAULT + * - DISPATCH_QUEUE_PRIORITY_LOW: QOS_CLASS_UTILITY + * - DISPATCH_QUEUE_PRIORITY_BACKGROUND: QOS_CLASS_BACKGROUND + * + * Example: + * + * dispatch_queue_t queue; + * dispatch_queue_attr_t attr; + * attr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, + * QOS_CLASS_UTILITY, 0); + * queue = dispatch_queue_create("com.example.myqueue", attr); + * + * + * The QOS class and relative priority set this way on a queue have no effect on + * blocks that are submitted synchronously to a queue (via dispatch_sync(), + * dispatch_barrier_sync()). + * + * @param attr + * A queue attribute value to be combined with the QOS class, or NULL. + * + * @param qos_class + * A QOS class value: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * Passing any other value results in NULL being returned. + * + * @param relative_priority + * A relative priority within the QOS class. This value is a negative + * offset from the maximum supported scheduler priority for the given class. + * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY + * results in NULL being returned. + * + * @return + * Returns an attribute value which may be provided to dispatch_queue_create() + * and dispatch_queue_create_with_target(), or NULL if an invalid QOS class was + * requested. + * The new value combines the attributes specified by the 'attr' parameter and + * the new QOS class and relative priority. + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW +dispatch_queue_attr_t +dispatch_queue_attr_make_with_qos_class(dispatch_queue_attr_t _Nullable attr, + dispatch_qos_class_t qos_class, int relative_priority); + +/*! + * @const DISPATCH_TARGET_QUEUE_DEFAULT + * @discussion Constant to pass to the dispatch_queue_create_with_target(), + * dispatch_set_target_queue() and dispatch_source_create() functions to + * indicate that the default target queue for the object type in question + * should be used. + */ +#define DISPATCH_TARGET_QUEUE_DEFAULT NULL + +/*! + * @function dispatch_queue_create_with_target + * + * @abstract + * Creates a new dispatch queue with a specified target queue. + * + * @discussion + * Dispatch queues created with the DISPATCH_QUEUE_SERIAL or a NULL attribute + * invoke blocks serially in FIFO order. + * + * Dispatch queues created with the DISPATCH_QUEUE_CONCURRENT attribute may + * invoke blocks concurrently (similarly to the global concurrent queues, but + * potentially with more overhead), and support barrier blocks submitted with + * the dispatch barrier API, which e.g. enables the implementation of efficient + * reader-writer schemes. + * + * When a dispatch queue is no longer needed, it should be released with + * dispatch_release(). Note that any pending blocks submitted asynchronously to + * a queue will hold a reference to that queue. Therefore a queue will not be + * deallocated until all pending blocks have finished. + * + * When using a dispatch queue attribute @a attr specifying a QoS class (derived + * from the result of dispatch_queue_attr_make_with_qos_class()), passing the + * result of dispatch_get_global_queue() in @a target will ignore the QoS class + * of that global queue and will use the global queue with the QoS class + * specified by attr instead. + * + * Queues created with dispatch_queue_create_with_target() cannot have their + * target queue changed, unless created inactive (See + * dispatch_queue_attr_make_initially_inactive()), in which case the target + * queue can be changed until the newly created queue is activated with + * dispatch_activate(). + * + * @param label + * A string label to attach to the queue. + * This parameter is optional and may be NULL. + * + * @param attr + * A predefined attribute such as DISPATCH_QUEUE_SERIAL, + * DISPATCH_QUEUE_CONCURRENT, or the result of a call to + * a dispatch_queue_attr_make_with_* function. + * + * @param target + * The target queue for the newly created queue. The target queue is retained. + * If this parameter is DISPATCH_TARGET_QUEUE_DEFAULT, sets the queue's target + * queue to the default target queue for the given queue type. + * + * @result + * The newly created dispatch queue. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_queue_t +dispatch_queue_create_with_target(const char *_Nullable label, + dispatch_queue_attr_t _Nullable attr, dispatch_queue_t _Nullable target) + DISPATCH_ALIAS_V2(dispatch_queue_create_with_target); + +/*! + * @function dispatch_queue_create + * + * @abstract + * Creates a new dispatch queue to which blocks may be submitted. + * + * @discussion + * Dispatch queues created with the DISPATCH_QUEUE_SERIAL or a NULL attribute + * invoke blocks serially in FIFO order. + * + * Dispatch queues created with the DISPATCH_QUEUE_CONCURRENT attribute may + * invoke blocks concurrently (similarly to the global concurrent queues, but + * potentially with more overhead), and support barrier blocks submitted with + * the dispatch barrier API, which e.g. enables the implementation of efficient + * reader-writer schemes. + * + * When a dispatch queue is no longer needed, it should be released with + * dispatch_release(). Note that any pending blocks submitted asynchronously to + * a queue will hold a reference to that queue. Therefore a queue will not be + * deallocated until all pending blocks have finished. + * + * Passing the result of the dispatch_queue_attr_make_with_qos_class() function + * to the attr parameter of this function allows a quality of service class and + * relative priority to be specified for the newly created queue. + * The quality of service class so specified takes precedence over the quality + * of service class of the newly created dispatch queue's target queue (if any) + * as long that does not result in a lower QOS class and relative priority. + * + * When no quality of service class is specified, the target queue of a newly + * created dispatch queue is the default priority global concurrent queue. + * + * @param label + * A string label to attach to the queue. + * This parameter is optional and may be NULL. + * + * @param attr + * A predefined attribute such as DISPATCH_QUEUE_SERIAL, + * DISPATCH_QUEUE_CONCURRENT, or the result of a call to + * a dispatch_queue_attr_make_with_* function. + * + * @result + * The newly created dispatch queue. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_queue_t +dispatch_queue_create(const char *_Nullable label, + dispatch_queue_attr_t _Nullable attr); + +/*! + * @const DISPATCH_CURRENT_QUEUE_LABEL + * @discussion Constant to pass to the dispatch_queue_get_label() function to + * retrieve the label of the current queue. + */ +#define DISPATCH_CURRENT_QUEUE_LABEL NULL + +/*! + * @function dispatch_queue_get_label + * + * @abstract + * Returns the label of the given queue, as specified when the queue was + * created, or the empty string if a NULL label was specified. + * + * Passing DISPATCH_CURRENT_QUEUE_LABEL will return the label of the current + * queue. + * + * @param queue + * The queue to query, or DISPATCH_CURRENT_QUEUE_LABEL. + * + * @result + * The label of the queue. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW +const char * +dispatch_queue_get_label(dispatch_queue_t _Nullable queue); + +/*! + * @function dispatch_queue_get_qos_class + * + * @abstract + * Returns the QOS class and relative priority of the given queue. + * + * @discussion + * If the given queue was created with an attribute value returned from + * dispatch_queue_attr_make_with_qos_class(), this function returns the QOS + * class and relative priority specified at that time; for any other attribute + * value it returns a QOS class of QOS_CLASS_UNSPECIFIED and a relative + * priority of 0. + * + * If the given queue is one of the global queues, this function returns its + * assigned QOS class value as documented under dispatch_get_global_queue() and + * a relative priority of 0; in the case of the main queue it returns the QOS + * value provided by qos_class_main() and a relative priority of 0. + * + * @param queue + * The queue to query. + * + * @param relative_priority_ptr + * A pointer to an int variable to be filled with the relative priority offset + * within the QOS class, or NULL. + * + * @return + * A QOS class value: + * - QOS_CLASS_USER_INTERACTIVE + * - QOS_CLASS_USER_INITIATED + * - QOS_CLASS_DEFAULT + * - QOS_CLASS_UTILITY + * - QOS_CLASS_BACKGROUND + * - QOS_CLASS_UNSPECIFIED + */ +API_AVAILABLE(macos(10.10), ios(8.0)) +DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NONNULL1 DISPATCH_NOTHROW +dispatch_qos_class_t +dispatch_queue_get_qos_class(dispatch_queue_t queue, + int *_Nullable relative_priority_ptr); + +/*! + * @function dispatch_set_target_queue + * + * @abstract + * Sets the target queue for the given object. + * + * @discussion + * An object's target queue is responsible for processing the object. + * + * When no quality of service class and relative priority is specified for a + * dispatch queue at the time of creation, a dispatch queue's quality of service + * class is inherited from its target queue. The dispatch_get_global_queue() + * function may be used to obtain a target queue of a specific quality of + * service class, however the use of dispatch_queue_attr_make_with_qos_class() + * is recommended instead. + * + * Blocks submitted to a serial queue whose target queue is another serial + * queue will not be invoked concurrently with blocks submitted to the target + * queue or to any other queue with that same target queue. + * + * The result of introducing a cycle into the hierarchy of target queues is + * undefined. + * + * A dispatch source's target queue specifies where its event handler and + * cancellation handler blocks will be submitted. + * + * A dispatch I/O channel's target queue specifies where where its I/O + * operations are executed. If the channel's target queue's priority is set to + * DISPATCH_QUEUE_PRIORITY_BACKGROUND, then the I/O operations performed by + * dispatch_io_read() or dispatch_io_write() on that queue will be + * throttled when there is I/O contention. + * + * For all other dispatch object types, the only function of the target queue + * is to determine where an object's finalizer function is invoked. + * + * In general, changing the target queue of an object is an asynchronous + * operation that doesn't take effect immediately, and doesn't affect blocks + * already associated with the specified object. + * + * However, if an object is inactive at the time dispatch_set_target_queue() is + * called, then the target queue change takes effect immediately, and will + * affect blocks already associated with the specified object. After an + * initially inactive object has been activated, calling + * dispatch_set_target_queue() results in an assertion and the process being + * terminated. + * + * If a dispatch queue is active and targeted by other dispatch objects, + * changing its target queue results in undefined behavior. + * + * @param object + * The object to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param queue + * The new target queue for the object. The queue is retained, and the + * previous target queue, if any, is released. + * If queue is DISPATCH_TARGET_QUEUE_DEFAULT, set the object's target queue + * to the default target queue for the given object type. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW +void +dispatch_set_target_queue(dispatch_object_t object, + dispatch_queue_t _Nullable queue); + +/*! + * @function dispatch_main + * + * @abstract + * Execute blocks submitted to the main queue. + * + * @discussion + * This function "parks" the main thread and waits for blocks to be submitted + * to the main queue. This function never returns. + * + * Applications that call NSApplicationMain() or CFRunLoopRun() on the + * main thread do not need to call dispatch_main(). + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NOTHROW DISPATCH_NORETURN +void +dispatch_main(void); + +/*! + * @function dispatch_after + * + * @abstract + * Schedule a block for execution on a given queue at a specified time. + * + * @discussion + * Passing DISPATCH_TIME_NOW as the "when" parameter is supported, but not as + * optimal as calling dispatch_async() instead. Passing DISPATCH_TIME_FOREVER + * is undefined. + * + * @param when + * A temporal milestone returned by dispatch_time() or dispatch_walltime(). + * + * @param queue + * A queue to which the given block will be submitted at the specified time. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block of code to execute. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_after(dispatch_time_t when, dispatch_queue_t queue, + dispatch_block_t block); +#endif + +/*! + * @function dispatch_after_f + * + * @abstract + * Schedule a function for execution on a given queue at a specified time. + * + * @discussion + * See dispatch_after() for details. + * + * @param when + * A temporal milestone returned by dispatch_time() or dispatch_walltime(). + * + * @param queue + * A queue to which the given function will be submitted at the specified time. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_after_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL4 DISPATCH_NOTHROW +void +dispatch_after_f(dispatch_time_t when, dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @functiongroup Dispatch Barrier API + * The dispatch barrier API is a mechanism for submitting barrier blocks to a + * dispatch queue, analogous to the dispatch_async()/dispatch_sync() API. + * It enables the implementation of efficient reader/writer schemes. + * Barrier blocks only behave specially when submitted to queues created with + * the DISPATCH_QUEUE_CONCURRENT attribute; on such a queue, a barrier block + * will not run until all blocks submitted to the queue earlier have completed, + * and any blocks submitted to the queue after a barrier block will not run + * until the barrier block has completed. + * When submitted to a a global queue or to a queue not created with the + * DISPATCH_QUEUE_CONCURRENT attribute, barrier blocks behave identically to + * blocks submitted with the dispatch_async()/dispatch_sync() API. + */ + +/*! + * @function dispatch_barrier_async + * + * @abstract + * Submits a barrier block for asynchronous execution on a dispatch queue. + * + * @discussion + * Submits a block to a dispatch queue like dispatch_async(), but marks that + * block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues). + * + * See dispatch_async() for details and "Dispatch Barrier API" for a description + * of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The system will hold a reference on the target queue until the block + * has finished. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to submit to the target dispatch queue. This function performs + * Block_copy() and Block_release() on behalf of callers. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_barrier_async(dispatch_queue_t queue, dispatch_block_t block); +#endif + +/*! + * @function dispatch_barrier_async_f + * + * @abstract + * Submits a barrier function for asynchronous execution on a dispatch queue. + * + * @discussion + * Submits a function to a dispatch queue like dispatch_async_f(), but marks + * that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT + * queues). + * + * See dispatch_async_f() for details and "Dispatch Barrier API" for a + * description of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The system will hold a reference on the target queue until the function + * has returned. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_barrier_async_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_barrier_async_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @function dispatch_barrier_sync + * + * @abstract + * Submits a barrier block for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a block to a dispatch queue like dispatch_sync(), but marks that + * block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues). + * + * See dispatch_sync() for details and "Dispatch Barrier API" for a description + * of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param block + * The block to be invoked on the target dispatch queue. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_barrier_sync(dispatch_queue_t queue, + DISPATCH_NOESCAPE dispatch_block_t block); +#endif + +/*! + * @function dispatch_barrier_sync_f + * + * @abstract + * Submits a barrier function for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a function to a dispatch queue like dispatch_sync_f(), but marks that + * fuction as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues). + * + * See dispatch_sync_f() for details. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_barrier_sync_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_barrier_sync_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @function dispatch_barrier_async_and_wait + * + * @abstract + * Submits a block for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a block to a dispatch queue like dispatch_async_and_wait(), but marks + * that block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT + * queues). + * + * See "Dispatch Barrier API" for a description of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the block is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param work + * The application-defined block to invoke on the target queue. + * The result of passing NULL in this parameter is undefined. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_barrier_async_and_wait(dispatch_queue_t queue, + DISPATCH_NOESCAPE dispatch_block_t block); +#endif + +/*! + * @function dispatch_barrier_async_and_wait_f + * + * @abstract + * Submits a function for synchronous execution on a dispatch queue. + * + * @discussion + * Submits a function to a dispatch queue like dispatch_async_and_wait_f(), but + * marks that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT + * queues). + * + * See "Dispatch Barrier API" for a description of the barrier semantics. + * + * @param queue + * The target dispatch queue to which the function is submitted. + * The result of passing NULL in this parameter is undefined. + * + * @param context + * The application-defined context parameter to pass to the function. + * + * @param work + * The application-defined function to invoke on the target queue. The first + * parameter passed to this function is the context provided to + * dispatch_barrier_async_and_wait_f(). + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW +void +dispatch_barrier_async_and_wait_f(dispatch_queue_t queue, + void *_Nullable context, dispatch_function_t work); + +/*! + * @functiongroup Dispatch queue-specific contexts + * This API allows different subsystems to associate context to a shared queue + * without risk of collision and to retrieve that context from blocks executing + * on that queue or any of its child queues in the target queue hierarchy. + */ + +/*! + * @function dispatch_queue_set_specific + * + * @abstract + * Associates a subsystem-specific context with a dispatch queue, for a key + * unique to the subsystem. + * + * @discussion + * The specified destructor will be invoked with the context on the default + * priority global concurrent queue when a new context is set for the same key, + * or after all references to the queue have been released. + * + * @param queue + * The dispatch queue to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param key + * The key to set the context for, typically a pointer to a static variable + * specific to the subsystem. Keys are only compared as pointers and never + * dereferenced. Passing a string constant directly is not recommended. + * The NULL key is reserved and attempts to set a context for it are ignored. + * + * @param context + * The new subsystem-specific context for the object. This may be NULL. + * + * @param destructor + * The destructor function pointer. This may be NULL and is ignored if context + * is NULL. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_queue_set_specific(dispatch_queue_t queue, const void *key, + void *_Nullable context, dispatch_function_t _Nullable destructor); + +/*! + * @function dispatch_queue_get_specific + * + * @abstract + * Returns the subsystem-specific context associated with a dispatch queue, for + * a key unique to the subsystem. + * + * @discussion + * Returns the context for the specified key if it has been set on the specified + * queue. + * + * @param queue + * The dispatch queue to query. + * The result of passing NULL in this parameter is undefined. + * + * @param key + * The key to get the context for, typically a pointer to a static variable + * specific to the subsystem. Keys are only compared as pointers and never + * dereferenced. Passing a string constant directly is not recommended. + * + * @result + * The context for the specified key or NULL if no context was found. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_PURE DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +void *_Nullable +dispatch_queue_get_specific(dispatch_queue_t queue, const void *key); + +/*! + * @function dispatch_get_specific + * + * @abstract + * Returns the current subsystem-specific context for a key unique to the + * subsystem. + * + * @discussion + * When called from a block executing on a queue, returns the context for the + * specified key if it has been set on the queue, otherwise returns the result + * of dispatch_get_specific() executed on the queue's target queue or NULL + * if the current queue is a global concurrent queue. + * + * @param key + * The key to get the context for, typically a pointer to a static variable + * specific to the subsystem. Keys are only compared as pointers and never + * dereferenced. Passing a string constant directly is not recommended. + * + * @result + * The context for the specified key or NULL if no context was found. + */ +API_AVAILABLE(macos(10.7), ios(5.0)) +DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW +void *_Nullable +dispatch_get_specific(const void *key); + +/*! + * @functiongroup Dispatch assertion API + * + * This API asserts at runtime that code is executing in (or out of) the context + * of a given queue. It can be used to check that a block accessing a resource + * does so from the proper queue protecting the resource. It also can be used + * to verify that a block that could cause a deadlock if run on a given queue + * never executes on that queue. + */ + +/*! + * @function dispatch_assert_queue + * + * @abstract + * Verifies that the current block is executing on a given dispatch queue. + * + * @discussion + * Some code expects to be run on a specific dispatch queue. This function + * verifies that that expectation is true. + * + * If the currently executing block was submitted to the specified queue or to + * any queue targeting it (see dispatch_set_target_queue()), this function + * returns. + * + * If the currently executing block was submitted with a synchronous API + * (dispatch_sync(), dispatch_barrier_sync(), ...), the context of the + * submitting block is also evaluated (recursively). + * If a synchronously submitting block is found that was itself submitted to + * the specified queue or to any queue targeting it, this function returns. + * + * Otherwise this function asserts: it logs an explanation to the system log and + * terminates the application. + * + * Passing the result of dispatch_get_main_queue() to this function verifies + * that the current block was submitted to the main queue, or to a queue + * targeting it, or is running on the main thread (in any context). + * + * When dispatch_assert_queue() is called outside of the context of a + * submitted block (for example from the context of a thread created manually + * with pthread_create()) then this function will also assert and terminate + * the application. + * + * The variant dispatch_assert_queue_debug() is compiled out when the + * preprocessor macro NDEBUG is defined. (See also assert(3)). + * + * @param queue + * The dispatch queue that the current block is expected to run on. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 +void +dispatch_assert_queue(dispatch_queue_t queue) + DISPATCH_ALIAS_V2(dispatch_assert_queue); + +/*! + * @function dispatch_assert_queue_barrier + * + * @abstract + * Verifies that the current block is executing on a given dispatch queue, + * and that the block acts as a barrier on that queue. + * + * @discussion + * This behaves exactly like dispatch_assert_queue(), with the additional check + * that the current block acts as a barrier on the specified queue, which is + * always true if the specified queue is serial (see DISPATCH_BLOCK_BARRIER or + * dispatch_barrier_async() for details). + * + * The variant dispatch_assert_queue_barrier_debug() is compiled out when the + * preprocessor macro NDEBUG is defined. (See also assert()). + * + * @param queue + * The dispatch queue that the current block is expected to run as a barrier on. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 +void +dispatch_assert_queue_barrier(dispatch_queue_t queue); + +/*! + * @function dispatch_assert_queue_not + * + * @abstract + * Verifies that the current block is not executing on a given dispatch queue. + * + * @discussion + * This function is the equivalent of dispatch_assert_queue() with the test for + * equality inverted. That means that it will terminate the application when + * dispatch_assert_queue() would return, and vice-versa. See discussion there. + * + * The variant dispatch_assert_queue_not_debug() is compiled out when the + * preprocessor macro NDEBUG is defined. (See also assert(3)). + * + * @param queue + * The dispatch queue that the current block is expected not to run on. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 +void +dispatch_assert_queue_not(dispatch_queue_t queue) + DISPATCH_ALIAS_V2(dispatch_assert_queue_not); + +#ifdef NDEBUG +#define dispatch_assert_queue_debug(q) ((void)(0 && (q))) +#define dispatch_assert_queue_barrier_debug(q) ((void)(0 && (q))) +#define dispatch_assert_queue_not_debug(q) ((void)(0 && (q))) +#else +#define dispatch_assert_queue_debug(q) dispatch_assert_queue(q) +#define dispatch_assert_queue_barrier_debug(q) dispatch_assert_queue_barrier(q) +#define dispatch_assert_queue_not_debug(q) dispatch_assert_queue_not(q) +#endif + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/dispatch/semaphore.h b/lib/libc/include/aarch64-macos-gnu/dispatch/semaphore.h new file mode 100644 index 0000000000..225fe41563 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/dispatch/semaphore.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2008-2013 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 __DISPATCH_SEMAPHORE__ +#define __DISPATCH_SEMAPHORE__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @typedef dispatch_semaphore_t + * + * @abstract + * A counting semaphore. + */ +DISPATCH_DECL(dispatch_semaphore); + +__BEGIN_DECLS + +/*! + * @function dispatch_semaphore_create + * + * @abstract + * Creates new counting semaphore with an initial value. + * + * @discussion + * Passing zero for the value is useful for when two threads need to reconcile + * the completion of a particular event. Passing a value greater than zero is + * useful for managing a finite pool of resources, where the pool size is equal + * to the value. + * + * @param value + * The starting value for the semaphore. Passing a value less than zero will + * cause NULL to be returned. + * + * @result + * The newly created semaphore, or NULL on failure. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_semaphore_t +dispatch_semaphore_create(intptr_t value); + +/*! + * @function dispatch_semaphore_wait + * + * @abstract + * Wait (decrement) for a semaphore. + * + * @discussion + * Decrement the counting semaphore. If the resulting value is less than zero, + * this function waits for a signal to occur before returning. + * + * @param dsema + * The semaphore. The result of passing NULL in this parameter is undefined. + * + * @param timeout + * When to timeout (see dispatch_time). As a convenience, there are the + * DISPATCH_TIME_NOW and DISPATCH_TIME_FOREVER constants. + * + * @result + * Returns zero on success, or non-zero if the timeout occurred. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +intptr_t +dispatch_semaphore_wait(dispatch_semaphore_t dsema, dispatch_time_t timeout); + +/*! + * @function dispatch_semaphore_signal + * + * @abstract + * Signal (increment) a semaphore. + * + * @discussion + * Increment the counting semaphore. If the previous value was less than zero, + * this function wakes a waiting thread before returning. + * + * @param dsema The counting semaphore. + * The result of passing NULL in this parameter is undefined. + * + * @result + * This function returns non-zero if a thread is woken. Otherwise, zero is + * returned. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +intptr_t +dispatch_semaphore_signal(dispatch_semaphore_t dsema); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif /* __DISPATCH_SEMAPHORE__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/dispatch/source.h b/lib/libc/include/aarch64-macos-gnu/dispatch/source.h new file mode 100644 index 0000000000..91b23badfd --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/dispatch/source.h @@ -0,0 +1,780 @@ +/* + * Copyright (c) 2008-2013 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 __DISPATCH_SOURCE__ +#define __DISPATCH_SOURCE__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +#if TARGET_OS_MAC +#include +#include +#endif + +#if !defined(_WIN32) +#include +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +/*! + * @header + * The dispatch framework provides a suite of interfaces for monitoring low- + * level system objects (file descriptors, Mach ports, signals, VFS nodes, etc.) + * for activity and automatically submitting event handler blocks to dispatch + * queues when such activity occurs. + * + * This suite of interfaces is known as the Dispatch Source API. + */ + +/*! + * @typedef dispatch_source_t + * + * @abstract + * Dispatch sources are used to automatically submit event handler blocks to + * dispatch queues in response to external events. + */ +DISPATCH_SOURCE_DECL(dispatch_source); + +__BEGIN_DECLS + +/*! + * @typedef dispatch_source_type_t + * + * @abstract + * Constants of this type represent the class of low-level system object that + * is being monitored by the dispatch source. Constants of this type are + * passed as a parameter to dispatch_source_create() and determine how the + * handle argument is interpreted (i.e. as a file descriptor, mach port, + * signal number, process identifier, etc.), and how the mask argument is + * interpreted. + */ +typedef const struct dispatch_source_type_s *dispatch_source_type_t; + +/*! + * @const DISPATCH_SOURCE_TYPE_DATA_ADD + * @discussion A dispatch source that coalesces data obtained via calls to + * dispatch_source_merge_data(). An ADD is used to coalesce the data. + * The handle is unused (pass zero for now). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_DATA_ADD (&_dispatch_source_type_data_add) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(data_add); + +/*! + * @const DISPATCH_SOURCE_TYPE_DATA_OR + * @discussion A dispatch source that coalesces data obtained via calls to + * dispatch_source_merge_data(). A bitwise OR is used to coalesce the data. + * The handle is unused (pass zero for now). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_DATA_OR (&_dispatch_source_type_data_or) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(data_or); + +/*! + * @const DISPATCH_SOURCE_TYPE_DATA_REPLACE + * @discussion A dispatch source that tracks data obtained via calls to + * dispatch_source_merge_data(). Newly obtained data values replace existing + * data values not yet delivered to the source handler + * + * A data value of zero will cause the source handler to not be invoked. + * + * The handle is unused (pass zero for now). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_DATA_REPLACE (&_dispatch_source_type_data_replace) +API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)) +DISPATCH_SOURCE_TYPE_DECL(data_replace); + +/*! + * @const DISPATCH_SOURCE_TYPE_MACH_SEND + * @discussion A dispatch source that monitors a Mach port for dead name + * notifications (send right no longer has any corresponding receive right). + * The handle is a Mach port with a send or send-once right (mach_port_t). + * The mask is a mask of desired events from dispatch_source_mach_send_flags_t. + */ +#define DISPATCH_SOURCE_TYPE_MACH_SEND (&_dispatch_source_type_mach_send) +API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(mach_send); + +/*! + * @const DISPATCH_SOURCE_TYPE_MACH_RECV + * @discussion A dispatch source that monitors a Mach port for pending messages. + * The handle is a Mach port with a receive right (mach_port_t). + * The mask is a mask of desired events from dispatch_source_mach_recv_flags_t, + * but no flags are currently defined (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_MACH_RECV (&_dispatch_source_type_mach_recv) +API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(mach_recv); + +/*! + * @const DISPATCH_SOURCE_TYPE_MEMORYPRESSURE + * @discussion A dispatch source that monitors the system for changes in + * memory pressure condition. + * The handle is unused (pass zero for now). + * The mask is a mask of desired events from + * dispatch_source_memorypressure_flags_t. + */ +#define DISPATCH_SOURCE_TYPE_MEMORYPRESSURE \ + (&_dispatch_source_type_memorypressure) +API_AVAILABLE(macos(10.9), ios(8.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(memorypressure); + +/*! + * @const DISPATCH_SOURCE_TYPE_PROC + * @discussion A dispatch source that monitors an external process for events + * defined by dispatch_source_proc_flags_t. + * The handle is a process identifier (pid_t). + * The mask is a mask of desired events from dispatch_source_proc_flags_t. + */ +#define DISPATCH_SOURCE_TYPE_PROC (&_dispatch_source_type_proc) +API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(proc); + +/*! + * @const DISPATCH_SOURCE_TYPE_READ + * @discussion A dispatch source that monitors a file descriptor for pending + * bytes available to be read. + * The handle is a file descriptor (int). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_READ (&_dispatch_source_type_read) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(read); + +/*! + * @const DISPATCH_SOURCE_TYPE_SIGNAL + * @discussion A dispatch source that monitors the current process for signals. + * The handle is a signal number (int). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_SIGNAL (&_dispatch_source_type_signal) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(signal); + +/*! + * @const DISPATCH_SOURCE_TYPE_TIMER + * @discussion A dispatch source that submits the event handler block based + * on a timer. + * The handle is unused (pass zero for now). + * The mask specifies which flags from dispatch_source_timer_flags_t to apply. + */ +#define DISPATCH_SOURCE_TYPE_TIMER (&_dispatch_source_type_timer) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(timer); + +/*! + * @const DISPATCH_SOURCE_TYPE_VNODE + * @discussion A dispatch source that monitors a file descriptor for events + * defined by dispatch_source_vnode_flags_t. + * The handle is a file descriptor (int). + * The mask is a mask of desired events from dispatch_source_vnode_flags_t. + */ +#define DISPATCH_SOURCE_TYPE_VNODE (&_dispatch_source_type_vnode) +API_AVAILABLE(macos(10.6), ios(4.0)) DISPATCH_LINUX_UNAVAILABLE() +DISPATCH_SOURCE_TYPE_DECL(vnode); + +/*! + * @const DISPATCH_SOURCE_TYPE_WRITE + * @discussion A dispatch source that monitors a file descriptor for available + * buffer space to write bytes. + * The handle is a file descriptor (int). + * The mask is unused (pass zero for now). + */ +#define DISPATCH_SOURCE_TYPE_WRITE (&_dispatch_source_type_write) +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_SOURCE_TYPE_DECL(write); + +/*! + * @typedef dispatch_source_mach_send_flags_t + * Type of dispatch_source_mach_send flags + * + * @constant DISPATCH_MACH_SEND_DEAD + * The receive right corresponding to the given send right was destroyed. + */ +#define DISPATCH_MACH_SEND_DEAD 0x1 + +typedef unsigned long dispatch_source_mach_send_flags_t; + +/*! + * @typedef dispatch_source_mach_recv_flags_t + * Type of dispatch_source_mach_recv flags + */ +typedef unsigned long dispatch_source_mach_recv_flags_t; + +/*! + * @typedef dispatch_source_memorypressure_flags_t + * Type of dispatch_source_memorypressure flags + * + * @constant DISPATCH_MEMORYPRESSURE_NORMAL + * The system memory pressure condition has returned to normal. + * + * @constant DISPATCH_MEMORYPRESSURE_WARN + * The system memory pressure condition has changed to warning. + * + * @constant DISPATCH_MEMORYPRESSURE_CRITICAL + * The system memory pressure condition has changed to critical. + * + * @discussion + * Elevated memory pressure is a system-wide condition that applications + * registered for this source should react to by changing their future memory + * use behavior, e.g. by reducing cache sizes of newly initiated operations + * until memory pressure returns back to normal. + * NOTE: applications should NOT traverse and discard existing caches for past + * operations when the system memory pressure enters an elevated state, as that + * is likely to trigger VM operations that will further aggravate system memory + * pressure. + */ + +#define DISPATCH_MEMORYPRESSURE_NORMAL 0x01 +#define DISPATCH_MEMORYPRESSURE_WARN 0x02 +#define DISPATCH_MEMORYPRESSURE_CRITICAL 0x04 + +typedef unsigned long dispatch_source_memorypressure_flags_t; + +/*! + * @typedef dispatch_source_proc_flags_t + * Type of dispatch_source_proc flags + * + * @constant DISPATCH_PROC_EXIT + * The process has exited (perhaps cleanly, perhaps not). + * + * @constant DISPATCH_PROC_FORK + * The process has created one or more child processes. + * + * @constant DISPATCH_PROC_EXEC + * The process has become another executable image via + * exec*() or posix_spawn*(). + * + * @constant DISPATCH_PROC_SIGNAL + * A Unix signal was delivered to the process. + */ +#define DISPATCH_PROC_EXIT 0x80000000 +#define DISPATCH_PROC_FORK 0x40000000 +#define DISPATCH_PROC_EXEC 0x20000000 +#define DISPATCH_PROC_SIGNAL 0x08000000 + +typedef unsigned long dispatch_source_proc_flags_t; + +/*! + * @typedef dispatch_source_vnode_flags_t + * Type of dispatch_source_vnode flags + * + * @constant DISPATCH_VNODE_DELETE + * The filesystem object was deleted from the namespace. + * + * @constant DISPATCH_VNODE_WRITE + * The filesystem object data changed. + * + * @constant DISPATCH_VNODE_EXTEND + * The filesystem object changed in size. + * + * @constant DISPATCH_VNODE_ATTRIB + * The filesystem object metadata changed. + * + * @constant DISPATCH_VNODE_LINK + * The filesystem object link count changed. + * + * @constant DISPATCH_VNODE_RENAME + * The filesystem object was renamed in the namespace. + * + * @constant DISPATCH_VNODE_REVOKE + * The filesystem object was revoked. + * + * @constant DISPATCH_VNODE_FUNLOCK + * The filesystem object was unlocked. + */ + +#define DISPATCH_VNODE_DELETE 0x1 +#define DISPATCH_VNODE_WRITE 0x2 +#define DISPATCH_VNODE_EXTEND 0x4 +#define DISPATCH_VNODE_ATTRIB 0x8 +#define DISPATCH_VNODE_LINK 0x10 +#define DISPATCH_VNODE_RENAME 0x20 +#define DISPATCH_VNODE_REVOKE 0x40 +#define DISPATCH_VNODE_FUNLOCK 0x100 + +typedef unsigned long dispatch_source_vnode_flags_t; + +/*! + * @typedef dispatch_source_timer_flags_t + * Type of dispatch_source_timer flags + * + * @constant DISPATCH_TIMER_STRICT + * Specifies that the system should make a best effort to strictly observe the + * leeway value specified for the timer via dispatch_source_set_timer(), even + * if that value is smaller than the default leeway value that would be applied + * to the timer otherwise. A minimal amount of leeway will be applied to the + * timer even if this flag is specified. + * + * CAUTION: Use of this flag may override power-saving techniques employed by + * the system and cause higher power consumption, so it must be used with care + * and only when absolutely necessary. + */ + +#define DISPATCH_TIMER_STRICT 0x1 + +typedef unsigned long dispatch_source_timer_flags_t; + +/*! + * @function dispatch_source_create + * + * @abstract + * Creates a new dispatch source to monitor low-level system objects and auto- + * matically submit a handler block to a dispatch queue in response to events. + * + * @discussion + * Dispatch sources are not reentrant. Any events received while the dispatch + * source is suspended or while the event handler block is currently executing + * will be coalesced and delivered after the dispatch source is resumed or the + * event handler block has returned. + * + * Dispatch sources are created in an inactive state. After creating the + * source and setting any desired attributes (i.e. the handler, context, etc.), + * a call must be made to dispatch_activate() in order to begin event delivery. + * + * Calling dispatch_set_target_queue() on a source once it has been activated + * is not allowed (see dispatch_activate() and dispatch_set_target_queue()). + * + * For backward compatibility reasons, dispatch_resume() on an inactive, + * and not otherwise suspended source has the same effect as calling + * dispatch_activate(). For new code, using dispatch_activate() is preferred. + * + * @param type + * Declares the type of the dispatch source. Must be one of the defined + * dispatch_source_type_t constants. + * + * @param handle + * The underlying system handle to monitor. The interpretation of this argument + * is determined by the constant provided in the type parameter. + * + * @param mask + * A mask of flags specifying which events are desired. The interpretation of + * this argument is determined by the constant provided in the type parameter. + * + * @param queue + * The dispatch queue to which the event handler block will be submitted. + * If queue is DISPATCH_TARGET_QUEUE_DEFAULT, the source will submit the event + * handler block to the default priority global queue. + * + * @result + * The newly created dispatch source. Or NULL if invalid arguments are passed. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_source_t +dispatch_source_create(dispatch_source_type_t type, + uintptr_t handle, + uintptr_t mask, + dispatch_queue_t _Nullable queue); + +/*! + * @function dispatch_source_set_event_handler + * + * @abstract + * Sets the event handler block for the given dispatch source. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The event handler block to submit to the source's target queue. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_event_handler(dispatch_source_t source, + dispatch_block_t _Nullable handler); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_source_set_event_handler_f + * + * @abstract + * Sets the event handler function for the given dispatch source. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The event handler function to submit to the source's target queue. + * The context parameter passed to the event handler function is the context of + * the dispatch source current at the time the event handler was set. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_event_handler_f(dispatch_source_t source, + dispatch_function_t _Nullable handler); + +/*! + * @function dispatch_source_set_cancel_handler + * + * @abstract + * Sets the cancellation handler block for the given dispatch source. + * + * @discussion + * The cancellation handler (if specified) will be submitted to the source's + * target queue in response to a call to dispatch_source_cancel() once the + * system has released all references to the source's underlying handle and + * the source's event handler block has returned. + * + * IMPORTANT: + * Source cancellation and a cancellation handler are required for file + * descriptor and mach port based sources in order to safely close the + * descriptor or destroy the port. + * Closing the descriptor or port before the cancellation handler is invoked may + * result in a race condition. If a new descriptor is allocated with the same + * value as the recently closed descriptor while the source's event handler is + * still running, the event handler may read/write data to the wrong descriptor. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The cancellation handler block to submit to the source's target queue. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_cancel_handler(dispatch_source_t source, + dispatch_block_t _Nullable handler); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_source_set_cancel_handler_f + * + * @abstract + * Sets the cancellation handler function for the given dispatch source. + * + * @discussion + * See dispatch_source_set_cancel_handler() for more details. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The cancellation handler function to submit to the source's target queue. + * The context parameter passed to the event handler function is the current + * context of the dispatch source at the time the handler call is made. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_cancel_handler_f(dispatch_source_t source, + dispatch_function_t _Nullable handler); + +/*! + * @function dispatch_source_cancel + * + * @abstract + * Asynchronously cancel the dispatch source, preventing any further invocation + * of its event handler block. + * + * @discussion + * Cancellation prevents any further invocation of the event handler block for + * the specified dispatch source, but does not interrupt an event handler + * block that is already in progress. + * + * The cancellation handler is submitted to the source's target queue once the + * the source's event handler has finished, indicating it is now safe to close + * the source's handle (i.e. file descriptor or mach port). + * + * See dispatch_source_set_cancel_handler() for more information. + * + * @param source + * The dispatch source to be canceled. + * The result of passing NULL in this parameter is undefined. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_source_cancel(dispatch_source_t source); + +/*! + * @function dispatch_source_testcancel + * + * @abstract + * Tests whether the given dispatch source has been canceled. + * + * @param source + * The dispatch source to be tested. + * The result of passing NULL in this parameter is undefined. + * + * @result + * Non-zero if canceled and zero if not canceled. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +intptr_t +dispatch_source_testcancel(dispatch_source_t source); + +/*! + * @function dispatch_source_get_handle + * + * @abstract + * Returns the underlying system handle associated with this dispatch source. + * + * @param source + * The result of passing NULL in this parameter is undefined. + * + * @result + * The return value should be interpreted according to the type of the dispatch + * source, and may be one of the following handles: + * + * DISPATCH_SOURCE_TYPE_DATA_ADD: n/a + * DISPATCH_SOURCE_TYPE_DATA_OR: n/a + * DISPATCH_SOURCE_TYPE_DATA_REPLACE: n/a + * DISPATCH_SOURCE_TYPE_MACH_SEND: mach port (mach_port_t) + * DISPATCH_SOURCE_TYPE_MACH_RECV: mach port (mach_port_t) + * DISPATCH_SOURCE_TYPE_MEMORYPRESSURE n/a + * DISPATCH_SOURCE_TYPE_PROC: process identifier (pid_t) + * DISPATCH_SOURCE_TYPE_READ: file descriptor (int) + * DISPATCH_SOURCE_TYPE_SIGNAL: signal number (int) + * DISPATCH_SOURCE_TYPE_TIMER: n/a + * DISPATCH_SOURCE_TYPE_VNODE: file descriptor (int) + * DISPATCH_SOURCE_TYPE_WRITE: file descriptor (int) + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +uintptr_t +dispatch_source_get_handle(dispatch_source_t source); + +/*! + * @function dispatch_source_get_mask + * + * @abstract + * Returns the mask of events monitored by the dispatch source. + * + * @param source + * The result of passing NULL in this parameter is undefined. + * + * @result + * The return value should be interpreted according to the type of the dispatch + * source, and may be one of the following flag sets: + * + * DISPATCH_SOURCE_TYPE_DATA_ADD: n/a + * DISPATCH_SOURCE_TYPE_DATA_OR: n/a + * DISPATCH_SOURCE_TYPE_DATA_REPLACE: n/a + * DISPATCH_SOURCE_TYPE_MACH_SEND: dispatch_source_mach_send_flags_t + * DISPATCH_SOURCE_TYPE_MACH_RECV: dispatch_source_mach_recv_flags_t + * DISPATCH_SOURCE_TYPE_MEMORYPRESSURE dispatch_source_memorypressure_flags_t + * DISPATCH_SOURCE_TYPE_PROC: dispatch_source_proc_flags_t + * DISPATCH_SOURCE_TYPE_READ: n/a + * DISPATCH_SOURCE_TYPE_SIGNAL: n/a + * DISPATCH_SOURCE_TYPE_TIMER: dispatch_source_timer_flags_t + * DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_vnode_flags_t + * DISPATCH_SOURCE_TYPE_WRITE: n/a + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +uintptr_t +dispatch_source_get_mask(dispatch_source_t source); + +/*! + * @function dispatch_source_get_data + * + * @abstract + * Returns pending data for the dispatch source. + * + * @discussion + * This function is intended to be called from within the event handler block. + * The result of calling this function outside of the event handler callback is + * undefined. + * + * @param source + * The result of passing NULL in this parameter is undefined. + * + * @result + * The return value should be interpreted according to the type of the dispatch + * source, and may be one of the following: + * + * DISPATCH_SOURCE_TYPE_DATA_ADD: application defined data + * DISPATCH_SOURCE_TYPE_DATA_OR: application defined data + * DISPATCH_SOURCE_TYPE_DATA_REPLACE: application defined data + * DISPATCH_SOURCE_TYPE_MACH_SEND: dispatch_source_mach_send_flags_t + * DISPATCH_SOURCE_TYPE_MACH_RECV: dispatch_source_mach_recv_flags_t + * DISPATCH_SOURCE_TYPE_MEMORYPRESSURE dispatch_source_memorypressure_flags_t + * DISPATCH_SOURCE_TYPE_PROC: dispatch_source_proc_flags_t + * DISPATCH_SOURCE_TYPE_READ: estimated bytes available to read + * DISPATCH_SOURCE_TYPE_SIGNAL: number of signals delivered since + * the last handler invocation + * DISPATCH_SOURCE_TYPE_TIMER: number of times the timer has fired + * since the last handler invocation + * DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_vnode_flags_t + * DISPATCH_SOURCE_TYPE_WRITE: estimated buffer space available + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_PURE +DISPATCH_NOTHROW +uintptr_t +dispatch_source_get_data(dispatch_source_t source); + +/*! + * @function dispatch_source_merge_data + * + * @abstract + * Merges data into a dispatch source of type DISPATCH_SOURCE_TYPE_DATA_ADD, + * DISPATCH_SOURCE_TYPE_DATA_OR or DISPATCH_SOURCE_TYPE_DATA_REPLACE, + * and submits its event handler block to its target queue. + * + * @param source + * The result of passing NULL in this parameter is undefined. + * + * @param value + * The value to coalesce with the pending data using a logical OR or an ADD + * as specified by the dispatch source type. A value of zero has no effect + * and will not result in the submission of the event handler block. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_source_merge_data(dispatch_source_t source, uintptr_t value); + +/*! + * @function dispatch_source_set_timer + * + * @abstract + * Sets a start time, interval, and leeway value for a timer source. + * + * @discussion + * Once this function returns, any pending source data accumulated for the + * previous timer values has been cleared; the next fire of the timer will + * occur at 'start', and every 'interval' nanoseconds thereafter until the + * timer source is canceled. + * + * Any fire of the timer may be delayed by the system in order to improve power + * consumption and system performance. The upper limit to the allowable delay + * may be configured with the 'leeway' argument, the lower limit is under the + * control of the system. + * + * For the initial timer fire at 'start', the upper limit to the allowable + * delay is set to 'leeway' nanoseconds. For the subsequent timer fires at + * 'start' + N * 'interval', the upper limit is MIN('leeway','interval'/2). + * + * The lower limit to the allowable delay may vary with process state such as + * visibility of application UI. If the specified timer source was created with + * a mask of DISPATCH_TIMER_STRICT, the system will make a best effort to + * strictly observe the provided 'leeway' value even if it is smaller than the + * current lower limit. Note that a minimal amount of delay is to be expected + * even if this flag is specified. + * + * The 'start' argument also determines which clock will be used for the timer: + * If 'start' is DISPATCH_TIME_NOW or was created with dispatch_time(3), the + * timer is based on up time (which is obtained from mach_absolute_time() on + * Apple platforms). If 'start' was created with dispatch_walltime(3), the + * timer is based on gettimeofday(3). + * + * Calling this function has no effect if the timer source has already been + * canceled. + * + * @param start + * The start time of the timer. See dispatch_time() and dispatch_walltime() + * for more information. + * + * @param interval + * The nanosecond interval for the timer. Use DISPATCH_TIME_FOREVER for a + * one-shot timer. + * + * @param leeway + * The nanosecond leeway for the timer. + */ +API_AVAILABLE(macos(10.6), ios(4.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_source_set_timer(dispatch_source_t source, + dispatch_time_t start, + uint64_t interval, + uint64_t leeway); + +/*! + * @function dispatch_source_set_registration_handler + * + * @abstract + * Sets the registration handler block for the given dispatch source. + * + * @discussion + * The registration handler (if specified) will be submitted to the source's + * target queue once the corresponding kevent() has been registered with the + * system, following the initial dispatch_resume() of the source. + * + * If a source is already registered when the registration handler is set, the + * registration handler will be invoked immediately. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The registration handler block to submit to the source's target queue. + */ +#ifdef __BLOCKS__ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_registration_handler(dispatch_source_t source, + dispatch_block_t _Nullable handler); +#endif /* __BLOCKS__ */ + +/*! + * @function dispatch_source_set_registration_handler_f + * + * @abstract + * Sets the registration handler function for the given dispatch source. + * + * @discussion + * See dispatch_source_set_registration_handler() for more details. + * + * @param source + * The dispatch source to modify. + * The result of passing NULL in this parameter is undefined. + * + * @param handler + * The registration handler function to submit to the source's target queue. + * The context parameter passed to the registration handler function is the + * current context of the dispatch source at the time the handler call is made. + */ +API_AVAILABLE(macos(10.7), ios(4.3)) +DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW +void +dispatch_source_set_registration_handler_f(dispatch_source_t source, + dispatch_function_t _Nullable handler); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/dispatch/workloop.h b/lib/libc/include/aarch64-macos-gnu/dispatch/workloop.h new file mode 100644 index 0000000000..7d27b1f207 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/dispatch/workloop.h @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2017-2019 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 __DISPATCH_WORKLOOP__ +#define __DISPATCH_WORKLOOP__ + +#ifndef __DISPATCH_INDIRECT__ +#error "Please #include instead of this file directly." +#include // for HeaderDoc +#endif + +DISPATCH_ASSUME_NONNULL_BEGIN + +__BEGIN_DECLS + +/*! + * @typedef dispatch_workloop_t + * + * @abstract + * Dispatch workloops invoke workitems submitted to them in priority order. + * + * @discussion + * A dispatch workloop is a flavor of dispatch_queue_t that is a priority + * ordered queue (using the QOS class of the submitted workitems as the + * ordering). + * + * Between each workitem invocation, the workloop will evaluate whether higher + * priority workitems have since been submitted, either directly to the + * workloop or to any queues that target the workloop, and execute these first. + * + * Serial queues targeting a workloop maintain FIFO execution of their + * workitems. However, the workloop may reorder workitems submitted to + * independent serial queues targeting it with respect to each other, + * based on their priorities, while preserving FIFO execution with respect to + * each serial queue. + * + * A dispatch workloop is a "subclass" of dispatch_queue_t which can be passed + * to all APIs accepting a dispatch queue, except for functions from the + * dispatch_sync() family. dispatch_async_and_wait() must be used for workloop + * objects. Functions from the dispatch_sync() family on queues targeting + * a workloop are still permitted but discouraged for performance reasons. + */ +DISPATCH_DECL_SUBCLASS(dispatch_workloop, dispatch_queue); + +/*! + * @function dispatch_workloop_create + * + * @abstract + * Creates a new dispatch workloop to which workitems may be submitted. + * + * @param label + * A string label to attach to the workloop. + * + * @result + * The newly created dispatch workloop. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_workloop_t +dispatch_workloop_create(const char *_Nullable label); + +/*! + * @function dispatch_workloop_create_inactive + * + * @abstract + * Creates a new inactive dispatch workloop that can be setup and then + * activated. + * + * @discussion + * Creating an inactive workloop allows for it to receive further configuration + * before it is activated, and workitems can be submitted to it. + * + * Submitting workitems to an inactive workloop is undefined and will cause the + * process to be terminated. + * + * @param label + * A string label to attach to the workloop. + * + * @result + * The newly created dispatch workloop. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW +dispatch_workloop_t +dispatch_workloop_create_inactive(const char *_Nullable label); + +/*! + * @function dispatch_workloop_set_autorelease_frequency + * + * @abstract + * Sets the autorelease frequency of the workloop. + * + * @discussion + * See dispatch_queue_attr_make_with_autorelease_frequency(). + * The default policy for a workloop is + * DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM. + * + * @param workloop + * The dispatch workloop to modify. + * + * This workloop must be inactive, passing an activated object is undefined + * and will cause the process to be terminated. + * + * @param frequency + * The requested autorelease frequency. + */ +API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_workloop_set_autorelease_frequency(dispatch_workloop_t workloop, + dispatch_autorelease_frequency_t frequency); + +/*! + * @function dispatch_workloop_set_os_workgroup + * + * @abstract + * Associates an os_workgroup_t with the specified dispatch workloop. + * + * The worker thread will be a member of the specified os_workgroup_t while executing + * work items submitted to the workloop. + * + * @param workloop + * The dispatch workloop to modify. + * + * This workloop must be inactive, passing an activated object is undefined + * and will cause the process to be terminated. + * + * @param workgroup + * The workgroup to associate with this workloop. + * + * The workgroup specified is retained and the previously associated workgroup + * (if any) is released. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW +void +dispatch_workloop_set_os_workgroup(dispatch_workloop_t workloop, + os_workgroup_t workgroup); + +__END_DECLS + +DISPATCH_ASSUME_NONNULL_END + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/libkern/OSAtomic.h b/lib/libc/include/aarch64-macos-gnu/libkern/OSAtomic.h new file mode 100644 index 0000000000..37ef16ce44 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/libkern/OSAtomic.h @@ -0,0 +1,47 @@ +/* + * 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_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/libkern/OSAtomicDeprecated.h b/lib/libc/include/aarch64-macos-gnu/libkern/OSAtomicDeprecated.h new file mode 100644 index 0000000000..6dc880b0d4 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/libkern/OSAtomicDeprecated.h @@ -0,0 +1,1266 @@ +/* + * 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_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/libkern/OSAtomicQueue.h b/lib/libc/include/aarch64-macos-gnu/libkern/OSAtomicQueue.h new file mode 100644 index 0000000000..66033fc834 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/libkern/OSAtomicQueue.h @@ -0,0 +1,115 @@ +/* + * 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_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/libkern/OSByteOrder.h b/lib/libc/include/aarch64-macos-gnu/libkern/OSByteOrder.h new file mode 100644 index 0000000000..3d1e742b31 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/libkern/OSByteOrder.h @@ -0,0 +1,317 @@ +/* + * 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 */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/libkern/OSSpinLockDeprecated.h b/lib/libc/include/aarch64-macos-gnu/libkern/OSSpinLockDeprecated.h new file mode 100644 index 0000000000..a654a7bbc2 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/libkern/OSSpinLockDeprecated.h @@ -0,0 +1,212 @@ +/* + * 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_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/libkern/_OSByteOrder.h b/lib/libc/include/aarch64-macos-gnu/libkern/_OSByteOrder.h new file mode 100644 index 0000000000..4d5a9301ef --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/libkern/_OSByteOrder.h @@ -0,0 +1,133 @@ +/* + * 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 */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/libkern/arm/OSByteOrder.h b/lib/libc/include/aarch64-macos-gnu/libkern/arm/OSByteOrder.h new file mode 100644 index 0000000000..f89a24b53f --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/libkern/arm/OSByteOrder.h @@ -0,0 +1,216 @@ +/* + * 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 */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach-o/dyld.h b/lib/libc/include/aarch64-macos-gnu/mach-o/dyld.h new file mode 100644 index 0000000000..63058bbbd9 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach-o/dyld.h @@ -0,0 +1,272 @@ +/* + * 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_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach-o/loader.h b/lib/libc/include/aarch64-macos-gnu/mach-o/loader.h new file mode 100644 index 0000000000..d1520d52cb --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach-o/loader.h @@ -0,0 +1,1601 @@ +/* + * 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 + +/* + * 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_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/_structs.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/_structs.h new file mode 100644 index 0000000000..ddee2f7341 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/_structs.h @@ -0,0 +1,645 @@ +/* + * Copyright (c) 2004-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +#ifndef _MACH_ARM__STRUCTS_H_ +#define _MACH_ARM__STRUCTS_H_ + +#include /* __DARWIN_UNIX03 */ +#include /* __uint32_t */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_EXCEPTION_STATE struct __darwin_arm_exception_state +_STRUCT_ARM_EXCEPTION_STATE +{ + __uint32_t __exception; /* number of arm exception taken */ + __uint32_t __fsr; /* Fault status */ + __uint32_t __far; /* Virtual Fault Address */ +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_ARM_EXCEPTION_STATE struct arm_exception_state +_STRUCT_ARM_EXCEPTION_STATE +{ + __uint32_t exception; /* number of arm exception taken */ + __uint32_t fsr; /* Fault status */ + __uint32_t far; /* Virtual Fault Address */ +}; +#endif /* __DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_EXCEPTION_STATE64 struct __darwin_arm_exception_state64 +_STRUCT_ARM_EXCEPTION_STATE64 +{ + __uint64_t __far; /* Virtual Fault Address */ + __uint32_t __esr; /* Exception syndrome */ + __uint32_t __exception; /* number of arm exception taken */ +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_ARM_EXCEPTION_STATE64 struct arm_exception_state64 +_STRUCT_ARM_EXCEPTION_STATE64 +{ + __uint64_t far; /* Virtual Fault Address */ + __uint32_t esr; /* Exception syndrome */ + __uint32_t exception; /* number of arm exception taken */ +}; +#endif /* __DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_THREAD_STATE struct __darwin_arm_thread_state +_STRUCT_ARM_THREAD_STATE +{ + __uint32_t __r[13]; /* General purpose register r0-r12 */ + __uint32_t __sp; /* Stack pointer r13 */ + __uint32_t __lr; /* Link register r14 */ + __uint32_t __pc; /* Program counter r15 */ + __uint32_t __cpsr; /* Current program status register */ +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_ARM_THREAD_STATE struct arm_thread_state +_STRUCT_ARM_THREAD_STATE +{ + __uint32_t r[13]; /* General purpose register r0-r12 */ + __uint32_t sp; /* Stack pointer r13 */ + __uint32_t lr; /* Link register r14 */ + __uint32_t pc; /* Program counter r15 */ + __uint32_t cpsr; /* Current program status register */ +}; +#endif /* __DARWIN_UNIX03 */ + + +/* + * By default, the pointer fields in the arm_thread_state64_t structure are + * opaque on the arm64e architecture and require the use of accessor macros. + * This mode can also be enabled on the arm64 architecture by building with + * -D__DARWIN_OPAQUE_ARM_THREAD_STATE64=1. + */ +#if defined(__arm64__) && defined(__LP64__) + +#if __has_feature(ptrauth_calls) +#define __DARWIN_OPAQUE_ARM_THREAD_STATE64 1 +#define __DARWIN_PTRAUTH_ARM_THREAD_STATE64 1 +#endif /* __has_feature(ptrauth_calls) */ + +#ifndef __DARWIN_OPAQUE_ARM_THREAD_STATE64 +#define __DARWIN_OPAQUE_ARM_THREAD_STATE64 0 +#endif + +#else /* defined(__arm64__) && defined(__LP64__) */ + +#undef __DARWIN_OPAQUE_ARM_THREAD_STATE64 +#define __DARWIN_OPAQUE_ARM_THREAD_STATE64 0 + +#endif /* defined(__arm64__) && defined(__LP64__) */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_THREAD_STATE64 struct __darwin_arm_thread_state64 +#if __DARWIN_OPAQUE_ARM_THREAD_STATE64 +_STRUCT_ARM_THREAD_STATE64 +{ + __uint64_t __x[29]; /* General purpose registers x0-x28 */ + void* __opaque_fp; /* Frame pointer x29 */ + void* __opaque_lr; /* Link register x30 */ + void* __opaque_sp; /* Stack pointer x31 */ + void* __opaque_pc; /* Program counter */ + __uint32_t __cpsr; /* Current program status register */ + __uint32_t __opaque_flags; /* Flags describing structure format */ +}; +#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ +_STRUCT_ARM_THREAD_STATE64 +{ + __uint64_t __x[29]; /* General purpose registers x0-x28 */ + __uint64_t __fp; /* Frame pointer x29 */ + __uint64_t __lr; /* Link register x30 */ + __uint64_t __sp; /* Stack pointer x31 */ + __uint64_t __pc; /* Program counter */ + __uint32_t __cpsr; /* Current program status register */ + __uint32_t __pad; /* Same size for 32-bit or 64-bit clients */ +}; +#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_ARM_THREAD_STATE64 struct arm_thread_state64 +#if __DARWIN_OPAQUE_ARM_THREAD_STATE64 +_STRUCT_ARM_THREAD_STATE64 +{ + __uint64_t x[29]; /* General purpose registers x0-x28 */ + void* __opaque_fp; /* Frame pointer x29 */ + void* __opaque_lr; /* Link register x30 */ + void* __opaque_sp; /* Stack pointer x31 */ + void* __opaque_pc; /* Program counter */ + __uint32_t cpsr; /* Current program status register */ + __uint32_t __opaque_flags; /* Flags describing structure format */ +}; +#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ +_STRUCT_ARM_THREAD_STATE64 +{ + __uint64_t x[29]; /* General purpose registers x0-x28 */ + __uint64_t fp; /* Frame pointer x29 */ + __uint64_t lr; /* Link register x30 */ + __uint64_t sp; /* Stack pointer x31 */ + __uint64_t pc; /* Program counter */ + __uint32_t cpsr; /* Current program status register */ + __uint32_t __pad; /* Same size for 32-bit or 64-bit clients */ +}; +#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ +#endif /* __DARWIN_UNIX03 */ + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) + +/* Accessor macros for arm_thread_state64_t pointer fields */ + +#if __has_feature(ptrauth_calls) && defined(__LP64__) +#include + +#if !__DARWIN_OPAQUE_ARM_THREAD_STATE64 || !__DARWIN_PTRAUTH_ARM_THREAD_STATE64 +#error "Invalid configuration" +#endif + +#define __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH 0x1 +#define __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR 0x2 + +/* Return pc field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_pc(ts) \ + __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + (uintptr_t)(__tsp->__opaque_pc && !(__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ + ptrauth_auth_data(__tsp->__opaque_pc, \ + ptrauth_key_process_independent_code, \ + ptrauth_string_discriminator("pc")) : __tsp->__opaque_pc); }) +/* Return pc field of arm_thread_state64_t as a function pointer. May return + * NULL if a valid function pointer cannot be constructed, the caller should + * fall back to the __darwin_arm_thread_state64_get_pc() macro in that case. */ +#define __darwin_arm_thread_state64_get_pc_fptr(ts) \ + __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + (__tsp->__opaque_pc && !(__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ + ptrauth_auth_function(__tsp->__opaque_pc, \ + ptrauth_key_process_independent_code, \ + ptrauth_string_discriminator("pc")) : NULL); }) +/* Set pc field of arm_thread_state64_t to a function pointer */ +#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ + __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + __typeof__(fptr) __f = (fptr); __tsp->__opaque_pc = \ + (__f ? (!(__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ + ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \ + ptrauth_key_process_independent_code, \ + ptrauth_string_discriminator("pc")) : ptrauth_auth_data(__f, \ + ptrauth_key_function_pointer, 0)) : __f); }) +/* Return lr field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_lr(ts) \ + __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + (uintptr_t)(__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \ + ptrauth_auth_data(__tsp->__opaque_lr, \ + ptrauth_key_process_independent_code, \ + ptrauth_string_discriminator("lr")) : __tsp->__opaque_lr); }) +/* Return lr field of arm_thread_state64_t as a function pointer. May return + * NULL if a valid function pointer cannot be constructed, the caller should + * fall back to the __darwin_arm_thread_state64_get_lr() macro in that case. */ +#define __darwin_arm_thread_state64_get_lr_fptr(ts) \ + __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + (__tsp->__opaque_lr && !(__tsp->__opaque_flags & ( \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? \ + ptrauth_auth_function(__tsp->__opaque_lr, \ + ptrauth_key_process_independent_code, \ + ptrauth_string_discriminator("lr")) : NULL); }) +/* Set lr field of arm_thread_state64_t to a function pointer */ +#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ + __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + __typeof__(fptr) __f = (fptr); __tsp->__opaque_lr = \ + (__f ? (!(__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? (__tsp->__opaque_flags \ + &= ~__DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR , \ + ptrauth_auth_and_resign(__f, ptrauth_key_function_pointer, 0, \ + ptrauth_key_process_independent_code, \ + ptrauth_string_discriminator("lr"))) : ptrauth_auth_data(__f, \ + ptrauth_key_function_pointer, 0)) : __f); }) +/* Return sp field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_sp(ts) \ + __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + (uintptr_t)(__tsp->__opaque_sp && !(__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ + ptrauth_auth_data(__tsp->__opaque_sp, \ + ptrauth_key_process_independent_data, \ + ptrauth_string_discriminator("sp")) : __tsp->__opaque_sp); }) +/* Set sp field of arm_thread_state64_t to a data pointer value */ +#define __darwin_arm_thread_state64_set_sp(ts, ptr) \ + __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_sp = \ + (__p && !(__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ + ptrauth_sign_unauthenticated(__p, \ + ptrauth_key_process_independent_data, \ + ptrauth_string_discriminator("sp")) : __p); }) +/* Return fp field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_fp(ts) \ + __extension__ ({ const _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + (uintptr_t)(__tsp->__opaque_fp && !(__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ + ptrauth_auth_data(__tsp->__opaque_fp, \ + ptrauth_key_process_independent_data, \ + ptrauth_string_discriminator("fp")) : __tsp->__opaque_fp); }) +/* Set fp field of arm_thread_state64_t to a data pointer value */ +#define __darwin_arm_thread_state64_set_fp(ts, ptr) \ + __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + void *__p = (void*)(uintptr_t)(ptr); __tsp->__opaque_fp = \ + (__p && !(__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? \ + ptrauth_sign_unauthenticated(__p, \ + ptrauth_key_process_independent_data, \ + ptrauth_string_discriminator("fp")) : __p); }) + +/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */ +#define __darwin_arm_thread_state64_ptrauth_strip(ts) \ + __extension__ ({ _STRUCT_ARM_THREAD_STATE64 *__tsp = &(ts); \ + __tsp->__opaque_pc = ((__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_pc : \ + ptrauth_strip(__tsp->__opaque_pc, ptrauth_key_process_independent_code)); \ + __tsp->__opaque_lr = ((__tsp->__opaque_flags & \ + (__DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH | \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_IB_SIGNED_LR)) ? __tsp->__opaque_lr : \ + ptrauth_strip(__tsp->__opaque_lr, ptrauth_key_process_independent_code)); \ + __tsp->__opaque_sp = ((__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_sp : \ + ptrauth_strip(__tsp->__opaque_sp, ptrauth_key_process_independent_data)); \ + __tsp->__opaque_fp = ((__tsp->__opaque_flags & \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH) ? __tsp->__opaque_fp : \ + ptrauth_strip(__tsp->__opaque_fp, ptrauth_key_process_independent_data)); \ + __tsp->__opaque_flags |= \ + __DARWIN_ARM_THREAD_STATE64_FLAGS_NO_PTRAUTH; }) + +#else /* __has_feature(ptrauth_calls) && defined(__LP64__) */ + +#if __DARWIN_OPAQUE_ARM_THREAD_STATE64 + +#ifndef __LP64__ +#error "Invalid configuration" +#endif + +/* Return pc field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_pc(ts) \ + ((uintptr_t)((ts).__opaque_pc)) +/* Return pc field of arm_thread_state64_t as a function pointer */ +#define __darwin_arm_thread_state64_get_pc_fptr(ts) \ + ((ts).__opaque_pc) +/* Set pc field of arm_thread_state64_t to a function pointer */ +#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ + ((ts).__opaque_pc = (fptr)) +/* Return lr field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_lr(ts) \ + ((uintptr_t)((ts).__opaque_lr)) +/* Return lr field of arm_thread_state64_t as a function pointer */ +#define __darwin_arm_thread_state64_get_lr_fptr(ts) \ + ((ts).__opaque_lr) +/* Set lr field of arm_thread_state64_t to a function pointer */ +#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ + ((ts).__opaque_lr = (fptr)) +/* Return sp field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_sp(ts) \ + ((uintptr_t)((ts).__opaque_sp)) +/* Set sp field of arm_thread_state64_t to a data pointer value */ +#define __darwin_arm_thread_state64_set_sp(ts, ptr) \ + ((ts).__opaque_sp = (void*)(uintptr_t)(ptr)) +/* Return fp field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_fp(ts) \ + ((uintptr_t)((ts).__opaque_fp)) +/* Set fp field of arm_thread_state64_t to a data pointer value */ +#define __darwin_arm_thread_state64_set_fp(ts, ptr) \ + ((ts).__opaque_fp = (void*)(uintptr_t)(ptr)) +/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */ +#define __darwin_arm_thread_state64_ptrauth_strip(ts) \ + (void)(ts) + +#else /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ +#if __DARWIN_UNIX03 + +/* Return pc field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_pc(ts) \ + ((ts).__pc) +/* Return pc field of arm_thread_state64_t as a function pointer */ +#define __darwin_arm_thread_state64_get_pc_fptr(ts) \ + ((void*)(uintptr_t)((ts).__pc)) +/* Set pc field of arm_thread_state64_t to a function pointer */ +#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ + ((ts).__pc = (uintptr_t)(fptr)) +/* Return lr field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_lr(ts) \ + ((ts).__lr) +/* Return lr field of arm_thread_state64_t as a function pointer */ +#define __darwin_arm_thread_state64_get_lr_fptr(ts) \ + ((void*)(uintptr_t)((ts).__lr)) +/* Set lr field of arm_thread_state64_t to a function pointer */ +#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ + ((ts).__lr = (uintptr_t)(fptr)) +/* Return sp field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_sp(ts) \ + ((ts).__sp) +/* Set sp field of arm_thread_state64_t to a data pointer value */ +#define __darwin_arm_thread_state64_set_sp(ts, ptr) \ + ((ts).__sp = (uintptr_t)(ptr)) +/* Return fp field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_fp(ts) \ + ((ts).__fp) +/* Set fp field of arm_thread_state64_t to a data pointer value */ +#define __darwin_arm_thread_state64_set_fp(ts, ptr) \ + ((ts).__fp = (uintptr_t)(ptr)) +/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */ +#define __darwin_arm_thread_state64_ptrauth_strip(ts) \ + (void)(ts) + +#else /* __DARWIN_UNIX03 */ + +/* Return pc field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_pc(ts) \ + ((ts).pc) +/* Return pc field of arm_thread_state64_t as a function pointer */ +#define __darwin_arm_thread_state64_get_pc_fptr(ts) \ + ((void*)(uintptr_t)((ts).pc)) +/* Set pc field of arm_thread_state64_t to a function pointer */ +#define __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) \ + ((ts).pc = (uintptr_t)(fptr)) +/* Return lr field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_lr(ts) \ + ((ts).lr) +/* Return lr field of arm_thread_state64_t as a function pointer */ +#define __darwin_arm_thread_state64_get_lr_fptr(ts) \ + ((void*)(uintptr_t)((ts).lr)) +/* Set lr field of arm_thread_state64_t to a function pointer */ +#define __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) \ + ((ts).lr = (uintptr_t)(fptr)) +/* Return sp field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_sp(ts) \ + ((ts).sp) +/* Set sp field of arm_thread_state64_t to a data pointer value */ +#define __darwin_arm_thread_state64_set_sp(ts, ptr) \ + ((ts).sp = (uintptr_t)(ptr)) +/* Return fp field of arm_thread_state64_t as a data pointer value */ +#define __darwin_arm_thread_state64_get_fp(ts) \ + ((ts).fp) +/* Set fp field of arm_thread_state64_t to a data pointer value */ +#define __darwin_arm_thread_state64_set_fp(ts, ptr) \ + ((ts).fp = (uintptr_t)(ptr)) +/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */ +#define __darwin_arm_thread_state64_ptrauth_strip(ts) \ + (void)(ts) + +#endif /* __DARWIN_UNIX03 */ +#endif /* __DARWIN_OPAQUE_ARM_THREAD_STATE64 */ + +#endif /* __has_feature(ptrauth_calls) && defined(__LP64__) */ +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_VFP_STATE struct __darwin_arm_vfp_state +_STRUCT_ARM_VFP_STATE +{ + __uint32_t __r[64]; + __uint32_t __fpscr; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_ARM_VFP_STATE struct arm_vfp_state +_STRUCT_ARM_VFP_STATE +{ + __uint32_t r[64]; + __uint32_t fpscr; +}; +#endif /* __DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_NEON_STATE64 struct __darwin_arm_neon_state64 +#define _STRUCT_ARM_NEON_STATE struct __darwin_arm_neon_state + +#if defined(__arm64__) +_STRUCT_ARM_NEON_STATE64 +{ + __uint128_t __v[32]; + __uint32_t __fpsr; + __uint32_t __fpcr; +}; + +_STRUCT_ARM_NEON_STATE +{ + __uint128_t __v[16]; + __uint32_t __fpsr; + __uint32_t __fpcr; +}; +#elif defined(__arm__) +/* + * No 128-bit intrinsic for ARM; leave it opaque for now. + */ +_STRUCT_ARM_NEON_STATE64 +{ + char opaque[(32 * 16) + (2 * sizeof(__uint32_t))]; +} __attribute__((aligned(16))); + +_STRUCT_ARM_NEON_STATE +{ + char opaque[(16 * 16) + (2 * sizeof(__uint32_t))]; +} __attribute__((aligned(16))); + +#else +#error Unknown architecture. +#endif + +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_ARM_NEON_STATE64 struct arm_neon_state64 +#define _STRUCT_ARM_NEON_STATE struct arm_neon_state + +#if defined(__arm64__) +_STRUCT_ARM_NEON_STATE64 +{ + __uint128_t q[32]; + uint32_t fpsr; + uint32_t fpcr; +}; + +_STRUCT_ARM_NEON_STATE +{ + __uint128_t q[16]; + uint32_t fpsr; + uint32_t fpcr; +}; +#elif defined(__arm__) +/* + * No 128-bit intrinsic for ARM; leave it opaque for now. + */ +_STRUCT_ARM_NEON_STATE64 +{ + char opaque[(32 * 16) + (2 * sizeof(__uint32_t))]; +} __attribute__((aligned(16))); + +_STRUCT_ARM_NEON_STATE +{ + char opaque[(16 * 16) + (2 * sizeof(__uint32_t))]; +} __attribute__((aligned(16))); + +#else +#error Unknown architecture. +#endif + +#endif /* __DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_AMX_STATE_V1 struct __darwin_arm_amx_state_v1 +_STRUCT_ARM_AMX_STATE_V1 +{ + __uint8_t __x[8][64]; /* 8 64-byte registers */ + __uint8_t __y[8][64]; /* 8 64-byte registers */ + __uint8_t __z[64][64]; /* 64 64-byte registers in an M-by-N matrix */ + __uint64_t __amx_state_t_el1; /* AMX_STATE_T_EL1 value */ +} __attribute__((aligned(64))); +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_ARM_AMX_STATE_V1 struct arm_amx_state_v1 +_STRUCT_ARM_AMX_STATE_V1 +{ + __uint8_t x[8][64]; /* 8 64-byte registers */ + __uint8_t y[8][64]; /* 8 64-byte registers */ + __uint8_t z[64][64]; /* 64 64-byte registers in an M-by-N matrix */ + __uint64_t amx_state_t_el1; /* AMX_STATE_T_EL1 value. */ +} __attribute__((aligned(64))); +#endif /* __DARWIN_UNIX03 */ + +#define _STRUCT_ARM_PAGEIN_STATE struct __arm_pagein_state +_STRUCT_ARM_PAGEIN_STATE +{ + int __pagein_error; +}; + +/* + * Debug State + */ +#if defined(__arm__) +/* Old-fashioned debug state is only for ARM */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_DEBUG_STATE struct __darwin_arm_debug_state +_STRUCT_ARM_DEBUG_STATE +{ + __uint32_t __bvr[16]; + __uint32_t __bcr[16]; + __uint32_t __wvr[16]; + __uint32_t __wcr[16]; +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_ARM_DEBUG_STATE struct arm_debug_state +_STRUCT_ARM_DEBUG_STATE +{ + __uint32_t bvr[16]; + __uint32_t bcr[16]; + __uint32_t wvr[16]; + __uint32_t wcr[16]; +}; +#endif /* __DARWIN_UNIX03 */ + +#elif defined(__arm64__) + +/* ARM's arm_debug_state is ARM64's arm_legacy_debug_state */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_LEGACY_DEBUG_STATE struct __arm_legacy_debug_state +_STRUCT_ARM_LEGACY_DEBUG_STATE +{ + __uint32_t __bvr[16]; + __uint32_t __bcr[16]; + __uint32_t __wvr[16]; + __uint32_t __wcr[16]; +}; +#else /* __DARWIN_UNIX03 */ +#define _STRUCT_ARM_LEGACY_DEBUG_STATE struct arm_legacy_debug_state +_STRUCT_ARM_LEGACY_DEBUG_STATE +{ + __uint32_t bvr[16]; + __uint32_t bcr[16]; + __uint32_t wvr[16]; + __uint32_t wcr[16]; +}; +#endif /* __DARWIN_UNIX03 */ +#else +#error unknown architecture +#endif + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_DEBUG_STATE32 struct __darwin_arm_debug_state32 +_STRUCT_ARM_DEBUG_STATE32 +{ + __uint32_t __bvr[16]; + __uint32_t __bcr[16]; + __uint32_t __wvr[16]; + __uint32_t __wcr[16]; + __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ +}; + +#define _STRUCT_ARM_DEBUG_STATE64 struct __darwin_arm_debug_state64 +_STRUCT_ARM_DEBUG_STATE64 +{ + __uint64_t __bvr[16]; + __uint64_t __bcr[16]; + __uint64_t __wvr[16]; + __uint64_t __wcr[16]; + __uint64_t __mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ +}; +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_ARM_DEBUG_STATE32 struct arm_debug_state32 +_STRUCT_ARM_DEBUG_STATE32 +{ + __uint32_t bvr[16]; + __uint32_t bcr[16]; + __uint32_t wvr[16]; + __uint32_t wcr[16]; + __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ +}; + +#define _STRUCT_ARM_DEBUG_STATE64 struct arm_debug_state64 +_STRUCT_ARM_DEBUG_STATE64 +{ + __uint64_t bvr[16]; + __uint64_t bcr[16]; + __uint64_t wvr[16]; + __uint64_t wcr[16]; + __uint64_t mdscr_el1; /* Bit 0 is SS (Hardware Single Step) */ +}; +#endif /* __DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_ARM_CPMU_STATE64 struct __darwin_arm_cpmu_state64 +_STRUCT_ARM_CPMU_STATE64 +{ + __uint64_t __ctrs[16]; +}; +#else /* __DARWIN_UNIX03 */ +#define _STRUCT_ARM_CPMU_STATE64 struct arm_cpmu_state64 +_STRUCT_ARM_CPMU_STATE64 +{ + __uint64_t ctrs[16]; +}; +#endif /* !__DARWIN_UNIX03 */ + +#endif /* _MACH_ARM__STRUCTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/boolean.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/boolean.h new file mode 100644 index 0000000000..703153e4e6 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/boolean.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ + +/* + * File: boolean.h + * + * Boolean type, for ARM. + */ + +#ifndef _MACH_ARM_BOOLEAN_H_ +#define _MACH_ARM_BOOLEAN_H_ + +typedef int boolean_t; + +#endif /* _MACH_ARM_BOOLEAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/exception.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/exception.h new file mode 100644 index 0000000000..cf804261a9 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/exception.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_ARM_EXCEPTION_H_ +#define _MACH_ARM_EXCEPTION_H_ + +#define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */ + +#define EXC_MASK_MACHINE 0 + +#define EXCEPTION_CODE_MAX 2 /* code and subcode */ + + +/* + * Trap numbers as defined by the hardware exception vectors. + */ + +/* + * EXC_BAD_INSTRUCTION + */ + +#define EXC_ARM_UNDEFINED 1 /* Undefined */ + +/* + * EXC_ARITHMETIC + */ + +#define EXC_ARM_FP_UNDEFINED 0 /* Undefined Floating Point Exception */ +#define EXC_ARM_FP_IO 1 /* Invalid Floating Point Operation */ +#define EXC_ARM_FP_DZ 2 /* Floating Point Divide by Zero */ +#define EXC_ARM_FP_OF 3 /* Floating Point Overflow */ +#define EXC_ARM_FP_UF 4 /* Floating Point Underflow */ +#define EXC_ARM_FP_IX 5 /* Inexact Floating Point Result */ +#define EXC_ARM_FP_ID 6 /* Floating Point Denormal Input */ + +/* + * EXC_BAD_ACCESS + * Note: do not conflict with kern_return_t values returned by vm_fault + */ + +#define EXC_ARM_DA_ALIGN 0x101 /* Alignment Fault */ +#define EXC_ARM_DA_DEBUG 0x102 /* Debug (watch/break) Fault */ +#define EXC_ARM_SP_ALIGN 0x103 /* SP Alignment Fault */ +#define EXC_ARM_SWP 0x104 /* SWP instruction */ +#define EXC_ARM_PAC_FAIL 0x105 /* PAC authentication failure */ + +/* + * EXC_BREAKPOINT + */ + +#define EXC_ARM_BREAKPOINT 1 /* breakpoint trap */ + + +#endif /* _MACH_ARM_EXCEPTION_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/kern_return.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/kern_return.h new file mode 100644 index 0000000000..0c23b0f973 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/kern_return.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ + +/* + * File: kern_return.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * Date: 1985 + * + * Machine-dependent kernel return definitions. + */ + +#ifndef _MACH_ARM_KERN_RETURN_H_ +#define _MACH_ARM_KERN_RETURN_H_ + +#ifndef ASSEMBLER +typedef int kern_return_t; +#endif /* ASSEMBLER */ + +#endif /* _MACH_ARM_KERN_RETURN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/processor_info.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/processor_info.h new file mode 100644 index 0000000000..cc2cfadeb4 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/processor_info.h @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2007-2018 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_ARM_PROCESSOR_INFO_H_ +#define _MACH_ARM_PROCESSOR_INFO_H_ + +#define PROCESSOR_CPU_STAT 0x10000003 /* Low-level CPU statistics */ +#define PROCESSOR_CPU_STAT64 0x10000004 /* Low-level CPU statistics, in full 64-bit */ + +#include /* uint32_t, uint64_t */ + +struct processor_cpu_stat { + uint32_t irq_ex_cnt; + uint32_t ipi_cnt; + uint32_t timer_cnt; + uint32_t undef_ex_cnt; + uint32_t unaligned_cnt; + uint32_t vfp_cnt; + uint32_t vfp_shortv_cnt; + uint32_t data_ex_cnt; + uint32_t instr_ex_cnt; +}; + +typedef struct processor_cpu_stat processor_cpu_stat_data_t; +typedef struct processor_cpu_stat *processor_cpu_stat_t; +#define PROCESSOR_CPU_STAT_COUNT ((mach_msg_type_number_t) \ + (sizeof(processor_cpu_stat_data_t) / sizeof(natural_t))) + +struct processor_cpu_stat64 { + uint64_t irq_ex_cnt; + uint64_t ipi_cnt; + uint64_t timer_cnt; + uint64_t undef_ex_cnt; + uint64_t unaligned_cnt; + uint64_t vfp_cnt; + uint64_t vfp_shortv_cnt; + uint64_t data_ex_cnt; + uint64_t instr_ex_cnt; + uint64_t pmi_cnt; +} __attribute__((packed, aligned(4))); + +typedef struct processor_cpu_stat64 processor_cpu_stat64_data_t; +typedef struct processor_cpu_stat64 *processor_cpu_stat64_t; +#define PROCESSOR_CPU_STAT64_COUNT ((mach_msg_type_number_t) \ + (sizeof(processor_cpu_stat64_data_t) / sizeof(integer_t))) + +#endif /* _MACH_ARM_PROCESSOR_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/rpc.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/rpc.h new file mode 100644 index 0000000000..3543cdf1ad --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/rpc.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#ifndef _MACH_ARM_RPC_H_ +#define _MACH_ARM_RPC_H_ + +#endif /* _MACH_ARM_RPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/thread_state.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/thread_state.h new file mode 100644 index 0000000000..75c28e6692 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/thread_state.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ + +#ifndef _MACH_ARM_THREAD_STATE_H_ +#define _MACH_ARM_THREAD_STATE_H_ + +/* Size of maximum exported thread state in words */ +#define ARM_THREAD_STATE_MAX (1296) /* Size of biggest state possible */ + +#if defined (__arm__) || defined(__arm64__) +#define THREAD_STATE_MAX ARM_THREAD_STATE_MAX +#else +#error Unsupported arch +#endif + +#endif /* _MACH_ARM_THREAD_STATE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/thread_status.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/thread_status.h new file mode 100644 index 0000000000..f8d0ccb037 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/thread_status.h @@ -0,0 +1,249 @@ +/* + * Copyright (c) 2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * FILE_ID: thread_status.h + */ + + +#ifndef _ARM_THREAD_STATUS_H_ +#define _ARM_THREAD_STATUS_H_ + +#include +#include +#include +#include + +/* + * Support for determining the state of a thread + */ + + +/* + * Flavors + */ + +#define ARM_THREAD_STATE 1 +#define ARM_UNIFIED_THREAD_STATE ARM_THREAD_STATE +#define ARM_VFP_STATE 2 +#define ARM_EXCEPTION_STATE 3 +#define ARM_DEBUG_STATE 4 /* pre-armv8 */ +#define THREAD_STATE_NONE 5 +#define ARM_THREAD_STATE64 6 +#define ARM_EXCEPTION_STATE64 7 +// ARM_THREAD_STATE_LAST 8 /* legacy */ +#define ARM_THREAD_STATE32 9 + + +/* API */ +#define ARM_DEBUG_STATE32 14 +#define ARM_DEBUG_STATE64 15 +#define ARM_NEON_STATE 16 +#define ARM_NEON_STATE64 17 +#define ARM_CPMU_STATE64 18 + + +/* API */ +#define ARM_AMX_STATE 24 +#define ARM_AMX_STATE_V1 25 +#define ARM_STATE_FLAVOR_IS_OTHER_VALID(_flavor_) \ + ((_flavor_) == ARM_AMX_STATE_V1) +#define ARM_PAGEIN_STATE 27 + +#define VALID_THREAD_STATE_FLAVOR(x) \ + ((x == ARM_THREAD_STATE) || \ + (x == ARM_VFP_STATE) || \ + (x == ARM_EXCEPTION_STATE) || \ + (x == ARM_DEBUG_STATE) || \ + (x == THREAD_STATE_NONE) || \ + (x == ARM_THREAD_STATE32) || \ + (x == ARM_THREAD_STATE64) || \ + (x == ARM_EXCEPTION_STATE64) || \ + (x == ARM_NEON_STATE) || \ + (x == ARM_NEON_STATE64) || \ + (x == ARM_DEBUG_STATE32) || \ + (x == ARM_DEBUG_STATE64) || \ + (x == ARM_PAGEIN_STATE) || \ + (ARM_STATE_FLAVOR_IS_OTHER_VALID(x))) + +struct arm_state_hdr { + uint32_t flavor; + uint32_t count; +}; +typedef struct arm_state_hdr arm_state_hdr_t; + +typedef _STRUCT_ARM_THREAD_STATE arm_thread_state_t; +typedef _STRUCT_ARM_THREAD_STATE arm_thread_state32_t; +typedef _STRUCT_ARM_THREAD_STATE64 arm_thread_state64_t; + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) + +/* Accessor macros for arm_thread_state64_t pointer fields */ + +/* Return pc field of arm_thread_state64_t as a data pointer value */ +#define arm_thread_state64_get_pc(ts) \ + __darwin_arm_thread_state64_get_pc(ts) +/* Return pc field of arm_thread_state64_t as a function pointer. May return + * NULL if a valid function pointer cannot be constructed, the caller should + * fall back to the arm_thread_state64_get_pc() macro in that case. */ +#define arm_thread_state64_get_pc_fptr(ts) \ + __darwin_arm_thread_state64_get_pc_fptr(ts) +/* Set pc field of arm_thread_state64_t to a function pointer */ +#define arm_thread_state64_set_pc_fptr(ts, fptr) \ + __darwin_arm_thread_state64_set_pc_fptr(ts, fptr) +/* Return lr field of arm_thread_state64_t as a data pointer value */ +#define arm_thread_state64_get_lr(ts) \ + __darwin_arm_thread_state64_get_lr(ts) +/* Return lr field of arm_thread_state64_t as a function pointer. May return + * NULL if a valid function pointer cannot be constructed, the caller should + * fall back to the arm_thread_state64_get_lr() macro in that case. */ +#define arm_thread_state64_get_lr_fptr(ts) \ + __darwin_arm_thread_state64_get_lr_fptr(ts) +/* Set lr field of arm_thread_state64_t to a function pointer */ +#define arm_thread_state64_set_lr_fptr(ts, fptr) \ + __darwin_arm_thread_state64_set_lr_fptr(ts, fptr) +/* Return sp field of arm_thread_state64_t as a data pointer value */ +#define arm_thread_state64_get_sp(ts) \ + __darwin_arm_thread_state64_get_sp(ts) +/* Set sp field of arm_thread_state64_t to a data pointer value */ +#define arm_thread_state64_set_sp(ts, ptr) \ + __darwin_arm_thread_state64_set_sp(ts, ptr) +/* Return fp field of arm_thread_state64_t as a data pointer value */ +#define arm_thread_state64_get_fp(ts) \ + __darwin_arm_thread_state64_get_fp(ts) +/* Set fp field of arm_thread_state64_t to a data pointer value */ +#define arm_thread_state64_set_fp(ts, ptr) \ + __darwin_arm_thread_state64_set_fp(ts, ptr) +/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */ +#define arm_thread_state64_ptrauth_strip(ts) \ + __darwin_arm_thread_state64_ptrauth_strip(ts) + +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */ + +struct arm_unified_thread_state { + arm_state_hdr_t ash; + union { + arm_thread_state32_t ts_32; + arm_thread_state64_t ts_64; + } uts; +}; +#define ts_32 uts.ts_32 +#define ts_64 uts.ts_64 +typedef struct arm_unified_thread_state arm_unified_thread_state_t; + +#define ARM_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_thread_state_t)/sizeof(uint32_t))) +#define ARM_THREAD_STATE32_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_thread_state32_t)/sizeof(uint32_t))) +#define ARM_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_thread_state64_t)/sizeof(uint32_t))) +#define ARM_UNIFIED_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_unified_thread_state_t)/sizeof(uint32_t))) + + +typedef _STRUCT_ARM_VFP_STATE arm_vfp_state_t; +typedef _STRUCT_ARM_NEON_STATE arm_neon_state_t; +typedef _STRUCT_ARM_NEON_STATE arm_neon_state32_t; +typedef _STRUCT_ARM_NEON_STATE64 arm_neon_state64_t; + +typedef _STRUCT_ARM_AMX_STATE_V1 arm_amx_state_v1_t; + +typedef _STRUCT_ARM_EXCEPTION_STATE arm_exception_state_t; +typedef _STRUCT_ARM_EXCEPTION_STATE arm_exception_state32_t; +typedef _STRUCT_ARM_EXCEPTION_STATE64 arm_exception_state64_t; + +typedef _STRUCT_ARM_DEBUG_STATE32 arm_debug_state32_t; +typedef _STRUCT_ARM_DEBUG_STATE64 arm_debug_state64_t; + +typedef _STRUCT_ARM_PAGEIN_STATE arm_pagein_state_t; + +/* + * Otherwise not ARM64 kernel and we must preserve legacy ARM definitions of + * arm_debug_state for binary compatability of userland consumers of this file. + */ +#if defined(__arm__) +typedef _STRUCT_ARM_DEBUG_STATE arm_debug_state_t; +#elif defined(__arm64__) +typedef _STRUCT_ARM_LEGACY_DEBUG_STATE arm_debug_state_t; +#else /* defined(__arm__) */ +#error Undefined architecture +#endif /* defined(__arm__) */ + +#define ARM_VFP_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_vfp_state_t)/sizeof(uint32_t))) + +#define ARM_EXCEPTION_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_exception_state_t)/sizeof(uint32_t))) + +#define ARM_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_exception_state64_t)/sizeof(uint32_t))) + +#define ARM_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_debug_state_t)/sizeof(uint32_t))) + +#define ARM_DEBUG_STATE32_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_debug_state32_t)/sizeof(uint32_t))) + +#define ARM_PAGEIN_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_pagein_state_t)/sizeof(uint32_t))) + +#define ARM_DEBUG_STATE64_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_debug_state64_t)/sizeof(uint32_t))) + +#define ARM_NEON_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_neon_state_t)/sizeof(uint32_t))) + +#define ARM_NEON_STATE64_COUNT ((mach_msg_type_number_t) \ + (sizeof (arm_neon_state64_t)/sizeof(uint32_t))) + +#define MACHINE_THREAD_STATE ARM_THREAD_STATE +#define MACHINE_THREAD_STATE_COUNT ARM_UNIFIED_THREAD_STATE_COUNT + + +struct arm_amx_state { + arm_state_hdr_t ash; + union { + arm_amx_state_v1_t as_v1; + } uas; +}; +#define as_v1 uas.as_v1 +typedef struct arm_amx_state arm_amx_state_t; + +#define ARM_AMX_STATE_V1_COUNT ((mach_msg_type_number_t) \ + (sizeof(arm_amx_state_v1_t)/sizeof(unsigned int))) + +#define ARM_AMX_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(arm_amx_state_t)/sizeof(unsigned int))) + + +/* + * Largest state on this machine: + */ +#define THREAD_MACHINE_STATE_MAX THREAD_STATE_MAX + + +#endif /* _ARM_THREAD_STATUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/vm_param.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/vm_param.h new file mode 100644 index 0000000000..75db0423d4 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/vm_param.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * FILE_ID: vm_param.h + */ + +/* + * ARM machine dependent virtual memory parameters. + */ + +#ifndef _MACH_ARM_VM_PARAM_H_ +#define _MACH_ARM_VM_PARAM_H_ + + +#if !defined (KERNEL) && !defined (__ASSEMBLER__) +#include +#endif + +#define BYTE_SIZE 8 /* byte size in bits */ + + +#define PAGE_SHIFT vm_page_shift +#define PAGE_SIZE vm_page_size +#define PAGE_MASK vm_page_mask + +#define VM_PAGE_SIZE vm_page_size + +#define machine_ptob(x) ((x) << PAGE_SHIFT) + + +#define PAGE_MAX_SHIFT 14 +#define PAGE_MAX_SIZE (1 << PAGE_MAX_SHIFT) +#define PAGE_MAX_MASK (PAGE_MAX_SIZE-1) + +#define PAGE_MIN_SHIFT 12 +#define PAGE_MIN_SIZE (1 << PAGE_MIN_SHIFT) +#define PAGE_MIN_MASK (PAGE_MIN_SIZE-1) + +#define VM_MAX_PAGE_ADDRESS MACH_VM_MAX_ADDRESS + +#ifndef __ASSEMBLER__ + + +#if defined (__arm__) + +#define VM_MIN_ADDRESS ((vm_address_t) 0x00000000) +#define VM_MAX_ADDRESS ((vm_address_t) 0x80000000) + +/* system-wide values */ +#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) 0) +#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) VM_MAX_ADDRESS) + +#elif defined (__arm64__) + +#define VM_MIN_ADDRESS ((vm_address_t) 0x0000000000000000ULL) +#define VM_MAX_ADDRESS ((vm_address_t) 0x0000000080000000ULL) + +/* system-wide values */ +#define MACH_VM_MIN_ADDRESS_RAW 0x0ULL +#define MACH_VM_MAX_ADDRESS_RAW 0x00007FFFFE000000ULL + +#define MACH_VM_MIN_ADDRESS ((mach_vm_offset_t) MACH_VM_MIN_ADDRESS_RAW) +#define MACH_VM_MAX_ADDRESS ((mach_vm_offset_t) MACH_VM_MAX_ADDRESS_RAW) + + +#else /* defined(__arm64__) */ +#error architecture not supported +#endif + +#define VM_MAP_MIN_ADDRESS VM_MIN_ADDRESS +#define VM_MAP_MAX_ADDRESS VM_MAX_ADDRESS + + +#endif /* !__ASSEMBLER__ */ + +#define SWI_SYSCALL 0x80 + +#endif /* _MACH_ARM_VM_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/arm/vm_types.h b/lib/libc/include/aarch64-macos-gnu/mach/arm/vm_types.h new file mode 100644 index 0000000000..6fcf262c24 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/arm/vm_types.h @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ + +/* + * File: vm_types.h + * Author: Avadis Tevanian, Jr. + * Date: 1985 + * + * Header file for VM data types. ARM version. + */ + +#ifndef _MACH_ARM_VM_TYPES_H_ +#define _MACH_ARM_VM_TYPES_H_ + +#ifndef ASSEMBLER + +#include +#include +#include + +/* + * natural_t and integer_t are Mach's legacy types for machine- + * independent integer types (unsigned, and signed, respectively). + * Their original purpose was to define other types in a machine/ + * compiler independent way. + * + * They also had an implicit "same size as pointer" characteristic + * to them (i.e. Mach's traditional types are very ILP32 or ILP64 + * centric). We will likely support x86 ABIs that do not follow + * either ofthese models (specifically LP64). Therefore, we had to + * make a choice between making these types scale with pointers or stay + * tied to integers. Because their use is predominantly tied to + * to the size of an integer, we are keeping that association and + * breaking free from pointer size guarantees. + * + * New use of these types is discouraged. + */ +typedef __darwin_natural_t natural_t; +typedef int integer_t; + +/* + * A vm_offset_t is a type-neutral pointer, + * e.g. an offset into a virtual memory space. + */ +#ifdef __LP64__ +typedef uintptr_t vm_offset_t; +typedef uintptr_t vm_size_t; + +typedef uint64_t mach_vm_address_t; +typedef uint64_t mach_vm_offset_t; +typedef uint64_t mach_vm_size_t; + +typedef uint64_t vm_map_offset_t; +typedef uint64_t vm_map_address_t; +typedef uint64_t vm_map_size_t; +#else +typedef natural_t vm_offset_t; +/* + * A vm_size_t is the proper type for e.g. + * expressing the difference between two + * vm_offset_t entities. + */ +typedef natural_t vm_size_t; + +/* + * This new type is independent of a particular vm map's + * implementation size - and represents appropriate types + * for all possible maps. This is used for interfaces + * where the size of the map is not known - or we don't + * want to have to distinguish. + */ +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0) +typedef uint32_t mach_vm_address_t; +typedef uint32_t mach_vm_offset_t; +typedef uint32_t mach_vm_size_t; +#else +typedef uint64_t mach_vm_address_t; +typedef uint64_t mach_vm_offset_t; +typedef uint64_t mach_vm_size_t; +#endif + +typedef uint32_t vm_map_offset_t; +typedef uint32_t vm_map_address_t; +typedef uint32_t vm_map_size_t; +#endif /* __LP64__ */ + + +typedef uint32_t vm32_offset_t; +typedef uint32_t vm32_address_t; +typedef uint32_t vm32_size_t; + +typedef vm_offset_t mach_port_context_t; + + +#endif /* ASSEMBLER */ + +/* + * If composing messages by hand (please do not) + */ +#define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32 + +#endif /* _MACH_ARM_VM_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/kern_return.h b/lib/libc/include/aarch64-macos-gnu/mach/kern_return.h new file mode 100644 index 0000000000..3ab2af7a7a --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/kern_return.h @@ -0,0 +1,334 @@ +/* + * 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * File: h/kern_return.h + * Author: Avadis Tevanian, Jr. + * Date: 1985 + * + * Kernel return codes. + * + */ + +#ifndef _MACH_KERN_RETURN_H_ +#define _MACH_KERN_RETURN_H_ + +#include + +#define KERN_SUCCESS 0 + +#define KERN_INVALID_ADDRESS 1 +/* Specified address is not currently valid. + */ + +#define KERN_PROTECTION_FAILURE 2 +/* Specified memory is valid, but does not permit the + * required forms of access. + */ + +#define KERN_NO_SPACE 3 +/* The address range specified is already in use, or + * no address range of the size specified could be + * found. + */ + +#define KERN_INVALID_ARGUMENT 4 +/* The function requested was not applicable to this + * type of argument, or an argument is invalid + */ + +#define KERN_FAILURE 5 +/* The function could not be performed. A catch-all. + */ + +#define KERN_RESOURCE_SHORTAGE 6 +/* A system resource could not be allocated to fulfill + * this request. This failure may not be permanent. + */ + +#define KERN_NOT_RECEIVER 7 +/* The task in question does not hold receive rights + * for the port argument. + */ + +#define KERN_NO_ACCESS 8 +/* Bogus access restriction. + */ + +#define KERN_MEMORY_FAILURE 9 +/* During a page fault, the target address refers to a + * memory object that has been destroyed. This + * failure is permanent. + */ + +#define KERN_MEMORY_ERROR 10 +/* During a page fault, the memory object indicated + * that the data could not be returned. This failure + * may be temporary; future attempts to access this + * same data may succeed, as defined by the memory + * object. + */ + +#define KERN_ALREADY_IN_SET 11 +/* The receive right is already a member of the portset. + */ + +#define KERN_NOT_IN_SET 12 +/* The receive right is not a member of a port set. + */ + +#define KERN_NAME_EXISTS 13 +/* The name already denotes a right in the task. + */ + +#define KERN_ABORTED 14 +/* The operation was aborted. Ipc code will + * catch this and reflect it as a message error. + */ + +#define KERN_INVALID_NAME 15 +/* The name doesn't denote a right in the task. + */ + +#define KERN_INVALID_TASK 16 +/* Target task isn't an active task. + */ + +#define KERN_INVALID_RIGHT 17 +/* The name denotes a right, but not an appropriate right. + */ + +#define KERN_INVALID_VALUE 18 +/* A blatant range error. + */ + +#define KERN_UREFS_OVERFLOW 19 +/* Operation would overflow limit on user-references. + */ + +#define KERN_INVALID_CAPABILITY 20 +/* The supplied (port) capability is improper. + */ + +#define KERN_RIGHT_EXISTS 21 +/* The task already has send or receive rights + * for the port under another name. + */ + +#define KERN_INVALID_HOST 22 +/* Target host isn't actually a host. + */ + +#define KERN_MEMORY_PRESENT 23 +/* An attempt was made to supply "precious" data + * for memory that is already present in a + * memory object. + */ + +#define KERN_MEMORY_DATA_MOVED 24 +/* A page was requested of a memory manager via + * memory_object_data_request for an object using + * a MEMORY_OBJECT_COPY_CALL strategy, with the + * VM_PROT_WANTS_COPY flag being used to specify + * that the page desired is for a copy of the + * object, and the memory manager has detected + * the page was pushed into a copy of the object + * while the kernel was walking the shadow chain + * from the copy to the object. This error code + * is delivered via memory_object_data_error + * and is handled by the kernel (it forces the + * kernel to restart the fault). It will not be + * seen by users. + */ + +#define KERN_MEMORY_RESTART_COPY 25 +/* A strategic copy was attempted of an object + * upon which a quicker copy is now possible. + * The caller should retry the copy using + * vm_object_copy_quickly. This error code + * is seen only by the kernel. + */ + +#define KERN_INVALID_PROCESSOR_SET 26 +/* An argument applied to assert processor set privilege + * was not a processor set control port. + */ + +#define KERN_POLICY_LIMIT 27 +/* The specified scheduling attributes exceed the thread's + * limits. + */ + +#define KERN_INVALID_POLICY 28 +/* The specified scheduling policy is not currently + * enabled for the processor set. + */ + +#define KERN_INVALID_OBJECT 29 +/* The external memory manager failed to initialize the + * memory object. + */ + +#define KERN_ALREADY_WAITING 30 +/* A thread is attempting to wait for an event for which + * there is already a waiting thread. + */ + +#define KERN_DEFAULT_SET 31 +/* An attempt was made to destroy the default processor + * set. + */ + +#define KERN_EXCEPTION_PROTECTED 32 +/* An attempt was made to fetch an exception port that is + * protected, or to abort a thread while processing a + * protected exception. + */ + +#define KERN_INVALID_LEDGER 33 +/* A ledger was required but not supplied. + */ + +#define KERN_INVALID_MEMORY_CONTROL 34 +/* The port was not a memory cache control port. + */ + +#define KERN_INVALID_SECURITY 35 +/* An argument supplied to assert security privilege + * was not a host security port. + */ + +#define KERN_NOT_DEPRESSED 36 +/* thread_depress_abort was called on a thread which + * was not currently depressed. + */ + +#define KERN_TERMINATED 37 +/* Object has been terminated and is no longer available + */ + +#define KERN_LOCK_SET_DESTROYED 38 +/* Lock set has been destroyed and is no longer available. + */ + +#define KERN_LOCK_UNSTABLE 39 +/* The thread holding the lock terminated before releasing + * the lock + */ + +#define KERN_LOCK_OWNED 40 +/* The lock is already owned by another thread + */ + +#define KERN_LOCK_OWNED_SELF 41 +/* The lock is already owned by the calling thread + */ + +#define KERN_SEMAPHORE_DESTROYED 42 +/* Semaphore has been destroyed and is no longer available. + */ + +#define KERN_RPC_SERVER_TERMINATED 43 +/* Return from RPC indicating the target server was + * terminated before it successfully replied + */ + +#define KERN_RPC_TERMINATE_ORPHAN 44 +/* Terminate an orphaned activation. + */ + +#define KERN_RPC_CONTINUE_ORPHAN 45 +/* Allow an orphaned activation to continue executing. + */ + +#define KERN_NOT_SUPPORTED 46 +/* Empty thread activation (No thread linked to it) + */ + +#define KERN_NODE_DOWN 47 +/* Remote node down or inaccessible. + */ + +#define KERN_NOT_WAITING 48 +/* A signalled thread was not actually waiting. */ + +#define KERN_OPERATION_TIMED_OUT 49 +/* Some thread-oriented operation (semaphore_wait) timed out + */ + +#define KERN_CODESIGN_ERROR 50 +/* During a page fault, indicates that the page was rejected + * as a result of a signature check. + */ + +#define KERN_POLICY_STATIC 51 +/* The requested property cannot be changed at this time. + */ + +#define KERN_INSUFFICIENT_BUFFER_SIZE 52 +/* The provided buffer is of insufficient size for the requested data. + */ + +#define KERN_DENIED 53 +/* Denied by security policy + */ + +#define KERN_RETURN_MAX 0x100 +/* Maximum return value allowable + */ + +#endif /* _MACH_KERN_RETURN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/mach_port.h b/lib/libc/include/aarch64-macos-gnu/mach/mach_port.h new file mode 100644 index 0000000000..c0b2526016 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/mach_port.h @@ -0,0 +1,1808 @@ +#ifndef _mach_port_user_ +#define _mach_port_user_ + +/* Module mach_port */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* BEGIN MIG_STRNCPY_ZEROFILL CODE */ + +#if defined(__has_include) +#if __has_include() +#ifndef USING_MIG_STRNCPY_ZEROFILL +#define USING_MIG_STRNCPY_ZEROFILL +#endif +#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ +#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ +#ifdef __cplusplus +extern "C" { +#endif + extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); +#ifdef __cplusplus +} +#endif +#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ +#endif /* __has_include() */ +#endif /* __has_include */ + +/* END MIG_STRNCPY_ZEROFILL CODE */ + + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef mach_port_MSG_COUNT +#define mach_port_MSG_COUNT 40 +#endif /* mach_port_MSG_COUNT */ + +#include +#include +#include +#include +#include + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include +__BEGIN_DECLS + + +/* Routine mach_port_names */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_names +( + ipc_space_t task, + mach_port_name_array_t *names, + mach_msg_type_number_t *namesCnt, + mach_port_type_array_t *types, + mach_msg_type_number_t *typesCnt +); + +/* Routine mach_port_type */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_type +( + ipc_space_t task, + mach_port_name_t name, + mach_port_type_t *ptype +); + +/* Routine mach_port_rename */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_rename +( + ipc_space_t task, + mach_port_name_t old_name, + mach_port_name_t new_name +); + +/* Routine mach_port_allocate_name */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t mach_port_allocate_name +( + ipc_space_t task, + mach_port_right_t right, + mach_port_name_t name +); + +/* Routine mach_port_allocate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_allocate +( + ipc_space_t task, + mach_port_right_t right, + mach_port_name_t *name +); + +/* Routine mach_port_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_destroy +( + ipc_space_t task, + mach_port_name_t name +); + +/* Routine mach_port_deallocate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_deallocate +( + ipc_space_t task, + mach_port_name_t name +); + +/* Routine mach_port_get_refs */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_refs +( + ipc_space_t task, + mach_port_name_t name, + mach_port_right_t right, + mach_port_urefs_t *refs +); + +/* Routine mach_port_mod_refs */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_mod_refs +( + ipc_space_t task, + mach_port_name_t name, + mach_port_right_t right, + mach_port_delta_t delta +); + +/* Routine mach_port_peek */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_peek +( + ipc_space_t task, + mach_port_name_t name, + mach_msg_trailer_type_t trailer_type, + mach_port_seqno_t *request_seqnop, + mach_msg_size_t *msg_sizep, + mach_msg_id_t *msg_idp, + mach_msg_trailer_info_t trailer_infop, + mach_msg_type_number_t *trailer_infopCnt +); + +/* Routine mach_port_set_mscount */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_set_mscount +( + ipc_space_t task, + mach_port_name_t name, + mach_port_mscount_t mscount +); + +/* Routine mach_port_get_set_status */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_set_status +( + ipc_space_read_t task, + mach_port_name_t name, + mach_port_name_array_t *members, + mach_msg_type_number_t *membersCnt +); + +/* Routine mach_port_move_member */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_move_member +( + ipc_space_t task, + mach_port_name_t member, + mach_port_name_t after +); + +/* Routine mach_port_request_notification */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_request_notification +( + ipc_space_t task, + mach_port_name_t name, + mach_msg_id_t msgid, + mach_port_mscount_t sync, + mach_port_t notify, + mach_msg_type_name_t notifyPoly, + mach_port_t *previous +); + +/* Routine mach_port_insert_right */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_insert_right +( + ipc_space_t task, + mach_port_name_t name, + mach_port_t poly, + mach_msg_type_name_t polyPoly +); + +/* Routine mach_port_extract_right */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_extract_right +( + ipc_space_t task, + mach_port_name_t name, + mach_msg_type_name_t msgt_name, + mach_port_t *poly, + mach_msg_type_name_t *polyPoly +); + +/* Routine mach_port_set_seqno */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_set_seqno +( + ipc_space_t task, + mach_port_name_t name, + mach_port_seqno_t seqno +); + +/* Routine mach_port_get_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_attributes +( + ipc_space_read_t task, + mach_port_name_t name, + mach_port_flavor_t flavor, + mach_port_info_t port_info_out, + mach_msg_type_number_t *port_info_outCnt +); + +/* Routine mach_port_set_attributes */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_set_attributes +( + ipc_space_t task, + mach_port_name_t name, + mach_port_flavor_t flavor, + mach_port_info_t port_info, + mach_msg_type_number_t port_infoCnt +); + +/* Routine mach_port_allocate_qos */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_allocate_qos +( + ipc_space_t task, + mach_port_right_t right, + mach_port_qos_t *qos, + mach_port_name_t *name +); + +/* Routine mach_port_allocate_full */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_allocate_full +( + ipc_space_t task, + mach_port_right_t right, + mach_port_t proto, + mach_port_qos_t *qos, + mach_port_name_t *name +); + +/* Routine task_set_port_space */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_set_port_space +( + ipc_space_t task, + int table_entries +); + +/* Routine mach_port_get_srights */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_srights +( + ipc_space_t task, + mach_port_name_t name, + mach_port_rights_t *srights +); + +/* Routine mach_port_space_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_space_info +( + ipc_space_read_t space, + ipc_info_space_t *space_info, + ipc_info_name_array_t *table_info, + mach_msg_type_number_t *table_infoCnt, + ipc_info_tree_name_array_t *tree_info, + mach_msg_type_number_t *tree_infoCnt +); + +/* Routine mach_port_dnrequest_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_dnrequest_info +( + ipc_space_t task, + mach_port_name_t name, + unsigned *dnr_total, + unsigned *dnr_used +); + +/* Routine mach_port_kernel_object */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_kernel_object +( + ipc_space_read_t task, + mach_port_name_t name, + unsigned *object_type, + unsigned *object_addr +); + +/* Routine mach_port_insert_member */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_insert_member +( + ipc_space_t task, + mach_port_name_t name, + mach_port_name_t pset +); + +/* Routine mach_port_extract_member */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_extract_member +( + ipc_space_t task, + mach_port_name_t name, + mach_port_name_t pset +); + +/* Routine mach_port_get_context */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_get_context +( + ipc_space_read_t task, + mach_port_name_t name, + mach_port_context_t *context +); + +/* Routine mach_port_set_context */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_set_context +( + ipc_space_t task, + mach_port_name_t name, + mach_port_context_t context +); + +/* Routine mach_port_kobject */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_kobject +( + ipc_space_read_t task, + mach_port_name_t name, + natural_t *object_type, + mach_vm_address_t *object_addr +); + +/* Routine mach_port_construct */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_construct +( + ipc_space_t task, + mach_port_options_ptr_t options, + mach_port_context_t context, + mach_port_name_t *name +); + +/* Routine mach_port_destruct */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_destruct +( + ipc_space_t task, + mach_port_name_t name, + mach_port_delta_t srdelta, + mach_port_context_t guard +); + +/* Routine mach_port_guard */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_guard +( + ipc_space_t task, + mach_port_name_t name, + mach_port_context_t guard, + boolean_t strict +); + +/* Routine mach_port_unguard */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_unguard +( + ipc_space_t task, + mach_port_name_t name, + mach_port_context_t guard +); + +/* Routine mach_port_space_basic_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_space_basic_info +( + ipc_space_inspect_t task, + ipc_info_space_basic_t *basic_info +); + +/* Routine mach_port_guard_with_flags */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_guard_with_flags +( + ipc_space_t task, + mach_port_name_t name, + mach_port_context_t guard, + uint64_t flags +); + +/* Routine mach_port_swap_guard */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_swap_guard +( + ipc_space_t task, + mach_port_name_t name, + mach_port_context_t old_guard, + mach_port_context_t new_guard +); + +/* Routine mach_port_kobject_description */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t mach_port_kobject_description +( + ipc_space_read_t task, + mach_port_name_t name, + natural_t *object_type, + mach_vm_address_t *object_addr, + kobject_description_t description +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__mach_port_subsystem__defined +#define __Request__mach_port_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__mach_port_names_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_type_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t old_name; + mach_port_name_t new_name; + } __Request__mach_port_rename_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_right_t right; + mach_port_name_t name; + } __Request__mach_port_allocate_name_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_right_t right; + } __Request__mach_port_allocate_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_destroy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_deallocate_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_right_t right; + } __Request__mach_port_get_refs_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_right_t right; + mach_port_delta_t delta; + } __Request__mach_port_mod_refs_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_msg_trailer_type_t trailer_type; + mach_port_seqno_t request_seqnop; + mach_msg_type_number_t trailer_infopCnt; + } __Request__mach_port_peek_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_mscount_t mscount; + } __Request__mach_port_set_mscount_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_get_set_status_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t member; + mach_port_name_t after; + } __Request__mach_port_move_member_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t notify; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_port_name_t name; + mach_msg_id_t msgid; + mach_port_mscount_t sync; + } __Request__mach_port_request_notification_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t poly; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_insert_right_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_msg_type_name_t msgt_name; + } __Request__mach_port_extract_right_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_seqno_t seqno; + } __Request__mach_port_set_seqno_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_flavor_t flavor; + mach_msg_type_number_t port_info_outCnt; + } __Request__mach_port_get_attributes_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_flavor_t flavor; + mach_msg_type_number_t port_infoCnt; + integer_t port_info[17]; + } __Request__mach_port_set_attributes_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_right_t right; + mach_port_qos_t qos; + } __Request__mach_port_allocate_qos_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t proto; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_port_right_t right; + mach_port_qos_t qos; + mach_port_name_t name; + } __Request__mach_port_allocate_full_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int table_entries; + } __Request__task_set_port_space_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_get_srights_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__mach_port_space_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_dnrequest_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_kernel_object_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_name_t pset; + } __Request__mach_port_insert_member_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_name_t pset; + } __Request__mach_port_extract_member_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_get_context_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_context_t context; + } __Request__mach_port_set_context_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_kobject_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t options; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_port_context_t context; + } __Request__mach_port_construct_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_delta_t srdelta; + mach_port_context_t guard; + } __Request__mach_port_destruct_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_context_t guard; + boolean_t strict; + } __Request__mach_port_guard_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_context_t guard; + } __Request__mach_port_unguard_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__mach_port_space_basic_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_context_t guard; + uint64_t flags; + } __Request__mach_port_guard_with_flags_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + mach_port_context_t old_guard; + mach_port_context_t new_guard; + } __Request__mach_port_swap_guard_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_port_name_t name; + } __Request__mach_port_kobject_description_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif +#endif /* !__Request__mach_port_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__mach_port_subsystem__defined +#define __RequestUnion__mach_port_subsystem__defined +union __RequestUnion__mach_port_subsystem { + __Request__mach_port_names_t Request_mach_port_names; + __Request__mach_port_type_t Request_mach_port_type; + __Request__mach_port_rename_t Request_mach_port_rename; + __Request__mach_port_allocate_name_t Request_mach_port_allocate_name; + __Request__mach_port_allocate_t Request_mach_port_allocate; + __Request__mach_port_destroy_t Request_mach_port_destroy; + __Request__mach_port_deallocate_t Request_mach_port_deallocate; + __Request__mach_port_get_refs_t Request_mach_port_get_refs; + __Request__mach_port_mod_refs_t Request_mach_port_mod_refs; + __Request__mach_port_peek_t Request_mach_port_peek; + __Request__mach_port_set_mscount_t Request_mach_port_set_mscount; + __Request__mach_port_get_set_status_t Request_mach_port_get_set_status; + __Request__mach_port_move_member_t Request_mach_port_move_member; + __Request__mach_port_request_notification_t Request_mach_port_request_notification; + __Request__mach_port_insert_right_t Request_mach_port_insert_right; + __Request__mach_port_extract_right_t Request_mach_port_extract_right; + __Request__mach_port_set_seqno_t Request_mach_port_set_seqno; + __Request__mach_port_get_attributes_t Request_mach_port_get_attributes; + __Request__mach_port_set_attributes_t Request_mach_port_set_attributes; + __Request__mach_port_allocate_qos_t Request_mach_port_allocate_qos; + __Request__mach_port_allocate_full_t Request_mach_port_allocate_full; + __Request__task_set_port_space_t Request_task_set_port_space; + __Request__mach_port_get_srights_t Request_mach_port_get_srights; + __Request__mach_port_space_info_t Request_mach_port_space_info; + __Request__mach_port_dnrequest_info_t Request_mach_port_dnrequest_info; + __Request__mach_port_kernel_object_t Request_mach_port_kernel_object; + __Request__mach_port_insert_member_t Request_mach_port_insert_member; + __Request__mach_port_extract_member_t Request_mach_port_extract_member; + __Request__mach_port_get_context_t Request_mach_port_get_context; + __Request__mach_port_set_context_t Request_mach_port_set_context; + __Request__mach_port_kobject_t Request_mach_port_kobject; + __Request__mach_port_construct_t Request_mach_port_construct; + __Request__mach_port_destruct_t Request_mach_port_destruct; + __Request__mach_port_guard_t Request_mach_port_guard; + __Request__mach_port_unguard_t Request_mach_port_unguard; + __Request__mach_port_space_basic_info_t Request_mach_port_space_basic_info; + __Request__mach_port_guard_with_flags_t Request_mach_port_guard_with_flags; + __Request__mach_port_swap_guard_t Request_mach_port_swap_guard; + __Request__mach_port_kobject_description_t Request_mach_port_kobject_description; +}; +#endif /* !__RequestUnion__mach_port_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__mach_port_subsystem__defined +#define __Reply__mach_port_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t names; + mach_msg_ool_descriptor_t types; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t namesCnt; + mach_msg_type_number_t typesCnt; + } __Reply__mach_port_names_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_type_t ptype; + } __Reply__mach_port_type_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_rename_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_allocate_name_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_name_t name; + } __Reply__mach_port_allocate_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_destroy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_deallocate_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_urefs_t refs; + } __Reply__mach_port_get_refs_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_mod_refs_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_seqno_t request_seqnop; + mach_msg_size_t msg_sizep; + mach_msg_id_t msg_idp; + mach_msg_type_number_t trailer_infopCnt; + char trailer_infop[68]; + } __Reply__mach_port_peek_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_set_mscount_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t members; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t membersCnt; + } __Reply__mach_port_get_set_status_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_move_member_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t previous; + /* end of the kernel processed data */ + } __Reply__mach_port_request_notification_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_insert_right_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t poly; + /* end of the kernel processed data */ + } __Reply__mach_port_extract_right_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_set_seqno_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t port_info_outCnt; + integer_t port_info_out[17]; + } __Reply__mach_port_get_attributes_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_set_attributes_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_qos_t qos; + mach_port_name_t name; + } __Reply__mach_port_allocate_qos_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_qos_t qos; + mach_port_name_t name; + } __Reply__mach_port_allocate_full_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_port_space_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_rights_t srights; + } __Reply__mach_port_get_srights_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t table_info; + mach_msg_ool_descriptor_t tree_info; + /* end of the kernel processed data */ + NDR_record_t NDR; + ipc_info_space_t space_info; + mach_msg_type_number_t table_infoCnt; + mach_msg_type_number_t tree_infoCnt; + } __Reply__mach_port_space_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + unsigned dnr_total; + unsigned dnr_used; + } __Reply__mach_port_dnrequest_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + unsigned object_type; + unsigned object_addr; + } __Reply__mach_port_kernel_object_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_insert_member_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_extract_member_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_context_t context; + } __Reply__mach_port_get_context_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_set_context_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + natural_t object_type; + mach_vm_address_t object_addr; + } __Reply__mach_port_kobject_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_port_name_t name; + } __Reply__mach_port_construct_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_destruct_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_guard_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_unguard_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + ipc_info_space_basic_t basic_info; + } __Reply__mach_port_space_basic_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_guard_with_flags_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_port_swap_guard_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + natural_t object_type; + mach_vm_address_t object_addr; + mach_msg_type_number_t descriptionOffset; /* MiG doesn't use it */ + mach_msg_type_number_t descriptionCnt; + char description[512]; + } __Reply__mach_port_kobject_description_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif +#endif /* !__Reply__mach_port_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__mach_port_subsystem__defined +#define __ReplyUnion__mach_port_subsystem__defined +union __ReplyUnion__mach_port_subsystem { + __Reply__mach_port_names_t Reply_mach_port_names; + __Reply__mach_port_type_t Reply_mach_port_type; + __Reply__mach_port_rename_t Reply_mach_port_rename; + __Reply__mach_port_allocate_name_t Reply_mach_port_allocate_name; + __Reply__mach_port_allocate_t Reply_mach_port_allocate; + __Reply__mach_port_destroy_t Reply_mach_port_destroy; + __Reply__mach_port_deallocate_t Reply_mach_port_deallocate; + __Reply__mach_port_get_refs_t Reply_mach_port_get_refs; + __Reply__mach_port_mod_refs_t Reply_mach_port_mod_refs; + __Reply__mach_port_peek_t Reply_mach_port_peek; + __Reply__mach_port_set_mscount_t Reply_mach_port_set_mscount; + __Reply__mach_port_get_set_status_t Reply_mach_port_get_set_status; + __Reply__mach_port_move_member_t Reply_mach_port_move_member; + __Reply__mach_port_request_notification_t Reply_mach_port_request_notification; + __Reply__mach_port_insert_right_t Reply_mach_port_insert_right; + __Reply__mach_port_extract_right_t Reply_mach_port_extract_right; + __Reply__mach_port_set_seqno_t Reply_mach_port_set_seqno; + __Reply__mach_port_get_attributes_t Reply_mach_port_get_attributes; + __Reply__mach_port_set_attributes_t Reply_mach_port_set_attributes; + __Reply__mach_port_allocate_qos_t Reply_mach_port_allocate_qos; + __Reply__mach_port_allocate_full_t Reply_mach_port_allocate_full; + __Reply__task_set_port_space_t Reply_task_set_port_space; + __Reply__mach_port_get_srights_t Reply_mach_port_get_srights; + __Reply__mach_port_space_info_t Reply_mach_port_space_info; + __Reply__mach_port_dnrequest_info_t Reply_mach_port_dnrequest_info; + __Reply__mach_port_kernel_object_t Reply_mach_port_kernel_object; + __Reply__mach_port_insert_member_t Reply_mach_port_insert_member; + __Reply__mach_port_extract_member_t Reply_mach_port_extract_member; + __Reply__mach_port_get_context_t Reply_mach_port_get_context; + __Reply__mach_port_set_context_t Reply_mach_port_set_context; + __Reply__mach_port_kobject_t Reply_mach_port_kobject; + __Reply__mach_port_construct_t Reply_mach_port_construct; + __Reply__mach_port_destruct_t Reply_mach_port_destruct; + __Reply__mach_port_guard_t Reply_mach_port_guard; + __Reply__mach_port_unguard_t Reply_mach_port_unguard; + __Reply__mach_port_space_basic_info_t Reply_mach_port_space_basic_info; + __Reply__mach_port_guard_with_flags_t Reply_mach_port_guard_with_flags; + __Reply__mach_port_swap_guard_t Reply_mach_port_swap_guard; + __Reply__mach_port_kobject_description_t Reply_mach_port_kobject_description; +}; +#endif /* !__RequestUnion__mach_port_subsystem__defined */ + +#ifndef subsystem_to_name_map_mach_port +#define subsystem_to_name_map_mach_port \ + { "mach_port_names", 3200 },\ + { "mach_port_type", 3201 },\ + { "mach_port_rename", 3202 },\ + { "mach_port_allocate_name", 3203 },\ + { "mach_port_allocate", 3204 },\ + { "mach_port_destroy", 3205 },\ + { "mach_port_deallocate", 3206 },\ + { "mach_port_get_refs", 3207 },\ + { "mach_port_mod_refs", 3208 },\ + { "mach_port_peek", 3209 },\ + { "mach_port_set_mscount", 3210 },\ + { "mach_port_get_set_status", 3211 },\ + { "mach_port_move_member", 3212 },\ + { "mach_port_request_notification", 3213 },\ + { "mach_port_insert_right", 3214 },\ + { "mach_port_extract_right", 3215 },\ + { "mach_port_set_seqno", 3216 },\ + { "mach_port_get_attributes", 3217 },\ + { "mach_port_set_attributes", 3218 },\ + { "mach_port_allocate_qos", 3219 },\ + { "mach_port_allocate_full", 3220 },\ + { "task_set_port_space", 3221 },\ + { "mach_port_get_srights", 3222 },\ + { "mach_port_space_info", 3223 },\ + { "mach_port_dnrequest_info", 3224 },\ + { "mach_port_kernel_object", 3225 },\ + { "mach_port_insert_member", 3226 },\ + { "mach_port_extract_member", 3227 },\ + { "mach_port_get_context", 3228 },\ + { "mach_port_set_context", 3229 },\ + { "mach_port_kobject", 3230 },\ + { "mach_port_construct", 3231 },\ + { "mach_port_destruct", 3232 },\ + { "mach_port_guard", 3233 },\ + { "mach_port_unguard", 3234 },\ + { "mach_port_space_basic_info", 3235 },\ + { "mach_port_guard_with_flags", 3237 },\ + { "mach_port_swap_guard", 3238 },\ + { "mach_port_kobject_description", 3239 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _mach_port_user_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/mach_traps.h b/lib/libc/include/aarch64-macos-gnu/mach/mach_traps.h new file mode 100644 index 0000000000..cf1df240b7 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/mach_traps.h @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2000-2019 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * Definitions of general Mach system traps. + * + * These are the definitions as seen from user-space. + * The kernel definitions are in . + * Kernel RPC functions are defined in . + */ + +#ifndef _MACH_MACH_TRAPS_H_ +#define _MACH_MACH_TRAPS_H_ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +__BEGIN_DECLS + + + +extern kern_return_t clock_sleep_trap( + mach_port_name_t clock_name, + sleep_type_t sleep_type, + int sleep_sec, + int sleep_nsec, + mach_timespec_t *wakeup_time); + +extern kern_return_t _kernelrpc_mach_vm_allocate_trap( + mach_port_name_t target, + mach_vm_offset_t *addr, + mach_vm_size_t size, + int flags); + +extern kern_return_t _kernelrpc_mach_vm_deallocate_trap( + mach_port_name_t target, + mach_vm_address_t address, + mach_vm_size_t size + ); + +extern kern_return_t _kernelrpc_mach_vm_protect_trap( + mach_port_name_t target, + mach_vm_address_t address, + mach_vm_size_t size, + boolean_t set_maximum, + vm_prot_t new_protection + ); + +extern kern_return_t _kernelrpc_mach_vm_map_trap( + mach_port_name_t target, + mach_vm_offset_t *address, + mach_vm_size_t size, + mach_vm_offset_t mask, + int flags, + vm_prot_t cur_protection + ); + +extern kern_return_t _kernelrpc_mach_vm_purgable_control_trap( + mach_port_name_t target, + mach_vm_offset_t address, + vm_purgable_t control, + int *state); + +extern kern_return_t _kernelrpc_mach_port_allocate_trap( + mach_port_name_t target, + mach_port_right_t right, + mach_port_name_t *name + ); + +extern kern_return_t _kernelrpc_mach_port_deallocate_trap( + mach_port_name_t target, + mach_port_name_t name + ); + +extern kern_return_t _kernelrpc_mach_port_mod_refs_trap( + mach_port_name_t target, + mach_port_name_t name, + mach_port_right_t right, + mach_port_delta_t delta + ); + +extern kern_return_t _kernelrpc_mach_port_move_member_trap( + mach_port_name_t target, + mach_port_name_t member, + mach_port_name_t after + ); + +extern kern_return_t _kernelrpc_mach_port_insert_right_trap( + mach_port_name_t target, + mach_port_name_t name, + mach_port_name_t poly, + mach_msg_type_name_t polyPoly + ); + +extern kern_return_t _kernelrpc_mach_port_get_attributes_trap( + mach_port_name_t target, + mach_port_name_t name, + mach_port_flavor_t flavor, + mach_port_info_t port_info_out, + mach_msg_type_number_t *port_info_outCnt + ); + +extern kern_return_t _kernelrpc_mach_port_insert_member_trap( + mach_port_name_t target, + mach_port_name_t name, + mach_port_name_t pset + ); + +extern kern_return_t _kernelrpc_mach_port_extract_member_trap( + mach_port_name_t target, + mach_port_name_t name, + mach_port_name_t pset + ); + +extern kern_return_t _kernelrpc_mach_port_construct_trap( + mach_port_name_t target, + mach_port_options_t *options, + uint64_t context, + mach_port_name_t *name + ); + +extern kern_return_t _kernelrpc_mach_port_destruct_trap( + mach_port_name_t target, + mach_port_name_t name, + mach_port_delta_t srdelta, + uint64_t guard + ); + +extern kern_return_t _kernelrpc_mach_port_guard_trap( + mach_port_name_t target, + mach_port_name_t name, + uint64_t guard, + boolean_t strict + ); + +extern kern_return_t _kernelrpc_mach_port_unguard_trap( + mach_port_name_t target, + mach_port_name_t name, + uint64_t guard + ); + +extern kern_return_t mach_generate_activity_id( + mach_port_name_t target, + int count, + uint64_t *activity_id + ); + +extern kern_return_t macx_swapon( + uint64_t filename, + int flags, + int size, + int priority); + +extern kern_return_t macx_swapoff( + uint64_t filename, + int flags); + +extern kern_return_t macx_triggers( + int hi_water, + int low_water, + int flags, + mach_port_t alert_port); + +extern kern_return_t macx_backing_store_suspend( + boolean_t suspend); + +extern kern_return_t macx_backing_store_recovery( + int pid); + +extern boolean_t swtch_pri(int pri); + +extern boolean_t swtch(void); + +extern kern_return_t thread_switch( + mach_port_name_t thread_name, + int option, + mach_msg_timeout_t option_time); + +extern mach_port_name_t task_self_trap(void); + +extern kern_return_t host_create_mach_voucher_trap( + mach_port_name_t host, + mach_voucher_attr_raw_recipe_array_t recipes, + int recipes_size, + mach_port_name_t *voucher); + +extern kern_return_t mach_voucher_extract_attr_recipe_trap( + mach_port_name_t voucher_name, + mach_voucher_attr_key_t key, + mach_voucher_attr_raw_recipe_t recipe, + mach_msg_type_number_t *recipe_size); + +extern kern_return_t _kernelrpc_mach_port_type_trap( + ipc_space_t task, + mach_port_name_t name, + mach_port_type_t *ptype); + +extern kern_return_t _kernelrpc_mach_port_request_notification_trap( + ipc_space_t task, + mach_port_name_t name, + mach_msg_id_t msgid, + mach_port_mscount_t sync, + mach_port_name_t notify, + mach_msg_type_name_t notifyPoly, + mach_port_name_t *previous); + +/* + * Obsolete interfaces. + */ + +extern kern_return_t task_for_pid( + mach_port_name_t target_tport, + int pid, + mach_port_name_t *t); + +extern kern_return_t task_name_for_pid( + mach_port_name_t target_tport, + int pid, + mach_port_name_t *tn); + +extern kern_return_t pid_for_task( + mach_port_name_t t, + int *x); + +extern kern_return_t debug_control_port_for_pid( + mach_port_name_t target_tport, + int pid, + mach_port_name_t *t); + + +__END_DECLS + +#endif /* _MACH_MACH_TRAPS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/mach_types.h b/lib/libc/include/aarch64-macos-gnu/mach/mach_types.h new file mode 100644 index 0000000000..5832587263 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/mach_types.h @@ -0,0 +1,283 @@ +/* + * Copyright (c) 2000-2018 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ +/* + * File: mach/mach_types.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * Date: 1986 + * + * Mach external interface definitions. + * + */ + +#ifndef _MACH_MACH_TYPES_H_ +#define _MACH_MACH_TYPES_H_ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* + * If we are not in the kernel, then these will all be represented by + * ports at user-space. + */ +typedef mach_port_t task_t; +typedef mach_port_t task_name_t; +typedef mach_port_t task_policy_set_t; +typedef mach_port_t task_policy_get_t; +typedef mach_port_t task_inspect_t; +typedef mach_port_t task_read_t; +typedef mach_port_t task_suspension_token_t; +typedef mach_port_t thread_t; +typedef mach_port_t thread_act_t; +typedef mach_port_t thread_inspect_t; +typedef mach_port_t thread_read_t; +typedef mach_port_t ipc_space_t; +typedef mach_port_t ipc_space_read_t; +typedef mach_port_t ipc_space_inspect_t; +typedef mach_port_t coalition_t; +typedef mach_port_t host_t; +typedef mach_port_t host_priv_t; +typedef mach_port_t host_security_t; +typedef mach_port_t processor_t; +typedef mach_port_t processor_set_t; +typedef mach_port_t processor_set_control_t; +typedef mach_port_t semaphore_t; +typedef mach_port_t lock_set_t; +typedef mach_port_t ledger_t; +typedef mach_port_t alarm_t; +typedef mach_port_t clock_serv_t; +typedef mach_port_t clock_ctrl_t; +typedef mach_port_t arcade_register_t; +typedef mach_port_t ipc_eventlink_t; +typedef mach_port_t eventlink_port_pair_t[2]; +typedef mach_port_t suid_cred_t; + + +/* + * These aren't really unique types. They are just called + * out as unique types at one point in history. So we list + * them here for compatibility. + */ +typedef processor_set_t processor_set_name_t; + +/* + * These types are just hard-coded as ports + */ +typedef mach_port_t clock_reply_t; +typedef mach_port_t bootstrap_t; +typedef mach_port_t mem_entry_name_port_t; +typedef mach_port_t exception_handler_t; +typedef exception_handler_t *exception_handler_array_t; +typedef mach_port_t vm_task_entry_t; +typedef mach_port_t io_master_t; +typedef mach_port_t UNDServerRef; +typedef mach_port_t mach_eventlink_t; + +/* + * Mig doesn't translate the components of an array. + * For example, Mig won't use the thread_t translations + * to translate a thread_array_t argument. So, these definitions + * are not completely accurate at the moment for other kernel + * components. + */ +typedef task_t *task_array_t; +typedef thread_t *thread_array_t; +typedef processor_set_t *processor_set_array_t; +typedef processor_set_t *processor_set_name_array_t; +typedef processor_t *processor_array_t; +typedef thread_act_t *thread_act_array_t; +typedef ledger_t *ledger_array_t; + +/* + * However the real mach_types got declared, we also have to declare + * types with "port" in the name for compatability with the way OSF + * had declared the user interfaces at one point. Someday these should + * go away. + */ +typedef task_t task_port_t; +typedef task_array_t task_port_array_t; +typedef thread_t thread_port_t; +typedef thread_array_t thread_port_array_t; +typedef ipc_space_t ipc_space_port_t; +typedef host_t host_name_t; +typedef host_t host_name_port_t; +typedef processor_set_t processor_set_port_t; +typedef processor_set_t processor_set_name_port_t; +typedef processor_set_array_t processor_set_name_port_array_t; +typedef processor_set_t processor_set_control_port_t; +typedef processor_t processor_port_t; +typedef processor_array_t processor_port_array_t; +typedef thread_act_t thread_act_port_t; +typedef thread_act_array_t thread_act_port_array_t; +typedef semaphore_t semaphore_port_t; +typedef lock_set_t lock_set_port_t; +typedef ledger_t ledger_port_t; +typedef ledger_array_t ledger_port_array_t; +typedef alarm_t alarm_port_t; +typedef clock_serv_t clock_serv_port_t; +typedef clock_ctrl_t clock_ctrl_port_t; +typedef exception_handler_t exception_port_t; +typedef exception_handler_array_t exception_port_arrary_t; +typedef char vfs_path_t[4096]; +typedef char nspace_path_t[1024]; /* 1024 == PATH_MAX */ +typedef char suid_cred_path_t[1024]; +typedef uint32_t suid_cred_uid_t; + +#define TASK_NULL ((task_t) 0) +#define TASK_NAME_NULL ((task_name_t) 0) +#define TASK_INSPECT_NULL ((task_inspect_t) 0) +#define TASK_READ_NULL ((task_read_t) 0) +#define THREAD_NULL ((thread_t) 0) +#define THREAD_INSPECT_NULL ((thread_inspect_t) 0) +#define THREAD_READ_NULL ((thread_read_t) 0) +#define TID_NULL ((uint64_t) 0) +#define THR_ACT_NULL ((thread_act_t) 0) +#define IPC_SPACE_NULL ((ipc_space_t) 0) +#define IPC_SPACE_READ_NULL ((ipc_space_read_t) 0) +#define IPC_SPACE_INSPECT_NULL ((ipc_space_inspect_t) 0) +#define COALITION_NULL ((coalition_t) 0) +#define HOST_NULL ((host_t) 0) +#define HOST_PRIV_NULL ((host_priv_t) 0) +#define HOST_SECURITY_NULL ((host_security_t) 0) +#define PROCESSOR_SET_NULL ((processor_set_t) 0) +#define PROCESSOR_NULL ((processor_t) 0) +#define SEMAPHORE_NULL ((semaphore_t) 0) +#define LOCK_SET_NULL ((lock_set_t) 0) +#define LEDGER_NULL ((ledger_t) 0) +#define ALARM_NULL ((alarm_t) 0) +#define CLOCK_NULL ((clock_t) 0) +#define UND_SERVER_NULL ((UNDServerRef) 0) +#define ARCADE_REG_NULL ((arcade_register_t) 0) +#define MACH_EVENTLINK_NULL ((mach_eventlink_t) 0) +#define IPC_EVENTLINK_NULL ((ipc_eventlink_t) 0) +#define SUID_CRED_NULL ((suid_cred_t) 0) + +/* capability strictly _DECREASING_. + * not ordered the other way around because we want TASK_FLAVOR_CONTROL + * to be closest to the itk_lock. see task.h. + */ +typedef unsigned int mach_task_flavor_t; +#define TASK_FLAVOR_CONTROL 0 /* a task_t */ +#define TASK_FLAVOR_READ 1 /* a task_read_t */ +#define TASK_FLAVOR_INSPECT 2 /* a task_inspect_t */ +#define TASK_FLAVOR_NAME 3 /* a task_name_t */ + +/* capability strictly _DECREASING_ */ +typedef unsigned int mach_thread_flavor_t; +#define THREAD_FLAVOR_CONTROL 0 /* a thread_t */ +#define THREAD_FLAVOR_READ 1 /* a thread_read_t */ +#define THREAD_FLAVOR_INSPECT 2 /* a thread_inspect_t */ + +/* DEPRECATED */ +typedef natural_t ledger_item_t; +#define LEDGER_ITEM_INFINITY ((ledger_item_t) (~0)) + +typedef int64_t ledger_amount_t; +#define LEDGER_LIMIT_INFINITY ((ledger_amount_t)((1ULL << 63) - 1)) + +typedef mach_vm_offset_t *emulation_vector_t; +typedef char *user_subsystem_t; + +typedef char *labelstr_t; +/* + * Backwards compatibility, for those programs written + * before mach/{std,mach}_types.{defs,h} were set up. + */ +#include + +#endif /* _MACH_MACH_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine.h b/lib/libc/include/aarch64-macos-gnu/mach/machine.h new file mode 100644 index 0000000000..7bcc490914 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine.h @@ -0,0 +1,411 @@ +/* + * Copyright (c) 2007-2016 Apple, Inc. All rights reserved. + * 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@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* File: machine.h + * Author: Avadis Tevanian, Jr. + * Date: 1986 + * + * Machine independent machine abstraction. + */ + +#ifndef _MACH_MACHINE_H_ +#define _MACH_MACHINE_H_ + +#ifndef __ASSEMBLER__ + +#include +#include +#include + +typedef integer_t cpu_type_t; +typedef integer_t cpu_subtype_t; +typedef integer_t cpu_threadtype_t; + +#define CPU_STATE_MAX 4 + +#define CPU_STATE_USER 0 +#define CPU_STATE_SYSTEM 1 +#define CPU_STATE_IDLE 2 +#define CPU_STATE_NICE 3 + + + +/* + * Capability bits used in the definition of cpu_type. + */ +#define CPU_ARCH_MASK 0xff000000 /* mask for architecture bits */ +#define CPU_ARCH_ABI64 0x01000000 /* 64 bit ABI */ +#define CPU_ARCH_ABI64_32 0x02000000 /* ABI for 64-bit hardware with 32-bit types; LP32 */ + +/* + * Machine types known by all. + */ + +#define CPU_TYPE_ANY ((cpu_type_t) -1) + +#define CPU_TYPE_VAX ((cpu_type_t) 1) +/* skip ((cpu_type_t) 2) */ +/* skip ((cpu_type_t) 3) */ +/* skip ((cpu_type_t) 4) */ +/* skip ((cpu_type_t) 5) */ +#define CPU_TYPE_MC680x0 ((cpu_type_t) 6) +#define CPU_TYPE_X86 ((cpu_type_t) 7) +#define CPU_TYPE_I386 CPU_TYPE_X86 /* compatibility */ +#define CPU_TYPE_X86_64 (CPU_TYPE_X86 | CPU_ARCH_ABI64) + +/* skip CPU_TYPE_MIPS ((cpu_type_t) 8) */ +/* skip ((cpu_type_t) 9) */ +#define CPU_TYPE_MC98000 ((cpu_type_t) 10) +#define CPU_TYPE_HPPA ((cpu_type_t) 11) +#define CPU_TYPE_ARM ((cpu_type_t) 12) +#define CPU_TYPE_ARM64 (CPU_TYPE_ARM | CPU_ARCH_ABI64) +#define CPU_TYPE_ARM64_32 (CPU_TYPE_ARM | CPU_ARCH_ABI64_32) +#define CPU_TYPE_MC88000 ((cpu_type_t) 13) +#define CPU_TYPE_SPARC ((cpu_type_t) 14) +#define CPU_TYPE_I860 ((cpu_type_t) 15) +/* skip CPU_TYPE_ALPHA ((cpu_type_t) 16) */ +/* skip ((cpu_type_t) 17) */ +#define CPU_TYPE_POWERPC ((cpu_type_t) 18) +#define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64) +/* skip ((cpu_type_t) 19) */ +/* skip ((cpu_type_t) 20 */ +/* skip ((cpu_type_t) 21 */ +/* skip ((cpu_type_t) 22 */ + +/* + * Machine subtypes (these are defined here, instead of in a machine + * dependent directory, so that any program can get all definitions + * regardless of where is it compiled). + */ + +/* + * Capability bits used in the definition of cpu_subtype. + */ +#define CPU_SUBTYPE_MASK 0xff000000 /* mask for feature flags */ +#define CPU_SUBTYPE_LIB64 0x80000000 /* 64 bit libraries */ +#define CPU_SUBTYPE_PTRAUTH_ABI 0x80000000 /* pointer authentication with versioned ABI */ + +/* + * When selecting a slice, ANY will pick the slice with the best + * grading for the selected cpu_type_t, unlike the "ALL" subtypes, + * which are the slices that can run on any hardware for that cpu type. + */ +#define CPU_SUBTYPE_ANY ((cpu_subtype_t) -1) + +/* + * Object files that are hand-crafted to run on any + * implementation of an architecture are tagged with + * CPU_SUBTYPE_MULTIPLE. This functions essentially the same as + * the "ALL" subtype of an architecture except that it allows us + * to easily find object files that may need to be modified + * whenever a new implementation of an architecture comes out. + * + * It is the responsibility of the implementor to make sure the + * software handles unsupported implementations elegantly. + */ +#define CPU_SUBTYPE_MULTIPLE ((cpu_subtype_t) -1) +#define CPU_SUBTYPE_LITTLE_ENDIAN ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_BIG_ENDIAN ((cpu_subtype_t) 1) + +/* + * Machine threadtypes. + * This is none - not defined - for most machine types/subtypes. + */ +#define CPU_THREADTYPE_NONE ((cpu_threadtype_t) 0) + +/* + * VAX subtypes (these do *not* necessary conform to the actual cpu + * ID assigned by DEC available via the SID register). + */ + +#define CPU_SUBTYPE_VAX_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_VAX780 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_VAX785 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_VAX750 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_VAX730 ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_UVAXI ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_UVAXII ((cpu_subtype_t) 6) +#define CPU_SUBTYPE_VAX8200 ((cpu_subtype_t) 7) +#define CPU_SUBTYPE_VAX8500 ((cpu_subtype_t) 8) +#define CPU_SUBTYPE_VAX8600 ((cpu_subtype_t) 9) +#define CPU_SUBTYPE_VAX8650 ((cpu_subtype_t) 10) +#define CPU_SUBTYPE_VAX8800 ((cpu_subtype_t) 11) +#define CPU_SUBTYPE_UVAXIII ((cpu_subtype_t) 12) + +/* + * 680x0 subtypes + * + * The subtype definitions here are unusual for historical reasons. + * NeXT used to consider 68030 code as generic 68000 code. For + * backwards compatability: + * + * CPU_SUBTYPE_MC68030 symbol has been preserved for source code + * compatability. + * + * CPU_SUBTYPE_MC680x0_ALL has been defined to be the same + * subtype as CPU_SUBTYPE_MC68030 for binary comatability. + * + * CPU_SUBTYPE_MC68030_ONLY has been added to allow new object + * files to be tagged as containing 68030-specific instructions. + */ + +#define CPU_SUBTYPE_MC680x0_ALL ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_MC68030 ((cpu_subtype_t) 1) /* compat */ +#define CPU_SUBTYPE_MC68040 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_MC68030_ONLY ((cpu_subtype_t) 3) + +/* + * I386 subtypes + */ + +#define CPU_SUBTYPE_INTEL(f, m) ((cpu_subtype_t) (f) + ((m) << 4)) + +#define CPU_SUBTYPE_I386_ALL CPU_SUBTYPE_INTEL(3, 0) +#define CPU_SUBTYPE_386 CPU_SUBTYPE_INTEL(3, 0) +#define CPU_SUBTYPE_486 CPU_SUBTYPE_INTEL(4, 0) +#define CPU_SUBTYPE_486SX CPU_SUBTYPE_INTEL(4, 8) // 8 << 4 = 128 +#define CPU_SUBTYPE_586 CPU_SUBTYPE_INTEL(5, 0) +#define CPU_SUBTYPE_PENT CPU_SUBTYPE_INTEL(5, 0) +#define CPU_SUBTYPE_PENTPRO CPU_SUBTYPE_INTEL(6, 1) +#define CPU_SUBTYPE_PENTII_M3 CPU_SUBTYPE_INTEL(6, 3) +#define CPU_SUBTYPE_PENTII_M5 CPU_SUBTYPE_INTEL(6, 5) +#define CPU_SUBTYPE_CELERON CPU_SUBTYPE_INTEL(7, 6) +#define CPU_SUBTYPE_CELERON_MOBILE CPU_SUBTYPE_INTEL(7, 7) +#define CPU_SUBTYPE_PENTIUM_3 CPU_SUBTYPE_INTEL(8, 0) +#define CPU_SUBTYPE_PENTIUM_3_M CPU_SUBTYPE_INTEL(8, 1) +#define CPU_SUBTYPE_PENTIUM_3_XEON CPU_SUBTYPE_INTEL(8, 2) +#define CPU_SUBTYPE_PENTIUM_M CPU_SUBTYPE_INTEL(9, 0) +#define CPU_SUBTYPE_PENTIUM_4 CPU_SUBTYPE_INTEL(10, 0) +#define CPU_SUBTYPE_PENTIUM_4_M CPU_SUBTYPE_INTEL(10, 1) +#define CPU_SUBTYPE_ITANIUM CPU_SUBTYPE_INTEL(11, 0) +#define CPU_SUBTYPE_ITANIUM_2 CPU_SUBTYPE_INTEL(11, 1) +#define CPU_SUBTYPE_XEON CPU_SUBTYPE_INTEL(12, 0) +#define CPU_SUBTYPE_XEON_MP CPU_SUBTYPE_INTEL(12, 1) + +#define CPU_SUBTYPE_INTEL_FAMILY(x) ((x) & 15) +#define CPU_SUBTYPE_INTEL_FAMILY_MAX 15 + +#define CPU_SUBTYPE_INTEL_MODEL(x) ((x) >> 4) +#define CPU_SUBTYPE_INTEL_MODEL_ALL 0 + +/* + * X86 subtypes. + */ + +#define CPU_SUBTYPE_X86_ALL ((cpu_subtype_t)3) +#define CPU_SUBTYPE_X86_64_ALL ((cpu_subtype_t)3) +#define CPU_SUBTYPE_X86_ARCH1 ((cpu_subtype_t)4) +#define CPU_SUBTYPE_X86_64_H ((cpu_subtype_t)8) /* Haswell feature subset */ + + +#define CPU_THREADTYPE_INTEL_HTT ((cpu_threadtype_t) 1) + +/* + * Mips subtypes. + */ + +#define CPU_SUBTYPE_MIPS_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_MIPS_R2300 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_MIPS_R2600 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_MIPS_R2800 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_MIPS_R2000a ((cpu_subtype_t) 4) /* pmax */ +#define CPU_SUBTYPE_MIPS_R2000 ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_MIPS_R3000a ((cpu_subtype_t) 6) /* 3max */ +#define CPU_SUBTYPE_MIPS_R3000 ((cpu_subtype_t) 7) + +/* + * MC98000 (PowerPC) subtypes + */ +#define CPU_SUBTYPE_MC98000_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_MC98601 ((cpu_subtype_t) 1) + +/* + * HPPA subtypes for Hewlett-Packard HP-PA family of + * risc processors. Port by NeXT to 700 series. + */ + +#define CPU_SUBTYPE_HPPA_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_HPPA_7100 ((cpu_subtype_t) 0) /* compat */ +#define CPU_SUBTYPE_HPPA_7100LC ((cpu_subtype_t) 1) + +/* + * MC88000 subtypes. + */ +#define CPU_SUBTYPE_MC88000_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_MC88100 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_MC88110 ((cpu_subtype_t) 2) + +/* + * SPARC subtypes + */ +#define CPU_SUBTYPE_SPARC_ALL ((cpu_subtype_t) 0) + +/* + * I860 subtypes + */ +#define CPU_SUBTYPE_I860_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_I860_860 ((cpu_subtype_t) 1) + +/* + * PowerPC subtypes + */ +#define CPU_SUBTYPE_POWERPC_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_POWERPC_601 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_POWERPC_602 ((cpu_subtype_t) 2) +#define CPU_SUBTYPE_POWERPC_603 ((cpu_subtype_t) 3) +#define CPU_SUBTYPE_POWERPC_603e ((cpu_subtype_t) 4) +#define CPU_SUBTYPE_POWERPC_603ev ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_POWERPC_604 ((cpu_subtype_t) 6) +#define CPU_SUBTYPE_POWERPC_604e ((cpu_subtype_t) 7) +#define CPU_SUBTYPE_POWERPC_620 ((cpu_subtype_t) 8) +#define CPU_SUBTYPE_POWERPC_750 ((cpu_subtype_t) 9) +#define CPU_SUBTYPE_POWERPC_7400 ((cpu_subtype_t) 10) +#define CPU_SUBTYPE_POWERPC_7450 ((cpu_subtype_t) 11) +#define CPU_SUBTYPE_POWERPC_970 ((cpu_subtype_t) 100) + +/* + * ARM subtypes + */ +#define CPU_SUBTYPE_ARM_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_ARM_V4T ((cpu_subtype_t) 5) +#define CPU_SUBTYPE_ARM_V6 ((cpu_subtype_t) 6) +#define CPU_SUBTYPE_ARM_V5TEJ ((cpu_subtype_t) 7) +#define CPU_SUBTYPE_ARM_XSCALE ((cpu_subtype_t) 8) +#define CPU_SUBTYPE_ARM_V7 ((cpu_subtype_t) 9) /* ARMv7-A and ARMv7-R */ +#define CPU_SUBTYPE_ARM_V7F ((cpu_subtype_t) 10) /* Cortex A9 */ +#define CPU_SUBTYPE_ARM_V7S ((cpu_subtype_t) 11) /* Swift */ +#define CPU_SUBTYPE_ARM_V7K ((cpu_subtype_t) 12) +#define CPU_SUBTYPE_ARM_V8 ((cpu_subtype_t) 13) +#define CPU_SUBTYPE_ARM_V6M ((cpu_subtype_t) 14) /* Not meant to be run under xnu */ +#define CPU_SUBTYPE_ARM_V7M ((cpu_subtype_t) 15) /* Not meant to be run under xnu */ +#define CPU_SUBTYPE_ARM_V7EM ((cpu_subtype_t) 16) /* Not meant to be run under xnu */ +#define CPU_SUBTYPE_ARM_V8M ((cpu_subtype_t) 17) /* Not meant to be run under xnu */ + +/* + * ARM64 subtypes + */ +#define CPU_SUBTYPE_ARM64_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_ARM64_V8 ((cpu_subtype_t) 1) +#define CPU_SUBTYPE_ARM64E ((cpu_subtype_t) 2) + +/* CPU subtype feature flags for ptrauth on arm64e platforms */ +#define CPU_SUBTYPE_ARM64_PTR_AUTH_MASK 0x0f000000 +#define CPU_SUBTYPE_ARM64_PTR_AUTH_VERSION(x) (((x) & CPU_SUBTYPE_ARM64_PTR_AUTH_MASK) >> 24) + +/* + * ARM64_32 subtypes + */ +#define CPU_SUBTYPE_ARM64_32_ALL ((cpu_subtype_t) 0) +#define CPU_SUBTYPE_ARM64_32_V8 ((cpu_subtype_t) 1) + +#endif /* !__ASSEMBLER__ */ + +/* + * CPU families (sysctl hw.cpufamily) + * + * These are meant to identify the CPU's marketing name - an + * application can map these to (possibly) localized strings. + * NB: the encodings of the CPU families are intentionally arbitrary. + * There is no ordering, and you should never try to deduce whether + * or not some feature is available based on the family. + * Use feature flags (eg, hw.optional.altivec) to test for optional + * functionality. + */ +#define CPUFAMILY_UNKNOWN 0 +#define CPUFAMILY_POWERPC_G3 0xcee41549 +#define CPUFAMILY_POWERPC_G4 0x77c184ae +#define CPUFAMILY_POWERPC_G5 0xed76d8aa +#define CPUFAMILY_INTEL_6_13 0xaa33392b +#define CPUFAMILY_INTEL_PENRYN 0x78ea4fbc +#define CPUFAMILY_INTEL_NEHALEM 0x6b5a4cd2 +#define CPUFAMILY_INTEL_WESTMERE 0x573b5eec +#define CPUFAMILY_INTEL_SANDYBRIDGE 0x5490b78c +#define CPUFAMILY_INTEL_IVYBRIDGE 0x1f65e835 +#define CPUFAMILY_INTEL_HASWELL 0x10b282dc +#define CPUFAMILY_INTEL_BROADWELL 0x582ed09c +#define CPUFAMILY_INTEL_SKYLAKE 0x37fc219f +#define CPUFAMILY_INTEL_KABYLAKE 0x0f817246 +#define CPUFAMILY_INTEL_ICELAKE 0x38435547 +#if !defined(RC_HIDE_XNU_COMETLAKE) +#define CPUFAMILY_INTEL_COMETLAKE 0x1cf8a03e +#endif /* not RC_HIDE_XNU_COMETLAKE */ +#define CPUFAMILY_ARM_9 0xe73283ae +#define CPUFAMILY_ARM_11 0x8ff620d8 +#define CPUFAMILY_ARM_XSCALE 0x53b005f5 +#define CPUFAMILY_ARM_12 0xbd1b0ae9 +#define CPUFAMILY_ARM_13 0x0cc90e64 +#define CPUFAMILY_ARM_14 0x96077ef1 +#define CPUFAMILY_ARM_15 0xa8511bca +#define CPUFAMILY_ARM_SWIFT 0x1e2d6381 +#define CPUFAMILY_ARM_CYCLONE 0x37a09642 +#define CPUFAMILY_ARM_TYPHOON 0x2c91a47e +#define CPUFAMILY_ARM_TWISTER 0x92fb37c8 +#define CPUFAMILY_ARM_HURRICANE 0x67ceee93 +#define CPUFAMILY_ARM_MONSOON_MISTRAL 0xe81e7ef6 +#define CPUFAMILY_ARM_VORTEX_TEMPEST 0x07d34b9f +#define CPUFAMILY_ARM_LIGHTNING_THUNDER 0x462504d2 +#define CPUFAMILY_ARM_FIRESTORM_ICESTORM 0x1b588bb3 + +#define CPUSUBFAMILY_UNKNOWN 0 +#define CPUSUBFAMILY_ARM_HP 1 +#define CPUSUBFAMILY_ARM_HG 2 +#define CPUSUBFAMILY_ARM_M 3 +#define CPUSUBFAMILY_ARM_HS 4 +#define CPUSUBFAMILY_ARM_HC_HD 5 + +/* The following synonyms are deprecated: */ +#define CPUFAMILY_INTEL_6_23 CPUFAMILY_INTEL_PENRYN +#define CPUFAMILY_INTEL_6_26 CPUFAMILY_INTEL_NEHALEM + + +#endif /* _MACH_MACHINE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/_structs.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/_structs.h new file mode 100644 index 0000000000..915d652c83 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/_structs.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE__STRUCTS_H_ +#define _MACH_MACHINE__STRUCTS_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/_structs.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/_structs.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE__STRUCTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/boolean.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/boolean.h new file mode 100644 index 0000000000..9d69543df9 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/boolean.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE_BOOLEAN_H_ +#define _MACH_MACHINE_BOOLEAN_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/boolean.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/boolean.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_BOOLEAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/exception.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/exception.h new file mode 100644 index 0000000000..20b4f63ae6 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/exception.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE_EXCEPTION_H_ +#define _MACH_MACHINE_EXCEPTION_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/exception.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/exception.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_EXCEPTION_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/kern_return.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/kern_return.h new file mode 100644 index 0000000000..67eac8ddf3 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/kern_return.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE_KERN_RETURN_H_ +#define _MACH_MACHINE_KERN_RETURN_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/kern_return.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/kern_return.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_KERN_RETURN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/processor_info.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/processor_info.h new file mode 100644 index 0000000000..e5a6a075ff --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/processor_info.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE_PROCESSOR_INFO_H_ +#define _MACH_MACHINE_PROCESSOR_INFO_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/processor_info.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/processor_info.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_PROCESSOR_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/rpc.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/rpc.h new file mode 100644 index 0000000000..b4ac238e1d --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/rpc.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE_RPC_H_ +#define _MACH_MACHINE_RPC_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/rpc.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/rpc.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_RPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/thread_state.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/thread_state.h new file mode 100644 index 0000000000..167b263c82 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/thread_state.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE_THREAD_STATE_H_ +#define _MACH_MACHINE_THREAD_STATE_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/thread_state.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/thread_state.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_THREAD_STATE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/thread_status.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/thread_status.h new file mode 100644 index 0000000000..6b087b68b0 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/thread_status.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE_THREAD_STATUS_H_ +#define _MACH_MACHINE_THREAD_STATUS_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/thread_status.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/thread_status.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_THREAD_STATUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/vm_param.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/vm_param.h new file mode 100644 index 0000000000..dee8f8b2ce --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/vm_param.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE_VM_PARAM_H_ +#define _MACH_MACHINE_VM_PARAM_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/vm_param.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/vm_param.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_VM_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/machine/vm_types.h b/lib/libc/include/aarch64-macos-gnu/mach/machine/vm_types.h new file mode 100644 index 0000000000..5613cd797c --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/machine/vm_types.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _MACH_MACHINE_VM_TYPES_H_ +#define _MACH_MACHINE_VM_TYPES_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "mach/i386/vm_types.h" +#elif defined (__arm__) || defined (__arm64__) +#include "mach/arm/vm_types.h" +#else +#error architecture not supported +#endif + +#endif /* _MACH_MACHINE_VM_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/message.h b/lib/libc/include/aarch64-macos-gnu/mach/message.h new file mode 100644 index 0000000000..6cbd768500 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/message.h @@ -0,0 +1,908 @@ +/* + * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * NOTICE: This file was modified by McAfee Research in 2004 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + * Copyright (c) 2005 SPARTA, Inc. + */ +/* + */ +/* + * File: mach/message.h + * + * Mach IPC message and primitive function definitions. + */ + +#ifndef _MACH_MESSAGE_H_ +#define _MACH_MESSAGE_H_ + +#include +#include +#include +#include +#include + +#include +#include +#include + +/* + * The timeout mechanism uses mach_msg_timeout_t values, + * passed by value. The timeout units are milliseconds. + * It is controlled with the MACH_SEND_TIMEOUT + * and MACH_RCV_TIMEOUT options. + */ + +typedef natural_t mach_msg_timeout_t; + +/* + * The value to be used when there is no timeout. + * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.) + */ + +#define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0) + +/* + * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it + * assumes the body of the message doesn't contain port rights or OOL + * data. The field is set in received messages. A user task must + * use caution in interpreting the body of a message if the bit isn't + * on, because the mach_msg_type's in the body might "lie" about the + * contents. If the bit isn't on, but the mach_msg_types + * in the body specify rights or OOL data, the behavior is undefined. + * (Ie, an error may or may not be produced.) + * + * The value of MACH_MSGH_BITS_REMOTE determines the interpretation + * of the msgh_remote_port field. It is handled like a msgt_name, + * but must result in a send or send-once type right. + * + * The value of MACH_MSGH_BITS_LOCAL determines the interpretation + * of the msgh_local_port field. It is handled like a msgt_name, + * and also must result in a send or send-once type right. + * + * The value of MACH_MSGH_BITS_VOUCHER determines the interpretation + * of the msgh_voucher_port field. It is handled like a msgt_name, + * but must result in a send right (and the msgh_voucher_port field + * must be the name of a send right to a Mach voucher kernel object. + * + * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote + * and local fields, into a single value suitable for msgh_bits. + * + * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally. + * + * The unused bits should be zero and are reserved for the kernel + * or for future interface expansion. + */ + +#define MACH_MSGH_BITS_ZERO 0x00000000 + +#define MACH_MSGH_BITS_REMOTE_MASK 0x0000001f +#define MACH_MSGH_BITS_LOCAL_MASK 0x00001f00 +#define MACH_MSGH_BITS_VOUCHER_MASK 0x001f0000 + +#define MACH_MSGH_BITS_PORTS_MASK \ + (MACH_MSGH_BITS_REMOTE_MASK | \ + MACH_MSGH_BITS_LOCAL_MASK | \ + MACH_MSGH_BITS_VOUCHER_MASK) + +#define MACH_MSGH_BITS_COMPLEX 0x80000000U /* message is complex */ + +#define MACH_MSGH_BITS_USER 0x801f1f1fU /* allowed bits user->kernel */ + +#define MACH_MSGH_BITS_RAISEIMP 0x20000000U /* importance raised due to msg */ +#define MACH_MSGH_BITS_DENAP MACH_MSGH_BITS_RAISEIMP + +#define MACH_MSGH_BITS_IMPHOLDASRT 0x10000000U /* assertion help, userland private */ +#define MACH_MSGH_BITS_DENAPHOLDASRT MACH_MSGH_BITS_IMPHOLDASRT + +#define MACH_MSGH_BITS_CIRCULAR 0x10000000U /* message circular, kernel private */ + +#define MACH_MSGH_BITS_USED 0xb01f1f1fU + +/* setter macros for the bits */ +#define MACH_MSGH_BITS(remote, local) /* legacy */ \ + ((remote) | ((local) << 8)) +#define MACH_MSGH_BITS_SET_PORTS(remote, local, voucher) \ + (((remote) & MACH_MSGH_BITS_REMOTE_MASK) | \ + (((local) << 8) & MACH_MSGH_BITS_LOCAL_MASK) | \ + (((voucher) << 16) & MACH_MSGH_BITS_VOUCHER_MASK)) +#define MACH_MSGH_BITS_SET(remote, local, voucher, other) \ + (MACH_MSGH_BITS_SET_PORTS((remote), (local), (voucher)) \ + | ((other) &~ MACH_MSGH_BITS_PORTS_MASK)) + +/* getter macros for pulling values out of the bits field */ +#define MACH_MSGH_BITS_REMOTE(bits) \ + ((bits) & MACH_MSGH_BITS_REMOTE_MASK) +#define MACH_MSGH_BITS_LOCAL(bits) \ + (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8) +#define MACH_MSGH_BITS_VOUCHER(bits) \ + (((bits) & MACH_MSGH_BITS_VOUCHER_MASK) >> 16) +#define MACH_MSGH_BITS_PORTS(bits) \ + ((bits) & MACH_MSGH_BITS_PORTS_MASK) +#define MACH_MSGH_BITS_OTHER(bits) \ + ((bits) &~ MACH_MSGH_BITS_PORTS_MASK) + +/* checking macros */ +#define MACH_MSGH_BITS_HAS_REMOTE(bits) \ + (MACH_MSGH_BITS_REMOTE(bits) != MACH_MSGH_BITS_ZERO) +#define MACH_MSGH_BITS_HAS_LOCAL(bits) \ + (MACH_MSGH_BITS_LOCAL(bits) != MACH_MSGH_BITS_ZERO) +#define MACH_MSGH_BITS_HAS_VOUCHER(bits) \ + (MACH_MSGH_BITS_VOUCHER(bits) != MACH_MSGH_BITS_ZERO) +#define MACH_MSGH_BITS_IS_COMPLEX(bits) \ + (((bits) & MACH_MSGH_BITS_COMPLEX) != MACH_MSGH_BITS_ZERO) + +/* importance checking macros */ +#define MACH_MSGH_BITS_RAISED_IMPORTANCE(bits) \ + (((bits) & MACH_MSGH_BITS_RAISEIMP) != MACH_MSGH_BITS_ZERO) +#define MACH_MSGH_BITS_HOLDS_IMPORTANCE_ASSERTION(bits) \ + (((bits) & MACH_MSGH_BITS_IMPHOLDASRT) != MACH_MSGH_BITS_ZERO) + +/* + * Every message starts with a message header. + * Following the message header, if the message is complex, are a count + * of type descriptors and the type descriptors themselves + * (mach_msg_descriptor_t). The size of the message must be specified in + * bytes, and includes the message header, descriptor count, descriptors, + * and inline data. + * + * The msgh_remote_port field specifies the destination of the message. + * It must specify a valid send or send-once right for a port. + * + * The msgh_local_port field specifies a "reply port". Normally, + * This field carries a send-once right that the receiver will use + * to reply to the message. It may carry the values MACH_PORT_NULL, + * MACH_PORT_DEAD, a send-once right, or a send right. + * + * The msgh_voucher_port field specifies a Mach voucher port. Only + * send rights to kernel-implemented Mach Voucher kernel objects in + * addition to MACH_PORT_NULL or MACH_PORT_DEAD may be passed. + * + * The msgh_id field is uninterpreted by the message primitives. + * It normally carries information specifying the format + * or meaning of the message. + */ + +typedef unsigned int mach_msg_bits_t; +typedef natural_t mach_msg_size_t; +typedef integer_t mach_msg_id_t; + +#define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0 + +typedef unsigned int mach_msg_priority_t; + +#define MACH_MSG_PRIORITY_UNSPECIFIED (mach_msg_priority_t) 0 + + +typedef unsigned int mach_msg_type_name_t; + +#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */ +#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send right(s) */ +#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce right */ +#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send right(s) */ +#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */ +#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive right */ +#define MACH_MSG_TYPE_COPY_RECEIVE 22 /* NOT VALID */ +#define MACH_MSG_TYPE_DISPOSE_RECEIVE 24 /* must hold receive right */ +#define MACH_MSG_TYPE_DISPOSE_SEND 25 /* must hold send right(s) */ +#define MACH_MSG_TYPE_DISPOSE_SEND_ONCE 26 /* must hold sendonce right */ + +typedef unsigned int mach_msg_copy_options_t; + +#define MACH_MSG_PHYSICAL_COPY 0 +#define MACH_MSG_VIRTUAL_COPY 1 +#define MACH_MSG_ALLOCATE 2 +#define MACH_MSG_OVERWRITE 3 /* deprecated */ +#ifdef MACH_KERNEL +#define MACH_MSG_KALLOC_COPY_T 4 +#endif /* MACH_KERNEL */ + +#define MACH_MSG_GUARD_FLAGS_NONE 0x0000 +#define MACH_MSG_GUARD_FLAGS_IMMOVABLE_RECEIVE 0x0001 /* Move the receive right and mark it as immovable */ +#define MACH_MSG_GUARD_FLAGS_UNGUARDED_ON_SEND 0x0002 /* Verify that the port is unguarded */ +#define MACH_MSG_GUARD_FLAGS_MASK 0x0003 /* Valid flag bits */ +typedef unsigned int mach_msg_guard_flags_t; + +/* + * In a complex mach message, the mach_msg_header_t is followed by + * a descriptor count, then an array of that number of descriptors + * (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t + * (which any descriptor can be cast to) indicates the flavor of the + * descriptor. + * + * Note that in LP64, the various types of descriptors are no longer all + * the same size as mach_msg_descriptor_t, so the array cannot be indexed + * as expected. + */ + +typedef unsigned int mach_msg_descriptor_type_t; + +#define MACH_MSG_PORT_DESCRIPTOR 0 +#define MACH_MSG_OOL_DESCRIPTOR 1 +#define MACH_MSG_OOL_PORTS_DESCRIPTOR 2 +#define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3 +#define MACH_MSG_GUARDED_PORT_DESCRIPTOR 4 + +#pragma pack(push, 4) + +typedef struct{ + natural_t pad1; + mach_msg_size_t pad2; + unsigned int pad3 : 24; + mach_msg_descriptor_type_t type : 8; +} mach_msg_type_descriptor_t; + +typedef struct{ + mach_port_t name; +// Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes + mach_msg_size_t pad1; + unsigned int pad2 : 16; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; +} mach_msg_port_descriptor_t; + +typedef struct{ + uint32_t address; + mach_msg_size_t size; + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + unsigned int pad1: 8; + mach_msg_descriptor_type_t type: 8; +} mach_msg_ool_descriptor32_t; + +typedef struct{ + uint64_t address; + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + unsigned int pad1: 8; + mach_msg_descriptor_type_t type: 8; + mach_msg_size_t size; +} mach_msg_ool_descriptor64_t; + +typedef struct{ + void* address; +#if !defined(__LP64__) + mach_msg_size_t size; +#endif + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + unsigned int pad1: 8; + mach_msg_descriptor_type_t type: 8; +#if defined(__LP64__) + mach_msg_size_t size; +#endif +} mach_msg_ool_descriptor_t; + +typedef struct{ + uint32_t address; + mach_msg_size_t count; + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; +} mach_msg_ool_ports_descriptor32_t; + +typedef struct{ + uint64_t address; + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; + mach_msg_size_t count; +} mach_msg_ool_ports_descriptor64_t; + +typedef struct{ + void* address; +#if !defined(__LP64__) + mach_msg_size_t count; +#endif + boolean_t deallocate: 8; + mach_msg_copy_options_t copy: 8; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; +#if defined(__LP64__) + mach_msg_size_t count; +#endif +} mach_msg_ool_ports_descriptor_t; + +typedef struct{ + uint32_t context; + mach_port_name_t name; + mach_msg_guard_flags_t flags : 16; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; +} mach_msg_guarded_port_descriptor32_t; + +typedef struct{ + uint64_t context; + mach_msg_guard_flags_t flags : 16; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; + mach_port_name_t name; +} mach_msg_guarded_port_descriptor64_t; + +typedef struct{ + mach_port_context_t context; +#if !defined(__LP64__) + mach_port_name_t name; +#endif + mach_msg_guard_flags_t flags : 16; + mach_msg_type_name_t disposition : 8; + mach_msg_descriptor_type_t type : 8; +#if defined(__LP64__) + mach_port_name_t name; +#endif /* defined(__LP64__) */ +} mach_msg_guarded_port_descriptor_t; + +/* + * LP64support - This union definition is not really + * appropriate in LP64 mode because not all descriptors + * are of the same size in that environment. + */ +typedef union{ + mach_msg_port_descriptor_t port; + mach_msg_ool_descriptor_t out_of_line; + mach_msg_ool_ports_descriptor_t ool_ports; + mach_msg_type_descriptor_t type; + mach_msg_guarded_port_descriptor_t guarded_port; +} mach_msg_descriptor_t; + +typedef struct{ + mach_msg_size_t msgh_descriptor_count; +} mach_msg_body_t; + +#define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0 +#define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0 + +typedef struct{ + mach_msg_bits_t msgh_bits; + mach_msg_size_t msgh_size; + mach_port_t msgh_remote_port; + mach_port_t msgh_local_port; + mach_port_name_t msgh_voucher_port; + mach_msg_id_t msgh_id; +} mach_msg_header_t; + +#define msgh_reserved msgh_voucher_port +#define MACH_MSG_NULL (mach_msg_header_t *) 0 + +typedef struct{ + mach_msg_header_t header; + mach_msg_body_t body; +} mach_msg_base_t; + +typedef unsigned int mach_msg_trailer_type_t; + +#define MACH_MSG_TRAILER_FORMAT_0 0 + +typedef unsigned int mach_msg_trailer_size_t; +typedef char *mach_msg_trailer_info_t; + +typedef struct{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; +} mach_msg_trailer_t; + +/* + * The msgh_seqno field carries a sequence number + * associated with the received-from port. A port's + * sequence number is incremented every time a message + * is received from it and included in the received + * trailer to help put messages back in sequence if + * multiple threads receive and/or process received + * messages. + */ +typedef struct{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; +} mach_msg_seqno_trailer_t; + +typedef struct{ + unsigned int val[2]; +} security_token_t; + +typedef struct{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; +} mach_msg_security_trailer_t; + +/* + * The audit token is an opaque token which identifies + * Mach tasks and senders of Mach messages as subjects + * to the BSM audit system. Only the appropriate BSM + * library routines should be used to interpret the + * contents of the audit token as the representation + * of the subject identity within the token may change + * over time. + */ +typedef struct{ + unsigned int val[8]; +} audit_token_t; + +typedef struct{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; +} mach_msg_audit_trailer_t; + +typedef struct{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; + mach_port_context_t msgh_context; +} mach_msg_context_trailer_t; + + + +typedef struct{ + mach_port_name_t sender; +} msg_labels_t; + +typedef int mach_msg_filter_id; +#define MACH_MSG_FILTER_POLICY_ALLOW (mach_msg_filter_id)0 + +/* + * Trailer type to pass MAC policy label info as a mach message trailer. + * + */ + +typedef struct{ + mach_msg_trailer_type_t msgh_trailer_type; + mach_msg_trailer_size_t msgh_trailer_size; + mach_port_seqno_t msgh_seqno; + security_token_t msgh_sender; + audit_token_t msgh_audit; + mach_port_context_t msgh_context; + mach_msg_filter_id msgh_ad; + msg_labels_t msgh_labels; +} mach_msg_mac_trailer_t; + + +#define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t) + +/* + * These values can change from release to release - but clearly + * code cannot request additional trailer elements one was not + * compiled to understand. Therefore, it is safe to use this + * constant when the same module specified the receive options. + * Otherwise, you run the risk that the options requested by + * another module may exceed the local modules notion of + * MAX_TRAILER_SIZE. + */ + +typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t; +#define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t)) + +/* + * Legacy requirements keep us from ever updating these defines (even + * when the format_0 trailers gain new option data fields in the future). + * Therefore, they shouldn't be used going forward. Instead, the sizes + * should be compared against the specific element size requested using + * REQUESTED_TRAILER_SIZE. + */ +typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t; + +/*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t; + */ + +#define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t) + +#define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} } +extern const security_token_t KERNEL_SECURITY_TOKEN; + +#define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} } +extern const audit_token_t KERNEL_AUDIT_TOKEN; + +typedef integer_t mach_msg_options_t; + +typedef struct{ + mach_msg_header_t header; +} mach_msg_empty_send_t; + +typedef struct{ + mach_msg_header_t header; + mach_msg_trailer_t trailer; +} mach_msg_empty_rcv_t; + +typedef union{ + mach_msg_empty_send_t send; + mach_msg_empty_rcv_t rcv; +} mach_msg_empty_t; + +#pragma pack(pop) + +/* utility to round the message size - will become machine dependent */ +#define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \ + ~(sizeof (natural_t) - 1)) + + +/* + * There is no fixed upper bound to the size of Mach messages. + */ +#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0) + +#if defined(__APPLE_API_PRIVATE) +/* + * But architectural limits of a given implementation, or + * temporal conditions may cause unpredictable send failures + * for messages larger than MACH_MSG_SIZE_RELIABLE. + * + * In either case, waiting for memory is [currently] outside + * the scope of send timeout values provided to IPC. + */ +#define MACH_MSG_SIZE_RELIABLE ((mach_msg_size_t) 256 * 1024) +#endif +/* + * Compatibility definitions, for code written + * when there was a msgh_kind instead of msgh_seqno. + */ +#define MACH_MSGH_KIND_NORMAL 0x00000000 +#define MACH_MSGH_KIND_NOTIFICATION 0x00000001 +#define msgh_kind msgh_seqno +#define mach_msg_kind_t mach_port_seqno_t + +typedef natural_t mach_msg_type_size_t; +typedef natural_t mach_msg_type_number_t; + +/* + * Values received/carried in messages. Tells the receiver what + * sort of port right he now has. + * + * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name + * which should remain uninterpreted by the kernel. (Port rights + * are not transferred, just the port name.) + */ + +#define MACH_MSG_TYPE_PORT_NONE 0 + +#define MACH_MSG_TYPE_PORT_NAME 15 +#define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE +#define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND +#define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE + +#define MACH_MSG_TYPE_LAST 22 /* Last assigned */ + +/* + * A dummy value. Mostly used to indicate that the actual value + * will be filled in later, dynamically. + */ + +#define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1) + +/* + * Is a given item a port type? + */ + +#define MACH_MSG_TYPE_PORT_ANY(x) \ + (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ + ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) + +#define MACH_MSG_TYPE_PORT_ANY_SEND(x) \ + (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \ + ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE)) + +#define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \ + (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \ + ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE)) + +typedef integer_t mach_msg_option_t; + +#define MACH_MSG_OPTION_NONE 0x00000000 + +#define MACH_SEND_MSG 0x00000001 +#define MACH_RCV_MSG 0x00000002 + +#define MACH_RCV_LARGE 0x00000004 /* report large message sizes */ +#define MACH_RCV_LARGE_IDENTITY 0x00000008 /* identify source of large messages */ + +#define MACH_SEND_TIMEOUT 0x00000010 /* timeout value applies to send */ +#define MACH_SEND_OVERRIDE 0x00000020 /* priority override for send */ +#define MACH_SEND_INTERRUPT 0x00000040 /* don't restart interrupted sends */ +#define MACH_SEND_NOTIFY 0x00000080 /* arm send-possible notify */ +#define MACH_SEND_ALWAYS 0x00010000 /* ignore qlimits - kernel only */ +#define MACH_SEND_TRAILER 0x00020000 /* sender-provided trailer */ +#define MACH_SEND_NOIMPORTANCE 0x00040000 /* msg won't carry importance */ +#define MACH_SEND_NODENAP MACH_SEND_NOIMPORTANCE +#define MACH_SEND_IMPORTANCE 0x00080000 /* msg carries importance - kernel only */ +#define MACH_SEND_SYNC_OVERRIDE 0x00100000 /* msg should do sync ipc override */ +#define MACH_SEND_PROPAGATE_QOS 0x00200000 /* IPC should propagate the caller's QoS */ +#define MACH_SEND_SYNC_USE_THRPRI MACH_SEND_PROPAGATE_QOS /* obsolete name */ +#define MACH_SEND_KERNEL 0x00400000 /* full send from kernel space - kernel only */ +#define MACH_SEND_SYNC_BOOTSTRAP_CHECKIN 0x00800000 /* special reply port should boost thread doing sync bootstrap checkin */ + +#define MACH_RCV_TIMEOUT 0x00000100 /* timeout value applies to receive */ +#define MACH_RCV_NOTIFY 0x00000000 /* legacy name (value was: 0x00000200) */ +#define MACH_RCV_INTERRUPT 0x00000400 /* don't restart interrupted receive */ +#define MACH_RCV_VOUCHER 0x00000800 /* willing to receive voucher port */ +#define MACH_RCV_OVERWRITE 0x00000000 /* scatter receive (deprecated) */ +#define MACH_RCV_GUARDED_DESC 0x00001000 /* Can receive new guarded descriptor */ +#define MACH_RCV_SYNC_WAIT 0x00004000 /* sync waiter waiting for rcv */ +#define MACH_RCV_SYNC_PEEK 0x00008000 /* sync waiter waiting to peek */ + +#define MACH_MSG_STRICT_REPLY 0x00000200 /* Enforce specific properties about the reply port, and + * the context in which a thread replies to a message. + * This flag must be passed on both the SEND and RCV */ + + +/* + * NOTE: a 0x00------ RCV mask implies to ask for + * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements, + * which is equivalent to a mach_msg_trailer_t. + * + * XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS + * needs its own private bit since we only calculate its fields when absolutely + * required. + */ +#define MACH_RCV_TRAILER_NULL 0 +#define MACH_RCV_TRAILER_SEQNO 1 +#define MACH_RCV_TRAILER_SENDER 2 +#define MACH_RCV_TRAILER_AUDIT 3 +#define MACH_RCV_TRAILER_CTX 4 +#define MACH_RCV_TRAILER_AV 7 +#define MACH_RCV_TRAILER_LABELS 8 + +#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28) +#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24) +#define MACH_RCV_TRAILER_MASK ((0xf << 24)) + +#define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf) + + +/* + * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS, + * we just fall through to mach_msg_max_trailer_t. + * This is correct behavior since mach_msg_max_trailer_t is defined as + * mac_msg_mac_trailer_t which is used for the LABELS trailer. + * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed + * with one of the other options. + */ + +#define REQUESTED_TRAILER_SIZE_NATIVE(y) \ + ((mach_msg_trailer_size_t) \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \ + sizeof(mach_msg_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \ + sizeof(mach_msg_seqno_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \ + sizeof(mach_msg_security_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \ + sizeof(mach_msg_audit_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \ + sizeof(mach_msg_context_trailer_t) : \ + ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \ + sizeof(mach_msg_mac_trailer_t) : \ + sizeof(mach_msg_max_trailer_t)))))))) + + +#define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y) + +/* + * Much code assumes that mach_msg_return_t == kern_return_t. + * This definition is useful for descriptive purposes. + * + * See for the format of error codes. + * IPC errors are system 4. Send errors are subsystem 0; + * receive errors are subsystem 1. The code field is always non-zero. + * The high bits of the code field communicate extra information + * for some error codes. MACH_MSG_MASK masks off these special bits. + */ + +typedef kern_return_t mach_msg_return_t; + +#define MACH_MSG_SUCCESS 0x00000000 + + +#define MACH_MSG_MASK 0x00003e00 +/* All special error code bits defined below. */ +#define MACH_MSG_IPC_SPACE 0x00002000 +/* No room in IPC name space for another capability name. */ +#define MACH_MSG_VM_SPACE 0x00001000 +/* No room in VM address space for out-of-line memory. */ +#define MACH_MSG_IPC_KERNEL 0x00000800 +/* Kernel resource shortage handling an IPC capability. */ +#define MACH_MSG_VM_KERNEL 0x00000400 +/* Kernel resource shortage handling out-of-line memory. */ + +#define MACH_SEND_IN_PROGRESS 0x10000001 +/* Thread is waiting to send. (Internal use only.) */ +#define MACH_SEND_INVALID_DATA 0x10000002 +/* Bogus in-line data. */ +#define MACH_SEND_INVALID_DEST 0x10000003 +/* Bogus destination port. */ +#define MACH_SEND_TIMED_OUT 0x10000004 +/* Message not sent before timeout expired. */ +#define MACH_SEND_INVALID_VOUCHER 0x10000005 +/* Bogus voucher port. */ +#define MACH_SEND_INTERRUPTED 0x10000007 +/* Software interrupt. */ +#define MACH_SEND_MSG_TOO_SMALL 0x10000008 +/* Data doesn't contain a complete message. */ +#define MACH_SEND_INVALID_REPLY 0x10000009 +/* Bogus reply port. */ +#define MACH_SEND_INVALID_RIGHT 0x1000000a +/* Bogus port rights in the message body. */ +#define MACH_SEND_INVALID_NOTIFY 0x1000000b +/* Bogus notify port argument. */ +#define MACH_SEND_INVALID_MEMORY 0x1000000c +/* Invalid out-of-line memory pointer. */ +#define MACH_SEND_NO_BUFFER 0x1000000d +/* No message buffer is available. */ +#define MACH_SEND_TOO_LARGE 0x1000000e +/* Send is too large for port */ +#define MACH_SEND_INVALID_TYPE 0x1000000f +/* Invalid msg-type specification. */ +#define MACH_SEND_INVALID_HEADER 0x10000010 +/* A field in the header had a bad value. */ +#define MACH_SEND_INVALID_TRAILER 0x10000011 +/* The trailer to be sent does not match kernel format. */ +#define MACH_SEND_INVALID_CONTEXT 0x10000012 +/* The sending thread context did not match the context on the dest port */ +#define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015 +/* compatibility: no longer a returned error */ +#define MACH_SEND_NO_GRANT_DEST 0x10000016 +/* The destination port doesn't accept ports in body */ +#define MACH_SEND_MSG_FILTERED 0x10000017 +/* Message send was rejected by message filter */ + +#define MACH_RCV_IN_PROGRESS 0x10004001 +/* Thread is waiting for receive. (Internal use only.) */ +#define MACH_RCV_INVALID_NAME 0x10004002 +/* Bogus name for receive port/port-set. */ +#define MACH_RCV_TIMED_OUT 0x10004003 +/* Didn't get a message within the timeout value. */ +#define MACH_RCV_TOO_LARGE 0x10004004 +/* Message buffer is not large enough for inline data. */ +#define MACH_RCV_INTERRUPTED 0x10004005 +/* Software interrupt. */ +#define MACH_RCV_PORT_CHANGED 0x10004006 +/* compatibility: no longer a returned error */ +#define MACH_RCV_INVALID_NOTIFY 0x10004007 +/* Bogus notify port argument. */ +#define MACH_RCV_INVALID_DATA 0x10004008 +/* Bogus message buffer for inline data. */ +#define MACH_RCV_PORT_DIED 0x10004009 +/* Port/set was sent away/died during receive. */ +#define MACH_RCV_IN_SET 0x1000400a +/* compatibility: no longer a returned error */ +#define MACH_RCV_HEADER_ERROR 0x1000400b +/* Error receiving message header. See special bits. */ +#define MACH_RCV_BODY_ERROR 0x1000400c +/* Error receiving message body. See special bits. */ +#define MACH_RCV_INVALID_TYPE 0x1000400d +/* Invalid msg-type specification in scatter list. */ +#define MACH_RCV_SCATTER_SMALL 0x1000400e +/* Out-of-line overwrite region is not large enough */ +#define MACH_RCV_INVALID_TRAILER 0x1000400f +/* trailer type or number of trailer elements not supported */ +#define MACH_RCV_IN_PROGRESS_TIMED 0x10004011 +/* Waiting for receive with timeout. (Internal use only.) */ +#define MACH_RCV_INVALID_REPLY 0x10004012 +/* invalid reply port used in a STRICT_REPLY message */ + + + +__BEGIN_DECLS + +/* + * Routine: mach_msg_overwrite + * Purpose: + * Send and/or receive a message. If the message operation + * is interrupted, and the user did not request an indication + * of that fact, then restart the appropriate parts of the + * operation silently (trap version does not restart). + * + * Distinct send and receive buffers may be specified. If + * no separate receive buffer is specified, the msg parameter + * will be used for both send and receive operations. + * + * In addition to a distinct receive buffer, that buffer may + * already contain scatter control information to direct the + * receiving of the message. + */ +__WATCHOS_PROHIBITED __TVOS_PROHIBITED +extern mach_msg_return_t mach_msg_overwrite( + mach_msg_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t send_size, + mach_msg_size_t rcv_size, + mach_port_name_t rcv_name, + mach_msg_timeout_t timeout, + mach_port_name_t notify, + mach_msg_header_t *rcv_msg, + mach_msg_size_t rcv_limit); + + +/* + * Routine: mach_msg + * Purpose: + * Send and/or receive a message. If the message operation + * is interrupted, and the user did not request an indication + * of that fact, then restart the appropriate parts of the + * operation silently (trap version does not restart). + */ +__WATCHOS_PROHIBITED __TVOS_PROHIBITED +extern mach_msg_return_t mach_msg( + mach_msg_header_t *msg, + mach_msg_option_t option, + mach_msg_size_t send_size, + mach_msg_size_t rcv_size, + mach_port_name_t rcv_name, + mach_msg_timeout_t timeout, + mach_port_name_t notify); + +/* + * Routine: mach_voucher_deallocate + * Purpose: + * Deallocate a mach voucher created or received in a message. Drops + * one (send right) reference to the voucher. + */ +__WATCHOS_PROHIBITED __TVOS_PROHIBITED +extern kern_return_t mach_voucher_deallocate( + mach_port_name_t voucher); + + +__END_DECLS + +#endif /* _MACH_MESSAGE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/port.h b/lib/libc/include/aarch64-macos-gnu/mach/port.h new file mode 100644 index 0000000000..f56d157f73 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/port.h @@ -0,0 +1,429 @@ +/* + * 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@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * NOTICE: This file was modified by McAfee Research in 2004 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ +/* + */ +/* + * File: mach/port.h + * + * Definition of a Mach port + * + * Mach ports are the endpoints to Mach-implemented communications + * channels (usually uni-directional message queues, but other types + * also exist). + * + * Unique collections of these endpoints are maintained for each + * Mach task. Each Mach port in the task's collection is given a + * [task-local] name to identify it - and the the various "rights" + * held by the task for that specific endpoint. + * + * This header defines the types used to identify these Mach ports + * and the various rights associated with them. For more info see: + * + * - manipulation of port rights in a given space + * - message queue [and port right passing] mechanism + * + */ + +#ifndef _MACH_PORT_H_ +#define _MACH_PORT_H_ + +#include +#include +#include +#include + +/* + * mach_port_name_t - the local identity for a Mach port + * + * The name is Mach port namespace specific. It is used to + * identify the rights held for that port by the task whose + * namespace is implied [or specifically provided]. + * + * Use of this type usually implies just a name - no rights. + * See mach_port_t for a type that implies a "named right." + * + */ + +typedef natural_t mach_port_name_t; +typedef mach_port_name_t *mach_port_name_array_t; + + +/* + * mach_port_t - a named port right + * + * In user-space, "rights" are represented by the name of the + * right in the Mach port namespace. Even so, this type is + * presented as a unique one to more clearly denote the presence + * of a right coming along with the name. + * + * Often, various rights for a port held in a single name space + * will coalesce and are, therefore, be identified by a single name + * [this is the case for send and receive rights]. But not + * always [send-once rights currently get a unique name for + * each right]. + * + */ + +#include +#include + + +typedef mach_port_t *mach_port_array_t; + +/* + * MACH_PORT_NULL is a legal value that can be carried in messages. + * It indicates the absence of any port or port rights. (A port + * argument keeps the message from being "simple", even if the + * value is MACH_PORT_NULL.) The value MACH_PORT_DEAD is also a legal + * value that can be carried in messages. It indicates + * that a port right was present, but it died. + */ + +#define MACH_PORT_NULL 0 /* intentional loose typing */ +#define MACH_PORT_DEAD ((mach_port_name_t) ~0) +#define MACH_PORT_VALID(name) \ + (((name) != MACH_PORT_NULL) && \ + ((name) != MACH_PORT_DEAD)) + + +/* + * For kernel-selected [assigned] port names, the name is + * comprised of two parts: a generation number and an index. + * This approach keeps the exact same name from being generated + * and reused too quickly [to catch right/reference counting bugs]. + * The dividing line between the constituent parts is exposed so + * that efficient "mach_port_name_t to data structure pointer" + * conversion implementation can be made. But it is possible + * for user-level code to assign their own names to Mach ports. + * These are not required to participate in this algorithm. So + * care should be taken before "assuming" this model. + * + */ + +#ifndef NO_PORT_GEN + +#define MACH_PORT_INDEX(name) ((name) >> 8) +#define MACH_PORT_GEN(name) (((name) & 0xff) << 24) +#define MACH_PORT_MAKE(index, gen) \ + (((index) << 8) | (gen) >> 24) + +#else /* NO_PORT_GEN */ + +#define MACH_PORT_INDEX(name) (name) +#define MACH_PORT_GEN(name) (0) +#define MACH_PORT_MAKE(index, gen) (index) + +#endif /* NO_PORT_GEN */ + + +/* + * These are the different rights a task may have for a port. + * The MACH_PORT_RIGHT_* definitions are used as arguments + * to mach_port_allocate, mach_port_get_refs, etc, to specify + * a particular right to act upon. The mach_port_names and + * mach_port_type calls return bitmasks using the MACH_PORT_TYPE_* + * definitions. This is because a single name may denote + * multiple rights. + */ + +typedef natural_t mach_port_right_t; + +#define MACH_PORT_RIGHT_SEND ((mach_port_right_t) 0) +#define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1) +#define MACH_PORT_RIGHT_SEND_ONCE ((mach_port_right_t) 2) +#define MACH_PORT_RIGHT_PORT_SET ((mach_port_right_t) 3) +#define MACH_PORT_RIGHT_DEAD_NAME ((mach_port_right_t) 4) +#define MACH_PORT_RIGHT_LABELH ((mach_port_right_t) 5) /* obsolete right */ +#define MACH_PORT_RIGHT_NUMBER ((mach_port_right_t) 6) /* right not implemented */ + + +typedef natural_t mach_port_type_t; +typedef mach_port_type_t *mach_port_type_array_t; + +#define MACH_PORT_TYPE(right) \ + ((mach_port_type_t)(((mach_port_type_t) 1) \ + << ((right) + ((mach_port_right_t) 16)))) +#define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0L) +#define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND) +#define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE) +#define MACH_PORT_TYPE_SEND_ONCE MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE) +#define MACH_PORT_TYPE_PORT_SET MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET) +#define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME) +#define MACH_PORT_TYPE_LABELH MACH_PORT_TYPE(MACH_PORT_RIGHT_LABELH) /* obsolete */ + + + +/* Convenient combinations. */ + +#define MACH_PORT_TYPE_SEND_RECEIVE \ + (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE) +#define MACH_PORT_TYPE_SEND_RIGHTS \ + (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE) +#define MACH_PORT_TYPE_PORT_RIGHTS \ + (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE) +#define MACH_PORT_TYPE_PORT_OR_DEAD \ + (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME) +#define MACH_PORT_TYPE_ALL_RIGHTS \ + (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET) + +/* Dummy type bits that mach_port_type/mach_port_names can return. */ + +#define MACH_PORT_TYPE_DNREQUEST 0x80000000 +#define MACH_PORT_TYPE_SPREQUEST 0x40000000 +#define MACH_PORT_TYPE_SPREQUEST_DELAYED 0x20000000 + +/* User-references for capabilities. */ + +typedef natural_t mach_port_urefs_t; +typedef integer_t mach_port_delta_t; /* change in urefs */ + +/* Attributes of ports. (See mach_port_get_receive_status.) */ + +typedef natural_t mach_port_seqno_t; /* sequence number */ +typedef natural_t mach_port_mscount_t; /* make-send count */ +typedef natural_t mach_port_msgcount_t; /* number of msgs */ +typedef natural_t mach_port_rights_t; /* number of rights */ + +/* + * Are there outstanding send rights for a given port? + */ +#define MACH_PORT_SRIGHTS_NONE 0 /* no srights */ +#define MACH_PORT_SRIGHTS_PRESENT 1 /* srights */ +typedef unsigned int mach_port_srights_t; /* status of send rights */ + +typedef struct mach_port_status { + mach_port_rights_t mps_pset; /* count of containing port sets */ + mach_port_seqno_t mps_seqno; /* sequence number */ + mach_port_mscount_t mps_mscount; /* make-send count */ + mach_port_msgcount_t mps_qlimit; /* queue limit */ + mach_port_msgcount_t mps_msgcount; /* number in the queue */ + mach_port_rights_t mps_sorights; /* how many send-once rights */ + boolean_t mps_srights; /* do send rights exist? */ + boolean_t mps_pdrequest; /* port-deleted requested? */ + boolean_t mps_nsrequest; /* no-senders requested? */ + natural_t mps_flags; /* port flags */ +} mach_port_status_t; + +/* System-wide values for setting queue limits on a port */ +#define MACH_PORT_QLIMIT_ZERO (0) +#define MACH_PORT_QLIMIT_BASIC (5) +#define MACH_PORT_QLIMIT_SMALL (16) +#define MACH_PORT_QLIMIT_LARGE (1024) +#define MACH_PORT_QLIMIT_KERNEL (65534) +#define MACH_PORT_QLIMIT_MIN MACH_PORT_QLIMIT_ZERO +#define MACH_PORT_QLIMIT_DEFAULT MACH_PORT_QLIMIT_BASIC +#define MACH_PORT_QLIMIT_MAX MACH_PORT_QLIMIT_LARGE + +typedef struct mach_port_limits { + mach_port_msgcount_t mpl_qlimit; /* number of msgs */ +} mach_port_limits_t; + +/* Possible values for mps_flags (part of mach_port_status_t) */ +#define MACH_PORT_STATUS_FLAG_TEMPOWNER 0x01 +#define MACH_PORT_STATUS_FLAG_GUARDED 0x02 +#define MACH_PORT_STATUS_FLAG_STRICT_GUARD 0x04 +#define MACH_PORT_STATUS_FLAG_IMP_DONATION 0x08 +#define MACH_PORT_STATUS_FLAG_REVIVE 0x10 +#define MACH_PORT_STATUS_FLAG_TASKPTR 0x20 +#define MACH_PORT_STATUS_FLAG_GUARD_IMMOVABLE_RECEIVE 0x40 +#define MACH_PORT_STATUS_FLAG_NO_GRANT 0x80 + +typedef struct mach_port_info_ext { + mach_port_status_t mpie_status; + mach_port_msgcount_t mpie_boost_cnt; + uint32_t reserved[6]; +} mach_port_info_ext_t; + +typedef integer_t *mach_port_info_t; /* varying array of natural_t */ + +/* Flavors for mach_port_get/set_attributes() */ +typedef int mach_port_flavor_t; +#define MACH_PORT_LIMITS_INFO 1 /* uses mach_port_limits_t */ +#define MACH_PORT_RECEIVE_STATUS 2 /* uses mach_port_status_t */ +#define MACH_PORT_DNREQUESTS_SIZE 3 /* info is int */ +#define MACH_PORT_TEMPOWNER 4 /* indicates receive right will be reassigned to another task */ +#define MACH_PORT_IMPORTANCE_RECEIVER 5 /* indicates recieve right accepts priority donation */ +#define MACH_PORT_DENAP_RECEIVER 6 /* indicates receive right accepts de-nap donation */ +#define MACH_PORT_INFO_EXT 7 /* uses mach_port_info_ext_t */ + +#define MACH_PORT_LIMITS_INFO_COUNT ((natural_t) \ + (sizeof(mach_port_limits_t)/sizeof(natural_t))) +#define MACH_PORT_RECEIVE_STATUS_COUNT ((natural_t) \ + (sizeof(mach_port_status_t)/sizeof(natural_t))) +#define MACH_PORT_DNREQUESTS_SIZE_COUNT 1 +#define MACH_PORT_INFO_EXT_COUNT ((natural_t) \ + (sizeof(mach_port_info_ext_t)/sizeof(natural_t))) +/* + * Structure used to pass information about port allocation requests. + * Must be padded to 64-bits total length. + */ +typedef struct mach_port_qos { + unsigned int name:1; /* name given */ + unsigned int prealloc:1; /* prealloced message */ + boolean_t pad1:30; + natural_t len; +} mach_port_qos_t; + +/* Mach Port Guarding definitions */ + +/* + * Flags for mach_port_options (used for + * invocation of mach_port_construct). + * Indicates attributes to be set for the newly + * allocated port. + */ +#define MPO_CONTEXT_AS_GUARD 0x01 /* Add guard to the port */ +#define MPO_QLIMIT 0x02 /* Set qlimit for the port msg queue */ +#define MPO_TEMPOWNER 0x04 /* Set the tempowner bit of the port */ +#define MPO_IMPORTANCE_RECEIVER 0x08 /* Mark the port as importance receiver */ +#define MPO_INSERT_SEND_RIGHT 0x10 /* Insert a send right for the port */ +#define MPO_STRICT 0x20 /* Apply strict guarding for port */ +#define MPO_DENAP_RECEIVER 0x40 /* Mark the port as App de-nap receiver */ +#define MPO_IMMOVABLE_RECEIVE 0x80 /* Mark the port as immovable; protected by the guard context */ +#define MPO_FILTER_MSG 0x100 /* Allow message filtering */ +#define MPO_TG_BLOCK_TRACKING 0x200 /* Track blocking relationship for thread group during sync IPC */ + +/* + * Structure to define optional attributes for a newly + * constructed port. + */ +typedef struct mach_port_options { + uint32_t flags; /* Flags defining attributes for port */ + mach_port_limits_t mpl; /* Message queue limit for port */ + union { + uint64_t reserved[2]; /* Reserved */ + mach_port_name_t work_interval_port; /* Work interval port */ + }; +}mach_port_options_t; + +typedef mach_port_options_t *mach_port_options_ptr_t; + +/* + * EXC_GUARD represents a guard violation for both + * mach ports and file descriptors. GUARD_TYPE_ is used + * to differentiate among them. + */ +#define GUARD_TYPE_MACH_PORT 0x1 + +/* Reasons for exception for a guarded mach port */ +enum mach_port_guard_exception_codes { + kGUARD_EXC_DESTROY = 1u << 0, + kGUARD_EXC_MOD_REFS = 1u << 1, + kGUARD_EXC_SET_CONTEXT = 1u << 2, + kGUARD_EXC_UNGUARDED = 1u << 3, + kGUARD_EXC_INCORRECT_GUARD = 1u << 4, + kGUARD_EXC_IMMOVABLE = 1u << 5, + kGUARD_EXC_STRICT_REPLY = 1u << 6, + kGUARD_EXC_MSG_FILTERED = 1u << 7, + /* start of [optionally] non-fatal guards */ + kGUARD_EXC_INVALID_RIGHT = 1u << 8, + kGUARD_EXC_INVALID_NAME = 1u << 9, + kGUARD_EXC_INVALID_VALUE = 1u << 10, + kGUARD_EXC_INVALID_ARGUMENT = 1u << 11, + kGUARD_EXC_RIGHT_EXISTS = 1u << 12, + kGUARD_EXC_KERN_NO_SPACE = 1u << 13, + kGUARD_EXC_KERN_FAILURE = 1u << 14, + kGUARD_EXC_KERN_RESOURCE = 1u << 15, + kGUARD_EXC_SEND_INVALID_REPLY = 1u << 16, + kGUARD_EXC_SEND_INVALID_VOUCHER = 1u << 17, + kGUARD_EXC_SEND_INVALID_RIGHT = 1u << 18, + kGUARD_EXC_RCV_INVALID_NAME = 1u << 19, + kGUARD_EXC_RCV_GUARDED_DESC = 1u << 20, /* should never be fatal; for development only */ +}; + +#define MAX_FATAL_kGUARD_EXC_CODE (1u << 6) + +/* + * These flags are used as bits in the subcode of kGUARD_EXC_STRICT_REPLY exceptions. + */ +#define MPG_FLAGS_STRICT_REPLY_INVALID_REPLY_DISP (0x01ull << 56) +#define MPG_FLAGS_STRICT_REPLY_INVALID_REPLY_PORT (0x02ull << 56) +#define MPG_FLAGS_STRICT_REPLY_INVALID_VOUCHER (0x04ull << 56) +#define MPG_FLAGS_STRICT_REPLY_NO_BANK_ATTR (0x08ull << 56) +#define MPG_FLAGS_STRICT_REPLY_MISMATCHED_PERSONA (0x10ull << 56) +#define MPG_FLAGS_STRICT_REPLY_MASK (0xffull << 56) + +/* + * Flags for mach_port_guard_with_flags. These flags extend + * the attributes associated with a guarded port. + */ +#define MPG_STRICT 0x01 /* Apply strict guarding for a port */ +#define MPG_IMMOVABLE_RECEIVE 0x02 /* Receive right cannot be moved out of the space */ + +#if !__DARWIN_UNIX03 && !defined(_NO_PORT_T_FROM_MACH) +/* + * Mach 3.0 renamed everything to have mach_ in front of it. + * These types and macros are provided for backward compatibility + * but are deprecated. + */ +typedef mach_port_t port_t; +typedef mach_port_name_t port_name_t; +typedef mach_port_name_t *port_name_array_t; + +#define PORT_NULL ((port_t) 0) +#define PORT_DEAD ((port_t) ~0) +#define PORT_VALID(name) \ + ((port_t)(name) != PORT_NULL && (port_t)(name) != PORT_DEAD) + +#endif /* !__DARWIN_UNIX03 && !_NO_PORT_T_FROM_MACH */ + +#endif /* _MACH_PORT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/processor_set.h b/lib/libc/include/aarch64-macos-gnu/mach/processor_set.h new file mode 100644 index 0000000000..9d748d01dc --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/processor_set.h @@ -0,0 +1,585 @@ +#ifndef _processor_set_user_ +#define _processor_set_user_ + +/* Module processor_set */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* BEGIN MIG_STRNCPY_ZEROFILL CODE */ + +#if defined(__has_include) +#if __has_include() +#ifndef USING_MIG_STRNCPY_ZEROFILL +#define USING_MIG_STRNCPY_ZEROFILL +#endif +#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ +#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ +#ifdef __cplusplus +extern "C" { +#endif + extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); +#ifdef __cplusplus +} +#endif +#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ +#endif /* __has_include() */ +#endif /* __has_include */ + +/* END MIG_STRNCPY_ZEROFILL CODE */ + + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef processor_set_MSG_COUNT +#define processor_set_MSG_COUNT 11 +#endif /* processor_set_MSG_COUNT */ + +#include +#include +#include +#include + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include +__BEGIN_DECLS + + +/* Routine processor_set_statistics */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_statistics +( + processor_set_name_t pset, + processor_set_flavor_t flavor, + processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt +); + +/* Routine processor_set_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_destroy +( + processor_set_t set +); + +/* Routine processor_set_max_priority */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_max_priority +( + processor_set_t processor_set, + int max_priority, + boolean_t change_threads +); + +/* Routine processor_set_policy_enable */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_policy_enable +( + processor_set_t processor_set, + int policy +); + +/* Routine processor_set_policy_disable */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_policy_disable +( + processor_set_t processor_set, + int policy, + boolean_t change_threads +); + +/* Routine processor_set_tasks */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_tasks +( + processor_set_t processor_set, + task_array_t *task_list, + mach_msg_type_number_t *task_listCnt +); + +/* Routine processor_set_threads */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_threads +( + processor_set_t processor_set, + thread_act_array_t *thread_list, + mach_msg_type_number_t *thread_listCnt +); + +/* Routine processor_set_policy_control */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_policy_control +( + processor_set_t pset, + processor_set_flavor_t flavor, + processor_set_info_t policy_info, + mach_msg_type_number_t policy_infoCnt, + boolean_t change +); + +/* Routine processor_set_stack_usage */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_stack_usage +( + processor_set_t pset, + unsigned *ltotal, + vm_size_t *space, + vm_size_t *resident, + vm_size_t *maxusage, + vm_offset_t *maxstack +); + +/* Routine processor_set_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_info +( + processor_set_name_t set_name, + int flavor, + host_t *host, + processor_set_info_t info_out, + mach_msg_type_number_t *info_outCnt +); + +/* Routine processor_set_tasks_with_flavor */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t processor_set_tasks_with_flavor +( + processor_set_t processor_set, + mach_task_flavor_t flavor, + task_array_t *task_list, + mach_msg_type_number_t *task_listCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__processor_set_subsystem__defined +#define __Request__processor_set_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + processor_set_flavor_t flavor; + mach_msg_type_number_t info_outCnt; + } __Request__processor_set_statistics_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_destroy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int max_priority; + boolean_t change_threads; + } __Request__processor_set_max_priority_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int policy; + } __Request__processor_set_policy_enable_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int policy; + boolean_t change_threads; + } __Request__processor_set_policy_disable_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_tasks_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_threads_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + processor_set_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[5]; + boolean_t change; + } __Request__processor_set_policy_control_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__processor_set_stack_usage_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t info_outCnt; + } __Request__processor_set_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_task_flavor_t flavor; + } __Request__processor_set_tasks_with_flavor_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif +#endif /* !__Request__processor_set_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__processor_set_subsystem__defined +#define __RequestUnion__processor_set_subsystem__defined +union __RequestUnion__processor_set_subsystem { + __Request__processor_set_statistics_t Request_processor_set_statistics; + __Request__processor_set_destroy_t Request_processor_set_destroy; + __Request__processor_set_max_priority_t Request_processor_set_max_priority; + __Request__processor_set_policy_enable_t Request_processor_set_policy_enable; + __Request__processor_set_policy_disable_t Request_processor_set_policy_disable; + __Request__processor_set_tasks_t Request_processor_set_tasks; + __Request__processor_set_threads_t Request_processor_set_threads; + __Request__processor_set_policy_control_t Request_processor_set_policy_control; + __Request__processor_set_stack_usage_t Request_processor_set_stack_usage; + __Request__processor_set_info_t Request_processor_set_info; + __Request__processor_set_tasks_with_flavor_t Request_processor_set_tasks_with_flavor; +}; +#endif /* !__RequestUnion__processor_set_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__processor_set_subsystem__defined +#define __Reply__processor_set_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t info_outCnt; + integer_t info_out[5]; + } __Reply__processor_set_statistics_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_destroy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_max_priority_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_policy_enable_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_policy_disable_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t task_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t task_listCnt; + } __Reply__processor_set_tasks_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t thread_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t thread_listCnt; + } __Reply__processor_set_threads_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__processor_set_policy_control_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + unsigned ltotal; + vm_size_t space; + vm_size_t resident; + vm_size_t maxusage; + vm_offset_t maxstack; + } __Reply__processor_set_stack_usage_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t host; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t info_outCnt; + integer_t info_out[5]; + } __Reply__processor_set_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t task_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t task_listCnt; + } __Reply__processor_set_tasks_with_flavor_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif +#endif /* !__Reply__processor_set_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__processor_set_subsystem__defined +#define __ReplyUnion__processor_set_subsystem__defined +union __ReplyUnion__processor_set_subsystem { + __Reply__processor_set_statistics_t Reply_processor_set_statistics; + __Reply__processor_set_destroy_t Reply_processor_set_destroy; + __Reply__processor_set_max_priority_t Reply_processor_set_max_priority; + __Reply__processor_set_policy_enable_t Reply_processor_set_policy_enable; + __Reply__processor_set_policy_disable_t Reply_processor_set_policy_disable; + __Reply__processor_set_tasks_t Reply_processor_set_tasks; + __Reply__processor_set_threads_t Reply_processor_set_threads; + __Reply__processor_set_policy_control_t Reply_processor_set_policy_control; + __Reply__processor_set_stack_usage_t Reply_processor_set_stack_usage; + __Reply__processor_set_info_t Reply_processor_set_info; + __Reply__processor_set_tasks_with_flavor_t Reply_processor_set_tasks_with_flavor; +}; +#endif /* !__RequestUnion__processor_set_subsystem__defined */ + +#ifndef subsystem_to_name_map_processor_set +#define subsystem_to_name_map_processor_set \ + { "processor_set_statistics", 4000 },\ + { "processor_set_destroy", 4001 },\ + { "processor_set_max_priority", 4002 },\ + { "processor_set_policy_enable", 4003 },\ + { "processor_set_policy_disable", 4004 },\ + { "processor_set_tasks", 4005 },\ + { "processor_set_threads", 4006 },\ + { "processor_set_policy_control", 4007 },\ + { "processor_set_stack_usage", 4008 },\ + { "processor_set_info", 4009 },\ + { "processor_set_tasks_with_flavor", 4010 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _processor_set_user_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/task.h b/lib/libc/include/aarch64-macos-gnu/mach/task.h new file mode 100644 index 0000000000..a7d1c9565b --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/task.h @@ -0,0 +1,2523 @@ +#ifndef _task_user_ +#define _task_user_ + +/* Module task */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* BEGIN MIG_STRNCPY_ZEROFILL CODE */ + +#if defined(__has_include) +#if __has_include() +#ifndef USING_MIG_STRNCPY_ZEROFILL +#define USING_MIG_STRNCPY_ZEROFILL +#endif +#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ +#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ +#ifdef __cplusplus +extern "C" { +#endif + extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); +#ifdef __cplusplus +} +#endif +#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ +#endif /* __has_include() */ +#endif /* __has_include */ + +/* END MIG_STRNCPY_ZEROFILL CODE */ + + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef task_MSG_COUNT +#define task_MSG_COUNT 55 +#endif /* task_MSG_COUNT */ + +#include +#include +#include +#include +#include + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include +__BEGIN_DECLS + + +/* Routine task_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_create +( + task_t target_task, + ledger_array_t ledgers, + mach_msg_type_number_t ledgersCnt, + boolean_t inherit_memory, + task_t *child_task +); + +/* Routine task_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_terminate +( + task_t target_task +); + +/* Routine task_threads */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_threads +( + task_inspect_t target_task, + thread_act_array_t *act_list, + mach_msg_type_number_t *act_listCnt +); + +/* Routine mach_ports_register */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t mach_ports_register +( + task_t target_task, + mach_port_array_t init_port_set, + mach_msg_type_number_t init_port_setCnt +); + +/* Routine mach_ports_lookup */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t mach_ports_lookup +( + task_t target_task, + mach_port_array_t *init_port_set, + mach_msg_type_number_t *init_port_setCnt +); + +/* Routine task_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_info +( + task_name_t target_task, + task_flavor_t flavor, + task_info_t task_info_out, + mach_msg_type_number_t *task_info_outCnt +); + +/* Routine task_set_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_set_info +( + task_t target_task, + task_flavor_t flavor, + task_info_t task_info_in, + mach_msg_type_number_t task_info_inCnt +); + +/* Routine task_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_suspend +( + task_t target_task +); + +/* Routine task_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_resume +( + task_t target_task +); + +/* Routine task_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_get_special_port +( + task_inspect_t task, + int which_port, + mach_port_t *special_port +); + +/* Routine task_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_set_special_port +( + task_t task, + int which_port, + mach_port_t special_port +); + +/* Routine thread_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_create +( + task_t parent_task, + thread_act_t *child_act +); + +/* Routine thread_create_running */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_create_running +( + task_t parent_task, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt, + thread_act_t *child_act +); + +/* Routine task_set_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_set_exception_ports +( + task_t task, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor +); + +/* Routine task_get_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_get_exception_ports +( + task_t task, + exception_mask_t exception_mask, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine task_swap_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_swap_exception_ports +( + task_t task, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlerss, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine lock_set_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_set_create +( + task_t task, + lock_set_t *new_lock_set, + int n_ulocks, + int policy +); + +/* Routine lock_set_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t lock_set_destroy +( + task_t task, + lock_set_t lock_set +); + +/* Routine semaphore_create */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t semaphore_create +( + task_t task, + semaphore_t *semaphore, + int policy, + int value +); + +/* Routine semaphore_destroy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t semaphore_destroy +( + task_t task, + semaphore_t semaphore +); + +/* Routine task_policy_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_policy_set +( + task_policy_set_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t policy_infoCnt +); + +/* Routine task_policy_get */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_policy_get +( + task_policy_get_t task, + task_policy_flavor_t flavor, + task_policy_t policy_info, + mach_msg_type_number_t *policy_infoCnt, + boolean_t *get_default +); + +/* Routine task_sample */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_sample +( + task_t task, + mach_port_t reply +); + +/* Routine task_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_policy +( + task_t task, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + boolean_t set_limit, + boolean_t change +); + +/* Routine task_set_emulation */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_emulation +( + task_t target_port, + vm_address_t routine_entry_pt, + int routine_number +); + +/* Routine task_get_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_emulation_vector +( + task_t task, + int *vector_start, + emulation_vector_t *emulation_vector, + mach_msg_type_number_t *emulation_vectorCnt +); + +/* Routine task_set_emulation_vector */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_emulation_vector +( + task_t task, + int vector_start, + emulation_vector_t emulation_vector, + mach_msg_type_number_t emulation_vectorCnt +); + +/* Routine task_set_ras_pc */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_ras_pc +( + task_t target_task, + vm_address_t basepc, + vm_address_t boundspc +); + +/* Routine task_zone_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_zone_info +( + task_inspect_t target_task, + mach_zone_name_array_t *names, + mach_msg_type_number_t *namesCnt, + task_zone_info_array_t *info, + mach_msg_type_number_t *infoCnt +); + +/* Routine task_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_assign +( + task_t task, + processor_set_t new_set, + boolean_t assign_threads +); + +/* Routine task_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_assign_default +( + task_t task, + boolean_t assign_threads +); + +/* Routine task_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_assignment +( + task_inspect_t task, + processor_set_name_t *assigned_set +); + +/* Routine task_set_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_policy +( + task_t task, + processor_set_t pset, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + policy_limit_t limit, + mach_msg_type_number_t limitCnt, + boolean_t change +); + +/* Routine task_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_get_state +( + task_read_t task, + thread_state_flavor_t flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine task_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_set_state +( + task_t task, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +/* Routine task_set_phys_footprint_limit */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_set_phys_footprint_limit +( + task_t task, + int new_limit, + int *old_limit +); + +/* Routine task_suspend2 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_suspend2 +( + task_t target_task, + task_suspension_token_t *suspend_token +); + +/* Routine task_resume2 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_resume2 +( + task_suspension_token_t suspend_token +); + +/* Routine task_purgable_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_purgable_info +( + task_inspect_t task, + task_purgable_info_t *stats +); + +/* Routine task_get_mach_voucher */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_get_mach_voucher +( + task_read_t task, + mach_voucher_selector_t which, + ipc_voucher_t *voucher +); + +/* Routine task_set_mach_voucher */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_set_mach_voucher +( + task_t task, + ipc_voucher_t voucher +); + +/* Routine task_swap_mach_voucher */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t task_swap_mach_voucher +( + task_t task, + ipc_voucher_t new_voucher, + ipc_voucher_t *old_voucher +); + +/* Routine task_generate_corpse */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_generate_corpse +( + task_t task, + mach_port_t *corpse_task_port +); + +/* Routine task_map_corpse_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_map_corpse_info +( + task_t task, + task_read_t corspe_task, + vm_address_t *kcd_addr_begin, + uint32_t *kcd_size +); + +/* Routine task_register_dyld_image_infos */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_register_dyld_image_infos +( + task_t task, + dyld_kernel_image_info_array_t dyld_images, + mach_msg_type_number_t dyld_imagesCnt +); + +/* Routine task_unregister_dyld_image_infos */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_unregister_dyld_image_infos +( + task_t task, + dyld_kernel_image_info_array_t dyld_images, + mach_msg_type_number_t dyld_imagesCnt +); + +/* Routine task_get_dyld_image_infos */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_dyld_image_infos +( + task_read_t task, + dyld_kernel_image_info_array_t *dyld_images, + mach_msg_type_number_t *dyld_imagesCnt +); + +/* Routine task_register_dyld_shared_cache_image_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_register_dyld_shared_cache_image_info +( + task_t task, + dyld_kernel_image_info_t dyld_cache_image, + boolean_t no_cache, + boolean_t private_cache +); + +/* Routine task_register_dyld_set_dyld_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_register_dyld_set_dyld_state +( + task_t task, + uint8_t dyld_state +); + +/* Routine task_register_dyld_get_process_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_register_dyld_get_process_state +( + task_t task, + dyld_kernel_process_info_t *dyld_process_state +); + +/* Routine task_map_corpse_info_64 */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_map_corpse_info_64 +( + task_t task, + task_read_t corspe_task, + mach_vm_address_t *kcd_addr_begin, + mach_vm_size_t *kcd_size +); + +/* Routine task_inspect */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_inspect +( + task_inspect_t task, + task_inspect_flavor_t flavor, + task_inspect_info_t info_out, + mach_msg_type_number_t *info_outCnt +); + +/* Routine task_get_exc_guard_behavior */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_get_exc_guard_behavior +( + task_inspect_t task, + task_exc_guard_behavior_t *behavior +); + +/* Routine task_set_exc_guard_behavior */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_set_exc_guard_behavior +( + task_t task, + task_exc_guard_behavior_t behavior +); + +/* Routine task_create_suid_cred */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t task_create_suid_cred +( + task_t task, + suid_cred_path_t path, + suid_cred_uid_t uid, + suid_cred_t *delegation +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__task_subsystem__defined +#define __Request__task_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t ledgers; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t ledgersCnt; + boolean_t inherit_memory; + } __Request__task_create_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_terminate_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_threads_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t init_port_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t init_port_setCnt; + } __Request__mach_ports_register_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__mach_ports_lookup_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_flavor_t flavor; + mach_msg_type_number_t task_info_outCnt; + } __Request__task_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_flavor_t flavor; + mach_msg_type_number_t task_info_inCnt; + integer_t task_info_in[87]; + } __Request__task_set_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_suspend_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_resume_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int which_port; + } __Request__task_get_special_port_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + int which_port; + } __Request__task_set_special_port_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_create_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[1296]; + } __Request__thread_create_running_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__task_set_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_mask_t exception_mask; + } __Request__task_get_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__task_swap_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int n_ulocks; + int policy; + } __Request__lock_set_create_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t lock_set; + /* end of the kernel processed data */ + } __Request__lock_set_destroy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int policy; + int value; + } __Request__semaphore_create_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t semaphore; + /* end of the kernel processed data */ + } __Request__semaphore_destroy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + } __Request__task_policy_set_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + boolean_t get_default; + } __Request__task_policy_get_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t reply; + /* end of the kernel processed data */ + } __Request__task_sample_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + boolean_t set_limit; + boolean_t change; + } __Request__task_policy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t routine_entry_pt; + int routine_number; + } __Request__task_set_emulation_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_emulation_vector_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t emulation_vector; + /* end of the kernel processed data */ + NDR_record_t NDR; + int vector_start; + mach_msg_type_number_t emulation_vectorCnt; + } __Request__task_set_emulation_vector_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + vm_address_t basepc; + vm_address_t boundspc; + } __Request__task_set_ras_pc_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_zone_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + boolean_t assign_threads; + } __Request__task_assign_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + boolean_t assign_threads; + } __Request__task_assign_default_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_assignment_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pset; + /* end of the kernel processed data */ + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + mach_msg_type_number_t limitCnt; + integer_t limit[1]; + boolean_t change; + } __Request__task_set_policy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__task_get_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[1296]; + } __Request__task_set_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int new_limit; + } __Request__task_set_phys_footprint_limit_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_suspend2_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_resume2_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_purgable_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_voucher_selector_t which; + } __Request__task_get_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t voucher; + /* end of the kernel processed data */ + } __Request__task_set_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_voucher; + mach_msg_port_descriptor_t old_voucher; + /* end of the kernel processed data */ + } __Request__task_swap_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_generate_corpse_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t corspe_task; + /* end of the kernel processed data */ + } __Request__task_map_corpse_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t dyld_images; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t dyld_imagesCnt; + } __Request__task_register_dyld_image_infos_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t dyld_images; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t dyld_imagesCnt; + } __Request__task_unregister_dyld_image_infos_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_dyld_image_infos_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + dyld_kernel_image_info_t dyld_cache_image; + boolean_t no_cache; + boolean_t private_cache; + } __Request__task_register_dyld_shared_cache_image_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + uint8_t dyld_state; + char dyld_statePad[3]; + } __Request__task_register_dyld_set_dyld_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_register_dyld_get_process_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t corspe_task; + /* end of the kernel processed data */ + } __Request__task_map_corpse_info_64_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_inspect_flavor_t flavor; + mach_msg_type_number_t info_outCnt; + } __Request__task_inspect_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__task_get_exc_guard_behavior_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + task_exc_guard_behavior_t behavior; + } __Request__task_set_exc_guard_behavior_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_msg_type_number_t pathOffset; /* MiG doesn't use it */ + mach_msg_type_number_t pathCnt; + char path[1024]; + suid_cred_uid_t uid; + } __Request__task_create_suid_cred_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif +#endif /* !__Request__task_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__task_subsystem__defined +#define __RequestUnion__task_subsystem__defined +union __RequestUnion__task_subsystem { + __Request__task_create_t Request_task_create; + __Request__task_terminate_t Request_task_terminate; + __Request__task_threads_t Request_task_threads; + __Request__mach_ports_register_t Request_mach_ports_register; + __Request__mach_ports_lookup_t Request_mach_ports_lookup; + __Request__task_info_t Request_task_info; + __Request__task_set_info_t Request_task_set_info; + __Request__task_suspend_t Request_task_suspend; + __Request__task_resume_t Request_task_resume; + __Request__task_get_special_port_t Request_task_get_special_port; + __Request__task_set_special_port_t Request_task_set_special_port; + __Request__thread_create_t Request_thread_create; + __Request__thread_create_running_t Request_thread_create_running; + __Request__task_set_exception_ports_t Request_task_set_exception_ports; + __Request__task_get_exception_ports_t Request_task_get_exception_ports; + __Request__task_swap_exception_ports_t Request_task_swap_exception_ports; + __Request__lock_set_create_t Request_lock_set_create; + __Request__lock_set_destroy_t Request_lock_set_destroy; + __Request__semaphore_create_t Request_semaphore_create; + __Request__semaphore_destroy_t Request_semaphore_destroy; + __Request__task_policy_set_t Request_task_policy_set; + __Request__task_policy_get_t Request_task_policy_get; + __Request__task_sample_t Request_task_sample; + __Request__task_policy_t Request_task_policy; + __Request__task_set_emulation_t Request_task_set_emulation; + __Request__task_get_emulation_vector_t Request_task_get_emulation_vector; + __Request__task_set_emulation_vector_t Request_task_set_emulation_vector; + __Request__task_set_ras_pc_t Request_task_set_ras_pc; + __Request__task_zone_info_t Request_task_zone_info; + __Request__task_assign_t Request_task_assign; + __Request__task_assign_default_t Request_task_assign_default; + __Request__task_get_assignment_t Request_task_get_assignment; + __Request__task_set_policy_t Request_task_set_policy; + __Request__task_get_state_t Request_task_get_state; + __Request__task_set_state_t Request_task_set_state; + __Request__task_set_phys_footprint_limit_t Request_task_set_phys_footprint_limit; + __Request__task_suspend2_t Request_task_suspend2; + __Request__task_resume2_t Request_task_resume2; + __Request__task_purgable_info_t Request_task_purgable_info; + __Request__task_get_mach_voucher_t Request_task_get_mach_voucher; + __Request__task_set_mach_voucher_t Request_task_set_mach_voucher; + __Request__task_swap_mach_voucher_t Request_task_swap_mach_voucher; + __Request__task_generate_corpse_t Request_task_generate_corpse; + __Request__task_map_corpse_info_t Request_task_map_corpse_info; + __Request__task_register_dyld_image_infos_t Request_task_register_dyld_image_infos; + __Request__task_unregister_dyld_image_infos_t Request_task_unregister_dyld_image_infos; + __Request__task_get_dyld_image_infos_t Request_task_get_dyld_image_infos; + __Request__task_register_dyld_shared_cache_image_info_t Request_task_register_dyld_shared_cache_image_info; + __Request__task_register_dyld_set_dyld_state_t Request_task_register_dyld_set_dyld_state; + __Request__task_register_dyld_get_process_state_t Request_task_register_dyld_get_process_state; + __Request__task_map_corpse_info_64_t Request_task_map_corpse_info_64; + __Request__task_inspect_t Request_task_inspect; + __Request__task_get_exc_guard_behavior_t Request_task_get_exc_guard_behavior; + __Request__task_set_exc_guard_behavior_t Request_task_set_exc_guard_behavior; + __Request__task_create_suid_cred_t Request_task_create_suid_cred; +}; +#endif /* !__RequestUnion__task_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__task_subsystem__defined +#define __Reply__task_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_task; + /* end of the kernel processed data */ + } __Reply__task_create_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_terminate_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t act_list; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t act_listCnt; + } __Reply__task_threads_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_ports_register_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_ports_descriptor_t init_port_set; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t init_port_setCnt; + } __Reply__mach_ports_lookup_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t task_info_outCnt; + integer_t task_info_out[87]; + } __Reply__task_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_suspend_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_resume_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + } __Reply__task_get_special_port_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_special_port_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_act; + /* end of the kernel processed data */ + } __Reply__thread_create_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t child_act; + /* end of the kernel processed data */ + } __Reply__thread_create_running_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__task_get_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlerss[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__task_swap_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_lock_set; + /* end of the kernel processed data */ + } __Reply__lock_set_create_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__lock_set_destroy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t semaphore; + /* end of the kernel processed data */ + } __Reply__semaphore_create_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__semaphore_destroy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_policy_set_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + boolean_t get_default; + } __Reply__task_policy_get_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_sample_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_policy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_emulation_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t emulation_vector; + /* end of the kernel processed data */ + NDR_record_t NDR; + int vector_start; + mach_msg_type_number_t emulation_vectorCnt; + } __Reply__task_get_emulation_vector_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_emulation_vector_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_ras_pc_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t names; + mach_msg_ool_descriptor_t info; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t namesCnt; + mach_msg_type_number_t infoCnt; + } __Reply__task_zone_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_assign_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_assign_default_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t assigned_set; + /* end of the kernel processed data */ + } __Reply__task_get_assignment_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_policy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[1296]; + } __Reply__task_get_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + int old_limit; + } __Reply__task_set_phys_footprint_limit_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t suspend_token; + /* end of the kernel processed data */ + } __Reply__task_suspend2_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_resume2_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + task_purgable_info_t stats; + } __Reply__task_purgable_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t voucher; + /* end of the kernel processed data */ + } __Reply__task_get_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_voucher; + /* end of the kernel processed data */ + } __Reply__task_swap_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t corpse_task_port; + /* end of the kernel processed data */ + } __Reply__task_generate_corpse_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + vm_address_t kcd_addr_begin; + uint32_t kcd_size; + } __Reply__task_map_corpse_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_register_dyld_image_infos_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_unregister_dyld_image_infos_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_ool_descriptor_t dyld_images; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t dyld_imagesCnt; + } __Reply__task_get_dyld_image_infos_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_register_dyld_shared_cache_image_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_register_dyld_set_dyld_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + dyld_kernel_process_info_t dyld_process_state; + } __Reply__task_register_dyld_get_process_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_vm_address_t kcd_addr_begin; + mach_vm_size_t kcd_size; + } __Reply__task_map_corpse_info_64_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t info_outCnt; + integer_t info_out[4]; + } __Reply__task_inspect_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + task_exc_guard_behavior_t behavior; + } __Reply__task_get_exc_guard_behavior_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__task_set_exc_guard_behavior_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t delegation; + /* end of the kernel processed data */ + } __Reply__task_create_suid_cred_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif +#endif /* !__Reply__task_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__task_subsystem__defined +#define __ReplyUnion__task_subsystem__defined +union __ReplyUnion__task_subsystem { + __Reply__task_create_t Reply_task_create; + __Reply__task_terminate_t Reply_task_terminate; + __Reply__task_threads_t Reply_task_threads; + __Reply__mach_ports_register_t Reply_mach_ports_register; + __Reply__mach_ports_lookup_t Reply_mach_ports_lookup; + __Reply__task_info_t Reply_task_info; + __Reply__task_set_info_t Reply_task_set_info; + __Reply__task_suspend_t Reply_task_suspend; + __Reply__task_resume_t Reply_task_resume; + __Reply__task_get_special_port_t Reply_task_get_special_port; + __Reply__task_set_special_port_t Reply_task_set_special_port; + __Reply__thread_create_t Reply_thread_create; + __Reply__thread_create_running_t Reply_thread_create_running; + __Reply__task_set_exception_ports_t Reply_task_set_exception_ports; + __Reply__task_get_exception_ports_t Reply_task_get_exception_ports; + __Reply__task_swap_exception_ports_t Reply_task_swap_exception_ports; + __Reply__lock_set_create_t Reply_lock_set_create; + __Reply__lock_set_destroy_t Reply_lock_set_destroy; + __Reply__semaphore_create_t Reply_semaphore_create; + __Reply__semaphore_destroy_t Reply_semaphore_destroy; + __Reply__task_policy_set_t Reply_task_policy_set; + __Reply__task_policy_get_t Reply_task_policy_get; + __Reply__task_sample_t Reply_task_sample; + __Reply__task_policy_t Reply_task_policy; + __Reply__task_set_emulation_t Reply_task_set_emulation; + __Reply__task_get_emulation_vector_t Reply_task_get_emulation_vector; + __Reply__task_set_emulation_vector_t Reply_task_set_emulation_vector; + __Reply__task_set_ras_pc_t Reply_task_set_ras_pc; + __Reply__task_zone_info_t Reply_task_zone_info; + __Reply__task_assign_t Reply_task_assign; + __Reply__task_assign_default_t Reply_task_assign_default; + __Reply__task_get_assignment_t Reply_task_get_assignment; + __Reply__task_set_policy_t Reply_task_set_policy; + __Reply__task_get_state_t Reply_task_get_state; + __Reply__task_set_state_t Reply_task_set_state; + __Reply__task_set_phys_footprint_limit_t Reply_task_set_phys_footprint_limit; + __Reply__task_suspend2_t Reply_task_suspend2; + __Reply__task_resume2_t Reply_task_resume2; + __Reply__task_purgable_info_t Reply_task_purgable_info; + __Reply__task_get_mach_voucher_t Reply_task_get_mach_voucher; + __Reply__task_set_mach_voucher_t Reply_task_set_mach_voucher; + __Reply__task_swap_mach_voucher_t Reply_task_swap_mach_voucher; + __Reply__task_generate_corpse_t Reply_task_generate_corpse; + __Reply__task_map_corpse_info_t Reply_task_map_corpse_info; + __Reply__task_register_dyld_image_infos_t Reply_task_register_dyld_image_infos; + __Reply__task_unregister_dyld_image_infos_t Reply_task_unregister_dyld_image_infos; + __Reply__task_get_dyld_image_infos_t Reply_task_get_dyld_image_infos; + __Reply__task_register_dyld_shared_cache_image_info_t Reply_task_register_dyld_shared_cache_image_info; + __Reply__task_register_dyld_set_dyld_state_t Reply_task_register_dyld_set_dyld_state; + __Reply__task_register_dyld_get_process_state_t Reply_task_register_dyld_get_process_state; + __Reply__task_map_corpse_info_64_t Reply_task_map_corpse_info_64; + __Reply__task_inspect_t Reply_task_inspect; + __Reply__task_get_exc_guard_behavior_t Reply_task_get_exc_guard_behavior; + __Reply__task_set_exc_guard_behavior_t Reply_task_set_exc_guard_behavior; + __Reply__task_create_suid_cred_t Reply_task_create_suid_cred; +}; +#endif /* !__RequestUnion__task_subsystem__defined */ + +#ifndef subsystem_to_name_map_task +#define subsystem_to_name_map_task \ + { "task_create", 3400 },\ + { "task_terminate", 3401 },\ + { "task_threads", 3402 },\ + { "mach_ports_register", 3403 },\ + { "mach_ports_lookup", 3404 },\ + { "task_info", 3405 },\ + { "task_set_info", 3406 },\ + { "task_suspend", 3407 },\ + { "task_resume", 3408 },\ + { "task_get_special_port", 3409 },\ + { "task_set_special_port", 3410 },\ + { "thread_create", 3411 },\ + { "thread_create_running", 3412 },\ + { "task_set_exception_ports", 3413 },\ + { "task_get_exception_ports", 3414 },\ + { "task_swap_exception_ports", 3415 },\ + { "lock_set_create", 3416 },\ + { "lock_set_destroy", 3417 },\ + { "semaphore_create", 3418 },\ + { "semaphore_destroy", 3419 },\ + { "task_policy_set", 3420 },\ + { "task_policy_get", 3421 },\ + { "task_sample", 3422 },\ + { "task_policy", 3423 },\ + { "task_set_emulation", 3424 },\ + { "task_get_emulation_vector", 3425 },\ + { "task_set_emulation_vector", 3426 },\ + { "task_set_ras_pc", 3427 },\ + { "task_zone_info", 3428 },\ + { "task_assign", 3429 },\ + { "task_assign_default", 3430 },\ + { "task_get_assignment", 3431 },\ + { "task_set_policy", 3432 },\ + { "task_get_state", 3433 },\ + { "task_set_state", 3434 },\ + { "task_set_phys_footprint_limit", 3435 },\ + { "task_suspend2", 3436 },\ + { "task_resume2", 3437 },\ + { "task_purgable_info", 3438 },\ + { "task_get_mach_voucher", 3439 },\ + { "task_set_mach_voucher", 3440 },\ + { "task_swap_mach_voucher", 3441 },\ + { "task_generate_corpse", 3442 },\ + { "task_map_corpse_info", 3443 },\ + { "task_register_dyld_image_infos", 3444 },\ + { "task_unregister_dyld_image_infos", 3445 },\ + { "task_get_dyld_image_infos", 3446 },\ + { "task_register_dyld_shared_cache_image_info", 3447 },\ + { "task_register_dyld_set_dyld_state", 3448 },\ + { "task_register_dyld_get_process_state", 3449 },\ + { "task_map_corpse_info_64", 3450 },\ + { "task_inspect", 3451 },\ + { "task_get_exc_guard_behavior", 3452 },\ + { "task_set_exc_guard_behavior", 3453 },\ + { "task_create_suid_cred", 3454 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _task_user_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/task_info.h b/lib/libc/include/aarch64-macos-gnu/mach/task_info.h new file mode 100644 index 0000000000..6d8258ad72 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/task_info.h @@ -0,0 +1,524 @@ +/* + * Copyright (c) 2000-2007, 2015 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * Machine-independent task information structures and definitions. + * + * The definitions in this file are exported to the user. The kernel + * will translate its internal data structures to these structures + * as appropriate. + * + */ + +#ifndef _MACH_TASK_INFO_H_ +#define _MACH_TASK_INFO_H_ + +#include +#include +#include +#include +#include /* for vm_extmod_statistics_data_t */ +#include + +#include + +/* + * Generic information structure to allow for expansion. + */ +typedef natural_t task_flavor_t; +typedef integer_t *task_info_t; /* varying array of int */ + +/* Deprecated, use per structure _data_t's instead */ +#define TASK_INFO_MAX (1024) /* maximum array size */ +typedef integer_t task_info_data_t[TASK_INFO_MAX]; + +/* + * Currently defined information structures. + */ + +#pragma pack(push, 4) + +/* Don't use this, use MACH_TASK_BASIC_INFO instead */ +#define TASK_BASIC_INFO_32 4 /* basic information */ +#define TASK_BASIC2_INFO_32 6 + +struct task_basic_info_32 { + integer_t suspend_count; /* suspend count for task */ + natural_t virtual_size; /* virtual memory size (bytes) */ + natural_t resident_size; /* resident memory size (bytes) */ + time_value_t user_time; /* total user run time for + * terminated threads */ + time_value_t system_time; /* total system run time for + * terminated threads */ + policy_t policy; /* default policy for new threads */ +}; +typedef struct task_basic_info_32 task_basic_info_32_data_t; +typedef struct task_basic_info_32 *task_basic_info_32_t; +#define TASK_BASIC_INFO_32_COUNT \ + (sizeof(task_basic_info_32_data_t) / sizeof(natural_t)) + +/* Don't use this, use MACH_TASK_BASIC_INFO instead */ +struct task_basic_info_64 { + integer_t suspend_count; /* suspend count for task */ +#if defined(__arm__) || defined(__arm64__) + mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ + mach_vm_size_t resident_size; /* resident memory size (bytes) */ +#else /* defined(__arm__) || defined(__arm64__) */ + mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ + mach_vm_size_t resident_size; /* resident memory size (bytes) */ +#endif /* defined(__arm__) || defined(__arm64__) */ + time_value_t user_time; /* total user run time for + * terminated threads */ + time_value_t system_time; /* total system run time for + * terminated threads */ + policy_t policy; /* default policy for new threads */ +}; +typedef struct task_basic_info_64 task_basic_info_64_data_t; +typedef struct task_basic_info_64 *task_basic_info_64_t; + +#if defined(__arm__) || defined(__arm64__) + #if defined(__arm__) && defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0) +/* + * Note: arm64 can't use the old flavor. If you somehow manage to, + * you can cope with the nonsense data yourself. + */ + #define TASK_BASIC_INFO_64 5 + #define TASK_BASIC_INFO_64_COUNT \ + (sizeof(task_basic_info_64_data_t) / sizeof(natural_t)) + + #else + + #define TASK_BASIC_INFO_64 TASK_BASIC_INFO_64_2 + #define TASK_BASIC_INFO_64_COUNT TASK_BASIC_INFO_64_2_COUNT + #endif +#else /* defined(__arm__) || defined(__arm64__) */ +#define TASK_BASIC_INFO_64 5 /* 64-bit capable basic info */ +#define TASK_BASIC_INFO_64_COUNT \ + (sizeof(task_basic_info_64_data_t) / sizeof(natural_t)) +#endif + + +/* localized structure - cannot be safely passed between tasks of differing sizes */ +/* Don't use this, use MACH_TASK_BASIC_INFO instead */ +struct task_basic_info { + integer_t suspend_count; /* suspend count for task */ + vm_size_t virtual_size; /* virtual memory size (bytes) */ + vm_size_t resident_size; /* resident memory size (bytes) */ + time_value_t user_time; /* total user run time for + * terminated threads */ + time_value_t system_time; /* total system run time for + * terminated threads */ + policy_t policy; /* default policy for new threads */ +}; + +typedef struct task_basic_info task_basic_info_data_t; +typedef struct task_basic_info *task_basic_info_t; +#define TASK_BASIC_INFO_COUNT \ + (sizeof(task_basic_info_data_t) / sizeof(natural_t)) +#if !defined(__LP64__) +#define TASK_BASIC_INFO TASK_BASIC_INFO_32 +#else +#define TASK_BASIC_INFO TASK_BASIC_INFO_64 +#endif + + + +#define TASK_EVENTS_INFO 2 /* various event counts */ + +struct task_events_info { + integer_t faults; /* number of page faults */ + integer_t pageins; /* number of actual pageins */ + integer_t cow_faults; /* number of copy-on-write faults */ + integer_t messages_sent; /* number of messages sent */ + integer_t messages_received; /* number of messages received */ + integer_t syscalls_mach; /* number of mach system calls */ + integer_t syscalls_unix; /* number of unix system calls */ + integer_t csw; /* number of context switches */ +}; +typedef struct task_events_info task_events_info_data_t; +typedef struct task_events_info *task_events_info_t; +#define TASK_EVENTS_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(task_events_info_data_t) / sizeof(natural_t))) + +#define TASK_THREAD_TIMES_INFO 3 /* total times for live threads - + * only accurate if suspended */ + +struct task_thread_times_info { + time_value_t user_time; /* total user run time for + * live threads */ + time_value_t system_time; /* total system run time for + * live threads */ +}; + +typedef struct task_thread_times_info task_thread_times_info_data_t; +typedef struct task_thread_times_info *task_thread_times_info_t; +#define TASK_THREAD_TIMES_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(task_thread_times_info_data_t) / sizeof(natural_t))) + +#define TASK_ABSOLUTETIME_INFO 1 + +struct task_absolutetime_info { + uint64_t total_user; + uint64_t total_system; + uint64_t threads_user; /* existing threads only */ + uint64_t threads_system; +}; + +typedef struct task_absolutetime_info task_absolutetime_info_data_t; +typedef struct task_absolutetime_info *task_absolutetime_info_t; +#define TASK_ABSOLUTETIME_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof (task_absolutetime_info_data_t) / sizeof (natural_t))) + +#define TASK_KERNELMEMORY_INFO 7 + +struct task_kernelmemory_info { + uint64_t total_palloc; /* private kernel mem alloc'ed */ + uint64_t total_pfree; /* private kernel mem freed */ + uint64_t total_salloc; /* shared kernel mem alloc'ed */ + uint64_t total_sfree; /* shared kernel mem freed */ +}; + +typedef struct task_kernelmemory_info task_kernelmemory_info_data_t; +typedef struct task_kernelmemory_info *task_kernelmemory_info_t; +#define TASK_KERNELMEMORY_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof (task_kernelmemory_info_data_t) / sizeof (natural_t))) + +#define TASK_SECURITY_TOKEN 13 +#define TASK_SECURITY_TOKEN_COUNT ((mach_msg_type_number_t) \ + (sizeof(security_token_t) / sizeof(natural_t))) + +#define TASK_AUDIT_TOKEN 15 +#define TASK_AUDIT_TOKEN_COUNT \ + (sizeof(audit_token_t) / sizeof(natural_t)) + + +#define TASK_AFFINITY_TAG_INFO 16 /* This is experimental. */ + +struct task_affinity_tag_info { + integer_t set_count; + integer_t min; + integer_t max; + integer_t task_count; +}; +typedef struct task_affinity_tag_info task_affinity_tag_info_data_t; +typedef struct task_affinity_tag_info *task_affinity_tag_info_t; +#define TASK_AFFINITY_TAG_INFO_COUNT \ + (sizeof(task_affinity_tag_info_data_t) / sizeof(natural_t)) + +#define TASK_DYLD_INFO 17 + +struct task_dyld_info { + mach_vm_address_t all_image_info_addr; + mach_vm_size_t all_image_info_size; + integer_t all_image_info_format; +}; +typedef struct task_dyld_info task_dyld_info_data_t; +typedef struct task_dyld_info *task_dyld_info_t; +#define TASK_DYLD_INFO_COUNT \ + (sizeof(task_dyld_info_data_t) / sizeof(natural_t)) +#define TASK_DYLD_ALL_IMAGE_INFO_32 0 /* format value */ +#define TASK_DYLD_ALL_IMAGE_INFO_64 1 /* format value */ + +#if defined(__arm__) || defined(__arm64__) + +/* Don't use this, use MACH_TASK_BASIC_INFO instead */ +/* Compatibility for old 32-bit mach_vm_*_t */ +#define TASK_BASIC_INFO_64_2 18 /* 64-bit capable basic info */ + +struct task_basic_info_64_2 { + integer_t suspend_count; /* suspend count for task */ + mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ + mach_vm_size_t resident_size; /* resident memory size (bytes) */ + time_value_t user_time; /* total user run time for + * terminated threads */ + time_value_t system_time; /* total system run time for + * terminated threads */ + policy_t policy; /* default policy for new threads */ +}; +typedef struct task_basic_info_64_2 task_basic_info_64_2_data_t; +typedef struct task_basic_info_64_2 *task_basic_info_64_2_t; +#define TASK_BASIC_INFO_64_2_COUNT \ + (sizeof(task_basic_info_64_2_data_t) / sizeof(natural_t)) +#endif + +#define TASK_EXTMOD_INFO 19 + +struct task_extmod_info { + unsigned char task_uuid[16]; + vm_extmod_statistics_data_t extmod_statistics; +}; +typedef struct task_extmod_info task_extmod_info_data_t; +typedef struct task_extmod_info *task_extmod_info_t; +#define TASK_EXTMOD_INFO_COUNT \ + (sizeof(task_extmod_info_data_t) / sizeof(natural_t)) + + +#define MACH_TASK_BASIC_INFO 20 /* always 64-bit basic info */ +struct mach_task_basic_info { + mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ + mach_vm_size_t resident_size; /* resident memory size (bytes) */ + mach_vm_size_t resident_size_max; /* maximum resident memory size (bytes) */ + time_value_t user_time; /* total user run time for + * terminated threads */ + time_value_t system_time; /* total system run time for + * terminated threads */ + policy_t policy; /* default policy for new threads */ + integer_t suspend_count; /* suspend count for task */ +}; +typedef struct mach_task_basic_info mach_task_basic_info_data_t; +typedef struct mach_task_basic_info *mach_task_basic_info_t; +#define MACH_TASK_BASIC_INFO_COUNT \ + (sizeof(mach_task_basic_info_data_t) / sizeof(natural_t)) + + +#define TASK_POWER_INFO 21 + +struct task_power_info { + uint64_t total_user; + uint64_t total_system; + uint64_t task_interrupt_wakeups; + uint64_t task_platform_idle_wakeups; + uint64_t task_timer_wakeups_bin_1; + uint64_t task_timer_wakeups_bin_2; +}; + +typedef struct task_power_info task_power_info_data_t; +typedef struct task_power_info *task_power_info_t; +#define TASK_POWER_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof (task_power_info_data_t) / sizeof (natural_t))) + + + +#define TASK_VM_INFO 22 +#define TASK_VM_INFO_PURGEABLE 23 +struct task_vm_info { + mach_vm_size_t virtual_size; /* virtual memory size (bytes) */ + integer_t region_count; /* number of memory regions */ + integer_t page_size; + mach_vm_size_t resident_size; /* resident memory size (bytes) */ + mach_vm_size_t resident_size_peak; /* peak resident size (bytes) */ + + mach_vm_size_t device; + mach_vm_size_t device_peak; + mach_vm_size_t internal; + mach_vm_size_t internal_peak; + mach_vm_size_t external; + mach_vm_size_t external_peak; + mach_vm_size_t reusable; + mach_vm_size_t reusable_peak; + mach_vm_size_t purgeable_volatile_pmap; + mach_vm_size_t purgeable_volatile_resident; + mach_vm_size_t purgeable_volatile_virtual; + mach_vm_size_t compressed; + mach_vm_size_t compressed_peak; + mach_vm_size_t compressed_lifetime; + + /* added for rev1 */ + mach_vm_size_t phys_footprint; + + /* added for rev2 */ + mach_vm_address_t min_address; + mach_vm_address_t max_address; + + /* added for rev3 */ + int64_t ledger_phys_footprint_peak; + int64_t ledger_purgeable_nonvolatile; + int64_t ledger_purgeable_novolatile_compressed; + int64_t ledger_purgeable_volatile; + int64_t ledger_purgeable_volatile_compressed; + int64_t ledger_tag_network_nonvolatile; + int64_t ledger_tag_network_nonvolatile_compressed; + int64_t ledger_tag_network_volatile; + int64_t ledger_tag_network_volatile_compressed; + int64_t ledger_tag_media_footprint; + int64_t ledger_tag_media_footprint_compressed; + int64_t ledger_tag_media_nofootprint; + int64_t ledger_tag_media_nofootprint_compressed; + int64_t ledger_tag_graphics_footprint; + int64_t ledger_tag_graphics_footprint_compressed; + int64_t ledger_tag_graphics_nofootprint; + int64_t ledger_tag_graphics_nofootprint_compressed; + int64_t ledger_tag_neural_footprint; + int64_t ledger_tag_neural_footprint_compressed; + int64_t ledger_tag_neural_nofootprint; + int64_t ledger_tag_neural_nofootprint_compressed; + + /* added for rev4 */ + uint64_t limit_bytes_remaining; + + /* added for rev5 */ + integer_t decompressions; +}; +typedef struct task_vm_info task_vm_info_data_t; +typedef struct task_vm_info *task_vm_info_t; +#define TASK_VM_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof (task_vm_info_data_t) / sizeof (natural_t))) +#define TASK_VM_INFO_REV5_COUNT TASK_VM_INFO_COUNT +#define TASK_VM_INFO_REV4_COUNT /* doesn't include decompressions */ \ + ((mach_msg_type_number_t) (TASK_VM_INFO_REV5_COUNT - 1)) +#define TASK_VM_INFO_REV3_COUNT /* doesn't include limit bytes */ \ + ((mach_msg_type_number_t) (TASK_VM_INFO_REV4_COUNT - 2)) +#define TASK_VM_INFO_REV2_COUNT /* doesn't include extra ledgers info */ \ + ((mach_msg_type_number_t) (TASK_VM_INFO_REV3_COUNT - 42)) +#define TASK_VM_INFO_REV1_COUNT /* doesn't include min and max address */ \ + ((mach_msg_type_number_t) (TASK_VM_INFO_REV2_COUNT - 4)) +#define TASK_VM_INFO_REV0_COUNT /* doesn't include phys_footprint */ \ + ((mach_msg_type_number_t) (TASK_VM_INFO_REV1_COUNT - 2)) + +typedef struct vm_purgeable_info task_purgable_info_t; + + +#define TASK_TRACE_MEMORY_INFO 24 /* no longer supported */ +struct task_trace_memory_info { + uint64_t user_memory_address; /* address of start of trace memory buffer */ + uint64_t buffer_size; /* size of buffer in bytes */ + uint64_t mailbox_array_size; /* size of mailbox area in bytes */ +}; +typedef struct task_trace_memory_info task_trace_memory_info_data_t; +typedef struct task_trace_memory_info * task_trace_memory_info_t; +#define TASK_TRACE_MEMORY_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(task_trace_memory_info_data_t) / sizeof(natural_t))) + +#define TASK_WAIT_STATE_INFO 25 /* deprecated. */ +struct task_wait_state_info { + uint64_t total_wait_state_time; /* Time that all threads past and present have been in a wait state */ + uint64_t total_wait_sfi_state_time; /* Time that threads have been in SFI wait (should be a subset of total wait state time */ + uint32_t _reserved[4]; +}; +typedef struct task_wait_state_info task_wait_state_info_data_t; +typedef struct task_wait_state_info * task_wait_state_info_t; +#define TASK_WAIT_STATE_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(task_wait_state_info_data_t) / sizeof(natural_t))) + +#define TASK_POWER_INFO_V2 26 + +typedef struct { + uint64_t task_gpu_utilisation; + uint64_t task_gpu_stat_reserved0; + uint64_t task_gpu_stat_reserved1; + uint64_t task_gpu_stat_reserved2; +} gpu_energy_data; + +typedef gpu_energy_data *gpu_energy_data_t; +struct task_power_info_v2 { + task_power_info_data_t cpu_energy; + gpu_energy_data gpu_energy; +#if defined(__arm__) || defined(__arm64__) + uint64_t task_energy; +#endif /* defined(__arm__) || defined(__arm64__) */ + uint64_t task_ptime; + uint64_t task_pset_switches; +}; + +typedef struct task_power_info_v2 task_power_info_v2_data_t; +typedef struct task_power_info_v2 *task_power_info_v2_t; +#define TASK_POWER_INFO_V2_COUNT_OLD \ + ((mach_msg_type_number_t) (sizeof (task_power_info_v2_data_t) - sizeof(uint64_t)*2) / sizeof (natural_t)) +#define TASK_POWER_INFO_V2_COUNT \ + ((mach_msg_type_number_t) (sizeof (task_power_info_v2_data_t) / sizeof (natural_t))) + +#define TASK_VM_INFO_PURGEABLE_ACCOUNT 27 /* Used for xnu purgeable vm unit tests */ + + +#define TASK_FLAGS_INFO 28 /* return t_flags field */ +struct task_flags_info { + uint32_t flags; /* task flags */ +}; +typedef struct task_flags_info task_flags_info_data_t; +typedef struct task_flags_info * task_flags_info_t; +#define TASK_FLAGS_INFO_COUNT ((mach_msg_type_number_t) \ + (sizeof(task_flags_info_data_t) / sizeof (natural_t))) + +#define TF_LP64 0x00000001 /* task has 64-bit addressing */ +#define TF_64B_DATA 0x00000002 /* task has 64-bit data registers */ + +#define TASK_DEBUG_INFO_INTERNAL 29 /* Used for kernel internal development tests. */ + + +/* + * Type to control EXC_GUARD delivery options for a task + * via task_get/set_exc_guard_behavior interface(s). + */ +typedef uint32_t task_exc_guard_behavior_t; + +/* EXC_GUARD optional delivery settings on a per-task basis */ +#define TASK_EXC_GUARD_VM_DELIVER 0x01 /* Deliver virtual memory EXC_GUARD exceptions */ +#define TASK_EXC_GUARD_VM_ONCE 0x02 /* Deliver them only once */ +#define TASK_EXC_GUARD_VM_CORPSE 0x04 /* Deliver them via a forked corpse */ +#define TASK_EXC_GUARD_VM_FATAL 0x08 /* Virtual Memory EXC_GUARD delivery is fatal */ +#define TASK_EXC_GUARD_VM_ALL 0x0f + +#define TASK_EXC_GUARD_MP_DELIVER 0x10 /* Deliver mach port EXC_GUARD exceptions */ +#define TASK_EXC_GUARD_MP_ONCE 0x20 /* Deliver them only once */ +#define TASK_EXC_GUARD_MP_CORPSE 0x40 /* Deliver them via a forked corpse */ +#define TASK_EXC_GUARD_MP_FATAL 0x80 /* mach port EXC_GUARD delivery is fatal */ +#define TASK_EXC_GUARD_MP_ALL 0xf0 + +#define TASK_EXC_GUARD_ALL 0xff /* All optional deliver settings */ + + +/* + * Obsolete interfaces. + */ + +#define TASK_SCHED_TIMESHARE_INFO 10 +#define TASK_SCHED_RR_INFO 11 +#define TASK_SCHED_FIFO_INFO 12 + +#define TASK_SCHED_INFO 14 + +#pragma pack(pop) + +#endif /* _MACH_TASK_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/task_policy.h b/lib/libc/include/aarch64-macos-gnu/mach/task_policy.h new file mode 100644 index 0000000000..6ded769b6f --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/task_policy.h @@ -0,0 +1,186 @@ +/* + * 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 _MACH_TASK_POLICY_H_ +#define _MACH_TASK_POLICY_H_ + +#include + +/* + * These are the calls for accessing the policy parameters + * of a particular task. + * + * The extra 'get_default' parameter to the second call is + * IN/OUT as follows: + * 1) if asserted on the way in it indicates that the default + * values should be returned, not the ones currently set, in + * this case 'get_default' will always be asserted on return; + * 2) if unasserted on the way in, the current settings are + * desired and if still unasserted on return, then the info + * returned reflects the current settings, otherwise if + * 'get_default' returns asserted, it means that there are no + * current settings due to other parameters taking precedence, + * and the default ones are being returned instead. + */ + +typedef natural_t task_policy_flavor_t; +typedef integer_t *task_policy_t; + +/* + * kern_return_t task_policy_set( + * task_t task, + * task_policy_flavor_t flavor, + * task_policy_t policy_info, + * mach_msg_type_number_t count); + * + * kern_return_t task_policy_get( + * task_t task, + * task_policy_flavor_t flavor, + * task_policy_t policy_info, + * mach_msg_type_number_t *count, + * boolean_t *get_default); + */ + +/* + * Defined flavors. + */ +/* + * TASK_CATEGORY_POLICY: + * + * This provides information to the kernel about the role + * of the task in the system. + * + * Parameters: + * + * role: Enumerated as follows: + * + * TASK_UNSPECIFIED is the default, since the role is not + * inherited from the parent. + * + * TASK_FOREGROUND_APPLICATION should be assigned when the + * task is a normal UI application in the foreground from + * the HI point of view. + * **N.B. There may be more than one of these at a given time. + * + * TASK_BACKGROUND_APPLICATION should be assigned when the + * task is a normal UI application in the background from + * the HI point of view. + * + * TASK_CONTROL_APPLICATION should be assigned to the unique + * UI application which implements the pop-up application dialog. + * There can only be one task at a time with this designation, + * which is assigned FCFS. + * + * TASK_GRAPHICS_SERVER should be assigned to the graphics + * management (window) server. There can only be one task at + * a time with this designation, which is assigned FCFS. + */ + +#define TASK_CATEGORY_POLICY 1 + +#define TASK_SUPPRESSION_POLICY 3 +#define TASK_POLICY_STATE 4 +#define TASK_BASE_QOS_POLICY 8 +#define TASK_OVERRIDE_QOS_POLICY 9 +#define TASK_BASE_LATENCY_QOS_POLICY 10 +#define TASK_BASE_THROUGHPUT_QOS_POLICY 11 + +typedef enum task_role { + TASK_RENICED = -1, + TASK_UNSPECIFIED = 0, + TASK_FOREGROUND_APPLICATION = 1, + TASK_BACKGROUND_APPLICATION = 2, + TASK_CONTROL_APPLICATION = 3, + TASK_GRAPHICS_SERVER = 4, + TASK_THROTTLE_APPLICATION = 5, + TASK_NONUI_APPLICATION = 6, + TASK_DEFAULT_APPLICATION = 7, + TASK_DARWINBG_APPLICATION = 8, +} task_role_t; + +struct task_category_policy { + task_role_t role; +}; + +typedef struct task_category_policy task_category_policy_data_t; +typedef struct task_category_policy *task_category_policy_t; + +#define TASK_CATEGORY_POLICY_COUNT ((mach_msg_type_number_t) \ + (sizeof (task_category_policy_data_t) / sizeof (integer_t))) + + +enum task_latency_qos { + LATENCY_QOS_TIER_UNSPECIFIED = 0x0, + LATENCY_QOS_TIER_0 = ((0xFF << 16) | 1), + LATENCY_QOS_TIER_1 = ((0xFF << 16) | 2), + LATENCY_QOS_TIER_2 = ((0xFF << 16) | 3), + LATENCY_QOS_TIER_3 = ((0xFF << 16) | 4), + LATENCY_QOS_TIER_4 = ((0xFF << 16) | 5), + LATENCY_QOS_TIER_5 = ((0xFF << 16) | 6) +}; +typedef integer_t task_latency_qos_t; +enum task_throughput_qos { + THROUGHPUT_QOS_TIER_UNSPECIFIED = 0x0, + THROUGHPUT_QOS_TIER_0 = ((0xFE << 16) | 1), + THROUGHPUT_QOS_TIER_1 = ((0xFE << 16) | 2), + THROUGHPUT_QOS_TIER_2 = ((0xFE << 16) | 3), + THROUGHPUT_QOS_TIER_3 = ((0xFE << 16) | 4), + THROUGHPUT_QOS_TIER_4 = ((0xFE << 16) | 5), + THROUGHPUT_QOS_TIER_5 = ((0xFE << 16) | 6), +}; + +#define LATENCY_QOS_LAUNCH_DEFAULT_TIER LATENCY_QOS_TIER_3 +#define THROUGHPUT_QOS_LAUNCH_DEFAULT_TIER THROUGHPUT_QOS_TIER_3 + +typedef integer_t task_throughput_qos_t; + +struct task_qos_policy { + task_latency_qos_t task_latency_qos_tier; + task_throughput_qos_t task_throughput_qos_tier; +}; + +typedef struct task_qos_policy *task_qos_policy_t; +#define TASK_QOS_POLICY_COUNT ((mach_msg_type_number_t) \ + (sizeof (struct task_qos_policy) / sizeof (integer_t))) + +/* These should be removed - they belong in proc_info.h */ +#define PROC_FLAG_DARWINBG 0x8000 /* process in darwin background */ +#define PROC_FLAG_EXT_DARWINBG 0x10000 /* process in darwin background - external enforcement */ +#define PROC_FLAG_IOS_APPLEDAEMON 0x20000 /* process is apple ios daemon */ +#define PROC_FLAG_IOS_IMPPROMOTION 0x80000 /* process is apple ios daemon */ +#define PROC_FLAG_ADAPTIVE 0x100000 /* Process is adaptive */ +#define PROC_FLAG_ADAPTIVE_IMPORTANT 0x200000 /* Process is adaptive, and is currently important */ +#define PROC_FLAG_IMPORTANCE_DONOR 0x400000 /* Process is marked as an importance donor */ +#define PROC_FLAG_SUPPRESSED 0x800000 /* Process is suppressed */ +#define PROC_FLAG_APPLICATION 0x1000000 /* Process is an application */ +#define PROC_FLAG_IOS_APPLICATION PROC_FLAG_APPLICATION /* Process is an application */ + + + + +#endif /* _MACH_TASK_POLICY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/task_special_ports.h b/lib/libc/include/aarch64-macos-gnu/mach/task_special_ports.h new file mode 100644 index 0000000000..1b23c6b7e6 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/task_special_ports.h @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2000-2010 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * File: mach/task_special_ports.h + * + * Defines codes for special_purpose task ports. These are NOT + * port identifiers - they are only used for the task_get_special_port + * and task_set_special_port routines. + * + */ + +#ifndef _MACH_TASK_SPECIAL_PORTS_H_ +#define _MACH_TASK_SPECIAL_PORTS_H_ + +typedef int task_special_port_t; + +#define TASK_KERNEL_PORT 1 /* The full task port for task. */ + +#define TASK_HOST_PORT 2 /* The host (priv) port for task. */ + +#define TASK_NAME_PORT 3 /* The name port for task. */ + +#define TASK_BOOTSTRAP_PORT 4 /* Bootstrap environment for task. */ + +#define TASK_INSPECT_PORT 5 /* The inspect port for task. */ + +#define TASK_READ_PORT 6 /* The read port for task. */ + + + +#define TASK_SEATBELT_PORT 7 /* Seatbelt compiler/DEM port for task. */ + +/* PORT 8 was the GSSD TASK PORT which transformed to a host port */ + +#define TASK_ACCESS_PORT 9 /* Permission check for task_for_pid. */ + +#define TASK_DEBUG_CONTROL_PORT 10 /* debug control port */ + +#define TASK_RESOURCE_NOTIFY_PORT 11 /* overrides host special RN port */ + +#define TASK_MAX_SPECIAL_PORT TASK_RESOURCE_NOTIFY_PORT + +/* + * Definitions for ease of use + */ + +#define task_get_kernel_port(task, port) \ + (task_get_special_port((task), TASK_KERNEL_PORT, (port))) + +#define task_set_kernel_port(task, port) \ + (task_set_special_port((task), TASK_KERNEL_PORT, (port))) + +#define task_get_host_port(task, port) \ + (task_get_special_port((task), TASK_HOST_PORT, (port))) + +#define task_set_host_port(task, port) \ + (task_set_special_port((task), TASK_HOST_PORT, (port))) + +#define task_get_bootstrap_port(task, port) \ + (task_get_special_port((task), TASK_BOOTSTRAP_PORT, (port))) + +#define task_get_debug_control_port(task, port) \ + (task_get_special_port((task), TASK_DEBUG_CONTROL_PORT, (port))) + +#define task_set_bootstrap_port(task, port) \ + (task_set_special_port((task), TASK_BOOTSTRAP_PORT, (port))) + +#define task_get_task_access_port(task, port) \ + (task_get_special_port((task), TASK_ACCESS_PORT, (port))) + +#define task_set_task_access_port(task, port) \ + (task_set_special_port((task), TASK_ACCESS_PORT, (port))) + +#define task_set_task_debug_control_port(task, port) \ + (task_set_special_port((task), TASK_DEBUG_CONTROL_PORT, (port))) + + +#endif /* _MACH_TASK_SPECIAL_PORTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/thread_act.h b/lib/libc/include/aarch64-macos-gnu/mach/thread_act.h new file mode 100644 index 0000000000..5d7e2625a2 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/thread_act.h @@ -0,0 +1,1386 @@ +#ifndef _thread_act_user_ +#define _thread_act_user_ + +/* Module thread_act */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* BEGIN MIG_STRNCPY_ZEROFILL CODE */ + +#if defined(__has_include) +#if __has_include() +#ifndef USING_MIG_STRNCPY_ZEROFILL +#define USING_MIG_STRNCPY_ZEROFILL +#endif +#ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ +#define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ +#ifdef __cplusplus +extern "C" { +#endif + extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); +#ifdef __cplusplus +} +#endif +#endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ +#endif /* __has_include() */ +#endif /* __has_include */ + +/* END MIG_STRNCPY_ZEROFILL CODE */ + + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef thread_act_MSG_COUNT +#define thread_act_MSG_COUNT 29 +#endif /* thread_act_MSG_COUNT */ + +#include +#include +#include +#include + +#ifdef __BeforeMigUserHeader +__BeforeMigUserHeader +#endif /* __BeforeMigUserHeader */ + +#include +__BEGIN_DECLS + + +/* Routine thread_terminate */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_terminate +( + thread_act_t target_act +); + +/* Routine act_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t act_get_state +( + thread_read_t target_act, + int flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine act_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t act_set_state +( + thread_act_t target_act, + int flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +/* Routine thread_get_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +kern_return_t thread_get_state +( + thread_read_t target_act, + thread_state_flavor_t flavor, + thread_state_t old_state, + mach_msg_type_number_t *old_stateCnt +); + +/* Routine thread_set_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +kern_return_t thread_set_state +( + thread_act_t target_act, + thread_state_flavor_t flavor, + thread_state_t new_state, + mach_msg_type_number_t new_stateCnt +); + +/* Routine thread_suspend */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +kern_return_t thread_suspend +( + thread_act_t target_act +); + +/* Routine thread_resume */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +kern_return_t thread_resume +( + thread_act_t target_act +); + +/* Routine thread_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +kern_return_t thread_abort +( + thread_act_t target_act +); + +/* Routine thread_abort_safely */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +kern_return_t thread_abort_safely +( + thread_act_t target_act +); + +/* Routine thread_depress_abort */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_depress_abort +( + thread_act_t thread +); + +/* Routine thread_get_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_get_special_port +( + thread_inspect_t thr_act, + int which_port, + mach_port_t *special_port +); + +/* Routine thread_set_special_port */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_set_special_port +( + thread_act_t thr_act, + int which_port, + mach_port_t special_port +); + +/* Routine thread_info */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_info +( + thread_inspect_t target_act, + thread_flavor_t flavor, + thread_info_t thread_info_out, + mach_msg_type_number_t *thread_info_outCnt +); + +/* Routine thread_set_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_set_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor +); + +/* Routine thread_get_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_get_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine thread_swap_exception_ports */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_swap_exception_ports +( + thread_act_t thread, + exception_mask_t exception_mask, + mach_port_t new_port, + exception_behavior_t behavior, + thread_state_flavor_t new_flavor, + exception_mask_array_t masks, + mach_msg_type_number_t *masksCnt, + exception_handler_array_t old_handlers, + exception_behavior_array_t old_behaviors, + exception_flavor_array_t old_flavors +); + +/* Routine thread_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy +( + thread_act_t thr_act, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + boolean_t set_limit +); + +/* Routine thread_policy_set */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy_set +( + thread_act_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t policy_infoCnt +); + +/* Routine thread_policy_get */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_policy_get +( + thread_inspect_t thread, + thread_policy_flavor_t flavor, + thread_policy_t policy_info, + mach_msg_type_number_t *policy_infoCnt, + boolean_t *get_default +); + +/* Routine thread_sample */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_sample +( + thread_act_t thread, + mach_port_t reply +); + +/* Routine etap_trace_thread */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t etap_trace_thread +( + thread_act_t target_act, + boolean_t trace_status +); + +/* Routine thread_assign */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_assign +( + thread_act_t thread, + processor_set_t new_set +); + +/* Routine thread_assign_default */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_assign_default +( + thread_act_t thread +); + +/* Routine thread_get_assignment */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_get_assignment +( + thread_inspect_t thread, + processor_set_name_t *assigned_set +); + +/* Routine thread_set_policy */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_set_policy +( + thread_act_t thr_act, + processor_set_t pset, + policy_t policy, + policy_base_t base, + mach_msg_type_number_t baseCnt, + policy_limit_t limit, + mach_msg_type_number_t limitCnt +); + +/* Routine thread_get_mach_voucher */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_get_mach_voucher +( + thread_read_t thr_act, + mach_voucher_selector_t which, + ipc_voucher_t *voucher +); + +/* Routine thread_set_mach_voucher */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_set_mach_voucher +( + thread_act_t thr_act, + ipc_voucher_t voucher +); + +/* Routine thread_swap_mach_voucher */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +__WATCHOS_PROHIBITED +__TVOS_PROHIBITED +kern_return_t thread_swap_mach_voucher +( + thread_act_t thr_act, + ipc_voucher_t new_voucher, + ipc_voucher_t *old_voucher +); + +/* Routine thread_convert_thread_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t thread_convert_thread_state +( + thread_act_t thread, + int direction, + thread_state_flavor_t flavor, + thread_state_t in_state, + mach_msg_type_number_t in_stateCnt, + thread_state_t out_state, + mach_msg_type_number_t *out_stateCnt +); + +__END_DECLS + +/********************** Caution **************************/ +/* The following data types should be used to calculate */ +/* maximum message sizes only. The actual message may be */ +/* smaller, and the position of the arguments within the */ +/* message layout may vary from what is presented here. */ +/* For example, if any of the arguments are variable- */ +/* sized, and less than the maximum is sent, the data */ +/* will be packed tight in the actual message to reduce */ +/* the presence of holes. */ +/********************** Caution **************************/ + +/* typedefs for all requests */ + +#ifndef __Request__thread_act_subsystem__defined +#define __Request__thread_act_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_terminate_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__act_get_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[1296]; + } __Request__act_set_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t old_stateCnt; + } __Request__thread_get_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_state_flavor_t flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[1296]; + } __Request__thread_set_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_suspend_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_resume_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_abort_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_abort_safely_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_depress_abort_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int which_port; + } __Request__thread_get_special_port_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + int which_port; + } __Request__thread_set_special_port_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_flavor_t flavor; + mach_msg_type_number_t thread_info_outCnt; + } __Request__thread_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__thread_set_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_mask_t exception_mask; + } __Request__thread_get_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_port; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_mask_t exception_mask; + exception_behavior_t behavior; + thread_state_flavor_t new_flavor; + } __Request__thread_swap_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + boolean_t set_limit; + } __Request__thread_policy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + } __Request__thread_policy_set_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + thread_policy_flavor_t flavor; + mach_msg_type_number_t policy_infoCnt; + boolean_t get_default; + } __Request__thread_policy_get_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t reply; + /* end of the kernel processed data */ + } __Request__thread_sample_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + boolean_t trace_status; + } __Request__etap_trace_thread_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_set; + /* end of the kernel processed data */ + } __Request__thread_assign_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_assign_default_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + } __Request__thread_get_assignment_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t pset; + /* end of the kernel processed data */ + NDR_record_t NDR; + policy_t policy; + mach_msg_type_number_t baseCnt; + integer_t base[5]; + mach_msg_type_number_t limitCnt; + integer_t limit[1]; + } __Request__thread_set_policy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + mach_voucher_selector_t which; + } __Request__thread_get_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t voucher; + /* end of the kernel processed data */ + } __Request__thread_set_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t new_voucher; + mach_msg_port_descriptor_t old_voucher; + /* end of the kernel processed data */ + } __Request__thread_swap_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + int direction; + thread_state_flavor_t flavor; + mach_msg_type_number_t in_stateCnt; + natural_t in_state[1296]; + mach_msg_type_number_t out_stateCnt; + } __Request__thread_convert_thread_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif +#endif /* !__Request__thread_act_subsystem__defined */ + +/* union of all requests */ + +#ifndef __RequestUnion__thread_act_subsystem__defined +#define __RequestUnion__thread_act_subsystem__defined +union __RequestUnion__thread_act_subsystem { + __Request__thread_terminate_t Request_thread_terminate; + __Request__act_get_state_t Request_act_get_state; + __Request__act_set_state_t Request_act_set_state; + __Request__thread_get_state_t Request_thread_get_state; + __Request__thread_set_state_t Request_thread_set_state; + __Request__thread_suspend_t Request_thread_suspend; + __Request__thread_resume_t Request_thread_resume; + __Request__thread_abort_t Request_thread_abort; + __Request__thread_abort_safely_t Request_thread_abort_safely; + __Request__thread_depress_abort_t Request_thread_depress_abort; + __Request__thread_get_special_port_t Request_thread_get_special_port; + __Request__thread_set_special_port_t Request_thread_set_special_port; + __Request__thread_info_t Request_thread_info; + __Request__thread_set_exception_ports_t Request_thread_set_exception_ports; + __Request__thread_get_exception_ports_t Request_thread_get_exception_ports; + __Request__thread_swap_exception_ports_t Request_thread_swap_exception_ports; + __Request__thread_policy_t Request_thread_policy; + __Request__thread_policy_set_t Request_thread_policy_set; + __Request__thread_policy_get_t Request_thread_policy_get; + __Request__thread_sample_t Request_thread_sample; + __Request__etap_trace_thread_t Request_etap_trace_thread; + __Request__thread_assign_t Request_thread_assign; + __Request__thread_assign_default_t Request_thread_assign_default; + __Request__thread_get_assignment_t Request_thread_get_assignment; + __Request__thread_set_policy_t Request_thread_set_policy; + __Request__thread_get_mach_voucher_t Request_thread_get_mach_voucher; + __Request__thread_set_mach_voucher_t Request_thread_set_mach_voucher; + __Request__thread_swap_mach_voucher_t Request_thread_swap_mach_voucher; + __Request__thread_convert_thread_state_t Request_thread_convert_thread_state; +}; +#endif /* !__RequestUnion__thread_act_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__thread_act_subsystem__defined +#define __Reply__thread_act_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_terminate_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[1296]; + } __Reply__act_get_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__act_set_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[1296]; + } __Reply__thread_get_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_suspend_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_resume_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_abort_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_abort_safely_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_depress_abort_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t special_port; + /* end of the kernel processed data */ + } __Reply__thread_get_special_port_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_special_port_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t thread_info_outCnt; + integer_t thread_info_out[32]; + } __Reply__thread_info_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__thread_get_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_handlers[32]; + /* end of the kernel processed data */ + NDR_record_t NDR; + mach_msg_type_number_t masksCnt; + exception_mask_t masks[32]; + exception_behavior_t old_behaviors[32]; + thread_state_flavor_t old_flavors[32]; + } __Reply__thread_swap_exception_ports_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_policy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_policy_set_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t policy_infoCnt; + integer_t policy_info[16]; + boolean_t get_default; + } __Reply__thread_policy_get_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_sample_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__etap_trace_thread_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_assign_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_assign_default_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t assigned_set; + /* end of the kernel processed data */ + } __Reply__thread_get_assignment_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_policy_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t voucher; + /* end of the kernel processed data */ + } __Reply__thread_get_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__thread_set_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t old_voucher; + /* end of the kernel processed data */ + } __Reply__thread_swap_mach_voucher_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif + +#ifdef __MigPackStructs +#pragma pack(push, 4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + mach_msg_type_number_t out_stateCnt; + natural_t out_state[1296]; + } __Reply__thread_convert_thread_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack(pop) +#endif +#endif /* !__Reply__thread_act_subsystem__defined */ + +/* union of all replies */ + +#ifndef __ReplyUnion__thread_act_subsystem__defined +#define __ReplyUnion__thread_act_subsystem__defined +union __ReplyUnion__thread_act_subsystem { + __Reply__thread_terminate_t Reply_thread_terminate; + __Reply__act_get_state_t Reply_act_get_state; + __Reply__act_set_state_t Reply_act_set_state; + __Reply__thread_get_state_t Reply_thread_get_state; + __Reply__thread_set_state_t Reply_thread_set_state; + __Reply__thread_suspend_t Reply_thread_suspend; + __Reply__thread_resume_t Reply_thread_resume; + __Reply__thread_abort_t Reply_thread_abort; + __Reply__thread_abort_safely_t Reply_thread_abort_safely; + __Reply__thread_depress_abort_t Reply_thread_depress_abort; + __Reply__thread_get_special_port_t Reply_thread_get_special_port; + __Reply__thread_set_special_port_t Reply_thread_set_special_port; + __Reply__thread_info_t Reply_thread_info; + __Reply__thread_set_exception_ports_t Reply_thread_set_exception_ports; + __Reply__thread_get_exception_ports_t Reply_thread_get_exception_ports; + __Reply__thread_swap_exception_ports_t Reply_thread_swap_exception_ports; + __Reply__thread_policy_t Reply_thread_policy; + __Reply__thread_policy_set_t Reply_thread_policy_set; + __Reply__thread_policy_get_t Reply_thread_policy_get; + __Reply__thread_sample_t Reply_thread_sample; + __Reply__etap_trace_thread_t Reply_etap_trace_thread; + __Reply__thread_assign_t Reply_thread_assign; + __Reply__thread_assign_default_t Reply_thread_assign_default; + __Reply__thread_get_assignment_t Reply_thread_get_assignment; + __Reply__thread_set_policy_t Reply_thread_set_policy; + __Reply__thread_get_mach_voucher_t Reply_thread_get_mach_voucher; + __Reply__thread_set_mach_voucher_t Reply_thread_set_mach_voucher; + __Reply__thread_swap_mach_voucher_t Reply_thread_swap_mach_voucher; + __Reply__thread_convert_thread_state_t Reply_thread_convert_thread_state; +}; +#endif /* !__RequestUnion__thread_act_subsystem__defined */ + +#ifndef subsystem_to_name_map_thread_act +#define subsystem_to_name_map_thread_act \ + { "thread_terminate", 3600 },\ + { "act_get_state", 3601 },\ + { "act_set_state", 3602 },\ + { "thread_get_state", 3603 },\ + { "thread_set_state", 3604 },\ + { "thread_suspend", 3605 },\ + { "thread_resume", 3606 },\ + { "thread_abort", 3607 },\ + { "thread_abort_safely", 3608 },\ + { "thread_depress_abort", 3609 },\ + { "thread_get_special_port", 3610 },\ + { "thread_set_special_port", 3611 },\ + { "thread_info", 3612 },\ + { "thread_set_exception_ports", 3613 },\ + { "thread_get_exception_ports", 3614 },\ + { "thread_swap_exception_ports", 3615 },\ + { "thread_policy", 3616 },\ + { "thread_policy_set", 3617 },\ + { "thread_policy_get", 3618 },\ + { "thread_sample", 3619 },\ + { "etap_trace_thread", 3620 },\ + { "thread_assign", 3621 },\ + { "thread_assign_default", 3622 },\ + { "thread_get_assignment", 3623 },\ + { "thread_set_policy", 3624 },\ + { "thread_get_mach_voucher", 3625 },\ + { "thread_set_mach_voucher", 3626 },\ + { "thread_swap_mach_voucher", 3627 },\ + { "thread_convert_thread_state", 3628 } +#endif + +#ifdef __AfterMigUserHeader +__AfterMigUserHeader +#endif /* __AfterMigUserHeader */ + +#endif /* _thread_act_user_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/thread_special_ports.h b/lib/libc/include/aarch64-macos-gnu/mach/thread_special_ports.h new file mode 100644 index 0000000000..2e0e1a4a58 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/thread_special_ports.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * File: mach/thread_special_ports.h + * + * Defines codes for special_purpose thread ports. These are NOT + * port identifiers - they are only used for the thread_get_special_port + * and thread_set_special_port routines. + * + */ + +#ifndef _MACH_THREAD_SPECIAL_PORTS_H_ +#define _MACH_THREAD_SPECIAL_PORTS_H_ + +#define THREAD_KERNEL_PORT 1 /* The full thread port for thread. */ + +#define THREAD_INSPECT_PORT 2 /* The inspect port for thread. */ + +#define THREAD_READ_PORT 3 /* The read port for thread. */ + +/* + * Definitions for ease of use + */ + +#define thread_get_kernel_port(thread, port) \ + (thread_get_special_port((thread), THREAD_KERNEL_PORT, (port))) + +#define thread_set_kernel_port(thread, port) \ + (thread_set_special_port((thread), THREAD_KERNEL_PORT, (port))) + +#endif /* _MACH_THREAD_SPECIAL_PORTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/thread_status.h b/lib/libc/include/aarch64-macos-gnu/mach/thread_status.h new file mode 100644 index 0000000000..f742500cac --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/thread_status.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * File: mach/thread_status.h + * Author: Avadis Tevanian, Jr. + * + * This file contains the structure definitions for the user-visible + * thread state. This thread state is examined with the thread_get_state + * kernel call and may be changed with the thread_set_state kernel call. + * + */ + +#ifndef _MACH_THREAD_STATUS_H_ +#define _MACH_THREAD_STATUS_H_ + +/* + * The actual structure that comprises the thread state is defined + * in the machine dependent module. + */ +#include +#include +#include + +/* + * Generic definition for machine-dependent thread status. + */ + +typedef natural_t *thread_state_t; /* Variable-length array */ + +/* THREAD_STATE_MAX is now defined in */ +typedef natural_t thread_state_data_t[THREAD_STATE_MAX]; + +#define THREAD_STATE_FLAVOR_LIST 0 /* List of valid flavors */ +#define THREAD_STATE_FLAVOR_LIST_NEW 128 +#define THREAD_STATE_FLAVOR_LIST_10_9 129 +#define THREAD_STATE_FLAVOR_LIST_10_13 130 +#define THREAD_STATE_FLAVOR_LIST_10_15 131 + +typedef int thread_state_flavor_t; +typedef thread_state_flavor_t *thread_state_flavor_array_t; + +#define THREAD_CONVERT_THREAD_STATE_TO_SELF 1 +#define THREAD_CONVERT_THREAD_STATE_FROM_SELF 2 + +#endif /* _MACH_THREAD_STATUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/vm_prot.h b/lib/libc/include/aarch64-macos-gnu/mach/vm_prot.h new file mode 100644 index 0000000000..08916dfa2a --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/vm_prot.h @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * File: mach/vm_prot.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young + * + * Virtual memory protection definitions. + * + */ + +#ifndef _MACH_VM_PROT_H_ +#define _MACH_VM_PROT_H_ + +/* + * Types defined: + * + * vm_prot_t VM protection values. + */ + +typedef int vm_prot_t; + +/* + * Protection values, defined as bits within the vm_prot_t type + */ + +#define VM_PROT_NONE ((vm_prot_t) 0x00) + +#define VM_PROT_READ ((vm_prot_t) 0x01) /* read permission */ +#define VM_PROT_WRITE ((vm_prot_t) 0x02) /* write permission */ +#define VM_PROT_EXECUTE ((vm_prot_t) 0x04) /* execute permission */ + +/* + * The default protection for newly-created virtual memory + */ + +#define VM_PROT_DEFAULT (VM_PROT_READ|VM_PROT_WRITE) + +/* + * The maximum privileges possible, for parameter checking. + */ + +#define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) + +/* + * An invalid protection value. + * Used only by memory_object_lock_request to indicate no change + * to page locks. Using -1 here is a bad idea because it + * looks like VM_PROT_ALL and then some. + */ + +#define VM_PROT_NO_CHANGE ((vm_prot_t) 0x08) + +/* + * When a caller finds that he cannot obtain write permission on a + * mapped entry, the following flag can be used. The entry will + * be made "needs copy" effectively copying the object (using COW), + * and write permission will be added to the maximum protections + * for the associated entry. + */ + +#define VM_PROT_COPY ((vm_prot_t) 0x10) + + +/* + * Another invalid protection value. + * Used only by memory_object_data_request upon an object + * which has specified a copy_call copy strategy. It is used + * when the kernel wants a page belonging to a copy of the + * object, and is only asking the object as a result of + * following a shadow chain. This solves the race between pages + * being pushed up by the memory manager and the kernel + * walking down the shadow chain. + */ + +#define VM_PROT_WANTS_COPY ((vm_prot_t) 0x10) + + +/* + * Another invalid protection value. + * Indicates that the other protection bits are to be applied as a mask + * against the actual protection bits of the map entry. + */ +#define VM_PROT_IS_MASK ((vm_prot_t) 0x40) + +/* + * Another invalid protection value to support execute-only protection. + * VM_PROT_STRIP_READ is a special marker that tells mprotect to not + * set VM_PROT_READ. We have to do it this way because existing code + * expects the system to set VM_PROT_READ if VM_PROT_EXECUTE is set. + * VM_PROT_EXECUTE_ONLY is just a convenience value to indicate that + * the memory should be executable and explicitly not readable. It will + * be ignored on platforms that do not support this type of protection. + */ +#define VM_PROT_STRIP_READ ((vm_prot_t) 0x80) +#define VM_PROT_EXECUTE_ONLY (VM_PROT_EXECUTE|VM_PROT_STRIP_READ) + + +#endif /* _MACH_VM_PROT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/mach/vm_statistics.h b/lib/libc/include/aarch64-macos-gnu/mach/vm_statistics.h new file mode 100644 index 0000000000..05e09ec20b --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/mach/vm_statistics.h @@ -0,0 +1,550 @@ +/* + * Copyright (c) 2000-2020 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * @OSF_COPYRIGHT@ + */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + */ +/* + * File: mach/vm_statistics.h + * Author: Avadis Tevanian, Jr., Michael Wayne Young, David Golub + * + * Virtual memory statistics structure. + * + */ + +#ifndef _MACH_VM_STATISTICS_H_ +#define _MACH_VM_STATISTICS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* + * vm_statistics + * + * History: + * rev0 - original structure. + * rev1 - added purgable info (purgable_count and purges). + * rev2 - added speculative_count. + * + * Note: you cannot add any new fields to this structure. Add them below in + * vm_statistics64. + */ + +struct vm_statistics { + natural_t free_count; /* # of pages free */ + natural_t active_count; /* # of pages active */ + natural_t inactive_count; /* # of pages inactive */ + natural_t wire_count; /* # of pages wired down */ + natural_t zero_fill_count; /* # of zero fill pages */ + natural_t reactivations; /* # of pages reactivated */ + natural_t pageins; /* # of pageins */ + natural_t pageouts; /* # of pageouts */ + natural_t faults; /* # of faults */ + natural_t cow_faults; /* # of copy-on-writes */ + natural_t lookups; /* object cache lookups */ + natural_t hits; /* object cache hits */ + + /* added for rev1 */ + natural_t purgeable_count; /* # of pages purgeable */ + natural_t purges; /* # of pages purged */ + + /* added for rev2 */ + /* + * NB: speculative pages are already accounted for in "free_count", + * so "speculative_count" is the number of "free" pages that are + * used to hold data that was read speculatively from disk but + * haven't actually been used by anyone so far. + */ + natural_t speculative_count; /* # of pages speculative */ +}; + +/* Used by all architectures */ +typedef struct vm_statistics *vm_statistics_t; +typedef struct vm_statistics vm_statistics_data_t; + +/* + * vm_statistics64 + * + * History: + * rev0 - original structure. + * rev1 - added purgable info (purgable_count and purges). + * rev2 - added speculative_count. + * ---- + * rev3 - changed name to vm_statistics64. + * changed some fields in structure to 64-bit on + * arm, i386 and x86_64 architectures. + * rev4 - require 64-bit alignment for efficient access + * in the kernel. No change to reported data. + * + */ + +struct vm_statistics64 { + natural_t free_count; /* # of pages free */ + natural_t active_count; /* # of pages active */ + natural_t inactive_count; /* # of pages inactive */ + natural_t wire_count; /* # of pages wired down */ + uint64_t zero_fill_count; /* # of zero fill pages */ + uint64_t reactivations; /* # of pages reactivated */ + uint64_t pageins; /* # of pageins */ + uint64_t pageouts; /* # of pageouts */ + uint64_t faults; /* # of faults */ + uint64_t cow_faults; /* # of copy-on-writes */ + uint64_t lookups; /* object cache lookups */ + uint64_t hits; /* object cache hits */ + uint64_t purges; /* # of pages purged */ + natural_t purgeable_count; /* # of pages purgeable */ + /* + * NB: speculative pages are already accounted for in "free_count", + * so "speculative_count" is the number of "free" pages that are + * used to hold data that was read speculatively from disk but + * haven't actually been used by anyone so far. + */ + natural_t speculative_count; /* # of pages speculative */ + + /* added for rev1 */ + uint64_t decompressions; /* # of pages decompressed */ + uint64_t compressions; /* # of pages compressed */ + uint64_t swapins; /* # of pages swapped in (via compression segments) */ + uint64_t swapouts; /* # of pages swapped out (via compression segments) */ + natural_t compressor_page_count; /* # of pages used by the compressed pager to hold all the compressed data */ + natural_t throttled_count; /* # of pages throttled */ + natural_t external_page_count; /* # of pages that are file-backed (non-swap) */ + natural_t internal_page_count; /* # of pages that are anonymous */ + uint64_t total_uncompressed_pages_in_compressor; /* # of pages (uncompressed) held within the compressor. */ +} __attribute__((aligned(8))); + +typedef struct vm_statistics64 *vm_statistics64_t; +typedef struct vm_statistics64 vm_statistics64_data_t; + +kern_return_t vm_stats(void *info, unsigned int *count); + +/* + * VM_STATISTICS_TRUNCATE_TO_32_BIT + * + * This is used by host_statistics() to truncate and peg the 64-bit in-kernel values from + * vm_statistics64 to the 32-bit values of the older structure above (vm_statistics). + */ +#define VM_STATISTICS_TRUNCATE_TO_32_BIT(value) ((uint32_t)(((value) > UINT32_MAX ) ? UINT32_MAX : (value))) + +/* + * vm_extmod_statistics + * + * Structure to record modifications to a task by an + * external agent. + * + * History: + * rev0 - original structure. + */ + +struct vm_extmod_statistics { + int64_t task_for_pid_count; /* # of times task port was looked up */ + int64_t task_for_pid_caller_count; /* # of times this task called task_for_pid */ + int64_t thread_creation_count; /* # of threads created in task */ + int64_t thread_creation_caller_count; /* # of threads created by task */ + int64_t thread_set_state_count; /* # of register state sets in task */ + int64_t thread_set_state_caller_count; /* # of register state sets by task */ +} __attribute__((aligned(8))); + +typedef struct vm_extmod_statistics *vm_extmod_statistics_t; +typedef struct vm_extmod_statistics vm_extmod_statistics_data_t; + +typedef struct vm_purgeable_stat { + uint64_t count; + uint64_t size; +}vm_purgeable_stat_t; + +struct vm_purgeable_info { + vm_purgeable_stat_t fifo_data[8]; + vm_purgeable_stat_t obsolete_data; + vm_purgeable_stat_t lifo_data[8]; +}; + +typedef struct vm_purgeable_info *vm_purgeable_info_t; + +/* included for the vm_map_page_query call */ + +#define VM_PAGE_QUERY_PAGE_PRESENT 0x1 +#define VM_PAGE_QUERY_PAGE_FICTITIOUS 0x2 +#define VM_PAGE_QUERY_PAGE_REF 0x4 +#define VM_PAGE_QUERY_PAGE_DIRTY 0x8 +#define VM_PAGE_QUERY_PAGE_PAGED_OUT 0x10 +#define VM_PAGE_QUERY_PAGE_COPIED 0x20 +#define VM_PAGE_QUERY_PAGE_SPECULATIVE 0x40 +#define VM_PAGE_QUERY_PAGE_EXTERNAL 0x80 +#define VM_PAGE_QUERY_PAGE_CS_VALIDATED 0x100 +#define VM_PAGE_QUERY_PAGE_CS_TAINTED 0x200 +#define VM_PAGE_QUERY_PAGE_CS_NX 0x400 +#define VM_PAGE_QUERY_PAGE_REUSABLE 0x800 + + +/* + * VM allocation flags: + * + * VM_FLAGS_FIXED + * (really the absence of VM_FLAGS_ANYWHERE) + * Allocate new VM region at the specified virtual address, if possible. + * + * VM_FLAGS_ANYWHERE + * Allocate new VM region anywhere it would fit in the address space. + * + * VM_FLAGS_PURGABLE + * Create a purgable VM object for that new VM region. + * + * VM_FLAGS_4GB_CHUNK + * The new VM region will be chunked up into 4GB sized pieces. + * + * VM_FLAGS_NO_PMAP_CHECK + * (for DEBUG kernel config only, ignored for other configs) + * Do not check that there is no stale pmap mapping for the new VM region. + * This is useful for kernel memory allocations at bootstrap when building + * the initial kernel address space while some memory is already in use. + * + * VM_FLAGS_OVERWRITE + * The new VM region can replace existing VM regions if necessary + * (to be used in combination with VM_FLAGS_FIXED). + * + * VM_FLAGS_NO_CACHE + * Pages brought in to this VM region are placed on the speculative + * queue instead of the active queue. In other words, they are not + * cached so that they will be stolen first if memory runs low. + */ + +#define VM_FLAGS_FIXED 0x0000 +#define VM_FLAGS_ANYWHERE 0x0001 +#define VM_FLAGS_PURGABLE 0x0002 +#define VM_FLAGS_4GB_CHUNK 0x0004 +#define VM_FLAGS_RANDOM_ADDR 0x0008 +#define VM_FLAGS_NO_CACHE 0x0010 +#define VM_FLAGS_RESILIENT_CODESIGN 0x0020 +#define VM_FLAGS_RESILIENT_MEDIA 0x0040 +#define VM_FLAGS_OVERWRITE 0x4000 /* delete any existing mappings first */ +/* + * VM_FLAGS_SUPERPAGE_MASK + * 3 bits that specify whether large pages should be used instead of + * base pages (!=0), as well as the requested page size. + */ +#define VM_FLAGS_SUPERPAGE_MASK 0x70000 /* bits 0x10000, 0x20000, 0x40000 */ +#define VM_FLAGS_RETURN_DATA_ADDR 0x100000 /* Return address of target data, rather than base of page */ +#define VM_FLAGS_RETURN_4K_DATA_ADDR 0x800000 /* Return 4K aligned address of target data */ +#define VM_FLAGS_ALIAS_MASK 0xFF000000 +#define VM_GET_FLAGS_ALIAS(flags, alias) \ + (alias) = ((flags) & VM_FLAGS_ALIAS_MASK) >> 24 +#define VM_SET_FLAGS_ALIAS(flags, alias) \ + (flags) = (((flags) & ~VM_FLAGS_ALIAS_MASK) | \ + (((alias) & ~VM_FLAGS_ALIAS_MASK) << 24)) + +/* These are the flags that we accept from user-space */ +#define VM_FLAGS_USER_ALLOCATE (VM_FLAGS_FIXED | \ + VM_FLAGS_ANYWHERE | \ + VM_FLAGS_PURGABLE | \ + VM_FLAGS_4GB_CHUNK | \ + VM_FLAGS_RANDOM_ADDR | \ + VM_FLAGS_NO_CACHE | \ + VM_FLAGS_OVERWRITE | \ + VM_FLAGS_SUPERPAGE_MASK | \ + VM_FLAGS_ALIAS_MASK) +#define VM_FLAGS_USER_MAP (VM_FLAGS_USER_ALLOCATE | \ + VM_FLAGS_RETURN_4K_DATA_ADDR | \ + VM_FLAGS_RETURN_DATA_ADDR) +#define VM_FLAGS_USER_REMAP (VM_FLAGS_FIXED | \ + VM_FLAGS_ANYWHERE | \ + VM_FLAGS_RANDOM_ADDR | \ + VM_FLAGS_OVERWRITE| \ + VM_FLAGS_RETURN_DATA_ADDR | \ + VM_FLAGS_RESILIENT_CODESIGN | \ + VM_FLAGS_RESILIENT_MEDIA) + +#define VM_FLAGS_SUPERPAGE_SHIFT 16 +#define SUPERPAGE_NONE 0 /* no superpages, if all bits are 0 */ +#define SUPERPAGE_SIZE_ANY 1 +#define VM_FLAGS_SUPERPAGE_NONE (SUPERPAGE_NONE << VM_FLAGS_SUPERPAGE_SHIFT) +#define VM_FLAGS_SUPERPAGE_SIZE_ANY (SUPERPAGE_SIZE_ANY << VM_FLAGS_SUPERPAGE_SHIFT) +#define SUPERPAGE_SIZE_2MB 2 +#define VM_FLAGS_SUPERPAGE_SIZE_2MB (SUPERPAGE_SIZE_2MB< +#include + +#include + +typedef vm_offset_t pointer_t; +typedef vm_offset_t vm_address_t; + +/* + * We use addr64_t for 64-bit addresses that are used on both + * 32 and 64-bit machines. On PPC, they are passed and returned as + * two adjacent 32-bit GPRs. We use addr64_t in places where + * common code must be useable both on 32 and 64-bit machines. + */ +typedef uint64_t addr64_t; /* Basic effective address */ + +/* + * We use reg64_t for addresses that are 32 bits on a 32-bit + * machine, and 64 bits on a 64-bit machine, but are always + * passed and returned in a single GPR on PPC. This type + * cannot be used in generic 32-bit c, since on a 64-bit + * machine the upper half of the register will be ignored + * by the c compiler in 32-bit mode. In c, we can only use the + * type in prototypes of functions that are written in and called + * from assembly language. This type is basically a comment. + */ +typedef uint32_t reg64_t; + +/* + * To minimize the use of 64-bit fields, we keep some physical + * addresses (that are page aligned) as 32-bit page numbers. + * This limits the physical address space to 16TB of RAM. + */ +typedef uint32_t ppnum_t; /* Physical page number */ +#define PPNUM_MAX UINT32_MAX + + + +typedef mach_port_t vm_map_t, vm_map_read_t, vm_map_inspect_t; + + +#define VM_MAP_NULL ((vm_map_t) 0) +#define VM_MAP_INSPECT_NULL ((vm_map_inspect_t) 0) +#define VM_MAP_READ_NULL ((vm_map_read_t) 0) + +/* + * Evolving definitions, likely to change. + */ + +typedef uint64_t vm_object_offset_t; +typedef uint64_t vm_object_size_t; + + + + +typedef mach_port_t upl_t; +typedef mach_port_t vm_named_entry_t; + + +#define UPL_NULL ((upl_t) 0) +#define VM_NAMED_ENTRY_NULL ((vm_named_entry_t) 0) + +#endif /* _MACH_VM_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/machine/_mcontext.h b/lib/libc/include/aarch64-macos-gnu/machine/_mcontext.h new file mode 100644 index 0000000000..12965510fa --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/machine/_mcontext.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#if defined (__i386__) || defined (__x86_64__) +#include "i386/_mcontext.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/_mcontext.h" +#else +#error architecture not supported +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/machine/_param.h b/lib/libc/include/aarch64-macos-gnu/machine/_param.h new file mode 100644 index 0000000000..5fdf54345f --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/machine/_param.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2004-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#if defined (__i386__) || defined (__x86_64__) +#include +#elif defined (__arm__) || defined (__arm64__) +#include +#else +#error architecture not supported +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/machine/_types.h b/lib/libc/include/aarch64-macos-gnu/machine/_types.h new file mode 100644 index 0000000000..6e38e3a253 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/machine/_types.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2003-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _BSD_MACHINE__TYPES_H_ +#define _BSD_MACHINE__TYPES_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "i386/_types.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/_types.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE__TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/machine/endian.h b/lib/libc/include/aarch64-macos-gnu/machine/endian.h new file mode 100644 index 0000000000..39758c04d2 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/machine/endian.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright 1995 NeXT Computer, Inc. All rights reserved. + */ +#ifndef _BSD_MACHINE_ENDIAN_H_ +#define _BSD_MACHINE_ENDIAN_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "i386/endian.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/endian.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_ENDIAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/machine/limits.h b/lib/libc/include/aarch64-macos-gnu/machine/limits.h new file mode 100644 index 0000000000..7523f8806d --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/machine/limits.h @@ -0,0 +1,11 @@ +/* This is the `system' limits.h, independent of any particular + * compiler. GCC provides its own limits.h which can be found in + * /usr/lib/gcc, although it is not very informative. + * This file is public domain. */ +#if defined (__i386__) || defined(__x86_64__) +#include +#elif defined (__arm__) || defined (__arm64__) +#include +#else +#error architecture not supported +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/machine/param.h b/lib/libc/include/aarch64-macos-gnu/machine/param.h new file mode 100644 index 0000000000..ccfeff4398 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/machine/param.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright 1995 NeXT Computer, Inc. All rights reserved. + */ +#ifndef _BSD_MACHINE_PARAM_H_ +#define _BSD_MACHINE_PARAM_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include +#elif defined (__arm__) || defined (__arm64__) +#include +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/machine/signal.h b/lib/libc/include/aarch64-macos-gnu/machine/signal.h new file mode 100644 index 0000000000..2f33966bf1 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/machine/signal.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _BSD_MACHINE_SIGNAL_H_ +#define _BSD_MACHINE_SIGNAL_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "i386/signal.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/signal.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/machine/types.h b/lib/libc/include/aarch64-macos-gnu/machine/types.h new file mode 100644 index 0000000000..a4c80b820f --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/machine/types.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2000-2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright 1995 NeXT Computer, Inc. All rights reserved. + */ +#ifndef _BSD_MACHINE_TYPES_H_ +#define _BSD_MACHINE_TYPES_H_ + +#if defined (__i386__) || defined(__x86_64__) +#include "i386/types.h" +#elif defined (__arm__) || defined (__arm64__) +#include "arm/types.h" +#else +#error architecture not supported +#endif + +#endif /* _BSD_MACHINE_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/malloc/_malloc.h b/lib/libc/include/aarch64-macos-gnu/malloc/_malloc.h new file mode 100644 index 0000000000..2c49d73458 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/malloc/_malloc.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018 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 _MALLOC_UNDERSCORE_MALLOC_H_ +#define _MALLOC_UNDERSCORE_MALLOC_H_ + +/* + * This header is included from , so the contents of this file have + * broad source compatibility and POSIX conformance implications. + * Be cautious about what is included and declared here. + */ + +#include +#include +#include <_types.h> +#include + +__BEGIN_DECLS + +void *malloc(size_t __size) __result_use_check __alloc_size(1); +void *calloc(size_t __count, size_t __size) __result_use_check __alloc_size(1,2); +void free(void *); +void *realloc(void *__ptr, size_t __size) __result_use_check __alloc_size(2); +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +void *valloc(size_t) __alloc_size(1); +#endif // !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#if (__DARWIN_C_LEVEL >= __DARWIN_C_FULL) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + (defined(__cplusplus) && __cplusplus >= 201703L) +void *aligned_alloc(size_t __alignment, size_t __size) __result_use_check __alloc_size(2) __OSX_AVAILABLE(10.15) __IOS_AVAILABLE(13.0) __TVOS_AVAILABLE(13.0) __WATCHOS_AVAILABLE(6.0); +#endif +int posix_memalign(void **__memptr, size_t __alignment, size_t __size) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0); + +__END_DECLS + +#endif /* _MALLOC_UNDERSCORE_MALLOC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/malloc/malloc.h b/lib/libc/include/aarch64-macos-gnu/malloc/malloc.h new file mode 100644 index 0000000000..33013ccc54 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/malloc/malloc.h @@ -0,0 +1,314 @@ +/* + * 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 _MALLOC_MALLOC_H_ +#define _MALLOC_MALLOC_H_ + +#include +#include +#include +#include + +#if __has_feature(ptrauth_calls) +#include + +// Zone function pointer, type-diversified but not address-diversified (because +// the zone can be copied). Process-independent because the zone structure may +// be in the shared library cache. +#define MALLOC_ZONE_FN_PTR(fn) __ptrauth(ptrauth_key_process_independent_code, \ + FALSE, ptrauth_string_discriminator("malloc_zone_fn." #fn)) fn + +// Introspection function pointer, address- and type-diversified. +// Process-independent because the malloc_introspection_t structure that contains +// these pointers may be in the shared library cache. +#define MALLOC_INTROSPECT_FN_PTR(fn) __ptrauth(ptrauth_key_process_independent_code, \ + TRUE, ptrauth_string_discriminator("malloc_introspect_fn." #fn)) fn + +// Pointer to the introspection pointer table, type-diversified but not +// address-diversified (because the zone can be copied). +// Process-independent because the table pointer may be in the shared library cache. +#define MALLOC_INTROSPECT_TBL_PTR(ptr) __ptrauth(ptrauth_key_process_independent_data,\ + FALSE, ptrauth_string_discriminator("malloc_introspect_tbl")) ptr + +#endif // __has_feature(ptrauth_calls) + +#ifndef MALLOC_ZONE_FN_PTR +#define MALLOC_ZONE_FN_PTR(fn) fn +#define MALLOC_INTROSPECT_FN_PTR(fn) fn +#define MALLOC_INTROSPECT_TBL_PTR(ptr) ptr +#endif // MALLOC_ZONE_FN_PTR + +__BEGIN_DECLS +/********* Type definitions ************/ + +typedef struct _malloc_zone_t { + /* Only zone implementors should depend on the layout of this structure; + Regular callers should use the access functions below */ + void *reserved1; /* RESERVED FOR CFAllocator DO NOT USE */ + void *reserved2; /* RESERVED FOR CFAllocator DO NOT USE */ + size_t (* MALLOC_ZONE_FN_PTR(size))(struct _malloc_zone_t *zone, const void *ptr); /* returns the size of a block or 0 if not in this zone; must be fast, especially for negative answers */ + void *(* MALLOC_ZONE_FN_PTR(malloc))(struct _malloc_zone_t *zone, size_t size); + void *(* MALLOC_ZONE_FN_PTR(calloc))(struct _malloc_zone_t *zone, size_t num_items, size_t size); /* same as malloc, but block returned is set to zero */ + void *(* MALLOC_ZONE_FN_PTR(valloc))(struct _malloc_zone_t *zone, size_t size); /* same as malloc, but block returned is set to zero and is guaranteed to be page aligned */ + void (* MALLOC_ZONE_FN_PTR(free))(struct _malloc_zone_t *zone, void *ptr); + void *(* MALLOC_ZONE_FN_PTR(realloc))(struct _malloc_zone_t *zone, void *ptr, size_t size); + void (* MALLOC_ZONE_FN_PTR(destroy))(struct _malloc_zone_t *zone); /* zone is destroyed and all memory reclaimed */ + const char *zone_name; + + /* Optional batch callbacks; these may be NULL */ + unsigned (* MALLOC_ZONE_FN_PTR(batch_malloc))(struct _malloc_zone_t *zone, size_t size, void **results, unsigned num_requested); /* given a size, returns pointers capable of holding that size; returns the number of pointers allocated (maybe 0 or less than num_requested) */ + void (* MALLOC_ZONE_FN_PTR(batch_free))(struct _malloc_zone_t *zone, void **to_be_freed, unsigned num_to_be_freed); /* frees all the pointers in to_be_freed; note that to_be_freed may be overwritten during the process */ + + struct malloc_introspection_t * MALLOC_INTROSPECT_TBL_PTR(introspect); + unsigned version; + + /* aligned memory allocation. The callback may be NULL. Present in version >= 5. */ + void *(* MALLOC_ZONE_FN_PTR(memalign))(struct _malloc_zone_t *zone, size_t alignment, size_t size); + + /* free a pointer known to be in zone and known to have the given size. The callback may be NULL. Present in version >= 6.*/ + void (* MALLOC_ZONE_FN_PTR(free_definite_size))(struct _malloc_zone_t *zone, void *ptr, size_t size); + + /* Empty out caches in the face of memory pressure. The callback may be NULL. Present in version >= 8. */ + size_t (* MALLOC_ZONE_FN_PTR(pressure_relief))(struct _malloc_zone_t *zone, size_t goal); + + /* + * Checks whether an address might belong to the zone. May be NULL. Present in version >= 10. + * False positives are allowed (e.g. the pointer was freed, or it's in zone space that has + * not yet been allocated. False negatives are not allowed. + */ + boolean_t (* MALLOC_ZONE_FN_PTR(claimed_address))(struct _malloc_zone_t *zone, void *ptr); +} malloc_zone_t; + +/********* Creation and destruction ************/ + +extern malloc_zone_t *malloc_default_zone(void); + /* The initial zone */ + +extern malloc_zone_t *malloc_create_zone(vm_size_t start_size, unsigned flags); + /* Creates a new zone with default behavior and registers it */ + +extern void malloc_destroy_zone(malloc_zone_t *zone); + /* Destroys zone and everything it allocated */ + +/********* Block creation and manipulation ************/ + +extern void *malloc_zone_malloc(malloc_zone_t *zone, size_t size) __alloc_size(2); + /* Allocates a new pointer of size size; zone must be non-NULL */ + +extern void *malloc_zone_calloc(malloc_zone_t *zone, size_t num_items, size_t size) __alloc_size(2,3); + /* Allocates a new pointer of size num_items * size; block is cleared; zone must be non-NULL */ + +extern void *malloc_zone_valloc(malloc_zone_t *zone, size_t size) __alloc_size(2); + /* Allocates a new pointer of size size; zone must be non-NULL; Pointer is guaranteed to be page-aligned and block is cleared */ + +extern void malloc_zone_free(malloc_zone_t *zone, void *ptr); + /* Frees pointer in zone; zone must be non-NULL */ + +extern void *malloc_zone_realloc(malloc_zone_t *zone, void *ptr, size_t size) __alloc_size(3); + /* Enlarges block if necessary; zone must be non-NULL */ + +extern malloc_zone_t *malloc_zone_from_ptr(const void *ptr); + /* Returns the zone for a pointer, or NULL if not in any zone. + The ptr must have been returned from a malloc or realloc call. */ + +extern size_t malloc_size(const void *ptr); + /* Returns size of given ptr */ + +extern size_t malloc_good_size(size_t size); + /* Returns number of bytes greater than or equal to size that can be allocated without padding */ + +extern void *malloc_zone_memalign(malloc_zone_t *zone, size_t alignment, size_t size) __alloc_size(3) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0); + /* + * Allocates a new pointer of size size whose address is an exact multiple of alignment. + * alignment must be a power of two and at least as large as sizeof(void *). + * zone must be non-NULL. + */ + +/********* Batch methods ************/ + +extern unsigned malloc_zone_batch_malloc(malloc_zone_t *zone, size_t size, void **results, unsigned num_requested); + /* Allocates num blocks of the same size; Returns the number truly allocated (may be 0) */ + +extern void malloc_zone_batch_free(malloc_zone_t *zone, void **to_be_freed, unsigned num); + /* frees all the pointers in to_be_freed; note that to_be_freed may be overwritten during the process; This function will always free even if the zone has no batch callback */ + +/********* Functions for libcache ************/ + +extern malloc_zone_t *malloc_default_purgeable_zone(void) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0); + /* Returns a pointer to the default purgeable_zone. */ + +extern void malloc_make_purgeable(void *ptr) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0); + /* Make an allocation from the purgeable zone purgeable if possible. */ + +extern int malloc_make_nonpurgeable(void *ptr) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0); + /* Makes an allocation from the purgeable zone nonpurgeable. + * Returns zero if the contents were not purged since the last + * call to malloc_make_purgeable, else returns non-zero. */ + +/********* Functions for zone implementors ************/ + +extern void malloc_zone_register(malloc_zone_t *zone); + /* Registers a custom malloc zone; Should typically be called after a + * malloc_zone_t has been filled in with custom methods by a client. See + * malloc_create_zone for creating additional malloc zones with the + * default allocation and free behavior. */ + +extern void malloc_zone_unregister(malloc_zone_t *zone); + /* De-registers a zone + Should typically be called before calling the zone destruction routine */ + +extern void malloc_set_zone_name(malloc_zone_t *zone, const char *name); + /* Sets the name of a zone */ + +extern const char *malloc_get_zone_name(malloc_zone_t *zone); + /* Returns the name of a zone */ + +size_t malloc_zone_pressure_relief(malloc_zone_t *zone, size_t goal) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); + /* malloc_zone_pressure_relief() advises the malloc subsystem that the process is under memory pressure and + * that the subsystem should make its best effort towards releasing (i.e. munmap()-ing) "goal" bytes from "zone". + * If "goal" is passed as zero, the malloc subsystem will attempt to achieve maximal pressure relief in "zone". + * If "zone" is passed as NULL, all zones are examined for pressure relief opportunities. + * malloc_zone_pressure_relief() returns the number of bytes released. + */ + +typedef struct { + vm_address_t address; + vm_size_t size; +} vm_range_t; + +typedef struct malloc_statistics_t { + unsigned blocks_in_use; + size_t size_in_use; + size_t max_size_in_use; /* high water mark of touched memory */ + size_t size_allocated; /* reserved in memory */ +} malloc_statistics_t; + +typedef kern_return_t memory_reader_t(task_t remote_task, vm_address_t remote_address, vm_size_t size, void **local_memory); + /* given a task, "reads" the memory at the given address and size +local_memory: set to a contiguous chunk of memory; validity of local_memory is assumed to be limited (until next call) */ + +#define MALLOC_PTR_IN_USE_RANGE_TYPE 1 /* for allocated pointers */ +#define MALLOC_PTR_REGION_RANGE_TYPE 2 /* for region containing pointers */ +#define MALLOC_ADMIN_REGION_RANGE_TYPE 4 /* for region used internally */ +#define MALLOC_ZONE_SPECIFIC_FLAGS 0xff00 /* bits reserved for zone-specific purposes */ + +typedef void vm_range_recorder_t(task_t, void *, unsigned type, vm_range_t *, unsigned); + /* given a task and context, "records" the specified addresses */ + +/* Print function for the print_task() operation. */ +typedef void print_task_printer_t(const char *fmt, ...) __printflike(1,2); + +typedef struct malloc_introspection_t { + kern_return_t (* MALLOC_INTROSPECT_FN_PTR(enumerator))(task_t task, void *, unsigned type_mask, vm_address_t zone_address, memory_reader_t reader, vm_range_recorder_t recorder); /* enumerates all the malloc pointers in use */ + size_t (* MALLOC_INTROSPECT_FN_PTR(good_size))(malloc_zone_t *zone, size_t size); + boolean_t (* MALLOC_INTROSPECT_FN_PTR(check))(malloc_zone_t *zone); /* Consistency checker */ + void (* MALLOC_INTROSPECT_FN_PTR(print))(malloc_zone_t *zone, boolean_t verbose); /* Prints zone */ + void (* MALLOC_INTROSPECT_FN_PTR(log))(malloc_zone_t *zone, void *address); /* Enables logging of activity */ + void (* MALLOC_INTROSPECT_FN_PTR(force_lock))(malloc_zone_t *zone); /* Forces locking zone */ + void (* MALLOC_INTROSPECT_FN_PTR(force_unlock))(malloc_zone_t *zone); /* Forces unlocking zone */ + void (* MALLOC_INTROSPECT_FN_PTR(statistics))(malloc_zone_t *zone, malloc_statistics_t *stats); /* Fills statistics */ + boolean_t (* MALLOC_INTROSPECT_FN_PTR(zone_locked))(malloc_zone_t *zone); /* Are any zone locks held */ + + /* Discharge checking. Present in version >= 7. */ + boolean_t (* MALLOC_INTROSPECT_FN_PTR(enable_discharge_checking))(malloc_zone_t *zone); + void (* MALLOC_INTROSPECT_FN_PTR(disable_discharge_checking))(malloc_zone_t *zone); + void (* MALLOC_INTROSPECT_FN_PTR(discharge))(malloc_zone_t *zone, void *memory); +#ifdef __BLOCKS__ + void (* MALLOC_INTROSPECT_FN_PTR(enumerate_discharged_pointers))(malloc_zone_t *zone, void (^report_discharged)(void *memory, void *info)); + #else + void *enumerate_unavailable_without_blocks; +#endif /* __BLOCKS__ */ + void (* MALLOC_INTROSPECT_FN_PTR(reinit_lock))(malloc_zone_t *zone); /* Reinitialize zone locks, called only from atfork_child handler. Present in version >= 9. */ + void (* MALLOC_INTROSPECT_FN_PTR(print_task))(task_t task, unsigned level, vm_address_t zone_address, memory_reader_t reader, print_task_printer_t printer); /* debug print for another process. Present in version >= 11. */ + void (* MALLOC_INTROSPECT_FN_PTR(task_statistics))(task_t task, vm_address_t zone_address, memory_reader_t reader, malloc_statistics_t *stats); /* Present in version >= 12 */ +} malloc_introspection_t; + +// The value of "level" when passed to print_task() that corresponds to +// verbose passed to print() +#define MALLOC_VERBOSE_PRINT_LEVEL 2 + +extern void malloc_printf(const char *format, ...); + /* Convenience for logging errors and warnings; + No allocation is performed during execution of this function; + Only understands usual %p %d %s formats, and %y that expresses a number of bytes (5b,10KB,1MB...) + */ + +/********* Functions for performance tools ************/ + +extern kern_return_t malloc_get_all_zones(task_t task, memory_reader_t reader, vm_address_t **addresses, unsigned *count); + /* Fills addresses and count with the addresses of the zones in task; + Note that the validity of the addresses returned correspond to the validity of the memory returned by reader */ + +/********* Debug helpers ************/ + +extern void malloc_zone_print_ptr_info(void *ptr); + /* print to stdout if this pointer is in the malloc heap, free status, and size */ + +extern boolean_t malloc_zone_check(malloc_zone_t *zone); + /* Checks zone is well formed; if !zone, checks all zones */ + +extern void malloc_zone_print(malloc_zone_t *zone, boolean_t verbose); + /* Prints summary on zone; if !zone, prints all zones */ + +extern void malloc_zone_statistics(malloc_zone_t *zone, malloc_statistics_t *stats); + /* Fills statistics for zone; if !zone, sums up all zones */ + +extern void malloc_zone_log(malloc_zone_t *zone, void *address); + /* Controls logging of all activity; if !zone, for all zones; + If address==0 nothing is logged; + If address==-1 all activity is logged; + Else only the activity regarding address is logged */ + +struct mstats { + size_t bytes_total; + size_t chunks_used; + size_t bytes_used; + size_t chunks_free; + size_t bytes_free; +}; + +extern struct mstats mstats(void); + +extern boolean_t malloc_zone_enable_discharge_checking(malloc_zone_t *zone) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +/* Increment the discharge checking enabled counter for a zone. Returns true if the zone supports checking, false if it does not. */ + +extern void malloc_zone_disable_discharge_checking(malloc_zone_t *zone) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +/* Decrement the discharge checking enabled counter for a zone. */ + +extern void malloc_zone_discharge(malloc_zone_t *zone, void *memory) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +/* Register memory that the programmer expects to be freed soon. + zone may be NULL in which case the zone is determined using malloc_zone_from_ptr(). + If discharge checking is off for the zone this function is a no-op. */ + +#ifdef __BLOCKS__ +extern void malloc_zone_enumerate_discharged_pointers(malloc_zone_t *zone, void (^report_discharged)(void *memory, void *info)) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +/* Calls report_discharged for each block that was registered using malloc_zone_discharge() but has not yet been freed. + info is used to provide zone defined information about the memory block. + If zone is NULL then the enumeration covers all zones. */ +#else +extern void malloc_zone_enumerate_discharged_pointers(malloc_zone_t *zone, void *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +#endif /* __BLOCKS__ */ + +__END_DECLS + +#endif /* _MALLOC_MALLOC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/math.h b/lib/libc/include/aarch64-macos-gnu/math.h new file mode 100644 index 0000000000..f3d6d6dbb4 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/math.h @@ -0,0 +1,775 @@ +/* + * Copyright (c) 2002-2017 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef __MATH_H__ +#define __MATH_H__ + +#ifndef __MATH__ +#define __MATH__ +#endif + +#include +#include + +__BEGIN_DECLS + +/****************************************************************************** + * Floating point data types * + ******************************************************************************/ + +/* Define float_t and double_t per C standard, ISO/IEC 9899:2011 7.12 2, + taking advantage of GCC's __FLT_EVAL_METHOD__ (which a compiler may + define anytime and GCC does) that shadows FLT_EVAL_METHOD (which a + compiler must define only in float.h). */ +#if __FLT_EVAL_METHOD__ == 0 + typedef float float_t; + typedef double double_t; +#elif __FLT_EVAL_METHOD__ == 1 + typedef double float_t; + typedef double double_t; +#elif __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ == -1 + typedef long double float_t; + typedef long double double_t; +#else /* __FLT_EVAL_METHOD__ */ +# error "Unsupported value of __FLT_EVAL_METHOD__." +#endif /* __FLT_EVAL_METHOD__ */ + +#if defined(__GNUC__) +# define HUGE_VAL __builtin_huge_val() +# define HUGE_VALF __builtin_huge_valf() +# define HUGE_VALL __builtin_huge_vall() +# define NAN __builtin_nanf("0x7fc00000") +#else +# define HUGE_VAL 1e500 +# define HUGE_VALF 1e50f +# define HUGE_VALL 1e5000L +# define NAN __nan() +#endif + +#define INFINITY HUGE_VALF + +/****************************************************************************** + * Taxonomy of floating point data types * + ******************************************************************************/ + +#define FP_NAN 1 +#define FP_INFINITE 2 +#define FP_ZERO 3 +#define FP_NORMAL 4 +#define FP_SUBNORMAL 5 +#define FP_SUPERNORMAL 6 /* legacy PowerPC support; this is otherwise unused */ + +#if defined __arm64__ || defined __ARM_VFPV4__ +/* On these architectures, fma(), fmaf( ), and fmal( ) are generally about as + fast as (or faster than) separate multiply and add of the same operands. */ +# define FP_FAST_FMA 1 +# define FP_FAST_FMAF 1 +# define FP_FAST_FMAL 1 +#elif (defined __i386__ || defined __x86_64__) && (defined __FMA__ || defined __AVX512F__) +/* When targeting the FMA ISA extension, fma() and fmaf( ) are generally + about as fast as (or faster than) separate multiply and add of the same + operands, but fmal( ) may be more costly. */ +# define FP_FAST_FMA 1 +# define FP_FAST_FMAF 1 +# undef FP_FAST_FMAL +#else +/* On these architectures, fma( ), fmaf( ), and fmal( ) function calls are + significantly more costly than separate multiply and add operations. */ +# undef FP_FAST_FMA +# undef FP_FAST_FMAF +# undef FP_FAST_FMAL +#endif + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +#define FP_ILOGB0 (-2147483647 - 1) +#define FP_ILOGBNAN (-2147483647 - 1) + +/* Bitmasks for the math_errhandling macro. */ +#define MATH_ERRNO 1 /* errno set by math functions. */ +#define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */ + +#define math_errhandling (__math_errhandling()) +extern int __math_errhandling(void); + +/****************************************************************************** + * * + * Inquiry macros * + * * + * fpclassify Returns one of the FP_* values. * + * isnormal Non-zero if and only if the argument x is normalized. * + * isfinite Non-zero if and only if the argument x is finite. * + * isnan Non-zero if and only if the argument x is a NaN. * + * signbit Non-zero if and only if the sign of the argument x is * + * negative. This includes, NaNs, infinities and zeros. * + * * + ******************************************************************************/ + +#define fpclassify(x) \ + ( sizeof(x) == sizeof(float) ? __fpclassifyf((float)(x)) \ + : sizeof(x) == sizeof(double) ? __fpclassifyd((double)(x)) \ + : __fpclassifyl((long double)(x))) + +extern int __fpclassifyf(float); +extern int __fpclassifyd(double); +extern int __fpclassifyl(long double); + +#if (defined(__GNUC__) && 0 == __FINITE_MATH_ONLY__) +/* These inline functions may fail to return expected results if unsafe + math optimizations like those enabled by -ffast-math are turned on. + Thus, (somewhat surprisingly) you only get the fast inline + implementations if such compiler options are NOT enabled. This is + because the inline functions require the compiler to be adhering to + the standard in order to work properly; -ffast-math, among other + things, implies that NaNs don't happen, which allows the compiler to + optimize away checks like x != x, which might lead to things like + isnan(NaN) returning false. + + Thus, if you compile with -ffast-math, actual function calls are + generated for these utilities. */ + +#define isnormal(x) \ + ( sizeof(x) == sizeof(float) ? __inline_isnormalf((float)(x)) \ + : sizeof(x) == sizeof(double) ? __inline_isnormald((double)(x)) \ + : __inline_isnormall((long double)(x))) + +#define isfinite(x) \ + ( sizeof(x) == sizeof(float) ? __inline_isfinitef((float)(x)) \ + : sizeof(x) == sizeof(double) ? __inline_isfinited((double)(x)) \ + : __inline_isfinitel((long double)(x))) + +#define isinf(x) \ + ( sizeof(x) == sizeof(float) ? __inline_isinff((float)(x)) \ + : sizeof(x) == sizeof(double) ? __inline_isinfd((double)(x)) \ + : __inline_isinfl((long double)(x))) + +#define isnan(x) \ + ( sizeof(x) == sizeof(float) ? __inline_isnanf((float)(x)) \ + : sizeof(x) == sizeof(double) ? __inline_isnand((double)(x)) \ + : __inline_isnanl((long double)(x))) + +#define signbit(x) \ + ( sizeof(x) == sizeof(float) ? __inline_signbitf((float)(x)) \ + : sizeof(x) == sizeof(double) ? __inline_signbitd((double)(x)) \ + : __inline_signbitl((long double)(x))) + +__header_always_inline int __inline_isfinitef(float); +__header_always_inline int __inline_isfinited(double); +__header_always_inline int __inline_isfinitel(long double); +__header_always_inline int __inline_isinff(float); +__header_always_inline int __inline_isinfd(double); +__header_always_inline int __inline_isinfl(long double); +__header_always_inline int __inline_isnanf(float); +__header_always_inline int __inline_isnand(double); +__header_always_inline int __inline_isnanl(long double); +__header_always_inline int __inline_isnormalf(float); +__header_always_inline int __inline_isnormald(double); +__header_always_inline int __inline_isnormall(long double); +__header_always_inline int __inline_signbitf(float); +__header_always_inline int __inline_signbitd(double); +__header_always_inline int __inline_signbitl(long double); + +__header_always_inline int __inline_isfinitef(float __x) { + return __x == __x && __builtin_fabsf(__x) != __builtin_inff(); +} +__header_always_inline int __inline_isfinited(double __x) { + return __x == __x && __builtin_fabs(__x) != __builtin_inf(); +} +__header_always_inline int __inline_isfinitel(long double __x) { + return __x == __x && __builtin_fabsl(__x) != __builtin_infl(); +} +__header_always_inline int __inline_isinff(float __x) { + return __builtin_fabsf(__x) == __builtin_inff(); +} +__header_always_inline int __inline_isinfd(double __x) { + return __builtin_fabs(__x) == __builtin_inf(); +} +__header_always_inline int __inline_isinfl(long double __x) { + return __builtin_fabsl(__x) == __builtin_infl(); +} +__header_always_inline int __inline_isnanf(float __x) { + return __x != __x; +} +__header_always_inline int __inline_isnand(double __x) { + return __x != __x; +} +__header_always_inline int __inline_isnanl(long double __x) { + return __x != __x; +} +__header_always_inline int __inline_signbitf(float __x) { + union { float __f; unsigned int __u; } __u; + __u.__f = __x; + return (int)(__u.__u >> 31); +} +__header_always_inline int __inline_signbitd(double __x) { + union { double __f; unsigned long long __u; } __u; + __u.__f = __x; + return (int)(__u.__u >> 63); +} +#if defined __i386__ || defined __x86_64__ +__header_always_inline int __inline_signbitl(long double __x) { + union { + long double __ld; + struct{ unsigned long long __m; unsigned short __sexp; } __p; + } __u; + __u.__ld = __x; + return (int)(__u.__p.__sexp >> 15); +} +#else +__header_always_inline int __inline_signbitl(long double __x) { + union { long double __f; unsigned long long __u;} __u; + __u.__f = __x; + return (int)(__u.__u >> 63); +} +#endif +__header_always_inline int __inline_isnormalf(float __x) { + return __inline_isfinitef(__x) && __builtin_fabsf(__x) >= __FLT_MIN__; +} +__header_always_inline int __inline_isnormald(double __x) { + return __inline_isfinited(__x) && __builtin_fabs(__x) >= __DBL_MIN__; +} +__header_always_inline int __inline_isnormall(long double __x) { + return __inline_isfinitel(__x) && __builtin_fabsl(__x) >= __LDBL_MIN__; +} + +#else /* defined(__GNUC__) && 0 == __FINITE_MATH_ONLY__ */ + +/* Implementations making function calls to fall back on when -ffast-math + or similar is specified. These are not available in iOS versions prior + to 6.0. If you need them, you must target that version or later. */ + +#define isnormal(x) \ + ( sizeof(x) == sizeof(float) ? __isnormalf((float)(x)) \ + : sizeof(x) == sizeof(double) ? __isnormald((double)(x)) \ + : __isnormall((long double)(x))) + +#define isfinite(x) \ + ( sizeof(x) == sizeof(float) ? __isfinitef((float)(x)) \ + : sizeof(x) == sizeof(double) ? __isfinited((double)(x)) \ + : __isfinitel((long double)(x))) + +#define isinf(x) \ + ( sizeof(x) == sizeof(float) ? __isinff((float)(x)) \ + : sizeof(x) == sizeof(double) ? __isinfd((double)(x)) \ + : __isinfl((long double)(x))) + +#define isnan(x) \ + ( sizeof(x) == sizeof(float) ? __isnanf((float)(x)) \ + : sizeof(x) == sizeof(double) ? __isnand((double)(x)) \ + : __isnanl((long double)(x))) + +#define signbit(x) \ + ( sizeof(x) == sizeof(float) ? __signbitf((float)(x)) \ + : sizeof(x) == sizeof(double) ? __signbitd((double)(x)) \ + : __signbitl((long double)(x))) + +extern int __isnormalf(float); +extern int __isnormald(double); +extern int __isnormall(long double); +extern int __isfinitef(float); +extern int __isfinited(double); +extern int __isfinitel(long double); +extern int __isinff(float); +extern int __isinfd(double); +extern int __isinfl(long double); +extern int __isnanf(float); +extern int __isnand(double); +extern int __isnanl(long double); +extern int __signbitf(float); +extern int __signbitd(double); +extern int __signbitl(long double); + +#endif /* defined(__GNUC__) && 0 == __FINITE_MATH_ONLY__ */ + +/****************************************************************************** + * * + * Math Functions * + * * + ******************************************************************************/ + +extern float acosf(float); +extern double acos(double); +extern long double acosl(long double); + +extern float asinf(float); +extern double asin(double); +extern long double asinl(long double); + +extern float atanf(float); +extern double atan(double); +extern long double atanl(long double); + +extern float atan2f(float, float); +extern double atan2(double, double); +extern long double atan2l(long double, long double); + +extern float cosf(float); +extern double cos(double); +extern long double cosl(long double); + +extern float sinf(float); +extern double sin(double); +extern long double sinl(long double); + +extern float tanf(float); +extern double tan(double); +extern long double tanl(long double); + +extern float acoshf(float); +extern double acosh(double); +extern long double acoshl(long double); + +extern float asinhf(float); +extern double asinh(double); +extern long double asinhl(long double); + +extern float atanhf(float); +extern double atanh(double); +extern long double atanhl(long double); + +extern float coshf(float); +extern double cosh(double); +extern long double coshl(long double); + +extern float sinhf(float); +extern double sinh(double); +extern long double sinhl(long double); + +extern float tanhf(float); +extern double tanh(double); +extern long double tanhl(long double); + +extern float expf(float); +extern double exp(double); +extern long double expl(long double); + +extern float exp2f(float); +extern double exp2(double); +extern long double exp2l(long double); + +extern float expm1f(float); +extern double expm1(double); +extern long double expm1l(long double); + +extern float logf(float); +extern double log(double); +extern long double logl(long double); + +extern float log10f(float); +extern double log10(double); +extern long double log10l(long double); + +extern float log2f(float); +extern double log2(double); +extern long double log2l(long double); + +extern float log1pf(float); +extern double log1p(double); +extern long double log1pl(long double); + +extern float logbf(float); +extern double logb(double); +extern long double logbl(long double); + +extern float modff(float, float *); +extern double modf(double, double *); +extern long double modfl(long double, long double *); + +extern float ldexpf(float, int); +extern double ldexp(double, int); +extern long double ldexpl(long double, int); + +extern float frexpf(float, int *); +extern double frexp(double, int *); +extern long double frexpl(long double, int *); + +extern int ilogbf(float); +extern int ilogb(double); +extern int ilogbl(long double); + +extern float scalbnf(float, int); +extern double scalbn(double, int); +extern long double scalbnl(long double, int); + +extern float scalblnf(float, long int); +extern double scalbln(double, long int); +extern long double scalblnl(long double, long int); + +extern float fabsf(float); +extern double fabs(double); +extern long double fabsl(long double); + +extern float cbrtf(float); +extern double cbrt(double); +extern long double cbrtl(long double); + +extern float hypotf(float, float); +extern double hypot(double, double); +extern long double hypotl(long double, long double); + +extern float powf(float, float); +extern double pow(double, double); +extern long double powl(long double, long double); + +extern float sqrtf(float); +extern double sqrt(double); +extern long double sqrtl(long double); + +extern float erff(float); +extern double erf(double); +extern long double erfl(long double); + +extern float erfcf(float); +extern double erfc(double); +extern long double erfcl(long double); + +/* lgammaf, lgamma, and lgammal are not thread-safe. The thread-safe + variants lgammaf_r, lgamma_r, and lgammal_r are made available if + you define the _REENTRANT symbol before including */ +extern float lgammaf(float); +extern double lgamma(double); +extern long double lgammal(long double); + +extern float tgammaf(float); +extern double tgamma(double); +extern long double tgammal(long double); + +extern float ceilf(float); +extern double ceil(double); +extern long double ceill(long double); + +extern float floorf(float); +extern double floor(double); +extern long double floorl(long double); + +extern float nearbyintf(float); +extern double nearbyint(double); +extern long double nearbyintl(long double); + +extern float rintf(float); +extern double rint(double); +extern long double rintl(long double); + +extern long int lrintf(float); +extern long int lrint(double); +extern long int lrintl(long double); + +extern float roundf(float); +extern double round(double); +extern long double roundl(long double); + +extern long int lroundf(float); +extern long int lround(double); +extern long int lroundl(long double); + +/* long long is not part of C90. Make sure you are passing -std=c99 or + -std=gnu99 or higher if you need these functions returning long longs */ +#if !(__DARWIN_NO_LONG_LONG) +extern long long int llrintf(float); +extern long long int llrint(double); +extern long long int llrintl(long double); + +extern long long int llroundf(float); +extern long long int llround(double); +extern long long int llroundl(long double); +#endif /* !(__DARWIN_NO_LONG_LONG) */ + +extern float truncf(float); +extern double trunc(double); +extern long double truncl(long double); + +extern float fmodf(float, float); +extern double fmod(double, double); +extern long double fmodl(long double, long double); + +extern float remainderf(float, float); +extern double remainder(double, double); +extern long double remainderl(long double, long double); + +extern float remquof(float, float, int *); +extern double remquo(double, double, int *); +extern long double remquol(long double, long double, int *); + +extern float copysignf(float, float); +extern double copysign(double, double); +extern long double copysignl(long double, long double); + +extern float nanf(const char *); +extern double nan(const char *); +extern long double nanl(const char *); + +extern float nextafterf(float, float); +extern double nextafter(double, double); +extern long double nextafterl(long double, long double); + +extern double nexttoward(double, long double); +extern float nexttowardf(float, long double); +extern long double nexttowardl(long double, long double); + +extern float fdimf(float, float); +extern double fdim(double, double); +extern long double fdiml(long double, long double); + +extern float fmaxf(float, float); +extern double fmax(double, double); +extern long double fmaxl(long double, long double); + +extern float fminf(float, float); +extern double fmin(double, double); +extern long double fminl(long double, long double); + +extern float fmaf(float, float, float); +extern double fma(double, double, double); +extern long double fmal(long double, long double, long double); + +#define isgreater(x, y) __builtin_isgreater((x),(y)) +#define isgreaterequal(x, y) __builtin_isgreaterequal((x),(y)) +#define isless(x, y) __builtin_isless((x),(y)) +#define islessequal(x, y) __builtin_islessequal((x),(y)) +#define islessgreater(x, y) __builtin_islessgreater((x),(y)) +#define isunordered(x, y) __builtin_isunordered((x),(y)) + +#if defined __i386__ || defined __x86_64__ +/* Deprecated functions; use the INFINITY and NAN macros instead. */ +extern float __inff(void) +__API_DEPRECATED("use `(float)INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +extern double __inf(void) +__API_DEPRECATED("use `INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +extern long double __infl(void) +__API_DEPRECATED("use `(long double)INFINITY` instead", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +extern float __nan(void) +__API_DEPRECATED("use `NAN` instead", macos(10.0, 10.14)) __API_UNAVAILABLE(ios, watchos, tvos); +#endif + +/****************************************************************************** + * Reentrant variants of lgamma[fl] * + ******************************************************************************/ + +#ifdef _REENTRANT +/* Reentrant variants of the lgamma[fl] functions. */ +extern float lgammaf_r(float, int *) __API_AVAILABLE(macos(10.6), ios(3.1)); +extern double lgamma_r(double, int *) __API_AVAILABLE(macos(10.6), ios(3.1)); +extern long double lgammal_r(long double, int *) __API_AVAILABLE(macos(10.6), ios(3.1)); +#endif /* _REENTRANT */ + +/****************************************************************************** + * Apple extensions to the C standard * + ******************************************************************************/ + +/* Because these functions are not specified by any relevant standard, they + are prefixed with __, which places them in the implementor's namespace, so + they should not conflict with any developer or third-party code. If they + are added to a relevant standard in the future, un-prefixed names may be + added to the library and they may be moved out of this section of the + header. + + Because these functions are non-standard, they may not be available on non- + Apple platforms. */ + +/* __exp10(x) returns 10**x. Edge cases match those of exp( ) and exp2( ). */ +extern float __exp10f(float) __API_AVAILABLE(macos(10.9), ios(7.0)); +extern double __exp10(double) __API_AVAILABLE(macos(10.9), ios(7.0)); + +/* __sincos(x,sinp,cosp) computes the sine and cosine of x with a single + function call, storing the sine in the memory pointed to by sinp, and + the cosine in the memory pointed to by cosp. Edge cases match those of + separate calls to sin( ) and cos( ). */ +__header_always_inline void __sincosf(float __x, float *__sinp, float *__cosp); +__header_always_inline void __sincos(double __x, double *__sinp, double *__cosp); + +/* __sinpi(x) returns the sine of pi times x; __cospi(x) and __tanpi(x) return + the cosine and tangent, respectively. These functions can produce a more + accurate answer than expressions of the form sin(M_PI * x) because they + avoid any loss of precision that results from rounding the result of the + multiplication M_PI * x. They may also be significantly more efficient in + some cases because the argument reduction for these functions is easier + to compute. Consult the man pages for edge case details. */ +extern float __cospif(float) __API_AVAILABLE(macos(10.9), ios(7.0)); +extern double __cospi(double) __API_AVAILABLE(macos(10.9), ios(7.0)); +extern float __sinpif(float) __API_AVAILABLE(macos(10.9), ios(7.0)); +extern double __sinpi(double) __API_AVAILABLE(macos(10.9), ios(7.0)); +extern float __tanpif(float) __API_AVAILABLE(macos(10.9), ios(7.0)); +extern double __tanpi(double) __API_AVAILABLE(macos(10.9), ios(7.0)); + +#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED < 1090) || \ + (defined __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < 70000) +/* __sincos and __sincosf were introduced in OSX 10.9 and iOS 7.0. When + targeting an older system, we simply split them up into discrete calls + to sin( ) and cos( ). */ +__header_always_inline void __sincosf(float __x, float *__sinp, float *__cosp) { + *__sinp = sinf(__x); + *__cosp = cosf(__x); +} + +__header_always_inline void __sincos(double __x, double *__sinp, double *__cosp) { + *__sinp = sin(__x); + *__cosp = cos(__x); +} +#else +/* __sincospi(x,sinp,cosp) computes the sine and cosine of pi times x with a + single function call, storing the sine in the memory pointed to by sinp, + and the cosine in the memory pointed to by cosp. Edge cases match those + of separate calls to __sinpi( ) and __cospi( ), and are documented in the + man pages. + + These functions were introduced in OSX 10.9 and iOS 7.0. Because they are + implemented as header inlines, weak-linking does not function as normal, + and they are simply hidden when targeting earlier OS versions. */ +__header_always_inline void __sincospif(float __x, float *__sinp, float *__cosp); +__header_always_inline void __sincospi(double __x, double *__sinp, double *__cosp); + +/* Implementation details of __sincos and __sincospi allowing them to return + two results while allowing the compiler to optimize away unnecessary load- + store traffic. Although these interfaces are exposed in the math.h header + to allow compilers to generate better code, users should call __sincos[f] + and __sincospi[f] instead and allow the compiler to emit these calls. */ +struct __float2 { float __sinval; float __cosval; }; +struct __double2 { double __sinval; double __cosval; }; + +extern struct __float2 __sincosf_stret(float); +extern struct __double2 __sincos_stret(double); +extern struct __float2 __sincospif_stret(float); +extern struct __double2 __sincospi_stret(double); + +__header_always_inline void __sincosf(float __x, float *__sinp, float *__cosp) { + const struct __float2 __stret = __sincosf_stret(__x); + *__sinp = __stret.__sinval; *__cosp = __stret.__cosval; +} + +__header_always_inline void __sincos(double __x, double *__sinp, double *__cosp) { + const struct __double2 __stret = __sincos_stret(__x); + *__sinp = __stret.__sinval; *__cosp = __stret.__cosval; +} + +__header_always_inline void __sincospif(float __x, float *__sinp, float *__cosp) { + const struct __float2 __stret = __sincospif_stret(__x); + *__sinp = __stret.__sinval; *__cosp = __stret.__cosval; +} + +__header_always_inline void __sincospi(double __x, double *__sinp, double *__cosp) { + const struct __double2 __stret = __sincospi_stret(__x); + *__sinp = __stret.__sinval; *__cosp = __stret.__cosval; +} +#endif + +/****************************************************************************** + * POSIX/UNIX extensions to the C standard * + ******************************************************************************/ + +#if __DARWIN_C_LEVEL >= 199506L +extern double j0(double) __API_AVAILABLE(macos(10.0), ios(3.2)); +extern double j1(double) __API_AVAILABLE(macos(10.0), ios(3.2)); +extern double jn(int, double) __API_AVAILABLE(macos(10.0), ios(3.2)); +extern double y0(double) __API_AVAILABLE(macos(10.0), ios(3.2)); +extern double y1(double) __API_AVAILABLE(macos(10.0), ios(3.2)); +extern double yn(int, double) __API_AVAILABLE(macos(10.0), ios(3.2)); +extern double scalb(double, double); +extern int signgam; + +/* Even though these might be more useful as long doubles, POSIX requires + that they be double-precision literals. */ +#define M_E 2.71828182845904523536028747135266250 /* e */ +#define M_LOG2E 1.44269504088896340735992468100189214 /* log2(e) */ +#define M_LOG10E 0.434294481903251827651128918916605082 /* log10(e) */ +#define M_LN2 0.693147180559945309417232121458176568 /* loge(2) */ +#define M_LN10 2.30258509299404568401799145468436421 /* loge(10) */ +#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#define M_PI_2 1.57079632679489661923132169163975144 /* pi/2 */ +#define M_PI_4 0.785398163397448309615660845819875721 /* pi/4 */ +#define M_1_PI 0.318309886183790671537767526745028724 /* 1/pi */ +#define M_2_PI 0.636619772367581343075535053490057448 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */ +#define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */ + +#define MAXFLOAT 0x1.fffffep+127f +#endif /* __DARWIN_C_LEVEL >= 199506L */ + +/* Long-double versions of M_E, etc for convenience on Intel where long- + double is not the same as double. Define __MATH_LONG_DOUBLE_CONSTANTS + to make these constants available. */ +#if defined __MATH_LONG_DOUBLE_CONSTANTS +#define M_El 0xa.df85458a2bb4a9bp-2L +#define M_LOG2El 0xb.8aa3b295c17f0bcp-3L +#define M_LOG10El 0xd.e5bd8a937287195p-5L +#define M_LN2l 0xb.17217f7d1cf79acp-4L +#define M_LN10l 0x9.35d8dddaaa8ac17p-2L +#define M_PIl 0xc.90fdaa22168c235p-2L +#define M_PI_2l 0xc.90fdaa22168c235p-3L +#define M_PI_4l 0xc.90fdaa22168c235p-4L +#define M_1_PIl 0xa.2f9836e4e44152ap-5L +#define M_2_PIl 0xa.2f9836e4e44152ap-4L +#define M_2_SQRTPIl 0x9.06eba8214db688dp-3L +#define M_SQRT2l 0xb.504f333f9de6484p-3L +#define M_SQRT1_2l 0xb.504f333f9de6484p-4L +#endif /* defined __MATH_LONG_DOUBLE_CONSTANTS */ + +/****************************************************************************** + * Legacy BSD extensions to the C standard * + ******************************************************************************/ + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#define FP_SNAN FP_NAN +#define FP_QNAN FP_NAN +#define HUGE MAXFLOAT +#define X_TLOSS 1.41484755040568800000e+16 +#define DOMAIN 1 +#define SING 2 +#define OVERFLOW 3 +#define UNDERFLOW 4 +#define TLOSS 5 +#define PLOSS 6 + +#if defined __i386__ || defined __x86_64__ +/* Legacy BSD API; use the C99 `lrint( )` function instead. */ +extern long int rinttol(double) +__API_DEPRECATED_WITH_REPLACEMENT("lrint", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +/* Legacy BSD API; use the C99 `lround( )` function instead. */ +extern long int roundtol(double) +__API_DEPRECATED_WITH_REPLACEMENT("lround", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +/* Legacy BSD API; use the C99 `remainder( )` function instead. */ +extern double drem(double, double) +__API_DEPRECATED_WITH_REPLACEMENT("remainder", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +/* Legacy BSD API; use the C99 `isfinite( )` macro instead. */ +extern int finite(double) +__API_DEPRECATED("Use `isfinite((double)x)` instead.", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +/* Legacy BSD API; use the C99 `tgamma( )` function instead. */ +extern double gamma(double) +__API_DEPRECATED_WITH_REPLACEMENT("tgamma", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +/* Legacy BSD API; use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead. */ +extern double significand(double) +__API_DEPRECATED("Use `2*frexp( )` or `scalbn(x, -ilogb(x))` instead.", macos(10.0, 10.9)) __API_UNAVAILABLE(ios, watchos, tvos); +#endif + +#if !defined __cplusplus +struct exception { + int type; + char *name; + double arg1; + double arg2; + double retval; +}; + +#endif /* !defined __cplusplus */ +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ + +__END_DECLS +#endif /* __MATH_H__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/net/if.h b/lib/libc/include/aarch64-macos-gnu/net/if.h new file mode 100644 index 0000000000..e77e7b8338 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/net/if.h @@ -0,0 +1,442 @@ +/* + * Copyright (c) 2000-2020 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)if.h 8.1 (Berkeley) 6/10/93 + */ + +#ifndef _NET_IF_H_ +#define _NET_IF_H_ + +#include +#include + +#define IF_NAMESIZE 16 + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#include +#ifdef __APPLE__ + +#include +#include +#include + +#endif + +struct if_clonereq { + int ifcr_total; /* total cloners (out) */ + int ifcr_count; /* room for this many in user buffer */ + char *ifcr_buffer; /* buffer for cloner names */ +}; + + +#define IFF_UP 0x1 /* interface is up */ +#define IFF_BROADCAST 0x2 /* broadcast address valid */ +#define IFF_DEBUG 0x4 /* turn on debugging */ +#define IFF_LOOPBACK 0x8 /* is a loopback net */ +#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */ +#define IFF_NOTRAILERS 0x20 /* obsolete: avoid use of trailers */ +#define IFF_RUNNING 0x40 /* resources allocated */ +#define IFF_NOARP 0x80 /* no address resolution protocol */ +#define IFF_PROMISC 0x100 /* receive all packets */ +#define IFF_ALLMULTI 0x200 /* receive all multicast packets */ +#define IFF_OACTIVE 0x400 /* transmission in progress */ +#define IFF_SIMPLEX 0x800 /* can't hear own transmissions */ +#define IFF_LINK0 0x1000 /* per link layer defined bit */ +#define IFF_LINK1 0x2000 /* per link layer defined bit */ +#define IFF_LINK2 0x4000 /* per link layer defined bit */ +#define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ +#define IFF_MULTICAST 0x8000 /* supports multicast */ + + + +/* + * Capabilities that interfaces can advertise. + * + * struct ifnet.if_capabilities + * contains the optional features & capabilities a particular interface + * supports (not only the driver but also the detected hw revision). + * Capabilities are defined by IFCAP_* below. + * struct ifnet.if_capenable + * contains the enabled (either by default or through ifconfig) optional + * features & capabilities on this interface. + * Capabilities are defined by IFCAP_* below. + * struct if_data.ifi_hwassist in IFNET_* form, defined in net/kpi_interface.h, + * contains the enabled optional features & capabilites that can be used + * individually per packet and are specified in the mbuf pkthdr.csum_flags + * field. IFCAP_* and IFNET_* do not match one to one and IFNET_* may be + * more detailed or differentiated than IFCAP_*. + * IFNET_* hwassist flags have corresponding CSUM_* in sys/mbuf.h + */ +#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */ +#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */ +#define IFCAP_VLAN_MTU 0x00004 /* VLAN-compatible MTU */ +#define IFCAP_VLAN_HWTAGGING 0x00008 /* hardware VLAN tag support */ +#define IFCAP_JUMBO_MTU 0x00010 /* 9000 byte MTU supported */ +#define IFCAP_TSO4 0x00020 /* can do TCP Segmentation Offload */ +#define IFCAP_TSO6 0x00040 /* can do TCP6 Segmentation Offload */ +#define IFCAP_LRO 0x00080 /* can do Large Receive Offload */ +#define IFCAP_AV 0x00100 /* can do 802.1 AV Bridging */ +#define IFCAP_TXSTATUS 0x00200 /* can return linklevel xmit status */ +#define IFCAP_SKYWALK 0x00400 /* Skywalk mode supported/enabled */ +#define IFCAP_HW_TIMESTAMP 0x00800 /* Time stamping in hardware */ +#define IFCAP_SW_TIMESTAMP 0x01000 /* Time stamping in software */ +#define IFCAP_CSUM_PARTIAL 0x02000 /* can offload partial checksum */ +#define IFCAP_CSUM_ZERO_INVERT 0x04000 /* can invert 0 to -0 (0xffff) */ + +#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) +#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) + +#define IFCAP_VALID (IFCAP_HWCSUM | IFCAP_TSO | IFCAP_LRO | IFCAP_VLAN_MTU | \ + IFCAP_VLAN_HWTAGGING | IFCAP_JUMBO_MTU | IFCAP_AV | IFCAP_TXSTATUS | \ + IFCAP_SKYWALK | IFCAP_SW_TIMESTAMP | IFCAP_HW_TIMESTAMP | \ + IFCAP_CSUM_PARTIAL | IFCAP_CSUM_ZERO_INVERT) + +#define IFQ_MAXLEN 128 +#define IFNET_SLOWHZ 1 /* granularity is 1 second */ +#define IFQ_TARGET_DELAY (10ULL * 1000 * 1000) /* 10 ms */ +#define IFQ_UPDATE_INTERVAL (100ULL * 1000 * 1000) /* 100 ms */ + +/* + * Message format for use in obtaining information about interfaces + * from sysctl and the routing socket + */ +struct if_msghdr { + unsigned short ifm_msglen; /* to skip non-understood messages */ + unsigned char ifm_version; /* future binary compatability */ + unsigned char ifm_type; /* message type */ + int ifm_addrs; /* like rtm_addrs */ + int ifm_flags; /* value of if_flags */ + unsigned short ifm_index; /* index for associated ifp */ + struct if_data ifm_data; /* statistics and other data about if */ +}; + +/* + * Message format for use in obtaining information about interface addresses + * from sysctl and the routing socket + */ +struct ifa_msghdr { + unsigned short ifam_msglen; /* to skip non-understood messages */ + unsigned char ifam_version; /* future binary compatability */ + unsigned char ifam_type; /* message type */ + int ifam_addrs; /* like rtm_addrs */ + int ifam_flags; /* value of ifa_flags */ + unsigned short ifam_index; /* index for associated ifp */ + int ifam_metric; /* value of ifa_metric */ +}; + +/* + * Message format for use in obtaining information about multicast addresses + * from the routing socket + */ +struct ifma_msghdr { + unsigned short ifmam_msglen; /* to skip non-understood messages */ + unsigned char ifmam_version; /* future binary compatability */ + unsigned char ifmam_type; /* message type */ + int ifmam_addrs; /* like rtm_addrs */ + int ifmam_flags; /* value of ifa_flags */ + unsigned short ifmam_index; /* index for associated ifp */ +}; + +/* + * Message format for use in obtaining information about interfaces + * from sysctl + */ +struct if_msghdr2 { + u_short ifm_msglen; /* to skip over non-understood messages */ + u_char ifm_version; /* future binary compatability */ + u_char ifm_type; /* message type */ + int ifm_addrs; /* like rtm_addrs */ + int ifm_flags; /* value of if_flags */ + u_short ifm_index; /* index for associated ifp */ + int ifm_snd_len; /* instantaneous length of send queue */ + int ifm_snd_maxlen; /* maximum length of send queue */ + int ifm_snd_drops; /* number of drops in send queue */ + int ifm_timer; /* time until if_watchdog called */ + struct if_data64 ifm_data; /* statistics and other data */ +}; + +/* + * Message format for use in obtaining information about multicast addresses + * from sysctl + */ +struct ifma_msghdr2 { + u_short ifmam_msglen; /* to skip over non-understood messages */ + u_char ifmam_version; /* future binary compatability */ + u_char ifmam_type; /* message type */ + int ifmam_addrs; /* like rtm_addrs */ + int ifmam_flags; /* value of ifa_flags */ + u_short ifmam_index; /* index for associated ifp */ + int32_t ifmam_refcount; +}; + +/* + * ifdevmtu: interface device mtu + * Used with SIOCGIFDEVMTU to get the current mtu in use by the device, + * as well as the minimum and maximum mtu allowed by the device. + */ +struct ifdevmtu { + int ifdm_current; + int ifdm_min; + int ifdm_max; +}; + +#pragma pack(4) + +/* + * ifkpi: interface kpi ioctl + * Used with SIOCSIFKPI and SIOCGIFKPI. + * + * ifk_module_id - From in the kernel, a value from kev_vendor_code_find. From + * user space, a value from SIOCGKEVVENDOR ioctl on a kernel event socket. + * ifk_type - The type. Types are specific to each module id. + * ifk_data - The data. ifk_ptr may be a 64bit pointer for 64 bit processes. + * + * Copying data between user space and kernel space is done using copyin + * and copyout. A process may be running in 64bit mode. In such a case, + * the pointer will be a 64bit pointer, not a 32bit pointer. The following + * sample is a safe way to copy the data in to the kernel from either a + * 32bit or 64bit process: + * + * user_addr_t tmp_ptr; + * if (IS_64BIT_PROCESS(current_proc())) { + * tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr64); + * } + * else { + * tmp_ptr = CAST_USER_ADDR_T(ifkpi.ifk_data.ifk_ptr); + * } + * error = copyin(tmp_ptr, allocated_dst_buffer, size of allocated_dst_buffer); + */ + +struct ifkpi { + unsigned int ifk_module_id; + unsigned int ifk_type; + union { + void *ifk_ptr; + int ifk_value; + } ifk_data; +}; + +/* Wake capabilities of a interface */ +#define IF_WAKE_ON_MAGIC_PACKET 0x01 + + +#pragma pack() + +/* + * Interface request structure used for socket + * ioctl's. All interface ioctl's must have parameter + * definitions which begin with ifr_name. The + * remainder may be interface specific. + */ +struct ifreq { +#ifndef IFNAMSIZ +#define IFNAMSIZ IF_NAMESIZE +#endif + char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + short ifru_flags; + int ifru_metric; + int ifru_mtu; + int ifru_phys; + int ifru_media; + int ifru_intval; + caddr_t ifru_data; + struct ifdevmtu ifru_devmtu; + struct ifkpi ifru_kpi; + u_int32_t ifru_wake_flags; + u_int32_t ifru_route_refcnt; + int ifru_cap[2]; + u_int32_t ifru_functional_type; +#define IFRTYPE_FUNCTIONAL_UNKNOWN 0 +#define IFRTYPE_FUNCTIONAL_LOOPBACK 1 +#define IFRTYPE_FUNCTIONAL_WIRED 2 +#define IFRTYPE_FUNCTIONAL_WIFI_INFRA 3 +#define IFRTYPE_FUNCTIONAL_WIFI_AWDL 4 +#define IFRTYPE_FUNCTIONAL_CELLULAR 5 +#define IFRTYPE_FUNCTIONAL_INTCOPROC 6 +#define IFRTYPE_FUNCTIONAL_COMPANIONLINK 7 +#define IFRTYPE_FUNCTIONAL_LAST 7 + } ifr_ifru; +#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ +#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ +#ifdef __APPLE__ +#define ifr_flags ifr_ifru.ifru_flags /* flags */ +#else +#define ifr_flags ifr_ifru.ifru_flags[0] /* flags */ +#define ifr_prevflags ifr_ifru.ifru_flags[1] /* flags */ +#endif /* __APPLE__ */ +#define ifr_metric ifr_ifru.ifru_metric /* metric */ +#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ +#define ifr_phys ifr_ifru.ifru_phys /* physical wire */ +#define ifr_media ifr_ifru.ifru_media /* physical media */ +#define ifr_data ifr_ifru.ifru_data /* for use by interface */ +#define ifr_devmtu ifr_ifru.ifru_devmtu +#define ifr_intval ifr_ifru.ifru_intval /* integer value */ +#define ifr_kpi ifr_ifru.ifru_kpi +#define ifr_wake_flags ifr_ifru.ifru_wake_flags /* wake capabilities */ +#define ifr_route_refcnt ifr_ifru.ifru_route_refcnt /* route references count */ +#define ifr_reqcap ifr_ifru.ifru_cap[0] /* requested capabilities */ +#define ifr_curcap ifr_ifru.ifru_cap[1] /* current capabilities */ +}; + +#define _SIZEOF_ADDR_IFREQ(ifr) \ + ((ifr).ifr_addr.sa_len > sizeof (struct sockaddr) ? \ + (sizeof (struct ifreq) - sizeof (struct sockaddr) + \ + (ifr).ifr_addr.sa_len) : sizeof (struct ifreq)) + +struct ifaliasreq { + char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + struct sockaddr ifra_addr; + struct sockaddr ifra_broadaddr; + struct sockaddr ifra_mask; +}; + +struct rslvmulti_req { + struct sockaddr *sa; + struct sockaddr **llsa; +}; + +#pragma pack(4) + +struct ifmediareq { + char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + int ifm_current; /* current media options */ + int ifm_mask; /* don't care mask */ + int ifm_status; /* media status */ + int ifm_active; /* active options */ + int ifm_count; /* # entries in ifm_ulist array */ + int *ifm_ulist; /* media words */ +}; + +#pragma pack() + + + +#pragma pack(4) +struct ifdrv { + char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + unsigned long ifd_cmd; + size_t ifd_len; /* length of ifd_data buffer */ + void *ifd_data; +}; +#pragma pack() + + +/* + * Structure used to retrieve aux status data from interfaces. + * Kernel suppliers to this interface should respect the formatting + * needed by ifconfig(8): each line starts with a TAB and ends with + * a newline. + */ + +#define IFSTATMAX 800 /* 10 lines of text */ +struct ifstat { + char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ + char ascii[IFSTATMAX + 1]; +}; + +/* + * Structure used in SIOCGIFCONF request. + * Used to retrieve interface configuration + * for machine (useful for programs which + * must know all networks accessible). + */ +#pragma pack(4) +struct ifconf { + int ifc_len; /* size of associated buffer */ + union { + caddr_t ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +}; +#pragma pack() +#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ +#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ + + +/* + * DLIL KEV_DL_PROTO_ATTACHED/DETACHED structure + */ +struct kev_dl_proto_data { + struct net_event_data link_data; + u_int32_t proto_family; + u_int32_t proto_remaining_count; +}; + + +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +struct if_nameindex { + unsigned int if_index; /* 1, 2, ... */ + char *if_name; /* null terminated name: "le0", ... */ +}; + +__BEGIN_DECLS +unsigned int if_nametoindex(const char *); +char *if_indextoname(unsigned int, char *); +struct if_nameindex *if_nameindex(void); +void if_freenameindex(struct if_nameindex *); +__END_DECLS + + +#endif /* !_NET_IF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/net/if_var.h b/lib/libc/include/aarch64-macos-gnu/net/if_var.h new file mode 100644 index 0000000000..79e6a60368 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/net/if_var.h @@ -0,0 +1,243 @@ +/* + * Copyright (c) 2000-2020 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * From: @(#)if.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/net/if_var.h,v 1.18.2.7 2001/07/24 19:10:18 brooks Exp $ + */ + +#ifndef _NET_IF_VAR_H_ +#define _NET_IF_VAR_H_ + +#include +#include +#include +#include +#include /* get TAILQ macros */ +#ifdef BSD_KERN_PRIVATE +#include +#include +#endif + + +#ifdef __APPLE__ +#define APPLE_IF_FAM_LOOPBACK 1 +#define APPLE_IF_FAM_ETHERNET 2 +#define APPLE_IF_FAM_SLIP 3 +#define APPLE_IF_FAM_TUN 4 +#define APPLE_IF_FAM_VLAN 5 +#define APPLE_IF_FAM_PPP 6 +#define APPLE_IF_FAM_PVC 7 +#define APPLE_IF_FAM_DISC 8 +#define APPLE_IF_FAM_MDECAP 9 +#define APPLE_IF_FAM_GIF 10 +#define APPLE_IF_FAM_FAITH 11 /* deprecated */ +#define APPLE_IF_FAM_STF 12 +#define APPLE_IF_FAM_FIREWIRE 13 +#define APPLE_IF_FAM_BOND 14 +#define APPLE_IF_FAM_CELLULAR 15 +#define APPLE_IF_FAM_6LOWPAN 16 +#define APPLE_IF_FAM_UTUN 17 +#define APPLE_IF_FAM_IPSEC 18 +#endif /* __APPLE__ */ + +/* + * 72 was chosen below because it is the size of a TCP/IP + * header (40) + the minimum mss (32). + */ +#define IF_MINMTU 72 +#define IF_MAXMTU 65535 + +/* + * Structures defining a network interface, providing a packet + * transport mechanism (ala level 0 of the PUP protocols). + * + * Each interface accepts output datagrams of a specified maximum + * length, and provides higher level routines with input datagrams + * received from its medium. + * + * Output occurs when the routine if_output is called, with three parameters: + * (*ifp->if_output)(ifp, m, dst, rt) + * Here m is the mbuf chain to be sent and dst is the destination address. + * The output routine encapsulates the supplied datagram if necessary, + * and then transmits it on its medium. + * + * On input, each interface unwraps the data received by it, and either + * places it on the input queue of a internetwork datagram routine + * and posts the associated software interrupt, or passes the datagram to a raw + * packet input routine. + * + * Routines exist for locating interfaces by their addresses + * or for locating a interface on a certain network, as well as more general + * routing and gateway routines maintaining information used to locate + * interfaces. These routines live in the files if.c and route.c + */ + +#define IFNAMSIZ 16 + +/* This belongs up in socket.h or socketvar.h, depending on how far the + * event bubbles up. + */ + +struct net_event_data { + u_int32_t if_family; + u_int32_t if_unit; + char if_name[IFNAMSIZ]; +}; + +#if defined(__LP64__) +#include +#define IF_DATA_TIMEVAL timeval32 +#else +#define IF_DATA_TIMEVAL timeval +#endif + +#pragma pack(4) + +/* + * Structure describing information about an interface + * which may be of interest to management entities. + */ +struct if_data { + /* generic interface information */ + u_char ifi_type; /* ethernet, tokenring, etc */ + u_char ifi_typelen; /* Length of frame type id */ + u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ + u_char ifi_addrlen; /* media address length */ + u_char ifi_hdrlen; /* media header length */ + u_char ifi_recvquota; /* polling quota for receive intrs */ + u_char ifi_xmitquota; /* polling quota for xmit intrs */ + u_char ifi_unused1; /* for future use */ + u_int32_t ifi_mtu; /* maximum transmission unit */ + u_int32_t ifi_metric; /* routing metric (external only) */ + u_int32_t ifi_baudrate; /* linespeed */ + /* volatile statistics */ + u_int32_t ifi_ipackets; /* packets received on interface */ + u_int32_t ifi_ierrors; /* input errors on interface */ + u_int32_t ifi_opackets; /* packets sent on interface */ + u_int32_t ifi_oerrors; /* output errors on interface */ + u_int32_t ifi_collisions; /* collisions on csma interfaces */ + u_int32_t ifi_ibytes; /* total number of octets received */ + u_int32_t ifi_obytes; /* total number of octets sent */ + u_int32_t ifi_imcasts; /* packets received via multicast */ + u_int32_t ifi_omcasts; /* packets sent via multicast */ + u_int32_t ifi_iqdrops; /* dropped on input, this interface */ + u_int32_t ifi_noproto; /* destined for unsupported protocol */ + u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ + u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ + struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ + u_int32_t ifi_unused2; /* used to be the default_proto */ + u_int32_t ifi_hwassist; /* HW offload capabilities */ + u_int32_t ifi_reserved1; /* for future use */ + u_int32_t ifi_reserved2; /* for future use */ +}; + +/* + * Structure describing information about an interface + * which may be of interest to management entities. + */ +struct if_data64 { + /* generic interface information */ + u_char ifi_type; /* ethernet, tokenring, etc */ + u_char ifi_typelen; /* Length of frame type id */ + u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ + u_char ifi_addrlen; /* media address length */ + u_char ifi_hdrlen; /* media header length */ + u_char ifi_recvquota; /* polling quota for receive intrs */ + u_char ifi_xmitquota; /* polling quota for xmit intrs */ + u_char ifi_unused1; /* for future use */ + u_int32_t ifi_mtu; /* maximum transmission unit */ + u_int32_t ifi_metric; /* routing metric (external only) */ + u_int64_t ifi_baudrate; /* linespeed */ + /* volatile statistics */ + u_int64_t ifi_ipackets; /* packets received on interface */ + u_int64_t ifi_ierrors; /* input errors on interface */ + u_int64_t ifi_opackets; /* packets sent on interface */ + u_int64_t ifi_oerrors; /* output errors on interface */ + u_int64_t ifi_collisions; /* collisions on csma interfaces */ + u_int64_t ifi_ibytes; /* total number of octets received */ + u_int64_t ifi_obytes; /* total number of octets sent */ + u_int64_t ifi_imcasts; /* packets received via multicast */ + u_int64_t ifi_omcasts; /* packets sent via multicast */ + u_int64_t ifi_iqdrops; /* dropped on input, this interface */ + u_int64_t ifi_noproto; /* destined for unsupported protocol */ + u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ + u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ + struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ +}; + + +#pragma pack() + +/* + * Structure defining a queue for a network interface. + */ +struct ifqueue { + void *ifq_head; + void *ifq_tail; + int ifq_len; + int ifq_maxlen; + int ifq_drops; +}; + + + + + + +#endif /* !_NET_IF_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/netinet/in.h b/lib/libc/include/aarch64-macos-gnu/netinet/in.h new file mode 100644 index 0000000000..8916f36091 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/netinet/in.h @@ -0,0 +1,672 @@ +/* + * Copyright (c) 2000-2018 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)in.h 8.3 (Berkeley) 1/3/94 + * $FreeBSD: src/sys/netinet/in.h,v 1.48.2.2 2001/04/21 14:53:06 ume Exp $ + */ + +#ifndef _NETINET_IN_H_ +#define _NETINET_IN_H_ + +#include +#include /* uint(8|16|32)_t */ + +#include + + +#include +#include + +/* + * POSIX 1003.1-2003 + * "Inclusion of the header may also make visible all + * symbols from and ". + */ +#include + +/* + * The following two #includes insure htonl and family are defined + */ +#include +#include + +/* + * Constants and structures defined by the internet system, + * Per RFC 790, September 1981, and numerous additions. + */ + +/* + * Protocols (RFC 1700) + */ +#define IPPROTO_IP 0 /* dummy for IP */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_IGMP 2 /* group mgmt protocol */ +#define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ +#define IPPROTO_IPV4 4 /* IPv4 encapsulation */ +#define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_TCP 6 /* tcp */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_ST 7 /* Stream protocol II */ +#define IPPROTO_EGP 8 /* exterior gateway protocol */ +#define IPPROTO_PIGP 9 /* private interior gateway */ +#define IPPROTO_RCCMON 10 /* BBN RCC Monitoring */ +#define IPPROTO_NVPII 11 /* network voice protocol*/ +#define IPPROTO_PUP 12 /* pup */ +#define IPPROTO_ARGUS 13 /* Argus */ +#define IPPROTO_EMCON 14 /* EMCON */ +#define IPPROTO_XNET 15 /* Cross Net Debugger */ +#define IPPROTO_CHAOS 16 /* Chaos*/ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_UDP 17 /* user datagram protocol */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_MUX 18 /* Multiplexing */ +#define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */ +#define IPPROTO_HMP 20 /* Host Monitoring */ +#define IPPROTO_PRM 21 /* Packet Radio Measurement */ +#define IPPROTO_IDP 22 /* xns idp */ +#define IPPROTO_TRUNK1 23 /* Trunk-1 */ +#define IPPROTO_TRUNK2 24 /* Trunk-2 */ +#define IPPROTO_LEAF1 25 /* Leaf-1 */ +#define IPPROTO_LEAF2 26 /* Leaf-2 */ +#define IPPROTO_RDP 27 /* Reliable Data */ +#define IPPROTO_IRTP 28 /* Reliable Transaction */ +#define IPPROTO_TP 29 /* tp-4 w/ class negotiation */ +#define IPPROTO_BLT 30 /* Bulk Data Transfer */ +#define IPPROTO_NSP 31 /* Network Services */ +#define IPPROTO_INP 32 /* Merit Internodal */ +#define IPPROTO_SEP 33 /* Sequential Exchange */ +#define IPPROTO_3PC 34 /* Third Party Connect */ +#define IPPROTO_IDPR 35 /* InterDomain Policy Routing */ +#define IPPROTO_XTP 36 /* XTP */ +#define IPPROTO_DDP 37 /* Datagram Delivery */ +#define IPPROTO_CMTP 38 /* Control Message Transport */ +#define IPPROTO_TPXX 39 /* TP++ Transport */ +#define IPPROTO_IL 40 /* IL transport protocol */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_IPV6 41 /* IP6 header */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_SDRP 42 /* Source Demand Routing */ +#define IPPROTO_ROUTING 43 /* IP6 routing header */ +#define IPPROTO_FRAGMENT 44 /* IP6 fragmentation header */ +#define IPPROTO_IDRP 45 /* InterDomain Routing*/ +#define IPPROTO_RSVP 46 /* resource reservation */ +#define IPPROTO_GRE 47 /* General Routing Encap. */ +#define IPPROTO_MHRP 48 /* Mobile Host Routing */ +#define IPPROTO_BHA 49 /* BHA */ +#define IPPROTO_ESP 50 /* IP6 Encap Sec. Payload */ +#define IPPROTO_AH 51 /* IP6 Auth Header */ +#define IPPROTO_INLSP 52 /* Integ. Net Layer Security */ +#define IPPROTO_SWIPE 53 /* IP with encryption */ +#define IPPROTO_NHRP 54 /* Next Hop Resolution */ +/* 55-57: Unassigned */ +#define IPPROTO_ICMPV6 58 /* ICMP6 */ +#define IPPROTO_NONE 59 /* IP6 no next header */ +#define IPPROTO_DSTOPTS 60 /* IP6 destination option */ +#define IPPROTO_AHIP 61 /* any host internal protocol */ +#define IPPROTO_CFTP 62 /* CFTP */ +#define IPPROTO_HELLO 63 /* "hello" routing protocol */ +#define IPPROTO_SATEXPAK 64 /* SATNET/Backroom EXPAK */ +#define IPPROTO_KRYPTOLAN 65 /* Kryptolan */ +#define IPPROTO_RVD 66 /* Remote Virtual Disk */ +#define IPPROTO_IPPC 67 /* Pluribus Packet Core */ +#define IPPROTO_ADFS 68 /* Any distributed FS */ +#define IPPROTO_SATMON 69 /* Satnet Monitoring */ +#define IPPROTO_VISA 70 /* VISA Protocol */ +#define IPPROTO_IPCV 71 /* Packet Core Utility */ +#define IPPROTO_CPNX 72 /* Comp. Prot. Net. Executive */ +#define IPPROTO_CPHB 73 /* Comp. Prot. HeartBeat */ +#define IPPROTO_WSN 74 /* Wang Span Network */ +#define IPPROTO_PVP 75 /* Packet Video Protocol */ +#define IPPROTO_BRSATMON 76 /* BackRoom SATNET Monitoring */ +#define IPPROTO_ND 77 /* Sun net disk proto (temp.) */ +#define IPPROTO_WBMON 78 /* WIDEBAND Monitoring */ +#define IPPROTO_WBEXPAK 79 /* WIDEBAND EXPAK */ +#define IPPROTO_EON 80 /* ISO cnlp */ +#define IPPROTO_VMTP 81 /* VMTP */ +#define IPPROTO_SVMTP 82 /* Secure VMTP */ +#define IPPROTO_VINES 83 /* Banyon VINES */ +#define IPPROTO_TTP 84 /* TTP */ +#define IPPROTO_IGP 85 /* NSFNET-IGP */ +#define IPPROTO_DGP 86 /* dissimilar gateway prot. */ +#define IPPROTO_TCF 87 /* TCF */ +#define IPPROTO_IGRP 88 /* Cisco/GXS IGRP */ +#define IPPROTO_OSPFIGP 89 /* OSPFIGP */ +#define IPPROTO_SRPC 90 /* Strite RPC protocol */ +#define IPPROTO_LARP 91 /* Locus Address Resoloution */ +#define IPPROTO_MTP 92 /* Multicast Transport */ +#define IPPROTO_AX25 93 /* AX.25 Frames */ +#define IPPROTO_IPEIP 94 /* IP encapsulated in IP */ +#define IPPROTO_MICP 95 /* Mobile Int.ing control */ +#define IPPROTO_SCCSP 96 /* Semaphore Comm. security */ +#define IPPROTO_ETHERIP 97 /* Ethernet IP encapsulation */ +#define IPPROTO_ENCAP 98 /* encapsulation header */ +#define IPPROTO_APES 99 /* any private encr. scheme */ +#define IPPROTO_GMTP 100 /* GMTP*/ +/* 101-252: Partly Unassigned */ +#define IPPROTO_PIM 103 /* Protocol Independent Mcast */ +#define IPPROTO_IPCOMP 108 /* payload compression (IPComp) */ +#define IPPROTO_PGM 113 /* PGM */ +#define IPPROTO_SCTP 132 /* SCTP */ +/* 253-254: Experimentation and testing; 255: Reserved (RFC3692) */ +/* BSD Private, local use, namespace incursion */ +#define IPPROTO_DIVERT 254 /* divert pseudo-protocol */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define IPPROTO_RAW 255 /* raw IP packet */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPPROTO_MAX 256 + +/* last return value of *_input(), meaning "all job for this pkt is done". */ +#define IPPROTO_DONE 257 +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * Local port number conventions: + * + * When a user does a bind(2) or connect(2) with a port number of zero, + * a non-conflicting local port address is chosen. + * The default range is IPPORT_RESERVED through + * IPPORT_USERRESERVED, although that is settable by sysctl. + * + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this + * default assignment range. + * + * The value IP_PORTRANGE_DEFAULT causes the default behavior. + * + * The value IP_PORTRANGE_HIGH changes the range of candidate port numbers + * into the "high" range. These are reserved for client outbound connections + * which do not want to be filtered by any firewalls. + * + * The value IP_PORTRANGE_LOW changes the range to the "low" are + * that is (by convention) restricted to privileged processes. This + * convention is based on "vouchsafe" principles only. It is only secure + * if you trust the remote host to restrict these ports. + * + * The default range of ports and the high range can be changed by + * sysctl(3). (net.inet.ip.port{hi,low}{first,last}_auto) + * + * Changing those values has bad security implications if you are + * using a a stateless firewall that is allowing packets outside of that + * range in order to allow transparent outgoing connections. + * + * Such a firewall configuration will generally depend on the use of these + * default values. If you change them, you may find your Security + * Administrator looking for you with a heavy object. + * + * For a slightly more orthodox text view on this: + * + * ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers + * + * port numbers are divided into three ranges: + * + * 0 - 1023 Well Known Ports + * 1024 - 49151 Registered Ports + * 49152 - 65535 Dynamic and/or Private Ports + * + */ + +#define __DARWIN_IPPORT_RESERVED 1024 + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * Ports < IPPORT_RESERVED are reserved for + * privileged processes (e.g. root). (IP_PORTRANGE_LOW) + * Ports > IPPORT_USERRESERVED are reserved + * for servers, not necessarily privileged. (IP_PORTRANGE_DEFAULT) + */ +#ifndef IPPORT_RESERVED +#define IPPORT_RESERVED __DARWIN_IPPORT_RESERVED +#endif +#define IPPORT_USERRESERVED 5000 + +/* + * Default local port range to use by setting IP_PORTRANGE_HIGH + */ +#define IPPORT_HIFIRSTAUTO 49152 +#define IPPORT_HILASTAUTO 65535 + +/* + * Scanning for a free reserved port return a value below IPPORT_RESERVED, + * but higher than IPPORT_RESERVEDSTART. Traditionally the start value was + * 512, but that conflicts with some well-known-services that firewalls may + * have a fit if we use. + */ +#define IPPORT_RESERVEDSTART 600 +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Internet address (a structure for historical reasons) + */ +struct in_addr { + in_addr_t s_addr; +}; + +/* + * Definitions of bits in internet address integers. + * On subnets, the decomposition of addresses to host and net parts + * is done according to subnet mask, not the masks here. + */ +#define INADDR_ANY (u_int32_t)0x00000000 +#define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IN_CLASSA(i) (((u_int32_t)(i) & 0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST 0x00ffffff +#define IN_CLASSA_MAX 128 + +#define IN_CLASSB(i) (((u_int32_t)(i) & 0xc0000000) == 0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST 0x0000ffff +#define IN_CLASSB_MAX 65536 + +#define IN_CLASSC(i) (((u_int32_t)(i) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST 0x000000ff + +#define IN_CLASSD(i) (((u_int32_t)(i) & 0xf0000000) == 0xe0000000) +#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ +#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ +#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ +#define IN_MULTICAST(i) IN_CLASSD(i) + +#define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) +#define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) + +#define INADDR_LOOPBACK (u_int32_t)0x7f000001 + +#define INADDR_NONE 0xffffffff /* -1 return */ + +#define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */ +#define INADDR_ALLRPTS_GROUP (u_int32_t)0xe0000016 /* 224.0.0.22, IGMPv3 */ +#define INADDR_CARP_GROUP (u_int32_t)0xe0000012 /* 224.0.0.18 */ +#define INADDR_PFSYNC_GROUP (u_int32_t)0xe00000f0 /* 224.0.0.240 */ +#define INADDR_ALLMDNS_GROUP (u_int32_t)0xe00000fb /* 224.0.0.251 */ +#define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff /* 224.0.0.255 */ + +#ifdef __APPLE__ +#define IN_LINKLOCALNETNUM (u_int32_t)0xA9FE0000 /* 169.254.0.0 */ +#define IN_LINKLOCAL(i) (((u_int32_t)(i) & IN_CLASSB_NET) == IN_LINKLOCALNETNUM) +#define IN_LOOPBACK(i) (((u_int32_t)(i) & 0xff000000) == 0x7f000000) +#define IN_ZERONET(i) (((u_int32_t)(i) & 0xff000000) == 0) + +#define IN_PRIVATE(i) ((((u_int32_t)(i) & 0xff000000) == 0x0a000000) || \ + (((u_int32_t)(i) & 0xfff00000) == 0xac100000) || \ + (((u_int32_t)(i) & 0xffff0000) == 0xc0a80000)) + + +#define IN_LOCAL_GROUP(i) (((u_int32_t)(i) & 0xffffff00) == 0xe0000000) + +#define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i)) +#endif /* __APPLE__ */ + +#define IN_LOOPBACKNET 127 /* official! */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Socket address, internet style. + */ +struct sockaddr_in { + __uint8_t sin_len; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +#define IN_ARE_ADDR_EQUAL(a, b) \ + (bcmp(&(a)->s_addr, &(b)->s_addr, \ + sizeof (struct in_addr)) == 0) + + +#define INET_ADDRSTRLEN 16 + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * Structure used to describe IP options. + * Used to store options internally, to pass them to a process, + * or to restore options retrieved earlier. + * The ip_dst is used for the first-hop gateway when using a source route + * (this gets put into the header proper). + */ +struct ip_opts { + struct in_addr ip_dst; /* first hop, 0 w/o src rt */ + char ip_opts[40]; /* actually variable in size */ +}; + +/* + * Options for use with [gs]etsockopt at the IP level. + * First word of comment is data type; bool is stored in int. + */ +#define IP_OPTIONS 1 /* buf/ip_opts; set/get IP options */ +#define IP_HDRINCL 2 /* int; header is included with data */ +#define IP_TOS 3 /* int; IP type of service and preced. */ +#define IP_TTL 4 /* int; IP time to live */ +#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */ +#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */ +#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */ +#define IP_RETOPTS 8 /* ip_opts; set/get IP options */ +#define IP_MULTICAST_IF 9 /* u_char; set/get IP multicast i/f */ +#define IP_MULTICAST_TTL 10 /* u_char; set/get IP multicast ttl */ +#define IP_MULTICAST_LOOP 11 /* u_char; set/get IP multicast loopback */ +#define IP_ADD_MEMBERSHIP 12 /* ip_mreq; add an IP group membership */ +#define IP_DROP_MEMBERSHIP 13 /* ip_mreq; drop an IP group membership */ +#define IP_MULTICAST_VIF 14 /* set/get IP mcast virt. iface */ +#define IP_RSVP_ON 15 /* enable RSVP in kernel */ +#define IP_RSVP_OFF 16 /* disable RSVP in kernel */ +#define IP_RSVP_VIF_ON 17 /* set RSVP per-vif socket */ +#define IP_RSVP_VIF_OFF 18 /* unset RSVP per-vif socket */ +#define IP_PORTRANGE 19 /* int; range to choose for unspec port */ +#define IP_RECVIF 20 /* bool; receive reception if w/dgram */ +/* for IPSEC */ +#define IP_IPSEC_POLICY 21 /* int; set/get security policy */ +#define IP_FAITH 22 /* deprecated */ +#ifdef __APPLE__ +#define IP_STRIPHDR 23 /* bool: drop receive of raw IP header */ +#endif +#define IP_RECVTTL 24 /* bool; receive reception TTL w/dgram */ +#define IP_BOUND_IF 25 /* int; set/get bound interface */ +#define IP_PKTINFO 26 /* get pktinfo on recv socket, set src on sent dgram */ +#define IP_RECVPKTINFO IP_PKTINFO /* receive pktinfo w/dgram */ +#define IP_RECVTOS 27 /* bool; receive IP TOS w/dgram */ +#define IP_DONTFRAG 28 /* don't fragment packet */ + +#define IP_FW_ADD 40 /* add a firewall rule to chain */ +#define IP_FW_DEL 41 /* delete a firewall rule from chain */ +#define IP_FW_FLUSH 42 /* flush firewall rule chain */ +#define IP_FW_ZERO 43 /* clear single/all firewall counter(s) */ +#define IP_FW_GET 44 /* get entire firewall rule chain */ +#define IP_FW_RESETLOG 45 /* reset logging counters */ + +/* These older firewall socket option codes are maintained for backward compatibility. */ +#define IP_OLD_FW_ADD 50 /* add a firewall rule to chain */ +#define IP_OLD_FW_DEL 51 /* delete a firewall rule from chain */ +#define IP_OLD_FW_FLUSH 52 /* flush firewall rule chain */ +#define IP_OLD_FW_ZERO 53 /* clear single/all firewall counter(s) */ +#define IP_OLD_FW_GET 54 /* get entire firewall rule chain */ +#define IP_NAT__XXX 55 /* set/get NAT opts XXX Deprecated, do not use */ +#define IP_OLD_FW_RESETLOG 56 /* reset logging counters */ + +#define IP_DUMMYNET_CONFIGURE 60 /* add/configure a dummynet pipe */ +#define IP_DUMMYNET_DEL 61 /* delete a dummynet pipe from chain */ +#define IP_DUMMYNET_FLUSH 62 /* flush dummynet */ +#define IP_DUMMYNET_GET 64 /* get entire dummynet pipes */ + +#define IP_TRAFFIC_MGT_BACKGROUND 65 /* int*; get background IO flags; set background IO */ +#define IP_MULTICAST_IFINDEX 66 /* int*; set/get IP multicast i/f index */ + +/* IPv4 Source Filter Multicast API [RFC3678] */ +#define IP_ADD_SOURCE_MEMBERSHIP 70 /* join a source-specific group */ +#define IP_DROP_SOURCE_MEMBERSHIP 71 /* drop a single source */ +#define IP_BLOCK_SOURCE 72 /* block a source */ +#define IP_UNBLOCK_SOURCE 73 /* unblock a source */ + +/* The following option is private; do not use it from user applications. */ +#define IP_MSFILTER 74 /* set/get filter list */ + +/* Protocol Independent Multicast API [RFC3678] */ +#define MCAST_JOIN_GROUP 80 /* join an any-source group */ +#define MCAST_LEAVE_GROUP 81 /* leave all sources for group */ +#define MCAST_JOIN_SOURCE_GROUP 82 /* join a source-specific group */ +#define MCAST_LEAVE_SOURCE_GROUP 83 /* leave a single source */ +#define MCAST_BLOCK_SOURCE 84 /* block a source */ +#define MCAST_UNBLOCK_SOURCE 85 /* unblock a source */ + + +/* + * Defaults and limits for options + */ +#define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */ +#define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ + +/* + * The imo_membership vector for each socket is now dynamically allocated at + * run-time, bounded by USHRT_MAX, and is reallocated when needed, sized + * according to a power-of-two increment. + */ +#define IP_MIN_MEMBERSHIPS 31 +#define IP_MAX_MEMBERSHIPS 4095 + +/* + * Default resource limits for IPv4 multicast source filtering. + * These may be modified by sysctl. + */ +#define IP_MAX_GROUP_SRC_FILTER 512 /* sources per group */ +#define IP_MAX_SOCK_SRC_FILTER 128 /* sources per socket/group */ +#define IP_MAX_SOCK_MUTE_FILTER 128 /* XXX no longer used */ + +/* + * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP. + */ +struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* + * Modified argument structure for IP_MULTICAST_IF, obtained from Linux. + * This is used to specify an interface index for multicast sends, as + * the IPv4 legacy APIs do not support this (unless IP_SENDIF is available). + */ +struct ip_mreqn { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_address; /* local IP address of interface */ + int imr_ifindex; /* Interface index; cast to uint32_t */ +}; + +#pragma pack(4) +/* + * Argument structure for IPv4 Multicast Source Filter APIs. [RFC3678] + */ +struct ip_mreq_source { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_sourceaddr; /* IP address of source */ + struct in_addr imr_interface; /* local IP address of interface */ +}; + +/* + * Argument structures for Protocol-Independent Multicast Source + * Filter APIs. [RFC3678] + */ +struct group_req { + uint32_t gr_interface; /* interface index */ + struct sockaddr_storage gr_group; /* group address */ +}; + +struct group_source_req { + uint32_t gsr_interface; /* interface index */ + struct sockaddr_storage gsr_group; /* group address */ + struct sockaddr_storage gsr_source; /* source address */ +}; + +#ifndef __MSFILTERREQ_DEFINED +#define __MSFILTERREQ_DEFINED +/* + * The following structure is private; do not use it from user applications. + * It is used to communicate IP_MSFILTER/IPV6_MSFILTER information between + * the RFC 3678 libc functions and the kernel. + */ +struct __msfilterreq { + uint32_t msfr_ifindex; /* interface index */ + uint32_t msfr_fmode; /* filter mode for group */ + uint32_t msfr_nsrcs; /* # of sources in msfr_srcs */ + uint32_t __msfr_align; + struct sockaddr_storage msfr_group; /* group address */ + struct sockaddr_storage *msfr_srcs; +}; + +#endif /* __MSFILTERREQ_DEFINED */ + +#pragma pack() +struct sockaddr; + +/* + * Advanced (Full-state) APIs [RFC3678] + * The RFC specifies uint_t for the 6th argument to [sg]etsourcefilter(). + * We use uint32_t here to be consistent. + */ +int setipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t, + uint32_t, struct in_addr *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +int getipv4sourcefilter(int, struct in_addr, struct in_addr, uint32_t *, + uint32_t *, struct in_addr *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +int setsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, + uint32_t, uint32_t, struct sockaddr_storage *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +int getsourcefilter(int, uint32_t, struct sockaddr *, socklen_t, + uint32_t *, uint32_t *, struct sockaddr_storage *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); + +/* + * Filter modes; also used to represent per-socket filter mode internally. + */ +#define MCAST_UNDEFINED 0 /* fmode: not yet defined */ +#define MCAST_INCLUDE 1 /* fmode: include these source(s) */ +#define MCAST_EXCLUDE 2 /* fmode: exclude these source(s) */ + +/* + * Argument for IP_PORTRANGE: + * - which range to search when port is unspecified at bind() or connect() + */ +#define IP_PORTRANGE_DEFAULT 0 /* default range */ +#define IP_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ +#define IP_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ + + +/* + * IP_PKTINFO: Packet information (equivalent to RFC2292 sec 5 for IPv4) + * This structure is used for + * + * 1) Receiving ancilliary data about the datagram if IP_PKTINFO sockopt is + * set on the socket. In this case ipi_ifindex will contain the interface + * index the datagram was received on, ipi_addr is the IP address the + * datagram was received to. + * + * 2) Sending a datagram using a specific interface or IP source address. + * if ipi_ifindex is set to non-zero when in_pktinfo is passed as + * ancilliary data of type IP_PKTINFO, this will be used as the source + * interface to send the datagram from. If ipi_ifindex is null, ip_spec_dst + * will be used for the source address. + * + * Note: if IP_BOUND_IF is set on the socket, ipi_ifindex in the ancillary + * IP_PKTINFO option silently overrides the bound interface when it is + * specified during send time. + */ +struct in_pktinfo { + unsigned int ipi_ifindex; /* send/recv interface index */ + struct in_addr ipi_spec_dst; /* Local address */ + struct in_addr ipi_addr; /* IP Header dst address */ +}; + +/* + * Definitions for inet sysctl operations. + * + * Third level is protocol number. + * Fourth level is desired variable within that protocol. + */ +#define IPPROTO_MAXID (IPPROTO_AH + 1) /* don't list to IPPROTO_MAX */ + + +/* + * Names for IP sysctl objects + */ +#define IPCTL_FORWARDING 1 /* act as router */ +#define IPCTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ +#define IPCTL_DEFTTL 3 /* default TTL */ +#ifdef notyet +#define IPCTL_DEFMTU 4 /* default MTU */ +#endif +#define IPCTL_RTEXPIRE 5 /* cloned route expiration time */ +#define IPCTL_RTMINEXPIRE 6 /* min value for expiration time */ +#define IPCTL_RTMAXCACHE 7 /* trigger level for dynamic expire */ +#define IPCTL_SOURCEROUTE 8 /* may perform source routes */ +#define IPCTL_DIRECTEDBROADCAST 9 /* may re-broadcast received packets */ +#define IPCTL_INTRQMAXLEN 10 /* max length of netisr queue */ +#define IPCTL_INTRQDROPS 11 /* number of netisr q drops */ +#define IPCTL_STATS 12 /* ipstat structure */ +#define IPCTL_ACCEPTSOURCEROUTE 13 /* may accept source routed packets */ +#define IPCTL_FASTFORWARDING 14 /* use fast IP forwarding code */ +#define IPCTL_KEEPFAITH 15 /* deprecated */ +#define IPCTL_GIF_TTL 16 /* default TTL for gif encap packet */ +#define IPCTL_MAXID 17 + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* INET6 stuff */ +#define __KAME_NETINET_IN_H_INCLUDED_ +#include +#undef __KAME_NETINET_IN_H_INCLUDED_ + + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +__BEGIN_DECLS +int bindresvport(int, struct sockaddr_in *); +struct sockaddr; +int bindresvport_sa(int, struct sockaddr *); +__END_DECLS +#endif +#endif /* _NETINET_IN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/netinet/tcp.h b/lib/libc/include/aarch64-macos-gnu/netinet/tcp.h new file mode 100644 index 0000000000..1d1030c509 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/netinet/tcp.h @@ -0,0 +1,285 @@ +/* + * Copyright (c) 2000-2018 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)tcp.h 8.1 (Berkeley) 6/10/93 + * $FreeBSD: src/sys/netinet/tcp.h,v 1.13.2.3 2001/03/01 22:08:42 jlemon Exp $ + */ + +#ifndef _NETINET_TCP_H_ +#define _NETINET_TCP_H_ +#include + +#include +#include /* __uint32_t */ + +#include + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +typedef __uint32_t tcp_seq; +typedef __uint32_t tcp_cc; /* connection count per rfc1644 */ + +#define tcp6_seq tcp_seq /* for KAME src sync over BSD*'s */ +#define tcp6hdr tcphdr /* for KAME src sync over BSD*'s */ + +/* + * TCP header. + * Per RFC 793, September, 1981. + */ +struct tcphdr { + unsigned short th_sport; /* source port */ + unsigned short th_dport; /* destination port */ + tcp_seq th_seq; /* sequence number */ + tcp_seq th_ack; /* acknowledgement number */ +#if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN + unsigned int th_x2:4, /* (unused) */ + th_off:4; /* data offset */ +#endif +#if __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN + unsigned int th_off:4, /* data offset */ + th_x2:4; /* (unused) */ +#endif + unsigned char th_flags; +#define TH_FIN 0x01 +#define TH_SYN 0x02 +#define TH_RST 0x04 +#define TH_PUSH 0x08 +#define TH_ACK 0x10 +#define TH_URG 0x20 +#define TH_ECE 0x40 +#define TH_CWR 0x80 +#define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR) +#define TH_ACCEPT (TH_FIN|TH_SYN|TH_RST|TH_ACK) + + unsigned short th_win; /* window */ + unsigned short th_sum; /* checksum */ + unsigned short th_urp; /* urgent pointer */ +}; + +#define TCPOPT_EOL 0 +#define TCPOPT_NOP 1 +#define TCPOPT_MAXSEG 2 +#define TCPOLEN_MAXSEG 4 +#define TCPOPT_WINDOW 3 +#define TCPOLEN_WINDOW 3 +#define TCPOPT_SACK_PERMITTED 4 /* Experimental */ +#define TCPOLEN_SACK_PERMITTED 2 +#define TCPOPT_SACK 5 /* Experimental */ +#define TCPOLEN_SACK 8 /* len of sack block */ +#define TCPOPT_TIMESTAMP 8 +#define TCPOLEN_TIMESTAMP 10 +#define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ +#define TCPOPT_TSTAMP_HDR \ + (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) + +#define MAX_TCPOPTLEN 40 /* Absolute maximum TCP options len */ + +#define TCPOPT_CC 11 /* CC options: RFC-1644 */ +#define TCPOPT_CCNEW 12 +#define TCPOPT_CCECHO 13 +#define TCPOLEN_CC 6 +#define TCPOLEN_CC_APPA (TCPOLEN_CC+2) +#define TCPOPT_CC_HDR(ccopt) \ + (TCPOPT_NOP<<24|TCPOPT_NOP<<16|(ccopt)<<8|TCPOLEN_CC) +#define TCPOPT_SIGNATURE 19 /* Keyed MD5: RFC 2385 */ +#define TCPOLEN_SIGNATURE 18 +#if MPTCP +#define TCPOPT_MULTIPATH 30 +#endif + +#define TCPOPT_FASTOPEN 34 +#define TCPOLEN_FASTOPEN_REQ 2 + +/* Option definitions */ +#define TCPOPT_SACK_PERMIT_HDR \ +(TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK_PERMITTED<<8|TCPOLEN_SACK_PERMITTED) +#define TCPOPT_SACK_HDR (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_SACK<<8) +/* Miscellaneous constants */ +#define MAX_SACK_BLKS 6 /* Max # SACK blocks stored at sender side */ + +/* + * A SACK option that specifies n blocks will have a length of (8*n + 2) + * bytes, so the 40 bytes available for TCP options can specify a + * maximum of 4 blocks. + */ + +#define TCP_MAX_SACK 4 /* MAX # SACKs sent in any segment */ + + +/* + * Default maximum segment size for TCP. + * With an IP MTU of 576, this is 536, + * but 512 is probably more convenient. + * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). + */ +#define TCP_MSS 512 + +/* + * TCP_MINMSS is defined to be 216 which is fine for the smallest + * link MTU (256 bytes, SLIP interface) in the Internet. + * However it is very unlikely to come across such low MTU interfaces + * these days (anno dato 2004). + * Probably it can be set to 512 without ill effects. But we play safe. + * See tcp_subr.c tcp_minmss SYSCTL declaration for more comments. + * Setting this to "0" disables the minmss check. + */ +#define TCP_MINMSS 216 + +/* + * Default maximum segment size for TCP6. + * With an IP6 MSS of 1280, this is 1220, + * but 1024 is probably more convenient. (xxx kazu in doubt) + * This should be defined as MIN(1024, IP6_MSS - sizeof (struct tcpip6hdr)) + */ +#define TCP6_MSS 1024 + +#define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ +#define TTCP_CLIENT_SND_WND 4096 /* dflt send window for T/TCP client */ + +#define TCP_MAX_WINSHIFT 14 /* maximum window shift */ + +#define TCP_MAXHLEN (0xf<<2) /* max length of header in bytes */ +#define TCP_MAXOLEN (TCP_MAXHLEN - sizeof(struct tcphdr)) +/* max space left for options */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * User-settable options (used with setsockopt). + */ +#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define TCP_MAXSEG 0x02 /* set maximum segment size */ +#define TCP_NOPUSH 0x04 /* don't push last block of write */ +#define TCP_NOOPT 0x08 /* don't use TCP options */ +#define TCP_KEEPALIVE 0x10 /* idle time used when SO_KEEPALIVE is enabled */ +#define TCP_CONNECTIONTIMEOUT 0x20 /* connection timeout */ +#define PERSIST_TIMEOUT 0x40 /* time after which a connection in + * persist timeout will terminate. + * see draft-ananth-tcpm-persist-02.txt + */ +#define TCP_RXT_CONNDROPTIME 0x80 /* time after which tcp retransmissions will be + * stopped and the connection will be dropped + */ +#define TCP_RXT_FINDROP 0x100 /* when this option is set, drop a connection + * after retransmitting the FIN 3 times. It will + * prevent holding too many mbufs in socket + * buffer queues. + */ +#define TCP_KEEPINTVL 0x101 /* interval between keepalives */ +#define TCP_KEEPCNT 0x102 /* number of keepalives before close */ +#define TCP_SENDMOREACKS 0x103 /* always ack every other packet */ +#define TCP_ENABLE_ECN 0x104 /* Enable ECN on a connection */ +#define TCP_FASTOPEN 0x105 /* Enable/Disable TCP Fastopen on this socket */ +#define TCP_CONNECTION_INFO 0x106 /* State of TCP connection */ + + + +#define TCP_NOTSENT_LOWAT 0x201 /* Low water mark for TCP unsent data */ + + +struct tcp_connection_info { + u_int8_t tcpi_state; /* connection state */ + u_int8_t tcpi_snd_wscale; /* Window scale for send window */ + u_int8_t tcpi_rcv_wscale; /* Window scale for receive window */ + u_int8_t __pad1; + u_int32_t tcpi_options; /* TCP options supported */ +#define TCPCI_OPT_TIMESTAMPS 0x00000001 /* Timestamps enabled */ +#define TCPCI_OPT_SACK 0x00000002 /* SACK enabled */ +#define TCPCI_OPT_WSCALE 0x00000004 /* Window scaling enabled */ +#define TCPCI_OPT_ECN 0x00000008 /* ECN enabled */ + u_int32_t tcpi_flags; /* flags */ +#define TCPCI_FLAG_LOSSRECOVERY 0x00000001 +#define TCPCI_FLAG_REORDERING_DETECTED 0x00000002 + u_int32_t tcpi_rto; /* retransmit timeout in ms */ + u_int32_t tcpi_maxseg; /* maximum segment size supported */ + u_int32_t tcpi_snd_ssthresh; /* slow start threshold in bytes */ + u_int32_t tcpi_snd_cwnd; /* send congestion window in bytes */ + u_int32_t tcpi_snd_wnd; /* send widnow in bytes */ + u_int32_t tcpi_snd_sbbytes; /* bytes in send socket buffer, including in-flight data */ + u_int32_t tcpi_rcv_wnd; /* receive window in bytes*/ + u_int32_t tcpi_rttcur; /* most recent RTT in ms */ + u_int32_t tcpi_srtt; /* average RTT in ms */ + u_int32_t tcpi_rttvar; /* RTT variance */ + u_int32_t + tcpi_tfo_cookie_req:1, /* Cookie requested? */ + tcpi_tfo_cookie_rcv:1, /* Cookie received? */ + tcpi_tfo_syn_loss:1, /* Fallback to reg. TCP after SYN-loss */ + tcpi_tfo_syn_data_sent:1, /* SYN+data has been sent out */ + tcpi_tfo_syn_data_acked:1, /* SYN+data has been fully acknowledged */ + tcpi_tfo_syn_data_rcv:1, /* Server received SYN+data with a valid cookie */ + tcpi_tfo_cookie_req_rcv:1, /* Server received cookie-request */ + tcpi_tfo_cookie_sent:1, /* Server announced cookie */ + tcpi_tfo_cookie_invalid:1, /* Server received an invalid cookie */ + tcpi_tfo_cookie_wrong:1, /* Our sent cookie was wrong */ + tcpi_tfo_no_cookie_rcv:1, /* We did not receive a cookie upon our request */ + tcpi_tfo_heuristics_disable:1, /* TFO-heuristics disabled it */ + tcpi_tfo_send_blackhole:1, /* A sending-blackhole got detected */ + tcpi_tfo_recv_blackhole:1, /* A receiver-blackhole got detected */ + tcpi_tfo_onebyte_proxy:1, /* A proxy acknowledges all but one byte of the SYN */ + __pad2:17; + u_int64_t tcpi_txpackets __attribute__((aligned(8))); + u_int64_t tcpi_txbytes __attribute__((aligned(8))); + u_int64_t tcpi_txretransmitbytes __attribute__((aligned(8))); + u_int64_t tcpi_rxpackets __attribute__((aligned(8))); + u_int64_t tcpi_rxbytes __attribute__((aligned(8))); + u_int64_t tcpi_rxoutoforderbytes __attribute__((aligned(8))); + u_int64_t tcpi_txretransmitpackets __attribute__((aligned(8))); +}; +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/netinet6/in6.h b/lib/libc/include/aarch64-macos-gnu/netinet6/in6.h new file mode 100644 index 0000000000..b912e8dbe7 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/netinet6/in6.h @@ -0,0 +1,681 @@ +/* + * Copyright (c) 2008-2020 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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. + */ + +/* + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)in.h 8.3 (Berkeley) 1/3/94 + */ + +#ifndef __KAME_NETINET_IN_H_INCLUDED_ +#error "do not include netinet6/in6.h directly, include netinet/in.h. " \ + " see RFC2553" +#endif + +#ifndef _NETINET6_IN6_H_ +#define _NETINET6_IN6_H_ +#include + +#include +#include + +/* + * Identification of the network protocol stack + * for *BSD-current/release: http://www.kame.net/dev/cvsweb.cgi/kame/COVERAGE + * has the table of implementation/integration differences. + */ +#define __KAME__ +#define __KAME_VERSION "2009/apple-darwin" + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * Local port number conventions: + * + * Ports < IPPORT_RESERVED are reserved for privileged processes (e.g. root), + * unless a kernel is compiled with IPNOPRIVPORTS defined. + * + * When a user does a bind(2) or connect(2) with a port number of zero, + * a non-conflicting local port address is chosen. + * + * The default range is IPPORT_ANONMIN to IPPORT_ANONMAX, although + * that is settable by sysctl(3); net.inet.ip.anonportmin and + * net.inet.ip.anonportmax respectively. + * + * A user may set the IPPROTO_IP option IP_PORTRANGE to change this + * default assignment range. + * + * The value IP_PORTRANGE_DEFAULT causes the default behavior. + * + * The value IP_PORTRANGE_HIGH is the same as IP_PORTRANGE_DEFAULT, + * and exists only for FreeBSD compatibility purposes. + * + * The value IP_PORTRANGE_LOW changes the range to the "low" are + * that is (by convention) restricted to privileged processes. + * This convention is based on "vouchsafe" principles only. + * It is only secure if you trust the remote host to restrict these ports. + * The range is IPPORT_RESERVEDMIN to IPPORT_RESERVEDMAX. + */ + +#define IPV6PORT_RESERVED 1024 +#define IPV6PORT_ANONMIN 49152 +#define IPV6PORT_ANONMAX 65535 +#define IPV6PORT_RESERVEDMIN 600 +#define IPV6PORT_RESERVEDMAX (IPV6PORT_RESERVED-1) +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * IPv6 address + */ +typedef struct in6_addr { + union { + __uint8_t __u6_addr8[16]; + __uint16_t __u6_addr16[8]; + __uint32_t __u6_addr32[4]; + } __u6_addr; /* 128-bit IP6 address */ +} in6_addr_t; + +#define s6_addr __u6_addr.__u6_addr8 + +#define INET6_ADDRSTRLEN 46 + +/* + * Socket address for IPv6 + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SIN6_LEN +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +struct sockaddr_in6 { + __uint8_t sin6_len; /* length of this struct(sa_family_t) */ + sa_family_t sin6_family; /* AF_INET6 (sa_family_t) */ + in_port_t sin6_port; /* Transport layer port # (in_port_t) */ + __uint32_t sin6_flowinfo; /* IP6 flow information */ + struct in6_addr sin6_addr; /* IP6 address */ + __uint32_t sin6_scope_id; /* scope zone index */ +}; + + + + + +/* + * Definition of some useful macros to handle IP6 addresses + */ +#define IN6ADDR_ANY_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}} +#define IN6ADDR_LOOPBACK_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IN6ADDR_NODELOCAL_ALLNODES_INIT \ + {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#define IN6ADDR_INTFACELOCAL_ALLNODES_INIT \ + {{{ 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#define IN6ADDR_LINKLOCAL_ALLNODES_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}} +#define IN6ADDR_LINKLOCAL_ALLROUTERS_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }}} +#define IN6ADDR_LINKLOCAL_ALLV2ROUTERS_INIT \ + {{{ 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16 }}} +#define IN6ADDR_V4MAPPED_INIT \ + {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }}} +#define IN6ADDR_MULTICAST_PREFIX IN6MASK8 +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +extern const struct in6_addr in6addr_nodelocal_allnodes; +extern const struct in6_addr in6addr_linklocal_allnodes; +extern const struct in6_addr in6addr_linklocal_allrouters; +extern const struct in6_addr in6addr_linklocal_allv2routers; +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * Equality + * NOTE: Some of kernel programming environment (for example, openbsd/sparc) + * does not supply memcmp(). For userland memcmp() is preferred as it is + * in ANSI standard. + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IN6_ARE_ADDR_EQUAL(a, b) \ + (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof (struct in6_addr)) \ + == 0) +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + + +/* + * Unspecified + */ +#define IN6_IS_ADDR_UNSPECIFIED(a) \ + ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == 0)) + +/* + * Loopback + */ +#define IN6_IS_ADDR_LOOPBACK(a) \ + ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1))) + +/* + * IPv4 compatible + */ +#define IN6_IS_ADDR_V4COMPAT(a) \ + ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) != 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) != ntohl(1))) + +/* + * Mapped + */ +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \ + (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == \ + ntohl(0x0000ffff))) + +/* + * 6to4 + */ +#define IN6_IS_ADDR_6TO4(x) (ntohs((x)->s6_addr16[0]) == 0x2002) + +/* + * KAME Scope Values + */ + +#define __IPV6_ADDR_SCOPE_NODELOCAL 0x01 +#define __IPV6_ADDR_SCOPE_INTFACELOCAL 0x01 +#define __IPV6_ADDR_SCOPE_LINKLOCAL 0x02 +#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05 +#define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08 /* just used in this file */ +#define __IPV6_ADDR_SCOPE_GLOBAL 0x0e + +/* + * Unicast Scope + * Note that we must check topmost 10 bits only, not 16 bits (see RFC2373). + */ +#define IN6_IS_ADDR_LINKLOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80)) +#define IN6_IS_ADDR_SITELOCAL(a) \ + (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0)) + +/* + * Multicast + */ +#define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff) + +#define IPV6_ADDR_MC_FLAGS(a) ((a)->s6_addr[1] & 0xf0) + +#define IPV6_ADDR_MC_FLAGS_TRANSIENT 0x10 +#define IPV6_ADDR_MC_FLAGS_PREFIX 0x20 +#define IPV6_ADDR_MC_FLAGS_UNICAST_BASED (IPV6_ADDR_MC_FLAGS_TRANSIENT | IPV6_ADDR_MC_FLAGS_PREFIX) + +#define IN6_IS_ADDR_UNICAST_BASED_MULTICAST(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_FLAGS(a) == IPV6_ADDR_MC_FLAGS_UNICAST_BASED)) + +/* + * Unique Local IPv6 Unicast Addresses (per RFC 4193) + */ +#define IN6_IS_ADDR_UNIQUE_LOCAL(a) \ + (((a)->s6_addr[0] == 0xfc) || ((a)->s6_addr[0] == 0xfd)) + +#define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f) + +/* + * Multicast Scope + */ +#define IN6_IS_ADDR_MC_NODELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL)) +#define IN6_IS_ADDR_MC_LINKLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (IPV6_ADDR_MC_FLAGS(a) != IPV6_ADDR_MC_FLAGS_UNICAST_BASED) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL)) +#define IN6_IS_ADDR_MC_SITELOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL)) +#define IN6_IS_ADDR_MC_ORGLOCAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL)) +#define IN6_IS_ADDR_MC_GLOBAL(a) \ + (IN6_IS_ADDR_MULTICAST(a) && \ + (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL)) + + + + +/* + * Options for use with [gs]etsockopt at the IPV6 level. + * First word of comment is data type; bool is stored in int. + */ +/* no hdrincl */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * RFC 3542 define the following socket options in a manner incompatible + * with RFC 2292: + * IPV6_PKTINFO + * IPV6_HOPLIMIT + * IPV6_NEXTHOP + * IPV6_HOPOPTS + * IPV6_DSTOPTS + * IPV6_RTHDR + * + * To use the new IPv6 Sockets options introduced by RFC 3542 + * the constant __APPLE_USE_RFC_3542 must be defined before + * including + * + * To use the old IPv6 Sockets options from RFC 2292 + * the constant __APPLE_USE_RFC_2292 must be defined before + * including + * + * Note that eventually RFC 3542 is going to be the + * default and RFC 2292 will be obsolete. + */ + +#if defined(__APPLE_USE_RFC_3542) && defined(__APPLE_USE_RFC_2292) +#error "__APPLE_USE_RFC_3542 and __APPLE_USE_RFC_2292 cannot be both defined" +#endif + +#if 0 /* the followings are relic in IPv4 and hence are disabled */ +#define IPV6_OPTIONS 1 /* buf/ip6_opts; set/get IP6 options */ +#define IPV6_RECVOPTS 5 /* bool; receive all IP6 opts w/dgram */ +#define IPV6_RECVRETOPTS 6 /* bool; receive IP6 opts for response */ +#define IPV6_RECVDSTADDR 7 /* bool; receive IP6 dst addr w/dgram */ +#define IPV6_RETOPTS 8 /* ip6_opts; set/get IP6 options */ +#endif /* 0 */ +#define IPV6_SOCKOPT_RESERVED1 3 /* reserved for future use */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#define IPV6_UNICAST_HOPS 4 /* int; IP6 hops */ +#define IPV6_MULTICAST_IF 9 /* u_int; set/get IP6 multicast i/f */ +#define IPV6_MULTICAST_HOPS 10 /* int; set/get IP6 multicast hops */ +#define IPV6_MULTICAST_LOOP 11 /* u_int; set/get IP6 mcast loopback */ +#define IPV6_JOIN_GROUP 12 /* ip6_mreq; join a group membership */ +#define IPV6_LEAVE_GROUP 13 /* ip6_mreq; leave a group membership */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPV6_PORTRANGE 14 /* int; range to choose for unspec port */ +#define ICMP6_FILTER 18 /* icmp6_filter; icmp6 filter */ +#define IPV6_2292PKTINFO 19 /* bool; send/recv if, src/dst addr */ +#define IPV6_2292HOPLIMIT 20 /* bool; hop limit */ +#define IPV6_2292NEXTHOP 21 /* bool; next hop addr */ +#define IPV6_2292HOPOPTS 22 /* bool; hop-by-hop option */ +#define IPV6_2292DSTOPTS 23 /* bool; destinaion option */ +#define IPV6_2292RTHDR 24 /* ip6_rthdr: routing header */ + +/* buf/cmsghdr; set/get IPv6 options [obsoleted by RFC3542] */ +#define IPV6_2292PKTOPTIONS 25 + +#ifdef __APPLE_USE_RFC_2292 +#define IPV6_PKTINFO IPV6_2292PKTINFO +#define IPV6_HOPLIMIT IPV6_2292HOPLIMIT +#define IPV6_NEXTHOP IPV6_2292NEXTHOP +#define IPV6_HOPOPTS IPV6_2292HOPOPTS +#define IPV6_DSTOPTS IPV6_2292DSTOPTS +#define IPV6_RTHDR IPV6_2292RTHDR +#define IPV6_PKTOPTIONS IPV6_2292PKTOPTIONS +#endif /* __APPLE_USE_RFC_2292 */ + +#define IPV6_CHECKSUM 26 /* int; checksum offset for raw socket */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#define IPV6_V6ONLY 27 /* bool; only bind INET6 at wildcard bind */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define IPV6_BINDV6ONLY IPV6_V6ONLY + + +#if 1 /* IPSEC */ +#define IPV6_IPSEC_POLICY 28 /* struct; get/set security policy */ +#endif /* 1 */ +#define IPV6_FAITH 29 /* deprecated */ + +#if 1 /* IPV6FIREWALL */ +#define IPV6_FW_ADD 30 /* add a firewall rule to chain */ +#define IPV6_FW_DEL 31 /* delete a firewall rule from chain */ +#define IPV6_FW_FLUSH 32 /* flush firewall rule chain */ +#define IPV6_FW_ZERO 33 /* clear single/all firewall counter(s) */ +#define IPV6_FW_GET 34 /* get entire firewall rule chain */ +#endif /* 1 */ + +/* + * APPLE: NOTE the value of those 2 options is kept unchanged from + * previous version of darwin/OS X for binary compatibility reasons + * and differ from FreeBSD (values 57 and 61). See below. + */ +#define IPV6_RECVTCLASS 35 /* bool; recv traffic class values */ +#define IPV6_TCLASS 36 /* int; send traffic class value */ + +#ifdef __APPLE_USE_RFC_3542 +/* new socket options introduced in RFC3542 */ +/* + * ip6_dest; send dst option before rthdr + * APPLE: Value purposely different than FreeBSD (35) to avoid + * collision with definition of IPV6_RECVTCLASS in previous + * darwin implementations + */ +#define IPV6_RTHDRDSTOPTS 57 + +/* + * bool; recv if, dst addr + * APPLE: Value purposely different than FreeBSD(36) to avoid + * collision with definition of IPV6_TCLASS in previous + * darwin implementations + */ +#define IPV6_RECVPKTINFO 61 + +#define IPV6_RECVHOPLIMIT 37 /* bool; recv hop limit */ +#define IPV6_RECVRTHDR 38 /* bool; recv routing header */ +#define IPV6_RECVHOPOPTS 39 /* bool; recv hop-by-hop option */ +#define IPV6_RECVDSTOPTS 40 /* bool; recv dst option after rthdr */ + +#define IPV6_USE_MIN_MTU 42 /* bool; send packets at the minimum MTU */ +#define IPV6_RECVPATHMTU 43 /* bool; notify an according MTU */ + +/* + * mtuinfo; get the current path MTU (sopt), 4 bytes int; + * MTU notification (cmsg) + */ +#define IPV6_PATHMTU 44 + +#if 0 /* obsoleted during 2292bis -> 3542 */ +/* no data; ND reachability confirm (cmsg only/not in of RFC3542) */ +#define IPV6_REACHCONF 45 +#endif +/* more new socket options introduced in RFC3542 */ +#define IPV6_3542PKTINFO 46 /* in6_pktinfo; send if, src addr */ +#define IPV6_3542HOPLIMIT 47 /* int; send hop limit */ +#define IPV6_3542NEXTHOP 48 /* sockaddr; next hop addr */ +#define IPV6_3542HOPOPTS 49 /* ip6_hbh; send hop-by-hop option */ +#define IPV6_3542DSTOPTS 50 /* ip6_dest; send dst option befor rthdr */ +#define IPV6_3542RTHDR 51 /* ip6_rthdr; send routing header */ + +#define IPV6_PKTINFO IPV6_3542PKTINFO +#define IPV6_HOPLIMIT IPV6_3542HOPLIMIT +#define IPV6_NEXTHOP IPV6_3542NEXTHOP +#define IPV6_HOPOPTS IPV6_3542HOPOPTS +#define IPV6_DSTOPTS IPV6_3542DSTOPTS +#define IPV6_RTHDR IPV6_3542RTHDR + +#define IPV6_AUTOFLOWLABEL 59 /* bool; attach flowlabel automagically */ + +#define IPV6_DONTFRAG 62 /* bool; disable IPv6 fragmentation */ + +/* int; prefer temporary addresses as the source address. */ +#define IPV6_PREFER_TEMPADDR 63 + +/* + * The following option is private; do not use it from user applications. + * It is deliberately defined to the same value as IP_MSFILTER. + */ +#define IPV6_MSFILTER 74 /* struct __msfilterreq; */ +#endif /* __APPLE_USE_RFC_3542 */ + +#define IPV6_BOUND_IF 125 /* int; set/get bound interface */ + + +/* to define items, should talk with KAME guys first, for *BSD compatibility */ + +#define IPV6_RTHDR_LOOSE 0 /* this hop need not be a neighbor. */ +#define IPV6_RTHDR_STRICT 1 /* this hop must be a neighbor. */ +#define IPV6_RTHDR_TYPE_0 0 /* IPv6 routing header type 0 */ + +/* + * Defaults and limits for options + */ +#define IPV6_DEFAULT_MULTICAST_HOPS 1 /* normally limit m'casts to 1 hop */ +#define IPV6_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */ + +/* + * The im6o_membership vector for each socket is now dynamically allocated at + * run-time, bounded by USHRT_MAX, and is reallocated when needed, sized + * according to a power-of-two increment. + */ +#define IPV6_MIN_MEMBERSHIPS 31 +#define IPV6_MAX_MEMBERSHIPS 4095 + +/* + * Default resource limits for IPv6 multicast source filtering. + * These may be modified by sysctl. + */ +#define IPV6_MAX_GROUP_SRC_FILTER 512 /* sources per group */ +#define IPV6_MAX_SOCK_SRC_FILTER 128 /* sources per socket/group */ + +/* + * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP. + */ +struct ipv6_mreq { + struct in6_addr ipv6mr_multiaddr; + unsigned int ipv6mr_interface; +}; + +/* + * IPV6_2292PKTINFO: Packet information(RFC2292 sec 5) + */ +struct in6_pktinfo { + struct in6_addr ipi6_addr; /* src/dst IPv6 address */ + unsigned int ipi6_ifindex; /* send/recv interface index */ +}; + +/* + * Control structure for IPV6_RECVPATHMTU socket option. + */ +struct ip6_mtuinfo { + struct sockaddr_in6 ip6m_addr; /* or sockaddr_storage? */ + uint32_t ip6m_mtu; +}; + +/* + * Argument for IPV6_PORTRANGE: + * - which range to search when port is unspecified at bind() or connect() + */ +#define IPV6_PORTRANGE_DEFAULT 0 /* default range */ +#define IPV6_PORTRANGE_HIGH 1 /* "high" - request firewall bypass */ +#define IPV6_PORTRANGE_LOW 2 /* "low" - vouchsafe security */ + +/* + * Definitions for inet6 sysctl operations. + * + * Third level is protocol number. + * Fourth level is desired variable within that protocol. + */ +#define IPV6PROTO_MAXID (IPPROTO_PIM + 1) /* don't list to IPV6PROTO_MAX */ + +/* + * Names for IP sysctl objects + */ +#define IPV6CTL_FORWARDING 1 /* act as router */ +#define IPV6CTL_SENDREDIRECTS 2 /* may send redirects when forwarding */ +#define IPV6CTL_DEFHLIM 3 /* default Hop-Limit */ +#ifdef notyet +#define IPV6CTL_DEFMTU 4 /* default MTU */ +#endif +#define IPV6CTL_FORWSRCRT 5 /* forward source-routed dgrams */ +#define IPV6CTL_STATS 6 /* stats */ +#define IPV6CTL_MRTSTATS 7 /* multicast forwarding stats */ +#define IPV6CTL_MRTPROTO 8 /* multicast routing protocol */ +#define IPV6CTL_MAXFRAGPACKETS 9 /* max packets reassembly queue */ +#define IPV6CTL_SOURCECHECK 10 /* verify source route and intf */ +#define IPV6CTL_SOURCECHECK_LOGINT 11 /* minimume logging interval */ +#define IPV6CTL_ACCEPT_RTADV 12 +#define IPV6CTL_KEEPFAITH 13 /* deprecated */ +#define IPV6CTL_LOG_INTERVAL 14 +#define IPV6CTL_HDRNESTLIMIT 15 +#define IPV6CTL_DAD_COUNT 16 +#define IPV6CTL_AUTO_FLOWLABEL 17 +#define IPV6CTL_DEFMCASTHLIM 18 +#define IPV6CTL_GIF_HLIM 19 /* default HLIM for gif encap packet */ +#define IPV6CTL_KAME_VERSION 20 +#define IPV6CTL_USE_DEPRECATED 21 /* use deprec addr (RFC2462 5.5.4) */ +#define IPV6CTL_RR_PRUNE 22 /* walk timer for router renumbering */ +#if 0 /* obsolete */ +#define IPV6CTL_MAPPED_ADDR 23 +#endif +#define IPV6CTL_V6ONLY 24 +#define IPV6CTL_RTEXPIRE 25 /* cloned route expiration time */ +#define IPV6CTL_RTMINEXPIRE 26 /* min value for expiration time */ +#define IPV6CTL_RTMAXCACHE 27 /* trigger level for dynamic expire */ + +#define IPV6CTL_USETEMPADDR 32 /* use temporary addresses [RFC 4941] */ +#define IPV6CTL_TEMPPLTIME 33 /* preferred lifetime for tmpaddrs */ +#define IPV6CTL_TEMPVLTIME 34 /* valid lifetime for tmpaddrs */ +#define IPV6CTL_AUTO_LINKLOCAL 35 /* automatic link-local addr assign */ +#define IPV6CTL_RIP6STATS 36 /* raw_ip6 stats */ +#define IPV6CTL_PREFER_TEMPADDR 37 /* prefer temporary addr as src */ +#define IPV6CTL_ADDRCTLPOLICY 38 /* get/set address selection policy */ +#define IPV6CTL_USE_DEFAULTZONE 39 /* use default scope zone */ + +#define IPV6CTL_MAXFRAGS 41 /* max fragments */ +#define IPV6CTL_MCAST_PMTU 44 /* enable pMTU discovery for mcast? */ + +#define IPV6CTL_NEIGHBORGCTHRESH 46 +#define IPV6CTL_MAXIFPREFIXES 47 +#define IPV6CTL_MAXIFDEFROUTERS 48 +#define IPV6CTL_MAXDYNROUTES 49 +#define ICMPV6CTL_ND6_ONLINKNSRFC4861 50 + +/* New entries should be added here from current IPV6CTL_MAXID value. */ +/* to define items, should talk with KAME guys first, for *BSD compatibility */ +#define IPV6CTL_MAXID 51 + + + + + +__BEGIN_DECLS +struct cmsghdr; + +extern int inet6_option_space(int); +extern int inet6_option_init(void *, struct cmsghdr **, int); +extern int inet6_option_append(struct cmsghdr *, const __uint8_t *, int, int); +extern __uint8_t *inet6_option_alloc(struct cmsghdr *, int, int, int); +extern int inet6_option_next(const struct cmsghdr *, __uint8_t **); +extern int inet6_option_find(const struct cmsghdr *, __uint8_t **, int); + +extern size_t inet6_rthdr_space(int, int); +extern struct cmsghdr *inet6_rthdr_init(void *, int); +extern int inet6_rthdr_add(struct cmsghdr *, const struct in6_addr *, + unsigned int); +extern int inet6_rthdr_lasthop(struct cmsghdr *, unsigned int); +#if 0 /* not implemented yet */ +extern int inet6_rthdr_reverse(const struct cmsghdr *, struct cmsghdr *); +#endif +extern int inet6_rthdr_segments(const struct cmsghdr *); +extern struct in6_addr *inet6_rthdr_getaddr(struct cmsghdr *, int); +extern int inet6_rthdr_getflags(const struct cmsghdr *, int); + +extern int inet6_opt_init(void *, socklen_t); +extern int inet6_opt_append(void *, socklen_t, int, __uint8_t, socklen_t, + __uint8_t, void **); +extern int inet6_opt_finish(void *, socklen_t, int); +extern int inet6_opt_set_val(void *, int, void *, socklen_t); + +extern int inet6_opt_next(void *, socklen_t, int, __uint8_t *, socklen_t *, + void **); +extern int inet6_opt_find(void *, socklen_t, int, __uint8_t, socklen_t *, + void **); +extern int inet6_opt_get_val(void *, int, void *, socklen_t); +extern socklen_t inet6_rth_space(int, int); +extern void *inet6_rth_init(void *, socklen_t, int, int); +extern int inet6_rth_add(void *, const struct in6_addr *); +extern int inet6_rth_reverse(const void *, void *); +extern int inet6_rth_segments(const void *); +extern struct in6_addr *inet6_rth_getaddr(const void *, int); + +__END_DECLS +#endif /* PLATFORM_DriverKit */ +#endif /* !_NETINET6_IN6_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/objc/objc-api.h b/lib/libc/include/aarch64-macos-gnu/objc/objc-api.h new file mode 100644 index 0000000000..16bac0c0e2 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/objc/objc-api.h @@ -0,0 +1,286 @@ +/* + * Copyright (c) 1999-2006 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@ + */ +// Copyright 1988-1996 NeXT Software, Inc. + +#ifndef _OBJC_OBJC_API_H_ +#define _OBJC_OBJC_API_H_ + +#include +#include +#include +#include + +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +#ifndef __has_extension +# define __has_extension __has_feature +#endif + +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + +#if !__has_feature(nullability) +# ifndef _Nullable +# define _Nullable +# endif +# ifndef _Nonnull +# define _Nonnull +# endif +# ifndef _Null_unspecified +# define _Null_unspecified +# endif +#endif + + + +/* + * OBJC_API_VERSION 0 or undef: Tiger and earlier API only + * OBJC_API_VERSION 2: Leopard and later API available + */ +#if !defined(OBJC_API_VERSION) +# if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_5 +# define OBJC_API_VERSION 0 +# else +# define OBJC_API_VERSION 2 +# endif +#endif + + +/* + * OBJC_NO_GC 1: GC is not supported + * OBJC_NO_GC undef: GC is supported. This SDK no longer supports this mode. + * + * OBJC_NO_GC_API undef: Libraries must export any symbols that + * dual-mode code may links to. + * OBJC_NO_GC_API 1: Libraries need not export GC-related symbols. + */ +#if defined(__OBJC_GC__) +# error Objective-C garbage collection is not supported. +#elif TARGET_OS_OSX + /* GC is unsupported. GC API symbols are exported. */ +# define OBJC_NO_GC 1 +# undef OBJC_NO_GC_API +#else + /* GC is unsupported. GC API symbols are not exported. */ +# define OBJC_NO_GC 1 +# define OBJC_NO_GC_API 1 +#endif + + +/* NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER == 1 + * marks -[NSObject init] as a designated initializer. */ +#if !defined(NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER) +# define NS_ENFORCE_NSOBJECT_DESIGNATED_INITIALIZER 1 +#endif + +/* The arm64 ABI requires proper casting to ensure arguments are passed + * * correctly. */ +#if defined(__arm64__) && !__swift__ +# undef OBJC_OLD_DISPATCH_PROTOTYPES +# define OBJC_OLD_DISPATCH_PROTOTYPES 0 +#endif + +/* OBJC_OLD_DISPATCH_PROTOTYPES == 0 enforces the rule that the dispatch + * functions must be cast to an appropriate function pointer type. */ +#if !defined(OBJC_OLD_DISPATCH_PROTOTYPES) +# if __swift__ + // Existing Swift code expects IMP to be Comparable. + // Variadic IMP is comparable via OpaquePointer; non-variadic IMP isn't. +# define OBJC_OLD_DISPATCH_PROTOTYPES 1 +# else +# define OBJC_OLD_DISPATCH_PROTOTYPES 0 +# endif +#endif + + +/* OBJC_AVAILABLE: shorthand for all-OS availability */ + +# if !defined(OBJC_AVAILABLE) +# define OBJC_AVAILABLE(x, i, t, w, b) \ + __OSX_AVAILABLE(x) __IOS_AVAILABLE(i) __TVOS_AVAILABLE(t) \ + __WATCHOS_AVAILABLE(w) +# endif + + + +/* OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE: Deprecated on OS X, + * unavailable everywhere else. */ + +# if !defined(OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE) +# define OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE(_start, _dep, _msg) \ + __OSX_DEPRECATED(_start, _dep, _msg) \ + __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \ + __WATCHOS_UNAVAILABLE +# endif + + + +/* OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE: Available on OS X, + * unavailable everywhere else. */ + +# if !defined(OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE) +# define OBJC_OSX_AVAILABLE_OTHERS_UNAVAILABLE(vers) \ + __OSX_AVAILABLE(vers) \ + __IOS_UNAVAILABLE __TVOS_UNAVAILABLE \ + __WATCHOS_UNAVAILABLE +# endif + + + +/* OBJC_ISA_AVAILABILITY: `isa` will be deprecated or unavailable + * in the future */ +#if !defined(OBJC_ISA_AVAILABILITY) +# if __OBJC2__ +# define OBJC_ISA_AVAILABILITY __attribute__((deprecated)) +# else +# define OBJC_ISA_AVAILABILITY /* still available */ +# endif +#endif + + +/* OBJC2_UNAVAILABLE: unavailable in objc 2.0, deprecated in Leopard */ +#if !defined(OBJC2_UNAVAILABLE) +# if __OBJC2__ +# define OBJC2_UNAVAILABLE UNAVAILABLE_ATTRIBUTE +# else + /* plain C code also falls here, but this is close enough */ +# define OBJC2_UNAVAILABLE \ + __OSX_DEPRECATED(10.5, 10.5, "not available in __OBJC2__") \ + __IOS_DEPRECATED(2.0, 2.0, "not available in __OBJC2__") \ + __TVOS_UNAVAILABLE __WATCHOS_UNAVAILABLE +# endif +#endif + +/* OBJC_UNAVAILABLE: unavailable, with a message where supported */ +#if !defined(OBJC_UNAVAILABLE) +# if __has_extension(attribute_unavailable_with_message) +# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable(_msg))) +# else +# define OBJC_UNAVAILABLE(_msg) __attribute__((unavailable)) +# endif +#endif + +/* OBJC_DEPRECATED: deprecated, with a message where supported */ +#if !defined(OBJC_DEPRECATED) +# if __has_extension(attribute_deprecated_with_message) +# define OBJC_DEPRECATED(_msg) __attribute__((deprecated(_msg))) +# else +# define OBJC_DEPRECATED(_msg) __attribute__((deprecated)) +# endif +#endif + +/* OBJC_ARC_UNAVAILABLE: unavailable with -fobjc-arc */ +#if !defined(OBJC_ARC_UNAVAILABLE) +# if __has_feature(objc_arc) +# define OBJC_ARC_UNAVAILABLE OBJC_UNAVAILABLE("not available in automatic reference counting mode") +# else +# define OBJC_ARC_UNAVAILABLE +# endif +#endif + +/* OBJC_SWIFT_UNAVAILABLE: unavailable in Swift */ +#if !defined(OBJC_SWIFT_UNAVAILABLE) +# if __has_feature(attribute_availability_swift) +# define OBJC_SWIFT_UNAVAILABLE(_msg) __attribute__((availability(swift, unavailable, message=_msg))) +# else +# define OBJC_SWIFT_UNAVAILABLE(_msg) +# endif +#endif + +/* OBJC_ARM64_UNAVAILABLE: unavailable on arm64 (i.e. stret dispatch) */ +#if !defined(OBJC_ARM64_UNAVAILABLE) +# if defined(__arm64__) +# define OBJC_ARM64_UNAVAILABLE OBJC_UNAVAILABLE("not available in arm64") +# else +# define OBJC_ARM64_UNAVAILABLE +# endif +#endif + +/* OBJC_GC_UNAVAILABLE: unavailable with -fobjc-gc or -fobjc-gc-only */ +#if !defined(OBJC_GC_UNAVAILABLE) +# define OBJC_GC_UNAVAILABLE +#endif + +#if !defined(OBJC_EXTERN) +# if defined(__cplusplus) +# define OBJC_EXTERN extern "C" +# else +# define OBJC_EXTERN extern +# endif +#endif + +#if !defined(OBJC_VISIBLE) + +# define OBJC_VISIBLE __attribute__((visibility("default"))) + +#endif + +#if !defined(OBJC_EXPORT) +# define OBJC_EXPORT OBJC_EXTERN OBJC_VISIBLE +#endif + +#if !defined(OBJC_IMPORT) +# define OBJC_IMPORT extern +#endif + +#if !defined(OBJC_ROOT_CLASS) +# if __has_attribute(objc_root_class) +# define OBJC_ROOT_CLASS __attribute__((objc_root_class)) +# else +# define OBJC_ROOT_CLASS +# endif +#endif + +#ifndef __DARWIN_NULL +#define __DARWIN_NULL NULL +#endif + +#if !defined(OBJC_INLINE) +# define OBJC_INLINE __inline +#endif + +// Declares an enum type or option bits type as appropriate for each language. +#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum)) +#define OBJC_ENUM(_type, _name) enum _name : _type _name; enum _name : _type +#if (__cplusplus) +#define OBJC_OPTIONS(_type, _name) _type _name; enum : _type +#else +#define OBJC_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type +#endif +#else +#define OBJC_ENUM(_type, _name) _type _name; enum +#define OBJC_OPTIONS(_type, _name) _type _name; enum +#endif + +#if !defined(OBJC_RETURNS_RETAINED) +# if __OBJC__ && __has_attribute(ns_returns_retained) +# define OBJC_RETURNS_RETAINED __attribute__((ns_returns_retained)) +# else +# define OBJC_RETURNS_RETAINED +# endif +#endif + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/objc/runtime.h b/lib/libc/include/aarch64-macos-gnu/objc/runtime.h new file mode 100644 index 0000000000..3e4440f632 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/objc/runtime.h @@ -0,0 +1,2164 @@ +/* + * Copyright (c) 1999-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 _OBJC_RUNTIME_H +#define _OBJC_RUNTIME_H + +#include +#include +#include +#include +#include +#include + +#if TARGET_OS_MAC +#include +#endif + + +/* Types */ + +#if !OBJC_TYPES_DEFINED + +/// An opaque type that represents a method in a class definition. +typedef struct objc_method *Method; + +/// An opaque type that represents an instance variable. +typedef struct objc_ivar *Ivar; + +/// An opaque type that represents a category. +typedef struct objc_category *Category; + +/// An opaque type that represents an Objective-C declared property. +typedef struct objc_property *objc_property_t; + +struct objc_class { + Class _Nonnull isa OBJC_ISA_AVAILABILITY; + +#if !__OBJC2__ + Class _Nullable super_class OBJC2_UNAVAILABLE; + const char * _Nonnull name OBJC2_UNAVAILABLE; + long version OBJC2_UNAVAILABLE; + long info OBJC2_UNAVAILABLE; + long instance_size OBJC2_UNAVAILABLE; + struct objc_ivar_list * _Nullable ivars OBJC2_UNAVAILABLE; + struct objc_method_list * _Nullable * _Nullable methodLists OBJC2_UNAVAILABLE; + struct objc_cache * _Nonnull cache OBJC2_UNAVAILABLE; + struct objc_protocol_list * _Nullable protocols OBJC2_UNAVAILABLE; +#endif + +} OBJC2_UNAVAILABLE; +/* Use `Class` instead of `struct objc_class *` */ + +#endif + +#ifdef __OBJC__ +@class Protocol; +#else +typedef struct objc_object Protocol; +#endif + +/// Defines a method +struct objc_method_description { + SEL _Nullable name; /**< The name of the method */ + char * _Nullable types; /**< The types of the method arguments */ +}; + +/// Defines a property attribute +typedef struct { + const char * _Nonnull name; /**< The name of the attribute */ + const char * _Nonnull value; /**< The value of the attribute (usually empty) */ +} objc_property_attribute_t; + + +/* Functions */ + +/* Working with Instances */ + +/** + * Returns a copy of a given object. + * + * @param obj An Objective-C object. + * @param size The size of the object \e obj. + * + * @return A copy of \e obj. + */ +OBJC_EXPORT id _Nullable object_copy(id _Nullable obj, size_t size) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0) + OBJC_ARC_UNAVAILABLE; + +/** + * Frees the memory occupied by a given object. + * + * @param obj An Objective-C object. + * + * @return nil + */ +OBJC_EXPORT id _Nullable +object_dispose(id _Nullable obj) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0) + OBJC_ARC_UNAVAILABLE; + +/** + * Returns the class of an object. + * + * @param obj The object you want to inspect. + * + * @return The class object of which \e object is an instance, + * or \c Nil if \e object is \c nil. + */ +OBJC_EXPORT Class _Nullable +object_getClass(id _Nullable obj) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Sets the class of an object. + * + * @param obj The object to modify. + * @param cls A class object. + * + * @return The previous value of \e object's class, or \c Nil if \e object is \c nil. + */ +OBJC_EXPORT Class _Nullable +object_setClass(id _Nullable obj, Class _Nonnull cls) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + + +/** + * Returns whether an object is a class object. + * + * @param obj An Objective-C object. + * + * @return true if the object is a class or metaclass, false otherwise. + */ +OBJC_EXPORT BOOL +object_isClass(id _Nullable obj) + OBJC_AVAILABLE(10.10, 8.0, 9.0, 1.0, 2.0); + + +/** + * Reads the value of an instance variable in an object. + * + * @param obj The object containing the instance variable whose value you want to read. + * @param ivar The Ivar describing the instance variable whose value you want to read. + * + * @return The value of the instance variable specified by \e ivar, or \c nil if \e object is \c nil. + * + * @note \c object_getIvar is faster than \c object_getInstanceVariable if the Ivar + * for the instance variable is already known. + */ +OBJC_EXPORT id _Nullable +object_getIvar(id _Nullable obj, Ivar _Nonnull ivar) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Sets the value of an instance variable in an object. + * + * @param obj The object containing the instance variable whose value you want to set. + * @param ivar The Ivar describing the instance variable whose value you want to set. + * @param value The new value for the instance variable. + * + * @note Instance variables with known memory management (such as ARC strong and weak) + * use that memory management. Instance variables with unknown memory management + * are assigned as if they were unsafe_unretained. + * @note \c object_setIvar is faster than \c object_setInstanceVariable if the Ivar + * for the instance variable is already known. + */ +OBJC_EXPORT void +object_setIvar(id _Nullable obj, Ivar _Nonnull ivar, id _Nullable value) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Sets the value of an instance variable in an object. + * + * @param obj The object containing the instance variable whose value you want to set. + * @param ivar The Ivar describing the instance variable whose value you want to set. + * @param value The new value for the instance variable. + * + * @note Instance variables with known memory management (such as ARC strong and weak) + * use that memory management. Instance variables with unknown memory management + * are assigned as if they were strong. + * @note \c object_setIvar is faster than \c object_setInstanceVariable if the Ivar + * for the instance variable is already known. + */ +OBJC_EXPORT void +object_setIvarWithStrongDefault(id _Nullable obj, Ivar _Nonnull ivar, + id _Nullable value) + OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0); + +/** + * Changes the value of an instance variable of a class instance. + * + * @param obj A pointer to an instance of a class. Pass the object containing + * the instance variable whose value you wish to modify. + * @param name A C string. Pass the name of the instance variable whose value you wish to modify. + * @param value The new value for the instance variable. + * + * @return A pointer to the \c Ivar data structure that defines the type and + * name of the instance variable specified by \e name. + * + * @note Instance variables with known memory management (such as ARC strong and weak) + * use that memory management. Instance variables with unknown memory management + * are assigned as if they were unsafe_unretained. + */ +OBJC_EXPORT Ivar _Nullable +object_setInstanceVariable(id _Nullable obj, const char * _Nonnull name, + void * _Nullable value) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0) + OBJC_ARC_UNAVAILABLE; + +/** + * Changes the value of an instance variable of a class instance. + * + * @param obj A pointer to an instance of a class. Pass the object containing + * the instance variable whose value you wish to modify. + * @param name A C string. Pass the name of the instance variable whose value you wish to modify. + * @param value The new value for the instance variable. + * + * @return A pointer to the \c Ivar data structure that defines the type and + * name of the instance variable specified by \e name. + * + * @note Instance variables with known memory management (such as ARC strong and weak) + * use that memory management. Instance variables with unknown memory management + * are assigned as if they were strong. + */ +OBJC_EXPORT Ivar _Nullable +object_setInstanceVariableWithStrongDefault(id _Nullable obj, + const char * _Nonnull name, + void * _Nullable value) + OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0) + OBJC_ARC_UNAVAILABLE; + +/** + * Obtains the value of an instance variable of a class instance. + * + * @param obj A pointer to an instance of a class. Pass the object containing + * the instance variable whose value you wish to obtain. + * @param name A C string. Pass the name of the instance variable whose value you wish to obtain. + * @param outValue On return, contains a pointer to the value of the instance variable. + * + * @return A pointer to the \c Ivar data structure that defines the type and name of + * the instance variable specified by \e name. + */ +OBJC_EXPORT Ivar _Nullable +object_getInstanceVariable(id _Nullable obj, const char * _Nonnull name, + void * _Nullable * _Nullable outValue) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0) + OBJC_ARC_UNAVAILABLE; + + +/* Obtaining Class Definitions */ + +/** + * Returns the class definition of a specified class. + * + * @param name The name of the class to look up. + * + * @return The Class object for the named class, or \c nil + * if the class is not registered with the Objective-C runtime. + * + * @note \c objc_getClass is different from \c objc_lookUpClass in that if the class + * is not registered, \c objc_getClass calls the class handler callback and then checks + * a second time to see whether the class is registered. \c objc_lookUpClass does + * not call the class handler callback. + * + * @warning Earlier implementations of this function (prior to OS X v10.0) + * terminate the program if the class does not exist. + */ +OBJC_EXPORT Class _Nullable +objc_getClass(const char * _Nonnull name) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the metaclass definition of a specified class. + * + * @param name The name of the class to look up. + * + * @return The \c Class object for the metaclass of the named class, or \c nil if the class + * is not registered with the Objective-C runtime. + * + * @note If the definition for the named class is not registered, this function calls the class handler + * callback and then checks a second time to see if the class is registered. However, every class + * definition must have a valid metaclass definition, and so the metaclass definition is always returned, + * whether it’s valid or not. + */ +OBJC_EXPORT Class _Nullable +objc_getMetaClass(const char * _Nonnull name) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the class definition of a specified class. + * + * @param name The name of the class to look up. + * + * @return The Class object for the named class, or \c nil if the class + * is not registered with the Objective-C runtime. + * + * @note \c objc_getClass is different from this function in that if the class is not + * registered, \c objc_getClass calls the class handler callback and then checks a second + * time to see whether the class is registered. This function does not call the class handler callback. + */ +OBJC_EXPORT Class _Nullable +objc_lookUpClass(const char * _Nonnull name) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the class definition of a specified class. + * + * @param name The name of the class to look up. + * + * @return The Class object for the named class. + * + * @note This function is the same as \c objc_getClass, but kills the process if the class is not found. + * @note This function is used by ZeroLink, where failing to find a class would be a compile-time link error without ZeroLink. + */ +OBJC_EXPORT Class _Nonnull +objc_getRequiredClass(const char * _Nonnull name) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Obtains the list of registered class definitions. + * + * @param buffer An array of \c Class values. On output, each \c Class value points to + * one class definition, up to either \e bufferCount or the total number of registered classes, + * whichever is less. You can pass \c NULL to obtain the total number of registered class + * definitions without actually retrieving any class definitions. + * @param bufferCount An integer value. Pass the number of pointers for which you have allocated space + * in \e buffer. On return, this function fills in only this number of elements. If this number is less + * than the number of registered classes, this function returns an arbitrary subset of the registered classes. + * + * @return An integer value indicating the total number of registered classes. + * + * @note The Objective-C runtime library automatically registers all the classes defined in your source code. + * You can create class definitions at runtime and register them with the \c objc_addClass function. + * + * @warning You cannot assume that class objects you get from this function are classes that inherit from \c NSObject, + * so you cannot safely call any methods on such classes without detecting that the method is implemented first. + */ +OBJC_EXPORT int +objc_getClassList(Class _Nonnull * _Nullable buffer, int bufferCount) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Creates and returns a list of pointers to all registered class definitions. + * + * @param outCount An integer pointer used to store the number of classes returned by + * this function in the list. It can be \c nil. + * + * @return A nil terminated array of classes. It must be freed with \c free(). + * + * @see objc_getClassList + */ +OBJC_EXPORT Class _Nonnull * _Nullable +objc_copyClassList(unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.7, 3.1, 9.0, 1.0, 2.0); + + +/* Working with Classes */ + +/** + * Returns the name of a class. + * + * @param cls A class object. + * + * @return The name of the class, or the empty string if \e cls is \c Nil. + */ +OBJC_EXPORT const char * _Nonnull +class_getName(Class _Nullable cls) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a Boolean value that indicates whether a class object is a metaclass. + * + * @param cls A class object. + * + * @return \c YES if \e cls is a metaclass, \c NO if \e cls is a non-meta class, + * \c NO if \e cls is \c Nil. + */ +OBJC_EXPORT BOOL +class_isMetaClass(Class _Nullable cls) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the superclass of a class. + * + * @param cls A class object. + * + * @return The superclass of the class, or \c Nil if + * \e cls is a root class, or \c Nil if \e cls is \c Nil. + * + * @note You should usually use \c NSObject's \c superclass method instead of this function. + */ +OBJC_EXPORT Class _Nullable +class_getSuperclass(Class _Nullable cls) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Sets the superclass of a given class. + * + * @param cls The class whose superclass you want to set. + * @param newSuper The new superclass for cls. + * + * @return The old superclass for cls. + * + * @warning You should not use this function. + */ +OBJC_EXPORT Class _Nonnull +class_setSuperclass(Class _Nonnull cls, Class _Nonnull newSuper) + __OSX_DEPRECATED(10.5, 10.5, "not recommended") + __IOS_DEPRECATED(2.0, 2.0, "not recommended") + __TVOS_DEPRECATED(9.0, 9.0, "not recommended") + __WATCHOS_DEPRECATED(1.0, 1.0, "not recommended") + +; + +/** + * Returns the version number of a class definition. + * + * @param cls A pointer to a \c Class data structure. Pass + * the class definition for which you wish to obtain the version. + * + * @return An integer indicating the version number of the class definition. + * + * @see class_setVersion + */ +OBJC_EXPORT int +class_getVersion(Class _Nullable cls) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Sets the version number of a class definition. + * + * @param cls A pointer to an Class data structure. + * Pass the class definition for which you wish to set the version. + * @param version An integer. Pass the new version number of the class definition. + * + * @note You can use the version number of the class definition to provide versioning of the + * interface that your class represents to other classes. This is especially useful for object + * serialization (that is, archiving of the object in a flattened form), where it is important to + * recognize changes to the layout of the instance variables in different class-definition versions. + * @note Classes derived from the Foundation framework \c NSObject class can set the class-definition + * version number using the \c setVersion: class method, which is implemented using the \c class_setVersion function. + */ +OBJC_EXPORT void +class_setVersion(Class _Nullable cls, int version) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the size of instances of a class. + * + * @param cls A class object. + * + * @return The size in bytes of instances of the class \e cls, or \c 0 if \e cls is \c Nil. + */ +OBJC_EXPORT size_t +class_getInstanceSize(Class _Nullable cls) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the \c Ivar for a specified instance variable of a given class. + * + * @param cls The class whose instance variable you wish to obtain. + * @param name The name of the instance variable definition to obtain. + * + * @return A pointer to an \c Ivar data structure containing information about + * the instance variable specified by \e name. + */ +OBJC_EXPORT Ivar _Nullable +class_getInstanceVariable(Class _Nullable cls, const char * _Nonnull name) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the Ivar for a specified class variable of a given class. + * + * @param cls The class definition whose class variable you wish to obtain. + * @param name The name of the class variable definition to obtain. + * + * @return A pointer to an \c Ivar data structure containing information about the class variable specified by \e name. + */ +OBJC_EXPORT Ivar _Nullable +class_getClassVariable(Class _Nullable cls, const char * _Nonnull name) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Describes the instance variables declared by a class. + * + * @param cls The class to inspect. + * @param outCount On return, contains the length of the returned array. + * If outCount is NULL, the length is not returned. + * + * @return An array of pointers of type Ivar describing the instance variables declared by the class. + * Any instance variables declared by superclasses are not included. The array contains *outCount + * pointers followed by a NULL terminator. You must free the array with free(). + * + * If the class declares no instance variables, or cls is Nil, NULL is returned and *outCount is 0. + */ +OBJC_EXPORT Ivar _Nonnull * _Nullable +class_copyIvarList(Class _Nullable cls, unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a specified instance method for a given class. + * + * @param cls The class you want to inspect. + * @param name The selector of the method you want to retrieve. + * + * @return The method that corresponds to the implementation of the selector specified by + * \e name for the class specified by \e cls, or \c NULL if the specified class or its + * superclasses do not contain an instance method with the specified selector. + * + * @note This function searches superclasses for implementations, whereas \c class_copyMethodList does not. + */ +OBJC_EXPORT Method _Nullable +class_getInstanceMethod(Class _Nullable cls, SEL _Nonnull name) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a pointer to the data structure describing a given class method for a given class. + * + * @param cls A pointer to a class definition. Pass the class that contains the method you want to retrieve. + * @param name A pointer of type \c SEL. Pass the selector of the method you want to retrieve. + * + * @return A pointer to the \c Method data structure that corresponds to the implementation of the + * selector specified by aSelector for the class specified by aClass, or NULL if the specified + * class or its superclasses do not contain an instance method with the specified selector. + * + * @note Note that this function searches superclasses for implementations, + * whereas \c class_copyMethodList does not. + */ +OBJC_EXPORT Method _Nullable +class_getClassMethod(Class _Nullable cls, SEL _Nonnull name) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the function pointer that would be called if a + * particular message were sent to an instance of a class. + * + * @param cls The class you want to inspect. + * @param name A selector. + * + * @return The function pointer that would be called if \c [object name] were called + * with an instance of the class, or \c NULL if \e cls is \c Nil. + * + * @note \c class_getMethodImplementation may be faster than \c method_getImplementation(class_getInstanceMethod(cls, name)). + * @note The function pointer returned may be a function internal to the runtime instead of + * an actual method implementation. For example, if instances of the class do not respond to + * the selector, the function pointer returned will be part of the runtime's message forwarding machinery. + */ +OBJC_EXPORT IMP _Nullable +class_getMethodImplementation(Class _Nullable cls, SEL _Nonnull name) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the function pointer that would be called if a particular + * message were sent to an instance of a class. + * + * @param cls The class you want to inspect. + * @param name A selector. + * + * @return The function pointer that would be called if \c [object name] were called + * with an instance of the class, or \c NULL if \e cls is \c Nil. + */ +OBJC_EXPORT IMP _Nullable +class_getMethodImplementation_stret(Class _Nullable cls, SEL _Nonnull name) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0) + OBJC_ARM64_UNAVAILABLE; + +/** + * Returns a Boolean value that indicates whether instances of a class respond to a particular selector. + * + * @param cls The class you want to inspect. + * @param sel A selector. + * + * @return \c YES if instances of the class respond to the selector, otherwise \c NO. + * + * @note You should usually use \c NSObject's \c respondsToSelector: or \c instancesRespondToSelector: + * methods instead of this function. + */ +OBJC_EXPORT BOOL +class_respondsToSelector(Class _Nullable cls, SEL _Nonnull sel) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Describes the instance methods implemented by a class. + * + * @param cls The class you want to inspect. + * @param outCount On return, contains the length of the returned array. + * If outCount is NULL, the length is not returned. + * + * @return An array of pointers of type Method describing the instance methods + * implemented by the class—any instance methods implemented by superclasses are not included. + * The array contains *outCount pointers followed by a NULL terminator. You must free the array with free(). + * + * If cls implements no instance methods, or cls is Nil, returns NULL and *outCount is 0. + * + * @note To get the class methods of a class, use \c class_copyMethodList(object_getClass(cls), &count). + * @note To get the implementations of methods that may be implemented by superclasses, + * use \c class_getInstanceMethod or \c class_getClassMethod. + */ +OBJC_EXPORT Method _Nonnull * _Nullable +class_copyMethodList(Class _Nullable cls, unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a Boolean value that indicates whether a class conforms to a given protocol. + * + * @param cls The class you want to inspect. + * @param protocol A protocol. + * + * @return YES if cls conforms to protocol, otherwise NO. + * + * @note You should usually use NSObject's conformsToProtocol: method instead of this function. + */ +OBJC_EXPORT BOOL +class_conformsToProtocol(Class _Nullable cls, Protocol * _Nullable protocol) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Describes the protocols adopted by a class. + * + * @param cls The class you want to inspect. + * @param outCount On return, contains the length of the returned array. + * If outCount is NULL, the length is not returned. + * + * @return An array of pointers of type Protocol* describing the protocols adopted + * by the class. Any protocols adopted by superclasses or other protocols are not included. + * The array contains *outCount pointers followed by a NULL terminator. You must free the array with free(). + * + * If cls adopts no protocols, or cls is Nil, returns NULL and *outCount is 0. + */ +OBJC_EXPORT Protocol * __unsafe_unretained _Nonnull * _Nullable +class_copyProtocolList(Class _Nullable cls, unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a property with a given name of a given class. + * + * @param cls The class you want to inspect. + * @param name The name of the property you want to inspect. + * + * @return A pointer of type \c objc_property_t describing the property, or + * \c NULL if the class does not declare a property with that name, + * or \c NULL if \e cls is \c Nil. + */ +OBJC_EXPORT objc_property_t _Nullable +class_getProperty(Class _Nullable cls, const char * _Nonnull name) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Describes the properties declared by a class. + * + * @param cls The class you want to inspect. + * @param outCount On return, contains the length of the returned array. + * If \e outCount is \c NULL, the length is not returned. + * + * @return An array of pointers of type \c objc_property_t describing the properties + * declared by the class. Any properties declared by superclasses are not included. + * The array contains \c *outCount pointers followed by a \c NULL terminator. You must free the array with \c free(). + * + * If \e cls declares no properties, or \e cls is \c Nil, returns \c NULL and \c *outCount is \c 0. + */ +OBJC_EXPORT objc_property_t _Nonnull * _Nullable +class_copyPropertyList(Class _Nullable cls, unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a description of the \c Ivar layout for a given class. + * + * @param cls The class to inspect. + * + * @return A description of the \c Ivar layout for \e cls. + */ +OBJC_EXPORT const uint8_t * _Nullable +class_getIvarLayout(Class _Nullable cls) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a description of the layout of weak Ivars for a given class. + * + * @param cls The class to inspect. + * + * @return A description of the layout of the weak \c Ivars for \e cls. + */ +OBJC_EXPORT const uint8_t * _Nullable +class_getWeakIvarLayout(Class _Nullable cls) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Adds a new method to a class with a given name and implementation. + * + * @param cls The class to which to add a method. + * @param name A selector that specifies the name of the method being added. + * @param imp A function which is the implementation of the new method. The function must take at least two arguments—self and _cmd. + * @param types An array of characters that describe the types of the arguments to the method. + * + * @return YES if the method was added successfully, otherwise NO + * (for example, the class already contains a method implementation with that name). + * + * @note class_addMethod will add an override of a superclass's implementation, + * but will not replace an existing implementation in this class. + * To change an existing implementation, use method_setImplementation. + */ +OBJC_EXPORT BOOL +class_addMethod(Class _Nullable cls, SEL _Nonnull name, IMP _Nonnull imp, + const char * _Nullable types) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Replaces the implementation of a method for a given class. + * + * @param cls The class you want to modify. + * @param name A selector that identifies the method whose implementation you want to replace. + * @param imp The new implementation for the method identified by name for the class identified by cls. + * @param types An array of characters that describe the types of the arguments to the method. + * Since the function must take at least two arguments—self and _cmd, the second and third characters + * must be “@:” (the first character is the return type). + * + * @return The previous implementation of the method identified by \e name for the class identified by \e cls. + * + * @note This function behaves in two different ways: + * - If the method identified by \e name does not yet exist, it is added as if \c class_addMethod were called. + * The type encoding specified by \e types is used as given. + * - If the method identified by \e name does exist, its \c IMP is replaced as if \c method_setImplementation were called. + * The type encoding specified by \e types is ignored. + */ +OBJC_EXPORT IMP _Nullable +class_replaceMethod(Class _Nullable cls, SEL _Nonnull name, IMP _Nonnull imp, + const char * _Nullable types) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Adds a new instance variable to a class. + * + * @return YES if the instance variable was added successfully, otherwise NO + * (for example, the class already contains an instance variable with that name). + * + * @note This function may only be called after objc_allocateClassPair and before objc_registerClassPair. + * Adding an instance variable to an existing class is not supported. + * @note The class must not be a metaclass. Adding an instance variable to a metaclass is not supported. + * @note The instance variable's minimum alignment in bytes is 1< Type Encodings. + */ +OBJC_EXPORT const char * _Nullable +ivar_getTypeEncoding(Ivar _Nonnull v) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the offset of an instance variable. + * + * @param v The instance variable you want to enquire about. + * + * @return The offset of \e v. + * + * @note For instance variables of type \c id or other object types, call \c object_getIvar + * and \c object_setIvar instead of using this offset to access the instance variable data directly. + */ +OBJC_EXPORT ptrdiff_t +ivar_getOffset(Ivar _Nonnull v) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + + +/* Working with Properties */ + +/** + * Returns the name of a property. + * + * @param property The property you want to inquire about. + * + * @return A C string containing the property's name. + */ +OBJC_EXPORT const char * _Nonnull +property_getName(objc_property_t _Nonnull property) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the attribute string of a property. + * + * @param property A property. + * + * @return A C string containing the property's attributes. + * + * @note The format of the attribute string is described in Declared Properties in Objective-C Runtime Programming Guide. + */ +OBJC_EXPORT const char * _Nullable +property_getAttributes(objc_property_t _Nonnull property) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns an array of property attributes for a property. + * + * @param property The property whose attributes you want copied. + * @param outCount The number of attributes returned in the array. + * + * @return An array of property attributes; must be free'd() by the caller. + */ +OBJC_EXPORT objc_property_attribute_t * _Nullable +property_copyAttributeList(objc_property_t _Nonnull property, + unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + +/** + * Returns the value of a property attribute given the attribute name. + * + * @param property The property whose attribute value you are interested in. + * @param attributeName C string representing the attribute name. + * + * @return The value string of the attribute \e attributeName if it exists in + * \e property, \c nil otherwise. + */ +OBJC_EXPORT char * _Nullable +property_copyAttributeValue(objc_property_t _Nonnull property, + const char * _Nonnull attributeName) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + + +/* Working with Protocols */ + +/** + * Returns a specified protocol. + * + * @param name The name of a protocol. + * + * @return The protocol named \e name, or \c NULL if no protocol named \e name could be found. + * + * @note This function acquires the runtime lock. + */ +OBJC_EXPORT Protocol * _Nullable +objc_getProtocol(const char * _Nonnull name) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns an array of all the protocols known to the runtime. + * + * @param outCount Upon return, contains the number of protocols in the returned array. + * + * @return A C array of all the protocols known to the runtime. The array contains \c *outCount + * pointers followed by a \c NULL terminator. You must free the list with \c free(). + * + * @note This function acquires the runtime lock. + */ +OBJC_EXPORT Protocol * __unsafe_unretained _Nonnull * _Nullable +objc_copyProtocolList(unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a Boolean value that indicates whether one protocol conforms to another protocol. + * + * @param proto A protocol. + * @param other A protocol. + * + * @return \c YES if \e proto conforms to \e other, otherwise \c NO. + * + * @note One protocol can incorporate other protocols using the same syntax + * that classes use to adopt a protocol: + * \code + * @protocol ProtocolName < protocol list > + * \endcode + * All the protocols listed between angle brackets are considered part of the ProtocolName protocol. + */ +OBJC_EXPORT BOOL +protocol_conformsToProtocol(Protocol * _Nullable proto, + Protocol * _Nullable other) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a Boolean value that indicates whether two protocols are equal. + * + * @param proto A protocol. + * @param other A protocol. + * + * @return \c YES if \e proto is the same as \e other, otherwise \c NO. + */ +OBJC_EXPORT BOOL +protocol_isEqual(Protocol * _Nullable proto, Protocol * _Nullable other) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the name of a protocol. + * + * @param proto A protocol. + * + * @return The name of the protocol \e p as a C string. + */ +OBJC_EXPORT const char * _Nonnull +protocol_getName(Protocol * _Nonnull proto) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a method description structure for a specified method of a given protocol. + * + * @param proto A protocol. + * @param aSel A selector. + * @param isRequiredMethod A Boolean value that indicates whether aSel is a required method. + * @param isInstanceMethod A Boolean value that indicates whether aSel is an instance method. + * + * @return An \c objc_method_description structure that describes the method specified by \e aSel, + * \e isRequiredMethod, and \e isInstanceMethod for the protocol \e p. + * If the protocol does not contain the specified method, returns an \c objc_method_description structure + * with the value \c {NULL, \c NULL}. + * + * @note This function recursively searches any protocols that this protocol conforms to. + */ +OBJC_EXPORT struct objc_method_description +protocol_getMethodDescription(Protocol * _Nonnull proto, SEL _Nonnull aSel, + BOOL isRequiredMethod, BOOL isInstanceMethod) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns an array of method descriptions of methods meeting a given specification for a given protocol. + * + * @param proto A protocol. + * @param isRequiredMethod A Boolean value that indicates whether returned methods should + * be required methods (pass YES to specify required methods). + * @param isInstanceMethod A Boolean value that indicates whether returned methods should + * be instance methods (pass YES to specify instance methods). + * @param outCount Upon return, contains the number of method description structures in the returned array. + * + * @return A C array of \c objc_method_description structures containing the names and types of \e p's methods + * specified by \e isRequiredMethod and \e isInstanceMethod. The array contains \c *outCount pointers followed + * by a \c NULL terminator. You must free the list with \c free(). + * If the protocol declares no methods that meet the specification, \c NULL is returned and \c *outCount is 0. + * + * @note Methods in other protocols adopted by this protocol are not included. + */ +OBJC_EXPORT struct objc_method_description * _Nullable +protocol_copyMethodDescriptionList(Protocol * _Nonnull proto, + BOOL isRequiredMethod, + BOOL isInstanceMethod, + unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the specified property of a given protocol. + * + * @param proto A protocol. + * @param name The name of a property. + * @param isRequiredProperty \c YES searches for a required property, \c NO searches for an optional property. + * @param isInstanceProperty \c YES searches for an instance property, \c NO searches for a class property. + * + * @return The property specified by \e name, \e isRequiredProperty, and \e isInstanceProperty for \e proto, + * or \c NULL if none of \e proto's properties meets the specification. + */ +OBJC_EXPORT objc_property_t _Nullable +protocol_getProperty(Protocol * _Nonnull proto, + const char * _Nonnull name, + BOOL isRequiredProperty, BOOL isInstanceProperty) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns an array of the required instance properties declared by a protocol. + * + * @note Identical to + * \code + * protocol_copyPropertyList2(proto, outCount, YES, YES); + * \endcode + */ +OBJC_EXPORT objc_property_t _Nonnull * _Nullable +protocol_copyPropertyList(Protocol * _Nonnull proto, + unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns an array of properties declared by a protocol. + * + * @param proto A protocol. + * @param outCount Upon return, contains the number of elements in the returned array. + * @param isRequiredProperty \c YES returns required properties, \c NO returns optional properties. + * @param isInstanceProperty \c YES returns instance properties, \c NO returns class properties. + * + * @return A C array of pointers of type \c objc_property_t describing the properties declared by \e proto. + * Any properties declared by other protocols adopted by this protocol are not included. The array contains + * \c *outCount pointers followed by a \c NULL terminator. You must free the array with \c free(). + * If the protocol declares no matching properties, \c NULL is returned and \c *outCount is \c 0. + */ +OBJC_EXPORT objc_property_t _Nonnull * _Nullable +protocol_copyPropertyList2(Protocol * _Nonnull proto, + unsigned int * _Nullable outCount, + BOOL isRequiredProperty, BOOL isInstanceProperty) + OBJC_AVAILABLE(10.12, 10.0, 10.0, 3.0, 2.0); + +/** + * Returns an array of the protocols adopted by a protocol. + * + * @param proto A protocol. + * @param outCount Upon return, contains the number of elements in the returned array. + * + * @return A C array of protocols adopted by \e proto. The array contains \e *outCount pointers + * followed by a \c NULL terminator. You must free the array with \c free(). + * If the protocol adopts no other protocols, \c NULL is returned and \c *outCount is \c 0. + */ +OBJC_EXPORT Protocol * __unsafe_unretained _Nonnull * _Nullable +protocol_copyProtocolList(Protocol * _Nonnull proto, + unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Creates a new protocol instance that cannot be used until registered with + * \c objc_registerProtocol() + * + * @param name The name of the protocol to create. + * + * @return The Protocol instance on success, \c nil if a protocol + * with the same name already exists. + * @note There is no dispose method for this. + */ +OBJC_EXPORT Protocol * _Nullable +objc_allocateProtocol(const char * _Nonnull name) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + +/** + * Registers a newly constructed protocol with the runtime. The protocol + * will be ready for use and is immutable after this. + * + * @param proto The protocol you want to register. + */ +OBJC_EXPORT void +objc_registerProtocol(Protocol * _Nonnull proto) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + +/** + * Adds a method to a protocol. The protocol must be under construction. + * + * @param proto The protocol to add a method to. + * @param name The name of the method to add. + * @param types A C string that represents the method signature. + * @param isRequiredMethod YES if the method is not an optional method. + * @param isInstanceMethod YES if the method is an instance method. + */ +OBJC_EXPORT void +protocol_addMethodDescription(Protocol * _Nonnull proto, SEL _Nonnull name, + const char * _Nullable types, + BOOL isRequiredMethod, BOOL isInstanceMethod) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + +/** + * Adds an incorporated protocol to another protocol. The protocol being + * added to must still be under construction, while the additional protocol + * must be already constructed. + * + * @param proto The protocol you want to add to, it must be under construction. + * @param addition The protocol you want to incorporate into \e proto, it must be registered. + */ +OBJC_EXPORT void +protocol_addProtocol(Protocol * _Nonnull proto, Protocol * _Nonnull addition) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + +/** + * Adds a property to a protocol. The protocol must be under construction. + * + * @param proto The protocol to add a property to. + * @param name The name of the property. + * @param attributes An array of property attributes. + * @param attributeCount The number of attributes in \e attributes. + * @param isRequiredProperty YES if the property (accessor methods) is not optional. + * @param isInstanceProperty YES if the property (accessor methods) are instance methods. + * This is the only case allowed fo a property, as a result, setting this to NO will + * not add the property to the protocol at all. + */ +OBJC_EXPORT void +protocol_addProperty(Protocol * _Nonnull proto, const char * _Nonnull name, + const objc_property_attribute_t * _Nullable attributes, + unsigned int attributeCount, + BOOL isRequiredProperty, BOOL isInstanceProperty) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + + +/* Working with Libraries */ + +/** + * Returns the names of all the loaded Objective-C frameworks and dynamic + * libraries. + * + * @param outCount The number of names returned. + * + * @return An array of C strings of names. Must be free()'d by caller. + */ +OBJC_EXPORT const char * _Nonnull * _Nonnull +objc_copyImageNames(unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the dynamic library name a class originated from. + * + * @param cls The class you are inquiring about. + * + * @return The name of the library containing this class. + */ +OBJC_EXPORT const char * _Nullable +class_getImageName(Class _Nullable cls) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns the names of all the classes within a library. + * + * @param image The library or framework you are inquiring about. + * @param outCount The number of class names returned. + * + * @return An array of C strings representing the class names. + */ +OBJC_EXPORT const char * _Nonnull * _Nullable +objc_copyClassNamesForImage(const char * _Nonnull image, + unsigned int * _Nullable outCount) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + + +/* Working with Selectors */ + +/** + * Returns the name of the method specified by a given selector. + * + * @param sel A pointer of type \c SEL. Pass the selector whose name you wish to determine. + * + * @return A C string indicating the name of the selector. + */ +OBJC_EXPORT const char * _Nonnull +sel_getName(SEL _Nonnull sel) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + + +/** + * Registers a method with the Objective-C runtime system, maps the method + * name to a selector, and returns the selector value. + * + * @param str A pointer to a C string. Pass the name of the method you wish to register. + * + * @return A pointer of type SEL specifying the selector for the named method. + * + * @note You must register a method name with the Objective-C runtime system to obtain the + * method’s selector before you can add the method to a class definition. If the method name + * has already been registered, this function simply returns the selector. + */ +OBJC_EXPORT SEL _Nonnull +sel_registerName(const char * _Nonnull str) + OBJC_AVAILABLE(10.0, 2.0, 9.0, 1.0, 2.0); + +/** + * Returns a Boolean value that indicates whether two selectors are equal. + * + * @param lhs The selector to compare with rhs. + * @param rhs The selector to compare with lhs. + * + * @return \c YES if \e lhs and \e rhs are equal, otherwise \c NO. + * + * @note sel_isEqual is equivalent to ==. + */ +OBJC_EXPORT BOOL +sel_isEqual(SEL _Nonnull lhs, SEL _Nonnull rhs) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + + +/* Objective-C Language Features */ + +/** + * This function is inserted by the compiler when a mutation + * is detected during a foreach iteration. It gets called + * when a mutation occurs, and the enumerationMutationHandler + * is enacted if it is set up. A fatal error occurs if a handler is not set up. + * + * @param obj The object being mutated. + * + */ +OBJC_EXPORT void +objc_enumerationMutation(id _Nonnull obj) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Sets the current mutation handler. + * + * @param handler Function pointer to the new mutation handler. + */ +OBJC_EXPORT void +objc_setEnumerationMutationHandler(void (*_Nullable handler)(id _Nonnull )) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Set the function to be called by objc_msgForward. + * + * @param fwd Function to be jumped to by objc_msgForward. + * @param fwd_stret Function to be jumped to by objc_msgForward_stret. + * + * @see message.h::_objc_msgForward + */ +OBJC_EXPORT void +objc_setForwardHandler(void * _Nonnull fwd, void * _Nonnull fwd_stret) + OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); + +/** + * Creates a pointer to a function that will call the block + * when the method is called. + * + * @param block The block that implements this method. Its signature should + * be: method_return_type ^(id self, method_args...). + * The selector is not available as a parameter to this block. + * The block is copied with \c Block_copy(). + * + * @return The IMP that calls this block. Must be disposed of with + * \c imp_removeBlock. + */ +OBJC_EXPORT IMP _Nonnull +imp_implementationWithBlock(id _Nonnull block) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + +/** + * Return the block associated with an IMP that was created using + * \c imp_implementationWithBlock. + * + * @param anImp The IMP that calls this block. + * + * @return The block called by \e anImp. + */ +OBJC_EXPORT id _Nullable +imp_getBlock(IMP _Nonnull anImp) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + +/** + * Disassociates a block from an IMP that was created using + * \c imp_implementationWithBlock and releases the copy of the + * block that was created. + * + * @param anImp An IMP that was created using \c imp_implementationWithBlock. + * + * @return YES if the block was released successfully, NO otherwise. + * (For example, the block might not have been used to create an IMP previously). + */ +OBJC_EXPORT BOOL +imp_removeBlock(IMP _Nonnull anImp) + OBJC_AVAILABLE(10.7, 4.3, 9.0, 1.0, 2.0); + +/** + * This loads the object referenced by a weak pointer and returns it, after + * retaining and autoreleasing the object to ensure that it stays alive + * long enough for the caller to use it. This function would be used + * anywhere a __weak variable is used in an expression. + * + * @param location The weak pointer address + * + * @return The object pointed to by \e location, or \c nil if \e *location is \c nil. + */ +OBJC_EXPORT id _Nullable +objc_loadWeak(id _Nullable * _Nonnull location) + OBJC_AVAILABLE(10.7, 5.0, 9.0, 1.0, 2.0); + +/** + * This function stores a new value into a __weak variable. It would + * be used anywhere a __weak variable is the target of an assignment. + * + * @param location The address of the weak pointer itself + * @param obj The new object this weak ptr should now point to + * + * @return The value stored into \e location, i.e. \e obj + */ +OBJC_EXPORT id _Nullable +objc_storeWeak(id _Nullable * _Nonnull location, id _Nullable obj) + OBJC_AVAILABLE(10.7, 5.0, 9.0, 1.0, 2.0); + + +/* Associative References */ + +/** + * Policies related to associative references. + * These are options to objc_setAssociatedObject() + */ +typedef OBJC_ENUM(uintptr_t, objc_AssociationPolicy) { + OBJC_ASSOCIATION_ASSIGN = 0, /**< Specifies a weak reference to the associated object. */ + OBJC_ASSOCIATION_RETAIN_NONATOMIC = 1, /**< Specifies a strong reference to the associated object. + * The association is not made atomically. */ + OBJC_ASSOCIATION_COPY_NONATOMIC = 3, /**< Specifies that the associated object is copied. + * The association is not made atomically. */ + OBJC_ASSOCIATION_RETAIN = 01401, /**< Specifies a strong reference to the associated object. + * The association is made atomically. */ + OBJC_ASSOCIATION_COPY = 01403 /**< Specifies that the associated object is copied. + * The association is made atomically. */ +}; + +/** + * Sets an associated value for a given object using a given key and association policy. + * + * @param object The source object for the association. + * @param key The key for the association. + * @param value The value to associate with the key key for object. Pass nil to clear an existing association. + * @param policy The policy for the association. For possible values, see “Associative Object Behaviors.” + * + * @see objc_setAssociatedObject + * @see objc_removeAssociatedObjects + */ +OBJC_EXPORT void +objc_setAssociatedObject(id _Nonnull object, const void * _Nonnull key, + id _Nullable value, objc_AssociationPolicy policy) + OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0, 2.0); + +/** + * Returns the value associated with a given object for a given key. + * + * @param object The source object for the association. + * @param key The key for the association. + * + * @return The value associated with the key \e key for \e object. + * + * @see objc_setAssociatedObject + */ +OBJC_EXPORT id _Nullable +objc_getAssociatedObject(id _Nonnull object, const void * _Nonnull key) + OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0, 2.0); + +/** + * Removes all associations for a given object. + * + * @param object An object that maintains associated objects. + * + * @note The main purpose of this function is to make it easy to return an object + * to a "pristine state”. You should not use this function for general removal of + * associations from objects, since it also removes associations that other clients + * may have added to the object. Typically you should use \c objc_setAssociatedObject + * with a nil value to clear an association. + * + * @see objc_setAssociatedObject + * @see objc_getAssociatedObject + */ +OBJC_EXPORT void +objc_removeAssociatedObjects(id _Nonnull object) + OBJC_AVAILABLE(10.6, 3.1, 9.0, 1.0, 2.0); + + +/* Hooks for Swift */ + +/** + * Function type for a hook that intercepts class_getImageName(). + * + * @param cls The class whose image name is being looked up. + * @param outImageName On return, the result of the image name lookup. + * @return YES if an image name for this class was found, NO otherwise. + * + * @see class_getImageName + * @see objc_setHook_getImageName + */ +typedef BOOL (*objc_hook_getImageName)(Class _Nonnull cls, const char * _Nullable * _Nonnull outImageName); + +/** + * Install a hook for class_getImageName(). + * + * @param newValue The hook function to install. + * @param outOldValue The address of a function pointer variable. On return, + * the old hook function is stored in the variable. + * + * @note The store to *outOldValue is thread-safe: the variable will be + * updated before class_getImageName() calls your new hook to read it, + * even if your new hook is called from another thread before this + * setter completes. + * @note The first hook in the chain is the native implementation of + * class_getImageName(). Your hook should call the previous hook for + * classes that you do not recognize. + * + * @see class_getImageName + * @see objc_hook_getImageName + */ +OBJC_EXPORT void objc_setHook_getImageName(objc_hook_getImageName _Nonnull newValue, + objc_hook_getImageName _Nullable * _Nonnull outOldValue) + OBJC_AVAILABLE(10.14, 12.0, 12.0, 5.0, 3.0); + +/** + * Function type for a hook that assists objc_getClass() and related functions. + * + * @param name The class name to look up. + * @param outClass On return, the result of the class lookup. + * @return YES if a class with this name was found, NO otherwise. + * + * @see objc_getClass + * @see objc_setHook_getClass + */ +typedef BOOL (*objc_hook_getClass)(const char * _Nonnull name, Class _Nullable * _Nonnull outClass); + +/** + * Install a hook for objc_getClass() and related functions. + * + * @param newValue The hook function to install. + * @param outOldValue The address of a function pointer variable. On return, + * the old hook function is stored in the variable. + * + * @note The store to *outOldValue is thread-safe: the variable will be + * updated before objc_getClass() calls your new hook to read it, + * even if your new hook is called from another thread before this + * setter completes. + * @note Your hook should call the previous hook for class names + * that you do not recognize. + * + * @see objc_getClass + * @see objc_hook_getClass + */ +#if !(TARGET_OS_OSX && __i386__) +#define OBJC_GETCLASSHOOK_DEFINED 1 +OBJC_EXPORT void objc_setHook_getClass(objc_hook_getClass _Nonnull newValue, + objc_hook_getClass _Nullable * _Nonnull outOldValue) + OBJC_AVAILABLE(10.14.4, 12.2, 12.2, 5.2, 3.2); +#endif + +/** + * Function type for a function that is called when an image is loaded. + * + * @param header The newly loaded header. + */ +struct mach_header; +typedef void (*objc_func_loadImage)(const struct mach_header * _Nonnull header); + +/** + * Add a function to be called when a new image is loaded. The function is + * called after ObjC has scanned and fixed up the image. It is called + * BEFORE +load methods are invoked. + * + * When adding a new function, that function is immediately called with all + * images that are currently loaded. It is then called as needed for images + * that are loaded afterwards. + * + * Note: the function is called with ObjC's internal runtime lock held. + * Be VERY careful with what the function does to avoid deadlocks or + * poor performance. + * + * @param func The function to add. + */ +#define OBJC_ADDLOADIMAGEFUNC_DEFINED 1 +OBJC_EXPORT void objc_addLoadImageFunc(objc_func_loadImage _Nonnull func) + OBJC_AVAILABLE(10.15, 13.0, 13.0, 6.0, 4.0); + +/** + * Function type for a hook that provides a name for lazily named classes. + * + * @param cls The class to generate a name for. + * @return The name of the class, or NULL if the name isn't known or can't me generated. + * + * @see objc_setHook_lazyClassNamer + */ +typedef const char * _Nullable (*objc_hook_lazyClassNamer)(_Nonnull Class cls); + +/** + * Install a hook to provide a name for lazily-named classes. + * + * @param newValue The hook function to install. + * @param outOldValue The address of a function pointer variable. On return, + * the old hook function is stored in the variable. + * + * @note The store to *outOldValue is thread-safe: the variable will be + * updated before objc_getClass() calls your new hook to read it, + * even if your new hook is called from another thread before this + * setter completes. + * @note Your hook must call the previous hook for class names + * that you do not recognize. + */ +#if !(TARGET_OS_OSX && __i386__) +#define OBJC_SETHOOK_LAZYCLASSNAMER_DEFINED 1 +OBJC_EXPORT +void objc_setHook_lazyClassNamer(_Nonnull objc_hook_lazyClassNamer newValue, + _Nonnull objc_hook_lazyClassNamer * _Nonnull oldOutValue) + OBJC_AVAILABLE(11.0, 14.0, 14.0, 7.0, 5.0); +#endif + +/** + * Callback from Objective-C to Swift to perform Swift class initialization. + */ +#if !(TARGET_OS_OSX && __i386__) +typedef Class _Nullable +(*_objc_swiftMetadataInitializer)(Class _Nonnull cls, void * _Nullable arg); +#endif + + +/** + * Perform Objective-C initialization of a Swift class. + * Do not call this function. It is provided for the Swift runtime's use only + * and will change without notice or mercy. + */ +#if !(TARGET_OS_OSX && __i386__) +#define OBJC_REALIZECLASSFROMSWIFT_DEFINED 1 +OBJC_EXPORT Class _Nullable +_objc_realizeClassFromSwift(Class _Nullable cls, void * _Nullable previously) + OBJC_AVAILABLE(10.14.4, 12.2, 12.2, 5.2, 3.2); +#endif + + +#define _C_ID '@' +#define _C_CLASS '#' +#define _C_SEL ':' +#define _C_CHR 'c' +#define _C_UCHR 'C' +#define _C_SHT 's' +#define _C_USHT 'S' +#define _C_INT 'i' +#define _C_UINT 'I' +#define _C_LNG 'l' +#define _C_ULNG 'L' +#define _C_LNG_LNG 'q' +#define _C_ULNG_LNG 'Q' +#define _C_FLT 'f' +#define _C_DBL 'd' +#define _C_BFLD 'b' +#define _C_BOOL 'B' +#define _C_VOID 'v' +#define _C_UNDEF '?' +#define _C_PTR '^' +#define _C_CHARPTR '*' +#define _C_ATOM '%' +#define _C_ARY_B '[' +#define _C_ARY_E ']' +#define _C_UNION_B '(' +#define _C_UNION_E ')' +#define _C_STRUCT_B '{' +#define _C_STRUCT_E '}' +#define _C_VECTOR '!' +#define _C_CONST 'r' + + +/* Obsolete types */ + +#if !__OBJC2__ + +#define CLS_GETINFO(cls,infomask) ((cls)->info & (infomask)) +#define CLS_SETINFO(cls,infomask) ((cls)->info |= (infomask)) + +// class is not a metaclass +#define CLS_CLASS 0x1 +// class is a metaclass +#define CLS_META 0x2 +// class's +initialize method has completed +#define CLS_INITIALIZED 0x4 +// class is posing +#define CLS_POSING 0x8 +// unused +#define CLS_MAPPED 0x10 +// class and subclasses need cache flush during image loading +#define CLS_FLUSH_CACHE 0x20 +// method cache should grow when full +#define CLS_GROW_CACHE 0x40 +// unused +#define CLS_NEED_BIND 0x80 +// methodLists is array of method lists +#define CLS_METHOD_ARRAY 0x100 +// the JavaBridge constructs classes with these markers +#define CLS_JAVA_HYBRID 0x200 +#define CLS_JAVA_CLASS 0x400 +// thread-safe +initialize +#define CLS_INITIALIZING 0x800 +// bundle unloading +#define CLS_FROM_BUNDLE 0x1000 +// C++ ivar support +#define CLS_HAS_CXX_STRUCTORS 0x2000 +// Lazy method list arrays +#define CLS_NO_METHOD_ARRAY 0x4000 +// +load implementation +#define CLS_HAS_LOAD_METHOD 0x8000 +// objc_allocateClassPair API +#define CLS_CONSTRUCTING 0x10000 +// class compiled with bigger class structure +#define CLS_EXT 0x20000 + + +struct objc_method_description_list { + int count; + struct objc_method_description list[1]; +}; + + +struct objc_protocol_list { + struct objc_protocol_list * _Nullable next; + long count; + __unsafe_unretained Protocol * _Nullable list[1]; +}; + + +struct objc_category { + char * _Nonnull category_name OBJC2_UNAVAILABLE; + char * _Nonnull class_name OBJC2_UNAVAILABLE; + struct objc_method_list * _Nullable instance_methods OBJC2_UNAVAILABLE; + struct objc_method_list * _Nullable class_methods OBJC2_UNAVAILABLE; + struct objc_protocol_list * _Nullable protocols OBJC2_UNAVAILABLE; +} OBJC2_UNAVAILABLE; + + +struct objc_ivar { + char * _Nullable ivar_name OBJC2_UNAVAILABLE; + char * _Nullable ivar_type OBJC2_UNAVAILABLE; + int ivar_offset OBJC2_UNAVAILABLE; +#ifdef __LP64__ + int space OBJC2_UNAVAILABLE; +#endif +} OBJC2_UNAVAILABLE; + +struct objc_ivar_list { + int ivar_count OBJC2_UNAVAILABLE; +#ifdef __LP64__ + int space OBJC2_UNAVAILABLE; +#endif + /* variable length structure */ + struct objc_ivar ivar_list[1] OBJC2_UNAVAILABLE; +} OBJC2_UNAVAILABLE; + + +struct objc_method { + SEL _Nonnull method_name OBJC2_UNAVAILABLE; + char * _Nullable method_types OBJC2_UNAVAILABLE; + IMP _Nonnull method_imp OBJC2_UNAVAILABLE; +} OBJC2_UNAVAILABLE; + +struct objc_method_list { + struct objc_method_list * _Nullable obsolete OBJC2_UNAVAILABLE; + + int method_count OBJC2_UNAVAILABLE; +#ifdef __LP64__ + int space OBJC2_UNAVAILABLE; +#endif + /* variable length structure */ + struct objc_method method_list[1] OBJC2_UNAVAILABLE; +} OBJC2_UNAVAILABLE; + + +typedef struct objc_symtab *Symtab OBJC2_UNAVAILABLE; + +struct objc_symtab { + unsigned long sel_ref_cnt OBJC2_UNAVAILABLE; + SEL _Nonnull * _Nullable refs OBJC2_UNAVAILABLE; + unsigned short cls_def_cnt OBJC2_UNAVAILABLE; + unsigned short cat_def_cnt OBJC2_UNAVAILABLE; + void * _Nullable defs[1] /* variable size */ OBJC2_UNAVAILABLE; +} OBJC2_UNAVAILABLE; + + +typedef struct objc_cache *Cache OBJC2_UNAVAILABLE; + +#define CACHE_BUCKET_NAME(B) ((B)->method_name) +#define CACHE_BUCKET_IMP(B) ((B)->method_imp) +#define CACHE_BUCKET_VALID(B) (B) +#ifndef __LP64__ +#define CACHE_HASH(sel, mask) (((uintptr_t)(sel)>>2) & (mask)) +#else +#define CACHE_HASH(sel, mask) (((unsigned int)((uintptr_t)(sel)>>3)) & (mask)) +#endif +struct objc_cache { + unsigned int mask /* total = mask + 1 */ OBJC2_UNAVAILABLE; + unsigned int occupied OBJC2_UNAVAILABLE; + Method _Nullable buckets[1] OBJC2_UNAVAILABLE; +}; + + +typedef struct objc_module *Module OBJC2_UNAVAILABLE; + +struct objc_module { + unsigned long version OBJC2_UNAVAILABLE; + unsigned long size OBJC2_UNAVAILABLE; + const char * _Nullable name OBJC2_UNAVAILABLE; + Symtab _Nullable symtab OBJC2_UNAVAILABLE; +} OBJC2_UNAVAILABLE; + +#else + +struct objc_method_list; + +#endif + + +/* Obsolete functions */ + +OBJC_EXPORT IMP _Nullable +class_lookupMethod(Class _Nullable cls, SEL _Nonnull sel) + __OSX_DEPRECATED(10.0, 10.5, "use class_getMethodImplementation instead") + __IOS_DEPRECATED(2.0, 2.0, "use class_getMethodImplementation instead") + __TVOS_DEPRECATED(9.0, 9.0, "use class_getMethodImplementation instead") + __WATCHOS_DEPRECATED(1.0, 1.0, "use class_getMethodImplementation instead") + +; +OBJC_EXPORT BOOL +class_respondsToMethod(Class _Nullable cls, SEL _Nonnull sel) + __OSX_DEPRECATED(10.0, 10.5, "use class_respondsToSelector instead") + __IOS_DEPRECATED(2.0, 2.0, "use class_respondsToSelector instead") + __TVOS_DEPRECATED(9.0, 9.0, "use class_respondsToSelector instead") + __WATCHOS_DEPRECATED(1.0, 1.0, "use class_respondsToSelector instead") + +; + +OBJC_EXPORT void +_objc_flush_caches(Class _Nullable cls) + __OSX_DEPRECATED(10.0, 10.5, "not recommended") + __IOS_DEPRECATED(2.0, 2.0, "not recommended") + __TVOS_DEPRECATED(9.0, 9.0, "not recommended") + __WATCHOS_DEPRECATED(1.0, 1.0, "not recommended") + +; + +OBJC_EXPORT id _Nullable +object_copyFromZone(id _Nullable anObject, size_t nBytes, void * _Nullable z) + OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE(10.0, 10.5, "use object_copy instead"); + +OBJC_EXPORT id _Nullable +object_realloc(id _Nullable anObject, size_t nBytes) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT id _Nullable +object_reallocFromZone(id _Nullable anObject, size_t nBytes, void * _Nullable z) + OBJC2_UNAVAILABLE; + +#define OBSOLETE_OBJC_GETCLASSES 1 +OBJC_EXPORT void * _Nonnull +objc_getClasses(void) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT void +objc_addClass(Class _Nonnull myClass) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT void +objc_setClassHandler(int (* _Nullable )(const char * _Nonnull)) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT void +objc_setMultithreaded(BOOL flag) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT id _Nullable +class_createInstanceFromZone(Class _Nullable, size_t idxIvars, + void * _Nullable z) + OBJC_OSX_DEPRECATED_OTHERS_UNAVAILABLE(10.0, 10.5, "use class_createInstance instead"); + +OBJC_EXPORT void +class_addMethods(Class _Nullable, struct objc_method_list * _Nonnull) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT void +class_removeMethods(Class _Nullable, struct objc_method_list * _Nonnull) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT void +_objc_resolve_categories_for_class(Class _Nonnull cls) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT Class _Nonnull +class_poseAs(Class _Nonnull imposter, Class _Nonnull original) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT unsigned int +method_getSizeOfArguments(Method _Nonnull m) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT unsigned +method_getArgumentInfo(struct objc_method * _Nonnull m, int arg, + const char * _Nullable * _Nonnull type, + int * _Nonnull offset) + UNAVAILABLE_ATTRIBUTE // This function was accidentally deleted in 10.9. + OBJC2_UNAVAILABLE; + +OBJC_EXPORT Class _Nullable +objc_getOrigClass(const char * _Nonnull name) + OBJC2_UNAVAILABLE; + +#define OBJC_NEXT_METHOD_LIST 1 +OBJC_EXPORT struct objc_method_list * _Nullable +class_nextMethodList(Class _Nullable, void * _Nullable * _Nullable) + OBJC2_UNAVAILABLE; +// usage for nextMethodList +// +// void *iterator = 0; +// struct objc_method_list *mlist; +// while ( mlist = class_nextMethodList( cls, &iterator ) ) +// ; + +OBJC_EXPORT id _Nullable +(* _Nonnull _alloc)(Class _Nullable, size_t) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT id _Nullable +(* _Nonnull _copy)(id _Nullable, size_t) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT id _Nullable +(* _Nonnull _realloc)(id _Nullable, size_t) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT id _Nullable +(* _Nonnull _dealloc)(id _Nullable) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT id _Nullable +(* _Nonnull _zoneAlloc)(Class _Nullable, size_t, void * _Nullable) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT id _Nullable +(* _Nonnull _zoneRealloc)(id _Nullable, size_t, void * _Nullable) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT id _Nullable +(* _Nonnull _zoneCopy)(id _Nullable, size_t, void * _Nullable) + OBJC2_UNAVAILABLE; + +OBJC_EXPORT void +(* _Nonnull _error)(id _Nullable, const char * _Nonnull, va_list) + OBJC2_UNAVAILABLE; + +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/os/base.h b/lib/libc/include/aarch64-macos-gnu/os/base.h new file mode 100644 index 0000000000..a630138a10 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/os/base.h @@ -0,0 +1,322 @@ +/* + * 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(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__ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/os/clock.h b/lib/libc/include/aarch64-macos-gnu/os/clock.h new file mode 100644 index 0000000000..2217dd6ef5 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/os/clock.h @@ -0,0 +1,18 @@ +#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__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/os/object.h b/lib/libc/include/aarch64-macos-gnu/os/object.h new file mode 100644 index 0000000000..b378cab8ae --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/os/object.h @@ -0,0 +1,303 @@ +/* + * 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 \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/os/workgroup.h b/lib/libc/include/aarch64-macos-gnu/os/workgroup.h new file mode 100644 index 0000000000..956808125c --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/os/workgroup.h @@ -0,0 +1,37 @@ +/* + * 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__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/os/workgroup_base.h b/lib/libc/include/aarch64-macos-gnu/os/workgroup_base.h new file mode 100644 index 0000000000..87ea379479 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/os/workgroup_base.h @@ -0,0 +1,78 @@ +#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 + +#if __has_feature(assume_nonnull) +#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +#define OS_WORKGROUP_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +#define OS_WORKGROUP_ASSUME_NONNULL_BEGIN +#define OS_WORKGROUP_ASSUME_NONNULL_END +#endif +#define OS_WORKGROUP_WARN_RESULT __attribute__((__warn_unused_result__)) +#define OS_WORKGROUP_EXPORT OS_EXPORT +#define OS_WORKGROUP_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED + +#define OS_WORKGROUP_DECL(name, swift_name) \ + OS_SWIFT_NAME(swift_name) \ + OS_OBJECT_SHOW_CLASS(name, OS_OBJECT_CLASS(object)) + +#if OS_OBJECT_USE_OBJC +#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...) \ + OS_SWIFT_NAME(swift_name) \ + OS_OBJECT_DECL_PROTOCOL(name ## __VA_ARGS__ ) +#else +#define OS_WORKGROUP_SUBCLASS_DECL_PROTO(name, swift_name, ...) +#endif + +#define OS_WORKGROUP_SUBCLASS_DECL(name, super, swift_name, ...) \ + OS_SWIFT_NAME(swift_name) \ + OS_OBJECT_SHOW_SUBCLASS(name, super, name, ## __VA_ARGS__) + +#if defined(__LP64__) +#define __OS_WORKGROUP_ATTR_SIZE__ 60 +#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56 +#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 36 +#else +#define __OS_WORKGROUP_ATTR_SIZE__ 60 +#define __OS_WORKGROUP_INTERVAL_DATA_SIZE__ 56 +#define __OS_WORKGROUP_JOIN_TOKEN_SIZE__ 28 +#endif + +#define _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT 0x2FA863B4 +#define _OS_WORKGROUP_ATTR_SIG_EMPTY_INIT 0x2FA863C4 + +struct OS_REFINED_FOR_SWIFT os_workgroup_attr_opaque_s { + uint32_t sig; + char opaque[__OS_WORKGROUP_ATTR_SIZE__]; +}; + +#define _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT 0x52A74C4D +struct OS_REFINED_FOR_SWIFT os_workgroup_interval_data_opaque_s { + uint32_t sig; + char opaque[__OS_WORKGROUP_INTERVAL_DATA_SIZE__]; +}; + +struct OS_REFINED_FOR_SWIFT os_workgroup_join_token_opaque_s { + uint32_t sig; + char opaque[__OS_WORKGROUP_JOIN_TOKEN_SIZE__]; +}; + +#endif /* __OS_WORKGROUP_BASE__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/os/workgroup_interval.h b/lib/libc/include/aarch64-macos-gnu/os/workgroup_interval.h new file mode 100644 index 0000000000..b68326dd1e --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/os/workgroup_interval.h @@ -0,0 +1,155 @@ +/* + * 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_INTERVAL__ +#define __OS_WORKGROUP_INTERVAL__ + +#ifndef __OS_WORKGROUP_INDIRECT__ +#error "Please #include instead of this file directly." +#include // For header doc +#endif + +__BEGIN_DECLS + +OS_WORKGROUP_ASSUME_NONNULL_BEGIN + +/*! + * @typedef os_workgroup_interval_t + * + * @abstract + * A subclass of an os_workgroup_t for tracking work performed as part of + * a repeating interval-driven workload. + */ +OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_interval, Repeatable); +OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_interval, os_workgroup, WorkGroupInterval); + +/* During the first instance of this API, the only supported interval + * workgroups are for audio workloads. Please refer to the AudioToolbox + * framework for more information. + */ + +/* + * @typedef os_workgroup_interval_data, os_workgroup_interval_data_t + * + * @abstract + * An opaque structure containing additional configuration for the workgroup + * interval. + */ +typedef struct os_workgroup_interval_data_opaque_s os_workgroup_interval_data_s; +typedef struct os_workgroup_interval_data_opaque_s *os_workgroup_interval_data_t; +#define OS_WORKGROUP_INTERVAL_DATA_INITIALIZER \ + { .sig = _OS_WORKGROUP_INTERVAL_DATA_SIG_INIT } + +/*! + * @function os_workgroup_interval_start + * + * @abstract + * Indicates to the system that the member threads of this + * os_workgroup_interval_t have begun working on an instance of the repeatable + * interval workload with the specified timestamps. This function is real time + * safe. + * + * This function will set and return an errno in the following cases: + * + * - The current thread is not a member of the os_workgroup_interval_t + * - The os_workgroup_interval_t has been cancelled + * - The timestamps passed in are malformed + * - os_workgroup_interval_start() was previously called on the + * os_workgroup_interval_t without an intervening os_workgroup_interval_finish() + * - A concurrent workgroup interval configuration operation is taking place. + * + * @param start + * Start timestamp specified in the os_clockid_t with which the + * os_workgroup_interval_t was created. This is generally a time in the past and + * indicates when the workgroup started working on an interval period + * + * @param deadline + * Deadline timestamp specified in the os_clockid_t with which the + * os_workgroup_interval_t was created. This specifies the deadline which the + * interval period would like to meet. + * + * @param data + * This field is currently unused and should be NULL + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_interval_start(os_workgroup_interval_t wg, uint64_t start, uint64_t + deadline, os_workgroup_interval_data_t _Nullable data); + +/*! + * @function os_workgroup_interval_update + * + * @abstract + * Updates an already started interval workgroup to have the new + * deadline specified. This function is real time safe. + * + * This function will return an error in the following cases: + * - The current thread is not a member of the os_workgroup_interval_t + * - The os_workgroup_interval_t has been cancelled + * - The timestamp passed in is malformed + * - os_workgroup_interval_start() was not previously called on the + * os_workgroup_interval_t or was already matched with an + * os_workgroup_interval_finish() + * - A concurrent workgroup interval configuration operation is taking place + * + * @param deadline + * Timestamp specified in the os_clockid_t with + * which the os_workgroup_interval_t was created. + * + * @param data + * This field is currently unused and should be NULL + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_interval_update(os_workgroup_interval_t wg, uint64_t deadline, + os_workgroup_interval_data_t _Nullable data); + +/*! + * @function os_workgroup_interval_finish + * + * @abstract + * Indicates to the system that the member threads of + * this os_workgroup_interval_t have finished working on the current instance + * of the interval workload. This function is real time safe. + * + * This function will return an error in the following cases: + * - The current thread is not a member of the os_workgroup_interval_t + * - os_workgroup_interval_start() was not previously called on the + * os_workgroup_interval_t or was already matched with an + * os_workgroup_interval_finish() + * - A concurrent workgroup interval configuration operation is taking place. + * + * @param data + * This field is currently unused and should be NULL + * + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_interval_finish(os_workgroup_interval_t wg, + os_workgroup_interval_data_t _Nullable data); + +OS_WORKGROUP_ASSUME_NONNULL_END + +__END_DECLS + +#endif /* __OS_WORKGROUP_INTERVAL__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/os/workgroup_object.h b/lib/libc/include/aarch64-macos-gnu/os/workgroup_object.h new file mode 100644 index 0000000000..f9e5b551db --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/os/workgroup_object.h @@ -0,0 +1,357 @@ +/* + * 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_OBJECT__ +#define __OS_WORKGROUP_OBJECT__ + +#ifndef __OS_WORKGROUP_INDIRECT__ +#error "Please #include instead of this file directly." +#include // For header doc +#endif + +__BEGIN_DECLS + +OS_WORKGROUP_ASSUME_NONNULL_BEGIN + +/*! + * @typedef os_workgroup_t + * + * @abstract + * A reference counted os object representing a workload that needs to + * be distinctly recognized and tracked by the system. The workgroup + * tracks a collection of threads all working cooperatively. An os_workgroup + * object - when not an instance of a specific os_workgroup_t subclass - + * represents a generic workload and makes no assumptions about the kind of + * work done. + * + * @discussion + * Threads can explicitly join an os_workgroup_t to mark themselves as + * participants in the workload. + */ +OS_WORKGROUP_DECL(os_workgroup, WorkGroup); + + +/* Attribute creation and specification */ + +/*! + * @typedef os_workgroup_attr_t + * + * @abstract + * Pointer to an opaque structure for describing attributes that can be + * configured on a workgroup at creation. + */ +typedef struct os_workgroup_attr_opaque_s os_workgroup_attr_s; +typedef struct os_workgroup_attr_opaque_s *os_workgroup_attr_t; + +/* os_workgroup_t attributes need to be initialized before use. This initializer + * allows you to create a workgroup with the system default attributes. */ +#define OS_WORKGROUP_ATTR_INITIALIZER_DEFAULT \ + { .sig = _OS_WORKGROUP_ATTR_SIG_DEFAULT_INIT } + + + +/* The main use of the workgroup API is through instantiations of the concrete + * subclasses - please refer to os/workgroup_interval.h and + * os/workgroup_parallel.h for more information on creating workgroups. + * + * The functions below operate on all subclasses of os_workgroup_t. + */ + +/*! + * @function os_workgroup_copy_port + * + * @abstract + * Returns a reference to a send right representing this workgroup that is to be + * sent to other processes. This port is to be passed to + * os_workgroup_create_with_port() to create a workgroup object. + * + * It is the client's responsibility to release the send right reference. + * + * If an error is encountered, errno is set and returned. + */ +API_AVAILABLE(macos(11.0)) +API_UNAVAILABLE(ios, tvos, watchos) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_copy_port(os_workgroup_t wg, mach_port_t *mach_port_out); + +/*! + * @function os_workgroup_create_with_port + * + * @abstract + * Create an os_workgroup_t object from a send right returned by a previous + * call to os_workgroup_copy_port, potentially in a different process. + * + * A newly created os_workgroup_t has no initial member threads - in particular + * the creating thread does not join the os_workgroup_t implicitly. + * + * @param name + * A client specified string for labelling the workgroup. This parameter is + * optional and can be NULL. + * + * @param mach_port + * The send right to create the workgroup from. No reference is consumed + * on the specified send right. + */ +API_AVAILABLE(macos(11.0)) +API_UNAVAILABLE(ios, tvos, watchos) +OS_SWIFT_NAME(WorkGroup.init(__name:port:)) OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED +os_workgroup_t _Nullable +os_workgroup_create_with_port(const char *_Nullable name, mach_port_t mach_port); + +/*! + * @function os_workgroup_create_with_workgroup + * + * @abstract + * Create a new os_workgroup object from an existing os_workgroup. + * + * The newly created os_workgroup has no initial member threads - in particular + * the creating threaad does not join the os_workgroup_t implicitly. + * + * @param name + * A client specified string for labelling the workgroup. This parameter is + * optional and can be NULL. + * + * @param wg + * The existing workgroup to create a new workgroup object from. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED +os_workgroup_t _Nullable +os_workgroup_create_with_workgroup(const char * _Nullable name, os_workgroup_t wg); + +/*! + * @typedef os_workgroup_join_token, os_workgroup_join_token_t + * + * @abstract + * An opaque join token which the client needs to pass to os_workgroup_join + * and os_workgroup_leave + */ +OS_REFINED_FOR_SWIFT +typedef struct os_workgroup_join_token_opaque_s os_workgroup_join_token_s; +OS_REFINED_FOR_SWIFT +typedef struct os_workgroup_join_token_opaque_s *os_workgroup_join_token_t; + + +/*! + * @function os_workgroup_join + * + * @abstract + * Joins the current thread to the specified workgroup and populates the join + * token that has been passed in. This API is real-time safe. + * + * @param wg + * The workgroup that the current thread would like to join + * + * @param token_out + * Pointer to a client allocated struct which the function will populate + * with the join token. This token must be passed in by the thread when it calls + * os_workgroup_leave(). + * + * Errors will be returned in the following cases: + * + * EALREADY The thread is already part of a workgroup that the specified + * workgroup does not nest with + * EINVAL The workgroup has been cancelled + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_join(os_workgroup_t wg, os_workgroup_join_token_t token_out); + +/*! + * @function os_workgroup_leave + * + * @abstract + * This removes the current thread from a workgroup it has previously + * joined. Threads must leave all workgroups in the reverse order that they + * have joined them. Failing to do so before exiting will result in undefined + * behavior. + * + * If the join token is malformed, the process will be aborted. + * + * This API is real time safe. + * + * @param wg + * The workgroup that the current thread would like to leave. + * + * @param token + * This is the join token populated by the most recent call to + * os_workgroup_join(). + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +void +os_workgroup_leave(os_workgroup_t wg, os_workgroup_join_token_t token); + +/* Working Arena index of a thread in a workgroup */ +typedef uint32_t os_workgroup_index; +/* Destructor for Working Arena */ +typedef void (*os_workgroup_working_arena_destructor_t)(void * _Nullable); + +/*! + * @function os_workgroup_set_working_arena + * + * @abstract + * Associates a client defined working arena with the workgroup. The arena + * is local to the workgroup object in the process. This is intended for + * distributing a manually managed memory allocation between member threads + * of the workgroup. + * + * This function can be called multiple times and the client specified + * destructor will be called on the previously assigned arena, if any. This + * function can only be called when no threads have currently joined the + * workgroup and all workloops associated with the workgroup are idle. + * + * @param wg + * The workgroup to associate the working arena with + * + * @param arena + * The client managed arena to associate with the workgroup. This value can + * be NULL. + * + * @param max_workers + * The maximum number of threads that will ever query the workgroup for the + * arena and request an index into it. If the arena is not used to partition + * work amongst member threads, then this field can be 0. + * + * @param destructor + * A destructor to call on the previously assigned working arena, if any + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT OS_WORKGROUP_WARN_RESULT +int +os_workgroup_set_working_arena(os_workgroup_t wg, void * _Nullable arena, + uint32_t max_workers, os_workgroup_working_arena_destructor_t destructor); + +/*! + * @function os_workgroup_get_working_arena + * + * @abstract + * Returns the working arena associated with the workgroup and the current + * thread's index in the workgroup. This function can only be called by a member + * of the workgroup. Multiple calls to this API by a member thread will return + * the same arena and index until the thread leaves the workgroup. + * + * For workloops with an associated workgroup, every work item on the workloop + * will receive the same index in the arena. + * + * This method returns NULL if no arena is set on the workgroup. The index + * returned by this function is zero-based and is namespaced per workgroup + * object in the process. The indices provided are strictly monotonic and never + * reused until a future call to os_workgroup_set_working_arena. + * + * @param wg + * The workgroup to get the working arena from. + * + * @param index_out + * A pointer to a os_workgroup_index which will be populated by the caller's + * index in the workgroup. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +void * _Nullable +os_workgroup_get_working_arena(os_workgroup_t wg, + os_workgroup_index * _Nullable index_out); + +/*! + * @function os_workgroup_cancel + * + * @abstract + * This API invalidates a workgroup and indicates to the system that the + * workload is no longer relevant to the caller. + * + * No new work should be initiated for a cancelled workgroup and + * work that is already underway should periodically check for + * cancellation with os_workgroup_testcancel and initiate cleanup if needed. + * + * Threads currently in the workgroup continue to be tracked together but no + * new threads may join this workgroup - the only possible operation allowed is + * to leave the workgroup. Other actions may have undefined behavior or + * otherwise fail. + * + * This API is idempotent. Cancellation is local to the workgroup object + * it is called on and does not affect other workgroups. + * + * @param wg + * The workgroup that that the thread would like to cancel + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +void +os_workgroup_cancel(os_workgroup_t wg); + +/*! + * @function os_workgroup_testcancel + * + * @abstract + * Returns true if the workgroup object has been cancelled. See also + * os_workgroup_cancel + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +bool +os_workgroup_testcancel(os_workgroup_t wg); + +/*! + * @typedef os_workgroup_max_parallel_threads_attr_t + * + * @abstract + * A pointer to a structure describing the set of properties of a workgroup to + * override with the explicitly specified values in the structure. + * + * See also os_workgroup_max_parallel_threads. + */ +OS_REFINED_FOR_SWIFT +typedef struct os_workgroup_max_parallel_threads_attr_s os_workgroup_mpt_attr_s; +OS_REFINED_FOR_SWIFT +typedef struct os_workgroup_max_parallel_threads_attr_s *os_workgroup_mpt_attr_t; + +/*! + * @function os_workgroup_max_parallel_threads + * + * @abstract + * Returns the system's recommendation for maximum number of threads the client + * should make for a multi-threaded workload in a given workgroup. + * + * This API takes into consideration the current hardware the code is running on + * and the attributes of the workgroup. It does not take into consideration the + * current load of the system and therefore always provides the most optimal + * recommendation for the workload. + * + * @param wg + * The workgroup in which the multi-threaded workload will be performed in. The + * threads performing the multi-threaded workload are expected to join this + * workgroup. + * + * @param attr + * This value is currently unused and should be NULL. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_REFINED_FOR_SWIFT OS_WORKGROUP_EXPORT +int +os_workgroup_max_parallel_threads(os_workgroup_t wg, os_workgroup_mpt_attr_t + _Nullable attr); + +OS_WORKGROUP_ASSUME_NONNULL_END + +__END_DECLS + +#endif /* __OS_WORKGROUP_OBJECT__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/os/workgroup_parallel.h b/lib/libc/include/aarch64-macos-gnu/os/workgroup_parallel.h new file mode 100644 index 0000000000..1a396f3f5d --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/os/workgroup_parallel.h @@ -0,0 +1,74 @@ +/* + * 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_PARALLEL__ +#define __OS_WORKGROUP_PARALLEL__ + +#ifndef __OS_WORKGROUP_INDIRECT__ +#error "Please #include instead of this file directly." +#include // For header doc +#endif + +#include + +__BEGIN_DECLS + +OS_WORKGROUP_ASSUME_NONNULL_BEGIN + +/*! + * @typedef os_workgroup_parallel_t + * + * @abstract + * A subclass of an os_workgroup_t for tracking parallel work. + */ +OS_WORKGROUP_SUBCLASS_DECL_PROTO(os_workgroup_parallel, Parallelizable); +OS_WORKGROUP_SUBCLASS_DECL(os_workgroup_parallel, os_workgroup, WorkGroupParallel); + +/*! + * @function os_workgroup_parallel_create + * + * @abstract + * Creates an os_workgroup_t which tracks a parallel workload. + * A newly created os_workgroup_interval_t has no initial member threads - + * in particular the creating thread does not join the os_workgroup_parallel_t + * implicitly. + * + * See also os_workgroup_max_parallel_threads(). + * + * @param name + * A client specified string for labelling the workgroup. This parameter is + * optional and can be NULL. + * + * @param attr + * The requested set of workgroup attributes. NULL is to be specified for the + * default set of attributes. + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +OS_WORKGROUP_EXPORT OS_WORKGROUP_RETURNS_RETAINED +OS_SWIFT_NAME(WorkGroupParallel.init(__name:attr:)) +os_workgroup_parallel_t _Nullable +os_workgroup_parallel_create(const char * _Nullable name, + os_workgroup_attr_t _Nullable attr); + +OS_WORKGROUP_ASSUME_NONNULL_END + +__END_DECLS + +#endif /* __OS_WORKGROUP_PARALLEL__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/pthread.h b/lib/libc/include/aarch64-macos-gnu/pthread.h new file mode 100644 index 0000000000..29a64eaea0 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/pthread.h @@ -0,0 +1,592 @@ +/* + * Copyright (c) 2000-2012 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@ + */ +/* + * Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991 + * All Rights Reserved + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose and without fee is hereby granted, + * provided that the above copyright notice appears in all copies and + * that both the copyright notice and this permission notice appear in + * supporting documentation. + * + * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, + * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* + * MkLinux + */ + +/* + * POSIX Threads - IEEE 1003.1c + */ + +#ifndef _PTHREAD_H +#define _PTHREAD_H + +#include <_types.h> +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(__cplusplus) + +#include +#include + +#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE || __cplusplus */ + +/* + * These symbols indicate which [optional] features are available + * They can be tested at compile time via '#ifdef XXX' + * The way to check for pthreads is like so: + + * #include + * #ifdef _POSIX_THREADS + * #include + * #endif + + */ + +/* These will be moved to unistd.h */ + +/* + * Note: These data structures are meant to be opaque. Only enough + * structure is exposed to support initializers. + * All of the typedefs will be moved to + */ + +#include +#include + +#if __has_feature(assume_nonnull) +_Pragma("clang assume_nonnull begin") +#endif +__BEGIN_DECLS +/* + * Threads + */ + + +/* + * Cancel cleanup handler management. Note, since these are implemented as macros, + * they *MUST* occur in matched pairs! + */ + +#define pthread_cleanup_push(func, val) \ + { \ + struct __darwin_pthread_handler_rec __handler; \ + pthread_t __self = pthread_self(); \ + __handler.__routine = func; \ + __handler.__arg = val; \ + __handler.__next = __self->__cleanup_stack; \ + __self->__cleanup_stack = &__handler; + +#define pthread_cleanup_pop(execute) \ + /* Note: 'handler' must be in this same lexical context! */ \ + __self->__cleanup_stack = __handler.__next; \ + if (execute) (__handler.__routine)(__handler.__arg); \ + } + +/* + * Thread attributes + */ + +#define PTHREAD_CREATE_JOINABLE 1 +#define PTHREAD_CREATE_DETACHED 2 + +#define PTHREAD_INHERIT_SCHED 1 +#define PTHREAD_EXPLICIT_SCHED 2 + +#define PTHREAD_CANCEL_ENABLE 0x01 /* Cancel takes place at next cancellation point */ +#define PTHREAD_CANCEL_DISABLE 0x00 /* Cancel postponed */ +#define PTHREAD_CANCEL_DEFERRED 0x02 /* Cancel waits until cancellation point */ +#define PTHREAD_CANCEL_ASYNCHRONOUS 0x00 /* Cancel occurs immediately */ + +/* Value returned from pthread_join() when a thread is canceled */ +#define PTHREAD_CANCELED ((void *) 1) + +/* We only support PTHREAD_SCOPE_SYSTEM */ +#define PTHREAD_SCOPE_SYSTEM 1 +#define PTHREAD_SCOPE_PROCESS 2 + +#define PTHREAD_PROCESS_SHARED 1 +#define PTHREAD_PROCESS_PRIVATE 2 + +/* + * Mutex protocol attributes + */ +#define PTHREAD_PRIO_NONE 0 +#define PTHREAD_PRIO_INHERIT 1 +#define PTHREAD_PRIO_PROTECT 2 + +/* + * Mutex type attributes + */ +#define PTHREAD_MUTEX_NORMAL 0 +#define PTHREAD_MUTEX_ERRORCHECK 1 +#define PTHREAD_MUTEX_RECURSIVE 2 +#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL + +/* + * Mutex policy attributes + */ +#define PTHREAD_MUTEX_POLICY_FAIRSHARE_NP 1 +#define PTHREAD_MUTEX_POLICY_FIRSTFIT_NP 3 + +/* + * RWLock variables + */ +#define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWLOCK_SIG_init, {0}} + +/* + * Mutex variables + */ +#define PTHREAD_MUTEX_INITIALIZER {_PTHREAD_MUTEX_SIG_init, {0}} + +/* */ +#if ((__MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070) || (__IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000)) || defined(__DRIVERKIT_VERSION_MIN_REQUIRED) +# if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) +# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER {_PTHREAD_ERRORCHECK_MUTEX_SIG_init, {0}} +# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER {_PTHREAD_RECURSIVE_MUTEX_SIG_init, {0}} +# endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */ +#endif + +/* */ +#define _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT \ + defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREAD_EPOCH) || (SWIFT_SDK_OVERLAY_PTHREAD_EPOCH < 1)) + +/* + * Condition variable attributes + */ + +/* + * Condition variables + */ + +#define PTHREAD_COND_INITIALIZER {_PTHREAD_COND_SIG_init, {0}} + +/* + * Initialization control (once) variables + */ + +#define PTHREAD_ONCE_INIT {_PTHREAD_ONCE_SIG_init, {0}} + +/* + * Prototypes for all PTHREAD interfaces + */ +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_atfork(void (* _Nullable)(void), void (* _Nullable)(void), + void (* _Nullable)(void)); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_destroy(pthread_attr_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_getdetachstate(const pthread_attr_t *, int *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_getguardsize(const pthread_attr_t * __restrict, size_t * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_getinheritsched(const pthread_attr_t * __restrict, int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_getschedparam(const pthread_attr_t * __restrict, + struct sched_param * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict, int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_getscope(const pthread_attr_t * __restrict, int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_getstack(const pthread_attr_t * __restrict, + void * _Nullable * _Nonnull __restrict, size_t * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_getstackaddr(const pthread_attr_t * __restrict, + void * _Nullable * _Nonnull __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_getstacksize(const pthread_attr_t * __restrict, size_t * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_init(pthread_attr_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_setdetachstate(pthread_attr_t *, int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_setguardsize(pthread_attr_t *, size_t); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_setinheritsched(pthread_attr_t *, int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_setschedparam(pthread_attr_t * __restrict, + const struct sched_param * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_setschedpolicy(pthread_attr_t *, int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_setscope(pthread_attr_t *, int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_setstack(pthread_attr_t *, void *, size_t); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_setstackaddr(pthread_attr_t *, void *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_attr_setstacksize(pthread_attr_t *, size_t); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_cancel(pthread_t) __DARWIN_ALIAS(pthread_cancel); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_cond_broadcast(pthread_cond_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_cond_destroy(pthread_cond_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_cond_init( + pthread_cond_t * __restrict, + const pthread_condattr_t * _Nullable __restrict) + __DARWIN_ALIAS(pthread_cond_init); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_cond_signal(pthread_cond_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_cond_timedwait( + pthread_cond_t * __restrict, pthread_mutex_t * __restrict, + const struct timespec * _Nullable __restrict) + __DARWIN_ALIAS_C(pthread_cond_timedwait); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_cond_wait(pthread_cond_t * __restrict, + pthread_mutex_t * __restrict) __DARWIN_ALIAS_C(pthread_cond_wait); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_condattr_destroy(pthread_condattr_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_condattr_init(pthread_condattr_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_condattr_getpshared(const pthread_condattr_t * __restrict, + int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_condattr_setpshared(pthread_condattr_t *, int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +#if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT +int pthread_create(pthread_t _Nullable * _Nonnull __restrict, + const pthread_attr_t * _Nullable __restrict, + void * _Nullable (* _Nonnull)(void * _Nullable), + void * _Nullable __restrict); +#else +int pthread_create(pthread_t * __restrict, + const pthread_attr_t * _Nullable __restrict, + void *(* _Nonnull)(void *), void * _Nullable __restrict); +#endif // _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_detach(pthread_t); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_equal(pthread_t _Nullable, pthread_t _Nullable); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +void pthread_exit(void * _Nullable) __dead2; + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_getconcurrency(void); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_getschedparam(pthread_t , int * _Nullable __restrict, + struct sched_param * _Nullable __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +void* _Nullable pthread_getspecific(pthread_key_t); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_join(pthread_t , void * _Nullable * _Nullable) + __DARWIN_ALIAS_C(pthread_join); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_key_create(pthread_key_t *, void (* _Nullable)(void *)); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_key_delete(pthread_key_t); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutex_destroy(pthread_mutex_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict, + int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutex_init(pthread_mutex_t * __restrict, + const pthread_mutexattr_t * _Nullable __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutex_lock(pthread_mutex_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict, int, + int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutex_trylock(pthread_mutex_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutex_unlock(pthread_mutex_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_destroy(pthread_mutexattr_t *) __DARWIN_ALIAS(pthread_mutexattr_destroy); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict, + int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict, + int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict, + int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict, + int * __restrict); + +__API_AVAILABLE(macos(10.13.4), ios(11.3), watchos(4.3), tvos(11.3)) +int pthread_mutexattr_getpolicy_np(const pthread_mutexattr_t * __restrict, + int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_init(pthread_mutexattr_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_mutexattr_settype(pthread_mutexattr_t *, int); + +__API_AVAILABLE(macos(10.7), ios(5.0)) +int pthread_mutexattr_setpolicy_np(pthread_mutexattr_t *, int); + +__SWIFT_UNAVAILABLE_MSG("Use lazily initialized globals instead") +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_once(pthread_once_t *, void (* _Nonnull)(void)); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlock_destroy(pthread_rwlock_t * ) __DARWIN_ALIAS(pthread_rwlock_destroy); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlock_init(pthread_rwlock_t * __restrict, + const pthread_rwlockattr_t * _Nullable __restrict) + __DARWIN_ALIAS(pthread_rwlock_init); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlock_rdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_rdlock); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlock_tryrdlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_tryrdlock); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlock_trywrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_trywrlock); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlock_wrlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_wrlock); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlock_unlock(pthread_rwlock_t *) __DARWIN_ALIAS(pthread_rwlock_unlock); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict, + int * __restrict); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlockattr_init(pthread_rwlockattr_t *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +pthread_t pthread_self(void); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_setcancelstate(int , int * _Nullable) + __DARWIN_ALIAS(pthread_setcancelstate); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_setcanceltype(int , int * _Nullable) + __DARWIN_ALIAS(pthread_setcanceltype); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_setconcurrency(int); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_setschedparam(pthread_t, int, const struct sched_param *); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_setspecific(pthread_key_t , const void * _Nullable); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +void pthread_testcancel(void) __DARWIN_ALIAS(pthread_testcancel); + +#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(__cplusplus) + +/* returns non-zero if pthread_create or cthread_fork have been called */ +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_is_threaded_np(void); + +__API_AVAILABLE(macos(10.6), ios(3.2)) +int pthread_threadid_np(pthread_t _Nullable,__uint64_t* _Nullable); + +/*SPI to set and get pthread name*/ +__API_AVAILABLE(macos(10.6), ios(3.2)) +int pthread_getname_np(pthread_t,char*,size_t); + +__API_AVAILABLE(macos(10.6), ios(3.2)) +int pthread_setname_np(const char*); + +/* returns non-zero if the current thread is the main thread */ +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_main_np(void); + +/* return the mach thread bound to the pthread */ +__API_AVAILABLE(macos(10.4), ios(2.0)) +mach_port_t pthread_mach_thread_np(pthread_t); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +size_t pthread_get_stacksize_np(pthread_t); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +void* pthread_get_stackaddr_np(pthread_t); + +/* Like pthread_cond_signal(), but only wake up the specified pthread */ +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_cond_signal_thread_np(pthread_cond_t *, pthread_t _Nullable); + +/* Like pthread_cond_timedwait, but use a relative timeout */ +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_cond_timedwait_relative_np(pthread_cond_t *, pthread_mutex_t *, + const struct timespec * _Nullable); + +/* Like pthread_create(), but leaves the thread suspended */ +__API_AVAILABLE(macos(10.4), ios(2.0)) +#if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT +int pthread_create_suspended_np( + pthread_t _Nullable * _Nonnull, const pthread_attr_t * _Nullable, + void * _Nullable (* _Nonnull)(void * _Nullable), void * _Nullable); +#else +int pthread_create_suspended_np(pthread_t *, const pthread_attr_t * _Nullable, + void *(* _Nonnull)(void *), void * _Nullable); +#endif + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_kill(pthread_t, int); + +__API_AVAILABLE(macos(10.5), ios(2.0)) +_Nullable pthread_t pthread_from_mach_thread_np(mach_port_t); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +int pthread_sigmask(int, const sigset_t * _Nullable, sigset_t * _Nullable) + __DARWIN_ALIAS(pthread_sigmask); + +__API_AVAILABLE(macos(10.4), ios(2.0)) +void pthread_yield_np(void); + +__API_AVAILABLE(macos(11.0)) +__API_UNAVAILABLE(ios, tvos, watchos) +void pthread_jit_write_protect_np(int enabled); + +__API_AVAILABLE(macos(11.0)) +__API_UNAVAILABLE(ios, tvos, watchos) +int pthread_jit_write_protect_supported_np(void); + +/*! + * @function pthread_cpu_number_np + * + * @param cpu_number_out + * The CPU number that the thread was running on at the time of query. + * This cpu number is in the interval [0, ncpus) (from sysctlbyname("hw.ncpu")) + * + * @result + * This function returns 0 or the value of errno if an error occurred. + * + * @note + * Optimizations of per-CPU datastructures based on the result of this function + * still require synchronization since it is not guaranteed that the thread will + * still be on the same CPU by the time the function returns. + */ +__API_AVAILABLE(macos(11.0), ios(14.2), tvos(14.2), watchos(7.1)) +int +pthread_cpu_number_np(size_t *cpu_number_out); + +#endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE || __cplusplus */ +__END_DECLS +#if __has_feature(assume_nonnull) +_Pragma("clang assume_nonnull end") +#endif + +#endif /* _PTHREAD_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/pthread/sched.h b/lib/libc/include/aarch64-macos-gnu/pthread/sched.h new file mode 100644 index 0000000000..88a783127d --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/pthread/sched.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2000-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 _SCHED_H_ +#define _SCHED_H_ + +#include +#include + +__BEGIN_DECLS +/* + * Scheduling paramters + */ +#ifndef __POSIX_LIB__ +struct sched_param { int sched_priority; char __opaque[__SCHED_PARAM_SIZE__]; }; +#else +struct sched_param; +#endif + +extern int sched_yield(void); +extern int sched_get_priority_min(int); +extern int sched_get_priority_max(int); +__END_DECLS + +#endif /* _SCHED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sched.h b/lib/libc/include/aarch64-macos-gnu/sched.h new file mode 100644 index 0000000000..88a783127d --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sched.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2000-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 _SCHED_H_ +#define _SCHED_H_ + +#include +#include + +__BEGIN_DECLS +/* + * Scheduling paramters + */ +#ifndef __POSIX_LIB__ +struct sched_param { int sched_priority; char __opaque[__SCHED_PARAM_SIZE__]; }; +#else +struct sched_param; +#endif + +extern int sched_yield(void); +extern int sched_get_priority_min(int); +extern int sched_get_priority_max(int); +__END_DECLS + +#endif /* _SCHED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/signal.h b/lib/libc/include/aarch64-macos-gnu/signal.h new file mode 100644 index 0000000000..5ae13452c1 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/signal.h @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2000 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@ + */ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)signal.h 8.3 (Berkeley) 3/30/94 + */ + +#ifndef _USER_SIGNAL_H +#define _USER_SIGNAL_H + +#include +#include <_types.h> +#include + +#include +#include + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +extern __const char *__const sys_signame[NSIG]; +extern __const char *__const sys_siglist[NSIG]; +#endif + +__BEGIN_DECLS +int raise(int); +__END_DECLS + +#ifndef _ANSI_SOURCE +__BEGIN_DECLS +void (* _Nullable bsd_signal(int, void (* _Nullable)(int)))(int); +int kill(pid_t, int) __DARWIN_ALIAS(kill); +int killpg(pid_t, int) __DARWIN_ALIAS(killpg); +int pthread_kill(pthread_t, int); +int pthread_sigmask(int, const sigset_t *, sigset_t *) __DARWIN_ALIAS(pthread_sigmask); +int sigaction(int, const struct sigaction * __restrict, + struct sigaction * __restrict); +int sigaddset(sigset_t *, int); +int sigaltstack(const stack_t * __restrict, stack_t * __restrict) __DARWIN_ALIAS(sigaltstack) __WATCHOS_PROHIBITED __TVOS_PROHIBITED; +int sigdelset(sigset_t *, int); +int sigemptyset(sigset_t *); +int sigfillset(sigset_t *); +int sighold(int); +int sigignore(int); +int siginterrupt(int, int); +int sigismember(const sigset_t *, int); +int sigpause(int) __DARWIN_ALIAS_C(sigpause); +int sigpending(sigset_t *); +int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict); +int sigrelse(int); +void (* _Nullable sigset(int, void (* _Nullable)(int)))(int); +int sigsuspend(const sigset_t *) __DARWIN_ALIAS_C(sigsuspend); +int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +void psignal(unsigned int, const char *); +int sigblock(int); +int sigsetmask(int); +int sigvec(int, struct sigvec *, struct sigvec *); +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +__END_DECLS + +/* List definitions after function declarations, or Reiser cpp gets upset. */ +__header_always_inline int +__sigbits(int __signo) +{ + return __signo > __DARWIN_NSIG ? 0 : (1 << (__signo - 1)); +} + +#define sigaddset(set, signo) (*(set) |= __sigbits(signo), 0) +#define sigdelset(set, signo) (*(set) &= ~__sigbits(signo), 0) +#define sigismember(set, signo) ((*(set) & __sigbits(signo)) != 0) +#define sigemptyset(set) (*(set) = 0, 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) +#endif /* !_ANSI_SOURCE */ + +#endif /* !_USER_SIGNAL_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/simd/common.h b/lib/libc/include/aarch64-macos-gnu/simd/common.h new file mode 100644 index 0000000000..5408c535fd --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/simd/common.h @@ -0,0 +1,4458 @@ +/*! @header + * The interfaces declared in this header provide "common" elementwise + * operations that are neither math nor logic functions. These are available + * only for floating-point vectors and scalars, except for min, max, abs, + * clamp, and the reduce operations, which also support integer vectors. + * + * simd_abs(x) Absolute value of x. Also available as fabs + * for floating-point vectors. If x is the + * smallest signed integer, x is returned. + * + * simd_max(x,y) Returns the maximum of x and y. Also available + * as fmax for floating-point vectors. + * + * simd_min(x,y) Returns the minimum of x and y. Also available + * as fmin for floating-point vectors. + * + * simd_clamp(x,min,max) x clamped to the range [min, max]. + * + * simd_sign(x) -1 if x is less than zero, 0 if x is zero or + * NaN, and +1 if x is greater than zero. + * + * simd_mix(x,y,t) If t is not in the range [0,1], the result is + * undefined. Otherwise the result is x+(y-x)*t, + * which linearly interpolates between x and y. + * + * simd_recip(x) An approximation to 1/x. If x is very near the + * limits of representable values, or is infinity + * or NaN, the result is undefined. There are + * two variants of this function: + * + * simd_precise_recip(x) + * + * and + * + * simd_fast_recip(x). + * + * The "precise" variant is accurate to a few ULPs, + * whereas the "fast" variant may have as little + * as 11 bits of accuracy in float and about 22 + * bits in double. + * + * The function simd_recip(x) resolves to + * simd_precise_recip(x) ordinarily, but to + * simd_fast_recip(x) when used in a translation + * unit compiled with -ffast-math (when + * -ffast-math is in effect, you may still use the + * precise version of this function by calling it + * explicitly by name). + * + * simd_rsqrt(x) An approximation to 1/sqrt(x). If x is + * infinity or NaN, the result is undefined. + * There are two variants of this function: + * + * simd_precise_rsqrt(x) + * + * and + * + * simd_fast_rsqrt(x). + * + * The "precise" variant is accurate to a few ULPs, + * whereas the "fast" variant may have as little + * as 11 bits of accuracy in float and about 22 + * bits in double. + * + * The function simd_rsqrt(x) resolves to + * simd_precise_rsqrt(x) ordinarily, but to + * simd_fast_rsqrt(x) when used in a translation + * unit compiled with -ffast-math (when + * -ffast-math is in effect, you may still use the + * precise version of this function by calling it + * explicitly by name). + * + * simd_fract(x) The "fractional part" of x, which lies strictly + * in the range [0, 0x1.fffffep-1]. + * + * simd_step(edge,x) 0 if x < edge, and 1 otherwise. + * + * simd_smoothstep(edge0,edge1,x) 0 if x <= edge0, 1 if x >= edge1, and + * a Hermite interpolation between 0 and 1 if + * edge0 < x < edge1. + * + * simd_reduce_add(x) Sum of the elements of x. + * + * simd_reduce_min(x) Minimum of the elements of x. + * + * simd_reduce_max(x) Maximum of the elements of x. + * + * simd_equal(x,y) True if and only if every lane of x is equal + * to the corresponding lane of y. + * + * The following common functions are available in the simd:: namespace: + * + * C++ Function Equivalent C Function + * -------------------------------------------------------------------- + * simd::abs(x) simd_abs(x) + * simd::max(x,y) simd_max(x,y) + * simd::min(x,y) simd_min(x,y) + * simd::clamp(x,min,max) simd_clamp(x,min,max) + * simd::sign(x) simd_sign(x) + * simd::mix(x,y,t) simd_mix(x,y,t) + * simd::recip(x) simd_recip(x) + * simd::rsqrt(x) simd_rsqrt(x) + * simd::fract(x) simd_fract(x) + * simd::step(edge,x) simd_step(edge,x) + * simd::smoothstep(e0,e1,x) simd_smoothstep(e0,e1,x) + * simd::reduce_add(x) simd_reduce_add(x) + * simd::reduce_max(x) simd_reduce_max(x) + * simd::reduce_min(x) simd_reduce_min(x) + * simd::equal(x,y) simd_equal(x,y) + * + * simd::precise::recip(x) simd_precise_recip(x) + * simd::precise::rsqrt(x) simd_precise_rsqrt(x) + * + * simd::fast::recip(x) simd_fast_recip(x) + * simd::fast::rsqrt(x) simd_fast_rsqrt(x) + * + * @copyright 2014-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_COMMON_HEADER +#define SIMD_COMMON_HEADER + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char2 simd_abs(simd_char2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char3 simd_abs(simd_char3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char4 simd_abs(simd_char4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char8 simd_abs(simd_char8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char16 simd_abs(simd_char16 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char32 simd_abs(simd_char32 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_char64 simd_abs(simd_char64 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short2 simd_abs(simd_short2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short3 simd_abs(simd_short3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short4 simd_abs(simd_short4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short8 simd_abs(simd_short8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short16 simd_abs(simd_short16 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_short32 simd_abs(simd_short32 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int2 simd_abs(simd_int2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int3 simd_abs(simd_int3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int4 simd_abs(simd_int4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int8 simd_abs(simd_int8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_int16 simd_abs(simd_int16 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float2 simd_abs(simd_float2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float3 simd_abs(simd_float3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float4 simd_abs(simd_float4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float8 simd_abs(simd_float8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_float16 simd_abs(simd_float16 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_long2 simd_abs(simd_long2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_long3 simd_abs(simd_long3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_long4 simd_abs(simd_long4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_long8 simd_abs(simd_long8 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_double2 simd_abs(simd_double2 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_double3 simd_abs(simd_double3 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_double4 simd_abs(simd_double4 x); +/*! @abstract The elementwise absolute value of x. */ +static inline SIMD_CFUNC simd_double8 simd_abs(simd_double8 x); +/*! @abstract The elementwise absolute value of x. + * @discussion Deprecated. Use simd_abs(x) instead. */ +#define vector_abs simd_abs + +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char2 simd_max(simd_char2 x, simd_char2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char3 simd_max(simd_char3 x, simd_char3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char4 simd_max(simd_char4 x, simd_char4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char8 simd_max(simd_char8 x, simd_char8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char16 simd_max(simd_char16 x, simd_char16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char32 simd_max(simd_char32 x, simd_char32 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_char64 simd_max(simd_char64 x, simd_char64 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar2 simd_max(simd_uchar2 x, simd_uchar2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar3 simd_max(simd_uchar3 x, simd_uchar3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar4 simd_max(simd_uchar4 x, simd_uchar4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar8 simd_max(simd_uchar8 x, simd_uchar8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar16 simd_max(simd_uchar16 x, simd_uchar16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar32 simd_max(simd_uchar32 x, simd_uchar32 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uchar64 simd_max(simd_uchar64 x, simd_uchar64 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short2 simd_max(simd_short2 x, simd_short2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short3 simd_max(simd_short3 x, simd_short3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short4 simd_max(simd_short4 x, simd_short4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short8 simd_max(simd_short8 x, simd_short8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short16 simd_max(simd_short16 x, simd_short16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_short32 simd_max(simd_short32 x, simd_short32 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort2 simd_max(simd_ushort2 x, simd_ushort2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort3 simd_max(simd_ushort3 x, simd_ushort3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort4 simd_max(simd_ushort4 x, simd_ushort4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort8 simd_max(simd_ushort8 x, simd_ushort8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort16 simd_max(simd_ushort16 x, simd_ushort16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ushort32 simd_max(simd_ushort32 x, simd_ushort32 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int2 simd_max(simd_int2 x, simd_int2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int3 simd_max(simd_int3 x, simd_int3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int4 simd_max(simd_int4 x, simd_int4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int8 simd_max(simd_int8 x, simd_int8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_int16 simd_max(simd_int16 x, simd_int16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint2 simd_max(simd_uint2 x, simd_uint2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint3 simd_max(simd_uint3 x, simd_uint3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint4 simd_max(simd_uint4 x, simd_uint4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint8 simd_max(simd_uint8 x, simd_uint8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_uint16 simd_max(simd_uint16 x, simd_uint16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC float simd_max(float x, float y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float2 simd_max(simd_float2 x, simd_float2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float3 simd_max(simd_float3 x, simd_float3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float4 simd_max(simd_float4 x, simd_float4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float8 simd_max(simd_float8 x, simd_float8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_float16 simd_max(simd_float16 x, simd_float16 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_long2 simd_max(simd_long2 x, simd_long2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_long3 simd_max(simd_long3 x, simd_long3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_long4 simd_max(simd_long4 x, simd_long4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_long8 simd_max(simd_long8 x, simd_long8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ulong2 simd_max(simd_ulong2 x, simd_ulong2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ulong3 simd_max(simd_ulong3 x, simd_ulong3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ulong4 simd_max(simd_ulong4 x, simd_ulong4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_ulong8 simd_max(simd_ulong8 x, simd_ulong8 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC double simd_max(double x, double y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_double2 simd_max(simd_double2 x, simd_double2 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_double3 simd_max(simd_double3 x, simd_double3 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_double4 simd_max(simd_double4 x, simd_double4 y); +/*! @abstract The elementwise maximum of x and y. */ +static inline SIMD_CFUNC simd_double8 simd_max(simd_double8 x, simd_double8 y); +/*! @abstract The elementwise maximum of x and y. + * @discussion Deprecated. Use simd_max(x,y) instead. */ +#define vector_max simd_max + +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char2 simd_min(simd_char2 x, simd_char2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char3 simd_min(simd_char3 x, simd_char3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char4 simd_min(simd_char4 x, simd_char4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char8 simd_min(simd_char8 x, simd_char8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char16 simd_min(simd_char16 x, simd_char16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char32 simd_min(simd_char32 x, simd_char32 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_char64 simd_min(simd_char64 x, simd_char64 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar2 simd_min(simd_uchar2 x, simd_uchar2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar3 simd_min(simd_uchar3 x, simd_uchar3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar4 simd_min(simd_uchar4 x, simd_uchar4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar8 simd_min(simd_uchar8 x, simd_uchar8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar16 simd_min(simd_uchar16 x, simd_uchar16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar32 simd_min(simd_uchar32 x, simd_uchar32 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uchar64 simd_min(simd_uchar64 x, simd_uchar64 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short2 simd_min(simd_short2 x, simd_short2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short3 simd_min(simd_short3 x, simd_short3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short4 simd_min(simd_short4 x, simd_short4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short8 simd_min(simd_short8 x, simd_short8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short16 simd_min(simd_short16 x, simd_short16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_short32 simd_min(simd_short32 x, simd_short32 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort2 simd_min(simd_ushort2 x, simd_ushort2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort3 simd_min(simd_ushort3 x, simd_ushort3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort4 simd_min(simd_ushort4 x, simd_ushort4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort8 simd_min(simd_ushort8 x, simd_ushort8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort16 simd_min(simd_ushort16 x, simd_ushort16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ushort32 simd_min(simd_ushort32 x, simd_ushort32 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int2 simd_min(simd_int2 x, simd_int2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int3 simd_min(simd_int3 x, simd_int3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int4 simd_min(simd_int4 x, simd_int4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int8 simd_min(simd_int8 x, simd_int8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_int16 simd_min(simd_int16 x, simd_int16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint2 simd_min(simd_uint2 x, simd_uint2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint3 simd_min(simd_uint3 x, simd_uint3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint4 simd_min(simd_uint4 x, simd_uint4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint8 simd_min(simd_uint8 x, simd_uint8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_uint16 simd_min(simd_uint16 x, simd_uint16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC float simd_min(float x, float y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float2 simd_min(simd_float2 x, simd_float2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float3 simd_min(simd_float3 x, simd_float3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float4 simd_min(simd_float4 x, simd_float4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float8 simd_min(simd_float8 x, simd_float8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_float16 simd_min(simd_float16 x, simd_float16 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_long2 simd_min(simd_long2 x, simd_long2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_long3 simd_min(simd_long3 x, simd_long3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_long4 simd_min(simd_long4 x, simd_long4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_long8 simd_min(simd_long8 x, simd_long8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ulong2 simd_min(simd_ulong2 x, simd_ulong2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ulong3 simd_min(simd_ulong3 x, simd_ulong3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ulong4 simd_min(simd_ulong4 x, simd_ulong4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_ulong8 simd_min(simd_ulong8 x, simd_ulong8 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC double simd_min(double x, double y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_double2 simd_min(simd_double2 x, simd_double2 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_double3 simd_min(simd_double3 x, simd_double3 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_double4 simd_min(simd_double4 x, simd_double4 y); +/*! @abstract The elementwise minimum of x and y. */ +static inline SIMD_CFUNC simd_double8 simd_min(simd_double8 x, simd_double8 y); +/*! @abstract The elementwise minimum of x and y. + * @discussion Deprecated. Use simd_min(x,y) instead. */ +#define vector_min simd_min + + +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char2 simd_clamp(simd_char2 x, simd_char2 min, simd_char2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char3 simd_clamp(simd_char3 x, simd_char3 min, simd_char3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char4 simd_clamp(simd_char4 x, simd_char4 min, simd_char4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char8 simd_clamp(simd_char8 x, simd_char8 min, simd_char8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char16 simd_clamp(simd_char16 x, simd_char16 min, simd_char16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char32 simd_clamp(simd_char32 x, simd_char32 min, simd_char32 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_char64 simd_clamp(simd_char64 x, simd_char64 min, simd_char64 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar2 simd_clamp(simd_uchar2 x, simd_uchar2 min, simd_uchar2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar3 simd_clamp(simd_uchar3 x, simd_uchar3 min, simd_uchar3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar4 simd_clamp(simd_uchar4 x, simd_uchar4 min, simd_uchar4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar8 simd_clamp(simd_uchar8 x, simd_uchar8 min, simd_uchar8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar16 simd_clamp(simd_uchar16 x, simd_uchar16 min, simd_uchar16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar32 simd_clamp(simd_uchar32 x, simd_uchar32 min, simd_uchar32 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uchar64 simd_clamp(simd_uchar64 x, simd_uchar64 min, simd_uchar64 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short2 simd_clamp(simd_short2 x, simd_short2 min, simd_short2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short3 simd_clamp(simd_short3 x, simd_short3 min, simd_short3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short4 simd_clamp(simd_short4 x, simd_short4 min, simd_short4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short8 simd_clamp(simd_short8 x, simd_short8 min, simd_short8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short16 simd_clamp(simd_short16 x, simd_short16 min, simd_short16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_short32 simd_clamp(simd_short32 x, simd_short32 min, simd_short32 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort2 simd_clamp(simd_ushort2 x, simd_ushort2 min, simd_ushort2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort3 simd_clamp(simd_ushort3 x, simd_ushort3 min, simd_ushort3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort4 simd_clamp(simd_ushort4 x, simd_ushort4 min, simd_ushort4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort8 simd_clamp(simd_ushort8 x, simd_ushort8 min, simd_ushort8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort16 simd_clamp(simd_ushort16 x, simd_ushort16 min, simd_ushort16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ushort32 simd_clamp(simd_ushort32 x, simd_ushort32 min, simd_ushort32 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int2 simd_clamp(simd_int2 x, simd_int2 min, simd_int2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int3 simd_clamp(simd_int3 x, simd_int3 min, simd_int3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int4 simd_clamp(simd_int4 x, simd_int4 min, simd_int4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int8 simd_clamp(simd_int8 x, simd_int8 min, simd_int8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_int16 simd_clamp(simd_int16 x, simd_int16 min, simd_int16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint2 simd_clamp(simd_uint2 x, simd_uint2 min, simd_uint2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint3 simd_clamp(simd_uint3 x, simd_uint3 min, simd_uint3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint4 simd_clamp(simd_uint4 x, simd_uint4 min, simd_uint4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint8 simd_clamp(simd_uint8 x, simd_uint8 min, simd_uint8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_uint16 simd_clamp(simd_uint16 x, simd_uint16 min, simd_uint16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC float simd_clamp(float x, float min, float max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float2 simd_clamp(simd_float2 x, simd_float2 min, simd_float2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float3 simd_clamp(simd_float3 x, simd_float3 min, simd_float3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float4 simd_clamp(simd_float4 x, simd_float4 min, simd_float4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float8 simd_clamp(simd_float8 x, simd_float8 min, simd_float8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_float16 simd_clamp(simd_float16 x, simd_float16 min, simd_float16 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_long2 simd_clamp(simd_long2 x, simd_long2 min, simd_long2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_long3 simd_clamp(simd_long3 x, simd_long3 min, simd_long3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_long4 simd_clamp(simd_long4 x, simd_long4 min, simd_long4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_long8 simd_clamp(simd_long8 x, simd_long8 min, simd_long8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ulong2 simd_clamp(simd_ulong2 x, simd_ulong2 min, simd_ulong2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ulong3 simd_clamp(simd_ulong3 x, simd_ulong3 min, simd_ulong3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ulong4 simd_clamp(simd_ulong4 x, simd_ulong4 min, simd_ulong4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_ulong8 simd_clamp(simd_ulong8 x, simd_ulong8 min, simd_ulong8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC double simd_clamp(double x, double min, double max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_double2 simd_clamp(simd_double2 x, simd_double2 min, simd_double2 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_double3 simd_clamp(simd_double3 x, simd_double3 min, simd_double3 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_double4 simd_clamp(simd_double4 x, simd_double4 min, simd_double4 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Note that if you want to clamp all lanes to the same range, + * you can use a scalar value for min and max. */ +static inline SIMD_CFUNC simd_double8 simd_clamp(simd_double8 x, simd_double8 min, simd_double8 max); +/*! @abstract x clamped to the range [min, max]. + * @discussion Deprecated. Use simd_clamp(x,min,max) instead. */ +#define vector_clamp simd_clamp + +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC float simd_sign(float x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float2 simd_sign(simd_float2 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float3 simd_sign(simd_float3 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float4 simd_sign(simd_float4 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float8 simd_sign(simd_float8 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_float16 simd_sign(simd_float16 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC double simd_sign(double x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_double2 simd_sign(simd_double2 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_double3 simd_sign(simd_double3 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_double4 simd_sign(simd_double4 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. */ +static inline SIMD_CFUNC simd_double8 simd_sign(simd_double8 x); +/*! @abstract -1 if x is negative, +1 if x is positive, and 0 otherwise. + * @discussion Deprecated. Use simd_sign(x) instead. */ +#define vector_sign simd_sign + +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC float simd_mix(float x, float y, float t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float2 simd_mix(simd_float2 x, simd_float2 y, simd_float2 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float3 simd_mix(simd_float3 x, simd_float3 y, simd_float3 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float4 simd_mix(simd_float4 x, simd_float4 y, simd_float4 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float8 simd_mix(simd_float8 x, simd_float8 y, simd_float8 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_float16 simd_mix(simd_float16 x, simd_float16 y, simd_float16 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC double simd_mix(double x, double y, double t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_double2 simd_mix(simd_double2 x, simd_double2 y, simd_double2 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_double3 simd_mix(simd_double3 x, simd_double3 y, simd_double3 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_double4 simd_mix(simd_double4 x, simd_double4 y, simd_double4 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 */ +static inline SIMD_CFUNC simd_double8 simd_mix(simd_double8 x, simd_double8 y, simd_double8 t); +/*! @abstract Linearly interpolates between x and y, taking the value x when + * t=0 and y when t=1 + * @discussion Deprecated. Use simd_mix(x, y, t) instead. */ +#define vector_mix simd_mix + +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC float simd_precise_recip(float x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float2 simd_precise_recip(simd_float2 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float3 simd_precise_recip(simd_float3 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float4 simd_precise_recip(simd_float4 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float8 simd_precise_recip(simd_float8 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_float16 simd_precise_recip(simd_float16 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC double simd_precise_recip(double x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_double2 simd_precise_recip(simd_double2 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_double3 simd_precise_recip(simd_double3 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_double4 simd_precise_recip(simd_double4 x); +/*! @abstract A good approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * a few units in the last place (ULPs). */ +static inline SIMD_CFUNC simd_double8 simd_precise_recip(simd_double8 x); +/*! @abstract A good approximation to 1/x. + * @discussion Deprecated. Use simd_precise_recip(x) instead. */ +#define vector_precise_recip simd_precise_recip + +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC float simd_fast_recip(float x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float2 simd_fast_recip(simd_float2 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float3 simd_fast_recip(simd_float3 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float4 simd_fast_recip(simd_float4 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float8 simd_fast_recip(simd_float8 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_float16 simd_fast_recip(simd_float16 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC double simd_fast_recip(double x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_double2 simd_fast_recip(simd_double2 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_double3 simd_fast_recip(simd_double3 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_double4 simd_fast_recip(simd_double4 x); +/*! @abstract A fast approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow; otherwise this function is accurate to + * at least 11 bits for float and 22 bits for double. */ +static inline SIMD_CFUNC simd_double8 simd_fast_recip(simd_double8 x); +/*! @abstract A fast approximation to 1/x. + * @discussion Deprecated. Use simd_fast_recip(x) instead. */ +#define vector_fast_recip simd_fast_recip + +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC float simd_recip(float x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float2 simd_recip(simd_float2 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float3 simd_recip(simd_float3 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float4 simd_recip(simd_float4 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float8 simd_recip(simd_float8 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float16 simd_recip(simd_float16 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC double simd_recip(double x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double2 simd_recip(simd_double2 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double3 simd_recip(simd_double3 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double4 simd_recip(simd_double4 x); +/*! @abstract An approximation to 1/x. + * @discussion If x is very close to the limits of representation, the + * result may overflow or underflow. This function maps to + * simd_fast_recip(x) if -ffast-math is specified, and to + * simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double8 simd_recip(simd_double8 x); +/*! @abstract An approximation to 1/x. + * @discussion Deprecated. Use simd_recip(x) instead. */ +#define vector_recip simd_recip + +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC float simd_precise_rsqrt(float x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float2 simd_precise_rsqrt(simd_float2 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float3 simd_precise_rsqrt(simd_float3 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float4 simd_precise_rsqrt(simd_float4 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float8 simd_precise_rsqrt(simd_float8 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_float16 simd_precise_rsqrt(simd_float16 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC double simd_precise_rsqrt(double x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_double2 simd_precise_rsqrt(simd_double2 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_double3 simd_precise_rsqrt(simd_double3 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_double4 simd_precise_rsqrt(simd_double4 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion This function is accurate to a few units in the last place + * (ULPs). */ +static inline SIMD_CFUNC simd_double8 simd_precise_rsqrt(simd_double8 x); +/*! @abstract A good approximation to 1/sqrt(x). + * @discussion Deprecated. Use simd_precise_rsqrt(x) instead. */ +#define vector_precise_rsqrt simd_precise_rsqrt + +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC float simd_fast_rsqrt(float x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float2 simd_fast_rsqrt(simd_float2 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float3 simd_fast_rsqrt(simd_float3 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float4 simd_fast_rsqrt(simd_float4 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float8 simd_fast_rsqrt(simd_float8 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_float16 simd_fast_rsqrt(simd_float16 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC double simd_fast_rsqrt(double x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_double2 simd_fast_rsqrt(simd_double2 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_double3 simd_fast_rsqrt(simd_double3 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_double4 simd_fast_rsqrt(simd_double4 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion This function is accurate to at least 11 bits for float and + * 22 bits for double. */ +static inline SIMD_CFUNC simd_double8 simd_fast_rsqrt(simd_double8 x); +/*! @abstract A fast approximation to 1/sqrt(x). + * @discussion Deprecated. Use simd_fast_rsqrt(x) instead. */ +#define vector_fast_rsqrt simd_fast_rsqrt + +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC float simd_rsqrt(float x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float2 simd_rsqrt(simd_float2 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float3 simd_rsqrt(simd_float3 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float4 simd_rsqrt(simd_float4 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float8 simd_rsqrt(simd_float8 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_float16 simd_rsqrt(simd_float16 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC double simd_rsqrt(double x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double2 simd_rsqrt(simd_double2 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double3 simd_rsqrt(simd_double3 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double4 simd_rsqrt(simd_double4 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion This function maps to simd_fast_recip(x) if -ffast-math is + * specified, and to simd_precise_recip(x) otherwise. */ +static inline SIMD_CFUNC simd_double8 simd_rsqrt(simd_double8 x); +/*! @abstract An approximation to 1/sqrt(x). + * @discussion Deprecated. Use simd_rsqrt(x) instead. */ +#define vector_rsqrt simd_rsqrt + +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC float simd_fract(float x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float2 simd_fract(simd_float2 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float3 simd_fract(simd_float3 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float4 simd_fract(simd_float4 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float8 simd_fract(simd_float8 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_float16 simd_fract(simd_float16 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC double simd_fract(double x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_double2 simd_fract(simd_double2 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_double3 simd_fract(simd_double3 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_double4 simd_fract(simd_double4 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion floor(x) + fract(x) is *approximately* equal to x. If x is + * positive and finite, then the two values are exactly equal. */ +static inline SIMD_CFUNC simd_double8 simd_fract(simd_double8 x); +/*! @abstract The "fractional part" of x, lying in the range [0, 1). + * @discussion Deprecated. Use simd_fract(x) instead. */ +#define vector_fract simd_fract + +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC float simd_step(float edge, float x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float2 simd_step(simd_float2 edge, simd_float2 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float3 simd_step(simd_float3 edge, simd_float3 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float4 simd_step(simd_float4 edge, simd_float4 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float8 simd_step(simd_float8 edge, simd_float8 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_float16 simd_step(simd_float16 edge, simd_float16 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC double simd_step(double edge, double x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_double2 simd_step(simd_double2 edge, simd_double2 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_double3 simd_step(simd_double3 edge, simd_double3 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_double4 simd_step(simd_double4 edge, simd_double4 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Use a scalar value for edge if you want to apply the same + * threshold to all lanes. */ +static inline SIMD_CFUNC simd_double8 simd_step(simd_double8 edge, simd_double8 x); +/*! @abstract 0 if x < edge, and 1 otherwise. + * @discussion Deprecated. Use simd_step(edge, x) instead. */ +#define vector_step simd_step + +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC float simd_smoothstep(float edge0, float edge1, float x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float2 simd_smoothstep(simd_float2 edge0, simd_float2 edge1, simd_float2 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float3 simd_smoothstep(simd_float3 edge0, simd_float3 edge1, simd_float3 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float4 simd_smoothstep(simd_float4 edge0, simd_float4 edge1, simd_float4 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float8 simd_smoothstep(simd_float8 edge0, simd_float8 edge1, simd_float8 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_float16 simd_smoothstep(simd_float16 edge0, simd_float16 edge1, simd_float16 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC double simd_smoothstep(double edge0, double edge1, double x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_double2 simd_smoothstep(simd_double2 edge0, simd_double2 edge1, simd_double2 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_double3 simd_smoothstep(simd_double3 edge0, simd_double3 edge1, simd_double3 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_double4 simd_smoothstep(simd_double4 edge0, simd_double4 edge1, simd_double4 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion You can use a scalar value for edge0 and edge1 if you want + * to clamp all lanes at the same points. */ +static inline SIMD_CFUNC simd_double8 simd_smoothstep(simd_double8 edge0, simd_double8 edge1, simd_double8 x); +/*! @abstract Interpolates smoothly between 0 at edge0 and 1 at edge1 + * @discussion Deprecated. Use simd_smoothstep(edge0, edge1, x) instead. */ +#define vector_smoothstep simd_smoothstep + +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char32 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC char simd_reduce_add(simd_char64 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar32 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar64 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC short simd_reduce_add(simd_short32 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort32 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC int simd_reduce_add(simd_int16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC float simd_reduce_add(simd_float16 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong8 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC double simd_reduce_add(simd_double2 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC double simd_reduce_add(simd_double3 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC double simd_reduce_add(simd_double4 x); +/*! @abstract Sum of elements in x. + * @discussion This computation may overflow; especial for 8-bit types you + * may need to convert to a wider type before reducing. */ +static inline SIMD_CFUNC double simd_reduce_add(simd_double8 x); +/*! @abstract Sum of elements in x. + * @discussion Deprecated. Use simd_add(x) instead. */ +#define vector_reduce_add simd_reduce_add + +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char32 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_min(simd_char64 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar32 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar64 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_min(simd_short32 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort32 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_min(simd_int16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_min(simd_float16 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong8 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_min(simd_double2 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_min(simd_double3 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_min(simd_double4 x); +/*! @abstract Minimum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_min(simd_double8 x); +/*! @abstract Minimum of elements in x. + * @discussion Deprecated. Use simd_min(x) instead. */ +#define vector_reduce_min simd_reduce_min + +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char32 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC char simd_reduce_max(simd_char64 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar32 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar64 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC short simd_reduce_max(simd_short32 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort32 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC int simd_reduce_max(simd_int16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC float simd_reduce_max(simd_float16 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong8 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_max(simd_double2 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_max(simd_double3 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_max(simd_double4 x); +/*! @abstract Maximum of elements in x. */ +static inline SIMD_CFUNC double simd_reduce_max(simd_double8 x); +/*! @abstract Maximum of elements in x. + * @discussion Deprecated. Use simd_max(x) instead. */ +#define vector_reduce_max simd_reduce_max + +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char2 x, simd_char2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char3 x, simd_char3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char4 x, simd_char4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char8 x, simd_char8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char16 x, simd_char16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char32 x, simd_char32 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_char64 x, simd_char64 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar2 x, simd_uchar2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar3 x, simd_uchar3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar4 x, simd_uchar4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar8 x, simd_uchar8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar16 x, simd_uchar16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar32 x, simd_uchar32 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uchar64 x, simd_uchar64 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short2 x, simd_short2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short3 x, simd_short3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short4 x, simd_short4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short8 x, simd_short8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short16 x, simd_short16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_short32 x, simd_short32 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort2 x, simd_ushort2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort3 x, simd_ushort3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort4 x, simd_ushort4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort8 x, simd_ushort8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort16 x, simd_ushort16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ushort32 x, simd_ushort32 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int2 x, simd_int2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int3 x, simd_int3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int4 x, simd_int4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int8 x, simd_int8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_int16 x, simd_int16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint2 x, simd_uint2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint3 x, simd_uint3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint4 x, simd_uint4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint8 x, simd_uint8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_uint16 x, simd_uint16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float2 x, simd_float2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float3 x, simd_float3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float4 x, simd_float4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float8 x, simd_float8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_float16 x, simd_float16 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_long2 x, simd_long2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_long3 x, simd_long3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_long4 x, simd_long4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_long8 x, simd_long8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong2 x, simd_ulong2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong3 x, simd_ulong3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong4 x, simd_ulong4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_ulong8 x, simd_ulong8 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_double2 x, simd_double2 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_double3 x, simd_double3 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_double4 x, simd_double4 y) { + return simd_all(x == y); +} +/*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. */ +static inline SIMD_CFUNC simd_bool simd_equal(simd_double8 x, simd_double8 y) { + return simd_all(x == y); +} + +#ifdef __cplusplus +} /* extern "C" */ + +namespace simd { + /*! @abstract The lanewise absolute value of x. */ + template static SIMD_CPPFUNC typeN abs(const typeN x) { return ::simd_abs(x); } + /*! @abstract The lanewise maximum of x and y. */ + template static SIMD_CPPFUNC typeN max(const typeN x, const typeN y) { return ::simd_max(x,y); } + /*! @abstract The lanewise minimum of x and y. */ + template static SIMD_CPPFUNC typeN min(const typeN x, const typeN y) { return ::simd_min(x,y); } + /*! @abstract x clamped to the interval [min, max]. */ + template static SIMD_CPPFUNC typeN clamp(const typeN x, const typeN min, const typeN max) { return ::simd_clamp(x,min,max); } + /*! @abstract -1 if x < 0, +1 if x > 0, and 0 otherwise. */ + template static SIMD_CPPFUNC fptypeN sign(const fptypeN x) { return ::simd_sign(x); } + /*! @abstract Linearly interpolates between x and y, taking the value x when t=0 and y when t=1 */ + template static SIMD_CPPFUNC fptypeN mix(const fptypeN x, const fptypeN y, const fptypeN t) { return ::simd_mix(x,y,t); } + /*! @abstract An approximation to 1/x. */ + template static SIMD_CPPFUNC fptypeN recip(const fptypeN x) { return simd_recip(x); } + /*! @abstract An approximation to 1/sqrt(x). */ + template static SIMD_CPPFUNC fptypeN rsqrt(const fptypeN x) { return simd_rsqrt(x); } + /*! @abstract The "fracional part" of x, in the range [0,1). */ + template static SIMD_CPPFUNC fptypeN fract(const fptypeN x) { return ::simd_fract(x); } + /*! @abstract 0 if x < edge, 1 otherwise. */ + template static SIMD_CPPFUNC fptypeN step(const fptypeN edge, const fptypeN x) { return ::simd_step(edge,x); } + /*! @abstract smoothly interpolates from 0 at edge0 to 1 at edge1. */ + template static SIMD_CPPFUNC fptypeN smoothstep(const fptypeN edge0, const fptypeN edge1, const fptypeN x) { return ::simd_smoothstep(edge0,edge1,x); } + /*! @abstract True if and only if each lane of x is equal to the + * corresponding lane of y. + * + * @discussion This isn't operator== because that's already defined by + * the compiler to return a lane mask. */ + template static SIMD_CPPFUNC simd_bool equal(const fptypeN x, const fptypeN y) { return ::simd_equal(x, y); } +#if __cpp_decltype_auto + /* If you are targeting an earlier version of the C++ standard that lacks + decltype_auto support, you may use the C-style simd_reduce_* functions + instead. */ + /*! @abstract The sum of the elements in x. May overflow. */ + template static SIMD_CPPFUNC auto reduce_add(typeN x) { return ::simd_reduce_add(x); } + /*! @abstract The least element in x. */ + template static SIMD_CPPFUNC auto reduce_min(typeN x) { return ::simd_reduce_min(x); } + /*! @abstract The greatest element in x. */ + template static SIMD_CPPFUNC auto reduce_max(typeN x) { return ::simd_reduce_max(x); } +#endif + namespace precise { + /*! @abstract An approximation to 1/x. */ + template static SIMD_CPPFUNC fptypeN recip(const fptypeN x) { return ::simd_precise_recip(x); } + /*! @abstract An approximation to 1/sqrt(x). */ + template static SIMD_CPPFUNC fptypeN rsqrt(const fptypeN x) { return ::simd_precise_rsqrt(x); } + } + namespace fast { + /*! @abstract An approximation to 1/x. */ + template static SIMD_CPPFUNC fptypeN recip(const fptypeN x) { return ::simd_fast_recip(x); } + /*! @abstract An approximation to 1/sqrt(x). */ + template static SIMD_CPPFUNC fptypeN rsqrt(const fptypeN x) { return ::simd_fast_rsqrt(x); } + } +} + +extern "C" { +#endif /* __cplusplus */ + +#pragma mark - Implementation + +static inline SIMD_CFUNC simd_char2 simd_abs(simd_char2 x) { + return simd_make_char2(simd_abs(simd_make_char8_undef(x))); +} + +static inline SIMD_CFUNC simd_char3 simd_abs(simd_char3 x) { + return simd_make_char3(simd_abs(simd_make_char8_undef(x))); +} + +static inline SIMD_CFUNC simd_char4 simd_abs(simd_char4 x) { + return simd_make_char4(simd_abs(simd_make_char8_undef(x))); +} + +static inline SIMD_CFUNC simd_char8 simd_abs(simd_char8 x) { +#if defined __arm__ || defined __arm64__ + return vabs_s8(x); +#else + return simd_make_char8(simd_abs(simd_make_char16_undef(x))); +#endif +} + +static inline SIMD_CFUNC simd_char16 simd_abs(simd_char16 x) { +#if defined __arm__ || defined __arm64__ + return vabsq_s8(x); +#elif defined __SSE4_1__ + return (simd_char16) _mm_abs_epi8((__m128i)x); +#else + simd_char16 mask = x >> 7; return (x ^ mask) - mask; +#endif +} + +static inline SIMD_CFUNC simd_char32 simd_abs(simd_char32 x) { +#if defined __AVX2__ + return _mm256_abs_epi8(x); +#else + return simd_make_char32(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_char64 simd_abs(simd_char64 x) { +#if defined __AVX512BW__ + return _mm512_abs_epi8(x); +#else + return simd_make_char64(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_short2 simd_abs(simd_short2 x) { + return simd_make_short2(simd_abs(simd_make_short4_undef(x))); +} + +static inline SIMD_CFUNC simd_short3 simd_abs(simd_short3 x) { + return simd_make_short3(simd_abs(simd_make_short4_undef(x))); +} + +static inline SIMD_CFUNC simd_short4 simd_abs(simd_short4 x) { +#if defined __arm__ || defined __arm64__ + return vabs_s16(x); +#else + return simd_make_short4(simd_abs(simd_make_short8_undef(x))); +#endif +} + +static inline SIMD_CFUNC simd_short8 simd_abs(simd_short8 x) { +#if defined __arm__ || defined __arm64__ + return vabsq_s16(x); +#elif defined __SSE4_1__ + return (simd_short8) _mm_abs_epi16((__m128i)x); +#else + simd_short8 mask = x >> 15; return (x ^ mask) - mask; +#endif +} + +static inline SIMD_CFUNC simd_short16 simd_abs(simd_short16 x) { +#if defined __AVX2__ + return _mm256_abs_epi16(x); +#else + return simd_make_short16(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_short32 simd_abs(simd_short32 x) { +#if defined __AVX512BW__ + return _mm512_abs_epi16(x); +#else + return simd_make_short32(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_int2 simd_abs(simd_int2 x) { +#if defined __arm__ || defined __arm64__ + return vabs_s32(x); +#else + return simd_make_int2(simd_abs(simd_make_int4_undef(x))); +#endif +} + +static inline SIMD_CFUNC simd_int3 simd_abs(simd_int3 x) { + return simd_make_int3(simd_abs(simd_make_int4_undef(x))); +} + +static inline SIMD_CFUNC simd_int4 simd_abs(simd_int4 x) { +#if defined __arm__ || defined __arm64__ + return vabsq_s32(x); +#elif defined __SSE4_1__ + return (simd_int4) _mm_abs_epi32((__m128i)x); +#else + simd_int4 mask = x >> 31; return (x ^ mask) - mask; +#endif +} + +static inline SIMD_CFUNC simd_int8 simd_abs(simd_int8 x) { +#if defined __AVX2__ + return _mm256_abs_epi32(x); +#else + return simd_make_int8(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_int16 simd_abs(simd_int16 x) { +#if defined __AVX512F__ + return _mm512_abs_epi32(x); +#else + return simd_make_int16(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_abs(simd_float2 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_float3 simd_abs(simd_float3 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_float4 simd_abs(simd_float4 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_float8 simd_abs(simd_float8 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_float16 simd_abs(simd_float16 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_long2 simd_abs(simd_long2 x) { +#if defined __arm64__ + return vabsq_s64(x); +#elif defined __SSE4_1__ + return (simd_long2) _mm_abs_epi64((__m128i)x); +#else + simd_long2 mask = x >> 63; return (x ^ mask) - mask; +#endif +} + +static inline SIMD_CFUNC simd_long3 simd_abs(simd_long3 x) { + return simd_make_long3(simd_abs(simd_make_long4_undef(x))); +} + +static inline SIMD_CFUNC simd_long4 simd_abs(simd_long4 x) { +#if defined __AVX2__ + return _mm256_abs_epi64(x); +#else + return simd_make_long4(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_long8 simd_abs(simd_long8 x) { +#if defined __AVX512F__ + return _mm512_abs_epi64(x); +#else + return simd_make_long8(simd_abs(x.lo), simd_abs(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_double2 simd_abs(simd_double2 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_double3 simd_abs(simd_double3 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_double4 simd_abs(simd_double4 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_double8 simd_abs(simd_double8 x) { + return __tg_fabs(x); +} + +static inline SIMD_CFUNC simd_char2 simd_min(simd_char2 x, simd_char2 y) { + return simd_make_char2(simd_min(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char3 simd_min(simd_char3 x, simd_char3 y) { + return simd_make_char3(simd_min(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char4 simd_min(simd_char4 x, simd_char4 y) { + return simd_make_char4(simd_min(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char8 simd_min(simd_char8 x, simd_char8 y) { +#if defined __arm__ || defined __arm64__ + return vmin_s8(x, y); +#else + return simd_make_char8(simd_min(simd_make_char16_undef(x), simd_make_char16_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_char16 simd_min(simd_char16 x, simd_char16 y) { +#if defined __arm__ || defined __arm64__ + return vminq_s8(x, y); +#elif defined __SSE4_1__ + return (simd_char16) _mm_min_epi8((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_char32 simd_min(simd_char32 x, simd_char32 y) { +#if defined __AVX2__ + return _mm256_min_epi8(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_char64 simd_min(simd_char64 x, simd_char64 y) { +#if defined __AVX512BW__ + return _mm512_min_epi8(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uchar2 simd_min(simd_uchar2 x, simd_uchar2 y) { + return simd_make_uchar2(simd_min(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar3 simd_min(simd_uchar3 x, simd_uchar3 y) { + return simd_make_uchar3(simd_min(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar4 simd_min(simd_uchar4 x, simd_uchar4 y) { + return simd_make_uchar4(simd_min(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar8 simd_min(simd_uchar8 x, simd_uchar8 y) { +#if defined __arm__ || defined __arm64__ + return vmin_u8(x, y); +#else + return simd_make_uchar8(simd_min(simd_make_uchar16_undef(x), simd_make_uchar16_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_uchar16 simd_min(simd_uchar16 x, simd_uchar16 y) { +#if defined __arm__ || defined __arm64__ + return vminq_u8(x, y); +#elif defined __SSE4_1__ + return (simd_uchar16) _mm_min_epu8((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uchar32 simd_min(simd_uchar32 x, simd_uchar32 y) { +#if defined __AVX2__ + return _mm256_min_epu8(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uchar64 simd_min(simd_uchar64 x, simd_uchar64 y) { +#if defined __AVX512BW__ + return _mm512_min_epu8(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_short2 simd_min(simd_short2 x, simd_short2 y) { + return simd_make_short2(simd_min(simd_make_short4_undef(x), simd_make_short4_undef(y))); +} + +static inline SIMD_CFUNC simd_short3 simd_min(simd_short3 x, simd_short3 y) { + return simd_make_short3(simd_min(simd_make_short4_undef(x), simd_make_short4_undef(y))); +} + +static inline SIMD_CFUNC simd_short4 simd_min(simd_short4 x, simd_short4 y) { +#if defined __arm__ || defined __arm64__ + return vmin_s16(x, y); +#else + return simd_make_short4(simd_min(simd_make_short8_undef(x), simd_make_short8_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_short8 simd_min(simd_short8 x, simd_short8 y) { +#if defined __arm__ || defined __arm64__ + return vminq_s16(x, y); +#elif defined __SSE4_1__ + return (simd_short8) _mm_min_epi16((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_short16 simd_min(simd_short16 x, simd_short16 y) { +#if defined __AVX2__ + return _mm256_min_epi16(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_short32 simd_min(simd_short32 x, simd_short32 y) { +#if defined __AVX512BW__ + return _mm512_min_epi16(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ushort2 simd_min(simd_ushort2 x, simd_ushort2 y) { + return simd_make_ushort2(simd_min(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y))); +} + +static inline SIMD_CFUNC simd_ushort3 simd_min(simd_ushort3 x, simd_ushort3 y) { + return simd_make_ushort3(simd_min(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y))); +} + +static inline SIMD_CFUNC simd_ushort4 simd_min(simd_ushort4 x, simd_ushort4 y) { +#if defined __arm__ || defined __arm64__ + return vmin_u16(x, y); +#else + return simd_make_ushort4(simd_min(simd_make_ushort8_undef(x), simd_make_ushort8_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_ushort8 simd_min(simd_ushort8 x, simd_ushort8 y) { +#if defined __arm__ || defined __arm64__ + return vminq_u16(x, y); +#elif defined __SSE4_1__ + return (simd_ushort8) _mm_min_epu16((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ushort16 simd_min(simd_ushort16 x, simd_ushort16 y) { +#if defined __AVX2__ + return _mm256_min_epu16(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ushort32 simd_min(simd_ushort32 x, simd_ushort32 y) { +#if defined __AVX512BW__ + return _mm512_min_epu16(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_int2 simd_min(simd_int2 x, simd_int2 y) { +#if defined __arm__ || defined __arm64__ + return vmin_s32(x, y); +#else + return simd_make_int2(simd_min(simd_make_int4_undef(x), simd_make_int4_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_int3 simd_min(simd_int3 x, simd_int3 y) { + return simd_make_int3(simd_min(simd_make_int4_undef(x), simd_make_int4_undef(y))); +} + +static inline SIMD_CFUNC simd_int4 simd_min(simd_int4 x, simd_int4 y) { +#if defined __arm__ || defined __arm64__ + return vminq_s32(x, y); +#elif defined __SSE4_1__ + return (simd_int4) _mm_min_epi32((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_int8 simd_min(simd_int8 x, simd_int8 y) { +#if defined __AVX2__ + return _mm256_min_epi32(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_int16 simd_min(simd_int16 x, simd_int16 y) { +#if defined __AVX512F__ + return _mm512_min_epi32(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uint2 simd_min(simd_uint2 x, simd_uint2 y) { +#if defined __arm__ || defined __arm64__ + return vmin_u32(x, y); +#else + return simd_make_uint2(simd_min(simd_make_uint4_undef(x), simd_make_uint4_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_uint3 simd_min(simd_uint3 x, simd_uint3 y) { + return simd_make_uint3(simd_min(simd_make_uint4_undef(x), simd_make_uint4_undef(y))); +} + +static inline SIMD_CFUNC simd_uint4 simd_min(simd_uint4 x, simd_uint4 y) { +#if defined __arm__ || defined __arm64__ + return vminq_u32(x, y); +#elif defined __SSE4_1__ + return (simd_uint4) _mm_min_epu32((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uint8 simd_min(simd_uint8 x, simd_uint8 y) { +#if defined __AVX2__ + return _mm256_min_epu32(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_uint16 simd_min(simd_uint16 x, simd_uint16 y) { +#if defined __AVX512F__ + return _mm512_min_epu32(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC float simd_min(float x, float y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float2 simd_min(simd_float2 x, simd_float2 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float3 simd_min(simd_float3 x, simd_float3 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float4 simd_min(simd_float4 x, simd_float4 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float8 simd_min(simd_float8 x, simd_float8 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_float16 simd_min(simd_float16 x, simd_float16 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_long2 simd_min(simd_long2 x, simd_long2 y) { +#if defined __AVX512VL__ + return _mm_min_epi64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_long3 simd_min(simd_long3 x, simd_long3 y) { + return simd_make_long3(simd_min(simd_make_long4_undef(x), simd_make_long4_undef(y))); +} + +static inline SIMD_CFUNC simd_long4 simd_min(simd_long4 x, simd_long4 y) { +#if defined __AVX512VL__ + return _mm256_min_epi64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_long8 simd_min(simd_long8 x, simd_long8 y) { +#if defined __AVX512F__ + return _mm512_min_epi64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ulong2 simd_min(simd_ulong2 x, simd_ulong2 y) { +#if defined __AVX512VL__ + return _mm_min_epu64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ulong3 simd_min(simd_ulong3 x, simd_ulong3 y) { + return simd_make_ulong3(simd_min(simd_make_ulong4_undef(x), simd_make_ulong4_undef(y))); +} + +static inline SIMD_CFUNC simd_ulong4 simd_min(simd_ulong4 x, simd_ulong4 y) { +#if defined __AVX512VL__ + return _mm256_min_epu64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC simd_ulong8 simd_min(simd_ulong8 x, simd_ulong8 y) { +#if defined __AVX512F__ + return _mm512_min_epu64(x, y); +#else + return simd_bitselect(x, y, y < x); +#endif +} + +static inline SIMD_CFUNC double simd_min(double x, double y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_double2 simd_min(simd_double2 x, simd_double2 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_double3 simd_min(simd_double3 x, simd_double3 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_double4 simd_min(simd_double4 x, simd_double4 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_double8 simd_min(simd_double8 x, simd_double8 y) { + return __tg_fmin(x,y); +} + +static inline SIMD_CFUNC simd_char2 simd_max(simd_char2 x, simd_char2 y) { + return simd_make_char2(simd_max(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char3 simd_max(simd_char3 x, simd_char3 y) { + return simd_make_char3(simd_max(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char4 simd_max(simd_char4 x, simd_char4 y) { + return simd_make_char4(simd_max(simd_make_char8_undef(x), simd_make_char8_undef(y))); +} + +static inline SIMD_CFUNC simd_char8 simd_max(simd_char8 x, simd_char8 y) { +#if defined __arm__ || defined __arm64__ + return vmax_s8(x, y); +#else + return simd_make_char8(simd_max(simd_make_char16_undef(x), simd_make_char16_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_char16 simd_max(simd_char16 x, simd_char16 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_s8(x, y); +#elif defined __SSE4_1__ + return (simd_char16) _mm_max_epi8((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_char32 simd_max(simd_char32 x, simd_char32 y) { +#if defined __AVX2__ + return _mm256_max_epi8(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_char64 simd_max(simd_char64 x, simd_char64 y) { +#if defined __AVX512BW__ + return _mm512_max_epi8(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uchar2 simd_max(simd_uchar2 x, simd_uchar2 y) { + return simd_make_uchar2(simd_max(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar3 simd_max(simd_uchar3 x, simd_uchar3 y) { + return simd_make_uchar3(simd_max(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar4 simd_max(simd_uchar4 x, simd_uchar4 y) { + return simd_make_uchar4(simd_max(simd_make_uchar8_undef(x), simd_make_uchar8_undef(y))); +} + +static inline SIMD_CFUNC simd_uchar8 simd_max(simd_uchar8 x, simd_uchar8 y) { +#if defined __arm__ || defined __arm64__ + return vmax_u8(x, y); +#else + return simd_make_uchar8(simd_max(simd_make_uchar16_undef(x), simd_make_uchar16_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_uchar16 simd_max(simd_uchar16 x, simd_uchar16 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_u8(x, y); +#elif defined __SSE4_1__ + return (simd_uchar16) _mm_max_epu8((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uchar32 simd_max(simd_uchar32 x, simd_uchar32 y) { +#if defined __AVX2__ + return _mm256_max_epu8(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uchar64 simd_max(simd_uchar64 x, simd_uchar64 y) { +#if defined __AVX512BW__ + return _mm512_max_epu8(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_short2 simd_max(simd_short2 x, simd_short2 y) { + return simd_make_short2(simd_max(simd_make_short4_undef(x), simd_make_short4_undef(y))); +} + +static inline SIMD_CFUNC simd_short3 simd_max(simd_short3 x, simd_short3 y) { + return simd_make_short3(simd_max(simd_make_short4_undef(x), simd_make_short4_undef(y))); +} + +static inline SIMD_CFUNC simd_short4 simd_max(simd_short4 x, simd_short4 y) { +#if defined __arm__ || defined __arm64__ + return vmax_s16(x, y); +#else + return simd_make_short4(simd_max(simd_make_short8_undef(x), simd_make_short8_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_short8 simd_max(simd_short8 x, simd_short8 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_s16(x, y); +#elif defined __SSE4_1__ + return (simd_short8) _mm_max_epi16((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_short16 simd_max(simd_short16 x, simd_short16 y) { +#if defined __AVX2__ + return _mm256_max_epi16(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_short32 simd_max(simd_short32 x, simd_short32 y) { +#if defined __AVX512BW__ + return _mm512_max_epi16(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ushort2 simd_max(simd_ushort2 x, simd_ushort2 y) { + return simd_make_ushort2(simd_max(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y))); +} + +static inline SIMD_CFUNC simd_ushort3 simd_max(simd_ushort3 x, simd_ushort3 y) { + return simd_make_ushort3(simd_max(simd_make_ushort4_undef(x), simd_make_ushort4_undef(y))); +} + +static inline SIMD_CFUNC simd_ushort4 simd_max(simd_ushort4 x, simd_ushort4 y) { +#if defined __arm__ || defined __arm64__ + return vmax_u16(x, y); +#else + return simd_make_ushort4(simd_max(simd_make_ushort8_undef(x), simd_make_ushort8_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_ushort8 simd_max(simd_ushort8 x, simd_ushort8 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_u16(x, y); +#elif defined __SSE4_1__ + return (simd_ushort8) _mm_max_epu16((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ushort16 simd_max(simd_ushort16 x, simd_ushort16 y) { +#if defined __AVX2__ + return _mm256_max_epu16(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ushort32 simd_max(simd_ushort32 x, simd_ushort32 y) { +#if defined __AVX512BW__ + return _mm512_max_epu16(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_int2 simd_max(simd_int2 x, simd_int2 y) { +#if defined __arm__ || defined __arm64__ + return vmax_s32(x, y); +#else + return simd_make_int2(simd_max(simd_make_int4_undef(x), simd_make_int4_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_int3 simd_max(simd_int3 x, simd_int3 y) { + return simd_make_int3(simd_max(simd_make_int4_undef(x), simd_make_int4_undef(y))); +} + +static inline SIMD_CFUNC simd_int4 simd_max(simd_int4 x, simd_int4 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_s32(x, y); +#elif defined __SSE4_1__ + return (simd_int4) _mm_max_epi32((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_int8 simd_max(simd_int8 x, simd_int8 y) { +#if defined __AVX2__ + return _mm256_max_epi32(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_int16 simd_max(simd_int16 x, simd_int16 y) { +#if defined __AVX512F__ + return _mm512_max_epi32(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uint2 simd_max(simd_uint2 x, simd_uint2 y) { +#if defined __arm__ || defined __arm64__ + return vmax_u32(x, y); +#else + return simd_make_uint2(simd_max(simd_make_uint4_undef(x), simd_make_uint4_undef(y))); +#endif + +} + +static inline SIMD_CFUNC simd_uint3 simd_max(simd_uint3 x, simd_uint3 y) { + return simd_make_uint3(simd_max(simd_make_uint4_undef(x), simd_make_uint4_undef(y))); +} + +static inline SIMD_CFUNC simd_uint4 simd_max(simd_uint4 x, simd_uint4 y) { +#if defined __arm__ || defined __arm64__ + return vmaxq_u32(x, y); +#elif defined __SSE4_1__ + return (simd_uint4) _mm_max_epu32((__m128i)x, (__m128i)y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uint8 simd_max(simd_uint8 x, simd_uint8 y) { +#if defined __AVX2__ + return _mm256_max_epu32(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_uint16 simd_max(simd_uint16 x, simd_uint16 y) { +#if defined __AVX512F__ + return _mm512_max_epu32(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC float simd_max(float x, float y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float2 simd_max(simd_float2 x, simd_float2 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float3 simd_max(simd_float3 x, simd_float3 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float4 simd_max(simd_float4 x, simd_float4 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float8 simd_max(simd_float8 x, simd_float8 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_float16 simd_max(simd_float16 x, simd_float16 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_long2 simd_max(simd_long2 x, simd_long2 y) { +#if defined __AVX512VL__ + return _mm_max_epi64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_long3 simd_max(simd_long3 x, simd_long3 y) { + return simd_make_long3(simd_max(simd_make_long4_undef(x), simd_make_long4_undef(y))); +} + +static inline SIMD_CFUNC simd_long4 simd_max(simd_long4 x, simd_long4 y) { +#if defined __AVX512VL__ + return _mm256_max_epi64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_long8 simd_max(simd_long8 x, simd_long8 y) { +#if defined __AVX512F__ + return _mm512_max_epi64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ulong2 simd_max(simd_ulong2 x, simd_ulong2 y) { +#if defined __AVX512VL__ + return _mm_max_epu64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ulong3 simd_max(simd_ulong3 x, simd_ulong3 y) { + return simd_make_ulong3(simd_max(simd_make_ulong4_undef(x), simd_make_ulong4_undef(y))); +} + +static inline SIMD_CFUNC simd_ulong4 simd_max(simd_ulong4 x, simd_ulong4 y) { +#if defined __AVX512VL__ + return _mm256_max_epu64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC simd_ulong8 simd_max(simd_ulong8 x, simd_ulong8 y) { +#if defined __AVX512F__ + return _mm512_max_epu64(x, y); +#else + return simd_bitselect(x, y, x < y); +#endif +} + +static inline SIMD_CFUNC double simd_max(double x, double y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_double2 simd_max(simd_double2 x, simd_double2 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_double3 simd_max(simd_double3 x, simd_double3 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_double4 simd_max(simd_double4 x, simd_double4 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_double8 simd_max(simd_double8 x, simd_double8 y) { + return __tg_fmax(x,y); +} + +static inline SIMD_CFUNC simd_char2 simd_clamp(simd_char2 x, simd_char2 min, simd_char2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char3 simd_clamp(simd_char3 x, simd_char3 min, simd_char3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char4 simd_clamp(simd_char4 x, simd_char4 min, simd_char4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char8 simd_clamp(simd_char8 x, simd_char8 min, simd_char8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char16 simd_clamp(simd_char16 x, simd_char16 min, simd_char16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char32 simd_clamp(simd_char32 x, simd_char32 min, simd_char32 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_char64 simd_clamp(simd_char64 x, simd_char64 min, simd_char64 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar2 simd_clamp(simd_uchar2 x, simd_uchar2 min, simd_uchar2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar3 simd_clamp(simd_uchar3 x, simd_uchar3 min, simd_uchar3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar4 simd_clamp(simd_uchar4 x, simd_uchar4 min, simd_uchar4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar8 simd_clamp(simd_uchar8 x, simd_uchar8 min, simd_uchar8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar16 simd_clamp(simd_uchar16 x, simd_uchar16 min, simd_uchar16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar32 simd_clamp(simd_uchar32 x, simd_uchar32 min, simd_uchar32 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uchar64 simd_clamp(simd_uchar64 x, simd_uchar64 min, simd_uchar64 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short2 simd_clamp(simd_short2 x, simd_short2 min, simd_short2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short3 simd_clamp(simd_short3 x, simd_short3 min, simd_short3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short4 simd_clamp(simd_short4 x, simd_short4 min, simd_short4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short8 simd_clamp(simd_short8 x, simd_short8 min, simd_short8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short16 simd_clamp(simd_short16 x, simd_short16 min, simd_short16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_short32 simd_clamp(simd_short32 x, simd_short32 min, simd_short32 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort2 simd_clamp(simd_ushort2 x, simd_ushort2 min, simd_ushort2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort3 simd_clamp(simd_ushort3 x, simd_ushort3 min, simd_ushort3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort4 simd_clamp(simd_ushort4 x, simd_ushort4 min, simd_ushort4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort8 simd_clamp(simd_ushort8 x, simd_ushort8 min, simd_ushort8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort16 simd_clamp(simd_ushort16 x, simd_ushort16 min, simd_ushort16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ushort32 simd_clamp(simd_ushort32 x, simd_ushort32 min, simd_ushort32 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int2 simd_clamp(simd_int2 x, simd_int2 min, simd_int2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int3 simd_clamp(simd_int3 x, simd_int3 min, simd_int3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int4 simd_clamp(simd_int4 x, simd_int4 min, simd_int4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int8 simd_clamp(simd_int8 x, simd_int8 min, simd_int8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_int16 simd_clamp(simd_int16 x, simd_int16 min, simd_int16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint2 simd_clamp(simd_uint2 x, simd_uint2 min, simd_uint2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint3 simd_clamp(simd_uint3 x, simd_uint3 min, simd_uint3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint4 simd_clamp(simd_uint4 x, simd_uint4 min, simd_uint4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint8 simd_clamp(simd_uint8 x, simd_uint8 min, simd_uint8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_uint16 simd_clamp(simd_uint16 x, simd_uint16 min, simd_uint16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC float simd_clamp(float x, float min, float max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float2 simd_clamp(simd_float2 x, simd_float2 min, simd_float2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float3 simd_clamp(simd_float3 x, simd_float3 min, simd_float3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float4 simd_clamp(simd_float4 x, simd_float4 min, simd_float4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float8 simd_clamp(simd_float8 x, simd_float8 min, simd_float8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_float16 simd_clamp(simd_float16 x, simd_float16 min, simd_float16 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_long2 simd_clamp(simd_long2 x, simd_long2 min, simd_long2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_long3 simd_clamp(simd_long3 x, simd_long3 min, simd_long3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_long4 simd_clamp(simd_long4 x, simd_long4 min, simd_long4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_long8 simd_clamp(simd_long8 x, simd_long8 min, simd_long8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ulong2 simd_clamp(simd_ulong2 x, simd_ulong2 min, simd_ulong2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ulong3 simd_clamp(simd_ulong3 x, simd_ulong3 min, simd_ulong3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ulong4 simd_clamp(simd_ulong4 x, simd_ulong4 min, simd_ulong4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_ulong8 simd_clamp(simd_ulong8 x, simd_ulong8 min, simd_ulong8 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC double simd_clamp(double x, double min, double max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_double2 simd_clamp(simd_double2 x, simd_double2 min, simd_double2 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_double3 simd_clamp(simd_double3 x, simd_double3 min, simd_double3 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_double4 simd_clamp(simd_double4 x, simd_double4 min, simd_double4 max) { + return simd_min(simd_max(x, min), max); +} + +static inline SIMD_CFUNC simd_double8 simd_clamp(simd_double8 x, simd_double8 min, simd_double8 max) { + return simd_min(simd_max(x, min), max); +} + + +static inline SIMD_CFUNC float simd_sign(float x) { + return (x == 0 | x != x) ? 0 : copysign(1,x); +} + +static inline SIMD_CFUNC simd_float2 simd_sign(simd_float2 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_float3 simd_sign(simd_float3 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_float4 simd_sign(simd_float4 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_float8 simd_sign(simd_float8 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_float16 simd_sign(simd_float16 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC double simd_sign(double x) { + return (x == 0 | x != x) ? 0 : copysign(1,x); +} + +static inline SIMD_CFUNC simd_double2 simd_sign(simd_double2 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_double3 simd_sign(simd_double3 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_double4 simd_sign(simd_double4 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC simd_double8 simd_sign(simd_double8 x) { + return simd_bitselect(__tg_copysign(1,x), 0, x == 0 | x != x); +} + +static inline SIMD_CFUNC float simd_mix(float x, float y, float t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float2 simd_mix(simd_float2 x, simd_float2 y, simd_float2 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float3 simd_mix(simd_float3 x, simd_float3 y, simd_float3 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float4 simd_mix(simd_float4 x, simd_float4 y, simd_float4 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float8 simd_mix(simd_float8 x, simd_float8 y, simd_float8 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_float16 simd_mix(simd_float16 x, simd_float16 y, simd_float16 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC double simd_mix(double x, double y, double t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_double2 simd_mix(simd_double2 x, simd_double2 y, simd_double2 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_double3 simd_mix(simd_double3 x, simd_double3 y, simd_double3 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_double4 simd_mix(simd_double4 x, simd_double4 y, simd_double4 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC simd_double8 simd_mix(simd_double8 x, simd_double8 y, simd_double8 t) { + return x + t*(y - x); +} + +static inline SIMD_CFUNC float simd_recip(float x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_recip(simd_float2 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_recip(simd_float3 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float4 simd_recip(simd_float4 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_recip(simd_float8 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_recip(simd_float16 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC double simd_recip(double x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_double2 simd_recip(simd_double2 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_double3 simd_recip(simd_double3 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_double4 simd_recip(simd_double4 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_double8 simd_recip(simd_double8 x) { +#if __FAST_MATH__ + return simd_fast_recip(x); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC float simd_fast_recip(float x) { +#if defined __AVX512VL__ + simd_float4 x4 = simd_make_float4(x); + return ((simd_float4)_mm_rcp14_ss(x4, x4)).x; +#elif defined __SSE__ + return ((simd_float4)_mm_rcp_ss(simd_make_float4(x))).x; +#elif defined __ARM_NEON__ + return simd_fast_recip(simd_make_float2_undef(x)).x; +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_fast_recip(simd_float2 x) { +#if defined __SSE__ + return simd_make_float2(simd_fast_recip(simd_make_float4_undef(x))); +#elif defined __ARM_NEON__ + simd_float2 r = vrecpe_f32(x); + return r * vrecps_f32(x, r); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_fast_recip(simd_float3 x) { + return simd_make_float3(simd_fast_recip(simd_make_float4_undef(x))); +} + +static inline SIMD_CFUNC simd_float4 simd_fast_recip(simd_float4 x) { +#if defined __AVX512VL__ + return _mm_rcp14_ps(x); +#elif defined __SSE__ + return _mm_rcp_ps(x); +#elif defined __ARM_NEON__ + simd_float4 r = vrecpeq_f32(x); + return r * vrecpsq_f32(x, r); +#else + return simd_precise_recip(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_fast_recip(simd_float8 x) { +#if defined __AVX512VL__ + return _mm256_rcp14_ps(x); +#elif defined __AVX__ + return _mm256_rcp_ps(x); +#else + return simd_make_float8(simd_fast_recip(x.lo), simd_fast_recip(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_fast_recip(simd_float16 x) { +#if defined __AVX512F__ + return _mm512_rcp14_ps(x); +#else + return simd_make_float16(simd_fast_recip(x.lo), simd_fast_recip(x.hi)); +#endif +} + +static inline SIMD_CFUNC double simd_fast_recip(double x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC simd_double2 simd_fast_recip(simd_double2 x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC simd_double3 simd_fast_recip(simd_double3 x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC simd_double4 simd_fast_recip(simd_double4 x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC simd_double8 simd_fast_recip(simd_double8 x) { + return simd_precise_recip(x); +} + +static inline SIMD_CFUNC float simd_precise_recip(float x) { +#if defined __SSE__ + float r = simd_fast_recip(x); + return r*(2 - (x == 0 ? -INFINITY : x)*r); +#elif defined __ARM_NEON__ + return simd_precise_recip(simd_make_float2_undef(x)).x; +#else + return 1/x; +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_precise_recip(simd_float2 x) { +#if defined __SSE__ + return simd_make_float2(simd_precise_recip(simd_make_float4_undef(x))); +#elif defined __ARM_NEON__ + simd_float2 r = simd_fast_recip(x); + return r*vrecps_f32(x, r); +#else + return 1/x; +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_precise_recip(simd_float3 x) { + return simd_make_float3(simd_precise_recip(simd_make_float4_undef(x))); +} + +static inline SIMD_CFUNC simd_float4 simd_precise_recip(simd_float4 x) { +#if defined __SSE__ + simd_float4 r = simd_fast_recip(x); + return r*(2 - simd_bitselect(x, -INFINITY, x == 0)*r); +#elif defined __ARM_NEON__ + simd_float4 r = simd_fast_recip(x); + return r*vrecpsq_f32(x, r); +#else + return 1/x; +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_precise_recip(simd_float8 x) { +#if defined __AVX__ + simd_float8 r = simd_fast_recip(x); + return r*(2 - simd_bitselect(x, -INFINITY, x == 0)*r); +#else + return simd_make_float8(simd_precise_recip(x.lo), simd_precise_recip(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_precise_recip(simd_float16 x) { +#if defined __AVX512F__ + simd_float16 r = simd_fast_recip(x); + return r*(2 - simd_bitselect(x, -INFINITY, x == 0)*r); +#else + return simd_make_float16(simd_precise_recip(x.lo), simd_precise_recip(x.hi)); +#endif +} + +static inline SIMD_CFUNC double simd_precise_recip(double x) { + return 1/x; +} + +static inline SIMD_CFUNC simd_double2 simd_precise_recip(simd_double2 x) { + return 1/x; +} + +static inline SIMD_CFUNC simd_double3 simd_precise_recip(simd_double3 x) { + return 1/x; +} + +static inline SIMD_CFUNC simd_double4 simd_precise_recip(simd_double4 x) { + return 1/x; +} + +static inline SIMD_CFUNC simd_double8 simd_precise_recip(simd_double8 x) { + return 1/x; +} + +static inline SIMD_CFUNC float simd_rsqrt(float x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_rsqrt(simd_float2 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_rsqrt(simd_float3 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float4 simd_rsqrt(simd_float4 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_rsqrt(simd_float8 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_rsqrt(simd_float16 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC double simd_rsqrt(double x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_double2 simd_rsqrt(simd_double2 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_double3 simd_rsqrt(simd_double3 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_double4 simd_rsqrt(simd_double4 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_double8 simd_rsqrt(simd_double8 x) { +#if __FAST_MATH__ + return simd_fast_rsqrt(x); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC float simd_fast_rsqrt(float x) { +#if defined __AVX512VL__ + simd_float4 x4 = simd_make_float4(x); + return ((simd_float4)_mm_rsqrt14_ss(x4, x4)).x; +#elif defined __SSE__ + return ((simd_float4)_mm_rsqrt_ss(simd_make_float4(x))).x; +#elif defined __ARM_NEON__ + return simd_fast_rsqrt(simd_make_float2_undef(x)).x; +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_fast_rsqrt(simd_float2 x) { +#if defined __SSE__ + return simd_make_float2(simd_fast_rsqrt(simd_make_float4_undef(x))); +#elif defined __ARM_NEON__ + simd_float2 r = vrsqrte_f32(x); + return r * vrsqrts_f32(x, r*r); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_fast_rsqrt(simd_float3 x) { + return simd_make_float3(simd_fast_rsqrt(simd_make_float4_undef(x))); +} + +static inline SIMD_CFUNC simd_float4 simd_fast_rsqrt(simd_float4 x) { +#if defined __AVX512VL__ + return _mm_rsqrt14_ps(x); +#elif defined __SSE__ + return _mm_rsqrt_ps(x); +#elif defined __ARM_NEON__ + simd_float4 r = vrsqrteq_f32(x); + return r * vrsqrtsq_f32(x, r*r); +#else + return simd_precise_rsqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_fast_rsqrt(simd_float8 x) { +#if defined __AVX512VL__ + return _mm256_rsqrt14_ps(x); +#elif defined __AVX__ + return _mm256_rsqrt_ps(x); +#else + return simd_make_float8(simd_fast_rsqrt(x.lo), simd_fast_rsqrt(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_fast_rsqrt(simd_float16 x) { +#if defined __AVX512F__ + return _mm512_rsqrt14_ps(x); +#else + return simd_make_float16(simd_fast_rsqrt(x.lo), simd_fast_rsqrt(x.hi)); +#endif +} + +static inline SIMD_CFUNC double simd_fast_rsqrt(double x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC simd_double2 simd_fast_rsqrt(simd_double2 x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC simd_double3 simd_fast_rsqrt(simd_double3 x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC simd_double4 simd_fast_rsqrt(simd_double4 x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC simd_double8 simd_fast_rsqrt(simd_double8 x) { + return simd_precise_rsqrt(x); +} + +static inline SIMD_CFUNC float simd_precise_rsqrt(float x) { +#if defined __SSE__ + float r = simd_fast_rsqrt(x); + return r*(1.5f - 0.5f*(r == INFINITY ? -INFINITY : x)*r*r); +#elif defined __ARM_NEON__ + return simd_precise_rsqrt(simd_make_float2_undef(x)).x; +#else + return 1/sqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float2 simd_precise_rsqrt(simd_float2 x) { +#if defined __SSE__ + return simd_make_float2(simd_precise_rsqrt(simd_make_float4_undef(x))); +#elif defined __ARM_NEON__ + simd_float2 r = simd_fast_rsqrt(x); + return r*vrsqrts_f32(x, r*r); +#else + return 1/__tg_sqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float3 simd_precise_rsqrt(simd_float3 x) { + return simd_make_float3(simd_precise_rsqrt(simd_make_float4_undef(x))); +} + +static inline SIMD_CFUNC simd_float4 simd_precise_rsqrt(simd_float4 x) { +#if defined __SSE__ + simd_float4 r = simd_fast_rsqrt(x); + return r*(1.5 - 0.5*simd_bitselect(x, -INFINITY, r == INFINITY)*r*r); +#elif defined __ARM_NEON__ + simd_float4 r = simd_fast_rsqrt(x); + return r*vrsqrtsq_f32(x, r*r); +#else + return 1/__tg_sqrt(x); +#endif +} + +static inline SIMD_CFUNC simd_float8 simd_precise_rsqrt(simd_float8 x) { +#if defined __AVX__ + simd_float8 r = simd_fast_rsqrt(x); + return r*(1.5 - 0.5*simd_bitselect(x, -INFINITY, r == INFINITY)*r*r); +#else + return simd_make_float8(simd_precise_rsqrt(x.lo), simd_precise_rsqrt(x.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 simd_precise_rsqrt(simd_float16 x) { +#if defined __AVX512F__ + simd_float16 r = simd_fast_rsqrt(x); + return r*(1.5 - 0.5*simd_bitselect(x, -INFINITY, r == INFINITY)*r*r); +#else + return simd_make_float16(simd_precise_rsqrt(x.lo), simd_precise_rsqrt(x.hi)); +#endif +} + +static inline SIMD_CFUNC double simd_precise_rsqrt(double x) { + return 1/sqrt(x); +} + +static inline SIMD_CFUNC simd_double2 simd_precise_rsqrt(simd_double2 x) { + return 1/__tg_sqrt(x); +} + +static inline SIMD_CFUNC simd_double3 simd_precise_rsqrt(simd_double3 x) { + return 1/__tg_sqrt(x); +} + +static inline SIMD_CFUNC simd_double4 simd_precise_rsqrt(simd_double4 x) { + return 1/__tg_sqrt(x); +} + +static inline SIMD_CFUNC simd_double8 simd_precise_rsqrt(simd_double8 x) { + return 1/__tg_sqrt(x); +} + +static inline SIMD_CFUNC float simd_fract(float x) { + return fmin(x - floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float2 simd_fract(simd_float2 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float3 simd_fract(simd_float3 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float4 simd_fract(simd_float4 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float8 simd_fract(simd_float8 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC simd_float16 simd_fract(simd_float16 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffep-1f); +} + +static inline SIMD_CFUNC double simd_fract(double x) { + return fmin(x - floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC simd_double2 simd_fract(simd_double2 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC simd_double3 simd_fract(simd_double3 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC simd_double4 simd_fract(simd_double4 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC simd_double8 simd_fract(simd_double8 x) { + return __tg_fmin(x - __tg_floor(x), 0x1.fffffffffffffp-1); +} + +static inline SIMD_CFUNC float simd_step(float edge, float x) { + return !(x < edge); +} + +static inline SIMD_CFUNC simd_float2 simd_step(simd_float2 edge, simd_float2 x) { + return simd_bitselect((simd_float2)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_float3 simd_step(simd_float3 edge, simd_float3 x) { + return simd_bitselect((simd_float3)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_float4 simd_step(simd_float4 edge, simd_float4 x) { + return simd_bitselect((simd_float4)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_float8 simd_step(simd_float8 edge, simd_float8 x) { + return simd_bitselect((simd_float8)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_float16 simd_step(simd_float16 edge, simd_float16 x) { + return simd_bitselect((simd_float16)1, 0, x < edge); +} + +static inline SIMD_CFUNC double simd_step(double edge, double x) { + return !(x < edge); +} + +static inline SIMD_CFUNC simd_double2 simd_step(simd_double2 edge, simd_double2 x) { + return simd_bitselect((simd_double2)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_double3 simd_step(simd_double3 edge, simd_double3 x) { + return simd_bitselect((simd_double3)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_double4 simd_step(simd_double4 edge, simd_double4 x) { + return simd_bitselect((simd_double4)1, 0, x < edge); +} + +static inline SIMD_CFUNC simd_double8 simd_step(simd_double8 edge, simd_double8 x) { + return simd_bitselect((simd_double8)1, 0, x < edge); +} + +static inline SIMD_CFUNC float simd_smoothstep(float edge0, float edge1, float x) { + float t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float2 simd_smoothstep(simd_float2 edge0, simd_float2 edge1, simd_float2 x) { + simd_float2 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float3 simd_smoothstep(simd_float3 edge0, simd_float3 edge1, simd_float3 x) { + simd_float3 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float4 simd_smoothstep(simd_float4 edge0, simd_float4 edge1, simd_float4 x) { + simd_float4 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float8 simd_smoothstep(simd_float8 edge0, simd_float8 edge1, simd_float8 x) { + simd_float8 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_float16 simd_smoothstep(simd_float16 edge0, simd_float16 edge1, simd_float16 x) { + simd_float16 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC double simd_smoothstep(double edge0, double edge1, double x) { + double t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_double2 simd_smoothstep(simd_double2 edge0, simd_double2 edge1, simd_double2 x) { + simd_double2 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_double3 simd_smoothstep(simd_double3 edge0, simd_double3 edge1, simd_double3 x) { + simd_double3 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_double4 simd_smoothstep(simd_double4 edge0, simd_double4 edge1, simd_double4 x) { + simd_double4 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC simd_double8 simd_smoothstep(simd_double8 edge0, simd_double8 edge1, simd_double8 x) { + simd_double8 t = simd_clamp((x - edge0)/(edge1 - edge0), 0, 1); + return t*t*(3 - 2*t); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char32 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_add(simd_char64 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar32 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_add(simd_uchar64 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC short simd_reduce_add(simd_short32 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_add(simd_ushort32 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC int simd_reduce_add(simd_int16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_add(simd_uint16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC float simd_reduce_add(simd_float16 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_add(simd_long8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_add(simd_ulong8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC double simd_reduce_add(simd_double2 x) { + return x.x + x.y; +} + +static inline SIMD_CFUNC double simd_reduce_add(simd_double3 x) { + return x.x + x.y + x.z; +} + +static inline SIMD_CFUNC double simd_reduce_add(simd_double4 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC double simd_reduce_add(simd_double8 x) { + return simd_reduce_add(x.lo + x.hi); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char3 x) { + char t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char32 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_min(simd_char64 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar3 x) { + unsigned char t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar32 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_min(simd_uchar64 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short3 x) { + short t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_min(simd_short32 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort3 x) { + unsigned short t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_min(simd_ushort32 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int3 x) { + int t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_min(simd_int16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint3 x) { + unsigned int t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_min(simd_uint16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float2 x) { + return fmin(x.x, x.y); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float3 x) { + return fmin(fmin(x.x, x.z), x.y); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_min(simd_float16 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long3 x) { + simd_long1 t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_min(simd_long8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong2 x) { + return x.y < x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong3 x) { + simd_ulong1 t = x.z < x.x ? x.z : x.x; + return x.y < t ? x.y : t; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_min(simd_ulong8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC double simd_reduce_min(simd_double2 x) { + return fmin(x.x, x.y); +} + +static inline SIMD_CFUNC double simd_reduce_min(simd_double3 x) { + return fmin(fmin(x.x, x.z), x.y); +} + +static inline SIMD_CFUNC double simd_reduce_min(simd_double4 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC double simd_reduce_min(simd_double8 x) { + return simd_reduce_min(simd_min(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char3 x) { + char t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char32 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC char simd_reduce_max(simd_char64 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar3 x) { + unsigned char t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar32 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned char simd_reduce_max(simd_uchar64 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short3 x) { + short t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC short simd_reduce_max(simd_short32 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort3 x) { + unsigned short t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned short simd_reduce_max(simd_ushort32 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int3 x) { + int t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC int simd_reduce_max(simd_int16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint3 x) { + unsigned int t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC unsigned int simd_reduce_max(simd_uint16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float2 x) { + return fmax(x.x, x.y); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float3 x) { + return fmax(fmax(x.x, x.z), x.y); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC float simd_reduce_max(simd_float16 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long3 x) { + simd_long1 t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_long1 simd_reduce_max(simd_long8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong2 x) { + return x.y > x.x ? x.y : x.x; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong3 x) { + simd_ulong1 t = x.z > x.x ? x.z : x.x; + return x.y > t ? x.y : t; +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC simd_ulong1 simd_reduce_max(simd_ulong8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC double simd_reduce_max(simd_double2 x) { + return fmax(x.x, x.y); +} + +static inline SIMD_CFUNC double simd_reduce_max(simd_double3 x) { + return fmax(fmax(x.x, x.z), x.y); +} + +static inline SIMD_CFUNC double simd_reduce_max(simd_double4 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +static inline SIMD_CFUNC double simd_reduce_max(simd_double8 x) { + return simd_reduce_max(simd_max(x.lo, x.hi)); +} + +#ifdef __cplusplus +} +#endif +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* SIMD_COMMON_HEADER */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/simd/conversion.h b/lib/libc/include/aarch64-macos-gnu/simd/conversion.h new file mode 100644 index 0000000000..6379afde05 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/simd/conversion.h @@ -0,0 +1,1966 @@ +/* Copyright (c) 2014-2017 Apple, Inc. All rights reserved. + * + * The interfaces declared in this header provide conversions between vector + * types. The following functions are available: + * + * simd_char(x) simd_uchar(x) + * simd_short(x) simd_ushort(x) + * simd_int(x) simd_uint(x) + * simd_long(x) simd_ulong(x) + * simd_float(x) + * simd_double(x) + * + * Each of these functions converts x to a vector whose elements have the + * type named by the function, with the same number of elements as x. Unlike + * a vector cast, these functions convert the elements to the new element + * type. These conversions behave exactly as C scalar conversions, except + * that conversions from integer vector types to signed integer vector types + * are guaranteed to wrap modulo 2^N (where N is the number of bits in an + * element of the result type). + * + * For integer vector types, saturating conversions are also available: + * + * simd_char_sat(x) simd_uchar_sat(x) + * simd_short_sat(x) simd_ushort_sat(x) + * simd_int_sat(x) simd_uint_sat(x) + * simd_long_sat(x) simd_ulong_sat(x) + * + * These conversions clamp x to the representable range of the result type + * before converting. + * + * Unlike most vector operations in , there are no abbreviated C++ + * names for these functions in the simd:: namespace. + */ + +#ifndef __SIMD_CONVERSION_HEADER__ +#define __SIMD_CONVERSION_HEADER__ + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static simd_char2 SIMD_CFUNC simd_char(simd_char2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_char3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_char4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_char8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_char16 __x); +static simd_char32 SIMD_CFUNC simd_char(simd_char32 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_uchar2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_uchar3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_uchar4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_uchar8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_uchar16 __x); +static simd_char32 SIMD_CFUNC simd_char(simd_uchar32 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_short2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_short3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_short4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_short8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_short16 __x); +static simd_char32 SIMD_CFUNC simd_char(simd_short32 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_ushort2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_ushort3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_ushort4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_ushort8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_ushort16 __x); +static simd_char32 SIMD_CFUNC simd_char(simd_ushort32 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_int2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_int3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_int4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_int8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_int16 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_uint2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_uint3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_uint4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_uint8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_uint16 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_float2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_float3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_float4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_float8 __x); +static simd_char16 SIMD_CFUNC simd_char(simd_float16 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_long2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_long3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_long4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_long8 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_ulong2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_ulong3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_ulong4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_ulong8 __x); +static simd_char2 SIMD_CFUNC simd_char(simd_double2 __x); +static simd_char3 SIMD_CFUNC simd_char(simd_double3 __x); +static simd_char4 SIMD_CFUNC simd_char(simd_double4 __x); +static simd_char8 SIMD_CFUNC simd_char(simd_double8 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_char2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_char3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_char4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_char8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_char16 __x); +static simd_char32 SIMD_CFUNC simd_char_sat(simd_char32 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_short2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_short3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_short4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_short8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_short16 __x); +static simd_char32 SIMD_CFUNC simd_char_sat(simd_short32 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_int2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_int3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_int4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_int8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_int16 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_float2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_float3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_float4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_float8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_float16 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_long2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_long3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_long4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_long8 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_double2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_double3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_double4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_double8 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_uchar2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_uchar3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_uchar4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_uchar8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_uchar16 __x); +static simd_char32 SIMD_CFUNC simd_char_sat(simd_uchar32 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_ushort2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_ushort3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_ushort4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_ushort8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_ushort16 __x); +static simd_char32 SIMD_CFUNC simd_char_sat(simd_ushort32 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_uint2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_uint3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_uint4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_uint8 __x); +static simd_char16 SIMD_CFUNC simd_char_sat(simd_uint16 __x); +static simd_char2 SIMD_CFUNC simd_char_sat(simd_ulong2 __x); +static simd_char3 SIMD_CFUNC simd_char_sat(simd_ulong3 __x); +static simd_char4 SIMD_CFUNC simd_char_sat(simd_ulong4 __x); +static simd_char8 SIMD_CFUNC simd_char_sat(simd_ulong8 __x); +#define vector_char simd_char +#define vector_char_sat simd_char_sat + +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_char2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_char3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_char4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_char8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_char16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_char32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uchar2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uchar3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uchar4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uchar8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uchar16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_uchar32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_short2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_short3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_short4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_short8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_short16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_short32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ushort2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ushort3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ushort4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ushort8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_ushort16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_ushort32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_int2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_int3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_int4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_int8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_int16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uint2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uint3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uint4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uint8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uint16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_float2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_float3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_float4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_float8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_float16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_long2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_long3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_long4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_long8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ulong2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ulong3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ulong4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ulong8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_double2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_double3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_double4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_double8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_char2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_char3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_char4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_char8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_char16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_char32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_short2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_short3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_short4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_short8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_short16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_short32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_int2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_int3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_int4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_int8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_int16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_float2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_float3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_float4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_float8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_float16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_long2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_long3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_long4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_long8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_double2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_double3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_double4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_double8 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uchar2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uchar3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uchar4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uchar8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uchar16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_uchar32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ushort2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ushort3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ushort4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ushort8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_ushort16 __x); +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_ushort32 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uint2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uint3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uint4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uint8 __x); +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uint16 __x); +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ulong2 __x); +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ulong3 __x); +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ulong4 __x); +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ulong8 __x); +#define vector_uchar simd_uchar +#define vector_uchar_sat simd_uchar_sat + +static simd_short2 SIMD_CFUNC simd_short(simd_char2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_char3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_char4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_char8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_char16 __x); +static simd_short32 SIMD_CFUNC simd_short(simd_char32 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_uchar2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_uchar3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_uchar4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_uchar8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_uchar16 __x); +static simd_short32 SIMD_CFUNC simd_short(simd_uchar32 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_short2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_short3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_short4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_short8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_short16 __x); +static simd_short32 SIMD_CFUNC simd_short(simd_short32 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_ushort2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_ushort3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_ushort4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_ushort8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_ushort16 __x); +static simd_short32 SIMD_CFUNC simd_short(simd_ushort32 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_int2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_int3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_int4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_int8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_int16 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_uint2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_uint3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_uint4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_uint8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_uint16 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_float2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_float3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_float4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_float8 __x); +static simd_short16 SIMD_CFUNC simd_short(simd_float16 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_long2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_long3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_long4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_long8 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_ulong2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_ulong3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_ulong4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_ulong8 __x); +static simd_short2 SIMD_CFUNC simd_short(simd_double2 __x); +static simd_short3 SIMD_CFUNC simd_short(simd_double3 __x); +static simd_short4 SIMD_CFUNC simd_short(simd_double4 __x); +static simd_short8 SIMD_CFUNC simd_short(simd_double8 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_char2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_char3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_char4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_char8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_char16 __x); +static simd_short32 SIMD_CFUNC simd_short_sat(simd_char32 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_short2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_short3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_short4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_short8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_short16 __x); +static simd_short32 SIMD_CFUNC simd_short_sat(simd_short32 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_int2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_int3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_int4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_int8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_int16 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_float2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_float3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_float4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_float8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_float16 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_long2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_long3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_long4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_long8 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_double2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_double3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_double4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_double8 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_uchar2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_uchar3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_uchar4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_uchar8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_uchar16 __x); +static simd_short32 SIMD_CFUNC simd_short_sat(simd_uchar32 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_ushort2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_ushort3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_ushort4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_ushort8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_ushort16 __x); +static simd_short32 SIMD_CFUNC simd_short_sat(simd_ushort32 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_uint2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_uint3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_uint4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_uint8 __x); +static simd_short16 SIMD_CFUNC simd_short_sat(simd_uint16 __x); +static simd_short2 SIMD_CFUNC simd_short_sat(simd_ulong2 __x); +static simd_short3 SIMD_CFUNC simd_short_sat(simd_ulong3 __x); +static simd_short4 SIMD_CFUNC simd_short_sat(simd_ulong4 __x); +static simd_short8 SIMD_CFUNC simd_short_sat(simd_ulong8 __x); +#define vector_short simd_short +#define vector_short_sat simd_short_sat + +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_char2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_char3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_char4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_char8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_char16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_char32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uchar2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uchar3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uchar4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uchar8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uchar16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_uchar32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_short2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_short3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_short4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_short8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_short16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_short32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ushort2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ushort3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ushort4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ushort8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_ushort16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_ushort32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_int2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_int3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_int4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_int8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_int16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uint2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uint3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uint4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uint8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uint16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_float2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_float3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_float4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_float8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_float16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_long2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_long3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_long4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_long8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ulong2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ulong3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ulong4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ulong8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_double2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_double3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_double4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_double8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_char2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_char3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_char4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_char8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_char16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_char32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_short2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_short3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_short4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_short8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_short16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_short32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_int2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_int3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_int4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_int8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_int16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_float2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_float3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_float4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_float8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_float16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_long2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_long3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_long4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_long8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_double2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_double3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_double4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_double8 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uchar2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uchar3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uchar4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uchar8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uchar16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_uchar32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ushort2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ushort3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ushort4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ushort8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_ushort16 __x); +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_ushort32 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uint2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uint3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uint4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uint8 __x); +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uint16 __x); +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ulong2 __x); +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ulong3 __x); +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ulong4 __x); +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ulong8 __x); +#define vector_ushort simd_ushort +#define vector_ushort_sat simd_ushort_sat + +static simd_int2 SIMD_CFUNC simd_int(simd_char2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_char3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_char4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_char8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_char16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_uchar2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_uchar3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_uchar4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_uchar8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_uchar16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_short2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_short3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_short4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_short8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_short16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_ushort2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_ushort3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_ushort4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_ushort8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_ushort16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_int2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_int3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_int4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_int8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_int16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_uint2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_uint3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_uint4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_uint8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_uint16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_float2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_float3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_float4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_float8 __x); +static simd_int16 SIMD_CFUNC simd_int(simd_float16 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_long2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_long3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_long4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_long8 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_ulong2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_ulong3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_ulong4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_ulong8 __x); +static simd_int2 SIMD_CFUNC simd_int(simd_double2 __x); +static simd_int3 SIMD_CFUNC simd_int(simd_double3 __x); +static simd_int4 SIMD_CFUNC simd_int(simd_double4 __x); +static simd_int8 SIMD_CFUNC simd_int(simd_double8 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_char2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_char3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_char4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_char8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_char16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_short2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_short3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_short4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_short8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_short16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_int2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_int3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_int4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_int8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_int16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_float2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_float3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_float4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_float8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_float16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_long2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_long3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_long4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_long8 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_double2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_double3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_double4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_double8 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_uchar2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_uchar3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_uchar4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_uchar8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_uchar16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_ushort2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_ushort3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_ushort4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_ushort8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_ushort16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_uint2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_uint3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_uint4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_uint8 __x); +static simd_int16 SIMD_CFUNC simd_int_sat(simd_uint16 __x); +static simd_int2 SIMD_CFUNC simd_int_sat(simd_ulong2 __x); +static simd_int3 SIMD_CFUNC simd_int_sat(simd_ulong3 __x); +static simd_int4 SIMD_CFUNC simd_int_sat(simd_ulong4 __x); +static simd_int8 SIMD_CFUNC simd_int_sat(simd_ulong8 __x); +static simd_int2 SIMD_CFUNC simd_int_rte(simd_float2 __x); +static simd_int3 SIMD_CFUNC simd_int_rte(simd_float3 __x); +static simd_int4 SIMD_CFUNC simd_int_rte(simd_float4 __x); +static simd_int8 SIMD_CFUNC simd_int_rte(simd_float8 __x); +static simd_int16 SIMD_CFUNC simd_int_rte(simd_float16 __x); +#define vector_int simd_int +#define vector_int_sat simd_int_sat + +static simd_uint2 SIMD_CFUNC simd_uint(simd_char2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_char3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_char4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_char8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_char16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_uchar2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_uchar3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_uchar4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_uchar8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_uchar16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_short2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_short3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_short4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_short8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_short16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_ushort2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_ushort3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_ushort4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_ushort8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_ushort16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_int2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_int3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_int4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_int8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_int16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_uint2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_uint3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_uint4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_uint8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_uint16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_float2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_float3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_float4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_float8 __x); +static simd_uint16 SIMD_CFUNC simd_uint(simd_float16 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_long2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_long3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_long4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_long8 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_ulong2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_ulong3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_ulong4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_ulong8 __x); +static simd_uint2 SIMD_CFUNC simd_uint(simd_double2 __x); +static simd_uint3 SIMD_CFUNC simd_uint(simd_double3 __x); +static simd_uint4 SIMD_CFUNC simd_uint(simd_double4 __x); +static simd_uint8 SIMD_CFUNC simd_uint(simd_double8 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_char2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_char3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_char4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_char8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_char16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_short2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_short3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_short4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_short8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_short16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_int2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_int3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_int4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_int8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_int16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_float2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_float3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_float4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_float8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_float16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_long2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_long3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_long4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_long8 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_double2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_double3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_double4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_double8 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uchar2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uchar3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uchar4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uchar8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uchar16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ushort2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ushort3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ushort4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ushort8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_ushort16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uint2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uint3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uint4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uint8 __x); +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uint16 __x); +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ulong2 __x); +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ulong3 __x); +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ulong4 __x); +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ulong8 __x); +#define vector_uint simd_uint +#define vector_uint_sat simd_uint_sat + +static simd_float2 SIMD_CFUNC simd_float(simd_char2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_char3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_char4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_char8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_char16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_uchar2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_uchar3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_uchar4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_uchar8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_uchar16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_short2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_short3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_short4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_short8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_short16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_ushort2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_ushort3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_ushort4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_ushort8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_ushort16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_int2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_int3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_int4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_int8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_int16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_uint2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_uint3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_uint4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_uint8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_uint16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_float2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_float3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_float4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_float8 __x); +static simd_float16 SIMD_CFUNC simd_float(simd_float16 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_long2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_long3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_long4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_long8 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_ulong2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_ulong3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_ulong4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_ulong8 __x); +static simd_float2 SIMD_CFUNC simd_float(simd_double2 __x); +static simd_float3 SIMD_CFUNC simd_float(simd_double3 __x); +static simd_float4 SIMD_CFUNC simd_float(simd_double4 __x); +static simd_float8 SIMD_CFUNC simd_float(simd_double8 __x); +#define vector_float simd_float + +static simd_long2 SIMD_CFUNC simd_long(simd_char2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_char3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_char4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_char8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_uchar2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_uchar3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_uchar4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_uchar8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_short2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_short3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_short4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_short8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_ushort2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_ushort3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_ushort4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_ushort8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_int2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_int3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_int4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_int8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_uint2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_uint3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_uint4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_uint8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_float2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_float3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_float4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_float8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_long2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_long3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_long4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_long8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_ulong2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_ulong3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_ulong4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_ulong8 __x); +static simd_long2 SIMD_CFUNC simd_long(simd_double2 __x); +static simd_long3 SIMD_CFUNC simd_long(simd_double3 __x); +static simd_long4 SIMD_CFUNC simd_long(simd_double4 __x); +static simd_long8 SIMD_CFUNC simd_long(simd_double8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_char2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_char3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_char4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_char8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_short2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_short3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_short4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_short8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_int2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_int3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_int4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_int8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_float2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_float3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_float4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_float8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_long2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_long3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_long4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_long8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_double2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_double3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_double4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_double8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_uchar2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_uchar3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_uchar4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_uchar8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_ushort2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_ushort3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_ushort4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_ushort8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_uint2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_uint3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_uint4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_uint8 __x); +static simd_long2 SIMD_CFUNC simd_long_sat(simd_ulong2 __x); +static simd_long3 SIMD_CFUNC simd_long_sat(simd_ulong3 __x); +static simd_long4 SIMD_CFUNC simd_long_sat(simd_ulong4 __x); +static simd_long8 SIMD_CFUNC simd_long_sat(simd_ulong8 __x); +static simd_long2 SIMD_CFUNC simd_long_rte(simd_double2 __x); +static simd_long3 SIMD_CFUNC simd_long_rte(simd_double3 __x); +static simd_long4 SIMD_CFUNC simd_long_rte(simd_double4 __x); +static simd_long8 SIMD_CFUNC simd_long_rte(simd_double8 __x); +#define vector_long simd_long +#define vector_long_sat simd_long_sat + +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_char2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_char3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_char4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_char8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uchar2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uchar3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uchar4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uchar8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_short2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_short3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_short4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_short8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ushort2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ushort3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ushort4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ushort8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_int2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_int3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_int4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_int8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uint2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uint3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uint4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uint8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_float2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_float3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_float4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_float8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_long2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_long3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_long4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_long8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ulong2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ulong3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ulong4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ulong8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_double2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_double3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_double4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_double8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_char2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_char3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_char4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_char8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_short2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_short3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_short4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_short8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_int2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_int3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_int4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_int8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_float2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_float3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_float4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_float8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_long2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_long3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_long4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_long8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_double2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_double3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_double4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_double8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uchar2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uchar3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uchar4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uchar8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ushort2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ushort3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ushort4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ushort8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uint2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uint3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uint4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uint8 __x); +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ulong2 __x); +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ulong3 __x); +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ulong4 __x); +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ulong8 __x); +#define vector_ulong simd_ulong +#define vector_ulong_sat simd_ulong_sat + +static simd_double2 SIMD_CFUNC simd_double(simd_char2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_char3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_char4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_char8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_uchar2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_uchar3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_uchar4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_uchar8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_short2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_short3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_short4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_short8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_ushort2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_ushort3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_ushort4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_ushort8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_int2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_int3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_int4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_int8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_uint2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_uint3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_uint4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_uint8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_float2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_float3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_float4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_float8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_long2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_long3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_long4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_long8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_ulong2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_ulong3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_ulong4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_ulong8 __x); +static simd_double2 SIMD_CFUNC simd_double(simd_double2 __x); +static simd_double3 SIMD_CFUNC simd_double(simd_double3 __x); +static simd_double4 SIMD_CFUNC simd_double(simd_double4 __x); +static simd_double8 SIMD_CFUNC simd_double(simd_double8 __x); +#define vector_double simd_double + +static simd_char2 SIMD_CFUNC vector2(char __x, char __y) { return ( simd_char2){__x, __y}; } +static simd_uchar2 SIMD_CFUNC vector2(unsigned char __x, unsigned char __y) { return ( simd_uchar2){__x, __y}; } +static simd_short2 SIMD_CFUNC vector2(short __x, short __y) { return ( simd_short2){__x, __y}; } +static simd_ushort2 SIMD_CFUNC vector2(unsigned short __x, unsigned short __y) { return (simd_ushort2){__x, __y}; } +static simd_int2 SIMD_CFUNC vector2(int __x, int __y) { return ( simd_int2){__x, __y}; } +static simd_uint2 SIMD_CFUNC vector2(unsigned int __x, unsigned int __y) { return ( simd_uint2){__x, __y}; } +static simd_float2 SIMD_CFUNC vector2(float __x, float __y) { return ( simd_float2){__x, __y}; } +static simd_long2 SIMD_CFUNC vector2(simd_long1 __x, simd_long1 __y) { return ( simd_long2){__x, __y}; } +static simd_ulong2 SIMD_CFUNC vector2(simd_ulong1 __x, simd_ulong1 __y) { return ( simd_ulong2){__x, __y}; } +static simd_double2 SIMD_CFUNC vector2(double __x, double __y) { return (simd_double2){__x, __y}; } + +static simd_char3 SIMD_CFUNC vector3(char __x, char __y, char __z) { return ( simd_char3){__x, __y, __z}; } +static simd_uchar3 SIMD_CFUNC vector3(unsigned char __x, unsigned char __y, unsigned char __z) { return ( simd_uchar3){__x, __y, __z}; } +static simd_short3 SIMD_CFUNC vector3(short __x, short __y, short __z) { return ( simd_short3){__x, __y, __z}; } +static simd_ushort3 SIMD_CFUNC vector3(unsigned short __x, unsigned short __y, unsigned short __z) { return (simd_ushort3){__x, __y, __z}; } +static simd_int3 SIMD_CFUNC vector3(int __x, int __y, int __z) { return ( simd_int3){__x, __y, __z}; } +static simd_uint3 SIMD_CFUNC vector3(unsigned int __x, unsigned int __y, unsigned int __z) { return ( simd_uint3){__x, __y, __z}; } +static simd_float3 SIMD_CFUNC vector3(float __x, float __y, float __z) { return ( simd_float3){__x, __y, __z}; } +static simd_long3 SIMD_CFUNC vector3(simd_long1 __x, simd_long1 __y, simd_long1 __z) { return ( simd_long3){__x, __y, __z}; } +static simd_ulong3 SIMD_CFUNC vector3(simd_ulong1 __x, simd_ulong1 __y, simd_ulong1 __z) { return ( simd_ulong3){__x, __y, __z}; } +static simd_double3 SIMD_CFUNC vector3(double __x, double __y, double __z) { return (simd_double3){__x, __y, __z}; } + +static simd_char3 SIMD_CFUNC vector3(simd_char2 __xy, char __z) { simd_char3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_uchar3 SIMD_CFUNC vector3(simd_uchar2 __xy, unsigned char __z) { simd_uchar3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_short3 SIMD_CFUNC vector3(simd_short2 __xy, short __z) { simd_short3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_ushort3 SIMD_CFUNC vector3(simd_ushort2 __xy, unsigned short __z) { simd_ushort3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_int3 SIMD_CFUNC vector3(simd_int2 __xy, int __z) { simd_int3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_uint3 SIMD_CFUNC vector3(simd_uint2 __xy, unsigned int __z) { simd_uint3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_float3 SIMD_CFUNC vector3(simd_float2 __xy, float __z) { simd_float3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_long3 SIMD_CFUNC vector3(simd_long2 __xy, simd_long1 __z) { simd_long3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_ulong3 SIMD_CFUNC vector3(simd_ulong2 __xy, simd_ulong1 __z) { simd_ulong3 __r; __r.xy = __xy; __r.z = __z; return __r; } +static simd_double3 SIMD_CFUNC vector3(simd_double2 __xy, double __z) { simd_double3 __r; __r.xy = __xy; __r.z = __z; return __r; } + +static simd_char4 SIMD_CFUNC vector4(char __x, char __y, char __z, char __w) { return ( simd_char4){__x, __y, __z, __w}; } +static simd_uchar4 SIMD_CFUNC vector4(unsigned char __x, unsigned char __y, unsigned char __z, unsigned char __w) { return ( simd_uchar4){__x, __y, __z, __w}; } +static simd_short4 SIMD_CFUNC vector4(short __x, short __y, short __z, short __w) { return ( simd_short4){__x, __y, __z, __w}; } +static simd_ushort4 SIMD_CFUNC vector4(unsigned short __x, unsigned short __y, unsigned short __z, unsigned short __w) { return (simd_ushort4){__x, __y, __z, __w}; } +static simd_int4 SIMD_CFUNC vector4(int __x, int __y, int __z, int __w) { return ( simd_int4){__x, __y, __z, __w}; } +static simd_uint4 SIMD_CFUNC vector4(unsigned int __x, unsigned int __y, unsigned int __z, unsigned int __w) { return ( simd_uint4){__x, __y, __z, __w}; } +static simd_float4 SIMD_CFUNC vector4(float __x, float __y, float __z, float __w) { return ( simd_float4){__x, __y, __z, __w}; } +static simd_long4 SIMD_CFUNC vector4(simd_long1 __x, simd_long1 __y, simd_long1 __z, simd_long1 __w) { return ( simd_long4){__x, __y, __z, __w}; } +static simd_ulong4 SIMD_CFUNC vector4(simd_ulong1 __x, simd_ulong1 __y, simd_ulong1 __z, simd_ulong1 __w) { return ( simd_ulong4){__x, __y, __z, __w}; } +static simd_double4 SIMD_CFUNC vector4(double __x, double __y, double __z, double __w) { return (simd_double4){__x, __y, __z, __w}; } + +static simd_char4 SIMD_CFUNC vector4(simd_char2 __xy, simd_char2 __zw) { simd_char4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_uchar4 SIMD_CFUNC vector4(simd_uchar2 __xy, simd_uchar2 __zw) { simd_uchar4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_short4 SIMD_CFUNC vector4(simd_short2 __xy, simd_short2 __zw) { simd_short4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_ushort4 SIMD_CFUNC vector4(simd_ushort2 __xy, simd_ushort2 __zw) { simd_ushort4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_int4 SIMD_CFUNC vector4(simd_int2 __xy, simd_int2 __zw) { simd_int4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_uint4 SIMD_CFUNC vector4(simd_uint2 __xy, simd_uint2 __zw) { simd_uint4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_float4 SIMD_CFUNC vector4(simd_float2 __xy, simd_float2 __zw) { simd_float4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_long4 SIMD_CFUNC vector4(simd_long2 __xy, simd_long2 __zw) { simd_long4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_ulong4 SIMD_CFUNC vector4(simd_ulong2 __xy, simd_ulong2 __zw) { simd_ulong4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } +static simd_double4 SIMD_CFUNC vector4(simd_double2 __xy, simd_double2 __zw) { simd_double4 __r; __r.xy = __xy; __r.zw = __zw; return __r; } + +static simd_char4 SIMD_CFUNC vector4(simd_char3 __xyz, char __w) { simd_char4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_uchar4 SIMD_CFUNC vector4(simd_uchar3 __xyz, unsigned char __w) { simd_uchar4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_short4 SIMD_CFUNC vector4(simd_short3 __xyz, short __w) { simd_short4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_ushort4 SIMD_CFUNC vector4(simd_ushort3 __xyz, unsigned short __w) { simd_ushort4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_int4 SIMD_CFUNC vector4(simd_int3 __xyz, int __w) { simd_int4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_uint4 SIMD_CFUNC vector4(simd_uint3 __xyz, unsigned int __w) { simd_uint4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_float4 SIMD_CFUNC vector4(simd_float3 __xyz, float __w) { simd_float4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_long4 SIMD_CFUNC vector4(simd_long3 __xyz, simd_long1 __w) { simd_long4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_ulong4 SIMD_CFUNC vector4(simd_ulong3 __xyz, simd_ulong1 __w) { simd_ulong4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } +static simd_double4 SIMD_CFUNC vector4(simd_double3 __xyz, double __w) { simd_double4 __r; __r.xyz = __xyz; __r.w = __w; return __r; } + +static simd_char8 SIMD_CFUNC vector8(simd_char4 __lo, simd_char4 __hi) { simd_char8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uchar8 SIMD_CFUNC vector8(simd_uchar4 __lo, simd_uchar4 __hi) { simd_uchar8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_short8 SIMD_CFUNC vector8(simd_short4 __lo, simd_short4 __hi) { simd_short8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_ushort8 SIMD_CFUNC vector8(simd_ushort4 __lo, simd_ushort4 __hi) { simd_ushort8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_int8 SIMD_CFUNC vector8(simd_int4 __lo, simd_int4 __hi) { simd_int8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uint8 SIMD_CFUNC vector8(simd_uint4 __lo, simd_uint4 __hi) { simd_uint8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_float8 SIMD_CFUNC vector8(simd_float4 __lo, simd_float4 __hi) { simd_float8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_long8 SIMD_CFUNC vector8(simd_long4 __lo, simd_long4 __hi) { simd_long8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_ulong8 SIMD_CFUNC vector8(simd_ulong4 __lo, simd_ulong4 __hi) { simd_ulong8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_double8 SIMD_CFUNC vector8(simd_double4 __lo, simd_double4 __hi) { simd_double8 __r; __r.lo = __lo; __r.hi = __hi; return __r; } + +static simd_char16 SIMD_CFUNC vector16(simd_char8 __lo, simd_char8 __hi) { simd_char16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uchar16 SIMD_CFUNC vector16(simd_uchar8 __lo, simd_uchar8 __hi) { simd_uchar16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_short16 SIMD_CFUNC vector16(simd_short8 __lo, simd_short8 __hi) { simd_short16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_ushort16 SIMD_CFUNC vector16(simd_ushort8 __lo, simd_ushort8 __hi) { simd_ushort16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_int16 SIMD_CFUNC vector16(simd_int8 __lo, simd_int8 __hi) { simd_int16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uint16 SIMD_CFUNC vector16(simd_uint8 __lo, simd_uint8 __hi) { simd_uint16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_float16 SIMD_CFUNC vector16(simd_float8 __lo, simd_float8 __hi) { simd_float16 __r; __r.lo = __lo; __r.hi = __hi; return __r; } + +static simd_char32 SIMD_CFUNC vector32(simd_char16 __lo, simd_char16 __hi) { simd_char32 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_uchar32 SIMD_CFUNC vector32(simd_uchar16 __lo, simd_uchar16 __hi) { simd_uchar32 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_short32 SIMD_CFUNC vector32(simd_short16 __lo, simd_short16 __hi) { simd_short32 __r; __r.lo = __lo; __r.hi = __hi; return __r; } +static simd_ushort32 SIMD_CFUNC vector32(simd_ushort16 __lo, simd_ushort16 __hi) { simd_ushort32 __r; __r.lo = __lo; __r.hi = __hi; return __r; } + +#pragma mark - Implementation + +static simd_char2 SIMD_CFUNC simd_char(simd_char2 __x) { return __x; } +static simd_char3 SIMD_CFUNC simd_char(simd_char3 __x) { return __x; } +static simd_char4 SIMD_CFUNC simd_char(simd_char4 __x) { return __x; } +static simd_char8 SIMD_CFUNC simd_char(simd_char8 __x) { return __x; } +static simd_char16 SIMD_CFUNC simd_char(simd_char16 __x) { return __x; } +static simd_char32 SIMD_CFUNC simd_char(simd_char32 __x) { return __x; } +static simd_char2 SIMD_CFUNC simd_char(simd_uchar2 __x) { return (simd_char2)__x; } +static simd_char3 SIMD_CFUNC simd_char(simd_uchar3 __x) { return (simd_char3)__x; } +static simd_char4 SIMD_CFUNC simd_char(simd_uchar4 __x) { return (simd_char4)__x; } +static simd_char8 SIMD_CFUNC simd_char(simd_uchar8 __x) { return (simd_char8)__x; } +static simd_char16 SIMD_CFUNC simd_char(simd_uchar16 __x) { return (simd_char16)__x; } +static simd_char32 SIMD_CFUNC simd_char(simd_uchar32 __x) { return (simd_char32)__x; } +static simd_char2 SIMD_CFUNC simd_char(simd_short2 __x) { return __builtin_convertvector(__x & 0xff, simd_char2); } +static simd_char3 SIMD_CFUNC simd_char(simd_short3 __x) { return __builtin_convertvector(__x & 0xff, simd_char3); } +static simd_char4 SIMD_CFUNC simd_char(simd_short4 __x) { return __builtin_convertvector(__x & 0xff, simd_char4); } +static simd_char8 SIMD_CFUNC simd_char(simd_short8 __x) { return __builtin_convertvector(__x & 0xff, simd_char8); } +static simd_char16 SIMD_CFUNC simd_char(simd_short16 __x) { return __builtin_convertvector(__x & 0xff, simd_char16); } +static simd_char32 SIMD_CFUNC simd_char(simd_short32 __x) { return __builtin_convertvector(__x & 0xff, simd_char32); } +static simd_char2 SIMD_CFUNC simd_char(simd_ushort2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_ushort3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_ushort4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_ushort8 __x) { return simd_char(simd_short(__x)); } +static simd_char16 SIMD_CFUNC simd_char(simd_ushort16 __x) { return simd_char(simd_short(__x)); } +static simd_char32 SIMD_CFUNC simd_char(simd_ushort32 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_int2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_int3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_int4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_int8 __x) { return simd_char(simd_short(__x)); } +static simd_char16 SIMD_CFUNC simd_char(simd_int16 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_uint2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_uint3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_uint4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_uint8 __x) { return simd_char(simd_short(__x)); } +static simd_char16 SIMD_CFUNC simd_char(simd_uint16 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_float2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_float3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_float4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_float8 __x) { return simd_char(simd_short(__x)); } +static simd_char16 SIMD_CFUNC simd_char(simd_float16 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_long2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_long3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_long4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_long8 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_ulong2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_ulong3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_ulong4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_ulong8 __x) { return simd_char(simd_short(__x)); } +static simd_char2 SIMD_CFUNC simd_char(simd_double2 __x) { return simd_char(simd_short(__x)); } +static simd_char3 SIMD_CFUNC simd_char(simd_double3 __x) { return simd_char(simd_short(__x)); } +static simd_char4 SIMD_CFUNC simd_char(simd_double4 __x) { return simd_char(simd_short(__x)); } +static simd_char8 SIMD_CFUNC simd_char(simd_double8 __x) { return simd_char(simd_short(__x)); } + +static simd_char2 SIMD_CFUNC simd_char_sat(simd_char2 __x) { return __x; } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_char3 __x) { return __x; } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_char4 __x) { return __x; } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_char8 __x) { return __x; } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_char16 __x) { return __x; } +static simd_char32 SIMD_CFUNC simd_char_sat(simd_char32 __x) { return __x; } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_short2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_short3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_short4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_short8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_short16 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char32 SIMD_CFUNC simd_char_sat(simd_short32 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_int2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_int3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_int4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_int8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_int16 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_float2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_float3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_float4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_float8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_float16 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_long2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_long3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_long4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_long8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_double2 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_double3 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_double4 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_double8 __x) { return simd_char(simd_clamp(__x,-0x80,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_uchar2 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_uchar3 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_uchar4 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_uchar8 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_uchar16 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char32 SIMD_CFUNC simd_char_sat(simd_uchar32 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_ushort2 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_ushort3 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_ushort4 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_ushort8 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_ushort16 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char32 SIMD_CFUNC simd_char_sat(simd_ushort32 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_uint2 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_uint3 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_uint4 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_uint8 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char16 SIMD_CFUNC simd_char_sat(simd_uint16 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char2 SIMD_CFUNC simd_char_sat(simd_ulong2 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char3 SIMD_CFUNC simd_char_sat(simd_ulong3 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char4 SIMD_CFUNC simd_char_sat(simd_ulong4 __x) { return simd_char(simd_min(__x,0x7f)); } +static simd_char8 SIMD_CFUNC simd_char_sat(simd_ulong8 __x) { return simd_char(simd_min(__x,0x7f)); } + + +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_char2 __x) { return (simd_uchar2)__x; } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_char3 __x) { return (simd_uchar3)__x; } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_char4 __x) { return (simd_uchar4)__x; } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_char8 __x) { return (simd_uchar8)__x; } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_char16 __x) { return (simd_uchar16)__x; } +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_char32 __x) { return (simd_uchar32)__x; } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uchar2 __x) { return __x; } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uchar3 __x) { return __x; } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uchar4 __x) { return __x; } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uchar8 __x) { return __x; } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uchar16 __x) { return __x; } +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_uchar32 __x) { return __x; } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_short2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_short3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_short4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_short8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_short16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_short32 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ushort2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ushort3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ushort4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ushort8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_ushort16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar32 SIMD_CFUNC simd_uchar(simd_ushort32 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_int2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_int3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_int4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_int8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_int16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_uint2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_uint3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_uint4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_uint8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_uint16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_float2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_float3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_float4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_float8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar(simd_float16 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_long2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_long3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_long4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_long8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_ulong2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_ulong3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_ulong4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_ulong8 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar(simd_double2 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar(simd_double3 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar(simd_double4 __x) { return simd_uchar(simd_char(__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar(simd_double8 __x) { return simd_uchar(simd_char(__x)); } + +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_char2 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_char3 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_char4 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_char8 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_char16 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_char32 __x) { return simd_uchar(simd_max(0,__x)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_short2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_short3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_short4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_short8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_short16 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_short32 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_int2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_int3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_int4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_int8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_int16 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_float2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_float3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_float4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_float8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_float16 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_long2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_long3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_long4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_long8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_double2 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_double3 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_double4 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_double8 __x) { return simd_uchar(simd_clamp(__x,0,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uchar2 __x) { return __x; } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uchar3 __x) { return __x; } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uchar4 __x) { return __x; } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uchar8 __x) { return __x; } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uchar16 __x) { return __x; } +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_uchar32 __x) { return __x; } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ushort2 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ushort3 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ushort4 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ushort8 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_ushort16 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar32 SIMD_CFUNC simd_uchar_sat(simd_ushort32 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_uint2 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_uint3 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_uint4 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_uint8 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar16 SIMD_CFUNC simd_uchar_sat(simd_uint16 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar2 SIMD_CFUNC simd_uchar_sat(simd_ulong2 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar3 SIMD_CFUNC simd_uchar_sat(simd_ulong3 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar4 SIMD_CFUNC simd_uchar_sat(simd_ulong4 __x) { return simd_uchar(simd_min(__x,0xff)); } +static simd_uchar8 SIMD_CFUNC simd_uchar_sat(simd_ulong8 __x) { return simd_uchar(simd_min(__x,0xff)); } + + +static simd_short2 SIMD_CFUNC simd_short(simd_char2 __x) { return __builtin_convertvector(__x, simd_short2); } +static simd_short3 SIMD_CFUNC simd_short(simd_char3 __x) { return __builtin_convertvector(__x, simd_short3); } +static simd_short4 SIMD_CFUNC simd_short(simd_char4 __x) { return __builtin_convertvector(__x, simd_short4); } +static simd_short8 SIMD_CFUNC simd_short(simd_char8 __x) { return __builtin_convertvector(__x, simd_short8); } +static simd_short16 SIMD_CFUNC simd_short(simd_char16 __x) { return __builtin_convertvector(__x, simd_short16); } +static simd_short32 SIMD_CFUNC simd_short(simd_char32 __x) { return __builtin_convertvector(__x, simd_short32); } +static simd_short2 SIMD_CFUNC simd_short(simd_uchar2 __x) { return __builtin_convertvector(__x, simd_short2); } +static simd_short3 SIMD_CFUNC simd_short(simd_uchar3 __x) { return __builtin_convertvector(__x, simd_short3); } +static simd_short4 SIMD_CFUNC simd_short(simd_uchar4 __x) { return __builtin_convertvector(__x, simd_short4); } +static simd_short8 SIMD_CFUNC simd_short(simd_uchar8 __x) { return __builtin_convertvector(__x, simd_short8); } +static simd_short16 SIMD_CFUNC simd_short(simd_uchar16 __x) { return __builtin_convertvector(__x, simd_short16); } +static simd_short32 SIMD_CFUNC simd_short(simd_uchar32 __x) { return __builtin_convertvector(__x, simd_short32); } +static simd_short2 SIMD_CFUNC simd_short(simd_short2 __x) { return __x; } +static simd_short3 SIMD_CFUNC simd_short(simd_short3 __x) { return __x; } +static simd_short4 SIMD_CFUNC simd_short(simd_short4 __x) { return __x; } +static simd_short8 SIMD_CFUNC simd_short(simd_short8 __x) { return __x; } +static simd_short16 SIMD_CFUNC simd_short(simd_short16 __x) { return __x; } +static simd_short32 SIMD_CFUNC simd_short(simd_short32 __x) { return __x; } +static simd_short2 SIMD_CFUNC simd_short(simd_ushort2 __x) { return (simd_short2)__x; } +static simd_short3 SIMD_CFUNC simd_short(simd_ushort3 __x) { return (simd_short3)__x; } +static simd_short4 SIMD_CFUNC simd_short(simd_ushort4 __x) { return (simd_short4)__x; } +static simd_short8 SIMD_CFUNC simd_short(simd_ushort8 __x) { return (simd_short8)__x; } +static simd_short16 SIMD_CFUNC simd_short(simd_ushort16 __x) { return (simd_short16)__x; } +static simd_short32 SIMD_CFUNC simd_short(simd_ushort32 __x) { return (simd_short32)__x; } +static simd_short2 SIMD_CFUNC simd_short(simd_int2 __x) { return __builtin_convertvector(__x & 0xffff, simd_short2); } +static simd_short3 SIMD_CFUNC simd_short(simd_int3 __x) { return __builtin_convertvector(__x & 0xffff, simd_short3); } +static simd_short4 SIMD_CFUNC simd_short(simd_int4 __x) { return __builtin_convertvector(__x & 0xffff, simd_short4); } +static simd_short8 SIMD_CFUNC simd_short(simd_int8 __x) { return __builtin_convertvector(__x & 0xffff, simd_short8); } +static simd_short16 SIMD_CFUNC simd_short(simd_int16 __x) { return __builtin_convertvector(__x & 0xffff, simd_short16); } +static simd_short2 SIMD_CFUNC simd_short(simd_uint2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_uint3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_uint4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_uint8 __x) { return simd_short(simd_int(__x)); } +static simd_short16 SIMD_CFUNC simd_short(simd_uint16 __x) { return simd_short(simd_int(__x)); } +static simd_short2 SIMD_CFUNC simd_short(simd_float2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_float3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_float4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_float8 __x) { return simd_short(simd_int(__x)); } +static simd_short16 SIMD_CFUNC simd_short(simd_float16 __x) { return simd_short(simd_int(__x)); } +static simd_short2 SIMD_CFUNC simd_short(simd_long2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_long3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_long4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_long8 __x) { return simd_short(simd_int(__x)); } +static simd_short2 SIMD_CFUNC simd_short(simd_ulong2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_ulong3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_ulong4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_ulong8 __x) { return simd_short(simd_int(__x)); } +static simd_short2 SIMD_CFUNC simd_short(simd_double2 __x) { return simd_short(simd_int(__x)); } +static simd_short3 SIMD_CFUNC simd_short(simd_double3 __x) { return simd_short(simd_int(__x)); } +static simd_short4 SIMD_CFUNC simd_short(simd_double4 __x) { return simd_short(simd_int(__x)); } +static simd_short8 SIMD_CFUNC simd_short(simd_double8 __x) { return simd_short(simd_int(__x)); } + +static simd_short2 SIMD_CFUNC simd_short_sat(simd_char2 __x) { return simd_short(__x); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_char3 __x) { return simd_short(__x); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_char4 __x) { return simd_short(__x); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_char8 __x) { return simd_short(__x); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_char16 __x) { return simd_short(__x); } +static simd_short32 SIMD_CFUNC simd_short_sat(simd_char32 __x) { return simd_short(__x); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_short2 __x) { return __x; } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_short3 __x) { return __x; } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_short4 __x) { return __x; } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_short8 __x) { return __x; } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_short16 __x) { return __x; } +static simd_short32 SIMD_CFUNC simd_short_sat(simd_short32 __x) { return __x; } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_int2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_int3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_int4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_int8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_int16 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_float2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_float3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_float4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_float8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_float16 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_long2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_long3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_long4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_long8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_double2 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_double3 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_double4 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_double8 __x) { return simd_short(simd_clamp(__x,-0x8000,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_uchar2 __x) { return simd_short(__x); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_uchar3 __x) { return simd_short(__x); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_uchar4 __x) { return simd_short(__x); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_uchar8 __x) { return simd_short(__x); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_uchar16 __x) { return simd_short(__x); } +static simd_short32 SIMD_CFUNC simd_short_sat(simd_uchar32 __x) { return simd_short(__x); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_ushort2 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_ushort3 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_ushort4 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_ushort8 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_ushort16 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short32 SIMD_CFUNC simd_short_sat(simd_ushort32 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_uint2 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_uint3 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_uint4 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_uint8 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short16 SIMD_CFUNC simd_short_sat(simd_uint16 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short2 SIMD_CFUNC simd_short_sat(simd_ulong2 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short3 SIMD_CFUNC simd_short_sat(simd_ulong3 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short4 SIMD_CFUNC simd_short_sat(simd_ulong4 __x) { return simd_short(simd_min(__x,0x7fff)); } +static simd_short8 SIMD_CFUNC simd_short_sat(simd_ulong8 __x) { return simd_short(simd_min(__x,0x7fff)); } + + +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_char2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_char3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_char4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_char8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_char16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_char32 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uchar2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uchar3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uchar4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uchar8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uchar16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_uchar32 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_short2 __x) { return (simd_ushort2)__x; } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_short3 __x) { return (simd_ushort3)__x; } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_short4 __x) { return (simd_ushort4)__x; } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_short8 __x) { return (simd_ushort8)__x; } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_short16 __x) { return (simd_ushort16)__x; } +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_short32 __x) { return (simd_ushort32)__x; } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ushort2 __x) { return __x; } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ushort3 __x) { return __x; } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ushort4 __x) { return __x; } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ushort8 __x) { return __x; } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_ushort16 __x) { return __x; } +static simd_ushort32 SIMD_CFUNC simd_ushort(simd_ushort32 __x) { return __x; } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_int2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_int3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_int4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_int8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_int16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_uint2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_uint3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_uint4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_uint8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_uint16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_float2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_float3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_float4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_float8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort16 SIMD_CFUNC simd_ushort(simd_float16 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_long2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_long3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_long4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_long8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_ulong2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_ulong3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_ulong4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_ulong8 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort2 SIMD_CFUNC simd_ushort(simd_double2 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort3 SIMD_CFUNC simd_ushort(simd_double3 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort4 SIMD_CFUNC simd_ushort(simd_double4 __x) { return simd_ushort(simd_short(__x)); } +static simd_ushort8 SIMD_CFUNC simd_ushort(simd_double8 __x) { return simd_ushort(simd_short(__x)); } + +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_char2 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_char3 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_char4 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_char8 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_char16 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_char32 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_short2 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_short3 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_short4 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_short8 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_short16 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_short32 __x) { return simd_ushort(simd_max(__x, 0)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_int2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_int3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_int4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_int8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_int16 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_float2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_float3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_float4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_float8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_float16 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_long2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_long3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_long4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_long8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_double2 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_double3 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_double4 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_double8 __x) { return simd_ushort(simd_clamp(__x, 0, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uchar2 __x) { return simd_ushort(__x); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uchar3 __x) { return simd_ushort(__x); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uchar4 __x) { return simd_ushort(__x); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uchar8 __x) { return simd_ushort(__x); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uchar16 __x) { return simd_ushort(__x); } +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_uchar32 __x) { return simd_ushort(__x); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ushort2 __x) { return __x; } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ushort3 __x) { return __x; } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ushort4 __x) { return __x; } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ushort8 __x) { return __x; } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_ushort16 __x) { return __x; } +static simd_ushort32 SIMD_CFUNC simd_ushort_sat(simd_ushort32 __x) { return __x; } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_uint2 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_uint3 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_uint4 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_uint8 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort16 SIMD_CFUNC simd_ushort_sat(simd_uint16 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort2 SIMD_CFUNC simd_ushort_sat(simd_ulong2 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort3 SIMD_CFUNC simd_ushort_sat(simd_ulong3 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort4 SIMD_CFUNC simd_ushort_sat(simd_ulong4 __x) { return simd_ushort(simd_min(__x, 0xffff)); } +static simd_ushort8 SIMD_CFUNC simd_ushort_sat(simd_ulong8 __x) { return simd_ushort(simd_min(__x, 0xffff)); } + + +static simd_int2 SIMD_CFUNC simd_int(simd_char2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_char3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_char4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_char8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_char16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_uchar2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_uchar3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_uchar4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_uchar8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_uchar16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_short2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_short3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_short4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_short8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_short16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_ushort2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_ushort3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_ushort4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_ushort8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_ushort16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_int2 __x) { return __x; } +static simd_int3 SIMD_CFUNC simd_int(simd_int3 __x) { return __x; } +static simd_int4 SIMD_CFUNC simd_int(simd_int4 __x) { return __x; } +static simd_int8 SIMD_CFUNC simd_int(simd_int8 __x) { return __x; } +static simd_int16 SIMD_CFUNC simd_int(simd_int16 __x) { return __x; } +static simd_int2 SIMD_CFUNC simd_int(simd_uint2 __x) { return (simd_int2)__x; } +static simd_int3 SIMD_CFUNC simd_int(simd_uint3 __x) { return (simd_int3)__x; } +static simd_int4 SIMD_CFUNC simd_int(simd_uint4 __x) { return (simd_int4)__x; } +static simd_int8 SIMD_CFUNC simd_int(simd_uint8 __x) { return (simd_int8)__x; } +static simd_int16 SIMD_CFUNC simd_int(simd_uint16 __x) { return (simd_int16)__x; } +static simd_int2 SIMD_CFUNC simd_int(simd_float2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_float3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_float4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_float8 __x) { return __builtin_convertvector(__x, simd_int8); } +static simd_int16 SIMD_CFUNC simd_int(simd_float16 __x) { return __builtin_convertvector(__x, simd_int16); } +static simd_int2 SIMD_CFUNC simd_int(simd_long2 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_long3 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_long4 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_long8 __x) { return __builtin_convertvector(__x & 0xffffffff, simd_int8); } +static simd_int2 SIMD_CFUNC simd_int(simd_ulong2 __x) { return simd_int(simd_long(__x)); } +static simd_int3 SIMD_CFUNC simd_int(simd_ulong3 __x) { return simd_int(simd_long(__x)); } +static simd_int4 SIMD_CFUNC simd_int(simd_ulong4 __x) { return simd_int(simd_long(__x)); } +static simd_int8 SIMD_CFUNC simd_int(simd_ulong8 __x) { return simd_int(simd_long(__x)); } +static simd_int2 SIMD_CFUNC simd_int(simd_double2 __x) { return __builtin_convertvector(__x, simd_int2); } +static simd_int3 SIMD_CFUNC simd_int(simd_double3 __x) { return __builtin_convertvector(__x, simd_int3); } +static simd_int4 SIMD_CFUNC simd_int(simd_double4 __x) { return __builtin_convertvector(__x, simd_int4); } +static simd_int8 SIMD_CFUNC simd_int(simd_double8 __x) { return __builtin_convertvector(__x, simd_int8); } + +static simd_int2 SIMD_CFUNC simd_int_sat(simd_char2 __x) { return simd_int(__x); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_char3 __x) { return simd_int(__x); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_char4 __x) { return simd_int(__x); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_char8 __x) { return simd_int(__x); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_char16 __x) { return simd_int(__x); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_short2 __x) { return simd_int(__x); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_short3 __x) { return simd_int(__x); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_short4 __x) { return simd_int(__x); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_short8 __x) { return simd_int(__x); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_short16 __x) { return simd_int(__x); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_int2 __x) { return __x; } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_int3 __x) { return __x; } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_int4 __x) { return __x; } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_int8 __x) { return __x; } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_int16 __x) { return __x; } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_float2 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_float3 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_float4 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_float8 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_float16 __x) { return simd_bitselect(simd_int(simd_max(__x,-0x1.0p31f)), 0x7fffffff, __x >= 0x1.0p31f); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_long2 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_long3 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_long4 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_long8 __x) { return simd_int(simd_clamp(__x,-0x80000000LL,0x7fffffffLL)); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_double2 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_double3 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_double4 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_double8 __x) { return simd_int(simd_clamp(__x,-0x1.0p31,0x1.fffffffcp30)); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_uchar2 __x) { return simd_int(__x); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_uchar3 __x) { return simd_int(__x); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_uchar4 __x) { return simd_int(__x); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_uchar8 __x) { return simd_int(__x); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_uchar16 __x) { return simd_int(__x); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_ushort2 __x) { return simd_int(__x); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_ushort3 __x) { return simd_int(__x); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_ushort4 __x) { return simd_int(__x); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_ushort8 __x) { return simd_int(__x); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_ushort16 __x) { return simd_int(__x); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_uint2 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_uint3 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_uint4 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_uint8 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int16 SIMD_CFUNC simd_int_sat(simd_uint16 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int2 SIMD_CFUNC simd_int_sat(simd_ulong2 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int3 SIMD_CFUNC simd_int_sat(simd_ulong3 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int4 SIMD_CFUNC simd_int_sat(simd_ulong4 __x) { return simd_int(simd_min(__x,0x7fffffff)); } +static simd_int8 SIMD_CFUNC simd_int_sat(simd_ulong8 __x) { return simd_int(simd_min(__x,0x7fffffff)); } + +static simd_int2 SIMD_CFUNC simd_int_rte(simd_float2 __x) { +#if defined __arm64__ + return vcvtn_s32_f32(__x); +#else + return simd_make_int2(simd_int_rte(simd_make_float4_undef(__x))); +#endif +} + +static simd_int3 SIMD_CFUNC simd_int_rte(simd_float3 __x) { + return simd_make_int3(simd_int_rte(simd_make_float4_undef(__x))); +} + +static simd_int4 SIMD_CFUNC simd_int_rte(simd_float4 __x) { +#if defined __SSE2__ + return _mm_cvtps_epi32(__x); +#elif defined __arm64__ + return vcvtnq_s32_f32(__x); +#else + simd_float4 magic = __tg_copysign(0x1.0p23, __x); + simd_int4 x_is_small = __tg_fabs(__x) < 0x1.0p23; + return __builtin_convertvector(simd_bitselect(__x, (__x + magic) - magic, x_is_small & 0x7fffffff), simd_int4); +#endif +} + +static simd_int8 SIMD_CFUNC simd_int_rte(simd_float8 __x) { +#if defined __AVX__ + return _mm256_cvtps_epi32(__x); +#else + return simd_make_int8(simd_int_rte(__x.lo), simd_int_rte(__x.hi)); +#endif +} + +static simd_int16 SIMD_CFUNC simd_int_rte(simd_float16 __x) { +#if defined __AVX512F__ + return _mm512_cvt_roundps_epi32(__x, _MM_FROUND_RINT); +#else + return simd_make_int16(simd_int_rte(__x.lo), simd_int_rte(__x.hi)); +#endif +} + +static simd_uint2 SIMD_CFUNC simd_uint(simd_char2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_char3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_char4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_char8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint16 SIMD_CFUNC simd_uint(simd_char16 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_uchar2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_uchar3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_uchar4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_uchar8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint16 SIMD_CFUNC simd_uint(simd_uchar16 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_short2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_short3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_short4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_short8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint16 SIMD_CFUNC simd_uint(simd_short16 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_ushort2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_ushort3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_ushort4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_ushort8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint16 SIMD_CFUNC simd_uint(simd_ushort16 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_int2 __x) { return (simd_uint2)__x; } +static simd_uint3 SIMD_CFUNC simd_uint(simd_int3 __x) { return (simd_uint3)__x; } +static simd_uint4 SIMD_CFUNC simd_uint(simd_int4 __x) { return (simd_uint4)__x; } +static simd_uint8 SIMD_CFUNC simd_uint(simd_int8 __x) { return (simd_uint8)__x; } +static simd_uint16 SIMD_CFUNC simd_uint(simd_int16 __x) { return (simd_uint16)__x; } +static simd_uint2 SIMD_CFUNC simd_uint(simd_uint2 __x) { return __x; } +static simd_uint3 SIMD_CFUNC simd_uint(simd_uint3 __x) { return __x; } +static simd_uint4 SIMD_CFUNC simd_uint(simd_uint4 __x) { return __x; } +static simd_uint8 SIMD_CFUNC simd_uint(simd_uint8 __x) { return __x; } +static simd_uint16 SIMD_CFUNC simd_uint(simd_uint16 __x) { return __x; } +static simd_uint2 SIMD_CFUNC simd_uint(simd_float2 __x) { simd_int2 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float2)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint2)0,0x80000000,__big); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_float3 __x) { simd_int3 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float3)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint3)0,0x80000000,__big); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_float4 __x) { simd_int4 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float4)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint4)0,0x80000000,__big); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_float8 __x) { simd_int8 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float8)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint8)0,0x80000000,__big); } +static simd_uint16 SIMD_CFUNC simd_uint(simd_float16 __x) { simd_int16 __big = __x > 0x1.0p31f; return simd_uint(simd_int(__x - simd_bitselect((simd_float16)0,0x1.0p31f,__big))) + simd_bitselect((simd_uint16)0,0x80000000,__big); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_long2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_long3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_long4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_long8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_ulong2 __x) { return simd_uint(simd_int(__x)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_ulong3 __x) { return simd_uint(simd_int(__x)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_ulong4 __x) { return simd_uint(simd_int(__x)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_ulong8 __x) { return simd_uint(simd_int(__x)); } +static simd_uint2 SIMD_CFUNC simd_uint(simd_double2 __x) { simd_long2 __big = __x > 0x1.fffffffcp30; return simd_uint(simd_int(__x - simd_bitselect((simd_double2)0,0x1.0p31,__big))) + simd_bitselect((simd_uint2)0,0x80000000,simd_int(__big)); } +static simd_uint3 SIMD_CFUNC simd_uint(simd_double3 __x) { simd_long3 __big = __x > 0x1.fffffffcp30; return simd_uint(simd_int(__x - simd_bitselect((simd_double3)0,0x1.0p31,__big))) + simd_bitselect((simd_uint3)0,0x80000000,simd_int(__big)); } +static simd_uint4 SIMD_CFUNC simd_uint(simd_double4 __x) { simd_long4 __big = __x > 0x1.fffffffcp30; return simd_uint(simd_int(__x - simd_bitselect((simd_double4)0,0x1.0p31,__big))) + simd_bitselect((simd_uint4)0,0x80000000,simd_int(__big)); } +static simd_uint8 SIMD_CFUNC simd_uint(simd_double8 __x) { simd_long8 __big = __x > 0x1.fffffffcp30; return simd_uint(simd_int(__x - simd_bitselect((simd_double8)0,0x1.0p31,__big))) + simd_bitselect((simd_uint8)0,0x80000000,simd_int(__big)); } + +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_char2 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_char3 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_char4 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_char8 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_char16 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_short2 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_short3 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_short4 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_short8 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_short16 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_int2 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_int3 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_int4 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_int8 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_int16 __x) { return simd_uint(simd_max(__x,0)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_float2 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_float3 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_float4 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_float8 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_float16 __x) { return simd_bitselect(simd_uint(simd_max(__x,0)), 0xffffffff, __x >= 0x1.0p32f); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_long2 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_long3 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_long4 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_long8 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_double2 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_double3 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_double4 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_double8 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uchar2 __x) { return simd_uint(__x); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uchar3 __x) { return simd_uint(__x); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uchar4 __x) { return simd_uint(__x); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uchar8 __x) { return simd_uint(__x); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uchar16 __x) { return simd_uint(__x); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ushort2 __x) { return simd_uint(__x); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ushort3 __x) { return simd_uint(__x); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ushort4 __x) { return simd_uint(__x); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ushort8 __x) { return simd_uint(__x); } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_ushort16 __x) { return simd_uint(__x); } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_uint2 __x) { return __x; } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_uint3 __x) { return __x; } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_uint4 __x) { return __x; } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_uint8 __x) { return __x; } +static simd_uint16 SIMD_CFUNC simd_uint_sat(simd_uint16 __x) { return __x; } +static simd_uint2 SIMD_CFUNC simd_uint_sat(simd_ulong2 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint3 SIMD_CFUNC simd_uint_sat(simd_ulong3 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint4 SIMD_CFUNC simd_uint_sat(simd_ulong4 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } +static simd_uint8 SIMD_CFUNC simd_uint_sat(simd_ulong8 __x) { return simd_uint(simd_clamp(__x,0,0xffffffff)); } + + +static simd_float2 SIMD_CFUNC simd_float(simd_char2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float3 SIMD_CFUNC simd_float(simd_char3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float4 SIMD_CFUNC simd_float(simd_char4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float8 SIMD_CFUNC simd_float(simd_char8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float16 SIMD_CFUNC simd_float(simd_char16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float2 SIMD_CFUNC simd_float(simd_uchar2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float3 SIMD_CFUNC simd_float(simd_uchar3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float4 SIMD_CFUNC simd_float(simd_uchar4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float8 SIMD_CFUNC simd_float(simd_uchar8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float16 SIMD_CFUNC simd_float(simd_uchar16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float2 SIMD_CFUNC simd_float(simd_short2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float3 SIMD_CFUNC simd_float(simd_short3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float4 SIMD_CFUNC simd_float(simd_short4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float8 SIMD_CFUNC simd_float(simd_short8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float16 SIMD_CFUNC simd_float(simd_short16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float2 SIMD_CFUNC simd_float(simd_ushort2 __x) { return (simd_float2)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float3 SIMD_CFUNC simd_float(simd_ushort3 __x) { return (simd_float3)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float4 SIMD_CFUNC simd_float(simd_ushort4 __x) { return (simd_float4)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float8 SIMD_CFUNC simd_float(simd_ushort8 __x) { return (simd_float8)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float16 SIMD_CFUNC simd_float(simd_ushort16 __x) { return (simd_float16)(simd_int(__x) + 0x4b400000) - 0x1.8p23f; } +static simd_float2 SIMD_CFUNC simd_float(simd_int2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_int3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_int4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_int8 __x) { return __builtin_convertvector(__x,simd_float8); } +static simd_float16 SIMD_CFUNC simd_float(simd_int16 __x) { return __builtin_convertvector(__x,simd_float16); } +static simd_float2 SIMD_CFUNC simd_float(simd_uint2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_uint3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_uint4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_uint8 __x) { return __builtin_convertvector(__x,simd_float8); } +static simd_float16 SIMD_CFUNC simd_float(simd_uint16 __x) { return __builtin_convertvector(__x,simd_float16); } +static simd_float2 SIMD_CFUNC simd_float(simd_float2 __x) { return __x; } +static simd_float3 SIMD_CFUNC simd_float(simd_float3 __x) { return __x; } +static simd_float4 SIMD_CFUNC simd_float(simd_float4 __x) { return __x; } +static simd_float8 SIMD_CFUNC simd_float(simd_float8 __x) { return __x; } +static simd_float16 SIMD_CFUNC simd_float(simd_float16 __x) { return __x; } +static simd_float2 SIMD_CFUNC simd_float(simd_long2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_long3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_long4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_long8 __x) { return __builtin_convertvector(__x,simd_float8); } +static simd_float2 SIMD_CFUNC simd_float(simd_ulong2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_ulong3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_ulong4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_ulong8 __x) { return __builtin_convertvector(__x,simd_float8); } +static simd_float2 SIMD_CFUNC simd_float(simd_double2 __x) { return __builtin_convertvector(__x,simd_float2); } +static simd_float3 SIMD_CFUNC simd_float(simd_double3 __x) { return __builtin_convertvector(__x,simd_float3); } +static simd_float4 SIMD_CFUNC simd_float(simd_double4 __x) { return __builtin_convertvector(__x,simd_float4); } +static simd_float8 SIMD_CFUNC simd_float(simd_double8 __x) { return __builtin_convertvector(__x,simd_float8); } + + +static simd_long2 SIMD_CFUNC simd_long(simd_char2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_char3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_char4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_char8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_uchar2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_uchar3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_uchar4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_uchar8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_short2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_short3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_short4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_short8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_ushort2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_ushort3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_ushort4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_ushort8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_int2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_int3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_int4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_int8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_uint2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_uint3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_uint4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_uint8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_float2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_float3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_float4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_float8 __x) { return __builtin_convertvector(__x,simd_long8); } +static simd_long2 SIMD_CFUNC simd_long(simd_long2 __x) { return __x; } +static simd_long3 SIMD_CFUNC simd_long(simd_long3 __x) { return __x; } +static simd_long4 SIMD_CFUNC simd_long(simd_long4 __x) { return __x; } +static simd_long8 SIMD_CFUNC simd_long(simd_long8 __x) { return __x; } +static simd_long2 SIMD_CFUNC simd_long(simd_ulong2 __x) { return (simd_long2)__x; } +static simd_long3 SIMD_CFUNC simd_long(simd_ulong3 __x) { return (simd_long3)__x; } +static simd_long4 SIMD_CFUNC simd_long(simd_ulong4 __x) { return (simd_long4)__x; } +static simd_long8 SIMD_CFUNC simd_long(simd_ulong8 __x) { return (simd_long8)__x; } +static simd_long2 SIMD_CFUNC simd_long(simd_double2 __x) { return __builtin_convertvector(__x,simd_long2); } +static simd_long3 SIMD_CFUNC simd_long(simd_double3 __x) { return __builtin_convertvector(__x,simd_long3); } +static simd_long4 SIMD_CFUNC simd_long(simd_double4 __x) { return __builtin_convertvector(__x,simd_long4); } +static simd_long8 SIMD_CFUNC simd_long(simd_double8 __x) { return __builtin_convertvector(__x,simd_long8); } + +static simd_long2 SIMD_CFUNC simd_long_sat(simd_char2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_char3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_char4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_char8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_short2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_short3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_short4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_short8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_int2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_int3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_int4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_int8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_float2 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63f)), 0x7fffffffffffffff, simd_long(__x >= 0x1.0p63f)); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_float3 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63f)), 0x7fffffffffffffff, simd_long(__x >= 0x1.0p63f)); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_float4 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63f)), 0x7fffffffffffffff, simd_long(__x >= 0x1.0p63f)); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_float8 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63f)), 0x7fffffffffffffff, simd_long(__x >= 0x1.0p63f)); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_long2 __x) { return __x; } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_long3 __x) { return __x; } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_long4 __x) { return __x; } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_long8 __x) { return __x; } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_double2 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_double3 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_double4 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_double8 __x) { return simd_bitselect(simd_long(simd_max(__x,-0x1.0p63)), 0x7fffffffffffffff, __x >= 0x1.0p63); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_uchar2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_uchar3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_uchar4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_uchar8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_ushort2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_ushort3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_ushort4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_ushort8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_uint2 __x) { return simd_long(__x); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_uint3 __x) { return simd_long(__x); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_uint4 __x) { return simd_long(__x); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_uint8 __x) { return simd_long(__x); } +static simd_long2 SIMD_CFUNC simd_long_sat(simd_ulong2 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); } +static simd_long3 SIMD_CFUNC simd_long_sat(simd_ulong3 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); } +static simd_long4 SIMD_CFUNC simd_long_sat(simd_ulong4 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); } +static simd_long8 SIMD_CFUNC simd_long_sat(simd_ulong8 __x) { return simd_long(simd_min(__x,0x7fffffffffffffff)); } + +static simd_long2 SIMD_CFUNC simd_long_rte(simd_double2 __x) { +#if defined __AVX512F__ + return _mm_cvtpd_epi64(__x); +#elif defined __arm64__ + return vcvtnq_s64_f64(__x); +#else + simd_double2 magic = __tg_copysign(0x1.0p52, __x); + simd_long2 x_is_small = __tg_fabs(__x) < 0x1.0p52; + return __builtin_convertvector(simd_bitselect(__x, (__x + magic) - magic, x_is_small & 0x7fffffffffffffff), simd_long2); +#endif +} + +static simd_long3 SIMD_CFUNC simd_long_rte(simd_double3 __x) { + return simd_make_long3(simd_long_rte(simd_make_double4_undef(__x))); +} + +static simd_long4 SIMD_CFUNC simd_long_rte(simd_double4 __x) { +#if defined __AVX512F__ + return _mm256_cvtpd_epi64(__x); +#else + return simd_make_long4(simd_long_rte(__x.lo), simd_long_rte(__x.hi)); +#endif +} + +static simd_long8 SIMD_CFUNC simd_long_rte(simd_double8 __x) { +#if defined __AVX512F__ + return _mm512_cvt_roundpd_epi64(__x, _MM_FROUND_RINT); +#else + return simd_make_long8(simd_long_rte(__x.lo), simd_long_rte(__x.hi)); +#endif +} + + +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_char2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_char3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_char4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_char8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uchar2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uchar3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uchar4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uchar8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_short2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_short3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_short4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_short8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ushort2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ushort3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ushort4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ushort8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_int2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_int3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_int4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_int8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_uint2 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_uint3 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_uint4 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_uint8 __x) { return simd_ulong(simd_long(__x)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_float2 __x) { simd_int2 __big = __x >= 0x1.0p63f; return simd_ulong(simd_long(__x - simd_bitselect((simd_float2)0,0x1.0p63f,__big))) + simd_bitselect((simd_ulong2)0,0x8000000000000000,simd_long(__big)); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_float3 __x) { simd_int3 __big = __x >= 0x1.0p63f; return simd_ulong(simd_long(__x - simd_bitselect((simd_float3)0,0x1.0p63f,__big))) + simd_bitselect((simd_ulong3)0,0x8000000000000000,simd_long(__big)); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_float4 __x) { simd_int4 __big = __x >= 0x1.0p63f; return simd_ulong(simd_long(__x - simd_bitselect((simd_float4)0,0x1.0p63f,__big))) + simd_bitselect((simd_ulong4)0,0x8000000000000000,simd_long(__big)); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_float8 __x) { simd_int8 __big = __x >= 0x1.0p63f; return simd_ulong(simd_long(__x - simd_bitselect((simd_float8)0,0x1.0p63f,__big))) + simd_bitselect((simd_ulong8)0,0x8000000000000000,simd_long(__big)); } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_long2 __x) { return (simd_ulong2)__x; } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_long3 __x) { return (simd_ulong3)__x; } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_long4 __x) { return (simd_ulong4)__x; } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_long8 __x) { return (simd_ulong8)__x; } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_ulong2 __x) { return __x; } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_ulong3 __x) { return __x; } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_ulong4 __x) { return __x; } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_ulong8 __x) { return __x; } +static simd_ulong2 SIMD_CFUNC simd_ulong(simd_double2 __x) { simd_long2 __big = __x >= 0x1.0p63; return simd_ulong(simd_long(__x - simd_bitselect((simd_double2)0,0x1.0p63,__big))) + simd_bitselect((simd_ulong2)0,0x8000000000000000,__big); } +static simd_ulong3 SIMD_CFUNC simd_ulong(simd_double3 __x) { simd_long3 __big = __x >= 0x1.0p63; return simd_ulong(simd_long(__x - simd_bitselect((simd_double3)0,0x1.0p63,__big))) + simd_bitselect((simd_ulong3)0,0x8000000000000000,__big); } +static simd_ulong4 SIMD_CFUNC simd_ulong(simd_double4 __x) { simd_long4 __big = __x >= 0x1.0p63; return simd_ulong(simd_long(__x - simd_bitselect((simd_double4)0,0x1.0p63,__big))) + simd_bitselect((simd_ulong4)0,0x8000000000000000,__big); } +static simd_ulong8 SIMD_CFUNC simd_ulong(simd_double8 __x) { simd_long8 __big = __x >= 0x1.0p63; return simd_ulong(simd_long(__x - simd_bitselect((simd_double8)0,0x1.0p63,__big))) + simd_bitselect((simd_ulong8)0,0x8000000000000000,__big); } + +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_char2 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_char3 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_char4 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_char8 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_short2 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_short3 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_short4 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_short8 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_int2 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_int3 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_int4 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_int8 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_float2 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.f)), 0xffffffffffffffff, simd_long(__x >= 0x1.0p64f)); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_float3 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.f)), 0xffffffffffffffff, simd_long(__x >= 0x1.0p64f)); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_float4 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.f)), 0xffffffffffffffff, simd_long(__x >= 0x1.0p64f)); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_float8 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.f)), 0xffffffffffffffff, simd_long(__x >= 0x1.0p64f)); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_long2 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_long3 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_long4 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_long8 __x) { return simd_ulong(simd_max(__x,0)); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_double2 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_double3 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_double4 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_double8 __x) { return simd_bitselect(simd_ulong(simd_max(__x,0.0)), 0xffffffffffffffff, __x >= 0x1.0p64); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uchar2 __x) { return simd_ulong(__x); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uchar3 __x) { return simd_ulong(__x); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uchar4 __x) { return simd_ulong(__x); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uchar8 __x) { return simd_ulong(__x); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ushort2 __x) { return simd_ulong(__x); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ushort3 __x) { return simd_ulong(__x); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ushort4 __x) { return simd_ulong(__x); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ushort8 __x) { return simd_ulong(__x); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_uint2 __x) { return simd_ulong(__x); } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_uint3 __x) { return simd_ulong(__x); } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_uint4 __x) { return simd_ulong(__x); } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_uint8 __x) { return simd_ulong(__x); } +static simd_ulong2 SIMD_CFUNC simd_ulong_sat(simd_ulong2 __x) { return __x; } +static simd_ulong3 SIMD_CFUNC simd_ulong_sat(simd_ulong3 __x) { return __x; } +static simd_ulong4 SIMD_CFUNC simd_ulong_sat(simd_ulong4 __x) { return __x; } +static simd_ulong8 SIMD_CFUNC simd_ulong_sat(simd_ulong8 __x) { return __x; } + + +static simd_double2 SIMD_CFUNC simd_double(simd_char2 __x) { return simd_double(simd_int(__x)); } +static simd_double3 SIMD_CFUNC simd_double(simd_char3 __x) { return simd_double(simd_int(__x)); } +static simd_double4 SIMD_CFUNC simd_double(simd_char4 __x) { return simd_double(simd_int(__x)); } +static simd_double8 SIMD_CFUNC simd_double(simd_char8 __x) { return simd_double(simd_int(__x)); } +static simd_double2 SIMD_CFUNC simd_double(simd_uchar2 __x) { return simd_double(simd_int(__x)); } +static simd_double3 SIMD_CFUNC simd_double(simd_uchar3 __x) { return simd_double(simd_int(__x)); } +static simd_double4 SIMD_CFUNC simd_double(simd_uchar4 __x) { return simd_double(simd_int(__x)); } +static simd_double8 SIMD_CFUNC simd_double(simd_uchar8 __x) { return simd_double(simd_int(__x)); } +static simd_double2 SIMD_CFUNC simd_double(simd_short2 __x) { return simd_double(simd_int(__x)); } +static simd_double3 SIMD_CFUNC simd_double(simd_short3 __x) { return simd_double(simd_int(__x)); } +static simd_double4 SIMD_CFUNC simd_double(simd_short4 __x) { return simd_double(simd_int(__x)); } +static simd_double8 SIMD_CFUNC simd_double(simd_short8 __x) { return simd_double(simd_int(__x)); } +static simd_double2 SIMD_CFUNC simd_double(simd_ushort2 __x) { return simd_double(simd_int(__x)); } +static simd_double3 SIMD_CFUNC simd_double(simd_ushort3 __x) { return simd_double(simd_int(__x)); } +static simd_double4 SIMD_CFUNC simd_double(simd_ushort4 __x) { return simd_double(simd_int(__x)); } +static simd_double8 SIMD_CFUNC simd_double(simd_ushort8 __x) { return simd_double(simd_int(__x)); } +static simd_double2 SIMD_CFUNC simd_double(simd_int2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_int3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_int4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_int8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_uint2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_uint3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_uint4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_uint8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_float2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_float3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_float4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_float8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_long2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_long3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_long4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_long8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_ulong2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_ulong3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_ulong4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_ulong8 __x) { return __builtin_convertvector(__x, simd_double8); } +static simd_double2 SIMD_CFUNC simd_double(simd_double2 __x) { return __builtin_convertvector(__x, simd_double2); } +static simd_double3 SIMD_CFUNC simd_double(simd_double3 __x) { return __builtin_convertvector(__x, simd_double3); } +static simd_double4 SIMD_CFUNC simd_double(simd_double4 __x) { return __builtin_convertvector(__x, simd_double4); } +static simd_double8 SIMD_CFUNC simd_double(simd_double8 __x) { return __builtin_convertvector(__x, simd_double8); } + + +#ifdef __cplusplus +} +#endif +#endif // SIMD_COMPILER_HAS_REQUIRED_FEATURES +#endif // __SIMD_CONVERSION_HEADER__ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/simd/logic.h b/lib/libc/include/aarch64-macos-gnu/simd/logic.h new file mode 100644 index 0000000000..fdefcb632d --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/simd/logic.h @@ -0,0 +1,1315 @@ +/*! @header + * The interfaces declared in this header provide logical and bitwise + * operations on vectors. Some of these function operate elementwise, + * and some produce a scalar result that depends on all lanes of the input. + * + * For functions returning a boolean value, the return type in C and + * Objective-C is _Bool; for C++ it is bool. + * + * Function Result + * ------------------------------------------------------------------ + * simd_all(comparison) True if and only if the comparison is true + * in every vector lane. e.g.: + * + * if (simd_all(x == 0.0f)) { + * // executed if every lane of x + * // contains zero. + * } + * + * The precise function of simd_all is to + * return the high-order bit of the result + * of a horizontal bitwise AND of all vector + * lanes. + * + * simd_any(comparison) True if and only if the comparison is true + * in at least one vector lane. e.g.: + * + * if (simd_any(x < 0.0f)) { + * // executed if any lane of x + * // contains a negative value. + * } + * + * The precise function of simd_all is to + * return the high-order bit of the result + * of a horizontal bitwise OR of all vector + * lanes. + * + * simd_select(x,y,mask) For each lane in the result, selects the + * corresponding element of x if the high- + * order bit of the corresponding element of + * mask is 0, and the corresponding element + * of y otherwise. + * + * simd_bitselect(x,y,mask) For each bit in the result, selects the + * corresponding bit of x if the corresponding + * bit of mask is clear, and the corresponding + * of y otherwise. + * + * In C++, these functions are available under the simd:: namespace: + * + * C++ Function Equivalent C Function + * -------------------------------------------------------------------- + * simd::all(comparison) simd_all(comparison) + * simd::any(comparison) simd_any(comparison) + * simd::select(x,y,mask) simd_select(x,y,mask) + * simd::bitselect(x,y,mask) simd_bitselect(x,y,mask) + * + * @copyright 2014-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_LOGIC_HEADER +#define SIMD_LOGIC_HEADER + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char32 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_char64 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar32 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar64 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_short32 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort32 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_int16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_uint16 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_long2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_long3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_long4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_long8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong2 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong3 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong4 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong8 x); +/*! @abstract True if and only if the high-order bit of any lane of the + * vector is set. + * @discussion Deprecated. Use simd_any instead. */ +#define vector_any simd_any + +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char32 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_char64 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar32 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar64 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_short32 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort32 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_int16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_uint16 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_long2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_long3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_long4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_long8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong2 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong3 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong4 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. */ +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong8 x); +/*! @abstract True if and only if the high-order bit of every lane of the + * vector is set. + * @discussion Deprecated. Use simd_all instead. */ +#define vector_all simd_all + +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float2 simd_select(simd_float2 x, simd_float2 y, simd_int2 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float3 simd_select(simd_float3 x, simd_float3 y, simd_int3 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float4 simd_select(simd_float4 x, simd_float4 y, simd_int4 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float8 simd_select(simd_float8 x, simd_float8 y, simd_int8 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_float16 simd_select(simd_float16 x, simd_float16 y, simd_int16 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_double2 simd_select(simd_double2 x, simd_double2 y, simd_long2 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_double3 simd_select(simd_double3 x, simd_double3 y, simd_long3 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_double4 simd_select(simd_double4 x, simd_double4 y, simd_long4 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ +static inline SIMD_CFUNC simd_double8 simd_select(simd_double8 x, simd_double8 y, simd_long8 mask); +/*! @abstract For each lane in the result, selects the corresponding element + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. + * @discussion Deprecated. Use simd_select instead. */ +#define vector_select simd_select + +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char2 simd_bitselect(simd_char2 x, simd_char2 y, simd_char2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char3 simd_bitselect(simd_char3 x, simd_char3 y, simd_char3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char4 simd_bitselect(simd_char4 x, simd_char4 y, simd_char4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char8 simd_bitselect(simd_char8 x, simd_char8 y, simd_char8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char16 simd_bitselect(simd_char16 x, simd_char16 y, simd_char16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char32 simd_bitselect(simd_char32 x, simd_char32 y, simd_char32 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_char64 simd_bitselect(simd_char64 x, simd_char64 y, simd_char64 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar2 simd_bitselect(simd_uchar2 x, simd_uchar2 y, simd_char2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar3 simd_bitselect(simd_uchar3 x, simd_uchar3 y, simd_char3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar4 simd_bitselect(simd_uchar4 x, simd_uchar4 y, simd_char4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar8 simd_bitselect(simd_uchar8 x, simd_uchar8 y, simd_char8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar16 simd_bitselect(simd_uchar16 x, simd_uchar16 y, simd_char16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar32 simd_bitselect(simd_uchar32 x, simd_uchar32 y, simd_char32 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uchar64 simd_bitselect(simd_uchar64 x, simd_uchar64 y, simd_char64 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short2 simd_bitselect(simd_short2 x, simd_short2 y, simd_short2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short3 simd_bitselect(simd_short3 x, simd_short3 y, simd_short3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short4 simd_bitselect(simd_short4 x, simd_short4 y, simd_short4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short8 simd_bitselect(simd_short8 x, simd_short8 y, simd_short8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short16 simd_bitselect(simd_short16 x, simd_short16 y, simd_short16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_short32 simd_bitselect(simd_short32 x, simd_short32 y, simd_short32 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort2 simd_bitselect(simd_ushort2 x, simd_ushort2 y, simd_short2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort3 simd_bitselect(simd_ushort3 x, simd_ushort3 y, simd_short3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort4 simd_bitselect(simd_ushort4 x, simd_ushort4 y, simd_short4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort8 simd_bitselect(simd_ushort8 x, simd_ushort8 y, simd_short8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort16 simd_bitselect(simd_ushort16 x, simd_ushort16 y, simd_short16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ushort32 simd_bitselect(simd_ushort32 x, simd_ushort32 y, simd_short32 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int2 simd_bitselect(simd_int2 x, simd_int2 y, simd_int2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int3 simd_bitselect(simd_int3 x, simd_int3 y, simd_int3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int4 simd_bitselect(simd_int4 x, simd_int4 y, simd_int4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int8 simd_bitselect(simd_int8 x, simd_int8 y, simd_int8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_int16 simd_bitselect(simd_int16 x, simd_int16 y, simd_int16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint2 simd_bitselect(simd_uint2 x, simd_uint2 y, simd_int2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint3 simd_bitselect(simd_uint3 x, simd_uint3 y, simd_int3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint4 simd_bitselect(simd_uint4 x, simd_uint4 y, simd_int4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint8 simd_bitselect(simd_uint8 x, simd_uint8 y, simd_int8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_uint16 simd_bitselect(simd_uint16 x, simd_uint16 y, simd_int16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float2 simd_bitselect(simd_float2 x, simd_float2 y, simd_int2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float3 simd_bitselect(simd_float3 x, simd_float3 y, simd_int3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float4 simd_bitselect(simd_float4 x, simd_float4 y, simd_int4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float8 simd_bitselect(simd_float8 x, simd_float8 y, simd_int8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_float16 simd_bitselect(simd_float16 x, simd_float16 y, simd_int16 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_long2 simd_bitselect(simd_long2 x, simd_long2 y, simd_long2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_long3 simd_bitselect(simd_long3 x, simd_long3 y, simd_long3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_long4 simd_bitselect(simd_long4 x, simd_long4 y, simd_long4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_long8 simd_bitselect(simd_long8 x, simd_long8 y, simd_long8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ulong2 simd_bitselect(simd_ulong2 x, simd_ulong2 y, simd_long2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ulong3 simd_bitselect(simd_ulong3 x, simd_ulong3 y, simd_long3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ulong4 simd_bitselect(simd_ulong4 x, simd_ulong4 y, simd_long4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_ulong8 simd_bitselect(simd_ulong8 x, simd_ulong8 y, simd_long8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_double2 simd_bitselect(simd_double2 x, simd_double2 y, simd_long2 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_double3 simd_bitselect(simd_double3 x, simd_double3 y, simd_long3 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_double4 simd_bitselect(simd_double4 x, simd_double4 y, simd_long4 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ +static inline SIMD_CFUNC simd_double8 simd_bitselect(simd_double8 x, simd_double8 y, simd_long8 mask); +/*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. + * @discussion Deprecated. Use simd_bitselect instead. */ +#define vector_bitselect simd_bitselect + +#ifdef __cplusplus +} /* extern "C" */ + +namespace simd { + /*! @abstract True if and only if the high-order bit of every lane is set. */ + template static SIMD_CPPFUNC simd_bool all(const inttypeN predicate) { return ::simd_all(predicate); } + /*! @abstract True if and only if the high-order bit of any lane is set. */ + template static SIMD_CPPFUNC simd_bool any(const inttypeN predicate) { return ::simd_any(predicate); } + /*! @abstract Each lane of the result is selected from the corresponding lane + * of x or y according to whether the high-order bit of the corresponding + * lane of mask is 0 or 1, respectively. */ + template static SIMD_CPPFUNC fptypeN select(const fptypeN x, const fptypeN y, const inttypeN predicate) { return ::simd_select(x,y,predicate); } + /*! @abstract For each bit in the result, selects the corresponding bit of x + * or y according to whether the corresponding bit of mask is 0 or 1, + * respectively. */ + template static SIMD_CPPFUNC typeN bitselect(const typeN x, const typeN y, const inttypeN mask) { return ::simd_bitselect(x,y,mask); } +} + +extern "C" { +#endif /* __cplusplus */ + +#pragma mark - Implementations + +static inline SIMD_CFUNC simd_bool simd_any(simd_char2 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x3); +#elif defined __arm64__ + return simd_any(x.xyxy); +#else + union { uint16_t i; simd_char2 v; } u = { .v = x }; + return (u.i & 0x8080); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char3 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x7); +#elif defined __arm64__ + return simd_any(x.xyzz); +#else + union { uint32_t i; simd_char3 v; } u = { .v = x }; + return (u.i & 0x808080); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char4 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xf); +#elif defined __arm64__ + return simd_any(x.xyzwxyzw); +#else + union { uint32_t i; simd_char4 v; } u = { .v = x }; + return (u.i & 0x80808080); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char8 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xff); +#elif defined __arm64__ + return vmaxv_u8(x) & 0x80; +#else + union { uint64_t i; simd_char8 v; } u = { .v = x }; + return (u.i & 0x8080808080808080); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char16 x) { +#if defined __SSE2__ + return _mm_movemask_epi8((__m128i)x); +#elif defined __arm64__ + return vmaxvq_u8(x) & 0x80; +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char32 x) { +#if defined __AVX2__ + return _mm256_movemask_epi8(x); +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_char64 x) { + return simd_any(x.lo | x.hi); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar2 x) { + return simd_any((simd_char2)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar3 x) { + return simd_any((simd_char3)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar4 x) { + return simd_any((simd_char4)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar8 x) { + return simd_any((simd_char8)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar16 x) { + return simd_any((simd_char16)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar32 x) { + return simd_any((simd_char32)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uchar64 x) { + return simd_any((simd_char64)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short2 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xa); +#elif defined __arm64__ + return simd_any(x.xyxy); +#else + union { uint32_t i; simd_short2 v; } u = { .v = x }; + return (u.i & 0x80008000); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short3 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0x2a); +#elif defined __arm64__ + return simd_any(x.xyzz); +#else + union { uint64_t i; simd_short3 v; } u = { .v = x }; + return (u.i & 0x800080008000); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short4 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xaa); +#elif defined __arm64__ + return vmaxv_u16(x) & 0x8000; +#else + union { uint64_t i; simd_short4 v; } u = { .v = x }; + return (u.i & 0x8000800080008000); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short8 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)x) & 0xaaaa); +#elif defined __arm64__ + return vmaxvq_u16(x) & 0x8000; +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short16 x) { +#if defined __AVX2__ + return (_mm256_movemask_epi8(x) & 0xaaaaaaaa); +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_short32 x) { + return simd_any(x.lo | x.hi); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort2 x) { + return simd_any((simd_short2)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort3 x) { + return simd_any((simd_short3)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort4 x) { + return simd_any((simd_short4)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort8 x) { + return simd_any((simd_short8)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort16 x) { + return simd_any((simd_short16)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ushort32 x) { + return simd_any((simd_short32)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int2 x) { +#if defined __SSE2__ + return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x3); +#elif defined __arm64__ + return vmaxv_u32(x) & 0x80000000; +#else + union { uint64_t i; simd_int2 v; } u = { .v = x }; + return (u.i & 0x8000000080000000); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int3 x) { +#if defined __SSE2__ + return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x7); +#elif defined __arm64__ + return simd_any(x.xyzz); +#else + return (x.x | x.y | x.z) & 0x80000000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int4 x) { +#if defined __SSE2__ + return _mm_movemask_ps((__m128)x); +#elif defined __arm64__ + return vmaxvq_u32(x) & 0x80000000; +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int8 x) { +#if defined __AVX__ + return _mm256_movemask_ps(x); +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_int16 x) { + return simd_any(x.lo | x.hi); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint2 x) { + return simd_any((simd_int2)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint3 x) { + return simd_any((simd_int3)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint4 x) { + return simd_any((simd_int4)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint8 x) { + return simd_any((simd_int8)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_uint16 x) { + return simd_any((simd_int16)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_long2 x) { +#if defined __SSE2__ + return _mm_movemask_pd((__m128d)x); +#elif defined __arm64__ + return (x.x | x.y) & 0x8000000000000000U; +#else + return (x.x | x.y) & 0x8000000000000000U; +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_long3 x) { +#if defined __AVX__ + return (_mm256_movemask_pd(simd_make_long4_undef(x)) & 0x7); +#else + return (x.x | x.y | x.z) & 0x8000000000000000U; +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_long4 x) { +#if defined __AVX__ + return _mm256_movemask_pd(x); +#else + return simd_any(x.lo | x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_any(simd_long8 x) { + return simd_any(x.lo | x.hi); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong2 x) { + return simd_any((simd_long2)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong3 x) { + return simd_any((simd_long3)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong4 x) { + return simd_any((simd_long4)x); +} +static inline SIMD_CFUNC simd_bool simd_any(simd_ulong8 x) { + return simd_any((simd_long8)x); +} + +static inline SIMD_CFUNC simd_bool simd_all(simd_char2 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x3) == 0x3; +#elif defined __arm64__ + return simd_all(x.xyxy); +#else + union { uint16_t i; simd_char2 v; } u = { .v = x }; + return (u.i & 0x8080) == 0x8080; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char3 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0x7) == 0x7; +#elif defined __arm64__ + return simd_all(x.xyzz); +#else + union { uint32_t i; simd_char3 v; } u = { .v = x }; + return (u.i & 0x808080) == 0x808080; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char4 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xf) == 0xf; +#elif defined __arm64__ + return simd_all(x.xyzwxyzw); +#else + union { uint32_t i; simd_char4 v; } u = { .v = x }; + return (u.i & 0x80808080) == 0x80808080; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char8 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_char16_undef(x)) & 0xff) == 0xff; +#elif defined __arm64__ + return vminv_u8(x) & 0x80; +#else + union { uint64_t i; simd_char8 v; } u = { .v = x }; + return (u.i & 0x8080808080808080) == 0x8080808080808080; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char16 x) { +#if defined __SSE2__ + return _mm_movemask_epi8((__m128i)x) == 0xffff; +#elif defined __arm64__ + return vminvq_u8(x) & 0x80; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char32 x) { +#if defined __AVX2__ + return _mm256_movemask_epi8(x) == 0xffffffff; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_char64 x) { + return simd_all(x.lo & x.hi); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar2 x) { + return simd_all((simd_char2)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar3 x) { + return simd_all((simd_char3)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar4 x) { + return simd_all((simd_char4)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar8 x) { + return simd_all((simd_char8)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar16 x) { + return simd_all((simd_char16)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar32 x) { + return simd_all((simd_char32)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uchar64 x) { + return simd_all((simd_char64)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short2 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xa) == 0xa; +#elif defined __arm64__ + return simd_all(x.xyxy); +#else + union { uint32_t i; simd_short2 v; } u = { .v = x }; + return (u.i & 0x80008000) == 0x80008000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short3 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0x2a) == 0x2a; +#elif defined __arm64__ + return simd_all(x.xyzz); +#else + union { uint64_t i; simd_short3 v; } u = { .v = x }; + return (u.i & 0x800080008000) == 0x800080008000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short4 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)simd_make_short8_undef(x)) & 0xaa) == 0xaa; +#elif defined __arm64__ + return vminv_u16(x) & 0x8000; +#else + union { uint64_t i; simd_short4 v; } u = { .v = x }; + return (u.i & 0x8000800080008000) == 0x8000800080008000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short8 x) { +#if defined __SSE2__ + return (_mm_movemask_epi8((__m128i)x) & 0xaaaa) == 0xaaaa; +#elif defined __arm64__ + return vminvq_u16(x) & 0x8000; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short16 x) { +#if defined __AVX2__ + return (_mm256_movemask_epi8(x) & 0xaaaaaaaa) == 0xaaaaaaaa; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_short32 x) { + return simd_all(x.lo & x.hi); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort2 x) { + return simd_all((simd_short2)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort3 x) { + return simd_all((simd_short3)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort4 x) { + return simd_all((simd_short4)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort8 x) { + return simd_all((simd_short8)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort16 x) { + return simd_all((simd_short16)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ushort32 x) { + return simd_all((simd_short32)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int2 x) { +#if defined __SSE2__ + return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x3) == 0x3; +#elif defined __arm64__ + return vminv_u32(x) & 0x80000000; +#else + union { uint64_t i; simd_int2 v; } u = { .v = x }; + return (u.i & 0x8000000080000000) == 0x8000000080000000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int3 x) { +#if defined __SSE2__ + return (_mm_movemask_ps((__m128)simd_make_int4_undef(x)) & 0x7) == 0x7; +#elif defined __arm64__ + return simd_all(x.xyzz); +#else + return (x.x & x.y & x.z) & 0x80000000; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int4 x) { +#if defined __SSE2__ + return _mm_movemask_ps((__m128)x) == 0xf; +#elif defined __arm64__ + return vminvq_u32(x) & 0x80000000; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int8 x) { +#if defined __AVX__ + return _mm256_movemask_ps(x) == 0xff; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_int16 x) { + return simd_all(x.lo & x.hi); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint2 x) { + return simd_all((simd_int2)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint3 x) { + return simd_all((simd_int3)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint4 x) { + return simd_all((simd_int4)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint8 x) { + return simd_all((simd_int8)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_uint16 x) { + return simd_all((simd_int16)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_long2 x) { +#if defined __SSE2__ + return _mm_movemask_pd((__m128d)x) == 0x3; +#elif defined __arm64__ + return (x.x & x.y) & 0x8000000000000000U; +#else + return (x.x & x.y) & 0x8000000000000000U; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_long3 x) { +#if defined __AVX__ + return (_mm256_movemask_pd(simd_make_long4_undef(x)) & 0x7) == 0x7; +#else + return (x.x & x.y & x.z) & 0x8000000000000000U; +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_long4 x) { +#if defined __AVX__ + return _mm256_movemask_pd(x) == 0xf; +#else + return simd_all(x.lo & x.hi); +#endif +} +static inline SIMD_CFUNC simd_bool simd_all(simd_long8 x) { + return simd_all(x.lo & x.hi); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong2 x) { + return simd_all((simd_long2)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong3 x) { + return simd_all((simd_long3)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong4 x) { + return simd_all((simd_long4)x); +} +static inline SIMD_CFUNC simd_bool simd_all(simd_ulong8 x) { + return simd_all((simd_long8)x); +} + +static inline SIMD_CFUNC simd_float2 simd_select(simd_float2 x, simd_float2 y, simd_int2 mask) { + return simd_make_float2(simd_select(simd_make_float4_undef(x), simd_make_float4_undef(y), simd_make_int4_undef(mask))); +} +static inline SIMD_CFUNC simd_float3 simd_select(simd_float3 x, simd_float3 y, simd_int3 mask) { + return simd_make_float3(simd_select(simd_make_float4_undef(x), simd_make_float4_undef(y), simd_make_int4_undef(mask))); +} +static inline SIMD_CFUNC simd_float4 simd_select(simd_float4 x, simd_float4 y, simd_int4 mask) { +#if defined __SSE4_1__ + return _mm_blendv_ps(x, y, (__m128)mask); +#else + return simd_bitselect(x, y, mask >> 31); +#endif +} +static inline SIMD_CFUNC simd_float8 simd_select(simd_float8 x, simd_float8 y, simd_int8 mask) { +#if defined __AVX__ + return _mm256_blendv_ps(x, y, mask); +#else + return simd_bitselect(x, y, mask >> 31); +#endif +} +static inline SIMD_CFUNC simd_float16 simd_select(simd_float16 x, simd_float16 y, simd_int16 mask) { + return simd_bitselect(x, y, mask >> 31); +} +static inline SIMD_CFUNC simd_double2 simd_select(simd_double2 x, simd_double2 y, simd_long2 mask) { +#if defined __SSE4_1__ + return _mm_blendv_pd(x, y, (__m128d)mask); +#else + return simd_bitselect(x, y, mask >> 63); +#endif +} +static inline SIMD_CFUNC simd_double3 simd_select(simd_double3 x, simd_double3 y, simd_long3 mask) { + return simd_make_double3(simd_select(simd_make_double4_undef(x), simd_make_double4_undef(y), simd_make_long4_undef(mask))); +} +static inline SIMD_CFUNC simd_double4 simd_select(simd_double4 x, simd_double4 y, simd_long4 mask) { +#if defined __AVX__ + return _mm256_blendv_pd(x, y, mask); +#else + return simd_bitselect(x, y, mask >> 63); +#endif +} +static inline SIMD_CFUNC simd_double8 simd_select(simd_double8 x, simd_double8 y, simd_long8 mask) { + return simd_bitselect(x, y, mask >> 63); +} + +static inline SIMD_CFUNC simd_char2 simd_bitselect(simd_char2 x, simd_char2 y, simd_char2 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char3 simd_bitselect(simd_char3 x, simd_char3 y, simd_char3 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char4 simd_bitselect(simd_char4 x, simd_char4 y, simd_char4 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char8 simd_bitselect(simd_char8 x, simd_char8 y, simd_char8 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char16 simd_bitselect(simd_char16 x, simd_char16 y, simd_char16 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char32 simd_bitselect(simd_char32 x, simd_char32 y, simd_char32 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_char64 simd_bitselect(simd_char64 x, simd_char64 y, simd_char64 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_uchar2 simd_bitselect(simd_uchar2 x, simd_uchar2 y, simd_char2 mask) { + return (simd_uchar2)simd_bitselect((simd_char2)x, (simd_char2)y, mask); +} +static inline SIMD_CFUNC simd_uchar3 simd_bitselect(simd_uchar3 x, simd_uchar3 y, simd_char3 mask) { + return (simd_uchar3)simd_bitselect((simd_char3)x, (simd_char3)y, mask); +} +static inline SIMD_CFUNC simd_uchar4 simd_bitselect(simd_uchar4 x, simd_uchar4 y, simd_char4 mask) { + return (simd_uchar4)simd_bitselect((simd_char4)x, (simd_char4)y, mask); +} +static inline SIMD_CFUNC simd_uchar8 simd_bitselect(simd_uchar8 x, simd_uchar8 y, simd_char8 mask) { + return (simd_uchar8)simd_bitselect((simd_char8)x, (simd_char8)y, mask); +} +static inline SIMD_CFUNC simd_uchar16 simd_bitselect(simd_uchar16 x, simd_uchar16 y, simd_char16 mask) { + return (simd_uchar16)simd_bitselect((simd_char16)x, (simd_char16)y, mask); +} +static inline SIMD_CFUNC simd_uchar32 simd_bitselect(simd_uchar32 x, simd_uchar32 y, simd_char32 mask) { + return (simd_uchar32)simd_bitselect((simd_char32)x, (simd_char32)y, mask); +} +static inline SIMD_CFUNC simd_uchar64 simd_bitselect(simd_uchar64 x, simd_uchar64 y, simd_char64 mask) { + return (simd_uchar64)simd_bitselect((simd_char64)x, (simd_char64)y, mask); +} +static inline SIMD_CFUNC simd_short2 simd_bitselect(simd_short2 x, simd_short2 y, simd_short2 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short3 simd_bitselect(simd_short3 x, simd_short3 y, simd_short3 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short4 simd_bitselect(simd_short4 x, simd_short4 y, simd_short4 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short8 simd_bitselect(simd_short8 x, simd_short8 y, simd_short8 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short16 simd_bitselect(simd_short16 x, simd_short16 y, simd_short16 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_short32 simd_bitselect(simd_short32 x, simd_short32 y, simd_short32 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_ushort2 simd_bitselect(simd_ushort2 x, simd_ushort2 y, simd_short2 mask) { + return (simd_ushort2)simd_bitselect((simd_short2)x, (simd_short2)y, mask); +} +static inline SIMD_CFUNC simd_ushort3 simd_bitselect(simd_ushort3 x, simd_ushort3 y, simd_short3 mask) { + return (simd_ushort3)simd_bitselect((simd_short3)x, (simd_short3)y, mask); +} +static inline SIMD_CFUNC simd_ushort4 simd_bitselect(simd_ushort4 x, simd_ushort4 y, simd_short4 mask) { + return (simd_ushort4)simd_bitselect((simd_short4)x, (simd_short4)y, mask); +} +static inline SIMD_CFUNC simd_ushort8 simd_bitselect(simd_ushort8 x, simd_ushort8 y, simd_short8 mask) { + return (simd_ushort8)simd_bitselect((simd_short8)x, (simd_short8)y, mask); +} +static inline SIMD_CFUNC simd_ushort16 simd_bitselect(simd_ushort16 x, simd_ushort16 y, simd_short16 mask) { + return (simd_ushort16)simd_bitselect((simd_short16)x, (simd_short16)y, mask); +} +static inline SIMD_CFUNC simd_ushort32 simd_bitselect(simd_ushort32 x, simd_ushort32 y, simd_short32 mask) { + return (simd_ushort32)simd_bitselect((simd_short32)x, (simd_short32)y, mask); +} +static inline SIMD_CFUNC simd_int2 simd_bitselect(simd_int2 x, simd_int2 y, simd_int2 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_int3 simd_bitselect(simd_int3 x, simd_int3 y, simd_int3 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_int4 simd_bitselect(simd_int4 x, simd_int4 y, simd_int4 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_int8 simd_bitselect(simd_int8 x, simd_int8 y, simd_int8 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_int16 simd_bitselect(simd_int16 x, simd_int16 y, simd_int16 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_uint2 simd_bitselect(simd_uint2 x, simd_uint2 y, simd_int2 mask) { + return (simd_uint2)simd_bitselect((simd_int2)x, (simd_int2)y, mask); +} +static inline SIMD_CFUNC simd_uint3 simd_bitselect(simd_uint3 x, simd_uint3 y, simd_int3 mask) { + return (simd_uint3)simd_bitselect((simd_int3)x, (simd_int3)y, mask); +} +static inline SIMD_CFUNC simd_uint4 simd_bitselect(simd_uint4 x, simd_uint4 y, simd_int4 mask) { + return (simd_uint4)simd_bitselect((simd_int4)x, (simd_int4)y, mask); +} +static inline SIMD_CFUNC simd_uint8 simd_bitselect(simd_uint8 x, simd_uint8 y, simd_int8 mask) { + return (simd_uint8)simd_bitselect((simd_int8)x, (simd_int8)y, mask); +} +static inline SIMD_CFUNC simd_uint16 simd_bitselect(simd_uint16 x, simd_uint16 y, simd_int16 mask) { + return (simd_uint16)simd_bitselect((simd_int16)x, (simd_int16)y, mask); +} +static inline SIMD_CFUNC simd_float2 simd_bitselect(simd_float2 x, simd_float2 y, simd_int2 mask) { + return (simd_float2)simd_bitselect((simd_int2)x, (simd_int2)y, mask); +} +static inline SIMD_CFUNC simd_float3 simd_bitselect(simd_float3 x, simd_float3 y, simd_int3 mask) { + return (simd_float3)simd_bitselect((simd_int3)x, (simd_int3)y, mask); +} +static inline SIMD_CFUNC simd_float4 simd_bitselect(simd_float4 x, simd_float4 y, simd_int4 mask) { + return (simd_float4)simd_bitselect((simd_int4)x, (simd_int4)y, mask); +} +static inline SIMD_CFUNC simd_float8 simd_bitselect(simd_float8 x, simd_float8 y, simd_int8 mask) { + return (simd_float8)simd_bitselect((simd_int8)x, (simd_int8)y, mask); +} +static inline SIMD_CFUNC simd_float16 simd_bitselect(simd_float16 x, simd_float16 y, simd_int16 mask) { + return (simd_float16)simd_bitselect((simd_int16)x, (simd_int16)y, mask); +} +static inline SIMD_CFUNC simd_long2 simd_bitselect(simd_long2 x, simd_long2 y, simd_long2 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_long3 simd_bitselect(simd_long3 x, simd_long3 y, simd_long3 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_long4 simd_bitselect(simd_long4 x, simd_long4 y, simd_long4 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_long8 simd_bitselect(simd_long8 x, simd_long8 y, simd_long8 mask) { + return (x & ~mask) | (y & mask); +} +static inline SIMD_CFUNC simd_ulong2 simd_bitselect(simd_ulong2 x, simd_ulong2 y, simd_long2 mask) { + return (simd_ulong2)simd_bitselect((simd_long2)x, (simd_long2)y, mask); +} +static inline SIMD_CFUNC simd_ulong3 simd_bitselect(simd_ulong3 x, simd_ulong3 y, simd_long3 mask) { + return (simd_ulong3)simd_bitselect((simd_long3)x, (simd_long3)y, mask); +} +static inline SIMD_CFUNC simd_ulong4 simd_bitselect(simd_ulong4 x, simd_ulong4 y, simd_long4 mask) { + return (simd_ulong4)simd_bitselect((simd_long4)x, (simd_long4)y, mask); +} +static inline SIMD_CFUNC simd_ulong8 simd_bitselect(simd_ulong8 x, simd_ulong8 y, simd_long8 mask) { + return (simd_ulong8)simd_bitselect((simd_long8)x, (simd_long8)y, mask); +} +static inline SIMD_CFUNC simd_double2 simd_bitselect(simd_double2 x, simd_double2 y, simd_long2 mask) { + return (simd_double2)simd_bitselect((simd_long2)x, (simd_long2)y, mask); +} +static inline SIMD_CFUNC simd_double3 simd_bitselect(simd_double3 x, simd_double3 y, simd_long3 mask) { + return (simd_double3)simd_bitselect((simd_long3)x, (simd_long3)y, mask); +} +static inline SIMD_CFUNC simd_double4 simd_bitselect(simd_double4 x, simd_double4 y, simd_long4 mask) { + return (simd_double4)simd_bitselect((simd_long4)x, (simd_long4)y, mask); +} +static inline SIMD_CFUNC simd_double8 simd_bitselect(simd_double8 x, simd_double8 y, simd_long8 mask) { + return (simd_double8)simd_bitselect((simd_long8)x, (simd_long8)y, mask); +} + +#ifdef __cplusplus +} +#endif +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* __SIMD_LOGIC_HEADER__ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/simd/math.h b/lib/libc/include/aarch64-macos-gnu/simd/math.h new file mode 100644 index 0000000000..4d5c654f69 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/simd/math.h @@ -0,0 +1,5380 @@ +/*! @header + * The interfaces declared in this header provide elementwise math operations + * on vectors; each lane of the result vector depends only on the data in the + * corresponding lane of the argument(s) to the function. + * + * You should not use the C functions declared in this header directly (these + * are functions with names like `__tg_cos(x)`). These are merely + * implementation details of overloading; instead of calling + * `__tg_cos(x)`, call `cos(x)`. If you are writing C++, use `simd::cos(x)`. + * + * Note that while these vector functions are relatively recent additions, + * scalar fallback is provided for all of them, so they are available even + * when targeting older OS versions. + * + * The following functions are available: + * + * C name C++ name Notes + * ---------------------------------------------------------------------- + * acos(x) simd::acos(x) + * asin(x) simd::asin(x) + * atan(x) simd::atan(x) + * atan2(y,x) simd::atan2(y,x) The argument order matches the scalar + * atan2 function, which gives the angle + * of a line with slope y/x. + * cos(x) simd::cos(x) + * sin(x) simd::sin(x) + * tan(x) simd::tan(x) + * + * cospi(x) simd::cospi(x) Returns cos(pi*x), sin(pi*x), tan(pi*x) + * sinpi(x) simd::sinpi(x) more efficiently and accurately than + * tanpi(x) simd::tanpi(x) would otherwise be possible + * + * acosh(x) simd::acosh(x) + * asinh(x) simd::asinh(x) + * atanh(x) simd::atanh(x) + * + * cosh(x) simd::cosh(x) + * sinh(x) simd::sinh(x) + * tanh(x) simd::tanh(x) + * + * exp(x) simd::exp(x) + * exp2(x) simd::exp2(x) + * exp10(x) simd::exp10(x) More efficient that pow(10,x). + * expm1(x) simd::expm1(x) exp(x)-1, accurate even for tiny x. + * + * log(x) simd::log(x) + * log2(x) simd::log2(x) + * log10(x) simd::log10(x) + * log1p(x) simd::log1p(x) log(1+x), accurate even for tiny x. + * + * fabs(x) simd::fabs(x) + * cbrt(x) simd::cbrt(x) + * sqrt(x) simd::sqrt(x) + * pow(x,y) simd::pow(x,y) + * copysign(x,y) simd::copysign(x,y) + * hypot(x,y) simd::hypot(x,y) sqrt(x*x + y*y), computed without + * overflow.1 + * erf(x) simd::erf(x) + * erfc(x) simd::erfc(x) + * tgamma(x) simd::tgamma(x) + * + * fmod(x,y) simd::fmod(x,y) + * remainder(x,y) simd::remainder(x,y) + * + * ceil(x) simd::ceil(x) + * floor(x) simd::floor(x) + * rint(x) simd::rint(x) + * round(x) simd::round(x) + * trunc(x) simd::trunc(x) + * + * fdim(x,y) simd::fdim(x,y) + * fmax(x,y) simd::fmax(x,y) When one argument to fmin or fmax is + * fmin(x,y) simd::fmin(x,y) constant, use it as the *second* (y) + * argument to get better codegen on some + * architectures. E.g., write fmin(x,2) + * instead of fmin(2,x). + * fma(x,y,z) simd::fma(x,y,z) Fast on arm64 and when targeting AVX2 + * and later; may be quite expensive on + * older hardware. + * simd_muladd(x,y,z) simd::muladd(x,y,z) + * + * @copyright 2014-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_MATH_HEADER +#define SIMD_MATH_HEADER + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_acos(simd_float2 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_acos(simd_float3 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_acos(simd_float4 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_acos(simd_float8 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_acos(simd_float16 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_acos(simd_double2 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_acos(simd_double3 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_acos(simd_double4 x); +/*! @abstract Do not call this function; instead use `acos` in C and + * Objective-C, and `simd::acos` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_acos(simd_double8 x); + +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_asin(simd_float2 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_asin(simd_float3 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_asin(simd_float4 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_asin(simd_float8 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_asin(simd_float16 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_asin(simd_double2 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_asin(simd_double3 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_asin(simd_double4 x); +/*! @abstract Do not call this function; instead use `asin` in C and + * Objective-C, and `simd::asin` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_asin(simd_double8 x); + +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_atan(simd_float2 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_atan(simd_float3 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_atan(simd_float4 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_atan(simd_float8 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_atan(simd_float16 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_atan(simd_double2 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_atan(simd_double3 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_atan(simd_double4 x); +/*! @abstract Do not call this function; instead use `atan` in C and + * Objective-C, and `simd::atan` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_atan(simd_double8 x); + +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_cos(simd_float2 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_cos(simd_float3 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_cos(simd_float8 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_cos(simd_float16 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_cos(simd_double3 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_cos(simd_double4 x); +/*! @abstract Do not call this function; instead use `cos` in C and + * Objective-C, and `simd::cos` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_cos(simd_double8 x); + +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_sin(simd_float2 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_sin(simd_float3 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_sin(simd_float8 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_sin(simd_float16 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_sin(simd_double3 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_sin(simd_double4 x); +/*! @abstract Do not call this function; instead use `sin` in C and + * Objective-C, and `simd::sin` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_sin(simd_double8 x); + +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_tan(simd_float2 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_tan(simd_float3 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_tan(simd_float4 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_tan(simd_float8 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_tan(simd_float16 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_tan(simd_double2 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_tan(simd_double3 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_tan(simd_double4 x); +/*! @abstract Do not call this function; instead use `tan` in C and + * Objective-C, and `simd::tan` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_tan(simd_double8 x); + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_cospi(simd_float2 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_cospi(simd_float3 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_cospi(simd_float4 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_cospi(simd_float8 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_cospi(simd_float16 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_cospi(simd_double2 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_cospi(simd_double3 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_cospi(simd_double4 x); +/*! @abstract Do not call this function; instead use `cospi` in C and + * Objective-C, and `simd::cospi` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_cospi(simd_double8 x); +#endif + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_sinpi(simd_float2 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_sinpi(simd_float3 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_sinpi(simd_float4 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_sinpi(simd_float8 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_sinpi(simd_float16 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_sinpi(simd_double2 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_sinpi(simd_double3 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_sinpi(simd_double4 x); +/*! @abstract Do not call this function; instead use `sinpi` in C and + * Objective-C, and `simd::sinpi` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_sinpi(simd_double8 x); +#endif + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_tanpi(simd_float2 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_tanpi(simd_float3 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_tanpi(simd_float4 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_tanpi(simd_float8 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_tanpi(simd_float16 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_tanpi(simd_double2 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_tanpi(simd_double3 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_tanpi(simd_double4 x); +/*! @abstract Do not call this function; instead use `tanpi` in C and + * Objective-C, and `simd::tanpi` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_tanpi(simd_double8 x); +#endif + +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_acosh(simd_float2 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_acosh(simd_float3 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_acosh(simd_float4 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_acosh(simd_float8 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_acosh(simd_float16 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_acosh(simd_double2 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_acosh(simd_double3 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_acosh(simd_double4 x); +/*! @abstract Do not call this function; instead use `acosh` in C and + * Objective-C, and `simd::acosh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_acosh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_asinh(simd_float2 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_asinh(simd_float3 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_asinh(simd_float4 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_asinh(simd_float8 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_asinh(simd_float16 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_asinh(simd_double2 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_asinh(simd_double3 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_asinh(simd_double4 x); +/*! @abstract Do not call this function; instead use `asinh` in C and + * Objective-C, and `simd::asinh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_asinh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_atanh(simd_float2 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_atanh(simd_float3 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_atanh(simd_float4 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_atanh(simd_float8 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_atanh(simd_float16 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_atanh(simd_double2 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_atanh(simd_double3 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_atanh(simd_double4 x); +/*! @abstract Do not call this function; instead use `atanh` in C and + * Objective-C, and `simd::atanh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_atanh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_cosh(simd_float2 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_cosh(simd_float3 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_cosh(simd_float4 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_cosh(simd_float8 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_cosh(simd_float16 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_cosh(simd_double2 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_cosh(simd_double3 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_cosh(simd_double4 x); +/*! @abstract Do not call this function; instead use `cosh` in C and + * Objective-C, and `simd::cosh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_cosh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_sinh(simd_float2 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_sinh(simd_float3 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_sinh(simd_float4 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_sinh(simd_float8 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_sinh(simd_float16 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_sinh(simd_double2 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_sinh(simd_double3 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_sinh(simd_double4 x); +/*! @abstract Do not call this function; instead use `sinh` in C and + * Objective-C, and `simd::sinh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_sinh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_tanh(simd_float2 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_tanh(simd_float3 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_tanh(simd_float4 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_tanh(simd_float8 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_tanh(simd_float16 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_tanh(simd_double2 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_tanh(simd_double3 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_tanh(simd_double4 x); +/*! @abstract Do not call this function; instead use `tanh` in C and + * Objective-C, and `simd::tanh` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_tanh(simd_double8 x); + +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_exp(simd_float2 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_exp(simd_float3 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_exp(simd_float4 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_exp(simd_float8 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_exp(simd_float16 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_exp(simd_double2 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_exp(simd_double3 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_exp(simd_double4 x); +/*! @abstract Do not call this function; instead use `exp` in C and + * Objective-C, and `simd::exp` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_exp(simd_double8 x); + +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_exp2(simd_float2 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_exp2(simd_float3 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_exp2(simd_float4 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_exp2(simd_float8 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_exp2(simd_float16 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_exp2(simd_double2 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_exp2(simd_double3 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_exp2(simd_double4 x); +/*! @abstract Do not call this function; instead use `exp2` in C and + * Objective-C, and `simd::exp2` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_exp2(simd_double8 x); + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_exp10(simd_float2 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_exp10(simd_float3 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_exp10(simd_float4 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_exp10(simd_float8 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_exp10(simd_float16 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_exp10(simd_double2 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_exp10(simd_double3 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_exp10(simd_double4 x); +/*! @abstract Do not call this function; instead use `exp10` in C and + * Objective-C, and `simd::exp10` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_exp10(simd_double8 x); +#endif + +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_expm1(simd_float2 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_expm1(simd_float3 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_expm1(simd_float4 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_expm1(simd_float8 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_expm1(simd_float16 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_expm1(simd_double2 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_expm1(simd_double3 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_expm1(simd_double4 x); +/*! @abstract Do not call this function; instead use `expm1` in C and + * Objective-C, and `simd::expm1` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_expm1(simd_double8 x); + +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_log(simd_float2 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_log(simd_float3 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_log(simd_float4 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_log(simd_float8 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_log(simd_float16 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_log(simd_double2 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_log(simd_double3 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_log(simd_double4 x); +/*! @abstract Do not call this function; instead use `log` in C and + * Objective-C, and `simd::log` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_log(simd_double8 x); + +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_log2(simd_float2 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_log2(simd_float3 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_log2(simd_float4 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_log2(simd_float8 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_log2(simd_float16 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_log2(simd_double2 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_log2(simd_double3 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_log2(simd_double4 x); +/*! @abstract Do not call this function; instead use `log2` in C and + * Objective-C, and `simd::log2` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_log2(simd_double8 x); + +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_log10(simd_float2 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_log10(simd_float3 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_log10(simd_float4 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_log10(simd_float8 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_log10(simd_float16 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_log10(simd_double2 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_log10(simd_double3 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_log10(simd_double4 x); +/*! @abstract Do not call this function; instead use `log10` in C and + * Objective-C, and `simd::log10` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_log10(simd_double8 x); + +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_log1p(simd_float2 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_log1p(simd_float3 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_log1p(simd_float4 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_log1p(simd_float8 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_log1p(simd_float16 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_log1p(simd_double2 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_log1p(simd_double3 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_log1p(simd_double4 x); +/*! @abstract Do not call this function; instead use `log1p` in C and + * Objective-C, and `simd::log1p` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_log1p(simd_double8 x); + +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fabs(simd_float2 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fabs(simd_float3 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fabs(simd_float4 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fabs(simd_float8 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fabs(simd_float16 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fabs(simd_double2 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fabs(simd_double3 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fabs(simd_double4 x); +/*! @abstract Do not call this function; instead use `fabs` in C and + * Objective-C, and `simd::fabs` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fabs(simd_double8 x); + +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_cbrt(simd_float2 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_cbrt(simd_float3 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_cbrt(simd_float4 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_cbrt(simd_float8 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_cbrt(simd_float16 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_cbrt(simd_double2 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_cbrt(simd_double3 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_cbrt(simd_double4 x); +/*! @abstract Do not call this function; instead use `cbrt` in C and + * Objective-C, and `simd::cbrt` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_cbrt(simd_double8 x); + +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_sqrt(simd_float2 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_sqrt(simd_float3 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_sqrt(simd_float4 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_sqrt(simd_float8 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_sqrt(simd_float16 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_sqrt(simd_double2 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_sqrt(simd_double3 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_sqrt(simd_double4 x); +/*! @abstract Do not call this function; instead use `sqrt` in C and + * Objective-C, and `simd::sqrt` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_sqrt(simd_double8 x); + +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_erf(simd_float2 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_erf(simd_float3 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_erf(simd_float4 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_erf(simd_float8 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_erf(simd_float16 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_erf(simd_double2 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_erf(simd_double3 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_erf(simd_double4 x); +/*! @abstract Do not call this function; instead use `erf` in C and + * Objective-C, and `simd::erf` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_erf(simd_double8 x); + +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_erfc(simd_float2 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_erfc(simd_float3 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_erfc(simd_float4 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_erfc(simd_float8 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_erfc(simd_float16 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_erfc(simd_double2 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_erfc(simd_double3 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_erfc(simd_double4 x); +/*! @abstract Do not call this function; instead use `erfc` in C and + * Objective-C, and `simd::erfc` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_erfc(simd_double8 x); + +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_tgamma(simd_float2 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_tgamma(simd_float3 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_tgamma(simd_float4 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_tgamma(simd_float8 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_tgamma(simd_float16 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_tgamma(simd_double2 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_tgamma(simd_double3 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_tgamma(simd_double4 x); +/*! @abstract Do not call this function; instead use `tgamma` in C and + * Objective-C, and `simd::tgamma` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_tgamma(simd_double8 x); + +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_ceil(simd_float2 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_ceil(simd_float3 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_ceil(simd_float4 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_ceil(simd_float8 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_ceil(simd_float16 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_ceil(simd_double2 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_ceil(simd_double3 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_ceil(simd_double4 x); +/*! @abstract Do not call this function; instead use `ceil` in C and + * Objective-C, and `simd::ceil` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_ceil(simd_double8 x); + +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_floor(simd_float2 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_floor(simd_float3 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_floor(simd_float4 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_floor(simd_float8 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_floor(simd_float16 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_floor(simd_double2 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_floor(simd_double3 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_floor(simd_double4 x); +/*! @abstract Do not call this function; instead use `floor` in C and + * Objective-C, and `simd::floor` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_floor(simd_double8 x); + +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_rint(simd_float2 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_rint(simd_float3 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_rint(simd_float4 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_rint(simd_float8 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_rint(simd_float16 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_rint(simd_double2 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_rint(simd_double3 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_rint(simd_double4 x); +/*! @abstract Do not call this function; instead use `rint` in C and + * Objective-C, and `simd::rint` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_rint(simd_double8 x); + +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_round(simd_float2 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_round(simd_float3 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_round(simd_float4 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_round(simd_float8 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_round(simd_float16 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_round(simd_double2 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_round(simd_double3 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_round(simd_double4 x); +/*! @abstract Do not call this function; instead use `round` in C and + * Objective-C, and `simd::round` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_round(simd_double8 x); + +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_trunc(simd_float2 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_trunc(simd_float3 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_trunc(simd_float4 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_trunc(simd_float8 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_trunc(simd_float16 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_trunc(simd_double2 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_trunc(simd_double3 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_trunc(simd_double4 x); +/*! @abstract Do not call this function; instead use `trunc` in C and + * Objective-C, and `simd::trunc` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_trunc(simd_double8 x); + + +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_atan2(simd_float2 y, simd_float2 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_atan2(simd_float3 y, simd_float3 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_atan2(simd_float4 y, simd_float4 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_atan2(simd_float8 y, simd_float8 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_atan2(simd_float16 y, simd_float16 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_atan2(simd_double2 y, simd_double2 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_atan2(simd_double3 y, simd_double3 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_atan2(simd_double4 y, simd_double4 x); +/*! @abstract Do not call this function; instead use `atan2` in C and + * Objective-C, and `simd::atan2` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_atan2(simd_double8 y, simd_double8 x); + +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_hypot(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_hypot(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_hypot(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_hypot(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_hypot(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_hypot(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_hypot(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_hypot(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `hypot` in C and + * Objective-C, and `simd::hypot` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_hypot(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_pow(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_pow(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_pow(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_pow(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_pow(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_pow(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_pow(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_pow(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `pow` in C and + * Objective-C, and `simd::pow` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_pow(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fmod(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fmod(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fmod(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fmod(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fmod(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fmod(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fmod(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fmod(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `fmod` in C and + * Objective-C, and `simd::fmod` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fmod(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_remainder(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_remainder(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_remainder(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_remainder(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_remainder(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_remainder(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_remainder(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_remainder(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `remainder` in C and + * Objective-C, and `simd::remainder` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_remainder(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_copysign(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_copysign(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_copysign(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_copysign(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_copysign(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_copysign(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_copysign(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_copysign(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `copysign` in C and + * Objective-C, and `simd::copysign` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_copysign(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_nextafter(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_nextafter(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_nextafter(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_nextafter(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_nextafter(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_nextafter(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_nextafter(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_nextafter(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `nextafter` in C and + * Objective-C, and `simd::nextafter` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_nextafter(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fdim(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fdim(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fdim(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fdim(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fdim(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fdim(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fdim(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fdim(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `fdim` in C and + * Objective-C, and `simd::fdim` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fdim(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fmax(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fmax(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fmax(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fmax(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fmax(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fmax(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fmax(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fmax(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `fmax` in C and + * Objective-C, and `simd::fmax` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fmax(simd_double8 x, simd_double8 y); + +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fmin(simd_float2 x, simd_float2 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fmin(simd_float3 x, simd_float3 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fmin(simd_float4 x, simd_float4 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fmin(simd_float8 x, simd_float8 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fmin(simd_float16 x, simd_float16 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fmin(simd_double2 x, simd_double2 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fmin(simd_double3 x, simd_double3 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fmin(simd_double4 x, simd_double4 y); +/*! @abstract Do not call this function; instead use `fmin` in C and + * Objective-C, and `simd::fmin` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fmin(simd_double8 x, simd_double8 y); + + +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float2 __tg_fma(simd_float2 x, simd_float2 y, simd_float2 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float3 __tg_fma(simd_float3 x, simd_float3 y, simd_float3 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float4 __tg_fma(simd_float4 x, simd_float4 y, simd_float4 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float8 __tg_fma(simd_float8 x, simd_float8 y, simd_float8 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_float16 __tg_fma(simd_float16 x, simd_float16 y, simd_float16 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_double2 __tg_fma(simd_double2 x, simd_double2 y, simd_double2 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_double3 __tg_fma(simd_double3 x, simd_double3 y, simd_double3 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_double4 __tg_fma(simd_double4 x, simd_double4 y, simd_double4 z); +/*! @abstract Do not call this function; instead use `fma` in C and Objective-C, + * and `simd::fma` in C++. */ +static inline SIMD_CFUNC simd_double8 __tg_fma(simd_double8 x, simd_double8 y, simd_double8 z); + +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC float simd_muladd(float x, float y, float z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float2 simd_muladd(simd_float2 x, simd_float2 y, simd_float2 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float3 simd_muladd(simd_float3 x, simd_float3 y, simd_float3 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float4 simd_muladd(simd_float4 x, simd_float4 y, simd_float4 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float8 simd_muladd(simd_float8 x, simd_float8 y, simd_float8 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_float16 simd_muladd(simd_float16 x, simd_float16 y, simd_float16 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC double simd_muladd(double x, double y, double z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_double2 simd_muladd(simd_double2 x, simd_double2 y, simd_double2 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_double3 simd_muladd(simd_double3 x, simd_double3 y, simd_double3 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_double4 simd_muladd(simd_double4 x, simd_double4 y, simd_double4 z); +/*! @abstract Computes accum + x*y by the most efficient means available; + * either a fused multiply add or separate multiply and add instructions. */ +static inline SIMD_CFUNC simd_double8 simd_muladd(simd_double8 x, simd_double8 y, simd_double8 z); + +#ifdef __cplusplus +} /* extern "C" */ + +#include +/*! @abstract Do not call this function directly; use simd::acos instead. */ +static SIMD_CPPFUNC float __tg_acos(float x) { return ::acos(x); } +/*! @abstract Do not call this function directly; use simd::acos instead. */ +static SIMD_CPPFUNC double __tg_acos(double x) { return ::acos(x); } +/*! @abstract Do not call this function directly; use simd::asin instead. */ +static SIMD_CPPFUNC float __tg_asin(float x) { return ::asin(x); } +/*! @abstract Do not call this function directly; use simd::asin instead. */ +static SIMD_CPPFUNC double __tg_asin(double x) { return ::asin(x); } +/*! @abstract Do not call this function directly; use simd::atan instead. */ +static SIMD_CPPFUNC float __tg_atan(float x) { return ::atan(x); } +/*! @abstract Do not call this function directly; use simd::atan instead. */ +static SIMD_CPPFUNC double __tg_atan(double x) { return ::atan(x); } +/*! @abstract Do not call this function directly; use simd::cos instead. */ +static SIMD_CPPFUNC float __tg_cos(float x) { return ::cos(x); } +/*! @abstract Do not call this function directly; use simd::cos instead. */ +static SIMD_CPPFUNC double __tg_cos(double x) { return ::cos(x); } +/*! @abstract Do not call this function directly; use simd::sin instead. */ +static SIMD_CPPFUNC float __tg_sin(float x) { return ::sin(x); } +/*! @abstract Do not call this function directly; use simd::sin instead. */ +static SIMD_CPPFUNC double __tg_sin(double x) { return ::sin(x); } +/*! @abstract Do not call this function directly; use simd::tan instead. */ +static SIMD_CPPFUNC float __tg_tan(float x) { return ::tan(x); } +/*! @abstract Do not call this function directly; use simd::tan instead. */ +static SIMD_CPPFUNC double __tg_tan(double x) { return ::tan(x); } +/*! @abstract Do not call this function directly; use simd::cospi instead. */ +static SIMD_CPPFUNC float __tg_cospi(float x) { return ::__cospi(x); } +/*! @abstract Do not call this function directly; use simd::cospi instead. */ +static SIMD_CPPFUNC double __tg_cospi(double x) { return ::__cospi(x); } +/*! @abstract Do not call this function directly; use simd::sinpi instead. */ +static SIMD_CPPFUNC float __tg_sinpi(float x) { return ::__sinpi(x); } +/*! @abstract Do not call this function directly; use simd::sinpi instead. */ +static SIMD_CPPFUNC double __tg_sinpi(double x) { return ::__sinpi(x); } +/*! @abstract Do not call this function directly; use simd::tanpi instead. */ +static SIMD_CPPFUNC float __tg_tanpi(float x) { return ::__tanpi(x); } +/*! @abstract Do not call this function directly; use simd::tanpi instead. */ +static SIMD_CPPFUNC double __tg_tanpi(double x) { return ::__tanpi(x); } +/*! @abstract Do not call this function directly; use simd::acosh instead. */ +static SIMD_CPPFUNC float __tg_acosh(float x) { return ::acosh(x); } +/*! @abstract Do not call this function directly; use simd::acosh instead. */ +static SIMD_CPPFUNC double __tg_acosh(double x) { return ::acosh(x); } +/*! @abstract Do not call this function directly; use simd::asinh instead. */ +static SIMD_CPPFUNC float __tg_asinh(float x) { return ::asinh(x); } +/*! @abstract Do not call this function directly; use simd::asinh instead. */ +static SIMD_CPPFUNC double __tg_asinh(double x) { return ::asinh(x); } +/*! @abstract Do not call this function directly; use simd::atanh instead. */ +static SIMD_CPPFUNC float __tg_atanh(float x) { return ::atanh(x); } +/*! @abstract Do not call this function directly; use simd::atanh instead. */ +static SIMD_CPPFUNC double __tg_atanh(double x) { return ::atanh(x); } +/*! @abstract Do not call this function directly; use simd::cosh instead. */ +static SIMD_CPPFUNC float __tg_cosh(float x) { return ::cosh(x); } +/*! @abstract Do not call this function directly; use simd::cosh instead. */ +static SIMD_CPPFUNC double __tg_cosh(double x) { return ::cosh(x); } +/*! @abstract Do not call this function directly; use simd::sinh instead. */ +static SIMD_CPPFUNC float __tg_sinh(float x) { return ::sinh(x); } +/*! @abstract Do not call this function directly; use simd::sinh instead. */ +static SIMD_CPPFUNC double __tg_sinh(double x) { return ::sinh(x); } +/*! @abstract Do not call this function directly; use simd::tanh instead. */ +static SIMD_CPPFUNC float __tg_tanh(float x) { return ::tanh(x); } +/*! @abstract Do not call this function directly; use simd::tanh instead. */ +static SIMD_CPPFUNC double __tg_tanh(double x) { return ::tanh(x); } +/*! @abstract Do not call this function directly; use simd::exp instead. */ +static SIMD_CPPFUNC float __tg_exp(float x) { return ::exp(x); } +/*! @abstract Do not call this function directly; use simd::exp instead. */ +static SIMD_CPPFUNC double __tg_exp(double x) { return ::exp(x); } +/*! @abstract Do not call this function directly; use simd::exp2 instead. */ +static SIMD_CPPFUNC float __tg_exp2(float x) { return ::exp2(x); } +/*! @abstract Do not call this function directly; use simd::exp2 instead. */ +static SIMD_CPPFUNC double __tg_exp2(double x) { return ::exp2(x); } +/*! @abstract Do not call this function directly; use simd::exp10 instead. */ +static SIMD_CPPFUNC float __tg_exp10(float x) { return ::__exp10(x); } +/*! @abstract Do not call this function directly; use simd::exp10 instead. */ +static SIMD_CPPFUNC double __tg_exp10(double x) { return ::__exp10(x); } +/*! @abstract Do not call this function directly; use simd::expm1 instead. */ +static SIMD_CPPFUNC float __tg_expm1(float x) { return ::expm1(x); } +/*! @abstract Do not call this function directly; use simd::expm1 instead. */ +static SIMD_CPPFUNC double __tg_expm1(double x) { return ::expm1(x); } +/*! @abstract Do not call this function directly; use simd::log instead. */ +static SIMD_CPPFUNC float __tg_log(float x) { return ::log(x); } +/*! @abstract Do not call this function directly; use simd::log instead. */ +static SIMD_CPPFUNC double __tg_log(double x) { return ::log(x); } +/*! @abstract Do not call this function directly; use simd::log2 instead. */ +static SIMD_CPPFUNC float __tg_log2(float x) { return ::log2(x); } +/*! @abstract Do not call this function directly; use simd::log2 instead. */ +static SIMD_CPPFUNC double __tg_log2(double x) { return ::log2(x); } +/*! @abstract Do not call this function directly; use simd::log10 instead. */ +static SIMD_CPPFUNC float __tg_log10(float x) { return ::log10(x); } +/*! @abstract Do not call this function directly; use simd::log10 instead. */ +static SIMD_CPPFUNC double __tg_log10(double x) { return ::log10(x); } +/*! @abstract Do not call this function directly; use simd::log1p instead. */ +static SIMD_CPPFUNC float __tg_log1p(float x) { return ::log1p(x); } +/*! @abstract Do not call this function directly; use simd::log1p instead. */ +static SIMD_CPPFUNC double __tg_log1p(double x) { return ::log1p(x); } +/*! @abstract Do not call this function directly; use simd::fabs instead. */ +static SIMD_CPPFUNC float __tg_fabs(float x) { return ::fabs(x); } +/*! @abstract Do not call this function directly; use simd::fabs instead. */ +static SIMD_CPPFUNC double __tg_fabs(double x) { return ::fabs(x); } +/*! @abstract Do not call this function directly; use simd::cbrt instead. */ +static SIMD_CPPFUNC float __tg_cbrt(float x) { return ::cbrt(x); } +/*! @abstract Do not call this function directly; use simd::cbrt instead. */ +static SIMD_CPPFUNC double __tg_cbrt(double x) { return ::cbrt(x); } +/*! @abstract Do not call this function directly; use simd::sqrt instead. */ +static SIMD_CPPFUNC float __tg_sqrt(float x) { return ::sqrt(x); } +/*! @abstract Do not call this function directly; use simd::sqrt instead. */ +static SIMD_CPPFUNC double __tg_sqrt(double x) { return ::sqrt(x); } +/*! @abstract Do not call this function directly; use simd::erf instead. */ +static SIMD_CPPFUNC float __tg_erf(float x) { return ::erf(x); } +/*! @abstract Do not call this function directly; use simd::erf instead. */ +static SIMD_CPPFUNC double __tg_erf(double x) { return ::erf(x); } +/*! @abstract Do not call this function directly; use simd::erfc instead. */ +static SIMD_CPPFUNC float __tg_erfc(float x) { return ::erfc(x); } +/*! @abstract Do not call this function directly; use simd::erfc instead. */ +static SIMD_CPPFUNC double __tg_erfc(double x) { return ::erfc(x); } +/*! @abstract Do not call this function directly; use simd::tgamma instead. */ +static SIMD_CPPFUNC float __tg_tgamma(float x) { return ::tgamma(x); } +/*! @abstract Do not call this function directly; use simd::tgamma instead. */ +static SIMD_CPPFUNC double __tg_tgamma(double x) { return ::tgamma(x); } +/*! @abstract Do not call this function directly; use simd::ceil instead. */ +static SIMD_CPPFUNC float __tg_ceil(float x) { return ::ceil(x); } +/*! @abstract Do not call this function directly; use simd::ceil instead. */ +static SIMD_CPPFUNC double __tg_ceil(double x) { return ::ceil(x); } +/*! @abstract Do not call this function directly; use simd::floor instead. */ +static SIMD_CPPFUNC float __tg_floor(float x) { return ::floor(x); } +/*! @abstract Do not call this function directly; use simd::floor instead. */ +static SIMD_CPPFUNC double __tg_floor(double x) { return ::floor(x); } +/*! @abstract Do not call this function directly; use simd::rint instead. */ +static SIMD_CPPFUNC float __tg_rint(float x) { return ::rint(x); } +/*! @abstract Do not call this function directly; use simd::rint instead. */ +static SIMD_CPPFUNC double __tg_rint(double x) { return ::rint(x); } +/*! @abstract Do not call this function directly; use simd::round instead. */ +static SIMD_CPPFUNC float __tg_round(float x) { return ::round(x); } +/*! @abstract Do not call this function directly; use simd::round instead. */ +static SIMD_CPPFUNC double __tg_round(double x) { return ::round(x); } +/*! @abstract Do not call this function directly; use simd::trunc instead. */ +static SIMD_CPPFUNC float __tg_trunc(float x) { return ::trunc(x); } +/*! @abstract Do not call this function directly; use simd::trunc instead. */ +static SIMD_CPPFUNC double __tg_trunc(double x) { return ::trunc(x); } +/*! @abstract Do not call this function directly; use simd::atan2 instead. */ +static SIMD_CPPFUNC float __tg_atan2(float x, float y) { return ::atan2(x, y); } +/*! @abstract Do not call this function directly; use simd::atan2 instead. */ +static SIMD_CPPFUNC double __tg_atan2(double x, float y) { return ::atan2(x, y); } +/*! @abstract Do not call this function directly; use simd::hypot instead. */ +static SIMD_CPPFUNC float __tg_hypot(float x, float y) { return ::hypot(x, y); } +/*! @abstract Do not call this function directly; use simd::hypot instead. */ +static SIMD_CPPFUNC double __tg_hypot(double x, float y) { return ::hypot(x, y); } +/*! @abstract Do not call this function directly; use simd::pow instead. */ +static SIMD_CPPFUNC float __tg_pow(float x, float y) { return ::pow(x, y); } +/*! @abstract Do not call this function directly; use simd::pow instead. */ +static SIMD_CPPFUNC double __tg_pow(double x, float y) { return ::pow(x, y); } +/*! @abstract Do not call this function directly; use simd::fmod instead. */ +static SIMD_CPPFUNC float __tg_fmod(float x, float y) { return ::fmod(x, y); } +/*! @abstract Do not call this function directly; use simd::fmod instead. */ +static SIMD_CPPFUNC double __tg_fmod(double x, float y) { return ::fmod(x, y); } +/*! @abstract Do not call this function directly; use simd::remainder + * instead. */ +static SIMD_CPPFUNC float __tg_remainder(float x, float y) { return ::remainder(x, y); } +/*! @abstract Do not call this function directly; use simd::remainder + * instead. */ +static SIMD_CPPFUNC double __tg_remainder(double x, float y) { return ::remainder(x, y); } +/*! @abstract Do not call this function directly; use simd::copysign + * instead. */ +static SIMD_CPPFUNC float __tg_copysign(float x, float y) { return ::copysign(x, y); } +/*! @abstract Do not call this function directly; use simd::copysign + * instead. */ +static SIMD_CPPFUNC double __tg_copysign(double x, float y) { return ::copysign(x, y); } +/*! @abstract Do not call this function directly; use simd::nextafter + * instead. */ +static SIMD_CPPFUNC float __tg_nextafter(float x, float y) { return ::nextafter(x, y); } +/*! @abstract Do not call this function directly; use simd::nextafter + * instead. */ +static SIMD_CPPFUNC double __tg_nextafter(double x, float y) { return ::nextafter(x, y); } +/*! @abstract Do not call this function directly; use simd::fdim instead. */ +static SIMD_CPPFUNC float __tg_fdim(float x, float y) { return ::fdim(x, y); } +/*! @abstract Do not call this function directly; use simd::fdim instead. */ +static SIMD_CPPFUNC double __tg_fdim(double x, float y) { return ::fdim(x, y); } +/*! @abstract Do not call this function directly; use simd::fmax instead. */ +static SIMD_CPPFUNC float __tg_fmax(float x, float y) { return ::fmax(x, y); } +/*! @abstract Do not call this function directly; use simd::fmax instead. */ +static SIMD_CPPFUNC double __tg_fmax(double x, float y) { return ::fmax(x, y); } +/*! @abstract Do not call this function directly; use simd::fmin instead. */ +static SIMD_CPPFUNC float __tg_fmin(float x, float y) { return ::fmin(x, y); } +/*! @abstract Do not call this function directly; use simd::fmin instead. */ +static SIMD_CPPFUNC double __tg_fmin(double x, float y) { return ::fmin(x, y); } +/*! @abstract Do not call this function directly; use simd::fma instead. */ +static SIMD_CPPFUNC float __tg_fma(float x, float y, float z) { return ::fma(x, y, z); } +/*! @abstract Do not call this function directly; use simd::fma instead. */ +static SIMD_CPPFUNC double __tg_fma(double x, double y, double z) { return ::fma(x, y, z); } + +namespace simd { +/*! @abstract Generalizes the function acos to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN acos(fptypeN x) { return ::__tg_acos(x); } + +/*! @abstract Generalizes the function asin to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN asin(fptypeN x) { return ::__tg_asin(x); } + +/*! @abstract Generalizes the function atan to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN atan(fptypeN x) { return ::__tg_atan(x); } + +/*! @abstract Generalizes the function cos to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN cos(fptypeN x) { return ::__tg_cos(x); } + +/*! @abstract Generalizes the function sin to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN sin(fptypeN x) { return ::__tg_sin(x); } + +/*! @abstract Generalizes the function tan to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN tan(fptypeN x) { return ::__tg_tan(x); } + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Generalizes the function cospi to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN cospi(fptypeN x) { return ::__tg_cospi(x); } +#endif + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Generalizes the function sinpi to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN sinpi(fptypeN x) { return ::__tg_sinpi(x); } +#endif + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Generalizes the function tanpi to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN tanpi(fptypeN x) { return ::__tg_tanpi(x); } +#endif + +/*! @abstract Generalizes the function acosh to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN acosh(fptypeN x) { return ::__tg_acosh(x); } + +/*! @abstract Generalizes the function asinh to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN asinh(fptypeN x) { return ::__tg_asinh(x); } + +/*! @abstract Generalizes the function atanh to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN atanh(fptypeN x) { return ::__tg_atanh(x); } + +/*! @abstract Generalizes the function cosh to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN cosh(fptypeN x) { return ::__tg_cosh(x); } + +/*! @abstract Generalizes the function sinh to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN sinh(fptypeN x) { return ::__tg_sinh(x); } + +/*! @abstract Generalizes the function tanh to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN tanh(fptypeN x) { return ::__tg_tanh(x); } + +/*! @abstract Generalizes the function exp to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN exp(fptypeN x) { return ::__tg_exp(x); } + +/*! @abstract Generalizes the function exp2 to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN exp2(fptypeN x) { return ::__tg_exp2(x); } + +#if SIMD_LIBRARY_VERSION >= 1 +/*! @abstract Generalizes the function exp10 to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN exp10(fptypeN x) { return ::__tg_exp10(x); } +#endif + +/*! @abstract Generalizes the function expm1 to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN expm1(fptypeN x) { return ::__tg_expm1(x); } + +/*! @abstract Generalizes the function log to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN log(fptypeN x) { return ::__tg_log(x); } + +/*! @abstract Generalizes the function log2 to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN log2(fptypeN x) { return ::__tg_log2(x); } + +/*! @abstract Generalizes the function log10 to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN log10(fptypeN x) { return ::__tg_log10(x); } + +/*! @abstract Generalizes the function log1p to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN log1p(fptypeN x) { return ::__tg_log1p(x); } + +/*! @abstract Generalizes the function fabs to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fabs(fptypeN x) { return ::__tg_fabs(x); } + +/*! @abstract Generalizes the function cbrt to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN cbrt(fptypeN x) { return ::__tg_cbrt(x); } + +/*! @abstract Generalizes the function sqrt to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN sqrt(fptypeN x) { return ::__tg_sqrt(x); } + +/*! @abstract Generalizes the function erf to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN erf(fptypeN x) { return ::__tg_erf(x); } + +/*! @abstract Generalizes the function erfc to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN erfc(fptypeN x) { return ::__tg_erfc(x); } + +/*! @abstract Generalizes the function tgamma to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN tgamma(fptypeN x) { return ::__tg_tgamma(x); } + +/*! @abstract Generalizes the function ceil to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN ceil(fptypeN x) { return ::__tg_ceil(x); } + +/*! @abstract Generalizes the function floor to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN floor(fptypeN x) { return ::__tg_floor(x); } + +/*! @abstract Generalizes the function rint to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN rint(fptypeN x) { return ::__tg_rint(x); } + +/*! @abstract Generalizes the function round to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN round(fptypeN x) { return ::__tg_round(x); } + +/*! @abstract Generalizes the function trunc to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN trunc(fptypeN x) { return ::__tg_trunc(x); } + +/*! @abstract Generalizes the function atan2 to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN atan2(fptypeN y, fptypeN x) { return ::__tg_atan2(y, x); } + +/*! @abstract Generalizes the function hypot to operate on vectors + * of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN hypot(fptypeN x, fptypeN y) { return ::__tg_hypot(x, y); } + +/*! @abstract Generalizes the function pow to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN pow(fptypeN x, fptypeN y) { return ::__tg_pow(x, y); } + +/*! @abstract Generalizes the function fmod to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fmod(fptypeN x, fptypeN y) { return ::__tg_fmod(x, y); } + +/*! @abstract Generalizes the function remainder to operate on + * vectors of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN remainder(fptypeN x, fptypeN y) { return ::__tg_remainder(x, y); } + +/*! @abstract Generalizes the function copysign to operate on + * vectors of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN copysign(fptypeN x, fptypeN y) { return ::__tg_copysign(x, y); } + +/*! @abstract Generalizes the function nextafter to operate on + * vectors of floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN nextafter(fptypeN x, fptypeN y) { return ::__tg_nextafter(x, y); } + +/*! @abstract Generalizes the function fdim to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fdim(fptypeN x, fptypeN y) { return ::__tg_fdim(x, y); } + +/*! @abstract Generalizes the function fmax to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fmax(fptypeN x, fptypeN y) { return ::__tg_fmax(x, y); } + +/*! @abstract Generalizes the function fmin to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fmin(fptypeN x, fptypeN y) { return ::__tg_fmin(x, y); } + +/*! @abstract Generalizes the function fma to operate on vectors of + * floats and doubles. */ + template + static SIMD_CPPFUNC fptypeN fma(fptypeN x, fptypeN y, fptypeN z) { return ::__tg_fma(x, y, z); } + +/*! @abstract Computes x*y + z by the most efficient means available; either + * a fused multiply add or separate multiply and add. */ + template + static SIMD_CPPFUNC fptypeN muladd(fptypeN x, fptypeN y, fptypeN z) { return ::simd_muladd(x, y, z); } +}; + +extern "C" { +#else +#include +/* C and Objective-C, we need some infrastructure to piggyback on tgmath.h */ +static SIMD_OVERLOAD simd_float2 __tg_promote(simd_float2); +static SIMD_OVERLOAD simd_float3 __tg_promote(simd_float3); +static SIMD_OVERLOAD simd_float4 __tg_promote(simd_float4); +static SIMD_OVERLOAD simd_float8 __tg_promote(simd_float8); +static SIMD_OVERLOAD simd_float16 __tg_promote(simd_float16); +static SIMD_OVERLOAD simd_double2 __tg_promote(simd_double2); +static SIMD_OVERLOAD simd_double3 __tg_promote(simd_double3); +static SIMD_OVERLOAD simd_double4 __tg_promote(simd_double4); +static SIMD_OVERLOAD simd_double8 __tg_promote(simd_double8); + +/* Apple extensions to , added in macOS 10.9 and iOS 7.0 */ +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_9 || \ + __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0 || \ + __DRIVERKIT_VERSION_MIN_REQUIRED >= __DRIVERKIT_19_0 +static inline SIMD_CFUNC float __tg_cospi(float x) { return __cospif(x); } +static inline SIMD_CFUNC double __tg_cospi(double x) { return __cospi(x); } +#undef cospi +/*! @abstract `cospi(x)` computes `cos(pi * x)` without intermediate rounding. + * + * @discussion Both faster and more accurate than multiplying by `pi` and then + * calling `cos`. Defined for `float` and `double` as well as vectors of + * floats and doubles as provided by ``. */ +#define cospi(__x) __tg_cospi(__tg_promote1((__x))(__x)) + +static inline SIMD_CFUNC float __tg_sinpi(float x) { return __sinpif(x); } +static inline SIMD_CFUNC double __tg_sinpi(double x) { return __sinpi(x); } +#undef sinpi +/*! @abstract `sinpi(x)` computes `sin(pi * x)` without intermediate rounding. + * + * @discussion Both faster and more accurate than multiplying by `pi` and then + * calling `sin`. Defined for `float` and `double` as well as vectors + * of floats and doubles as provided by ``. */ +#define sinpi(__x) __tg_sinpi(__tg_promote1((__x))(__x)) + +static inline SIMD_CFUNC float __tg_tanpi(float x) { return __tanpif(x); } +static inline SIMD_CFUNC double __tg_tanpi(double x) { return __tanpi(x); } +#undef tanpi +/*! @abstract `tanpi(x)` computes `tan(pi * x)` without intermediate rounding. + * + * @discussion Both faster and more accurate than multiplying by `pi` and then + * calling `tan`. Defined for `float` and `double` as well as vectors of + * floats and doubles as provided by ``. */ +#define tanpi(__x) __tg_tanpi(__tg_promote1((__x))(__x)) + +static inline SIMD_CFUNC float __tg_exp10(float x) { return __exp10f(x); } +static inline SIMD_CFUNC double __tg_exp10(double x) { return __exp10(x); } +#undef exp10 +/*! @abstract `exp10(x)` computes `10**x` more efficiently and accurately + * than `pow(10, x)`. + * + * @discussion Defined for `float` and `double` as well as vectors of floats + * and doubles as provided by ``. */ +#define exp10(__x) __tg_exp10(__tg_promote1((__x))(__x)) +#endif + + +#endif /* !__cplusplus */ + +#pragma mark - fabs implementation +static inline SIMD_CFUNC simd_float2 __tg_fabs(simd_float2 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float3 __tg_fabs(simd_float3 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float4 __tg_fabs(simd_float4 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float8 __tg_fabs(simd_float8 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float16 __tg_fabs(simd_float16 x) { return simd_bitselect(0.0, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_double2 __tg_fabs(simd_double2 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double3 __tg_fabs(simd_double3 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double4 __tg_fabs(simd_double4 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double8 __tg_fabs(simd_double8 x) { return simd_bitselect(0.0, x, 0x7fffffffffffffffL); } + +#pragma mark - fmin, fmax implementation +static SIMD_CFUNC simd_float2 __tg_fmin(simd_float2 x, simd_float2 y) { +#if defined __SSE2__ + return simd_make_float2(__tg_fmin(simd_make_float4_undef(x), simd_make_float4_undef(y))); +#elif defined __arm64__ + return vminnm_f32(x, y); +#elif defined __arm__ && __FINITE_MATH_ONLY__ + return vmin_f32(x, y); +#else + return simd_bitselect(y, x, (x <= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_fmin(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_fmin(simd_make_float4_undef(x), simd_make_float4_undef(y))); +} + +static SIMD_CFUNC simd_float4 __tg_fmin(simd_float4 x, simd_float4 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__ + return _mm_range_ps(x, y, 4); +#elif defined __SSE2__ && __FINITE_MATH_ONLY__ + return _mm_min_ps(x, y); +#elif defined __SSE2__ + return simd_bitselect(_mm_min_ps(x, y), x, y != y); +#elif defined __arm64__ + return vminnmq_f32(x, y); +#elif defined __arm__ && __FINITE_MATH_ONLY__ + return vminq_f32(x, y); +#else + return simd_bitselect(y, x, (x <= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_fmin(simd_float8 x, simd_float8 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__ + return _mm256_range_ps(x, y, 4); +#elif defined __AVX__ && __FINITE_MATH_ONLY__ + return _mm256_min_ps(x, y); +#elif defined __AVX__ + return simd_bitselect(_mm256_min_ps(x, y), x, y != y); +#else + return simd_make_float8(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_fmin(simd_float16 x, simd_float16 y) { +#if defined __x86_64__ && defined __AVX512DQ__ && !__FINITE_MATH_ONLY__ + return _mm512_range_ps(x, y, 4); +#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__ + return _mm512_min_ps(x, y); +#elif defined __x86_64__ && defined __AVX512F__ + return simd_bitselect(_mm512_min_ps(x, y), x, y != y); +#else + return simd_make_float16(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_double2 __tg_fmin(simd_double2 x, simd_double2 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ + return _mm_range_pd(x, y, 4); +#elif defined __SSE2__ && __FINITE_MATH_ONLY__ + return _mm_min_pd(x, y); +#elif defined __SSE2__ + return simd_bitselect(_mm_min_pd(x, y), x, y != y); +#elif defined __arm64__ + return vminnmq_f64(x, y); +#else + return simd_bitselect(y, x, (x <= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_fmin(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_fmin(simd_make_double4_undef(x), simd_make_double4_undef(y))); +} + +static SIMD_CFUNC simd_double4 __tg_fmin(simd_double4 x, simd_double4 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ + return _mm256_range_pd(x, y, 4); +#elif defined __AVX__ && __FINITE_MATH_ONLY__ + return _mm256_min_pd(x, y); +#elif defined __AVX__ + return simd_bitselect(_mm256_min_pd(x, y), x, y != y); +#else + return simd_make_double4(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_fmin(simd_double8 x, simd_double8 y) { +#if defined __x86_64__ && defined __AVX512DQ__ + return _mm512_range_pd(x, y, 4); +#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__ + return _mm512_min_pd(x, y); +#elif defined __x86_64__ && defined __AVX512F__ + return simd_bitselect(_mm512_min_pd(x, y), x, y != y); +#else + return simd_make_double8(__tg_fmin(x.lo, y.lo), __tg_fmin(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_float2 __tg_fmax(simd_float2 x, simd_float2 y) { +#if defined __SSE2__ + return simd_make_float2(__tg_fmax(simd_make_float4_undef(x), simd_make_float4_undef(y))); +#elif defined __arm64__ + return vmaxnm_f32(x, y); +#elif defined __arm__ && __FINITE_MATH_ONLY__ + return vmax_f32(x, y); +#else + return simd_bitselect(y, x, (x >= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_fmax(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_fmax(simd_make_float4_undef(x), simd_make_float4_undef(y))); +} + +static SIMD_CFUNC simd_float4 __tg_fmax(simd_float4 x, simd_float4 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__ + return _mm_range_ps(x, y, 5); +#elif defined __SSE2__ && __FINITE_MATH_ONLY__ + return _mm_max_ps(x, y); +#elif defined __SSE2__ + return simd_bitselect(_mm_max_ps(x, y), x, y != y); +#elif defined __arm64__ + return vmaxnmq_f32(x, y); +#elif defined __arm__ && __FINITE_MATH_ONLY__ + return vmaxq_f32(x, y); +#else + return simd_bitselect(y, x, (x >= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_fmax(simd_float8 x, simd_float8 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ && !__FINITE_MATH_ONLY__ + return _mm256_range_ps(x, y, 5); +#elif defined __AVX__ && __FINITE_MATH_ONLY__ + return _mm256_max_ps(x, y); +#elif defined __AVX__ + return simd_bitselect(_mm256_max_ps(x, y), x, y != y); +#else + return simd_make_float8(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_fmax(simd_float16 x, simd_float16 y) { +#if defined __x86_64__ && defined __AVX512DQ__ && !__FINITE_MATH_ONLY__ + return _mm512_range_ps(x, y, 5); +#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__ + return _mm512_max_ps(x, y); +#elif defined __x86_64__ && defined __AVX512F__ + return simd_bitselect(_mm512_max_ps(x, y), x, y != y); +#else + return simd_make_float16(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_double2 __tg_fmax(simd_double2 x, simd_double2 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ + return _mm_range_pd(x, y, 5); +#elif defined __SSE2__ && __FINITE_MATH_ONLY__ + return _mm_max_pd(x, y); +#elif defined __SSE2__ + return simd_bitselect(_mm_max_pd(x, y), x, y != y); +#elif defined __arm64__ + return vmaxnmq_f64(x, y); +#else + return simd_bitselect(y, x, (x >= y) | (y != y)); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_fmax(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_fmax(simd_make_double4_undef(x), simd_make_double4_undef(y))); +} + +static SIMD_CFUNC simd_double4 __tg_fmax(simd_double4 x, simd_double4 y) { +#if defined __AVX512DQ__ && defined __AVX512VL__ + return _mm256_range_pd(x, y, 5); +#elif defined __AVX__ && __FINITE_MATH_ONLY__ + return _mm256_max_pd(x, y); +#elif defined __AVX__ + return simd_bitselect(_mm256_max_pd(x, y), x, y != y); +#else + return simd_make_double4(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_fmax(simd_double8 x, simd_double8 y) { +#if defined __x86_64__ && defined __AVX512DQ__ + return _mm512_range_pd(x, y, 5); +#elif defined __x86_64__ && defined __AVX512F__ && __FINITE_MATH_ONLY__ + return _mm512_max_pd(x, y); +#elif defined __x86_64__ && defined __AVX512F__ + return simd_bitselect(_mm512_max_pd(x, y), x, y != y); +#else + return simd_make_double8(__tg_fmax(x.lo, y.lo), __tg_fmax(x.hi, y.hi)); +#endif +} + +#pragma mark - copysign implementation +static inline SIMD_CFUNC simd_float2 __tg_copysign(simd_float2 x, simd_float2 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float3 __tg_copysign(simd_float3 x, simd_float3 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float4 __tg_copysign(simd_float4 x, simd_float4 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float8 __tg_copysign(simd_float8 x, simd_float8 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_float16 __tg_copysign(simd_float16 x, simd_float16 y) { return simd_bitselect(y, x, 0x7fffffff); } +static inline SIMD_CFUNC simd_double2 __tg_copysign(simd_double2 x, simd_double2 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double3 __tg_copysign(simd_double3 x, simd_double3 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double4 __tg_copysign(simd_double4 x, simd_double4 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); } +static inline SIMD_CFUNC simd_double8 __tg_copysign(simd_double8 x, simd_double8 y) { return simd_bitselect(y, x, 0x7fffffffffffffffL); } + +#pragma mark - sqrt implementation +static SIMD_CFUNC simd_float2 __tg_sqrt(simd_float2 x) { +#if defined __SSE2__ + return simd_make_float2(__tg_sqrt(simd_make_float4_undef(x))); +#elif defined __arm64__ + return vsqrt_f32(x); +#else + return simd_make_float2(sqrt(x.x), sqrt(x.y)); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_sqrt(simd_float3 x) { + return simd_make_float3(__tg_sqrt(simd_make_float4_undef(x))); +} + +static SIMD_CFUNC simd_float4 __tg_sqrt(simd_float4 x) { +#if defined __SSE2__ + return _mm_sqrt_ps(x); +#elif defined __arm64__ + return vsqrtq_f32(x); +#else + return simd_make_float4(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_sqrt(simd_float8 x) { +#if defined __AVX__ + return _mm256_sqrt_ps(x); +#else + return simd_make_float8(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_sqrt(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_sqrt_ps(x); +#else + return simd_make_float16(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double2 __tg_sqrt(simd_double2 x) { +#if defined __SSE2__ + return _mm_sqrt_pd(x); +#elif defined __arm64__ + return vsqrtq_f64(x); +#else + return simd_make_double2(sqrt(x.x), sqrt(x.y)); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_sqrt(simd_double3 x) { + return simd_make_double3(__tg_sqrt(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_sqrt(simd_double4 x) { +#if defined __AVX__ + return _mm256_sqrt_pd(x); +#else + return simd_make_double4(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_sqrt(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_sqrt_pd(x); +#else + return simd_make_double8(__tg_sqrt(x.lo), __tg_sqrt(x.hi)); +#endif +} + +#pragma mark - ceil, floor, rint, trunc implementation +static SIMD_CFUNC simd_float2 __tg_ceil(simd_float2 x) { +#if defined __arm64__ + return vrndp_f32(x); +#else + return simd_make_float2(__tg_ceil(simd_make_float4_undef(x))); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_ceil(simd_float3 x) { + return simd_make_float3(__tg_ceil(simd_make_float4_undef(x))); +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_ceil_f4(simd_float4 x); +#endif + +static SIMD_CFUNC simd_float4 __tg_ceil(simd_float4 x) { +#if defined __SSE4_1__ + return _mm_round_ps(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndpq_f32(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_ceil_f4(x); +#else + simd_float4 truncated = __tg_trunc(x); + simd_float4 adjust = simd_bitselect((simd_float4)0, 1, truncated < x); + return __tg_copysign(truncated + adjust, x); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_ceil(simd_float8 x) { +#if defined __AVX__ + return _mm256_round_ps(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_float8(__tg_ceil(x.lo), __tg_ceil(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_ceil(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_ps(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_float16(__tg_ceil(x.lo), __tg_ceil(x.hi)); +#endif +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_ceil_d2(simd_double2 x); +#endif + +static SIMD_CFUNC simd_double2 __tg_ceil(simd_double2 x) { +#if defined __SSE4_1__ + return _mm_round_pd(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndpq_f64(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_ceil_d2(x); +#else + simd_double2 truncated = __tg_trunc(x); + simd_double2 adjust = simd_bitselect((simd_double2)0, 1, truncated < x); + return __tg_copysign(truncated + adjust, x); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_ceil(simd_double3 x) { + return simd_make_double3(__tg_ceil(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_ceil(simd_double4 x) { +#if defined __AVX__ + return _mm256_round_pd(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_double4(__tg_ceil(x.lo), __tg_ceil(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_ceil(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_pd(x, _MM_FROUND_TO_POS_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_double8(__tg_ceil(x.lo), __tg_ceil(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float2 __tg_floor(simd_float2 x) { +#if defined __arm64__ + return vrndm_f32(x); +#else + return simd_make_float2(__tg_floor(simd_make_float4_undef(x))); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_floor(simd_float3 x) { + return simd_make_float3(__tg_floor(simd_make_float4_undef(x))); +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_floor_f4(simd_float4 x); +#endif + +static SIMD_CFUNC simd_float4 __tg_floor(simd_float4 x) { +#if defined __SSE4_1__ + return _mm_round_ps(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndmq_f32(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_floor_f4(x); +#else + simd_float4 truncated = __tg_trunc(x); + simd_float4 adjust = simd_bitselect((simd_float4)0, 1, truncated > x); + return truncated - adjust; +#endif +} + +static SIMD_CFUNC simd_float8 __tg_floor(simd_float8 x) { +#if defined __AVX__ + return _mm256_round_ps(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_float8(__tg_floor(x.lo), __tg_floor(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_floor(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_ps(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_float16(__tg_floor(x.lo), __tg_floor(x.hi)); +#endif +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_floor_d2(simd_double2 x); +#endif + +static SIMD_CFUNC simd_double2 __tg_floor(simd_double2 x) { +#if defined __SSE4_1__ + return _mm_round_pd(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndmq_f64(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_floor_d2(x); +#else + simd_double2 truncated = __tg_trunc(x); + simd_double2 adjust = simd_bitselect((simd_double2)0, 1, truncated > x); + return truncated - adjust; +#endif +} + +static SIMD_CFUNC simd_double3 __tg_floor(simd_double3 x) { + return simd_make_double3(__tg_floor(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_floor(simd_double4 x) { +#if defined __AVX__ + return _mm256_round_pd(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_double4(__tg_floor(x.lo), __tg_floor(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_floor(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_pd(x, _MM_FROUND_TO_NEG_INF | _MM_FROUND_NO_EXC); +#else + return simd_make_double8(__tg_floor(x.lo), __tg_floor(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float2 __tg_rint(simd_float2 x) { +#if defined __arm64__ + return vrndx_f32(x); +#else + return simd_make_float2(__tg_rint(simd_make_float4_undef(x))); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_rint(simd_float3 x) { + return simd_make_float3(__tg_rint(simd_make_float4_undef(x))); +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_rint_f4(simd_float4 x); +#endif + +static SIMD_CFUNC simd_float4 __tg_rint(simd_float4 x) { +#if defined __SSE4_1__ + return _mm_round_ps(x, _MM_FROUND_RINT); +#elif defined __arm64__ + return vrndxq_f32(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_rint_f4(x); +#else + simd_float4 magic = __tg_copysign(0x1.0p23, x); + simd_int4 x_is_small = __tg_fabs(x) < 0x1.0p23; + return simd_bitselect(x, (x + magic) - magic, x_is_small & 0x7fffffff); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_rint(simd_float8 x) { +#if defined __AVX__ + return _mm256_round_ps(x, _MM_FROUND_RINT); +#else + return simd_make_float8(__tg_rint(x.lo), __tg_rint(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_rint(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_ps(x, _MM_FROUND_RINT); +#else + return simd_make_float16(__tg_rint(x.lo), __tg_rint(x.hi)); +#endif +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_rint_d2(simd_double2 x); +#endif + +static SIMD_CFUNC simd_double2 __tg_rint(simd_double2 x) { +#if defined __SSE4_1__ + return _mm_round_pd(x, _MM_FROUND_RINT); +#elif defined __arm64__ + return vrndxq_f64(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_rint_d2(x); +#else + simd_double2 magic = __tg_copysign(0x1.0p52, x); + simd_long2 x_is_small = __tg_fabs(x) < 0x1.0p52; + return simd_bitselect(x, (x + magic) - magic, x_is_small & 0x7fffffffffffffff); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_rint(simd_double3 x) { + return simd_make_double3(__tg_rint(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_rint(simd_double4 x) { +#if defined __AVX__ + return _mm256_round_pd(x, _MM_FROUND_RINT); +#else + return simd_make_double4(__tg_rint(x.lo), __tg_rint(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_rint(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_pd(x, _MM_FROUND_RINT); +#else + return simd_make_double8(__tg_rint(x.lo), __tg_rint(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float2 __tg_trunc(simd_float2 x) { +#if defined __arm64__ + return vrnd_f32(x); +#else + return simd_make_float2(__tg_trunc(simd_make_float4_undef(x))); +#endif +} + +static SIMD_CFUNC simd_float3 __tg_trunc(simd_float3 x) { + return simd_make_float3(__tg_trunc(simd_make_float4_undef(x))); +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_trunc_f4(simd_float4 x); +#endif + +static SIMD_CFUNC simd_float4 __tg_trunc(simd_float4 x) { +#if defined __SSE4_1__ + return _mm_round_ps(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndq_f32(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_trunc_f4(x); +#else + simd_float4 binade = simd_bitselect(0, x, 0x7f800000); + simd_int4 mask = (simd_int4)__tg_fmin(-2*binade + 1, -0); + simd_float4 result = simd_bitselect(0, x, mask); + return simd_bitselect(x, result, binade < 0x1.0p23); +#endif +} + +static SIMD_CFUNC simd_float8 __tg_trunc(simd_float8 x) { +#if defined __AVX__ + return _mm256_round_ps(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#else + return simd_make_float8(__tg_trunc(x.lo), __tg_trunc(x.hi)); +#endif +} + +static SIMD_CFUNC simd_float16 __tg_trunc(simd_float16 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_ps(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#else + return simd_make_float16(__tg_trunc(x.lo), __tg_trunc(x.hi)); +#endif +} + +#if defined __arm__ && SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_trunc_d2(simd_double2 x); +#endif + +static SIMD_CFUNC simd_double2 __tg_trunc(simd_double2 x) { +#if defined __SSE4_1__ + return _mm_round_pd(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#elif defined __arm64__ + return vrndq_f64(x); +#elif defined __arm__ && SIMD_LIBRARY_VERSION >= 3 + return _simd_trunc_d2(x); +#else + simd_double2 binade = simd_bitselect(0, x, 0x7ff0000000000000); + simd_long2 mask = (simd_long2)__tg_fmin(-2*binade + 1, -0); + simd_double2 result = simd_bitselect(0, x, mask); + return simd_bitselect(x, result, binade < 0x1.0p52); +#endif +} + +static SIMD_CFUNC simd_double3 __tg_trunc(simd_double3 x) { + return simd_make_double3(__tg_trunc(simd_make_double4_undef(x))); +} + +static SIMD_CFUNC simd_double4 __tg_trunc(simd_double4 x) { +#if defined __AVX__ + return _mm256_round_pd(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#else + return simd_make_double4(__tg_trunc(x.lo), __tg_trunc(x.hi)); +#endif +} + +static SIMD_CFUNC simd_double8 __tg_trunc(simd_double8 x) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_roundscale_pd(x, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +#else + return simd_make_double8(__tg_trunc(x.lo), __tg_trunc(x.hi)); +#endif +} + +#pragma mark - sine, cosine implementation +static inline SIMD_CFUNC simd_float2 __tg_sin(simd_float2 x) { + return simd_make_float2(__tg_sin(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_sin(simd_float3 x) { + return simd_make_float3(__tg_sin(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_sin_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x) { + return _simd_sin_f4(x); +} +#elif SIMD_LIBRARY_VERSION == 1 +extern simd_float4 __sin_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x) { + return __sin_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_sin(simd_float4 x) { + return simd_make_float4(sin(x.x), sin(x.y), sin(x.z), sin(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_sin_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_sin(simd_float8 x) { + return _simd_sin_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_sin(simd_float8 x) { + return simd_make_float8(__tg_sin(x.lo), __tg_sin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_sin_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_sin(simd_float16 x) { + return _simd_sin_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_sin(simd_float16 x) { + return simd_make_float16(__tg_sin(x.lo), __tg_sin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_sin_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x) { + return _simd_sin_d2(x); +} +#elif SIMD_LIBRARY_VERSION == 1 +extern simd_double2 __sin_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x) { + return __sin_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_sin(simd_double2 x) { + return simd_make_double2(sin(x.x), sin(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_sin(simd_double3 x) { + return simd_make_double3(__tg_sin(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_sin_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_sin(simd_double4 x) { + return _simd_sin_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_sin(simd_double4 x) { + return simd_make_double4(__tg_sin(x.lo), __tg_sin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_sin_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_sin(simd_double8 x) { + return _simd_sin_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_sin(simd_double8 x) { + return simd_make_double8(__tg_sin(x.lo), __tg_sin(x.hi)); +} +#endif + +static inline SIMD_CFUNC simd_float2 __tg_cos(simd_float2 x) { + return simd_make_float2(__tg_cos(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_cos(simd_float3 x) { + return simd_make_float3(__tg_cos(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_cos_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x) { + return _simd_cos_f4(x); +} +#elif SIMD_LIBRARY_VERSION == 1 +extern simd_float4 __cos_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x) { + return __cos_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_cos(simd_float4 x) { + return simd_make_float4(cos(x.x), cos(x.y), cos(x.z), cos(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_cos_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_cos(simd_float8 x) { + return _simd_cos_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_cos(simd_float8 x) { + return simd_make_float8(__tg_cos(x.lo), __tg_cos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_cos_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_cos(simd_float16 x) { + return _simd_cos_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_cos(simd_float16 x) { + return simd_make_float16(__tg_cos(x.lo), __tg_cos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_cos_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x) { + return _simd_cos_d2(x); +} +#elif SIMD_LIBRARY_VERSION == 1 +extern simd_double2 __cos_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x) { + return __cos_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_cos(simd_double2 x) { + return simd_make_double2(cos(x.x), cos(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_cos(simd_double3 x) { + return simd_make_double3(__tg_cos(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_cos_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_cos(simd_double4 x) { + return _simd_cos_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_cos(simd_double4 x) { + return simd_make_double4(__tg_cos(x.lo), __tg_cos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_cos_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_cos(simd_double8 x) { + return _simd_cos_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_cos(simd_double8 x) { + return simd_make_double8(__tg_cos(x.lo), __tg_cos(x.hi)); +} +#endif + + +#pragma mark - acos implementation +static inline SIMD_CFUNC simd_float2 __tg_acos(simd_float2 x) { + return simd_make_float2(__tg_acos(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_acos(simd_float3 x) { + return simd_make_float3(__tg_acos(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_acos_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_acos(simd_float4 x) { + return _simd_acos_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_acos(simd_float4 x) { + return simd_make_float4(acos(x.x), acos(x.y), acos(x.z), acos(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_acos_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_acos(simd_float8 x) { + return _simd_acos_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_acos(simd_float8 x) { + return simd_make_float8(__tg_acos(x.lo), __tg_acos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_acos_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_acos(simd_float16 x) { + return _simd_acos_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_acos(simd_float16 x) { + return simd_make_float16(__tg_acos(x.lo), __tg_acos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_acos_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_acos(simd_double2 x) { + return _simd_acos_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_acos(simd_double2 x) { + return simd_make_double2(acos(x.x), acos(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_acos(simd_double3 x) { + return simd_make_double3(__tg_acos(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_acos_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_acos(simd_double4 x) { + return _simd_acos_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_acos(simd_double4 x) { + return simd_make_double4(__tg_acos(x.lo), __tg_acos(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_acos_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_acos(simd_double8 x) { + return _simd_acos_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_acos(simd_double8 x) { + return simd_make_double8(__tg_acos(x.lo), __tg_acos(x.hi)); +} +#endif + +#pragma mark - asin implementation +static inline SIMD_CFUNC simd_float2 __tg_asin(simd_float2 x) { + return simd_make_float2(__tg_asin(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_asin(simd_float3 x) { + return simd_make_float3(__tg_asin(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_asin_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_asin(simd_float4 x) { + return _simd_asin_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_asin(simd_float4 x) { + return simd_make_float4(asin(x.x), asin(x.y), asin(x.z), asin(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_asin_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_asin(simd_float8 x) { + return _simd_asin_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_asin(simd_float8 x) { + return simd_make_float8(__tg_asin(x.lo), __tg_asin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_asin_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_asin(simd_float16 x) { + return _simd_asin_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_asin(simd_float16 x) { + return simd_make_float16(__tg_asin(x.lo), __tg_asin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_asin_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_asin(simd_double2 x) { + return _simd_asin_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_asin(simd_double2 x) { + return simd_make_double2(asin(x.x), asin(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_asin(simd_double3 x) { + return simd_make_double3(__tg_asin(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_asin_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_asin(simd_double4 x) { + return _simd_asin_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_asin(simd_double4 x) { + return simd_make_double4(__tg_asin(x.lo), __tg_asin(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_asin_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_asin(simd_double8 x) { + return _simd_asin_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_asin(simd_double8 x) { + return simd_make_double8(__tg_asin(x.lo), __tg_asin(x.hi)); +} +#endif + +#pragma mark - atan implementation +static inline SIMD_CFUNC simd_float2 __tg_atan(simd_float2 x) { + return simd_make_float2(__tg_atan(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_atan(simd_float3 x) { + return simd_make_float3(__tg_atan(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_atan_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_atan(simd_float4 x) { + return _simd_atan_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_atan(simd_float4 x) { + return simd_make_float4(atan(x.x), atan(x.y), atan(x.z), atan(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_atan_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_atan(simd_float8 x) { + return _simd_atan_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_atan(simd_float8 x) { + return simd_make_float8(__tg_atan(x.lo), __tg_atan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_atan_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_atan(simd_float16 x) { + return _simd_atan_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_atan(simd_float16 x) { + return simd_make_float16(__tg_atan(x.lo), __tg_atan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_atan_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_atan(simd_double2 x) { + return _simd_atan_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_atan(simd_double2 x) { + return simd_make_double2(atan(x.x), atan(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_atan(simd_double3 x) { + return simd_make_double3(__tg_atan(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_atan_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_atan(simd_double4 x) { + return _simd_atan_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_atan(simd_double4 x) { + return simd_make_double4(__tg_atan(x.lo), __tg_atan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_atan_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_atan(simd_double8 x) { + return _simd_atan_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_atan(simd_double8 x) { + return simd_make_double8(__tg_atan(x.lo), __tg_atan(x.hi)); +} +#endif + +#pragma mark - tan implementation +static inline SIMD_CFUNC simd_float2 __tg_tan(simd_float2 x) { + return simd_make_float2(__tg_tan(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_tan(simd_float3 x) { + return simd_make_float3(__tg_tan(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_tan_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_tan(simd_float4 x) { + return _simd_tan_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_tan(simd_float4 x) { + return simd_make_float4(tan(x.x), tan(x.y), tan(x.z), tan(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_tan_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_tan(simd_float8 x) { + return _simd_tan_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_tan(simd_float8 x) { + return simd_make_float8(__tg_tan(x.lo), __tg_tan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_tan_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_tan(simd_float16 x) { + return _simd_tan_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_tan(simd_float16 x) { + return simd_make_float16(__tg_tan(x.lo), __tg_tan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_tan_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_tan(simd_double2 x) { + return _simd_tan_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_tan(simd_double2 x) { + return simd_make_double2(tan(x.x), tan(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_tan(simd_double3 x) { + return simd_make_double3(__tg_tan(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_tan_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_tan(simd_double4 x) { + return _simd_tan_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_tan(simd_double4 x) { + return simd_make_double4(__tg_tan(x.lo), __tg_tan(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_tan_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_tan(simd_double8 x) { + return _simd_tan_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_tan(simd_double8 x) { + return simd_make_double8(__tg_tan(x.lo), __tg_tan(x.hi)); +} +#endif + +#pragma mark - cospi implementation +#if SIMD_LIBRARY_VERSION >= 1 +static inline SIMD_CFUNC simd_float2 __tg_cospi(simd_float2 x) { + return simd_make_float2(__tg_cospi(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_cospi(simd_float3 x) { + return simd_make_float3(__tg_cospi(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_cospi_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cospi(simd_float4 x) { + return _simd_cospi_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_cospi(simd_float4 x) { + return simd_make_float4(__cospi(x.x), __cospi(x.y), __cospi(x.z), __cospi(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_cospi_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_cospi(simd_float8 x) { + return _simd_cospi_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_cospi(simd_float8 x) { + return simd_make_float8(__tg_cospi(x.lo), __tg_cospi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_cospi_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_cospi(simd_float16 x) { + return _simd_cospi_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_cospi(simd_float16 x) { + return simd_make_float16(__tg_cospi(x.lo), __tg_cospi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_cospi_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cospi(simd_double2 x) { + return _simd_cospi_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_cospi(simd_double2 x) { + return simd_make_double2(__cospi(x.x), __cospi(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_cospi(simd_double3 x) { + return simd_make_double3(__tg_cospi(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_cospi_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_cospi(simd_double4 x) { + return _simd_cospi_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_cospi(simd_double4 x) { + return simd_make_double4(__tg_cospi(x.lo), __tg_cospi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_cospi_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_cospi(simd_double8 x) { + return _simd_cospi_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_cospi(simd_double8 x) { + return simd_make_double8(__tg_cospi(x.lo), __tg_cospi(x.hi)); +} +#endif + +#endif /* SIMD_LIBRARY_VERSION */ +#pragma mark - sinpi implementation +#if SIMD_LIBRARY_VERSION >= 1 +static inline SIMD_CFUNC simd_float2 __tg_sinpi(simd_float2 x) { + return simd_make_float2(__tg_sinpi(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_sinpi(simd_float3 x) { + return simd_make_float3(__tg_sinpi(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_sinpi_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_sinpi(simd_float4 x) { + return _simd_sinpi_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_sinpi(simd_float4 x) { + return simd_make_float4(__sinpi(x.x), __sinpi(x.y), __sinpi(x.z), __sinpi(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_sinpi_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_sinpi(simd_float8 x) { + return _simd_sinpi_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_sinpi(simd_float8 x) { + return simd_make_float8(__tg_sinpi(x.lo), __tg_sinpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_sinpi_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_sinpi(simd_float16 x) { + return _simd_sinpi_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_sinpi(simd_float16 x) { + return simd_make_float16(__tg_sinpi(x.lo), __tg_sinpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_sinpi_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_sinpi(simd_double2 x) { + return _simd_sinpi_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_sinpi(simd_double2 x) { + return simd_make_double2(__sinpi(x.x), __sinpi(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_sinpi(simd_double3 x) { + return simd_make_double3(__tg_sinpi(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_sinpi_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_sinpi(simd_double4 x) { + return _simd_sinpi_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_sinpi(simd_double4 x) { + return simd_make_double4(__tg_sinpi(x.lo), __tg_sinpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_sinpi_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_sinpi(simd_double8 x) { + return _simd_sinpi_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_sinpi(simd_double8 x) { + return simd_make_double8(__tg_sinpi(x.lo), __tg_sinpi(x.hi)); +} +#endif + +#endif /* SIMD_LIBRARY_VERSION */ +#pragma mark - tanpi implementation +#if SIMD_LIBRARY_VERSION >= 1 +static inline SIMD_CFUNC simd_float2 __tg_tanpi(simd_float2 x) { + return simd_make_float2(__tg_tanpi(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_tanpi(simd_float3 x) { + return simd_make_float3(__tg_tanpi(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_tanpi_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_tanpi(simd_float4 x) { + return _simd_tanpi_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_tanpi(simd_float4 x) { + return simd_make_float4(__tanpi(x.x), __tanpi(x.y), __tanpi(x.z), __tanpi(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_tanpi_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_tanpi(simd_float8 x) { + return _simd_tanpi_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_tanpi(simd_float8 x) { + return simd_make_float8(__tg_tanpi(x.lo), __tg_tanpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_tanpi_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_tanpi(simd_float16 x) { + return _simd_tanpi_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_tanpi(simd_float16 x) { + return simd_make_float16(__tg_tanpi(x.lo), __tg_tanpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_tanpi_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_tanpi(simd_double2 x) { + return _simd_tanpi_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_tanpi(simd_double2 x) { + return simd_make_double2(__tanpi(x.x), __tanpi(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_tanpi(simd_double3 x) { + return simd_make_double3(__tg_tanpi(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_tanpi_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_tanpi(simd_double4 x) { + return _simd_tanpi_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_tanpi(simd_double4 x) { + return simd_make_double4(__tg_tanpi(x.lo), __tg_tanpi(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_tanpi_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_tanpi(simd_double8 x) { + return _simd_tanpi_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_tanpi(simd_double8 x) { + return simd_make_double8(__tg_tanpi(x.lo), __tg_tanpi(x.hi)); +} +#endif + +#endif /* SIMD_LIBRARY_VERSION */ +#pragma mark - acosh implementation +static inline SIMD_CFUNC simd_float2 __tg_acosh(simd_float2 x) { + return simd_make_float2(__tg_acosh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_acosh(simd_float3 x) { + return simd_make_float3(__tg_acosh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_acosh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_acosh(simd_float4 x) { + return _simd_acosh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_acosh(simd_float4 x) { + return simd_make_float4(acosh(x.x), acosh(x.y), acosh(x.z), acosh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_acosh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_acosh(simd_float8 x) { + return _simd_acosh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_acosh(simd_float8 x) { + return simd_make_float8(__tg_acosh(x.lo), __tg_acosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_acosh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_acosh(simd_float16 x) { + return _simd_acosh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_acosh(simd_float16 x) { + return simd_make_float16(__tg_acosh(x.lo), __tg_acosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_acosh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_acosh(simd_double2 x) { + return _simd_acosh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_acosh(simd_double2 x) { + return simd_make_double2(acosh(x.x), acosh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_acosh(simd_double3 x) { + return simd_make_double3(__tg_acosh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_acosh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_acosh(simd_double4 x) { + return _simd_acosh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_acosh(simd_double4 x) { + return simd_make_double4(__tg_acosh(x.lo), __tg_acosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_acosh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_acosh(simd_double8 x) { + return _simd_acosh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_acosh(simd_double8 x) { + return simd_make_double8(__tg_acosh(x.lo), __tg_acosh(x.hi)); +} +#endif + +#pragma mark - asinh implementation +static inline SIMD_CFUNC simd_float2 __tg_asinh(simd_float2 x) { + return simd_make_float2(__tg_asinh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_asinh(simd_float3 x) { + return simd_make_float3(__tg_asinh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_asinh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_asinh(simd_float4 x) { + return _simd_asinh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_asinh(simd_float4 x) { + return simd_make_float4(asinh(x.x), asinh(x.y), asinh(x.z), asinh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_asinh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_asinh(simd_float8 x) { + return _simd_asinh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_asinh(simd_float8 x) { + return simd_make_float8(__tg_asinh(x.lo), __tg_asinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_asinh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_asinh(simd_float16 x) { + return _simd_asinh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_asinh(simd_float16 x) { + return simd_make_float16(__tg_asinh(x.lo), __tg_asinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_asinh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_asinh(simd_double2 x) { + return _simd_asinh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_asinh(simd_double2 x) { + return simd_make_double2(asinh(x.x), asinh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_asinh(simd_double3 x) { + return simd_make_double3(__tg_asinh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_asinh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_asinh(simd_double4 x) { + return _simd_asinh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_asinh(simd_double4 x) { + return simd_make_double4(__tg_asinh(x.lo), __tg_asinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_asinh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_asinh(simd_double8 x) { + return _simd_asinh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_asinh(simd_double8 x) { + return simd_make_double8(__tg_asinh(x.lo), __tg_asinh(x.hi)); +} +#endif + +#pragma mark - atanh implementation +static inline SIMD_CFUNC simd_float2 __tg_atanh(simd_float2 x) { + return simd_make_float2(__tg_atanh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_atanh(simd_float3 x) { + return simd_make_float3(__tg_atanh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_atanh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_atanh(simd_float4 x) { + return _simd_atanh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_atanh(simd_float4 x) { + return simd_make_float4(atanh(x.x), atanh(x.y), atanh(x.z), atanh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_atanh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_atanh(simd_float8 x) { + return _simd_atanh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_atanh(simd_float8 x) { + return simd_make_float8(__tg_atanh(x.lo), __tg_atanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_atanh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_atanh(simd_float16 x) { + return _simd_atanh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_atanh(simd_float16 x) { + return simd_make_float16(__tg_atanh(x.lo), __tg_atanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_atanh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_atanh(simd_double2 x) { + return _simd_atanh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_atanh(simd_double2 x) { + return simd_make_double2(atanh(x.x), atanh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_atanh(simd_double3 x) { + return simd_make_double3(__tg_atanh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_atanh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_atanh(simd_double4 x) { + return _simd_atanh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_atanh(simd_double4 x) { + return simd_make_double4(__tg_atanh(x.lo), __tg_atanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_atanh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_atanh(simd_double8 x) { + return _simd_atanh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_atanh(simd_double8 x) { + return simd_make_double8(__tg_atanh(x.lo), __tg_atanh(x.hi)); +} +#endif + +#pragma mark - cosh implementation +static inline SIMD_CFUNC simd_float2 __tg_cosh(simd_float2 x) { + return simd_make_float2(__tg_cosh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_cosh(simd_float3 x) { + return simd_make_float3(__tg_cosh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_cosh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cosh(simd_float4 x) { + return _simd_cosh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_cosh(simd_float4 x) { + return simd_make_float4(cosh(x.x), cosh(x.y), cosh(x.z), cosh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_cosh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_cosh(simd_float8 x) { + return _simd_cosh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_cosh(simd_float8 x) { + return simd_make_float8(__tg_cosh(x.lo), __tg_cosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_cosh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_cosh(simd_float16 x) { + return _simd_cosh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_cosh(simd_float16 x) { + return simd_make_float16(__tg_cosh(x.lo), __tg_cosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_cosh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cosh(simd_double2 x) { + return _simd_cosh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_cosh(simd_double2 x) { + return simd_make_double2(cosh(x.x), cosh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_cosh(simd_double3 x) { + return simd_make_double3(__tg_cosh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_cosh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_cosh(simd_double4 x) { + return _simd_cosh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_cosh(simd_double4 x) { + return simd_make_double4(__tg_cosh(x.lo), __tg_cosh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_cosh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_cosh(simd_double8 x) { + return _simd_cosh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_cosh(simd_double8 x) { + return simd_make_double8(__tg_cosh(x.lo), __tg_cosh(x.hi)); +} +#endif + +#pragma mark - sinh implementation +static inline SIMD_CFUNC simd_float2 __tg_sinh(simd_float2 x) { + return simd_make_float2(__tg_sinh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_sinh(simd_float3 x) { + return simd_make_float3(__tg_sinh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_sinh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_sinh(simd_float4 x) { + return _simd_sinh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_sinh(simd_float4 x) { + return simd_make_float4(sinh(x.x), sinh(x.y), sinh(x.z), sinh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_sinh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_sinh(simd_float8 x) { + return _simd_sinh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_sinh(simd_float8 x) { + return simd_make_float8(__tg_sinh(x.lo), __tg_sinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_sinh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_sinh(simd_float16 x) { + return _simd_sinh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_sinh(simd_float16 x) { + return simd_make_float16(__tg_sinh(x.lo), __tg_sinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_sinh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_sinh(simd_double2 x) { + return _simd_sinh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_sinh(simd_double2 x) { + return simd_make_double2(sinh(x.x), sinh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_sinh(simd_double3 x) { + return simd_make_double3(__tg_sinh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_sinh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_sinh(simd_double4 x) { + return _simd_sinh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_sinh(simd_double4 x) { + return simd_make_double4(__tg_sinh(x.lo), __tg_sinh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_sinh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_sinh(simd_double8 x) { + return _simd_sinh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_sinh(simd_double8 x) { + return simd_make_double8(__tg_sinh(x.lo), __tg_sinh(x.hi)); +} +#endif + +#pragma mark - tanh implementation +static inline SIMD_CFUNC simd_float2 __tg_tanh(simd_float2 x) { + return simd_make_float2(__tg_tanh(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_tanh(simd_float3 x) { + return simd_make_float3(__tg_tanh(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_tanh_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_tanh(simd_float4 x) { + return _simd_tanh_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_tanh(simd_float4 x) { + return simd_make_float4(tanh(x.x), tanh(x.y), tanh(x.z), tanh(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_tanh_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_tanh(simd_float8 x) { + return _simd_tanh_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_tanh(simd_float8 x) { + return simd_make_float8(__tg_tanh(x.lo), __tg_tanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_tanh_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_tanh(simd_float16 x) { + return _simd_tanh_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_tanh(simd_float16 x) { + return simd_make_float16(__tg_tanh(x.lo), __tg_tanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_tanh_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_tanh(simd_double2 x) { + return _simd_tanh_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_tanh(simd_double2 x) { + return simd_make_double2(tanh(x.x), tanh(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_tanh(simd_double3 x) { + return simd_make_double3(__tg_tanh(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_tanh_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_tanh(simd_double4 x) { + return _simd_tanh_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_tanh(simd_double4 x) { + return simd_make_double4(__tg_tanh(x.lo), __tg_tanh(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_tanh_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_tanh(simd_double8 x) { + return _simd_tanh_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_tanh(simd_double8 x) { + return simd_make_double8(__tg_tanh(x.lo), __tg_tanh(x.hi)); +} +#endif + +#pragma mark - exp implementation +static inline SIMD_CFUNC simd_float2 __tg_exp(simd_float2 x) { + return simd_make_float2(__tg_exp(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_exp(simd_float3 x) { + return simd_make_float3(__tg_exp(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_exp_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_exp(simd_float4 x) { + return _simd_exp_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_exp(simd_float4 x) { + return simd_make_float4(exp(x.x), exp(x.y), exp(x.z), exp(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_exp_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_exp(simd_float8 x) { + return _simd_exp_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_exp(simd_float8 x) { + return simd_make_float8(__tg_exp(x.lo), __tg_exp(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_exp_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_exp(simd_float16 x) { + return _simd_exp_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_exp(simd_float16 x) { + return simd_make_float16(__tg_exp(x.lo), __tg_exp(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_exp_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_exp(simd_double2 x) { + return _simd_exp_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_exp(simd_double2 x) { + return simd_make_double2(exp(x.x), exp(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_exp(simd_double3 x) { + return simd_make_double3(__tg_exp(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_exp_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_exp(simd_double4 x) { + return _simd_exp_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_exp(simd_double4 x) { + return simd_make_double4(__tg_exp(x.lo), __tg_exp(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_exp_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_exp(simd_double8 x) { + return _simd_exp_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_exp(simd_double8 x) { + return simd_make_double8(__tg_exp(x.lo), __tg_exp(x.hi)); +} +#endif + +#pragma mark - exp2 implementation +static inline SIMD_CFUNC simd_float2 __tg_exp2(simd_float2 x) { + return simd_make_float2(__tg_exp2(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_exp2(simd_float3 x) { + return simd_make_float3(__tg_exp2(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_exp2_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_exp2(simd_float4 x) { + return _simd_exp2_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_exp2(simd_float4 x) { + return simd_make_float4(exp2(x.x), exp2(x.y), exp2(x.z), exp2(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_exp2_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_exp2(simd_float8 x) { + return _simd_exp2_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_exp2(simd_float8 x) { + return simd_make_float8(__tg_exp2(x.lo), __tg_exp2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_exp2_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_exp2(simd_float16 x) { + return _simd_exp2_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_exp2(simd_float16 x) { + return simd_make_float16(__tg_exp2(x.lo), __tg_exp2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_exp2_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_exp2(simd_double2 x) { + return _simd_exp2_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_exp2(simd_double2 x) { + return simd_make_double2(exp2(x.x), exp2(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_exp2(simd_double3 x) { + return simd_make_double3(__tg_exp2(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_exp2_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_exp2(simd_double4 x) { + return _simd_exp2_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_exp2(simd_double4 x) { + return simd_make_double4(__tg_exp2(x.lo), __tg_exp2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_exp2_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_exp2(simd_double8 x) { + return _simd_exp2_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_exp2(simd_double8 x) { + return simd_make_double8(__tg_exp2(x.lo), __tg_exp2(x.hi)); +} +#endif + +#pragma mark - exp10 implementation +#if SIMD_LIBRARY_VERSION >= 1 +static inline SIMD_CFUNC simd_float2 __tg_exp10(simd_float2 x) { + return simd_make_float2(__tg_exp10(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_exp10(simd_float3 x) { + return simd_make_float3(__tg_exp10(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_exp10_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_exp10(simd_float4 x) { + return _simd_exp10_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_exp10(simd_float4 x) { + return simd_make_float4(__exp10(x.x), __exp10(x.y), __exp10(x.z), __exp10(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_exp10_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_exp10(simd_float8 x) { + return _simd_exp10_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_exp10(simd_float8 x) { + return simd_make_float8(__tg_exp10(x.lo), __tg_exp10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_exp10_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_exp10(simd_float16 x) { + return _simd_exp10_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_exp10(simd_float16 x) { + return simd_make_float16(__tg_exp10(x.lo), __tg_exp10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_exp10_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_exp10(simd_double2 x) { + return _simd_exp10_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_exp10(simd_double2 x) { + return simd_make_double2(__exp10(x.x), __exp10(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_exp10(simd_double3 x) { + return simd_make_double3(__tg_exp10(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_exp10_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_exp10(simd_double4 x) { + return _simd_exp10_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_exp10(simd_double4 x) { + return simd_make_double4(__tg_exp10(x.lo), __tg_exp10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_exp10_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_exp10(simd_double8 x) { + return _simd_exp10_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_exp10(simd_double8 x) { + return simd_make_double8(__tg_exp10(x.lo), __tg_exp10(x.hi)); +} +#endif + +#endif /* SIMD_LIBRARY_VERSION */ +#pragma mark - expm1 implementation +static inline SIMD_CFUNC simd_float2 __tg_expm1(simd_float2 x) { + return simd_make_float2(__tg_expm1(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_expm1(simd_float3 x) { + return simd_make_float3(__tg_expm1(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_expm1_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_expm1(simd_float4 x) { + return _simd_expm1_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_expm1(simd_float4 x) { + return simd_make_float4(expm1(x.x), expm1(x.y), expm1(x.z), expm1(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_expm1_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_expm1(simd_float8 x) { + return _simd_expm1_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_expm1(simd_float8 x) { + return simd_make_float8(__tg_expm1(x.lo), __tg_expm1(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_expm1_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_expm1(simd_float16 x) { + return _simd_expm1_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_expm1(simd_float16 x) { + return simd_make_float16(__tg_expm1(x.lo), __tg_expm1(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_expm1_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_expm1(simd_double2 x) { + return _simd_expm1_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_expm1(simd_double2 x) { + return simd_make_double2(expm1(x.x), expm1(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_expm1(simd_double3 x) { + return simd_make_double3(__tg_expm1(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_expm1_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_expm1(simd_double4 x) { + return _simd_expm1_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_expm1(simd_double4 x) { + return simd_make_double4(__tg_expm1(x.lo), __tg_expm1(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_expm1_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_expm1(simd_double8 x) { + return _simd_expm1_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_expm1(simd_double8 x) { + return simd_make_double8(__tg_expm1(x.lo), __tg_expm1(x.hi)); +} +#endif + +#pragma mark - log implementation +static inline SIMD_CFUNC simd_float2 __tg_log(simd_float2 x) { + return simd_make_float2(__tg_log(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_log(simd_float3 x) { + return simd_make_float3(__tg_log(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_log_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_log(simd_float4 x) { + return _simd_log_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_log(simd_float4 x) { + return simd_make_float4(log(x.x), log(x.y), log(x.z), log(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_log_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_log(simd_float8 x) { + return _simd_log_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_log(simd_float8 x) { + return simd_make_float8(__tg_log(x.lo), __tg_log(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_log_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_log(simd_float16 x) { + return _simd_log_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_log(simd_float16 x) { + return simd_make_float16(__tg_log(x.lo), __tg_log(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_log_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_log(simd_double2 x) { + return _simd_log_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_log(simd_double2 x) { + return simd_make_double2(log(x.x), log(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_log(simd_double3 x) { + return simd_make_double3(__tg_log(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_log_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_log(simd_double4 x) { + return _simd_log_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_log(simd_double4 x) { + return simd_make_double4(__tg_log(x.lo), __tg_log(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_log_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_log(simd_double8 x) { + return _simd_log_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_log(simd_double8 x) { + return simd_make_double8(__tg_log(x.lo), __tg_log(x.hi)); +} +#endif + +#pragma mark - log2 implementation +static inline SIMD_CFUNC simd_float2 __tg_log2(simd_float2 x) { + return simd_make_float2(__tg_log2(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_log2(simd_float3 x) { + return simd_make_float3(__tg_log2(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_log2_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_log2(simd_float4 x) { + return _simd_log2_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_log2(simd_float4 x) { + return simd_make_float4(log2(x.x), log2(x.y), log2(x.z), log2(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_log2_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_log2(simd_float8 x) { + return _simd_log2_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_log2(simd_float8 x) { + return simd_make_float8(__tg_log2(x.lo), __tg_log2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_log2_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_log2(simd_float16 x) { + return _simd_log2_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_log2(simd_float16 x) { + return simd_make_float16(__tg_log2(x.lo), __tg_log2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_log2_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_log2(simd_double2 x) { + return _simd_log2_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_log2(simd_double2 x) { + return simd_make_double2(log2(x.x), log2(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_log2(simd_double3 x) { + return simd_make_double3(__tg_log2(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_log2_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_log2(simd_double4 x) { + return _simd_log2_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_log2(simd_double4 x) { + return simd_make_double4(__tg_log2(x.lo), __tg_log2(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_log2_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_log2(simd_double8 x) { + return _simd_log2_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_log2(simd_double8 x) { + return simd_make_double8(__tg_log2(x.lo), __tg_log2(x.hi)); +} +#endif + +#pragma mark - log10 implementation +static inline SIMD_CFUNC simd_float2 __tg_log10(simd_float2 x) { + return simd_make_float2(__tg_log10(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_log10(simd_float3 x) { + return simd_make_float3(__tg_log10(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_log10_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_log10(simd_float4 x) { + return _simd_log10_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_log10(simd_float4 x) { + return simd_make_float4(log10(x.x), log10(x.y), log10(x.z), log10(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_log10_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_log10(simd_float8 x) { + return _simd_log10_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_log10(simd_float8 x) { + return simd_make_float8(__tg_log10(x.lo), __tg_log10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_log10_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_log10(simd_float16 x) { + return _simd_log10_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_log10(simd_float16 x) { + return simd_make_float16(__tg_log10(x.lo), __tg_log10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_log10_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_log10(simd_double2 x) { + return _simd_log10_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_log10(simd_double2 x) { + return simd_make_double2(log10(x.x), log10(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_log10(simd_double3 x) { + return simd_make_double3(__tg_log10(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_log10_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_log10(simd_double4 x) { + return _simd_log10_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_log10(simd_double4 x) { + return simd_make_double4(__tg_log10(x.lo), __tg_log10(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_log10_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_log10(simd_double8 x) { + return _simd_log10_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_log10(simd_double8 x) { + return simd_make_double8(__tg_log10(x.lo), __tg_log10(x.hi)); +} +#endif + +#pragma mark - log1p implementation +static inline SIMD_CFUNC simd_float2 __tg_log1p(simd_float2 x) { + return simd_make_float2(__tg_log1p(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_log1p(simd_float3 x) { + return simd_make_float3(__tg_log1p(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_log1p_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_log1p(simd_float4 x) { + return _simd_log1p_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_log1p(simd_float4 x) { + return simd_make_float4(log1p(x.x), log1p(x.y), log1p(x.z), log1p(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_log1p_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_log1p(simd_float8 x) { + return _simd_log1p_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_log1p(simd_float8 x) { + return simd_make_float8(__tg_log1p(x.lo), __tg_log1p(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_log1p_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_log1p(simd_float16 x) { + return _simd_log1p_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_log1p(simd_float16 x) { + return simd_make_float16(__tg_log1p(x.lo), __tg_log1p(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_log1p_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_log1p(simd_double2 x) { + return _simd_log1p_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_log1p(simd_double2 x) { + return simd_make_double2(log1p(x.x), log1p(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_log1p(simd_double3 x) { + return simd_make_double3(__tg_log1p(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_log1p_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_log1p(simd_double4 x) { + return _simd_log1p_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_log1p(simd_double4 x) { + return simd_make_double4(__tg_log1p(x.lo), __tg_log1p(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_log1p_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_log1p(simd_double8 x) { + return _simd_log1p_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_log1p(simd_double8 x) { + return simd_make_double8(__tg_log1p(x.lo), __tg_log1p(x.hi)); +} +#endif + +#pragma mark - cbrt implementation +static inline SIMD_CFUNC simd_float2 __tg_cbrt(simd_float2 x) { + return simd_make_float2(__tg_cbrt(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_cbrt(simd_float3 x) { + return simd_make_float3(__tg_cbrt(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_cbrt_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_cbrt(simd_float4 x) { + return _simd_cbrt_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_cbrt(simd_float4 x) { + return simd_make_float4(cbrt(x.x), cbrt(x.y), cbrt(x.z), cbrt(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_cbrt_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_cbrt(simd_float8 x) { + return _simd_cbrt_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_cbrt(simd_float8 x) { + return simd_make_float8(__tg_cbrt(x.lo), __tg_cbrt(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_cbrt_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_cbrt(simd_float16 x) { + return _simd_cbrt_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_cbrt(simd_float16 x) { + return simd_make_float16(__tg_cbrt(x.lo), __tg_cbrt(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_cbrt_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_cbrt(simd_double2 x) { + return _simd_cbrt_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_cbrt(simd_double2 x) { + return simd_make_double2(cbrt(x.x), cbrt(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_cbrt(simd_double3 x) { + return simd_make_double3(__tg_cbrt(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_cbrt_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_cbrt(simd_double4 x) { + return _simd_cbrt_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_cbrt(simd_double4 x) { + return simd_make_double4(__tg_cbrt(x.lo), __tg_cbrt(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_cbrt_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_cbrt(simd_double8 x) { + return _simd_cbrt_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_cbrt(simd_double8 x) { + return simd_make_double8(__tg_cbrt(x.lo), __tg_cbrt(x.hi)); +} +#endif + +#pragma mark - erf implementation +static inline SIMD_CFUNC simd_float2 __tg_erf(simd_float2 x) { + return simd_make_float2(__tg_erf(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_erf(simd_float3 x) { + return simd_make_float3(__tg_erf(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_erf_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_erf(simd_float4 x) { + return _simd_erf_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_erf(simd_float4 x) { + return simd_make_float4(erf(x.x), erf(x.y), erf(x.z), erf(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_erf_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_erf(simd_float8 x) { + return _simd_erf_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_erf(simd_float8 x) { + return simd_make_float8(__tg_erf(x.lo), __tg_erf(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_erf_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_erf(simd_float16 x) { + return _simd_erf_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_erf(simd_float16 x) { + return simd_make_float16(__tg_erf(x.lo), __tg_erf(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_erf_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_erf(simd_double2 x) { + return _simd_erf_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_erf(simd_double2 x) { + return simd_make_double2(erf(x.x), erf(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_erf(simd_double3 x) { + return simd_make_double3(__tg_erf(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_erf_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_erf(simd_double4 x) { + return _simd_erf_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_erf(simd_double4 x) { + return simd_make_double4(__tg_erf(x.lo), __tg_erf(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_erf_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_erf(simd_double8 x) { + return _simd_erf_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_erf(simd_double8 x) { + return simd_make_double8(__tg_erf(x.lo), __tg_erf(x.hi)); +} +#endif + +#pragma mark - erfc implementation +static inline SIMD_CFUNC simd_float2 __tg_erfc(simd_float2 x) { + return simd_make_float2(__tg_erfc(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_erfc(simd_float3 x) { + return simd_make_float3(__tg_erfc(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_erfc_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_erfc(simd_float4 x) { + return _simd_erfc_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_erfc(simd_float4 x) { + return simd_make_float4(erfc(x.x), erfc(x.y), erfc(x.z), erfc(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_erfc_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_erfc(simd_float8 x) { + return _simd_erfc_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_erfc(simd_float8 x) { + return simd_make_float8(__tg_erfc(x.lo), __tg_erfc(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_erfc_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_erfc(simd_float16 x) { + return _simd_erfc_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_erfc(simd_float16 x) { + return simd_make_float16(__tg_erfc(x.lo), __tg_erfc(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_erfc_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_erfc(simd_double2 x) { + return _simd_erfc_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_erfc(simd_double2 x) { + return simd_make_double2(erfc(x.x), erfc(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_erfc(simd_double3 x) { + return simd_make_double3(__tg_erfc(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_erfc_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_erfc(simd_double4 x) { + return _simd_erfc_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_erfc(simd_double4 x) { + return simd_make_double4(__tg_erfc(x.lo), __tg_erfc(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_erfc_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_erfc(simd_double8 x) { + return _simd_erfc_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_erfc(simd_double8 x) { + return simd_make_double8(__tg_erfc(x.lo), __tg_erfc(x.hi)); +} +#endif + +#pragma mark - tgamma implementation +static inline SIMD_CFUNC simd_float2 __tg_tgamma(simd_float2 x) { + return simd_make_float2(__tg_tgamma(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_tgamma(simd_float3 x) { + return simd_make_float3(__tg_tgamma(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_tgamma_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_tgamma(simd_float4 x) { + return _simd_tgamma_f4(x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_tgamma(simd_float4 x) { + return simd_make_float4(tgamma(x.x), tgamma(x.y), tgamma(x.z), tgamma(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_tgamma_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_tgamma(simd_float8 x) { + return _simd_tgamma_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_tgamma(simd_float8 x) { + return simd_make_float8(__tg_tgamma(x.lo), __tg_tgamma(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_tgamma_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_tgamma(simd_float16 x) { + return _simd_tgamma_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_tgamma(simd_float16 x) { + return simd_make_float16(__tg_tgamma(x.lo), __tg_tgamma(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_tgamma_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_tgamma(simd_double2 x) { + return _simd_tgamma_d2(x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_tgamma(simd_double2 x) { + return simd_make_double2(tgamma(x.x), tgamma(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_tgamma(simd_double3 x) { + return simd_make_double3(__tg_tgamma(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_tgamma_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_tgamma(simd_double4 x) { + return _simd_tgamma_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_tgamma(simd_double4 x) { + return simd_make_double4(__tg_tgamma(x.lo), __tg_tgamma(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_tgamma_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_tgamma(simd_double8 x) { + return _simd_tgamma_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_tgamma(simd_double8 x) { + return simd_make_double8(__tg_tgamma(x.lo), __tg_tgamma(x.hi)); +} +#endif + +#pragma mark - round implementation +static inline SIMD_CFUNC simd_float2 __tg_round(simd_float2 x) { + return simd_make_float2(__tg_round(simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_round(simd_float3 x) { + return simd_make_float3(__tg_round(simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_round_f4(simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_round(simd_float4 x) { +#if defined __arm64__ + return vrndaq_f32(x); +#else + return _simd_round_f4(x); +#endif +} +#else +static inline SIMD_CFUNC simd_float4 __tg_round(simd_float4 x) { + return simd_make_float4(round(x.x), round(x.y), round(x.z), round(x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_round_f8(simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_round(simd_float8 x) { + return _simd_round_f8(x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_round(simd_float8 x) { + return simd_make_float8(__tg_round(x.lo), __tg_round(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_round_f16(simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_round(simd_float16 x) { + return _simd_round_f16(x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_round(simd_float16 x) { + return simd_make_float16(__tg_round(x.lo), __tg_round(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_round_d2(simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_round(simd_double2 x) { +#if defined __arm64__ + return vrndaq_f64(x); +#else + return _simd_round_d2(x); +#endif +} +#else +static inline SIMD_CFUNC simd_double2 __tg_round(simd_double2 x) { + return simd_make_double2(round(x.x), round(x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_round(simd_double3 x) { + return simd_make_double3(__tg_round(simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_round_d4(simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_round(simd_double4 x) { + return _simd_round_d4(x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_round(simd_double4 x) { + return simd_make_double4(__tg_round(x.lo), __tg_round(x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_round_d8(simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_round(simd_double8 x) { + return _simd_round_d8(x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_round(simd_double8 x) { + return simd_make_double8(__tg_round(x.lo), __tg_round(x.hi)); +} +#endif + +#pragma mark - atan2 implementation +static inline SIMD_CFUNC simd_float2 __tg_atan2(simd_float2 y, simd_float2 x) { + return simd_make_float2(__tg_atan2(simd_make_float4(y), simd_make_float4(x))); +} + +static inline SIMD_CFUNC simd_float3 __tg_atan2(simd_float3 y, simd_float3 x) { + return simd_make_float3(__tg_atan2(simd_make_float4(y), simd_make_float4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_atan2_f4(simd_float4 y, simd_float4 x); +static inline SIMD_CFUNC simd_float4 __tg_atan2(simd_float4 y, simd_float4 x) { + return _simd_atan2_f4(y, x); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_atan2(simd_float4 y, simd_float4 x) { + return simd_make_float4(atan2(y.x, x.x), atan2(y.y, x.y), atan2(y.z, x.z), atan2(y.w, x.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_atan2_f8(simd_float8 y, simd_float8 x); +static inline SIMD_CFUNC simd_float8 __tg_atan2(simd_float8 y, simd_float8 x) { + return _simd_atan2_f8(y, x); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_atan2(simd_float8 y, simd_float8 x) { + return simd_make_float8(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_atan2_f16(simd_float16 y, simd_float16 x); +static inline SIMD_CFUNC simd_float16 __tg_atan2(simd_float16 y, simd_float16 x) { + return _simd_atan2_f16(y, x); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_atan2(simd_float16 y, simd_float16 x) { + return simd_make_float16(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_atan2_d2(simd_double2 y, simd_double2 x); +static inline SIMD_CFUNC simd_double2 __tg_atan2(simd_double2 y, simd_double2 x) { + return _simd_atan2_d2(y, x); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_atan2(simd_double2 y, simd_double2 x) { + return simd_make_double2(atan2(y.x, x.x), atan2(y.y, x.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_atan2(simd_double3 y, simd_double3 x) { + return simd_make_double3(__tg_atan2(simd_make_double4(y), simd_make_double4(x))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_atan2_d4(simd_double4 y, simd_double4 x); +static inline SIMD_CFUNC simd_double4 __tg_atan2(simd_double4 y, simd_double4 x) { + return _simd_atan2_d4(y, x); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_atan2(simd_double4 y, simd_double4 x) { + return simd_make_double4(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_atan2_d8(simd_double8 y, simd_double8 x); +static inline SIMD_CFUNC simd_double8 __tg_atan2(simd_double8 y, simd_double8 x) { + return _simd_atan2_d8(y, x); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_atan2(simd_double8 y, simd_double8 x) { + return simd_make_double8(__tg_atan2(y.lo, x.lo), __tg_atan2(y.hi, x.hi)); +} +#endif + +#pragma mark - hypot implementation +static inline SIMD_CFUNC simd_float2 __tg_hypot(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_hypot(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_hypot(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_hypot(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_hypot_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_hypot(simd_float4 x, simd_float4 y) { + return _simd_hypot_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_hypot(simd_float4 x, simd_float4 y) { + return simd_make_float4(hypot(x.x, y.x), hypot(x.y, y.y), hypot(x.z, y.z), hypot(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_hypot_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_hypot(simd_float8 x, simd_float8 y) { + return _simd_hypot_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_hypot(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_hypot_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_hypot(simd_float16 x, simd_float16 y) { + return _simd_hypot_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_hypot(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_hypot_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_hypot(simd_double2 x, simd_double2 y) { + return _simd_hypot_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_hypot(simd_double2 x, simd_double2 y) { + return simd_make_double2(hypot(x.x, y.x), hypot(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_hypot(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_hypot(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_hypot_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_hypot(simd_double4 x, simd_double4 y) { + return _simd_hypot_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_hypot(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_hypot_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_hypot(simd_double8 x, simd_double8 y) { + return _simd_hypot_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_hypot(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_hypot(x.lo, y.lo), __tg_hypot(x.hi, y.hi)); +} +#endif + +#pragma mark - pow implementation +static inline SIMD_CFUNC simd_float2 __tg_pow(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_pow(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_pow(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_pow(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_pow_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_pow(simd_float4 x, simd_float4 y) { + return _simd_pow_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_pow(simd_float4 x, simd_float4 y) { + return simd_make_float4(pow(x.x, y.x), pow(x.y, y.y), pow(x.z, y.z), pow(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_pow_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_pow(simd_float8 x, simd_float8 y) { + return _simd_pow_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_pow(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_pow_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_pow(simd_float16 x, simd_float16 y) { + return _simd_pow_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_pow(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_pow_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_pow(simd_double2 x, simd_double2 y) { + return _simd_pow_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_pow(simd_double2 x, simd_double2 y) { + return simd_make_double2(pow(x.x, y.x), pow(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_pow(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_pow(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_pow_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_pow(simd_double4 x, simd_double4 y) { + return _simd_pow_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_pow(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_pow_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_pow(simd_double8 x, simd_double8 y) { + return _simd_pow_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_pow(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_pow(x.lo, y.lo), __tg_pow(x.hi, y.hi)); +} +#endif + +#pragma mark - fmod implementation +static inline SIMD_CFUNC simd_float2 __tg_fmod(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_fmod(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_fmod(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_fmod(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_fmod_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_fmod(simd_float4 x, simd_float4 y) { + return _simd_fmod_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_fmod(simd_float4 x, simd_float4 y) { + return simd_make_float4(fmod(x.x, y.x), fmod(x.y, y.y), fmod(x.z, y.z), fmod(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_fmod_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_fmod(simd_float8 x, simd_float8 y) { + return _simd_fmod_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_fmod(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_fmod_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_fmod(simd_float16 x, simd_float16 y) { + return _simd_fmod_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_fmod(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_fmod_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_fmod(simd_double2 x, simd_double2 y) { + return _simd_fmod_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_fmod(simd_double2 x, simd_double2 y) { + return simd_make_double2(fmod(x.x, y.x), fmod(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_fmod(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_fmod(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_fmod_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_fmod(simd_double4 x, simd_double4 y) { + return _simd_fmod_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_fmod(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_fmod_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_fmod(simd_double8 x, simd_double8 y) { + return _simd_fmod_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_fmod(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_fmod(x.lo, y.lo), __tg_fmod(x.hi, y.hi)); +} +#endif + +#pragma mark - remainder implementation +static inline SIMD_CFUNC simd_float2 __tg_remainder(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_remainder(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_remainder(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_remainder(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_remainder_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_remainder(simd_float4 x, simd_float4 y) { + return _simd_remainder_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_remainder(simd_float4 x, simd_float4 y) { + return simd_make_float4(remainder(x.x, y.x), remainder(x.y, y.y), remainder(x.z, y.z), remainder(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_remainder_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_remainder(simd_float8 x, simd_float8 y) { + return _simd_remainder_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_remainder(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_remainder_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_remainder(simd_float16 x, simd_float16 y) { + return _simd_remainder_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_remainder(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_remainder_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_remainder(simd_double2 x, simd_double2 y) { + return _simd_remainder_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_remainder(simd_double2 x, simd_double2 y) { + return simd_make_double2(remainder(x.x, y.x), remainder(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_remainder(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_remainder(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_remainder_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_remainder(simd_double4 x, simd_double4 y) { + return _simd_remainder_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_remainder(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_remainder_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_remainder(simd_double8 x, simd_double8 y) { + return _simd_remainder_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_remainder(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_remainder(x.lo, y.lo), __tg_remainder(x.hi, y.hi)); +} +#endif + +#pragma mark - nextafter implementation +static inline SIMD_CFUNC simd_float2 __tg_nextafter(simd_float2 x, simd_float2 y) { + return simd_make_float2(__tg_nextafter(simd_make_float4(x), simd_make_float4(y))); +} + +static inline SIMD_CFUNC simd_float3 __tg_nextafter(simd_float3 x, simd_float3 y) { + return simd_make_float3(__tg_nextafter(simd_make_float4(x), simd_make_float4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_float4 _simd_nextafter_f4(simd_float4 x, simd_float4 y); +static inline SIMD_CFUNC simd_float4 __tg_nextafter(simd_float4 x, simd_float4 y) { + return _simd_nextafter_f4(x, y); +} +#else +static inline SIMD_CFUNC simd_float4 __tg_nextafter(simd_float4 x, simd_float4 y) { + return simd_make_float4(nextafter(x.x, y.x), nextafter(x.y, y.y), nextafter(x.z, y.z), nextafter(x.w, y.w)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_float8 _simd_nextafter_f8(simd_float8 x, simd_float8 y); +static inline SIMD_CFUNC simd_float8 __tg_nextafter(simd_float8 x, simd_float8 y) { + return _simd_nextafter_f8(x, y); +} +#else +static inline SIMD_CFUNC simd_float8 __tg_nextafter(simd_float8 x, simd_float8 y) { + return simd_make_float8(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_float16 _simd_nextafter_f16(simd_float16 x, simd_float16 y); +static inline SIMD_CFUNC simd_float16 __tg_nextafter(simd_float16 x, simd_float16 y) { + return _simd_nextafter_f16(x, y); +} +#else +static inline SIMD_CFUNC simd_float16 __tg_nextafter(simd_float16 x, simd_float16 y) { + return simd_make_float16(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_nextafter_d2(simd_double2 x, simd_double2 y); +static inline SIMD_CFUNC simd_double2 __tg_nextafter(simd_double2 x, simd_double2 y) { + return _simd_nextafter_d2(x, y); +} +#else +static inline SIMD_CFUNC simd_double2 __tg_nextafter(simd_double2 x, simd_double2 y) { + return simd_make_double2(nextafter(x.x, y.x), nextafter(x.y, y.y)); +} +#endif + +static inline SIMD_CFUNC simd_double3 __tg_nextafter(simd_double3 x, simd_double3 y) { + return simd_make_double3(__tg_nextafter(simd_make_double4(x), simd_make_double4(y))); +} + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX2__ +extern simd_double4 _simd_nextafter_d4(simd_double4 x, simd_double4 y); +static inline SIMD_CFUNC simd_double4 __tg_nextafter(simd_double4 x, simd_double4 y) { + return _simd_nextafter_d4(x, y); +} +#else +static inline SIMD_CFUNC simd_double4 __tg_nextafter(simd_double4 x, simd_double4 y) { + return simd_make_double4(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi)); +} +#endif + +#if SIMD_LIBRARY_VERSION >= 3 && defined __x86_64__ && defined __AVX512F__ +extern simd_double8 _simd_nextafter_d8(simd_double8 x, simd_double8 y); +static inline SIMD_CFUNC simd_double8 __tg_nextafter(simd_double8 x, simd_double8 y) { + return _simd_nextafter_d8(x, y); +} +#else +static inline SIMD_CFUNC simd_double8 __tg_nextafter(simd_double8 x, simd_double8 y) { + return simd_make_double8(__tg_nextafter(x.lo, y.lo), __tg_nextafter(x.hi, y.hi)); +} +#endif + +static inline SIMD_CFUNC simd_float2 __tg_fdim(simd_float2 x, simd_float2 y) { return simd_bitselect(x-y, 0, x= 3 +extern simd_float4 _simd_fma_f4(simd_float4 x, simd_float4 y, simd_float4 z); +#endif +static inline SIMD_CFUNC simd_float4 __tg_fma(simd_float4 x, simd_float4 y, simd_float4 z) { +#if defined __arm64__ || defined __ARM_VFPV4__ + return vfmaq_f32(z, x, y); +#elif (defined __i386__ || defined __x86_64__) && defined __FMA__ + return _mm_fmadd_ps(x, y, z); +#elif SIMD_LIBRARY_VERSION >= 3 + return _simd_fma_f4(x, y, z); +#else + return simd_make_float4(fma(x.x, y.x, z.x), fma(x.y, y.y, z.y), fma(x.z, y.z, z.z), fma(x.w, y.w, z.w)); +#endif +} + +static inline SIMD_CFUNC simd_float8 __tg_fma(simd_float8 x, simd_float8 y, simd_float8 z) { +#if (defined __i386__ || defined __x86_64__) && defined __FMA__ + return _mm256_fmadd_ps(x, y, z); +#else + return simd_make_float8(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi)); +#endif +} + +static inline SIMD_CFUNC simd_float16 __tg_fma(simd_float16 x, simd_float16 y, simd_float16 z) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_fmadd_ps(x, y, z); +#else + return simd_make_float16(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi)); +#endif +} + +#if SIMD_LIBRARY_VERSION >= 3 +extern simd_double2 _simd_fma_d2(simd_double2 x, simd_double2 y, simd_double2 z); +#endif +static inline SIMD_CFUNC simd_double2 __tg_fma(simd_double2 x, simd_double2 y, simd_double2 z) { +#if defined __arm64__ + return vfmaq_f64(z, x, y); +#elif (defined __i386__ || defined __x86_64__) && defined __FMA__ + return _mm_fmadd_pd(x, y, z); +#elif SIMD_LIBRARY_VERSION >= 3 + return _simd_fma_d2(x, y, z); +#else + return simd_make_double2(fma(x.x, y.x, z.x), fma(x.y, y.y, z.y)); +#endif +} + +static inline SIMD_CFUNC simd_double3 __tg_fma(simd_double3 x, simd_double3 y, simd_double3 z) { + return simd_make_double3(__tg_fma(simd_make_double4(x), simd_make_double4(y), simd_make_double4(z))); +} + +static inline SIMD_CFUNC simd_double4 __tg_fma(simd_double4 x, simd_double4 y, simd_double4 z) { +#if (defined __i386__ || defined __x86_64__) && defined __FMA__ + return _mm256_fmadd_pd(x, y, z); +#else + return simd_make_double4(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi)); +#endif +} + +static inline SIMD_CFUNC simd_double8 __tg_fma(simd_double8 x, simd_double8 y, simd_double8 z) { +#if defined __x86_64__ && defined __AVX512F__ + return _mm512_fmadd_pd(x, y, z); +#else + return simd_make_double8(__tg_fma(x.lo, y.lo, z.lo), __tg_fma(x.hi, y.hi, z.hi)); +#endif +} + +static inline SIMD_CFUNC float simd_muladd(float x, float y, float z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float2 simd_muladd(simd_float2 x, simd_float2 y, simd_float2 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float3 simd_muladd(simd_float3 x, simd_float3 y, simd_float3 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float4 simd_muladd(simd_float4 x, simd_float4 y, simd_float4 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float8 simd_muladd(simd_float8 x, simd_float8 y, simd_float8 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_float16 simd_muladd(simd_float16 x, simd_float16 y, simd_float16 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC double simd_muladd(double x, double y, double z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_double2 simd_muladd(simd_double2 x, simd_double2 y, simd_double2 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_double3 simd_muladd(simd_double3 x, simd_double3 y, simd_double3 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_double4 simd_muladd(simd_double4 x, simd_double4 y, simd_double4 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +static inline SIMD_CFUNC simd_double8 simd_muladd(simd_double8 x, simd_double8 y, simd_double8 z) { +#pragma STDC FP_CONTRACT ON + return x*y + z; +} +#ifdef __cplusplus +} /* extern "C" */ +#endif +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* SIMD_MATH_HEADER */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/simd/packed.h b/lib/libc/include/aarch64-macos-gnu/simd/packed.h new file mode 100644 index 0000000000..ddbd861090 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/simd/packed.h @@ -0,0 +1,1031 @@ +/*! @header + * This header defines fixed size vector types with relaxed alignment. For + * each vector type defined by that is not a 1- or 3- + * element vector, there is a corresponding type defined by this header that + * requires only the alignment matching that of the underlying scalar type. + * + * These types should be used to access buffers that may not be sufficiently + * aligned to allow them to be accessed using the "normal" simd vector types. + * As an example of this usage, suppose that you want to load a vector of + * four floats from an array of floats. The type simd_float4 has sixteen byte + * alignment, whereas an array of floats has only four byte alignment. + * Thus, naively casting a pointer into the array to (simd_float4 *) would + * invoke undefined behavior, and likely produce an alignment fault at + * runtime. Instead, use the corresponding packed type to load from the array: + * + *

    + *  @textblock
    + *  simd_float4 vector = *(packed_simd_float4 *)&array[i];
    + *  // do something with vector ...
    + *  @/textblock
    + *  
    + * + * It's important to note that the packed_ types are only needed to work with + * memory; once the data is loaded, we simply operate on it as usual using + * the simd_float4 type, as illustrated above. + * + * @copyright 2014-2017 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_PACKED_TYPES +#define SIMD_PACKED_TYPES + +# include +# if SIMD_COMPILER_HAS_REQUIRED_FEATURES +/*! @abstract A vector of two 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::char2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(1))) char simd_packed_char2; + +/*! @abstract A vector of four 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::char4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(1))) char simd_packed_char4; + +/*! @abstract A vector of eight 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ this type is also available as simd::packed::char8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(1))) char simd_packed_char8; + +/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::char16. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(1))) char simd_packed_char16; + +/*! @abstract A vector of thirty-two 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::char32. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(1))) char simd_packed_char32; + +/*! @abstract A vector of sixty-four 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::char64. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(64),__aligned__(1))) char simd_packed_char64; + +/*! @abstract A vector of two 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::uchar2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(1))) unsigned char simd_packed_uchar2; + +/*! @abstract A vector of four 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::uchar4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(1))) unsigned char simd_packed_uchar4; + +/*! @abstract A vector of eight 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::uchar8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(1))) unsigned char simd_packed_uchar8; + +/*! @abstract A vector of sixteen 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::uchar16. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(1))) unsigned char simd_packed_uchar16; + +/*! @abstract A vector of thirty-two 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::uchar32. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(1))) unsigned char simd_packed_uchar32; + +/*! @abstract A vector of sixty-four 8-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::uchar64. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(64),__aligned__(1))) unsigned char simd_packed_uchar64; + +/*! @abstract A vector of two 16-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::short2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(2))) short simd_packed_short2; + +/*! @abstract A vector of four 16-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::short4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(2))) short simd_packed_short4; + +/*! @abstract A vector of eight 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::short8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(2))) short simd_packed_short8; + +/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as + * simd::packed::short16. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(2))) short simd_packed_short16; + +/*! @abstract A vector of thirty-two 16-bit signed (twos-complement) + * integers with relaxed alignment. + * @description In C++ this type is also available as + * simd::packed::short32. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(2))) short simd_packed_short32; + +/*! @abstract A vector of two 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::ushort2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(2))) unsigned short simd_packed_ushort2; + +/*! @abstract A vector of four 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::ushort4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(2))) unsigned short simd_packed_ushort4; + +/*! @abstract A vector of eight 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::ushort8. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(2))) unsigned short simd_packed_ushort8; + +/*! @abstract A vector of sixteen 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::ushort16. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(2))) unsigned short simd_packed_ushort16; + +/*! @abstract A vector of thirty-two 16-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::ushort32. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(32),__aligned__(2))) unsigned short simd_packed_ushort32; + +/*! @abstract A vector of two 32-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::int2. The alignment of this type is that of the underlying + * scalar element type, so you can use it to load or store from an array of + * that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) int simd_packed_int2; + +/*! @abstract A vector of four 32-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::int4. The alignment of this type is that of the underlying + * scalar element type, so you can use it to load or store from an array of + * that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) int simd_packed_int4; + +/*! @abstract A vector of eight 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::int8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) int simd_packed_int8; + +/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::int16. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(4))) int simd_packed_int16; + +/*! @abstract A vector of two 32-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::uint2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) unsigned int simd_packed_uint2; + +/*! @abstract A vector of four 32-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::uint4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) unsigned int simd_packed_uint4; + +/*! @abstract A vector of eight 32-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::uint8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) unsigned int simd_packed_uint8; + +/*! @abstract A vector of sixteen 32-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::uint16. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(4))) unsigned int simd_packed_uint16; + +/*! @abstract A vector of two 32-bit floating-point numbers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::float2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) float simd_packed_float2; + +/*! @abstract A vector of four 32-bit floating-point numbers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::float4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) float simd_packed_float4; + +/*! @abstract A vector of eight 32-bit floating-point numbers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::float8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) float simd_packed_float8; + +/*! @abstract A vector of sixteen 32-bit floating-point numbers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::float16. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef __attribute__((__ext_vector_type__(16),__aligned__(4))) float simd_packed_float16; + +/*! @abstract A vector of two 64-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::long2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(2),__aligned__(8))) simd_long1 simd_packed_long2; +#else +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) simd_long1 simd_packed_long2; +#endif + +/*! @abstract A vector of four 64-bit signed (twos-complement) integers with + * relaxed alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::long4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(4),__aligned__(8))) simd_long1 simd_packed_long4; +#else +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) simd_long1 simd_packed_long4; +#endif + +/*! @abstract A vector of eight 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C++ this type is also available as simd::packed::long8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(8),__aligned__(8))) simd_long1 simd_packed_long8; +#else +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) simd_long1 simd_packed_long8; +#endif + +/*! @abstract A vector of two 64-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::ulong2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(2),__aligned__(8))) simd_ulong1 simd_packed_ulong2; +#else +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) simd_ulong1 simd_packed_ulong2; +#endif + +/*! @abstract A vector of four 64-bit unsigned integers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::ulong4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(4),__aligned__(8))) simd_ulong1 simd_packed_ulong4; +#else +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) simd_ulong1 simd_packed_ulong4; +#endif + +/*! @abstract A vector of eight 64-bit unsigned integers with relaxed + * alignment. + * @description In C++ this type is also available as simd::packed::ulong8. + * This type is not available in Metal. The alignment of this type is only + * that of the underlying scalar element type, so you can use it to load or + * store from an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(8),__aligned__(8))) simd_ulong1 simd_packed_ulong8; +#else +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) simd_ulong1 simd_packed_ulong8; +#endif + +/*! @abstract A vector of two 64-bit floating-point numbers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::double2. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(2),__aligned__(8))) double simd_packed_double2; +#else +typedef __attribute__((__ext_vector_type__(2),__aligned__(4))) double simd_packed_double2; +#endif + +/*! @abstract A vector of four 64-bit floating-point numbers with relaxed + * alignment. + * @description In C++ and Metal, this type is also available as + * simd::packed::double4. The alignment of this type is that of the + * underlying scalar element type, so you can use it to load or store from + * an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(4),__aligned__(8))) double simd_packed_double4; +#else +typedef __attribute__((__ext_vector_type__(4),__aligned__(4))) double simd_packed_double4; +#endif + +/*! @abstract A vector of eight 64-bit floating-point numbers with relaxed + * alignment. + * @description In C++ this type is also available as + * simd::packed::double8. This type is not available in Metal. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +#if defined __LP64__ +typedef __attribute__((__ext_vector_type__(8),__aligned__(8))) double simd_packed_double8; +#else +typedef __attribute__((__ext_vector_type__(8),__aligned__(4))) double simd_packed_double8; +#endif + +/* MARK: C++ vector types */ +#if defined __cplusplus +namespace simd { + namespace packed { + /*! @abstract A vector of two 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_char2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_char2 char2; + + /*! @abstract A vector of four 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_char4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_char4 char4; + + /*! @abstract A vector of eight 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_char8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_char8 char8; + + /*! @abstract A vector of sixteen 8-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_char16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_char16 char16; + + /*! @abstract A vector of thirty-two 8-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_char32. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_char32 char32; + + /*! @abstract A vector of sixty-four 8-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_char64. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_char64 char64; + + /*! @abstract A vector of two 8-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_uchar2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_uchar2 uchar2; + + /*! @abstract A vector of four 8-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_uchar4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_uchar4 uchar4; + + /*! @abstract A vector of eight 8-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uchar8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uchar8 uchar8; + + /*! @abstract A vector of sixteen 8-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uchar16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uchar16 uchar16; + + /*! @abstract A vector of thirty-two 8-bit unsigned integers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uchar32. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uchar32 uchar32; + + /*! @abstract A vector of sixty-four 8-bit unsigned integers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uchar64. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uchar64 uchar64; + + /*! @abstract A vector of two 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_short2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_short2 short2; + + /*! @abstract A vector of four 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_short4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_short4 short4; + + /*! @abstract A vector of eight 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_short8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_short8 short8; + + /*! @abstract A vector of sixteen 16-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_short16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_short16 short16; + + /*! @abstract A vector of thirty-two 16-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_short32. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_short32 short32; + + /*! @abstract A vector of two 16-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_ushort2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_ushort2 ushort2; + + /*! @abstract A vector of four 16-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_ushort4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_ushort4 ushort4; + + /*! @abstract A vector of eight 16-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_ushort8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_ushort8 ushort8; + + /*! @abstract A vector of sixteen 16-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_ushort16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_ushort16 ushort16; + + /*! @abstract A vector of thirty-two 16-bit unsigned integers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_ushort32. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_ushort32 ushort32; + + /*! @abstract A vector of two 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_int2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_int2 int2; + + /*! @abstract A vector of four 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_int4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_int4 int4; + + /*! @abstract A vector of eight 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_int8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_int8 int8; + + /*! @abstract A vector of sixteen 32-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_int16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_int16 int16; + + /*! @abstract A vector of two 32-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_uint2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_uint2 uint2; + + /*! @abstract A vector of four 32-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_uint4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_uint4 uint4; + + /*! @abstract A vector of eight 32-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uint8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uint8 uint8; + + /*! @abstract A vector of sixteen 32-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_uint16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_uint16 uint16; + + /*! @abstract A vector of two 32-bit floating-point numbers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_float2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_float2 float2; + + /*! @abstract A vector of four 32-bit floating-point numbers with + * relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_float4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_float4 float4; + + /*! @abstract A vector of eight 32-bit floating-point numbers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_float8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_float8 float8; + + /*! @abstract A vector of sixteen 32-bit floating-point numbers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_float16. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_float16 float16; + + /*! @abstract A vector of two 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_long2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_long2 long2; + + /*! @abstract A vector of four 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_long4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_long4 long4; + + /*! @abstract A vector of eight 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_long8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_long8 long8; + + /*! @abstract A vector of two 64-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_ulong2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_ulong2 ulong2; + + /*! @abstract A vector of four 64-bit unsigned integers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_ulong4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_ulong4 ulong4; + + /*! @abstract A vector of eight 64-bit unsigned integers with relaxed + * alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_ulong8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_ulong8 ulong8; + + /*! @abstract A vector of two 64-bit floating-point numbers with relaxed + * alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_double2. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_double2 double2; + + /*! @abstract A vector of four 64-bit floating-point numbers with + * relaxed alignment. + * @description In C or Objective-C, this type is available as + * simd_packed_double4. The alignment of this type is only that of the + * underlying scalar element type, so you can use it to load or store + * from an array of that type. */ +typedef ::simd_packed_double4 double4; + + /*! @abstract A vector of eight 64-bit floating-point numbers with + * relaxed alignment. + * @description This type is not available in Metal. In C or + * Objective-C, this type is available as simd_packed_double8. The + * alignment of this type is only that of the underlying scalar element + * type, so you can use it to load or store from an array of that type. */ +typedef ::simd_packed_double8 double8; + + } /* namespace simd::packed:: */ +} /* namespace simd:: */ +#endif /* __cplusplus */ + +/* MARK: Deprecated vector types */ +/*! @group Deprecated vector types + * @discussion These are the original types used by earlier versions of the + * simd library; they are provided here for compatability with existing source + * files. Use the new ("simd_"-prefixed) types for future development. */ +/*! @abstract A vector of two 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char2 + * or simd::packed::char2 instead. */ +typedef simd_packed_char2 packed_char2; + +/*! @abstract A vector of four 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char4 + * or simd::packed::char4 instead. */ +typedef simd_packed_char4 packed_char4; + +/*! @abstract A vector of eight 8-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char8 + * or simd::packed::char8 instead. */ +typedef simd_packed_char8 packed_char8; + +/*! @abstract A vector of sixteen 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char16 + * or simd::packed::char16 instead. */ +typedef simd_packed_char16 packed_char16; + +/*! @abstract A vector of thirty-two 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char32 + * or simd::packed::char32 instead. */ +typedef simd_packed_char32 packed_char32; + +/*! @abstract A vector of sixty-four 8-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_char64 + * or simd::packed::char64 instead. */ +typedef simd_packed_char64 packed_char64; + +/*! @abstract A vector of two 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar2 + * or simd::packed::uchar2 instead. */ +typedef simd_packed_uchar2 packed_uchar2; + +/*! @abstract A vector of four 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar4 + * or simd::packed::uchar4 instead. */ +typedef simd_packed_uchar4 packed_uchar4; + +/*! @abstract A vector of eight 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar8 + * or simd::packed::uchar8 instead. */ +typedef simd_packed_uchar8 packed_uchar8; + +/*! @abstract A vector of sixteen 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar16 + * or simd::packed::uchar16 instead. */ +typedef simd_packed_uchar16 packed_uchar16; + +/*! @abstract A vector of thirty-two 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar32 + * or simd::packed::uchar32 instead. */ +typedef simd_packed_uchar32 packed_uchar32; + +/*! @abstract A vector of sixty-four 8-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uchar64 + * or simd::packed::uchar64 instead. */ +typedef simd_packed_uchar64 packed_uchar64; + +/*! @abstract A vector of two 16-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short2 + * or simd::packed::short2 instead. */ +typedef simd_packed_short2 packed_short2; + +/*! @abstract A vector of four 16-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short4 + * or simd::packed::short4 instead. */ +typedef simd_packed_short4 packed_short4; + +/*! @abstract A vector of eight 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short8 + * or simd::packed::short8 instead. */ +typedef simd_packed_short8 packed_short8; + +/*! @abstract A vector of sixteen 16-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short16 + * or simd::packed::short16 instead. */ +typedef simd_packed_short16 packed_short16; + +/*! @abstract A vector of thirty-two 16-bit signed (twos-complement) + * integers with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_short32 + * or simd::packed::short32 instead. */ +typedef simd_packed_short32 packed_short32; + +/*! @abstract A vector of two 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ushort2 + * or simd::packed::ushort2 instead. */ +typedef simd_packed_ushort2 packed_ushort2; + +/*! @abstract A vector of four 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ushort4 + * or simd::packed::ushort4 instead. */ +typedef simd_packed_ushort4 packed_ushort4; + +/*! @abstract A vector of eight 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ushort8 + * or simd::packed::ushort8 instead. */ +typedef simd_packed_ushort8 packed_ushort8; + +/*! @abstract A vector of sixteen 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use + * simd_packed_ushort16 or simd::packed::ushort16 instead. */ +typedef simd_packed_ushort16 packed_ushort16; + +/*! @abstract A vector of thirty-two 16-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use + * simd_packed_ushort32 or simd::packed::ushort32 instead. */ +typedef simd_packed_ushort32 packed_ushort32; + +/*! @abstract A vector of two 32-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_int2 or + * simd::packed::int2 instead. */ +typedef simd_packed_int2 packed_int2; + +/*! @abstract A vector of four 32-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_int4 or + * simd::packed::int4 instead. */ +typedef simd_packed_int4 packed_int4; + +/*! @abstract A vector of eight 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_int8 or + * simd::packed::int8 instead. */ +typedef simd_packed_int8 packed_int8; + +/*! @abstract A vector of sixteen 32-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_int16 + * or simd::packed::int16 instead. */ +typedef simd_packed_int16 packed_int16; + +/*! @abstract A vector of two 32-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uint2 + * or simd::packed::uint2 instead. */ +typedef simd_packed_uint2 packed_uint2; + +/*! @abstract A vector of four 32-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uint4 + * or simd::packed::uint4 instead. */ +typedef simd_packed_uint4 packed_uint4; + +/*! @abstract A vector of eight 32-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uint8 + * or simd::packed::uint8 instead. */ +typedef simd_packed_uint8 packed_uint8; + +/*! @abstract A vector of sixteen 32-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_uint16 + * or simd::packed::uint16 instead. */ +typedef simd_packed_uint16 packed_uint16; + +/*! @abstract A vector of two 32-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_float2 + * or simd::packed::float2 instead. */ +typedef simd_packed_float2 packed_float2; + +/*! @abstract A vector of four 32-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_float4 + * or simd::packed::float4 instead. */ +typedef simd_packed_float4 packed_float4; + +/*! @abstract A vector of eight 32-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_float8 + * or simd::packed::float8 instead. */ +typedef simd_packed_float8 packed_float8; + +/*! @abstract A vector of sixteen 32-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_float16 + * or simd::packed::float16 instead. */ +typedef simd_packed_float16 packed_float16; + +/*! @abstract A vector of two 64-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_long2 + * or simd::packed::long2 instead. */ +typedef simd_packed_long2 packed_long2; + +/*! @abstract A vector of four 64-bit signed (twos-complement) integers with + * relaxed alignment. + * @description This type is deprecated; you should use simd_packed_long4 + * or simd::packed::long4 instead. */ +typedef simd_packed_long4 packed_long4; + +/*! @abstract A vector of eight 64-bit signed (twos-complement) integers + * with relaxed alignment. + * @description This type is deprecated; you should use simd_packed_long8 + * or simd::packed::long8 instead. */ +typedef simd_packed_long8 packed_long8; + +/*! @abstract A vector of two 64-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ulong2 + * or simd::packed::ulong2 instead. */ +typedef simd_packed_ulong2 packed_ulong2; + +/*! @abstract A vector of four 64-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ulong4 + * or simd::packed::ulong4 instead. */ +typedef simd_packed_ulong4 packed_ulong4; + +/*! @abstract A vector of eight 64-bit unsigned integers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_ulong8 + * or simd::packed::ulong8 instead. */ +typedef simd_packed_ulong8 packed_ulong8; + +/*! @abstract A vector of two 64-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_double2 + * or simd::packed::double2 instead. */ +typedef simd_packed_double2 packed_double2; + +/*! @abstract A vector of four 64-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_double4 + * or simd::packed::double4 instead. */ +typedef simd_packed_double4 packed_double4; + +/*! @abstract A vector of eight 64-bit floating-point numbers with relaxed + * alignment. + * @description This type is deprecated; you should use simd_packed_double8 + * or simd::packed::double8 instead. */ +typedef simd_packed_double8 packed_double8; + +# endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/simd/quaternion.h b/lib/libc/include/aarch64-macos-gnu/simd/quaternion.h new file mode 100644 index 0000000000..b7c5e2909d --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/simd/quaternion.h @@ -0,0 +1,1194 @@ +/*! @header + * This header defines functions for constructing and using quaternions. + * @copyright 2015-2016 Apple, Inc. All rights reserved. + * @unsorted */ + +#ifndef SIMD_QUATERNIONS +#define SIMD_QUATERNIONS + +#include +#if SIMD_COMPILER_HAS_REQUIRED_FEATURES +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* MARK: - C and Objective-C float interfaces */ + +/*! @abstract Constructs a quaternion from four scalar values. + * + * @param ix The first component of the imaginary (vector) part. + * @param iy The second component of the imaginary (vector) part. + * @param iz The third component of the imaginary (vector) part. + * + * @param r The real (scalar) part. */ +static inline SIMD_CFUNC simd_quatf simd_quaternion(float ix, float iy, float iz, float r) { + return (simd_quatf){ { ix, iy, iz, r } }; +} + +/*! @abstract Constructs a quaternion from an array of four scalars. + * + * @discussion Note that the imaginary part of the quaternion comes from + * array elements 0, 1, and 2, and the real part comes from element 3. */ +static inline SIMD_NONCONST simd_quatf simd_quaternion(const float xyzr[4]) { + return (simd_quatf){ *(const simd_packed_float4 *)xyzr }; +} + +/*! @abstract Constructs a quaternion from a four-element vector. + * + * @discussion Note that the imaginary (vector) part of the quaternion comes + * from lanes 0, 1, and 2 of the vector, and the real (scalar) part comes from + * lane 3. */ +static inline SIMD_CFUNC simd_quatf simd_quaternion(simd_float4 xyzr) { + return (simd_quatf){ xyzr }; +} + +/*! @abstract Constructs a quaternion that rotates by `angle` radians about + * `axis`. */ +static inline SIMD_CFUNC simd_quatf simd_quaternion(float angle, simd_float3 axis); + +/*! @abstract Construct a quaternion that rotates from one vector to another. + * + * @param from A normalized three-element vector. + * @param to A normalized three-element vector. + * + * @discussion The rotation axis is `simd_cross(from, to)`. If `from` and + * `to` point in opposite directions (to within machine precision), an + * arbitrary rotation axis is chosen, and the angle is pi radians. */ +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3 from, simd_float3 to); + +/*! @abstract Construct a quaternion from a 3x3 rotation `matrix`. + * + * @discussion If `matrix` is not orthogonal with determinant 1, the result + * is undefined. */ +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3x3 matrix); + +/*! @abstract Construct a quaternion from a 4x4 rotation `matrix`. + * + * @discussion The last row and column of the matrix are ignored. This + * function is equivalent to calling simd_quaternion with the upper-left 3x3 + * submatrix . */ +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float4x4 matrix); + +/*! @abstract The real (scalar) part of the quaternion `q`. */ +static inline SIMD_CFUNC float simd_real(simd_quatf q) { + return q.vector.w; +} + +/*! @abstract The imaginary (vector) part of the quaternion `q`. */ +static inline SIMD_CFUNC simd_float3 simd_imag(simd_quatf q) { + return q.vector.xyz; +} + +/*! @abstract The angle (in radians) of rotation represented by `q`. */ +static inline SIMD_CFUNC float simd_angle(simd_quatf q); + +/*! @abstract The normalized axis (a 3-element vector) around which the + * action of the quaternion `q` rotates. */ +static inline SIMD_CFUNC simd_float3 simd_axis(simd_quatf q); + +/*! @abstract The sum of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatf simd_add(simd_quatf p, simd_quatf q); + +/*! @abstract The difference of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatf simd_sub(simd_quatf p, simd_quatf q); + +/*! @abstract The product of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf p, simd_quatf q); + +/*! @abstract The quaternion `q` scaled by the real value `a`. */ +static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf q, float a); + +/*! @abstract The quaternion `q` scaled by the real value `a`. */ +static inline SIMD_CFUNC simd_quatf simd_mul(float a, simd_quatf q); + +/*! @abstract The conjugate of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatf simd_conjugate(simd_quatf q); + +/*! @abstract The (multiplicative) inverse of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatf simd_inverse(simd_quatf q); + +/*! @abstract The negation (additive inverse) of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatf simd_negate(simd_quatf q); + +/*! @abstract The dot product of the quaternions `p` and `q` interpreted as + * four-dimensional vectors. */ +static inline SIMD_CFUNC float simd_dot(simd_quatf p, simd_quatf q); + +/*! @abstract The length of the quaternion `q`. */ +static inline SIMD_CFUNC float simd_length(simd_quatf q); + +/*! @abstract The unit quaternion obtained by normalizing `q`. */ +static inline SIMD_CFUNC simd_quatf simd_normalize(simd_quatf q); + +/*! @abstract Rotates the vector `v` by the quaternion `q`. */ +static inline SIMD_CFUNC simd_float3 simd_act(simd_quatf q, simd_float3 v); + +/*! @abstract Logarithm of the quaternion `q`. + * @discussion Do not call this function directly; use `log(q)` instead. + * + * We can write a quaternion `q` in the form: `r(cos(t) + sin(t)v)` where + * `r` is the length of `q`, `t` is an angle, and `v` is a unit 3-vector. + * The logarithm of `q` is `log(r) + tv`, just like the logarithm of the + * complex number `r*(cos(t) + i sin(t))` is `log(r) + it`. + * + * Note that this function is not robust against poorly-scaled non-unit + * quaternions, because it is primarily used for spline interpolation of + * unit quaternions. If you need to compute a robust logarithm of general + * quaternions, you can use the following approach: + * + * scale = simd_reduce_max(simd_abs(q.vector)); + * logq = log(simd_recip(scale)*q); + * logq.real += log(scale); + * return logq; */ +static SIMD_NOINLINE simd_quatf __tg_log(simd_quatf q); + +/*! @abstract Inverse of `log( )`; the exponential map on quaternions. + * @discussion Do not call this function directly; use `exp(q)` instead. */ +static SIMD_NOINLINE simd_quatf __tg_exp(simd_quatf q); + +/*! @abstract Spherical linear interpolation along the shortest arc between + * quaternions `q0` and `q1`. */ +static SIMD_NOINLINE simd_quatf simd_slerp(simd_quatf q0, simd_quatf q1, float t); + +/*! @abstract Spherical linear interpolation along the longest arc between + * quaternions `q0` and `q1`. */ +static SIMD_NOINLINE simd_quatf simd_slerp_longest(simd_quatf q0, simd_quatf q1, float t); + +/*! @abstract Interpolate between quaternions along a spherical cubic spline. + * + * @discussion The function interpolates between q1 and q2. q0 is the left + * endpoint of the previous interval, and q3 is the right endpoint of the next + * interval. Use this function to smoothly interpolate between a sequence of + * rotations. */ +static SIMD_NOINLINE simd_quatf simd_spline(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t); + +/*! @abstract Spherical cubic Bezier interpolation between quaternions. + * + * @discussion The function treats q0 ... q3 as control points and uses slerp + * in place of lerp in the De Castlejeau algorithm. The endpoints of + * interpolation are thus q0 and q3, and the curve will not generally pass + * through q1 or q2. Note that the convex hull property of "standard" Bezier + * curve does not hold on the sphere. */ +static SIMD_NOINLINE simd_quatf simd_bezier(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t); + +#ifdef __cplusplus +} /* extern "C" */ +/* MARK: - C++ float interfaces */ + +namespace simd { + struct quatf : ::simd_quatf { + /*! @abstract The identity quaternion. */ + quatf( ) : ::simd_quatf(::simd_quaternion((float4){0,0,0,1})) { } + + /*! @abstract Constructs a C++ quaternion from a C quaternion. */ + quatf(::simd_quatf q) : ::simd_quatf(q) { } + + /*! @abstract Constructs a quaternion from components. */ + quatf(float ix, float iy, float iz, float r) : ::simd_quatf(::simd_quaternion(ix, iy, iz, r)) { } + + /*! @abstract Constructs a quaternion from an array of scalars. */ + quatf(const float xyzr[4]) : ::simd_quatf(::simd_quaternion(xyzr)) { } + + /*! @abstract Constructs a quaternion from a vector. */ + quatf(float4 xyzr) : ::simd_quatf(::simd_quaternion(xyzr)) { } + + /*! @abstract Quaternion representing rotation about `axis` by `angle` + * radians. */ + quatf(float angle, float3 axis) : ::simd_quatf(::simd_quaternion(angle, axis)) { } + + /*! @abstract Quaternion that rotates `from` into `to`. */ + quatf(float3 from, float3 to) : ::simd_quatf(::simd_quaternion(from, to)) { } + + /*! @abstract Constructs a quaternion from a rotation matrix. */ + quatf(::simd_float3x3 matrix) : ::simd_quatf(::simd_quaternion(matrix)) { } + + /*! @abstract Constructs a quaternion from a rotation matrix. */ + quatf(::simd_float4x4 matrix) : ::simd_quatf(::simd_quaternion(matrix)) { } + + /*! @abstract The real (scalar) part of the quaternion. */ + float real(void) const { return ::simd_real(*this); } + + /*! @abstract The imaginary (vector) part of the quaternion. */ + float3 imag(void) const { return ::simd_imag(*this); } + + /*! @abstract The angle the quaternion rotates by. */ + float angle(void) const { return ::simd_angle(*this); } + + /*! @abstract The axis the quaternion rotates about. */ + float3 axis(void) const { return ::simd_axis(*this); } + + /*! @abstract The length of the quaternion. */ + float length(void) const { return ::simd_length(*this); } + + /*! @abstract Act on the vector `v` by rotation. */ + float3 operator()(const ::simd_float3 v) const { return ::simd_act(*this, v); } + }; + + static SIMD_CPPFUNC quatf operator+(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_add(p, q); } + static SIMD_CPPFUNC quatf operator-(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_sub(p, q); } + static SIMD_CPPFUNC quatf operator-(const ::simd_quatf p) { return ::simd_negate(p); } + static SIMD_CPPFUNC quatf operator*(const float r, const ::simd_quatf p) { return ::simd_mul(r, p); } + static SIMD_CPPFUNC quatf operator*(const ::simd_quatf p, const float r) { return ::simd_mul(p, r); } + static SIMD_CPPFUNC quatf operator*(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_mul(p, q); } + static SIMD_CPPFUNC quatf operator/(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_mul(p, ::simd_inverse(q)); } + static SIMD_CPPFUNC quatf operator+=(quatf &p, const ::simd_quatf q) { return p = p+q; } + static SIMD_CPPFUNC quatf operator-=(quatf &p, const ::simd_quatf q) { return p = p-q; } + static SIMD_CPPFUNC quatf operator*=(quatf &p, const float r) { return p = p*r; } + static SIMD_CPPFUNC quatf operator*=(quatf &p, const ::simd_quatf q) { return p = p*q; } + static SIMD_CPPFUNC quatf operator/=(quatf &p, const ::simd_quatf q) { return p = p/q; } + + /*! @abstract The conjugate of the quaternion `q`. */ + static SIMD_CPPFUNC quatf conjugate(const ::simd_quatf p) { return ::simd_conjugate(p); } + + /*! @abstract The (multiplicative) inverse of the quaternion `q`. */ + static SIMD_CPPFUNC quatf inverse(const ::simd_quatf p) { return ::simd_inverse(p); } + + /*! @abstract The dot product of the quaternions `p` and `q` interpreted as + * four-dimensional vectors. */ + static SIMD_CPPFUNC float dot(const ::simd_quatf p, const ::simd_quatf q) { return ::simd_dot(p, q); } + + /*! @abstract The unit quaternion obtained by normalizing `q`. */ + static SIMD_CPPFUNC quatf normalize(const ::simd_quatf p) { return ::simd_normalize(p); } + + /*! @abstract logarithm of the quaternion `q`. */ + static SIMD_CPPFUNC quatf log(const ::simd_quatf q) { return ::__tg_log(q); } + + /*! @abstract exponential map of quaterion `q`. */ + static SIMD_CPPFUNC quatf exp(const ::simd_quatf q) { return ::__tg_exp(q); } + + /*! @abstract Spherical linear interpolation along the shortest arc between + * quaternions `q0` and `q1`. */ + static SIMD_CPPFUNC quatf slerp(const ::simd_quatf p0, const ::simd_quatf p1, float t) { return ::simd_slerp(p0, p1, t); } + + /*! @abstract Spherical linear interpolation along the longest arc between + * quaternions `q0` and `q1`. */ + static SIMD_CPPFUNC quatf slerp_longest(const ::simd_quatf p0, const ::simd_quatf p1, float t) { return ::simd_slerp_longest(p0, p1, t); } + + /*! @abstract Interpolate between quaternions along a spherical cubic spline. + * + * @discussion The function interpolates between q1 and q2. q0 is the left + * endpoint of the previous interval, and q3 is the right endpoint of the next + * interval. Use this function to smoothly interpolate between a sequence of + * rotations. */ + static SIMD_CPPFUNC quatf spline(const ::simd_quatf p0, const ::simd_quatf p1, const ::simd_quatf p2, const ::simd_quatf p3, float t) { return ::simd_spline(p0, p1, p2, p3, t); } + + /*! @abstract Spherical cubic Bezier interpolation between quaternions. + * + * @discussion The function treats q0 ... q3 as control points and uses slerp + * in place of lerp in the De Castlejeau algorithm. The endpoints of + * interpolation are thus q0 and q3, and the curve will not generally pass + * through q1 or q2. Note that the convex hull property of "standard" Bezier + * curve does not hold on the sphere. */ + static SIMD_CPPFUNC quatf bezier(const ::simd_quatf p0, const ::simd_quatf p1, const ::simd_quatf p2, const ::simd_quatf p3, float t) { return ::simd_bezier(p0, p1, p2, p3, t); } +} + +extern "C" { +#endif /* __cplusplus */ + +/* MARK: - float implementations */ + +#include +#include + +/* tg_promote is implementation gobbledygook that enables the compile-time + * dispatching in tgmath.h to work its magic. */ +static simd_quatf __attribute__((__overloadable__)) __tg_promote(simd_quatf); + +/*! @abstract Constructs a quaternion from imaginary and real parts. + * @discussion This function is hidden behind an underscore to avoid confusion + * with the angle-axis constructor. */ +static inline SIMD_CFUNC simd_quatf _simd_quaternion(simd_float3 imag, float real) { + return simd_quaternion(simd_make_float4(imag, real)); +} + +static inline SIMD_CFUNC simd_quatf simd_quaternion(float angle, simd_float3 axis) { + return _simd_quaternion(sin(angle/2) * axis, cos(angle/2)); +} + +static inline SIMD_CFUNC float simd_angle(simd_quatf q) { + return 2*atan2(simd_length(q.vector.xyz), q.vector.w); +} + +static inline SIMD_CFUNC simd_float3 simd_axis(simd_quatf q) { + return simd_normalize(q.vector.xyz); +} + +static inline SIMD_CFUNC simd_quatf simd_add(simd_quatf p, simd_quatf q) { + return simd_quaternion(p.vector + q.vector); +} + +static inline SIMD_CFUNC simd_quatf simd_sub(simd_quatf p, simd_quatf q) { + return simd_quaternion(p.vector - q.vector); +} + +static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf p, simd_quatf q) { + #pragma STDC FP_CONTRACT ON + return simd_quaternion((p.vector.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) + + p.vector.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5)) + + (p.vector.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6) + + p.vector.w * q.vector)); +} + +static inline SIMD_CFUNC simd_quatf simd_mul(simd_quatf q, float a) { + return simd_quaternion(a * q.vector); +} + +static inline SIMD_CFUNC simd_quatf simd_mul(float a, simd_quatf q) { + return simd_mul(q,a); +} + +static inline SIMD_CFUNC simd_quatf simd_conjugate(simd_quatf q) { + return simd_quaternion(q.vector * (simd_float4){-1,-1,-1, 1}); +} + +static inline SIMD_CFUNC simd_quatf simd_inverse(simd_quatf q) { + return simd_quaternion(simd_conjugate(q).vector * simd_recip(simd_length_squared(q.vector))); +} + +static inline SIMD_CFUNC simd_quatf simd_negate(simd_quatf q) { + return simd_quaternion(-q.vector); +} + +static inline SIMD_CFUNC float simd_dot(simd_quatf p, simd_quatf q) { + return simd_dot(p.vector, q.vector); +} + +static inline SIMD_CFUNC float simd_length(simd_quatf q) { + return simd_length(q.vector); +} + +static inline SIMD_CFUNC simd_quatf simd_normalize(simd_quatf q) { + float length_squared = simd_length_squared(q.vector); + if (length_squared == 0) { + return simd_quaternion((simd_float4){0,0,0,1}); + } + return simd_quaternion(q.vector * simd_rsqrt(length_squared)); +} + +#if defined __arm__ || defined __arm64__ +/*! @abstract Multiplies the vector `v` by the quaternion `q`. + * + * @discussion This IS NOT the action of `q` on `v` (i.e. this is not rotation + * by `q`. That operation is provided by `simd_act(q, v)`. This function is an + * implementation detail and you should not call it directly. It may be + * removed or modified in future versions of the simd module. */ +static inline SIMD_CFUNC simd_quatf _simd_mul_vq(simd_float3 v, simd_quatf q) { + #pragma STDC FP_CONTRACT ON + return simd_quaternion(v.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) + + v.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5) + + v.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6)); +} +#endif + +static inline SIMD_CFUNC simd_float3 simd_act(simd_quatf q, simd_float3 v) { +#if defined __arm__ || defined __arm64__ + return simd_mul(q, _simd_mul_vq(v, simd_conjugate(q))).vector.xyz; +#else + #pragma STDC FP_CONTRACT ON + simd_float3 t = 2*simd_cross(simd_imag(q),v); + return v + simd_real(q)*t + simd_cross(simd_imag(q), t); +#endif +} + +static SIMD_NOINLINE simd_quatf __tg_log(simd_quatf q) { + float real = __tg_log(simd_length_squared(q.vector))/2; + if (simd_equal(simd_imag(q), 0)) return _simd_quaternion(0, real); + simd_float3 imag = __tg_acos(simd_real(q)/simd_length(q)) * simd_normalize(simd_imag(q)); + return _simd_quaternion(imag, real); +} + +static SIMD_NOINLINE simd_quatf __tg_exp(simd_quatf q) { + // angle is actually *twice* the angle of the rotation corresponding to + // the resulting quaternion, which is why we don't simply use the (angle, + // axis) constructor to generate `unit`. + float angle = simd_length(simd_imag(q)); + if (angle == 0) return _simd_quaternion(0, exp(simd_real(q))); + simd_float3 axis = simd_normalize(simd_imag(q)); + simd_quatf unit = _simd_quaternion(sin(angle)*axis, cosf(angle)); + return simd_mul(exp(simd_real(q)), unit); +} + +/*! @abstract Implementation detail of the `simd_quaternion(from, to)` + * initializer. + * + * @discussion Computes the quaternion rotation `from` to `to` if they are + * separated by less than 90 degrees. Not numerically stable for larger + * angles. This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static inline SIMD_CFUNC simd_quatf _simd_quaternion_reduced(simd_float3 from, simd_float3 to) { + simd_float3 half = simd_normalize(from + to); + return _simd_quaternion(simd_cross(from, half), simd_dot(from, half)); +} + +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3 from, simd_float3 to) { + + // If the angle between from and to is not too big, we can compute the + // rotation accurately using a simple implementation. + if (simd_dot(from, to) >= 0) { + return _simd_quaternion_reduced(from, to); + } + + // Because from and to are more than 90 degrees apart, we compute the + // rotation in two stages (from -> half), (half -> to) to preserve numerical + // accuracy. + simd_float3 half = from + to; + + if (simd_length_squared(half) == 0) { + // half is nearly zero, so from and to point in nearly opposite directions + // and the rotation is numerically underspecified. Pick an axis orthogonal + // to the vectors, and use an angle of pi radians. + simd_float3 abs_from = simd_abs(from); + if (abs_from.x <= abs_from.y && abs_from.x <= abs_from.z) + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_float3){1,0,0})), 0.f); + else if (abs_from.y <= abs_from.z) + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_float3){0,1,0})), 0.f); + else + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_float3){0,0,1})), 0.f); + } + + // Compute the two-step rotation. */ + half = simd_normalize(half); + return simd_mul(_simd_quaternion_reduced(from, half), + _simd_quaternion_reduced(half, to)); +} + +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float3x3 matrix) { + const simd_float3 *mat = matrix.columns; + float trace = mat[0][0] + mat[1][1] + mat[2][2]; + if (trace >= 0.0) { + float r = 2*sqrt(1 + trace); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[1][2] - mat[2][1]), + rinv*(mat[2][0] - mat[0][2]), + rinv*(mat[0][1] - mat[1][0]), + r/4); + } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) { + float r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]); + float rinv = simd_recip(r); + return simd_quaternion(r/4, + rinv*(mat[0][1] + mat[1][0]), + rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] - mat[2][1])); + } else if (mat[1][1] >= mat[2][2]) { + float r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][1] + mat[1][0]), + r/4, + rinv*(mat[1][2] + mat[2][1]), + rinv*(mat[2][0] - mat[0][2])); + } else { + float r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] + mat[2][1]), + r/4, + rinv*(mat[0][1] - mat[1][0])); + } +} + +static SIMD_NOINLINE simd_quatf simd_quaternion(simd_float4x4 matrix) { + const simd_float4 *mat = matrix.columns; + float trace = mat[0][0] + mat[1][1] + mat[2][2]; + if (trace >= 0.0) { + float r = 2*sqrt(1 + trace); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[1][2] - mat[2][1]), + rinv*(mat[2][0] - mat[0][2]), + rinv*(mat[0][1] - mat[1][0]), + r/4); + } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) { + float r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]); + float rinv = simd_recip(r); + return simd_quaternion(r/4, + rinv*(mat[0][1] + mat[1][0]), + rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] - mat[2][1])); + } else if (mat[1][1] >= mat[2][2]) { + float r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][1] + mat[1][0]), + r/4, + rinv*(mat[1][2] + mat[2][1]), + rinv*(mat[2][0] - mat[0][2])); + } else { + float r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]); + float rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] + mat[2][1]), + r/4, + rinv*(mat[0][1] - mat[1][0])); + } +} + +/*! @abstract The angle between p and q interpreted as 4-dimensional vectors. + * + * @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE float _simd_angle(simd_quatf p, simd_quatf q) { + return 2*atan2(simd_length(p.vector - q.vector), simd_length(p.vector + q.vector)); +} + +/*! @abstract sin(x)/x. + * + * @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_CFUNC float _simd_sinc(float x) { + if (x == 0) return 1; + return sin(x)/x; +} + +/*! @abstract Spherical lerp between q0 and q1. + * + * @discussion This function may interpolate along either the longer or + * shorter path between q0 and q1; it is used as an implementation detail + * in `simd_slerp` and `simd_slerp_longest`; you should use those functions + * instead of calling this directly. */ +static SIMD_NOINLINE simd_quatf _simd_slerp_internal(simd_quatf q0, simd_quatf q1, float t) { + float s = 1 - t; + float a = _simd_angle(q0, q1); + float r = simd_recip(_simd_sinc(a)); + return simd_normalize(simd_quaternion(_simd_sinc(s*a)*r*s*q0.vector + _simd_sinc(t*a)*r*t*q1.vector)); +} + +static SIMD_NOINLINE simd_quatf simd_slerp(simd_quatf q0, simd_quatf q1, float t) { + if (simd_dot(q0, q1) >= 0) + return _simd_slerp_internal(q0, q1, t); + return _simd_slerp_internal(q0, simd_negate(q1), t); +} + +static SIMD_NOINLINE simd_quatf simd_slerp_longest(simd_quatf q0, simd_quatf q1, float t) { + if (simd_dot(q0, q1) >= 0) + return _simd_slerp_internal(q0, simd_negate(q1), t); + return _simd_slerp_internal(q0, q1, t); +} + +/*! @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE simd_quatf _simd_intermediate(simd_quatf q0, simd_quatf q1, simd_quatf q2) { + simd_quatf p0 = __tg_log(simd_mul(q0, simd_inverse(q1))); + simd_quatf p2 = __tg_log(simd_mul(q2, simd_inverse(q1))); + return simd_normalize(simd_mul(q1, __tg_exp(simd_mul(-0.25, simd_add(p0,p2))))); +} + +/*! @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE simd_quatf _simd_squad(simd_quatf q0, simd_quatf qa, simd_quatf qb, simd_quatf q1, float t) { + simd_quatf r0 = _simd_slerp_internal(q0, q1, t); + simd_quatf r1 = _simd_slerp_internal(qa, qb, t); + return _simd_slerp_internal(r0, r1, 2*t*(1 - t)); +} + +static SIMD_NOINLINE simd_quatf simd_spline(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t) { + simd_quatf qa = _simd_intermediate(q0, q1, q2); + simd_quatf qb = _simd_intermediate(q1, q2, q3); + return _simd_squad(q1, qa, qb, q2, t); +} + +static SIMD_NOINLINE simd_quatf simd_bezier(simd_quatf q0, simd_quatf q1, simd_quatf q2, simd_quatf q3, float t) { + simd_quatf q01 = _simd_slerp_internal(q0, q1, t); + simd_quatf q12 = _simd_slerp_internal(q1, q2, t); + simd_quatf q23 = _simd_slerp_internal(q2, q3, t); + simd_quatf q012 = _simd_slerp_internal(q01, q12, t); + simd_quatf q123 = _simd_slerp_internal(q12, q23, t); + return _simd_slerp_internal(q012, q123, t); +} + +/* MARK: - C and Objective-C double interfaces */ + +/*! @abstract Constructs a quaternion from four scalar values. + * + * @param ix The first component of the imaginary (vector) part. + * @param iy The second component of the imaginary (vector) part. + * @param iz The third component of the imaginary (vector) part. + * + * @param r The real (scalar) part. */ +static inline SIMD_CFUNC simd_quatd simd_quaternion(double ix, double iy, double iz, double r) { + return (simd_quatd){ { ix, iy, iz, r } }; +} + +/*! @abstract Constructs a quaternion from an array of four scalars. + * + * @discussion Note that the imaginary part of the quaternion comes from + * array elements 0, 1, and 2, and the real part comes from element 3. */ +static inline SIMD_NONCONST simd_quatd simd_quaternion(const double xyzr[4]) { + return (simd_quatd){ *(const simd_packed_double4 *)xyzr }; +} + +/*! @abstract Constructs a quaternion from a four-element vector. + * + * @discussion Note that the imaginary (vector) part of the quaternion comes + * from lanes 0, 1, and 2 of the vector, and the real (scalar) part comes from + * lane 3. */ +static inline SIMD_CFUNC simd_quatd simd_quaternion(simd_double4 xyzr) { + return (simd_quatd){ xyzr }; +} + +/*! @abstract Constructs a quaternion that rotates by `angle` radians about + * `axis`. */ +static inline SIMD_CFUNC simd_quatd simd_quaternion(double angle, simd_double3 axis); + +/*! @abstract Construct a quaternion that rotates from one vector to another. + * + * @param from A normalized three-element vector. + * @param to A normalized three-element vector. + * + * @discussion The rotation axis is `simd_cross(from, to)`. If `from` and + * `to` point in opposite directions (to within machine precision), an + * arbitrary rotation axis is chosen, and the angle is pi radians. */ +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3 from, simd_double3 to); + +/*! @abstract Construct a quaternion from a 3x3 rotation `matrix`. + * + * @discussion If `matrix` is not orthogonal with determinant 1, the result + * is undefined. */ +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3x3 matrix); + +/*! @abstract Construct a quaternion from a 4x4 rotation `matrix`. + * + * @discussion The last row and column of the matrix are ignored. This + * function is equivalent to calling simd_quaternion with the upper-left 3x3 + * submatrix . */ +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double4x4 matrix); + +/*! @abstract The real (scalar) part of the quaternion `q`. */ +static inline SIMD_CFUNC double simd_real(simd_quatd q) { + return q.vector.w; +} + +/*! @abstract The imaginary (vector) part of the quaternion `q`. */ +static inline SIMD_CFUNC simd_double3 simd_imag(simd_quatd q) { + return q.vector.xyz; +} + +/*! @abstract The angle (in radians) of rotation represented by `q`. */ +static inline SIMD_CFUNC double simd_angle(simd_quatd q); + +/*! @abstract The normalized axis (a 3-element vector) around which the + * action of the quaternion `q` rotates. */ +static inline SIMD_CFUNC simd_double3 simd_axis(simd_quatd q); + +/*! @abstract The sum of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatd simd_add(simd_quatd p, simd_quatd q); + +/*! @abstract The difference of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatd simd_sub(simd_quatd p, simd_quatd q); + +/*! @abstract The product of the quaternions `p` and `q`. */ +static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd p, simd_quatd q); + +/*! @abstract The quaternion `q` scaled by the real value `a`. */ +static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd q, double a); + +/*! @abstract The quaternion `q` scaled by the real value `a`. */ +static inline SIMD_CFUNC simd_quatd simd_mul(double a, simd_quatd q); + +/*! @abstract The conjugate of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatd simd_conjugate(simd_quatd q); + +/*! @abstract The (multiplicative) inverse of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatd simd_inverse(simd_quatd q); + +/*! @abstract The negation (additive inverse) of the quaternion `q`. */ +static inline SIMD_CFUNC simd_quatd simd_negate(simd_quatd q); + +/*! @abstract The dot product of the quaternions `p` and `q` interpreted as + * four-dimensional vectors. */ +static inline SIMD_CFUNC double simd_dot(simd_quatd p, simd_quatd q); + +/*! @abstract The length of the quaternion `q`. */ +static inline SIMD_CFUNC double simd_length(simd_quatd q); + +/*! @abstract The unit quaternion obtained by normalizing `q`. */ +static inline SIMD_CFUNC simd_quatd simd_normalize(simd_quatd q); + +/*! @abstract Rotates the vector `v` by the quaternion `q`. */ +static inline SIMD_CFUNC simd_double3 simd_act(simd_quatd q, simd_double3 v); + +/*! @abstract Logarithm of the quaternion `q`. + * @discussion Do not call this function directly; use `log(q)` instead. + * + * We can write a quaternion `q` in the form: `r(cos(t) + sin(t)v)` where + * `r` is the length of `q`, `t` is an angle, and `v` is a unit 3-vector. + * The logarithm of `q` is `log(r) + tv`, just like the logarithm of the + * complex number `r*(cos(t) + i sin(t))` is `log(r) + it`. + * + * Note that this function is not robust against poorly-scaled non-unit + * quaternions, because it is primarily used for spline interpolation of + * unit quaternions. If you need to compute a robust logarithm of general + * quaternions, you can use the following approach: + * + * scale = simd_reduce_max(simd_abs(q.vector)); + * logq = log(simd_recip(scale)*q); + * logq.real += log(scale); + * return logq; */ +static SIMD_NOINLINE simd_quatd __tg_log(simd_quatd q); + +/*! @abstract Inverse of `log( )`; the exponential map on quaternions. + * @discussion Do not call this function directly; use `exp(q)` instead. */ +static SIMD_NOINLINE simd_quatd __tg_exp(simd_quatd q); + +/*! @abstract Spherical linear interpolation along the shortest arc between + * quaternions `q0` and `q1`. */ +static SIMD_NOINLINE simd_quatd simd_slerp(simd_quatd q0, simd_quatd q1, double t); + +/*! @abstract Spherical linear interpolation along the longest arc between + * quaternions `q0` and `q1`. */ +static SIMD_NOINLINE simd_quatd simd_slerp_longest(simd_quatd q0, simd_quatd q1, double t); + +/*! @abstract Interpolate between quaternions along a spherical cubic spline. + * + * @discussion The function interpolates between q1 and q2. q0 is the left + * endpoint of the previous interval, and q3 is the right endpoint of the next + * interval. Use this function to smoothly interpolate between a sequence of + * rotations. */ +static SIMD_NOINLINE simd_quatd simd_spline(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t); + +/*! @abstract Spherical cubic Bezier interpolation between quaternions. + * + * @discussion The function treats q0 ... q3 as control points and uses slerp + * in place of lerp in the De Castlejeau algorithm. The endpoints of + * interpolation are thus q0 and q3, and the curve will not generally pass + * through q1 or q2. Note that the convex hull property of "standard" Bezier + * curve does not hold on the sphere. */ +static SIMD_NOINLINE simd_quatd simd_bezier(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t); + +#ifdef __cplusplus +} /* extern "C" */ +/* MARK: - C++ double interfaces */ + +namespace simd { + struct quatd : ::simd_quatd { + /*! @abstract The identity quaternion. */ + quatd( ) : ::simd_quatd(::simd_quaternion((double4){0,0,0,1})) { } + + /*! @abstract Constructs a C++ quaternion from a C quaternion. */ + quatd(::simd_quatd q) : ::simd_quatd(q) { } + + /*! @abstract Constructs a quaternion from components. */ + quatd(double ix, double iy, double iz, double r) : ::simd_quatd(::simd_quaternion(ix, iy, iz, r)) { } + + /*! @abstract Constructs a quaternion from an array of scalars. */ + quatd(const double xyzr[4]) : ::simd_quatd(::simd_quaternion(xyzr)) { } + + /*! @abstract Constructs a quaternion from a vector. */ + quatd(double4 xyzr) : ::simd_quatd(::simd_quaternion(xyzr)) { } + + /*! @abstract Quaternion representing rotation about `axis` by `angle` + * radians. */ + quatd(double angle, double3 axis) : ::simd_quatd(::simd_quaternion(angle, axis)) { } + + /*! @abstract Quaternion that rotates `from` into `to`. */ + quatd(double3 from, double3 to) : ::simd_quatd(::simd_quaternion(from, to)) { } + + /*! @abstract Constructs a quaternion from a rotation matrix. */ + quatd(::simd_double3x3 matrix) : ::simd_quatd(::simd_quaternion(matrix)) { } + + /*! @abstract Constructs a quaternion from a rotation matrix. */ + quatd(::simd_double4x4 matrix) : ::simd_quatd(::simd_quaternion(matrix)) { } + + /*! @abstract The real (scalar) part of the quaternion. */ + double real(void) const { return ::simd_real(*this); } + + /*! @abstract The imaginary (vector) part of the quaternion. */ + double3 imag(void) const { return ::simd_imag(*this); } + + /*! @abstract The angle the quaternion rotates by. */ + double angle(void) const { return ::simd_angle(*this); } + + /*! @abstract The axis the quaternion rotates about. */ + double3 axis(void) const { return ::simd_axis(*this); } + + /*! @abstract The length of the quaternion. */ + double length(void) const { return ::simd_length(*this); } + + /*! @abstract Act on the vector `v` by rotation. */ + double3 operator()(const ::simd_double3 v) const { return ::simd_act(*this, v); } + }; + + static SIMD_CPPFUNC quatd operator+(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_add(p, q); } + static SIMD_CPPFUNC quatd operator-(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_sub(p, q); } + static SIMD_CPPFUNC quatd operator-(const ::simd_quatd p) { return ::simd_negate(p); } + static SIMD_CPPFUNC quatd operator*(const double r, const ::simd_quatd p) { return ::simd_mul(r, p); } + static SIMD_CPPFUNC quatd operator*(const ::simd_quatd p, const double r) { return ::simd_mul(p, r); } + static SIMD_CPPFUNC quatd operator*(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_mul(p, q); } + static SIMD_CPPFUNC quatd operator/(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_mul(p, ::simd_inverse(q)); } + static SIMD_CPPFUNC quatd operator+=(quatd &p, const ::simd_quatd q) { return p = p+q; } + static SIMD_CPPFUNC quatd operator-=(quatd &p, const ::simd_quatd q) { return p = p-q; } + static SIMD_CPPFUNC quatd operator*=(quatd &p, const double r) { return p = p*r; } + static SIMD_CPPFUNC quatd operator*=(quatd &p, const ::simd_quatd q) { return p = p*q; } + static SIMD_CPPFUNC quatd operator/=(quatd &p, const ::simd_quatd q) { return p = p/q; } + + /*! @abstract The conjugate of the quaternion `q`. */ + static SIMD_CPPFUNC quatd conjugate(const ::simd_quatd p) { return ::simd_conjugate(p); } + + /*! @abstract The (multiplicative) inverse of the quaternion `q`. */ + static SIMD_CPPFUNC quatd inverse(const ::simd_quatd p) { return ::simd_inverse(p); } + + /*! @abstract The dot product of the quaternions `p` and `q` interpreted as + * four-dimensional vectors. */ + static SIMD_CPPFUNC double dot(const ::simd_quatd p, const ::simd_quatd q) { return ::simd_dot(p, q); } + + /*! @abstract The unit quaternion obtained by normalizing `q`. */ + static SIMD_CPPFUNC quatd normalize(const ::simd_quatd p) { return ::simd_normalize(p); } + + /*! @abstract logarithm of the quaternion `q`. */ + static SIMD_CPPFUNC quatd log(const ::simd_quatd q) { return ::__tg_log(q); } + + /*! @abstract exponential map of quaterion `q`. */ + static SIMD_CPPFUNC quatd exp(const ::simd_quatd q) { return ::__tg_exp(q); } + + /*! @abstract Spherical linear interpolation along the shortest arc between + * quaternions `q0` and `q1`. */ + static SIMD_CPPFUNC quatd slerp(const ::simd_quatd p0, const ::simd_quatd p1, double t) { return ::simd_slerp(p0, p1, t); } + + /*! @abstract Spherical linear interpolation along the longest arc between + * quaternions `q0` and `q1`. */ + static SIMD_CPPFUNC quatd slerp_longest(const ::simd_quatd p0, const ::simd_quatd p1, double t) { return ::simd_slerp_longest(p0, p1, t); } + + /*! @abstract Interpolate between quaternions along a spherical cubic spline. + * + * @discussion The function interpolates between q1 and q2. q0 is the left + * endpoint of the previous interval, and q3 is the right endpoint of the next + * interval. Use this function to smoothly interpolate between a sequence of + * rotations. */ + static SIMD_CPPFUNC quatd spline(const ::simd_quatd p0, const ::simd_quatd p1, const ::simd_quatd p2, const ::simd_quatd p3, double t) { return ::simd_spline(p0, p1, p2, p3, t); } + + /*! @abstract Spherical cubic Bezier interpolation between quaternions. + * + * @discussion The function treats q0 ... q3 as control points and uses slerp + * in place of lerp in the De Castlejeau algorithm. The endpoints of + * interpolation are thus q0 and q3, and the curve will not generally pass + * through q1 or q2. Note that the convex hull property of "standard" Bezier + * curve does not hold on the sphere. */ + static SIMD_CPPFUNC quatd bezier(const ::simd_quatd p0, const ::simd_quatd p1, const ::simd_quatd p2, const ::simd_quatd p3, double t) { return ::simd_bezier(p0, p1, p2, p3, t); } +} + +extern "C" { +#endif /* __cplusplus */ + +/* MARK: - double implementations */ + +#include +#include + +/* tg_promote is implementation gobbledygook that enables the compile-time + * dispatching in tgmath.h to work its magic. */ +static simd_quatd __attribute__((__overloadable__)) __tg_promote(simd_quatd); + +/*! @abstract Constructs a quaternion from imaginary and real parts. + * @discussion This function is hidden behind an underscore to avoid confusion + * with the angle-axis constructor. */ +static inline SIMD_CFUNC simd_quatd _simd_quaternion(simd_double3 imag, double real) { + return simd_quaternion(simd_make_double4(imag, real)); +} + +static inline SIMD_CFUNC simd_quatd simd_quaternion(double angle, simd_double3 axis) { + return _simd_quaternion(sin(angle/2) * axis, cos(angle/2)); +} + +static inline SIMD_CFUNC double simd_angle(simd_quatd q) { + return 2*atan2(simd_length(q.vector.xyz), q.vector.w); +} + +static inline SIMD_CFUNC simd_double3 simd_axis(simd_quatd q) { + return simd_normalize(q.vector.xyz); +} + +static inline SIMD_CFUNC simd_quatd simd_add(simd_quatd p, simd_quatd q) { + return simd_quaternion(p.vector + q.vector); +} + +static inline SIMD_CFUNC simd_quatd simd_sub(simd_quatd p, simd_quatd q) { + return simd_quaternion(p.vector - q.vector); +} + +static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd p, simd_quatd q) { + #pragma STDC FP_CONTRACT ON + return simd_quaternion((p.vector.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) + + p.vector.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5)) + + (p.vector.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6) + + p.vector.w * q.vector)); +} + +static inline SIMD_CFUNC simd_quatd simd_mul(simd_quatd q, double a) { + return simd_quaternion(a * q.vector); +} + +static inline SIMD_CFUNC simd_quatd simd_mul(double a, simd_quatd q) { + return simd_mul(q,a); +} + +static inline SIMD_CFUNC simd_quatd simd_conjugate(simd_quatd q) { + return simd_quaternion(q.vector * (simd_double4){-1,-1,-1, 1}); +} + +static inline SIMD_CFUNC simd_quatd simd_inverse(simd_quatd q) { + return simd_quaternion(simd_conjugate(q).vector * simd_recip(simd_length_squared(q.vector))); +} + +static inline SIMD_CFUNC simd_quatd simd_negate(simd_quatd q) { + return simd_quaternion(-q.vector); +} + +static inline SIMD_CFUNC double simd_dot(simd_quatd p, simd_quatd q) { + return simd_dot(p.vector, q.vector); +} + +static inline SIMD_CFUNC double simd_length(simd_quatd q) { + return simd_length(q.vector); +} + +static inline SIMD_CFUNC simd_quatd simd_normalize(simd_quatd q) { + double length_squared = simd_length_squared(q.vector); + if (length_squared == 0) { + return simd_quaternion((simd_double4){0,0,0,1}); + } + return simd_quaternion(q.vector * simd_rsqrt(length_squared)); +} + +#if defined __arm__ || defined __arm64__ +/*! @abstract Multiplies the vector `v` by the quaternion `q`. + * + * @discussion This IS NOT the action of `q` on `v` (i.e. this is not rotation + * by `q`. That operation is provided by `simd_act(q, v)`. This function is an + * implementation detail and you should not call it directly. It may be + * removed or modified in future versions of the simd module. */ +static inline SIMD_CFUNC simd_quatd _simd_mul_vq(simd_double3 v, simd_quatd q) { + #pragma STDC FP_CONTRACT ON + return simd_quaternion(v.x * __builtin_shufflevector(q.vector, -q.vector, 3,6,1,4) + + v.y * __builtin_shufflevector(q.vector, -q.vector, 2,3,4,5) + + v.z * __builtin_shufflevector(q.vector, -q.vector, 5,0,3,6)); +} +#endif + +static inline SIMD_CFUNC simd_double3 simd_act(simd_quatd q, simd_double3 v) { +#if defined __arm__ || defined __arm64__ + return simd_mul(q, _simd_mul_vq(v, simd_conjugate(q))).vector.xyz; +#else + #pragma STDC FP_CONTRACT ON + simd_double3 t = 2*simd_cross(simd_imag(q),v); + return v + simd_real(q)*t + simd_cross(simd_imag(q), t); +#endif +} + +static SIMD_NOINLINE simd_quatd __tg_log(simd_quatd q) { + double real = __tg_log(simd_length_squared(q.vector))/2; + if (simd_equal(simd_imag(q), 0)) return _simd_quaternion(0, real); + simd_double3 imag = __tg_acos(simd_real(q)/simd_length(q)) * simd_normalize(simd_imag(q)); + return _simd_quaternion(imag, real); +} + +static SIMD_NOINLINE simd_quatd __tg_exp(simd_quatd q) { + // angle is actually *twice* the angle of the rotation corresponding to + // the resulting quaternion, which is why we don't simply use the (angle, + // axis) constructor to generate `unit`. + double angle = simd_length(simd_imag(q)); + if (angle == 0) return _simd_quaternion(0, exp(simd_real(q))); + simd_double3 axis = simd_normalize(simd_imag(q)); + simd_quatd unit = _simd_quaternion(sin(angle)*axis, cosf(angle)); + return simd_mul(exp(simd_real(q)), unit); +} + +/*! @abstract Implementation detail of the `simd_quaternion(from, to)` + * initializer. + * + * @discussion Computes the quaternion rotation `from` to `to` if they are + * separated by less than 90 degrees. Not numerically stable for larger + * angles. This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static inline SIMD_CFUNC simd_quatd _simd_quaternion_reduced(simd_double3 from, simd_double3 to) { + simd_double3 half = simd_normalize(from + to); + return _simd_quaternion(simd_cross(from, half), simd_dot(from, half)); +} + +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3 from, simd_double3 to) { + + // If the angle between from and to is not too big, we can compute the + // rotation accurately using a simple implementation. + if (simd_dot(from, to) >= 0) { + return _simd_quaternion_reduced(from, to); + } + + // Because from and to are more than 90 degrees apart, we compute the + // rotation in two stages (from -> half), (half -> to) to preserve numerical + // accuracy. + simd_double3 half = from + to; + + if (simd_length_squared(half) == 0) { + // half is nearly zero, so from and to point in nearly opposite directions + // and the rotation is numerically underspecified. Pick an axis orthogonal + // to the vectors, and use an angle of pi radians. + simd_double3 abs_from = simd_abs(from); + if (abs_from.x <= abs_from.y && abs_from.x <= abs_from.z) + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_double3){1,0,0})), 0.f); + else if (abs_from.y <= abs_from.z) + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_double3){0,1,0})), 0.f); + else + return _simd_quaternion(simd_normalize(simd_cross(from, (simd_double3){0,0,1})), 0.f); + } + + // Compute the two-step rotation. */ + half = simd_normalize(half); + return simd_mul(_simd_quaternion_reduced(from, half), + _simd_quaternion_reduced(half, to)); +} + +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double3x3 matrix) { + const simd_double3 *mat = matrix.columns; + double trace = mat[0][0] + mat[1][1] + mat[2][2]; + if (trace >= 0.0) { + double r = 2*sqrt(1 + trace); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[1][2] - mat[2][1]), + rinv*(mat[2][0] - mat[0][2]), + rinv*(mat[0][1] - mat[1][0]), + r/4); + } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) { + double r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]); + double rinv = simd_recip(r); + return simd_quaternion(r/4, + rinv*(mat[0][1] + mat[1][0]), + rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] - mat[2][1])); + } else if (mat[1][1] >= mat[2][2]) { + double r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][1] + mat[1][0]), + r/4, + rinv*(mat[1][2] + mat[2][1]), + rinv*(mat[2][0] - mat[0][2])); + } else { + double r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] + mat[2][1]), + r/4, + rinv*(mat[0][1] - mat[1][0])); + } +} + +static SIMD_NOINLINE simd_quatd simd_quaternion(simd_double4x4 matrix) { + const simd_double4 *mat = matrix.columns; + double trace = mat[0][0] + mat[1][1] + mat[2][2]; + if (trace >= 0.0) { + double r = 2*sqrt(1 + trace); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[1][2] - mat[2][1]), + rinv*(mat[2][0] - mat[0][2]), + rinv*(mat[0][1] - mat[1][0]), + r/4); + } else if (mat[0][0] >= mat[1][1] && mat[0][0] >= mat[2][2]) { + double r = 2*sqrt(1 - mat[1][1] - mat[2][2] + mat[0][0]); + double rinv = simd_recip(r); + return simd_quaternion(r/4, + rinv*(mat[0][1] + mat[1][0]), + rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] - mat[2][1])); + } else if (mat[1][1] >= mat[2][2]) { + double r = 2*sqrt(1 - mat[0][0] - mat[2][2] + mat[1][1]); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][1] + mat[1][0]), + r/4, + rinv*(mat[1][2] + mat[2][1]), + rinv*(mat[2][0] - mat[0][2])); + } else { + double r = 2*sqrt(1 - mat[0][0] - mat[1][1] + mat[2][2]); + double rinv = simd_recip(r); + return simd_quaternion(rinv*(mat[0][2] + mat[2][0]), + rinv*(mat[1][2] + mat[2][1]), + r/4, + rinv*(mat[0][1] - mat[1][0])); + } +} + +/*! @abstract The angle between p and q interpreted as 4-dimensional vectors. + * + * @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE double _simd_angle(simd_quatd p, simd_quatd q) { + return 2*atan2(simd_length(p.vector - q.vector), simd_length(p.vector + q.vector)); +} + +/*! @abstract sin(x)/x. + * + * @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_CFUNC double _simd_sinc(double x) { + if (x == 0) return 1; + return sin(x)/x; +} + +/*! @abstract Spherical lerp between q0 and q1. + * + * @discussion This function may interpolate along either the longer or + * shorter path between q0 and q1; it is used as an implementation detail + * in `simd_slerp` and `simd_slerp_longest`; you should use those functions + * instead of calling this directly. */ +static SIMD_NOINLINE simd_quatd _simd_slerp_internal(simd_quatd q0, simd_quatd q1, double t) { + double s = 1 - t; + double a = _simd_angle(q0, q1); + double r = simd_recip(_simd_sinc(a)); + return simd_normalize(simd_quaternion(_simd_sinc(s*a)*r*s*q0.vector + _simd_sinc(t*a)*r*t*q1.vector)); +} + +static SIMD_NOINLINE simd_quatd simd_slerp(simd_quatd q0, simd_quatd q1, double t) { + if (simd_dot(q0, q1) >= 0) + return _simd_slerp_internal(q0, q1, t); + return _simd_slerp_internal(q0, simd_negate(q1), t); +} + +static SIMD_NOINLINE simd_quatd simd_slerp_longest(simd_quatd q0, simd_quatd q1, double t) { + if (simd_dot(q0, q1) >= 0) + return _simd_slerp_internal(q0, simd_negate(q1), t); + return _simd_slerp_internal(q0, q1, t); +} + +/*! @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE simd_quatd _simd_intermediate(simd_quatd q0, simd_quatd q1, simd_quatd q2) { + simd_quatd p0 = __tg_log(simd_mul(q0, simd_inverse(q1))); + simd_quatd p2 = __tg_log(simd_mul(q2, simd_inverse(q1))); + return simd_normalize(simd_mul(q1, __tg_exp(simd_mul(-0.25, simd_add(p0,p2))))); +} + +/*! @discussion This function is an implementation detail and you should not + * call it directly. It may be removed or modified in future versions of the + * simd module. */ +static SIMD_NOINLINE simd_quatd _simd_squad(simd_quatd q0, simd_quatd qa, simd_quatd qb, simd_quatd q1, double t) { + simd_quatd r0 = _simd_slerp_internal(q0, q1, t); + simd_quatd r1 = _simd_slerp_internal(qa, qb, t); + return _simd_slerp_internal(r0, r1, 2*t*(1 - t)); +} + +static SIMD_NOINLINE simd_quatd simd_spline(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t) { + simd_quatd qa = _simd_intermediate(q0, q1, q2); + simd_quatd qb = _simd_intermediate(q1, q2, q3); + return _simd_squad(q1, qa, qb, q2, t); +} + +static SIMD_NOINLINE simd_quatd simd_bezier(simd_quatd q0, simd_quatd q1, simd_quatd q2, simd_quatd q3, double t) { + simd_quatd q01 = _simd_slerp_internal(q0, q1, t); + simd_quatd q12 = _simd_slerp_internal(q1, q2, t); + simd_quatd q23 = _simd_slerp_internal(q2, q3, t); + simd_quatd q012 = _simd_slerp_internal(q01, q12, t); + simd_quatd q123 = _simd_slerp_internal(q12, q23, t); + return _simd_slerp_internal(q012, q123, t); +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ +#endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ +#endif /* SIMD_QUATERNIONS */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/spawn.h b/lib/libc/include/aarch64-macos-gnu/spawn.h new file mode 100644 index 0000000000..8a59eac2fa --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/spawn.h @@ -0,0 +1,187 @@ +/* + * 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 _SPAWN_H_ +#define _SPAWN_H_ + +/* + * [SPN] Support for _POSIX_SPAWN + */ + +#include +#include <_types.h> +#include /* shared types */ + +#include + +/* + * [SPN] Inclusion of the header may make visible symbols defined + * in the , , and headers. + */ +#include +#include +#include + +/* + * Opaque types for use with posix_spawn() family functions. Internals are + * not defined, and should not be accessed directly. Types are defined as + * mandated by POSIX. + */ +typedef void *posix_spawnattr_t; +typedef void *posix_spawn_file_actions_t; + +__BEGIN_DECLS +/* + * gcc under c99 mode won't compile "[ __restrict]" by itself. As a workaround, + * a dummy argument name is added. + */ + +int posix_spawn(pid_t * __restrict, const char * __restrict, + const posix_spawn_file_actions_t *, + const posix_spawnattr_t * __restrict, + char *const __argv[__restrict], + char *const __envp[__restrict]) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnp(pid_t * __restrict, const char * __restrict, + const posix_spawn_file_actions_t *, + const posix_spawnattr_t * __restrict, + char *const __argv[__restrict], + char *const __envp[__restrict]) __API_AVAILABLE(macos(10.5), ios(2.0)); + +int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, + int) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawn_file_actions_addopen( + posix_spawn_file_actions_t * __restrict, int, + const char * __restrict, int, mode_t) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawn_file_actions_init(posix_spawn_file_actions_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_destroy(posix_spawnattr_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict, + sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_getflags(const posix_spawnattr_t * __restrict, + short * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict, + pid_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict, + sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_init(posix_spawnattr_t *) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict, + const sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_setflags(posix_spawnattr_t *, short) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_setpgroup(posix_spawnattr_t *, pid_t) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict, + const sigset_t * __restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +#if 0 /* _POSIX_PRIORITY_SCHEDULING [PS] : not supported */ +int posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict, + const struct sched_param * __restrict); +int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int); +int posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict, + struct sched_param * __restrict); +int posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict, + int * __restrict); +#endif /* 0 */ + +__END_DECLS + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * Darwin-specific extensions below + */ +#include +#include +#include + +#include + +__BEGIN_DECLS + +int posix_spawnattr_getbinpref_np(const posix_spawnattr_t * __restrict, + size_t, cpu_type_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_getarchpref_np(const posix_spawnattr_t * __restrict, + size_t, cpu_type_t *__restrict, cpu_subtype_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(11.0), ios(14.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_setauditsessionport_np(posix_spawnattr_t * __restrict, + mach_port_t) __API_AVAILABLE(macos(10.6), ios(3.2)); + +int posix_spawnattr_setbinpref_np(posix_spawnattr_t * __restrict, + size_t, cpu_type_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_setarchpref_np(posix_spawnattr_t * __restrict, + size_t, cpu_type_t *__restrict, cpu_subtype_t *__restrict, size_t *__restrict) __API_AVAILABLE(macos(11.0), ios(14.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_setexceptionports_np(posix_spawnattr_t * __restrict, + exception_mask_t, mach_port_t, + exception_behavior_t, thread_state_flavor_t) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_setspecialport_np(posix_spawnattr_t * __restrict, + mach_port_t, int) __API_AVAILABLE(macos(10.5), ios(2.0)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawnattr_setsuidcredport_np(posix_spawnattr_t * __restrict, mach_port_t) __API_UNAVAILABLE(ios, macos); + +int posix_spawnattr_setnosmt_np(const posix_spawnattr_t * __restrict attr) __API_AVAILABLE(macos(11.0)); + +/* + * Set CPU Security Mitigation on the spawned process + * This attribute affects all threads and is inherited on fork and exec + */ +int posix_spawnattr_set_csm_np(const posix_spawnattr_t * __restrict attr, uint32_t flags) __API_AVAILABLE(macos(11.0)); +/* + * flags for CPU Security Mitigation attribute + * POSIX_SPAWN_NP_CSM_ALL should be used in most cases, + * the individual flags are provided only for performance evaluation etc + */ +#define POSIX_SPAWN_NP_CSM_ALL 0x0001 +#define POSIX_SPAWN_NP_CSM_NOSMT 0x0002 +#define POSIX_SPAWN_NP_CSM_TECS 0x0004 + +int posix_spawn_file_actions_addinherit_np(posix_spawn_file_actions_t *, + int) __API_AVAILABLE(macos(10.7), ios(4.3)) __API_UNAVAILABLE(watchos, tvos); + +int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *, + const char * __restrict) __API_AVAILABLE(macos(10.15)) __API_UNAVAILABLE(ios, tvos, watchos); + +int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *, + int) __API_AVAILABLE(macos(10.15)) __API_UNAVAILABLE(ios, tvos, watchos); + +__END_DECLS + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* _SPAWN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/stdio.h b/lib/libc/include/aarch64-macos-gnu/stdio.h new file mode 100644 index 0000000000..f28020b797 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/stdio.h @@ -0,0 +1,410 @@ +/* + * Copyright (c) 2000, 2005, 2007, 2009, 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@ + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * 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. + * + * @(#)stdio.h 8.5 (Berkeley) 4/29/95 + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +#include <_stdio.h> + +__BEGIN_DECLS +extern FILE *__stdinp; +extern FILE *__stdoutp; +extern FILE *__stderrp; +__END_DECLS + +#define __SLBF 0x0001 /* line buffered */ +#define __SNBF 0x0002 /* unbuffered */ +#define __SRD 0x0004 /* OK to read */ +#define __SWR 0x0008 /* OK to write */ + /* RD and WR are never simultaneously asserted */ +#define __SRW 0x0010 /* open for reading & writing */ +#define __SEOF 0x0020 /* found EOF */ +#define __SERR 0x0040 /* found error */ +#define __SMBF 0x0080 /* _buf is from malloc */ +#define __SAPP 0x0100 /* fdopen()ed in append mode */ +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ +#define __SOPT 0x0400 /* do fseek() optimisation */ +#define __SNPT 0x0800 /* do not do fseek() optimisation */ +#define __SOFF 0x1000 /* set iff _offset is in fact correct */ +#define __SMOD 0x2000 /* true => fgetln modified _p text */ +#define __SALC 0x4000 /* allocate string space dynamically */ +#define __SIGN 0x8000 /* ignore this file in _fwalk */ + +/* + * The following three definitions are for ANSI C, which took them + * from System V, which brilliantly took internal interface macros and + * made them official arguments to setvbuf(), without renaming them. + * Hence, these ugly _IOxxx names are *supposed* to appear in user code. + * + * Although numbered as their counterparts above, the implementation + * does not rely on this. + */ +#define _IOFBF 0 /* setvbuf should set fully buffered */ +#define _IOLBF 1 /* setvbuf should set line buffered */ +#define _IONBF 2 /* setvbuf should set unbuffered */ + +#define BUFSIZ 1024 /* size of buffer used by setbuf */ +#define EOF (-1) + + /* must be == _POSIX_STREAM_MAX */ +#define FOPEN_MAX 20 /* must be <= OPEN_MAX */ +#define FILENAME_MAX 1024 /* must be <= PATH_MAX */ + +/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ +#ifndef _ANSI_SOURCE +#define P_tmpdir "/var/tmp/" +#endif +#define L_tmpnam 1024 /* XXX must be == PATH_MAX */ +#define TMP_MAX 308915776 + +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + +#define stdin __stdinp +#define stdout __stdoutp +#define stderr __stderrp + +#ifdef _DARWIN_UNLIMITED_STREAMS +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_3_2 +#error "_DARWIN_UNLIMITED_STREAMS specified, but -miphoneos-version-min version does not support it." +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_6 +#error "_DARWIN_UNLIMITED_STREAMS specified, but -mmacosx-version-min version does not support it." +#endif +#endif + +/* ANSI-C */ + +__BEGIN_DECLS +void clearerr(FILE *); +int fclose(FILE *); +int feof(FILE *); +int ferror(FILE *); +int fflush(FILE *); +int fgetc(FILE *); +int fgetpos(FILE * __restrict, fpos_t *); +char *fgets(char * __restrict, int, FILE *); +#if defined(_DARWIN_UNLIMITED_STREAMS) || defined(_DARWIN_C_SOURCE) +FILE *fopen(const char * __restrict __filename, const char * __restrict __mode) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(fopen)); +#else /* !_DARWIN_UNLIMITED_STREAMS && !_DARWIN_C_SOURCE */ +FILE *fopen(const char * __restrict __filename, const char * __restrict __mode) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fopen)); +#endif /* (DARWIN_UNLIMITED_STREAMS || _DARWIN_C_SOURCE) */ +int fprintf(FILE * __restrict, const char * __restrict, ...) __printflike(2, 3); +int fputc(int, FILE *); +int fputs(const char * __restrict, FILE * __restrict) __DARWIN_ALIAS(fputs); +size_t fread(void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream); +FILE *freopen(const char * __restrict, const char * __restrict, + FILE * __restrict) __DARWIN_ALIAS(freopen); +int fscanf(FILE * __restrict, const char * __restrict, ...) __scanflike(2, 3); +int fseek(FILE *, long, int); +int fsetpos(FILE *, const fpos_t *); +long ftell(FILE *); +size_t fwrite(const void * __restrict __ptr, size_t __size, size_t __nitems, FILE * __restrict __stream) __DARWIN_ALIAS(fwrite); +int getc(FILE *); +int getchar(void); +char *gets(char *); +void perror(const char *) __cold; +int printf(const char * __restrict, ...) __printflike(1, 2); +int putc(int, FILE *); +int putchar(int); +int puts(const char *); +int remove(const char *); +int rename (const char *__old, const char *__new); +void rewind(FILE *); +int scanf(const char * __restrict, ...) __scanflike(1, 2); +void setbuf(FILE * __restrict, char * __restrict); +int setvbuf(FILE * __restrict, char * __restrict, int, size_t); +int sprintf(char * __restrict, const char * __restrict, ...) __printflike(2, 3) __swift_unavailable("Use snprintf instead."); +int sscanf(const char * __restrict, const char * __restrict, ...) __scanflike(2, 3); +FILE *tmpfile(void); + +__swift_unavailable("Use mkstemp(3) instead.") +#if !defined(_POSIX_C_SOURCE) +__deprecated_msg("This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.") +#endif +char *tmpnam(char *); +int ungetc(int, FILE *); +int vfprintf(FILE * __restrict, const char * __restrict, va_list) __printflike(2, 0); +int vprintf(const char * __restrict, va_list) __printflike(1, 0); +int vsprintf(char * __restrict, const char * __restrict, va_list) __printflike(2, 0) __swift_unavailable("Use vsnprintf instead."); +__END_DECLS + + + +/* Additional functionality provided by: + * POSIX.1-1988 + */ + +#if __DARWIN_C_LEVEL >= 198808L +#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */ + +__BEGIN_DECLS +#include <_ctermid.h> + +#if defined(_DARWIN_UNLIMITED_STREAMS) || defined(_DARWIN_C_SOURCE) +FILE *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(fdopen)); +#else /* !_DARWIN_UNLIMITED_STREAMS && !_DARWIN_C_SOURCE */ +FILE *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fdopen)); +#endif /* (DARWIN_UNLIMITED_STREAMS || _DARWIN_C_SOURCE) */ +int fileno(FILE *); +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 198808L */ + + +/* Additional functionality provided by: + * POSIX.2-1992 C Language Binding Option + */ +#if TARGET_OS_IPHONE +#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg) +#else +#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg) +#endif + +#if __DARWIN_C_LEVEL >= 199209L +__BEGIN_DECLS +int pclose(FILE *) __swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable."); +#if defined(_DARWIN_UNLIMITED_STREAMS) || defined(_DARWIN_C_SOURCE) +FILE *popen(const char *, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(popen)) __swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable."); +#else /* !_DARWIN_UNLIMITED_STREAMS && !_DARWIN_C_SOURCE */ +FILE *popen(const char *, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(popen)) __swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable."); +#endif /* (DARWIN_UNLIMITED_STREAMS || _DARWIN_C_SOURCE) */ +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 199209L */ + +#undef __swift_unavailable_on + +/* Additional functionality provided by: + * POSIX.1c-1995, + * POSIX.1i-1995, + * and the omnibus ISO/IEC 9945-1: 1996 + */ + +#if __DARWIN_C_LEVEL >= 199506L + +/* Functions internal to the implementation. */ +__BEGIN_DECLS +int __srget(FILE *); +int __svfscanf(FILE *, const char *, va_list) __scanflike(2, 0); +int __swbuf(int, FILE *); +__END_DECLS + +/* + * The __sfoo macros are here so that we can + * define function versions in the C library. + */ +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) +#if defined(__GNUC__) && defined(__STDC__) +__header_always_inline int __sputc(int _c, FILE *_p) { + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf(_c, _p)); +} +#else +/* + * This has been tuned to generate reasonable code on the vax using pcc. + */ +#define __sputc(c, p) \ + (--(p)->_w < 0 ? \ + (p)->_w >= (p)->_lbfsize ? \ + (*(p)->_p = (c)), *(p)->_p != '\n' ? \ + (int)*(p)->_p++ : \ + __swbuf('\n', p) : \ + __swbuf((int)(c), p) : \ + (*(p)->_p = (c), (int)*(p)->_p++)) +#endif + +#define __sfeof(p) (((p)->_flags & __SEOF) != 0) +#define __sferror(p) (((p)->_flags & __SERR) != 0) +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) +#define __sfileno(p) ((p)->_file) + +__BEGIN_DECLS +void flockfile(FILE *); +int ftrylockfile(FILE *); +void funlockfile(FILE *); +int getc_unlocked(FILE *); +int getchar_unlocked(void); +int putc_unlocked(int, FILE *); +int putchar_unlocked(int); + +/* Removed in Issue 6 */ +#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L +int getw(FILE *); +int putw(int, FILE *); +#endif + +__swift_unavailable("Use mkstemp(3) instead.") +#if !defined(_POSIX_C_SOURCE) +__deprecated_msg("This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tempnam(3), it is highly recommended that you use mkstemp(3) instead.") +#endif +char *tempnam(const char *__dir, const char *__prefix) __DARWIN_ALIAS(tempnam); +__END_DECLS + +#ifndef lint +#define getc_unlocked(fp) __sgetc(fp) +#define putc_unlocked(x, fp) __sputc(x, fp) +#endif /* lint */ + +#define getchar_unlocked() getc_unlocked(stdin) +#define putchar_unlocked(x) putc_unlocked(x, stdout) +#endif /* __DARWIN_C_LEVEL >= 199506L */ + + + +/* Additional functionality provided by: + * POSIX.1-2001 + * ISO C99 + */ + +#if __DARWIN_C_LEVEL >= 200112L +#include + +__BEGIN_DECLS +int fseeko(FILE * __stream, off_t __offset, int __whence); +off_t ftello(FILE * __stream); +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 200112L */ + +#if __DARWIN_C_LEVEL >= 200112L || defined(_C99_SOURCE) || defined(__cplusplus) +__BEGIN_DECLS +int snprintf(char * __restrict __str, size_t __size, const char * __restrict __format, ...) __printflike(3, 4); +int vfscanf(FILE * __restrict __stream, const char * __restrict __format, va_list) __scanflike(2, 0); +int vscanf(const char * __restrict __format, va_list) __scanflike(1, 0); +int vsnprintf(char * __restrict __str, size_t __size, const char * __restrict __format, va_list) __printflike(3, 0); +int vsscanf(const char * __restrict __str, const char * __restrict __format, va_list) __scanflike(2, 0); +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 200112L || defined(_C99_SOURCE) || defined(__cplusplus) */ + + + +/* Additional functionality provided by: + * POSIX.1-2008 + */ + +#if __DARWIN_C_LEVEL >= 200809L +#include + +__BEGIN_DECLS +int dprintf(int, const char * __restrict, ...) __printflike(2, 3) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +int vdprintf(int, const char * __restrict, va_list) __printflike(2, 0) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +ssize_t getdelim(char ** __restrict __linep, size_t * __restrict __linecapp, int __delimiter, FILE * __restrict __stream) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +ssize_t getline(char ** __restrict __linep, size_t * __restrict __linecapp, FILE * __restrict __stream) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +FILE *fmemopen(void * __restrict __buf, size_t __size, const char * __restrict __mode) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)); +FILE *open_memstream(char **__bufp, size_t *__sizep) __API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)); +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 200809L */ + + + +/* Darwin extensions */ + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +__BEGIN_DECLS +extern __const int sys_nerr; /* perror(3) external variables */ +extern __const char *__const sys_errlist[]; + +int asprintf(char ** __restrict, const char * __restrict, ...) __printflike(2, 3); +char *ctermid_r(char *); +char *fgetln(FILE *, size_t *); +__const char *fmtcheck(const char *, const char *); +int fpurge(FILE *); +void setbuffer(FILE *, char *, int); +int setlinebuf(FILE *); +int vasprintf(char ** __restrict, const char * __restrict, va_list) __printflike(2, 0); +FILE *zopen(const char *, const char *, int); + + +/* + * Stdio function-access interface. + */ +FILE *funopen(const void *, + int (* _Nullable)(void *, char *, int), + int (* _Nullable)(void *, const char *, int), + fpos_t (* _Nullable)(void *, fpos_t, int), + int (* _Nullable)(void *)); +__END_DECLS +#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) +#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) + +#define feof_unlocked(p) __sfeof(p) +#define ferror_unlocked(p) __sferror(p) +#define clearerr_unlocked(p) __sclearerr(p) +#define fileno_unlocked(p) __sfileno(p) + +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ + + +#ifdef _USE_EXTENDED_LOCALES_ +#include +#endif /* _USE_EXTENDED_LOCALES_ */ + +#if defined (__GNUC__) && _FORTIFY_SOURCE > 0 && !defined (__cplusplus) +/* Security checking functions. */ +#include +#endif + +#endif /* _STDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/stdlib.h b/lib/libc/include/aarch64-macos-gnu/stdlib.h new file mode 100644 index 0000000000..699d3e85c2 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/stdlib.h @@ -0,0 +1,373 @@ +/* + * Copyright (c) 2000, 2002 - 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@ + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 + */ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +#include +#include + +#include <_types.h> +#if !defined(_ANSI_SOURCE) +#include +#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#include +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#endif /* !_ANSI_SOURCE */ + +/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see: + * _GCC_SIZE_T */ +#include + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#include +#include +#endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#include + +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +#if !__DARWIN_NO_LONG_LONG +typedef struct { + long long quot; + long long rem; +} lldiv_t; +#endif /* !__DARWIN_NO_LONG_LONG */ + +#include + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +#define RAND_MAX 0x7fffffff + +#ifdef _USE_EXTENDED_LOCALES_ +#include <_xlocale.h> +#endif /* _USE_EXTENDED_LOCALES_ */ + +#ifndef MB_CUR_MAX +#ifdef _USE_EXTENDED_LOCALES_ +#define MB_CUR_MAX (___mb_cur_max()) +#ifndef MB_CUR_MAX_L +#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x)) +#endif /* !MB_CUR_MAX_L */ +#else /* !_USE_EXTENDED_LOCALES_ */ +extern int __mb_cur_max; +#define MB_CUR_MAX __mb_cur_max +#endif /* _USE_EXTENDED_LOCALES_ */ +#endif /* MB_CUR_MAX */ + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) \ + && defined(_USE_EXTENDED_LOCALES_) && !defined(MB_CUR_MAX_L) +#define MB_CUR_MAX_L(x) (___mb_cur_max_l(x)) +#endif + +#include + +__BEGIN_DECLS +void abort(void) __cold __dead2; +int abs(int) __pure2; +int atexit(void (* _Nonnull)(void)); +double atof(const char *); +int atoi(const char *); +long atol(const char *); +#if !__DARWIN_NO_LONG_LONG +long long + atoll(const char *); +#endif /* !__DARWIN_NO_LONG_LONG */ +void *bsearch(const void *__key, const void *__base, size_t __nel, + size_t __width, int (* _Nonnull __compar)(const void *, const void *)); +/* calloc is now declared in _malloc.h */ +div_t div(int, int) __pure2; +void exit(int) __dead2; +/* free is now declared in _malloc.h */ +char *getenv(const char *); +long labs(long) __pure2; +ldiv_t ldiv(long, long) __pure2; +#if !__DARWIN_NO_LONG_LONG +long long + llabs(long long); +lldiv_t lldiv(long long, long long); +#endif /* !__DARWIN_NO_LONG_LONG */ +/* malloc is now declared in _malloc.h */ +int mblen(const char *__s, size_t __n); +size_t mbstowcs(wchar_t * __restrict , const char * __restrict, size_t); +int mbtowc(wchar_t * __restrict, const char * __restrict, size_t); +/* posix_memalign is now declared in _malloc.h */ +void qsort(void *__base, size_t __nel, size_t __width, + int (* _Nonnull __compar)(const void *, const void *)); +int rand(void) __swift_unavailable("Use arc4random instead."); +/* realloc is now declared in _malloc.h */ +void srand(unsigned) __swift_unavailable("Use arc4random instead."); +double strtod(const char *, char **) __DARWIN_ALIAS(strtod); +float strtof(const char *, char **) __DARWIN_ALIAS(strtof); +long strtol(const char *__str, char **__endptr, int __base); +long double + strtold(const char *, char **); +#if !__DARWIN_NO_LONG_LONG +long long + strtoll(const char *__str, char **__endptr, int __base); +#endif /* !__DARWIN_NO_LONG_LONG */ +unsigned long + strtoul(const char *__str, char **__endptr, int __base); +#if !__DARWIN_NO_LONG_LONG +unsigned long long + strtoull(const char *__str, char **__endptr, int __base); +#endif /* !__DARWIN_NO_LONG_LONG */ + +#if TARGET_OS_IPHONE +#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(ios_msg) +#else +#define __swift_unavailable_on(osx_msg, ios_msg) __swift_unavailable(osx_msg) +#endif + +__swift_unavailable_on("Use posix_spawn APIs or NSTask instead.", "Process spawning is unavailable") +__API_AVAILABLE(macos(10.0)) __IOS_PROHIBITED +__WATCHOS_PROHIBITED __TVOS_PROHIBITED +int system(const char *) __DARWIN_ALIAS_C(system); + +#undef __swift_unavailable_on + +size_t wcstombs(char * __restrict, const wchar_t * __restrict, size_t); +int wctomb(char *, wchar_t); + +#ifndef _ANSI_SOURCE +void _Exit(int) __dead2; +long a64l(const char *); +double drand48(void); +char *ecvt(double, int, int *__restrict, int *__restrict); /* LEGACY */ +double erand48(unsigned short[3]); +char *fcvt(double, int, int *__restrict, int *__restrict); /* LEGACY */ +char *gcvt(double, int, char *); /* LEGACY */ +int getsubopt(char **, char * const *, char **); +int grantpt(int); +#if __DARWIN_UNIX03 +char *initstate(unsigned, char *, size_t); /* no __DARWIN_ALIAS needed */ +#else /* !__DARWIN_UNIX03 */ +char *initstate(unsigned long, char *, long); +#endif /* __DARWIN_UNIX03 */ +long jrand48(unsigned short[3]) __swift_unavailable("Use arc4random instead."); +char *l64a(long); +void lcong48(unsigned short[7]); +long lrand48(void) __swift_unavailable("Use arc4random instead."); +char *mktemp(char *); +int mkstemp(char *); +long mrand48(void) __swift_unavailable("Use arc4random instead."); +long nrand48(unsigned short[3]) __swift_unavailable("Use arc4random instead."); +int posix_openpt(int); +char *ptsname(int); + +#if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +int ptsname_r(int fildes, char *buffer, size_t buflen) __API_AVAILABLE(macos(10.13.4), ios(11.3), tvos(11.3), watchos(4.3)); +#endif + +int putenv(char *) __DARWIN_ALIAS(putenv); +long random(void) __swift_unavailable("Use arc4random instead."); +int rand_r(unsigned *) __swift_unavailable("Use arc4random instead."); +#if (__DARWIN_UNIX03 && !defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(_DARWIN_BETTER_REALPATH) +char *realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath); +#else /* (!__DARWIN_UNIX03 || _POSIX_C_SOURCE) && !_DARWIN_C_SOURCE && !_DARWIN_BETTER_REALPATH */ +char *realpath(const char * __restrict, char * __restrict) __DARWIN_ALIAS(realpath); +#endif /* (__DARWIN_UNIX03 && _POSIX_C_SOURCE) || _DARWIN_C_SOURCE || _DARWIN_BETTER_REALPATH */ +unsigned short + *seed48(unsigned short[3]); +int setenv(const char * __name, const char * __value, int __overwrite) __DARWIN_ALIAS(setenv); +#if __DARWIN_UNIX03 +void setkey(const char *) __DARWIN_ALIAS(setkey); +#else /* !__DARWIN_UNIX03 */ +int setkey(const char *); +#endif /* __DARWIN_UNIX03 */ +char *setstate(const char *); +void srand48(long); +#if __DARWIN_UNIX03 +void srandom(unsigned); +#else /* !__DARWIN_UNIX03 */ +void srandom(unsigned long); +#endif /* __DARWIN_UNIX03 */ +int unlockpt(int); +#if __DARWIN_UNIX03 +int unsetenv(const char *) __DARWIN_ALIAS(unsetenv); +#else /* !__DARWIN_UNIX03 */ +void unsetenv(const char *); +#endif /* __DARWIN_UNIX03 */ +#endif /* !_ANSI_SOURCE */ + +#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) +#include +#include +#include +#include <_types/_uint32_t.h> + +uint32_t arc4random(void); +void arc4random_addrandom(unsigned char * /*dat*/, int /*datlen*/) + __OSX_DEPRECATED(10.0, 10.12, "use arc4random_stir") + __IOS_DEPRECATED(2.0, 10.0, "use arc4random_stir") + __TVOS_DEPRECATED(2.0, 10.0, "use arc4random_stir") + __WATCHOS_DEPRECATED(1.0, 3.0, "use arc4random_stir"); +void arc4random_buf(void * __buf, size_t __nbytes) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +void arc4random_stir(void); +uint32_t + arc4random_uniform(uint32_t __upper_bound) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +#ifdef __BLOCKS__ +int atexit_b(void (^ _Nonnull)(void)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); +void *bsearch_b(const void *__key, const void *__base, size_t __nel, + size_t __width, int (^ _Nonnull __compar)(const void *, const void *)) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); +#endif /* __BLOCKS__ */ + + /* getcap(3) functions */ +char *cgetcap(char *, const char *, int); +int cgetclose(void); +int cgetent(char **, char **, const char *); +int cgetfirst(char **, char **); +int cgetmatch(const char *, const char *); +int cgetnext(char **, char **); +int cgetnum(char *, const char *, long *); +int cgetset(const char *); +int cgetstr(char *, const char *, char **); +int cgetustr(char *, const char *, char **); + +int daemon(int, int) __DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED_MSG(__MAC_10_0, __MAC_10_5, __IPHONE_2_0, __IPHONE_2_0, "Use posix_spawn APIs instead.") __WATCHOS_PROHIBITED __TVOS_PROHIBITED; +char *devname(dev_t, mode_t); +char *devname_r(dev_t, mode_t, char *buf, int len); +char *getbsize(int *, long *); +int getloadavg(double [], int); +const char + *getprogname(void); +void setprogname(const char *); + +#ifdef __BLOCKS__ +#if __has_attribute(noescape) +#define __sort_noescape __attribute__((__noescape__)) +#else +#define __sort_noescape +#endif +#endif /* __BLOCKS__ */ + +int heapsort(void *__base, size_t __nel, size_t __width, + int (* _Nonnull __compar)(const void *, const void *)); +#ifdef __BLOCKS__ +int heapsort_b(void *__base, size_t __nel, size_t __width, + int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape) + __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); +#endif /* __BLOCKS__ */ +int mergesort(void *__base, size_t __nel, size_t __width, + int (* _Nonnull __compar)(const void *, const void *)); +#ifdef __BLOCKS__ +int mergesort_b(void *__base, size_t __nel, size_t __width, + int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape) + __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); +#endif /* __BLOCKS__ */ +void psort(void *__base, size_t __nel, size_t __width, + int (* _Nonnull __compar)(const void *, const void *)) + __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); +#ifdef __BLOCKS__ +void psort_b(void *__base, size_t __nel, size_t __width, + int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape) + __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); +#endif /* __BLOCKS__ */ +void psort_r(void *__base, size_t __nel, size_t __width, void *, + int (* _Nonnull __compar)(void *, const void *, const void *)) + __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); +#ifdef __BLOCKS__ +void qsort_b(void *__base, size_t __nel, size_t __width, + int (^ _Nonnull __compar)(const void *, const void *) __sort_noescape) + __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); +#endif /* __BLOCKS__ */ +void qsort_r(void *__base, size_t __nel, size_t __width, void *, + int (* _Nonnull __compar)(void *, const void *, const void *)); +int radixsort(const unsigned char **__base, int __nel, const unsigned char *__table, + unsigned __endbyte); +int rpmatch(const char *) + __API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0), watchos(6.0)); +int sradixsort(const unsigned char **__base, int __nel, const unsigned char *__table, + unsigned __endbyte); +void sranddev(void); +void srandomdev(void); +void *reallocf(void *__ptr, size_t __size) __alloc_size(2); +long long + strtonum(const char *__numstr, long long __minval, long long __maxval, const char **__errstrp) + __API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)); +#if !__DARWIN_NO_LONG_LONG +long long + strtoq(const char *__str, char **__endptr, int __base); +unsigned long long + strtouq(const char *__str, char **__endptr, int __base); +#endif /* !__DARWIN_NO_LONG_LONG */ +extern char *suboptarg; /* getsubopt(3) external variable */ +/* valloc is now declared in _malloc.h */ +#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ + +/* Poison the following routines if -fshort-wchar is set */ +#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU +#pragma GCC poison mbstowcs mbtowc wcstombs wctomb +#endif +__END_DECLS + +#ifdef _USE_EXTENDED_LOCALES_ +#include +#endif /* _USE_EXTENDED_LOCALES_ */ + +#endif /* _STDLIB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/string.h b/lib/libc/include/aarch64-macos-gnu/string.h new file mode 100644 index 0000000000..c704ee5940 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/string.h @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2000, 2007, 2010 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)string.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _STRING_H_ +#define _STRING_H_ + +#include <_types.h> +#include +#include +#include +#include + +/* ANSI-C */ + +__BEGIN_DECLS +void *memchr(const void *__s, int __c, size_t __n); +int memcmp(const void *__s1, const void *__s2, size_t __n); +void *memcpy(void *__dst, const void *__src, size_t __n); +void *memmove(void *__dst, const void *__src, size_t __len); +void *memset(void *__b, int __c, size_t __len); +char *strcat(char *__s1, const char *__s2); +char *strchr(const char *__s, int __c); +int strcmp(const char *__s1, const char *__s2); +int strcoll(const char *__s1, const char *__s2); +char *strcpy(char *__dst, const char *__src); +size_t strcspn(const char *__s, const char *__charset); +char *strerror(int __errnum) __DARWIN_ALIAS(strerror); +size_t strlen(const char *__s); +char *strncat(char *__s1, const char *__s2, size_t __n); +int strncmp(const char *__s1, const char *__s2, size_t __n); +char *strncpy(char *__dst, const char *__src, size_t __n); +char *strpbrk(const char *__s, const char *__charset); +char *strrchr(const char *__s, int __c); +size_t strspn(const char *__s, const char *__charset); +char *strstr(const char *__big, const char *__little); +char *strtok(char *__str, const char *__sep); +size_t strxfrm(char *__s1, const char *__s2, size_t __n); +__END_DECLS + + + +/* Additional functionality provided by: + * POSIX.1c-1995, + * POSIX.1i-1995, + * and the omnibus ISO/IEC 9945-1: 1996 + */ + +#if __DARWIN_C_LEVEL >= 199506L +__BEGIN_DECLS +char *strtok_r(char *__str, const char *__sep, char **__lasts); +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 199506L */ + + + +/* Additional functionality provided by: + * POSIX.1-2001 + */ + +#if __DARWIN_C_LEVEL >= 200112L +__BEGIN_DECLS +int strerror_r(int __errnum, char *__strerrbuf, size_t __buflen); +char *strdup(const char *__s1); +void *memccpy(void *__dst, const void *__src, int __c, size_t __n); +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 200112L */ + + + +/* Additional functionality provided by: + * POSIX.1-2008 + */ + +#if __DARWIN_C_LEVEL >= 200809L +__BEGIN_DECLS +char *stpcpy(char *__dst, const char *__src); +char *stpncpy(char *__dst, const char *__src, size_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +char *strndup(const char *__s1, size_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +size_t strnlen(const char *__s1, size_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +char *strsignal(int __sig); +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 200809L */ + +/* C11 Annex K */ + +#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 +#include +#include + +__BEGIN_DECLS +errno_t memset_s(void *__s, rsize_t __smax, int __c, rsize_t __n) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0); +__END_DECLS +#endif + +/* Darwin extensions */ + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#include + +__BEGIN_DECLS +void *memmem(const void *__big, size_t __big_len, const void *__little, size_t __little_len) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +void memset_pattern4(void *__b, const void *__pattern4, size_t __len) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0); +void memset_pattern8(void *__b, const void *__pattern8, size_t __len) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0); +void memset_pattern16(void *__b, const void *__pattern16, size_t __len) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_3_0); + +char *strcasestr(const char *__big, const char *__little); +char *strnstr(const char *__big, const char *__little, size_t __len); +size_t strlcat(char *__dst, const char *__source, size_t __size); +size_t strlcpy(char *__dst, const char *__source, size_t __size); +void strmode(int __mode, char *__bp); +char *strsep(char **__stringp, const char *__delim); + +/* SUS places swab() in unistd.h. It is listed here for source compatibility */ +void swab(const void * __restrict, void * __restrict, ssize_t); + +__OSX_AVAILABLE(10.12.1) __IOS_AVAILABLE(10.1) +__TVOS_AVAILABLE(10.0.1) __WATCHOS_AVAILABLE(3.1) +int timingsafe_bcmp(const void *__b1, const void *__b2, size_t __len); + +__OSX_AVAILABLE(11.0) __IOS_AVAILABLE(14.0) +__TVOS_AVAILABLE(14.0) __WATCHOS_AVAILABLE(7.0) +int strsignal_r(int __sig, char *__strsignalbuf, size_t __buflen); +__END_DECLS + +/* Some functions historically defined in string.h were placed in strings.h + * by SUS. We are using "strings.h" instead of to avoid an issue + * where /Developer/Headers/FlatCarbon/Strings.h could be included instead on + * case-insensitive file systems. + */ +#include "strings.h" +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ + + +#ifdef _USE_EXTENDED_LOCALES_ +#include +#endif /* _USE_EXTENDED_LOCALES_ */ + +#if defined (__GNUC__) && _FORTIFY_SOURCE > 0 && !defined (__cplusplus) +/* Security checking functions. */ +#include +#endif + +#endif /* _STRING_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_attr_t.h b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_attr_t.h new file mode 100644 index 0000000000..e46261f1e4 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_attr_t.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _PTHREAD_ATTR_T +#define _PTHREAD_ATTR_T +#include /* __darwin_pthread_attr_t */ +typedef __darwin_pthread_attr_t pthread_attr_t; +#endif /* _PTHREAD_ATTR_T */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_cond_t.h b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_cond_t.h new file mode 100644 index 0000000000..628bd99ce7 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_cond_t.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _PTHREAD_COND_T +#define _PTHREAD_COND_T +#include /* __darwin_pthread_cond_t */ +typedef __darwin_pthread_cond_t pthread_cond_t; +#endif /* _PTHREAD_COND_T */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_condattr_t.h b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_condattr_t.h new file mode 100644 index 0000000000..4352a31611 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_condattr_t.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _PTHREAD_CONDATTR_T +#define _PTHREAD_CONDATTR_T +#include /* __darwin_pthread_condattr_t */ +typedef __darwin_pthread_condattr_t pthread_condattr_t; +#endif /* _PTHREAD_CONDATTR_T */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h new file mode 100644 index 0000000000..f033ed3069 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _PTHREAD_RWLOCK_T +#define _PTHREAD_RWLOCK_T +#include /* __darwin_pthread_rwlock_t */ +typedef __darwin_pthread_rwlock_t pthread_rwlock_t; +#endif /* _PTHREAD_RWLOCK_T */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h new file mode 100644 index 0000000000..6843d994ea --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _PTHREAD_RWLOCKATTR_T +#define _PTHREAD_RWLOCKATTR_T +#include /* __darwin_pthread_rwlockattr_t */ +typedef __darwin_pthread_rwlockattr_t pthread_rwlockattr_t; +#endif /* _PTHREAD_RWLOCKATTR_T */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_t.h b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_t.h new file mode 100644 index 0000000000..bc03e26c2e --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_t.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _PTHREAD_T +#define _PTHREAD_T +#include /* __darwin_pthread_t */ +typedef __darwin_pthread_t pthread_t; +#endif /* _PTHREAD_T */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_types.h b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_types.h new file mode 100644 index 0000000000..5cf3d7a442 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_pthread/_pthread_types.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2003-2013 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _SYS__PTHREAD_TYPES_H_ +#define _SYS__PTHREAD_TYPES_H_ + +#include + +// pthread opaque structures +#if defined(__LP64__) +#define __PTHREAD_SIZE__ 8176 +#define __PTHREAD_ATTR_SIZE__ 56 +#define __PTHREAD_MUTEXATTR_SIZE__ 8 +#define __PTHREAD_MUTEX_SIZE__ 56 +#define __PTHREAD_CONDATTR_SIZE__ 8 +#define __PTHREAD_COND_SIZE__ 40 +#define __PTHREAD_ONCE_SIZE__ 8 +#define __PTHREAD_RWLOCK_SIZE__ 192 +#define __PTHREAD_RWLOCKATTR_SIZE__ 16 +#else // !__LP64__ +#define __PTHREAD_SIZE__ 4088 +#define __PTHREAD_ATTR_SIZE__ 36 +#define __PTHREAD_MUTEXATTR_SIZE__ 8 +#define __PTHREAD_MUTEX_SIZE__ 40 +#define __PTHREAD_CONDATTR_SIZE__ 4 +#define __PTHREAD_COND_SIZE__ 24 +#define __PTHREAD_ONCE_SIZE__ 4 +#define __PTHREAD_RWLOCK_SIZE__ 124 +#define __PTHREAD_RWLOCKATTR_SIZE__ 12 +#endif // !__LP64__ + +struct __darwin_pthread_handler_rec { + void (*__routine)(void *); // Routine to call + void *__arg; // Argument to pass + struct __darwin_pthread_handler_rec *__next; +}; + +struct _opaque_pthread_attr_t { + long __sig; + char __opaque[__PTHREAD_ATTR_SIZE__]; +}; + +struct _opaque_pthread_cond_t { + long __sig; + char __opaque[__PTHREAD_COND_SIZE__]; +}; + +struct _opaque_pthread_condattr_t { + long __sig; + char __opaque[__PTHREAD_CONDATTR_SIZE__]; +}; + +struct _opaque_pthread_mutex_t { + long __sig; + char __opaque[__PTHREAD_MUTEX_SIZE__]; +}; + +struct _opaque_pthread_mutexattr_t { + long __sig; + char __opaque[__PTHREAD_MUTEXATTR_SIZE__]; +}; + +struct _opaque_pthread_once_t { + long __sig; + char __opaque[__PTHREAD_ONCE_SIZE__]; +}; + +struct _opaque_pthread_rwlock_t { + long __sig; + char __opaque[__PTHREAD_RWLOCK_SIZE__]; +}; + +struct _opaque_pthread_rwlockattr_t { + long __sig; + char __opaque[__PTHREAD_RWLOCKATTR_SIZE__]; +}; + +struct _opaque_pthread_t { + long __sig; + struct __darwin_pthread_handler_rec *__cleanup_stack; + char __opaque[__PTHREAD_SIZE__]; +}; + +typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t; +typedef struct _opaque_pthread_cond_t __darwin_pthread_cond_t; +typedef struct _opaque_pthread_condattr_t __darwin_pthread_condattr_t; +typedef unsigned long __darwin_pthread_key_t; +typedef struct _opaque_pthread_mutex_t __darwin_pthread_mutex_t; +typedef struct _opaque_pthread_mutexattr_t __darwin_pthread_mutexattr_t; +typedef struct _opaque_pthread_once_t __darwin_pthread_once_t; +typedef struct _opaque_pthread_rwlock_t __darwin_pthread_rwlock_t; +typedef struct _opaque_pthread_rwlockattr_t __darwin_pthread_rwlockattr_t; +typedef struct _opaque_pthread_t *__darwin_pthread_t; + +#endif // _SYS__PTHREAD_TYPES_H_ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_select.h b/lib/libc/include/aarch64-macos-gnu/sys/_select.h new file mode 100644 index 0000000000..587b506d0c --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_select.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2005, 2007 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +/* + * This is called from sys/select.h and sys/time.h for the common prototype + * of select(). Setting _DARWIN_C_SOURCE or _DARWIN_UNLIMITED_SELECT uses + * the version of select() that does not place a limit on the first argument + * (nfds). In the UNIX conformance case, values of nfds greater than + * FD_SETSIZE will return an error of EINVAL. + */ +#ifndef _SYS__SELECT_H_ +#define _SYS__SELECT_H_ + +#include /* __DARWIN_EXTSN_C, __DARWIN_1050, __DARWIN_ALIAS_C */ +#include /* fd_set */ +#include /* struct timeval */ + +int select(int, fd_set * __restrict, fd_set * __restrict, + fd_set * __restrict, struct timeval * __restrict) + +#if defined(_DARWIN_C_SOURCE) || defined(_DARWIN_UNLIMITED_SELECT) +__DARWIN_EXTSN_C(select) +#else /* !_DARWIN_C_SOURCE && !_DARWIN_UNLIMITED_SELECT */ +# if defined(__LP64__) && !__DARWIN_NON_CANCELABLE +__DARWIN_1050(select) +# else /* !__LP64__ || __DARWIN_NON_CANCELABLE */ +__DARWIN_ALIAS_C(select) +# endif /* __LP64__ && !__DARWIN_NON_CANCELABLE */ +#endif /* _DARWIN_C_SOURCE || _DARWIN_UNLIMITED_SELECT */ +; + +#endif /* !_SYS__SELECT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_symbol_aliasing.h b/lib/libc/include/aarch64-macos-gnu/sys/_symbol_aliasing.h new file mode 100644 index 0000000000..151156d6e1 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_symbol_aliasing.h @@ -0,0 +1,534 @@ +/* Copyright (c) 2010 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +#ifndef _CDEFS_H_ +# error "Never use directly. Use instead." +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_2_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_2_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_2_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_2_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 20200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_2_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_2_2(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_3_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_3_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_3_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_3_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 30200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_3_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_3_2(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_2(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 40300 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_4_3(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 50000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_5_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_5_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 50100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_5_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_5_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 60000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_6_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_6_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 60100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_6_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_6_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 70000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_7_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_7_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 70100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_7_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_7_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 80000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 80100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 80200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_2(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 80300 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_3(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 80400 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_4(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_4(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 90000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 90100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 90200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_2(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 90300 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_3(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_2(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100300 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_3(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 110000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 110100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 110200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_2(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 110300 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_3(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 110400 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_4(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_11_4(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 120000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 120100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 120200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_2(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 120300 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_3(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 120400 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_4(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_12_4(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_2(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130300 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_3(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130400 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_4(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_4(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130500 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_5(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_5(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130600 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_6(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_6(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130700 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_7(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_13_7(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140000 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_0(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140100 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_1(x) +#endif + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 140200 +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_14_2(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1000 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_0(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1010 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_1(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1020 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_2(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1030 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_3(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1040 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_4(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_4(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_5(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_5(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_6(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_6(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_7(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_7(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1080 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_8(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_8(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1090 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_9(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_9(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101000 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_10(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_10(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101002 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_10_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_10_2(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101003 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_10_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_10_3(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101100 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_11(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_11(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101102 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_11_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_11_2(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101103 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_11_3(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_11_3(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101104 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_11_4(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_11_4(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_12(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_12(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101201 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_12_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_12_1(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101202 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_12_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_12_2(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101204 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_12_4(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_12_4(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101300 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_13(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_13(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101301 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_13_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_13_1(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101302 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_13_2(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_13_2(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101304 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_13_4(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_13_4(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101400 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101401 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_1(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101404 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_4(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_4(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101405 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_5(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_5(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101406 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_6(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_14_6(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_15(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_15(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101501 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_15_1(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_15_1(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101600 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_16(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_10_16(x) +#endif + +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 110000 +#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_0(x) x +#else +#define __DARWIN_ALIAS_STARTING_MAC___MAC_11_0(x) +#endif \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_types/_fd_def.h b/lib/libc/include/aarch64-macos-gnu/sys/_types/_fd_def.h new file mode 100644 index 0000000000..138a1d49e2 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_types/_fd_def.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _FD_SET +#define _FD_SET + +#include /* __int32_t and uintptr_t */ +#include + +/* + * Select uses bit masks of file descriptors in longs. These macros + * manipulate such bit fields (the filesystem macros use chars). The + * extra protection here is to permit application redefinition above + * the default size. + */ +#ifdef FD_SETSIZE +#define __DARWIN_FD_SETSIZE FD_SETSIZE +#else /* !FD_SETSIZE */ +#define __DARWIN_FD_SETSIZE 1024 +#endif /* FD_SETSIZE */ +#define __DARWIN_NBBY 8 /* bits in a byte */ +#define __DARWIN_NFDBITS (sizeof(__int32_t) * __DARWIN_NBBY) /* bits per mask */ +#define __DARWIN_howmany(x, y) ((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1)) /* # y's == x bits? */ + +__BEGIN_DECLS +typedef struct fd_set { + __int32_t fds_bits[__DARWIN_howmany(__DARWIN_FD_SETSIZE, __DARWIN_NFDBITS)]; +} fd_set; + +int __darwin_check_fd_set_overflow(int, const void *, int) __API_AVAILABLE(macosx(11.0), ios(14.0), tvos(14.0), watchos(7.0)); +__END_DECLS + +__header_always_inline int +__darwin_check_fd_set(int _a, const void *_b) +{ +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability-new" +#endif + if ((uintptr_t)&__darwin_check_fd_set_overflow != (uintptr_t) 0) { +#if defined(_DARWIN_UNLIMITED_SELECT) || defined(_DARWIN_C_SOURCE) + return __darwin_check_fd_set_overflow(_a, _b, 1); +#else + return __darwin_check_fd_set_overflow(_a, _b, 0); +#endif + } else { + return 1; + } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +} + +/* This inline avoids argument side-effect issues with FD_ISSET() */ +__header_always_inline int +__darwin_fd_isset(int _fd, const struct fd_set *_p) +{ + if (__darwin_check_fd_set(_fd, (const void *) _p)) { + return _p->fds_bits[(unsigned long)_fd / __DARWIN_NFDBITS] & ((__int32_t)(((unsigned long)1) << ((unsigned long)_fd % __DARWIN_NFDBITS))); + } + + return 0; +} + +__header_always_inline void +__darwin_fd_set(int _fd, struct fd_set *const _p) +{ + if (__darwin_check_fd_set(_fd, (const void *) _p)) { + (_p->fds_bits[(unsigned long)_fd / __DARWIN_NFDBITS] |= ((__int32_t)(((unsigned long)1) << ((unsigned long)_fd % __DARWIN_NFDBITS)))); + } +} + +__header_always_inline void +__darwin_fd_clr(int _fd, struct fd_set *const _p) +{ + if (__darwin_check_fd_set(_fd, (const void *) _p)) { + (_p->fds_bits[(unsigned long)_fd / __DARWIN_NFDBITS] &= ~((__int32_t)(((unsigned long)1) << ((unsigned long)_fd % __DARWIN_NFDBITS)))); + } +} + + +#define __DARWIN_FD_SET(n, p) __darwin_fd_set((n), (p)) +#define __DARWIN_FD_CLR(n, p) __darwin_fd_clr((n), (p)) +#define __DARWIN_FD_ISSET(n, p) __darwin_fd_isset((n), (p)) + +#if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3 +/* + * Use the built-in bzero function instead of the library version so that + * we do not pollute the namespace or introduce prototype warnings. + */ +#define __DARWIN_FD_ZERO(p) __builtin_bzero(p, sizeof(*(p))) +#else +#define __DARWIN_FD_ZERO(p) bzero(p, sizeof(*(p))) +#endif + +#define __DARWIN_FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) +#endif /* _FD_SET */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_types/_int8_t.h b/lib/libc/include/aarch64-macos-gnu/sys/_types/_int8_t.h new file mode 100644 index 0000000000..5ca9ba85b0 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_types/_int8_t.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _INT8_T +#define _INT8_T +typedef signed char int8_t; +#endif /* _INT8_T */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/_types/_ucontext.h b/lib/libc/include/aarch64-macos-gnu/sys/_types/_ucontext.h new file mode 100644 index 0000000000..de3132a861 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/_types/_ucontext.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2003-2012 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +#ifndef _STRUCT_UCONTEXT + +#include /* __DARWIN_UNIX03 */ + +#if __DARWIN_UNIX03 +#define _STRUCT_UCONTEXT struct __darwin_ucontext +#else /* !__DARWIN_UNIX03 */ +#define _STRUCT_UCONTEXT struct ucontext +#endif /* __DARWIN_UNIX03 */ + +#include /* __darwin_size_t */ +#include /* _STRUCT_MCONTEXT */ +#include /* __darwin_sigset_t */ +#include /* _STRUCT_SIGALTSTACK */ + +_STRUCT_UCONTEXT +{ + int uc_onstack; + __darwin_sigset_t uc_sigmask; /* signal mask used by this context */ + _STRUCT_SIGALTSTACK uc_stack; /* stack used by this context */ + _STRUCT_UCONTEXT *uc_link; /* pointer to resuming context */ + __darwin_size_t uc_mcsize; /* size of the machine context passed in */ + _STRUCT_MCONTEXT *uc_mcontext; /* pointer to machine specific context */ +#ifdef _XOPEN_SOURCE + _STRUCT_MCONTEXT __mcontext_data; +#endif /* _XOPEN_SOURCE */ +}; + +/* user context */ +typedef _STRUCT_UCONTEXT ucontext_t; /* [???] user context */ + +#endif /* _STRUCT_UCONTEXT */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/acl.h b/lib/libc/include/aarch64-macos-gnu/sys/acl.h new file mode 100644 index 0000000000..f2a5385714 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/acl.h @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2004, 2010 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. + * + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _SYS_ACL_H +#define _SYS_ACL_H + +#include +#include +#include + +#define __DARWIN_ACL_READ_DATA (1<<1) +#define __DARWIN_ACL_LIST_DIRECTORY __DARWIN_ACL_READ_DATA +#define __DARWIN_ACL_WRITE_DATA (1<<2) +#define __DARWIN_ACL_ADD_FILE __DARWIN_ACL_WRITE_DATA +#define __DARWIN_ACL_EXECUTE (1<<3) +#define __DARWIN_ACL_SEARCH __DARWIN_ACL_EXECUTE +#define __DARWIN_ACL_DELETE (1<<4) +#define __DARWIN_ACL_APPEND_DATA (1<<5) +#define __DARWIN_ACL_ADD_SUBDIRECTORY __DARWIN_ACL_APPEND_DATA +#define __DARWIN_ACL_DELETE_CHILD (1<<6) +#define __DARWIN_ACL_READ_ATTRIBUTES (1<<7) +#define __DARWIN_ACL_WRITE_ATTRIBUTES (1<<8) +#define __DARWIN_ACL_READ_EXTATTRIBUTES (1<<9) +#define __DARWIN_ACL_WRITE_EXTATTRIBUTES (1<<10) +#define __DARWIN_ACL_READ_SECURITY (1<<11) +#define __DARWIN_ACL_WRITE_SECURITY (1<<12) +#define __DARWIN_ACL_CHANGE_OWNER (1<<13) +#define __DARWIN_ACL_SYNCHRONIZE (1<<20) + +#define __DARWIN_ACL_EXTENDED_ALLOW 1 +#define __DARWIN_ACL_EXTENDED_DENY 2 + +#define __DARWIN_ACL_ENTRY_INHERITED (1<<4) +#define __DARWIN_ACL_ENTRY_FILE_INHERIT (1<<5) +#define __DARWIN_ACL_ENTRY_DIRECTORY_INHERIT (1<<6) +#define __DARWIN_ACL_ENTRY_LIMIT_INHERIT (1<<7) +#define __DARWIN_ACL_ENTRY_ONLY_INHERIT (1<<8) +#define __DARWIN_ACL_FLAG_NO_INHERIT (1<<17) + +/* + * Implementation constants. + * + * The ACL_TYPE_EXTENDED binary format permits 169 entries plus + * the ACL header in a page. Give ourselves some room to grow; + * this limit is arbitrary. + */ +#define ACL_MAX_ENTRIES 128 + +/* 23.2.2 Individual object access permissions - nonstandard */ +typedef enum { + ACL_READ_DATA = __DARWIN_ACL_READ_DATA, + ACL_LIST_DIRECTORY = __DARWIN_ACL_LIST_DIRECTORY, + ACL_WRITE_DATA = __DARWIN_ACL_WRITE_DATA, + ACL_ADD_FILE = __DARWIN_ACL_ADD_FILE, + ACL_EXECUTE = __DARWIN_ACL_EXECUTE, + ACL_SEARCH = __DARWIN_ACL_SEARCH, + ACL_DELETE = __DARWIN_ACL_DELETE, + ACL_APPEND_DATA = __DARWIN_ACL_APPEND_DATA, + ACL_ADD_SUBDIRECTORY = __DARWIN_ACL_ADD_SUBDIRECTORY, + ACL_DELETE_CHILD = __DARWIN_ACL_DELETE_CHILD, + ACL_READ_ATTRIBUTES = __DARWIN_ACL_READ_ATTRIBUTES, + ACL_WRITE_ATTRIBUTES = __DARWIN_ACL_WRITE_ATTRIBUTES, + ACL_READ_EXTATTRIBUTES = __DARWIN_ACL_READ_EXTATTRIBUTES, + ACL_WRITE_EXTATTRIBUTES = __DARWIN_ACL_WRITE_EXTATTRIBUTES, + ACL_READ_SECURITY = __DARWIN_ACL_READ_SECURITY, + ACL_WRITE_SECURITY = __DARWIN_ACL_WRITE_SECURITY, + ACL_CHANGE_OWNER = __DARWIN_ACL_CHANGE_OWNER, + ACL_SYNCHRONIZE = __DARWIN_ACL_SYNCHRONIZE, +} acl_perm_t; + +/* 23.2.5 ACL entry tag type bits - nonstandard */ +typedef enum { + ACL_UNDEFINED_TAG = 0, + ACL_EXTENDED_ALLOW = __DARWIN_ACL_EXTENDED_ALLOW, + ACL_EXTENDED_DENY = __DARWIN_ACL_EXTENDED_DENY +} acl_tag_t; + +/* 23.2.6 Individual ACL types */ +typedef enum { + ACL_TYPE_EXTENDED = 0x00000100, +/* Posix 1003.1e types - not supported */ + ACL_TYPE_ACCESS = 0x00000000, + ACL_TYPE_DEFAULT = 0x00000001, +/* The following types are defined on FreeBSD/Linux - not supported */ + ACL_TYPE_AFS = 0x00000002, + ACL_TYPE_CODA = 0x00000003, + ACL_TYPE_NTFS = 0x00000004, + ACL_TYPE_NWFS = 0x00000005 +} acl_type_t; + +/* 23.2.7 ACL qualifier constants */ + +#define ACL_UNDEFINED_ID NULL /* XXX ? */ + +/* 23.2.8 ACL Entry Constants */ +typedef enum { + ACL_FIRST_ENTRY = 0, + ACL_NEXT_ENTRY = -1, + ACL_LAST_ENTRY = -2 +} acl_entry_id_t; + +/* nonstandard ACL / entry flags */ +typedef enum { + ACL_FLAG_DEFER_INHERIT = (1 << 0), /* tentative */ + ACL_FLAG_NO_INHERIT = __DARWIN_ACL_FLAG_NO_INHERIT, + ACL_ENTRY_INHERITED = __DARWIN_ACL_ENTRY_INHERITED, + ACL_ENTRY_FILE_INHERIT = __DARWIN_ACL_ENTRY_FILE_INHERIT, + ACL_ENTRY_DIRECTORY_INHERIT = __DARWIN_ACL_ENTRY_DIRECTORY_INHERIT, + ACL_ENTRY_LIMIT_INHERIT = __DARWIN_ACL_ENTRY_LIMIT_INHERIT, + ACL_ENTRY_ONLY_INHERIT = __DARWIN_ACL_ENTRY_ONLY_INHERIT +} acl_flag_t; + +/* "External" ACL types */ + +struct _acl; +struct _acl_entry; +struct _acl_permset; +struct _acl_flagset; + +typedef struct _acl *acl_t; +typedef struct _acl_entry *acl_entry_t; +typedef struct _acl_permset *acl_permset_t; +typedef struct _acl_flagset *acl_flagset_t; + +typedef u_int64_t acl_permset_mask_t; + +__BEGIN_DECLS +/* 23.1.6.1 ACL Storage Management */ +extern acl_t acl_dup(acl_t acl); +extern int acl_free(void *obj_p); +extern acl_t acl_init(int count); + +/* 23.1.6.2 (1) ACL Entry manipulation */ +extern int acl_copy_entry(acl_entry_t dest_d, acl_entry_t src_d); +extern int acl_create_entry(acl_t *acl_p, acl_entry_t *entry_p); +extern int acl_create_entry_np(acl_t *acl_p, acl_entry_t *entry_p, int entry_index); +extern int acl_delete_entry(acl_t acl, acl_entry_t entry_d); +extern int acl_get_entry(acl_t acl, int entry_id, acl_entry_t *entry_p); +extern int acl_valid(acl_t acl); +extern int acl_valid_fd_np(int fd, acl_type_t type, acl_t acl); +extern int acl_valid_file_np(const char *path, acl_type_t type, acl_t acl); +extern int acl_valid_link_np(const char *path, acl_type_t type, acl_t acl); + +/* 23.1.6.2 (2) Manipulate permissions within an ACL entry */ +extern int acl_add_perm(acl_permset_t permset_d, acl_perm_t perm); +extern int acl_calc_mask(acl_t *acl_p); /* not supported */ +extern int acl_clear_perms(acl_permset_t permset_d); +extern int acl_delete_perm(acl_permset_t permset_d, acl_perm_t perm); +extern int acl_get_perm_np(acl_permset_t permset_d, acl_perm_t perm); +extern int acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p); +extern int acl_set_permset(acl_entry_t entry_d, acl_permset_t permset_d); + +/* nonstandard - manipulate permissions within an ACL entry using bitmasks */ +extern int acl_maximal_permset_mask_np(acl_permset_mask_t * mask_p) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +extern int acl_get_permset_mask_np(acl_entry_t entry_d, acl_permset_mask_t * mask_p) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +extern int acl_set_permset_mask_np(acl_entry_t entry_d, acl_permset_mask_t mask) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); + +/* nonstandard - manipulate flags on ACLs and entries */ +extern int acl_add_flag_np(acl_flagset_t flagset_d, acl_flag_t flag); +extern int acl_clear_flags_np(acl_flagset_t flagset_d); +extern int acl_delete_flag_np(acl_flagset_t flagset_d, acl_flag_t flag); +extern int acl_get_flag_np(acl_flagset_t flagset_d, acl_flag_t flag); +extern int acl_get_flagset_np(void *obj_p, acl_flagset_t *flagset_p); +extern int acl_set_flagset_np(void *obj_p, acl_flagset_t flagset_d); + +/* 23.1.6.2 (3) Manipulate ACL entry tag type and qualifier */ +extern void *acl_get_qualifier(acl_entry_t entry_d); +extern int acl_get_tag_type(acl_entry_t entry_d, acl_tag_t *tag_type_p); +extern int acl_set_qualifier(acl_entry_t entry_d, const void *tag_qualifier_p); +extern int acl_set_tag_type(acl_entry_t entry_d, acl_tag_t tag_type); + +/* 23.1.6.3 ACL manipulation on an Object */ +extern int acl_delete_def_file(const char *path_p); /* not supported */ +extern acl_t acl_get_fd(int fd); +extern acl_t acl_get_fd_np(int fd, acl_type_t type); +extern acl_t acl_get_file(const char *path_p, acl_type_t type); +extern acl_t acl_get_link_np(const char *path_p, acl_type_t type); +extern int acl_set_fd(int fd, acl_t acl); +extern int acl_set_fd_np(int fd, acl_t acl, acl_type_t acl_type); +extern int acl_set_file(const char *path_p, acl_type_t type, acl_t acl); +extern int acl_set_link_np(const char *path_p, acl_type_t type, acl_t acl); + +/* 23.1.6.4 ACL Format translation */ +extern ssize_t acl_copy_ext(void *buf_p, acl_t acl, ssize_t size); +extern ssize_t acl_copy_ext_native(void *buf_p, acl_t acl, ssize_t size); +extern acl_t acl_copy_int(const void *buf_p); +extern acl_t acl_copy_int_native(const void *buf_p); +extern acl_t acl_from_text(const char *buf_p); +extern ssize_t acl_size(acl_t acl); +extern char *acl_to_text(acl_t acl, ssize_t *len_p); +__END_DECLS + +#endif /* _SYS_ACL_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/attr.h b/lib/libc/include/aarch64-macos-gnu/sys/attr.h new file mode 100644 index 0000000000..9eca5efb34 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/attr.h @@ -0,0 +1,586 @@ +/* + * Copyright (c) 2000-2018 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ + +/* + * attr.h - attribute data structures and interfaces + * + * Copyright (c) 1998, Apple Computer, Inc. All Rights Reserved. + */ + +#ifndef _SYS_ATTR_H_ +#define _SYS_ATTR_H_ + +#include + +#ifdef __APPLE_API_UNSTABLE +#include +#include +#include +#include + +#define FSOPT_NOFOLLOW 0x00000001 +#define FSOPT_NOINMEMUPDATE 0x00000002 +#define FSOPT_REPORT_FULLSIZE 0x00000004 +/* The following option only valid when requesting ATTR_CMN_RETURNED_ATTRS */ +#define FSOPT_PACK_INVAL_ATTRS 0x00000008 + + +#define FSOPT_ATTR_CMN_EXTENDED 0x00000020 +#define FSOPT_RETURN_REALDEV 0x00000200 + +/* we currently aren't anywhere near this amount for a valid + * fssearchblock.sizeofsearchparams1 or fssearchblock.sizeofsearchparams2 + * but we put a sanity check in to avoid abuse of the value passed in from + * user land. + */ +#define SEARCHFS_MAX_SEARCHPARMS 4096 + +typedef u_int32_t text_encoding_t; + +typedef u_int32_t fsobj_type_t; + +typedef u_int32_t fsobj_tag_t; + +typedef u_int32_t fsfile_type_t; + +typedef u_int32_t fsvolid_t; + +#include /* file object id type */ + +typedef u_int32_t attrgroup_t; + +struct attrlist { + u_short bitmapcount; /* number of attr. bit sets in list (should be 5) */ + u_int16_t reserved; /* (to maintain 4-byte alignment) */ + attrgroup_t commonattr; /* common attribute group */ + attrgroup_t volattr; /* Volume attribute group */ + attrgroup_t dirattr; /* directory attribute group */ + attrgroup_t fileattr; /* file attribute group */ + attrgroup_t forkattr; /* fork attribute group */ +}; +#define ATTR_BIT_MAP_COUNT 5 + +typedef struct attribute_set { + attrgroup_t commonattr; /* common attribute group */ + attrgroup_t volattr; /* Volume attribute group */ + attrgroup_t dirattr; /* directory attribute group */ + attrgroup_t fileattr; /* file attribute group */ + attrgroup_t forkattr; /* fork attribute group */ +} attribute_set_t; + +typedef struct attrreference { + int32_t attr_dataoffset; + u_int32_t attr_length; +} attrreference_t; + +/* XXX PPD This is derived from HFSVolumePriv.h and should perhaps be referenced from there? */ + +struct diskextent { + u_int32_t startblock; /* first block allocated */ + u_int32_t blockcount; /* number of blocks allocated */ +}; + +typedef struct diskextent extentrecord[8]; + +typedef u_int32_t vol_capabilities_set_t[4]; + +#define VOL_CAPABILITIES_FORMAT 0 +#define VOL_CAPABILITIES_INTERFACES 1 +#define VOL_CAPABILITIES_RESERVED1 2 +#define VOL_CAPABILITIES_RESERVED2 3 + +typedef struct vol_capabilities_attr { + vol_capabilities_set_t capabilities; + vol_capabilities_set_t valid; +} vol_capabilities_attr_t; + +/* + * XXX this value needs to be raised - 3893388 + */ +#define ATTR_MAX_BUFFER 8192 + +/* + * VOL_CAP_FMT_PERSISTENTOBJECTIDS: When set, the volume has object IDs + * that are persistent (retain their values even when the volume is + * unmounted and remounted), and a file or directory can be looked up + * by ID. Volumes that support VolFS and can support Carbon File ID + * references should set this bit. + * + * VOL_CAP_FMT_SYMBOLICLINKS: When set, the volume supports symbolic + * links. The symlink(), readlink(), and lstat() calls all use this + * symbolic link. + * + * VOL_CAP_FMT_HARDLINKS: When set, the volume supports hard links. + * The link() call creates hard links. + * + * VOL_CAP_FMT_JOURNAL: When set, the volume is capable of supporting + * a journal used to speed recovery in case of unplanned shutdown + * (such as a power outage or crash). This bit does not necessarily + * mean the volume is actively using a journal for recovery. + * + * VOL_CAP_FMT_JOURNAL_ACTIVE: When set, the volume is currently using + * a journal for use in speeding recovery after an unplanned shutdown. + * This bit can be set only if VOL_CAP_FMT_JOURNAL is also set. + * + * VOL_CAP_FMT_NO_ROOT_TIMES: When set, the volume format does not + * store reliable times for the root directory, so you should not + * depend on them to detect changes, etc. + * + * VOL_CAP_FMT_SPARSE_FILES: When set, the volume supports sparse files. + * That is, files which can have "holes" that have never been written + * to, and are not allocated on disk. Sparse files may have an + * allocated size that is less than the file's logical length. + * + * VOL_CAP_FMT_ZERO_RUNS: For security reasons, parts of a file (runs) + * that have never been written to must appear to contain zeroes. When + * this bit is set, the volume keeps track of allocated but unwritten + * runs of a file so that it can substitute zeroes without actually + * writing zeroes to the media. This provides performance similar to + * sparse files, but not the space savings. + * + * VOL_CAP_FMT_CASE_SENSITIVE: When set, file and directory names are + * case sensitive (upper and lower case are different). When clear, + * an upper case character is equivalent to a lower case character, + * and you can't have two names that differ solely in the case of + * the characters. + * + * VOL_CAP_FMT_CASE_PRESERVING: When set, file and directory names + * preserve the difference between upper and lower case. If clear, + * the volume may change the case of some characters (typically + * making them all upper or all lower case). A volume that sets + * VOL_CAP_FMT_CASE_SENSITIVE should also set VOL_CAP_FMT_CASE_PRESERVING. + * + * VOL_CAP_FMT_FAST_STATFS: This bit is used as a hint to upper layers + * (especially Carbon) that statfs() is fast enough that its results + * need not be cached by those upper layers. A volume that caches + * the statfs information in its in-memory structures should set this bit. + * A volume that must always read from disk or always perform a network + * transaction should not set this bit. + * + * VOL_CAP_FMT_2TB_FILESIZE: If this bit is set the volume format supports + * file sizes larger than 4GB, and potentially up to 2TB; it does not + * indicate whether the filesystem supports files larger than that. + * + * VOL_CAP_FMT_OPENDENYMODES: When set, the volume supports open deny + * modes (e.g. "open for read write, deny write"; effectively, mandatory + * file locking based on open modes). + * + * VOL_CAP_FMT_HIDDEN_FILES: When set, the volume supports the UF_HIDDEN + * file flag, and the UF_HIDDEN flag is mapped to that volume's native + * "hidden" or "invisible" bit (which may be the invisible bit from the + * Finder Info extended attribute). + * + * VOL_CAP_FMT_PATH_FROM_ID: When set, the volume supports the ability + * to derive a pathname to the root of the file system given only the + * id of an object. This also implies that object ids on this file + * system are persistent and not recycled. This is a very specialized + * capability and it is assumed that most file systems will not support + * it. Its use is for legacy non-posix APIs like ResolveFileIDRef. + * + * VOL_CAP_FMT_NO_VOLUME_SIZES: When set, the volume does not support + * returning values for total data blocks, available blocks, or free blocks + * (as in f_blocks, f_bavail, or f_bfree in "struct statfs"). Historically, + * those values were set to 0xFFFFFFFF for volumes that did not support them. + * + * VOL_CAP_FMT_DECMPFS_COMPRESSION: When set, the volume supports transparent + * decompression of compressed files using decmpfs. + * + * VOL_CAP_FMT_64BIT_OBJECT_IDS: When set, the volume uses object IDs that + * are 64-bit. This means that ATTR_CMN_FILEID and ATTR_CMN_PARENTID are the + * only legitimate attributes for obtaining object IDs from this volume and the + * 32-bit fid_objno fields of the fsobj_id_t returned by ATTR_CMN_OBJID, + * ATTR_CMN_OBJPERMID, and ATTR_CMN_PAROBJID are undefined. + * + * VOL_CAP_FMT_DIR_HARDLINKS: When set, the volume supports directory + * hard links. + * + * VOL_CAP_FMT_DOCUMENT_ID: When set, the volume supports document IDs + * (an ID which persists across object ID changes) for document revisions. + * + * VOL_CAP_FMT_WRITE_GENERATION_COUNT: When set, the volume supports write + * generation counts (a count of how many times an object has been modified) + * + * VOL_CAP_FMT_NO_IMMUTABLE_FILES: When set, the volume does not support + * setting the UF_IMMUTABLE flag. + * + * VOL_CAP_FMT_NO_PERMISSIONS: When set, the volume does not support setting + * permissions. + * + * VOL_CAP_FMT_SHARED_SPACE: When set, the volume supports sharing space with + * other filesystems i.e. multiple logical filesystems can exist in the same + * "partition". An implication of this is that the filesystem which sets + * this capability treats waitfor arguments to VFS_SYNC as bit flags. + * + * VOL_CAP_FMT_VOL_GROUPS: When set, this volume is part of a volume-group + * that implies multiple volumes must be mounted in order to boot and root the + * operating system. Typically, this means a read-only system volume and a + * writable data volume. + * + * VOL_CAP_FMT_SEALED: When set, this volume is cryptographically sealed. + * Any modifications to volume data or metadata will be detected and may + * render the volume unusable. + */ +#define VOL_CAP_FMT_PERSISTENTOBJECTIDS 0x00000001 +#define VOL_CAP_FMT_SYMBOLICLINKS 0x00000002 +#define VOL_CAP_FMT_HARDLINKS 0x00000004 +#define VOL_CAP_FMT_JOURNAL 0x00000008 +#define VOL_CAP_FMT_JOURNAL_ACTIVE 0x00000010 +#define VOL_CAP_FMT_NO_ROOT_TIMES 0x00000020 +#define VOL_CAP_FMT_SPARSE_FILES 0x00000040 +#define VOL_CAP_FMT_ZERO_RUNS 0x00000080 +#define VOL_CAP_FMT_CASE_SENSITIVE 0x00000100 +#define VOL_CAP_FMT_CASE_PRESERVING 0x00000200 +#define VOL_CAP_FMT_FAST_STATFS 0x00000400 +#define VOL_CAP_FMT_2TB_FILESIZE 0x00000800 +#define VOL_CAP_FMT_OPENDENYMODES 0x00001000 +#define VOL_CAP_FMT_HIDDEN_FILES 0x00002000 +#define VOL_CAP_FMT_PATH_FROM_ID 0x00004000 +#define VOL_CAP_FMT_NO_VOLUME_SIZES 0x00008000 +#define VOL_CAP_FMT_DECMPFS_COMPRESSION 0x00010000 +#define VOL_CAP_FMT_64BIT_OBJECT_IDS 0x00020000 +#define VOL_CAP_FMT_DIR_HARDLINKS 0x00040000 +#define VOL_CAP_FMT_DOCUMENT_ID 0x00080000 +#define VOL_CAP_FMT_WRITE_GENERATION_COUNT 0x00100000 +#define VOL_CAP_FMT_NO_IMMUTABLE_FILES 0x00200000 +#define VOL_CAP_FMT_NO_PERMISSIONS 0x00400000 +#define VOL_CAP_FMT_SHARED_SPACE 0x00800000 +#define VOL_CAP_FMT_VOL_GROUPS 0x01000000 +#define VOL_CAP_FMT_SEALED 0x02000000 + +/* + * VOL_CAP_INT_SEARCHFS: When set, the volume implements the + * searchfs() system call (the vnop_searchfs vnode operation). + * + * VOL_CAP_INT_ATTRLIST: When set, the volume implements the + * getattrlist() and setattrlist() system calls (vnop_getattrlist + * and vnop_setattrlist vnode operations) for the volume, files, + * and directories. The volume may or may not implement the + * readdirattr() system call. XXX Is there any minimum set + * of attributes that should be supported? To determine the + * set of supported attributes, get the ATTR_VOL_ATTRIBUTES + * attribute of the volume. + * + * VOL_CAP_INT_NFSEXPORT: When set, the volume implements exporting + * of NFS volumes. + * + * VOL_CAP_INT_READDIRATTR: When set, the volume implements the + * readdirattr() system call (vnop_readdirattr vnode operation). + * + * VOL_CAP_INT_EXCHANGEDATA: When set, the volume implements the + * exchangedata() system call (VNOP_EXCHANGE vnode operation). + * + * VOL_CAP_INT_COPYFILE: When set, the volume implements the + * VOP_COPYFILE vnode operation. (XXX There should be a copyfile() + * system call in .) + * + * VOL_CAP_INT_ALLOCATE: When set, the volume implements the + * VNOP_ALLOCATE vnode operation, which means it implements the + * F_PREALLOCATE selector of fcntl(2). + * + * VOL_CAP_INT_VOL_RENAME: When set, the volume implements the + * ATTR_VOL_NAME attribute for both getattrlist() and setattrlist(). + * The volume can be renamed by setting ATTR_VOL_NAME with setattrlist(). + * + * VOL_CAP_INT_ADVLOCK: When set, the volume implements POSIX style + * byte range locks via vnop_advlock (accessible from fcntl(2)). + * + * VOL_CAP_INT_FLOCK: When set, the volume implements whole-file flock(2) + * style locks via vnop_advlock. This includes the O_EXLOCK and O_SHLOCK + * flags of the open(2) call. + * + * VOL_CAP_INT_EXTENDED_SECURITY: When set, the volume implements + * extended security (ACLs). + * + * VOL_CAP_INT_USERACCESS: When set, the volume supports the + * ATTR_CMN_USERACCESS attribute (used to get the user's access + * mode to the file). + * + * VOL_CAP_INT_MANLOCK: When set, the volume supports AFP-style + * mandatory byte range locks via an ioctl(). + * + * VOL_CAP_INT_EXTENDED_ATTR: When set, the volume implements + * native extended attribues. + * + * VOL_CAP_INT_NAMEDSTREAMS: When set, the volume supports + * native named streams. + * + * VOL_CAP_INT_CLONE: When set, the volume supports clones. + * + * VOL_CAP_INT_SNAPSHOT: When set, the volume supports snapshots. + * + * VOL_CAP_INT_RENAME_SWAP: When set, the volume supports swapping + * file system objects. + * + * VOL_CAP_INT_RENAME_EXCL: When set, the volume supports an + * exclusive rename operation. + * + * VOL_CAP_INT_RENAME_OPENFAIL: When set, the volume may fail rename + * operations on files that are open. + */ +#define VOL_CAP_INT_SEARCHFS 0x00000001 +#define VOL_CAP_INT_ATTRLIST 0x00000002 +#define VOL_CAP_INT_NFSEXPORT 0x00000004 +#define VOL_CAP_INT_READDIRATTR 0x00000008 +#define VOL_CAP_INT_EXCHANGEDATA 0x00000010 +#define VOL_CAP_INT_COPYFILE 0x00000020 +#define VOL_CAP_INT_ALLOCATE 0x00000040 +#define VOL_CAP_INT_VOL_RENAME 0x00000080 +#define VOL_CAP_INT_ADVLOCK 0x00000100 +#define VOL_CAP_INT_FLOCK 0x00000200 +#define VOL_CAP_INT_EXTENDED_SECURITY 0x00000400 +#define VOL_CAP_INT_USERACCESS 0x00000800 +#define VOL_CAP_INT_MANLOCK 0x00001000 +#define VOL_CAP_INT_NAMEDSTREAMS 0x00002000 +#define VOL_CAP_INT_EXTENDED_ATTR 0x00004000 +#define VOL_CAP_INT_CLONE 0x00010000 +#define VOL_CAP_INT_SNAPSHOT 0x00020000 +#define VOL_CAP_INT_RENAME_SWAP 0x00040000 +#define VOL_CAP_INT_RENAME_EXCL 0x00080000 +#define VOL_CAP_INT_RENAME_OPENFAIL 0x00100000 + +typedef struct vol_attributes_attr { + attribute_set_t validattr; + attribute_set_t nativeattr; +} vol_attributes_attr_t; + +#define ATTR_CMN_NAME 0x00000001 +#define ATTR_CMN_DEVID 0x00000002 +#define ATTR_CMN_FSID 0x00000004 +#define ATTR_CMN_OBJTYPE 0x00000008 +#define ATTR_CMN_OBJTAG 0x00000010 +#define ATTR_CMN_OBJID 0x00000020 +#define ATTR_CMN_OBJPERMANENTID 0x00000040 +#define ATTR_CMN_PAROBJID 0x00000080 +#define ATTR_CMN_SCRIPT 0x00000100 +#define ATTR_CMN_CRTIME 0x00000200 +#define ATTR_CMN_MODTIME 0x00000400 +#define ATTR_CMN_CHGTIME 0x00000800 +#define ATTR_CMN_ACCTIME 0x00001000 +#define ATTR_CMN_BKUPTIME 0x00002000 +#define ATTR_CMN_FNDRINFO 0x00004000 +#define ATTR_CMN_OWNERID 0x00008000 +#define ATTR_CMN_GRPID 0x00010000 +#define ATTR_CMN_ACCESSMASK 0x00020000 +#define ATTR_CMN_FLAGS 0x00040000 + +/* The following were defined as: */ +/* #define ATTR_CMN_NAMEDATTRCOUNT 0x00080000 */ +/* #define ATTR_CMN_NAMEDATTRLIST 0x00100000 */ +/* These bits have been salvaged for use as: */ +/* #define ATTR_CMN_GEN_COUNT 0x00080000 */ +/* #define ATTR_CMN_DOCUMENT_ID 0x00100000 */ +/* They can only be used with the FSOPT_ATTR_CMN_EXTENDED */ +/* option flag. */ + +#define ATTR_CMN_GEN_COUNT 0x00080000 +#define ATTR_CMN_DOCUMENT_ID 0x00100000 + +#define ATTR_CMN_USERACCESS 0x00200000 +#define ATTR_CMN_EXTENDED_SECURITY 0x00400000 +#define ATTR_CMN_UUID 0x00800000 +#define ATTR_CMN_GRPUUID 0x01000000 +#define ATTR_CMN_FILEID 0x02000000 +#define ATTR_CMN_PARENTID 0x04000000 +#define ATTR_CMN_FULLPATH 0x08000000 +#define ATTR_CMN_ADDEDTIME 0x10000000 +#define ATTR_CMN_ERROR 0x20000000 +#define ATTR_CMN_DATA_PROTECT_FLAGS 0x40000000 + +/* + * ATTR_CMN_RETURNED_ATTRS is only valid with getattrlist(2) and + * getattrlistbulk(2). It is always the first attribute in the return buffer. + */ +#define ATTR_CMN_RETURNED_ATTRS 0x80000000 + +#define ATTR_CMN_VALIDMASK 0xFFFFFFFF +/* + * The settable ATTR_CMN_* attributes include the following: + * ATTR_CMN_SCRIPT + * ATTR_CMN_CRTIME + * ATTR_CMN_MODTIME + * ATTR_CMN_CHGTIME + * + * ATTR_CMN_ACCTIME + * ATTR_CMN_BKUPTIME + * ATTR_CMN_FNDRINFO + * ATTR_CMN_OWNERID + * + * ATTR_CMN_GRPID + * ATTR_CMN_ACCESSMASK + * ATTR_CMN_FLAGS + * + * ATTR_CMN_EXTENDED_SECURITY + * ATTR_CMN_UUID + * + * ATTR_CMN_GRPUUID + * + * ATTR_CMN_DATA_PROTECT_FLAGS + */ +#define ATTR_CMN_SETMASK 0x51C7FF00 +#define ATTR_CMN_VOLSETMASK 0x00006700 + +#define ATTR_VOL_FSTYPE 0x00000001 +#define ATTR_VOL_SIGNATURE 0x00000002 +#define ATTR_VOL_SIZE 0x00000004 +#define ATTR_VOL_SPACEFREE 0x00000008 +#define ATTR_VOL_SPACEAVAIL 0x00000010 +#define ATTR_VOL_MINALLOCATION 0x00000020 +#define ATTR_VOL_ALLOCATIONCLUMP 0x00000040 +#define ATTR_VOL_IOBLOCKSIZE 0x00000080 +#define ATTR_VOL_OBJCOUNT 0x00000100 +#define ATTR_VOL_FILECOUNT 0x00000200 +#define ATTR_VOL_DIRCOUNT 0x00000400 +#define ATTR_VOL_MAXOBJCOUNT 0x00000800 +#define ATTR_VOL_MOUNTPOINT 0x00001000 +#define ATTR_VOL_NAME 0x00002000 +#define ATTR_VOL_MOUNTFLAGS 0x00004000 +#define ATTR_VOL_MOUNTEDDEVICE 0x00008000 +#define ATTR_VOL_ENCODINGSUSED 0x00010000 +#define ATTR_VOL_CAPABILITIES 0x00020000 +#define ATTR_VOL_UUID 0x00040000 +#define ATTR_VOL_QUOTA_SIZE 0x10000000 +#define ATTR_VOL_RESERVED_SIZE 0x20000000 +#define ATTR_VOL_ATTRIBUTES 0x40000000 +#define ATTR_VOL_INFO 0x80000000 + +#define ATTR_VOL_VALIDMASK 0xF007FFFF + +/* + * The list of settable ATTR_VOL_* attributes include the following: + * ATTR_VOL_NAME + * ATTR_VOL_INFO + */ +#define ATTR_VOL_SETMASK 0x80002000 + + +/* File/directory attributes: */ +#define ATTR_DIR_LINKCOUNT 0x00000001 +#define ATTR_DIR_ENTRYCOUNT 0x00000002 +#define ATTR_DIR_MOUNTSTATUS 0x00000004 +#define ATTR_DIR_ALLOCSIZE 0x00000008 +#define ATTR_DIR_IOBLOCKSIZE 0x00000010 +#define ATTR_DIR_DATALENGTH 0x00000020 + +/* ATTR_DIR_MOUNTSTATUS Flags: */ +#define DIR_MNTSTATUS_MNTPOINT 0x00000001 +#define DIR_MNTSTATUS_TRIGGER 0x00000002 + +#define ATTR_DIR_VALIDMASK 0x0000003f +#define ATTR_DIR_SETMASK 0x00000000 + +#define ATTR_FILE_LINKCOUNT 0x00000001 +#define ATTR_FILE_TOTALSIZE 0x00000002 +#define ATTR_FILE_ALLOCSIZE 0x00000004 +#define ATTR_FILE_IOBLOCKSIZE 0x00000008 +#define ATTR_FILE_DEVTYPE 0x00000020 +#define ATTR_FILE_FORKCOUNT 0x00000080 +#define ATTR_FILE_FORKLIST 0x00000100 +#define ATTR_FILE_DATALENGTH 0x00000200 +#define ATTR_FILE_DATAALLOCSIZE 0x00000400 +#define ATTR_FILE_RSRCLENGTH 0x00001000 +#define ATTR_FILE_RSRCALLOCSIZE 0x00002000 + +#define ATTR_FILE_VALIDMASK 0x000037FF +/* + * Settable ATTR_FILE_* attributes include: + * ATTR_FILE_DEVTYPE + */ +#define ATTR_FILE_SETMASK 0x00000020 + +/* CMNEXT attributes extend the common attributes, but in the forkattr field */ +#define ATTR_CMNEXT_RELPATH 0x00000004 +#define ATTR_CMNEXT_PRIVATESIZE 0x00000008 +#define ATTR_CMNEXT_LINKID 0x00000010 +#define ATTR_CMNEXT_NOFIRMLINKPATH 0x00000020 +#define ATTR_CMNEXT_REALDEVID 0x00000040 +#define ATTR_CMNEXT_REALFSID 0x00000080 +#define ATTR_CMNEXT_CLONEID 0x00000100 +#define ATTR_CMNEXT_EXT_FLAGS 0x00000200 +#define ATTR_CMNEXT_RECURSIVE_GENCOUNT 0x00000400 + +#define ATTR_CMNEXT_VALIDMASK 0x000007fc +#define ATTR_CMNEXT_SETMASK 0x00000000 + +/* Deprecated fork attributes */ +#define ATTR_FORK_TOTALSIZE 0x00000001 +#define ATTR_FORK_ALLOCSIZE 0x00000002 +#define ATTR_FORK_RESERVED 0xffffffff + +#define ATTR_FORK_VALIDMASK 0x00000003 +#define ATTR_FORK_SETMASK 0x00000000 + +/* Obsolete, implemented, not supported */ +#define ATTR_CMN_NAMEDATTRCOUNT 0x00080000 +#define ATTR_CMN_NAMEDATTRLIST 0x00100000 +#define ATTR_FILE_CLUMPSIZE 0x00000010 /* obsolete */ +#define ATTR_FILE_FILETYPE 0x00000040 /* always zero */ +#define ATTR_FILE_DATAEXTENTS 0x00000800 /* obsolete, HFS-specific */ +#define ATTR_FILE_RSRCEXTENTS 0x00004000 /* obsolete, HFS-specific */ + +/* Required attributes for getattrlistbulk(2) */ +#define ATTR_BULK_REQUIRED (ATTR_CMN_NAME | ATTR_CMN_RETURNED_ATTRS) + +/* + * Searchfs + */ +#define SRCHFS_START 0x00000001 +#define SRCHFS_MATCHPARTIALNAMES 0x00000002 +#define SRCHFS_MATCHDIRS 0x00000004 +#define SRCHFS_MATCHFILES 0x00000008 +#define SRCHFS_SKIPLINKS 0x00000010 +#define SRCHFS_SKIPINVISIBLE 0x00000020 +#define SRCHFS_SKIPPACKAGES 0x00000040 +#define SRCHFS_SKIPINAPPROPRIATE 0x00000080 + +#define SRCHFS_NEGATEPARAMS 0x80000000 +#define SRCHFS_VALIDOPTIONSMASK 0x800000FF + +struct fssearchblock { + struct attrlist *returnattrs; + void *returnbuffer; + size_t returnbuffersize; + u_long maxmatches; + struct timeval timelimit; + void *searchparams1; + size_t sizeofsearchparams1; + void *searchparams2; + size_t sizeofsearchparams2; + struct attrlist searchattrs; +}; + + +struct searchstate { + uint32_t ss_union_flags; // for SRCHFS_START + uint32_t ss_union_layer; // 0 = top + u_char ss_fsstate[548]; // fs private +} __attribute__((packed)); + +#define FST_EOF (-1) /* end-of-file offset */ + +#endif /* __APPLE_API_UNSTABLE */ +#endif /* !_SYS_ATTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/cdefs.h b/lib/libc/include/aarch64-macos-gnu/sys/cdefs.h new file mode 100644 index 0000000000..e8145978d4 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/cdefs.h @@ -0,0 +1,876 @@ +/* + * Copyright (c) 2000-2018 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright 1995 NeXT Computer, Inc. All rights reserved. */ +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 + */ + +#ifndef _CDEFS_H_ +#define _CDEFS_H_ + +#if defined(__cplusplus) +#define __BEGIN_DECLS extern "C" { +#define __END_DECLS } +#else +#define __BEGIN_DECLS +#define __END_DECLS +#endif + +/* This SDK is designed to work with clang and specific versions of + * gcc >= 4.0 with Apple's patch sets */ +#if !defined(__GNUC__) || __GNUC__ < 4 +#warning "Unsupported compiler detected" +#endif + +/* + * Compatibility with compilers and environments that don't support compiler + * feature checking function-like macros. + */ +#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 + +/* + * The __CONCAT macro is used to concatenate parts of symbol names, e.g. + * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. + * The __CONCAT macro is a bit tricky -- make sure you don't put spaces + * in between its arguments. __CONCAT can also concatenate double-quoted + * strings produced by the __STRING macro, but this only works with ANSI C. + */ +#if defined(__STDC__) || defined(__cplusplus) +#define __P(protos) protos /* full-blown ANSI C */ +#define __CONCAT(x, y) x ## y +#define __STRING(x) #x + +#define __const const /* define reserved names to standard */ +#define __signed signed +#define __volatile volatile +#if defined(__cplusplus) +#define __inline inline /* convert to C++ keyword */ +#else +#ifndef __GNUC__ +#define __inline /* delete GCC keyword */ +#endif /* !__GNUC__ */ +#endif /* !__cplusplus */ + +#else /* !(__STDC__ || __cplusplus) */ +#define __P(protos) () /* traditional C preprocessor */ +#define __CONCAT(x, y) x /**/ y +#define __STRING(x) "x" + +#ifndef __GNUC__ +#define __const /* delete pseudo-ANSI C keywords */ +#define __inline +#define __signed +#define __volatile +#endif /* !__GNUC__ */ + +/* + * In non-ANSI C environments, new programs will want ANSI-only C keywords + * deleted from the program and old programs will want them left alone. + * When using a compiler other than gcc, programs using the ANSI C keywords + * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. + * When using "gcc -traditional", we assume that this is the intent; if + * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. + */ +#ifndef NO_ANSI_KEYWORDS +#define const __const /* convert ANSI C keywords */ +#define inline __inline +#define signed __signed +#define volatile __volatile +#endif /* !NO_ANSI_KEYWORDS */ +#endif /* !(__STDC__ || __cplusplus) */ + +#define __dead2 __attribute__((__noreturn__)) +#define __pure2 __attribute__((__const__)) + +/* __unused denotes variables and functions that may not be used, preventing + * the compiler from warning about it if not used. + */ +#define __unused __attribute__((__unused__)) + +/* __used forces variables and functions to be included even if it appears + * to the compiler that they are not used (and would thust be discarded). + */ +#define __used __attribute__((__used__)) + +/* __cold marks code used for debugging or that is rarely taken + * and tells the compiler to optimize for size and outline code. + */ +#if __has_attribute(cold) +#define __cold __attribute__((__cold__)) +#else +#define __cold +#endif + +/* __exported denotes symbols that should be exported even when symbols + * are hidden by default. + * __exported_push/_exported_pop are pragmas used to delimit a range of + * symbols that should be exported even when symbols are hidden by default. + */ +#define __exported __attribute__((__visibility__("default"))) +#define __exported_push _Pragma("GCC visibility push(default)") +#define __exported_pop _Pragma("GCC visibility pop") + +/* __deprecated causes the compiler to produce a warning when encountering + * code using the deprecated functionality. + * __deprecated_msg() does the same, and compilers that support it will print + * a message along with the deprecation warning. + * This may require turning on such warning with the -Wdeprecated flag. + * __deprecated_enum_msg() should be used on enums, and compilers that support + * it will print the deprecation warning. + * __kpi_deprecated() specifically indicates deprecation of kernel programming + * interfaces in Kernel.framework used by KEXTs. + */ +#define __deprecated __attribute__((__deprecated__)) + +#if __has_extension(attribute_deprecated_with_message) || \ + (defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)))) + #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg))) +#else + #define __deprecated_msg(_msg) __attribute__((__deprecated__)) +#endif + +#if __has_extension(enumerator_attributes) + #define __deprecated_enum_msg(_msg) __deprecated_msg(_msg) +#else + #define __deprecated_enum_msg(_msg) +#endif + +#define __kpi_deprecated(_msg) + +/* __unavailable causes the compiler to error out when encountering + * code using the tagged function + */ +#if __has_attribute(unavailable) +#define __unavailable __attribute__((__unavailable__)) +#else +#define __unavailable +#endif + +#define __kpi_unavailable + +#define __kpi_deprecated_arm64_macos_unavailable + +/* Delete pseudo-keywords wherever they are not available or needed. */ +#ifndef __dead +#define __dead +#define __pure +#endif + +/* + * We use `__restrict' as a way to define the `restrict' type qualifier + * without disturbing older software that is unaware of C99 keywords. + */ +#if __STDC_VERSION__ < 199901 +#define __restrict +#else +#define __restrict restrict +#endif + +/* Compatibility with compilers and environments that don't support the + * nullability feature. + */ + +#if !__has_feature(nullability) +#ifndef __nullable +#define __nullable +#endif +#ifndef __nonnull +#define __nonnull +#endif +#ifndef __null_unspecified +#define __null_unspecified +#endif +#ifndef _Nullable +#define _Nullable +#endif +#ifndef _Nonnull +#define _Nonnull +#endif +#ifndef _Null_unspecified +#define _Null_unspecified +#endif +#endif + +/* + * __disable_tail_calls causes the compiler to not perform tail call + * optimization inside the marked function. + */ +#if __has_attribute(disable_tail_calls) +#define __disable_tail_calls __attribute__((__disable_tail_calls__)) +#else +#define __disable_tail_calls +#endif + +/* + * __not_tail_called causes the compiler to prevent tail call optimization + * on statically bound calls to the function. It has no effect on indirect + * calls. Virtual functions, objective-c methods, and functions marked as + * "always_inline" cannot be marked as __not_tail_called. + */ +#if __has_attribute(not_tail_called) +#define __not_tail_called __attribute__((__not_tail_called__)) +#else +#define __not_tail_called +#endif + +/* + * __result_use_check warns callers of a function that not using the function + * return value is a bug, i.e. dismissing malloc() return value results in a + * memory leak. + */ +#if __has_attribute(warn_unused_result) +#define __result_use_check __attribute__((__warn_unused_result__)) +#else +#define __result_use_check +#endif + +/* + * __swift_unavailable causes the compiler to mark a symbol as specifically + * unavailable in Swift, regardless of any other availability in C. + */ +#if __has_feature(attribute_availability_swift) +#define __swift_unavailable(_msg) __attribute__((__availability__(swift, unavailable, message=_msg))) +#else +#define __swift_unavailable(_msg) +#endif + +/* + * __abortlike is the attribute to put on functions like abort() that are + * typically used to mark assertions. These optimize the codegen + * for outlining while still maintaining debugability. + */ +#ifndef __abortlike +#define __abortlike __dead2 __cold __not_tail_called +#endif + +/* Declaring inline functions within headers is error-prone due to differences + * across various versions of the C language and extensions. __header_inline + * can be used to declare inline functions within system headers. In cases + * where you want to force inlining instead of letting the compiler make + * the decision, you can use __header_always_inline. + * + * Be aware that using inline for functions which compilers may also provide + * builtins can behave differently under various compilers. If you intend to + * provide an inline version of such a function, you may want to use a macro + * instead. + * + * The check for !__GNUC__ || __clang__ is because gcc doesn't correctly + * support c99 inline in some cases: + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55965 + */ + +#if defined(__cplusplus) || \ + (__STDC_VERSION__ >= 199901L && \ + !defined(__GNUC_GNU_INLINE__) && \ + (!defined(__GNUC__) || defined(__clang__))) +# define __header_inline inline +#elif defined(__GNUC__) && defined(__GNUC_STDC_INLINE__) +# define __header_inline extern __inline __attribute__((__gnu_inline__)) +#elif defined(__GNUC__) +# define __header_inline extern __inline +#else +/* If we land here, we've encountered an unsupported compiler, + * so hopefully it understands static __inline as a fallback. + */ +# define __header_inline static __inline +#endif + +#ifdef __GNUC__ +# define __header_always_inline __header_inline __attribute__ ((__always_inline__)) +#else +/* Unfortunately, we're using a compiler that we don't know how to force to + * inline. Oh well. + */ +# define __header_always_inline __header_inline +#endif + +/* + * Compiler-dependent macros that bracket portions of code where the + * "-Wunreachable-code" warning should be ignored. Please use sparingly. + */ +#if defined(__clang__) +# define __unreachable_ok_push \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wunreachable-code\"") +# define __unreachable_ok_pop \ + _Pragma("clang diagnostic pop") +#elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +# define __unreachable_ok_push \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wunreachable-code\"") +# define __unreachable_ok_pop \ + _Pragma("GCC diagnostic pop") +#else +# define __unreachable_ok_push +# define __unreachable_ok_pop +#endif + +/* + * Compiler-dependent macros to declare that functions take printf-like + * or scanf-like arguments. They are null except for versions of gcc + * that are known to support the features properly. Functions declared + * with these attributes will cause compilation warnings if there is a + * mismatch between the format string and subsequent function parameter + * types. + */ +#define __printflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf__, fmtarg, firstvararg))) +#define __printf0like(fmtarg, firstvararg) \ + __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) +#define __scanflike(fmtarg, firstvararg) \ + __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) + +#define __IDSTRING(name, string) static const char name[] __used = string + +#ifndef __COPYRIGHT +#define __COPYRIGHT(s) __IDSTRING(copyright,s) +#endif + +#ifndef __RCSID +#define __RCSID(s) __IDSTRING(rcsid,s) +#endif + +#ifndef __SCCSID +#define __SCCSID(s) __IDSTRING(sccsid,s) +#endif + +#ifndef __PROJECT_VERSION +#define __PROJECT_VERSION(s) __IDSTRING(project_version,s) +#endif + +/* Source compatibility only, ID string not emitted in object file */ +#ifndef __FBSDID +#define __FBSDID(s) +#endif + +#ifndef __DECONST +#define __DECONST(type, var) __CAST_AWAY_QUALIFIER(var, const, type) +#endif + +#ifndef __DEVOLATILE +#define __DEVOLATILE(type, var) __CAST_AWAY_QUALIFIER(var, volatile, type) +#endif + +#ifndef __DEQUALIFY +#define __DEQUALIFY(type, var) __CAST_AWAY_QUALIFIER(var, const volatile, type) +#endif + +/* + * __alloc_size can be used to label function arguments that represent the + * size of memory that the function allocates and returns. The one-argument + * form labels a single argument that gives the allocation size (where the + * arguments are numbered from 1): + * + * void *malloc(size_t __size) __alloc_size(1); + * + * The two-argument form handles the case where the size is calculated as the + * product of two arguments: + * + * void *calloc(size_t __count, size_t __size) __alloc_size(1,2); + */ +#ifndef __alloc_size +#if __has_attribute(alloc_size) +#define __alloc_size(...) __attribute__((alloc_size(__VA_ARGS__))) +#else +#define __alloc_size(...) +#endif +#endif // __alloc_size + +/* + * COMPILATION ENVIRONMENTS -- see compat(5) for additional detail + * + * DEFAULT By default newly complied code will get POSIX APIs plus + * Apple API extensions in scope. + * + * Most users will use this compilation environment to avoid + * behavioral differences between 32 and 64 bit code. + * + * LEGACY Defining _NONSTD_SOURCE will get pre-POSIX APIs plus Apple + * API extensions in scope. + * + * This is generally equivalent to the Tiger release compilation + * environment, except that it cannot be applied to 64 bit code; + * its use is discouraged. + * + * We expect this environment to be deprecated in the future. + * + * STRICT Defining _POSIX_C_SOURCE or _XOPEN_SOURCE restricts the + * available APIs to exactly the set of APIs defined by the + * corresponding standard, based on the value defined. + * + * A correct, portable definition for _POSIX_C_SOURCE is 200112L. + * A correct, portable definition for _XOPEN_SOURCE is 600L. + * + * Apple API extensions are not visible in this environment, + * which can cause Apple specific code to fail to compile, + * or behave incorrectly if prototypes are not in scope or + * warnings about missing prototypes are not enabled or ignored. + * + * In any compilation environment, for correct symbol resolution to occur, + * function prototypes must be in scope. It is recommended that all Apple + * tools users add either the "-Wall" or "-Wimplicit-function-declaration" + * compiler flags to their projects to be warned when a function is being + * used without a prototype in scope. + */ + +/* These settings are particular to each product. */ +/* Platform: MacOSX */ +#if defined(__i386__) +#define __DARWIN_ONLY_64_BIT_INO_T 0 +#define __DARWIN_ONLY_UNIX_CONFORMANCE 0 +#define __DARWIN_ONLY_VERS_1050 0 +#elif defined(__x86_64__) +#define __DARWIN_ONLY_64_BIT_INO_T 0 +#define __DARWIN_ONLY_UNIX_CONFORMANCE 1 +#define __DARWIN_ONLY_VERS_1050 0 +#else +#define __DARWIN_ONLY_64_BIT_INO_T 1 +#define __DARWIN_ONLY_UNIX_CONFORMANCE 1 +#define __DARWIN_ONLY_VERS_1050 1 +#endif + +/* + * The __DARWIN_ALIAS macros are used to do symbol renaming; they allow + * legacy code to use the old symbol, thus maintaining binary compatibility + * while new code can use a standards compliant version of the same function. + * + * __DARWIN_ALIAS is used by itself if the function signature has not + * changed, it is used along with a #ifdef check for __DARWIN_UNIX03 + * if the signature has changed. Because the __LP64__ environment + * only supports UNIX03 semantics it causes __DARWIN_UNIX03 to be + * defined, but causes __DARWIN_ALIAS to do no symbol mangling. + * + * As a special case, when XCode is used to target a specific version of the + * OS, the manifest constant __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ + * will be defined by the compiler, with the digits representing major version + * time 100 + minor version times 10 (e.g. 10.5 := 1050). If we are targeting + * pre-10.5, and it is the default compilation environment, revert the + * compilation environment to pre-__DARWIN_UNIX03. + */ +#if !defined(__DARWIN_UNIX03) +# if __DARWIN_ONLY_UNIX_CONFORMANCE +# if defined(_NONSTD_SOURCE) +# error "Can't define _NONSTD_SOURCE when only UNIX conformance is available." +# endif /* _NONSTD_SOURCE */ +# define __DARWIN_UNIX03 1 +# elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0) < 1040) +# define __DARWIN_UNIX03 0 +# elif defined(_DARWIN_C_SOURCE) || defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE) +# if defined(_NONSTD_SOURCE) +# error "Can't define both _NONSTD_SOURCE and any of _DARWIN_C_SOURCE, _XOPEN_SOURCE or _POSIX_C_SOURCE." +# endif /* _NONSTD_SOURCE */ +# define __DARWIN_UNIX03 1 +# elif defined(_NONSTD_SOURCE) +# define __DARWIN_UNIX03 0 +# else /* default */ +# if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0) < 1050) +# define __DARWIN_UNIX03 0 +# else /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */ +# define __DARWIN_UNIX03 1 +# endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050 */ +# endif /* _DARWIN_C_SOURCE || _XOPEN_SOURCE || _POSIX_C_SOURCE || __LP64__ */ +#endif /* !__DARWIN_UNIX03 */ + +#if !defined(__DARWIN_64_BIT_INO_T) +# if defined(_DARWIN_USE_64_BIT_INODE) +# if defined(_DARWIN_NO_64_BIT_INODE) +# error "Can't define both _DARWIN_USE_64_BIT_INODE and _DARWIN_NO_64_BIT_INODE." +# endif /* _DARWIN_NO_64_BIT_INODE */ +# define __DARWIN_64_BIT_INO_T 1 +# elif defined(_DARWIN_NO_64_BIT_INODE) +# if __DARWIN_ONLY_64_BIT_INO_T +# error "Can't define _DARWIN_NO_64_BIT_INODE when only 64-bit inodes are available." +# endif /* __DARWIN_ONLY_64_BIT_INO_T */ +# define __DARWIN_64_BIT_INO_T 0 +# else /* default */ +# if __DARWIN_ONLY_64_BIT_INO_T +# define __DARWIN_64_BIT_INO_T 1 +# elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0) < 1060) || __DARWIN_UNIX03 == 0 +# define __DARWIN_64_BIT_INO_T 0 +# else /* default */ +# define __DARWIN_64_BIT_INO_T 1 +# endif /* __DARWIN_ONLY_64_BIT_INO_T */ +# endif +#endif /* !__DARWIN_64_BIT_INO_T */ + +#if !defined(__DARWIN_VERS_1050) +# if __DARWIN_ONLY_VERS_1050 +# define __DARWIN_VERS_1050 1 +# elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0) < 1050) || __DARWIN_UNIX03 == 0 +# define __DARWIN_VERS_1050 0 +# else /* default */ +# define __DARWIN_VERS_1050 1 +# endif +#endif /* !__DARWIN_VERS_1050 */ + +#if !defined(__DARWIN_NON_CANCELABLE) +# define __DARWIN_NON_CANCELABLE 0 +#endif /* !__DARWIN_NON_CANCELABLE */ + +/* + * symbol suffixes used for symbol versioning + */ +#if __DARWIN_UNIX03 +# if __DARWIN_ONLY_UNIX_CONFORMANCE +# define __DARWIN_SUF_UNIX03 /* nothing */ +# else /* !__DARWIN_ONLY_UNIX_CONFORMANCE */ +# define __DARWIN_SUF_UNIX03 "$UNIX2003" +# endif /* __DARWIN_ONLY_UNIX_CONFORMANCE */ + +# if __DARWIN_64_BIT_INO_T +# if __DARWIN_ONLY_64_BIT_INO_T +# define __DARWIN_SUF_64_BIT_INO_T /* nothing */ +# else /* !__DARWIN_ONLY_64_BIT_INO_T */ +# define __DARWIN_SUF_64_BIT_INO_T "$INODE64" +# endif /* __DARWIN_ONLY_64_BIT_INO_T */ +# else /* !__DARWIN_64_BIT_INO_T */ +# define __DARWIN_SUF_64_BIT_INO_T /* nothing */ +# endif /* __DARWIN_64_BIT_INO_T */ + +# if __DARWIN_VERS_1050 +# if __DARWIN_ONLY_VERS_1050 +# define __DARWIN_SUF_1050 /* nothing */ +# else /* !__DARWIN_ONLY_VERS_1050 */ +# define __DARWIN_SUF_1050 "$1050" +# endif /* __DARWIN_ONLY_VERS_1050 */ +# else /* !__DARWIN_VERS_1050 */ +# define __DARWIN_SUF_1050 /* nothing */ +# endif /* __DARWIN_VERS_1050 */ + +# if __DARWIN_NON_CANCELABLE +# define __DARWIN_SUF_NON_CANCELABLE "$NOCANCEL" +# else /* !__DARWIN_NON_CANCELABLE */ +# define __DARWIN_SUF_NON_CANCELABLE /* nothing */ +# endif /* __DARWIN_NON_CANCELABLE */ + +#else /* !__DARWIN_UNIX03 */ +# define __DARWIN_SUF_UNIX03 /* nothing */ +# define __DARWIN_SUF_64_BIT_INO_T /* nothing */ +# define __DARWIN_SUF_NON_CANCELABLE /* nothing */ +# define __DARWIN_SUF_1050 /* nothing */ +#endif /* __DARWIN_UNIX03 */ + +#define __DARWIN_SUF_EXTSN "$DARWIN_EXTSN" + +/* + * symbol versioning macros + */ +#define __DARWIN_ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_UNIX03) +#define __DARWIN_ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) +#define __DARWIN_ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03) +#define __DARWIN_NOCANCEL(sym) __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE) +#define __DARWIN_INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T) + +#define __DARWIN_1050(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050) +#define __DARWIN_1050ALIAS(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_UNIX03) +#define __DARWIN_1050ALIAS_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03) +#define __DARWIN_1050ALIAS_I(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03) +#define __DARWIN_1050INODE64(sym) __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T) + +#define __DARWIN_EXTSN(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN) +#define __DARWIN_EXTSN_C(sym) __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN __DARWIN_SUF_NON_CANCELABLE) + +/* + * symbol release macros + */ +#include + +#if defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) +#define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) __DARWIN_ALIAS_STARTING_IPHONE_##_iphone(x) +#elif defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) +#define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) __DARWIN_ALIAS_STARTING_MAC_##_mac(x) +#else +#define __DARWIN_ALIAS_STARTING(_mac, _iphone, x) x +#endif + + +/* + * POSIX.1 requires that the macros we test be defined before any standard + * header file is included. This permits us to convert values for feature + * testing, as necessary, using only _POSIX_C_SOURCE. + * + * Here's a quick run-down of the versions: + * defined(_POSIX_SOURCE) 1003.1-1988 + * _POSIX_C_SOURCE == 1L 1003.1-1990 + * _POSIX_C_SOURCE == 2L 1003.2-1992 C Language Binding Option + * _POSIX_C_SOURCE == 199309L 1003.1b-1993 + * _POSIX_C_SOURCE == 199506L 1003.1c-1995, 1003.1i-1995, + * and the omnibus ISO/IEC 9945-1: 1996 + * _POSIX_C_SOURCE == 200112L 1003.1-2001 + * _POSIX_C_SOURCE == 200809L 1003.1-2008 + * + * In addition, the X/Open Portability Guide, which is now the Single UNIX + * Specification, defines a feature-test macro which indicates the version of + * that specification, and which subsumes _POSIX_C_SOURCE. + */ + +/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1L. */ +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1L +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199009L +#endif + +/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2L. */ +#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2L +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199209L +#endif + +/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ +#ifdef _XOPEN_SOURCE +#if _XOPEN_SOURCE - 0L >= 700L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200809L) +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#elif _XOPEN_SOURCE - 0L >= 600L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200112L) +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200112L +#elif _XOPEN_SOURCE - 0L >= 500L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 199506L) +#undef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 199506L +#endif +#endif + +/* + * Deal with all versions of POSIX. The ordering relative to the tests above is + * important. + */ +#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 198808L +#endif + +/* POSIX C deprecation macros */ +#include + +#define __POSIX_C_DEPRECATED(ver) ___POSIX_C_DEPRECATED_STARTING_##ver + +/* + * Set a single macro which will always be defined and can be used to determine + * the appropriate namespace. For POSIX, these values will correspond to + * _POSIX_C_SOURCE value. Currently there are two additional levels corresponding + * to ANSI (_ANSI_SOURCE) and Darwin extensions (_DARWIN_C_SOURCE) + */ +#define __DARWIN_C_ANSI 010000L +#define __DARWIN_C_FULL 900000L + +#if defined(_ANSI_SOURCE) +#define __DARWIN_C_LEVEL __DARWIN_C_ANSI +#elif defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE) && !defined(_NONSTD_SOURCE) +#define __DARWIN_C_LEVEL _POSIX_C_SOURCE +#else +#define __DARWIN_C_LEVEL __DARWIN_C_FULL +#endif + +/* If the developer has neither requested a strict language mode nor a version + * of POSIX, turn on functionality provided by __STDC_WANT_LIB_EXT1__ as part + * of __DARWIN_C_FULL. + */ +#if !defined(__STDC_WANT_LIB_EXT1__) && !defined(__STRICT_ANSI__) && __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#define __STDC_WANT_LIB_EXT1__ 1 +#endif + +/* + * long long is not supported in c89 (__STRICT_ANSI__), but g++ -ansi and + * c99 still want long longs. While not perfect, we allow long longs for + * g++. + */ +#if (defined(__STRICT_ANSI__) && (__STDC_VERSION__ - 0 < 199901L) && !defined(__GNUG__)) +#define __DARWIN_NO_LONG_LONG 1 +#else +#define __DARWIN_NO_LONG_LONG 0 +#endif + +/***************************************** +* Public darwin-specific feature macros +*****************************************/ + +/* + * _DARWIN_FEATURE_64_BIT_INODE indicates that the ino_t type is 64-bit, and + * structures modified for 64-bit inodes (like struct stat) will be used. + */ +#if __DARWIN_64_BIT_INO_T +#define _DARWIN_FEATURE_64_BIT_INODE 1 +#endif + +/* + * _DARWIN_FEATURE_64_ONLY_BIT_INODE indicates that the ino_t type may only + * be 64-bit; there is no support for 32-bit ino_t when this macro is defined + * (and non-zero). There is no struct stat64 either, as the regular + * struct stat will already be the 64-bit version. + */ +#if __DARWIN_ONLY_64_BIT_INO_T +#define _DARWIN_FEATURE_ONLY_64_BIT_INODE 1 +#endif + +/* + * _DARWIN_FEATURE_ONLY_VERS_1050 indicates that only those APIs updated + * in 10.5 exists; no pre-10.5 variants are available. + */ +#if __DARWIN_ONLY_VERS_1050 +#define _DARWIN_FEATURE_ONLY_VERS_1050 1 +#endif + +/* + * _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE indicates only UNIX conforming API + * are available (the legacy BSD APIs are not available) + */ +#if __DARWIN_ONLY_UNIX_CONFORMANCE +#define _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE 1 +#endif + +/* + * _DARWIN_FEATURE_UNIX_CONFORMANCE indicates whether UNIX conformance is on, + * and specifies the conformance level (3 is SUSv3) + */ +#if __DARWIN_UNIX03 +#define _DARWIN_FEATURE_UNIX_CONFORMANCE 3 +#endif + + +/* + * This macro casts away the qualifier from the variable + * + * Note: use at your own risk, removing qualifiers can result in + * catastrophic run-time failures. + */ +#ifndef __CAST_AWAY_QUALIFIER +#define __CAST_AWAY_QUALIFIER(variable, qualifier, type) (type) (long)(variable) +#endif + +/* + * __XNU_PRIVATE_EXTERN is a linkage decoration indicating that a symbol can be + * used from other compilation units, but not other libraries or executables. + */ +#ifndef __XNU_PRIVATE_EXTERN +#define __XNU_PRIVATE_EXTERN __attribute__((visibility("hidden"))) +#endif + +/* + * Architecture validation for current SDK + */ +#if !defined(__sys_cdefs_arch_unknown__) && defined(__i386__) +#elif !defined(__sys_cdefs_arch_unknown__) && defined(__x86_64__) +#elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm__) +#elif !defined(__sys_cdefs_arch_unknown__) && defined(__arm64__) +#else +#error Unsupported architecture +#endif + + + +#define __compiler_barrier() __asm__ __volatile__("" ::: "memory") + +#if __has_attribute(enum_extensibility) +#define __enum_open __attribute__((__enum_extensibility__(open))) +#define __enum_closed __attribute__((__enum_extensibility__(closed))) +#else +#define __enum_open +#define __enum_closed +#endif // __has_attribute(enum_extensibility) + +#if __has_attribute(flag_enum) +#define __enum_options __attribute__((__flag_enum__)) +#else +#define __enum_options +#endif + +/* + * Similar to OS_ENUM/OS_CLOSED_ENUM/OS_OPTIONS/OS_CLOSED_OPTIONS + * + * This provides more advanced type checking on compilers supporting + * the proper extensions, even in C. + */ +#if __has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum) || \ + __has_extension(cxx_strong_enums) +#define __enum_decl(_name, _type, ...) \ + typedef enum : _type __VA_ARGS__ __enum_open _name +#define __enum_closed_decl(_name, _type, ...) \ + typedef enum : _type __VA_ARGS__ __enum_closed _name +#define __options_decl(_name, _type, ...) \ + typedef enum : _type __VA_ARGS__ __enum_open __enum_options _name +#define __options_closed_decl(_name, _type, ...) \ + typedef enum : _type __VA_ARGS__ __enum_closed __enum_options _name +#else +#define __enum_decl(_name, _type, ...) \ + typedef _type _name; enum __VA_ARGS__ __enum_open +#define __enum_closed_decl(_name, _type, ...) \ + typedef _type _name; enum __VA_ARGS__ __enum_closed +#define __options_decl(_name, _type, ...) \ + typedef _type _name; enum __VA_ARGS__ __enum_open __enum_options +#define __options_closed_decl(_name, _type, ...) \ + typedef _type _name; enum __VA_ARGS__ __enum_closed __enum_options +#endif + +#endif /* !_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/event.h b/lib/libc/include/aarch64-macos-gnu/sys/event.h new file mode 100644 index 0000000000..b03d37f867 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/event.h @@ -0,0 +1,396 @@ +/* + * Copyright (c) 2003-2019 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/*- + * Copyright (c) 1999,2000,2001 Jonathan Lemon + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/sys/event.h,v 1.5.2.5 2001/12/14 19:21:22 jlemon Exp $ + */ + +#ifndef _SYS_EVENT_H_ +#define _SYS_EVENT_H_ + +#include +#include +#include + +/* + * Filter types + */ +#define EVFILT_READ (-1) +#define EVFILT_WRITE (-2) +#define EVFILT_AIO (-3) /* attached to aio requests */ +#define EVFILT_VNODE (-4) /* attached to vnodes */ +#define EVFILT_PROC (-5) /* attached to struct proc */ +#define EVFILT_SIGNAL (-6) /* attached to struct proc */ +#define EVFILT_TIMER (-7) /* timers */ +#define EVFILT_MACHPORT (-8) /* Mach portsets */ +#define EVFILT_FS (-9) /* Filesystem events */ +#define EVFILT_USER (-10) /* User events */ +#define EVFILT_VM (-12) /* Virtual memory events */ +#define EVFILT_EXCEPT (-15) /* Exception events */ + +#define EVFILT_SYSCOUNT 17 +#define EVFILT_THREADMARKER EVFILT_SYSCOUNT /* Internal use only */ + +#pragma pack(4) + +struct kevent { + uintptr_t ident; /* identifier for this event */ + int16_t filter; /* filter for event */ + uint16_t flags; /* general flags */ + uint32_t fflags; /* filter-specific flags */ + intptr_t data; /* filter-specific data */ + void *udata; /* opaque user data identifier */ +}; + + +#pragma pack() + +struct kevent64_s { + uint64_t ident; /* identifier for this event */ + int16_t filter; /* filter for event */ + uint16_t flags; /* general flags */ + uint32_t fflags; /* filter-specific flags */ + int64_t data; /* filter-specific data */ + uint64_t udata; /* opaque user data identifier */ + uint64_t ext[2]; /* filter-specific extensions */ +}; + + +#define EV_SET(kevp, a, b, c, d, e, f) do { \ + struct kevent *__kevp__ = (kevp); \ + __kevp__->ident = (a); \ + __kevp__->filter = (b); \ + __kevp__->flags = (c); \ + __kevp__->fflags = (d); \ + __kevp__->data = (e); \ + __kevp__->udata = (f); \ +} while(0) + +#define EV_SET64(kevp, a, b, c, d, e, f, g, h) do { \ + struct kevent64_s *__kevp__ = (kevp); \ + __kevp__->ident = (a); \ + __kevp__->filter = (b); \ + __kevp__->flags = (c); \ + __kevp__->fflags = (d); \ + __kevp__->data = (e); \ + __kevp__->udata = (f); \ + __kevp__->ext[0] = (g); \ + __kevp__->ext[1] = (h); \ +} while(0) + + +/* kevent system call flags */ +#define KEVENT_FLAG_NONE 0x000000 /* no flag value */ +#define KEVENT_FLAG_IMMEDIATE 0x000001 /* immediate timeout */ +#define KEVENT_FLAG_ERROR_EVENTS 0x000002 /* output events only include change errors */ + + +/* actions */ +#define EV_ADD 0x0001 /* add event to kq (implies enable) */ +#define EV_DELETE 0x0002 /* delete event from kq */ +#define EV_ENABLE 0x0004 /* enable event */ +#define EV_DISABLE 0x0008 /* disable event (not reported) */ + +/* flags */ +#define EV_ONESHOT 0x0010 /* only report one occurrence */ +#define EV_CLEAR 0x0020 /* clear event state after reporting */ +#define EV_RECEIPT 0x0040 /* force immediate event output */ + /* ... with or without EV_ERROR */ + /* ... use KEVENT_FLAG_ERROR_EVENTS */ + /* on syscalls supporting flags */ + +#define EV_DISPATCH 0x0080 /* disable event after reporting */ +#define EV_UDATA_SPECIFIC 0x0100 /* unique kevent per udata value */ + +#define EV_DISPATCH2 (EV_DISPATCH | EV_UDATA_SPECIFIC) +/* ... in combination with EV_DELETE */ +/* will defer delete until udata-specific */ +/* event enabled. EINPROGRESS will be */ +/* returned to indicate the deferral */ + +#define EV_VANISHED 0x0200 /* report that source has vanished */ + /* ... only valid with EV_DISPATCH2 */ + +#define EV_SYSFLAGS 0xF000 /* reserved by system */ +#define EV_FLAG0 0x1000 /* filter-specific flag */ +#define EV_FLAG1 0x2000 /* filter-specific flag */ + +/* returned values */ +#define EV_EOF 0x8000 /* EOF detected */ +#define EV_ERROR 0x4000 /* error, data contains errno */ + +/* + * Filter specific flags for EVFILT_READ + * + * The default behavior for EVFILT_READ is to make the "read" determination + * relative to the current file descriptor read pointer. + * + * The EV_POLL flag indicates the determination should be made via poll(2) + * semantics. These semantics dictate always returning true for regular files, + * regardless of the amount of unread data in the file. + * + * On input, EV_OOBAND specifies that filter should actively return in the + * presence of OOB on the descriptor. It implies that filter will return + * if there is OOB data available to read OR when any other condition + * for the read are met (for example number of bytes regular data becomes >= + * low-watermark). + * If EV_OOBAND is not set on input, it implies that the filter should not actively + * return for out of band data on the descriptor. The filter will then only return + * when some other condition for read is met (ex: when number of regular data bytes + * >=low-watermark OR when socket can't receive more data (SS_CANTRCVMORE)). + * + * On output, EV_OOBAND indicates the presence of OOB data on the descriptor. + * If it was not specified as an input parameter, then the data count is the + * number of bytes before the current OOB marker, else data count is the number + * of bytes beyond OOB marker. + */ +#define EV_POLL EV_FLAG0 +#define EV_OOBAND EV_FLAG1 + +/* + * data/hint fflags for EVFILT_USER, shared with userspace + */ + +/* + * On input, NOTE_TRIGGER causes the event to be triggered for output. + */ +#define NOTE_TRIGGER 0x01000000 + +/* + * On input, the top two bits of fflags specifies how the lower twenty four + * bits should be applied to the stored value of fflags. + * + * On output, the top two bits will always be set to NOTE_FFNOP and the + * remaining twenty four bits will contain the stored fflags value. + */ +#define NOTE_FFNOP 0x00000000 /* ignore input fflags */ +#define NOTE_FFAND 0x40000000 /* and fflags */ +#define NOTE_FFOR 0x80000000 /* or fflags */ +#define NOTE_FFCOPY 0xc0000000 /* copy fflags */ +#define NOTE_FFCTRLMASK 0xc0000000 /* mask for operations */ +#define NOTE_FFLAGSMASK 0x00ffffff + + +/* + * data/hint fflags for EVFILT_{READ|WRITE}, shared with userspace + * + * The default behavior for EVFILT_READ is to make the determination + * realtive to the current file descriptor read pointer. + */ +#define NOTE_LOWAT 0x00000001 /* low water mark */ + +/* data/hint flags for EVFILT_EXCEPT, shared with userspace */ +#define NOTE_OOB 0x00000002 /* OOB data */ + +/* + * data/hint fflags for EVFILT_VNODE, shared with userspace + */ +#define NOTE_DELETE 0x00000001 /* vnode was removed */ +#define NOTE_WRITE 0x00000002 /* data contents changed */ +#define NOTE_EXTEND 0x00000004 /* size increased */ +#define NOTE_ATTRIB 0x00000008 /* attributes changed */ +#define NOTE_LINK 0x00000010 /* link count changed */ +#define NOTE_RENAME 0x00000020 /* vnode was renamed */ +#define NOTE_REVOKE 0x00000040 /* vnode access was revoked */ +#define NOTE_NONE 0x00000080 /* No specific vnode event: to test for EVFILT_READ activation*/ +#define NOTE_FUNLOCK 0x00000100 /* vnode was unlocked by flock(2) */ + +/* + * data/hint fflags for EVFILT_PROC, shared with userspace + * + * Please note that EVFILT_PROC and EVFILT_SIGNAL share the same knote list + * that hangs off the proc structure. They also both play games with the hint + * passed to KNOTE(). If NOTE_SIGNAL is passed as a hint, then the lower bits + * of the hint contain the signal. IF NOTE_FORK is passed, then the lower bits + * contain the PID of the child (but the pid does not get passed through in + * the actual kevent). + */ +enum { + eNoteReapDeprecated __deprecated_enum_msg("This kqueue(2) EVFILT_PROC flag is deprecated") = 0x10000000 +}; + +#define NOTE_EXIT 0x80000000 /* process exited */ +#define NOTE_FORK 0x40000000 /* process forked */ +#define NOTE_EXEC 0x20000000 /* process exec'd */ +#define NOTE_REAP ((unsigned int)eNoteReapDeprecated /* 0x10000000 */ ) /* process reaped */ +#define NOTE_SIGNAL 0x08000000 /* shared with EVFILT_SIGNAL */ +#define NOTE_EXITSTATUS 0x04000000 /* exit status to be returned, valid for child process or when allowed to signal target pid */ +#define NOTE_EXIT_DETAIL 0x02000000 /* provide details on reasons for exit */ + +#define NOTE_PDATAMASK 0x000fffff /* mask for signal & exit status */ +#define NOTE_PCTRLMASK (~NOTE_PDATAMASK) + +/* + * If NOTE_EXITSTATUS is present, provide additional info about exiting process. + */ +enum { + eNoteExitReparentedDeprecated __deprecated_enum_msg("This kqueue(2) EVFILT_PROC flag is no longer sent") = 0x00080000 +}; +#define NOTE_EXIT_REPARENTED ((unsigned int)eNoteExitReparentedDeprecated) /* exited while reparented */ + +/* + * If NOTE_EXIT_DETAIL is present, these bits indicate specific reasons for exiting. + */ +#define NOTE_EXIT_DETAIL_MASK 0x00070000 +#define NOTE_EXIT_DECRYPTFAIL 0x00010000 +#define NOTE_EXIT_MEMORY 0x00020000 +#define NOTE_EXIT_CSERROR 0x00040000 + + +/* + * data/hint fflags for EVFILT_VM, shared with userspace. + */ +#define NOTE_VM_PRESSURE 0x80000000 /* will react on memory pressure */ +#define NOTE_VM_PRESSURE_TERMINATE 0x40000000 /* will quit on memory pressure, possibly after cleaning up dirty state */ +#define NOTE_VM_PRESSURE_SUDDEN_TERMINATE 0x20000000 /* will quit immediately on memory pressure */ +#define NOTE_VM_ERROR 0x10000000 /* there was an error */ + + +/* + * data/hint fflags for EVFILT_TIMER, shared with userspace. + * The default is a (repeating) interval timer with the data + * specifying the timeout interval in milliseconds. + * + * All timeouts are implicitly EV_CLEAR events. + */ +#define NOTE_SECONDS 0x00000001 /* data is seconds */ +#define NOTE_USECONDS 0x00000002 /* data is microseconds */ +#define NOTE_NSECONDS 0x00000004 /* data is nanoseconds */ +#define NOTE_ABSOLUTE 0x00000008 /* absolute timeout */ +/* ... implicit EV_ONESHOT, timeout uses the gettimeofday epoch */ +#define NOTE_LEEWAY 0x00000010 /* ext[1] holds leeway for power aware timers */ +#define NOTE_CRITICAL 0x00000020 /* system does minimal timer coalescing */ +#define NOTE_BACKGROUND 0x00000040 /* system does maximum timer coalescing */ +#define NOTE_MACH_CONTINUOUS_TIME 0x00000080 +/* + * NOTE_MACH_CONTINUOUS_TIME: + * with NOTE_ABSOLUTE: causes the timer to continue to tick across sleep, + * still uses gettimeofday epoch + * with NOTE_MACHTIME and NOTE_ABSOLUTE: uses mach continuous time epoch + * without NOTE_ABSOLUTE (interval timer mode): continues to tick across sleep + */ +#define NOTE_MACHTIME 0x00000100 /* data is mach absolute time units */ +/* timeout uses the mach absolute time epoch */ + + +/* + * data/hint fflags for EVFILT_MACHPORT, shared with userspace. + * + * Only portsets are supported at this time. + * + * The fflags field can optionally contain the MACH_RCV_MSG, MACH_RCV_LARGE, + * and related trailer receive options as defined in . + * The presence of these flags directs the kevent64() call to attempt to receive + * the message during kevent delivery, rather than just indicate that a message exists. + * On setup, The ext[0] field contains the receive buffer pointer and ext[1] contains + * the receive buffer length. Upon event delivery, the actual received message size + * is returned in ext[1]. As with mach_msg(), the buffer must be large enough to + * receive the message and the requested (or default) message trailers. In addition, + * the fflags field contains the return code normally returned by mach_msg(). + * + * If MACH_RCV_MSG is specified, and the ext[1] field specifies a zero length, the + * system call argument specifying an ouput area (kevent_qos) will be consulted. If + * the system call specified an output data area, the user-space address + * of the received message is carved from that provided output data area (if enough + * space remains there). The address and length of each received message is + * returned in the ext[0] and ext[1] fields (respectively) of the corresponding kevent. + * + * IF_MACH_RCV_VOUCHER_CONTENT is specified, the contents of the message voucher is + * extracted (as specified in the xflags field) and stored in ext[2] up to ext[3] + * length. If the input length is zero, and the system call provided a data area, + * the space for the voucher content is carved from the provided space and its + * address and length is returned in ext[2] and ext[3] respectively. + * + * If no message receipt options were provided in the fflags field on setup, no + * message is received by this call. Instead, on output, the data field simply + * contains the name of the actual port detected with a message waiting. + */ + +/* + * DEPRECATED!!!!!!!!! + * NOTE_TRACK, NOTE_TRACKERR, and NOTE_CHILD are no longer supported as of 10.5 + */ +/* additional flags for EVFILT_PROC */ +#define NOTE_TRACK 0x00000001 /* follow across forks */ +#define NOTE_TRACKERR 0x00000002 /* could not track child */ +#define NOTE_CHILD 0x00000004 /* am a child process */ + + + +/* Temporay solution for BootX to use inode.h till kqueue moves to vfs layer */ +#include +struct knote; +SLIST_HEAD(klist, knote); + + +#include + +struct timespec; + +__BEGIN_DECLS +int kqueue(void); +int kevent(int kq, + const struct kevent *changelist, int nchanges, + struct kevent *eventlist, int nevents, + const struct timespec *timeout); +int kevent64(int kq, + const struct kevent64_s *changelist, int nchanges, + struct kevent64_s *eventlist, int nevents, + unsigned int flags, + const struct timespec *timeout); + + +__END_DECLS + + + + +#endif /* !_SYS_EVENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/fcntl.h b/lib/libc/include/aarch64-macos-gnu/sys/fcntl.h new file mode 100644 index 0000000000..8f13a01f90 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/fcntl.h @@ -0,0 +1,581 @@ +/* + * Copyright (c) 2000-2013 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/*- + * Copyright (c) 1983, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)fcntl.h 8.3 (Berkeley) 1/21/94 + */ + + +#ifndef _SYS_FCNTL_H_ +#define _SYS_FCNTL_H_ + +/* + * This file includes the definitions for open and fcntl + * described by POSIX for ; it also includes + * related kernel definitions. + */ +#include +#include +#include + +/* We should not be exporting size_t here. Temporary for gcc bootstrapping. */ +#include +#include +#include +#include + +/* + * File status flags: these are used by open(2), fcntl(2). + * They are also used (indirectly) in the kernel file structure f_flags, + * which is a superset of the open/fcntl flags. Open flags and f_flags + * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags). + * Open/fcntl flags begin with O_; kernel-internal flags begin with F. + */ +/* open-only flags */ +#define O_RDONLY 0x0000 /* open for reading only */ +#define O_WRONLY 0x0001 /* open for writing only */ +#define O_RDWR 0x0002 /* open for reading and writing */ +#define O_ACCMODE 0x0003 /* mask for above modes */ + +/* + * Kernel encoding of open mode; separate read and write bits that are + * independently testable: 1 greater than the above. + * + * XXX + * FREAD and FWRITE are excluded from the #ifdef KERNEL so that TIOCFLUSH, + * which was documented to use FREAD/FWRITE, continues to work. + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define FREAD 0x00000001 +#define FWRITE 0x00000002 +#endif +#define O_NONBLOCK 0x00000004 /* no delay */ +#define O_APPEND 0x00000008 /* set append mode */ + +#include + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define O_SHLOCK 0x00000010 /* open with shared file lock */ +#define O_EXLOCK 0x00000020 /* open with exclusive file lock */ +#define O_ASYNC 0x00000040 /* signal pgrp when data ready */ +#define O_FSYNC O_SYNC /* source compatibility: do not use */ +#define O_NOFOLLOW 0x00000100 /* don't follow symlinks */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#define O_CREAT 0x00000200 /* create if nonexistant */ +#define O_TRUNC 0x00000400 /* truncate to zero length */ +#define O_EXCL 0x00000800 /* error if already exists */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define O_EVTONLY 0x00008000 /* descriptor requested for event notifications only */ +#endif + + +#define O_NOCTTY 0x00020000 /* don't assign controlling terminal */ + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define O_DIRECTORY 0x00100000 +#define O_SYMLINK 0x00200000 /* allow open of a symlink */ +#endif + +// O_DSYNC 0x00400000 /* synch I/O data integrity */ +#include + + +#if __DARWIN_C_LEVEL >= 200809L +#define O_CLOEXEC 0x01000000 /* implicitly set FD_CLOEXEC */ +#endif + + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#define O_NOFOLLOW_ANY 0x20000000 /* no symlinks allowed in path */ +#endif + + +#if __DARWIN_C_LEVEL >= 200809L +/* + * Descriptor value for the current working directory + */ +#define AT_FDCWD -2 + +/* + * Flags for the at functions + */ +#define AT_EACCESS 0x0010 /* Use effective ids in access check */ +#define AT_SYMLINK_NOFOLLOW 0x0020 /* Act on the symlink itself not the target */ +#define AT_SYMLINK_FOLLOW 0x0040 /* Act on target of symlink */ +#define AT_REMOVEDIR 0x0080 /* Path refers to directory */ +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#define AT_REALDEV 0x0200 /* Return real device inodes resides on for fstatat(2) */ +#define AT_FDONLY 0x0400 /* Use only the fd and Ignore the path for fstatat(2) */ +#endif +#endif + +/* Data Protection Flags */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define O_DP_GETRAWENCRYPTED 0x0001 +#define O_DP_GETRAWUNENCRYPTED 0x0002 +#endif + + + +/* + * The O_* flags used to have only F* names, which were used in the kernel + * and by fcntl. We retain the F* names for the kernel f_flags field + * and for backward compatibility for fcntl. + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define FAPPEND O_APPEND /* kernel/compat */ +#define FASYNC O_ASYNC /* kernel/compat */ +#define FFSYNC O_FSYNC /* kernel */ +#define FFDSYNC O_DSYNC /* kernel */ +#define FNONBLOCK O_NONBLOCK /* kernel */ +#define FNDELAY O_NONBLOCK /* compat */ +#define O_NDELAY O_NONBLOCK /* compat */ +#endif + +/* + * Flags used for copyfile(2) + */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define CPF_OVERWRITE 0x0001 +#define CPF_IGNORE_MODE 0x0002 +#define CPF_MASK (CPF_OVERWRITE|CPF_IGNORE_MODE) +#endif + +/* + * Constants used for fcntl(2) + */ + +/* command values */ +#define F_DUPFD 0 /* duplicate file descriptor */ +#define F_GETFD 1 /* get file descriptor flags */ +#define F_SETFD 2 /* set file descriptor flags */ +#define F_GETFL 3 /* get file status flags */ +#define F_SETFL 4 /* set file status flags */ +#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */ +#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */ +#define F_GETLK 7 /* get record locking information */ +#define F_SETLK 8 /* set record locking information */ +#define F_SETLKW 9 /* F_SETLK; wait if blocked */ +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#define F_SETLKWTIMEOUT 10 /* F_SETLK; wait if blocked, return on timeout */ +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define F_FLUSH_DATA 40 +#define F_CHKCLEAN 41 /* Used for regression test */ +#define F_PREALLOCATE 42 /* Preallocate storage */ +#define F_SETSIZE 43 /* Truncate a file. Equivalent to calling truncate(2) */ +#define F_RDADVISE 44 /* Issue an advisory read async with no copy to user */ +#define F_RDAHEAD 45 /* turn read ahead off/on for this fd */ +/* + * 46,47 used to be F_READBOOTSTRAP and F_WRITEBOOTSTRAP + */ +#define F_NOCACHE 48 /* turn data caching off/on for this fd */ +#define F_LOG2PHYS 49 /* file offset to device offset */ +#define F_GETPATH 50 /* return the full path of the fd */ +#define F_FULLFSYNC 51 /* fsync + ask the drive to flush to the media */ +#define F_PATHPKG_CHECK 52 /* find which component (if any) is a package */ +#define F_FREEZE_FS 53 /* "freeze" all fs operations */ +#define F_THAW_FS 54 /* "thaw" all fs operations */ +#define F_GLOBAL_NOCACHE 55 /* turn data caching off/on (globally) for this file */ + + +#define F_ADDSIGS 59 /* add detached signatures */ + + +#define F_ADDFILESIGS 61 /* add signature from same file (used by dyld for shared libs) */ + +#define F_NODIRECT 62 /* used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes */ + /* should not be used (i.e. its ok to temporaily create cached pages) */ + +#define F_GETPROTECTIONCLASS 63 /* Get the protection class of a file from the EA, returns int */ +#define F_SETPROTECTIONCLASS 64 /* Set the protection class of a file for the EA, requires int */ + +#define F_LOG2PHYS_EXT 65 /* file offset to device offset, extended */ + +#define F_GETLKPID 66 /* get record locking information, per-process */ + +/* See F_DUPFD_CLOEXEC below for 67 */ + + +#define F_SETBACKINGSTORE 70 /* Mark the file as being the backing store for another filesystem */ +#define F_GETPATH_MTMINFO 71 /* return the full path of the FD, but error in specific mtmd circumstances */ + +#define F_GETCODEDIR 72 /* Returns the code directory, with associated hashes, to the caller */ + +#define F_SETNOSIGPIPE 73 /* No SIGPIPE generated on EPIPE */ +#define F_GETNOSIGPIPE 74 /* Status of SIGPIPE for this fd */ + +#define F_TRANSCODEKEY 75 /* For some cases, we need to rewrap the key for AKS/MKB */ + +#define F_SINGLE_WRITER 76 /* file being written to a by single writer... if throttling enabled, writes */ + /* may be broken into smaller chunks with throttling in between */ + +#define F_GETPROTECTIONLEVEL 77 /* Get the protection version number for this filesystem */ + +#define F_FINDSIGS 78 /* Add detached code signatures (used by dyld for shared libs) */ + + +#define F_ADDFILESIGS_FOR_DYLD_SIM 83 /* Add signature from same file, only if it is signed by Apple (used by dyld for simulator) */ + + +#define F_BARRIERFSYNC 85 /* fsync + issue barrier to drive */ + + +#define F_ADDFILESIGS_RETURN 97 /* Add signature from same file, return end offset in structure on success */ +#define F_CHECK_LV 98 /* Check if Library Validation allows this Mach-O file to be mapped into the calling process */ + +#define F_PUNCHHOLE 99 /* Deallocate a range of the file */ + +#define F_TRIM_ACTIVE_FILE 100 /* Trim an active file */ + +#define F_SPECULATIVE_READ 101 /* Synchronous advisory read fcntl for regular and compressed file */ + +#define F_GETPATH_NOFIRMLINK 102 /* return the full path without firmlinks of the fd */ + +#define F_ADDFILESIGS_INFO 103 /* Add signature from same file, return information */ +#define F_ADDFILESUPPL 104 /* Add supplemental signature from same file with fd reference to original */ +#define F_GETSIGSINFO 105 /* Look up code signature information attached to a file or slice */ + +// FS-specific fcntl()'s numbers begin at 0x00010000 and go up +#define FCNTL_FS_SPECIFIC_BASE 0x00010000 + +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +#if __DARWIN_C_LEVEL >= 200809L +#define F_DUPFD_CLOEXEC 67 /* mark the dup with FD_CLOEXEC */ +#endif + +/* file descriptor flags (F_GETFD, F_SETFD) */ +#define FD_CLOEXEC 1 /* close-on-exec flag */ + +/* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */ +#define F_RDLCK 1 /* shared or read lock */ +#define F_UNLCK 2 /* unlock */ +#define F_WRLCK 3 /* exclusive or write lock */ + + +/* + * [XSI] The values used for l_whence shall be defined as described + * in + */ +#include + +/* + * [XSI] The symbolic names for file modes for use as values of mode_t + * shall be defined as described in + */ +#include + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* allocate flags (F_PREALLOCATE) */ + +#define F_ALLOCATECONTIG 0x00000002 /* allocate contigious space */ +#define F_ALLOCATEALL 0x00000004 /* allocate all requested space or no space at all */ + +/* Position Modes (fst_posmode) for F_PREALLOCATE */ + +#define F_PEOFPOSMODE 3 /* Make it past all of the SEEK pos modes so that */ + /* we can keep them in sync should we desire */ +#define F_VOLPOSMODE 4 /* specify volume starting postion */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +/* + * Advisory file segment locking data type - + * information passed to system by user + */ +struct flock { + off_t l_start; /* starting offset */ + off_t l_len; /* len = 0 means until end of file */ + pid_t l_pid; /* lock owner */ + short l_type; /* lock type: read/write, etc. */ + short l_whence; /* type of l_start */ +}; + +#include + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +/* + * Advisory file segment locking with time out - + * Information passed to system by user for F_SETLKWTIMEOUT + */ +struct flocktimeout { + struct flock fl; /* flock passed for file locking */ + struct timespec timeout; /* timespec struct for timeout */ +}; +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * advisory file read data type - + * information passed by user to system + */ + + +struct radvisory { + off_t ra_offset; + int ra_count; +}; + + +/* + * detached code signatures data type - + * information passed by user to system used by F_ADDSIGS and F_ADDFILESIGS. + * F_ADDFILESIGS is a shortcut for files that contain their own signature and + * doesn't require mapping of the file in order to load the signature. + */ +#define USER_FSIGNATURES_CDHASH_LEN 20 +typedef struct fsignatures { + off_t fs_file_start; + void *fs_blob_start; + size_t fs_blob_size; + + /* The following fields are only applicable to F_ADDFILESIGS_INFO (64bit only). */ + /* Prior to F_ADDFILESIGS_INFO, this struct ended after fs_blob_size. */ + size_t fs_fsignatures_size;// input: size of this struct (for compatibility) + char fs_cdhash[USER_FSIGNATURES_CDHASH_LEN]; // output: cdhash + int fs_hash_type;// output: hash algorithm type for cdhash +} fsignatures_t; + +typedef struct fsupplement { + off_t fs_file_start; /* offset of Mach-O image in FAT file */ + off_t fs_blob_start; /* offset of signature in Mach-O image */ + size_t fs_blob_size; /* signature blob size */ + int fs_orig_fd; /* address of original image */ +} fsupplement_t; + + + +/* + * DYLD needs to check if the object is allowed to be combined + * into the main binary. This is done between the code signature + * is loaded and dyld is doing all the work to process the LOAD commands. + * + * While this could be done in F_ADDFILESIGS.* family the hook into + * the MAC module doesn't say no when LV isn't enabled and then that + * is cached on the vnode, and the MAC module never gets change once + * a process that library validation enabled. + */ +typedef struct fchecklv { + off_t lv_file_start; + size_t lv_error_message_size; + void *lv_error_message; +} fchecklv_t; + + +/* At this time F_GETSIGSINFO can only indicate platformness. + * As additional requestable information is defined, new keys will be added and the + * fgetsigsinfo_t structure will be lengthened to add space for the additional information + */ +#define GETSIGSINFO_PLATFORM_BINARY 1 + +/* fgetsigsinfo_t used by F_GETSIGSINFO command */ +typedef struct fgetsigsinfo { + off_t fg_file_start; /* IN: Offset in the file to look for a signature, -1 for any signature */ + int fg_info_request; /* IN: Key indicating the info requested */ + int fg_sig_is_platform; /* OUT: 1 if the signature is a plat form binary, 0 if not */ +} fgetsigsinfo_t; + + +/* lock operations for flock(2) */ +#define LOCK_SH 0x01 /* shared file lock */ +#define LOCK_EX 0x02 /* exclusive file lock */ +#define LOCK_NB 0x04 /* don't block when locking */ +#define LOCK_UN 0x08 /* unlock file */ + +/* fstore_t type used by F_PREALLOCATE command */ + +typedef struct fstore { + unsigned int fst_flags; /* IN: flags word */ + int fst_posmode; /* IN: indicates use of offset field */ + off_t fst_offset; /* IN: start of the region */ + off_t fst_length; /* IN: size of the region */ + off_t fst_bytesalloc; /* OUT: number of bytes allocated */ +} fstore_t; + +/* fpunchhole_t used by F_PUNCHHOLE */ +typedef struct fpunchhole { + unsigned int fp_flags; /* unused */ + unsigned int reserved; /* (to maintain 8-byte alignment) */ + off_t fp_offset; /* IN: start of the region */ + off_t fp_length; /* IN: size of the region */ +} fpunchhole_t; + +/* factive_file_trim_t used by F_TRIM_ACTIVE_FILE */ +typedef struct ftrimactivefile { + off_t fta_offset; /* IN: start of the region */ + off_t fta_length; /* IN: size of the region */ +} ftrimactivefile_t; + +/* fspecread_t used by F_SPECULATIVE_READ */ +typedef struct fspecread { + unsigned int fsr_flags; /* IN: flags word */ + unsigned int reserved; /* to maintain 8-byte alignment */ + off_t fsr_offset; /* IN: start of the region */ + off_t fsr_length; /* IN: size of the region */ +} fspecread_t; + +/* fbootstraptransfer_t used by F_READBOOTSTRAP and F_WRITEBOOTSTRAP commands */ + +typedef struct fbootstraptransfer { + off_t fbt_offset; /* IN: offset to start read/write */ + size_t fbt_length; /* IN: number of bytes to transfer */ + void *fbt_buffer; /* IN: buffer to be read/written */ +} fbootstraptransfer_t; + + +/* + * For F_LOG2PHYS this information is passed back to user + * Currently only devoffset is returned - that is the VOP_BMAP + * result - the disk device address corresponding to the + * current file offset (likely set with an lseek). + * + * The flags could hold an indication of whether the # of + * contiguous bytes reflects the true extent length on disk, + * or is an advisory value that indicates there is at least that + * many bytes contiguous. For some filesystems it might be too + * inefficient to provide anything beyond the advisory value. + * Flags and contiguous bytes return values are not yet implemented. + * For them the fcntl will nedd to switch from using BMAP to CMAP + * and a per filesystem type flag will be needed to interpret the + * contiguous bytes count result from CMAP. + * + * F_LOG2PHYS_EXT is a variant of F_LOG2PHYS that uses a passed in + * file offset and length instead of the current file offset. + * F_LOG2PHYS_EXT operates on the same structure as F_LOG2PHYS, but + * treats it as an in/out. + */ +#pragma pack(4) + +struct log2phys { + unsigned int l2p_flags; /* unused so far */ + off_t l2p_contigbytes; /* F_LOG2PHYS: unused so far */ + /* F_LOG2PHYS_EXT: IN: number of bytes to be queried */ + /* OUT: number of contiguous bytes at this position */ + off_t l2p_devoffset; /* F_LOG2PHYS: OUT: bytes into device */ + /* F_LOG2PHYS_EXT: IN: bytes into file */ + /* OUT: bytes into device */ +}; + +#pragma pack() + +#define O_POPUP 0x80000000 /* force window to popup on open */ +#define O_ALERT 0x20000000 /* small, clean popup window */ + + +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + +#include + +typedef enum { + FILESEC_OWNER = 1, + FILESEC_GROUP = 2, + FILESEC_UUID = 3, + FILESEC_MODE = 4, + FILESEC_ACL = 5, + FILESEC_GRPUUID = 6, + +/* XXX these are private to the implementation */ + FILESEC_ACL_RAW = 100, + FILESEC_ACL_ALLOCSIZE = 101 +} filesec_property_t; + +/* XXX backwards compatibility */ +#define FILESEC_GUID FILESEC_UUID +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +__BEGIN_DECLS +int open(const char *, int, ...) __DARWIN_ALIAS_C(open); +#if __DARWIN_C_LEVEL >= 200809L +int openat(int, const char *, int, ...) __DARWIN_NOCANCEL(openat) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); +#endif +int creat(const char *, mode_t) __DARWIN_ALIAS_C(creat); +int fcntl(int, int, ...) __DARWIN_ALIAS_C(fcntl); +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + +int openx_np(const char *, int, filesec_t); +/* + * data-protected non-portable open(2) : + * int open_dprotected_np(user_addr_t path, int flags, int class, int dpflags, int mode) + */ +int open_dprotected_np( const char *, int, int, int, ...); +int flock(int, int); +filesec_t filesec_init(void); +filesec_t filesec_dup(filesec_t); +void filesec_free(filesec_t); +int filesec_get_property(filesec_t, filesec_property_t, void *); +int filesec_query_property(filesec_t, filesec_property_t, int *); +int filesec_set_property(filesec_t, filesec_property_t, const void *); +int filesec_unset_property(filesec_t, filesec_property_t) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); +#define _FILESEC_UNSET_PROPERTY ((void *)0) +#define _FILESEC_REMOVE_ACL ((void *)1) +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +__END_DECLS + +#endif /* !_SYS_FCNTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/ioccom.h b/lib/libc/include/aarch64-macos-gnu/sys/ioccom.h new file mode 100644 index 0000000000..d4be2e433e --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/ioccom.h @@ -0,0 +1,99 @@ +/* + * 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) 1995 NeXT Computer, Inc. All Rights Reserved */ +/*- + * Copyright (c) 1982, 1986, 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)ioccom.h 8.2 (Berkeley) 3/28/94 + */ + +#ifndef _SYS_IOCCOM_H_ +#define _SYS_IOCCOM_H_ + +#include + +/* + * Ioctl's have the command encoded in the lower word, and the size of + * any in or out parameters in the upper word. The high 3 bits of the + * upper word are used to encode the in/out status of the parameter. + */ +#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */ +#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) +#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16)) +#define IOCGROUP(x) (((x) >> 8) & 0xff) + +#define IOCPARM_MAX (IOCPARM_MASK + 1) /* max size of ioctl args */ +/* no parameters */ +#define IOC_VOID (__uint32_t)0x20000000 +/* copy parameters out */ +#define IOC_OUT (__uint32_t)0x40000000 +/* copy parameters in */ +#define IOC_IN (__uint32_t)0x80000000 +/* copy parameters in and out */ +#define IOC_INOUT (IOC_IN|IOC_OUT) +/* mask for IN/OUT/VOID */ +#define IOC_DIRMASK (__uint32_t)0xe0000000 + +#define _IOC(inout, group, num, len) \ + (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)) +#define _IO(g, n) _IOC(IOC_VOID, (g), (n), 0) +#define _IOR(g, n, t) _IOC(IOC_OUT, (g), (n), sizeof(t)) +#define _IOW(g, n, t) _IOC(IOC_IN, (g), (n), sizeof(t)) +/* this should be _IORW, but stdio got there first */ +#define _IOWR(g, n, t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) + +#endif /* !_SYS_IOCCOM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/kauth.h b/lib/libc/include/aarch64-macos-gnu/sys/kauth.h new file mode 100644 index 0000000000..8742c60439 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/kauth.h @@ -0,0 +1,410 @@ +/* + * Copyright (c) 2004-2010 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ + +#ifndef _SYS_KAUTH_H +#define _SYS_KAUTH_H + +#include +#include +#include +#include /* u_int8_t, etc. */ +#include /* __offsetof() */ +#include /* uid_t */ +#include /* gid_t */ +#include /* NGROUPS_MAX */ + +#ifdef __APPLE_API_EVOLVING + +/* + * Identities. + */ + +#define KAUTH_UID_NONE (~(uid_t)0 - 100) /* not a valid UID */ +#define KAUTH_GID_NONE (~(gid_t)0 - 100) /* not a valid GID */ + +#include + +/* NT Security Identifier, structure as defined by Microsoft */ +#pragma pack(1) /* push packing of 1 byte */ +typedef struct { + u_int8_t sid_kind; + u_int8_t sid_authcount; + u_int8_t sid_authority[6]; +#define KAUTH_NTSID_MAX_AUTHORITIES 16 + u_int32_t sid_authorities[KAUTH_NTSID_MAX_AUTHORITIES]; +} ntsid_t; +#pragma pack() /* pop packing to previous packing level */ +#define _NTSID_T + +/* valid byte count inside a SID structure */ +#define KAUTH_NTSID_HDRSIZE (8) +#define KAUTH_NTSID_SIZE(_s) (KAUTH_NTSID_HDRSIZE + ((_s)->sid_authcount * sizeof(u_int32_t))) + +/* + * External lookup message payload; this structure is shared between the + * kernel group membership resolver, and the user space group membership + * resolver daemon, and is use to communicate resolution requests from the + * kernel to user space, and the result of that request from user space to + * the kernel. + */ +struct kauth_identity_extlookup { + u_int32_t el_seqno; /* request sequence number */ + u_int32_t el_result; /* lookup result */ +#define KAUTH_EXTLOOKUP_SUCCESS 0 /* results here are good */ +#define KAUTH_EXTLOOKUP_BADRQ 1 /* request badly formatted */ +#define KAUTH_EXTLOOKUP_FAILURE 2 /* transient failure during lookup */ +#define KAUTH_EXTLOOKUP_FATAL 3 /* permanent failure during lookup */ +#define KAUTH_EXTLOOKUP_INPROG 100 /* request in progress */ + u_int32_t el_flags; +#define KAUTH_EXTLOOKUP_VALID_UID (1<<0) +#define KAUTH_EXTLOOKUP_VALID_UGUID (1<<1) +#define KAUTH_EXTLOOKUP_VALID_USID (1<<2) +#define KAUTH_EXTLOOKUP_VALID_GID (1<<3) +#define KAUTH_EXTLOOKUP_VALID_GGUID (1<<4) +#define KAUTH_EXTLOOKUP_VALID_GSID (1<<5) +#define KAUTH_EXTLOOKUP_WANT_UID (1<<6) +#define KAUTH_EXTLOOKUP_WANT_UGUID (1<<7) +#define KAUTH_EXTLOOKUP_WANT_USID (1<<8) +#define KAUTH_EXTLOOKUP_WANT_GID (1<<9) +#define KAUTH_EXTLOOKUP_WANT_GGUID (1<<10) +#define KAUTH_EXTLOOKUP_WANT_GSID (1<<11) +#define KAUTH_EXTLOOKUP_WANT_MEMBERSHIP (1<<12) +#define KAUTH_EXTLOOKUP_VALID_MEMBERSHIP (1<<13) +#define KAUTH_EXTLOOKUP_ISMEMBER (1<<14) +#define KAUTH_EXTLOOKUP_VALID_PWNAM (1<<15) +#define KAUTH_EXTLOOKUP_WANT_PWNAM (1<<16) +#define KAUTH_EXTLOOKUP_VALID_GRNAM (1<<17) +#define KAUTH_EXTLOOKUP_WANT_GRNAM (1<<18) +#define KAUTH_EXTLOOKUP_VALID_SUPGRPS (1<<19) +#define KAUTH_EXTLOOKUP_WANT_SUPGRPS (1<<20) + + __darwin_pid_t el_info_pid; /* request on behalf of PID */ + u_int64_t el_extend; /* extension field */ + u_int32_t el_info_reserved_1; /* reserved (APPLE) */ + + uid_t el_uid; /* user ID */ + guid_t el_uguid; /* user GUID */ + u_int32_t el_uguid_valid; /* TTL on translation result (seconds) */ + ntsid_t el_usid; /* user NT SID */ + u_int32_t el_usid_valid; /* TTL on translation result (seconds) */ + gid_t el_gid; /* group ID */ + guid_t el_gguid; /* group GUID */ + u_int32_t el_gguid_valid; /* TTL on translation result (seconds) */ + ntsid_t el_gsid; /* group SID */ + u_int32_t el_gsid_valid; /* TTL on translation result (seconds) */ + u_int32_t el_member_valid; /* TTL on group lookup result */ + u_int32_t el_sup_grp_cnt; /* count of supplemental groups up to NGROUPS */ + gid_t el_sup_groups[NGROUPS_MAX]; /* supplemental group list */ +}; + +struct kauth_cache_sizes { + u_int32_t kcs_group_size; + u_int32_t kcs_id_size; +}; + +#define KAUTH_EXTLOOKUP_REGISTER (0) +#define KAUTH_EXTLOOKUP_RESULT (1<<0) +#define KAUTH_EXTLOOKUP_WORKER (1<<1) +#define KAUTH_EXTLOOKUP_DEREGISTER (1<<2) +#define KAUTH_GET_CACHE_SIZES (1<<3) +#define KAUTH_SET_CACHE_SIZES (1<<4) +#define KAUTH_CLEAR_CACHES (1<<5) + +#define IDENTITYSVC_ENTITLEMENT "com.apple.private.identitysvc" + + + +/* + * Generic Access Control Lists. + */ +#if defined(KERNEL) || defined (_SYS_ACL_H) + +typedef u_int32_t kauth_ace_rights_t; + +/* Access Control List Entry (ACE) */ +struct kauth_ace { + guid_t ace_applicable; + u_int32_t ace_flags; +#define KAUTH_ACE_KINDMASK 0xf +#define KAUTH_ACE_PERMIT 1 +#define KAUTH_ACE_DENY 2 +#define KAUTH_ACE_AUDIT 3 /* not implemented */ +#define KAUTH_ACE_ALARM 4 /* not implemented */ +#define KAUTH_ACE_INHERITED (1<<4) +#define KAUTH_ACE_FILE_INHERIT (1<<5) +#define KAUTH_ACE_DIRECTORY_INHERIT (1<<6) +#define KAUTH_ACE_LIMIT_INHERIT (1<<7) +#define KAUTH_ACE_ONLY_INHERIT (1<<8) +#define KAUTH_ACE_SUCCESS (1<<9) /* not implemented (AUDIT/ALARM) */ +#define KAUTH_ACE_FAILURE (1<<10) /* not implemented (AUDIT/ALARM) */ +/* All flag bits controlling ACE inheritance */ +#define KAUTH_ACE_INHERIT_CONTROL_FLAGS \ + (KAUTH_ACE_FILE_INHERIT | \ + KAUTH_ACE_DIRECTORY_INHERIT | \ + KAUTH_ACE_LIMIT_INHERIT | \ + KAUTH_ACE_ONLY_INHERIT) + kauth_ace_rights_t ace_rights; /* scope specific */ + /* These rights are never tested, but may be present in an ACL */ +#define KAUTH_ACE_GENERIC_ALL (1<<21) +#define KAUTH_ACE_GENERIC_EXECUTE (1<<22) +#define KAUTH_ACE_GENERIC_WRITE (1<<23) +#define KAUTH_ACE_GENERIC_READ (1<<24) +}; + +#ifndef _KAUTH_ACE +#define _KAUTH_ACE +typedef struct kauth_ace *kauth_ace_t; +#endif + + +/* Access Control List */ +struct kauth_acl { + u_int32_t acl_entrycount; + u_int32_t acl_flags; + + struct kauth_ace acl_ace[1]; +}; + +/* + * XXX this value needs to be raised - 3893388 + */ +#define KAUTH_ACL_MAX_ENTRIES 128 + +/* + * The low 16 bits of the flags field are reserved for filesystem + * internal use and must be preserved by all APIs. This includes + * round-tripping flags through user-space interfaces. + */ +#define KAUTH_ACL_FLAGS_PRIVATE (0xffff) + +/* + * The high 16 bits of the flags are used to store attributes and + * to request specific handling of the ACL. + */ + +/* inheritance will be deferred until the first rename operation */ +#define KAUTH_ACL_DEFER_INHERIT (1<<16) +/* this ACL must not be overwritten as part of an inheritance operation */ +#define KAUTH_ACL_NO_INHERIT (1<<17) + +/* acl_entrycount that tells us the ACL is not valid */ +#define KAUTH_FILESEC_NOACL ((u_int32_t)(-1)) + +/* + * If the acl_entrycount field is KAUTH_FILESEC_NOACL, then the size is the + * same as a kauth_acl structure; the intent is to put an actual entrycount of + * KAUTH_FILESEC_NOACL on disk to distinguish a kauth_filesec_t with an empty + * entry (Windows treats this as "deny all") from one that merely indicates a + * file group and/or owner guid values. + */ +#define KAUTH_ACL_SIZE(c) (__offsetof(struct kauth_acl, acl_ace) + ((u_int32_t)(c) != KAUTH_FILESEC_NOACL ? ((c) * sizeof(struct kauth_ace)) : 0)) +#define KAUTH_ACL_COPYSIZE(p) KAUTH_ACL_SIZE((p)->acl_entrycount) + + +#ifndef _KAUTH_ACL +#define _KAUTH_ACL +typedef struct kauth_acl *kauth_acl_t; +#endif + + + +/* + * Extended File Security. + */ + +/* File Security information */ +struct kauth_filesec { + u_int32_t fsec_magic; +#define KAUTH_FILESEC_MAGIC 0x012cc16d + guid_t fsec_owner; + guid_t fsec_group; + + struct kauth_acl fsec_acl; +}; + +/* backwards compatibility */ +#define fsec_entrycount fsec_acl.acl_entrycount +#define fsec_flags fsec_acl.acl_flags +#define fsec_ace fsec_acl.acl_ace +#define KAUTH_FILESEC_FLAGS_PRIVATE KAUTH_ACL_FLAGS_PRIVATE +#define KAUTH_FILESEC_DEFER_INHERIT KAUTH_ACL_DEFER_INHERIT +#define KAUTH_FILESEC_NO_INHERIT KAUTH_ACL_NO_INHERIT +#define KAUTH_FILESEC_NONE ((kauth_filesec_t)0) +#define KAUTH_FILESEC_WANTED ((kauth_filesec_t)1) + +#ifndef _KAUTH_FILESEC +#define _KAUTH_FILESEC +typedef struct kauth_filesec *kauth_filesec_t; +#endif + +#define KAUTH_FILESEC_SIZE(c) (__offsetof(struct kauth_filesec, fsec_acl) + __offsetof(struct kauth_acl, acl_ace) + (c) * sizeof(struct kauth_ace)) +#define KAUTH_FILESEC_COPYSIZE(p) KAUTH_FILESEC_SIZE(((p)->fsec_entrycount == KAUTH_FILESEC_NOACL) ? 0 : (p)->fsec_entrycount) +#define KAUTH_FILESEC_COUNT(s) (((s) - KAUTH_FILESEC_SIZE(0)) / sizeof(struct kauth_ace)) +#define KAUTH_FILESEC_VALID(s) ((s) >= KAUTH_FILESEC_SIZE(0) && (((s) - KAUTH_FILESEC_SIZE(0)) % sizeof(struct kauth_ace)) == 0) + +#define KAUTH_FILESEC_XATTR "com.apple.system.Security" + +/* Allowable first arguments to kauth_filesec_acl_setendian() */ +#define KAUTH_ENDIAN_HOST 0x00000001 /* set host endianness */ +#define KAUTH_ENDIAN_DISK 0x00000002 /* set disk endianness */ + +#endif /* KERNEL || */ + + + +/* Actions, also rights bits in an ACE */ + +#if defined(KERNEL) || defined (_SYS_ACL_H) +#define KAUTH_VNODE_READ_DATA (1U<<1) +#define KAUTH_VNODE_LIST_DIRECTORY KAUTH_VNODE_READ_DATA +#define KAUTH_VNODE_WRITE_DATA (1U<<2) +#define KAUTH_VNODE_ADD_FILE KAUTH_VNODE_WRITE_DATA +#define KAUTH_VNODE_EXECUTE (1U<<3) +#define KAUTH_VNODE_SEARCH KAUTH_VNODE_EXECUTE +#define KAUTH_VNODE_DELETE (1U<<4) +#define KAUTH_VNODE_APPEND_DATA (1U<<5) +#define KAUTH_VNODE_ADD_SUBDIRECTORY KAUTH_VNODE_APPEND_DATA +#define KAUTH_VNODE_DELETE_CHILD (1U<<6) +#define KAUTH_VNODE_READ_ATTRIBUTES (1U<<7) +#define KAUTH_VNODE_WRITE_ATTRIBUTES (1U<<8) +#define KAUTH_VNODE_READ_EXTATTRIBUTES (1U<<9) +#define KAUTH_VNODE_WRITE_EXTATTRIBUTES (1U<<10) +#define KAUTH_VNODE_READ_SECURITY (1U<<11) +#define KAUTH_VNODE_WRITE_SECURITY (1U<<12) +#define KAUTH_VNODE_TAKE_OWNERSHIP (1U<<13) + +/* backwards compatibility only */ +#define KAUTH_VNODE_CHANGE_OWNER KAUTH_VNODE_TAKE_OWNERSHIP + +/* For Windows interoperability only */ +#define KAUTH_VNODE_SYNCHRONIZE (1U<<20) + +/* (1<<21) - (1<<24) are reserved for generic rights bits */ + +/* Actions not expressed as rights bits */ +/* + * Authorizes the vnode as the target of a hard link. + */ +#define KAUTH_VNODE_LINKTARGET (1U<<25) + +/* + * Indicates that other steps have been taken to authorise the action, + * but authorisation should be denied for immutable objects. + */ +#define KAUTH_VNODE_CHECKIMMUTABLE (1U<<26) + +/* Action modifiers */ +/* + * The KAUTH_VNODE_ACCESS bit is passed to the callback if the authorisation + * request in progress is advisory, rather than authoritative. Listeners + * performing consequential work (i.e. not strictly checking authorisation) + * may test this flag to avoid performing unnecessary work. + * + * This bit will never be present in an ACE. + */ +#define KAUTH_VNODE_ACCESS (1U<<31) + +/* + * The KAUTH_VNODE_NOIMMUTABLE bit is passed to the callback along with the + * KAUTH_VNODE_WRITE_SECURITY bit (and no others) to indicate that the + * caller wishes to change one or more of the immutable flags, and the + * state of these flags should not be considered when authorizing the request. + * The system immutable flags are only ignored when the system securelevel + * is low enough to allow their removal. + */ +#define KAUTH_VNODE_NOIMMUTABLE (1U<<30) + + +/* + * fake right that is composed by the following... + * vnode must have search for owner, group and world allowed + * plus there must be no deny modes present for SEARCH... this fake + * right is used by the fast lookup path to avoid checking + * for an exact match on the last credential to lookup + * the component being acted on + */ +#define KAUTH_VNODE_SEARCHBYANYONE (1U<<29) + + +/* + * when passed as an 'action' to "vnode_uncache_authorized_actions" + * it indicates that all of the cached authorizations for that + * vnode should be invalidated + */ +#define KAUTH_INVALIDATE_CACHED_RIGHTS ((kauth_action_t)~0) + + + +/* The expansions of the GENERIC bits at evaluation time */ +#define KAUTH_VNODE_GENERIC_READ_BITS (KAUTH_VNODE_READ_DATA | \ + KAUTH_VNODE_READ_ATTRIBUTES | \ + KAUTH_VNODE_READ_EXTATTRIBUTES | \ + KAUTH_VNODE_READ_SECURITY) + +#define KAUTH_VNODE_GENERIC_WRITE_BITS (KAUTH_VNODE_WRITE_DATA | \ + KAUTH_VNODE_APPEND_DATA | \ + KAUTH_VNODE_DELETE | \ + KAUTH_VNODE_DELETE_CHILD | \ + KAUTH_VNODE_WRITE_ATTRIBUTES | \ + KAUTH_VNODE_WRITE_EXTATTRIBUTES | \ + KAUTH_VNODE_WRITE_SECURITY) + +#define KAUTH_VNODE_GENERIC_EXECUTE_BITS (KAUTH_VNODE_EXECUTE) + +#define KAUTH_VNODE_GENERIC_ALL_BITS (KAUTH_VNODE_GENERIC_READ_BITS | \ + KAUTH_VNODE_GENERIC_WRITE_BITS | \ + KAUTH_VNODE_GENERIC_EXECUTE_BITS) + +/* + * Some sets of bits, defined here for convenience. + */ +#define KAUTH_VNODE_WRITE_RIGHTS (KAUTH_VNODE_ADD_FILE | \ + KAUTH_VNODE_ADD_SUBDIRECTORY | \ + KAUTH_VNODE_DELETE_CHILD | \ + KAUTH_VNODE_WRITE_DATA | \ + KAUTH_VNODE_APPEND_DATA | \ + KAUTH_VNODE_DELETE | \ + KAUTH_VNODE_WRITE_ATTRIBUTES | \ + KAUTH_VNODE_WRITE_EXTATTRIBUTES | \ + KAUTH_VNODE_WRITE_SECURITY | \ + KAUTH_VNODE_TAKE_OWNERSHIP | \ + KAUTH_VNODE_LINKTARGET | \ + KAUTH_VNODE_CHECKIMMUTABLE) + + +#endif /* KERNEL || */ + + +#endif /* __APPLE_API_EVOLVING */ +#endif /* _SYS_KAUTH_H */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/mman.h b/lib/libc/include/aarch64-macos-gnu/sys/mman.h new file mode 100644 index 0000000000..b254715ad3 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/mman.h @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2000-2020 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/*- + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)mman.h 8.1 (Berkeley) 6/2/93 + */ + +/* + * Currently unsupported: + * + * [TYM] POSIX_TYPED_MEM_ALLOCATE + * [TYM] POSIX_TYPED_MEM_ALLOCATE_CONTIG + * [TYM] POSIX_TYPED_MEM_MAP_ALLOCATABLE + * [TYM] struct posix_typed_mem_info + * [TYM] posix_mem_offset() + * [TYM] posix_typed_mem_get_info() + * [TYM] posix_typed_mem_open() + */ + +#ifndef _SYS_MMAN_H_ +#define _SYS_MMAN_H_ + +#include +#include + +#include + +/* + * [various] The mode_t, off_t, and size_t types shall be defined as + * described in + */ +#include +#include +#include + +#if __DARWIN_C_LEVEL >= 200809L +#include +#endif /* __DARWIN_C_LEVEL */ + +/* + * Protections are chosen from these bits, or-ed together + */ +#define PROT_NONE 0x00 /* [MC2] no permissions */ +#define PROT_READ 0x01 /* [MC2] pages can be read */ +#define PROT_WRITE 0x02 /* [MC2] pages can be written */ +#define PROT_EXEC 0x04 /* [MC2] pages can be executed */ + +/* + * Flags contain sharing type and options. + * Sharing types; choose one. + */ +#define MAP_SHARED 0x0001 /* [MF|SHM] share changes */ +#define MAP_PRIVATE 0x0002 /* [MF|SHM] changes are private */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define MAP_COPY MAP_PRIVATE /* Obsolete */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Other flags + */ +#define MAP_FIXED 0x0010 /* [MF|SHM] interpret addr exactly */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define MAP_RENAME 0x0020 /* Sun: rename private pages to file */ +#define MAP_NORESERVE 0x0040 /* Sun: don't reserve needed swap area */ +#define MAP_RESERVED0080 0x0080 /* previously unimplemented MAP_INHERIT */ +#define MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */ +#define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ +#define MAP_NOCACHE 0x0400 /* don't cache pages for this mapping */ +#define MAP_JIT 0x0800 /* Allocate a region that will be used for JIT purposes */ + +/* + * Mapping type + */ +#define MAP_FILE 0x0000 /* map from file (default) */ +#define MAP_ANON 0x1000 /* allocated from memory, swap space */ +#define MAP_ANONYMOUS MAP_ANON + +/* + * The MAP_RESILIENT_* flags can be used when the caller wants to map some + * possibly unreliable memory and be able to access it safely, possibly + * getting the wrong contents rather than raising any exception. + * For safety reasons, such mappings have to be read-only (PROT_READ access + * only). + * + * MAP_RESILIENT_CODESIGN: + * accessing this mapping will not generate code-signing violations, + * even if the contents are tainted. + * MAP_RESILIENT_MEDIA: + * accessing this mapping will not generate an exception if the contents + * are not available (unreachable removable or remote media, access beyond + * end-of-file, ...). Missing contents will be replaced with zeroes. + */ +#define MAP_RESILIENT_CODESIGN 0x2000 /* no code-signing failures */ +#define MAP_RESILIENT_MEDIA 0x4000 /* no backing-store failures */ + +#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 +#define MAP_32BIT 0x8000 /* Return virtual addresses <4G only */ +#endif /* defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500 */ + + +/* + * Flags used to support translated processes. + */ +#define MAP_TRANSLATED_ALLOW_EXECUTE 0x20000 /* allow execute in translated processes */ + +#define MAP_UNIX03 0x40000 /* UNIX03 compliance */ + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Process memory locking + */ +#define MCL_CURRENT 0x0001 /* [ML] Lock only current memory */ +#define MCL_FUTURE 0x0002 /* [ML] Lock all future memory as well */ + +/* + * Error return from mmap() + */ +#define MAP_FAILED ((void *)-1) /* [MF|SHM] mmap failed */ + +/* + * msync() flags + */ +#define MS_ASYNC 0x0001 /* [MF|SIO] return immediately */ +#define MS_INVALIDATE 0x0002 /* [MF|SIO] invalidate all cached data */ +#define MS_SYNC 0x0010 /* [MF|SIO] msync synchronously */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define MS_KILLPAGES 0x0004 /* invalidate pages, leave mapped */ +#define MS_DEACTIVATE 0x0008 /* deactivate pages, leave mapped */ + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + +/* + * Advice to madvise + */ +#define POSIX_MADV_NORMAL 0 /* [MC1] no further special treatment */ +#define POSIX_MADV_RANDOM 1 /* [MC1] expect random page refs */ +#define POSIX_MADV_SEQUENTIAL 2 /* [MC1] expect sequential page refs */ +#define POSIX_MADV_WILLNEED 3 /* [MC1] will need these pages */ +#define POSIX_MADV_DONTNEED 4 /* [MC1] dont need these pages */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define MADV_NORMAL POSIX_MADV_NORMAL +#define MADV_RANDOM POSIX_MADV_RANDOM +#define MADV_SEQUENTIAL POSIX_MADV_SEQUENTIAL +#define MADV_WILLNEED POSIX_MADV_WILLNEED +#define MADV_DONTNEED POSIX_MADV_DONTNEED +#define MADV_FREE 5 /* pages unneeded, discard contents */ +#define MADV_ZERO_WIRED_PAGES 6 /* zero the wired pages that have not been unwired before the entry is deleted */ +#define MADV_FREE_REUSABLE 7 /* pages can be reused (by anyone) */ +#define MADV_FREE_REUSE 8 /* caller wants to reuse those pages */ +#define MADV_CAN_REUSE 9 +#define MADV_PAGEOUT 10 /* page out now (internal only) */ + +/* + * Return bits from mincore + */ +#define MINCORE_INCORE 0x1 /* Page is incore */ +#define MINCORE_REFERENCED 0x2 /* Page has been referenced by us */ +#define MINCORE_MODIFIED 0x4 /* Page has been modified by us */ +#define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */ +#define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */ +#define MINCORE_PAGED_OUT 0x20 /* Page has been paged out */ +#define MINCORE_COPIED 0x40 /* Page has been copied */ +#define MINCORE_ANONYMOUS 0x80 /* Page belongs to an anonymous object */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + + + +__BEGIN_DECLS +/* [ML] */ +int mlockall(int); +int munlockall(void); +/* [MR] */ +int mlock(const void *, size_t); +#ifndef _MMAP +#define _MMAP +/* [MC3]*/ +void * mmap(void *, size_t, int, int, int, off_t) __DARWIN_ALIAS(mmap); +#endif +/* [MPR] */ +int mprotect(void *, size_t, int) __DARWIN_ALIAS(mprotect); +/* [MF|SIO] */ +int msync(void *, size_t, int) __DARWIN_ALIAS_C(msync); +/* [MR] */ +int munlock(const void *, size_t); +/* [MC3]*/ +int munmap(void *, size_t) __DARWIN_ALIAS(munmap); +/* [SHM] */ +int shm_open(const char *, int, ...); +int shm_unlink(const char *); +/* [ADV] */ +int posix_madvise(void *, size_t, int); + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +int madvise(void *, size_t, int); +int mincore(const void *, size_t, char *); +int minherit(void *, size_t, int); +#endif + + +__END_DECLS + +#endif /* !_SYS_MMAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/mount.h b/lib/libc/include/aarch64-macos-gnu/sys/mount.h new file mode 100644 index 0000000000..85a8347ddf --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/mount.h @@ -0,0 +1,434 @@ +/* + * Copyright (c) 2000-2018 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1989, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)mount.h 8.21 (Berkeley) 5/20/95 + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ + + +#ifndef _SYS_MOUNT_H_ +#define _SYS_MOUNT_H_ + +#include +#include +#include /* needed for vol_capabilities_attr_t */ +#include + +#include +#include +#include /* XXX needed for user builds */ +#include + +#include /* file system id type */ + +/* + * file system statistics + */ + +#define MFSNAMELEN 15 /* length of fs type name, not inc. null */ +#define MFSTYPENAMELEN 16 /* length of fs type name including null */ + +#if __DARWIN_64_BIT_INO_T +#define MNAMELEN MAXPATHLEN /* length of buffer for returned name */ +#else /* ! __DARWIN_64_BIT_INO_T */ +#define MNAMELEN 90 /* length of buffer for returned name */ +#endif /* __DARWIN_64_BIT_INO_T */ + +#define MNT_EXT_ROOT_DATA_VOL 0x00000001 /* Data volume of root volume group */ + +#define __DARWIN_STRUCT_STATFS64 { \ + uint32_t f_bsize; /* fundamental file system block size */ \ + int32_t f_iosize; /* optimal transfer block size */ \ + uint64_t f_blocks; /* total data blocks in file system */ \ + uint64_t f_bfree; /* free blocks in fs */ \ + uint64_t f_bavail; /* free blocks avail to non-superuser */ \ + uint64_t f_files; /* total file nodes in file system */ \ + uint64_t f_ffree; /* free file nodes in fs */ \ + fsid_t f_fsid; /* file system id */ \ + uid_t f_owner; /* user that mounted the filesystem */ \ + uint32_t f_type; /* type of filesystem */ \ + uint32_t f_flags; /* copy of mount exported flags */ \ + uint32_t f_fssubtype; /* fs sub-type (flavor) */ \ + char f_fstypename[MFSTYPENAMELEN]; /* fs type name */ \ + char f_mntonname[MAXPATHLEN]; /* directory on which mounted */ \ + char f_mntfromname[MAXPATHLEN]; /* mounted filesystem */ \ + uint32_t f_flags_ext; /* extended flags */ \ + uint32_t f_reserved[7]; /* For future use */ \ +} + +#if !__DARWIN_ONLY_64_BIT_INO_T + +struct statfs64 __DARWIN_STRUCT_STATFS64; + +#endif /* !__DARWIN_ONLY_64_BIT_INO_T */ + +#if __DARWIN_64_BIT_INO_T + +struct statfs __DARWIN_STRUCT_STATFS64; + +#else /* !__DARWIN_64_BIT_INO_T */ + +/* + * LP64 - WARNING - must be kept in sync with struct user_statfs in mount_internal.h. + */ +struct statfs { + short f_otype; /* TEMPORARY SHADOW COPY OF f_type */ + short f_oflags; /* TEMPORARY SHADOW COPY OF f_flags */ + long f_bsize; /* fundamental file system block size */ + long f_iosize; /* optimal transfer block size */ + long f_blocks; /* total data blocks in file system */ + long f_bfree; /* free blocks in fs */ + long f_bavail; /* free blocks avail to non-superuser */ + long f_files; /* total file nodes in file system */ + long f_ffree; /* free file nodes in fs */ + fsid_t f_fsid; /* file system id */ + uid_t f_owner; /* user that mounted the filesystem */ + short f_reserved1; /* spare for later */ + short f_type; /* type of filesystem */ + long f_flags; /* copy of mount exported flags */ + long f_reserved2[2]; /* reserved for future use */ + char f_fstypename[MFSNAMELEN]; /* fs type name */ + char f_mntonname[MNAMELEN]; /* directory on which mounted */ + char f_mntfromname[MNAMELEN];/* mounted filesystem */ + char f_reserved3; /* For alignment */ + long f_reserved4[4]; /* For future use */ +}; + +#endif /* __DARWIN_64_BIT_INO_T */ + +#pragma pack(4) + +struct vfsstatfs { + uint32_t f_bsize; /* fundamental file system block size */ + size_t f_iosize; /* optimal transfer block size */ + uint64_t f_blocks; /* total data blocks in file system */ + uint64_t f_bfree; /* free blocks in fs */ + uint64_t f_bavail; /* free blocks avail to non-superuser */ + uint64_t f_bused; /* free blocks avail to non-superuser */ + uint64_t f_files; /* total file nodes in file system */ + uint64_t f_ffree; /* free file nodes in fs */ + fsid_t f_fsid; /* file system id */ + uid_t f_owner; /* user that mounted the filesystem */ + uint64_t f_flags; /* copy of mount exported flags */ + char f_fstypename[MFSTYPENAMELEN];/* fs type name inclus */ + char f_mntonname[MAXPATHLEN];/* directory on which mounted */ + char f_mntfromname[MAXPATHLEN];/* mounted filesystem */ + uint32_t f_fssubtype; /* fs sub-type (flavor) */ + void *f_reserved[2]; /* For future use == 0 */ +}; + +#pragma pack() + + +/* + * User specifiable flags. + * + * Unmount uses MNT_FORCE flag. + */ +#define MNT_RDONLY 0x00000001 /* read only filesystem */ +#define MNT_SYNCHRONOUS 0x00000002 /* file system written synchronously */ +#define MNT_NOEXEC 0x00000004 /* can't exec from filesystem */ +#define MNT_NOSUID 0x00000008 /* don't honor setuid bits on fs */ +#define MNT_NODEV 0x00000010 /* don't interpret special files */ +#define MNT_UNION 0x00000020 /* union with underlying filesystem */ +#define MNT_ASYNC 0x00000040 /* file system written asynchronously */ +#define MNT_CPROTECT 0x00000080 /* file system supports content protection */ + +/* + * NFS export related mount flags. + */ +#define MNT_EXPORTED 0x00000100 /* file system is exported */ + +/* + * Denotes storage which can be removed from the system by the user. + */ + +#define MNT_REMOVABLE 0x00000200 + +/* + * MAC labeled / "quarantined" flag + */ +#define MNT_QUARANTINE 0x00000400 /* file system is quarantined */ + +/* + * Flags set by internal operations. + */ +#define MNT_LOCAL 0x00001000 /* filesystem is stored locally */ +#define MNT_QUOTA 0x00002000 /* quotas are enabled on filesystem */ +#define MNT_ROOTFS 0x00004000 /* identifies the root filesystem */ +#define MNT_DOVOLFS 0x00008000 /* FS supports volfs (deprecated flag in Mac OS X 10.5) */ + + +#define MNT_DONTBROWSE 0x00100000 /* file system is not appropriate path to user data */ +#define MNT_IGNORE_OWNERSHIP 0x00200000 /* VFS will ignore ownership information on filesystem objects */ +#define MNT_AUTOMOUNTED 0x00400000 /* filesystem was mounted by automounter */ +#define MNT_JOURNALED 0x00800000 /* filesystem is journaled */ +#define MNT_NOUSERXATTR 0x01000000 /* Don't allow user extended attributes */ +#define MNT_DEFWRITE 0x02000000 /* filesystem should defer writes */ +#define MNT_MULTILABEL 0x04000000 /* MAC support for individual labels */ +#define MNT_NOATIME 0x10000000 /* disable update of file access time */ +#define MNT_SNAPSHOT 0x40000000 /* The mount is a snapshot */ +#define MNT_STRICTATIME 0x80000000 /* enable strict update of file access time */ + +/* backwards compatibility only */ +#define MNT_UNKNOWNPERMISSIONS MNT_IGNORE_OWNERSHIP + + +/* + * XXX I think that this could now become (~(MNT_CMDFLAGS)) + * but the 'mount' program may need changing to handle this. + */ +#define MNT_VISFLAGMASK (MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC | \ + MNT_NOSUID | MNT_NODEV | MNT_UNION | \ + MNT_ASYNC | MNT_EXPORTED | MNT_QUARANTINE | \ + MNT_LOCAL | MNT_QUOTA | MNT_REMOVABLE | \ + MNT_ROOTFS | MNT_DOVOLFS | MNT_DONTBROWSE | \ + MNT_IGNORE_OWNERSHIP | MNT_AUTOMOUNTED | MNT_JOURNALED | \ + MNT_NOUSERXATTR | MNT_DEFWRITE | MNT_MULTILABEL | \ + MNT_NOATIME | MNT_STRICTATIME | MNT_SNAPSHOT | MNT_CPROTECT) +/* + * External filesystem command modifier flags. + * Unmount can use the MNT_FORCE flag. + * XXX These are not STATES and really should be somewhere else. + * External filesystem control flags. + */ +#define MNT_UPDATE 0x00010000 /* not a real mount, just an update */ +#define MNT_NOBLOCK 0x00020000 /* don't block unmount if not responding */ +#define MNT_RELOAD 0x00040000 /* reload filesystem data */ +#define MNT_FORCE 0x00080000 /* force unmount or readonly change */ +#define MNT_CMDFLAGS (MNT_UPDATE|MNT_NOBLOCK|MNT_RELOAD|MNT_FORCE) + + + +/* + * Sysctl CTL_VFS definitions. + * + * Second level identifier specifies which filesystem. Second level + * identifier VFS_GENERIC returns information about all filesystems. + */ +#define VFS_GENERIC 0 /* generic filesystem information */ +#define VFS_NUMMNTOPS 1 /* int: total num of vfs mount/unmount operations */ +/* + * Third level identifiers for VFS_GENERIC are given below; third + * level identifiers for specific filesystems are given in their + * mount specific header files. + */ +#define VFS_MAXTYPENUM 1 /* int: highest defined filesystem type */ +#define VFS_CONF 2 /* struct: vfsconf for filesystem given + * as next argument */ + +/* + * Flags for various system call interfaces. + * + * waitfor flags to vfs_sync() and getfsstat() + */ +#define MNT_WAIT 1 /* synchronized I/O file integrity completion */ +#define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */ +#define MNT_DWAIT 4 /* synchronized I/O data integrity completion */ + + +#if !defined(KERNEL) && !defined(_KERN_SYS_KERNELTYPES_H_) /* also defined in kernel_types.h */ +struct mount; +typedef struct mount * mount_t; +struct vnode; +typedef struct vnode * vnode_t; +#endif + +/* Reserved fields preserve binary compatibility */ +struct vfsconf { + uint32_t vfc_reserved1; /* opaque */ + char vfc_name[MFSNAMELEN]; /* filesystem type name */ + int vfc_typenum; /* historic filesystem type number */ + int vfc_refcount; /* number mounted of this type */ + int vfc_flags; /* permanent flags */ + uint32_t vfc_reserved2; /* opaque */ + uint32_t vfc_reserved3; /* opaque */ +}; + +struct vfsidctl { + int vc_vers; /* should be VFSIDCTL_VERS1 (below) */ + fsid_t vc_fsid; /* fsid to operate on. */ + void *vc_ptr; /* pointer to data structure. */ + size_t vc_len; /* sizeof said structure. */ + u_int32_t vc_spare[12]; /* spare (must be zero). */ +}; + + +/* vfsidctl API version. */ +#define VFS_CTL_VERS1 0x01 + + +/* + * New style VFS sysctls, do not reuse/conflict with the namespace for + * private sysctls. + */ +#define VFS_CTL_OSTATFS 0x00010001 /* old legacy statfs */ +#define VFS_CTL_UMOUNT 0x00010002 /* unmount */ +#define VFS_CTL_QUERY 0x00010003 /* anything wrong? (vfsquery) */ +#define VFS_CTL_NEWADDR 0x00010004 /* reconnect to new address */ +#define VFS_CTL_TIMEO 0x00010005 /* set timeout for vfs notification */ +#define VFS_CTL_NOLOCKS 0x00010006 /* disable file locking */ +#define VFS_CTL_SADDR 0x00010007 /* get server address */ +#define VFS_CTL_DISC 0x00010008 /* server disconnected */ +#define VFS_CTL_SERVERINFO 0x00010009 /* information about fs server */ +#define VFS_CTL_NSTATUS 0x0001000A /* netfs mount status */ +#define VFS_CTL_STATFS64 0x0001000B /* statfs64 */ + +/* + * Automatically select the correct VFS_CTL_*STATFS* flavor based + * on what "struct statfs" layout the client will use. + */ +#if __DARWIN_64_BIT_INO_T +#define VFS_CTL_STATFS VFS_CTL_STATFS64 +#else +#define VFS_CTL_STATFS VFS_CTL_OSTATFS +#endif + +struct vfsquery { + u_int32_t vq_flags; + u_int32_t vq_spare[31]; +}; + +struct vfs_server { + int32_t vs_minutes; /* minutes until server goes down. */ + u_int8_t vs_server_name[MAXHOSTNAMELEN * 3]; /* UTF8 server name to display (null terminated) */ +}; + +/* + * NetFS mount status - returned by VFS_CTL_NSTATUS + */ +struct netfs_status { + u_int32_t ns_status; // Current status of mount (vfsquery flags) + char ns_mountopts[512]; // Significant mount options + uint32_t ns_waittime; // Time waiting for reply (sec) + uint32_t ns_threadcount; // Number of threads blocked on network calls + uint64_t ns_threadids[0]; // Thread IDs of those blocked threads +}; + +/* vfsquery flags */ +#define VQ_NOTRESP 0x0001 /* server down */ +#define VQ_NEEDAUTH 0x0002 /* server bad auth */ +#define VQ_LOWDISK 0x0004 /* we're low on space */ +#define VQ_MOUNT 0x0008 /* new filesystem arrived */ +#define VQ_UNMOUNT 0x0010 /* filesystem has left */ +#define VQ_DEAD 0x0020 /* filesystem is dead, needs force unmount */ +#define VQ_ASSIST 0x0040 /* filesystem needs assistance from external program */ +#define VQ_NOTRESPLOCK 0x0080 /* server lockd down */ +#define VQ_UPDATE 0x0100 /* filesystem information has changed */ +#define VQ_VERYLOWDISK 0x0200 /* file system has *very* little disk space left */ +#define VQ_SYNCEVENT 0x0400 /* a sync just happened (not set by kernel starting Mac OS X 10.9) */ +#define VQ_SERVEREVENT 0x0800 /* server issued notification/warning */ +#define VQ_QUOTA 0x1000 /* a user quota has been hit */ +#define VQ_NEARLOWDISK 0x2000 /* Above lowdisk and below desired disk space */ +#define VQ_DESIRED_DISK 0x4000 /* the desired disk space */ +#define VQ_FREE_SPACE_CHANGE 0x8000 /* free disk space has significantly changed */ +#define VQ_FLAG10000 0x10000 /* placeholder */ + + + + +/* + * Generic file handle + */ +#define NFS_MAX_FH_SIZE NFSV4_MAX_FH_SIZE +#define NFSV4_MAX_FH_SIZE 128 +#define NFSV3_MAX_FH_SIZE 64 +#define NFSV2_MAX_FH_SIZE 32 +struct fhandle { + unsigned int fh_len; /* length of file handle */ + unsigned char fh_data[NFS_MAX_FH_SIZE]; /* file handle value */ +}; +typedef struct fhandle fhandle_t; + + +__BEGIN_DECLS +int fhopen(const struct fhandle *, int); +int fstatfs(int, struct statfs *) __DARWIN_INODE64(fstatfs); +#if !__DARWIN_ONLY_64_BIT_INO_T +int fstatfs64(int, struct statfs64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +#endif /* !__DARWIN_ONLY_64_BIT_INO_T */ +int getfh(const char *, fhandle_t *); +int getfsstat(struct statfs *, int, int) __DARWIN_INODE64(getfsstat); +#if !__DARWIN_ONLY_64_BIT_INO_T +int getfsstat64(struct statfs64 *, int, int) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +#endif /* !__DARWIN_ONLY_64_BIT_INO_T */ +int getmntinfo(struct statfs **, int) __DARWIN_INODE64(getmntinfo); +int getmntinfo_r_np(struct statfs **, int) __DARWIN_INODE64(getmntinfo_r_np) +__OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) +__TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0); +#if !__DARWIN_ONLY_64_BIT_INO_T +int getmntinfo64(struct statfs64 **, int) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +#endif /* !__DARWIN_ONLY_64_BIT_INO_T */ +int mount(const char *, const char *, int, void *); +int fmount(const char *, int, int, void *) __OSX_AVAILABLE(10.13) __IOS_AVAILABLE(11.0) __TVOS_AVAILABLE(11.0) __WATCHOS_AVAILABLE(4.0); +int statfs(const char *, struct statfs *) __DARWIN_INODE64(statfs); +#if !__DARWIN_ONLY_64_BIT_INO_T +int statfs64(const char *, struct statfs64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +#endif /* !__DARWIN_ONLY_64_BIT_INO_T */ +int unmount(const char *, int); +int getvfsbyname(const char *, struct vfsconf *); +__END_DECLS + +#endif /* !_SYS_MOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/param.h b/lib/libc/include/aarch64-macos-gnu/sys/param.h new file mode 100644 index 0000000000..ee007bdd3e --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/param.h @@ -0,0 +1,235 @@ +/* + * 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) 1995, 1997 Apple Computer, Inc. All Rights Reserved */ +/*- + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)param.h 8.3 (Berkeley) 4/4/95 + */ + +#ifndef _SYS_PARAM_H_ +#define _SYS_PARAM_H_ + +#define BSD 199506 /* System version (year & month). */ +#define BSD4_3 1 +#define BSD4_4 1 + +#define NeXTBSD 1995064 /* NeXTBSD version (year, month, release) */ +#define NeXTBSD4_0 0 /* NeXTBSD 4.0 */ + +#include +#include + +#ifndef LOCORE +#include +#endif + +/* + * Machine-independent constants (some used in following include files). + * Redefined constants are from POSIX 1003.1 limits file. + * + * MAXCOMLEN should be >= sizeof(ac_comm) (see ) + * MAXLOGNAME should be >= UT_NAMESIZE (see ) + */ +#include + +#define MAXCOMLEN 16 /* max command name remembered */ +#define MAXINTERP 64 /* max interpreter file name length */ +#define MAXLOGNAME 255 /* max login name length */ +#define MAXUPRC CHILD_MAX /* max simultaneous processes */ +#define NCARGS ARG_MAX /* max bytes for an exec function */ +#define NGROUPS NGROUPS_MAX /* max number groups */ +#define NOFILE 256 /* default max open files per process */ +#define NOGROUP 65535 /* marker for empty group set member */ +#define MAXHOSTNAMELEN 256 /* max hostname size */ +#define MAXDOMNAMELEN 256 /* maximum domain name length */ + +/* Machine type dependent parameters. */ +#include + +/* More types and definitions used throughout the kernel. */ +#include + +/* Signals. */ +#include + +/* + * Priorities. Note that with 32 run queues, differences less than 4 are + * insignificant. + */ +#define PSWP 0 +#define PVM 4 +#define PINOD 8 +#define PRIBIO 16 +#define PVFS 20 +#define PZERO 22 /* No longer magic, shouldn't be here. XXX */ +#define PSOCK 24 +#define PWAIT 32 +#define PLOCK 36 +#define PPAUSE 40 +#define PUSER 50 +#define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */ + +#define PRIMASK 0x0ff +#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ +#define PTTYBLOCK 0x200 /* for tty SIGTTOU and SIGTTIN blocking */ +#define PDROP 0x400 /* OR'd with pri to stop re-aquistion of mutex upon wakeup */ +#define PSPIN 0x800 /* OR'd with pri to require mutex in spin mode upon wakeup */ + +#define NBPW sizeof(int) /* number of bytes per word (integer) */ + +#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ +#define NODEV (dev_t)(-1) /* non-existent device */ + +/* + * Clustering of hardware pages on machines with ridiculously small + * page sizes is done here. The paging subsystem deals with units of + * CLSIZE pte's describing NBPG (from machine/param.h) pages each. + */ +#define CLBYTES (CLSIZE*NBPG) +#define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */ +#define claligned(x) ((((int)(x))&CLOFSET)==0) +#define CLOFF CLOFSET +#define CLSHIFT (PGSHIFT+CLSIZELOG2) + +#if CLSIZE == 1 +#define clbase(i) (i) +#define clrnd(i) (i) +#else +/* Give the base virtual address (first of CLSIZE). */ +#define clbase(i) ((i) &~ (CLSIZE-1)) +/* Round a number of clicks up to a whole cluster. */ +#define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1)) +#endif + +#define CBLOCK 64 /* Clist block size, must be a power of 2. */ +#define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */ + /* Data chars/clist. */ +#define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) +#define CROUND (CBLOCK - 1) /* Clist rounding. */ + +/* + * File system parameters and macros. + * + * The file system is made out of blocks of at most MAXPHYS units, with + * smaller units (fragments) only in the last direct block. MAXBSIZE + * primarily determines the size of buffers in the buffer pool. It may be + * made larger than MAXPHYS without any effect on existing file systems; + * however making it smaller may make some file systems unmountable. + * We set this to track the value of MAX_UPL_TRANSFER_BYTES from + * osfmk/mach/memory_object_types.h to bound it at the maximum UPL size. + */ +#define MAXBSIZE (256 * 4096) +#define MAXPHYSIO MAXPHYS +#define MAXFRAG 8 + +#define MAXPHYSIO_WIRED (16 * 1024 * 1024) + +/* + * MAXPATHLEN defines the longest permissable path length after expanding + * symbolic links. It is used to allocate a temporary buffer from the buffer + * pool in which to do the name expansion, hence should be a power of two, + * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the + * maximum number of symbolic links that may be expanded in a path name. + * It should be set high enough to allow all legitimate uses, but halt + * infinite loops reasonably quickly. + */ +#define MAXPATHLEN PATH_MAX +#define MAXSYMLINKS 32 + +/* Bit map related macros. */ +#define setbit(a, i) (((unsigned char *)(a))[(i)/NBBY] |= 1u<<((i)%NBBY)) +#define clrbit(a, i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1u<<((i)%NBBY))) +#define isset(a, i) (((unsigned char *)(a))[(i)/NBBY] & (1u<<((i)%NBBY))) +#define isclr(a, i) ((((unsigned char *)(a))[(i)/NBBY] & (1u<<((i)%NBBY))) == 0) + +/* Macros for counting and rounding. */ +#ifndef howmany +#define howmany(x, y) ((((x) % (y)) == 0) ? ((x) / (y)) : (((x) / (y)) + 1)) +#endif +#define roundup(x, y) ((((x) % (y)) == 0) ? \ + (x) : ((x) + ((y) - ((x) % (y))))) +#define powerof2(x) ((((x)-1)&(x))==0) + +/* Macros for min/max. */ +#ifndef MIN +#define MIN(a, b) (((a)<(b))?(a):(b)) +#endif /* MIN */ +#ifndef MAX +#define MAX(a, b) (((a)>(b))?(a):(b)) +#endif /* MAX */ + +/* + * Scale factor for scaled integers used to count %cpu time and load avgs. + * + * The number of CPU `tick's that map to a unique `%age' can be expressed + * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that + * can be calculated (assuming 32 bits) can be closely approximated using + * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). + * + * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', + * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. + */ +#define FSHIFT 11 /* bits to right of fixed binary point */ +#define FSCALE (1< +#include +#include /* For struct selinfo. */ +#include +#include +#include +#include +#include +#include + + + +struct session; +struct pgrp; +struct proc; +struct proc_ident; + +/* Exported fields for kern sysctls */ +struct extern_proc { + union { + struct { + struct proc *__p_forw; /* Doubly-linked run/sleep queue. */ + struct proc *__p_back; + } p_st1; + struct timeval __p_starttime; /* process start time */ + } p_un; +#define p_forw p_un.p_st1.__p_forw +#define p_back p_un.p_st1.__p_back +#define p_starttime p_un.__p_starttime + struct vmspace *p_vmspace; /* Address space. */ + struct sigacts *p_sigacts; /* Signal actions, state (PROC ONLY). */ + int p_flag; /* P_* flags. */ + char p_stat; /* S* process status. */ + pid_t p_pid; /* Process identifier. */ + pid_t p_oppid; /* Save parent pid during ptrace. XXX */ + int p_dupfd; /* Sideways return value from fdopen. XXX */ + /* Mach related */ + caddr_t user_stack; /* where user stack was allocated */ + void *exit_thread; /* XXX Which thread is exiting? */ + int p_debugger; /* allow to debug */ + boolean_t sigwait; /* indication to suspend */ + /* scheduling */ + u_int p_estcpu; /* Time averaged value of p_cpticks. */ + int p_cpticks; /* Ticks of cpu time. */ + fixpt_t p_pctcpu; /* %cpu for this process during p_swtime */ + void *p_wchan; /* Sleep address. */ + char *p_wmesg; /* Reason for sleep. */ + u_int p_swtime; /* Time swapped in or out. */ + u_int p_slptime; /* Time since last blocked. */ + struct itimerval p_realtimer; /* Alarm timer. */ + struct timeval p_rtime; /* Real time. */ + u_quad_t p_uticks; /* Statclock hits in user mode. */ + u_quad_t p_sticks; /* Statclock hits in system mode. */ + u_quad_t p_iticks; /* Statclock hits processing intr. */ + int p_traceflag; /* Kernel trace points. */ + struct vnode *p_tracep; /* Trace to vnode. */ + int p_siglist; /* DEPRECATED. */ + struct vnode *p_textvp; /* Vnode of executable. */ + int p_holdcnt; /* If non-zero, don't swap. */ + sigset_t p_sigmask; /* DEPRECATED. */ + sigset_t p_sigignore; /* Signals being ignored. */ + sigset_t p_sigcatch; /* Signals being caught by user. */ + u_char p_priority; /* Process priority. */ + u_char p_usrpri; /* User-priority based on p_cpu and p_nice. */ + char p_nice; /* Process "nice" value. */ + char p_comm[MAXCOMLEN + 1]; + struct pgrp *p_pgrp; /* Pointer to process group. */ + struct user *p_addr; /* Kernel virtual addr of u-area (PROC ONLY). */ + u_short p_xstat; /* Exit status for wait; also stop signal. */ + u_short p_acflag; /* Accounting flags. */ + struct rusage *p_ru; /* Exit information. XXX */ +}; + + +/* Status values. */ +#define SIDL 1 /* Process being created by fork. */ +#define SRUN 2 /* Currently runnable. */ +#define SSLEEP 3 /* Sleeping on an address. */ +#define SSTOP 4 /* Process debugging or suspension. */ +#define SZOMB 5 /* Awaiting collection by parent. */ + +/* These flags are kept in extern_proc.p_flag. */ +#define P_ADVLOCK 0x00000001 /* Process may hold POSIX adv. lock */ +#define P_CONTROLT 0x00000002 /* Has a controlling terminal */ +#define P_LP64 0x00000004 /* Process is LP64 */ +#define P_NOCLDSTOP 0x00000008 /* No SIGCHLD when children stop */ + +#define P_PPWAIT 0x00000010 /* Parent waiting for chld exec/exit */ +#define P_PROFIL 0x00000020 /* Has started profiling */ +#define P_SELECT 0x00000040 /* Selecting; wakeup/waiting danger */ +#define P_CONTINUED 0x00000080 /* Process was stopped and continued */ + +#define P_SUGID 0x00000100 /* Has set privileges since last exec */ +#define P_SYSTEM 0x00000200 /* Sys proc: no sigs, stats or swap */ +#define P_TIMEOUT 0x00000400 /* Timing out during sleep */ +#define P_TRACED 0x00000800 /* Debugged process being traced */ + +#define P_DISABLE_ASLR 0x00001000 /* Disable address space layout randomization */ +#define P_WEXIT 0x00002000 /* Working on exiting */ +#define P_EXEC 0x00004000 /* Process called exec. */ + +/* Should be moved to machine-dependent areas. */ +#define P_OWEUPC 0x00008000 /* Owe process an addupc() call at next ast. */ + +#define P_AFFINITY 0x00010000 /* xxx */ +#define P_TRANSLATED 0x00020000 /* xxx */ +#define P_CLASSIC P_TRANSLATED /* xxx */ + +#define P_DELAYIDLESLEEP 0x00040000 /* Process is marked to delay idle sleep on disk IO */ +#define P_CHECKOPENEVT 0x00080000 /* check if a vnode has the OPENEVT flag set on open */ + +#define P_DEPENDENCY_CAPABLE 0x00100000 /* process is ok to call vfs_markdependency() */ +#define P_REBOOT 0x00200000 /* Process called reboot() */ +#define P_RESV6 0x00400000 /* used to be P_TBE */ +#define P_RESV7 0x00800000 /* (P_SIGEXC)signal exceptions */ + +#define P_THCWD 0x01000000 /* process has thread cwd */ +#define P_RESV9 0x02000000 /* (P_VFORK)process has vfork children */ +#define P_ADOPTPERSONA 0x04000000 /* process adopted a persona (used to be P_NOATTACH) */ +#define P_RESV11 0x08000000 /* (P_INVFORK) proc in vfork */ + +#define P_NOSHLIB 0x10000000 /* no shared libs are in use for proc */ + /* flag set on exec */ +#define P_FORCEQUOTA 0x20000000 /* Force quota for root */ +#define P_NOCLDWAIT 0x40000000 /* No zombies when chil procs exit */ +#define P_NOREMOTEHANG 0x80000000 /* Don't hang on remote FS ops */ + +#define P_INMEM 0 /* Obsolete: retained for compilation */ +#define P_NOSWAP 0 /* Obsolete: retained for compilation */ +#define P_PHYSIO 0 /* Obsolete: retained for compilation */ +#define P_FSTRACE 0 /* Obsolete: retained for compilation */ +#define P_SSTEP 0 /* Obsolete: retained for compilation */ + +#define P_DIRTY_TRACK 0x00000001 /* track dirty state */ +#define P_DIRTY_ALLOW_IDLE_EXIT 0x00000002 /* process can be idle-exited when clean */ +#define P_DIRTY_DEFER 0x00000004 /* defer initial opt-in to idle-exit */ +#define P_DIRTY 0x00000008 /* process is dirty */ +#define P_DIRTY_SHUTDOWN 0x00000010 /* process is dirty during shutdown */ +#define P_DIRTY_TERMINATED 0x00000020 /* process has been marked for termination */ +#define P_DIRTY_BUSY 0x00000040 /* serialization flag */ +#define P_DIRTY_MARKED 0x00000080 /* marked dirty previously */ +#define P_DIRTY_AGING_IN_PROGRESS 0x00000100 /* aging in one of the 'aging bands' */ +#define P_DIRTY_LAUNCH_IN_PROGRESS 0x00000200 /* launch is in progress */ +#define P_DIRTY_DEFER_ALWAYS 0x00000400 /* defer going to idle-exit after every dirty->clean transition. + * For legacy jetsam policy only. This is the default with the other policies.*/ + +#define P_DIRTY_IS_DIRTY (P_DIRTY | P_DIRTY_SHUTDOWN) +#define P_DIRTY_IDLE_EXIT_ENABLED (P_DIRTY_TRACK|P_DIRTY_ALLOW_IDLE_EXIT) + + + + +#endif /* !_SYS_PROC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/resource.h b/lib/libc/include/aarch64-macos-gnu/sys/resource.h new file mode 100644 index 0000000000..b8da0be04d --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/resource.h @@ -0,0 +1,512 @@ +/* + * Copyright (c) 2000-2018 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)resource.h 8.2 (Berkeley) 1/4/94 + */ + +#ifndef _SYS_RESOURCE_H_ +#define _SYS_RESOURCE_H_ + +#include +#include +#include + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#include +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ + +#include + +/* [XSI] The timeval structure shall be defined as described in + * + */ +#include + +/* The id_t type shall be defined as described in */ +#include + + +/* + * Resource limit type (low 63 bits, excluding the sign bit) + */ +typedef __uint64_t rlim_t; + + +/***** + * PRIORITY + */ + +/* + * Possible values of the first parameter to getpriority()/setpriority(), + * used to indicate the type of the second parameter. + */ +#define PRIO_PROCESS 0 /* Second argument is a PID */ +#define PRIO_PGRP 1 /* Second argument is a GID */ +#define PRIO_USER 2 /* Second argument is a UID */ + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#define PRIO_DARWIN_THREAD 3 /* Second argument is always 0 (current thread) */ +#define PRIO_DARWIN_PROCESS 4 /* Second argument is a PID */ + + +/* + * Range limitations for the value of the third parameter to setpriority(). + */ +#define PRIO_MIN -20 +#define PRIO_MAX 20 + +/* + * use PRIO_DARWIN_BG to set the current thread into "background" state + * which lowers CPU, disk IO, and networking priorites until thread terminates + * or "background" state is revoked + */ +#define PRIO_DARWIN_BG 0x1000 + +/* + * use PRIO_DARWIN_NONUI to restrict a process's ability to make calls to + * the GPU. (deprecated) + */ +#define PRIO_DARWIN_NONUI 0x1001 + +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ + + + +/***** + * RESOURCE USAGE + */ + +/* + * Possible values of the first parameter to getrusage(), used to indicate + * the scope of the information to be returned. + */ +#define RUSAGE_SELF 0 /* Current process information */ +#define RUSAGE_CHILDREN -1 /* Current process' children */ + +/* + * A structure representing an accounting of resource utilization. The + * address of an instance of this structure is the second parameter to + * getrusage(). + * + * Note: All values other than ru_utime and ru_stime are implementaiton + * defined and subject to change in a future release. Their use + * is discouraged for standards compliant programs. + */ +struct rusage { + struct timeval ru_utime; /* user time used (PL) */ + struct timeval ru_stime; /* system time used (PL) */ +#if __DARWIN_C_LEVEL < __DARWIN_C_FULL + long ru_opaque[14]; /* implementation defined */ +#else + /* + * Informational aliases for source compatibility with programs + * that need more information than that provided by standards, + * and which do not mind being OS-dependent. + */ + long ru_maxrss; /* max resident set size (PL) */ +#define ru_first ru_ixrss /* internal: ruadd() range start */ + long ru_ixrss; /* integral shared memory size (NU) */ + long ru_idrss; /* integral unshared data (NU) */ + long ru_isrss; /* integral unshared stack (NU) */ + long ru_minflt; /* page reclaims (NU) */ + long ru_majflt; /* page faults (NU) */ + long ru_nswap; /* swaps (NU) */ + long ru_inblock; /* block input operations (atomic) */ + long ru_oublock; /* block output operations (atomic) */ + long ru_msgsnd; /* messages sent (atomic) */ + long ru_msgrcv; /* messages received (atomic) */ + long ru_nsignals; /* signals received (atomic) */ + long ru_nvcsw; /* voluntary context switches (atomic) */ + long ru_nivcsw; /* involuntary " */ +#define ru_last ru_nivcsw /* internal: ruadd() range end */ +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ +}; + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +/* + * Flavors for proc_pid_rusage(). + */ +#define RUSAGE_INFO_V0 0 +#define RUSAGE_INFO_V1 1 +#define RUSAGE_INFO_V2 2 +#define RUSAGE_INFO_V3 3 +#define RUSAGE_INFO_V4 4 +#define RUSAGE_INFO_V5 5 +#define RUSAGE_INFO_CURRENT RUSAGE_INFO_V5 + +/* + * Flags for RUSAGE_INFO_V5 + */ +#define RU_PROC_RUNS_RESLIDE 0x00000001 /* proc has reslid shared cache */ + +typedef void *rusage_info_t; + +struct rusage_info_v0 { + uint8_t ri_uuid[16]; + uint64_t ri_user_time; + uint64_t ri_system_time; + uint64_t ri_pkg_idle_wkups; + uint64_t ri_interrupt_wkups; + uint64_t ri_pageins; + uint64_t ri_wired_size; + uint64_t ri_resident_size; + uint64_t ri_phys_footprint; + uint64_t ri_proc_start_abstime; + uint64_t ri_proc_exit_abstime; +}; + +struct rusage_info_v1 { + uint8_t ri_uuid[16]; + uint64_t ri_user_time; + uint64_t ri_system_time; + uint64_t ri_pkg_idle_wkups; + uint64_t ri_interrupt_wkups; + uint64_t ri_pageins; + uint64_t ri_wired_size; + uint64_t ri_resident_size; + uint64_t ri_phys_footprint; + uint64_t ri_proc_start_abstime; + uint64_t ri_proc_exit_abstime; + uint64_t ri_child_user_time; + uint64_t ri_child_system_time; + uint64_t ri_child_pkg_idle_wkups; + uint64_t ri_child_interrupt_wkups; + uint64_t ri_child_pageins; + uint64_t ri_child_elapsed_abstime; +}; + +struct rusage_info_v2 { + uint8_t ri_uuid[16]; + uint64_t ri_user_time; + uint64_t ri_system_time; + uint64_t ri_pkg_idle_wkups; + uint64_t ri_interrupt_wkups; + uint64_t ri_pageins; + uint64_t ri_wired_size; + uint64_t ri_resident_size; + uint64_t ri_phys_footprint; + uint64_t ri_proc_start_abstime; + uint64_t ri_proc_exit_abstime; + uint64_t ri_child_user_time; + uint64_t ri_child_system_time; + uint64_t ri_child_pkg_idle_wkups; + uint64_t ri_child_interrupt_wkups; + uint64_t ri_child_pageins; + uint64_t ri_child_elapsed_abstime; + uint64_t ri_diskio_bytesread; + uint64_t ri_diskio_byteswritten; +}; + +struct rusage_info_v3 { + uint8_t ri_uuid[16]; + uint64_t ri_user_time; + uint64_t ri_system_time; + uint64_t ri_pkg_idle_wkups; + uint64_t ri_interrupt_wkups; + uint64_t ri_pageins; + uint64_t ri_wired_size; + uint64_t ri_resident_size; + uint64_t ri_phys_footprint; + uint64_t ri_proc_start_abstime; + uint64_t ri_proc_exit_abstime; + uint64_t ri_child_user_time; + uint64_t ri_child_system_time; + uint64_t ri_child_pkg_idle_wkups; + uint64_t ri_child_interrupt_wkups; + uint64_t ri_child_pageins; + uint64_t ri_child_elapsed_abstime; + uint64_t ri_diskio_bytesread; + uint64_t ri_diskio_byteswritten; + uint64_t ri_cpu_time_qos_default; + uint64_t ri_cpu_time_qos_maintenance; + uint64_t ri_cpu_time_qos_background; + uint64_t ri_cpu_time_qos_utility; + uint64_t ri_cpu_time_qos_legacy; + uint64_t ri_cpu_time_qos_user_initiated; + uint64_t ri_cpu_time_qos_user_interactive; + uint64_t ri_billed_system_time; + uint64_t ri_serviced_system_time; +}; + +struct rusage_info_v4 { + uint8_t ri_uuid[16]; + uint64_t ri_user_time; + uint64_t ri_system_time; + uint64_t ri_pkg_idle_wkups; + uint64_t ri_interrupt_wkups; + uint64_t ri_pageins; + uint64_t ri_wired_size; + uint64_t ri_resident_size; + uint64_t ri_phys_footprint; + uint64_t ri_proc_start_abstime; + uint64_t ri_proc_exit_abstime; + uint64_t ri_child_user_time; + uint64_t ri_child_system_time; + uint64_t ri_child_pkg_idle_wkups; + uint64_t ri_child_interrupt_wkups; + uint64_t ri_child_pageins; + uint64_t ri_child_elapsed_abstime; + uint64_t ri_diskio_bytesread; + uint64_t ri_diskio_byteswritten; + uint64_t ri_cpu_time_qos_default; + uint64_t ri_cpu_time_qos_maintenance; + uint64_t ri_cpu_time_qos_background; + uint64_t ri_cpu_time_qos_utility; + uint64_t ri_cpu_time_qos_legacy; + uint64_t ri_cpu_time_qos_user_initiated; + uint64_t ri_cpu_time_qos_user_interactive; + uint64_t ri_billed_system_time; + uint64_t ri_serviced_system_time; + uint64_t ri_logical_writes; + uint64_t ri_lifetime_max_phys_footprint; + uint64_t ri_instructions; + uint64_t ri_cycles; + uint64_t ri_billed_energy; + uint64_t ri_serviced_energy; + uint64_t ri_interval_max_phys_footprint; + uint64_t ri_runnable_time; +}; + +struct rusage_info_v5 { + uint8_t ri_uuid[16]; + uint64_t ri_user_time; + uint64_t ri_system_time; + uint64_t ri_pkg_idle_wkups; + uint64_t ri_interrupt_wkups; + uint64_t ri_pageins; + uint64_t ri_wired_size; + uint64_t ri_resident_size; + uint64_t ri_phys_footprint; + uint64_t ri_proc_start_abstime; + uint64_t ri_proc_exit_abstime; + uint64_t ri_child_user_time; + uint64_t ri_child_system_time; + uint64_t ri_child_pkg_idle_wkups; + uint64_t ri_child_interrupt_wkups; + uint64_t ri_child_pageins; + uint64_t ri_child_elapsed_abstime; + uint64_t ri_diskio_bytesread; + uint64_t ri_diskio_byteswritten; + uint64_t ri_cpu_time_qos_default; + uint64_t ri_cpu_time_qos_maintenance; + uint64_t ri_cpu_time_qos_background; + uint64_t ri_cpu_time_qos_utility; + uint64_t ri_cpu_time_qos_legacy; + uint64_t ri_cpu_time_qos_user_initiated; + uint64_t ri_cpu_time_qos_user_interactive; + uint64_t ri_billed_system_time; + uint64_t ri_serviced_system_time; + uint64_t ri_logical_writes; + uint64_t ri_lifetime_max_phys_footprint; + uint64_t ri_instructions; + uint64_t ri_cycles; + uint64_t ri_billed_energy; + uint64_t ri_serviced_energy; + uint64_t ri_interval_max_phys_footprint; + uint64_t ri_runnable_time; + uint64_t ri_flags; +}; + +typedef struct rusage_info_v5 rusage_info_current; + +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ + + + +/***** + * RESOURCE LIMITS + */ + +/* + * Symbolic constants for resource limits; since all limits are representable + * as a type rlim_t, we are permitted to define RLIM_SAVED_* in terms of + * RLIM_INFINITY. + */ +#define RLIM_INFINITY (((__uint64_t)1 << 63) - 1) /* no limit */ +#define RLIM_SAVED_MAX RLIM_INFINITY /* Unrepresentable hard limit */ +#define RLIM_SAVED_CUR RLIM_INFINITY /* Unrepresentable soft limit */ + +/* + * Possible values of the first parameter to getrlimit()/setrlimit(), to + * indicate for which resource the operation is being performed. + */ +#define RLIMIT_CPU 0 /* cpu time per process */ +#define RLIMIT_FSIZE 1 /* file size */ +#define RLIMIT_DATA 2 /* data segment size */ +#define RLIMIT_STACK 3 /* stack size */ +#define RLIMIT_CORE 4 /* core file size */ +#define RLIMIT_AS 5 /* address space (resident set size) */ +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#define RLIMIT_RSS RLIMIT_AS /* source compatibility alias */ +#define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ +#define RLIMIT_NPROC 7 /* number of processes */ +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ +#define RLIMIT_NOFILE 8 /* number of open files */ +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +#define RLIM_NLIMITS 9 /* total number of resource limits */ +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ +#define _RLIMIT_POSIX_FLAG 0x1000 /* Set bit for strict POSIX */ + +/* + * A structure representing a resource limit. The address of an instance + * of this structure is the second parameter to getrlimit()/setrlimit(). + */ +struct rlimit { + rlim_t rlim_cur; /* current (soft) limit */ + rlim_t rlim_max; /* maximum value for rlim_cur */ +}; + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +/* + * proc_rlimit_control() + * + * Resource limit flavors + */ +#define RLIMIT_WAKEUPS_MONITOR 0x1 /* Configure the wakeups monitor. */ +#define RLIMIT_CPU_USAGE_MONITOR 0x2 /* Configure the CPU usage monitor. */ +#define RLIMIT_THREAD_CPULIMITS 0x3 /* Configure a blocking, per-thread, CPU limits. */ +#define RLIMIT_FOOTPRINT_INTERVAL 0x4 /* Configure memory footprint interval tracking */ + +/* + * Flags for wakeups monitor control. + */ +#define WAKEMON_ENABLE 0x01 +#define WAKEMON_DISABLE 0x02 +#define WAKEMON_GET_PARAMS 0x04 +#define WAKEMON_SET_DEFAULTS 0x08 +#define WAKEMON_MAKE_FATAL 0x10 /* Configure the task so that violations are fatal. */ + +/* + * Flags for CPU usage monitor control. + */ +#define CPUMON_MAKE_FATAL 0x1000 + +/* + * Flags for memory footprint interval tracking. + */ +#define FOOTPRINT_INTERVAL_RESET 0x1 /* Reset the footprint interval counter to zero */ + +struct proc_rlimit_control_wakeupmon { + uint32_t wm_flags; + int32_t wm_rate; +}; + + + +/* I/O type */ +#define IOPOL_TYPE_DISK 0 +#define IOPOL_TYPE_VFS_ATIME_UPDATES 2 +#define IOPOL_TYPE_VFS_MATERIALIZE_DATALESS_FILES 3 +#define IOPOL_TYPE_VFS_STATFS_NO_DATA_VOLUME 4 +#define IOPOL_TYPE_VFS_TRIGGER_RESOLVE 5 +#define IOPOL_TYPE_VFS_IGNORE_CONTENT_PROTECTION 6 + +/* scope */ +#define IOPOL_SCOPE_PROCESS 0 +#define IOPOL_SCOPE_THREAD 1 +#define IOPOL_SCOPE_DARWIN_BG 2 + +/* I/O Priority */ +#define IOPOL_DEFAULT 0 +#define IOPOL_IMPORTANT 1 +#define IOPOL_PASSIVE 2 +#define IOPOL_THROTTLE 3 +#define IOPOL_UTILITY 4 +#define IOPOL_STANDARD 5 + +/* compatibility with older names */ +#define IOPOL_APPLICATION IOPOL_STANDARD +#define IOPOL_NORMAL IOPOL_IMPORTANT + + +#define IOPOL_ATIME_UPDATES_DEFAULT 0 +#define IOPOL_ATIME_UPDATES_OFF 1 + +#define IOPOL_MATERIALIZE_DATALESS_FILES_DEFAULT 0 +#define IOPOL_MATERIALIZE_DATALESS_FILES_OFF 1 +#define IOPOL_MATERIALIZE_DATALESS_FILES_ON 2 + +#define IOPOL_VFS_STATFS_NO_DATA_VOLUME_DEFAULT 0 +#define IOPOL_VFS_STATFS_FORCE_NO_DATA_VOLUME 1 + +#define IOPOL_VFS_TRIGGER_RESOLVE_DEFAULT 0 +#define IOPOL_VFS_TRIGGER_RESOLVE_OFF 1 + +#define IOPOL_VFS_CONTENT_PROTECTION_DEFAULT 0 +#define IOPOL_VFS_CONTENT_PROTECTION_IGNORE 1 + +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ + + +__BEGIN_DECLS +int getpriority(int, id_t); +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ +int getrlimit(int, struct rlimit *) __DARWIN_ALIAS(getrlimit); +int getrusage(int, struct rusage *); +int setpriority(int, id_t, int); +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +int setiopolicy_np(int, int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ +int setrlimit(int, const struct rlimit *) __DARWIN_ALIAS(setrlimit); +__END_DECLS + +#endif /* !_SYS_RESOURCE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/shm.h b/lib/libc/include/aarch64-macos-gnu/sys/shm.h new file mode 100644 index 0000000000..4c34bf4dc7 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/shm.h @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $ */ + +/* + * Copyright (c) 1994 Adam Glass + * 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 Adam Glass. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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. + */ + +/* + * As defined+described in "X/Open System Interfaces and Headers" + * Issue 4, p. XXX + */ + +#ifndef _SYS_SHM_H_ +#define _SYS_SHM_H_ + +#include +#include + +/* + * [XSI] All of the symbols from SHALL be defined + * when this header is included + */ +#include + +/* + * [XSI] The pid_t, time_t, key_t, and size_t types shall be defined as + * described in . + * + * NOTE: The definition of the key_t type is implicit from the + * inclusion of + */ +#include +#include +#include + +/* + * [XSI] The unsigned integer type used for the number of current attaches + * that MUST be able to store values at least as large as a type unsigned + * short. + */ +typedef unsigned short shmatt_t; + + +/* + * Possible flag values which may be OR'ed into the third argument to + * shmat() + */ +#define SHM_RDONLY 010000 /* [XSI] Attach read-only (else read-write) */ +#define SHM_RND 020000 /* [XSI] Round attach address to SHMLBA */ + +/* + * This value is symbolic, and generally not expected to be sed by user + * programs directly, although such ise is permitted by the standard. Its + * value in our implementation is equal to the number of bytes per page. + * + * NOTE: We DO NOT obtain this value from the appropriate system + * headers at this time, to avoid the resulting namespace + * pollution, which is why we discourages its use. + */ +#if __arm64__ +#define SHMLBA (16*1024) /* [XSI] Segment low boundary address multiple*/ +#else /* __arm64__ */ +#define SHMLBA 4096 /* [XSI] Segment low boundary address multiple*/ +#endif /* __arm64__ */ + +/* "official" access mode definitions; somewhat braindead since you have + * to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */ +#define SHM_R (IPC_R) +#define SHM_W (IPC_W) + +#pragma pack(4) + +/* + * Technically, we should force all code references to the new structure + * definition, not in just the standards conformance case, and leave the + * legacy interface there for binary compatibility only. Currently, we + * are only forcing this for programs requesting standards conformance. + */ +#if __DARWIN_UNIX03 || defined(KERNEL) +/* + * Structure used internally. + * + * This structure is exposed because standards dictate that it is used as + * the third argment to shmctl(). + * + * NOTE: The field shm_internal is not meaningful in user space, + * and must not be used there. + */ +#if (defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE)) +struct shmid_ds +#else +#define shmid_ds __shmid_ds_new +struct __shmid_ds_new +#endif +{ + struct __ipc_perm_new shm_perm; /* [XSI] Operation permission value */ + size_t shm_segsz; /* [XSI] Size of segment in bytes */ + pid_t shm_lpid; /* [XSI] PID of last shared memory op */ + pid_t shm_cpid; /* [XSI] PID of creator */ + shmatt_t shm_nattch; /* [XSI] Number of current attaches */ + time_t shm_atime; /* [XSI] Time of last shmat() */ + time_t shm_dtime; /* [XSI] Time of last shmdt() */ + time_t shm_ctime; /* [XSI] Time of last shmctl() change */ + void *shm_internal; /* reserved for kernel use */ +}; +#else /* !__DARWIN_UNIX03 */ +#define shmid_ds __shmid_ds_old +#endif /* !__DARWIN_UNIX03 */ + +#if !__DARWIN_UNIX03 +struct __shmid_ds_old { + struct __ipc_perm_old shm_perm; /* [XSI] Operation permission value */ + size_t shm_segsz; /* [XSI] Size of segment in bytes */ + pid_t shm_lpid; /* [XSI] PID of last shared memory op */ + pid_t shm_cpid; /* [XSI] PID of creator */ + shmatt_t shm_nattch; /* [XSI] Number of current attaches */ + time_t shm_atime; /* [XSI] Time of last shmat() */ + time_t shm_dtime; /* [XSI] Time of last shmdt() */ + time_t shm_ctime; /* [XSI] Time of last shmctl() change */ + void *shm_internal; /* reserved for kernel use */ +}; +#endif /* !__DARWIN_UNIX03 */ + +#pragma pack() + + +__BEGIN_DECLS +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +int shmsys(int, ...); +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +void *shmat(int, const void *, int); +int shmctl(int, int, struct shmid_ds *) __DARWIN_ALIAS(shmctl); +int shmdt(const void *); +int shmget(key_t, size_t, int); +__END_DECLS + + +#endif /* !_SYS_SHM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/socket.h b/lib/libc/include/aarch64-macos-gnu/sys/socket.h new file mode 100644 index 0000000000..0c6b09babe --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/socket.h @@ -0,0 +1,741 @@ +/* + * Copyright (c) 2000-2019 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1998, 1999 Apple Computer, Inc. All Rights Reserved */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)socket.h 8.4 (Berkeley) 2/21/94 + * $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $ + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ + +#ifndef _SYS_SOCKET_H_ +#define _SYS_SOCKET_H_ + +#include +#include +#include +#include + + +#include + +/* + * Definitions related to sockets: types, address families, options. + */ + +/* + * Data types. + */ + +#include +#include +#include +#include +#include + +/* XXX Not explicitly defined by POSIX, but function return types are */ +#include + +/* XXX Not explicitly defined by POSIX, but function return types are */ +#include + +/* + * [XSI] The iovec structure shall be defined as described in . + */ +#include + +/* + * Types + */ +#define SOCK_STREAM 1 /* stream socket */ +#define SOCK_DGRAM 2 /* datagram socket */ +#define SOCK_RAW 3 /* raw-protocol interface */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SOCK_RDM 4 /* reliably-delivered message */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define SOCK_SEQPACKET 5 /* sequenced packet stream */ + +/* + * Option flags per-socket. + */ +#define SO_DEBUG 0x0001 /* turn on debugging info recording */ +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ +#define SO_REUSEADDR 0x0004 /* allow local address reuse */ +#define SO_KEEPALIVE 0x0008 /* keep connections alive */ +#define SO_DONTROUTE 0x0010 /* just use interface addresses */ +#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ +#define SO_LINGER 0x0080 /* linger on close if data present (in ticks) */ +#else +#define SO_LINGER 0x1080 /* linger on close if data present (in seconds) */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ +#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ +#define SO_TIMESTAMP_MONOTONIC 0x0800 /* Monotonically increasing timestamp on rcvd dgram */ +#ifndef __APPLE__ +#define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ +#else +#define SO_DONTTRUNC 0x2000 /* APPLE: Retain unread data */ + /* (ATOMIC proto) */ +#define SO_WANTMORE 0x4000 /* APPLE: Give hint when more data ready */ +#define SO_WANTOOBFLAG 0x8000 /* APPLE: Want OOB in MSG_FLAG on receive */ + + +#endif /* (!__APPLE__) */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Additional options, not kept in so_options. + */ +#define SO_SNDBUF 0x1001 /* send buffer size */ +#define SO_RCVBUF 0x1002 /* receive buffer size */ +#define SO_SNDLOWAT 0x1003 /* send low-water mark */ +#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ +#define SO_SNDTIMEO 0x1005 /* send timeout */ +#define SO_RCVTIMEO 0x1006 /* receive timeout */ +#define SO_ERROR 0x1007 /* get error status and clear */ +#define SO_TYPE 0x1008 /* get socket type */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SO_LABEL 0x1010 /* deprecated */ +#define SO_PEERLABEL 0x1011 /* deprecated */ +#ifdef __APPLE__ +#define SO_NREAD 0x1020 /* APPLE: get 1st-packet byte count */ +#define SO_NKE 0x1021 /* APPLE: Install socket-level NKE */ +#define SO_NOSIGPIPE 0x1022 /* APPLE: No SIGPIPE on EPIPE */ +#define SO_NOADDRERR 0x1023 /* APPLE: Returns EADDRNOTAVAIL when src is not available anymore */ +#define SO_NWRITE 0x1024 /* APPLE: Get number of bytes currently in send socket buffer */ +#define SO_REUSESHAREUID 0x1025 /* APPLE: Allow reuse of port/socket by different userids */ +#ifdef __APPLE_API_PRIVATE +#define SO_NOTIFYCONFLICT 0x1026 /* APPLE: send notification if there is a bind on a port which is already in use */ +#define SO_UPCALLCLOSEWAIT 0x1027 /* APPLE: block on close until an upcall returns */ +#endif +#define SO_LINGER_SEC 0x1080 /* linger on close if data present (in seconds) */ +#define SO_RANDOMPORT 0x1082 /* APPLE: request local port randomization */ +#define SO_NP_EXTENSIONS 0x1083 /* To turn off some POSIX behavior */ +#endif + +#define SO_NUMRCVPKT 0x1112 /* number of datagrams in receive socket buffer */ +#define SO_NET_SERVICE_TYPE 0x1116 /* Network service type */ + + +#define SO_NETSVC_MARKING_LEVEL 0x1119 /* Get QoS marking in effect for socket */ + +/* + * Network Service Type for option SO_NET_SERVICE_TYPE + * + * The vast majority of sockets should use Best Effort that is the default + * Network Service Type. Other Network Service Types have to be used only if + * the traffic actually matches the description of the Network Service Type. + * + * Network Service Types do not represent priorities but rather describe + * different categories of delay, jitter and loss parameters. + * Those parameters may influence protocols from layer 4 protocols like TCP + * to layer 2 protocols like Wi-Fi. The Network Service Type can determine + * how the traffic is queued and scheduled by the host networking stack and + * by other entities on the network like switches and routers. For example + * for Wi-Fi, the Network Service Type can select the marking of the + * layer 2 packet with the appropriate WMM Access Category. + * + * There is no point in attempting to game the system and use + * a Network Service Type that does not correspond to the actual + * traffic characteristic but one that seems to have a higher precedence. + * The reason is that for service classes that have lower tolerance + * for delay and jitter, the queues size is lower than for service + * classes that are more tolerant to delay and jitter. + * + * For example using a voice service type for bulk data transfer will lead + * to disastrous results as soon as congestion happens because the voice + * queue overflows and packets get dropped. This is not only bad for the bulk + * data transfer but it is also bad for VoIP apps that legitimately are using + * the voice service type. + * + * The characteristics of the Network Service Types are based on the service + * classes defined in RFC 4594 "Configuration Guidelines for DiffServ Service + * Classes" + * + * When system detects the outgoing interface belongs to a DiffServ domain + * that follows the recommendation of the IETF draft "Guidelines for DiffServ to + * IEEE 802.11 Mapping", the packet will marked at layer 3 with a DSCP value + * that corresponds to Network Service Type. + * + * NET_SERVICE_TYPE_BE + * "Best Effort", unclassified/standard. This is the default service + * class and cover the majority of the traffic. + * + * NET_SERVICE_TYPE_BK + * "Background", high delay tolerant, loss tolerant. elastic flow, + * variable size & long-lived. E.g: non-interactive network bulk transfer + * like synching or backup. + * + * NET_SERVICE_TYPE_RD + * "Responsive Data", a notch higher than "Best Effort", medium delay + * tolerant, elastic & inelastic flow, bursty, long-lived. E.g. email, + * instant messaging, for which there is a sense of interactivity and + * urgency (user waiting for output). + * + * NET_SERVICE_TYPE_OAM + * "Operations, Administration, and Management", medium delay tolerant, + * low-medium loss tolerant, elastic & inelastic flows, variable size. + * E.g. VPN tunnels. + * + * NET_SERVICE_TYPE_AV + * "Multimedia Audio/Video Streaming", medium delay tolerant, low-medium + * loss tolerant, elastic flow, constant packet interval, variable rate + * and size. E.g. video and audio playback with buffering. + * + * NET_SERVICE_TYPE_RV + * "Responsive Multimedia Audio/Video", low delay tolerant, low-medium + * loss tolerant, elastic flow, variable packet interval, rate and size. + * E.g. screen sharing. + * + * NET_SERVICE_TYPE_VI + * "Interactive Video", low delay tolerant, low-medium loss tolerant, + * elastic flow, constant packet interval, variable rate & size. E.g. + * video telephony. + * + * NET_SERVICE_TYPE_SIG + * "Signaling", low delay tolerant, low loss tolerant, inelastic flow, + * jitter tolerant, rate is bursty but short, variable size. E.g. SIP. + * + * NET_SERVICE_TYPE_VO + * "Interactive Voice", very low delay tolerant, very low loss tolerant, + * inelastic flow, constant packet rate, somewhat fixed size. + * E.g. VoIP. + */ + +#define NET_SERVICE_TYPE_BE 0 /* Best effort */ +#define NET_SERVICE_TYPE_BK 1 /* Background system initiated */ +#define NET_SERVICE_TYPE_SIG 2 /* Signaling */ +#define NET_SERVICE_TYPE_VI 3 /* Interactive Video */ +#define NET_SERVICE_TYPE_VO 4 /* Interactive Voice */ +#define NET_SERVICE_TYPE_RV 5 /* Responsive Multimedia Audio/Video */ +#define NET_SERVICE_TYPE_AV 6 /* Multimedia Audio/Video Streaming */ +#define NET_SERVICE_TYPE_OAM 7 /* Operations, Administration, and Management */ +#define NET_SERVICE_TYPE_RD 8 /* Responsive Data */ + + +/* These are supported values for SO_NETSVC_MARKING_LEVEL */ +#define NETSVC_MRKNG_UNKNOWN 0 /* The outgoing network interface is not known */ +#define NETSVC_MRKNG_LVL_L2 1 /* Default marking at layer 2 (for example Wi-Fi WMM) */ +#define NETSVC_MRKNG_LVL_L3L2_ALL 2 /* Layer 3 DSCP marking and layer 2 marking for all Network Service Types */ +#define NETSVC_MRKNG_LVL_L3L2_BK 3 /* The system policy limits layer 3 DSCP marking and layer 2 marking + * to background Network Service Types */ + + +typedef __uint32_t sae_associd_t; +#define SAE_ASSOCID_ANY 0 +#define SAE_ASSOCID_ALL ((sae_associd_t)(-1ULL)) + +typedef __uint32_t sae_connid_t; +#define SAE_CONNID_ANY 0 +#define SAE_CONNID_ALL ((sae_connid_t)(-1ULL)) + +/* connectx() flag parameters */ +#define CONNECT_RESUME_ON_READ_WRITE 0x1 /* resume connect() on read/write */ +#define CONNECT_DATA_IDEMPOTENT 0x2 /* data is idempotent */ +#define CONNECT_DATA_AUTHENTICATED 0x4 /* data includes security that replaces the TFO-cookie */ + +/* sockaddr endpoints */ +typedef struct sa_endpoints { + unsigned int sae_srcif; /* optional source interface */ + const struct sockaddr *sae_srcaddr; /* optional source address */ + socklen_t sae_srcaddrlen; /* size of source address */ + const struct sockaddr *sae_dstaddr; /* destination address */ + socklen_t sae_dstaddrlen; /* size of destination address */ +} sa_endpoints_t; +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Structure used for manipulating linger option. + */ +struct linger { + int l_onoff; /* option on/off */ + int l_linger; /* linger time */ +}; + +#ifndef __APPLE__ +struct accept_filter_arg { + char af_name[16]; + char af_arg[256 - 16]; +}; +#endif + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifdef __APPLE__ + +/* + * Structure to control non-portable Sockets extension to POSIX + */ +struct so_np_extensions { + u_int32_t npx_flags; + u_int32_t npx_mask; +}; + +#define SONPX_SETOPTSHUT 0x000000001 /* flag for allowing setsockopt after shutdown */ + + + +#endif +#endif + +/* + * Level number for (get/set)sockopt() to apply to socket itself. + */ +#define SOL_SOCKET 0xffff /* options for socket level */ + + +/* + * Address families. + */ +#define AF_UNSPEC 0 /* unspecified */ +#define AF_UNIX 1 /* local to host (pipes) */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define AF_LOCAL AF_UNIX /* backward compatibility */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define AF_IMPLINK 3 /* arpanet imp addresses */ +#define AF_PUP 4 /* pup protocols: e.g. BSP */ +#define AF_CHAOS 5 /* mit CHAOS protocols */ +#define AF_NS 6 /* XEROX NS protocols */ +#define AF_ISO 7 /* ISO protocols */ +#define AF_OSI AF_ISO +#define AF_ECMA 8 /* European computer manufacturers */ +#define AF_DATAKIT 9 /* datakit protocols */ +#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ +#define AF_SNA 11 /* IBM SNA */ +#define AF_DECnet 12 /* DECnet */ +#define AF_DLI 13 /* DEC Direct data link interface */ +#define AF_LAT 14 /* LAT */ +#define AF_HYLINK 15 /* NSC Hyperchannel */ +#define AF_APPLETALK 16 /* Apple Talk */ +#define AF_ROUTE 17 /* Internal Routing Protocol */ +#define AF_LINK 18 /* Link layer interface */ +#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ +#define AF_COIP 20 /* connection-oriented IP, aka ST II */ +#define AF_CNT 21 /* Computer Network Technology */ +#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ +#define AF_IPX 23 /* Novell Internet Protocol */ +#define AF_SIP 24 /* Simple Internet Protocol */ +#define pseudo_AF_PIP 25 /* Help Identify PIP packets */ +#define AF_NDRV 27 /* Network Driver 'raw' access */ +#define AF_ISDN 28 /* Integrated Services Digital Network */ +#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ +#define pseudo_AF_KEY 29 /* Internal key-management function */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +#define AF_INET6 30 /* IPv6 */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define AF_NATM 31 /* native ATM access */ +#define AF_SYSTEM 32 /* Kernel event messages */ +#define AF_NETBIOS 33 /* NetBIOS */ +#define AF_PPP 34 /* PPP communication protocol */ +#define pseudo_AF_HDRCMPLT 35 /* Used by BPF to not rewrite headers + * in interface output routine */ +#define AF_RESERVED_36 36 /* Reserved for internal usage */ +#define AF_IEEE80211 37 /* IEEE 802.11 protocol */ +#define AF_UTUN 38 +#define AF_VSOCK 40 /* VM Sockets */ +#define AF_MAX 41 +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * [XSI] Structure used by kernel to store most addresses. + */ +struct sockaddr { + __uint8_t sa_len; /* total length */ + sa_family_t sa_family; /* [XSI] address family */ + char sa_data[14]; /* [XSI] addr value (actually larger) */ +}; + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SOCK_MAXADDRLEN 255 /* longest possible addresses */ + +/* + * Structure used by kernel to pass protocol + * information in raw sockets. + */ +struct sockproto { + __uint16_t sp_family; /* address family */ + __uint16_t sp_protocol; /* protocol */ +}; +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * RFC 2553: protocol-independent placeholder for socket addresses + */ +#define _SS_MAXSIZE 128 +#define _SS_ALIGNSIZE (sizeof(__int64_t)) +#define _SS_PAD1SIZE \ + (_SS_ALIGNSIZE - sizeof(__uint8_t) - sizeof(sa_family_t)) +#define _SS_PAD2SIZE \ + (_SS_MAXSIZE - sizeof(__uint8_t) - sizeof(sa_family_t) - \ + _SS_PAD1SIZE - _SS_ALIGNSIZE) + +/* + * [XSI] sockaddr_storage + */ +struct sockaddr_storage { + __uint8_t ss_len; /* address length */ + sa_family_t ss_family; /* [XSI] address family */ + char __ss_pad1[_SS_PAD1SIZE]; + __int64_t __ss_align; /* force structure storage alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; + +/* + * Protocol families, same as address families for now. + */ +#define PF_UNSPEC AF_UNSPEC +#define PF_LOCAL AF_LOCAL +#define PF_UNIX PF_LOCAL /* backward compatibility */ +#define PF_INET AF_INET +#define PF_IMPLINK AF_IMPLINK +#define PF_PUP AF_PUP +#define PF_CHAOS AF_CHAOS +#define PF_NS AF_NS +#define PF_ISO AF_ISO +#define PF_OSI AF_ISO +#define PF_ECMA AF_ECMA +#define PF_DATAKIT AF_DATAKIT +#define PF_CCITT AF_CCITT +#define PF_SNA AF_SNA +#define PF_DECnet AF_DECnet +#define PF_DLI AF_DLI +#define PF_LAT AF_LAT +#define PF_HYLINK AF_HYLINK +#define PF_APPLETALK AF_APPLETALK +#define PF_ROUTE AF_ROUTE +#define PF_LINK AF_LINK +#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ +#define PF_COIP AF_COIP +#define PF_CNT AF_CNT +#define PF_SIP AF_SIP +#define PF_IPX AF_IPX /* same format as AF_NS */ +#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ +#define PF_PIP pseudo_AF_PIP +#define PF_NDRV AF_NDRV +#define PF_ISDN AF_ISDN +#define PF_KEY pseudo_AF_KEY +#define PF_INET6 AF_INET6 +#define PF_NATM AF_NATM +#define PF_SYSTEM AF_SYSTEM +#define PF_NETBIOS AF_NETBIOS +#define PF_PPP AF_PPP +#define PF_RESERVED_36 AF_RESERVED_36 +#define PF_UTUN AF_UTUN +#define PF_VSOCK AF_VSOCK +#define PF_MAX AF_MAX + +/* + * These do not have socket-layer support: + */ +#define PF_VLAN ((uint32_t)0x766c616e) /* 'vlan' */ +#define PF_BOND ((uint32_t)0x626f6e64) /* 'bond' */ + +/* + * Definitions for network related sysctl, CTL_NET. + * + * Second level is protocol family. + * Third level is protocol number. + * + * Further levels are defined by the individual families below. + */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define NET_MAXID AF_MAX +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * PF_ROUTE - Routing table + * + * Three additional levels are defined: + * Fourth: address family, 0 is wildcard + * Fifth: type of info, defined below + * Sixth: flag(s) to mask with for NET_RT_FLAGS + */ +#define NET_RT_DUMP 1 /* dump; may limit to a.f. */ +#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ +#define NET_RT_IFLIST 3 /* survey interface list */ +#define NET_RT_STAT 4 /* routing statistics */ +#define NET_RT_TRASH 5 /* routes not in table but not freed */ +#define NET_RT_IFLIST2 6 /* interface list with addresses */ +#define NET_RT_DUMP2 7 /* dump; may limit to a.f. */ +/* + * Allows read access non-local host's MAC address + * if the process has neighbor cache entitlement. + */ +#define NET_RT_FLAGS_PRIV 10 +#define NET_RT_MAXID 11 +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + + + + +/* + * Maximum queue length specifiable by listen. + */ +#define SOMAXCONN 128 + +/* + * [XSI] Message header for recvmsg and sendmsg calls. + * Used value-result for recvmsg, value only for sendmsg. + */ +struct msghdr { + void *msg_name; /* [XSI] optional address */ + socklen_t msg_namelen; /* [XSI] size of address */ + struct iovec *msg_iov; /* [XSI] scatter/gather array */ + int msg_iovlen; /* [XSI] # elements in msg_iov */ + void *msg_control; /* [XSI] ancillary data, see below */ + socklen_t msg_controllen; /* [XSI] ancillary data buffer len */ + int msg_flags; /* [XSI] flags on received message */ +}; + + + +#define MSG_OOB 0x1 /* process out-of-band data */ +#define MSG_PEEK 0x2 /* peek at incoming message */ +#define MSG_DONTROUTE 0x4 /* send without using routing tables */ +#define MSG_EOR 0x8 /* data completes record */ +#define MSG_TRUNC 0x10 /* data discarded before delivery */ +#define MSG_CTRUNC 0x20 /* control data lost before delivery */ +#define MSG_WAITALL 0x40 /* wait for full request or error */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ +#define MSG_EOF 0x100 /* data completes connection */ +#ifdef __APPLE__ +#ifdef __APPLE_API_OBSOLETE +#define MSG_WAITSTREAM 0x200 /* wait up to full request.. may return partial */ +#endif +#define MSG_FLUSH 0x400 /* Start of 'hold' seq; dump so_temp, deprecated */ +#define MSG_HOLD 0x800 /* Hold frag in so_temp, deprecated */ +#define MSG_SEND 0x1000 /* Send the packet in so_temp, deprecated */ +#define MSG_HAVEMORE 0x2000 /* Data ready to be read */ +#define MSG_RCVMORE 0x4000 /* Data remains in current pkt */ +#endif +#define MSG_NEEDSA 0x10000 /* Fail receive if socket address cannot be allocated */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#if __DARWIN_C_LEVEL >= 200809L +#define MSG_NOSIGNAL 0x80000 /* do not generate SIGPIPE on EOF */ +#endif /* __DARWIN_C_LEVEL */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * Header for ancillary data objects in msg_control buffer. + * Used for additional information with/about a datagram + * not expressible by flags. The format is a sequence + * of message elements headed by cmsghdr structures. + */ +struct cmsghdr { + socklen_t cmsg_len; /* [XSI] data byte count, including hdr */ + int cmsg_level; /* [XSI] originating protocol */ + int cmsg_type; /* [XSI] protocol-specific type */ +/* followed by unsigned char cmsg_data[]; */ +}; + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#ifndef __APPLE__ +/* + * While we may have more groups than this, the cmsgcred struct must + * be able to fit in an mbuf, and NGROUPS_MAX is too large to allow + * this. + */ +#define CMGROUP_MAX 16 + +/* + * Credentials structure, used to verify the identity of a peer + * process that has sent us a message. This is allocated by the + * peer process but filled in by the kernel. This prevents the + * peer from lying about its identity. (Note that cmcred_groups[0] + * is the effective GID.) + */ +struct cmsgcred { + pid_t cmcred_pid; /* PID of sending process */ + uid_t cmcred_uid; /* real UID of sending process */ + uid_t cmcred_euid; /* effective UID of sending process */ + gid_t cmcred_gid; /* real GID of sending process */ + short cmcred_ngroups; /* number or groups */ + gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ +}; +#endif +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* given pointer to struct cmsghdr, return pointer to data */ +#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ + __DARWIN_ALIGN32(sizeof(struct cmsghdr))) + +/* + * RFC 2292 requires to check msg_controllen, in case that the kernel returns + * an empty list for some reasons. + */ +#define CMSG_FIRSTHDR(mhdr) \ + ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(mhdr)->msg_control : \ + (struct cmsghdr *)0L) + + +/* + * Given pointer to struct cmsghdr, return pointer to next cmsghdr + * RFC 2292 says that CMSG_NXTHDR(mhdr, NULL) is equivalent to CMSG_FIRSTHDR(mhdr) + */ +#define CMSG_NXTHDR(mhdr, cmsg) \ + ((char *)(cmsg) == (char *)0L ? CMSG_FIRSTHDR(mhdr) : \ + ((((unsigned char *)(cmsg) + \ + __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len) + \ + __DARWIN_ALIGN32(sizeof(struct cmsghdr))) > \ + ((unsigned char *)(mhdr)->msg_control + \ + (mhdr)->msg_controllen)) ? \ + (struct cmsghdr *)0L /* NULL */ : \ + (struct cmsghdr *)(void *)((unsigned char *)(cmsg) + \ + __DARWIN_ALIGN32((__uint32_t)(cmsg)->cmsg_len)))) + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* RFC 2292 additions */ +#define CMSG_SPACE(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l)) +#define CMSG_LEN(l) (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + (l)) + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* "Socket"-level control message types: */ +#define SCM_RIGHTS 0x01 /* access rights (array of int) */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ +#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ +#define SCM_TIMESTAMP_MONOTONIC 0x04 /* timestamp (uint64_t) */ + + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * howto arguments for shutdown(2), specified by Posix.1g. + */ +#define SHUT_RD 0 /* shut down the reading side */ +#define SHUT_WR 1 /* shut down the writing side */ +#define SHUT_RDWR 2 /* shut down both sides */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * sendfile(2) header/trailer struct + */ +struct sf_hdtr { + struct iovec *headers; /* pointer to an array of header struct iovec's */ + int hdr_cnt; /* number of header iovec's */ + struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ + int trl_cnt; /* number of trailer iovec's */ +}; + + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + +__BEGIN_DECLS + +int accept(int, struct sockaddr * __restrict, socklen_t * __restrict) +__DARWIN_ALIAS_C(accept); +int bind(int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS(bind); +int connect(int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS_C(connect); +int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict) +__DARWIN_ALIAS(getpeername); +int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict) +__DARWIN_ALIAS(getsockname); +int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); +int listen(int, int) __DARWIN_ALIAS(listen); +ssize_t recv(int, void *, size_t, int) __DARWIN_ALIAS_C(recv); +ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, + socklen_t * __restrict) __DARWIN_ALIAS_C(recvfrom); +ssize_t recvmsg(int, struct msghdr *, int) __DARWIN_ALIAS_C(recvmsg); +ssize_t send(int, const void *, size_t, int) __DARWIN_ALIAS_C(send); +ssize_t sendmsg(int, const struct msghdr *, int) __DARWIN_ALIAS_C(sendmsg); +ssize_t sendto(int, const void *, size_t, + int, const struct sockaddr *, socklen_t) __DARWIN_ALIAS_C(sendto); +int setsockopt(int, int, int, const void *, socklen_t); +int shutdown(int, int); +int sockatmark(int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); +int socket(int, int, int); +int socketpair(int, int, int, int *) __DARWIN_ALIAS(socketpair); + +#if !defined(_POSIX_C_SOURCE) +int sendfile(int, int, off_t, off_t *, struct sf_hdtr *, int); +#endif /* !_POSIX_C_SOURCE */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +void pfctlinput(int, struct sockaddr *); + +__API_AVAILABLE(macosx(10.11), ios(9.0), tvos(9.0), watchos(2.0)) +int connectx(int, const sa_endpoints_t *, sae_associd_t, unsigned int, + const struct iovec *, unsigned int, size_t *, sae_connid_t *); + +__API_AVAILABLE(macosx(10.11), ios(9.0), tvos(9.0), watchos(2.0)) +int disconnectx(int, sae_associd_t, sae_connid_t); +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ +__END_DECLS + + +#endif /* !_SYS_SOCKET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/sockio.h b/lib/libc/include/aarch64-macos-gnu/sys/sockio.h new file mode 100644 index 0000000000..9dc2ee7489 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/sockio.h @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2000-2019 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/*- + * Copyright (c) 1982, 1986, 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)sockio.h 8.1 (Berkeley) 3/28/94 + */ + +#ifndef _SYS_SOCKIO_H_ +#define _SYS_SOCKIO_H_ + +#include + +#include + +/* Socket ioctl's. */ +#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ +#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ +#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ +#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ +#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ +#define SIOCSPGRP _IOW('s', 8, int) /* set process group */ +#define SIOCGPGRP _IOR('s', 9, int) /* get process group */ + +/* + * OSIOCGIF* ioctls are deprecated; they are kept for binary compatibility. + */ +#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */ +#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ +#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */ +#define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get ifnet flags */ +#define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */ +#define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */ +#define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */ +#define SIOCSIFMETRIC _IOW('i', 24, struct ifreq) /* set IF metric */ +#define SIOCDIFADDR _IOW('i', 25, struct ifreq) /* delete IF addr */ +#define SIOCAIFADDR _IOW('i', 26, struct ifaliasreq)/* add/chg IF alias */ + +#define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */ +#define SIOCGIFDSTADDR _IOWR('i', 34, struct ifreq) /* get p-p address */ +#define SIOCGIFBRDADDR _IOWR('i', 35, struct ifreq) /* get broadcast addr */ +#define SIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */ +#define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */ +#define SIOCAUTOADDR _IOWR('i', 38, struct ifreq) /* autoconf address */ +#define SIOCAUTONETMASK _IOW('i', 39, struct ifreq) /* autoconf netmask */ +#define SIOCARPIPLL _IOWR('i', 40, struct ifreq) /* arp for IPv4LL address */ + +#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */ +#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */ +#define SIOCGIFMTU _IOWR('i', 51, struct ifreq) /* get IF mtu */ +#define SIOCSIFMTU _IOW('i', 52, struct ifreq) /* set IF mtu */ +#define SIOCGIFPHYS _IOWR('i', 53, struct ifreq) /* get IF wire */ +#define SIOCSIFPHYS _IOW('i', 54, struct ifreq) /* set IF wire */ +#define SIOCSIFMEDIA _IOWR('i', 55, struct ifreq) /* set net media */ + +/* + * The command SIOCGIFMEDIA does not allow a process to access the extended + * media subtype and extended subtype values are returned as IFM_OTHER. + */ +#define SIOCGIFMEDIA _IOWR('i', 56, struct ifmediareq) /* get compatible net media */ + +#define SIOCSIFGENERIC _IOW('i', 57, struct ifreq) /* generic IF set op */ +#define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */ +#define SIOCRSLVMULTI _IOWR('i', 59, struct rslvmulti_req) + +#define SIOCSIFLLADDR _IOW('i', 60, struct ifreq) /* set link level addr */ +#define SIOCGIFSTATUS _IOWR('i', 61, struct ifstat) /* get IF status */ +#define SIOCSIFPHYADDR _IOW('i', 62, struct ifaliasreq) /* set gif addres */ +#define SIOCGIFPSRCADDR _IOWR('i', 63, struct ifreq) /* get gif psrc addr */ +#define SIOCGIFPDSTADDR _IOWR('i', 64, struct ifreq) /* get gif pdst addr */ +#define SIOCDIFPHYADDR _IOW('i', 65, struct ifreq) /* delete gif addrs */ + +#define SIOCGIFDEVMTU _IOWR('i', 68, struct ifreq) /* get if ifdevmtu */ +#define SIOCSIFALTMTU _IOW('i', 69, struct ifreq) /* set if alternate mtu */ +#define SIOCGIFALTMTU _IOWR('i', 72, struct ifreq) /* get if alternate mtu */ +#define SIOCSIFBOND _IOW('i', 70, struct ifreq) /* set bond if config */ +#define SIOCGIFBOND _IOWR('i', 71, struct ifreq) /* get bond if config */ + +/* + * The command SIOCGIFXMEDIA is meant to be used by processes only to be able + * to access the extended media subtypes with the extended IFM_TMASK. + * + * An ifnet must not implement SIOCGIFXMEDIA as it gets the extended + * media subtypes by simply compiling with + */ +#define SIOCGIFXMEDIA _IOWR('i', 72, struct ifmediareq) /* get net extended media */ + + +#define SIOCSIFCAP _IOW('i', 90, struct ifreq) /* set IF features */ +#define SIOCGIFCAP _IOWR('i', 91, struct ifreq) /* get IF features */ + +#define SIOCIFCREATE _IOWR('i', 120, struct ifreq) /* create clone if */ +#define SIOCIFDESTROY _IOW('i', 121, struct ifreq) /* destroy clone if */ +#define SIOCIFCREATE2 _IOWR('i', 122, struct ifreq) /* create clone if with data */ + +#define SIOCSDRVSPEC _IOW('i', 123, struct ifdrv) /* set driver-specific + * parameters */ +#define SIOCGDRVSPEC _IOWR('i', 123, struct ifdrv) /* get driver-specific + * parameters */ +#define SIOCSIFVLAN _IOW('i', 126, struct ifreq) /* set VLAN config */ +#define SIOCGIFVLAN _IOWR('i', 127, struct ifreq) /* get VLAN config */ +#define SIOCSETVLAN SIOCSIFVLAN +#define SIOCGETVLAN SIOCGIFVLAN + +#define SIOCIFGCLONERS _IOWR('i', 129, struct if_clonereq) /* get cloners */ + +#define SIOCGIFASYNCMAP _IOWR('i', 124, struct ifreq) /* get ppp asyncmap */ +#define SIOCSIFASYNCMAP _IOW('i', 125, struct ifreq) /* set ppp asyncmap */ + + + +#define SIOCGIFMAC _IOWR('i', 130, struct ifreq) /* deprecated */ +#define SIOCSIFMAC _IOW('i', 131, struct ifreq) /* deprecated */ +#define SIOCSIFKPI _IOW('i', 134, struct ifreq) /* set interface kext param - root only */ +#define SIOCGIFKPI _IOWR('i', 135, struct ifreq) /* get interface kext param */ + +#define SIOCGIFWAKEFLAGS _IOWR('i', 136, struct ifreq) /* get interface wake property flags */ + +#define SIOCGIFFUNCTIONALTYPE _IOWR('i', 173, struct ifreq) /* get interface functional type */ + +#define SIOCSIF6LOWPAN _IOW('i', 196, struct ifreq) /* set 6LOWPAN config */ +#define SIOCGIF6LOWPAN _IOWR('i', 197, struct ifreq) /* get 6LOWPAN config */ + + +#endif /* !_SYS_SOCKIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/spawn.h b/lib/libc/include/aarch64-macos-gnu/sys/spawn.h new file mode 100644 index 0000000000..aeb42a9bb1 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/spawn.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2006-2020 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@ + */ + +/* + * [SPN] Support for _POSIX_SPAWN + * + * This header contains information that is shared between the user space + * and kernel versions of the posix_spawn() code. Shared elements are all + * manifest constants, at the current time. + */ + +#ifndef _SYS_SPAWN_H_ +#define _SYS_SPAWN_H_ + +/* + * Possible bit values which may be OR'ed together and provided as the second + * parameter to posix_spawnattr_setflags() or implicit returned in the value of + * the second parameter to posix_spawnattr_getflags(). + */ +#define POSIX_SPAWN_RESETIDS 0x0001 /* [SPN] R[UG]ID not E[UG]ID */ +#define POSIX_SPAWN_SETPGROUP 0x0002 /* [SPN] set non-parent PGID */ +#define POSIX_SPAWN_SETSIGDEF 0x0004 /* [SPN] reset sigset default */ +#define POSIX_SPAWN_SETSIGMASK 0x0008 /* [SPN] set signal mask */ + +#if 0 /* _POSIX_PRIORITY_SCHEDULING [PS] : not supported */ +#define POSIX_SPAWN_SETSCHEDPARAM 0x0010 +#define POSIX_SPAWN_SETSCHEDULER 0x0020 +#endif /* 0 */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * Darwin-specific flags + */ +#define POSIX_SPAWN_SETEXEC 0x0040 +#define POSIX_SPAWN_START_SUSPENDED 0x0080 +#define POSIX_SPAWN_SETSID 0x0400 +#define POSIX_SPAWN_CLOEXEC_DEFAULT 0x4000 + +#define _POSIX_SPAWN_RESLIDE 0x0800 + +/* + * Possible values to be set for the process control actions on resource starvation. + * POSIX_SPAWN_PCONTROL_THROTTLE indicates that the process is to be throttled on starvation. + * POSIX_SPAWN_PCONTROL_SUSPEND indicates that the process is to be suspended on starvation. + * POSIX_SPAWN_PCONTROL_KILL indicates that the process is to be terminated on starvation. + */ +#define POSIX_SPAWN_PCONTROL_NONE 0x0000 +#define POSIX_SPAWN_PCONTROL_THROTTLE 0x0001 +#define POSIX_SPAWN_PCONTROL_SUSPEND 0x0002 +#define POSIX_SPAWN_PCONTROL_KILL 0x0003 + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +#endif /* _SYS_SPAWN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/stat.h b/lib/libc/include/aarch64-macos-gnu/sys/stat.h new file mode 100644 index 0000000000..fb60146e5c --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/stat.h @@ -0,0 +1,432 @@ +/* + * Copyright (c) 2000-2014 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/*- + * Copyright (c) 1982, 1986, 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)stat.h 8.9 (Berkeley) 8/17/94 + */ + + +#ifndef _SYS_STAT_H_ +#define _SYS_STAT_H_ + +#include +#include +#include + +/* [XSI] The timespec structure may be defined as described in */ +#include + +/* + * [XSI] The blkcnt_t, blksize_t, dev_t, ino_t, mode_t, nlink_t, uid_t, + * gid_t, off_t, and time_t types shall be defined as described in + * . + */ +#include +#include +#include /* device number */ +#include + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#include +#endif /* !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) */ + +#include +#include +#include +#include +#include +#include + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * XXX So deprecated, it would make your head spin + * + * The old stat structure. In fact, this is not used by the kernel at all, + * and should not be used by user space, and should be removed from this + * header file entirely (along with the unused cvtstat() prototype in + * vnode_internal.h). + */ +struct ostat { + __uint16_t st_dev; /* inode's device */ + ino_t st_ino; /* inode's number */ + mode_t st_mode; /* inode protection mode */ + nlink_t st_nlink; /* number of hard links */ + __uint16_t st_uid; /* user ID of the file's owner */ + __uint16_t st_gid; /* group ID of the file's group */ + __uint16_t st_rdev; /* device type */ + __int32_t st_size; /* file size, in bytes */ + struct timespec st_atimespec; /* time of last access */ + struct timespec st_mtimespec; /* time of last data modification */ + struct timespec st_ctimespec; /* time of last file status change */ + __int32_t st_blksize; /* optimal blocksize for I/O */ + __int32_t st_blocks; /* blocks allocated for file */ + __uint32_t st_flags; /* user defined flags for file */ + __uint32_t st_gen; /* file generation number */ +}; + +#define __DARWIN_STRUCT_STAT64_TIMES \ + struct timespec st_atimespec; /* time of last access */ \ + struct timespec st_mtimespec; /* time of last data modification */ \ + struct timespec st_ctimespec; /* time of last status change */ \ + struct timespec st_birthtimespec; /* time of file creation(birth) */ + +#else /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ + +#define __DARWIN_STRUCT_STAT64_TIMES \ + time_t st_atime; /* [XSI] Time of last access */ \ + long st_atimensec; /* nsec of last access */ \ + time_t st_mtime; /* [XSI] Last data modification time */ \ + long st_mtimensec; /* last data modification nsec */ \ + time_t st_ctime; /* [XSI] Time of last status change */ \ + long st_ctimensec; /* nsec of last status change */ \ + time_t st_birthtime; /* File creation time(birth) */ \ + long st_birthtimensec; /* nsec of File creation time */ + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * This structure is used as the second parameter to the fstat64(), + * lstat64(), and stat64() functions, and for struct stat when + * __DARWIN_64_BIT_INO_T is set. __DARWIN_STRUCT_STAT64 is defined + * above, depending on whether we use struct timespec or the direct + * components. + * + * This is simillar to stat except for 64bit inode number + * number instead of 32bit ino_t and the addition of create(birth) time. + */ +#define __DARWIN_STRUCT_STAT64 { \ + dev_t st_dev; /* [XSI] ID of device containing file */ \ + mode_t st_mode; /* [XSI] Mode of file (see below) */ \ + nlink_t st_nlink; /* [XSI] Number of hard links */ \ + __darwin_ino64_t st_ino; /* [XSI] File serial number */ \ + uid_t st_uid; /* [XSI] User ID of the file */ \ + gid_t st_gid; /* [XSI] Group ID of the file */ \ + dev_t st_rdev; /* [XSI] Device ID */ \ + __DARWIN_STRUCT_STAT64_TIMES \ + off_t st_size; /* [XSI] file size, in bytes */ \ + blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ \ + blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ \ + __uint32_t st_flags; /* user defined flags for file */ \ + __uint32_t st_gen; /* file generation number */ \ + __int32_t st_lspare; /* RESERVED: DO NOT USE! */ \ + __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ \ +} + +/* + * [XSI] This structure is used as the second parameter to the fstat(), + * lstat(), and stat() functions. + */ +#if __DARWIN_64_BIT_INO_T + +struct stat __DARWIN_STRUCT_STAT64; + +#else /* !__DARWIN_64_BIT_INO_T */ + +struct stat { + dev_t st_dev; /* [XSI] ID of device containing file */ + ino_t st_ino; /* [XSI] File serial number */ + mode_t st_mode; /* [XSI] Mode of file (see below) */ + nlink_t st_nlink; /* [XSI] Number of hard links */ + uid_t st_uid; /* [XSI] User ID of the file */ + gid_t st_gid; /* [XSI] Group ID of the file */ + dev_t st_rdev; /* [XSI] Device ID */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + struct timespec st_atimespec; /* time of last access */ + struct timespec st_mtimespec; /* time of last data modification */ + struct timespec st_ctimespec; /* time of last status change */ +#else + time_t st_atime; /* [XSI] Time of last access */ + long st_atimensec; /* nsec of last access */ + time_t st_mtime; /* [XSI] Last data modification time */ + long st_mtimensec; /* last data modification nsec */ + time_t st_ctime; /* [XSI] Time of last status change */ + long st_ctimensec; /* nsec of last status change */ +#endif + off_t st_size; /* [XSI] file size, in bytes */ + blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ + blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ + __uint32_t st_flags; /* user defined flags for file */ + __uint32_t st_gen; /* file generation number */ + __int32_t st_lspare; /* RESERVED: DO NOT USE! */ + __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ +}; + +#endif /* __DARWIN_64_BIT_INO_T */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + +#if !__DARWIN_ONLY_64_BIT_INO_T + +struct stat64 __DARWIN_STRUCT_STAT64; + +#endif /* !__DARWIN_ONLY_64_BIT_INO_T */ + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define st_atime st_atimespec.tv_sec +#define st_mtime st_mtimespec.tv_sec +#define st_ctime st_ctimespec.tv_sec +#define st_birthtime st_birthtimespec.tv_sec +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +/* + * [XSI] The following are symbolic names for the values of type mode_t. They + * are bitmap values. + */ +#include + +/* + * [XSI] The following macros shall be provided to test whether a file is + * of the specified type. The value m supplied to the macros is the value + * of st_mode from a stat structure. The macro shall evaluate to a non-zero + * value if the test is true; 0 if the test is false. + */ +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) /* block special */ +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* char special */ +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* directory */ +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* fifo or socket */ +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* regular file */ +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* symbolic link */ +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) /* socket */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define S_ISWHT(m) (((m) & S_IFMT) == S_IFWHT) /* OBSOLETE: whiteout */ +#endif + +/* + * [XSI] The implementation may implement message queues, semaphores, or + * shared memory objects as distinct file types. The following macros + * shall be provided to test whether a file is of the specified type. + * The value of the buf argument supplied to the macros is a pointer to + * a stat structure. The macro shall evaluate to a non-zero value if + * the specified object is implemented as a distinct file type and the + * specified file type is contained in the stat structure referenced by + * buf. Otherwise, the macro shall evaluate to zero. + * + * NOTE: The current implementation does not do this, although + * this may change in future revisions, and co currently only + * provides these macros to ensure source compatability with + * implementations which do. + */ +#define S_TYPEISMQ(buf) (0) /* Test for a message queue */ +#define S_TYPEISSEM(buf) (0) /* Test for a semaphore */ +#define S_TYPEISSHM(buf) (0) /* Test for a shared memory object */ + +/* + * [TYM] The implementation may implement typed memory objects as distinct + * file types, and the following macro shall test whether a file is of the + * specified type. The value of the buf argument supplied to the macros is + * a pointer to a stat structure. The macro shall evaluate to a non-zero + * value if the specified object is implemented as a distinct file type and + * the specified file type is contained in the stat structure referenced by + * buf. Otherwise, the macro shall evaluate to zero. + * + * NOTE: The current implementation does not do this, although + * this may change in future revisions, and co currently only + * provides this macro to ensure source compatability with + * implementations which do. + */ +#define S_TYPEISTMO(buf) (0) /* Test for a typed memory object */ + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */ + /* 7777 */ +#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO) +/* 0666 */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) + +#define S_BLKSIZE 512 /* block size used in the stat struct */ + +/* + * Definitions of flags stored in file flags word. + * + * Super-user and owner changeable flags. + */ +#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */ +#define UF_NODUMP 0x00000001 /* do not dump file */ +#define UF_IMMUTABLE 0x00000002 /* file may not be changed */ +#define UF_APPEND 0x00000004 /* writes to file may only append */ +#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */ +/* + * The following bit is reserved for FreeBSD. It is not implemented + * in Mac OS X. + */ +/* #define UF_NOUNLINK 0x00000010 */ /* file may not be removed or renamed */ +#define UF_COMPRESSED 0x00000020 /* file is compressed (some file-systems) */ + +/* UF_TRACKED is used for dealing with document IDs. We no longer issue + * notifications for deletes or renames for files which have UF_TRACKED set. */ +#define UF_TRACKED 0x00000040 + +#define UF_DATAVAULT 0x00000080 /* entitlement required for reading */ + /* and writing */ + +/* Bits 0x0100 through 0x4000 are currently undefined. */ +#define UF_HIDDEN 0x00008000 /* hint that this item should not be */ + /* displayed in a GUI */ +/* + * Super-user changeable flags. + */ +#define SF_SUPPORTED 0x009f0000 /* mask of superuser supported flags */ +#define SF_SETTABLE 0x3fff0000 /* mask of superuser changeable flags */ +#define SF_SYNTHETIC 0xc0000000 /* mask of system read-only synthetic flags */ +#define SF_ARCHIVED 0x00010000 /* file is archived */ +#define SF_IMMUTABLE 0x00020000 /* file may not be changed */ +#define SF_APPEND 0x00040000 /* writes to file may only append */ +#define SF_RESTRICTED 0x00080000 /* entitlement required for writing */ +#define SF_NOUNLINK 0x00100000 /* Item may not be removed, renamed or mounted on */ + +/* + * The following two bits are reserved for FreeBSD. They are not + * implemented in Mac OS X. + */ +/* #define SF_SNAPSHOT 0x00200000 */ /* snapshot inode */ +/* NOTE: There is no SF_HIDDEN bit. */ + +#define SF_FIRMLINK 0x00800000 /* file is a firmlink */ + +/* + * Synthetic flags. + * + * These are read-only. We keep them out of SF_SUPPORTED so that + * attempts to set them will fail. + */ +#define SF_DATALESS 0x40000000 /* file is dataless object */ + + +#endif + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +/* + * Extended flags ("EF") returned by ATTR_CMNEXT_EXT_FLAGS from getattrlist/getattrlistbulk + */ +#define EF_MAY_SHARE_BLOCKS 0x00000001 /* file may share blocks with another file */ +#define EF_NO_XATTRS 0x00000002 /* file has no xattrs at all */ +#define EF_IS_SYNC_ROOT 0x00000004 /* file is a sync root for iCloud */ +#define EF_IS_PURGEABLE 0x00000008 /* file is purgeable */ +#define EF_IS_SPARSE 0x00000010 /* file has at least one sparse region */ +#define EF_IS_SYNTHETIC 0x00000020 /* a synthetic directory/symlink */ +#endif + + + +__BEGIN_DECLS +/* [XSI] */ +int chmod(const char *, mode_t) __DARWIN_ALIAS(chmod); +int fchmod(int, mode_t) __DARWIN_ALIAS(fchmod); +int fstat(int, struct stat *) __DARWIN_INODE64(fstat); +int lstat(const char *, struct stat *) __DARWIN_INODE64(lstat); +int mkdir(const char *, mode_t); +int mkfifo(const char *, mode_t); +int stat(const char *, struct stat *) __DARWIN_INODE64(stat); +int mknod(const char *, mode_t, dev_t); +mode_t umask(mode_t); + +#if __DARWIN_C_LEVEL >= 200809L +int fchmodat(int, const char *, mode_t, int) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); +int fstatat(int, const char *, struct stat *, int) __DARWIN_INODE64(fstatat) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); +int mkdirat(int, const char *, mode_t) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); + +#define UTIME_NOW -1 +#define UTIME_OMIT -2 + +int futimens(int __fd, const struct timespec __times[2]) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0)); +int utimensat(int __fd, const char *__path, const struct timespec __times[2], + int __flag) __API_AVAILABLE(macosx(10.13), ios(11.0), tvos(11.0), watchos(4.0)); +#endif + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + +#include + +int chflags(const char *, __uint32_t); +int chmodx_np(const char *, filesec_t); +int fchflags(int, __uint32_t); +int fchmodx_np(int, filesec_t); +int fstatx_np(int, struct stat *, filesec_t) __DARWIN_INODE64(fstatx_np); +int lchflags(const char *, __uint32_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); +int lchmod(const char *, mode_t) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); +int lstatx_np(const char *, struct stat *, filesec_t) __DARWIN_INODE64(lstatx_np); +int mkdirx_np(const char *, filesec_t); +int mkfifox_np(const char *, filesec_t); +int statx_np(const char *, struct stat *, filesec_t) __DARWIN_INODE64(statx_np); +int umaskx_np(filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); + +#if !__DARWIN_ONLY_64_BIT_INO_T +/* The following deprecated routines are simillar to stat and friends except provide struct stat64 instead of struct stat */ +int fstatx64_np(int, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +int lstatx64_np(const char *, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +int statx64_np(const char *, struct stat64 *, filesec_t) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +int fstat64(int, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +int lstat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +int stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5, __MAC_10_6, __IPHONE_NA, __IPHONE_NA); +#endif /* !__DARWIN_ONLY_64_BIT_INO_T */ +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + +__END_DECLS +#endif /* !_SYS_STAT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/sysctl.h b/lib/libc/include/aarch64-macos-gnu/sys/sysctl.h new file mode 100644 index 0000000000..80dbee50aa --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/sysctl.h @@ -0,0 +1,779 @@ +/* + * Copyright (c) 2000-2019 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Mike Karels at Berkeley Software Design, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 + */ +/* + * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce + * support for mandatory and extensible security protections. This notice + * is included in support of clause 2.2 (b) of the Apple Public License, + * Version 2.0. + */ + +#ifndef _SYS_SYSCTL_H_ +#define _SYS_SYSCTL_H_ + +/* + * These are for the eproc structure defined below. + */ +#include + +#include +#include +#include +#include +#include + + +/* + * Definitions for sysctl call. The sysctl call uses a hierarchical name + * for objects that can be examined or modified. The name is expressed as + * a sequence of integers. Like a file path name, the meaning of each + * component depends on its place in the hierarchy. The top-level and kern + * identifiers are defined here, and other identifiers are defined in the + * respective subsystem header files. + */ + +#define CTL_MAXNAME 12 /* largest number of components supported */ + +/* + * Each subsystem defined by sysctl defines a list of variables + * for that subsystem. Each name is either a node with further + * levels defined below it, or it is a leaf of some particular + * type given below. Each sysctl level defines a set of name/type + * pairs to be used by sysctl(1) in manipulating the subsystem. + * + * When declaring new sysctl names, use the CTLFLAG_LOCKED flag in the + * type to indicate that all necessary locking will be handled + * within the sysctl. + * + * Any sysctl defined without CTLFLAG_LOCKED is considered legacy + * and will be protected by a global mutex. + * + * Note: This is not optimal, so it is best to handle locking + * yourself, if you are able to do so. A simple design + * pattern for use to avoid in a single function known + * to potentially be in the paging path ot doing a DMA + * to physical memory in a user space process is: + * + * lock + * perform operation vs. local buffer + * unlock + * SYSCTL_OUT(rey, local buffer, length) + * + * ...this assumes you are not using a deep call graph + * or are unable to pass a local buffer address as a + * parameter into your deep call graph. + * + * Note that very large user buffers can fail the wire + * if to do so would require more physical pages than + * are available (the caller will get an ENOMEM error, + * see sysctl_mem_hold() for details). + */ +struct ctlname { + char *ctl_name; /* subsystem name */ + int ctl_type; /* type of name */ +}; + +#define CTLTYPE 0xf /* Mask for the type */ +#define CTLTYPE_NODE 1 /* name is a node */ +#define CTLTYPE_INT 2 /* name describes an integer */ +#define CTLTYPE_STRING 3 /* name describes a string */ +#define CTLTYPE_QUAD 4 /* name describes a 64-bit number */ +#define CTLTYPE_OPAQUE 5 /* name describes a structure */ +#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ + +#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ +#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ +#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) +#define CTLFLAG_NOLOCK 0x20000000 /* XXX Don't Lock */ +#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ +#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ +#define CTLFLAG_MASKED 0x04000000 /* deprecated variable, do not display */ +#define CTLFLAG_NOAUTO 0x02000000 /* do not auto-register */ +#define CTLFLAG_KERN 0x01000000 /* valid inside the kernel */ +#define CTLFLAG_LOCKED 0x00800000 /* node will handle locking itself */ +#define CTLFLAG_OID2 0x00400000 /* struct sysctl_oid has version info */ + +/* + * USE THIS instead of a hardwired number from the categories below + * to get dynamically assigned sysctl entries using the linker-set + * technology. This is the way nearly all new sysctl variables should + * be implemented. + * + * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); + * + * Note that linker set technology will automatically register all nodes + * declared like this on kernel initialization, UNLESS they are defined + * in I/O-Kit. In this case, you have to call sysctl_register_oid() + * manually - just like in a KEXT. + */ +#define OID_AUTO (-1) +#define OID_AUTO_START 100 /* conventional */ + + +#define SYSCTL_DEF_ENABLED + +#ifdef SYSCTL_DEF_ENABLED +/* + * Top-level identifiers + */ +#define CTL_UNSPEC 0 /* unused */ +#define CTL_KERN 1 /* "high kernel": proc, limits */ +#define CTL_VM 2 /* virtual memory */ +#define CTL_VFS 3 /* file system, mount type is next */ +#define CTL_NET 4 /* network, see socket.h */ +#define CTL_DEBUG 5 /* debugging parameters */ +#define CTL_HW 6 /* generic cpu/io */ +#define CTL_MACHDEP 7 /* machine dependent */ +#define CTL_USER 8 /* user-level */ +#define CTL_MAXID 9 /* number of valid top-level ids */ + +#define CTL_NAMES { \ + { 0, 0 }, \ + { "kern", CTLTYPE_NODE }, \ + { "vm", CTLTYPE_NODE }, \ + { "vfs", CTLTYPE_NODE }, \ + { "net", CTLTYPE_NODE }, \ + { "debug", CTLTYPE_NODE }, \ + { "hw", CTLTYPE_NODE }, \ + { "machdep", CTLTYPE_NODE }, \ + { "user", CTLTYPE_NODE }, \ +} + +/* + * CTL_KERN identifiers + */ +#define KERN_OSTYPE 1 /* string: system version */ +#define KERN_OSRELEASE 2 /* string: system release */ +#define KERN_OSREV 3 /* int: system revision */ +#define KERN_VERSION 4 /* string: compile time info */ +#define KERN_MAXVNODES 5 /* int: max vnodes */ +#define KERN_MAXPROC 6 /* int: max processes */ +#define KERN_MAXFILES 7 /* int: max open files */ +#define KERN_ARGMAX 8 /* int: max arguments to exec */ +#define KERN_SECURELVL 9 /* int: system security level */ +#define KERN_HOSTNAME 10 /* string: hostname */ +#define KERN_HOSTID 11 /* int: host identifier */ +#define KERN_CLOCKRATE 12 /* struct: struct clockrate */ +#define KERN_VNODE 13 /* struct: vnode structures */ +#define KERN_PROC 14 /* struct: process entries */ +#define KERN_FILE 15 /* struct: file entries */ +#define KERN_PROF 16 /* node: kernel profiling info */ +#define KERN_POSIX1 17 /* int: POSIX.1 version */ +#define KERN_NGROUPS 18 /* int: # of supplemental group ids */ +#define KERN_JOB_CONTROL 19 /* int: is job control available */ +#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ +#define KERN_BOOTTIME 21 /* struct: time kernel was booted */ +#define KERN_NISDOMAINNAME 22 /* string: YP domain name */ +#define KERN_DOMAINNAME KERN_NISDOMAINNAME +#define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */ +#define KERN_KDEBUG 24 /* int: kernel trace points */ +#define KERN_UPDATEINTERVAL 25 /* int: update process sleep time */ +#define KERN_OSRELDATE 26 /* int: OS release date */ +#define KERN_NTP_PLL 27 /* node: NTP PLL control */ +#define KERN_BOOTFILE 28 /* string: name of booted kernel */ +#define KERN_MAXFILESPERPROC 29 /* int: max open files per proc */ +#define KERN_MAXPROCPERUID 30 /* int: max processes per uid */ +#define KERN_DUMPDEV 31 /* dev_t: device to dump on */ +#define KERN_IPC 32 /* node: anything related to IPC */ +#define KERN_DUMMY 33 /* unused */ +#define KERN_PS_STRINGS 34 /* int: address of PS_STRINGS */ +#define KERN_USRSTACK32 35 /* int: address of USRSTACK */ +#define KERN_LOGSIGEXIT 36 /* int: do we log sigexit procs? */ +#define KERN_SYMFILE 37 /* string: kernel symbol filename */ +#define KERN_PROCARGS 38 +/* 39 was KERN_PCSAMPLES... now obsolete */ +#define KERN_NETBOOT 40 /* int: are we netbooted? 1=yes,0=no */ +/* 41 was KERN_PANICINFO : panic UI information (deprecated) */ +#define KERN_SYSV 42 /* node: System V IPC information */ +#define KERN_AFFINITY 43 /* xxx */ +#define KERN_TRANSLATE 44 /* xxx */ +#define KERN_CLASSIC KERN_TRANSLATE /* XXX backwards compat */ +#define KERN_EXEC 45 /* xxx */ +#define KERN_CLASSICHANDLER KERN_EXEC /* XXX backwards compatibility */ +#define KERN_AIOMAX 46 /* int: max aio requests */ +#define KERN_AIOPROCMAX 47 /* int: max aio requests per process */ +#define KERN_AIOTHREADS 48 /* int: max aio worker threads */ +#ifdef __APPLE_API_UNSTABLE +#define KERN_PROCARGS2 49 +#endif /* __APPLE_API_UNSTABLE */ +#define KERN_COREFILE 50 /* string: corefile format string */ +#define KERN_COREDUMP 51 /* int: whether to coredump at all */ +#define KERN_SUGID_COREDUMP 52 /* int: whether to dump SUGID cores */ +#define KERN_PROCDELAYTERM 53 /* int: set/reset current proc for delayed termination during shutdown */ +#define KERN_SHREG_PRIVATIZABLE 54 /* int: can shared regions be privatized ? */ +/* 55 was KERN_PROC_LOW_PRI_IO... now deprecated */ +#define KERN_LOW_PRI_WINDOW 56 /* int: set/reset throttle window - milliseconds */ +#define KERN_LOW_PRI_DELAY 57 /* int: set/reset throttle delay - milliseconds */ +#define KERN_POSIX 58 /* node: posix tunables */ +#define KERN_USRSTACK64 59 /* LP64 user stack query */ +#define KERN_NX_PROTECTION 60 /* int: whether no-execute protection is enabled */ +#define KERN_TFP 61 /* Task for pid settings */ +#define KERN_PROCNAME 62 /* setup process program name(2*MAXCOMLEN) */ +#define KERN_THALTSTACK 63 /* for compat with older x86 and does nothing */ +#define KERN_SPECULATIVE_READS 64 /* int: whether speculative reads are disabled */ +#define KERN_OSVERSION 65 /* for build number i.e. 9A127 */ +#define KERN_SAFEBOOT 66 /* are we booted safe? */ +/* 67 was KERN_LCTX (login context) */ +#define KERN_RAGEVNODE 68 +#define KERN_TTY 69 /* node: tty settings */ +#define KERN_CHECKOPENEVT 70 /* spi: check the VOPENEVT flag on vnodes at open time */ +#define KERN_THREADNAME 71 /* set/get thread name */ +#define KERN_MAXID 72 /* number of valid kern ids */ +/* + * Don't add any more sysctls like this. Instead, use the SYSCTL_*() macros + * and OID_AUTO. This will have the added benefit of not having to recompile + * sysctl(8) to pick up your changes. + */ + + +#if defined(__LP64__) +#define KERN_USRSTACK KERN_USRSTACK64 +#else +#define KERN_USRSTACK KERN_USRSTACK32 +#endif + + +/* KERN_RAGEVNODE types */ +#define KERN_RAGE_PROC 1 +#define KERN_RAGE_THREAD 2 +#define KERN_UNRAGE_PROC 3 +#define KERN_UNRAGE_THREAD 4 + +/* KERN_OPENEVT types */ +#define KERN_OPENEVT_PROC 1 +#define KERN_UNOPENEVT_PROC 2 + +/* KERN_TFP types */ +#define KERN_TFP_POLICY 1 + +/* KERN_TFP_POLICY values . All policies allow task port for self */ +#define KERN_TFP_POLICY_DENY 0 /* Deny Mode: None allowed except privileged */ +#define KERN_TFP_POLICY_DEFAULT 2 /* Default Mode: related ones allowed and upcall authentication */ + +/* KERN_KDEBUG types */ +#define KERN_KDEFLAGS 1 +#define KERN_KDDFLAGS 2 +#define KERN_KDENABLE 3 +#define KERN_KDSETBUF 4 +#define KERN_KDGETBUF 5 +#define KERN_KDSETUP 6 +#define KERN_KDREMOVE 7 +#define KERN_KDSETREG 8 +#define KERN_KDGETREG 9 +#define KERN_KDREADTR 10 +#define KERN_KDPIDTR 11 +#define KERN_KDTHRMAP 12 +/* Don't use 13 as it is overloaded with KERN_VNODE */ +#define KERN_KDPIDEX 14 +#define KERN_KDSETRTCDEC 15 /* obsolete */ +#define KERN_KDGETENTROPY 16 /* obsolete */ +#define KERN_KDWRITETR 17 +#define KERN_KDWRITEMAP 18 +#define KERN_KDTEST 19 +/* 20 unused */ +#define KERN_KDREADCURTHRMAP 21 +#define KERN_KDSET_TYPEFILTER 22 +#define KERN_KDBUFWAIT 23 +#define KERN_KDCPUMAP 24 +/* 25 - 26 unused */ +#define KERN_KDWRITEMAP_V3 27 +#define KERN_KDWRITETR_V3 28 + +#define CTL_KERN_NAMES { \ + { 0, 0 }, \ + { "ostype", CTLTYPE_STRING }, \ + { "osrelease", CTLTYPE_STRING }, \ + { "osrevision", CTLTYPE_INT }, \ + { "version", CTLTYPE_STRING }, \ + { "maxvnodes", CTLTYPE_INT }, \ + { "maxproc", CTLTYPE_INT }, \ + { "maxfiles", CTLTYPE_INT }, \ + { "argmax", CTLTYPE_INT }, \ + { "securelevel", CTLTYPE_INT }, \ + { "hostname", CTLTYPE_STRING }, \ + { "hostid", CTLTYPE_INT }, \ + { "clockrate", CTLTYPE_STRUCT }, \ + { "vnode", CTLTYPE_STRUCT }, \ + { "proc", CTLTYPE_STRUCT }, \ + { "file", CTLTYPE_STRUCT }, \ + { "profiling", CTLTYPE_NODE }, \ + { "posix1version", CTLTYPE_INT }, \ + { "ngroups", CTLTYPE_INT }, \ + { "job_control", CTLTYPE_INT }, \ + { "saved_ids", CTLTYPE_INT }, \ + { "boottime", CTLTYPE_STRUCT }, \ + { "nisdomainname", CTLTYPE_STRING }, \ + { "maxpartitions", CTLTYPE_INT }, \ + { "kdebug", CTLTYPE_INT }, \ + { "update", CTLTYPE_INT }, \ + { "osreldate", CTLTYPE_INT }, \ + { "ntp_pll", CTLTYPE_NODE }, \ + { "bootfile", CTLTYPE_STRING }, \ + { "maxfilesperproc", CTLTYPE_INT }, \ + { "maxprocperuid", CTLTYPE_INT }, \ + { "dumpdev", CTLTYPE_STRUCT }, /* we lie; don't print as int */ \ + { "ipc", CTLTYPE_NODE }, \ + { "dummy", CTLTYPE_INT }, \ + { "dummy", CTLTYPE_INT }, \ + { "usrstack", CTLTYPE_INT }, \ + { "logsigexit", CTLTYPE_INT }, \ + { "symfile",CTLTYPE_STRING },\ + { "procargs",CTLTYPE_STRUCT },\ + { "dummy", CTLTYPE_INT }, /* deprecated pcsamples */ \ + { "netboot", CTLTYPE_INT }, \ + { "dummy", CTLTYPE_INT }, /* deprecated: panicinfo */ \ + { "sysv", CTLTYPE_NODE }, \ + { "dummy", CTLTYPE_INT }, \ + { "dummy", CTLTYPE_INT }, \ + { "exec", CTLTYPE_NODE }, \ + { "aiomax", CTLTYPE_INT }, \ + { "aioprocmax", CTLTYPE_INT }, \ + { "aiothreads", CTLTYPE_INT }, \ + { "procargs2",CTLTYPE_STRUCT }, \ + { "corefile",CTLTYPE_STRING }, \ + { "coredump", CTLTYPE_INT }, \ + { "sugid_coredump", CTLTYPE_INT }, \ + { "delayterm", CTLTYPE_INT }, \ + { "shreg_private", CTLTYPE_INT }, \ + { "proc_low_pri_io", CTLTYPE_INT }, \ + { "low_pri_window", CTLTYPE_INT }, \ + { "low_pri_delay", CTLTYPE_INT }, \ + { "posix", CTLTYPE_NODE }, \ + { "usrstack64", CTLTYPE_QUAD }, \ + { "nx", CTLTYPE_INT }, \ + { "tfp", CTLTYPE_NODE }, \ + { "procname", CTLTYPE_STRING }, \ + { "threadsigaltstack", CTLTYPE_INT }, \ + { "speculative_reads_disabled", CTLTYPE_INT }, \ + { "osversion", CTLTYPE_STRING }, \ + { "safeboot", CTLTYPE_INT }, \ + { "dummy", CTLTYPE_INT }, /* deprecated: lctx */ \ + { "rage_vnode", CTLTYPE_INT }, \ + { "tty", CTLTYPE_NODE }, \ + { "check_openevt", CTLTYPE_INT }, \ + { "thread_name", CTLTYPE_STRING } \ +} + +/* + * CTL_VFS identifiers + */ +#define CTL_VFS_NAMES { \ + { "vfsconf", CTLTYPE_STRUCT } \ +} + +/* + * KERN_PROC subtypes + */ +#define KERN_PROC_ALL 0 /* everything */ +#define KERN_PROC_PID 1 /* by process id */ +#define KERN_PROC_PGRP 2 /* by process group id */ +#define KERN_PROC_SESSION 3 /* by session of pid */ +#define KERN_PROC_TTY 4 /* by controlling tty */ +#define KERN_PROC_UID 5 /* by effective uid */ +#define KERN_PROC_RUID 6 /* by real uid */ +#define KERN_PROC_LCID 7 /* by login context id */ + +/* + * KERN_VFSNSPACE subtypes + */ +#define KERN_VFSNSPACE_HANDLE_PROC 1 +#define KERN_VFSNSPACE_UNHANDLE_PROC 2 + +/* + * KERN_PROC subtype ops return arrays of augmented proc structures: + */ + +struct _pcred { + char pc_lock[72]; /* opaque content */ + struct ucred *pc_ucred; /* Current credentials. */ + uid_t p_ruid; /* Real user id. */ + uid_t p_svuid; /* Saved effective user id. */ + gid_t p_rgid; /* Real group id. */ + gid_t p_svgid; /* Saved effective group id. */ + int p_refcnt; /* Number of references. */ +}; + +struct _ucred { + int32_t cr_ref; /* reference count */ + uid_t cr_uid; /* effective user id */ + short cr_ngroups; /* number of groups */ + gid_t cr_groups[NGROUPS]; /* groups */ +}; + +struct kinfo_proc { + struct extern_proc kp_proc; /* proc structure */ + struct eproc { + struct proc *e_paddr; /* address of proc */ + struct session *e_sess; /* session pointer */ + struct _pcred e_pcred; /* process credentials */ + struct _ucred e_ucred; /* current credentials */ + struct vmspace e_vm; /* address space */ + pid_t e_ppid; /* parent process id */ + pid_t e_pgid; /* process group id */ + short e_jobc; /* job control counter */ + dev_t e_tdev; /* controlling tty dev */ + pid_t e_tpgid; /* tty process group id */ + struct session *e_tsess; /* tty session pointer */ +#define WMESGLEN 7 + char e_wmesg[WMESGLEN + 1]; /* wchan message */ + segsz_t e_xsize; /* text size */ + short e_xrssize; /* text rss */ + short e_xccount; /* text references */ + short e_xswrss; + int32_t e_flag; +#define EPROC_CTTY 0x01 /* controlling tty vnode active */ +#define EPROC_SLEADER 0x02 /* session leader */ +#define COMAPT_MAXLOGNAME 12 + char e_login[COMAPT_MAXLOGNAME]; /* short setlogin() name */ + int32_t e_spare[4]; + } kp_eproc; +}; + + + +/* + * KERN_IPC identifiers + */ +#define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ +#define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ +#define KIPC_SOMAXCONN 3 /* int: max length of connection q */ +#define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ +#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ +#define KIPC_MAX_HDR 6 /* int: max total length of headers */ +#define KIPC_MAX_DATALEN 7 /* int: max length of data? */ +#define KIPC_MBSTAT 8 /* struct: mbuf usage statistics */ +#define KIPC_NMBCLUSTERS 9 /* int: maximum mbuf clusters */ +#define KIPC_SOQLIMITCOMPAT 10 /* int: socket queue limit */ + +/* + * CTL_VM identifiers + */ +#define VM_METER 1 /* struct vmmeter */ +#define VM_LOADAVG 2 /* struct loadavg */ +/* + * Note: "3" was skipped sometime ago and should probably remain unused + * to avoid any new entry from being accepted by older kernels... + */ +#define VM_MACHFACTOR 4 /* struct loadavg with mach factor*/ +#define VM_SWAPUSAGE 5 /* total swap usage */ +#define VM_MAXID 6 /* number of valid vm ids */ + +#define CTL_VM_NAMES { \ + { 0, 0 }, \ + { "vmmeter", CTLTYPE_STRUCT }, \ + { "loadavg", CTLTYPE_STRUCT }, \ + { 0, 0 }, /* placeholder for "3" (see comment above) */ \ + { "dummy", CTLTYPE_INT }, \ + { "swapusage", CTLTYPE_STRUCT } \ +} + +struct xsw_usage { + u_int64_t xsu_total; + u_int64_t xsu_avail; + u_int64_t xsu_used; + u_int32_t xsu_pagesize; + boolean_t xsu_encrypted; +}; + +#ifdef __APPLE_API_PRIVATE +/* Load average structure. Use of fixpt_t assume in scope. */ +/* XXX perhaps we should protect fixpt_t, and define it here (or discard it) */ +struct loadavg { + fixpt_t ldavg[3]; + long fscale; +}; +extern struct loadavg averunnable; +#define LSCALE 1000 /* scaling for "fixed point" arithmetic */ + +#endif /* __APPLE_API_PRIVATE */ + + +/* + * CTL_HW identifiers + */ +#define HW_MACHINE 1 /* string: machine class (deprecated: use HW_PRODUCT) */ +#define HW_MODEL 2 /* string: specific machine model (deprecated: use HW_TARGET) */ +#define HW_NCPU 3 /* int: number of cpus */ +#define HW_BYTEORDER 4 /* int: machine byte order */ +#define HW_PHYSMEM 5 /* int: total memory */ +#define HW_USERMEM 6 /* int: non-kernel memory */ +#define HW_PAGESIZE 7 /* int: software page size */ +#define HW_DISKNAMES 8 /* strings: disk drive names */ +#define HW_DISKSTATS 9 /* struct: diskstats[] */ +#define HW_EPOCH 10 /* int: 0 for Legacy, else NewWorld */ +#define HW_FLOATINGPT 11 /* int: has HW floating point? */ +#define HW_MACHINE_ARCH 12 /* string: machine architecture */ +#define HW_VECTORUNIT 13 /* int: has HW vector unit? */ +#define HW_BUS_FREQ 14 /* int: Bus Frequency */ +#define HW_CPU_FREQ 15 /* int: CPU Frequency */ +#define HW_CACHELINE 16 /* int: Cache Line Size in Bytes */ +#define HW_L1ICACHESIZE 17 /* int: L1 I Cache Size in Bytes */ +#define HW_L1DCACHESIZE 18 /* int: L1 D Cache Size in Bytes */ +#define HW_L2SETTINGS 19 /* int: L2 Cache Settings */ +#define HW_L2CACHESIZE 20 /* int: L2 Cache Size in Bytes */ +#define HW_L3SETTINGS 21 /* int: L3 Cache Settings */ +#define HW_L3CACHESIZE 22 /* int: L3 Cache Size in Bytes */ +#define HW_TB_FREQ 23 /* int: Bus Frequency */ +#define HW_MEMSIZE 24 /* uint64_t: physical ram size */ +#define HW_AVAILCPU 25 /* int: number of available CPUs */ +#define HW_TARGET 26 /* string: model identifier */ +#define HW_PRODUCT 27 /* string: product identifier */ +#define HW_MAXID 28 /* number of valid hw ids */ + +#define CTL_HW_NAMES { \ + { 0, 0 }, \ + { "machine", CTLTYPE_STRING }, /* Deprecated: use hw.product */ \ + { "model", CTLTYPE_STRING }, /* Deprecated: use hw.target */ \ + { "ncpu", CTLTYPE_INT }, \ + { "byteorder", CTLTYPE_INT }, \ + { "physmem", CTLTYPE_INT }, \ + { "usermem", CTLTYPE_INT }, \ + { "pagesize", CTLTYPE_INT }, \ + { "disknames", CTLTYPE_STRUCT }, \ + { "diskstats", CTLTYPE_STRUCT }, \ + { "epoch", CTLTYPE_INT }, \ + { "floatingpoint", CTLTYPE_INT }, \ + { "machinearch", CTLTYPE_STRING }, \ + { "vectorunit", CTLTYPE_INT }, \ + { "busfrequency", CTLTYPE_INT }, \ + { "cpufrequency", CTLTYPE_INT }, \ + { "cachelinesize", CTLTYPE_INT }, \ + { "l1icachesize", CTLTYPE_INT }, \ + { "l1dcachesize", CTLTYPE_INT }, \ + { "l2settings", CTLTYPE_INT }, \ + { "l2cachesize", CTLTYPE_INT }, \ + { "l3settings", CTLTYPE_INT }, \ + { "l3cachesize", CTLTYPE_INT }, \ + { "tbfrequency", CTLTYPE_INT }, \ + { "memsize", CTLTYPE_QUAD }, \ + { "availcpu", CTLTYPE_INT }, \ + { "target", CTLTYPE_STRING }, \ + { "product", CTLTYPE_STRING }, \ +} + +/* + * XXX This information should be moved to the man page. + * + * These are the support HW selectors for sysctlbyname. Parameters that are byte counts or frequencies are 64 bit numbers. + * All other parameters are 32 bit numbers. + * + * hw.memsize - The number of bytes of physical memory in the system. + * + * hw.ncpu - The maximum number of processors that could be available this boot. + * Use this value for sizing of static per processor arrays; i.e. processor load statistics. + * + * hw.activecpu - The number of processors currently available for executing threads. + * Use this number to determine the number threads to create in SMP aware applications. + * This number can change when power management modes are changed. + * + * hw.physicalcpu - The number of physical processors available in the current power management mode. + * hw.physicalcpu_max - The maximum number of physical processors that could be available this boot + * + * hw.logicalcpu - The number of logical processors available in the current power management mode. + * hw.logicalcpu_max - The maximum number of logical processors that could be available this boot + * + * hw.tbfrequency - This gives the time base frequency used by the OS and is the basis of all timing services. + * In general is is better to use mach's or higher level timing services, but this value + * is needed to convert the PPC Time Base registers to real time. + * + * hw.cpufrequency - These values provide the current, min and max cpu frequency. The min and max are for + * hw.cpufrequency_max - all power management modes. The current frequency is the max frequency in the current mode. + * hw.cpufrequency_min - All frequencies are in Hz. + * + * hw.busfrequency - These values provide the current, min and max bus frequency. The min and max are for + * hw.busfrequency_max - all power management modes. The current frequency is the max frequency in the current mode. + * hw.busfrequency_min - All frequencies are in Hz. + * + * hw.cputype - These values provide the mach-o cpu type and subtype. A complete list is in + * hw.cpusubtype - These values should be used to determine what processor family the running cpu is from so that + * the best binary can be chosen, or the best dynamic code generated. They should not be used + * to determine if a given processor feature is available. + * hw.cputhreadtype - This value will be present if the processor supports threads. Like hw.cpusubtype this selector + * should not be used to infer features, and only used to name the processors thread architecture. + * The values are defined in + * + * hw.byteorder - Gives the byte order of the processor. 4321 for big endian, 1234 for little. + * + * hw.pagesize - Gives the size in bytes of the pages used by the processor and VM system. + * + * hw.cachelinesize - Gives the size in bytes of the processor's cache lines. + * This value should be use to control the strides of loops that use cache control instructions + * like dcbz, dcbt or dcbst. + * + * hw.l1dcachesize - These values provide the size in bytes of the L1, L2 and L3 caches. If a cache is not present + * hw.l1icachesize - then the selector will return and error. + * hw.l2cachesize - + * hw.l3cachesize - + * + * hw.packages - Gives the number of processor packages. + * + * These are the selectors for optional processor features for specific processors. Selectors that return errors are not support + * on the system. Supported features will return 1 if they are recommended or 0 if they are supported but are not expected to help . + * performance. Future versions of these selectors may return larger values as necessary so it is best to test for non zero. + * + * For PowerPC: + * + * hw.optional.floatingpoint - Floating Point Instructions + * hw.optional.altivec - AltiVec Instructions + * hw.optional.graphicsops - Graphics Operations + * hw.optional.64bitops - 64-bit Instructions + * hw.optional.fsqrt - HW Floating Point Square Root Instruction + * hw.optional.stfiwx - Store Floating Point as Integer Word Indexed Instructions + * hw.optional.dcba - Data Cache Block Allocate Instruction + * hw.optional.datastreams - Data Streams Instructions + * hw.optional.dcbtstreams - Data Cache Block Touch Steams Instruction Form + * + * For x86 Architecture: + * + * hw.optional.floatingpoint - Floating Point Instructions + * hw.optional.mmx - Original MMX vector instructions + * hw.optional.sse - Streaming SIMD Extensions + * hw.optional.sse2 - Streaming SIMD Extensions 2 + * hw.optional.sse3 - Streaming SIMD Extensions 3 + * hw.optional.supplementalsse3 - Supplemental Streaming SIMD Extensions 3 + * hw.optional.x86_64 - 64-bit support + */ + + +/* + * CTL_USER definitions + */ +#define USER_CS_PATH 1 /* string: _CS_PATH */ +#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ +#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ +#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ +#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ +#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ +#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ +#define USER_LINE_MAX 8 /* int: LINE_MAX */ +#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ +#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ +#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ +#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ +#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ +#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ +#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ +#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ +#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ +#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ +#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ +#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ +#define USER_MAXID 21 /* number of valid user ids */ + +#define CTL_USER_NAMES { \ + { 0, 0 }, \ + { "cs_path", CTLTYPE_STRING }, \ + { "bc_base_max", CTLTYPE_INT }, \ + { "bc_dim_max", CTLTYPE_INT }, \ + { "bc_scale_max", CTLTYPE_INT }, \ + { "bc_string_max", CTLTYPE_INT }, \ + { "coll_weights_max", CTLTYPE_INT }, \ + { "expr_nest_max", CTLTYPE_INT }, \ + { "line_max", CTLTYPE_INT }, \ + { "re_dup_max", CTLTYPE_INT }, \ + { "posix2_version", CTLTYPE_INT }, \ + { "posix2_c_bind", CTLTYPE_INT }, \ + { "posix2_c_dev", CTLTYPE_INT }, \ + { "posix2_char_term", CTLTYPE_INT }, \ + { "posix2_fort_dev", CTLTYPE_INT }, \ + { "posix2_fort_run", CTLTYPE_INT }, \ + { "posix2_localedef", CTLTYPE_INT }, \ + { "posix2_sw_dev", CTLTYPE_INT }, \ + { "posix2_upe", CTLTYPE_INT }, \ + { "stream_max", CTLTYPE_INT }, \ + { "tzname_max", CTLTYPE_INT } \ +} + + + +/* + * CTL_DEBUG definitions + * + * Second level identifier specifies which debug variable. + * Third level identifier specifies which stucture component. + */ +#define CTL_DEBUG_NAME 0 /* string: variable name */ +#define CTL_DEBUG_VALUE 1 /* int: variable value */ +#define CTL_DEBUG_MAXID 20 + + +#if (CTL_MAXID != 9) || (KERN_MAXID != 72) || (VM_MAXID != 6) || (HW_MAXID != 28) || (USER_MAXID != 21) || (CTL_DEBUG_MAXID != 20) +#error Use the SYSCTL_*() macros and OID_AUTO instead! +#endif + + + +__BEGIN_DECLS +int sysctl(int *, u_int, void *, size_t *, void *, size_t); +int sysctlbyname(const char *, void *, size_t *, void *, size_t); +int sysctlnametomib(const char *, int *, size_t *); +__END_DECLS + + + +#endif /* SYSCTL_DEF_ENABLED */ + + +#endif /* !_SYS_SYSCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/syslimits.h b/lib/libc/include/aarch64-macos-gnu/sys/syslimits.h new file mode 100644 index 0000000000..ee8da5a411 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/syslimits.h @@ -0,0 +1,125 @@ +/* + * 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@ + */ +/* $NetBSD: syslimits.h,v 1.15 1997/06/25 00:48:09 lukem Exp $ */ + +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)syslimits.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _SYS_SYSLIMITS_H_ +#define _SYS_SYSLIMITS_H_ + +#include + +#if !defined(_ANSI_SOURCE) + +/* max bytes for an exec function */ +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) +#define ARG_MAX (1024 * 1024) +#else +#define ARG_MAX (256 * 1024) +#endif + +/* + * Note: CHILD_MAX *must* be less than hard_maxproc, which is set at + * compile time; you *cannot* set it higher than the hard limit!! + */ + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define CHILD_MAX 266 /* max simultaneous processes */ +#define GID_MAX 2147483647U /* max value for a gid_t (2^31-2) */ +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#define LINK_MAX 32767 /* max file link count */ +#define MAX_CANON 1024 /* max bytes in term canon input line */ +#define MAX_INPUT 1024 /* max bytes in terminal input */ +#define NAME_MAX 255 /* max bytes in a file name */ +#define NGROUPS_MAX 16 /* max supplemental group id's */ +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +#define UID_MAX 2147483647U /* max value for a uid_t (2^31-2) */ + +#define OPEN_MAX 10240 /* max open files per process - todo, make a config option? */ + +#endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ +#define PATH_MAX 1024 /* max bytes in pathname */ +#define PIPE_BUF 512 /* max bytes for atomic pipe writes */ + +#define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */ +#define BC_DIM_MAX 2048 /* max array elements in bc(1) */ +#define BC_SCALE_MAX 99 /* max scale value in bc(1) */ +#define BC_STRING_MAX 1000 /* max const string length in bc(1) */ +#define CHARCLASS_NAME_MAX 14 /* max character class name size */ +#define COLL_WEIGHTS_MAX 2 /* max weights for order keyword */ +#define EQUIV_CLASS_MAX 2 +#define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */ +#define LINE_MAX 2048 /* max bytes in an input line */ +#define RE_DUP_MAX 255 /* max RE's in interval notation */ + +#if __DARWIN_UNIX03 +#define NZERO 20 /* default priority [XSI] */ + /* = ((PRIO_MAX - PRIO_MIN) / 2) + 1 */ + /* range: 0 - 39 [(2 * NZERO) - 1] */ + /* 0 is not actually used */ +#else /* !__DARWIN_UNIX03 */ +#define NZERO 0 /* default priority */ + /* range: -20 - 20 */ + /* (PRIO_MIN - PRIO_MAX) */ +#endif /* __DARWIN_UNIX03 */ +#endif /* !_ANSI_SOURCE */ + +#endif /* !_SYS_SYSLIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/uio.h b/lib/libc/include/aarch64-macos-gnu/sys/uio.h new file mode 100644 index 0000000000..619a8f1786 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/uio.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2000-2019 Apple Inc. All rights reserved. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ + */ +/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ +/* + * Copyright (c) 1982, 1986, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)uio.h 8.5 (Berkeley) 2/22/94 + */ + +#ifndef _SYS_UIO_H_ +#define _SYS_UIO_H_ + +#include +#include +#include +#include + +/* + * [XSI] The ssize_t and size_t types shall be defined as described + * in . + */ +#include +#include + +/* + * [XSI] Structure whose address is passed as the second parameter to the + * readv(), preadv(), writev() and pwritev() functions. + */ +#include + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* + * IO direction for uio_t. + * UIO_READ - data moves into iovec(s) associated with uio_t + * UIO_WRITE - data moves out of iovec(s) associated with uio_t + */ +enum uio_rw { UIO_READ, UIO_WRITE }; +#endif + + + +__BEGIN_DECLS +ssize_t readv(int, const struct iovec *, int) __DARWIN_ALIAS_C(readv); +ssize_t writev(int, const struct iovec *, int) __DARWIN_ALIAS_C(writev); + +#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) + +ssize_t preadv(int, const struct iovec *, int, off_t) __DARWIN_NOCANCEL(preadv) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)); +ssize_t pwritev(int, const struct iovec *, int, off_t) __DARWIN_NOCANCEL(pwritev) __API_AVAILABLE(macos(11.0), ios(14.0), watchos(7.0), tvos(14.0)); + +#endif /* #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) */ + +__END_DECLS + + +#endif /* !_SYS_UIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/sys/un.h b/lib/libc/include/aarch64-macos-gnu/sys/un.h new file mode 100644 index 0000000000..305196b361 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/sys/un.h @@ -0,0 +1,106 @@ +/* + * 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) 1982, 1986, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 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. + * + * @(#)un.h 8.3 (Berkeley) 2/19/95 + */ + +#ifndef _SYS_UN_H_ +#define _SYS_UN_H_ + +#include +#include +#include + +/* [XSI] The sa_family_t type shall be defined as described in */ +#include + +/* + * [XSI] Definitions for UNIX IPC domain. + */ +struct sockaddr_un { + unsigned char sun_len; /* sockaddr len including null */ + sa_family_t sun_family; /* [XSI] AF_UNIX */ + char sun_path[104]; /* [XSI] path name (gag) */ +}; + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) + +/* Level number of get/setsockopt for local domain sockets */ +#define SOL_LOCAL 0 + +/* Socket options. */ +#define LOCAL_PEERCRED 0x001 /* retrieve peer credentials */ +#define LOCAL_PEERPID 0x002 /* retrieve peer pid */ +#define LOCAL_PEEREPID 0x003 /* retrieve eff. peer pid */ +#define LOCAL_PEERUUID 0x004 /* retrieve peer UUID */ +#define LOCAL_PEEREUUID 0x005 /* retrieve eff. peer UUID */ +#define LOCAL_PEERTOKEN 0x006 /* retrieve peer audit token */ + +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + + +#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) +/* actual length of an initialized sockaddr_un */ +#define SUN_LEN(su) \ + (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) +#endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ + + +#endif /* !_SYS_UN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/xlocale/_inttypes.h b/lib/libc/include/aarch64-macos-gnu/xlocale/_inttypes.h new file mode 100644 index 0000000000..1323b05e23 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/xlocale/_inttypes.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2005 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 _XLOCALE__INTTYPES_H_ +#define _XLOCALE__INTTYPES_H_ + +#include +#include +#include /* wchar_t */ +#include <_xlocale.h> + +__BEGIN_DECLS +intmax_t strtoimax_l(const char * __restrict nptr, char ** __restrict endptr, + int base, locale_t); +uintmax_t strtoumax_l(const char * __restrict nptr, char ** __restrict endptr, + int base, locale_t); +intmax_t wcstoimax_l(const wchar_t * __restrict nptr, + wchar_t ** __restrict endptr, int base, locale_t); +uintmax_t wcstoumax_l(const wchar_t * __restrict nptr, + wchar_t ** __restrict endptr, int base, locale_t); + +/* Poison the following routines if -fshort-wchar is set */ +#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU +#pragma GCC poison wcstoimax_l wcstoumax_l +#endif +__END_DECLS + +#endif /* _XLOCALE__INTTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/xlocale/_wchar.h b/lib/libc/include/aarch64-macos-gnu/xlocale/_wchar.h new file mode 100644 index 0000000000..99a2e4f259 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/xlocale/_wchar.h @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2005 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 _XLOCALE__WCHAR_H_ +#define _XLOCALE__WCHAR_H_ + +#include <_stdio.h> +#include <_xlocale.h> +#include +#include +#include /* wchar_t */ + +/* Initially added in Issue 4 */ +__BEGIN_DECLS +wint_t btowc_l(int, locale_t); +wint_t fgetwc_l(FILE *, locale_t); +wchar_t *fgetws_l(wchar_t * __restrict, int, FILE * __restrict, locale_t); +wint_t fputwc_l(wchar_t, FILE *, locale_t); +int fputws_l(const wchar_t * __restrict, FILE * __restrict, locale_t); +int fwprintf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, ...); +int fwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, ...); +wint_t getwc_l(FILE *, locale_t); +wint_t getwchar_l(locale_t); +size_t mbrlen_l(const char * __restrict, size_t, mbstate_t * __restrict, + locale_t); +size_t mbrtowc_l(wchar_t * __restrict, const char * __restrict, size_t, + mbstate_t * __restrict, locale_t); +int mbsinit_l(const mbstate_t *, locale_t); +size_t mbsrtowcs_l(wchar_t * __restrict, const char ** __restrict, size_t, + mbstate_t * __restrict, locale_t); +wint_t putwc_l(wchar_t, FILE *, locale_t); +wint_t putwchar_l(wchar_t, locale_t); +int swprintf_l(wchar_t * __restrict, size_t n, locale_t, + const wchar_t * __restrict, ...); +int swscanf_l(const wchar_t * __restrict, locale_t, + const wchar_t * __restrict, ...); +wint_t ungetwc_l(wint_t, FILE *, locale_t); +int vfwprintf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, + __darwin_va_list); +int vswprintf_l(wchar_t * __restrict, size_t n, locale_t, + const wchar_t * __restrict, __darwin_va_list); +int vwprintf_l(locale_t, const wchar_t * __restrict, __darwin_va_list); +size_t wcrtomb_l(char * __restrict, wchar_t, mbstate_t * __restrict, + locale_t); +int wcscoll_l(const wchar_t *, const wchar_t *, locale_t); +size_t wcsftime_l(wchar_t * __restrict, size_t, const wchar_t * __restrict, + const struct tm * __restrict, locale_t) + __DARWIN_ALIAS(wcsftime_l); +size_t wcsrtombs_l(char * __restrict, const wchar_t ** __restrict, size_t, + mbstate_t * __restrict, locale_t); +double wcstod_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); +long wcstol_l(const wchar_t * __restrict, wchar_t ** __restrict, int, + locale_t); +unsigned long + wcstoul_l(const wchar_t * __restrict, wchar_t ** __restrict, int, + locale_t); +int wcswidth_l(const wchar_t *, size_t, locale_t); +size_t wcsxfrm_l(wchar_t * __restrict, const wchar_t * __restrict, size_t, + locale_t); +int wctob_l(wint_t, locale_t); +int wcwidth_l(wchar_t, locale_t); +int wprintf_l(locale_t, const wchar_t * __restrict, ...); +int wscanf_l(locale_t, const wchar_t * __restrict, ...); +__END_DECLS + + + +/* Additional functionality provided by: + * POSIX.1-2001 + */ + +#if __DARWIN_C_LEVEL >= 200112L +__BEGIN_DECLS +int vfwscanf_l(FILE * __restrict, locale_t, const wchar_t * __restrict, + __darwin_va_list); +int vswscanf_l(const wchar_t * __restrict, locale_t, + const wchar_t * __restrict, __darwin_va_list); +int vwscanf_l(locale_t, const wchar_t * __restrict, __darwin_va_list); +float wcstof_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); +long double + wcstold_l(const wchar_t * __restrict, wchar_t ** __restrict, locale_t); +#if !__DARWIN_NO_LONG_LONG +long long + wcstoll_l(const wchar_t * __restrict, wchar_t ** __restrict, int, + locale_t); +unsigned long long + wcstoull_l(const wchar_t * __restrict, wchar_t ** __restrict, int, + locale_t); +#endif /* !__DARWIN_NO_LONG_LONG */ +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 200112L */ + + + +/* Additional functionality provided by: + * POSIX.1-2008 + */ + +#if __DARWIN_C_LEVEL >= 200809L +__BEGIN_DECLS +size_t mbsnrtowcs_l(wchar_t * __restrict, const char ** __restrict, size_t, + size_t, mbstate_t * __restrict, locale_t); +int wcscasecmp_l(const wchar_t *, const wchar_t *, locale_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +int wcsncasecmp_l(const wchar_t *, const wchar_t *, size_t n, locale_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +size_t wcsnrtombs_l(char * __restrict, const wchar_t ** __restrict, size_t, + size_t, mbstate_t * __restrict, locale_t); +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= 200809L */ + + + +/* Darwin extensions */ + +#if __DARWIN_C_LEVEL >= __DARWIN_C_FULL +__BEGIN_DECLS +wchar_t *fgetwln_l(FILE * __restrict, size_t *, locale_t) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); +__END_DECLS +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ + + + +/* Poison the following routines if -fshort-wchar is set */ +#if !defined(__cplusplus) && defined(__WCHAR_MAX__) && __WCHAR_MAX__ <= 0xffffU +#pragma GCC poison fgetwln_l fgetws_l fputwc_l fputws_l fwprintf_l fwscanf_l mbrtowc_l mbsnrtowcs_l mbsrtowcs_l putwc_l putwchar_l swprintf_l swscanf_l vfwprintf_l vfwscanf_l vswprintf_l vswscanf_l vwprintf_l vwscanf_l wcrtomb_l wcscoll_l wcsftime_l wcsftime_l wcsnrtombs_l wcsrtombs_l wcstod_l wcstof_l wcstol_l wcstold_l wcstoll_l wcstoul_l wcstoull_l wcswidth_l wcsxfrm_l wcwidth_l wprintf_l wscanf_l +#endif + +#endif /* _XLOCALE__WCHAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/xpc/availability.h b/lib/libc/include/aarch64-macos-gnu/xpc/availability.h new file mode 100644 index 0000000000..4005a84bdf --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/xpc/availability.h @@ -0,0 +1,124 @@ +#ifndef __XPC_AVAILABILITY_H__ +#define __XPC_AVAILABILITY_H__ + +#include + +// Certain parts of the project use all the project's headers but have to build +// against newer OSX SDKs than ebuild uses -- liblaunch_host being the example. +// So we need to define these. +#ifndef __MAC_10_16 +#define __MAC_10_16 101600 +#endif // __MAC_10_16 + +#ifndef __MAC_10_15 +#define __MAC_10_15 101500 +#define __AVAILABILITY_INTERNAL__MAC_10_15 \ +__attribute__((availability(macosx, introduced=10.15))) +#endif // __MAC_10_15 + +#ifndef __MAC_10_14 +#define __MAC_10_14 101400 +#define __AVAILABILITY_INTERNAL__MAC_10_14 \ +__attribute__((availability(macosx, introduced=10.14))) +#endif // __MAC_10_14 + +#ifndef __MAC_10_13 +#define __MAC_10_13 101300 +#define __AVAILABILITY_INTERNAL__MAC_10_13 \ + __attribute__((availability(macosx, introduced=10.13))) +#endif // __MAC_10_13 + +#ifndef __MAC_10_12 +#define __MAC_10_12 101200 +#define __AVAILABILITY_INTERNAL__MAC_10_12 \ + __attribute__((availability(macosx, introduced=10.12))) +#endif // __MAC_10_12 + +#ifndef __MAC_10_11 +#define __MAC_10_11 101100 +#define __AVAILABILITY_INTERNAL__MAC_10_11 \ + __attribute__((availability(macosx, introduced=10.11))) +#endif // __MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_9_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_10_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11 +#define __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11 +#endif // __AVAILABILITY_INTERNAL__MAC_10_11_DEP__MAC_10_11 + +#ifndef __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13 +#define __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13 +#endif // __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_13 + +#if __has_include() +#include +#else // __has_include() +#ifndef IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED +#define IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED 999999 +#endif // IPHONE_SIMULATOR_HOST_MIN_VERSION_REQUIRED +#endif // __has_include() + +#ifndef __WATCHOS_UNAVAILABLE +#define __WATCHOS_UNAVAILABLE +#endif + +#ifndef __TVOS_UNAVAILABLE +#define __TVOS_UNAVAILABLE +#endif + +// simulator host-side bits build against SDKs not having __*_AVAILABLE() yet +#ifndef __OSX_AVAILABLE +#define __OSX_AVAILABLE(...) +#endif + +#ifndef __IOS_AVAILABLE +#define __IOS_AVAILABLE(...) +#endif + +#ifndef __TVOS_AVAILABLE +#define __TVOS_AVAILABLE(...) +#endif + +#ifndef __WATCHOS_AVAILABLE +#define __WATCHOS_AVAILABLE(...) +#endif + +#ifndef __API_AVAILABLE +#define __API_AVAILABLE(...) +#endif + +#endif // __XPC_AVAILABILITY_H__ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/xpc/base.h b/lib/libc/include/aarch64-macos-gnu/xpc/base.h new file mode 100644 index 0000000000..ab708965cc --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/xpc/base.h @@ -0,0 +1,213 @@ +// Copyright (c) 2009-2011 Apple Inc. All rights reserved. + +#ifndef __XPC_BASE_H__ +#define __XPC_BASE_H__ + +#include + +__BEGIN_DECLS + +#if !defined(__has_include) +#define __has_include(x) 0 +#endif // !defined(__has_include) + +#if !defined(__has_attribute) +#define __has_attribute(x) 0 +#endif // !defined(__has_attribute) + +#if !defined(__has_feature) +#define __has_feature(x) 0 +#endif // !defined(__has_feature) + +#if !defined(__has_extension) +#define __has_extension(x) 0 +#endif // !defined(__has_extension) + +#if __has_include() +#include +#else // __has_include() +#include +#endif // __has_include() + +#include + +#ifndef __XPC_INDIRECT__ +#error "Please #include instead of this file directly." +#endif // __XPC_INDIRECT__ + +#pragma mark Attribute Shims +#ifdef __GNUC__ +#define XPC_CONSTRUCTOR __attribute__((constructor)) +#define XPC_NORETURN __attribute__((__noreturn__)) +#define XPC_NOTHROW __attribute__((__nothrow__)) +#define XPC_NONNULL1 __attribute__((__nonnull__(1))) +#define XPC_NONNULL2 __attribute__((__nonnull__(2))) +#define XPC_NONNULL3 __attribute__((__nonnull__(3))) +#define XPC_NONNULL4 __attribute__((__nonnull__(4))) +#define XPC_NONNULL5 __attribute__((__nonnull__(5))) +#define XPC_NONNULL6 __attribute__((__nonnull__(6))) +#define XPC_NONNULL7 __attribute__((__nonnull__(7))) +#define XPC_NONNULL8 __attribute__((__nonnull__(8))) +#define XPC_NONNULL9 __attribute__((__nonnull__(9))) +#define XPC_NONNULL10 __attribute__((__nonnull__(10))) +#define XPC_NONNULL11 __attribute__((__nonnull__(11))) +#define XPC_NONNULL_ALL __attribute__((__nonnull__)) +#define XPC_SENTINEL __attribute__((__sentinel__)) +#define XPC_PURE __attribute__((__pure__)) +#define XPC_WARN_RESULT __attribute__((__warn_unused_result__)) +#define XPC_MALLOC __attribute__((__malloc__)) +#define XPC_UNUSED __attribute__((__unused__)) +#define XPC_USED __attribute__((__used__)) +#define XPC_PACKED __attribute__((__packed__)) +#define XPC_PRINTF(m, n) __attribute__((format(printf, m, n))) +#define XPC_INLINE static __inline__ __attribute__((__always_inline__)) +#define XPC_NOINLINE __attribute__((noinline)) +#define XPC_NOIMPL __attribute__((unavailable)) + +#if __has_attribute(noescape) +#define XPC_NOESCAPE __attribute__((__noescape__)) +#else +#define XPC_NOESCAPE +#endif + +#if __has_extension(attribute_unavailable_with_message) +#define XPC_UNAVAILABLE(m) __attribute__((unavailable(m))) +#else // __has_extension(attribute_unavailable_with_message) +#define XPC_UNAVAILABLE(m) XPC_NOIMPL +#endif // __has_extension(attribute_unavailable_with_message) + +#define XPC_EXPORT extern __attribute__((visibility("default"))) +#define XPC_NOEXPORT __attribute__((visibility("hidden"))) +#define XPC_WEAKIMPORT extern __attribute__((weak_import)) +#define XPC_DEBUGGER_EXCL XPC_NOEXPORT XPC_USED +#define XPC_TRANSPARENT_UNION __attribute__((transparent_union)) +#if __clang__ +#define XPC_DEPRECATED(m) __attribute__((deprecated(m))) +#else // __clang__ +#define XPC_DEPRECATED(m) __attribute__((deprecated)) +#endif // __clang + +#if defined(__XPC_TEST__) && __XPC_TEST__ +#define XPC_TESTSTATIC +#define XPC_TESTEXTERN extern +#else // defined(__XPC_TEST__) && __XPC_TEST__ +#define XPC_TESTSTATIC static +#endif // defined(__XPC_TEST__) && __XPC_TEST__ + +#if __has_feature(objc_arc) +#define XPC_GIVES_REFERENCE __strong +#define XPC_UNRETAINED __unsafe_unretained +#define XPC_BRIDGE(xo) ((__bridge void *)(xo)) +#define XPC_BRIDGEREF_BEGIN(xo) ((__bridge_retained void *)(xo)) +#define XPC_BRIDGEREF_BEGIN_WITH_REF(xo) ((__bridge void *)(xo)) +#define XPC_BRIDGEREF_MIDDLE(xo) ((__bridge id)(xo)) +#define XPC_BRIDGEREF_END(xo) ((__bridge_transfer id)(xo)) +#else // __has_feature(objc_arc) +#define XPC_GIVES_REFERENCE +#define XPC_UNRETAINED +#define XPC_BRIDGE(xo) (xo) +#define XPC_BRIDGEREF_BEGIN(xo) (xo) +#define XPC_BRIDGEREF_BEGIN_WITH_REF(xo) (xo) +#define XPC_BRIDGEREF_MIDDLE(xo) (xo) +#define XPC_BRIDGEREF_END(xo) (xo) +#endif // __has_feature(objc_arc) + +#define _xpc_unreachable() __builtin_unreachable() +#else // __GNUC__ +/*! @parseOnly */ +#define XPC_CONSTRUCTOR +/*! @parseOnly */ +#define XPC_NORETURN +/*! @parseOnly */ +#define XPC_NOTHROW +/*! @parseOnly */ +#define XPC_NONNULL1 +/*! @parseOnly */ +#define XPC_NONNULL2 +/*! @parseOnly */ +#define XPC_NONNULL3 +/*! @parseOnly */ +#define XPC_NONNULL4 +/*! @parseOnly */ +#define XPC_NONNULL5 +/*! @parseOnly */ +#define XPC_NONNULL6 +/*! @parseOnly */ +#define XPC_NONNULL7 +/*! @parseOnly */ +#define XPC_NONNULL8 +/*! @parseOnly */ +#define XPC_NONNULL9 +/*! @parseOnly */ +#define XPC_NONNULL10 +/*! @parseOnly */ +#define XPC_NONNULL11 +/*! @parseOnly */ +#define XPC_NONNULL(n) +/*! @parseOnly */ +#define XPC_NONNULL_ALL +/*! @parseOnly */ +#define XPC_SENTINEL +/*! @parseOnly */ +#define XPC_PURE +/*! @parseOnly */ +#define XPC_WARN_RESULT +/*! @parseOnly */ +#define XPC_MALLOC +/*! @parseOnly */ +#define XPC_UNUSED +/*! @parseOnly */ +#define XPC_PACKED +/*! @parseOnly */ +#define XPC_PRINTF(m, n) +/*! @parseOnly */ +#define XPC_INLINE static inline +/*! @parseOnly */ +#define XPC_NOINLINE +/*! @parseOnly */ +#define XPC_NOIMPL +/*! @parseOnly */ +#define XPC_EXPORT extern +/*! @parseOnly */ +#define XPC_WEAKIMPORT +/*! @parseOnly */ +#define XPC_DEPRECATED +/*! @parseOnly */ +#define XPC_UNAVAILABLE(m) +/*! @parseOnly */ +#define XPC_NOESCAPE +#endif // __GNUC__ + +#if __has_feature(assume_nonnull) +#define XPC_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin") +#define XPC_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end") +#else +#define XPC_ASSUME_NONNULL_BEGIN +#define XPC_ASSUME_NONNULL_END +#endif + +#if __has_feature(nullability_on_arrays) +#define XPC_NONNULL_ARRAY _Nonnull +#else +#define XPC_NONNULL_ARRAY +#endif + +#ifdef OS_CLOSED_OPTIONS +#define XPC_FLAGS_ENUM(_name, _type, ...) \ + OS_CLOSED_OPTIONS(_name, _type, __VA_ARGS__) +#else // OS_CLOSED_ENUM +#define XPC_FLAGS_ENUM(_name, _type, ...) \ + OS_ENUM(_name, _type, __VA_ARGS__) +#endif // OS_CLOSED_ENUM + +#ifdef OS_CLOSED_ENUM +#define XPC_ENUM(_name, _type, ...) \ + OS_CLOSED_ENUM(_name, _type, __VA_ARGS__) +#else // OS_CLOSED_ENUM +#define XPC_ENUM(_name, _type, ...) \ + OS_ENUM(_name, _type, __VA_ARGS__) +#endif // OS_CLOSED_ENUM + +__END_DECLS + +#endif // __XPC_BASE_H__ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/xpc/connection.h b/lib/libc/include/aarch64-macos-gnu/xpc/connection.h new file mode 100644 index 0000000000..fda085bb12 --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/xpc/connection.h @@ -0,0 +1,748 @@ +#ifndef __XPC_CONNECTION_H__ +#define __XPC_CONNECTION_H__ + +#ifndef __XPC_INDIRECT__ +#error "Please #include instead of this file directly." +// For HeaderDoc. +#include +#endif // __XPC_INDIRECT__ + +#ifndef __BLOCKS__ +#error "XPC connections require Blocks support." +#endif // __BLOCKS__ + +XPC_ASSUME_NONNULL_BEGIN +__BEGIN_DECLS + +/*! + * @constant XPC_ERROR_CONNECTION_INTERRUPTED + * Will be delivered to the connection's event handler if the remote service + * exited. The connection is still live even in this case, and resending a + * message will cause the service to be launched on-demand. This error serves + * as a client's indication that it should resynchronize any state that it had + * given the service. + * + * Any messages in the queue to be sent will be unwound and canceled when this + * error occurs. In the case where a message waiting to be sent has a reply + * handler, that handler will be invoked with this error. In the context of the + * reply handler, this error indicates that a reply to the message will never + * arrive. + * + * Messages that do not have reply handlers associated with them will be + * silently disposed of. This error will only be given to peer connections. + */ +#define XPC_ERROR_CONNECTION_INTERRUPTED \ + XPC_GLOBAL_OBJECT(_xpc_error_connection_interrupted) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_dictionary_s _xpc_error_connection_interrupted; + +/*! + * @constant XPC_ERROR_CONNECTION_INVALID + * Will be delivered to the connection's event handler if the named service + * provided to xpc_connection_create() could not be found in the XPC service + * namespace. The connection is useless and should be disposed of. + * + * Any messages in the queue to be sent will be unwound and canceled when this + * error occurs, similarly to the behavior when XPC_ERROR_CONNECTION_INTERRUPTED + * occurs. The only difference is that the XPC_ERROR_CONNECTION_INVALID will be + * given to outstanding reply handlers and the connection's event handler. + * + * This error may be given to any type of connection. + */ +#define XPC_ERROR_CONNECTION_INVALID \ + XPC_GLOBAL_OBJECT(_xpc_error_connection_invalid) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_dictionary_s _xpc_error_connection_invalid; + +/*! + * @constant XPC_ERROR_TERMINATION_IMMINENT + * On macOS, this error will be delivered to a peer connection's event handler + * when the XPC runtime has determined that the program should exit and that + * all outstanding transactions must be wound down, and no new transactions can + * be opened. + * + * After this error has been delivered to the event handler, no more messages + * will be received by the connection. The runtime will still attempt to deliver + * outgoing messages, but this error should be treated as an indication that + * the program will exit very soon, and any outstanding business over the + * connection should be wrapped up as quickly as possible and the connection + * canceled shortly thereafter. + * + * This error will only be delivered to peer connections received through a + * listener or the xpc_main() event handler. + */ +#define XPC_ERROR_TERMINATION_IMMINENT \ + XPC_GLOBAL_OBJECT(_xpc_error_termination_imminent) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_dictionary_s _xpc_error_termination_imminent; + +/*! + * @constant XPC_CONNECTION_MACH_SERVICE_LISTENER + * Passed to xpc_connection_create_mach_service(). This flag indicates that the + * caller is the listener for the named service. This flag may only be passed + * for services which are advertised in the process' launchd.plist(5). You may + * not use this flag to dynamically add services to the Mach bootstrap + * namespace. + */ +#define XPC_CONNECTION_MACH_SERVICE_LISTENER (1 << 0) + +/*! + * @constant XPC_CONNECTION_MACH_SERVICE_PRIVILEGED + * Passed to xpc_connection_create_mach_service(). This flag indicates that the + * job advertising the service name in its launchd.plist(5) should be in the + * privileged Mach bootstrap. This is typically accomplished by placing your + * launchd.plist(5) in /Library/LaunchDaemons. If specified alongside the + * XPC_CONNECTION_MACH_SERVICE_LISTENER flag, this flag is a no-op. + */ +#define XPC_CONNECTION_MACH_SERVICE_PRIVILEGED (1 << 1) + +/*! + * @typedef xpc_finalizer_f + * A function that is invoked when a connection is being torn down and its + * context needs to be freed. The sole argument is the value that was given to + * {@link xpc_connection_set_context} or NULL if no context has been set. It is + * not safe to reference the connection from within this function. + * + * @param value + * The context object that is to be disposed of. + */ +typedef void (*xpc_finalizer_t)(void * _Nullable value); + +/*! + * @function xpc_connection_create + * Creates a new connection object. + * + * @param name + * If non-NULL, the name of the service with which to connect. The returned + * connection will be a peer. + * + * If NULL, an anonymous listener connection will be created. You can embed the + * ability to create new peer connections in an endpoint, which can be inserted + * into a message and sent to another process . + * + * @param targetq + * The GCD queue to which the event handler block will be submitted. This + * parameter may be NULL, in which case the connection's target queue will be + * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. + * The target queue may be changed later with a call to + * xpc_connection_set_target_queue(). + * + * @result + * A new connection object. The caller is responsible for disposing of the + * returned object with {@link xpc_release} when it is no longer needed. + * + * @discussion + * This method will succeed even if the named service does not exist. This is + * because the XPC namespace is not queried for the service name until the + * connection has been activated. See {@link xpc_connection_activate()}. + * + * XPC connections, like dispatch sources, are returned in an inactive state, so + * you must call {@link xpc_connection_activate()} in order to begin receiving + * events from the connection. Also like dispatch sources, connections must be + * activated and not suspended in order to be safely released. It is + * a programming error to release an inactive or suspended connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_connection_t +xpc_connection_create(const char * _Nullable name, + dispatch_queue_t _Nullable targetq); + +/*! + * @function xpc_connection_create_mach_service + * Creates a new connection object representing a Mach service. + * + * @param name + * The name of the remote service with which to connect. The service name must + * exist in a Mach bootstrap that is accessible to the process and be advertised + * in a launchd.plist. + * + * @param targetq + * The GCD queue to which the event handler block will be submitted. This + * parameter may be NULL, in which case the connection's target queue will be + * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. + * The target queue may be changed later with a call to + * xpc_connection_set_target_queue(). + * + * @param flags + * Additional attributes with which to create the connection. + * + * @result + * A new connection object. + * + * @discussion + * If the XPC_CONNECTION_MACH_SERVICE_LISTENER flag is given to this method, + * then the connection returned will be a listener connection. Otherwise, a peer + * connection will be returned. See the documentation for + * {@link xpc_connection_set_event_handler()} for the semantics of listener + * connections versus peer connections. + * + * This method will succeed even if the named service does not exist. This is + * because the Mach namespace is not queried for the service name until the + * connection has been activated. See {@link xpc_connection_activate()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_connection_t +xpc_connection_create_mach_service(const char *name, + dispatch_queue_t _Nullable targetq, uint64_t flags); + +/*! + * @function xpc_connection_create_from_endpoint + * Creates a new connection from the given endpoint. + * + * @param endpoint + * The endpoint from which to create the new connection. + * + * @result + * A new peer connection to the listener represented by the given endpoint. + * + * The same responsibilities of setting an event handler and activating the + * connection after calling xpc_connection_create() apply to the connection + * returned by this API. Since the connection yielded by this API is not + * associated with a name (and therefore is not rediscoverable), this connection + * will receive XPC_ERROR_CONNECTION_INVALID if the listening side crashes, + * exits or cancels the listener connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_connection_t +xpc_connection_create_from_endpoint(xpc_endpoint_t endpoint); + +/*! + * @function xpc_connection_set_target_queue + * Sets the target queue of the given connection. + * + * @param connection + * The connection object which is to be manipulated. + * + * @param targetq + * The GCD queue to which the event handler block will be submitted. This + * parameter may be NULL, in which case the connection's target queue will be + * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. + * + * @discussion + * Setting the target queue is asynchronous and non-preemptive and therefore + * this method will not interrupt the execution of an already-running event + * handler block. Setting the target queue may be likened to issuing a barrier + * to the connection which does the actual work of changing the target queue. + * + * The XPC runtime guarantees this non-preemptiveness even for concurrent target + * queues. If the target queue is a concurrent queue, then XPC still guarantees + * that there will never be more than one invocation of the connection's event + * handler block executing concurrently. If you wish to process events + * concurrently, you can dispatch_async(3) to a concurrent queue from within + * the event handler. + * + * IMPORTANT: When called from within the event handler block, + * dispatch_get_current_queue(3) is NOT guaranteed to return a pointer to the + * queue set with this method. + * + * Despite this seeming inconsistency, the XPC runtime guarantees that, when the + * target queue is a serial queue, the event handler block will execute + * synchonously with respect to other blocks submitted to that same queue. When + * the target queue is a concurrent queue, the event handler block may run + * concurrently with other blocks submitted to that queue, but it will never run + * concurrently with other invocations of itself for the same connection, as + * discussed previously. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_connection_set_target_queue(xpc_connection_t connection, + dispatch_queue_t _Nullable targetq); + +/*! + * @function xpc_connection_set_event_handler + * Sets the event handler block for the connection. + * + * @param connection + * The connection object which is to be manipulated. + * + * @param handler + * The event handler block. + * + * @discussion + * Setting the event handler is asynchronous and non-preemptive, and therefore + * this method will not interrupt the execution of an already-running event + * handler block. If the event handler is executing at the time of this call, it + * will finish, and then the connection's event handler will be changed before + * the next invocation of the event handler. The XPC runtime guarantees this + * non-preemptiveness even for concurrent target queues. + * + * Connection event handlers are non-reentrant, so it is safe to call + * xpc_connection_set_event_handler() from within the event handler block. + * + * The event handler's execution should be treated as a barrier to all + * connection activity. When it is executing, the connection will not attempt to + * send or receive messages, including reply messages. Thus, it is not safe to + * call xpc_connection_send_message_with_reply_sync() on the connection from + * within the event handler. + * + * You do not hold a reference on the object received as the event handler's + * only argument. Regardless of the type of object received, it is safe to call + * xpc_retain() on the object to obtain a reference to it. + * + * A connection may receive different events depending upon whether it is a + * listener or not. Any connection may receive an error in its event handler. + * But while normal connections may receive messages in addition to errors, + * listener connections will receive connections and and not messages. + * + * Connections received by listeners are equivalent to those returned by + * xpc_connection_create() with a non-NULL name argument and a NULL targetq + * argument with the exception that you do not hold a reference on them. + * You must set an event handler and activate the connection. If you do not wish + * to accept the connection, you may simply call xpc_connection_cancel() on it + * and return. The runtime will dispose of it for you. + * + * If there is an error in the connection, this handler will be invoked with the + * error dictionary as its argument. This dictionary will be one of the well- + * known XPC_ERROR_* dictionaries. + * + * Regardless of the type of event, ownership of the event object is NOT + * implicitly transferred. Thus, the object will be released and deallocated at + * some point in the future after the event handler returns. If you wish the + * event's lifetime to persist, you must retain it with xpc_retain(). + * + * Connections received through the event handler will be released and + * deallocated after the connection has gone invalid and delivered that event to + * its event handler. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_set_event_handler(xpc_connection_t connection, + xpc_handler_t handler); + +/*! + * @function xpc_connection_activate + * Activates the connection. Connections start in an inactive state, so you must + * call xpc_connection_activate() on a connection before it will send or receive + * any messages. + * + * @param connection + * The connection object which is to be manipulated. + * + * @discussion + * Calling xpc_connection_activate() on an active connection has no effect. + * Releasing the last reference on an inactive connection that was created with + * an xpc_connection_create*() call is undefined. + * + * For backward compatibility reasons, xpc_connection_resume() on an inactive + * and not otherwise suspended xpc connection has the same effect as calling + * xpc_connection_activate(). For new code, using xpc_connection_activate() + * is preferred. + */ +__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0) +__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_activate(xpc_connection_t connection); + +/*! + * @function xpc_connection_suspend + * Suspends the connection so that the event handler block will not fire and + * that the connection will not attempt to send any messages it has in its + * queue. All calls to xpc_connection_suspend() must be balanced with calls to + * xpc_connection_resume() before releasing the last reference to the + * connection. + * + * @param connection + * The connection object which is to be manipulated. + * + * @discussion + * Suspension is asynchronous and non-preemptive, and therefore this method will + * not interrupt the execution of an already-running event handler block. If + * the event handler is executing at the time of this call, it will finish, and + * then the connection will be suspended before the next scheduled invocation + * of the event handler. The XPC runtime guarantees this non-preemptiveness even + * for concurrent target queues. + * + * Connection event handlers are non-reentrant, so it is safe to call + * xpc_connection_suspend() from within the event handler block. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_suspend(xpc_connection_t connection); + +/*! + * @function xpc_connection_resume + * Resumes the connection. + * + * @param connection + * The connection object which is to be manipulated. + * + * @discussion + * In order for a connection to become live, every call to + * xpc_connection_suspend() must be balanced with a call to + * xpc_connection_resume(). + * + * For backward compatibility reasons, xpc_connection_resume() on an inactive + * and not otherwise suspended xpc connection has the same effect as calling + * xpc_connection_activate(). For new code, using xpc_connection_activate() + * is preferred. + * + * Calling xpc_connection_resume() more times than xpc_connection_suspend() + * has been called is otherwise considered an error. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_resume(xpc_connection_t connection); + +/*! + * @function xpc_connection_send_message + * Sends a message over the connection to the destination service. + * + * @param connection + * The connection over which the message shall be sent. + * + * @param message + * The message to send. This must be a dictionary object. This dictionary is + * logically copied by the connection, so it is safe to modify the dictionary + * after this call. + * + * @discussion + * Messages are delivered in FIFO order. This API is safe to call from multiple + * GCD queues. There is no indication that a message was delivered successfully. + * This is because even once the message has been successfully enqueued on the + * remote end, there are no guarantees about when the runtime will dequeue the + * message and invoke the other connection's event handler block. + * + * If this API is used to send a message that is in reply to another message, + * there is no guarantee of ordering between the invocations of the connection's + * event handler and the reply handler for that message, even if they are + * targeted to the same queue. + * + * After extensive study, we have found that clients who are interested in + * the state of the message on the server end are typically holding open + * transactions related to that message. And the only reliable way to track the + * lifetime of that transaction is at the protocol layer. So the server should + * send a reply message, which upon receiving, will cause the client to close + * its transaction. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_send_message(xpc_connection_t connection, xpc_object_t message); + +/*! + * @function xpc_connection_send_barrier + * Issues a barrier against the connection's message-send activity. + * + * @param connection + * The connection against which the barrier is to be issued. + * + * @param barrier + * The barrier block to issue. This barrier prevents concurrent message-send + * activity on the connection. No messages will be sent while the barrier block + * is executing. + * + * @discussion + * XPC guarantees that, even if the connection's target queue is a concurrent + * queue, there are no other messages being sent concurrently while the barrier + * block is executing. XPC does not guarantee that the receipt of messages + * (either through the connection's event handler or through reply handlers) + * will be suspended while the barrier is executing. + * + * A barrier is issued relative to the message-send queue. Thus, if you call + * xpc_connection_send_message() five times and then call + * xpc_connection_send_barrier(), the barrier will be invoked after the fifth + * message has been sent and its memory disposed of. You may safely cancel a + * connection from within a barrier block. + * + * If a barrier is issued after sending a message which expects a reply, the + * behavior is the same as described above. The receipt of a reply message will + * not influence when the barrier runs. + * + * A barrier block can be useful for throttling resource consumption on the + * connected side of a connection. For example, if your connection sends many + * large messages, you can use a barrier to limit the number of messages that + * are inflight at any given time. This can be particularly useful for messages + * that contain kernel resources (like file descriptors) which have a system- + * wide limit. + * + * If a barrier is issued on a canceled connection, it will be invoked + * immediately. If a connection has been canceled and still has outstanding + * barriers, those barriers will be invoked as part of the connection's + * unwinding process. + * + * It is important to note that a barrier block's execution order is not + * guaranteed with respect to other blocks that have been scheduled on the + * target queue of the connection. Or said differently, + * xpc_connection_send_barrier(3) is not equivalent to dispatch_async(3). + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_send_barrier(xpc_connection_t connection, + dispatch_block_t barrier); + +/*! + * @function xpc_connection_send_message_with_reply + * Sends a message over the connection to the destination service and associates + * a handler to be invoked when the remote service sends a reply message. + * + * @param connection + * The connection over which the message shall be sent. + * + * @param message + * The message to send. This must be a dictionary object. + * + * @param replyq + * The GCD queue to which the reply handler will be submitted. This may be a + * concurrent queue. + * + * @param handler + * The handler block to invoke when a reply to the message is received from + * the connection. If the remote service exits prematurely before the reply was + * received, the XPC_ERROR_CONNECTION_INTERRUPTED error will be returned. + * If the connection went invalid before the message could be sent, the + * XPC_ERROR_CONNECTION_INVALID error will be returned. + * + * @discussion + * If the given GCD queue is a concurrent queue, XPC cannot guarantee that there + * will not be multiple reply handlers being invoked concurrently. XPC does not + * guarantee any ordering for the invocation of reply handers. So if multiple + * messages are waiting for replies and the connection goes invalid, there is no + * guarantee that the reply handlers will be invoked in FIFO order. Similarly, + * XPC does not guarantee that reply handlers will not run concurrently with + * the connection's event handler in the case that the reply queue and the + * connection's target queue are the same concurrent queue. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL4 +void +xpc_connection_send_message_with_reply(xpc_connection_t connection, + xpc_object_t message, dispatch_queue_t _Nullable replyq, + xpc_handler_t handler); + +/*! + * @function xpc_connection_send_message_with_reply_sync + * Sends a message over the connection and blocks the caller until a reply is + * received. + * + * @param connection + * The connection over which the message shall be sent. + * + * @param message + * The message to send. This must be a dictionary object. + * + * @result + * The message that the remote service sent in reply to the original message. + * If the remote service exits prematurely before the reply was received, the + * XPC_ERROR_CONNECTION_INTERRUPTED error will be returned. If the connection + * went invalid before the message could be sent, the + * XPC_ERROR_CONNECTION_INVALID error will be returned. + * + * You are responsible for releasing the returned object. + * + * @discussion + * This API supports priority inversion avoidance, and should be used instead of + * combining xpc_connection_send_message_with_reply() with a semaphore. + * + * Invoking this API from a queue that is a part of the target queue hierarchy + * results in deadlocks under certain conditions. + * + * Be judicious about your use of this API. It can block indefinitely, so if you + * are using it to implement an API that can be called from the main thread, you + * may wish to consider allowing the API to take a queue and callback block so + * that results may be delivered asynchronously if possible. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT XPC_RETURNS_RETAINED +xpc_object_t +xpc_connection_send_message_with_reply_sync(xpc_connection_t connection, + xpc_object_t message); + +/*! + * @function xpc_connection_cancel + * Cancels the connection and ensures that its event handler will not fire + * again. After this call, any messages that have not yet been sent will be + * discarded, and the connection will be unwound. If there are messages that are + * awaiting replies, they will have their reply handlers invoked with the + * XPC_ERROR_CONNECTION_INVALID error. + * + * @param connection + * The connection object which is to be manipulated. + * + * @discussion + * Cancellation is asynchronous and non-preemptive and therefore this method + * will not interrupt the execution of an already-running event handler block. + * If the event handler is executing at the time of this call, it will finish, + * and then the connection will be canceled, causing a final invocation of the + * event handler to be scheduled with the XPC_ERROR_CONNECTION_INVALID error. + * After that invocation, there will be no further invocations of the event + * handler. + * + * The XPC runtime guarantees this non-preemptiveness even for concurrent target + * queues. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +void +xpc_connection_cancel(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_name + * Returns the name of the service with which the connections was created. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The name of the remote service. If you obtained the connection through an + * invocation of another connection's event handler, NULL is returned. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +const char * _Nullable +xpc_connection_get_name(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_euid + * Returns the EUID of the remote peer. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The EUID of the remote peer at the time the connection was made. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +uid_t +xpc_connection_get_euid(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_egid + * Returns the EGID of the remote peer. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The EGID of the remote peer at the time the connection was made. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +gid_t +xpc_connection_get_egid(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_pid + * Returns the PID of the remote peer. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The PID of the remote peer. + * + * @discussion + * A given PID is not guaranteed to be unique across an entire boot cycle. + * Great care should be taken when dealing with this information, as it can go + * stale after the connection is established. OS X recycles PIDs, and therefore + * another process could spawn and claim the PID before a message is actually + * received from the connection. + * + * XPC will deliver an error to your event handler if the remote process goes + * away, but there are no guarantees as to the timing of this notification's + * delivery either at the kernel layer or at the XPC layer. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +pid_t +xpc_connection_get_pid(xpc_connection_t connection); + +/*! + * @function xpc_connection_get_asid + * Returns the audit session identifier of the remote peer. + * + * @param connection + * The connection object which is to be examined. + * + * @result + * The audit session ID of the remote peer at the time the connection was made. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +au_asid_t +xpc_connection_get_asid(xpc_connection_t connection); + +/*! + * @function xpc_connection_set_context + * Sets context on an connection. + * + * @param connection + * The connection which is to be manipulated. + * + * @param context + * The context to associate with the connection. + * + * @discussion + * If you must manage the memory of the context object, you must set a finalizer + * to dispose of it. If this method is called on a connection which already has + * context associated with it, the finalizer will NOT be invoked. The finalizer + * is only invoked when the connection is being deallocated. + * + * It is recommended that, instead of changing the actual context pointer + * associated with the object, you instead change the state of the context + * object itself. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_connection_set_context(xpc_connection_t connection, + void * _Nullable context); + +/*! + * @function xpc_connection_get_context + * Returns the context associated with the connection. + * + * @param connection + * The connection which is to be examined. + * + * @result + * The context associated with the connection. NULL if there has been no context + * associated with the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +void * _Nullable +xpc_connection_get_context(xpc_connection_t connection); + +/*! + * @function xpc_connection_set_finalizer_f + * Sets the finalizer for the given connection. + * + * @param connection + * The connection on which to set the finalizer. + * + * @param finalizer + * The function that will be invoked when the connection's retain count has + * dropped to zero and is being torn down. + * + * @discussion + * This method disposes of the context value associated with a connection, as + * set by {@link xpc_connection_set_context}. + * + * For many uses of context objects, this API allows for a convenient shorthand + * for freeing them. For example, for a context object allocated with malloc(3): + * + * xpc_connection_set_finalizer_f(object, free); + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_connection_set_finalizer_f(xpc_connection_t connection, + xpc_finalizer_t _Nullable finalizer); + +__END_DECLS +XPC_ASSUME_NONNULL_END + +#endif // __XPC_CONNECTION_H__ \ No newline at end of file diff --git a/lib/libc/include/aarch64-macos-gnu/xpc/xpc.h b/lib/libc/include/aarch64-macos-gnu/xpc/xpc.h new file mode 100644 index 0000000000..5fdc35ee8c --- /dev/null +++ b/lib/libc/include/aarch64-macos-gnu/xpc/xpc.h @@ -0,0 +1,2701 @@ +// Copyright (c) 2009-2020 Apple Inc. All rights reserved. + +#ifndef __XPC_H__ +#define __XPC_H__ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __XPC_INDIRECT__ +#define __XPC_INDIRECT__ +#endif // __XPC_INDIRECT__ + +#include + +#if __has_include() +#include +#else // __has_include() +#define XPC_TRANSACTION_DEPRECATED +#endif // __has_include() + +XPC_ASSUME_NONNULL_BEGIN +__BEGIN_DECLS + +#ifndef __OSX_AVAILABLE_STARTING +#define __OSX_AVAILABLE_STARTING(x, y) +#endif // __OSX_AVAILABLE_STARTING + +#define XPC_API_VERSION 20200610 + +/*! + * @typedef xpc_type_t + * A type that describes XPC object types. + */ +typedef const struct _xpc_type_s * xpc_type_t; +#ifndef XPC_TYPE +#define XPC_TYPE(type) const struct _xpc_type_s type +#endif // XPC_TYPE + +/*! + * @typedef xpc_object_t + * A type that can describe all XPC objects. Dictionaries, arrays, strings, etc. + * are all described by this type. + * + * XPC objects are created with a retain count of 1, and therefore it is the + * caller's responsibility to call xpc_release() on them when they are no longer + * needed. + */ + +#if OS_OBJECT_USE_OBJC +/* By default, 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. + * + * See for details. + */ +OS_OBJECT_DECL(xpc_object); +#ifndef XPC_DECL +#define XPC_DECL(name) typedef xpc_object_t name##_t +#endif // XPC_DECL + +#define XPC_GLOBAL_OBJECT(object) ((OS_OBJECT_BRIDGE xpc_object_t)&(object)) +#define XPC_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED +XPC_INLINE XPC_NONNULL_ALL +void +_xpc_object_validate(xpc_object_t object) { + (void)*(unsigned long volatile *)(OS_OBJECT_BRIDGE void *)object; +} +#else // OS_OBJECT_USE_OBJC +typedef void * xpc_object_t; +#define XPC_DECL(name) typedef struct _##name##_s * name##_t +#define XPC_GLOBAL_OBJECT(object) (&(object)) +#define XPC_RETURNS_RETAINED +#endif // OS_OBJECT_USE_OBJC + +/*! + * @typedef xpc_handler_t + * The type of block that is accepted by the XPC connection APIs. + * + * @param object + * An XPC object that is to be handled. If there was an error, this object will + * be equal to one of the well-known XPC_ERROR_* dictionaries and can be + * compared with the equality operator. + * + * @discussion + * You are not responsible for releasing the event object. + */ +#if __BLOCKS__ +typedef void (^xpc_handler_t)(xpc_object_t object); +#endif // __BLOCKS__ + +/*! + * @define XPC_TYPE_CONNECTION + * A type representing a connection to a named service. This connection is + * bidirectional and can be used to both send and receive messages. A + * connection carries the credentials of the remote service provider. + */ +#define XPC_TYPE_CONNECTION (&_xpc_type_connection) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_connection); +XPC_DECL(xpc_connection); + +/*! + * @typedef xpc_connection_handler_t + * The type of the function that will be invoked for a bundled XPC service when + * there is a new connection on the service. + * + * @param connection + * A new connection that is equivalent to one received by a listener connection. + * See the documentation for {@link xpc_connection_set_event_handler} for the + * semantics associated with the received connection. + */ +typedef void (*xpc_connection_handler_t)(xpc_connection_t connection); + +/*! + * @define XPC_TYPE_ENDPOINT + * A type representing a connection in serialized form. Unlike a connection, an + * endpoint is an inert object that does not have any runtime activity + * associated with it. Thus, it is safe to pass an endpoint in a message. Upon + * receiving an endpoint, the recipient can use + * xpc_connection_create_from_endpoint() to create as many distinct connections + * as desired. + */ +#define XPC_TYPE_ENDPOINT (&_xpc_type_endpoint) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_endpoint); +XPC_DECL(xpc_endpoint); + +/*! + * @define XPC_TYPE_NULL + * A type representing a null object. This type is useful for disambiguating + * an unset key in a dictionary and one which has been reserved but set empty. + * Also, this type is a way to represent a "null" value in dictionaries, which + * do not accept NULL. + */ +#define XPC_TYPE_NULL (&_xpc_type_null) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_null); + +/*! + * @define XPC_TYPE_BOOL + * A type representing a Boolean value. + */ +#define XPC_TYPE_BOOL (&_xpc_type_bool) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_bool); + +/*! + * @define XPC_BOOL_TRUE + * A constant representing a Boolean value of true. You may compare a Boolean + * object against this constant to determine its value. + */ +#define XPC_BOOL_TRUE XPC_GLOBAL_OBJECT(_xpc_bool_true) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_bool_s _xpc_bool_true; + +/*! + * @define XPC_BOOL_FALSE + * A constant representing a Boolean value of false. You may compare a Boolean + * object against this constant to determine its value. + */ +#define XPC_BOOL_FALSE XPC_GLOBAL_OBJECT(_xpc_bool_false) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const struct _xpc_bool_s _xpc_bool_false; + +/*! + * @define XPC_TYPE_INT64 + * A type representing a signed, 64-bit integer value. + */ +#define XPC_TYPE_INT64 (&_xpc_type_int64) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_int64); + +/*! + * @define XPC_TYPE_UINT64 + * A type representing an unsigned, 64-bit integer value. + */ +#define XPC_TYPE_UINT64 (&_xpc_type_uint64) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_uint64); + +/*! + * @define XPC_TYPE_DOUBLE + * A type representing an IEEE-compliant, double-precision floating point value. + */ +#define XPC_TYPE_DOUBLE (&_xpc_type_double) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_double); + +/*! + * @define XPC_TYPE_DATE +* A type representing a date interval. The interval is with respect to the + * Unix epoch. XPC dates are in Unix time and are thus unaware of local time + * or leap seconds. + */ +#define XPC_TYPE_DATE (&_xpc_type_date) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_date); + +/*! + * @define XPC_TYPE_DATA + * A type representing a an arbitrary buffer of bytes. + */ +#define XPC_TYPE_DATA (&_xpc_type_data) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_data); + +/*! + * @define XPC_TYPE_STRING + * A type representing a NUL-terminated C-string. + */ +#define XPC_TYPE_STRING (&_xpc_type_string) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_string); + +/*! + * @define XPC_TYPE_UUID + * A type representing a Universally Unique Identifier as defined by uuid(3). + */ +#define XPC_TYPE_UUID (&_xpc_type_uuid) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_uuid); + +/*! + * @define XPC_TYPE_FD + * A type representing a POSIX file descriptor. + */ +#define XPC_TYPE_FD (&_xpc_type_fd) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_fd); + +/*! + * @define XPC_TYPE_SHMEM + * A type representing a region of shared memory. + */ +#define XPC_TYPE_SHMEM (&_xpc_type_shmem) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_shmem); + +/*! + * @define XPC_TYPE_ARRAY + * A type representing an array of XPC objects. This array must be contiguous, + * i.e. it cannot contain NULL values. If you wish to indicate that a slot + * is empty, you can insert a null object. The array will grow as needed to + * accommodate more objects. + */ +#define XPC_TYPE_ARRAY (&_xpc_type_array) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_array); + +/*! + * @define XPC_TYPE_DICTIONARY + * A type representing a dictionary of XPC objects, keyed off of C-strings. + * You may insert NULL values into this collection. The dictionary will grow + * as needed to accommodate more key/value pairs. + */ +#define XPC_TYPE_DICTIONARY (&_xpc_type_dictionary) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_dictionary); + +/*! + * @define XPC_TYPE_ERROR + * A type representing an error object. Errors in XPC are dictionaries, but + * xpc_get_type() will return this type when given an error object. You + * cannot create an error object directly; XPC will only give them to handlers. + * These error objects have pointer values that are constant across the lifetime + * of your process and can be safely compared. + * + * These constants are enumerated in the header for the connection object. Error + * dictionaries may reserve keys so that they can be queried to obtain more + * detailed information about the error. Currently, the only reserved key is + * XPC_ERROR_KEY_DESCRIPTION. + */ +#define XPC_TYPE_ERROR (&_xpc_type_error) +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +XPC_TYPE(_xpc_type_error); + +/*! + * @define XPC_ERROR_KEY_DESCRIPTION + * In an error dictionary, querying for this key will return a string object + * that describes the error in a human-readable way. + */ +#define XPC_ERROR_KEY_DESCRIPTION _xpc_error_key_description +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const char * const _xpc_error_key_description; + +/*! + * @define XPC_EVENT_KEY_NAME + * In an event dictionary, this querying for this key will return a string + * object that describes the event. + */ +#define XPC_EVENT_KEY_NAME _xpc_event_key_name +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +const char * const _xpc_event_key_name; + +XPC_ASSUME_NONNULL_END +#if !defined(__XPC_BUILDING_XPC__) || !__XPC_BUILDING_XPC__ +#include +#include +#if __BLOCKS__ +#include +#include +#endif // __BLOCKS__ +#undef __XPC_INDIRECT__ +#include +#endif // !defined(__XPC_BUILDING_XPC__) || !__XPC_BUILDING_XPC__ +XPC_ASSUME_NONNULL_BEGIN + +#pragma mark XPC Object Protocol +/*! + * @function xpc_retain + * + * @abstract + * Increments the reference count of an object. + * + * @param object + * The object which is to be manipulated. + * + * @result + * The object which was given. + * + * @discussion + * Calls to xpc_retain() must be balanced with calls to xpc_release() + * to avoid leaking memory. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +xpc_object_t +xpc_retain(xpc_object_t object); +#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE +#undef xpc_retain +#define xpc_retain(object) ({ xpc_object_t _o = (object); \ + _xpc_object_validate(_o); [_o retain]; }) +#endif // OS_OBJECT_USE_OBJC_RETAIN_RELEASE + +/*! + * @function xpc_release + * + * @abstract + * Decrements the reference count of an object. + * + * @param object + * The object which is to be manipulated. + * + * @discussion + * The caller must take care to balance retains and releases. When creating or + * retaining XPC objects, the creator obtains a reference on the object. Thus, + * it is the caller's responsibility to call xpc_release() on those objects when + * they are no longer needed. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_release(xpc_object_t object); +#if OS_OBJECT_USE_OBJC_RETAIN_RELEASE +#undef xpc_release +#define xpc_release(object) ({ xpc_object_t _o = (object); \ + _xpc_object_validate(_o); [_o release]; }) +#endif // OS_OBJECT_USE_OBJC_RETAIN_RELEASE + +/*! + * @function xpc_get_type + * + * @abstract + * Returns the type of an object. + * + * @param object + * The object to examine. + * + * @result + * An opaque pointer describing the type of the object. This pointer is suitable + * direct comparison to exported type constants with the equality operator. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT +xpc_type_t +xpc_get_type(xpc_object_t object); + +/*! + * @function xpc_type_get_name + * + * @abstract + * Returns a string describing an XPC object type. + * + * @param type + * The type to describe. + * + * @result + * A string describing the type of an object, like "string" or "int64". + * This string should not be freed or modified. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_15, __IPHONE_13_0) +XPC_EXPORT XPC_NONNULL1 +const char * +xpc_type_get_name(xpc_type_t type); + +/*! + * @function xpc_copy + * + * @abstract + * Creates a copy of the object. + * + * @param object + * The object to copy. + * + * @result + * The new object. NULL if the object type does not support copying or if + * sufficient memory for the copy could not be allocated. Service objects do + * not support copying. + * + * @discussion + * When called on an array or dictionary, xpc_copy() will perform a deep copy. + * + * The object returned is not necessarily guaranteed to be a new object, and + * whether it is will depend on the implementation of the object being copied. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL XPC_WARN_RESULT XPC_RETURNS_RETAINED +xpc_object_t _Nullable +xpc_copy(xpc_object_t object); + +/*! + * @function xpc_equal + * + * @abstract + * Compares two objects for equality. + * + * @param object1 + * The first object to compare. + * + * @param object2 + * The second object to compare. + * + * @result + * Returns true if the objects are equal, otherwise false. Two objects must be + * of the same type in order to be equal. + * + * For two arrays to be equal, they must contain the same values at the + * same indexes. For two dictionaries to be equal, they must contain the same + * values for the same keys. + * + * Two objects being equal implies that their hashes (as returned by xpc_hash()) + * are also equal. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_WARN_RESULT +bool +xpc_equal(xpc_object_t object1, xpc_object_t object2); + +/*! + * @function xpc_hash + * + * @abstract + * Calculates a hash value for the given object. + * + * @param object + * The object for which to calculate a hash value. This value may be modded + * with a table size for insertion into a dictionary-like data structure. + * + * @result + * The calculated hash value. + * + * @discussion + * Note that the computed hash values for any particular type and value of an + * object can change from across releases and platforms and should not be + * assumed to be constant across all time and space or stored persistently. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_WARN_RESULT +size_t +xpc_hash(xpc_object_t object); + +/*! + * @function xpc_copy_description + * + * @abstract + * Copies a debug string describing the object. + * + * @param object + * The object which is to be examined. + * + * @result + * A string describing object which contains information useful for debugging. + * This string should be disposed of with free(3) when done. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_WARN_RESULT XPC_NONNULL1 +char * +xpc_copy_description(xpc_object_t object); + +#pragma mark XPC Object Types +#pragma mark Null +/*! + * @function xpc_null_create + * + * @abstract + * Creates an XPC object representing the null object. + * + * @result + * A new null object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_null_create(void); + +#pragma mark Boolean +/*! + * @function xpc_bool_create + * + * @abstract + * Creates an XPC Boolean object. + * + * @param value + * The Boolean primitive value which is to be boxed. + * + * @result + * A new Boolean object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_bool_create(bool value); + +/*! + * @function xpc_bool_get_value + * + * @abstract + * Returns the underlying Boolean value from the object. + * + * @param xbool + * The Boolean object which is to be examined. + * + * @result + * The underlying Boolean value or false if the given object was not an XPC + * Boolean object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT +bool +xpc_bool_get_value(xpc_object_t xbool); + +#pragma mark Signed Integer +/*! + * @function xpc_int64_create + * + * @abstract + * Creates an XPC signed integer object. + * + * @param value + * The signed integer value which is to be boxed. + * + * @result + * A new signed integer object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_int64_create(int64_t value); + +/*! + * @function xpc_int64_get_value + * + * @abstract + * Returns the underlying signed 64-bit integer value from an object. + * + * @param xint + * The signed integer object which is to be examined. + * + * @result + * The underlying signed 64-bit value or 0 if the given object was not an XPC + * integer object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int64_t +xpc_int64_get_value(xpc_object_t xint); + +#pragma mark Unsigned Integer +/*! + * @function xpc_uint64_create + * + * @abstract + * Creates an XPC unsigned integer object. + * + * @param value + * The unsigned integer value which is to be boxed. + * + * @result + * A new unsigned integer object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_uint64_create(uint64_t value); + +/*! + * @function xpc_uint64_get_value + * + * @abstract + * Returns the underlying unsigned 64-bit integer value from an object. + * + * @param xuint + * The unsigned integer object which is to be examined. + * + * @result + * The underlying unsigned integer value or 0 if the given object was not an XPC + * unsigned integer object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +uint64_t +xpc_uint64_get_value(xpc_object_t xuint); + +#pragma mark Double +/*! + * @function xpc_double_create + * + * @abstract + * Creates an XPC double object. + * + * @param value + * The floating point quantity which is to be boxed. + * + * @result + * A new floating point object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_double_create(double value); + +/*! + * @function xpc_double_get_value + * + * @abstract + * Returns the underlying double-precision floating point value from an object. + * + * @param xdouble + * The floating point object which is to be examined. + * + * @result + * The underlying floating point value or NAN if the given object was not an XPC + * floating point object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +double +xpc_double_get_value(xpc_object_t xdouble); + +#pragma mark Date +/*! + * @function xpc_date_create + * + * @abstract + * Creates an XPC date object. + * + * @param interval + * The date interval which is to be boxed. Negative values indicate the number + * of nanoseconds before the epoch. Positive values indicate the number of + * nanoseconds after the epoch. + * + * @result + * A new date object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_date_create(int64_t interval); + +/*! + * @function xpc_date_create_from_current + * + * @abstract + * Creates an XPC date object representing the current date. + * + * @result + * A new date object representing the current date. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_date_create_from_current(void); + +/*! + * @function xpc_date_get_value + * + * @abstract + * Returns the underlying date interval from an object. + * + * @param xdate + * The date object which is to be examined. + * + * @result + * The underlying date interval or 0 if the given object was not an XPC date + * object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int64_t +xpc_date_get_value(xpc_object_t xdate); + +#pragma mark Data +/*! + * @function xpc_data_create + * + * @abstract + * Creates an XPC object representing buffer of bytes. + * + * @param bytes + * The buffer of bytes which is to be boxed. You may create an empty data object + * by passing NULL for this parameter and 0 for the length. Passing NULL with + * any other length will result in undefined behavior. + * + * @param length + * The number of bytes which are to be boxed. + * + * @result + * A new data object. + * + * @discussion + * This method will copy the buffer given into internal storage. After calling + * this method, it is safe to dispose of the given buffer. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_data_create(const void * _Nullable bytes, size_t length); + +/*! + * @function xpc_data_create_with_dispatch_data + * + * @abstract + * Creates an XPC object representing buffer of bytes described by the given GCD + * data object. + * + * @param ddata + * The GCD data object containing the bytes which are to be boxed. This object + * is retained by the data object. + * + * @result + * A new data object. + * + * @discussion + * The object returned by this method will refer to the buffer returned by + * dispatch_data_create_map(). The point where XPC will make the call to + * dispatch_data_create_map() is undefined. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_object_t +xpc_data_create_with_dispatch_data(dispatch_data_t ddata); + +/*! + * @function xpc_data_get_length + * + * @abstract + * Returns the length of the data encapsulated by an XPC data object. + * + * @param xdata + * The data object which is to be examined. + * + * @result + * The length of the underlying boxed data or 0 if the given object was not an + * XPC data object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +size_t +xpc_data_get_length(xpc_object_t xdata); + +/*! + * @function xpc_data_get_bytes_ptr + * + * @abstract + * Returns a pointer to the internal storage of a data object. + * + * @param xdata + * The data object which is to be examined. + * + * @result + * A pointer to the underlying boxed data or NULL if the given object was not an + * XPC data object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const void * _Nullable +xpc_data_get_bytes_ptr(xpc_object_t xdata); + +/*! + * @function xpc_data_get_bytes + * + * @abstract + * Copies the bytes stored in an data objects into the specified buffer. + * + * @param xdata + * The data object which is to be examined. + * + * @param buffer + * The buffer in which to copy the data object's bytes. + * + * @param off + * The offset at which to begin the copy. If this offset is greater than the + * length of the data element, nothing is copied. Pass 0 to start the copy + * at the beginning of the buffer. + * + * @param length + * The length of the destination buffer. + * + * @result + * The number of bytes that were copied into the buffer or 0 if the given object + * was not an XPC data object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2 +size_t +xpc_data_get_bytes(xpc_object_t xdata, + void *buffer, size_t off, size_t length); + +#pragma mark String +/*! + * @function xpc_string_create + * + * @abstract + * Creates an XPC object representing a NUL-terminated C-string. + * + * @param string + * The C-string which is to be boxed. + * + * @result + * A new string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_object_t +xpc_string_create(const char *string); + +/*! + * @function xpc_string_create_with_format + * + * @abstract + * Creates an XPC object representing a C-string that is generated from the + * given format string and arguments. + * + * @param fmt + * The printf(3)-style format string from which to construct the final C-string + * to be boxed. + * + * @param ... + * The arguments which correspond to those specified in the format string. + * + * @result + * A new string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +XPC_PRINTF(1, 2) +xpc_object_t +xpc_string_create_with_format(const char *fmt, ...); + +/*! + * @function xpc_string_create_with_format_and_arguments + * + * @abstract + * Creates an XPC object representing a C-string that is generated from the + * given format string and argument list pointer. + * + * @param fmt + * The printf(3)-style format string from which to construct the final C-string + * to be boxed. + * + * @param ap + * A pointer to the arguments which correspond to those specified in the format + * string. + * + * @result + * A new string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +XPC_PRINTF(1, 0) +xpc_object_t +xpc_string_create_with_format_and_arguments(const char *fmt, va_list ap); + +/*! + * @function xpc_string_get_length + * + * @abstract + * Returns the length of the underlying string. + * + * @param xstring + * The string object which is to be examined. + * + * @result + * The length of the underlying string, not including the NUL-terminator, or 0 + * if the given object was not an XPC string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +size_t +xpc_string_get_length(xpc_object_t xstring); + +/*! + * @function xpc_string_get_string_ptr + * + * @abstract + * Returns a pointer to the internal storage of a string object. + * + * @param xstring + * The string object which is to be examined. + * + * @result + * A pointer to the string object's internal storage or NULL if the given object + * was not an XPC string object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const char * _Nullable +xpc_string_get_string_ptr(xpc_object_t xstring); + +#pragma mark UUID +/*! + * @function xpc_uuid_create + * + * @abstract + * Creates an XPC object representing a universally-unique identifier (UUID) as + * described by uuid(3). + * + * @param uuid + * The UUID which is to be boxed. + * + * @result + * A new UUID object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_object_t +xpc_uuid_create(const uuid_t XPC_NONNULL_ARRAY uuid); + +/*! + * @function xpc_uuid_get_bytes + * + * @abstract + * Returns a pointer to the the boxed UUID bytes in an XPC UUID object. + * + * @param xuuid + * The UUID object which is to be examined. + * + * @result + * The underlying uuid_t bytes or NULL if the given object was not + * an XPC UUID object. The returned pointer may be safely passed to the uuid(3) + * APIs. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +const uint8_t * _Nullable +xpc_uuid_get_bytes(xpc_object_t xuuid); + +#pragma mark File Descriptors +/*! + * @function xpc_fd_create + * + * @abstract + * Creates an XPC object representing a POSIX file descriptor. + * + * @param fd + * The file descriptor which is to be boxed. + * + * @result + * A new file descriptor object. NULL if sufficient memory could not be + * allocated or if the given file descriptor was not valid. + * + * @discussion + * This method performs the equivalent of a dup(2) on the descriptor, and thus + * it is safe to call close(2) on the descriptor after boxing it with a file + * descriptor object. + * + * IMPORTANT: Pointer equality is the ONLY valid test for equality between two + * file descriptor objects. There is no reliable way to determine whether two + * file descriptors refer to the same inode with the same capabilities, so two + * file descriptor objects created from the same underlying file descriptor + * number will not compare equally with xpc_equal(). This is also true of a + * file descriptor object created using xpc_copy() and the original. + * + * This also implies that two collections containing file descriptor objects + * cannot be equal unless the exact same object was inserted into both. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t _Nullable +xpc_fd_create(int fd); + +/*! + * @function xpc_fd_dup + * + * @abstract + * Returns a file descriptor that is equivalent to the one boxed by the file + * file descriptor object. + * + * @param xfd + * The file descriptor object which is to be examined. + * + * @result + * A file descriptor that is equivalent to the one originally given to + * xpc_fd_create(). If the descriptor could not be created or if the given + * object was not an XPC file descriptor, -1 is returned. + * + * @discussion + * Multiple invocations of xpc_fd_dup() will not return the same file descriptor + * number, but they will return descriptors that are equivalent, as though they + * had been created by dup(2). + * + * The caller is responsible for calling close(2) on the returned descriptor. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int +xpc_fd_dup(xpc_object_t xfd); + +#pragma mark Shared Memory +/*! + * @function xpc_shmem_create + * + * @abstract + * Creates an XPC object representing the given shared memory region. + * + * @param region + * A pointer to a region of shared memory, created through a call to mmap(2) + * with the MAP_SHARED flag, which is to be boxed. + * + * @param length + * The length of the region. + * + * @result + * A new shared memory object. + * + * @discussion + * Only memory regions whose exact characteristics are known to the caller + * should be boxed using this API. Memory returned from malloc(3) may not be + * safely shared on either OS X or iOS because the underlying virtual memory + * objects for malloc(3)ed allocations are owned by the malloc(3) subsystem and + * not the caller of malloc(3). + * + * If you wish to share a memory region that you receive from another subsystem, + * part of the interface contract with that other subsystem must include how to + * create the region of memory, or sharing it may be unsafe. + * + * Certain operations may internally fragment a region of memory in a way that + * would truncate the range detected by the shared memory object. vm_copy(), for + * example, may split the region into multiple parts to avoid copying certain + * page ranges. For this reason, it is recommended that you delay all VM + * operations until the shared memory object has been created so that the VM + * system knows that the entire range is intended for sharing. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_object_t +xpc_shmem_create(void *region, size_t length); + +/*! + * @function xpc_shmem_map + * + * @abstract + * Maps the region boxed by the XPC shared memory object into the caller's + * address space. + * + * @param xshmem + * The shared memory object to be examined. + * + * @param region + * On return, this will point to the region at which the shared memory was + * mapped. + * + * @result + * The length of the region that was mapped. If the mapping failed or if the + * given object was not an XPC shared memory object, 0 is returned. The length + * of the mapped region will always be an integral page size, even if the + * creator of the region specified a non-integral page size. + * + * @discussion + * The resulting region must be disposed of with munmap(2). + * + * It is the responsibility of the caller to manage protections on the new + * region accordingly. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +size_t +xpc_shmem_map(xpc_object_t xshmem, void * _Nullable * _Nonnull region); + +#pragma mark Array +/*! + * @typedef xpc_array_applier_t + * A block to be invoked for every value in the array. + * + * @param index + * The current index in the iteration. + * + * @param value + * The current value in the iteration. + * + * @result + * A Boolean indicating whether iteration should continue. + */ +#ifdef __BLOCKS__ +typedef bool (^xpc_array_applier_t)(size_t index, xpc_object_t _Nonnull value); +#endif // __BLOCKS__ + +/*! + * @function xpc_array_create + * + * @abstract + * Creates an XPC object representing an array of XPC objects. + * + * @discussion + * This array must be contiguous and cannot contain any NULL values. If you + * wish to insert the equivalent of a NULL value, you may use the result of + * {@link xpc_null_create}. + * + * @param objects + * An array of XPC objects which is to be boxed. The order of this array is + * preserved in the object. If this array contains a NULL value, the behavior + * is undefined. This parameter may be NULL only if the count is 0. + * + * @param count + * The number of objects in the given array. If the number passed is less than + * the actual number of values in the array, only the specified number of items + * are inserted into the resulting array. If the number passed is more than + * the the actual number of values, the behavior is undefined. + * + * @result + * A new array object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_array_create(const xpc_object_t _Nonnull * _Nullable objects, size_t count); + +/*! + * @function xpc_array_create_empty + * + * @abstract + * Creates an XPC object representing an array of XPC objects. + * + * @result + * A new array object. + * + * @see + * xpc_array_create + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_array_create_empty(void); + +/*! + * @function xpc_array_set_value + * + * @abstract + * Inserts the specified object into the array at the specified index. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array). + * If the index is outside that range, the behavior is undefined. + * + * @param value + * The object to insert. This value is retained by the array and cannot be + * NULL. If there is already a value at the specified index, it is released, + * and the new value is inserted in its place. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_value(xpc_object_t xarray, size_t index, xpc_object_t value); + +/*! + * @function xpc_array_append_value + * + * @abstract + * Appends an object to an XPC array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param value + * The object to append. This object is retained by the array. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_array_append_value(xpc_object_t xarray, xpc_object_t value); + +/*! + * @function xpc_array_get_count + * + * @abstract + * Returns the count of values currently in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @result + * The count of values in the array or 0 if the given object was not an XPC + * array. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +size_t +xpc_array_get_count(xpc_object_t xarray); + +/*! + * @function xpc_array_get_value + * + * @abstract + * Returns the value at the specified index in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the range of + * indexes as specified in xpc_array_set_value(). + * + * @result + * The object at the specified index within the array or NULL if the given + * object was not an XPC array. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +xpc_object_t +xpc_array_get_value(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_apply + * + * @abstract + * Invokes the given block for every value in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @param applier + * The block which this function applies to every element in the array. + * + * @result + * A Boolean indicating whether iteration of the array completed successfully. + * Iteration will only fail if the applier block returns false. + * + * @discussion + * You should not modify an array's contents during iteration. The array indexes + * are iterated in order. + */ +#ifdef __BLOCKS__ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +bool +xpc_array_apply(xpc_object_t xarray, XPC_NOESCAPE xpc_array_applier_t applier); +#endif // __BLOCKS__ + +#pragma mark Array Primitive Setters +/*! + * @define XPC_ARRAY_APPEND + * A constant that may be passed as the destination index to the class of + * primitive XPC array setters indicating that the given primitive should be + * appended to the array. + */ +#define XPC_ARRAY_APPEND ((size_t)(-1)) + +/*! + * @function xpc_array_set_bool + * + * @abstract + * Inserts a bool (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The bool value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_bool(xpc_object_t xarray, size_t index, bool value); + +/*! + * @function xpc_array_set_int64 + * + * @abstract + * Inserts an int64_t (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The int64_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_int64(xpc_object_t xarray, size_t index, int64_t value); + +/*! + * @function xpc_array_set_uint64 + * + * @abstract + * Inserts a uint64_t (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The uint64_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_uint64(xpc_object_t xarray, size_t index, uint64_t value); + +/*! + * @function xpc_array_set_double + * + * @abstract + * Inserts a double (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The double value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_double(xpc_object_t xarray, size_t index, double value); + +/*! + * @function xpc_array_set_date + * + * @abstract + * Inserts a date value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param value + * The date value to insert, represented as an int64_t. After + * calling this method, the XPC object corresponding to the primitive value + * inserted may be safely retrieved with {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_date(xpc_object_t xarray, size_t index, int64_t value); + +/*! + * @function xpc_array_set_data + * + * @abstract + * Inserts a raw data value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param bytes + * The raw data to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. + * + * @param length + * The length of the data. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_data(xpc_object_t xarray, size_t index, const void *bytes, + size_t length); + +/*! + * @function xpc_array_set_string + * + * @abstract + * Inserts a C string into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param string + * The C string to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_string(xpc_object_t xarray, size_t index, const char *string); + +/*! + * @function xpc_array_set_uuid + * + * @abstract + * Inserts a uuid_t (primitive) value into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param uuid + * The UUID primitive to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_uuid(xpc_object_t xarray, size_t index, + const uuid_t XPC_NONNULL_ARRAY uuid); + +/*! + * @function xpc_array_set_fd + * + * @abstract + * Inserts a file descriptor into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param fd + * The file descriptor to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 +void +xpc_array_set_fd(xpc_object_t xarray, size_t index, int fd); + +/*! + * @function xpc_array_set_connection + * + * @abstract + * Inserts a connection into an array. + * + * @param xarray + * The array object which is to be manipulated. + * + * @param index + * The index at which to insert the value. This value must lie within the index + * space of the array (0 to N-1 inclusive, where N is the count of the array) or + * be XPC_ARRAY_APPEND. If the index is outside that range, the behavior is + * undefined. + * + * @param connection + * The connection to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_array_get_value()}. The connection is NOT retained by the array. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_array_set_connection(xpc_object_t xarray, size_t index, + xpc_connection_t connection); + +#pragma mark Array Primitive Getters +/*! + * @function xpc_array_get_bool + * + * @abstract + * Gets a bool primitive value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying bool value at the specified index. false if the + * value at the specified index is not a Boolean value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +bool +xpc_array_get_bool(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_int64 + * + * @abstract + * Gets an int64_t primitive value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying int64_t value at the specified index. 0 if the + * value at the specified index is not a signed integer value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int64_t +xpc_array_get_int64(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_uint64 + * + * @abstract + * Gets a uint64_t primitive value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying uint64_t value at the specified index. 0 if the + * value at the specified index is not an unsigned integer value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +uint64_t +xpc_array_get_uint64(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_double + * + * @abstract + * Gets a double primitive value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying double value at the specified index. NAN if the + * value at the specified index is not a floating point value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +double +xpc_array_get_double(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_date + * + * @abstract + * Gets a date interval from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying date interval at the specified index. 0 if the value at the + * specified index is not a date value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int64_t +xpc_array_get_date(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_data + * + * @abstract + * Gets a pointer to the raw bytes of a data object from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @param length + * Upon return output, will contain the length of the data corresponding to the + * specified key. + * + * @result + * The underlying bytes at the specified index. NULL if the value at the + * specified index is not a data value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const void * _Nullable +xpc_array_get_data(xpc_object_t xarray, size_t index, + size_t * _Nullable length); + +/*! + * @function xpc_array_get_string + * + * @abstract + * Gets a C string value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying C string at the specified index. NULL if the value at the + * specified index is not a C string value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const char * _Nullable +xpc_array_get_string(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_uuid + * + * @abstract + * Gets a uuid_t value from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * The underlying uuid_t value at the specified index. The null + * UUID if the value at the specified index is not a UUID value. The returned + * pointer may be safely passed to the uuid(3) APIs. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const uint8_t * _Nullable +xpc_array_get_uuid(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_dup_fd + * + * @abstract + * Gets a file descriptor from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * A new file descriptor created from the value at the specified index. You are + * responsible for close(2)ing this descriptor. -1 if the value at the specified + * index is not a file descriptor value. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +int +xpc_array_dup_fd(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_create_connection + * + * @abstract + * Creates a connection object from an array directly. + * + * @param xarray + * The array which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the index space + * of the array (0 to N-1 inclusive, where N is the count of the array). If the + * index is outside that range, the behavior is undefined. + * + * @result + * A new connection created from the value at the specified index. You are + * responsible for calling xpc_release() on the returned connection. NULL if the + * value at the specified index is not an endpoint containing a connection. Each + * call to this method for the same index in the same array will yield a + * different connection. See {@link xpc_connection_create_from_endpoint()} for + * discussion as to the responsibilities when dealing with the returned + * connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 +xpc_connection_t _Nullable +xpc_array_create_connection(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_dictionary + * + * @abstract + * Returns the dictionary at the specified index in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the range of + * indexes as specified in xpc_array_set_value(). + * + * @result + * The object at the specified index within the array or NULL if the given + * object was not an XPC array or if the the value at the specified index was + * not a dictionary. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_array_get_dictionary(xpc_object_t xarray, size_t index); + +/*! + * @function xpc_array_get_array + * + * @abstract + * Returns the array at the specified index in the array. + * + * @param xarray + * The array object which is to be examined. + * + * @param index + * The index of the value to obtain. This value must lie within the range of + * indexes as specified in xpc_array_set_value(). + * + * @result + * The object at the specified index within the array or NULL if the given + * object was not an XPC array or if the the value at the specified index was + * not an array. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_array_get_array(xpc_object_t xarray, size_t index); + +#pragma mark Dictionary +/*! + * @typedef xpc_dictionary_applier_t + * A block to be invoked for every key/value pair in the dictionary. + * + * @param key + * The current key in the iteration. + * + * @param value + * The current value in the iteration. + * + * @result + * A Boolean indicating whether iteration should continue. + */ +#ifdef __BLOCKS__ +typedef bool (^xpc_dictionary_applier_t)(const char * _Nonnull key, + xpc_object_t _Nonnull value); +#endif // __BLOCKS__ + +/*! + * @function xpc_dictionary_create + * + * @abstract + * Creates an XPC object representing a dictionary of XPC objects keyed to + * C-strings. + * + * @param keys + * An array of C-strings that are to be the keys for the values to be inserted. + * Each element of this array is copied into the dictionary's internal storage. + * Elements of this array may NOT be NULL. + * + * @param values + * A C-array that is parallel to the array of keys, consisting of objects that + * are to be inserted. Each element in this array is retained. Elements in this + * array may be NULL. + * + * @param count + * The number of key/value pairs in the given arrays. If the count is less than + * the actual count of values, only that many key/value pairs will be inserted + * into the dictionary. + * + * If the count is more than the the actual count of key/value pairs, the + * behavior is undefined. If one array is NULL and the other is not, the + * behavior is undefined. If both arrays are NULL and the count is non-0, the + * behavior is undefined. + * + * @result + * The new dictionary object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_dictionary_create(const char * _Nonnull const * _Nullable keys, + const xpc_object_t _Nullable * _Nullable values, size_t count); + +/*! + * @function xpc_dictionary_create_empty + * + * @abstract + * Creates an XPC object representing a dictionary of XPC objects keyed to + * C-strings. + * + * @result + * The new dictionary object. + * + * @see + * xpc_dictionary_create + */ +API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0), watchos(7.0)) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT +xpc_object_t +xpc_dictionary_create_empty(void); + +/*! + * @function xpc_dictionary_create_reply + * + * @abstract + * Creates a dictionary that is in reply to the given dictionary. + * + * @param original + * The original dictionary that is to be replied to. + * + * @result + * The new dictionary object. NULL if the object was not a dictionary with a + * reply context. + * + * @discussion + * After completing successfully on a dictionary, this method may not be called + * again on that same dictionary. Attempts to do so will return NULL. + * + * When this dictionary is sent across the reply connection, the remote end's + * reply handler is invoked. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_dictionary_create_reply(xpc_object_t original); + +/*! + * @function xpc_dictionary_set_value + * + * @abstract + * Sets the value for the specified key to the specified object. + * + * @param xdict + * The dictionary object which is to be manipulated. + * + * @param key + * The key for which the value shall be set. + * + * @param value + * The object to insert. The object is retained by the dictionary. If there + * already exists a value for the specified key, the old value is released + * and overwritten by the new value. This parameter may be NULL, in which case + * the value corresponding to the specified key is deleted if present. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_value(xpc_object_t xdict, const char *key, + xpc_object_t _Nullable value); + +/*! + * @function xpc_dictionary_get_value + * + * @abstract + * Returns the value for the specified key. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The object for the specified key within the dictionary. NULL if there is no + * value associated with the specified key or if the given object was not an + * XPC dictionary. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2 +xpc_object_t _Nullable +xpc_dictionary_get_value(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_count + * + * @abstract + * Returns the number of values stored in the dictionary. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @result + * The number of values stored in the dictionary or 0 if the given object was + * not an XPC dictionary. Calling xpc_dictionary_set_value() with a non-NULL + * value will increment the count. Calling xpc_dictionary_set_value() with a + * NULL value will decrement the count. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +size_t +xpc_dictionary_get_count(xpc_object_t xdict); + +/*! + * @function xpc_dictionary_apply + * + * @abstract + * Invokes the given block for every key/value pair in the dictionary. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param applier + * The block which this function applies to every key/value pair in the + * dictionary. + * + * @result + * A Boolean indicating whether iteration of the dictionary completed + * successfully. Iteration will only fail if the applier block returns false. + * + * @discussion + * You should not modify a dictionary's contents during iteration. There is no + * guaranteed order of iteration over dictionaries. + */ +#ifdef __BLOCKS__ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL_ALL +bool +xpc_dictionary_apply(xpc_object_t xdict, + XPC_NOESCAPE xpc_dictionary_applier_t applier); +#endif // __BLOCKS__ + +/*! + * @function xpc_dictionary_get_remote_connection + * + * @abstract + * Returns the connection from which the dictionary was received. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @result + * If the dictionary was received by a connection event handler or a dictionary + * created through xpc_dictionary_create_reply(), a connection object over which + * a reply message can be sent is returned. For any other dictionary, NULL is + * returned. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_connection_t _Nullable +xpc_dictionary_get_remote_connection(xpc_object_t xdict); + +#pragma mark Dictionary Primitive Setters +/*! + * @function xpc_dictionary_set_bool + * + * @abstract + * Inserts a bool (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The bool value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_bool(xpc_object_t xdict, const char *key, bool value); + +/*! + * @function xpc_dictionary_set_int64 + * + * @abstract + * Inserts an int64_t (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The int64_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_int64(xpc_object_t xdict, const char *key, int64_t value); + +/*! + * @function xpc_dictionary_set_uint64 + * + * @abstract + * Inserts a uint64_t (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The uint64_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_uint64(xpc_object_t xdict, const char *key, uint64_t value); + +/*! + * @function xpc_dictionary_set_double + * + * @abstract + * Inserts a double (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The double value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_double(xpc_object_t xdict, const char *key, double value); + +/*! + * @function xpc_dictionary_set_date + * + * @abstract + * Inserts a date (primitive) value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param value + * The date value to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_date(xpc_object_t xdict, const char *key, int64_t value); + +/*! + * @function xpc_dictionary_set_data + * + * @abstract + * Inserts a raw data value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param bytes + * The bytes to insert. After calling this method, the XPC object corresponding + * to the primitive value inserted may be safely retrieved with + * {@link xpc_dictionary_get_value()}. + * + * @param length + * The length of the data. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 +void +xpc_dictionary_set_data(xpc_object_t xdict, const char *key, const void *bytes, + size_t length); + +/*! + * @function xpc_dictionary_set_string + * + * @abstract + * Inserts a C string value into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param string + * The C string to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved with + * {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 +void +xpc_dictionary_set_string(xpc_object_t xdict, const char *key, + const char *string); + +/*! + * @function xpc_dictionary_set_uuid + * + * @abstract + * Inserts a uuid (primitive) value into an array. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param uuid + * The uuid_t value to insert. After calling this method, the XPC + * object corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 +void +xpc_dictionary_set_uuid(xpc_object_t xdict, const char *key, + const uuid_t XPC_NONNULL_ARRAY uuid); + +/*! + * @function xpc_dictionary_set_fd + * + * @abstract + * Inserts a file descriptor into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param fd + * The file descriptor to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 +void +xpc_dictionary_set_fd(xpc_object_t xdict, const char *key, int fd); + +/*! + * @function xpc_dictionary_set_connection + * + * @abstract + * Inserts a connection into a dictionary. + * + * @param xdict + * The dictionary which is to be manipulated. + * + * @param key + * The key for which the primitive value shall be set. + * + * @param connection + * The connection to insert. After calling this method, the XPC object + * corresponding to the primitive value inserted may be safely retrieved + * with {@link xpc_dictionary_get_value()}. The connection is NOT retained by + * the dictionary. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL2 XPC_NONNULL3 +void +xpc_dictionary_set_connection(xpc_object_t xdict, const char *key, + xpc_connection_t connection); + +#pragma mark Dictionary Primitive Getters +/*! + * @function xpc_dictionary_get_bool + * + * @abstract + * Gets a bool primitive value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying bool value for the specified key. false if the + * the value for the specified key is not a Boolean value or if there is no + * value for the specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +bool +xpc_dictionary_get_bool(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_int64 + * + * @abstract + * Gets an int64 primitive value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying int64_t value for the specified key. 0 if the + * value for the specified key is not a signed integer value or if there is no + * value for the specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +int64_t +xpc_dictionary_get_int64(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_uint64 + * + * @abstract + * Gets a uint64 primitive value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying uint64_t value for the specified key. 0 if the + * value for the specified key is not an unsigned integer value or if there is + * no value for the specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +uint64_t +xpc_dictionary_get_uint64(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_double + * + * @abstract + * Gets a double primitive value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying double value for the specified key. NAN if the + * value for the specified key is not a floating point value or if there is no + * value for the specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +double +xpc_dictionary_get_double(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_date + * + * @abstract + * Gets a date value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying date interval for the specified key. 0 if the value for the + * specified key is not a date value or if there is no value for the specified + * key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +int64_t +xpc_dictionary_get_date(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_data + * + * @abstract + * Gets a raw data value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @param length + * For the data type, the third parameter, upon output, will contain the length + * of the data corresponding to the specified key. May be NULL. + * + * @result + * The underlying raw data for the specified key. NULL if the value for the + * specified key is not a data value or if there is no value for the specified + * key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 +const void * _Nullable +xpc_dictionary_get_data(xpc_object_t xdict, const char *key, + size_t * _Nullable length); + +/*! + * @function xpc_dictionary_get_string + * + * @abstract + * Gets a C string value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying C string for the specified key. NULL if the value for the + * specified key is not a C string value or if there is no value for the + * specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +const char * _Nullable +xpc_dictionary_get_string(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_uuid + * + * @abstract + * Gets a uuid value from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The underlying uuid_t value for the specified key. NULL is the + * value at the specified index is not a UUID value. The returned pointer may be + * safely passed to the uuid(3) APIs. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL1 XPC_NONNULL2 +const uint8_t * _Nullable +xpc_dictionary_get_uuid(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_dup_fd + * + * @abstract + * Creates a file descriptor from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * A new file descriptor created from the value for the specified key. You are + * responsible for close(2)ing this descriptor. -1 if the value for the + * specified key is not a file descriptor value or if there is no value for the + * specified key. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +int +xpc_dictionary_dup_fd(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_create_connection + * + * @abstract + * Creates a connection from a dictionary directly. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * A new connection created from the value for the specified key. You are + * responsible for calling xpc_release() on the returned connection. NULL if the + * value for the specified key is not an endpoint containing a connection or if + * there is no value for the specified key. Each call to this method for the + * same key in the same dictionary will yield a different connection. See + * {@link xpc_connection_create_from_endpoint()} for discussion as to the + * responsibilities when dealing with the returned connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_connection_t _Nullable +xpc_dictionary_create_connection(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_dictionary + * + * @abstract + * Returns the dictionary value for the specified key. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The object for the specified key within the dictionary. NULL if there is no + * value associated with the specified key, if the given object was not an + * XPC dictionary, or if the object for the specified key is not a dictionary. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_dictionary_get_dictionary(xpc_object_t xdict, const char *key); + +/*! + * @function xpc_dictionary_get_array + * + * @abstract + * Returns the array value for the specified key. + * + * @param xdict + * The dictionary object which is to be examined. + * + * @param key + * The key whose value is to be obtained. + * + * @result + * The object for the specified key within the dictionary. NULL if there is no + * value associated with the specified key, if the given object was not an + * XPC dictionary, or if the object for the specified key is not an array. + * + * @discussion + * This method does not grant the caller a reference to the underlying object, + * and thus the caller is not responsible for releasing the object. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0) +XPC_EXPORT XPC_WARN_RESULT XPC_NONNULL_ALL +xpc_object_t _Nullable +xpc_dictionary_get_array(xpc_object_t xdict, const char *key); + +#pragma mark Runtime +/*! + * @function xpc_main + * The springboard into the XPCService runtime. This function will set up your + * service bundle's listener connection and manage it automatically. After this + * initial setup, this function will, by default, call dispatch_main(). You may + * override this behavior by setting the RunLoopType key in your XPC service + * bundle's Info.plist under the XPCService dictionary. + * + * @param handler + * The handler with which to accept new connections. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NORETURN XPC_NONNULL1 +void +xpc_main(xpc_connection_handler_t handler); + +#pragma mark Transactions +/*! + * @function xpc_transaction_begin + * Informs the XPC runtime that a transaction has begun and that the service + * should not exit due to inactivity. + * + * @discussion + * A service with no outstanding transactions may automatically exit due to + * inactivity as determined by the system. + * + * This function may be used to manually manage transactions in cases where + * their automatic management (as described below) does not meet the needs of an + * XPC service. This function also updates the transaction count used for sudden + * termination, i.e. vproc_transaction_begin(), and these two interfaces may be + * used in combination. + * + * The XPC runtime will automatically begin a transaction on behalf of a service + * when a new message is received. If no reply message is expected, the + * transaction is automatically ended when the connection event handler returns. + * If a reply message is created, the transaction will end when the reply + * message is sent or released. An XPC service may use xpc_transaction_begin() + * and xpc_transaction_end() to inform the XPC runtime about activity that + * occurs outside of this common pattern. + * + * On macOS, when the XPC runtime has determined that the service should exit, + * the event handlers for all active peer connections will receive + * {@link XPC_ERROR_TERMINATION_IMMINENT} as an indication that they should + * unwind their existing transactions. After this error is delivered to a + * connection's event handler, no more messages will be delivered to the + * connection. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_TRANSACTION_DEPRECATED +XPC_EXPORT +void +xpc_transaction_begin(void); + +/*! + * @function xpc_transaction_end + * Informs the XPC runtime that a transaction has ended. + * + * @discussion + * As described in {@link xpc_transaction_begin()}, this API may be used + * interchangeably with vproc_transaction_end(). + * + * See the discussion for {@link xpc_transaction_begin()} for details regarding + * the XPC runtime's idle-exit policy. + */ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_TRANSACTION_DEPRECATED +XPC_EXPORT +void +xpc_transaction_end(void); + +#pragma mark XPC Event Stream +/*! + * @function xpc_set_event_stream_handler + * Sets the event handler to invoke when streamed events are received. + * + * @param stream + * The name of the event stream for which this handler will be invoked. + * + * @param targetq + * The GCD queue to which the event handler block will be submitted. This + * parameter may be NULL, in which case the connection's target queue will be + * libdispatch's default target queue, defined as DISPATCH_TARGET_QUEUE_DEFAULT. + * + * @param handler + * The event handler block. The event which this block receives as its first + * parameter will always be a dictionary which contains the XPC_EVENT_KEY_NAME + * key. The value for this key will be a string whose value is the name assigned + * to the XPC event specified in the launchd.plist. Future keys may be added to + * this dictionary. + * + * @discussion + * Multiple calls to this function for the same event stream will result in + * undefined behavior. + * + * There is no API to pause delivery of XPC events. If a process that + * has set an XPC event handler exits, events may be dropped due to races + * between the event handler running and the process exiting. + */ +#if __BLOCKS__ +__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0) +XPC_EXPORT XPC_NONNULL1 XPC_NONNULL3 +void +xpc_set_event_stream_handler(const char *stream, + dispatch_queue_t _Nullable targetq, xpc_handler_t handler); +#endif // __BLOCKS__ + +__END_DECLS +XPC_ASSUME_NONNULL_END + +#endif // __XPC_H__ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/AssertMacros.h b/lib/libc/include/any-macos-any/AssertMacros.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/AssertMacros.h rename to lib/libc/include/any-macos-any/AssertMacros.h index c338a0f9e4..7dc2e589af 100644 --- a/lib/libc/include/x86_64-macos-gnu/AssertMacros.h +++ b/lib/libc/include/any-macos-any/AssertMacros.h @@ -1438,4 +1438,4 @@ #endif /* ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES */ -#endif /* __ASSERTMACROS__ */ +#endif /* __ASSERTMACROS__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/Block.h b/lib/libc/include/any-macos-any/Block.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/Block.h rename to lib/libc/include/any-macos-any/Block.h index a98d83539c..2e27bd800a 100644 --- a/lib/libc/include/x86_64-macos-gnu/Block.h +++ b/lib/libc/include/any-macos-any/Block.h @@ -61,4 +61,4 @@ BLOCK_EXPORT void * _NSConcreteStackBlock[32] #define Block_release(...) _Block_release((const void *)(__VA_ARGS__)) -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/ConditionalMacros.h b/lib/libc/include/any-macos-any/ConditionalMacros.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/ConditionalMacros.h rename to lib/libc/include/any-macos-any/ConditionalMacros.h index 5344fb985f..4f817ec1c1 100644 --- a/lib/libc/include/x86_64-macos-gnu/ConditionalMacros.h +++ b/lib/libc/include/any-macos-any/ConditionalMacros.h @@ -615,5 +615,4 @@ -#endif /* __CONDITIONALMACROS__ */ - +#endif /* __CONDITIONALMACROS__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/MacTypes.h b/lib/libc/include/any-macos-any/MacTypes.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/MacTypes.h rename to lib/libc/include/any-macos-any/MacTypes.h index 135fad0fd2..b4bba7e446 100644 --- a/lib/libc/include/x86_64-macos-gnu/MacTypes.h +++ b/lib/libc/include/any-macos-any/MacTypes.h @@ -804,5 +804,4 @@ SysBreakFunc(ConstStr255Param debuggerMsg) __OSX_AVAILABLE_BU } #endif -#endif /* __MACTYPES__ */ - +#endif /* __MACTYPES__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/__wctype.h b/lib/libc/include/any-macos-any/__wctype.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/__wctype.h rename to lib/libc/include/any-macos-any/__wctype.h index 3b4eb2c8a7..0e1d8d2d86 100644 --- a/lib/libc/include/x86_64-macos-gnu/__wctype.h +++ b/lib/libc/include/any-macos-any/__wctype.h @@ -71,4 +71,4 @@ #include -#endif /* ___WCTYPE_H_ */ +#endif /* ___WCTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_ctype.h b/lib/libc/include/any-macos-any/_ctype.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/_ctype.h rename to lib/libc/include/any-macos-any/_ctype.h index 86e8b229b4..34824a0e67 100644 --- a/lib/libc/include/x86_64-macos-gnu/_ctype.h +++ b/lib/libc/include/any-macos-any/_ctype.h @@ -384,4 +384,4 @@ __END_DECLS #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* !_CTYPE_H_ */ +#endif /* !_CTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_locale.h b/lib/libc/include/any-macos-any/_locale.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/_locale.h rename to lib/libc/include/any-macos-any/_locale.h index b87458ddf5..e59625eb5f 100644 --- a/lib/libc/include/x86_64-macos-gnu/_locale.h +++ b/lib/libc/include/any-macos-any/_locale.h @@ -73,4 +73,4 @@ __BEGIN_DECLS struct lconv *localeconv(void); __END_DECLS -#endif /* __LOCALE_H_ */ +#endif /* __LOCALE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_regex.h b/lib/libc/include/any-macos-any/_regex.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/_regex.h rename to lib/libc/include/any-macos-any/_regex.h index 1fb98e312d..0e6f48a04d 100644 --- a/lib/libc/include/x86_64-macos-gnu/_regex.h +++ b/lib/libc/include/any-macos-any/_regex.h @@ -118,4 +118,4 @@ typedef struct { regoff_t rm_eo; /* end of match */ } regmatch_t; -#endif /* !__REGEX_H_ */ +#endif /* !__REGEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_stdio.h b/lib/libc/include/any-macos-any/_stdio.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/_stdio.h rename to lib/libc/include/any-macos-any/_stdio.h index 0f3ae7a7ba..5c46369ce5 100644 --- a/lib/libc/include/x86_64-macos-gnu/_stdio.h +++ b/lib/libc/include/any-macos-any/_stdio.h @@ -156,4 +156,4 @@ typedef struct __sFILE { fpos_t _offset; /* current lseek offset (see WARNING) */ } FILE; -#endif /* __STDIO_H_ */ +#endif /* __STDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_types.h b/lib/libc/include/any-macos-any/_types.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/_types.h rename to lib/libc/include/any-macos-any/_types.h index 83cd510175..bbd89d0f16 100644 --- a/lib/libc/include/x86_64-macos-gnu/_types.h +++ b/lib/libc/include/any-macos-any/_types.h @@ -66,4 +66,4 @@ typedef unsigned long __darwin_wctype_t; # endif #endif -#endif /* __TYPES_H_ */ +#endif /* __TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_types/_intmax_t.h b/lib/libc/include/any-macos-any/_types/_intmax_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/_types/_intmax_t.h rename to lib/libc/include/any-macos-any/_types/_intmax_t.h index abb585e653..286fe6b732 100644 --- a/lib/libc/include/x86_64-macos-gnu/_types/_intmax_t.h +++ b/lib/libc/include/any-macos-any/_types/_intmax_t.h @@ -37,4 +37,4 @@ typedef long int intmax_t; typedef long long int intmax_t; #endif /* __LP64__ */ #endif /* __INTMAX_TYPE__ */ -#endif /* _INTMAX_T */ +#endif /* _INTMAX_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_types/_nl_item.h b/lib/libc/include/any-macos-any/_types/_nl_item.h similarity index 100% rename from lib/libc/include/x86_64-macos-gnu/_types/_nl_item.h rename to lib/libc/include/any-macos-any/_types/_nl_item.h diff --git a/lib/libc/include/x86_64-macos-gnu/_types/_uint16_t.h b/lib/libc/include/any-macos-any/_types/_uint16_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/_types/_uint16_t.h rename to lib/libc/include/any-macos-any/_types/_uint16_t.h index 9ce9976013..ff8521b488 100644 --- a/lib/libc/include/x86_64-macos-gnu/_types/_uint16_t.h +++ b/lib/libc/include/any-macos-any/_types/_uint16_t.h @@ -29,4 +29,4 @@ #ifndef _UINT16_T #define _UINT16_T typedef unsigned short uint16_t; -#endif /* _UINT16_T */ +#endif /* _UINT16_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_types/_uint32_t.h b/lib/libc/include/any-macos-any/_types/_uint32_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/_types/_uint32_t.h rename to lib/libc/include/any-macos-any/_types/_uint32_t.h index 8c9c92e310..b5cecad80e 100644 --- a/lib/libc/include/x86_64-macos-gnu/_types/_uint32_t.h +++ b/lib/libc/include/any-macos-any/_types/_uint32_t.h @@ -29,4 +29,4 @@ #ifndef _UINT32_T #define _UINT32_T typedef unsigned int uint32_t; -#endif /* _UINT32_T */ +#endif /* _UINT32_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_types/_uint64_t.h b/lib/libc/include/any-macos-any/_types/_uint64_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/_types/_uint64_t.h rename to lib/libc/include/any-macos-any/_types/_uint64_t.h index 37866cfe02..e50a58e428 100644 --- a/lib/libc/include/x86_64-macos-gnu/_types/_uint64_t.h +++ b/lib/libc/include/any-macos-any/_types/_uint64_t.h @@ -29,4 +29,4 @@ #ifndef _UINT64_T #define _UINT64_T typedef unsigned long long uint64_t; -#endif /* _UINT64_T */ +#endif /* _UINT64_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_types/_uint8_t.h b/lib/libc/include/any-macos-any/_types/_uint8_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/_types/_uint8_t.h rename to lib/libc/include/any-macos-any/_types/_uint8_t.h index 9fb2a8e51a..676f112413 100644 --- a/lib/libc/include/x86_64-macos-gnu/_types/_uint8_t.h +++ b/lib/libc/include/any-macos-any/_types/_uint8_t.h @@ -29,4 +29,4 @@ #ifndef _UINT8_T #define _UINT8_T typedef unsigned char uint8_t; -#endif /* _UINT8_T */ +#endif /* _UINT8_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_types/_uintmax_t.h b/lib/libc/include/any-macos-any/_types/_uintmax_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/_types/_uintmax_t.h rename to lib/libc/include/any-macos-any/_types/_uintmax_t.h index ee52755772..334a65267b 100644 --- a/lib/libc/include/x86_64-macos-gnu/_types/_uintmax_t.h +++ b/lib/libc/include/any-macos-any/_types/_uintmax_t.h @@ -37,4 +37,4 @@ typedef long unsigned int uintmax_t; typedef long long unsigned int uintmax_t; #endif /* __LP64__ */ #endif /* __UINTMAX_TYPE__ */ -#endif /* _UINTMAX_T */ +#endif /* _UINTMAX_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_types/_wctrans_t.h b/lib/libc/include/any-macos-any/_types/_wctrans_t.h similarity index 100% rename from lib/libc/include/x86_64-macos-gnu/_types/_wctrans_t.h rename to lib/libc/include/any-macos-any/_types/_wctrans_t.h diff --git a/lib/libc/include/x86_64-macos-gnu/_types/_wctype_t.h b/lib/libc/include/any-macos-any/_types/_wctype_t.h similarity index 100% rename from lib/libc/include/x86_64-macos-gnu/_types/_wctype_t.h rename to lib/libc/include/any-macos-any/_types/_wctype_t.h diff --git a/lib/libc/include/x86_64-macos-gnu/_wctype.h b/lib/libc/include/any-macos-any/_wctype.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/_wctype.h rename to lib/libc/include/any-macos-any/_wctype.h index 04da7960ef..3bc10b16d3 100644 --- a/lib/libc/include/x86_64-macos-gnu/_wctype.h +++ b/lib/libc/include/any-macos-any/_wctype.h @@ -161,4 +161,4 @@ __END_DECLS #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* __WCTYPE_H_ */ +#endif /* __WCTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_xlocale.h b/lib/libc/include/any-macos-any/_xlocale.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/_xlocale.h rename to lib/libc/include/any-macos-any/_xlocale.h index 0ba412c5bd..ed6da667da 100644 --- a/lib/libc/include/x86_64-macos-gnu/_xlocale.h +++ b/lib/libc/include/any-macos-any/_xlocale.h @@ -34,4 +34,4 @@ int ___mb_cur_max(void); int ___mb_cur_max_l(locale_t); __END_DECLS -#endif /* __XLOCALE_H_ */ +#endif /* __XLOCALE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/aio.h b/lib/libc/include/any-macos-any/aio.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/aio.h rename to lib/libc/include/any-macos-any/aio.h index b031764468..36b7812682 100644 --- a/lib/libc/include/x86_64-macos-gnu/aio.h +++ b/lib/libc/include/any-macos-any/aio.h @@ -34,4 +34,4 @@ #include -#endif /* _AIO_H_ */ +#endif /* _AIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/alloca.h b/lib/libc/include/any-macos-any/alloca.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/alloca.h rename to lib/libc/include/any-macos-any/alloca.h index 0264ae680d..acb3390005 100644 --- a/lib/libc/include/x86_64-macos-gnu/alloca.h +++ b/lib/libc/include/any-macos-any/alloca.h @@ -40,4 +40,4 @@ __END_DECLS #define __alloca(size) __builtin_alloca(size) #endif -#endif /* _ALLOCA_H_ */ +#endif /* _ALLOCA_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/architecture/byte_order.h b/lib/libc/include/any-macos-any/architecture/byte_order.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/architecture/byte_order.h rename to lib/libc/include/any-macos-any/architecture/byte_order.h index 7a04ff899c..82ef17af08 100644 --- a/lib/libc/include/x86_64-macos-gnu/architecture/byte_order.h +++ b/lib/libc/include/any-macos-any/architecture/byte_order.h @@ -378,4 +378,4 @@ NXSwapHostFloatToLittle( return (NXSwappedFloat)OSSwapHostToLittleInt32((uint32_t)NXConvertHostFloatToSwapped(x)); } -#endif /* _ARCHITECTURE_BYTE_ORDER_H_ */ +#endif /* _ARCHITECTURE_BYTE_ORDER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/arpa/inet.h b/lib/libc/include/any-macos-any/arpa/inet.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/arpa/inet.h rename to lib/libc/include/any-macos-any/arpa/inet.h index 46f44e1a82..68a17d7313 100644 --- a/lib/libc/include/x86_64-macos-gnu/arpa/inet.h +++ b/lib/libc/include/any-macos-any/arpa/inet.h @@ -94,4 +94,4 @@ char *inet_nsap_ntoa(int, const unsigned char *, char *); __END_DECLS -#endif /* !_ARPA_INET_H_ */ +#endif /* !_ARPA_INET_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/assert.h b/lib/libc/include/any-macos-any/assert.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/assert.h rename to lib/libc/include/any-macos-any/assert.h index 2cc0ac0a24..e08d52cb28 100644 --- a/lib/libc/include/x86_64-macos-gnu/assert.h +++ b/lib/libc/include/any-macos-any/assert.h @@ -108,4 +108,4 @@ __END_DECLS #endif /* __STDC_VERSION__ */ #endif /* !__cplusplus */ -#endif /* _ASSERT_H_ */ +#endif /* _ASSERT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/complex.h b/lib/libc/include/any-macos-any/complex.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/complex.h rename to lib/libc/include/any-macos-any/complex.h index fd47a890a9..7d09126ef4 100644 --- a/lib/libc/include/x86_64-macos-gnu/complex.h +++ b/lib/libc/include/any-macos-any/complex.h @@ -164,4 +164,4 @@ extern double creal(double complex); extern long double creall(long double complex); __END_DECLS -#endif /* __COMPLEX_H__ */ +#endif /* __COMPLEX_H__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/copyfile.h b/lib/libc/include/any-macos-any/copyfile.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/copyfile.h rename to lib/libc/include/any-macos-any/copyfile.h index dfe4d0824d..50239ee191 100644 --- a/lib/libc/include/x86_64-macos-gnu/copyfile.h +++ b/lib/libc/include/any-macos-any/copyfile.h @@ -130,4 +130,4 @@ typedef int (*copyfile_callback_t)(int, int, copyfile_state_t, const char *, con __END_DECLS -#endif /* _COPYFILE_H_ */ +#endif /* _COPYFILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/cpio.h b/lib/libc/include/any-macos-any/cpio.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/cpio.h rename to lib/libc/include/any-macos-any/cpio.h index d287af631c..09e00dbcbb 100644 --- a/lib/libc/include/x86_64-macos-gnu/cpio.h +++ b/lib/libc/include/any-macos-any/cpio.h @@ -52,4 +52,4 @@ #define MAGIC "070707" -#endif /* _CPIO_H_ */ +#endif /* _CPIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/crt_externs.h b/lib/libc/include/any-macos-any/crt_externs.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/crt_externs.h rename to lib/libc/include/any-macos-any/crt_externs.h index eb3729adad..d4367a9101 100644 --- a/lib/libc/include/x86_64-macos-gnu/crt_externs.h +++ b/lib/libc/include/any-macos-any/crt_externs.h @@ -44,4 +44,4 @@ extern struct mach_header_64 * extern struct mach_header * #endif /* __LP64__ */ _NSGetMachExecuteHeader(void); -__END_DECLS +__END_DECLS \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/ctype.h b/lib/libc/include/any-macos-any/ctype.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/ctype.h rename to lib/libc/include/any-macos-any/ctype.h index b8933696a4..dbdd5a440b 100644 --- a/lib/libc/include/x86_64-macos-gnu/ctype.h +++ b/lib/libc/include/any-macos-any/ctype.h @@ -72,4 +72,4 @@ #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* !_CTYPE_H_ */ +#endif /* !_CTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/device/device_types.h b/lib/libc/include/any-macos-any/device/device_types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/device/device_types.h rename to lib/libc/include/any-macos-any/device/device_types.h index 2125026e9b..2878666853 100644 --- a/lib/libc/include/x86_64-macos-gnu/device/device_types.h +++ b/lib/libc/include/any-macos-any/device/device_types.h @@ -115,4 +115,4 @@ typedef mach_port_t io_object_t; #endif /* IOKIT */ -#endif /* DEVICE_TYPES_H */ +#endif /* DEVICE_TYPES_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dirent.h b/lib/libc/include/any-macos-any/dirent.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/dirent.h rename to lib/libc/include/any-macos-any/dirent.h index 0791063fdf..b9b8d33830 100644 --- a/lib/libc/include/x86_64-macos-gnu/dirent.h +++ b/lib/libc/include/any-macos-any/dirent.h @@ -188,4 +188,4 @@ __END_DECLS #endif /* !KERNEL */ -#endif /* !_DIRENT_H_ */ +#endif /* !_DIRENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/base.h b/lib/libc/include/any-macos-any/dispatch/base.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/dispatch/base.h rename to lib/libc/include/any-macos-any/dispatch/base.h index 8ede9615bc..86ed15d144 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/base.h +++ b/lib/libc/include/any-macos-any/dispatch/base.h @@ -303,4 +303,4 @@ typedef void (*dispatch_function_t)(void *_Nullable); -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/data.h b/lib/libc/include/any-macos-any/dispatch/data.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/dispatch/data.h rename to lib/libc/include/any-macos-any/dispatch/data.h index 8250669183..7d8557dd39 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/data.h +++ b/lib/libc/include/any-macos-any/dispatch/data.h @@ -275,4 +275,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif /* __DISPATCH_DATA__ */ +#endif /* __DISPATCH_DATA__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/io.h b/lib/libc/include/any-macos-any/dispatch/io.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/dispatch/io.h rename to lib/libc/include/any-macos-any/dispatch/io.h index db9733d829..2dfc3fc0a6 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/io.h +++ b/lib/libc/include/any-macos-any/dispatch/io.h @@ -594,4 +594,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif /* __DISPATCH_IO__ */ +#endif /* __DISPATCH_IO__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/once.h b/lib/libc/include/any-macos-any/dispatch/once.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/dispatch/once.h rename to lib/libc/include/any-macos-any/dispatch/once.h index fbce4b111e..8ea5ecf100 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/once.h +++ b/lib/libc/include/any-macos-any/dispatch/once.h @@ -122,4 +122,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/time.h b/lib/libc/include/any-macos-any/dispatch/time.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/dispatch/time.h rename to lib/libc/include/any-macos-any/dispatch/time.h index a1cd2006ef..79e91e2ccb 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/time.h +++ b/lib/libc/include/any-macos-any/dispatch/time.h @@ -133,4 +133,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dlfcn.h b/lib/libc/include/any-macos-any/dlfcn.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/dlfcn.h rename to lib/libc/include/any-macos-any/dlfcn.h index f11d3f5e68..8b5db209ce 100644 --- a/lib/libc/include/x86_64-macos-gnu/dlfcn.h +++ b/lib/libc/include/any-macos-any/dlfcn.h @@ -94,4 +94,4 @@ extern bool dlopen_preflight(const char* __path) __OSX_AVAILABLE_STARTING(__MAC_ } #endif -#endif /* _DLFCN_H_ */ +#endif /* _DLFCN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/errno.h b/lib/libc/include/any-macos-any/errno.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/errno.h rename to lib/libc/include/any-macos-any/errno.h index 9879cc4fc2..7768ed7e94 100644 --- a/lib/libc/include/x86_64-macos-gnu/errno.h +++ b/lib/libc/include/any-macos-any/errno.h @@ -20,5 +20,4 @@ * * @APPLE_LICENSE_HEADER_END@ */ -#include - +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/execinfo.h b/lib/libc/include/any-macos-any/execinfo.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/execinfo.h rename to lib/libc/include/any-macos-any/execinfo.h index 97d942274c..65d9d20486 100644 --- a/lib/libc/include/x86_64-macos-gnu/execinfo.h +++ b/lib/libc/include/any-macos-any/execinfo.h @@ -60,4 +60,4 @@ void backtrace_image_offsets(void* const* array, __END_DECLS -#endif /* !_EXECINFO_H_ */ +#endif /* !_EXECINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/fcntl.h b/lib/libc/include/any-macos-any/fcntl.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/fcntl.h rename to lib/libc/include/any-macos-any/fcntl.h index d4b1ae2b29..838022fd72 100644 --- a/lib/libc/include/x86_64-macos-gnu/fcntl.h +++ b/lib/libc/include/any-macos-any/fcntl.h @@ -20,4 +20,4 @@ * * @APPLE_LICENSE_HEADER_END@ */ -#include +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/fenv.h b/lib/libc/include/any-macos-any/fenv.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/fenv.h rename to lib/libc/include/any-macos-any/fenv.h index d5ebc83654..df59070441 100644 --- a/lib/libc/include/x86_64-macos-gnu/fenv.h +++ b/lib/libc/include/any-macos-any/fenv.h @@ -357,5 +357,4 @@ extern int feupdateenv(const fenv_t * /* envp */); } #endif -#endif /* __FENV_H__ */ - +#endif /* __FENV_H__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/float.h b/lib/libc/include/any-macos-any/float.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/float.h rename to lib/libc/include/any-macos-any/float.h index d0c159657a..3a533f3284 100644 --- a/lib/libc/include/x86_64-macos-gnu/float.h +++ b/lib/libc/include/any-macos-any/float.h @@ -137,4 +137,4 @@ # define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ #endif -#endif /* __FLOAT_H */ +#endif /* __FLOAT_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/fmtmsg.h b/lib/libc/include/any-macos-any/fmtmsg.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/fmtmsg.h rename to lib/libc/include/any-macos-any/fmtmsg.h index 256cf335e6..408fbaa3ac 100644 --- a/lib/libc/include/x86_64-macos-gnu/fmtmsg.h +++ b/lib/libc/include/any-macos-any/fmtmsg.h @@ -70,4 +70,4 @@ int fmtmsg(long, const char *, int, const char *, const char *, const char *); -#endif /* !_FMTMSG_H_ */ +#endif /* !_FMTMSG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/fnmatch.h b/lib/libc/include/any-macos-any/fnmatch.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/fnmatch.h rename to lib/libc/include/any-macos-any/fnmatch.h index e1ffaea62a..55c45f0719 100644 --- a/lib/libc/include/x86_64-macos-gnu/fnmatch.h +++ b/lib/libc/include/any-macos-any/fnmatch.h @@ -79,4 +79,4 @@ __BEGIN_DECLS int fnmatch(const char *, const char *, int) __DARWIN_ALIAS(fnmatch); __END_DECLS -#endif /* !_FNMATCH_H_ */ +#endif /* !_FNMATCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/ftw.h b/lib/libc/include/any-macos-any/ftw.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/ftw.h rename to lib/libc/include/any-macos-any/ftw.h index acf0bc54c6..c1666beee7 100644 --- a/lib/libc/include/x86_64-macos-gnu/ftw.h +++ b/lib/libc/include/any-macos-any/ftw.h @@ -57,4 +57,4 @@ int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int) __DARWIN_ALIAS_I(nftw); __END_DECLS -#endif /* !_FTW_H */ +#endif /* !_FTW_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/gethostuuid.h b/lib/libc/include/any-macos-any/gethostuuid.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/gethostuuid.h rename to lib/libc/include/any-macos-any/gethostuuid.h index 94808a7f74..cc7f473118 100644 --- a/lib/libc/include/x86_64-macos-gnu/gethostuuid.h +++ b/lib/libc/include/any-macos-any/gethostuuid.h @@ -39,4 +39,4 @@ int gethostuuid(uuid_t, const struct timespec *) __OSX_AVAILABLE_BUT_DEPRECATED_ int gethostuuid(uuid_t, const struct timespec *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA); #endif -#endif /* __GETHOSTUUID_H */ +#endif /* __GETHOSTUUID_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/glob.h b/lib/libc/include/any-macos-any/glob.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/glob.h rename to lib/libc/include/any-macos-any/glob.h index 50881d7a05..c8fd109174 100644 --- a/lib/libc/include/x86_64-macos-gnu/glob.h +++ b/lib/libc/include/any-macos-any/glob.h @@ -127,4 +127,4 @@ int glob_b(const char * __restrict, int, int (^)(const char *, int) __glob_noesc void globfree(glob_t *); __END_DECLS -#endif /* !_GLOB_H_ */ +#endif /* !_GLOB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/grp.h b/lib/libc/include/any-macos-any/grp.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/grp.h rename to lib/libc/include/any-macos-any/grp.h index 0091ee44c7..5cf7f0c5db 100644 --- a/lib/libc/include/x86_64-macos-gnu/grp.h +++ b/lib/libc/include/any-macos-any/grp.h @@ -90,4 +90,4 @@ int setgroupent(int); __END_DECLS #endif -#endif /* !_GRP_H_ */ +#endif /* !_GRP_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/hfs/hfs_format.h b/lib/libc/include/any-macos-any/hfs/hfs_format.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/hfs/hfs_format.h rename to lib/libc/include/any-macos-any/hfs/hfs_format.h index 89df0dc69b..4fc240cf69 100644 --- a/lib/libc/include/x86_64-macos-gnu/hfs/hfs_format.h +++ b/lib/libc/include/any-macos-any/hfs/hfs_format.h @@ -815,4 +815,4 @@ enum { } #endif -#endif /* __HFS_FORMAT__ */ +#endif /* __HFS_FORMAT__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/hfs/hfs_unistr.h b/lib/libc/include/any-macos-any/hfs/hfs_unistr.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/hfs/hfs_unistr.h rename to lib/libc/include/any-macos-any/hfs/hfs_unistr.h index 5b300a28d1..9331d30436 100644 --- a/lib/libc/include/x86_64-macos-gnu/hfs/hfs_unistr.h +++ b/lib/libc/include/any-macos-any/hfs/hfs_unistr.h @@ -61,4 +61,4 @@ typedef const HFSUniStr255 *ConstHFSUniStr255Param; #endif -#endif /* __HFS_UNISTR__ */ +#endif /* __HFS_UNISTR__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/iconv.h b/lib/libc/include/any-macos-any/iconv.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/iconv.h rename to lib/libc/include/any-macos-any/iconv.h index 2a6cc01c30..a0e45daf8a 100644 --- a/lib/libc/include/x86_64-macos-gnu/iconv.h +++ b/lib/libc/include/any-macos-any/iconv.h @@ -190,4 +190,4 @@ extern __LIBICONV_DLL_EXPORTED void libiconv_set_relocation_prefix (const char * #endif -#endif /* _LIBICONV_H */ +#endif /* _LIBICONV_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/ifaddrs.h b/lib/libc/include/any-macos-any/ifaddrs.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/ifaddrs.h rename to lib/libc/include/any-macos-any/ifaddrs.h index cf78188537..04d0703b1b 100644 --- a/lib/libc/include/x86_64-macos-gnu/ifaddrs.h +++ b/lib/libc/include/any-macos-any/ifaddrs.h @@ -67,4 +67,4 @@ extern int getifmaddrs(struct ifmaddrs **) API_AVAILABLE(macos(10.7), ios(4.3), extern void freeifmaddrs(struct ifmaddrs *) API_AVAILABLE(macos(10.7), ios(4.3), watchos(4.0), tvos(11.0)); __END_DECLS -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/inttypes.h b/lib/libc/include/any-macos-any/inttypes.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/inttypes.h rename to lib/libc/include/any-macos-any/inttypes.h index c29873da31..2872c18f1e 100644 --- a/lib/libc/include/x86_64-macos-gnu/inttypes.h +++ b/lib/libc/include/any-macos-any/inttypes.h @@ -294,4 +294,4 @@ __END_DECLS not where it is #defined. */ -#endif /* !_INTTYPES_H_ */ +#endif /* !_INTTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/langinfo.h b/lib/libc/include/any-macos-any/langinfo.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/langinfo.h rename to lib/libc/include/any-macos-any/langinfo.h index a7a3b2b53e..424ff84aa0 100644 --- a/lib/libc/include/x86_64-macos-gnu/langinfo.h +++ b/lib/libc/include/any-macos-any/langinfo.h @@ -117,4 +117,4 @@ __END_DECLS #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* !_LANGINFO_H_ */ +#endif /* !_LANGINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/launch.h b/lib/libc/include/any-macos-any/launch.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/launch.h rename to lib/libc/include/any-macos-any/launch.h index 905b9ef931..88a849b7e2 100644 --- a/lib/libc/include/x86_64-macos-gnu/launch.h +++ b/lib/libc/include/any-macos-any/launch.h @@ -406,4 +406,4 @@ __END_DECLS _Pragma("clang assume_nonnull end") #endif -#endif // __XPC_LAUNCH_H__ +#endif // __XPC_LAUNCH_H__ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libgen.h b/lib/libc/include/any-macos-any/libgen.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/libgen.h rename to lib/libc/include/any-macos-any/libgen.h index 4200fc6c40..3fbd2806ce 100644 --- a/lib/libc/include/x86_64-macos-gnu/libgen.h +++ b/lib/libc/include/any-macos-any/libgen.h @@ -60,4 +60,4 @@ char *dirname_r(const char *, char *) __END_DECLS -#endif /* _LIBGEN_H_ */ +#endif /* _LIBGEN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSTypes.h b/lib/libc/include/any-macos-any/libkern/OSTypes.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/libkern/OSTypes.h rename to lib/libc/include/any-macos-any/libkern/OSTypes.h index 451ef763c8..0fff18c1f6 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/OSTypes.h +++ b/lib/libc/include/any-macos-any/libkern/OSTypes.h @@ -39,4 +39,4 @@ typedef signed int SInt; #include -#endif /* _OS_OSTYPES_H */ +#endif /* _OS_OSTYPES_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/limits.h b/lib/libc/include/any-macos-any/limits.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/limits.h rename to lib/libc/include/any-macos-any/limits.h index 2ed444e09d..52f4e9add6 100644 --- a/lib/libc/include/x86_64-macos-gnu/limits.h +++ b/lib/libc/include/any-macos-any/limits.h @@ -164,4 +164,4 @@ /* NZERO to be defined here. TBD. See also sys/param.h */ -#endif /* !_LIMITS_H_ */ +#endif /* !_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/locale.h b/lib/libc/include/any-macos-any/locale.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/locale.h rename to lib/libc/include/any-macos-any/locale.h index ab28ceba40..5936af133e 100644 --- a/lib/libc/include/x86_64-macos-gnu/locale.h +++ b/lib/libc/include/any-macos-any/locale.h @@ -53,4 +53,4 @@ __BEGIN_DECLS char *setlocale(int, const char *); __END_DECLS -#endif /* _LOCALE_H_ */ +#endif /* _LOCALE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/boolean.h b/lib/libc/include/any-macos-any/mach/boolean.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/boolean.h rename to lib/libc/include/any-macos-any/mach/boolean.h index 6ef6d4bcd5..ba88429343 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/boolean.h +++ b/lib/libc/include/any-macos-any/mach/boolean.h @@ -85,4 +85,4 @@ #define FALSE 0 #endif /* FALSE */ -#endif /* _MACH_BOOLEAN_H_ */ +#endif /* _MACH_BOOLEAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/clock.h b/lib/libc/include/any-macos-any/mach/clock.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/clock.h rename to lib/libc/include/any-macos-any/mach/clock.h index 81e90eea3b..ec293fc9c1 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/clock.h +++ b/lib/libc/include/any-macos-any/mach/clock.h @@ -242,4 +242,4 @@ union __ReplyUnion__clock_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _clock_user_ */ +#endif /* _clock_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/clock_priv.h b/lib/libc/include/any-macos-any/mach/clock_priv.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/clock_priv.h rename to lib/libc/include/any-macos-any/mach/clock_priv.h index ec6a65840d..0c9d11d9c6 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/clock_priv.h +++ b/lib/libc/include/any-macos-any/mach/clock_priv.h @@ -196,4 +196,4 @@ union __ReplyUnion__clock_priv_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _clock_priv_user_ */ +#endif /* _clock_priv_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/clock_types.h b/lib/libc/include/any-macos-any/mach/clock_types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/clock_types.h rename to lib/libc/include/any-macos-any/mach/clock_types.h index 9b3d49a94b..87daf9270a 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/clock_types.h +++ b/lib/libc/include/any-macos-any/mach/clock_types.h @@ -124,4 +124,4 @@ typedef struct mach_timespec mach_timespec_t; #define BAD_ALRMTYPE(t) (((t) &~ TIME_RELATIVE) != 0) -#endif /* _MACH_CLOCK_TYPES_H_ */ +#endif /* _MACH_CLOCK_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/dyld_kernel.h b/lib/libc/include/any-macos-any/mach/dyld_kernel.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/dyld_kernel.h rename to lib/libc/include/any-macos-any/mach/dyld_kernel.h index b28e45f199..606ac289f2 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/dyld_kernel.h +++ b/lib/libc/include/any-macos-any/mach/dyld_kernel.h @@ -63,4 +63,4 @@ typedef struct dyld_kernel_image_info dyld_kernel_image_info_t; typedef struct dyld_kernel_process_info dyld_kernel_process_info_t; typedef dyld_kernel_image_info_t *dyld_kernel_image_info_array_t; -#endif /* _MACH_DYLIB_INFO_H_ */ +#endif /* _MACH_DYLIB_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/error.h b/lib/libc/include/any-macos-any/mach/error.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/error.h rename to lib/libc/include/any-macos-any/mach/error.h index 50c77b9cda..0643a9881f 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/error.h +++ b/lib/libc/include/any-macos-any/mach/error.h @@ -111,4 +111,4 @@ typedef kern_return_t mach_error_t; typedef mach_error_t (* mach_error_fn_t)( void ); -#endif /* _MACH_ERROR_H_ */ +#endif /* _MACH_ERROR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/exception_types.h b/lib/libc/include/any-macos-any/mach/exception_types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/exception_types.h rename to lib/libc/include/any-macos-any/mach/exception_types.h index ccbcf0bb42..a0026b9ce2 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/exception_types.h +++ b/lib/libc/include/any-macos-any/mach/exception_types.h @@ -201,4 +201,4 @@ typedef mach_exception_data_type_t mach_exception_subcode_t; #endif /* ASSEMBLER */ -#endif /* _MACH_EXCEPTION_TYPES_H_ */ +#endif /* _MACH_EXCEPTION_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/host_info.h b/lib/libc/include/any-macos-any/mach/host_info.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/host_info.h rename to lib/libc/include/any-macos-any/mach/host_info.h index 648d25ca79..362a7d40c8 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/host_info.h +++ b/lib/libc/include/any-macos-any/mach/host_info.h @@ -257,4 +257,4 @@ typedef struct host_preferred_user_arch *host_preferred_user_arch_t; -#endif /* _MACH_HOST_INFO_H_ */ +#endif /* _MACH_HOST_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/host_notify.h b/lib/libc/include/any-macos-any/mach/host_notify.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/mach/host_notify.h rename to lib/libc/include/any-macos-any/mach/host_notify.h index cda654bf4c..9816fcbbf4 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/host_notify.h +++ b/lib/libc/include/any-macos-any/mach/host_notify.h @@ -36,4 +36,4 @@ #define HOST_CALENDAR_CHANGED_REPLYID 950 #define HOST_CALENDAR_SET_REPLYID 951 -#endif /* _MACH_HOST_NOTIFY_H_ */ +#endif /* _MACH_HOST_NOTIFY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/host_priv.h b/lib/libc/include/any-macos-any/mach/host_priv.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/host_priv.h rename to lib/libc/include/any-macos-any/mach/host_priv.h index 33d87f2f23..9445ae5d93 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/host_priv.h +++ b/lib/libc/include/any-macos-any/mach/host_priv.h @@ -1160,4 +1160,4 @@ union __ReplyUnion__host_priv_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _host_priv_user_ */ +#endif /* _host_priv_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/host_security.h b/lib/libc/include/any-macos-any/mach/host_security.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/host_security.h rename to lib/libc/include/any-macos-any/mach/host_security.h index a7928db8ef..1c1b6d9144 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/host_security.h +++ b/lib/libc/include/any-macos-any/mach/host_security.h @@ -218,4 +218,4 @@ union __ReplyUnion__host_security_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _host_security_user_ */ +#endif /* _host_security_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/host_special_ports.h b/lib/libc/include/any-macos-any/mach/host_special_ports.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/host_special_ports.h rename to lib/libc/include/any-macos-any/mach/host_special_ports.h index d09b44b6b6..8d4cdbefce 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/host_special_ports.h +++ b/lib/libc/include/any-macos-any/mach/host_special_ports.h @@ -278,4 +278,4 @@ * All lookups go through send_resource_violation() */ -#endif /* _MACH_HOST_SPECIAL_PORTS_H_ */ +#endif /* _MACH_HOST_SPECIAL_PORTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/kmod.h b/lib/libc/include/any-macos-any/mach/kmod.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/kmod.h rename to lib/libc/include/any-macos-any/mach/kmod.h index d23086b52f..57ff5bd22f 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/kmod.h +++ b/lib/libc/include/any-macos-any/mach/kmod.h @@ -177,4 +177,4 @@ typedef kmod_info_t * kmod_info_array_t; __END_DECLS -#endif /* _MACH_KMOD_H_ */ +#endif /* _MACH_KMOD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/lock_set.h b/lib/libc/include/any-macos-any/mach/lock_set.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/lock_set.h rename to lib/libc/include/any-macos-any/mach/lock_set.h index e4dcf8a829..752d7c2976 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/lock_set.h +++ b/lib/libc/include/any-macos-any/mach/lock_set.h @@ -347,4 +347,4 @@ union __ReplyUnion__lock_set_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _lock_set_user_ */ +#endif /* _lock_set_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach.h b/lib/libc/include/any-macos-any/mach/mach.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/mach.h rename to lib/libc/include/any-macos-any/mach/mach.h index 9ebf5c8c7c..159fd67b99 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach.h +++ b/lib/libc/include/any-macos-any/mach/mach.h @@ -242,4 +242,4 @@ extern void voucher_mach_msg_revert(voucher_mach_msg_state_t state); __END_DECLS -#endif /* _MACH_H_ */ +#endif /* _MACH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_error.h b/lib/libc/include/any-macos-any/mach/mach_error.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/mach_error.h rename to lib/libc/include/any-macos-any/mach/mach_error.h index 538b5cb1b0..bf800a9b07 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_error.h +++ b/lib/libc/include/any-macos-any/mach/mach_error.h @@ -90,4 +90,4 @@ char *mach_error_type( ); __END_DECLS -#endif /* _MACH_ERROR_ */ +#endif /* _MACH_ERROR_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_host.h b/lib/libc/include/any-macos-any/mach/mach_host.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/mach_host.h rename to lib/libc/include/any-macos-any/mach/mach_host.h index 41c68050b8..a5b6d2cd84 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_host.h +++ b/lib/libc/include/any-macos-any/mach/mach_host.h @@ -1292,4 +1292,4 @@ union __ReplyUnion__mach_host_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _mach_host_user_ */ +#endif /* _mach_host_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_init.h b/lib/libc/include/any-macos-any/mach/mach_init.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/mach_init.h rename to lib/libc/include/any-macos-any/mach/mach_init.h index 4d9d51f466..d61d6e90b5 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_init.h +++ b/lib/libc/include/any-macos-any/mach/mach_init.h @@ -107,4 +107,4 @@ extern int (*vprintf_stderr_func)(const char *format, va_list ap); __END_DECLS -#endif /* _MACH_INIT_ */ +#endif /* _MACH_INIT_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_interface.h b/lib/libc/include/any-macos-any/mach/mach_interface.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/mach_interface.h rename to lib/libc/include/any-macos-any/mach/mach_interface.h index e6c6b7acf6..466a57a348 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_interface.h +++ b/lib/libc/include/any-macos-any/mach/mach_interface.h @@ -50,4 +50,4 @@ #include #include -#endif /* _MACH_INTERFACE_H_ */ +#endif /* _MACH_INTERFACE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_time.h b/lib/libc/include/any-macos-any/mach/mach_time.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/mach_time.h rename to lib/libc/include/any-macos-any/mach/mach_time.h index 2853aac32c..4a936ca6cc 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_time.h +++ b/lib/libc/include/any-macos-any/mach/mach_time.h @@ -70,4 +70,4 @@ uint64_t mach_continuous_approximate_time(void); __END_DECLS -#endif /* _MACH_MACH_TIME_H_ */ +#endif /* _MACH_MACH_TIME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_voucher_types.h b/lib/libc/include/any-macos-any/mach/mach_voucher_types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/mach_voucher_types.h rename to lib/libc/include/any-macos-any/mach/mach_voucher_types.h index 89d3821642..b5b34d7e4c 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_voucher_types.h +++ b/lib/libc/include/any-macos-any/mach/mach_voucher_types.h @@ -242,4 +242,4 @@ typedef uint32_t mach_voucher_attr_importance_refs; */ #define MACH_ACTIVITY_ID_COUNT_MAX 16 -#endif /* _MACH_VOUCHER_TYPES_H_ */ +#endif /* _MACH_VOUCHER_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/memory_object_types.h b/lib/libc/include/any-macos-any/mach/memory_object_types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/memory_object_types.h rename to lib/libc/include/any-macos-any/mach/memory_object_types.h index 1a731d5b26..fec6e53593 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/memory_object_types.h +++ b/lib/libc/include/any-macos-any/mach/memory_object_types.h @@ -296,4 +296,4 @@ typedef struct memory_object_attr_info memory_object_attr_info_data_t; MAP_MEM_FLAGS_USER) -#endif /* _MACH_MEMORY_OBJECT_TYPES_H_ */ +#endif /* _MACH_MEMORY_OBJECT_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mig.h b/lib/libc/include/any-macos-any/mach/mig.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/mig.h rename to lib/libc/include/any-macos-any/mach/mig.h index 066ffa75b4..aa7bcf7448 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mig.h +++ b/lib/libc/include/any-macos-any/mach/mig.h @@ -177,4 +177,4 @@ extern void mig_deallocate(vm_address_t, vm_size_t); __END_DECLS -#endif /* _MACH_MIG_H_ */ +#endif /* _MACH_MIG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mig_errors.h b/lib/libc/include/any-macos-any/mach/mig_errors.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/mig_errors.h rename to lib/libc/include/any-macos-any/mach/mig_errors.h index 418a05da3a..9af52d06d9 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mig_errors.h +++ b/lib/libc/include/any-macos-any/mach/mig_errors.h @@ -122,4 +122,4 @@ __NDR_convert__mig_reply_error_t(__unused mig_reply_error_t *x) __END_DECLS -#endif /* _MACH_MIG_ERRORS_H_ */ +#endif /* _MACH_MIG_ERRORS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mig_strncpy_zerofill_support.h b/lib/libc/include/any-macos-any/mach/mig_strncpy_zerofill_support.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/mach/mig_strncpy_zerofill_support.h rename to lib/libc/include/any-macos-any/mach/mig_strncpy_zerofill_support.h index 92d0ff8e44..1aacea41df 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mig_strncpy_zerofill_support.h +++ b/lib/libc/include/any-macos-any/mach/mig_strncpy_zerofill_support.h @@ -32,4 +32,4 @@ #ifndef __MACH_MIG_STRNCPY_ZEROFILL_SUPPORT__ #define __MACH_MIG_STRNCPY_ZEROFILL_SUPPORT__ -#endif // __MACH_MIG_STRNCPY_ZEROFILL_SUPPORT__ +#endif // __MACH_MIG_STRNCPY_ZEROFILL_SUPPORT__ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/ndr.h b/lib/libc/include/any-macos-any/mach/ndr.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/ndr.h rename to lib/libc/include/any-macos-any/mach/ndr.h index 61c00ff1d3..608f9acc38 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/ndr.h +++ b/lib/libc/include/any-macos-any/mach/ndr.h @@ -204,4 +204,4 @@ __END_DECLS #endif /* __NDR_convert__ */ -#endif /* _MACH_NDR_H_ */ +#endif /* _MACH_NDR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/notify.h b/lib/libc/include/any-macos-any/mach/notify.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/notify.h rename to lib/libc/include/any-macos-any/mach/notify.h index 5737dbc9de..d8cace1f5e 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/notify.h +++ b/lib/libc/include/any-macos-any/mach/notify.h @@ -138,4 +138,4 @@ typedef struct { mach_msg_format_0_trailer_t trailer; } mach_dead_name_notification_t; -#endif /* _MACH_NOTIFY_H_ */ +#endif /* _MACH_NOTIFY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/policy.h b/lib/libc/include/any-macos-any/mach/policy.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/policy.h rename to lib/libc/include/any-macos-any/mach/policy.h index 836b95f747..4f0df4917c 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/policy.h +++ b/lib/libc/include/any-macos-any/mach/policy.h @@ -232,4 +232,4 @@ typedef struct policy_bases policy_base_data_t; typedef struct policy_limits policy_limit_data_t; typedef struct policy_infos policy_info_data_t; -#endif /* _MACH_POLICY_H_ */ +#endif /* _MACH_POLICY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/processor.h b/lib/libc/include/any-macos-any/mach/processor.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/processor.h rename to lib/libc/include/any-macos-any/mach/processor.h index a1b9c3ba56..64cf6b97b3 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/processor.h +++ b/lib/libc/include/any-macos-any/mach/processor.h @@ -357,4 +357,4 @@ union __ReplyUnion__processor_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _processor_user_ */ +#endif /* _processor_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/processor_info.h b/lib/libc/include/any-macos-any/mach/processor_info.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/processor_info.h rename to lib/libc/include/any-macos-any/mach/processor_info.h index 8553760799..c66a7bbee8 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/processor_info.h +++ b/lib/libc/include/any-macos-any/mach/processor_info.h @@ -150,4 +150,4 @@ typedef struct processor_set_load_info *processor_set_load_info_t; (sizeof(processor_set_load_info_data_t)/sizeof(natural_t))) -#endif /* _MACH_PROCESSOR_INFO_H_ */ +#endif /* _MACH_PROCESSOR_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/rpc.h b/lib/libc/include/any-macos-any/mach/rpc.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/rpc.h rename to lib/libc/include/any-macos-any/mach/rpc.h index f3361d7690..a5579594a9 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/rpc.h +++ b/lib/libc/include/any-macos-any/mach/rpc.h @@ -132,4 +132,4 @@ typedef struct rpc_subsystem *rpc_subsystem_t; #define RPC_SUBSYSTEM_NULL ((rpc_subsystem_t) 0) -#endif /* _MACH_RPC_H_ */ +#endif /* _MACH_RPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/semaphore.h b/lib/libc/include/any-macos-any/mach/semaphore.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/semaphore.h rename to lib/libc/include/any-macos-any/mach/semaphore.h index 1ff46e4140..7779a58faf 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/semaphore.h +++ b/lib/libc/include/any-macos-any/mach/semaphore.h @@ -75,4 +75,4 @@ extern kern_return_t semaphore_signal_thread(semaphore_t semaphore, __END_DECLS -#endif /* _MACH_SEMAPHORE_H_ */ +#endif /* _MACH_SEMAPHORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/std_types.h b/lib/libc/include/any-macos-any/mach/std_types.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/std_types.h rename to lib/libc/include/any-macos-any/mach/std_types.h index 5815302d42..b83ff2f57e 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/std_types.h +++ b/lib/libc/include/any-macos-any/mach/std_types.h @@ -72,4 +72,4 @@ #include #include -#endif /* _MACH_STD_TYPES_H_ */ +#endif /* _MACH_STD_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/sync_policy.h b/lib/libc/include/any-macos-any/mach/sync_policy.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/sync_policy.h rename to lib/libc/include/any-macos-any/mach/sync_policy.h index ff487f6a80..a4c477bf5d 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/sync_policy.h +++ b/lib/libc/include/any-macos-any/mach/sync_policy.h @@ -46,4 +46,4 @@ typedef int sync_policy_t; #define SYNC_POLICY_MAX 0x7 -#endif /* _MACH_SYNC_POLICY_H_ */ +#endif /* _MACH_SYNC_POLICY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/task_inspect.h b/lib/libc/include/any-macos-any/mach/task_inspect.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/mach/task_inspect.h rename to lib/libc/include/any-macos-any/mach/task_inspect.h index b13310f75e..1ae3c6e5f1 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/task_inspect.h +++ b/lib/libc/include/any-macos-any/mach/task_inspect.h @@ -51,4 +51,4 @@ typedef struct task_inspect_basic_counts *task_inspect_basic_counts_t; typedef integer_t *task_inspect_info_t; -#endif /* !defined(MACH_TASK_INSPECT_H) */ +#endif /* !defined(MACH_TASK_INSPECT_H) */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/thread_info.h b/lib/libc/include/any-macos-any/mach/thread_info.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/thread_info.h rename to lib/libc/include/any-macos-any/mach/thread_info.h index c31a27b024..d0fdffc40b 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/thread_info.h +++ b/lib/libc/include/any-macos-any/mach/thread_info.h @@ -208,4 +208,4 @@ typedef struct io_stat_info *io_stat_info_t; #define THREAD_SCHED_RR_INFO 11 #define THREAD_SCHED_FIFO_INFO 12 -#endif /* _MACH_THREAD_INFO_H_ */ +#endif /* _MACH_THREAD_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/thread_policy.h b/lib/libc/include/any-macos-any/mach/thread_policy.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/thread_policy.h rename to lib/libc/include/any-macos-any/mach/thread_policy.h index d5c8c1bafa..e15504cff4 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/thread_policy.h +++ b/lib/libc/include/any-macos-any/mach/thread_policy.h @@ -263,4 +263,4 @@ typedef struct thread_throughput_qos_policy *thread_throughput_qos_policy_t; -#endif /* _MACH_THREAD_POLICY_H_ */ +#endif /* _MACH_THREAD_POLICY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/thread_switch.h b/lib/libc/include/any-macos-any/mach/thread_switch.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/thread_switch.h rename to lib/libc/include/any-macos-any/mach/thread_switch.h index 4ac56bfafb..79bcc00a8c 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/thread_switch.h +++ b/lib/libc/include/any-macos-any/mach/thread_switch.h @@ -74,4 +74,4 @@ #define valid_switch_option(opt) (0 <= (opt) && (opt) <= 5) -#endif /* _MACH_THREAD_SWITCH_H_ */ +#endif /* _MACH_THREAD_SWITCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/time_value.h b/lib/libc/include/any-macos-any/mach/time_value.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/time_value.h rename to lib/libc/include/any-macos-any/mach/time_value.h index 8cfd37d740..4bbf2ea567 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/time_value.h +++ b/lib/libc/include/any-macos-any/mach/time_value.h @@ -93,4 +93,4 @@ typedef struct time_value time_value_t; } \ } -#endif /* _MACH_TIME_VALUE_H_ */ +#endif /* _MACH_TIME_VALUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_attributes.h b/lib/libc/include/any-macos-any/mach/vm_attributes.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/vm_attributes.h rename to lib/libc/include/any-macos-any/mach/vm_attributes.h index bac0993cb3..2ec117793d 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_attributes.h +++ b/lib/libc/include/any-macos-any/mach/vm_attributes.h @@ -96,4 +96,4 @@ typedef int vm_machine_attribute_val_t; #define MATTR_VAL_GET_INFO 10 /* get page info (stats) */ -#endif /* _MACH_VM_ATTRIBUTES_H_ */ +#endif /* _MACH_VM_ATTRIBUTES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_behavior.h b/lib/libc/include/any-macos-any/mach/vm_behavior.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/vm_behavior.h rename to lib/libc/include/any-macos-any/mach/vm_behavior.h index 727980d51e..33db5ca54c 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_behavior.h +++ b/lib/libc/include/any-macos-any/mach/vm_behavior.h @@ -76,4 +76,4 @@ typedef int vm_behavior_t; #define VM_BEHAVIOR_CAN_REUSE ((vm_behavior_t) 10) #define VM_BEHAVIOR_PAGEOUT ((vm_behavior_t) 11) -#endif /*_MACH_VM_BEHAVIOR_H_*/ +#endif /*_MACH_VM_BEHAVIOR_H_*/ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_inherit.h b/lib/libc/include/any-macos-any/mach/vm_inherit.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/vm_inherit.h rename to lib/libc/include/any-macos-any/mach/vm_inherit.h index 528d691798..ffb7eb812a 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_inherit.h +++ b/lib/libc/include/any-macos-any/mach/vm_inherit.h @@ -86,4 +86,4 @@ typedef unsigned int vm_inherit_t; /* might want to change this */ #define VM_INHERIT_DEFAULT VM_INHERIT_COPY #define VM_INHERIT_LAST_VALID VM_INHERIT_NONE -#endif /* _MACH_VM_INHERIT_H_ */ +#endif /* _MACH_VM_INHERIT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_map.h b/lib/libc/include/any-macos-any/mach/vm_map.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/vm_map.h rename to lib/libc/include/any-macos-any/mach/vm_map.h index 6c419075f1..59b3e7ffac 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_map.h +++ b/lib/libc/include/any-macos-any/mach/vm_map.h @@ -1437,4 +1437,4 @@ union __ReplyUnion__vm_map_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _vm_map_user_ */ +#endif /* _vm_map_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_page_size.h b/lib/libc/include/any-macos-any/mach/vm_page_size.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/vm_page_size.h rename to lib/libc/include/any-macos-any/mach/vm_page_size.h index 26d7a73039..a818eabbeb 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_page_size.h +++ b/lib/libc/include/any-macos-any/mach/vm_page_size.h @@ -65,4 +65,4 @@ extern int vm_kernel_page_shift __OSX_AVAILABLE_STARTING(__MAC_1 __END_DECLS -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_purgable.h b/lib/libc/include/any-macos-any/mach/vm_purgable.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/vm_purgable.h rename to lib/libc/include/any-macos-any/mach/vm_purgable.h index 80ea756d9d..bbc6ae9641 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_purgable.h +++ b/lib/libc/include/any-macos-any/mach/vm_purgable.h @@ -159,4 +159,4 @@ typedef int vm_purgable_t; VM_VOLATILE_GROUP_MASK | \ VM_PURGABLE_DEBUG_MASK | \ VM_PURGABLE_NO_AGING_MASK) -#endif /* _MACH_VM_PURGABLE_H_ */ +#endif /* _MACH_VM_PURGABLE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_region.h b/lib/libc/include/any-macos-any/mach/vm_region.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach/vm_region.h rename to lib/libc/include/any-macos-any/mach/vm_region.h index f6f371fa44..0fd4b17ff3 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_region.h +++ b/lib/libc/include/any-macos-any/mach/vm_region.h @@ -346,4 +346,4 @@ typedef struct vm_page_info_basic vm_page_info_basic_data_t; (sizeof(vm_page_info_basic_data_t)/sizeof(int))) -#endif /*_MACH_VM_REGION_H_*/ +#endif /*_MACH_VM_REGION_H_*/ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_sync.h b/lib/libc/include/any-macos-any/mach/vm_sync.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach/vm_sync.h rename to lib/libc/include/any-macos-any/mach/vm_sync.h index 8dccb9c2c9..a928fb037d 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_sync.h +++ b/lib/libc/include/any-macos-any/mach/vm_sync.h @@ -77,4 +77,4 @@ typedef unsigned vm_sync_t; #define VM_SYNC_CONTIGUOUS ((vm_sync_t) 0x20) #define VM_SYNC_REUSABLEPAGES ((vm_sync_t) 0x40) -#endif /* _MACH_VM_SYNC_H_ */ +#endif /* _MACH_VM_SYNC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach_debug/hash_info.h b/lib/libc/include/any-macos-any/mach_debug/hash_info.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach_debug/hash_info.h rename to lib/libc/include/any-macos-any/mach_debug/hash_info.h index ba4bd39e85..56d0a4b07e 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach_debug/hash_info.h +++ b/lib/libc/include/any-macos-any/mach_debug/hash_info.h @@ -72,4 +72,4 @@ typedef struct hash_info_bucket { typedef hash_info_bucket_t *hash_info_bucket_array_t; -#endif /* _MACH_DEBUG_HASH_INFO_H_ */ +#endif /* _MACH_DEBUG_HASH_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach_debug/ipc_info.h b/lib/libc/include/any-macos-any/mach_debug/ipc_info.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach_debug/ipc_info.h rename to lib/libc/include/any-macos-any/mach_debug/ipc_info.h index 520830894a..deb07cac5e 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach_debug/ipc_info.h +++ b/lib/libc/include/any-macos-any/mach_debug/ipc_info.h @@ -113,4 +113,4 @@ typedef struct ipc_info_tree_name { typedef ipc_info_tree_name_t *ipc_info_tree_name_array_t; -#endif /* _MACH_DEBUG_IPC_INFO_H_ */ +#endif /* _MACH_DEBUG_IPC_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach_debug/lockgroup_info.h b/lib/libc/include/any-macos-any/mach_debug/lockgroup_info.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach_debug/lockgroup_info.h rename to lib/libc/include/any-macos-any/mach_debug/lockgroup_info.h index ee744bb576..38bb6dece4 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach_debug/lockgroup_info.h +++ b/lib/libc/include/any-macos-any/mach_debug/lockgroup_info.h @@ -71,4 +71,4 @@ typedef struct lockgroup_info { typedef lockgroup_info_t *lockgroup_info_array_t; -#endif /* _MACH_DEBUG_LOCKGROUP_INFO_H_ */ +#endif /* _MACH_DEBUG_LOCKGROUP_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach_debug/mach_debug_types.h b/lib/libc/include/any-macos-any/mach_debug/mach_debug_types.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach_debug/mach_debug_types.h rename to lib/libc/include/any-macos-any/mach_debug/mach_debug_types.h index 8781b108e7..a4a2f3d7c7 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach_debug/mach_debug_types.h +++ b/lib/libc/include/any-macos-any/mach_debug/mach_debug_types.h @@ -92,4 +92,4 @@ struct mach_core_fileheader { #define KOBJECT_DESCRIPTION_LENGTH 512 typedef char kobject_description_t[KOBJECT_DESCRIPTION_LENGTH]; -#endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_H_ */ +#endif /* _MACH_DEBUG_MACH_DEBUG_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach_debug/page_info.h b/lib/libc/include/any-macos-any/mach_debug/page_info.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/mach_debug/page_info.h rename to lib/libc/include/any-macos-any/mach_debug/page_info.h index b0b5db3872..2c4d4a67aa 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach_debug/page_info.h +++ b/lib/libc/include/any-macos-any/mach_debug/page_info.h @@ -61,4 +61,4 @@ #include typedef vm_offset_t *page_address_array_t; -#endif /* MACH_DEBUG_PAGE_INFO_H */ +#endif /* MACH_DEBUG_PAGE_INFO_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach_debug/vm_info.h b/lib/libc/include/any-macos-any/mach_debug/vm_info.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach_debug/vm_info.h rename to lib/libc/include/any-macos-any/mach_debug/vm_info.h index 8e2eb5f059..4efebb0488 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach_debug/vm_info.h +++ b/lib/libc/include/any-macos-any/mach_debug/vm_info.h @@ -146,4 +146,4 @@ typedef vm_info_object_t *vm_info_object_array_t; #pragma pack() -#endif /* _MACH_DEBUG_VM_INFO_H_ */ +#endif /* _MACH_DEBUG_VM_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach_debug/zone_info.h b/lib/libc/include/any-macos-any/mach_debug/zone_info.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/mach_debug/zone_info.h rename to lib/libc/include/any-macos-any/mach_debug/zone_info.h index 1022eca68c..b91d4d4138 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach_debug/zone_info.h +++ b/lib/libc/include/any-macos-any/mach_debug/zone_info.h @@ -198,4 +198,4 @@ typedef struct zone_btrecord { typedef zone_btrecord_t *zone_btrecord_array_t; -#endif /* _MACH_DEBUG_ZONE_INFO_H_ */ +#endif /* _MACH_DEBUG_ZONE_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/memory.h b/lib/libc/include/any-macos-any/memory.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/memory.h rename to lib/libc/include/any-macos-any/memory.h index cb9c8b5f77..c95c218099 100644 --- a/lib/libc/include/x86_64-macos-gnu/memory.h +++ b/lib/libc/include/any-macos-any/memory.h @@ -33,4 +33,4 @@ * @(#)memory.h 8.1 (Berkeley) 6/2/93 */ -#include +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/monetary.h b/lib/libc/include/any-macos-any/monetary.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/monetary.h rename to lib/libc/include/any-macos-any/monetary.h index a32f404d0e..590b856caa 100644 --- a/lib/libc/include/x86_64-macos-gnu/monetary.h +++ b/lib/libc/include/any-macos-any/monetary.h @@ -42,4 +42,4 @@ __END_DECLS #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* !_MONETARY_H_ */ +#endif /* !_MONETARY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/ndbm.h b/lib/libc/include/any-macos-any/ndbm.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/ndbm.h rename to lib/libc/include/any-macos-any/ndbm.h index b400c6207e..a26ddd4b56 100644 --- a/lib/libc/include/x86_64-macos-gnu/ndbm.h +++ b/lib/libc/include/any-macos-any/ndbm.h @@ -117,4 +117,4 @@ DBM *dbm_open(const char *, int, mode_t); int dbm_store(DBM *, datum, datum, int); __END_DECLS -#endif /* !_NDBM_H_ */ +#endif /* !_NDBM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/net/if_dl.h b/lib/libc/include/any-macos-any/net/if_dl.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/net/if_dl.h rename to lib/libc/include/any-macos-any/net/if_dl.h index 728e2f1e8b..230e09ca76 100644 --- a/lib/libc/include/x86_64-macos-gnu/net/if_dl.h +++ b/lib/libc/include/any-macos-any/net/if_dl.h @@ -118,4 +118,4 @@ char *link_ntoa(const struct sockaddr_dl *); __END_DECLS -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/net/net_kev.h b/lib/libc/include/any-macos-any/net/net_kev.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/net/net_kev.h rename to lib/libc/include/any-macos-any/net/net_kev.h index 4bb71821fb..0919e59ff2 100644 --- a/lib/libc/include/x86_64-macos-gnu/net/net_kev.h +++ b/lib/libc/include/any-macos-any/net/net_kev.h @@ -95,4 +95,4 @@ #define KEV_INET6_REQUEST_NAT64_PREFIX 7 /* Asking for the NAT64-prefix */ #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ -#endif /* _NET_NETKEV_H_ */ +#endif /* _NET_NETKEV_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/netdb.h b/lib/libc/include/any-macos-any/netdb.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/netdb.h rename to lib/libc/include/any-macos-any/netdb.h index ea30449e60..9ff0a92b8a 100644 --- a/lib/libc/include/x86_64-macos-gnu/netdb.h +++ b/lib/libc/include/any-macos-any/netdb.h @@ -316,4 +316,4 @@ void setnetgrent(const char *); __END_DECLS -#endif /* !_NETDB_H_ */ +#endif /* !_NETDB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/nl_types.h b/lib/libc/include/any-macos-any/nl_types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/nl_types.h rename to lib/libc/include/any-macos-any/nl_types.h index 72d0da254d..2cc919e727 100644 --- a/lib/libc/include/x86_64-macos-gnu/nl_types.h +++ b/lib/libc/include/any-macos-any/nl_types.h @@ -100,4 +100,4 @@ char *catgets(nl_catd, int, int, const char *) int catclose(nl_catd); __END_DECLS -#endif /* _NL_TYPES_H_ */ +#endif /* _NL_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/objc/NSObjCRuntime.h b/lib/libc/include/any-macos-any/objc/NSObjCRuntime.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/objc/NSObjCRuntime.h rename to lib/libc/include/any-macos-any/objc/NSObjCRuntime.h index ab0b6b9b75..c0d01f928e 100644 --- a/lib/libc/include/x86_64-macos-gnu/objc/NSObjCRuntime.h +++ b/lib/libc/include/any-macos-any/objc/NSObjCRuntime.h @@ -30,4 +30,4 @@ typedef unsigned int NSUInteger; #endif #endif -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/objc/NSObject.h b/lib/libc/include/any-macos-any/objc/NSObject.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/objc/NSObject.h rename to lib/libc/include/any-macos-any/objc/NSObject.h index 2172abaf4e..cbb2fc8aa2 100644 --- a/lib/libc/include/x86_64-macos-gnu/objc/NSObject.h +++ b/lib/libc/include/any-macos-any/objc/NSObject.h @@ -109,4 +109,4 @@ OBJC_EXPORT #endif -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/objc/message.h b/lib/libc/include/any-macos-any/objc/message.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/objc/message.h rename to lib/libc/include/any-macos-any/objc/message.h index 31bd544bc8..3c9a5e0d08 100644 --- a/lib/libc/include/x86_64-macos-gnu/objc/message.h +++ b/lib/libc/include/any-macos-any/objc/message.h @@ -385,4 +385,4 @@ objc_msgSendv_fpret(id _Nullable self, SEL _Nonnull op, #endif -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/objc/objc.h b/lib/libc/include/any-macos-any/objc/objc.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/objc/objc.h rename to lib/libc/include/any-macos-any/objc/objc.h index 4c68159452..76da49110b 100644 --- a/lib/libc/include/x86_64-macos-gnu/objc/objc.h +++ b/lib/libc/include/any-macos-any/objc/objc.h @@ -256,4 +256,4 @@ typedef char *STR; #endif -#endif /* _OBJC_OBJC_H_ */ +#endif /* _OBJC_OBJC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/os/availability.h b/lib/libc/include/any-macos-any/os/availability.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/os/availability.h rename to lib/libc/include/any-macos-any/os/availability.h index 1b3f5d9ddd..1068bd663d 100644 --- a/lib/libc/include/x86_64-macos-gnu/os/availability.h +++ b/lib/libc/include/any-macos-any/os/availability.h @@ -162,4 +162,4 @@ #define SPI_DEPRECATED_WITH_REPLACEMENT(...) #endif -#endif /* __OS_AVAILABILITY__ */ +#endif /* __OS_AVAILABILITY__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/os/lock.h b/lib/libc/include/any-macos-any/os/lock.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/os/lock.h rename to lib/libc/include/any-macos-any/os/lock.h index 5c46f28e94..889ad2a3df 100644 --- a/lib/libc/include/x86_64-macos-gnu/os/lock.h +++ b/lib/libc/include/any-macos-any/os/lock.h @@ -186,4 +186,4 @@ __END_DECLS OS_ASSUME_NONNULL_END -#endif // __OS_LOCK__ +#endif // __OS_LOCK__ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/poll.h b/lib/libc/include/any-macos-any/poll.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/poll.h rename to lib/libc/include/any-macos-any/poll.h index 75f90feee5..18f97cf7ae 100644 --- a/lib/libc/include/x86_64-macos-gnu/poll.h +++ b/lib/libc/include/any-macos-any/poll.h @@ -20,7 +20,4 @@ * * @APPLE_LICENSE_HEADER_END@ */ -#include - - - +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/pthread/pthread_impl.h b/lib/libc/include/any-macos-any/pthread/pthread_impl.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/pthread/pthread_impl.h rename to lib/libc/include/any-macos-any/pthread/pthread_impl.h index 35d32d3021..aae74c2c03 100644 --- a/lib/libc/include/x86_64-macos-gnu/pthread/pthread_impl.h +++ b/lib/libc/include/any-macos-any/pthread/pthread_impl.h @@ -63,4 +63,4 @@ _Pragma("clang assume_nonnull begin") _Pragma("clang assume_nonnull end") #endif -#endif /* _PTHREAD_IMPL_H_ */ +#endif /* _PTHREAD_IMPL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/pthread/qos.h b/lib/libc/include/any-macos-any/pthread/qos.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/pthread/qos.h rename to lib/libc/include/any-macos-any/pthread/qos.h index 9c1bfd8a2b..530d5db24d 100644 --- a/lib/libc/include/x86_64-macos-gnu/pthread/qos.h +++ b/lib/libc/include/any-macos-any/pthread/qos.h @@ -301,4 +301,4 @@ _Pragma("clang assume_nonnull end") #endif // __DARWIN_C_LEVEL >= __DARWIN_C_FULL -#endif // _PTHREAD_QOS_H +#endif // _PTHREAD_QOS_H \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/pwd.h b/lib/libc/include/any-macos-any/pwd.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/pwd.h rename to lib/libc/include/any-macos-any/pwd.h index 67cc5a69fc..18cc0ab288 100644 --- a/lib/libc/include/x86_64-macos-gnu/pwd.h +++ b/lib/libc/include/any-macos-any/pwd.h @@ -116,4 +116,4 @@ int getpwuuid_r(uuid_t, struct passwd *, char *, size_t, struct passwd **); __END_DECLS #endif -#endif /* !_PWD_H_ */ +#endif /* !_PWD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/regex.h b/lib/libc/include/any-macos-any/regex.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/regex.h rename to lib/libc/include/any-macos-any/regex.h index 11f592b3fb..f84f764a93 100644 --- a/lib/libc/include/x86_64-macos-gnu/regex.h +++ b/lib/libc/include/any-macos-any/regex.h @@ -214,4 +214,4 @@ __END_DECLS #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* !_REGEX_H_ */ +#endif /* !_REGEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/runetype.h b/lib/libc/include/any-macos-any/runetype.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/runetype.h rename to lib/libc/include/any-macos-any/runetype.h index b3dcce26fd..e1369709ce 100644 --- a/lib/libc/include/x86_64-macos-gnu/runetype.h +++ b/lib/libc/include/any-macos-any/runetype.h @@ -112,4 +112,4 @@ extern _RuneLocale _DefaultRuneLocale; extern _RuneLocale *_CurrentRuneLocale; __END_DECLS -#endif /* !_RUNETYPE_H_ */ +#endif /* !_RUNETYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/search.h b/lib/libc/include/any-macos-any/search.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/search.h rename to lib/libc/include/any-macos-any/search.h index 58d69e76b7..36d30fb3e6 100644 --- a/lib/libc/include/x86_64-macos-gnu/search.h +++ b/lib/libc/include/any-macos-any/search.h @@ -59,4 +59,4 @@ void *tsearch(const void *, void **, int (*)(const void *, const void *)); void twalk(const void *, void (*)(const void *, VISIT, int)); __END_DECLS -#endif /* !_SEARCH_H_ */ +#endif /* !_SEARCH_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/secure/_common.h b/lib/libc/include/any-macos-any/secure/_common.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/secure/_common.h rename to lib/libc/include/any-macos-any/secure/_common.h index a7acfaa0de..7e1e43d722 100644 --- a/lib/libc/include/x86_64-macos-gnu/secure/_common.h +++ b/lib/libc/include/any-macos-any/secure/_common.h @@ -38,4 +38,4 @@ #define __darwin_obsz0(object) __builtin_object_size (object, 0) #define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0) -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/secure/_stdio.h b/lib/libc/include/any-macos-any/secure/_stdio.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/secure/_stdio.h rename to lib/libc/include/any-macos-any/secure/_stdio.h index c4dc7b2343..89e4c90ae0 100644 --- a/lib/libc/include/x86_64-macos-gnu/secure/_stdio.h +++ b/lib/libc/include/any-macos-any/secure/_stdio.h @@ -83,4 +83,4 @@ extern int __vsnprintf_chk (char * __restrict, size_t, int, size_t, #endif #endif /* _USE_FORTIFY_LEVEL > 0 */ -#endif /* _SECURE__STDIO_H_ */ +#endif /* _SECURE__STDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/secure/_string.h b/lib/libc/include/any-macos-any/secure/_string.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/secure/_string.h rename to lib/libc/include/any-macos-any/secure/_string.h index f101c134c9..9fac5296c7 100644 --- a/lib/libc/include/x86_64-macos-gnu/secure/_string.h +++ b/lib/libc/include/any-macos-any/secure/_string.h @@ -147,4 +147,4 @@ #undef __HAS_FIXED_CHK_PROTOTYPES #endif /* _USE_FORTIFY_LEVEL > 0 */ -#endif /* _SECURE__STRING_H_ */ +#endif /* _SECURE__STRING_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/secure/_strings.h b/lib/libc/include/any-macos-any/secure/_strings.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/secure/_strings.h rename to lib/libc/include/any-macos-any/secure/_strings.h index 9069e59591..c50dcb5cf5 100644 --- a/lib/libc/include/x86_64-macos-gnu/secure/_strings.h +++ b/lib/libc/include/any-macos-any/secure/_strings.h @@ -56,4 +56,4 @@ #endif #endif /* _USE_FORTIFY_LEVEL > 0 */ -#endif /* _SECURE__STRINGS_H_ */ +#endif /* _SECURE__STRINGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/semaphore.h b/lib/libc/include/any-macos-any/semaphore.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/semaphore.h rename to lib/libc/include/any-macos-any/semaphore.h index 638aa6138f..96fa229741 100644 --- a/lib/libc/include/x86_64-macos-gnu/semaphore.h +++ b/lib/libc/include/any-macos-any/semaphore.h @@ -28,4 +28,4 @@ #include -#endif /* _BSD_SEMAPHORE_H */ +#endif /* _BSD_SEMAPHORE_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/setjmp.h b/lib/libc/include/any-macos-any/setjmp.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/setjmp.h rename to lib/libc/include/any-macos-any/setjmp.h index f54ddefa57..24ec583696 100644 --- a/lib/libc/include/x86_64-macos-gnu/setjmp.h +++ b/lib/libc/include/any-macos-any/setjmp.h @@ -99,4 +99,4 @@ void longjmperror(void); #endif /* neither ANSI nor POSIX */ __END_DECLS -#endif /* _BSD_SETJMP_H */ +#endif /* _BSD_SETJMP_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/base.h b/lib/libc/include/any-macos-any/simd/base.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/simd/base.h rename to lib/libc/include/any-macos-any/simd/base.h index 01371186dc..fdc2e3c879 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/base.h +++ b/lib/libc/include/any-macos-any/simd/base.h @@ -119,4 +119,4 @@ typedef _Bool simd_bool; typedef simd_bool __SIMD_BOOLEAN_TYPE__; # endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* defined SIMD_BASE */ +#endif /* defined SIMD_BASE */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/extern.h b/lib/libc/include/any-macos-any/simd/extern.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/simd/extern.h rename to lib/libc/include/any-macos-any/simd/extern.h index b4b6b8f53d..83f37e2351 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/extern.h +++ b/lib/libc/include/any-macos-any/simd/extern.h @@ -46,4 +46,4 @@ extern simd_double4x4 __invert_d4(simd_double4x4); } #endif #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* __SIMD_EXTERN_HEADER__ */ +#endif /* __SIMD_EXTERN_HEADER__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/geometry.h b/lib/libc/include/any-macos-any/simd/geometry.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/simd/geometry.h rename to lib/libc/include/any-macos-any/simd/geometry.h index 80b2e5f0f6..649bfb6237 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/geometry.h +++ b/lib/libc/include/any-macos-any/simd/geometry.h @@ -1080,4 +1080,4 @@ static double SIMD_CFUNC simd_insphere(simd_double3 __x, simd_double3 __a, simd_ } #endif #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* __SIMD_COMMON_HEADER__ */ +#endif /* __SIMD_COMMON_HEADER__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/matrix.h b/lib/libc/include/any-macos-any/simd/matrix.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/simd/matrix.h rename to lib/libc/include/any-macos-any/simd/matrix.h index 6c0941a296..a62384e133 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/matrix.h +++ b/lib/libc/include/any-macos-any/simd/matrix.h @@ -1783,4 +1783,4 @@ static simd_bool SIMD_CFUNC simd_almost_equal_elements_relative(simd_double4x4 _ } #endif #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* __SIMD_HEADER__ */ +#endif /* __SIMD_HEADER__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/matrix_types.h b/lib/libc/include/any-macos-any/simd/matrix_types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/simd/matrix_types.h rename to lib/libc/include/any-macos-any/simd/matrix_types.h index 0f2e90df66..904df687a6 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/matrix_types.h +++ b/lib/libc/include/any-macos-any/simd/matrix_types.h @@ -261,4 +261,4 @@ namespace simd { } #endif /* __cplusplus */ #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* SIMD_MATRIX_TYPES_HEADER */ +#endif /* SIMD_MATRIX_TYPES_HEADER */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/simd.h b/lib/libc/include/any-macos-any/simd/simd.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/simd/simd.h rename to lib/libc/include/any-macos-any/simd/simd.h index 2850d75ae9..e504527ef6 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/simd.h +++ b/lib/libc/include/any-macos-any/simd/simd.h @@ -18,4 +18,4 @@ #include #include -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/types.h b/lib/libc/include/any-macos-any/simd/types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/simd/types.h rename to lib/libc/include/any-macos-any/simd/types.h index e094467047..85ae1b2924 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/types.h +++ b/lib/libc/include/any-macos-any/simd/types.h @@ -125,4 +125,4 @@ typedef struct { simd_float4 vector; } simd_quatf; typedef struct { simd_double4 vector; } simd_quatd; #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* SIMD_TYPES */ +#endif /* SIMD_TYPES */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/vector.h b/lib/libc/include/any-macos-any/simd/vector.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/simd/vector.h rename to lib/libc/include/any-macos-any/simd/vector.h index 7ab8f2adbc..0bc2e9ec44 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/vector.h +++ b/lib/libc/include/any-macos-any/simd/vector.h @@ -49,4 +49,4 @@ #include #include -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/vector_make.h b/lib/libc/include/any-macos-any/simd/vector_make.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/simd/vector_make.h rename to lib/libc/include/any-macos-any/simd/vector_make.h index 34396b2608..b8e2323944 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/vector_make.h +++ b/lib/libc/include/any-macos-any/simd/vector_make.h @@ -6765,4 +6765,4 @@ template static SIMD_CPPFUNC double8 make_double8_undef(typeN o } /* namespace simd */ #endif /* __cplusplus */ #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* SIMD_VECTOR_CONSTRUCTORS */ +#endif /* SIMD_VECTOR_CONSTRUCTORS */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/vector_types.h b/lib/libc/include/any-macos-any/simd/vector_types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/simd/vector_types.h rename to lib/libc/include/any-macos-any/simd/vector_types.h index 223d696e10..09701acfa9 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/vector_types.h +++ b/lib/libc/include/any-macos-any/simd/vector_types.h @@ -1278,4 +1278,4 @@ typedef simd_double4 vector_double4; typedef simd_double8 vector_double8; # endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/stdint.h b/lib/libc/include/any-macos-any/stdint.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/stdint.h rename to lib/libc/include/any-macos-any/stdint.h index f4bb4cd758..9ad9bbedb5 100644 --- a/lib/libc/include/x86_64-macos-gnu/stdint.h +++ b/lib/libc/include/any-macos-any/stdint.h @@ -202,4 +202,4 @@ typedef uint64_t uint_fast64_t; #define SIG_ATOMIC_MIN INT32_MIN #define SIG_ATOMIC_MAX INT32_MAX -#endif /* _STDINT_H_ */ +#endif /* _STDINT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/strings.h b/lib/libc/include/any-macos-any/strings.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/strings.h rename to lib/libc/include/any-macos-any/strings.h index c0e915f8ac..aad5d6a46e 100644 --- a/lib/libc/include/x86_64-macos-gnu/strings.h +++ b/lib/libc/include/any-macos-any/strings.h @@ -97,5 +97,4 @@ __END_DECLS #include #endif -#endif /* _STRINGS_H_ */ - +#endif /* _STRINGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_endian.h b/lib/libc/include/any-macos-any/sys/_endian.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/_endian.h rename to lib/libc/include/any-macos-any/sys/_endian.h index 4b8daa8521..ed7452a381 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_endian.h +++ b/lib/libc/include/any-macos-any/sys/_endian.h @@ -148,4 +148,4 @@ __END_DECLS #define HTONLL(x) (x) = htonll((__uint64_t)x) #endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ #endif /* __DARWIN_BYTE_ORDER */ -#endif /* !_SYS__ENDIAN_H_ */ +#endif /* !_SYS__ENDIAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_posix_availability.h b/lib/libc/include/any-macos-any/sys/_posix_availability.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/_posix_availability.h rename to lib/libc/include/any-macos-any/sys/_posix_availability.h index a540f26a17..62199619a6 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_posix_availability.h +++ b/lib/libc/include/any-macos-any/sys/_posix_availability.h @@ -69,5 +69,4 @@ #define ___POSIX_C_DEPRECATED_STARTING_200809L __deprecated #else #define ___POSIX_C_DEPRECATED_STARTING_200809L -#endif - +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_key_t.h b/lib/libc/include/any-macos-any/sys/_pthread/_pthread_key_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_key_t.h rename to lib/libc/include/any-macos-any/sys/_pthread/_pthread_key_t.h index 20d7a0a444..272982564d 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_key_t.h +++ b/lib/libc/include/any-macos-any/sys/_pthread/_pthread_key_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_KEY_T #include /* __darwin_pthread_key_t */ typedef __darwin_pthread_key_t pthread_key_t; -#endif /* _PTHREAD_KEY_T */ +#endif /* _PTHREAD_KEY_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_mutex_t.h b/lib/libc/include/any-macos-any/sys/_pthread/_pthread_mutex_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_mutex_t.h rename to lib/libc/include/any-macos-any/sys/_pthread/_pthread_mutex_t.h index e5aff0bc2e..44b2bedb9a 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_mutex_t.h +++ b/lib/libc/include/any-macos-any/sys/_pthread/_pthread_mutex_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_MUTEX_T #include /* __darwin_pthread_mutex_t */ typedef __darwin_pthread_mutex_t pthread_mutex_t; -#endif /*_PTHREAD_MUTEX_T */ +#endif /*_PTHREAD_MUTEX_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_mutexattr_t.h b/lib/libc/include/any-macos-any/sys/_pthread/_pthread_mutexattr_t.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_mutexattr_t.h rename to lib/libc/include/any-macos-any/sys/_pthread/_pthread_mutexattr_t.h index 218d74a91c..07bd2801c9 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_mutexattr_t.h +++ b/lib/libc/include/any-macos-any/sys/_pthread/_pthread_mutexattr_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_MUTEXATTR_T #include /* __darwin_pthread_mutexattr_t */ typedef __darwin_pthread_mutexattr_t pthread_mutexattr_t; -#endif /* _PTHREAD_MUTEXATTR_T */ +#endif /* _PTHREAD_MUTEXATTR_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_once_t.h b/lib/libc/include/any-macos-any/sys/_pthread/_pthread_once_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_once_t.h rename to lib/libc/include/any-macos-any/sys/_pthread/_pthread_once_t.h index d50a6244f9..85a63a60f1 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_once_t.h +++ b/lib/libc/include/any-macos-any/sys/_pthread/_pthread_once_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_ONCE_T #include /* __darwin_pthread_once_t */ typedef __darwin_pthread_once_t pthread_once_t; -#endif /* _PTHREAD_ONCE_T */ +#endif /* _PTHREAD_ONCE_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types.h b/lib/libc/include/any-macos-any/sys/_types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/_types.h rename to lib/libc/include/any-macos-any/sys/_types.h index 43be468d7b..8d8f62d445 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types.h +++ b/lib/libc/include/any-macos-any/sys/_types.h @@ -86,4 +86,4 @@ typedef char __darwin_uuid_string_t[37]; #endif /* (gcc >= 3.5) */ -#endif /* _SYS__TYPES_H_ */ +#endif /* _SYS__TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_blkcnt_t.h b/lib/libc/include/any-macos-any/sys/_types/_blkcnt_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_blkcnt_t.h rename to lib/libc/include/any-macos-any/sys/_types/_blkcnt_t.h index 9d4d1ee883..4ac9463a46 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_blkcnt_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_blkcnt_t.h @@ -29,4 +29,4 @@ #define _BLKCNT_T #include /* __darwin_blkcnt_t */ typedef __darwin_blkcnt_t blkcnt_t; -#endif /* _BLKCNT_T */ +#endif /* _BLKCNT_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_blksize_t.h b/lib/libc/include/any-macos-any/sys/_types/_blksize_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_blksize_t.h rename to lib/libc/include/any-macos-any/sys/_types/_blksize_t.h index 82931f7bfa..59ccf3de3c 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_blksize_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_blksize_t.h @@ -29,4 +29,4 @@ #define _BLKSIZE_T #include /* __darwin_blksize_t */ typedef __darwin_blksize_t blksize_t; -#endif /* _BLKSIZE_T */ +#endif /* _BLKSIZE_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_caddr_t.h b/lib/libc/include/any-macos-any/sys/_types/_caddr_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_caddr_t.h rename to lib/libc/include/any-macos-any/sys/_types/_caddr_t.h index 159e186d39..64c58299af 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_caddr_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_caddr_t.h @@ -28,4 +28,4 @@ #ifndef _CADDR_T #define _CADDR_T typedef char * caddr_t; -#endif /* _CADDR_T */ +#endif /* _CADDR_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_clock_t.h b/lib/libc/include/any-macos-any/sys/_types/_clock_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_clock_t.h rename to lib/libc/include/any-macos-any/sys/_types/_clock_t.h index 991d2cd528..4a34772e46 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_clock_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_clock_t.h @@ -29,4 +29,4 @@ #define _CLOCK_T #include /* __darwin_clock_t */ typedef __darwin_clock_t clock_t; -#endif /* _CLOCK_T */ +#endif /* _CLOCK_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ct_rune_t.h b/lib/libc/include/any-macos-any/sys/_types/_ct_rune_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_ct_rune_t.h rename to lib/libc/include/any-macos-any/sys/_types/_ct_rune_t.h index 3878dff806..da2f6603f2 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ct_rune_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_ct_rune_t.h @@ -30,4 +30,4 @@ #define _CT_RUNE_T #include /* __darwin_ct_rune_t */ typedef __darwin_ct_rune_t ct_rune_t; -#endif /* _CT_RUNE_T */ +#endif /* _CT_RUNE_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_dev_t.h b/lib/libc/include/any-macos-any/sys/_types/_dev_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_dev_t.h rename to lib/libc/include/any-macos-any/sys/_types/_dev_t.h index be5c73ee50..95125a6509 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_dev_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_dev_t.h @@ -29,4 +29,4 @@ #define _DEV_T #include /* __darwin_dev_t */ typedef __darwin_dev_t dev_t; /* device number */ -#endif /* _DEV_T */ +#endif /* _DEV_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_errno_t.h b/lib/libc/include/any-macos-any/sys/_types/_errno_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_errno_t.h rename to lib/libc/include/any-macos-any/sys/_types/_errno_t.h index 557282a2d3..081bae2e0f 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_errno_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_errno_t.h @@ -28,4 +28,4 @@ #ifndef _ERRNO_T #define _ERRNO_T typedef int errno_t; -#endif /* _ERRNO_T */ +#endif /* _ERRNO_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_clr.h b/lib/libc/include/any-macos-any/sys/_types/_fd_clr.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_clr.h rename to lib/libc/include/any-macos-any/sys/_types/_fd_clr.h index eeb65b3627..8cd61878c0 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_clr.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fd_clr.h @@ -27,4 +27,4 @@ */ #ifndef FD_CLR #define FD_CLR(n, p) __DARWIN_FD_CLR(n, p) -#endif /* FD_CLR */ +#endif /* FD_CLR */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_copy.h b/lib/libc/include/any-macos-any/sys/_types/_fd_copy.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_copy.h rename to lib/libc/include/any-macos-any/sys/_types/_fd_copy.h index d0e9c1ec9a..19248ec806 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_copy.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fd_copy.h @@ -27,4 +27,4 @@ */ #ifndef FD_COPY #define FD_COPY(f, t) __DARWIN_FD_COPY(f, t) -#endif /* FD_COPY */ +#endif /* FD_COPY */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_isset.h b/lib/libc/include/any-macos-any/sys/_types/_fd_isset.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_isset.h rename to lib/libc/include/any-macos-any/sys/_types/_fd_isset.h index e3b3d98561..4aaa92fdec 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_isset.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fd_isset.h @@ -27,4 +27,4 @@ */ #ifndef FD_ISSET #define FD_ISSET(n, p) __DARWIN_FD_ISSET(n, p) -#endif /* FD_ISSET */ +#endif /* FD_ISSET */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_set.h b/lib/libc/include/any-macos-any/sys/_types/_fd_set.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_set.h rename to lib/libc/include/any-macos-any/sys/_types/_fd_set.h index 67f4fa4df3..fe21ec1bb9 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_set.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fd_set.h @@ -27,4 +27,4 @@ */ #ifndef FD_SET #define FD_SET(n, p) __DARWIN_FD_SET(n, p) -#endif /* FD_SET */ +#endif /* FD_SET */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_setsize.h b/lib/libc/include/any-macos-any/sys/_types/_fd_setsize.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_setsize.h rename to lib/libc/include/any-macos-any/sys/_types/_fd_setsize.h index c5c3ec9d8f..b45f19ac69 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_setsize.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fd_setsize.h @@ -27,4 +27,4 @@ */ #ifndef FD_SETSIZE #define FD_SETSIZE __DARWIN_FD_SETSIZE -#endif /* FD_SETSIZE */ +#endif /* FD_SETSIZE */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_zero.h b/lib/libc/include/any-macos-any/sys/_types/_fd_zero.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_zero.h rename to lib/libc/include/any-macos-any/sys/_types/_fd_zero.h index 8363df3bd7..c065a6fa67 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_zero.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fd_zero.h @@ -27,4 +27,4 @@ */ #ifndef FD_ZERO #define FD_ZERO(p) __DARWIN_FD_ZERO(p) -#endif /* FD_ZERO */ +#endif /* FD_ZERO */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_filesec_t.h b/lib/libc/include/any-macos-any/sys/_types/_filesec_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_filesec_t.h rename to lib/libc/include/any-macos-any/sys/_types/_filesec_t.h index 6812eba467..dbaa6f2947 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_filesec_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_filesec_t.h @@ -29,4 +29,4 @@ #define _FILESEC_T struct _filesec; typedef struct _filesec *filesec_t; -#endif /* _FILESEC_T */ +#endif /* _FILESEC_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fsblkcnt_t.h b/lib/libc/include/any-macos-any/sys/_types/_fsblkcnt_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fsblkcnt_t.h rename to lib/libc/include/any-macos-any/sys/_types/_fsblkcnt_t.h index a80d02f671..5c4bbaada1 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fsblkcnt_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fsblkcnt_t.h @@ -29,4 +29,4 @@ #define _FSBLKCNT_T #include /* __darwin_fsblkcnt_t */ typedef __darwin_fsblkcnt_t fsblkcnt_t; -#endif /* _FSBLKCNT_T */ +#endif /* _FSBLKCNT_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fsfilcnt_t.h b/lib/libc/include/any-macos-any/sys/_types/_fsfilcnt_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fsfilcnt_t.h rename to lib/libc/include/any-macos-any/sys/_types/_fsfilcnt_t.h index be5e9b4aba..e5c2dd54e3 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fsfilcnt_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fsfilcnt_t.h @@ -29,4 +29,4 @@ #define _FSFILCNT_T #include /* __darwin_fsfilcnt_t */ typedef __darwin_fsfilcnt_t fsfilcnt_t; -#endif /* _FSFILCNT_T */ +#endif /* _FSFILCNT_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fsid_t.h b/lib/libc/include/any-macos-any/sys/_types/_fsid_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fsid_t.h rename to lib/libc/include/any-macos-any/sys/_types/_fsid_t.h index d4e70f2997..c7cec84752 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fsid_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fsid_t.h @@ -29,4 +29,4 @@ #define _FSID_T #include /* int32_t */ typedef struct fsid { int32_t val[2]; } fsid_t; /* file system id type */ -#endif /* _FSID_T */ +#endif /* _FSID_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fsobj_id_t.h b/lib/libc/include/any-macos-any/sys/_types/_fsobj_id_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_fsobj_id_t.h rename to lib/libc/include/any-macos-any/sys/_types/_fsobj_id_t.h index a396cdff9e..eaaab2e53f 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fsobj_id_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_fsobj_id_t.h @@ -35,4 +35,4 @@ typedef struct fsobj_id { u_int32_t fid_generation; } fsobj_id_t; -#endif /* _FSOBJ_ID_T */ +#endif /* _FSOBJ_ID_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_gid_t.h b/lib/libc/include/any-macos-any/sys/_types/_gid_t.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_gid_t.h rename to lib/libc/include/any-macos-any/sys/_types/_gid_t.h index ebf4970689..c5cb252206 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_gid_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_gid_t.h @@ -29,4 +29,4 @@ #define _GID_T #include /* __darwin_gid_t */ typedef __darwin_gid_t gid_t; -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_guid_t.h b/lib/libc/include/any-macos-any/sys/_types/_guid_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_guid_t.h rename to lib/libc/include/any-macos-any/sys/_types/_guid_t.h index df29f9ca39..22e28de8db 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_guid_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_guid_t.h @@ -34,4 +34,4 @@ typedef union { unsigned int g_guid_asint[KAUTH_GUID_SIZE / sizeof(unsigned int)]; } guid_t; #define _GUID_T -#endif /* _KAUTH_GUID */ +#endif /* _KAUTH_GUID */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_id_t.h b/lib/libc/include/any-macos-any/sys/_types/_id_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_id_t.h rename to lib/libc/include/any-macos-any/sys/_types/_id_t.h index 9af9610a27..839a8de1b8 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_id_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_id_t.h @@ -29,4 +29,4 @@ #define _ID_T #include /* __darwin_id_t */ typedef __darwin_id_t id_t; /* can hold pid_t, gid_t, or uid_t */ -#endif /* _ID_T */ +#endif /* _ID_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_in_addr_t.h b/lib/libc/include/any-macos-any/sys/_types/_in_addr_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_in_addr_t.h rename to lib/libc/include/any-macos-any/sys/_types/_in_addr_t.h index edcf66e507..2b40b85cb2 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_in_addr_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_in_addr_t.h @@ -29,4 +29,4 @@ #define _IN_ADDR_T #include /* __uint32_t */ typedef __uint32_t in_addr_t; /* base type for internet address */ -#endif /* _IN_ADDR_T */ +#endif /* _IN_ADDR_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_in_port_t.h b/lib/libc/include/any-macos-any/sys/_types/_in_port_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_in_port_t.h rename to lib/libc/include/any-macos-any/sys/_types/_in_port_t.h index 8b102566c9..42f2f8c2a6 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_in_port_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_in_port_t.h @@ -29,4 +29,4 @@ #define _IN_PORT_T #include /* __uint16_t */ typedef __uint16_t in_port_t; -#endif /* _IN_PORT_T */ +#endif /* _IN_PORT_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ino64_t.h b/lib/libc/include/any-macos-any/sys/_types/_ino64_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_ino64_t.h rename to lib/libc/include/any-macos-any/sys/_types/_ino64_t.h index c142b1baec..4fdc1ca3e0 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ino64_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_ino64_t.h @@ -29,4 +29,4 @@ #define _INO64_T #include /* __darwin_ino64_t */ typedef __darwin_ino64_t ino64_t; /* 64bit inode number */ -#endif /* _INO64_T */ +#endif /* _INO64_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ino_t.h b/lib/libc/include/any-macos-any/sys/_types/_ino_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_ino_t.h rename to lib/libc/include/any-macos-any/sys/_types/_ino_t.h index 2a693ddbfd..0c5dacd648 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ino_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_ino_t.h @@ -29,4 +29,4 @@ #define _INO_T #include /* __darwin_ino_t */ typedef __darwin_ino_t ino_t; /* inode number */ -#endif /* _INO_T */ +#endif /* _INO_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int16_t.h b/lib/libc/include/any-macos-any/sys/_types/_int16_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_int16_t.h rename to lib/libc/include/any-macos-any/sys/_types/_int16_t.h index 3bf3da0681..d104e06cb8 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int16_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_int16_t.h @@ -28,4 +28,4 @@ #ifndef _INT16_T #define _INT16_T typedef short int16_t; -#endif /* _INT16_T */ +#endif /* _INT16_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int32_t.h b/lib/libc/include/any-macos-any/sys/_types/_int32_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_int32_t.h rename to lib/libc/include/any-macos-any/sys/_types/_int32_t.h index 9b1d72ba74..d46ca4cb15 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int32_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_int32_t.h @@ -28,4 +28,4 @@ #ifndef _INT32_T #define _INT32_T typedef int int32_t; -#endif /* _INT32_T */ +#endif /* _INT32_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int64_t.h b/lib/libc/include/any-macos-any/sys/_types/_int64_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_int64_t.h rename to lib/libc/include/any-macos-any/sys/_types/_int64_t.h index 4f3e7de38a..5d8253c74f 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int64_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_int64_t.h @@ -28,4 +28,4 @@ #ifndef _INT64_T #define _INT64_T typedef long long int64_t; -#endif /* _INT64_T */ +#endif /* _INT64_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_intptr_t.h b/lib/libc/include/any-macos-any/sys/_types/_intptr_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_intptr_t.h rename to lib/libc/include/any-macos-any/sys/_types/_intptr_t.h index 0f494b9e5c..71966e3097 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_intptr_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_intptr_t.h @@ -30,4 +30,4 @@ #include /* __darwin_intptr_t */ typedef __darwin_intptr_t intptr_t; -#endif /* _INTPTR_T */ +#endif /* _INTPTR_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_iovec_t.h b/lib/libc/include/any-macos-any/sys/_types/_iovec_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_iovec_t.h rename to lib/libc/include/any-macos-any/sys/_types/_iovec_t.h index f89c7306f2..96b7326ba6 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_iovec_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_iovec_t.h @@ -32,4 +32,4 @@ struct iovec { void * iov_base; /* [XSI] Base address of I/O memory region */ size_t iov_len; /* [XSI] Size of region iov_base points to */ }; -#endif /* _STRUCT_IOVEC */ +#endif /* _STRUCT_IOVEC */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_key_t.h b/lib/libc/include/any-macos-any/sys/_types/_key_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_key_t.h rename to lib/libc/include/any-macos-any/sys/_types/_key_t.h index ec093d7699..3d30305ee5 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_key_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_key_t.h @@ -29,4 +29,4 @@ #define _KEY_T #include /* __int32_t */ typedef __int32_t key_t; /* IPC key (for Sys V IPC) */ -#endif /* _KEY_T */ +#endif /* _KEY_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_mach_port_t.h b/lib/libc/include/any-macos-any/sys/_types/_mach_port_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_mach_port_t.h rename to lib/libc/include/any-macos-any/sys/_types/_mach_port_t.h index fa96565f66..df36dc2b7a 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_mach_port_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_mach_port_t.h @@ -48,4 +48,4 @@ #define _MACH_PORT_T #include /* __darwin_mach_port_t */ typedef __darwin_mach_port_t mach_port_t; -#endif /* _MACH_PORT_T */ +#endif /* _MACH_PORT_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_mbstate_t.h b/lib/libc/include/any-macos-any/sys/_types/_mbstate_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_mbstate_t.h rename to lib/libc/include/any-macos-any/sys/_types/_mbstate_t.h index 771728bfa7..2d85de97f6 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_mbstate_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_mbstate_t.h @@ -30,4 +30,4 @@ #define _MBSTATE_T #include /* __darwin_mbstate_t */ typedef __darwin_mbstate_t mbstate_t; -#endif /* _MBSTATE_T */ +#endif /* _MBSTATE_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_mode_t.h b/lib/libc/include/any-macos-any/sys/_types/_mode_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_mode_t.h rename to lib/libc/include/any-macos-any/sys/_types/_mode_t.h index 36f8d2b324..ee9c3aaffc 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_mode_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_mode_t.h @@ -29,4 +29,4 @@ #define _MODE_T #include /* __darwin_mode_t */ typedef __darwin_mode_t mode_t; -#endif /* _MODE_T */ +#endif /* _MODE_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_nlink_t.h b/lib/libc/include/any-macos-any/sys/_types/_nlink_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_nlink_t.h rename to lib/libc/include/any-macos-any/sys/_types/_nlink_t.h index c3f83365ff..19bdbab55b 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_nlink_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_nlink_t.h @@ -29,4 +29,4 @@ #define _NLINK_T #include /* __uint16_t */ typedef __uint16_t nlink_t; /* link count */ -#endif /* _NLINK_T */ +#endif /* _NLINK_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_null.h b/lib/libc/include/any-macos-any/sys/_types/_null.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_null.h rename to lib/libc/include/any-macos-any/sys/_types/_null.h index 9c21571ea4..310a71788b 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_null.h +++ b/lib/libc/include/any-macos-any/sys/_types/_null.h @@ -28,4 +28,4 @@ #ifndef NULL #include /* __DARWIN_NULL */ #define NULL __DARWIN_NULL -#endif /* NULL */ +#endif /* NULL */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_o_dsync.h b/lib/libc/include/any-macos-any/sys/_types/_o_dsync.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_o_dsync.h rename to lib/libc/include/any-macos-any/sys/_types/_o_dsync.h index bd4f2884fa..3012119653 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_o_dsync.h +++ b/lib/libc/include/any-macos-any/sys/_types/_o_dsync.h @@ -27,4 +27,4 @@ */ #ifndef O_DSYNC #define O_DSYNC 0x400000 /* synch I/O data integrity */ -#endif /* O_DSYNC */ +#endif /* O_DSYNC */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_o_sync.h b/lib/libc/include/any-macos-any/sys/_types/_o_sync.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_o_sync.h rename to lib/libc/include/any-macos-any/sys/_types/_o_sync.h index a3952cc35f..334754973b 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_o_sync.h +++ b/lib/libc/include/any-macos-any/sys/_types/_o_sync.h @@ -27,4 +27,4 @@ */ #ifndef O_SYNC #define O_SYNC 0x0080 /* synch I/O file integrity */ -#endif /* O_SYNC */ +#endif /* O_SYNC */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_off_t.h b/lib/libc/include/any-macos-any/sys/_types/_off_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_off_t.h rename to lib/libc/include/any-macos-any/sys/_types/_off_t.h index bdc3d5e383..32c92d5803 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_off_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_off_t.h @@ -29,4 +29,4 @@ #define _OFF_T #include /* __darwin_off_t */ typedef __darwin_off_t off_t; -#endif /* _OFF_T */ +#endif /* _OFF_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_os_inline.h b/lib/libc/include/any-macos-any/sys/_types/_os_inline.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_os_inline.h rename to lib/libc/include/any-macos-any/sys/_types/_os_inline.h index fd68cff47a..36c1c8f07b 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_os_inline.h +++ b/lib/libc/include/any-macos-any/sys/_types/_os_inline.h @@ -31,4 +31,4 @@ # else # define OS_INLINE static __inline__ # endif -#endif /* OS_INLINE */ +#endif /* OS_INLINE */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_pid_t.h b/lib/libc/include/any-macos-any/sys/_types/_pid_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_pid_t.h rename to lib/libc/include/any-macos-any/sys/_types/_pid_t.h index 994f84e87d..ad6c990052 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_pid_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_pid_t.h @@ -29,4 +29,4 @@ #define _PID_T #include /* __darwin_pid_t */ typedef __darwin_pid_t pid_t; -#endif /* _PID_T */ +#endif /* _PID_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_posix_vdisable.h b/lib/libc/include/any-macos-any/sys/_types/_posix_vdisable.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_posix_vdisable.h rename to lib/libc/include/any-macos-any/sys/_types/_posix_vdisable.h index 970f1b5d73..6c663dd8f1 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_posix_vdisable.h +++ b/lib/libc/include/any-macos-any/sys/_types/_posix_vdisable.h @@ -27,4 +27,4 @@ */ #ifndef _POSIX_VDISABLE #define _POSIX_VDISABLE ((unsigned char)'\377') -#endif /* POSIX_VDISABLE */ +#endif /* POSIX_VDISABLE */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_rsize_t.h b/lib/libc/include/any-macos-any/sys/_types/_rsize_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_rsize_t.h rename to lib/libc/include/any-macos-any/sys/_types/_rsize_t.h index 6aa2f6b320..8bea5a8fe3 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_rsize_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_rsize_t.h @@ -29,4 +29,4 @@ #define _RSIZE_T #include /* __darwin_size_t */ typedef __darwin_size_t rsize_t; -#endif /* _RSIZE_T */ +#endif /* _RSIZE_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_rune_t.h b/lib/libc/include/any-macos-any/sys/_types/_rune_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_rune_t.h rename to lib/libc/include/any-macos-any/sys/_types/_rune_t.h index bd10ef1ba5..713444c945 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_rune_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_rune_t.h @@ -29,4 +29,4 @@ #define _RUNE_T #include /* __darwin_rune_t */ typedef __darwin_rune_t rune_t; -#endif /* _RUNE_T */ +#endif /* _RUNE_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_s_ifmt.h b/lib/libc/include/any-macos-any/sys/_types/_s_ifmt.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_s_ifmt.h rename to lib/libc/include/any-macos-any/sys/_types/_s_ifmt.h index 1139cb25b7..66f3f068f0 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_s_ifmt.h +++ b/lib/libc/include/any-macos-any/sys/_types/_s_ifmt.h @@ -71,4 +71,4 @@ #define S_IWRITE S_IWUSR /* backward compatability */ #define S_IEXEC S_IXUSR /* backward compatability */ #endif -#endif /* !S_IFMT */ +#endif /* !S_IFMT */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_sa_family_t.h b/lib/libc/include/any-macos-any/sys/_types/_sa_family_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_sa_family_t.h rename to lib/libc/include/any-macos-any/sys/_types/_sa_family_t.h index 857cdd09c3..d1f5aaf724 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_sa_family_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_sa_family_t.h @@ -29,4 +29,4 @@ #define _SA_FAMILY_T #include /* __uint8_t */ typedef __uint8_t sa_family_t; -#endif /* _SA_FAMILY_T */ +#endif /* _SA_FAMILY_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_seek_set.h b/lib/libc/include/any-macos-any/sys/_types/_seek_set.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_seek_set.h rename to lib/libc/include/any-macos-any/sys/_types/_seek_set.h index f55175ad1f..2ba1d6b0d1 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_seek_set.h +++ b/lib/libc/include/any-macos-any/sys/_types/_seek_set.h @@ -43,4 +43,4 @@ #ifndef SEEK_DATA #define SEEK_DATA 4 /* set file offset to the start of the next non-hole file region greater than or equal to the supplied offset */ #endif -#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ +#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_sigaltstack.h b/lib/libc/include/any-macos-any/sys/_types/_sigaltstack.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_sigaltstack.h rename to lib/libc/include/any-macos-any/sys/_types/_sigaltstack.h index 8c34305842..1274acbe3a 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_sigaltstack.h +++ b/lib/libc/include/any-macos-any/sys/_types/_sigaltstack.h @@ -47,4 +47,4 @@ _STRUCT_SIGALTSTACK }; typedef _STRUCT_SIGALTSTACK stack_t; /* [???] signal stack */ -#endif /* _STRUCT_SIGALTSTACK */ +#endif /* _STRUCT_SIGALTSTACK */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_sigset_t.h b/lib/libc/include/any-macos-any/sys/_types/_sigset_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_sigset_t.h rename to lib/libc/include/any-macos-any/sys/_types/_sigset_t.h index 51844dddbb..cdf1551b03 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_sigset_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_sigset_t.h @@ -29,4 +29,4 @@ #define _SIGSET_T #include /* __darwin_sigset_t */ typedef __darwin_sigset_t sigset_t; -#endif /* _SIGSET_T */ +#endif /* _SIGSET_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_size_t.h b/lib/libc/include/any-macos-any/sys/_types/_size_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_size_t.h rename to lib/libc/include/any-macos-any/sys/_types/_size_t.h index a14a8885fa..8cd30fccd5 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_size_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_size_t.h @@ -29,4 +29,4 @@ #define _SIZE_T #include /* __darwin_size_t */ typedef __darwin_size_t size_t; -#endif /* _SIZE_T */ +#endif /* _SIZE_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_socklen_t.h b/lib/libc/include/any-macos-any/sys/_types/_socklen_t.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_socklen_t.h rename to lib/libc/include/any-macos-any/sys/_types/_socklen_t.h index a7b8431561..221d68a6ed 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_socklen_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_socklen_t.h @@ -29,4 +29,4 @@ #define _SOCKLEN_T #include /* __darwin_socklen_t */ typedef __darwin_socklen_t socklen_t; -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ssize_t.h b/lib/libc/include/any-macos-any/sys/_types/_ssize_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_ssize_t.h rename to lib/libc/include/any-macos-any/sys/_types/_ssize_t.h index 056607814d..426361129a 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ssize_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_ssize_t.h @@ -29,4 +29,4 @@ #define _SSIZE_T #include /* __darwin_ssize_t */ typedef __darwin_ssize_t ssize_t; -#endif /* _SSIZE_T */ +#endif /* _SSIZE_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_suseconds_t.h b/lib/libc/include/any-macos-any/sys/_types/_suseconds_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_suseconds_t.h rename to lib/libc/include/any-macos-any/sys/_types/_suseconds_t.h index 3980dfedf5..9e338c6c23 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_suseconds_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_suseconds_t.h @@ -29,4 +29,4 @@ #define _SUSECONDS_T #include /* __darwin_suseconds_t */ typedef __darwin_suseconds_t suseconds_t; -#endif /* _SUSECONDS_T */ +#endif /* _SUSECONDS_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_time_t.h b/lib/libc/include/any-macos-any/sys/_types/_time_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_time_t.h rename to lib/libc/include/any-macos-any/sys/_types/_time_t.h index 2a91ef225a..29546387f0 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_time_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_time_t.h @@ -29,4 +29,4 @@ #define _TIME_T #include /* __darwin_time_t */ typedef __darwin_time_t time_t; -#endif /* _TIME_T */ +#endif /* _TIME_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_timespec.h b/lib/libc/include/any-macos-any/sys/_types/_timespec.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_timespec.h rename to lib/libc/include/any-macos-any/sys/_types/_timespec.h index 82cc723ec6..7a34f30c98 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_timespec.h +++ b/lib/libc/include/any-macos-any/sys/_types/_timespec.h @@ -35,4 +35,4 @@ _STRUCT_TIMESPEC __darwin_time_t tv_sec; long tv_nsec; }; -#endif /* _STRUCT_TIMESPEC */ +#endif /* _STRUCT_TIMESPEC */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_timeval.h b/lib/libc/include/any-macos-any/sys/_types/_timeval.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_timeval.h rename to lib/libc/include/any-macos-any/sys/_types/_timeval.h index 1b9a000a6b..653ea0e6b2 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_timeval.h +++ b/lib/libc/include/any-macos-any/sys/_types/_timeval.h @@ -36,4 +36,4 @@ _STRUCT_TIMEVAL __darwin_time_t tv_sec; /* seconds */ __darwin_suseconds_t tv_usec; /* and microseconds */ }; -#endif /* _STRUCT_TIMEVAL */ +#endif /* _STRUCT_TIMEVAL */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_timeval32.h b/lib/libc/include/any-macos-any/sys/_types/_timeval32.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_timeval32.h rename to lib/libc/include/any-macos-any/sys/_types/_timeval32.h index 71518173a3..411f4aa3fe 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_timeval32.h +++ b/lib/libc/include/any-macos-any/sys/_types/_timeval32.h @@ -35,4 +35,4 @@ _STRUCT_TIMEVAL32 __int32_t tv_sec; /* seconds */ __int32_t tv_usec; /* and microseconds */ }; -#endif /* _STRUCT_TIMEVAL32 */ +#endif /* _STRUCT_TIMEVAL32 */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_timeval64.h b/lib/libc/include/any-macos-any/sys/_types/_timeval64.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_timeval64.h rename to lib/libc/include/any-macos-any/sys/_types/_timeval64.h index 2eb3c434fb..ed1959359e 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_timeval64.h +++ b/lib/libc/include/any-macos-any/sys/_types/_timeval64.h @@ -35,4 +35,4 @@ struct timeval64 { __int64_t tv_sec; /* seconds */ __int64_t tv_usec; /* and microseconds */ }; -#endif /* _STRUCT_TIMEVAL32 */ +#endif /* _STRUCT_TIMEVAL32 */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_char.h b/lib/libc/include/any-macos-any/sys/_types/_u_char.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_u_char.h rename to lib/libc/include/any-macos-any/sys/_types/_u_char.h index b6add3feb3..fa1d9d9543 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_char.h +++ b/lib/libc/include/any-macos-any/sys/_types/_u_char.h @@ -28,4 +28,4 @@ #ifndef _U_CHAR #define _U_CHAR typedef unsigned char u_char; -#endif /* _U_CHAR */ +#endif /* _U_CHAR */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int.h b/lib/libc/include/any-macos-any/sys/_types/_u_int.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int.h rename to lib/libc/include/any-macos-any/sys/_types/_u_int.h index 161b3baf14..df928def41 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int.h +++ b/lib/libc/include/any-macos-any/sys/_types/_u_int.h @@ -28,4 +28,4 @@ #ifndef _U_INT #define _U_INT typedef unsigned int u_int; -#endif /* _U_INT */ +#endif /* _U_INT */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int16_t.h b/lib/libc/include/any-macos-any/sys/_types/_u_int16_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int16_t.h rename to lib/libc/include/any-macos-any/sys/_types/_u_int16_t.h index 5a01fc450b..9726b93934 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int16_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_u_int16_t.h @@ -28,4 +28,4 @@ #ifndef _U_INT16_T #define _U_INT16_T typedef unsigned short u_int16_t; -#endif /* _U_INT16_T */ +#endif /* _U_INT16_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int32_t.h b/lib/libc/include/any-macos-any/sys/_types/_u_int32_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int32_t.h rename to lib/libc/include/any-macos-any/sys/_types/_u_int32_t.h index 4f01b22bd2..2361ef622f 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int32_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_u_int32_t.h @@ -28,4 +28,4 @@ #ifndef _U_INT32_T #define _U_INT32_T typedef unsigned int u_int32_t; -#endif /* _U_INT32_T */ +#endif /* _U_INT32_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int64_t.h b/lib/libc/include/any-macos-any/sys/_types/_u_int64_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int64_t.h rename to lib/libc/include/any-macos-any/sys/_types/_u_int64_t.h index bd866cbc2a..af2d9f4537 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int64_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_u_int64_t.h @@ -28,4 +28,4 @@ #ifndef _U_INT64_T #define _U_INT64_T typedef unsigned long long u_int64_t; -#endif /* _U_INT64_T */ +#endif /* _U_INT64_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int8_t.h b/lib/libc/include/any-macos-any/sys/_types/_u_int8_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int8_t.h rename to lib/libc/include/any-macos-any/sys/_types/_u_int8_t.h index ac9bf77111..bd1539c862 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_int8_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_u_int8_t.h @@ -28,4 +28,4 @@ #ifndef _U_INT8_T #define _U_INT8_T typedef unsigned char u_int8_t; -#endif /* _U_INT8_T */ +#endif /* _U_INT8_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_short.h b/lib/libc/include/any-macos-any/sys/_types/_u_short.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_u_short.h rename to lib/libc/include/any-macos-any/sys/_types/_u_short.h index 58816d3576..b693b30028 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_u_short.h +++ b/lib/libc/include/any-macos-any/sys/_types/_u_short.h @@ -28,4 +28,4 @@ #ifndef _U_SHORT #define _U_SHORT typedef unsigned short u_short; -#endif /* _U_SHORT */ +#endif /* _U_SHORT */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_uid_t.h b/lib/libc/include/any-macos-any/sys/_types/_uid_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_uid_t.h rename to lib/libc/include/any-macos-any/sys/_types/_uid_t.h index a9769db30d..2b8aaea3a8 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_uid_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_uid_t.h @@ -29,4 +29,4 @@ #define _UID_T #include /* __darwin_uid_t */ typedef __darwin_uid_t uid_t; -#endif /* _UID_T */ +#endif /* _UID_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_uintptr_t.h b/lib/libc/include/any-macos-any/sys/_types/_uintptr_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_uintptr_t.h rename to lib/libc/include/any-macos-any/sys/_types/_uintptr_t.h index c22d02b1cc..7971dbc86a 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_uintptr_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_uintptr_t.h @@ -28,4 +28,4 @@ #ifndef _UINTPTR_T #define _UINTPTR_T typedef unsigned long uintptr_t; -#endif /* _UINTPTR_T */ +#endif /* _UINTPTR_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_useconds_t.h b/lib/libc/include/any-macos-any/sys/_types/_useconds_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_useconds_t.h rename to lib/libc/include/any-macos-any/sys/_types/_useconds_t.h index 1b020a3bd2..aad70c2fc2 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_useconds_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_useconds_t.h @@ -29,4 +29,4 @@ #define _USECONDS_T #include /* __darwin_useconds_t */ typedef __darwin_useconds_t useconds_t; -#endif /* _USECONDS_T */ +#endif /* _USECONDS_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_uuid_t.h b/lib/libc/include/any-macos-any/sys/_types/_uuid_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_uuid_t.h rename to lib/libc/include/any-macos-any/sys/_types/_uuid_t.h index 66e7da7949..20acb344b8 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_uuid_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_uuid_t.h @@ -29,4 +29,4 @@ #define _UUID_T #include /* __darwin_uuid_t */ typedef __darwin_uuid_t uuid_t; -#endif /* _UUID_T */ +#endif /* _UUID_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_va_list.h b/lib/libc/include/any-macos-any/sys/_types/_va_list.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_va_list.h rename to lib/libc/include/any-macos-any/sys/_types/_va_list.h index f7687baea9..2525aaa658 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_va_list.h +++ b/lib/libc/include/any-macos-any/sys/_types/_va_list.h @@ -30,4 +30,4 @@ #define _VA_LIST_T #include /* __darwin_va_list */ typedef __darwin_va_list va_list; -#endif /* _VA_LIST_T */ +#endif /* _VA_LIST_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_wchar_t.h b/lib/libc/include/any-macos-any/sys/_types/_wchar_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_wchar_t.h rename to lib/libc/include/any-macos-any/sys/_types/_wchar_t.h index d67cfcdd23..6b36b33af8 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_wchar_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_wchar_t.h @@ -33,4 +33,4 @@ #include /* __darwin_wchar_t */ typedef __darwin_wchar_t wchar_t; #endif /* _WCHAR_T */ -#endif /* __cplusplus */ +#endif /* __cplusplus */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_wint_t.h b/lib/libc/include/any-macos-any/sys/_types/_wint_t.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/_types/_wint_t.h rename to lib/libc/include/any-macos-any/sys/_types/_wint_t.h index caad07fdb0..f2eea76671 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_wint_t.h +++ b/lib/libc/include/any-macos-any/sys/_types/_wint_t.h @@ -30,4 +30,4 @@ #define _WINT_T #include /* __darwin_wint_t */ typedef __darwin_wint_t wint_t; -#endif /* _WINT_T */ +#endif /* _WINT_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/aio.h b/lib/libc/include/any-macos-any/sys/aio.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/aio.h rename to lib/libc/include/any-macos-any/sys/aio.h index 6f8f36d7a7..8653b43fe7 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/aio.h +++ b/lib/libc/include/any-macos-any/sys/aio.h @@ -245,4 +245,4 @@ int lio_listio( int mode, struct sigevent *sigp ); __END_DECLS -#endif /* _SYS_AIO_H_ */ +#endif /* _SYS_AIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/appleapiopts.h b/lib/libc/include/any-macos-any/sys/appleapiopts.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/appleapiopts.h rename to lib/libc/include/any-macos-any/sys/appleapiopts.h index 92e9fd6919..a773c93b54 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/appleapiopts.h +++ b/lib/libc/include/any-macos-any/sys/appleapiopts.h @@ -58,4 +58,4 @@ #endif /* __APPLE_API_STRICT_CONFORMANCE */ -#endif /* __SYS_APPLEAPIOPTS_H__ */ +#endif /* __SYS_APPLEAPIOPTS_H__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/dirent.h b/lib/libc/include/any-macos-any/sys/dirent.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/dirent.h rename to lib/libc/include/any-macos-any/sys/dirent.h index 9a107a016c..f7992e3714 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/dirent.h +++ b/lib/libc/include/any-macos-any/sys/dirent.h @@ -138,4 +138,4 @@ struct dirent __DARWIN_STRUCT_DIRENTRY; #endif -#endif /* _SYS_DIRENT_H */ +#endif /* _SYS_DIRENT_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/errno.h b/lib/libc/include/any-macos-any/sys/errno.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/errno.h rename to lib/libc/include/any-macos-any/sys/errno.h index 0360a496f0..7dc6a481dd 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/errno.h +++ b/lib/libc/include/any-macos-any/sys/errno.h @@ -263,4 +263,4 @@ __END_DECLS #define ELAST 106 /* Must be equal largest errno */ #endif -#endif /* _SYS_ERRNO_H_ */ +#endif /* _SYS_ERRNO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/file.h b/lib/libc/include/any-macos-any/sys/file.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/file.h rename to lib/libc/include/any-macos-any/sys/file.h index b24ec6a292..7187715558 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/file.h +++ b/lib/libc/include/any-macos-any/sys/file.h @@ -83,4 +83,4 @@ typedef struct posix_cred *posix_cred_t; __BEGIN_DECLS __END_DECLS -#endif /* !_SYS_FILE_H_ */ +#endif /* !_SYS_FILE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/filio.h b/lib/libc/include/any-macos-any/sys/filio.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/filio.h rename to lib/libc/include/any-macos-any/sys/filio.h index 81e4b89474..60ec8185f6 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/filio.h +++ b/lib/libc/include/any-macos-any/sys/filio.h @@ -82,4 +82,4 @@ #define FIODTYPE _IOR('f', 122, int) /* get d_type */ -#endif /* !_SYS_FILIO_H_ */ +#endif /* !_SYS_FILIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/ioctl.h b/lib/libc/include/any-macos-any/sys/ioctl.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/ioctl.h rename to lib/libc/include/any-macos-any/sys/ioctl.h index aee7d6163f..bb84842dd2 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/ioctl.h +++ b/lib/libc/include/any-macos-any/sys/ioctl.h @@ -107,4 +107,4 @@ __END_DECLS */ #if defined(USE_OLD_TTY) || defined(BSD_KERNEL_PRIVATE) #include -#endif /* !_SYS_IOCTL_H_ */ +#endif /* !_SYS_IOCTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/ipc.h b/lib/libc/include/any-macos-any/sys/ipc.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/ipc.h rename to lib/libc/include/any-macos-any/sys/ipc.h index b2ce992a7c..86b665e04f 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/ipc.h +++ b/lib/libc/include/any-macos-any/sys/ipc.h @@ -173,4 +173,4 @@ key_t ftok(const char *, int); __END_DECLS -#endif /* !_SYS_IPC_H_ */ +#endif /* !_SYS_IPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/lock.h b/lib/libc/include/any-macos-any/sys/lock.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/lock.h rename to lib/libc/include/any-macos-any/sys/lock.h index cafc4e04d8..90c963a9e7 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/lock.h +++ b/lib/libc/include/any-macos-any/sys/lock.h @@ -73,4 +73,4 @@ #include -#endif /* _SYS_LOCK_H_ */ +#endif /* _SYS_LOCK_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/msg.h b/lib/libc/include/any-macos-any/sys/msg.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/msg.h rename to lib/libc/include/any-macos-any/sys/msg.h index 3bbe9e1e1d..657ae2db00 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/msg.h +++ b/lib/libc/include/any-macos-any/sys/msg.h @@ -222,4 +222,4 @@ int msgsnd(int, const void *, size_t, int) __DARWIN_ALIAS_C(msgsnd); __END_DECLS -#endif /* !_SYS_MSG_H_ */ +#endif /* !_SYS_MSG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/poll.h b/lib/libc/include/any-macos-any/sys/poll.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/poll.h rename to lib/libc/include/any-macos-any/sys/poll.h index 7467936a9b..fccd5d034d 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/poll.h +++ b/lib/libc/include/any-macos-any/sys/poll.h @@ -115,4 +115,4 @@ extern int poll(struct pollfd *, nfds_t, int) __DARWIN_ALIAS_C(poll); __END_DECLS -#endif /* !_SYS_POLL_H_ */ +#endif /* !_SYS_POLL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/qos.h b/lib/libc/include/any-macos-any/sys/qos.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/qos.h rename to lib/libc/include/any-macos-any/sys/qos.h index 2aa7dcd5c6..0edcbffdab 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/qos.h +++ b/lib/libc/include/any-macos-any/sys/qos.h @@ -197,4 +197,4 @@ __END_DECLS #endif // KERNEL -#endif // _SYS_QOS_H +#endif // _SYS_QOS_H \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/queue.h b/lib/libc/include/any-macos-any/sys/queue.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/queue.h rename to lib/libc/include/any-macos-any/sys/queue.h index 4ae79ffc23..b3394c2cfc 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/queue.h +++ b/lib/libc/include/any-macos-any/sys/queue.h @@ -906,4 +906,4 @@ void remque(void *a); #endif /* NOTFB31 */ #endif /* _KERNEL */ -#endif /* !_SYS_QUEUE_H_ */ +#endif /* !_SYS_QUEUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/select.h b/lib/libc/include/any-macos-any/sys/select.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/select.h rename to lib/libc/include/any-macos-any/sys/select.h index 50c5ce98d6..5ef1a78597 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/select.h +++ b/lib/libc/include/any-macos-any/sys/select.h @@ -131,4 +131,4 @@ __DARWIN_ALIAS_C(pselect) __END_DECLS -#endif /* !_SYS_SELECT_H_ */ +#endif /* !_SYS_SELECT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/sem.h b/lib/libc/include/any-macos-any/sys/sem.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/sem.h rename to lib/libc/include/any-macos-any/sys/sem.h index 32777590d6..8f5f08411b 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/sem.h +++ b/lib/libc/include/any-macos-any/sys/sem.h @@ -203,4 +203,4 @@ int semop(int, struct sembuf *, size_t); __END_DECLS -#endif /* !_SEM_H_ */ +#endif /* !_SEM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/semaphore.h b/lib/libc/include/any-macos-any/sys/semaphore.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/semaphore.h rename to lib/libc/include/any-macos-any/sys/semaphore.h index 6e945f6906..3e32669f1a 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/semaphore.h +++ b/lib/libc/include/any-macos-any/sys/semaphore.h @@ -61,4 +61,4 @@ int sem_wait(sem_t *) __DARWIN_ALIAS_C(sem_wait); __END_DECLS -#endif /* _SYS_SEMAPHORE_H_ */ +#endif /* _SYS_SEMAPHORE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/signal.h b/lib/libc/include/any-macos-any/sys/signal.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/signal.h rename to lib/libc/include/any-macos-any/sys/signal.h index 7c5de71a10..6ba6806200 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/signal.h +++ b/lib/libc/include/any-macos-any/sys/signal.h @@ -389,4 +389,4 @@ struct sigstack { __BEGIN_DECLS void(*signal(int, void (*)(int)))(int); __END_DECLS -#endif /* !_SYS_SIGNAL_H_ */ +#endif /* !_SYS_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/statvfs.h b/lib/libc/include/any-macos-any/sys/statvfs.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/statvfs.h rename to lib/libc/include/any-macos-any/sys/statvfs.h index a8d661a5c6..3a2b5cde36 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/statvfs.h +++ b/lib/libc/include/any-macos-any/sys/statvfs.h @@ -57,4 +57,4 @@ int fstatvfs(int, struct statvfs *); int statvfs(const char * __restrict, struct statvfs * __restrict); __END_DECLS -#endif /* _SYS_STATVFS_H_ */ +#endif /* _SYS_STATVFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/stdio.h b/lib/libc/include/any-macos-any/sys/stdio.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/sys/stdio.h rename to lib/libc/include/any-macos-any/sys/stdio.h index 5b42672c01..c51c1b9c7d 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/stdio.h +++ b/lib/libc/include/any-macos-any/sys/stdio.h @@ -52,4 +52,4 @@ __END_DECLS #endif /* __DARWIN_C_LEVEL >= 200809L */ -#endif /* _SYS_STDIO_H_ */ +#endif /* _SYS_STDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/syslog.h b/lib/libc/include/any-macos-any/sys/syslog.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/syslog.h rename to lib/libc/include/any-macos-any/sys/syslog.h index c72d998b8f..a2f4e4daab 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/syslog.h +++ b/lib/libc/include/any-macos-any/sys/syslog.h @@ -233,4 +233,4 @@ void vsyslog(int, const char *, __darwin_va_list) __printflike(2, 0) __not_ta #endif __END_DECLS -#endif /* !_SYS_SYSLOG_H_ */ +#endif /* !_SYS_SYSLOG_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/termios.h b/lib/libc/include/any-macos-any/sys/termios.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/termios.h rename to lib/libc/include/any-macos-any/sys/termios.h index 3d7778bdff..2f746b7d99 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/termios.h +++ b/lib/libc/include/any-macos-any/sys/termios.h @@ -363,4 +363,4 @@ __END_DECLS #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) #include -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/time.h b/lib/libc/include/any-macos-any/sys/time.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/time.h rename to lib/libc/include/any-macos-any/sys/time.h index 9c35edb9f1..192ae1c0f2 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/time.h +++ b/lib/libc/include/any-macos-any/sys/time.h @@ -205,4 +205,4 @@ int utimes(const char *, const struct timeval *); __END_DECLS -#endif /* !_SYS_TIME_H_ */ +#endif /* !_SYS_TIME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/times.h b/lib/libc/include/any-macos-any/sys/times.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/times.h rename to lib/libc/include/any-macos-any/sys/times.h index 3fc3000281..9739e311cf 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/times.h +++ b/lib/libc/include/any-macos-any/sys/times.h @@ -89,4 +89,4 @@ struct tms { __BEGIN_DECLS clock_t times(struct tms *); __END_DECLS -#endif /* !_SYS_TIMES_H_ */ +#endif /* !_SYS_TIMES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/ttycom.h b/lib/libc/include/any-macos-any/sys/ttycom.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/ttycom.h rename to lib/libc/include/any-macos-any/sys/ttycom.h index 547dd3c180..e3830c8627 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/ttycom.h +++ b/lib/libc/include/any-macos-any/sys/ttycom.h @@ -170,4 +170,4 @@ struct winsize { #define SLIPDISC 4 /* serial IP discipline */ #define PPPDISC 5 /* PPP discipline */ -#endif /* !_SYS_TTYCOM_H_ */ +#endif /* !_SYS_TTYCOM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/ttydefaults.h b/lib/libc/include/any-macos-any/sys/ttydefaults.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/ttydefaults.h rename to lib/libc/include/any-macos-any/sys/ttydefaults.h index eed46dded2..27b17da43a 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/ttydefaults.h +++ b/lib/libc/include/any-macos-any/sys/ttydefaults.h @@ -121,4 +121,4 @@ static cc_t ttydefchars[NCCS] = { CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE }; #undef TTYDEFCHARS -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/types.h b/lib/libc/include/any-macos-any/sys/types.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/types.h rename to lib/libc/include/any-macos-any/sys/types.h index 6e06f7dee5..adf67a3b0d 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/types.h +++ b/lib/libc/include/any-macos-any/sys/types.h @@ -232,4 +232,4 @@ typedef __int32_t fd_mask; #include #include -#endif /* !_SYS_TYPES_H_ */ +#endif /* !_SYS_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/ucred.h b/lib/libc/include/any-macos-any/sys/ucred.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/ucred.h rename to lib/libc/include/any-macos-any/sys/ucred.h index 1a4c10dd88..0dc5465485 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/ucred.h +++ b/lib/libc/include/any-macos-any/sys/ucred.h @@ -113,4 +113,4 @@ struct xucred { #endif /* __APPLE_API_UNSTABLE */ -#endif /* !_SYS_UCRED_H_ */ +#endif /* !_SYS_UCRED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/unistd.h b/lib/libc/include/any-macos-any/sys/unistd.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/unistd.h rename to lib/libc/include/any-macos-any/sys/unistd.h index e8105ea007..53d0331b06 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/unistd.h +++ b/lib/libc/include/any-macos-any/sys/unistd.h @@ -215,4 +215,4 @@ __END_DECLS #endif /* __DARWIN_C_LEVEL >= 200809L */ -#endif /* !_SYS_UNISTD_H_ */ +#endif /* !_SYS_UNISTD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/utsname.h b/lib/libc/include/any-macos-any/sys/utsname.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/utsname.h rename to lib/libc/include/any-macos-any/sys/utsname.h index b4ae9f4c49..0772b2bfc9 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/utsname.h +++ b/lib/libc/include/any-macos-any/sys/utsname.h @@ -83,4 +83,4 @@ __BEGIN_DECLS int uname(struct utsname *); __END_DECLS -#endif /* !_SYS_UTSNAME_H */ +#endif /* !_SYS_UTSNAME_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/vm.h b/lib/libc/include/any-macos-any/sys/vm.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/vm.h rename to lib/libc/include/any-macos-any/sys/vm.h index 52152e8a8b..8f32f5e2c1 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/vm.h +++ b/lib/libc/include/any-macos-any/sys/vm.h @@ -86,4 +86,4 @@ struct vmspace { -#endif /* _SYS_VM_H */ +#endif /* _SYS_VM_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/wait.h b/lib/libc/include/any-macos-any/sys/wait.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sys/wait.h rename to lib/libc/include/any-macos-any/sys/wait.h index e3cbb5833f..236d0f9015 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/wait.h +++ b/lib/libc/include/any-macos-any/sys/wait.h @@ -255,4 +255,4 @@ pid_t wait3(int *, int, struct rusage *); pid_t wait4(pid_t, int *, int, struct rusage *); #endif /* (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ __END_DECLS -#endif /* !_SYS_WAIT_H_ */ +#endif /* !_SYS_WAIT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sysexits.h b/lib/libc/include/any-macos-any/sysexits.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/sysexits.h rename to lib/libc/include/any-macos-any/sysexits.h index 464cb11bab..84c139f3b1 100644 --- a/lib/libc/include/x86_64-macos-gnu/sysexits.h +++ b/lib/libc/include/any-macos-any/sysexits.h @@ -115,4 +115,4 @@ #define EX__MAX 78 /* maximum listed value */ -#endif /* !_SYSEXITS_H_ */ +#endif /* !_SYSEXITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/syslog.h b/lib/libc/include/any-macos-any/syslog.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/syslog.h rename to lib/libc/include/any-macos-any/syslog.h index d3f4192ba5..03d2fb4658 100644 --- a/lib/libc/include/x86_64-macos-gnu/syslog.h +++ b/lib/libc/include/any-macos-any/syslog.h @@ -20,5 +20,4 @@ * * @APPLE_LICENSE_HEADER_END@ */ -#include - +#include \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/tar.h b/lib/libc/include/any-macos-any/tar.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/tar.h rename to lib/libc/include/any-macos-any/tar.h index 764ca01a10..13bb90a9a0 100644 --- a/lib/libc/include/x86_64-macos-gnu/tar.h +++ b/lib/libc/include/any-macos-any/tar.h @@ -70,4 +70,4 @@ #define TOWRITE 00002 /* Write by other */ #define TOEXEC 00001 /* Execute/Search by other */ -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/termios.h b/lib/libc/include/any-macos-any/termios.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/termios.h rename to lib/libc/include/any-macos-any/termios.h index 94f315b58c..44007f0013 100644 --- a/lib/libc/include/x86_64-macos-gnu/termios.h +++ b/lib/libc/include/any-macos-any/termios.h @@ -32,4 +32,4 @@ __BEGIN_DECLS pid_t tcgetsid(int); __END_DECLS -#endif /* __TERMIOS_H__ */ +#endif /* __TERMIOS_H__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/tgmath.h b/lib/libc/include/any-macos-any/tgmath.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/tgmath.h rename to lib/libc/include/any-macos-any/tgmath.h index c4760071be..16c04107d9 100644 --- a/lib/libc/include/x86_64-macos-gnu/tgmath.h +++ b/lib/libc/include/any-macos-any/tgmath.h @@ -1369,4 +1369,4 @@ static long double #undef _TG_ATTRS #endif /* __cplusplus */ -#endif /* __TGMATH_H */ +#endif /* __TGMATH_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/time.h b/lib/libc/include/any-macos-any/time.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/time.h rename to lib/libc/include/any-macos-any/time.h index dafb113e00..b2edfb95cd 100644 --- a/lib/libc/include/x86_64-macos-gnu/time.h +++ b/lib/libc/include/any-macos-any/time.h @@ -205,4 +205,4 @@ __END_DECLS #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* !_TIME_H_ */ +#endif /* !_TIME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/ulimit.h b/lib/libc/include/any-macos-any/ulimit.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/ulimit.h rename to lib/libc/include/any-macos-any/ulimit.h index c6a451c75f..a73058aedd 100644 --- a/lib/libc/include/x86_64-macos-gnu/ulimit.h +++ b/lib/libc/include/any-macos-any/ulimit.h @@ -38,4 +38,4 @@ __BEGIN_DECLS long ulimit(int, ...); __END_DECLS -#endif /* !_ULIMIT_H_ */ +#endif /* !_ULIMIT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/unistd.h b/lib/libc/include/any-macos-any/unistd.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/unistd.h rename to lib/libc/include/any-macos-any/unistd.h index 8350f5d226..d07a4a61f5 100644 --- a/lib/libc/include/x86_64-macos-gnu/unistd.h +++ b/lib/libc/include/any-macos-any/unistd.h @@ -784,4 +784,4 @@ extern int optreset; __END_DECLS #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ -#endif /* _UNISTD_H_ */ +#endif /* _UNISTD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/utime.h b/lib/libc/include/any-macos-any/utime.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/utime.h rename to lib/libc/include/any-macos-any/utime.h index 106e494940..16fcc283ba 100644 --- a/lib/libc/include/x86_64-macos-gnu/utime.h +++ b/lib/libc/include/any-macos-any/utime.h @@ -72,4 +72,4 @@ __BEGIN_DECLS int utime(const char *, const struct utimbuf *); __END_DECLS -#endif /* !_UTIME_H_ */ +#endif /* !_UTIME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/utmpx.h b/lib/libc/include/any-macos-any/utmpx.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/utmpx.h rename to lib/libc/include/any-macos-any/utmpx.h index a461c9ecbc..96871e4c0e 100644 --- a/lib/libc/include/x86_64-macos-gnu/utmpx.h +++ b/lib/libc/include/any-macos-any/utmpx.h @@ -173,4 +173,4 @@ int wtmpxname(const char *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); __END_DECLS -#endif /* !_UTMPX_H_ */ +#endif /* !_UTMPX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/uuid/uuid.h b/lib/libc/include/any-macos-any/uuid/uuid.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/uuid/uuid.h rename to lib/libc/include/any-macos-any/uuid/uuid.h index 28f231f8b4..ce75c9e0e1 100644 --- a/lib/libc/include/x86_64-macos-gnu/uuid/uuid.h +++ b/lib/libc/include/any-macos-any/uuid/uuid.h @@ -76,4 +76,4 @@ void uuid_unparse_upper(const uuid_t uu, uuid_string_t out); } #endif -#endif /* _UUID_UUID_H */ +#endif /* _UUID_UUID_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/wchar.h b/lib/libc/include/any-macos-any/wchar.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/wchar.h rename to lib/libc/include/any-macos-any/wchar.h index 38f84f8bb5..0b3916c0e9 100644 --- a/lib/libc/include/x86_64-macos-gnu/wchar.h +++ b/lib/libc/include/any-macos-any/wchar.h @@ -228,4 +228,4 @@ __END_DECLS #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* !_WCHAR_H_ */ +#endif /* !_WCHAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/wctype.h b/lib/libc/include/any-macos-any/wctype.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/wctype.h rename to lib/libc/include/any-macos-any/wctype.h index c270cc60d6..db3b5477f3 100644 --- a/lib/libc/include/x86_64-macos-gnu/wctype.h +++ b/lib/libc/include/any-macos-any/wctype.h @@ -127,4 +127,4 @@ __END_DECLS #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* _WCTYPE_H_ */ +#endif /* _WCTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/wordexp.h b/lib/libc/include/any-macos-any/wordexp.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/wordexp.h rename to lib/libc/include/any-macos-any/wordexp.h index 705b15c4e1..41a0b5f18f 100644 --- a/lib/libc/include/x86_64-macos-gnu/wordexp.h +++ b/lib/libc/include/any-macos-any/wordexp.h @@ -82,4 +82,4 @@ int wordexp(const char * __restrict, wordexp_t * __restrict, int) __OSX_AVAILABL void wordfree(wordexp_t *) __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA); __END_DECLS -#endif /* _WORDEXP_H */ +#endif /* _WORDEXP_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale.h b/lib/libc/include/any-macos-any/xlocale.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/xlocale.h rename to lib/libc/include/any-macos-any/xlocale.h index f5824b3b1a..e89e359620 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale.h +++ b/lib/libc/include/any-macos-any/xlocale.h @@ -108,4 +108,4 @@ __END_DECLS #include #endif /* _WCTYPE_H_ */ -#endif /* _XLOCALE_H_ */ +#endif /* _XLOCALE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/__wctype.h b/lib/libc/include/any-macos-any/xlocale/__wctype.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/xlocale/__wctype.h rename to lib/libc/include/any-macos-any/xlocale/__wctype.h index 2246382739..d377bf5a76 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/__wctype.h +++ b/lib/libc/include/any-macos-any/xlocale/__wctype.h @@ -140,4 +140,4 @@ wctype_t wctype_l(const char *, locale_t); __END_DECLS -#endif /* _XLOCALE___WCTYPE_H_ */ +#endif /* _XLOCALE___WCTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_ctype.h b/lib/libc/include/any-macos-any/xlocale/_ctype.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/xlocale/_ctype.h rename to lib/libc/include/any-macos-any/xlocale/_ctype.h index 99fe94ddd8..316b55dad5 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_ctype.h +++ b/lib/libc/include/any-macos-any/xlocale/_ctype.h @@ -234,4 +234,4 @@ int toupper_l(int, locale_t); __END_DECLS #endif /* using inlines */ -#endif /* _XLOCALE__CTYPE_H_ */ +#endif /* _XLOCALE__CTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_langinfo.h b/lib/libc/include/any-macos-any/xlocale/_langinfo.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/xlocale/_langinfo.h rename to lib/libc/include/any-macos-any/xlocale/_langinfo.h index 0190cf6b6c..28577e9353 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_langinfo.h +++ b/lib/libc/include/any-macos-any/xlocale/_langinfo.h @@ -32,4 +32,4 @@ __BEGIN_DECLS char *nl_langinfo_l(nl_item, locale_t); __END_DECLS -#endif /* _XLOCALE__LANGINFO_H_ */ +#endif /* _XLOCALE__LANGINFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_monetary.h b/lib/libc/include/any-macos-any/xlocale/_monetary.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/xlocale/_monetary.h rename to lib/libc/include/any-macos-any/xlocale/_monetary.h index cf1046868c..d553c86baf 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_monetary.h +++ b/lib/libc/include/any-macos-any/xlocale/_monetary.h @@ -35,4 +35,4 @@ ssize_t strfmon_l(char *, size_t, locale_t, const char *, ...) __strfmonlike(4, 5); __END_DECLS -#endif /* _XLOCALE__MONETARY_H_ */ +#endif /* _XLOCALE__MONETARY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_regex.h b/lib/libc/include/any-macos-any/xlocale/_regex.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/xlocale/_regex.h rename to lib/libc/include/any-macos-any/xlocale/_regex.h index 8f4fcf374d..3aaf4bef23 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_regex.h +++ b/lib/libc/include/any-macos-any/xlocale/_regex.h @@ -52,4 +52,4 @@ int regwnexec_l(const regex_t * __restrict, const wchar_t * __restrict, __END_DECLS -#endif /* _XLOCALE__REGEX_H_ */ +#endif /* _XLOCALE__REGEX_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_stdio.h b/lib/libc/include/any-macos-any/xlocale/_stdio.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/xlocale/_stdio.h rename to lib/libc/include/any-macos-any/xlocale/_stdio.h index f9272ff76c..7620a3ea04 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_stdio.h +++ b/lib/libc/include/any-macos-any/xlocale/_stdio.h @@ -79,4 +79,4 @@ int vasprintf_l(char ** __restrict, locale_t __restrict, const char * __restric __END_DECLS -#endif /* _XLOCALE__STDIO_H_ */ +#endif /* _XLOCALE__STDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_stdlib.h b/lib/libc/include/any-macos-any/xlocale/_stdlib.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/xlocale/_stdlib.h rename to lib/libc/include/any-macos-any/xlocale/_stdlib.h index add77d696f..494502d3f7 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_stdlib.h +++ b/lib/libc/include/any-macos-any/xlocale/_stdlib.h @@ -71,4 +71,4 @@ int wctomb_l(char *, wchar_t, locale_t); #endif __END_DECLS -#endif /* _XLOCALE__STDLIB_H_ */ +#endif /* _XLOCALE__STDLIB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_string.h b/lib/libc/include/any-macos-any/xlocale/_string.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/xlocale/_string.h rename to lib/libc/include/any-macos-any/xlocale/_string.h index 8aa73fac45..46b31e395d 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_string.h +++ b/lib/libc/include/any-macos-any/xlocale/_string.h @@ -36,4 +36,4 @@ char *strcasestr_l(const char *, const char *, locale_t); int strncasecmp_l(const char *, const char *, size_t, locale_t); __END_DECLS -#endif /* _XLOCALE__STRING_H_ */ +#endif /* _XLOCALE__STRING_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_time.h b/lib/libc/include/any-macos-any/xlocale/_time.h similarity index 97% rename from lib/libc/include/x86_64-macos-gnu/xlocale/_time.h rename to lib/libc/include/any-macos-any/xlocale/_time.h index c2c0965446..ed497992ec 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_time.h +++ b/lib/libc/include/any-macos-any/xlocale/_time.h @@ -38,4 +38,4 @@ char *strptime_l(const char * __restrict, const char * __restrict, __DARWIN_ALIAS(strptime_l) __strftimelike(2); __END_DECLS -#endif /* _XLOCALE__TIME_H_ */ +#endif /* _XLOCALE__TIME_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xlocale/_wctype.h b/lib/libc/include/any-macos-any/xlocale/_wctype.h similarity index 98% rename from lib/libc/include/x86_64-macos-gnu/xlocale/_wctype.h rename to lib/libc/include/any-macos-any/xlocale/_wctype.h index 2b0c6846f7..be65829381 100644 --- a/lib/libc/include/x86_64-macos-gnu/xlocale/_wctype.h +++ b/lib/libc/include/any-macos-any/xlocale/_wctype.h @@ -94,4 +94,4 @@ wctrans_t wctrans_l(const char *, locale_t); __END_DECLS -#endif /* _XLOCALE__WCTYPE_H_ */ +#endif /* _XLOCALE__WCTYPE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/activity.h b/lib/libc/include/any-macos-any/xpc/activity.h similarity index 99% rename from lib/libc/include/x86_64-macos-gnu/xpc/activity.h rename to lib/libc/include/any-macos-any/xpc/activity.h index c4f58e8f6c..c48051f145 100644 --- a/lib/libc/include/x86_64-macos-gnu/xpc/activity.h +++ b/lib/libc/include/any-macos-any/xpc/activity.h @@ -443,5 +443,4 @@ XPC_ASSUME_NONNULL_END #endif // __BLOCKS__ -#endif // __XPC_ACTIVITY_H__ - +#endif // __XPC_ACTIVITY_H__ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/debug.h b/lib/libc/include/any-macos-any/xpc/debug.h similarity index 96% rename from lib/libc/include/x86_64-macos-gnu/xpc/debug.h rename to lib/libc/include/any-macos-any/xpc/debug.h index b50361c6e9..8f86802951 100644 --- a/lib/libc/include/x86_64-macos-gnu/xpc/debug.h +++ b/lib/libc/include/any-macos-any/xpc/debug.h @@ -20,4 +20,4 @@ XPC_DEBUGGER_EXCL const char * xpc_debugger_api_misuse_info(void); -#endif // __XPC_DEBUG_H__ +#endif // __XPC_DEBUG_H__ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/xpc/endpoint.h b/lib/libc/include/any-macos-any/xpc/endpoint.h similarity index 95% rename from lib/libc/include/x86_64-macos-gnu/xpc/endpoint.h rename to lib/libc/include/any-macos-any/xpc/endpoint.h index aa43449b1d..a8032d98e3 100644 --- a/lib/libc/include/x86_64-macos-gnu/xpc/endpoint.h +++ b/lib/libc/include/any-macos-any/xpc/endpoint.h @@ -19,4 +19,4 @@ XPC_EXPORT XPC_MALLOC XPC_RETURNS_RETAINED XPC_WARN_RESULT XPC_NONNULL1 xpc_endpoint_t _Nonnull xpc_endpoint_create(xpc_connection_t _Nonnull connection); -#endif // __XPC_ENDPOINT_H__ +#endif // __XPC_ENDPOINT_H__ \ No newline at end of file diff --git a/lib/libc/include/arm-linux-musl/bits/alltypes.h b/lib/libc/include/arm-linux-musl/bits/alltypes.h index a99e771958..aa8607d008 100644 --- a/lib/libc/include/arm-linux-musl/bits/alltypes.h +++ b/lib/libc/include/arm-linux-musl/bits/alltypes.h @@ -350,6 +350,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/arm-linux-musl/bits/syscall.h b/lib/libc/include/arm-linux-musl/bits/syscall.h index 5429a867e3..479dd8a379 100644 --- a/lib/libc/include/arm-linux-musl/bits/syscall.h +++ b/lib/libc/include/arm-linux-musl/bits/syscall.h @@ -389,6 +389,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define __ARM_NR_breakpoint 0x0f0001 #define __ARM_NR_cacheflush 0x0f0002 @@ -787,4 +791,8 @@ #define SYS_fsmount 432 #define SYS_fspick 433 #define SYS_pidfd_open 434 -#define SYS_clone3 435 \ No newline at end of file +#define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 \ No newline at end of file diff --git a/lib/libc/musl/arch/x86_64/bits/fcntl.h b/lib/libc/include/generic-musl/bits/fcntl.h similarity index 83% rename from lib/libc/musl/arch/x86_64/bits/fcntl.h rename to lib/libc/include/generic-musl/bits/fcntl.h index 1b88ad3917..77c9b4cbfe 100644 --- a/lib/libc/musl/arch/x86_64/bits/fcntl.h +++ b/lib/libc/include/generic-musl/bits/fcntl.h @@ -13,7 +13,7 @@ #define O_ASYNC 020000 #define O_DIRECT 040000 -#define O_LARGEFILE 0 +#define O_LARGEFILE 0100000 #define O_NOATIME 01000000 #define O_PATH 010000000 #define O_TMPFILE 020200000 @@ -30,11 +30,17 @@ #define F_SETSIG 10 #define F_GETSIG 11 +#if __LONG_MAX == 0x7fffffffL +#define F_GETLK 12 +#define F_SETLK 13 +#define F_SETLKW 14 +#else #define F_GETLK 5 #define F_SETLK 6 #define F_SETLKW 7 +#endif #define F_SETOWN_EX 15 #define F_GETOWN_EX 16 -#define F_GETOWNER_UIDS 17 +#define F_GETOWNER_UIDS 17 \ No newline at end of file diff --git a/lib/libc/include/generic-musl/elf.h b/lib/libc/include/generic-musl/elf.h index 7ab2c85fe2..ff7214ed48 100644 --- a/lib/libc/include/generic-musl/elf.h +++ b/lib/libc/include/generic-musl/elf.h @@ -603,6 +603,7 @@ typedef struct { #define PT_GNU_EH_FRAME 0x6474e550 #define PT_GNU_STACK 0x6474e551 #define PT_GNU_RELRO 0x6474e552 +#define PT_GNU_PROPERTY 0x6474e553 #define PT_LOSUNW 0x6ffffffa #define PT_SUNWBSS 0x6ffffffa #define PT_SUNWSTACK 0x6ffffffb @@ -1085,6 +1086,7 @@ typedef struct { #define NT_GNU_BUILD_ID 3 #define NT_GNU_GOLD_VERSION 4 +#define NT_GNU_PROPERTY_TYPE_0 5 diff --git a/lib/libc/include/generic-musl/netinet/if_ether.h b/lib/libc/include/generic-musl/netinet/if_ether.h index 8be01cd4ef..d1c0a03570 100644 --- a/lib/libc/include/generic-musl/netinet/if_ether.h +++ b/lib/libc/include/generic-musl/netinet/if_ether.h @@ -59,6 +59,7 @@ #define ETH_P_PREAUTH 0x88C7 #define ETH_P_TIPC 0x88CA #define ETH_P_LLDP 0x88CC +#define ETH_P_MRP 0x88E3 #define ETH_P_MACSEC 0x88E5 #define ETH_P_8021AH 0x88E7 #define ETH_P_MVRP 0x88F5 diff --git a/lib/libc/include/generic-musl/netinet/in.h b/lib/libc/include/generic-musl/netinet/in.h index e3bf81b8d3..a57f3a6c7c 100644 --- a/lib/libc/include/generic-musl/netinet/in.h +++ b/lib/libc/include/generic-musl/netinet/in.h @@ -101,8 +101,10 @@ uint16_t ntohs(uint16_t); #define IPPROTO_MH 135 #define IPPROTO_UDPLITE 136 #define IPPROTO_MPLS 137 +#define IPPROTO_ETHERNET 143 #define IPPROTO_RAW 255 -#define IPPROTO_MAX 256 +#define IPPROTO_MPTCP 262 +#define IPPROTO_MAX 263 #define IN6_IS_ADDR_UNSPECIFIED(a) \ (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ @@ -200,6 +202,7 @@ uint16_t ntohs(uint16_t); #define IP_CHECKSUM 23 #define IP_BIND_ADDRESS_NO_PORT 24 #define IP_RECVFRAGSIZE 25 +#define IP_RECVERR_RFC4884 26 #define IP_MULTICAST_IF 32 #define IP_MULTICAST_TTL 33 #define IP_MULTICAST_LOOP 34 diff --git a/lib/libc/include/generic-musl/netinet/tcp.h b/lib/libc/include/generic-musl/netinet/tcp.h index f0bdb19232..9f514e33af 100644 --- a/lib/libc/include/generic-musl/netinet/tcp.h +++ b/lib/libc/include/generic-musl/netinet/tcp.h @@ -78,6 +78,8 @@ enum { TCP_NLA_DSACK_DUPS, TCP_NLA_REORD_SEEN, TCP_NLA_SRTT, + TCP_NLA_TIMEOUT_REHASH, + TCP_NLA_BYTES_NOTSENT, }; #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) @@ -181,6 +183,13 @@ struct tcphdr { #define TCP_CA_Recovery 3 #define TCP_CA_Loss 4 +enum tcp_fastopen_client_fail { + TFO_STATUS_UNSPEC, + TFO_COOKIE_UNAVAILABLE, + TFO_DATA_NOT_ACKED, + TFO_SYN_RETRANSMITTED, +}; + struct tcp_info { uint8_t tcpi_state; uint8_t tcpi_ca_state; @@ -189,7 +198,7 @@ struct tcp_info { uint8_t tcpi_backoff; uint8_t tcpi_options; uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; - uint8_t tcpi_delivery_rate_app_limited : 1; + uint8_t tcpi_delivery_rate_app_limited : 1, tcpi_fastopen_client_fail : 2; uint32_t tcpi_rto; uint32_t tcpi_ato; uint32_t tcpi_snd_mss; @@ -240,14 +249,15 @@ struct tcp_info { #define TCP_MD5SIG_MAXKEYLEN 80 -#define TCP_MD5SIG_FLAG_PREFIX 1 +#define TCP_MD5SIG_FLAG_PREFIX 0x1 +#define TCP_MD5SIG_FLAG_IFINDEX 0x2 struct tcp_md5sig { struct sockaddr_storage tcpm_addr; uint8_t tcpm_flags; uint8_t tcpm_prefixlen; uint16_t tcpm_keylen; - uint32_t __tcpm_pad; + int tcpm_ifindex; uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; }; @@ -275,6 +285,8 @@ struct tcp_zerocopy_receive { uint64_t address; uint32_t length; uint32_t recv_skip_hint; + uint32_t inq; + int32_t err; }; #endif diff --git a/lib/libc/include/generic-musl/netinet/udp.h b/lib/libc/include/generic-musl/netinet/udp.h index 40ca6df985..0355761025 100644 --- a/lib/libc/include/generic-musl/netinet/udp.h +++ b/lib/libc/include/generic-musl/netinet/udp.h @@ -35,6 +35,7 @@ struct udphdr { #define UDP_ENCAP_GTP0 4 #define UDP_ENCAP_GTP1U 5 #define UDP_ENCAP_RXRPC 6 +#define TCP_ENCAP_ESPINTCP 7 #define SOL_UDP 17 diff --git a/lib/libc/include/generic-musl/sched.h b/lib/libc/include/generic-musl/sched.h index 6225d25d53..91431b5d07 100644 --- a/lib/libc/include/generic-musl/sched.h +++ b/lib/libc/include/generic-musl/sched.h @@ -49,6 +49,7 @@ int sched_yield(void); #ifdef _GNU_SOURCE #define CSIGNAL 0x000000ff +#define CLONE_NEWTIME 0x00000080 #define CLONE_VM 0x00000100 #define CLONE_FS 0x00000200 #define CLONE_FILES 0x00000400 diff --git a/lib/libc/include/generic-musl/signal.h b/lib/libc/include/generic-musl/signal.h index 99d473c50e..779f4f0609 100644 --- a/lib/libc/include/generic-musl/signal.h +++ b/lib/libc/include/generic-musl/signal.h @@ -180,14 +180,24 @@ struct sigevent { union sigval sigev_value; int sigev_signo; int sigev_notify; - void (*sigev_notify_function)(union sigval); - pthread_attr_t *sigev_notify_attributes; - char __pad[56-3*sizeof(long)]; + union { + char __pad[64 - 2*sizeof(int) - sizeof(union sigval)]; + pid_t sigev_notify_thread_id; + struct { + void (*sigev_notify_function)(union sigval); + pthread_attr_t *sigev_notify_attributes; + } __sev_thread; + } __sev_fields; }; +#define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id +#define sigev_notify_function __sev_fields.__sev_thread.sigev_notify_function +#define sigev_notify_attributes __sev_fields.__sev_thread.sigev_notify_attributes + #define SIGEV_SIGNAL 0 #define SIGEV_NONE 1 #define SIGEV_THREAD 2 +#define SIGEV_THREAD_ID 4 int __libc_current_sigrtmin(void); int __libc_current_sigrtmax(void); diff --git a/lib/libc/include/generic-musl/stdlib.h b/lib/libc/include/generic-musl/stdlib.h index f7c4f9d8de..ee777fc915 100644 --- a/lib/libc/include/generic-musl/stdlib.h +++ b/lib/libc/include/generic-musl/stdlib.h @@ -145,6 +145,7 @@ int getloadavg(double *, int); int clearenv(void); #define WCOREDUMP(s) ((s) & 0x80) #define WIFCONTINUED(s) ((s) == 0xffff) +void *reallocarray (void *, size_t, size_t); #endif #ifdef _GNU_SOURCE diff --git a/lib/libc/include/generic-musl/sys/fanotify.h b/lib/libc/include/generic-musl/sys/fanotify.h index ba00797ca2..601e0e7206 100644 --- a/lib/libc/include/generic-musl/sys/fanotify.h +++ b/lib/libc/include/generic-musl/sys/fanotify.h @@ -55,8 +55,9 @@ struct fanotify_response { #define FAN_OPEN_PERM 0x10000 #define FAN_ACCESS_PERM 0x20000 #define FAN_OPEN_EXEC_PERM 0x40000 -#define FAN_ONDIR 0x40000000 +#define FAN_DIR_MODIFY 0x00080000 #define FAN_EVENT_ON_CHILD 0x08000000 +#define FAN_ONDIR 0x40000000 #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) #define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO) #define FAN_CLOEXEC 0x01 @@ -70,6 +71,9 @@ struct fanotify_response { #define FAN_ENABLE_AUDIT 0x40 #define FAN_REPORT_TID 0x100 #define FAN_REPORT_FID 0x200 +#define FAN_REPORT_DIR_FID 0x00000400 +#define FAN_REPORT_NAME 0x00000800 +#define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME) #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS) #define FAN_MARK_ADD 0x01 #define FAN_MARK_REMOVE 0x02 @@ -88,6 +92,8 @@ struct fanotify_response { #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW) #define FANOTIFY_METADATA_VERSION 3 #define FAN_EVENT_INFO_TYPE_FID 1 +#define FAN_EVENT_INFO_TYPE_DFID_NAME 2 +#define FAN_EVENT_INFO_TYPE_DFID 3 #define FAN_ALLOW 0x01 #define FAN_DENY 0x02 #define FAN_AUDIT 0x10 diff --git a/lib/libc/include/generic-musl/sys/ioctl.h b/lib/libc/include/generic-musl/sys/ioctl.h index 28c9b6e24f..a741ae18a8 100644 --- a/lib/libc/include/generic-musl/sys/ioctl.h +++ b/lib/libc/include/generic-musl/sys/ioctl.h @@ -4,6 +4,8 @@ extern "C" { #endif +#define __NEED_struct_winsize + #include #include @@ -47,13 +49,6 @@ extern "C" { #define TIOCSER_TEMT 1 -struct winsize { - unsigned short ws_row; - unsigned short ws_col; - unsigned short ws_xpixel; - unsigned short ws_ypixel; -}; - #define SIOCADDRT 0x890B #define SIOCDELRT 0x890C #define SIOCRTMSG 0x890D diff --git a/lib/libc/include/generic-musl/sys/mman.h b/lib/libc/include/generic-musl/sys/mman.h index 9bfd0a1075..a620fffea1 100644 --- a/lib/libc/include/generic-musl/sys/mman.h +++ b/lib/libc/include/generic-musl/sys/mman.h @@ -101,6 +101,7 @@ extern "C" { #ifdef _GNU_SOURCE #define MREMAP_MAYMOVE 1 #define MREMAP_FIXED 2 +#define MREMAP_DONTUNMAP 4 #define MLOCK_ONFAULT 0x01 diff --git a/lib/libc/include/generic-musl/sys/personality.h b/lib/libc/include/generic-musl/sys/personality.h index aafda2657b..8c8a278cae 100644 --- a/lib/libc/include/generic-musl/sys/personality.h +++ b/lib/libc/include/generic-musl/sys/personality.h @@ -5,7 +5,9 @@ extern "C" { #endif +#define UNAME26 0x0020000 #define ADDR_NO_RANDOMIZE 0x0040000 +#define FDPIC_FUNCPTRS 0x0080000 #define MMAP_PAGE_ZERO 0x0100000 #define ADDR_COMPAT_LAYOUT 0x0200000 #define READ_IMPLIES_EXEC 0x0400000 @@ -17,6 +19,7 @@ extern "C" { #define PER_LINUX 0 #define PER_LINUX_32BIT ADDR_LIMIT_32BIT +#define PER_LINUX_FDPIC FDPIC_FUNCPTRS #define PER_SVR4 (1 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO) #define PER_SVR3 (2 | STICKY_TIMEOUTS | SHORT_INODE) #define PER_SCOSVR3 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE) diff --git a/lib/libc/include/generic-musl/sys/prctl.h b/lib/libc/include/generic-musl/sys/prctl.h index c5f79d86d2..bceebd8bcf 100644 --- a/lib/libc/include/generic-musl/sys/prctl.h +++ b/lib/libc/include/generic-musl/sys/prctl.h @@ -158,6 +158,9 @@ struct prctl_mm_map { #define PR_GET_TAGGED_ADDR_CTRL 56 #define PR_TAGGED_ADDR_ENABLE (1UL << 0) +#define PR_SET_IO_FLUSHER 57 +#define PR_GET_IO_FLUSHER 58 + int prctl (int, ...); #ifdef __cplusplus diff --git a/lib/libc/include/generic-musl/sys/random.h b/lib/libc/include/generic-musl/sys/random.h index f6141970f4..e5ee99a2ae 100644 --- a/lib/libc/include/generic-musl/sys/random.h +++ b/lib/libc/include/generic-musl/sys/random.h @@ -10,6 +10,7 @@ extern "C" { #define GRND_NONBLOCK 0x0001 #define GRND_RANDOM 0x0002 +#define GRND_INSECURE 0x0004 ssize_t getrandom(void *, size_t, unsigned); diff --git a/lib/libc/include/generic-musl/termios.h b/lib/libc/include/generic-musl/termios.h index 4a72bd4e07..735c759923 100644 --- a/lib/libc/include/generic-musl/termios.h +++ b/lib/libc/include/generic-musl/termios.h @@ -8,6 +8,7 @@ extern "C" { #include #define __NEED_pid_t +#define __NEED_struct_winsize #include @@ -27,6 +28,9 @@ int cfsetispeed (struct termios *, speed_t); int tcgetattr (int, struct termios *); int tcsetattr (int, int, const struct termios *); +int tcgetwinsize (int, struct winsize *); +int tcsetwinsize (int, const struct winsize *); + int tcsendbreak (int, int); int tcdrain (int); int tcflush (int, int); diff --git a/lib/libc/include/generic-musl/unistd.h b/lib/libc/include/generic-musl/unistd.h index c6b3f1a2ad..c6f5698b4e 100644 --- a/lib/libc/include/generic-musl/unistd.h +++ b/lib/libc/include/generic-musl/unistd.h @@ -82,6 +82,7 @@ unsigned sleep(unsigned); int pause(void); pid_t fork(void); +pid_t _Fork(void); int execve(const char *, char *const [], char *const []); int execv(const char *, char *const []); int execle(const char *, const char *, ...); @@ -190,6 +191,7 @@ int syncfs(int); int euidaccess(const char *, int); int eaccess(const char *, int); ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); +pid_t gettid(void); #endif #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) diff --git a/lib/libc/include/i386-linux-musl/bits/alltypes.h b/lib/libc/include/i386-linux-musl/bits/alltypes.h index c330f5dd05..f430f25cff 100644 --- a/lib/libc/include/i386-linux-musl/bits/alltypes.h +++ b/lib/libc/include/i386-linux-musl/bits/alltypes.h @@ -380,6 +380,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/i386-linux-musl/bits/syscall.h b/lib/libc/include/i386-linux-musl/bits/syscall.h index c9bfc7f95e..4a727513c1 100644 --- a/lib/libc/include/i386-linux-musl/bits/syscall.h +++ b/lib/libc/include/i386-linux-musl/bits/syscall.h @@ -426,6 +426,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define SYS_restart_syscall 0 #define SYS_exit 1 @@ -852,4 +856,8 @@ #define SYS_fsmount 432 #define SYS_fspick 433 #define SYS_pidfd_open 434 -#define SYS_clone3 435 \ No newline at end of file +#define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 \ No newline at end of file diff --git a/lib/libc/include/mips-linux-musl/bits/alltypes.h b/lib/libc/include/mips-linux-musl/bits/alltypes.h index c714577aaa..46b309d668 100644 --- a/lib/libc/include/mips-linux-musl/bits/alltypes.h +++ b/lib/libc/include/mips-linux-musl/bits/alltypes.h @@ -350,6 +350,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/mips-linux-musl/bits/syscall.h b/lib/libc/include/mips-linux-musl/bits/syscall.h index 3f2666e56f..982dcca465 100644 --- a/lib/libc/include/mips-linux-musl/bits/syscall.h +++ b/lib/libc/include/mips-linux-musl/bits/syscall.h @@ -408,6 +408,10 @@ #define __NR_fspick 4433 #define __NR_pidfd_open 4434 #define __NR_clone3 4435 +#define __NR_close_range 4436 +#define __NR_openat2 4437 +#define __NR_pidfd_getfd 4438 +#define __NR_faccessat2 4439 #define SYS_syscall 4000 #define SYS_exit 4001 @@ -818,4 +822,8 @@ #define SYS_fsmount 4432 #define SYS_fspick 4433 #define SYS_pidfd_open 4434 -#define SYS_clone3 4435 \ No newline at end of file +#define SYS_clone3 4435 +#define SYS_close_range 4436 +#define SYS_openat2 4437 +#define SYS_pidfd_getfd 4438 +#define SYS_faccessat2 4439 \ No newline at end of file diff --git a/lib/libc/include/mips64-linux-musl/bits/alltypes.h b/lib/libc/include/mips64-linux-musl/bits/alltypes.h index 9745553d16..4ab49779d8 100644 --- a/lib/libc/include/mips64-linux-musl/bits/alltypes.h +++ b/lib/libc/include/mips64-linux-musl/bits/alltypes.h @@ -355,6 +355,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/mips64-linux-musl/bits/fcntl.h b/lib/libc/include/mips64-linux-musl/bits/fcntl.h index 30ca0e0ca1..cba13902f6 100644 --- a/lib/libc/include/mips64-linux-musl/bits/fcntl.h +++ b/lib/libc/include/mips64-linux-musl/bits/fcntl.h @@ -13,7 +13,7 @@ #define O_ASYNC 010000 #define O_DIRECT 0100000 -#define O_LARGEFILE 0 +#define O_LARGEFILE 020000 #define O_NOATIME 01000000 #define O_PATH 010000000 #define O_TMPFILE 020200000 diff --git a/lib/libc/include/mips64-linux-musl/bits/syscall.h b/lib/libc/include/mips64-linux-musl/bits/syscall.h index b3d86fe1d8..27a8226b71 100644 --- a/lib/libc/include/mips64-linux-musl/bits/syscall.h +++ b/lib/libc/include/mips64-linux-musl/bits/syscall.h @@ -338,6 +338,10 @@ #define __NR_fspick 5433 #define __NR_pidfd_open 5434 #define __NR_clone3 5435 +#define __NR_close_range 5436 +#define __NR_openat2 5437 +#define __NR_pidfd_getfd 5438 +#define __NR_faccessat2 5439 #define SYS_read 5000 #define SYS_write 5001 @@ -678,4 +682,8 @@ #define SYS_fsmount 5432 #define SYS_fspick 5433 #define SYS_pidfd_open 5434 -#define SYS_clone3 5435 \ No newline at end of file +#define SYS_clone3 5435 +#define SYS_close_range 5436 +#define SYS_openat2 5437 +#define SYS_pidfd_getfd 5438 +#define SYS_faccessat2 5439 \ No newline at end of file diff --git a/lib/libc/include/powerpc-linux-musl/bits/alltypes.h b/lib/libc/include/powerpc-linux-musl/bits/alltypes.h index f655b43e3d..43153d4170 100644 --- a/lib/libc/include/powerpc-linux-musl/bits/alltypes.h +++ b/lib/libc/include/powerpc-linux-musl/bits/alltypes.h @@ -353,6 +353,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/powerpc-linux-musl/bits/syscall.h b/lib/libc/include/powerpc-linux-musl/bits/syscall.h index ce2818352c..3c935d00da 100644 --- a/lib/libc/include/powerpc-linux-musl/bits/syscall.h +++ b/lib/libc/include/powerpc-linux-musl/bits/syscall.h @@ -415,6 +415,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define SYS_restart_syscall 0 #define SYS_exit 1 @@ -832,4 +836,8 @@ #define SYS_fsmount 432 #define SYS_fspick 433 #define SYS_pidfd_open 434 -#define SYS_clone3 435 \ No newline at end of file +#define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 \ No newline at end of file diff --git a/lib/libc/include/powerpc64-linux-musl/bits/alltypes.h b/lib/libc/include/powerpc64-linux-musl/bits/alltypes.h index 6177874ffa..e0deec33b3 100644 --- a/lib/libc/include/powerpc64-linux-musl/bits/alltypes.h +++ b/lib/libc/include/powerpc64-linux-musl/bits/alltypes.h @@ -349,6 +349,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/powerpc64-linux-musl/bits/syscall.h b/lib/libc/include/powerpc64-linux-musl/bits/syscall.h index 4592aac64d..de64c3ef30 100644 --- a/lib/libc/include/powerpc64-linux-musl/bits/syscall.h +++ b/lib/libc/include/powerpc64-linux-musl/bits/syscall.h @@ -387,6 +387,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define SYS_restart_syscall 0 #define SYS_exit 1 @@ -776,4 +780,8 @@ #define SYS_fsmount 432 #define SYS_fspick 433 #define SYS_pidfd_open 434 -#define SYS_clone3 435 \ No newline at end of file +#define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 \ No newline at end of file diff --git a/lib/libc/include/riscv64-linux-musl/bits/alltypes.h b/lib/libc/include/riscv64-linux-musl/bits/alltypes.h index 8db53c8293..0f79bc567d 100644 --- a/lib/libc/include/riscv64-linux-musl/bits/alltypes.h +++ b/lib/libc/include/riscv64-linux-musl/bits/alltypes.h @@ -355,6 +355,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/riscv64-linux-musl/bits/signal.h b/lib/libc/include/riscv64-linux-musl/bits/signal.h index 87ae2ee7d1..5cf2d5895d 100644 --- a/lib/libc/include/riscv64-linux-musl/bits/signal.h +++ b/lib/libc/include/riscv64-linux-musl/bits/signal.h @@ -60,10 +60,10 @@ struct sigaltstack { size_t ss_size; }; -typedef struct ucontext_t +typedef struct __ucontext { unsigned long uc_flags; - struct ucontext_t *uc_link; + struct __ucontext *uc_link; stack_t uc_stack; sigset_t uc_sigmask; mcontext_t uc_mcontext; diff --git a/lib/libc/include/riscv64-linux-musl/bits/syscall.h b/lib/libc/include/riscv64-linux-musl/bits/syscall.h index 808207fb4b..27e10f5768 100644 --- a/lib/libc/include/riscv64-linux-musl/bits/syscall.h +++ b/lib/libc/include/riscv64-linux-musl/bits/syscall.h @@ -289,6 +289,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define __NR_sysriscv __NR_arch_specific_syscall #define __NR_riscv_flush_icache (__NR_sysriscv + 15) @@ -583,5 +587,9 @@ #define SYS_fspick 433 #define SYS_pidfd_open 434 #define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 #define SYS_sysriscv __NR_arch_specific_syscall #define SYS_riscv_flush_icache (__NR_sysriscv + 15) \ No newline at end of file diff --git a/lib/libc/include/s390x-linux-musl/bits/alltypes.h b/lib/libc/include/s390x-linux-musl/bits/alltypes.h index 55dbfa500c..c1b9e7b694 100644 --- a/lib/libc/include/s390x-linux-musl/bits/alltypes.h +++ b/lib/libc/include/s390x-linux-musl/bits/alltypes.h @@ -13,11 +13,19 @@ typedef int wchar_t; #endif +#if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 1 #if defined(__NEED_float_t) && !defined(__DEFINED_float_t) typedef double float_t; #define __DEFINED_float_t #endif +#else +#if defined(__NEED_float_t) && !defined(__DEFINED_float_t) +typedef float float_t; +#define __DEFINED_float_t +#endif + +#endif #if defined(__NEED_double_t) && !defined(__DEFINED_double_t) typedef double double_t; #define __DEFINED_double_t @@ -344,6 +352,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/s390x-linux-musl/bits/float.h b/lib/libc/include/s390x-linux-musl/bits/float.h index fc6f4bb8fa..127787d2cb 100644 --- a/lib/libc/include/s390x-linux-musl/bits/float.h +++ b/lib/libc/include/s390x-linux-musl/bits/float.h @@ -1,4 +1,8 @@ -#define FLT_EVAL_METHOD 1 +#ifdef __FLT_EVAL_METHOD__ +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#else +#define FLT_EVAL_METHOD 0 +#endif #define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L #define LDBL_MIN 3.36210314311209350626267781732175260e-4932L diff --git a/lib/libc/include/s390x-linux-musl/bits/syscall.h b/lib/libc/include/s390x-linux-musl/bits/syscall.h index 790f513736..2874c40203 100644 --- a/lib/libc/include/s390x-linux-musl/bits/syscall.h +++ b/lib/libc/include/s390x-linux-musl/bits/syscall.h @@ -352,6 +352,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define SYS_exit 1 #define SYS_fork 2 @@ -706,4 +710,8 @@ #define SYS_fsmount 432 #define SYS_fspick 433 #define SYS_pidfd_open 434 -#define SYS_clone3 435 \ No newline at end of file +#define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 \ No newline at end of file diff --git a/lib/libc/include/x86_64-linux-musl/bits/alltypes.h b/lib/libc/include/x86_64-linux-musl/bits/alltypes.h index 7418a48234..c57d9bb42a 100644 --- a/lib/libc/include/x86_64-linux-musl/bits/alltypes.h +++ b/lib/libc/include/x86_64-linux-musl/bits/alltypes.h @@ -357,6 +357,12 @@ struct iovec { void *iov_base; size_t iov_len; }; #endif +#if defined(__NEED_struct_winsize) && !defined(__DEFINED_struct_winsize) +struct winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; +#define __DEFINED_struct_winsize +#endif + + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t diff --git a/lib/libc/include/x86_64-linux-musl/bits/syscall.h b/lib/libc/include/x86_64-linux-musl/bits/syscall.h index e4dbe4b061..d91f553b77 100644 --- a/lib/libc/include/x86_64-linux-musl/bits/syscall.h +++ b/lib/libc/include/x86_64-linux-musl/bits/syscall.h @@ -345,6 +345,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define SYS_read 0 #define SYS_write 1 @@ -692,4 +696,8 @@ #define SYS_fsmount 432 #define SYS_fspick 433 #define SYS_pidfd_open 434 -#define SYS_clone3 435 \ No newline at end of file +#define SYS_clone3 435 +#define SYS_close_range 436 +#define SYS_openat2 437 +#define SYS_pidfd_getfd 438 +#define SYS_faccessat2 439 \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/Availability.h b/lib/libc/include/x86_64-macos-gnu/Availability.h index c81a1940fa..bdfd794d89 100644 --- a/lib/libc/include/x86_64-macos-gnu/Availability.h +++ b/lib/libc/include/x86_64-macos-gnu/Availability.h @@ -602,5 +602,4 @@ #define __SPI_DEPRECATED_WITH_REPLACEMENT(...) #endif -#endif /* __AVAILABILITY__ */ - +#endif /* __AVAILABILITY__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/AvailabilityInternal.h b/lib/libc/include/x86_64-macos-gnu/AvailabilityInternal.h index 92bbd4b36f..11e6d1ed17 100644 --- a/lib/libc/include/x86_64-macos-gnu/AvailabilityInternal.h +++ b/lib/libc/include/x86_64-macos-gnu/AvailabilityInternal.h @@ -4669,4 +4669,4 @@ #define __SPI_AVAILABLE(...) #endif -#endif /* __AVAILABILITY_INTERNAL__ */ +#endif /* __AVAILABILITY_INTERNAL__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/AvailabilityMacros.h b/lib/libc/include/x86_64-macos-gnu/AvailabilityMacros.h index 639955f2f1..9cc7100ffe 100644 --- a/lib/libc/include/x86_64-macos-gnu/AvailabilityMacros.h +++ b/lib/libc/include/x86_64-macos-gnu/AvailabilityMacros.h @@ -4010,6 +4010,4 @@ #define DEPRECATED_IN_MAC_OS_X_VERSION_10_14_4_AND_LATER #endif -#endif /* __AVAILABILITYMACROS__ */ - - +#endif /* __AVAILABILITYMACROS__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/TargetConditionals.h b/lib/libc/include/x86_64-macos-gnu/TargetConditionals.h index ca021fd11b..896956f33d 100644 --- a/lib/libc/include/x86_64-macos-gnu/TargetConditionals.h +++ b/lib/libc/include/x86_64-macos-gnu/TargetConditionals.h @@ -499,4 +499,4 @@ #endif -#endif /* __TARGETCONDITIONALS__ */ +#endif /* __TARGETCONDITIONALS__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/_ctermid.h b/lib/libc/include/x86_64-macos-gnu/_ctermid.h index 540b117622..b941ea10d4 100644 --- a/lib/libc/include/x86_64-macos-gnu/_ctermid.h +++ b/lib/libc/include/x86_64-macos-gnu/_ctermid.h @@ -24,4 +24,4 @@ #ifndef _CTERMID_H_ #define _CTERMID_H_ char *ctermid(char *); -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/bsm/audit.h b/lib/libc/include/x86_64-macos-gnu/bsm/audit.h index 2bac16e91a..e65ccbfab6 100644 --- a/lib/libc/include/x86_64-macos-gnu/bsm/audit.h +++ b/lib/libc/include/x86_64-macos-gnu/bsm/audit.h @@ -375,4 +375,4 @@ int audit_session_port(au_asid_t asid, mach_port_name_t *portname); __END_DECLS -#endif /* !_BSM_AUDIT_H */ +#endif /* !_BSM_AUDIT_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/block.h b/lib/libc/include/x86_64-macos-gnu/dispatch/block.h index 4d6f5b5489..5a28f48ce4 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/block.h +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/block.h @@ -425,4 +425,4 @@ DISPATCH_ASSUME_NONNULL_END #endif // __BLOCKS__ -#endif // __DISPATCH_BLOCK__ +#endif // __DISPATCH_BLOCK__ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/dispatch.h b/lib/libc/include/x86_64-macos-gnu/dispatch/dispatch.h index df9beb93d4..7d5356aab6 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/dispatch.h +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/dispatch.h @@ -72,4 +72,4 @@ #undef __DISPATCH_INDIRECT__ -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/group.h b/lib/libc/include/x86_64-macos-gnu/dispatch/group.h index 8d74ada2e4..bb9bad30e3 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/group.h +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/group.h @@ -276,4 +276,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/object.h b/lib/libc/include/x86_64-macos-gnu/dispatch/object.h index 7d7f0d09bb..3d89eb1fe6 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/object.h +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/object.h @@ -603,4 +603,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/queue.h b/lib/libc/include/x86_64-macos-gnu/dispatch/queue.h index 4ea1bf2eb0..f644b0266d 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/queue.h +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/queue.h @@ -1671,4 +1671,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/semaphore.h b/lib/libc/include/x86_64-macos-gnu/dispatch/semaphore.h index f5394b45dd..156fb800f3 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/semaphore.h +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/semaphore.h @@ -114,4 +114,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif /* __DISPATCH_SEMAPHORE__ */ +#endif /* __DISPATCH_SEMAPHORE__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/source.h b/lib/libc/include/x86_64-macos-gnu/dispatch/source.h index 40453fa3eb..968b9ff89e 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/source.h +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/source.h @@ -777,4 +777,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/dispatch/workloop.h b/lib/libc/include/x86_64-macos-gnu/dispatch/workloop.h index d0b17c2357..dcd1db43cc 100644 --- a/lib/libc/include/x86_64-macos-gnu/dispatch/workloop.h +++ b/lib/libc/include/x86_64-macos-gnu/dispatch/workloop.h @@ -133,4 +133,4 @@ __END_DECLS DISPATCH_ASSUME_NONNULL_END -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/_limits.h b/lib/libc/include/x86_64-macos-gnu/i386/_limits.h index 0d46e8511f..f942e7abd8 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/_limits.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/_limits.h @@ -24,4 +24,4 @@ #define __DARWIN_CLK_TCK 100 /* ticks per second */ -#endif /* _I386__LIMITS_H_ */ +#endif /* _I386__LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/_mcontext.h b/lib/libc/include/x86_64-macos-gnu/i386/_mcontext.h index ee3dfe990d..424ca21359 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/_mcontext.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/_mcontext.h @@ -209,4 +209,4 @@ typedef _STRUCT_MCONTEXT32 *mcontext_t; #endif #endif /* _MCONTEXT_T */ -#endif /* __I386_MCONTEXT_H_ */ +#endif /* __I386_MCONTEXT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/_param.h b/lib/libc/include/x86_64-macos-gnu/i386/_param.h index 3a0ac8bba7..d8f7b3d4bf 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/_param.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/_param.h @@ -43,4 +43,4 @@ #define __DARWIN_ALIGN32(p) ((__darwin_size_t)((char *)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~ __DARWIN_ALIGNBYTES32) -#endif /* _I386__PARAM_H_ */ +#endif /* _I386__PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/_types.h b/lib/libc/include/x86_64-macos-gnu/i386/_types.h index b115ed12da..9dcffa5241 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/_types.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/_types.h @@ -119,4 +119,4 @@ typedef __uint32_t __darwin_socklen_t; /* socklen_t (duh) */ typedef long __darwin_ssize_t; /* byte count or error */ typedef long __darwin_time_t; /* time() */ -#endif /* _BSD_I386__TYPES_H_ */ +#endif /* _BSD_I386__TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/eflags.h b/lib/libc/include/x86_64-macos-gnu/i386/eflags.h index 1ac8b72680..dc73c43126 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/eflags.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/eflags.h @@ -91,4 +91,4 @@ #define EFL_USER_SET (EFL_IF) #define EFL_USER_CLEAR (EFL_IOPL|EFL_NT|EFL_RF) -#endif /* _I386_EFLAGS_H_ */ +#endif /* _I386_EFLAGS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/endian.h b/lib/libc/include/x86_64-macos-gnu/i386/endian.h index 06854fe46b..95ca16e406 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/endian.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/endian.h @@ -99,4 +99,4 @@ #include #endif /* defined(KERNEL) || (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) */ -#endif /* !_I386__ENDIAN_H_ */ +#endif /* !_I386__ENDIAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/limits.h b/lib/libc/include/x86_64-macos-gnu/i386/limits.h index 9bc2e57184..651d770335 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/limits.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/limits.h @@ -104,4 +104,4 @@ #endif /* (!_POSIX_C_SOURCE && !_XOPEN_SOURCE) || _DARWIN_C_SOURCE */ #endif /* !_ANSI_SOURCE */ -#endif /* _I386_LIMITS_H_ */ +#endif /* _I386_LIMITS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/param.h b/lib/libc/include/x86_64-macos-gnu/i386/param.h index bff89a5168..e8eb8272e7 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/param.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/param.h @@ -168,4 +168,4 @@ #define DELAY(n) { int N = (n); while (--N > 0); } #endif /* defined(KERNEL) || defined(STANDALONE) */ -#endif /* _I386_PARAM_H_ */ +#endif /* _I386_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/signal.h b/lib/libc/include/x86_64-macos-gnu/i386/signal.h index 1843b79e51..cd837bb7f6 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/signal.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/signal.h @@ -40,4 +40,4 @@ typedef int sig_atomic_t; #endif /* ! _ANSI_SOURCE */ -#endif /* _I386_SIGNAL_H_ */ +#endif /* _I386_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/i386/types.h b/lib/libc/include/x86_64-macos-gnu/i386/types.h index fa219b1c7a..00dee1a917 100644 --- a/lib/libc/include/x86_64-macos-gnu/i386/types.h +++ b/lib/libc/include/x86_64-macos-gnu/i386/types.h @@ -111,4 +111,4 @@ typedef int64_t user_off_t; typedef u_int64_t syscall_arg_t; #endif /* __ASSEMBLER__ */ -#endif /* _MACHTYPES_H_ */ +#endif /* _MACHTYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomic.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomic.h index ac38f94409..37ef16ce44 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomic.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomic.h @@ -44,4 +44,4 @@ #include "OSSpinLockDeprecated.h" #include "OSAtomicQueue.h" -#endif /* _OSATOMIC_H_ */ +#endif /* _OSATOMIC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicDeprecated.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicDeprecated.h index 1b0ef91c12..aef009bc04 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicDeprecated.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicDeprecated.h @@ -1174,4 +1174,4 @@ __END_DECLS #endif // defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED -#endif /* _OSATOMIC_DEPRECATED_H_ */ +#endif /* _OSATOMIC_DEPRECATED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicQueue.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicQueue.h index 103f1e86ba..3f673861e3 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicQueue.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSAtomicQueue.h @@ -188,4 +188,4 @@ void* OSAtomicFifoDequeue( OSFifoQueueHead *__list, size_t __offset); __END_DECLS -#endif /* _OSATOMICQUEUE_H_ */ +#endif /* _OSATOMICQUEUE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSByteOrder.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSByteOrder.h index d9712031e5..25563e26e7 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/OSByteOrder.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSByteOrder.h @@ -302,4 +302,4 @@ _OSWriteInt64( #error Unknown endianess. #endif -#endif /* ! _OS_OSBYTEORDER_H */ +#endif /* ! _OS_OSBYTEORDER_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/OSSpinLockDeprecated.h b/lib/libc/include/x86_64-macos-gnu/libkern/OSSpinLockDeprecated.h index f22b14199d..a654a7bbc2 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/OSSpinLockDeprecated.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/OSSpinLockDeprecated.h @@ -209,4 +209,4 @@ __END_DECLS #endif /* OSSPINLOCK_USE_INLINED */ -#endif /* _OSSPINLOCK_DEPRECATED_H_ */ +#endif /* _OSSPINLOCK_DEPRECATED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h b/lib/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h index 89c2714b3b..06614c63ea 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/_OSByteOrder.h @@ -127,4 +127,4 @@ _OSSwapInt64( #endif /* __GNUC__ */ -#endif /* ! _OS__OSBYTEORDER_H */ +#endif /* ! _OS__OSBYTEORDER_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/i386/OSByteOrder.h b/lib/libc/include/x86_64-macos-gnu/libkern/i386/OSByteOrder.h index 84c632bb52..d6783b74e0 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/i386/OSByteOrder.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/i386/OSByteOrder.h @@ -109,4 +109,4 @@ OSWriteSwapInt64( *(volatile uint64_t *)((uintptr_t)base + byteOffset) = _OSSwapInt64(data); } -#endif /* ! _OS_OSBYTEORDERI386_H */ +#endif /* ! _OS_OSBYTEORDERI386_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/libkern/i386/_OSByteOrder.h b/lib/libc/include/x86_64-macos-gnu/libkern/i386/_OSByteOrder.h index e95c3975d4..4b160f734f 100644 --- a/lib/libc/include/x86_64-macos-gnu/libkern/i386/_OSByteOrder.h +++ b/lib/libc/include/x86_64-macos-gnu/libkern/i386/_OSByteOrder.h @@ -101,4 +101,4 @@ _OSSwapInt64( #error Unknown architecture #endif -#endif /* ! _OS__OSBYTEORDERI386_H */ +#endif /* ! _OS__OSBYTEORDERI386_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach-o/dyld.h b/lib/libc/include/x86_64-macos-gnu/mach-o/dyld.h index 4e8f31f57a..0b293cbd09 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach-o/dyld.h +++ b/lib/libc/include/x86_64-macos-gnu/mach-o/dyld.h @@ -260,4 +260,4 @@ extern const struct mach_header* _dyld_get_image_header_containing_address(cons } #endif -#endif /* _MACH_O_DYLD_H_ */ +#endif /* _MACH_O_DYLD_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach-o/loader.h b/lib/libc/include/x86_64-macos-gnu/mach-o/loader.h index a6bdbcbde3..a088105205 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach-o/loader.h +++ b/lib/libc/include/x86_64-macos-gnu/mach-o/loader.h @@ -1574,4 +1574,4 @@ struct note_command { uint64_t size; /* length of data region */ }; -#endif /* _MACHO_LOADER_H_ */ +#endif /* _MACHO_LOADER_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/_structs.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/_structs.h index c9cc8992cf..f041af9f3f 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/_structs.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/_structs.h @@ -1229,4 +1229,4 @@ _STRUCT_X86_CPMU_STATE64 }; #endif /* !__DARWIN_UNIX03 */ -#endif /* _MACH_I386__STRUCTS_H_ */ +#endif /* _MACH_I386__STRUCTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/boolean.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/boolean.h index 7023759383..d604dfcea2 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/boolean.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/boolean.h @@ -71,4 +71,4 @@ typedef unsigned int boolean_t; typedef int boolean_t; #endif -#endif /* _MACH_I386_BOOLEAN_H_ */ +#endif /* _MACH_I386_BOOLEAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/exception.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/exception.h index 44b5272d30..3f21c3d4e6 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/exception.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/exception.h @@ -132,4 +132,4 @@ */ #define EXC_MASK_MACHINE 0 -#endif /* _MACH_I386_EXCEPTION_H_ */ +#endif /* _MACH_I386_EXCEPTION_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/fp_reg.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/fp_reg.h index 3593705935..eb010ad950 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/fp_reg.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/fp_reg.h @@ -115,4 +115,4 @@ #define FP_387 3 /* 80387 or 80486 */ #define FP_FXSR 4 /* Fast save/restore SIMD Extension */ -#endif /* _I386_FP_SAVE_H_ */ +#endif /* _I386_FP_SAVE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/kern_return.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/kern_return.h index 5caefe8a6f..47aa4b8753 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/kern_return.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/kern_return.h @@ -71,4 +71,4 @@ typedef int kern_return_t; #endif /* ASSEMBLER */ -#endif /* _MACH_I386_KERN_RETURN_H_ */ +#endif /* _MACH_I386_KERN_RETURN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/processor_info.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/processor_info.h index a1930895ec..4426e0041c 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/processor_info.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/processor_info.h @@ -34,4 +34,4 @@ #ifndef _MACH_I386_PROCESSOR_INFO_H_ #define _MACH_I386_PROCESSOR_INFO_H_ -#endif /* _MACH_I386_PROCESSOR_INFO_H_ */ +#endif /* _MACH_I386_PROCESSOR_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/rpc.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/rpc.h index 396bdea32c..0298ebb804 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/rpc.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/rpc.h @@ -32,4 +32,4 @@ #ifndef _MACH_I386_RPC_H_ #define _MACH_I386_RPC_H_ -#endif /* _MACH_I386_RPC_H_ */ +#endif /* _MACH_I386_RPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_state.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_state.h index 759489dcf7..78595255a3 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_state.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_state.h @@ -39,4 +39,4 @@ #define THREAD_STATE_MAX I386_THREAD_STATE_MAX #endif -#endif /* _MACH_I386_THREAD_STATE_H_ */ +#endif /* _MACH_I386_THREAD_STATE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_status.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_status.h index 105fe352df..233e0f22a6 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_status.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/thread_status.h @@ -342,4 +342,4 @@ typedef struct x86_avx512_state x86_avx512_state_t; #define MACHINE_THREAD_STATE_COUNT x86_THREAD_STATE_COUNT -#endif /* _MACH_I386_THREAD_STATUS_H_ */ +#endif /* _MACH_I386_THREAD_STATUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_param.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_param.h index fc37cd1d80..a85ee924b7 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_param.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_param.h @@ -167,4 +167,4 @@ -#endif /* _MACH_I386_VM_PARAM_H_ */ +#endif /* _MACH_I386_VM_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_types.h b/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_types.h index f75fd05a91..8a95db53ee 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_types.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/i386/vm_types.h @@ -139,4 +139,4 @@ typedef mach_vm_address_t mach_port_context_t; */ #define MACH_MSG_TYPE_INTEGER_T MACH_MSG_TYPE_INTEGER_32 -#endif /* _MACH_I386_VM_TYPES_H_ */ +#endif /* _MACH_I386_VM_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/kern_return.h b/lib/libc/include/x86_64-macos-gnu/mach/kern_return.h index cbc29d9374..62d6415f52 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/kern_return.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/kern_return.h @@ -327,4 +327,4 @@ /* Maximum return value allowable */ -#endif /* _MACH_KERN_RETURN_H_ */ +#endif /* _MACH_KERN_RETURN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_port.h b/lib/libc/include/x86_64-macos-gnu/mach/mach_port.h index 8f587e3bfa..fcec114ccf 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_port.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/mach_port.h @@ -1805,4 +1805,4 @@ union __ReplyUnion__mach_port_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _mach_port_user_ */ +#endif /* _mach_port_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_traps.h b/lib/libc/include/x86_64-macos-gnu/mach/mach_traps.h index e38647c7a6..d3aaf577ed 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_traps.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/mach_traps.h @@ -300,4 +300,4 @@ extern kern_return_t debug_control_port_for_pid( __END_DECLS -#endif /* _MACH_MACH_TRAPS_H_ */ +#endif /* _MACH_MACH_TRAPS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/mach_types.h b/lib/libc/include/x86_64-macos-gnu/mach/mach_types.h index bd4bc3424c..0c35705acf 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/mach_types.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/mach_types.h @@ -251,4 +251,4 @@ typedef char *labelstr_t; */ #include -#endif /* _MACH_MACH_TYPES_H_ */ +#endif /* _MACH_MACH_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine.h b/lib/libc/include/x86_64-macos-gnu/mach/machine.h index a209623264..30aafcc812 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine.h @@ -392,4 +392,4 @@ typedef integer_t cpu_threadtype_t; #define CPUFAMILY_INTEL_6_26 CPUFAMILY_INTEL_NEHALEM -#endif /* _MACH_MACHINE_H_ */ +#endif /* _MACH_MACHINE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/_structs.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/_structs.h index e0bdc10828..0a61125417 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/_structs.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/_structs.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE__STRUCTS_H_ */ +#endif /* _MACH_MACHINE__STRUCTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/boolean.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/boolean.h index 6423078b8b..d373913b40 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/boolean.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/boolean.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE_BOOLEAN_H_ */ +#endif /* _MACH_MACHINE_BOOLEAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/exception.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/exception.h index 5a85bd37f3..f3e960d436 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/exception.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/exception.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE_EXCEPTION_H_ */ +#endif /* _MACH_MACHINE_EXCEPTION_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/kern_return.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/kern_return.h index 276656cbc5..b764492d29 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/kern_return.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/kern_return.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE_KERN_RETURN_H_ */ +#endif /* _MACH_MACHINE_KERN_RETURN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/processor_info.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/processor_info.h index da865d7fc5..4e5028d24d 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/processor_info.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/processor_info.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE_PROCESSOR_INFO_H_ */ +#endif /* _MACH_MACHINE_PROCESSOR_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/rpc.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/rpc.h index 196a1546d6..7d6ccee5f8 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/rpc.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/rpc.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE_RPC_H_ */ +#endif /* _MACH_MACHINE_RPC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_state.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_state.h index 7dbfecefc3..91daad8671 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_state.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_state.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE_THREAD_STATE_H_ */ +#endif /* _MACH_MACHINE_THREAD_STATE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_status.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_status.h index 1c389658b0..7e65df246e 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_status.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/thread_status.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE_THREAD_STATUS_H_ */ +#endif /* _MACH_MACHINE_THREAD_STATUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_param.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_param.h index 08f4ac5fc9..7f272f5b70 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_param.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_param.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE_VM_PARAM_H_ */ +#endif /* _MACH_MACHINE_VM_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_types.h b/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_types.h index 66cbebfda9..5d16a871ea 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_types.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/machine/vm_types.h @@ -35,4 +35,4 @@ #error architecture not supported #endif -#endif /* _MACH_MACHINE_VM_TYPES_H_ */ +#endif /* _MACH_MACHINE_VM_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/message.h b/lib/libc/include/x86_64-macos-gnu/mach/message.h index 59e9fa07fb..3f9f9a0605 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/message.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/message.h @@ -899,4 +899,4 @@ extern kern_return_t mach_voucher_deallocate( __END_DECLS -#endif /* _MACH_MESSAGE_H_ */ +#endif /* _MACH_MESSAGE_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/port.h b/lib/libc/include/x86_64-macos-gnu/mach/port.h index bd1fc19fd4..3547576e80 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/port.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/port.h @@ -419,4 +419,4 @@ typedef mach_port_name_t *port_name_array_t; #endif /* !__DARWIN_UNIX03 && !_NO_PORT_T_FROM_MACH */ -#endif /* _MACH_PORT_H_ */ +#endif /* _MACH_PORT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/processor_set.h b/lib/libc/include/x86_64-macos-gnu/mach/processor_set.h index c306155ff2..c7637d1f19 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/processor_set.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/processor_set.h @@ -537,4 +537,4 @@ union __ReplyUnion__processor_set_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _processor_set_user_ */ +#endif /* _processor_set_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/task.h b/lib/libc/include/x86_64-macos-gnu/mach/task.h index 20019654bb..5f0de2dcd5 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/task.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/task.h @@ -2520,4 +2520,4 @@ union __ReplyUnion__task_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _task_user_ */ +#endif /* _task_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/task_info.h b/lib/libc/include/x86_64-macos-gnu/mach/task_info.h index 86cfdb3492..5b2046a700 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/task_info.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/task_info.h @@ -475,4 +475,4 @@ typedef uint32_t task_exc_guard_behavior_t; #pragma pack(pop) -#endif /* _MACH_TASK_INFO_H_ */ +#endif /* _MACH_TASK_INFO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/task_policy.h b/lib/libc/include/x86_64-macos-gnu/mach/task_policy.h index 04970a5b63..4b6d3f9449 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/task_policy.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/task_policy.h @@ -186,4 +186,4 @@ typedef struct task_qos_policy *task_qos_policy_t; -#endif /* _MACH_TASK_POLICY_H_ */ +#endif /* _MACH_TASK_POLICY_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/task_special_ports.h b/lib/libc/include/x86_64-macos-gnu/mach/task_special_ports.h index ded90941a4..f8ee7c2bbf 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/task_special_ports.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/task_special_ports.h @@ -129,4 +129,4 @@ typedef int task_special_port_t; (task_set_special_port((task), TASK_DEBUG_CONTROL_PORT, (port))) -#endif /* _MACH_TASK_SPECIAL_PORTS_H_ */ +#endif /* _MACH_TASK_SPECIAL_PORTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/thread_act.h b/lib/libc/include/x86_64-macos-gnu/mach/thread_act.h index 5a21aa7e81..88561082cd 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/thread_act.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/thread_act.h @@ -1333,4 +1333,4 @@ union __ReplyUnion__thread_act_subsystem { __AfterMigUserHeader #endif /* __AfterMigUserHeader */ -#endif /* _thread_act_user_ */ +#endif /* _thread_act_user_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/thread_special_ports.h b/lib/libc/include/x86_64-macos-gnu/mach/thread_special_ports.h index 02199835a4..f777e0060c 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/thread_special_ports.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/thread_special_ports.h @@ -80,4 +80,4 @@ #define thread_set_kernel_port(thread, port) \ (thread_set_special_port((thread), THREAD_KERNEL_PORT, (port))) -#endif /* _MACH_THREAD_SPECIAL_PORTS_H_ */ +#endif /* _MACH_THREAD_SPECIAL_PORTS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/thread_status.h b/lib/libc/include/x86_64-macos-gnu/mach/thread_status.h index a91b936eba..886cae365c 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/thread_status.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/thread_status.h @@ -94,4 +94,4 @@ typedef natural_t thread_state_data_t[THREAD_STATE_MAX]; typedef int thread_state_flavor_t; typedef thread_state_flavor_t *thread_state_flavor_array_t; -#endif /* _MACH_THREAD_STATUS_H_ */ +#endif /* _MACH_THREAD_STATUS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_prot.h b/lib/libc/include/x86_64-macos-gnu/mach/vm_prot.h index 8914da2372..75812fedf6 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_prot.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/vm_prot.h @@ -149,4 +149,4 @@ typedef int vm_prot_t; #define VM_PROT_STRIP_READ ((vm_prot_t) 0x80) #define VM_PROT_EXECUTE_ONLY (VM_PROT_EXECUTE|VM_PROT_STRIP_READ) -#endif /* _MACH_VM_PROT_H_ */ +#endif /* _MACH_VM_PROT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_statistics.h b/lib/libc/include/x86_64-macos-gnu/mach/vm_statistics.h index 0a2ee5b74c..2bfd8136b4 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_statistics.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/vm_statistics.h @@ -520,4 +520,4 @@ enum virtual_memory_guard_exception_codes { -#endif /* _MACH_VM_STATISTICS_H_ */ +#endif /* _MACH_VM_STATISTICS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/mach/vm_types.h b/lib/libc/include/x86_64-macos-gnu/mach/vm_types.h index 1367f255b0..18ff9ae771 100644 --- a/lib/libc/include/x86_64-macos-gnu/mach/vm_types.h +++ b/lib/libc/include/x86_64-macos-gnu/mach/vm_types.h @@ -92,4 +92,4 @@ typedef mach_port_t vm_named_entry_t; #define UPL_NULL ((upl_t) 0) #define VM_NAMED_ENTRY_NULL ((vm_named_entry_t) 0) -#endif /* _MACH_VM_TYPES_H_ */ +#endif /* _MACH_VM_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/machine/_mcontext.h b/lib/libc/include/x86_64-macos-gnu/machine/_mcontext.h index 27ac45190e..9ccd985fcc 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/_mcontext.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/_mcontext.h @@ -29,4 +29,4 @@ #include "i386/_mcontext.h" #else #error architecture not supported -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/machine/_param.h b/lib/libc/include/x86_64-macos-gnu/machine/_param.h index c8e35a1c29..c40232c3c2 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/_param.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/_param.h @@ -29,4 +29,4 @@ #include "i386/_param.h" #else #error architecture not supported -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/machine/_types.h b/lib/libc/include/x86_64-macos-gnu/machine/_types.h index 2873a84a85..0ed6acf677 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/_types.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/_types.h @@ -34,4 +34,4 @@ #error architecture not supported #endif -#endif /* _BSD_MACHINE__TYPES_H_ */ +#endif /* _BSD_MACHINE__TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/machine/endian.h b/lib/libc/include/x86_64-macos-gnu/machine/endian.h index 4bbc8c4df8..85c8f12508 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/endian.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/endian.h @@ -37,4 +37,4 @@ #error architecture not supported #endif -#endif /* _BSD_MACHINE_ENDIAN_H_ */ +#endif /* _BSD_MACHINE_ENDIAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/machine/limits.h b/lib/libc/include/x86_64-macos-gnu/machine/limits.h index bfe42ba649..9763e810b6 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/limits.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/limits.h @@ -6,4 +6,4 @@ #include #else #error architecture not supported -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/machine/param.h b/lib/libc/include/x86_64-macos-gnu/machine/param.h index 10f8f6332e..8435acbdfb 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/param.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/param.h @@ -37,4 +37,4 @@ #error architecture not supported #endif -#endif /* _BSD_MACHINE_PARAM_H_ */ +#endif /* _BSD_MACHINE_PARAM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/machine/signal.h b/lib/libc/include/x86_64-macos-gnu/machine/signal.h index def4d744b7..19ef535ebd 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/signal.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/signal.h @@ -34,4 +34,4 @@ #error architecture not supported #endif -#endif /* _BSD_MACHINE_SIGNAL_H_ */ +#endif /* _BSD_MACHINE_SIGNAL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/machine/types.h b/lib/libc/include/x86_64-macos-gnu/machine/types.h index a991f733e5..5d1a1e575f 100644 --- a/lib/libc/include/x86_64-macos-gnu/machine/types.h +++ b/lib/libc/include/x86_64-macos-gnu/machine/types.h @@ -37,4 +37,4 @@ #error architecture not supported #endif -#endif /* _BSD_MACHINE_TYPES_H_ */ +#endif /* _BSD_MACHINE_TYPES_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/malloc/_malloc.h b/lib/libc/include/x86_64-macos-gnu/malloc/_malloc.h index c0270235da..91555d11bb 100644 --- a/lib/libc/include/x86_64-macos-gnu/malloc/_malloc.h +++ b/lib/libc/include/x86_64-macos-gnu/malloc/_malloc.h @@ -53,4 +53,4 @@ int posix_memalign(void **__memptr, size_t __alignment, size_t __size) __OSX_A __END_DECLS -#endif /* _MALLOC_UNDERSCORE_MALLOC_H_ */ +#endif /* _MALLOC_UNDERSCORE_MALLOC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/malloc/malloc.h b/lib/libc/include/x86_64-macos-gnu/malloc/malloc.h index 40e7469da3..0bddfda43b 100644 --- a/lib/libc/include/x86_64-macos-gnu/malloc/malloc.h +++ b/lib/libc/include/x86_64-macos-gnu/malloc/malloc.h @@ -311,4 +311,4 @@ extern void malloc_zone_enumerate_discharged_pointers(malloc_zone_t *zone, void __END_DECLS -#endif /* _MALLOC_MALLOC_H_ */ +#endif /* _MALLOC_MALLOC_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/math.h b/lib/libc/include/x86_64-macos-gnu/math.h index 535d7b5976..8bb019247e 100644 --- a/lib/libc/include/x86_64-macos-gnu/math.h +++ b/lib/libc/include/x86_64-macos-gnu/math.h @@ -768,4 +768,4 @@ struct exception { #endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL */ __END_DECLS -#endif /* __MATH_H__ */ +#endif /* __MATH_H__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/net/if.h b/lib/libc/include/x86_64-macos-gnu/net/if.h index 946332ff00..c0729f0eb8 100644 --- a/lib/libc/include/x86_64-macos-gnu/net/if.h +++ b/lib/libc/include/x86_64-macos-gnu/net/if.h @@ -439,4 +439,4 @@ void if_freenameindex(struct if_nameindex *); __END_DECLS -#endif /* !_NET_IF_H_ */ +#endif /* !_NET_IF_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/net/if_var.h b/lib/libc/include/x86_64-macos-gnu/net/if_var.h index 4787d9e145..6dcaa3842e 100644 --- a/lib/libc/include/x86_64-macos-gnu/net/if_var.h +++ b/lib/libc/include/x86_64-macos-gnu/net/if_var.h @@ -239,4 +239,4 @@ struct ifqueue { -#endif /* !_NET_IF_VAR_H_ */ +#endif /* !_NET_IF_VAR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/netinet/in.h b/lib/libc/include/x86_64-macos-gnu/netinet/in.h index 0fc452a587..0e921c2965 100644 --- a/lib/libc/include/x86_64-macos-gnu/netinet/in.h +++ b/lib/libc/include/x86_64-macos-gnu/netinet/in.h @@ -668,4 +668,4 @@ struct sockaddr; int bindresvport_sa(int, struct sockaddr *); __END_DECLS #endif -#endif /* _NETINET_IN_H_ */ +#endif /* _NETINET_IN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/netinet/tcp.h b/lib/libc/include/x86_64-macos-gnu/netinet/tcp.h index 4a716d498b..f089db156e 100644 --- a/lib/libc/include/x86_64-macos-gnu/netinet/tcp.h +++ b/lib/libc/include/x86_64-macos-gnu/netinet/tcp.h @@ -280,4 +280,4 @@ struct tcp_connection_info { }; #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/netinet6/in6.h b/lib/libc/include/x86_64-macos-gnu/netinet6/in6.h index fc4550f3fc..19899090ad 100644 --- a/lib/libc/include/x86_64-macos-gnu/netinet6/in6.h +++ b/lib/libc/include/x86_64-macos-gnu/netinet6/in6.h @@ -664,4 +664,4 @@ extern struct in6_addr *inet6_rth_getaddr(const void *, int); __END_DECLS #endif /* (_POSIX_C_SOURCE && !_DARWIN_C_SOURCE) */ -#endif /* !_NETINET6_IN6_H_ */ +#endif /* !_NETINET6_IN6_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/objc/objc-api.h b/lib/libc/include/x86_64-macos-gnu/objc/objc-api.h index a098b6afc8..504fee6113 100644 --- a/lib/libc/include/x86_64-macos-gnu/objc/objc-api.h +++ b/lib/libc/include/x86_64-macos-gnu/objc/objc-api.h @@ -277,4 +277,4 @@ # endif #endif -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/objc/runtime.h b/lib/libc/include/x86_64-macos-gnu/objc/runtime.h index e66756d1b4..0b49b72559 100644 --- a/lib/libc/include/x86_64-macos-gnu/objc/runtime.h +++ b/lib/libc/include/x86_64-macos-gnu/objc/runtime.h @@ -2166,4 +2166,4 @@ OBJC_EXPORT void (* _Nonnull _error)(id _Nullable, const char * _Nonnull, va_list) OBJC2_UNAVAILABLE; -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/os/base.h b/lib/libc/include/x86_64-macos-gnu/os/base.h index e8e9059272..a57f8373a4 100644 --- a/lib/libc/include/x86_64-macos-gnu/os/base.h +++ b/lib/libc/include/x86_64-macos-gnu/os/base.h @@ -322,4 +322,4 @@ typedef void (*os_function_t)(void *_Nullable); typedef void (^os_block_t)(void); #endif -#endif // __OS_BASE__ +#endif // __OS_BASE__ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/os/object.h b/lib/libc/include/x86_64-macos-gnu/os/object.h index 2979de8919..be281bcd9a 100644 --- a/lib/libc/include/x86_64-macos-gnu/os/object.h +++ b/lib/libc/include/x86_64-macos-gnu/os/object.h @@ -268,4 +268,4 @@ os_release(void *object); __END_DECLS -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/pthread.h b/lib/libc/include/x86_64-macos-gnu/pthread.h index a042c82aed..0826a7dc70 100644 --- a/lib/libc/include/x86_64-macos-gnu/pthread.h +++ b/lib/libc/include/x86_64-macos-gnu/pthread.h @@ -565,4 +565,4 @@ __END_DECLS _Pragma("clang assume_nonnull end") #endif -#endif /* _PTHREAD_H */ +#endif /* _PTHREAD_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/pthread/sched.h b/lib/libc/include/x86_64-macos-gnu/pthread/sched.h index 91efb4eae3..3c49e7980d 100644 --- a/lib/libc/include/x86_64-macos-gnu/pthread/sched.h +++ b/lib/libc/include/x86_64-macos-gnu/pthread/sched.h @@ -40,5 +40,4 @@ extern int sched_get_priority_min(int); extern int sched_get_priority_max(int); __END_DECLS -#endif /* _SCHED_H_ */ - +#endif /* _SCHED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/pthread_impl.h b/lib/libc/include/x86_64-macos-gnu/pthread_impl.h index 35d32d3021..aae74c2c03 100644 --- a/lib/libc/include/x86_64-macos-gnu/pthread_impl.h +++ b/lib/libc/include/x86_64-macos-gnu/pthread_impl.h @@ -63,4 +63,4 @@ _Pragma("clang assume_nonnull begin") _Pragma("clang assume_nonnull end") #endif -#endif /* _PTHREAD_IMPL_H_ */ +#endif /* _PTHREAD_IMPL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sched.h b/lib/libc/include/x86_64-macos-gnu/sched.h index 91efb4eae3..3c49e7980d 100644 --- a/lib/libc/include/x86_64-macos-gnu/sched.h +++ b/lib/libc/include/x86_64-macos-gnu/sched.h @@ -40,5 +40,4 @@ extern int sched_get_priority_min(int); extern int sched_get_priority_max(int); __END_DECLS -#endif /* _SCHED_H_ */ - +#endif /* _SCHED_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/signal.h b/lib/libc/include/x86_64-macos-gnu/signal.h index 94c4c1bb4d..dbc5b35f2b 100644 --- a/lib/libc/include/x86_64-macos-gnu/signal.h +++ b/lib/libc/include/x86_64-macos-gnu/signal.h @@ -126,4 +126,4 @@ __sigbits(int __signo) #define sigfillset(set) (*(set) = ~(sigset_t)0, 0) #endif /* !_ANSI_SOURCE */ -#endif /* !_USER_SIGNAL_H */ +#endif /* !_USER_SIGNAL_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/common.h b/lib/libc/include/x86_64-macos-gnu/simd/common.h index 059e852e37..4c2f4d0760 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/common.h +++ b/lib/libc/include/x86_64-macos-gnu/simd/common.h @@ -4455,4 +4455,4 @@ static inline SIMD_CFUNC double simd_reduce_max(simd_double8 x) { } #endif #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* SIMD_COMMON_HEADER */ +#endif /* SIMD_COMMON_HEADER */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/conversion.h b/lib/libc/include/x86_64-macos-gnu/simd/conversion.h index 184358e258..cc6c533e8f 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/conversion.h +++ b/lib/libc/include/x86_64-macos-gnu/simd/conversion.h @@ -1873,4 +1873,4 @@ static simd_double8 SIMD_CFUNC simd_double(simd_double8 __x) { return __builti } #endif #endif // SIMD_COMPILER_HAS_REQUIRED_FEATURES -#endif // __SIMD_CONVERSION_HEADER__ +#endif // __SIMD_CONVERSION_HEADER__ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/logic.h b/lib/libc/include/x86_64-macos-gnu/simd/logic.h index ef5b125e34..38bd9bf58c 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/logic.h +++ b/lib/libc/include/x86_64-macos-gnu/simd/logic.h @@ -1312,4 +1312,4 @@ static inline SIMD_CFUNC simd_double8 simd_bitselect(simd_double8 x, simd_double } #endif #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* __SIMD_LOGIC_HEADER__ */ +#endif /* __SIMD_LOGIC_HEADER__ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/math.h b/lib/libc/include/x86_64-macos-gnu/simd/math.h index 7443b51fc9..5e2b31cae2 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/math.h +++ b/lib/libc/include/x86_64-macos-gnu/simd/math.h @@ -5376,4 +5376,4 @@ static inline SIMD_CFUNC simd_double8 simd_muladd(simd_double8 x, simd_double8 y } /* extern "C" */ #endif #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* SIMD_MATH_HEADER */ +#endif /* SIMD_MATH_HEADER */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/packed.h b/lib/libc/include/x86_64-macos-gnu/simd/packed.h index 435608df73..dfdc199999 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/packed.h +++ b/lib/libc/include/x86_64-macos-gnu/simd/packed.h @@ -1028,4 +1028,4 @@ typedef simd_packed_double4 packed_double4; typedef simd_packed_double8 packed_double8; # endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/simd/quaternion.h b/lib/libc/include/x86_64-macos-gnu/simd/quaternion.h index a1b46be335..32158d7e8d 100644 --- a/lib/libc/include/x86_64-macos-gnu/simd/quaternion.h +++ b/lib/libc/include/x86_64-macos-gnu/simd/quaternion.h @@ -1189,4 +1189,4 @@ static SIMD_NOINLINE simd_quatd simd_bezier(simd_quatd q0, simd_quatd q1, simd_q } /* extern "C" */ #endif /* __cplusplus */ #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */ -#endif /* SIMD_QUATERNIONS */ +#endif /* SIMD_QUATERNIONS */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/spawn.h b/lib/libc/include/x86_64-macos-gnu/spawn.h index a80f4d936a..8441df3abe 100644 --- a/lib/libc/include/x86_64-macos-gnu/spawn.h +++ b/lib/libc/include/x86_64-macos-gnu/spawn.h @@ -162,4 +162,4 @@ int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *, __END_DECLS #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ -#endif /* _SPAWN_H_ */ +#endif /* _SPAWN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/stdio.h b/lib/libc/include/x86_64-macos-gnu/stdio.h index ab46f071ea..0a756d415d 100644 --- a/lib/libc/include/x86_64-macos-gnu/stdio.h +++ b/lib/libc/include/x86_64-macos-gnu/stdio.h @@ -407,4 +407,4 @@ __END_DECLS #include #endif -#endif /* _STDIO_H_ */ +#endif /* _STDIO_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/stdlib.h b/lib/libc/include/x86_64-macos-gnu/stdlib.h index 035e6c0adc..a5b61930fd 100644 --- a/lib/libc/include/x86_64-macos-gnu/stdlib.h +++ b/lib/libc/include/x86_64-macos-gnu/stdlib.h @@ -367,4 +367,4 @@ __END_DECLS #include #endif /* _USE_EXTENDED_LOCALES_ */ -#endif /* _STDLIB_H_ */ +#endif /* _STDLIB_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/string.h b/lib/libc/include/x86_64-macos-gnu/string.h index 6329c62d8b..bca8f8c881 100644 --- a/lib/libc/include/x86_64-macos-gnu/string.h +++ b/lib/libc/include/x86_64-macos-gnu/string.h @@ -190,4 +190,4 @@ __END_DECLS #include #endif -#endif /* _STRING_H_ */ +#endif /* _STRING_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_attr_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_attr_t.h index cba5882afb..a71842cb99 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_attr_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_attr_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_ATTR_T #include /* __darwin_pthread_attr_t */ typedef __darwin_pthread_attr_t pthread_attr_t; -#endif /* _PTHREAD_ATTR_T */ +#endif /* _PTHREAD_ATTR_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_cond_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_cond_t.h index b6a7b42f4a..3eceff6274 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_cond_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_cond_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_COND_T #include /* __darwin_pthread_cond_t */ typedef __darwin_pthread_cond_t pthread_cond_t; -#endif /* _PTHREAD_COND_T */ +#endif /* _PTHREAD_COND_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_condattr_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_condattr_t.h index 6e9227a8a3..7fd62badd7 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_condattr_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_condattr_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_CONDATTR_T #include /* __darwin_pthread_condattr_t */ typedef __darwin_pthread_condattr_t pthread_condattr_t; -#endif /* _PTHREAD_CONDATTR_T */ +#endif /* _PTHREAD_CONDATTR_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h index 75c4e350b4..dc1f013f3b 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlock_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_RWLOCK_T #include /* __darwin_pthread_rwlock_t */ typedef __darwin_pthread_rwlock_t pthread_rwlock_t; -#endif /* _PTHREAD_RWLOCK_T */ +#endif /* _PTHREAD_RWLOCK_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h index 6ccd234725..99fda712f4 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_rwlockattr_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_RWLOCKATTR_T #include /* __darwin_pthread_rwlockattr_t */ typedef __darwin_pthread_rwlockattr_t pthread_rwlockattr_t; -#endif /* _PTHREAD_RWLOCKATTR_T */ +#endif /* _PTHREAD_RWLOCKATTR_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_t.h index 4d9e3dac95..87f42ee9aa 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_t.h @@ -29,4 +29,4 @@ #define _PTHREAD_T #include /* __darwin_pthread_t */ typedef __darwin_pthread_t pthread_t; -#endif /* _PTHREAD_T */ +#endif /* _PTHREAD_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_types.h b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_types.h index d9d51b89ea..7aa42bdff1 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_types.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_pthread/_pthread_types.h @@ -117,4 +117,4 @@ typedef struct _opaque_pthread_rwlock_t __darwin_pthread_rwlock_t; typedef struct _opaque_pthread_rwlockattr_t __darwin_pthread_rwlockattr_t; typedef struct _opaque_pthread_t *__darwin_pthread_t; -#endif // _SYS__PTHREAD_TYPES_H_ +#endif // _SYS__PTHREAD_TYPES_H_ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_select.h b/lib/libc/include/x86_64-macos-gnu/sys/_select.h index 567d621856..70842ca2f5 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_select.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_select.h @@ -49,4 +49,4 @@ __DARWIN_ALIAS_C(select) #endif /* _DARWIN_C_SOURCE || _DARWIN_UNLIMITED_SELECT */ ; -#endif /* !_SYS__SELECT_H_ */ +#endif /* !_SYS__SELECT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h b/lib/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h index 1bbcd58ebd..17b4d6fe37 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_symbol_aliasing.h @@ -495,5 +495,4 @@ #define __DARWIN_ALIAS_STARTING_MAC___MAC_10_15_1(x) x #else #define __DARWIN_ALIAS_STARTING_MAC___MAC_10_15_1(x) -#endif - +#endif \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_def.h b/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_def.h index daadcfe6ec..ec0bad4289 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_def.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_types/_fd_def.h @@ -111,4 +111,4 @@ __darwin_fd_clr(int _fd, struct fd_set *const _p) #endif #define __DARWIN_FD_COPY(f, t) bcopy(f, t, sizeof(*(f))) -#endif /* _FD_SET */ +#endif /* _FD_SET */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int8_t.h b/lib/libc/include/x86_64-macos-gnu/sys/_types/_int8_t.h index 9176298a5f..15b281d533 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_int8_t.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_types/_int8_t.h @@ -28,4 +28,4 @@ #ifndef _INT8_T #define _INT8_T typedef __signed char int8_t; -#endif /* _INT8_T */ +#endif /* _INT8_T */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ucontext.h b/lib/libc/include/x86_64-macos-gnu/sys/_types/_ucontext.h index 65184e44e4..1e563f4581 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/_types/_ucontext.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/_types/_ucontext.h @@ -55,4 +55,4 @@ _STRUCT_UCONTEXT /* user context */ typedef _STRUCT_UCONTEXT ucontext_t; /* [???] user context */ -#endif /* _STRUCT_UCONTEXT */ +#endif /* _STRUCT_UCONTEXT */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/acl.h b/lib/libc/include/x86_64-macos-gnu/sys/acl.h index 62240bfc87..dc134613d1 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/acl.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/acl.h @@ -208,4 +208,4 @@ extern ssize_t acl_size(acl_t acl); extern char *acl_to_text(acl_t acl, ssize_t *len_p); __END_DECLS -#endif /* _SYS_ACL_H */ +#endif /* _SYS_ACL_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/attr.h b/lib/libc/include/x86_64-macos-gnu/sys/attr.h index c9b825b0ae..7de047ec5b 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/attr.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/attr.h @@ -576,4 +576,4 @@ struct searchstate { #define FST_EOF (-1) /* end-of-file offset */ #endif /* __APPLE_API_UNSTABLE */ -#endif /* !_SYS_ATTR_H_ */ +#endif /* !_SYS_ATTR_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/cdefs.h b/lib/libc/include/x86_64-macos-gnu/sys/cdefs.h index 443b7496a5..b2b091e28e 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/cdefs.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/cdefs.h @@ -852,4 +852,4 @@ typedef _type _name; enum __VA_ARGS__ __enum_closed __enum_options #endif -#endif /* !_CDEFS_H_ */ +#endif /* !_CDEFS_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/event.h b/lib/libc/include/x86_64-macos-gnu/sys/event.h index de14e54236..1fbce9a75c 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/event.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/event.h @@ -393,4 +393,4 @@ __END_DECLS -#endif /* !_SYS_EVENT_H_ */ +#endif /* !_SYS_EVENT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/fcntl.h b/lib/libc/include/x86_64-macos-gnu/sys/fcntl.h index ef0db5a3cf..9326ed0dab 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/fcntl.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/fcntl.h @@ -554,4 +554,4 @@ int filesec_unset_property(filesec_t, filesec_property_t) __OSX_AVAILABLE_ST #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ __END_DECLS -#endif /* !_SYS_FCNTL_H_ */ +#endif /* !_SYS_FCNTL_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/ioccom.h b/lib/libc/include/x86_64-macos-gnu/sys/ioccom.h index cabce8cf7e..39c6964568 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/ioccom.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/ioccom.h @@ -96,4 +96,4 @@ /* this should be _IORW, but stdio got there first */ #define _IOWR(g, n, t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) -#endif /* !_SYS_IOCCOM_H_ */ +#endif /* !_SYS_IOCCOM_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/kauth.h b/lib/libc/include/x86_64-macos-gnu/sys/kauth.h index d2f1916262..99784e35c8 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/kauth.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/kauth.h @@ -404,4 +404,4 @@ typedef struct kauth_filesec *kauth_filesec_t; #endif /* __APPLE_API_EVOLVING */ -#endif /* _SYS_KAUTH_H */ +#endif /* _SYS_KAUTH_H */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/mman.h b/lib/libc/include/x86_64-macos-gnu/sys/mman.h index 45ed2b8f8c..fec1caac71 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/mman.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/mman.h @@ -247,4 +247,4 @@ int minherit(void *, size_t, int); __END_DECLS -#endif /* !_SYS_MMAN_H_ */ +#endif /* !_SYS_MMAN_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/mount.h b/lib/libc/include/x86_64-macos-gnu/sys/mount.h index b1d5386eae..0a77b455a6 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/mount.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/mount.h @@ -420,4 +420,4 @@ int unmount(const char *, int); int getvfsbyname(const char *, struct vfsconf *); __END_DECLS -#endif /* !_SYS_MOUNT_H_ */ +#endif /* !_SYS_MOUNT_H_ */ \ No newline at end of file diff --git a/lib/libc/include/x86_64-macos-gnu/sys/param.h b/lib/libc/include/x86_64-macos-gnu/sys/param.h index e271b592b3..88330ebbe7 100644 --- a/lib/libc/include/x86_64-macos-gnu/sys/param.h +++ b/lib/libc/include/x86_64-macos-gnu/sys/param.h @@ -250,4 +250,4 @@ #define FSHIFT 11 /* bits to right of fixed binary point */ #define FSCALE (1< & __ptr64) __ptr64 +??0CPidRemapper@@QEAA@AEAV?$XInterface@UIPropertyMapper@@@@@Z +; public: __cdecl CPidRemapper::CPidRemapper(class CPidMapper const & __ptr64,class XInterface & __ptr64,class CRestriction * __ptr64,class CColumnSet * __ptr64,class CSortSet * __ptr64) __ptr64 +??0CPidRemapper@@QEAA@AEBVCPidMapper@@AEAV?$XInterface@UIPropertyMapper@@@@PEAVCRestriction@@PEAVCColumnSet@@PEAVCSortSet@@@Z +; public: __cdecl CPropListFile::CPropListFile(class CEmptyPropertyList * __ptr64,int,unsigned short const * __ptr64,unsigned long) __ptr64 +??0CPropListFile@@QEAA@PEAVCEmptyPropertyList@@HPEBGK@Z +; public: __cdecl CPropNameArray::CPropNameArray(class PDeSerStream & __ptr64) __ptr64 +??0CPropNameArray@@QEAA@AEAVPDeSerStream@@@Z +; public: __cdecl CPropNameArray::CPropNameArray(unsigned int) __ptr64 +??0CPropNameArray@@QEAA@I@Z +; public: __cdecl CPropStoreManager::CPropStoreManager(unsigned long) __ptr64 +??0CPropStoreManager@@QEAA@K@Z +; public: __cdecl CPropertyRestriction::CPropertyRestriction(unsigned long,class CFullPropSpec const & __ptr64,class CStorageVariant const & __ptr64) __ptr64 +??0CPropertyRestriction@@QEAA@KAEBVCFullPropSpec@@AEBVCStorageVariant@@@Z +; public: __cdecl CPropertyRestriction::CPropertyRestriction(void) __ptr64 +??0CPropertyRestriction@@QEAA@XZ +; public: __cdecl CPropertyStoreWids::CPropertyStoreWids(class CPropStoreManager & __ptr64) __ptr64 +??0CPropertyStoreWids@@QEAA@AEAVCPropStoreManager@@@Z +; public: __cdecl CPropertyValueParser::CPropertyValueParser(class CQueryScanner & __ptr64,unsigned short,unsigned long) __ptr64 +??0CPropertyValueParser@@QEAA@AEAVCQueryScanner@@GK@Z +; public: __cdecl CQueryScanner::CQueryScanner(unsigned short const * __ptr64,int,unsigned long,int) __ptr64 +??0CQueryScanner@@QEAA@PEBGHKH@Z +; public: __cdecl CRangeKeyRepository::CRangeKeyRepository(void) __ptr64 +??0CRangeKeyRepository@@QEAA@XZ +; public: __cdecl CRcovStrmAppendTrans::CRcovStrmAppendTrans(class PRcovStorageObj & __ptr64) __ptr64 +??0CRcovStrmAppendTrans@@QEAA@AEAVPRcovStorageObj@@@Z +; public: __cdecl CRcovStrmMDTrans::CRcovStrmMDTrans(class PRcovStorageObj & __ptr64,enum CRcovStrmMDTrans::MDOp,unsigned long) __ptr64 +??0CRcovStrmMDTrans@@QEAA@AEAVPRcovStorageObj@@W4MDOp@0@K@Z +; protected: __cdecl CRcovStrmTrans::CRcovStrmTrans(class PRcovStorageObj & __ptr64,enum RcovOpType) __ptr64 +??0CRcovStrmTrans@@IEAA@AEAVPRcovStorageObj@@W4RcovOpType@@@Z +; public: __cdecl CRegAccess::CRegAccess(unsigned long,unsigned short const * __ptr64) __ptr64 +??0CRegAccess@@QEAA@KPEBG@Z +; public: __cdecl CRegChangeEvent::CRegChangeEvent(unsigned short const * __ptr64,int) __ptr64 +??0CRegChangeEvent@@QEAA@PEBGH@Z +; public: __cdecl CRegNotify::CRegNotify(unsigned short const * __ptr64) __ptr64 +??0CRegNotify@@QEAA@PEBG@Z +; public: __cdecl CRequestClient::CRequestClient(unsigned short const * __ptr64,struct IDBProperties * __ptr64) __ptr64 +??0CRequestClient@@QEAA@PEBGPEAUIDBProperties@@@Z +; public: __cdecl CRequestQueue::CRequestQueue(unsigned int,unsigned int,unsigned int,int,unsigned int,unsigned int,struct _GUID const & __ptr64) __ptr64 +??0CRequestQueue@@QEAA@IIIHIIAEBU_GUID@@@Z +; public: __cdecl CScopeRestriction::CScopeRestriction(unsigned short const * __ptr64,int,int) __ptr64 +??0CScopeRestriction@@QEAA@PEBGHH@Z +; public: __cdecl CSdidLookupTable::CSdidLookupTable(void) __ptr64 +??0CSdidLookupTable@@QEAA@XZ +; public: __cdecl CSizeSerStream::CSizeSerStream(void) __ptr64 +??0CSizeSerStream@@QEAA@XZ +; public: __cdecl CSort::CSort(unsigned int) __ptr64 +??0CSort@@QEAA@I@Z +; public: __cdecl CSortSet::CSortSet(unsigned int) __ptr64 +??0CSortSet@@QEAA@I@Z +; public: __cdecl CStandardPropMapper::CStandardPropMapper(void) __ptr64 +??0CStandardPropMapper@@QEAA@XZ +; public: __cdecl CSvcQuery::CSvcQuery(unsigned short const * __ptr64,struct IDBProperties * __ptr64) __ptr64 +??0CSvcQuery@@QEAA@PEBGPEAUIDBProperties@@@Z +; public: __cdecl CSynRestriction::CSynRestriction(class CKey const & __ptr64,unsigned long,unsigned long,unsigned long,int) __ptr64 +??0CSynRestriction@@QEAA@AEBVCKey@@KKKH@Z +; public: __cdecl CTimeLimit::CTimeLimit(unsigned long,unsigned long) __ptr64 +??0CTimeLimit@@QEAA@KK@Z +; public: __cdecl CTransaction::CTransaction(void) __ptr64 +??0CTransaction@@QEAA@XZ +; public: __cdecl CUnfilteredRestriction::CUnfilteredRestriction(void) __ptr64 +??0CUnfilteredRestriction@@QEAA@XZ +; public: __cdecl CValueNormalizer::CValueNormalizer(class PKeyRepository & __ptr64) __ptr64 +??0CValueNormalizer@@QEAA@AEAVPKeyRepository@@@Z +; public: __cdecl CVirtualString::CVirtualString(unsigned int) __ptr64 +??0CVirtualString@@QEAA@I@Z +; public: __cdecl CWin32RegAccess::CWin32RegAccess(struct HKEY__ * __ptr64,unsigned short const * __ptr64) __ptr64 +??0CWin32RegAccess@@QEAA@PEAUHKEY__@@PEBG@Z +; public: __cdecl CWordRestriction::CWordRestriction(class CKeyBuf const & __ptr64,unsigned long,unsigned long,unsigned long,int) __ptr64 +??0CWordRestriction@@QEAA@AEBVCKeyBuf@@KKKH@Z +; public: __cdecl CWorkQueue::CWorkQueue(unsigned int,enum CWorkQueue::WorkQueueType) __ptr64 +??0CWorkQueue@@QEAA@IW4WorkQueueType@0@@Z +; public: __cdecl CiStorage::CiStorage(unsigned short const * __ptr64,struct ICiCAdviseStatus & __ptr64,unsigned long,unsigned long,int) __ptr64 +??0CiStorage@@QEAA@PEBGAEAUICiCAdviseStatus@@KKH@Z +; public: __cdecl SStorageObject::SStorageObject(class PStorageObject * __ptr64) __ptr64 +??0SStorageObject@@QEAA@PEAVPStorageObject@@@Z +; protected: __cdecl CAllocStorageVariant::~CAllocStorageVariant(void) __ptr64 +??1CAllocStorageVariant@@IEAA@XZ +; public: __cdecl CCatState::~CCatState(void) __ptr64 +??1CCatState@@QEAA@XZ +; public: __cdecl CCatalogAdmin::~CCatalogAdmin(void) __ptr64 +??1CCatalogAdmin@@QEAA@XZ +; public: __cdecl CCatalogEnum::~CCatalogEnum(void) __ptr64 +??1CCatalogEnum@@QEAA@XZ +; public: __cdecl CColumns::~CColumns(void) __ptr64 +??1CColumns@@QEAA@XZ +; public: __cdecl CContentRestriction::~CContentRestriction(void) __ptr64 +??1CContentRestriction@@QEAA@XZ +; public: __cdecl CDFA::~CDFA(void) __ptr64 +??1CDFA@@QEAA@XZ +; public: __cdecl CDbCmdTreeNode::~CDbCmdTreeNode(void) __ptr64 +??1CDbCmdTreeNode@@QEAA@XZ +; public: __cdecl CDbColumns::~CDbColumns(void) __ptr64 +??1CDbColumns@@QEAA@XZ +; public: __cdecl CDbPropSet::~CDbPropSet(void) __ptr64 +??1CDbPropSet@@QEAA@XZ +; public: __cdecl CDbQueryResults::~CDbQueryResults(void) __ptr64 +??1CDbQueryResults@@QEAA@XZ +; public: __cdecl CDbSortSet::~CDbSortSet(void) __ptr64 +??1CDbSortSet@@QEAA@XZ +; public: __cdecl CDynStream::~CDynStream(void) __ptr64 +??1CDynStream@@QEAA@XZ +; public: __cdecl CEventItem::~CEventItem(void) __ptr64 +??1CEventItem@@QEAA@XZ +; public: __cdecl CEventLog::~CEventLog(void) __ptr64 +??1CEventLog@@QEAA@XZ +; public: __cdecl CFileMapView::~CFileMapView(void) __ptr64 +??1CFileMapView@@QEAA@XZ +; public: __cdecl CFilterDaemon::~CFilterDaemon(void) __ptr64 +??1CFilterDaemon@@QEAA@XZ +; public: virtual __cdecl CFwAsyncWorkItem::~CFwAsyncWorkItem(void) __ptr64 +??1CFwAsyncWorkItem@@UEAA@XZ +; public: __cdecl CFwEventItem::~CFwEventItem(void) __ptr64 +??1CFwEventItem@@QEAA@XZ +; public: virtual __cdecl CGenericCiProxy::~CGenericCiProxy(void) __ptr64 +??1CGenericCiProxy@@UEAA@XZ +; public: __cdecl CImpersonateClient::~CImpersonateClient(void) __ptr64 +??1CImpersonateClient@@QEAA@XZ +; public: __cdecl CImpersonateSystem::~CImpersonateSystem(void) __ptr64 +??1CImpersonateSystem@@QEAA@XZ +; public: __cdecl CImpersonationTokenCache::~CImpersonationTokenCache(void) __ptr64 +??1CImpersonationTokenCache@@QEAA@XZ +; public: __cdecl CInternalPropertyRestriction::~CInternalPropertyRestriction(void) __ptr64 +??1CInternalPropertyRestriction@@QEAA@XZ +; public: __cdecl CKeyArray::~CKeyArray(void) __ptr64 +??1CKeyArray@@QEAA@XZ +; public: __cdecl CLangList::~CLangList(void) __ptr64 +??1CLangList@@QEAA@XZ +; public: __cdecl CMachineAdmin::~CMachineAdmin(void) __ptr64 +??1CMachineAdmin@@QEAA@XZ +; public: virtual __cdecl CMemSerStream::~CMemSerStream(void) __ptr64 +??1CMemSerStream@@UEAA@XZ +; public: __cdecl CMetaDataMgr::~CMetaDataMgr(void) __ptr64 +??1CMetaDataMgr@@QEAA@XZ +; public: virtual __cdecl CMmStream::~CMmStream(void) __ptr64 +??1CMmStream@@UEAA@XZ +; public: __cdecl CMmStreamConsecBuf::~CMmStreamConsecBuf(void) __ptr64 +??1CMmStreamConsecBuf@@QEAA@XZ +; public: __cdecl CNatLanguageRestriction::~CNatLanguageRestriction(void) __ptr64 +??1CNatLanguageRestriction@@QEAA@XZ +; public: __cdecl CNodeRestriction::~CNodeRestriction(void) __ptr64 +??1CNodeRestriction@@QEAA@XZ +; public: __cdecl CNotRestriction::~CNotRestriction(void) __ptr64 +??1CNotRestriction@@QEAA@XZ +; public: __cdecl COccRestriction::~COccRestriction(void) __ptr64 +??1COccRestriction@@QEAA@XZ +; public: __cdecl CParseCommandTree::~CParseCommandTree(void) __ptr64 +??1CParseCommandTree@@QEAA@XZ +; public: __cdecl CPerfMon::~CPerfMon(void) __ptr64 +??1CPerfMon@@QEAA@XZ +; public: __cdecl CPhraseRestriction::~CPhraseRestriction(void) __ptr64 +??1CPhraseRestriction@@QEAA@XZ +; public: virtual __cdecl CPhysStorage::~CPhysStorage(void) __ptr64 +??1CPhysStorage@@UEAA@XZ +; public: __cdecl CPidLookupTable::~CPidLookupTable(void) __ptr64 +??1CPidLookupTable@@QEAA@XZ +; public: __cdecl CPidRemapper::~CPidRemapper(void) __ptr64 +??1CPidRemapper@@QEAA@XZ +; public: __cdecl CProcess::~CProcess(void) __ptr64 +??1CProcess@@QEAA@XZ +; public: __cdecl CPropStoreManager::~CPropStoreManager(void) __ptr64 +??1CPropStoreManager@@QEAA@XZ +; public: virtual __cdecl CPropertyList::~CPropertyList(void) __ptr64 +??1CPropertyList@@UEAA@XZ +; public: __cdecl CPropertyRestriction::~CPropertyRestriction(void) __ptr64 +??1CPropertyRestriction@@QEAA@XZ +; public: __cdecl CPropertyStore::~CPropertyStore(void) __ptr64 +??1CPropertyStore@@QEAA@XZ +; public: __cdecl CPropertyStoreWids::~CPropertyStoreWids(void) __ptr64 +??1CPropertyStoreWids@@QEAA@XZ +; public: __cdecl CQueryUnknown::~CQueryUnknown(void) __ptr64 +??1CQueryUnknown@@QEAA@XZ +; public: virtual __cdecl CRangeKeyRepository::~CRangeKeyRepository(void) __ptr64 +??1CRangeKeyRepository@@UEAA@XZ +; public: __cdecl CRegChangeEvent::~CRegChangeEvent(void) __ptr64 +??1CRegChangeEvent@@QEAA@XZ +; protected: virtual __cdecl CRegNotify::~CRegNotify(void) __ptr64 +??1CRegNotify@@MEAA@XZ +; public: __cdecl CRestriction::~CRestriction(void) __ptr64 +??1CRestriction@@QEAA@XZ +; public: __cdecl CScopeAdmin::~CScopeAdmin(void) __ptr64 +??1CScopeAdmin@@QEAA@XZ +; public: __cdecl CScopeEnum::~CScopeEnum(void) __ptr64 +??1CScopeEnum@@QEAA@XZ +; public: __cdecl CScopeRestriction::~CScopeRestriction(void) __ptr64 +??1CScopeRestriction@@QEAA@XZ +; public: __cdecl CSdidLookupTable::~CSdidLookupTable(void) __ptr64 +??1CSdidLookupTable@@QEAA@XZ +; public: virtual __cdecl CSizeSerStream::~CSizeSerStream(void) __ptr64 +??1CSizeSerStream@@UEAA@XZ +; public: __cdecl CSort::~CSort(void) __ptr64 +??1CSort@@QEAA@XZ +; public: __cdecl CSynRestriction::~CSynRestriction(void) __ptr64 +??1CSynRestriction@@QEAA@XZ +; public: __cdecl CVirtualString::~CVirtualString(void) __ptr64 +??1CVirtualString@@QEAA@XZ +; public: __cdecl CWin32RegAccess::~CWin32RegAccess(void) __ptr64 +??1CWin32RegAccess@@QEAA@XZ +; public: __cdecl CWordRestriction::~CWordRestriction(void) __ptr64 +??1CWordRestriction@@QEAA@XZ +; public: __cdecl CWorkManager::~CWorkManager(void) __ptr64 +??1CWorkManager@@QEAA@XZ +; public: __cdecl CWorkQueue::~CWorkQueue(void) __ptr64 +??1CWorkQueue@@QEAA@XZ +; public: __cdecl SStorageObject::~SStorageObject(void) __ptr64 +??1SStorageObject@@QEAA@XZ +; public: class CDbColId & __ptr64 __cdecl CDbColId::operator=(class CDbColId const & __ptr64) __ptr64 +??4CDbColId@@QEAAAEAV0@AEBV0@@Z +; public: int __cdecl CDbColId::operator==(class CDbColId const & __ptr64)const __ptr64 +??8CDbColId@@QEBAHAEBV0@@Z +; public: void __cdecl CWorkManager::AbortWorkItems(void) __ptr64 +?AbortWorkItems@CWorkManager@@QEAAXXZ +; public: void __cdecl CQueryScanner::Accept(void) __ptr64 +?Accept@CQueryScanner@@QEAAXXZ +; public: void __cdecl CQueryScanner::AcceptCommand(void) __ptr64 +?AcceptCommand@CQueryScanner@@QEAAXXZ +; public: void __cdecl CQueryScanner::AcceptWord(void) __ptr64 +?AcceptWord@CQueryScanner@@QEAAXXZ +; public: int __cdecl CSdidLookupTable::AccessCheck(unsigned long,void * __ptr64,unsigned long,int & __ptr64) __ptr64 +?AccessCheck@CSdidLookupTable@@QEAAHKPEAXKAEAH@Z +; public: unsigned short * __ptr64 __cdecl CQueryScanner::AcqLine(int) __ptr64 +?AcqLine@CQueryScanner@@QEAAPEAGH@Z +; public: unsigned short * __ptr64 __cdecl CQueryScanner::AcqPath(void) __ptr64 +?AcqPath@CQueryScanner@@QEAAPEAGXZ +; public: unsigned short * __ptr64 __cdecl CQueryScanner::AcqPhrase(void) __ptr64 +?AcqPhrase@CQueryScanner@@QEAAPEAGXZ +; public: class CRangeRestriction * __ptr64 __cdecl CRangeKeyRepository::AcqRst(void) __ptr64 +?AcqRst@CRangeKeyRepository@@QEAAPEAVCRangeRestriction@@XZ +; public: unsigned short * __ptr64 __cdecl CQueryScanner::AcqWord(void) __ptr64 +?AcqWord@CQueryScanner@@QEAAPEAGXZ +; private: void __cdecl CPropertyStore::AcquireRead(class CReadWriteLockRecord & __ptr64) __ptr64 +?AcquireRead@CPropertyStore@@AEAAXAEAVCReadWriteLockRecord@@@Z +; public: int __cdecl CDbColumns::Add(class CDbColId const & __ptr64,unsigned int) __ptr64 +?Add@CDbColumns@@QEAAHAEBVCDbColId@@I@Z +; public: void __cdecl CDbQueryResults::Add(unsigned short * __ptr64,unsigned long) __ptr64 +?Add@CDbQueryResults@@QEAAXPEAGK@Z +; public: int __cdecl CDbSortSet::Add(class CDbColId const & __ptr64,unsigned long,unsigned int) __ptr64 +?Add@CDbSortSet@@QEAAHAEBVCDbColId@@KI@Z +; public: int __cdecl CDbSortSet::Add(class CDbSortKey const & __ptr64,unsigned int) __ptr64 +?Add@CDbSortSet@@QEAAHAEBVCDbSortKey@@I@Z +; public: int __cdecl CKeyArray::Add(int,class CKey const & __ptr64) __ptr64 +?Add@CKeyArray@@QEAAHHAEBVCKey@@@Z +; public: int __cdecl CKeyArray::Add(int,class CKeyBuf const & __ptr64) __ptr64 +?Add@CKeyArray@@QEAAHHAEBVCKeyBuf@@@Z +; public: void __cdecl CWorkQueue::Add(class PWorkItem * __ptr64) __ptr64 +?Add@CWorkQueue@@QEAAXPEAVPWorkItem@@@Z +; public: void __cdecl CEventItem::AddArg(unsigned long) __ptr64 +?AddArg@CEventItem@@QEAAXK@Z +; public: void __cdecl CEventItem::AddArg(unsigned short const * __ptr64) __ptr64 +?AddArg@CEventItem@@QEAAXPEBG@Z +; public: void __cdecl CFwEventItem::AddArg(unsigned long) __ptr64 +?AddArg@CFwEventItem@@QEAAXK@Z +; public: void __cdecl CFwEventItem::AddArg(unsigned short const * __ptr64) __ptr64 +?AddArg@CFwEventItem@@QEAAXPEBG@Z +; public: void __cdecl CCatalogAdmin::AddCachedProperty(class CFullPropSpec const & __ptr64,unsigned long,unsigned long,unsigned long,int) __ptr64 +?AddCachedProperty@CCatalogAdmin@@QEAAXAEBVCFullPropSpec@@KKKH@Z +; public: void __cdecl CCatState::AddCatalog(class XPtrST & __ptr64) __ptr64 +?AddCatalog@CCatState@@QEAAXAEAV?$XPtrST@G@@@Z +; public: void __cdecl CMachineAdmin::AddCatalog(unsigned short const * __ptr64,unsigned short const * __ptr64) __ptr64 +?AddCatalog@CMachineAdmin@@QEAAXPEBG0@Z +; public: void __cdecl CNodeRestriction::AddChild(class CRestriction * __ptr64,unsigned int & __ptr64) __ptr64 +?AddChild@CNodeRestriction@@QEAAXPEAVCRestriction@@AEAI@Z +; public: void __cdecl CCatState::AddDir(class XPtrST & __ptr64) __ptr64 +?AddDir@CCatState@@QEAAXAEAV?$XPtrST@G@@@Z +; public: virtual void __cdecl CPropertyList::AddEntry(class CPropEntry * __ptr64,int) __ptr64 +?AddEntry@CPropertyList@@UEAAXPEAVCPropEntry@@H@Z +; public: void __cdecl CEventItem::AddError(unsigned long) __ptr64 +?AddError@CEventItem@@QEAAXK@Z +; public: void __cdecl CSynRestriction::AddKey(class CKeyBuf const & __ptr64) __ptr64 +?AddKey@CSynRestriction@@QEAAXAEBVCKeyBuf@@@Z +; public: void __cdecl CCatState::AddMachine(class XPtrST & __ptr64) __ptr64 +?AddMachine@CCatState@@QEAAXAEAV?$XPtrST@G@@@Z +; public: virtual unsigned long __cdecl CDbProperties::AddRef(void) __ptr64 +?AddRef@CDbProperties@@UEAAKXZ +; public: virtual unsigned long __cdecl CEmptyPropertyList::AddRef(void) __ptr64 +?AddRef@CEmptyPropertyList@@UEAAKXZ +; public: virtual unsigned long __cdecl CEnumString::AddRef(void) __ptr64 +?AddRef@CEnumString@@UEAAKXZ +; public: virtual unsigned long __cdecl CEnumWorkid::AddRef(void) __ptr64 +?AddRef@CEnumWorkid@@UEAAKXZ +; public: virtual unsigned long __cdecl CFwPropertyMapper::AddRef(void) __ptr64 +?AddRef@CFwPropertyMapper@@UEAAKXZ +; public: virtual unsigned long __cdecl CQueryUnknown::AddRef(void) __ptr64 +?AddRef@CQueryUnknown@@UEAAKXZ +; public: void __cdecl CWorkQueue::AddRefWorkThreads(void) __ptr64 +?AddRefWorkThreads@CWorkQueue@@QEAAXXZ +; public: void __cdecl CCatalogAdmin::AddScope(unsigned short const * __ptr64,unsigned short const * __ptr64,int,unsigned short const * __ptr64,unsigned short const * __ptr64) __ptr64 +?AddScope@CCatalogAdmin@@QEAAXPEBG0H00@Z +; public: int __cdecl CDbSortNode::AddSortColumn(struct tagDBID const & __ptr64,int,unsigned long) __ptr64 +?AddSortColumn@CDbSortNode@@QEAAHAEBUtagDBID@@HK@Z +; public: int __cdecl CDbNestingNode::AddTable(class CDbCmdTreeNode * __ptr64) __ptr64 +?AddTable@CDbNestingNode@@QEAAHPEAVCDbCmdTreeNode@@@Z +; public: void __cdecl CWorkManager::AddToWorkList(class CFwAsyncWorkItem * __ptr64) __ptr64 +?AddToWorkList@CWorkManager@@QEAAXPEAVCFwAsyncWorkItem@@@Z +; public: void __cdecl CFwAsyncWorkItem::AddToWorkQueue(void) __ptr64 +?AddToWorkQueue@CFwAsyncWorkItem@@QEAAXXZ +; public: static unsigned short * __ptr64 __cdecl CDbCmdTreeNode::AllocAndCopyWString(unsigned short const * __ptr64) +?AllocAndCopyWString@CDbCmdTreeNode@@SAPEAGPEBG@Z +; unsigned short * __ptr64 __cdecl AllocHeapAndCopy(unsigned short const * __ptr64,unsigned long & __ptr64) +?AllocHeapAndCopy@@YAPEAGPEBGAEAK@Z +; unsigned short * __ptr64 __cdecl AllocHeapAndGetWString(class PDeSerStream & __ptr64) +?AllocHeapAndGetWString@@YAPEAGAEAVPDeSerStream@@@Z +; public: void __cdecl CEnumString::Append(unsigned short const * __ptr64) __ptr64 +?Append@CEnumString@@QEAAXPEBG@Z +; public: void __cdecl CEnumWorkid::Append(unsigned long) __ptr64 +?Append@CEnumWorkid@@QEAAXK@Z +; protected: void __cdecl CDbCmdTreeNode::AppendChild(class CDbCmdTreeNode * __ptr64) __ptr64 +?AppendChild@CDbCmdTreeNode@@IEAAXPEAV1@@Z +; protected: int __cdecl CDbListAnchor::AppendListElement(unsigned short,struct tagDBID const & __ptr64) __ptr64 +?AppendListElement@CDbListAnchor@@IEAAHGAEBUtagDBID@@@Z +; protected: int __cdecl CDbListAnchor::AppendListElement(class CDbCmdTreeNode * __ptr64) __ptr64 +?AppendListElement@CDbListAnchor@@IEAAHPEAVCDbCmdTreeNode@@@Z +; public: int __cdecl CDbProjectListAnchor::AppendListElement(struct tagDBID const & __ptr64,unsigned short * __ptr64) __ptr64 +?AppendListElement@CDbProjectListAnchor@@QEAAHAEBUtagDBID@@PEAG@Z +; public: unsigned __int64 __cdecl CPropStoreManager::BeginTransaction(void) __ptr64 +?BeginTransaction@CPropStoreManager@@QEAA_KXZ +; public: static long __cdecl CCiOle::BindIFilter(unsigned short const * __ptr64,struct IUnknown * __ptr64,struct _GUID const & __ptr64,struct IFilter * __ptr64 * __ptr64,int) +?BindIFilter@CCiOle@@SAJPEBGPEAUIUnknown@@AEBU_GUID@@PEAPEAUIFilter@@H@Z +; public: static long __cdecl CCiOle::BindIFilter(unsigned short const * __ptr64,struct IUnknown * __ptr64,struct IFilter * __ptr64 * __ptr64,int) +?BindIFilter@CCiOle@@SAJPEBGPEAUIUnknown@@PEAPEAUIFilter@@H@Z +; public: unsigned long * __ptr64 __cdecl CPhysStorage::BorrowBuffer(unsigned long,int,int) __ptr64 +?BorrowBuffer@CPhysStorage@@QEAAPEAKKHH@Z +; public: unsigned long * __ptr64 __cdecl CPhysStorage::BorrowNewBuffer(unsigned long) __ptr64 +?BorrowNewBuffer@CPhysStorage@@QEAAPEAKK@Z +; void __cdecl BuildRegistryPropertiesKey(class XArray & __ptr64,unsigned short const * __ptr64) +?BuildRegistryPropertiesKey@@YAXAEAV?$XArray@G@@PEBG@Z +; void __cdecl BuildRegistryScopesKey(class XArray & __ptr64,unsigned short const * __ptr64) +?BuildRegistryScopesKey@@YAXAEAV?$XArray@G@@PEBG@Z +; void __cdecl CIShutdown(void) +?CIShutdown@@YAXXZ +; public: void __cdecl CCatState::ChangeCurrentCatalog(unsigned short const * __ptr64) __ptr64 +?ChangeCurrentCatalog@CCatState@@QEAAXPEBG@Z +; public: void __cdecl CCatState::ChangeCurrentDepth(int) __ptr64 +?ChangeCurrentDepth@CCatState@@QEAAXH@Z +; public: void __cdecl CCatState::ChangeCurrentMachine(unsigned short const * __ptr64) __ptr64 +?ChangeCurrentMachine@CCatState@@QEAAXPEBG@Z +; public: void __cdecl CCatState::ChangeCurrentScope(unsigned short const * __ptr64) __ptr64 +?ChangeCurrentScope@CCatState@@QEAAXPEBG@Z +; private: void __cdecl CPropStoreInfo::ChangeDirty(int) __ptr64 +?ChangeDirty@CPropStoreInfo@@AEAAXH@Z +; public: long __cdecl CLocalGlobalPropertyList::CheckError(unsigned long & __ptr64,unsigned short * __ptr64 * __ptr64) __ptr64 +?CheckError@CLocalGlobalPropertyList@@QEAAJAEAKPEAPEAG@Z +; public: long __cdecl CPropListFile::CheckError(unsigned long & __ptr64,unsigned short * __ptr64 * __ptr64) __ptr64 +?CheckError@CPropListFile@@QEAAJAEAKPEAPEAG@Z +; public: static int __cdecl CiStorage::CheckHasIndexTable(unsigned short const * __ptr64) +?CheckHasIndexTable@CiStorage@@SAHPEBG@Z +CiCreateSecurityDescriptor +; int __cdecl CiGetPassword(unsigned short const * __ptr64,unsigned short const * __ptr64,unsigned short * __ptr64) +?CiGetPassword@@YAHPEBG0PEAG@Z +; void * __ptr64 __cdecl CiNtOpen(unsigned short const * __ptr64,unsigned long,unsigned long,unsigned long) +?CiNtOpen@@YAPEAXPEBGKKK@Z +; long __cdecl CiNtOpenNoThrow(void * __ptr64 & __ptr64,unsigned short const * __ptr64,unsigned long,unsigned long,unsigned long) +?CiNtOpenNoThrow@@YAJAEAPEAXPEBGKKK@Z +; public: void __cdecl CDbColId::Cleanup(void) __ptr64 +?Cleanup@CDbColId@@QEAAXXZ +; protected: void __cdecl CDbCmdTreeNode::CleanupDataValue(void) __ptr64 +?CleanupDataValue@CDbCmdTreeNode@@IEAAXXZ +; public: void __cdecl CCombinedPropertyList::ClearList(void) __ptr64 +?ClearList@CCombinedPropertyList@@QEAAXXZ +; public: void __cdecl CPropertyList::ClearList(void) __ptr64 +?ClearList@CPropertyList@@QEAAXXZ +; public: class CDbCmdTreeNode * __ptr64 __cdecl CDbCmdTreeNode::Clone(int)const __ptr64 +?Clone@CDbCmdTreeNode@@QEBAPEAV1@H@Z +; public: virtual long __cdecl CEnumString::Clone(struct IEnumString * __ptr64 * __ptr64) __ptr64 +?Clone@CEnumString@@UEAAJPEAPEAUIEnumString@@@Z +; public: class CNodeRestriction * __ptr64 __cdecl CNodeRestriction::Clone(void)const __ptr64 +?Clone@CNodeRestriction@@QEBAPEAV1@XZ +; public: class COccRestriction * __ptr64 __cdecl COccRestriction::Clone(void)const __ptr64 +?Clone@COccRestriction@@QEBAPEAV1@XZ +; public: class CRestriction * __ptr64 __cdecl CRestriction::Clone(void)const __ptr64 +?Clone@CRestriction@@QEBAPEAV1@XZ +; public: void __cdecl CPhysStorage::Close(void) __ptr64 +?Close@CPhysStorage@@QEAAXXZ +; protected: void __cdecl CPipeClient::Close(void) __ptr64 +?Close@CPipeClient@@IEAAXXZ +; public: void __cdecl COLEPropManager::CPropSetMap::Close(void) __ptr64 +?Close@CPropSetMap@COLEPropManager@@QEAAXXZ +; public: void __cdecl CPropStoreManager::CloseRecord(class CCompositePropRecord * __ptr64) __ptr64 +?CloseRecord@CPropStoreManager@@QEAAXPEAVCCompositePropRecord@@@Z +; public: void __cdecl CPropStoreManager::CloseRecord(class CCompositePropRecordForWrites * __ptr64) __ptr64 +?CloseRecord@CPropStoreManager@@QEAAXPEAVCCompositePropRecordForWrites@@@Z +; public: void __cdecl CRcovStrmAppendTrans::Commit(void) __ptr64 +?Commit@CRcovStrmAppendTrans@@QEAAXXZ +; public: void __cdecl CRcovStrmMDTrans::Commit(void) __ptr64 +?Commit@CRcovStrmMDTrans@@QEAAXXZ +; public: void __cdecl CRcovStrmWriteTrans::Commit(void) __ptr64 +?Commit@CRcovStrmWriteTrans@@QEAAXXZ +; public: static int __cdecl CDriveInfo::ContainsDrive(unsigned short const * __ptr64) +?ContainsDrive@CDriveInfo@@SAHPEBG@Z +; public: void __cdecl CMachineAdmin::CreateSubdirs(unsigned short const * __ptr64) __ptr64 +?CreateSubdirs@CMachineAdmin@@QEAAXPEBG@Z +; public: void __cdecl CRequestClient::DataWriteRead(void * __ptr64,unsigned long,void * __ptr64,unsigned long,unsigned long & __ptr64) __ptr64 +?DataWriteRead@CRequestClient@@QEAAXPEAXK0KAEAK@Z +; void __cdecl DecodeEscapes(unsigned short * __ptr64,unsigned long & __ptr64,unsigned short * __ptr64) +?DecodeEscapes@@YAXPEAGAEAK0@Z +; void __cdecl DecodeHtmlNumeric(unsigned short * __ptr64) +?DecodeHtmlNumeric@@YAXPEAG@Z +; void __cdecl DecodeURLEscapes(unsigned char * __ptr64,unsigned long & __ptr64,unsigned short * __ptr64,unsigned long) +?DecodeURLEscapes@@YAXPEAEAEAKPEAGK@Z +; public: void __cdecl CPropStoreManager::DeleteRecord(unsigned long) __ptr64 +?DeleteRecord@CPropStoreManager@@QEAAXK@Z +; public: void __cdecl CCatalogAdmin::DeleteRegistryParamNoThrow(unsigned short const * __ptr64) __ptr64 +?DeleteRegistryParamNoThrow@CCatalogAdmin@@QEAAXPEBG@Z +; public: static unsigned int __cdecl CiStorage::DetermineDriveType(unsigned short const * __ptr64) +?DetermineDriveType@CiStorage@@SAIPEBG@Z +; public: int __cdecl CMachineAdmin::DisableCI(void) __ptr64 +?DisableCI@CMachineAdmin@@QEAAHXZ +; public: void __cdecl CRegNotify::DisableNotification(void) __ptr64 +?DisableNotification@CRegNotify@@QEAAXXZ +; public: void __cdecl CMetaDataMgr::DisableVPathNotify(void) __ptr64 +?DisableVPathNotify@CMetaDataMgr@@QEAAXXZ +; public: void __cdecl CRequestClient::Disconnect(void) __ptr64 +?Disconnect@CRequestClient@@QEAAXXZ +; public: long __cdecl CCopyRcovObject::DoIt(void) __ptr64 +?DoIt@CCopyRcovObject@@QEAAJXZ +; public: long __cdecl CFilterDaemon::DoUpdates(void) __ptr64 +?DoUpdates@CFilterDaemon@@QEAAJXZ +; public: void __cdecl CFwAsyncWorkItem::Done(void) __ptr64 +?Done@CFwAsyncWorkItem@@QEAAXXZ +; long __cdecl DumpWorkId(unsigned short const * __ptr64,unsigned long,unsigned char * __ptr64,unsigned long & __ptr64,unsigned short const * __ptr64,unsigned short const * __ptr64,unsigned long) +?DumpWorkId@@YAJPEBGKPEAEAEAK00K@Z +; public: void __cdecl CPidLookupTable::Empty(void) __ptr64 +?Empty@CPidLookupTable@@QEAAXXZ +; public: void __cdecl CPropStoreManager::Empty(void) __ptr64 +?Empty@CPropStoreManager@@QEAAXXZ +; public: void __cdecl CRcovStrmWriteTrans::Empty(void) __ptr64 +?Empty@CRcovStrmWriteTrans@@QEAAXXZ +; public: void __cdecl CSdidLookupTable::Empty(void) __ptr64 +?Empty@CSdidLookupTable@@QEAAXXZ +; public: int __cdecl CMachineAdmin::EnableCI(void) __ptr64 +?EnableCI@CMachineAdmin@@QEAAHXZ +; public: void __cdecl CMetaDataMgr::EnableVPathNotify(class CMetaDataVPathChangeCallBack * __ptr64) __ptr64 +?EnableVPathNotify@CMetaDataMgr@@QEAAXPEAVCMetaDataVPathChangeCallBack@@@Z +; public: void __cdecl CPropStoreManager::EndTransaction(unsigned __int64,int,unsigned long,unsigned long) __ptr64 +?EndTransaction@CPropStoreManager@@QEAAX_KHKK@Z +; public: int __cdecl CWin32RegAccess::Enum(unsigned short * __ptr64,unsigned long) __ptr64 +?Enum@CWin32RegAccess@@QEAAHPEAGK@Z +; public: virtual long __cdecl CEmptyPropertyList::EnumPropInfo(unsigned long,unsigned short const * __ptr64 * __ptr64,struct tagDBID * __ptr64 * __ptr64,unsigned short * __ptr64,unsigned int * __ptr64) __ptr64 +?EnumPropInfo@CEmptyPropertyList@@UEAAJKPEAPEBGPEAPEAUtagDBID@@PEAGPEAI@Z +; public: void __cdecl CMetaDataMgr::EnumVPaths(class CMetaDataCallBack & __ptr64) __ptr64 +?EnumVPaths@CMetaDataMgr@@QEAAXAEAVCMetaDataCallBack@@@Z +; public: void __cdecl CMetaDataMgr::EnumVServers(class CMetaDataVirtualServerCallBack & __ptr64) __ptr64 +?EnumVServers@CMetaDataMgr@@QEAAXAEAVCMetaDataVirtualServerCallBack@@@Z +; public: static void __cdecl CiStorage::EnumerateFilesInDir(unsigned short const * __ptr64,class CEnumString & __ptr64) +?EnumerateFilesInDir@CiStorage@@SAXPEBGAEAVCEnumString@@@Z +; public: int __cdecl CPidLookupTable::EnumerateProperty(class CFullPropSpec & __ptr64,unsigned int & __ptr64) __ptr64 +?EnumerateProperty@CPidLookupTable@@QEAAHAEAVCFullPropSpec@@AEAI@Z +; public: void __cdecl CRegAccess::EnumerateValues(unsigned short * __ptr64,class CRegCallBack & __ptr64) __ptr64 +?EnumerateValues@CRegAccess@@QEAAXPEAGAEAVCRegCallBack@@@Z +; public: int __cdecl CMmStreamConsecBuf::Eof(void) __ptr64 +?Eof@CMmStreamConsecBuf@@QEAAHXZ +; public: int __cdecl CMetaDataMgr::ExtensionHasScriptMap(unsigned short const * __ptr64) __ptr64 +?ExtensionHasScriptMap@CMetaDataMgr@@QEAAHPEBG@Z +; public: virtual long __cdecl CPidConverter::FPSToPROPID(class CFullPropSpec const & __ptr64,unsigned long & __ptr64) __ptr64 +?FPSToPROPID@CPidConverter@@UEAAJAEBVCFullPropSpec@@AEAK@Z +; public: void __cdecl CPropStoreManager::FastInit(class CiStorage * __ptr64) __ptr64 +?FastInit@CPropStoreManager@@QEAAXPEAVCiStorage@@@Z +; public: void __cdecl COLEPropManager::FetchProperty(struct _GUID const & __ptr64,struct tagPROPSPEC const & __ptr64,struct tagPROPVARIANT * __ptr64,unsigned int * __ptr64) __ptr64 +?FetchProperty@COLEPropManager@@QEAAXAEBU_GUID@@AEBUtagPROPSPEC@@PEAUtagPROPVARIANT@@PEAI@Z +; public: int __cdecl CKeyArray::FillMax(int) __ptr64 +?FillMax@CKeyArray@@QEAAHH@Z +; public: class CPropEntry const * __ptr64 __cdecl CEmptyPropertyList::Find(class CDbColId const & __ptr64) __ptr64 +?Find@CEmptyPropertyList@@QEAAPEBVCPropEntry@@AEBVCDbColId@@@Z +; public: virtual class CPropEntry const * __ptr64 __cdecl CPropertyList::Find(class CDbColId const & __ptr64) __ptr64 +?Find@CPropertyList@@UEAAPEBVCPropEntry@@AEBVCDbColId@@@Z +; public: virtual class CPropEntry const * __ptr64 __cdecl CPropertyList::Find(unsigned short const * __ptr64) __ptr64 +?Find@CPropertyList@@UEAAPEBVCPropEntry@@PEBG@Z +; public: int __cdecl CPidLookupTable::FindPropid(class CFullPropSpec const & __ptr64,unsigned long & __ptr64,int) __ptr64 +?FindPropid@CPidLookupTable@@QEAAHAEBVCFullPropSpec@@AEAKH@Z +; public: void __cdecl CDynStream::Flush(void) __ptr64 +?Flush@CDynStream@@QEAAXXZ +; public: void __cdecl CPhysStorage::Flush(int) __ptr64 +?Flush@CPhysStorage@@QEAAXH@Z +; public: void __cdecl CPropStoreManager::Flush(void) __ptr64 +?Flush@CPropStoreManager@@QEAAXXZ +; public: static void __cdecl CCiOle::FlushIdle(void) +?FlushIdle@CCiOle@@SAXXZ +; public: struct tagDBCOMMANDTREE * __ptr64 __cdecl CTextToTree::FormFullTree(void) __ptr64 +?FormFullTree@CTextToTree@@QEAAPEAUtagDBCOMMANDTREE@@XZ +; class CDbCmdTreeNode * __ptr64 __cdecl FormQueryTree(class CDbCmdTreeNode & __ptr64,class CCatState & __ptr64,struct IColumnMapper * __ptr64,int,int) +?FormQueryTree@@YAPEAVCDbCmdTreeNode@@AEAV1@AEAVCCatState@@PEAUIColumnMapper@@HH@Z +FsCiShutdown +; public: unsigned long __cdecl CRegAccess::Get(unsigned short const * __ptr64) __ptr64 +?Get@CRegAccess@@QEAAKPEBG@Z +; public: void __cdecl CRegAccess::Get(unsigned short const * __ptr64,unsigned short * __ptr64,unsigned int) __ptr64 +?Get@CRegAccess@@QEAAXPEBGPEAGI@Z +; public: int __cdecl CWin32RegAccess::Get(unsigned short const * __ptr64,unsigned long & __ptr64) __ptr64 +?Get@CWin32RegAccess@@QEAAHPEBGAEAK@Z +; public: int __cdecl CWin32RegAccess::Get(unsigned short const * __ptr64,unsigned short * __ptr64,unsigned int,int) __ptr64 +?Get@CWin32RegAccess@@QEAAHPEBGPEAGIH@Z +; public: virtual long __cdecl CPropertyList::GetAllEntries(class CPropEntry * __ptr64 * __ptr64,unsigned long) __ptr64 +?GetAllEntries@CPropertyList@@UEAAJPEAPEAVCPropEntry@@K@Z +; public: short __cdecl CAllocStorageVariant::GetBOOL(unsigned int)const __ptr64 +?GetBOOL@CAllocStorageVariant@@QEBAFI@Z +; public: unsigned long __cdecl CPropStoreManager::GetBackupSize(unsigned long) __ptr64 +?GetBackupSize@CPropStoreManager@@QEAAKK@Z +; public: virtual void __cdecl CMemDeSerStream::GetBlob(unsigned char * __ptr64,unsigned long) __ptr64 +?GetBlob@CMemDeSerStream@@UEAAXPEAEK@Z +; unsigned long __cdecl GetBrowserCodepage(class CWebServer & __ptr64,unsigned long) +?GetBrowserCodepage@@YAKAEAVCWebServer@@K@Z +; public: virtual unsigned char __cdecl CMemDeSerStream::GetByte(void) __ptr64 +?GetByte@CMemDeSerStream@@UEAAEXZ +; public: unsigned short const * __ptr64 __cdecl CCatState::GetCD(void) __ptr64 +?GetCD@CCatState@@QEAAPEBGXZ +; public: int __cdecl CWebServer::GetCGIVariable(char const * __ptr64,class XArray & __ptr64,unsigned long & __ptr64) __ptr64 +?GetCGIVariable@CWebServer@@QEAAHPEBDAEAV?$XArray@G@@AEAK@Z +; public: int __cdecl CWebServer::GetCGIVariableW(unsigned short const * __ptr64,class XArray & __ptr64,unsigned long & __ptr64) __ptr64 +?GetCGIVariableW@CWebServer@@QEAAHPEBGAEAV?$XArray@G@@AEAK@Z +; public: struct _GUID __cdecl CAllocStorageVariant::GetCLSID(unsigned int)const __ptr64 +?GetCLSID@CAllocStorageVariant@@QEBA?AU_GUID@@I@Z +; public: union tagCY __cdecl CAllocStorageVariant::GetCY(unsigned int)const __ptr64 +?GetCY@CAllocStorageVariant@@QEBA?ATtagCY@@I@Z +; public: unsigned short const * __ptr64 __cdecl CCatState::GetCategory(unsigned int)const __ptr64 +?GetCategory@CCatState@@QEBAPEBGI@Z +; public: virtual void __cdecl CMemDeSerStream::GetChar(char * __ptr64,unsigned long) __ptr64 +?GetChar@CMemDeSerStream@@UEAAXPEADK@Z +; public: unsigned short const * __ptr64 __cdecl CCatState::GetColumn(unsigned int)const __ptr64 +?GetColumn@CCatState@@QEBAPEBGI@Z +; public: unsigned short __cdecl CQueryScanner::GetCommandChar(void) __ptr64 +?GetCommandChar@CQueryScanner@@QEAAGXZ +; public: double __cdecl CAllocStorageVariant::GetDATE(unsigned int)const __ptr64 +?GetDATE@CAllocStorageVariant@@QEBANI@Z +; public: int __cdecl CCatalogAdmin::GetDWORDParam(unsigned short const * __ptr64,unsigned long & __ptr64) __ptr64 +?GetDWORDParam@CCatalogAdmin@@QEAAHPEBGAEAK@Z +; public: int __cdecl CMachineAdmin::GetDWORDParam(unsigned short const * __ptr64,unsigned long & __ptr64) __ptr64 +?GetDWORDParam@CMachineAdmin@@QEAAHPEBGAEAK@Z +; public: void __cdecl CDriveInfo::GetDiskSpace(__int64 & __ptr64,__int64 & __ptr64) __ptr64 +?GetDiskSpace@CDriveInfo@@QEAAXAEA_J0@Z +; public: virtual double __cdecl CMemDeSerStream::GetDouble(void) __ptr64 +?GetDouble@CMemDeSerStream@@UEAANXZ +; public: static void __cdecl CDriveInfo::GetDrive(unsigned short const * __ptr64,unsigned short * __ptr64) +?GetDrive@CDriveInfo@@SAXPEBGPEAG@Z +; public: unsigned char * __ptr64 __cdecl CGenericCiProxy::GetEntryBuffer(unsigned long & __ptr64) __ptr64 +?GetEntryBuffer@CGenericCiProxy@@QEAAPEAEAEAK@Z +; public: struct _FILETIME __cdecl CAllocStorageVariant::GetFILETIME(unsigned int)const __ptr64 +?GetFILETIME@CAllocStorageVariant@@QEBA?AU_FILETIME@@I@Z +; public: int __cdecl CPathParser::GetFileName(unsigned short * __ptr64,unsigned long & __ptr64)const __ptr64 +?GetFileName@CPathParser@@QEBAHPEAGAEAK@Z +; public: enum CDriveInfo::eFileSystem __cdecl CDriveInfo::GetFileSystem(int) __ptr64 +?GetFileSystem@CDriveInfo@@QEAA?AW4eFileSystem@1@H@Z +; public: virtual float __cdecl CMemDeSerStream::GetFloat(void) __ptr64 +?GetFloat@CMemDeSerStream@@UEAAMXZ +; public: virtual void __cdecl CMemDeSerStream::GetGUID(struct _GUID & __ptr64) __ptr64 +?GetGUID@CMemDeSerStream@@UEAAXAEAU_GUID@@@Z +; class CPropListFile * __ptr64 __cdecl GetGlobalPropListFile(void) +?GetGlobalPropListFile@@YAPEAVCPropListFile@@XZ +; class CStaticPropertyList * __ptr64 __cdecl GetGlobalStaticPropertyList(void) +?GetGlobalStaticPropertyList@@YAPEAVCStaticPropertyList@@XZ +; public: short __cdecl CAllocStorageVariant::GetI2(unsigned int)const __ptr64 +?GetI2@CAllocStorageVariant@@QEBAFI@Z +; public: long __cdecl CAllocStorageVariant::GetI4(unsigned int)const __ptr64 +?GetI4@CAllocStorageVariant@@QEBAJI@Z +; public: union _LARGE_INTEGER __cdecl CAllocStorageVariant::GetI8(unsigned int)const __ptr64 +?GetI8@CAllocStorageVariant@@QEBA?AT_LARGE_INTEGER@@I@Z +; unsigned long __cdecl GetLCIDFromString(unsigned short * __ptr64) +?GetLCIDFromString@@YAKPEAG@Z +; public: char * __ptr64 __cdecl CAllocStorageVariant::GetLPSTR(unsigned int)const __ptr64 +?GetLPSTR@CAllocStorageVariant@@QEBAPEADI@Z +; public: unsigned short * __ptr64 __cdecl CAllocStorageVariant::GetLPWSTR(unsigned int)const __ptr64 +?GetLPWSTR@CAllocStorageVariant@@QEBAPEAGI@Z +; public: unsigned short const * __ptr64 __cdecl CCatalogAdmin::GetLocation(void) __ptr64 +?GetLocation@CCatalogAdmin@@QEAAPEBGXZ +; public: virtual long __cdecl CMemDeSerStream::GetLong(void) __ptr64 +?GetLong@CMemDeSerStream@@UEAAJXZ +; public: int __cdecl CQueryScanner::GetNumber(unsigned long & __ptr64,int & __ptr64) __ptr64 +?GetNumber@CQueryScanner@@QEAAHAEAKAEAH@Z +; public: int __cdecl CQueryScanner::GetNumber(double & __ptr64) __ptr64 +?GetNumber@CQueryScanner@@QEAAHAEAN@Z +; public: int __cdecl CQueryScanner::GetNumber(__int64 & __ptr64,int & __ptr64) __ptr64 +?GetNumber@CQueryScanner@@QEAAHAEA_JAEAH@Z +; public: int __cdecl CQueryScanner::GetNumber(unsigned __int64 & __ptr64,int & __ptr64) __ptr64 +?GetNumber@CQueryScanner@@QEAAHAEA_KAEAH@Z +; public: void __cdecl CKeyDeComp::GetOffset(struct BitOffset & __ptr64) __ptr64 +?GetOffset@CKeyDeComp@@QEAAXAEAUBitOffset@@@Z +; long __cdecl GetOleDBErrorInfo(struct IUnknown * __ptr64,struct _GUID const & __ptr64,unsigned long,unsigned int,struct tagERRORINFO * __ptr64,struct IErrorInfo * __ptr64 * __ptr64) +?GetOleDBErrorInfo@@YAJPEAUIUnknown@@AEBU_GUID@@KIPEAUtagERRORINFO@@PEAPEAUIErrorInfo@@@Z +; long __cdecl GetOleError(class CException & __ptr64) +?GetOleError@@YAJAEAVCException@@@Z +; public: unsigned long __cdecl CWebServer::GetPhysicalPath(unsigned short const * __ptr64,unsigned short * __ptr64,unsigned long,unsigned long) __ptr64 +?GetPhysicalPath@CWebServer@@QEAAKPEBGPEAGKK@Z +; public: int __cdecl CEmptyPropertyList::GetPropInfo(class CDbColId const & __ptr64,unsigned short const * __ptr64 * __ptr64,unsigned short * __ptr64,unsigned int * __ptr64) __ptr64 +?GetPropInfo@CEmptyPropertyList@@QEAAHAEBVCDbColId@@PEAPEBGPEAGPEAI@Z +; public: int __cdecl CEmptyPropertyList::GetPropInfo(unsigned short const * __ptr64,class CDbColId * __ptr64 * __ptr64,unsigned short * __ptr64,unsigned int * __ptr64) __ptr64 +?GetPropInfo@CEmptyPropertyList@@QEAAHPEBGPEAPEAVCDbColId@@PEAGPEAI@Z +; public: virtual long __cdecl CEmptyPropertyList::GetPropInfoFromId(struct tagDBID const * __ptr64,unsigned short * __ptr64 * __ptr64,unsigned short * __ptr64,unsigned int * __ptr64) __ptr64 +?GetPropInfoFromId@CEmptyPropertyList@@UEAAJPEBUtagDBID@@PEAPEAGPEAGPEAI@Z +; public: virtual long __cdecl CEmptyPropertyList::GetPropInfoFromName(unsigned short const * __ptr64,struct tagDBID * __ptr64 * __ptr64,unsigned short * __ptr64,unsigned int * __ptr64) __ptr64 +?GetPropInfoFromName@CEmptyPropertyList@@UEAAJPEBGPEAPEAUtagDBID@@PEAGPEAI@Z +; public: static unsigned short __cdecl CEmptyPropertyList::GetPropType(unsigned int) +?GetPropType@CEmptyPropertyList@@SAGI@Z +; public: static unsigned int __cdecl CEmptyPropertyList::GetPropTypeCount(void) +?GetPropTypeCount@CEmptyPropertyList@@SAIXZ +; public: static unsigned short const * __ptr64 __cdecl CEmptyPropertyList::GetPropTypeName(unsigned int) +?GetPropTypeName@CEmptyPropertyList@@SAPEBGI@Z +; public: virtual long __cdecl CDbProperties::GetProperties(unsigned long,struct tagDBPROPIDSET const * __ptr64 const,unsigned long * __ptr64,struct tagDBPROPSET * __ptr64 * __ptr64) __ptr64 +?GetProperties@CDbProperties@@UEAAJKQEBUtagDBPROPIDSET@@PEAKPEAPEAUtagDBPROPSET@@@Z +; public: void __cdecl CGetDbProps::GetProperties(struct IDBProperties * __ptr64,unsigned long) __ptr64 +?GetProperties@CGetDbProps@@QEAAXPEAUIDBProperties@@K@Z +; public: virtual long __cdecl CDbProperties::GetPropertyInfo(unsigned long,struct tagDBPROPIDSET const * __ptr64 const,unsigned long * __ptr64,struct tagDBPROPINFOSET * __ptr64 * __ptr64,unsigned short * __ptr64 * __ptr64) __ptr64 +?GetPropertyInfo@CDbProperties@@UEAAJKQEBUtagDBPROPIDSET@@PEAKPEAPEAUtagDBPROPINFOSET@@PEAPEAG@Z +; public: float __cdecl CAllocStorageVariant::GetR4(unsigned int)const __ptr64 +?GetR4@CAllocStorageVariant@@QEBAMI@Z +; public: double __cdecl CAllocStorageVariant::GetR8(unsigned int)const __ptr64 +?GetR8@CAllocStorageVariant@@QEBANI@Z +; public: int __cdecl CMachineAdmin::GetSZParam(unsigned short const * __ptr64,unsigned short * __ptr64,unsigned long) __ptr64 +?GetSZParam@CMachineAdmin@@QEAAHPEBGPEAGK@Z +; long __cdecl GetScodeError(class CException & __ptr64) +?GetScodeError@@YAJAEAVCException@@@Z +; int __cdecl GetSecret(unsigned short const * __ptr64,unsigned short const * __ptr64,unsigned short * __ptr64 * __ptr64,unsigned long * __ptr64) +?GetSecret@@YAHPEBG0PEAPEAGPEAK@Z +; public: unsigned long __cdecl CDriveInfo::GetSectorSize(void) __ptr64 +?GetSectorSize@CDriveInfo@@QEAAKXZ +; public: void __cdecl CCatState::GetSortProp(unsigned int,unsigned short const * __ptr64 * __ptr64,enum SORTDIR * __ptr64)const __ptr64 +?GetSortProp@CCatState@@QEBAXIPEAPEBGPEAW4SORTDIR@@@Z +; void __cdecl GetStackTrace(char * __ptr64,unsigned long) +?GetStackTrace@@YAXPEADK@Z +; public: unsigned char const * __ptr64 __cdecl CGenericCiProxy::GetStartupData(struct _GUID & __ptr64,unsigned long & __ptr64) __ptr64 +?GetStartupData@CGenericCiProxy@@QEAAPEBEAEAU_GUID@@AEAK@Z +; public: class PStorage & __ptr64 __cdecl CPropStoreManager::GetStorage(unsigned long) __ptr64 +?GetStorage@CPropStoreManager@@QEAAAEAVPStorage@@K@Z +; public: unsigned short * __ptr64 __cdecl CKey::GetStr(void)const __ptr64 +?GetStr@CKey@@QEBAPEAGXZ +; public: unsigned short * __ptr64 __cdecl CKeyBuf::GetStr(void)const __ptr64 +?GetStr@CKeyBuf@@QEBAPEAGXZ +; public: virtual char * __ptr64 __cdecl CMemDeSerStream::GetString(void) __ptr64 +?GetString@CMemDeSerStream@@UEAAPEADXZ +; class CDbRestriction * __ptr64 __cdecl GetStringDbRestriction(unsigned short const * __ptr64,unsigned long,struct IColumnMapper * __ptr64,unsigned long) +?GetStringDbRestriction@@YAPEAVCDbRestriction@@PEBGKPEAUIColumnMapper@@K@Z +; void __cdecl GetStringFromLCID(unsigned long,unsigned short * __ptr64) +?GetStringFromLCID@@YAXKPEAG@Z +; public: unsigned long __cdecl CPropStoreManager::GetTotalSizeInKB(void) __ptr64 +?GetTotalSizeInKB@CPropStoreManager@@QEAAKXZ +; public: unsigned long __cdecl CPropertyStore::GetTotalSizeInKB(void) __ptr64 +?GetTotalSizeInKB@CPropertyStore@@QEAAKXZ +; public: virtual unsigned long __cdecl CMemDeSerStream::GetULong(void) __ptr64 +?GetULong@CMemDeSerStream@@UEAAKXZ +; public: virtual unsigned short __cdecl CMemDeSerStream::GetUShort(void) __ptr64 +?GetUShort@CMemDeSerStream@@UEAAGXZ +; public: void __cdecl CIndexTable::GetUserHdrInfo(unsigned int & __ptr64,int & __ptr64) __ptr64 +?GetUserHdrInfo@CIndexTable@@QEAAXAEAIAEAH@Z +; public: unsigned long __cdecl CMetaDataMgr::GetVPathAccess(unsigned short const * __ptr64) __ptr64 +?GetVPathAccess@CMetaDataMgr@@QEAAKPEBG@Z +; public: unsigned long __cdecl CMetaDataMgr::GetVPathAuthorization(unsigned short const * __ptr64) __ptr64 +?GetVPathAuthorization@CMetaDataMgr@@QEAAKPEBG@Z +; public: unsigned long __cdecl CMetaDataMgr::GetVPathSSLAccess(unsigned short const * __ptr64) __ptr64 +?GetVPathSSLAccess@CMetaDataMgr@@QEAAKPEBG@Z +; public: unsigned short const * __ptr64 __cdecl CDriveInfo::GetVolumeName(int) __ptr64 +?GetVolumeName@CDriveInfo@@QEAAPEBGH@Z +; public: virtual void __cdecl CMemDeSerStream::GetWChar(unsigned short * __ptr64,unsigned long) __ptr64 +?GetWChar@CMemDeSerStream@@UEAAXPEAGK@Z +; public: virtual unsigned short * __ptr64 __cdecl CMemDeSerStream::GetWString(void) __ptr64 +?GetWString@CMemDeSerStream@@UEAAPEAGXZ +; public: long __cdecl CDbCmdTreeNode::GetWeight(void)const __ptr64 +?GetWeight@CDbCmdTreeNode@@QEBAJXZ +; public: void __cdecl CDynStream::Grow(class PStorage & __ptr64,unsigned long) __ptr64 +?Grow@CDynStream@@QEAAXAEAVPStorage@@K@Z +; private: void __cdecl CVirtualString::GrowBuffer(unsigned long) __ptr64 +?GrowBuffer@CVirtualString@@AEAAXK@Z +; void __cdecl HTMLEscapeW(unsigned short const * __ptr64,class CVirtualString & __ptr64,unsigned long) +?HTMLEscapeW@@YAXPEBGAEAVCVirtualString@@K@Z +; private: void __cdecl CImpersonateClient::Impersonate(void) __ptr64 +?Impersonate@CImpersonateClient@@AEAAXXZ +; public: void __cdecl CFileMapView::Init(void) __ptr64 +?Init@CFileMapView@@QEAAXXZ +; public: void __cdecl CMmStreamConsecBuf::Init(class PMmStream * __ptr64) __ptr64 +?Init@CMmStreamConsecBuf@@QEAAXPEAVPMmStream@@@Z +; public: int __cdecl CPidLookupTable::Init(class PRcovStorageObj * __ptr64) __ptr64 +?Init@CPidLookupTable@@QEAAHPEAVPRcovStorageObj@@@Z +; public: void __cdecl CRcovStorageHdr::Init(unsigned long) __ptr64 +?Init@CRcovStorageHdr@@QEAAXK@Z +; public: void __cdecl CRegChangeEvent::Init(void) __ptr64 +?Init@CRegChangeEvent@@QEAAXXZ +; public: int __cdecl CSdidLookupTable::Init(class CiStorage * __ptr64) __ptr64 +?Init@CSdidLookupTable@@QEAAHPEAVCiStorage@@@Z +; public: virtual void __cdecl CPropertyList::InitIterator(void) __ptr64 +?InitIterator@CPropertyList@@UEAAXXZ +; public: void __cdecl CImpersonationTokenCache::Initialize(unsigned short const * __ptr64,int,int,int,unsigned long,unsigned long,unsigned long) __ptr64 +?Initialize@CImpersonationTokenCache@@QEAAXPEBGHHHKKK@Z +; public: void __cdecl CDynStream::InitializeForRead(void) __ptr64 +?InitializeForRead@CDynStream@@QEAAXXZ +; public: void __cdecl CDynStream::InitializeForWrite(unsigned long) __ptr64 +?InitializeForWrite@CDynStream@@QEAAXK@Z +; protected: void __cdecl CDbCmdTreeNode::InsertChild(class CDbCmdTreeNode * __ptr64) __ptr64 +?InsertChild@CDbCmdTreeNode@@IEAAXPEAV1@@Z +; public: int __cdecl CMachineAdmin::IsCIEnabled(void) __ptr64 +?IsCIEnabled@CMachineAdmin@@QEAAHXZ +; public: int __cdecl CMachineAdmin::IsCIPaused(void) __ptr64 +?IsCIPaused@CMachineAdmin@@QEAAHXZ +; public: int __cdecl CMachineAdmin::IsCIStarted(void) __ptr64 +?IsCIStarted@CMachineAdmin@@QEAAHXZ +; public: int __cdecl CMachineAdmin::IsCIStopped(void) __ptr64 +?IsCIStopped@CMachineAdmin@@QEAAHXZ +; public: int __cdecl CCatalogAdmin::IsCatalogInactive(void) __ptr64 +?IsCatalogInactive@CCatalogAdmin@@QEAAHXZ +; int __cdecl IsDirectoryWritable(unsigned short const * __ptr64) +?IsDirectoryWritable@@YAHPEBG@Z +; public: static int __cdecl CMetaDataMgr::IsIISAdminUp(int & __ptr64) +?IsIISAdminUp@CMetaDataMgr@@SAHAEAH@Z +; public: static int __cdecl CImpersonateSystem::IsImpersonated(void) +?IsImpersonated@CImpersonateSystem@@SAHXZ +; public: int __cdecl CRestriction::IsLeaf(void)const __ptr64 +?IsLeaf@CRestriction@@QEBAHXZ +; int __cdecl IsNullPointerVariant(struct tagPROPVARIANT * __ptr64) +?IsNullPointerVariant@@YAHPEAUtagPROPVARIANT@@@Z +; public: int __cdecl CCatalogAdmin::IsPaused(void) __ptr64 +?IsPaused@CCatalogAdmin@@QEAAHXZ +; public: static int __cdecl CImpersonateSystem::IsRunningAsSystem(void) +?IsRunningAsSystem@CImpersonateSystem@@SAHXZ +; public: int __cdecl CDriveInfo::IsSameDrive(unsigned short const * __ptr64) __ptr64 +?IsSameDrive@CDriveInfo@@QEAAHPEBG@Z +; long __cdecl IsScopeValid(unsigned short const * __ptr64,unsigned int,int) +?IsScopeValid@@YAJPEBGIH@Z +; public: int __cdecl CCatalogAdmin::IsStarted(void) __ptr64 +?IsStarted@CCatalogAdmin@@QEAAHXZ +; public: int __cdecl CCatalogAdmin::IsStopped(void) __ptr64 +?IsStopped@CCatalogAdmin@@QEAAHXZ +; public: int __cdecl CAllocStorageVariant::IsValid(void)const __ptr64 +?IsValid@CAllocStorageVariant@@QEBAHXZ +; public: int __cdecl CNodeRestriction::IsValid(void)const __ptr64 +?IsValid@CNodeRestriction@@QEBAHXZ +; public: int __cdecl COccRestriction::IsValid(void)const __ptr64 +?IsValid@COccRestriction@@QEBAHXZ +; public: int __cdecl CRestriction::IsValid(void)const __ptr64 +?IsValid@CRestriction@@QEBAHXZ +; public: int __cdecl CFilterDaemon::IsWaitingForDocument(void) __ptr64 +?IsWaitingForDocument@CFilterDaemon@@QEAAHXZ +; public: int __cdecl CDriveInfo::IsWriteProtected(void) __ptr64 +?IsWriteProtected@CDriveInfo@@QEAAHXZ +; public: void __cdecl CLocalGlobalPropertyList::Load(unsigned short const * __ptr64 const) __ptr64 +?Load@CLocalGlobalPropertyList@@QEAAXQEBG@Z +; unsigned long __cdecl LocaleToCodepage(unsigned long) +?LocaleToCodepage@@YAKK@Z +; private: unsigned long __cdecl CPropertyStore::LokNewWorkId(unsigned long,int,int) __ptr64 +?LokNewWorkId@CPropertyStore@@AEAAKKHH@Z +; public: int __cdecl CCatStateInfo::LokUpdate(void) __ptr64 +?LokUpdate@CCatStateInfo@@QEAAHXZ +; public: void __cdecl CPropStoreManager::LongInit(int & __ptr64,unsigned long & __ptr64,void (__cdecl*)(unsigned long,int,void const * __ptr64),void const * __ptr64) __ptr64 +?LongInit@CPropStoreManager@@QEAAXAEAHAEAKP6AXKHPEBX@Z2@Z +; private: unsigned int __cdecl CPropStoreInfo::Lookup(unsigned long) __ptr64 +?Lookup@CPropStoreInfo@@AEAAIK@Z +; public: unsigned long __cdecl CSdidLookupTable::LookupSDID(void * __ptr64,unsigned long) __ptr64 +?LookupSDID@CSdidLookupTable@@QEAAKPEAXK@Z +; public: void __cdecl CPhysStorage::MakeBackupCopy(class CPhysStorage & __ptr64,class PSaveProgressTracker & __ptr64) __ptr64 +?MakeBackupCopy@CPhysStorage@@QEAAXAEAV1@AEAVPSaveProgressTracker@@@Z +; public: void __cdecl CPidLookupTable::MakeBackupCopy(class PRcovStorageObj & __ptr64,class PSaveProgressTracker & __ptr64) __ptr64 +?MakeBackupCopy@CPidLookupTable@@QEAAXAEAVPRcovStorageObj@@AEAVPSaveProgressTracker@@@Z +; public: void __cdecl CPropStoreManager::MakeBackupCopy(struct IProgressNotify * __ptr64,int & __ptr64,class CiStorage & __ptr64,struct ICiEnumWorkids * __ptr64,struct IEnumString * __ptr64 * __ptr64) __ptr64 +?MakeBackupCopy@CPropStoreManager@@QEAAXPEAUIProgressNotify@@AEAHAEAVCiStorage@@PEAUICiEnumWorkids@@PEAPEAUIEnumString@@@Z +; long __cdecl MakeICommand(struct IUnknown * __ptr64 * __ptr64,unsigned short const * __ptr64,unsigned short const * __ptr64,struct IUnknown * __ptr64) +?MakeICommand@@YAJPEAPEAUIUnknown@@PEBG1PEAU1@@Z +; long __cdecl MakeISearch(struct ISearchQueryHits * __ptr64 * __ptr64,class CDbRestriction * __ptr64,unsigned short const * __ptr64) +?MakeISearch@@YAJPEAPEAUISearchQueryHits@@PEAVCDbRestriction@@PEBG@Z +; long __cdecl MakeLocalICommand(struct IUnknown * __ptr64 * __ptr64,struct ICiCDocStore * __ptr64,struct IUnknown * __ptr64) +?MakeLocalICommand@@YAJPEAPEAUIUnknown@@PEAUICiCDocStore@@PEAU1@@Z +; long __cdecl MakeMetadataICommand(struct IUnknown * __ptr64 * __ptr64,enum CiMetaData,unsigned short const * __ptr64,unsigned short const * __ptr64,struct IUnknown * __ptr64) +?MakeMetadataICommand@@YAJPEAPEAUIUnknown@@W4CiMetaData@@PEBG2PEAU1@@Z +; public: void __cdecl CFullPath::MakePath(unsigned short const * __ptr64) __ptr64 +?MakePath@CFullPath@@QEAAXPEBG@Z +; public: void __cdecl CFullPath::MakePath(unsigned short const * __ptr64,unsigned int) __ptr64 +?MakePath@CFullPath@@QEAAXPEBGI@Z +; private: void __cdecl CImpersonateSystem::MakePrivileged(void) __ptr64 +?MakePrivileged@CImpersonateSystem@@AEAAXXZ +; public: void __cdecl CMmStreamConsecBuf::Map(unsigned long) __ptr64 +?Map@CMmStreamConsecBuf@@QEAAXK@Z +; public: int __cdecl CDynStream::MarkDirty(void) __ptr64 +?MarkDirty@CDynStream@@QEAAHXZ +; public: void __cdecl CBaseStorageVariant::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CBaseStorageVariant@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CContentRestriction::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CContentRestriction@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CDbCmdTreeNode::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CDbCmdTreeNode@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CFullPropSpec::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CFullPropSpec@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CNatLanguageRestriction::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CNatLanguageRestriction@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CNodeRestriction::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CNodeRestriction@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CNotRestriction::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CNotRestriction@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CPropNameArray::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CPropNameArray@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CPropertyRestriction::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CPropertyRestriction@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CRestriction::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CRestriction@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CVectorRestriction::Marshall(class PSerStream & __ptr64)const __ptr64 +?Marshall@CVectorRestriction@@QEBAXAEAVPSerStream@@@Z +; public: int __cdecl CBufferCache::MinPageInUse(unsigned long & __ptr64) __ptr64 +?MinPageInUse@CBufferCache@@QEAAHAEAK@Z +; public: int __cdecl CPhysStorage::MinPageInUse(unsigned long & __ptr64) __ptr64 +?MinPageInUse@CPhysStorage@@QEAAHAEAK@Z +; unsigned long __cdecl MultiByteToXArrayWideChar(unsigned char const * __ptr64,unsigned long,unsigned int,class XArray & __ptr64) +?MultiByteToXArrayWideChar@@YAKPEBEKIAEAV?$XArray@G@@@Z +; unsigned __int64 __cdecl My_wcstoui64(unsigned short const * __ptr64,unsigned short * __ptr64 * __ptr64,int) +?My_wcstoui64@@YA_KPEBGPEAPEAGH@Z +; public: unsigned long __cdecl CPidRemapper::NameToReal(class CFullPropSpec const * __ptr64) __ptr64 +?NameToReal@CPidRemapper@@QEAAKPEBVCFullPropSpec@@@Z +; public: static struct IStemmer * __ptr64 __cdecl CCiOle::NewStemmer(struct _GUID const & __ptr64) +?NewStemmer@CCiOle@@SAPEAUIStemmer@@AEBU_GUID@@@Z +; public: static struct IWordBreaker * __ptr64 __cdecl CCiOle::NewWordBreaker(struct _GUID const & __ptr64) +?NewWordBreaker@CCiOle@@SAPEAUIWordBreaker@@AEBU_GUID@@@Z +; public: int __cdecl CCatalogEnum::Next(void) __ptr64 +?Next@CCatalogEnum@@QEAAHXZ +; public: virtual long __cdecl CEnumString::Next(unsigned long,unsigned short * __ptr64 * __ptr64,unsigned long * __ptr64) __ptr64 +?Next@CEnumString@@UEAAJKPEAPEAGPEAK@Z +; public: virtual long __cdecl CEnumWorkid::Next(unsigned long,unsigned long * __ptr64,unsigned long * __ptr64) __ptr64 +?Next@CEnumWorkid@@UEAAJKPEAK0@Z +; public: virtual class CPropEntry const * __ptr64 __cdecl CPropertyList::Next(void) __ptr64 +?Next@CPropertyList@@UEAAPEBVCPropEntry@@XZ +; public: int __cdecl CScopeEnum::Next(void) __ptr64 +?Next@CScopeEnum@@QEAAHXZ +; public: unsigned long __cdecl CPropertyStoreWids::NextWorkId(void) __ptr64 +?NextWorkId@CPropertyStoreWids@@QEAAKXZ +; public: unsigned int __cdecl CCatState::NumberOfColumns(void)const __ptr64 +?NumberOfColumns@CCatState@@QEBAIXZ +; public: unsigned int __cdecl CCatState::NumberOfSortProps(void)const __ptr64 +?NumberOfSortProps@CCatState@@QEBAIXZ +; public: void __cdecl CMmStream::Open(unsigned short const * __ptr64,unsigned long,unsigned long,unsigned long,unsigned long,int) __ptr64 +?Open@CMmStream@@QEAAXPEBGKKKKH@Z +; public: int __cdecl COLEPropManager::Open(class CFunnyPath const & __ptr64) __ptr64 +?Open@COLEPropManager@@QEAAHAEBVCFunnyPath@@@Z +; public: void __cdecl CMmStream::OpenExclusive(unsigned short * __ptr64,int) __ptr64 +?OpenExclusive@CMmStream@@QEAAXPEAGH@Z +; struct _iobuf * __ptr64 __cdecl OpenFileFromPath(unsigned short const * __ptr64) +?OpenFileFromPath@@YAPEAU_iobuf@@PEBG@Z +; public: class CCompositePropRecord * __ptr64 __cdecl CPropStoreManager::OpenRecord(unsigned long,unsigned char * __ptr64) __ptr64 +?OpenRecord@CPropStoreManager@@QEAAPEAVCCompositePropRecord@@KPEAE@Z +; public: class CCompositePropRecordForWrites * __ptr64 __cdecl CPropStoreManager::OpenRecordForWrites(unsigned long,unsigned char * __ptr64) __ptr64 +?OpenRecordForWrites@CPropStoreManager@@QEAAPEAVCCompositePropRecordForWrites@@KPEAE@Z +; long __cdecl ParseCatalogURL(unsigned short const * __ptr64,class XPtrST & __ptr64,class XPtrST & __ptr64) +?ParseCatalogURL@@YAJPEBGAEAV?$XPtrST@G@@1@Z +; public: class CRestriction * __ptr64 __cdecl CParseCommandTree::ParseExpression(class CDbCmdTreeNode * __ptr64) __ptr64 +?ParseExpression@CParseCommandTree@@QEAAPEAVCRestriction@@PEAVCDbCmdTreeNode@@@Z +; public: static void __cdecl CPropertyList::ParseOneLine(class CQueryScanner & __ptr64,int,class XPtr & __ptr64) +?ParseOneLine@CPropertyList@@SAXAEAVCQueryScanner@@HAEAV?$XPtr@VCPropEntry@@@@@Z +; public: class CDbRestriction * __ptr64 __cdecl CQueryParser::ParseQueryPhrase(void) __ptr64 +?ParseQueryPhrase@CQueryParser@@QEAAPEAVCDbRestriction@@XZ +; class CDbColumns * __ptr64 __cdecl ParseStringColumns(unsigned short const * __ptr64,struct IColumnMapper * __ptr64,unsigned long,class PVariableSet * __ptr64,class CDynArray * __ptr64) +?ParseStringColumns@@YAPEAVCDbColumns@@PEBGPEAUIColumnMapper@@KPEAVPVariableSet@@PEAV?$CDynArray@G@@@Z +; public: int __cdecl CCatalogAdmin::Pause(void) __ptr64 +?Pause@CCatalogAdmin@@QEAAHXZ +; public: int __cdecl CMachineAdmin::PauseCI(void) __ptr64 +?PauseCI@CMachineAdmin@@QEAAHXZ +; public: virtual unsigned long __cdecl CMemDeSerStream::PeekULong(void) __ptr64 +?PeekULong@CMemDeSerStream@@UEAAKXZ +; public: unsigned long __cdecl CPidMapper::PidToRealPid(unsigned long) __ptr64 +?PidToRealPid@CPidMapper@@QEAAKK@Z +; public: unsigned long __cdecl CStandardPropMapper::PropertyToPropId(class CFullPropSpec const & __ptr64,int) __ptr64 +?PropertyToPropId@CStandardPropMapper@@QEAAKAEBVCFullPropSpec@@H@Z +; public: virtual long __cdecl CFwPropertyMapper::PropertyToPropid(struct tagFULLPROPSPEC const * __ptr64,int,unsigned long * __ptr64) __ptr64 +?PropertyToPropid@CFwPropertyMapper@@UEAAJPEBUtagFULLPROPSPEC@@HPEAK@Z +; public: void __cdecl CValueNormalizer::PutMaxValue(unsigned long,unsigned long & __ptr64,enum VARENUM) __ptr64 +?PutMaxValue@CValueNormalizer@@QEAAXKAEAKW4VARENUM@@@Z +; public: void __cdecl CValueNormalizer::PutMinValue(unsigned long,unsigned long & __ptr64,enum VARENUM) __ptr64 +?PutMinValue@CValueNormalizer@@QEAAXKAEAKW4VARENUM@@@Z +; public: void __cdecl CValueNormalizer::PutValue(unsigned long,unsigned long & __ptr64,class CStorageVariant const & __ptr64) __ptr64 +?PutValue@CValueNormalizer@@QEAAXKAEAKAEBVCStorageVariant@@@Z +; void __cdecl PutWString(class PSerStream & __ptr64,unsigned short const * __ptr64) +?PutWString@@YAXAEAVPSerStream@@PEBG@Z +; private: class CDbRestriction * __ptr64 __cdecl CQueryParser::Query(class CDbNodeRestriction * __ptr64) __ptr64 +?Query@CQueryParser@@AEAAPEAVCDbRestriction@@PEAVCDbNodeRestriction@@@Z +; public: class CCatalogAdmin * __ptr64 __cdecl CCatalogEnum::QueryCatalogAdmin(void) __ptr64 +?QueryCatalogAdmin@CCatalogEnum@@QEAAPEAVCCatalogAdmin@@XZ +; public: class CCatalogAdmin * __ptr64 __cdecl CMachineAdmin::QueryCatalogAdmin(unsigned short const * __ptr64) __ptr64 +?QueryCatalogAdmin@CMachineAdmin@@QEAAPEAVCCatalogAdmin@@PEBG@Z +; public: class CCatalogEnum * __ptr64 __cdecl CMachineAdmin::QueryCatalogEnum(void) __ptr64 +?QueryCatalogEnum@CMachineAdmin@@QEAAPEAVCCatalogEnum@@XZ +; public: virtual long __cdecl CDbProperties::QueryInterface(struct _GUID const & __ptr64,void * __ptr64 * __ptr64) __ptr64 +?QueryInterface@CDbProperties@@UEAAJAEBU_GUID@@PEAPEAX@Z +; public: virtual long __cdecl CEmptyPropertyList::QueryInterface(struct _GUID const & __ptr64,void * __ptr64 * __ptr64) __ptr64 +?QueryInterface@CEmptyPropertyList@@UEAAJAEBU_GUID@@PEAPEAX@Z +; public: virtual long __cdecl CEnumString::QueryInterface(struct _GUID const & __ptr64,void * __ptr64 * __ptr64) __ptr64 +?QueryInterface@CEnumString@@UEAAJAEBU_GUID@@PEAPEAX@Z +; public: virtual long __cdecl CEnumWorkid::QueryInterface(struct _GUID const & __ptr64,void * __ptr64 * __ptr64) __ptr64 +?QueryInterface@CEnumWorkid@@UEAAJAEBU_GUID@@PEAPEAX@Z +; public: virtual long __cdecl CFwPropertyMapper::QueryInterface(struct _GUID const & __ptr64,void * __ptr64 * __ptr64) __ptr64 +?QueryInterface@CFwPropertyMapper@@UEAAJAEBU_GUID@@PEAPEAX@Z +; public: virtual long __cdecl CQueryUnknown::QueryInterface(struct _GUID const & __ptr64,void * __ptr64 * __ptr64) __ptr64 +?QueryInterface@CQueryUnknown@@UEAAJAEBU_GUID@@PEAPEAX@Z +; public: class PRcovStorageObj * __ptr64 __cdecl CiStorage::QueryPidLookupTable(unsigned long) __ptr64 +?QueryPidLookupTable@CiStorage@@QEAAPEAVPRcovStorageObj@@K@Z +; public: class CScopeAdmin * __ptr64 __cdecl CCatalogAdmin::QueryScopeAdmin(unsigned short const * __ptr64) __ptr64 +?QueryScopeAdmin@CCatalogAdmin@@QEAAPEAVCScopeAdmin@@PEBG@Z +; public: class CScopeAdmin * __ptr64 __cdecl CScopeEnum::QueryScopeAdmin(void) __ptr64 +?QueryScopeAdmin@CScopeEnum@@QEAAPEAVCScopeAdmin@@XZ +; public: class CScopeEnum * __ptr64 __cdecl CCatalogAdmin::QueryScopeEnum(void) __ptr64 +?QueryScopeEnum@CCatalogAdmin@@QEAAPEAVCScopeEnum@@XZ +; public: class PRcovStorageObj * __ptr64 __cdecl CiStorage::QueryScopeList(unsigned long) __ptr64 +?QueryScopeList@CiStorage@@QEAAPEAVPRcovStorageObj@@K@Z +; public: class PRcovStorageObj * __ptr64 __cdecl CiStorage::QuerySdidLookupTable(unsigned long) __ptr64 +?QuerySdidLookupTable@CiStorage@@QEAAPEAVPRcovStorageObj@@K@Z +; public: class PRcovStorageObj * __ptr64 __cdecl CiStorage::QueryVirtualScopeList(unsigned long) __ptr64 +?QueryVirtualScopeList@CiStorage@@QEAAPEAVPRcovStorageObj@@K@Z +; public: void __cdecl CPidRemapper::ReBuild(class CPidMapper const & __ptr64) __ptr64 +?ReBuild@CPidRemapper@@QEAAXAEBVCPidMapper@@@Z +; public: void __cdecl CQueryUnknown::ReInit(unsigned long,class CRowset * __ptr64 * __ptr64) __ptr64 +?ReInit@CQueryUnknown@@QEAAXKPEAPEAVCRowset@@@Z +; public: void __cdecl CImpersonationTokenCache::ReInitializeIISScopes(void) __ptr64 +?ReInitializeIISScopes@CImpersonationTokenCache@@QEAAXXZ +; private: virtual void __cdecl CPhysIndex::ReOpenStream(void) __ptr64 +?ReOpenStream@CPhysIndex@@EEAAXXZ +; public: unsigned long __cdecl CDynStream::Read(void * __ptr64,unsigned long) __ptr64 +?Read@CDynStream@@QEAAKPEAXK@Z +; public: unsigned long __cdecl CRcovStrmTrans::Read(void * __ptr64,unsigned long) __ptr64 +?Read@CRcovStrmTrans@@QEAAKPEAXK@Z +; public: unsigned long __cdecl CRegAccess::Read(unsigned short const * __ptr64,unsigned long) __ptr64 +?Read@CRegAccess@@QEAAKPEBGK@Z +; public: unsigned short * __ptr64 __cdecl CRegAccess::Read(unsigned short const * __ptr64,unsigned short const * __ptr64) __ptr64 +?Read@CRegAccess@@QEAAPEAGPEBG0@Z +; public: int __cdecl CPropStoreManager::ReadPrimaryProperty(unsigned long,unsigned long,struct tagPROPVARIANT & __ptr64) __ptr64 +?ReadPrimaryProperty@CPropStoreManager@@QEAAHKKAEAUtagPROPVARIANT@@@Z +; public: int __cdecl COLEPropManager::ReadProperty(class CFullPropSpec const & __ptr64,struct tagPROPVARIANT & __ptr64) __ptr64 +?ReadProperty@COLEPropManager@@QEAAHAEBVCFullPropSpec@@AEAUtagPROPVARIANT@@@Z +; public: int __cdecl CPropStoreManager::ReadProperty(class CCompositePropRecord & __ptr64,unsigned long,struct tagPROPVARIANT & __ptr64) __ptr64 +?ReadProperty@CPropStoreManager@@QEAAHAEAVCCompositePropRecord@@KAEAUtagPROPVARIANT@@@Z +; public: int __cdecl CPropStoreManager::ReadProperty(class CCompositePropRecord & __ptr64,unsigned long,struct tagPROPVARIANT & __ptr64,unsigned char * __ptr64,unsigned int * __ptr64) __ptr64 +?ReadProperty@CPropStoreManager@@QEAAHAEAVCCompositePropRecord@@KAEAUtagPROPVARIANT@@PEAEPEAI@Z +; public: int __cdecl CPropStoreManager::ReadProperty(class CCompositePropRecord & __ptr64,unsigned long,struct tagPROPVARIANT * __ptr64,unsigned int * __ptr64) __ptr64 +?ReadProperty@CPropStoreManager@@QEAAHAEAVCCompositePropRecord@@KPEAUtagPROPVARIANT@@PEAI@Z +; public: int __cdecl CPropStoreManager::ReadProperty(unsigned long,unsigned long,struct tagPROPVARIANT & __ptr64) __ptr64 +?ReadProperty@CPropStoreManager@@QEAAHKKAEAUtagPROPVARIANT@@@Z +; public: int __cdecl CPropStoreManager::ReadProperty(unsigned long,unsigned long,struct tagPROPVARIANT & __ptr64,unsigned char * __ptr64,unsigned int * __ptr64) __ptr64 +?ReadProperty@CPropStoreManager@@QEAAHKKAEAUtagPROPVARIANT@@PEAEPEAI@Z +; public: int __cdecl CPropStoreManager::ReadProperty(unsigned long,unsigned long,struct tagPROPVARIANT * __ptr64,unsigned int * __ptr64) __ptr64 +?ReadProperty@CPropStoreManager@@QEAAHKKPEAUtagPROPVARIANT@@PEAI@Z +; public: int __cdecl CPropertyStore::ReadProperty(class CPropRecordNoLock & __ptr64,unsigned long,struct tagPROPVARIANT * __ptr64,unsigned int * __ptr64) __ptr64 +?ReadProperty@CPropertyStore@@QEAAHAEAVCPropRecordNoLock@@KPEAUtagPROPVARIANT@@PEAI@Z +; public: int __cdecl CPropertyStore::ReadProperty(unsigned long,unsigned long,struct tagPROPVARIANT & __ptr64) __ptr64 +?ReadProperty@CPropertyStore@@QEAAHKKAEAUtagPROPVARIANT@@@Z +; public: unsigned char __cdecl CDFA::Recognize(unsigned short const * __ptr64) __ptr64 +?Recognize@CDFA@@QEAAEPEBG@Z +; public: void __cdecl CCiRegParams::Refresh(struct ICiAdminParams * __ptr64,int) __ptr64 +?Refresh@CCiRegParams@@QEAAXPEAUICiAdminParams@@H@Z +; public: void __cdecl CDefColumnRegEntry::Refresh(int) __ptr64 +?Refresh@CDefColumnRegEntry@@QEAAXH@Z +; public: void __cdecl CWorkQueue::RefreshParams(unsigned long,unsigned long) __ptr64 +?RefreshParams@CWorkQueue@@QEAAXKK@Z +; public: virtual unsigned long __cdecl CDbProperties::Release(void) __ptr64 +?Release@CDbProperties@@UEAAKXZ +; public: virtual unsigned long __cdecl CEmptyPropertyList::Release(void) __ptr64 +?Release@CEmptyPropertyList@@UEAAKXZ +; public: virtual unsigned long __cdecl CEnumString::Release(void) __ptr64 +?Release@CEnumString@@UEAAKXZ +; public: virtual unsigned long __cdecl CEnumWorkid::Release(void) __ptr64 +?Release@CEnumWorkid@@UEAAKXZ +; public: virtual unsigned long __cdecl CFwPropertyMapper::Release(void) __ptr64 +?Release@CFwPropertyMapper@@UEAAKXZ +; public: void __cdecl CImpersonateRemoteAccess::Release(void) __ptr64 +?Release@CImpersonateRemoteAccess@@QEAAXXZ +; public: virtual unsigned long __cdecl CQueryUnknown::Release(void) __ptr64 +?Release@CQueryUnknown@@UEAAKXZ +; public: void __cdecl CWorkQueue::Release(class CWorkThread * __ptr64) __ptr64 +?Release@CWorkQueue@@QEAAXPEAVCWorkThread@@@Z +; private: void __cdecl CPropertyStore::ReleaseRead(class CReadWriteLockRecord & __ptr64) __ptr64 +?ReleaseRead@CPropertyStore@@AEAAXAEAVCReadWriteLockRecord@@@Z +; public: void __cdecl CWorkQueue::ReleaseWorkThreads(void) __ptr64 +?ReleaseWorkThreads@CWorkQueue@@QEAAXXZ +; public: void __cdecl CColumns::Remove(unsigned int) __ptr64 +?Remove@CColumns@@QEAAXI@Z +; public: void __cdecl CDbSortSet::Remove(unsigned int) __ptr64 +?Remove@CDbSortSet@@QEAAXI@Z +; public: void __cdecl CSort::Remove(unsigned int) __ptr64 +?Remove@CSort@@QEAAXI@Z +; private: void __cdecl CWorkQueue::Remove(class CWorkThread & __ptr64) __ptr64 +?Remove@CWorkQueue@@AEAAXAEAVCWorkThread@@@Z +; public: void __cdecl CWorkQueue::Remove(class PWorkItem * __ptr64) __ptr64 +?Remove@CWorkQueue@@QEAAXPEAVPWorkItem@@@Z +; public: void __cdecl CMachineAdmin::RemoveCatalog(unsigned short const * __ptr64,int) __ptr64 +?RemoveCatalog@CMachineAdmin@@QEAAXPEBGH@Z +; public: void __cdecl CMachineAdmin::RemoveCatalogFiles(unsigned short const * __ptr64) __ptr64 +?RemoveCatalogFiles@CMachineAdmin@@QEAAXPEBG@Z +; public: class CRestriction * __ptr64 __cdecl CNodeRestriction::RemoveChild(unsigned int) __ptr64 +?RemoveChild@CNodeRestriction@@QEAAPEAVCRestriction@@I@Z +; protected: class CDbCmdTreeNode * __ptr64 __cdecl CDbCmdTreeNode::RemoveFirstChild(void) __ptr64 +?RemoveFirstChild@CDbCmdTreeNode@@IEAAPEAV1@XZ +; public: void __cdecl CCatalogAdmin::RemoveScope(unsigned short const * __ptr64) __ptr64 +?RemoveScope@CCatalogAdmin@@QEAAXPEBG@Z +; public: void __cdecl CPhysStorage::Reopen(int) __ptr64 +?Reopen@CPhysStorage@@QEAAXH@Z +; public: void __cdecl CEventLog::ReportEventW(class CEventItem & __ptr64) __ptr64 +?ReportEventW@CEventLog@@QEAAXAEAVCEventItem@@@Z +; public: void __cdecl CFwEventItem::ReportEventW(struct ICiCAdviseStatus & __ptr64) __ptr64 +?ReportEventW@CFwEventItem@@QEAAXAEAUICiCAdviseStatus@@@Z +; public: int __cdecl CPhysStorage::RequiresFlush(unsigned long) __ptr64 +?RequiresFlush@CPhysStorage@@QEAAHK@Z +; public: void __cdecl CRegChangeEvent::Reset(void) __ptr64 +?Reset@CRegChangeEvent@@QEAAXXZ +; public: void __cdecl CQueryScanner::ResetBuffer(unsigned short const * __ptr64) __ptr64 +?ResetBuffer@CQueryScanner@@QEAAXPEBG@Z +; protected: void __cdecl CAllocStorageVariant::ResetType(class PMemoryAllocator & __ptr64) __ptr64 +?ResetType@CAllocStorageVariant@@IEAAXAEAVPMemoryAllocator@@@Z +; public: void __cdecl CProcess::Resume(void) __ptr64 +?Resume@CProcess@@QEAAXXZ +; public: void __cdecl CPhysStorage::ReturnBuffer(unsigned long,int,int) __ptr64 +?ReturnBuffer@CPhysStorage@@QEAAXKHH@Z +; public: void __cdecl CMmStreamConsecBuf::Rewind(void) __ptr64 +?Rewind@CMmStreamConsecBuf@@QEAAXXZ +; unsigned long __cdecl SaComputeSize(unsigned short,struct tagSAFEARRAY & __ptr64) +?SaComputeSize@@YAKGAEAUtagSAFEARRAY@@@Z +; int __cdecl SaCreateAndCopy(class PMemoryAllocator & __ptr64,struct tagSAFEARRAY * __ptr64,struct tagSAFEARRAY * __ptr64 * __ptr64) +?SaCreateAndCopy@@YAHAEAVPMemoryAllocator@@PEAUtagSAFEARRAY@@PEAPEAU2@@Z +; int __cdecl SaCreateData(class PVarAllocator & __ptr64,unsigned short,struct tagSAFEARRAY & __ptr64,struct tagSAFEARRAY & __ptr64,int) +?SaCreateData@@YAHAEAVPVarAllocator@@GAEAUtagSAFEARRAY@@1H@Z +; public: int __cdecl CRcovStrmTrans::Seek(unsigned long) __ptr64 +?Seek@CRcovStrmTrans@@QEAAHK@Z +; public: void __cdecl CDbQueryResults::Serialize(class PSerStream & __ptr64)const __ptr64 +?Serialize@CDbQueryResults@@QEBAXAEAVPSerStream@@@Z +; public: void __cdecl CPidRemapper::Set(class XArray & __ptr64) __ptr64 +?Set@CPidRemapper@@QEAAXAEAV?$XArray@K@@@Z +; public: void __cdecl CScopeAdmin::SetAlias(unsigned short const * __ptr64) __ptr64 +?SetAlias@CScopeAdmin@@QEAAXPEBG@Z +; public: void __cdecl CStorageVariant::SetBOOL(short,unsigned int) __ptr64 +?SetBOOL@CStorageVariant@@QEAAXFI@Z +; public: void __cdecl CAllocStorageVariant::SetBSTR(unsigned short * __ptr64,class PMemoryAllocator & __ptr64) __ptr64 +?SetBSTR@CAllocStorageVariant@@QEAAXPEAGAEAVPMemoryAllocator@@@Z +; public: void __cdecl CStorageVariant::SetBSTR(unsigned short * __ptr64,unsigned int) __ptr64 +?SetBSTR@CStorageVariant@@QEAAXPEAGI@Z +; public: void __cdecl CPropStoreManager::SetBackupSize(unsigned long,unsigned long) __ptr64 +?SetBackupSize@CPropStoreManager@@QEAAXKK@Z +; public: void __cdecl CCatState::SetCD(unsigned short const * __ptr64) __ptr64 +?SetCD@CCatState@@QEAAXPEBG@Z +; public: void __cdecl CStorageVariant::SetCLSID(struct _GUID const * __ptr64) __ptr64 +?SetCLSID@CStorageVariant@@QEAAXPEBU_GUID@@@Z +; public: void __cdecl CStorageVariant::SetCLSID(struct _GUID,unsigned int) __ptr64 +?SetCLSID@CStorageVariant@@QEAAXU_GUID@@I@Z +; public: void __cdecl CStorageVariant::SetCY(union tagCY,unsigned int) __ptr64 +?SetCY@CStorageVariant@@QEAAXTtagCY@@I@Z +; public: void __cdecl CCatState::SetCatalog(unsigned short const * __ptr64) __ptr64 +?SetCatalog@CCatState@@QEAAXPEBG@Z +; public: void __cdecl CCatState::SetColumn(unsigned short const * __ptr64,unsigned int) __ptr64 +?SetColumn@CCatState@@QEAAXPEBGI@Z +; private: void __cdecl CQueryParser::SetCurrentProperty(unsigned short const * __ptr64,enum PropertyType) __ptr64 +?SetCurrentProperty@CQueryParser@@AEAAXPEBGW4PropertyType@@@Z +; public: void __cdecl CStorageVariant::SetDATE(double,unsigned int) __ptr64 +?SetDATE@CStorageVariant@@QEAAXNI@Z +; public: void __cdecl CCatalogAdmin::SetDWORDParam(unsigned short const * __ptr64,unsigned long) __ptr64 +?SetDWORDParam@CCatalogAdmin@@QEAAXPEBGK@Z +; public: void __cdecl CMachineAdmin::SetDWORDParam(unsigned short const * __ptr64,unsigned long) __ptr64 +?SetDWORDParam@CMachineAdmin@@QEAAXPEBGK@Z +; public: void __cdecl CCatState::SetDefaultProperty(unsigned short const * __ptr64) __ptr64 +?SetDefaultProperty@CCatState@@QEAAXPEBG@Z +; public: void __cdecl CScopeAdmin::SetExclude(int) __ptr64 +?SetExclude@CScopeAdmin@@QEAAXH@Z +; public: void __cdecl CStorageVariant::SetFILETIME(struct _FILETIME,unsigned int) __ptr64 +?SetFILETIME@CStorageVariant@@QEAAXU_FILETIME@@I@Z +; public: void __cdecl CStorageVariant::SetI2(short,unsigned int) __ptr64 +?SetI2@CStorageVariant@@QEAAXFI@Z +; public: void __cdecl CStorageVariant::SetI4(long,unsigned int) __ptr64 +?SetI4@CStorageVariant@@QEAAXJI@Z +; public: void __cdecl CStorageVariant::SetI8(union _LARGE_INTEGER,unsigned int) __ptr64 +?SetI8@CStorageVariant@@QEAAXT_LARGE_INTEGER@@I@Z +; public: void __cdecl CStorageVariant::SetLPSTR(char const * __ptr64,unsigned int) __ptr64 +?SetLPSTR@CStorageVariant@@QEAAXPEBDI@Z +; public: void __cdecl CStorageVariant::SetLPWSTR(unsigned short const * __ptr64,unsigned int) __ptr64 +?SetLPWSTR@CStorageVariant@@QEAAXPEBGI@Z +; public: void __cdecl CCatState::SetLocale(unsigned short const * __ptr64) __ptr64 +?SetLocale@CCatState@@QEAAXPEBG@Z +; public: void __cdecl CScopeAdmin::SetLogonInfo(unsigned short const * __ptr64,unsigned short const * __ptr64,class CCatalogAdmin & __ptr64) __ptr64 +?SetLogonInfo@CScopeAdmin@@QEAAXPEBG0AEAVCCatalogAdmin@@@Z +; public: void __cdecl CPropStoreManager::SetMappedCacheSize(unsigned long,unsigned long) __ptr64 +?SetMappedCacheSize@CPropStoreManager@@QEAAXKK@Z +; public: void __cdecl CCatState::SetNumberOfColumns(unsigned int) __ptr64 +?SetNumberOfColumns@CCatState@@QEAAXI@Z +; public: void __cdecl CCatState::SetNumberOfSortProps(unsigned int) __ptr64 +?SetNumberOfSortProps@CCatState@@QEAAXI@Z +; public: void __cdecl CScopeAdmin::SetPath(unsigned short const * __ptr64) __ptr64 +?SetPath@CScopeAdmin@@QEAAXPEBG@Z +; public: void __cdecl CContentRestriction::SetPhrase(unsigned short const * __ptr64) __ptr64 +?SetPhrase@CContentRestriction@@QEAAXPEBG@Z +; public: void __cdecl CNatLanguageRestriction::SetPhrase(unsigned short const * __ptr64) __ptr64 +?SetPhrase@CNatLanguageRestriction@@QEAAXPEBG@Z +; public: void __cdecl CGenericCiProxy::SetPriority(unsigned long,unsigned long) __ptr64 +?SetPriority@CGenericCiProxy@@QEAAXKK@Z +; public: virtual long __cdecl CDbProperties::SetProperties(unsigned long,struct tagDBPROPSET * __ptr64 const) __ptr64 +?SetProperties@CDbProperties@@UEAAJKQEAUtagDBPROPSET@@@Z +; public: int __cdecl CDbColId::SetProperty(unsigned short const * __ptr64) __ptr64 +?SetProperty@CDbColId@@QEAAHPEBG@Z +; public: int __cdecl CDbPropBaseRestriction::SetProperty(struct tagDBID const & __ptr64) __ptr64 +?SetProperty@CDbPropBaseRestriction@@QEAAHAEBUtagDBID@@@Z +; public: int __cdecl CDbPropBaseRestriction::SetProperty(class CDbColumnNode const & __ptr64) __ptr64 +?SetProperty@CDbPropBaseRestriction@@QEAAHAEBVCDbColumnNode@@@Z +; public: int __cdecl CFullPropSpec::SetProperty(unsigned short const * __ptr64) __ptr64 +?SetProperty@CFullPropSpec@@QEAAHPEBG@Z +; public: void __cdecl CFullPropSpec::SetProperty(unsigned long) __ptr64 +?SetProperty@CFullPropSpec@@QEAAXK@Z +; public: void __cdecl CStorageVariant::SetR4(float,unsigned int) __ptr64 +?SetR4@CStorageVariant@@QEAAXMI@Z +; public: void __cdecl CStorageVariant::SetR8(double,unsigned int) __ptr64 +?SetR8@CStorageVariant@@QEAAXNI@Z +; public: int __cdecl CDbSelectNode::SetRestriction(class CDbCmdTreeNode * __ptr64) __ptr64 +?SetRestriction@CDbSelectNode@@QEAAHPEAVCDbCmdTreeNode@@@Z +; public: static void __cdecl CImpersonateSystem::SetRunningAsSystem(void) +?SetRunningAsSystem@CImpersonateSystem@@SAXXZ +; public: void __cdecl CMachineAdmin::SetSZParam(unsigned short const * __ptr64,unsigned short const * __ptr64,unsigned long) __ptr64 +?SetSZParam@CMachineAdmin@@QEAAXPEBG0K@Z +; void __cdecl SetScopeProperties(struct ICommand * __ptr64,unsigned int,unsigned short const * __ptr64 const * __ptr64,unsigned long const * __ptr64,unsigned short const * __ptr64 const * __ptr64,unsigned short const * __ptr64 const * __ptr64) +?SetScopeProperties@@YAXPEAUICommand@@IPEBQEBGPEBK11@Z +; long __cdecl SetScopePropertiesNoThrow(struct ICommand * __ptr64,unsigned int,unsigned short const * __ptr64 const * __ptr64,unsigned long const * __ptr64,unsigned short const * __ptr64 const * __ptr64,unsigned short const * __ptr64 const * __ptr64) +?SetScopePropertiesNoThrow@@YAJPEAUICommand@@IPEBQEBGPEBK11@Z +; void __cdecl SetSecret(unsigned short const * __ptr64,unsigned short const * __ptr64,unsigned short const * __ptr64,unsigned long) +?SetSecret@@YAXPEBG00K@Z +; public: void __cdecl CCatState::SetSortProp(unsigned short const * __ptr64,enum SORTDIR,unsigned int) __ptr64 +?SetSortProp@CCatState@@QEAAXPEBGW4SORTDIR@@I@Z +; public: void __cdecl CStorageVariant::SetUI1(unsigned char,unsigned int) __ptr64 +?SetUI1@CStorageVariant@@QEAAXEI@Z +; public: void __cdecl CStorageVariant::SetUI2(unsigned short,unsigned int) __ptr64 +?SetUI2@CStorageVariant@@QEAAXGI@Z +; public: void __cdecl CStorageVariant::SetUI4(unsigned long,unsigned int) __ptr64 +?SetUI4@CStorageVariant@@QEAAXKI@Z +; public: void __cdecl CStorageVariant::SetUI8(union _ULARGE_INTEGER,unsigned int) __ptr64 +?SetUI8@CStorageVariant@@QEAAXT_ULARGE_INTEGER@@I@Z +; public: void __cdecl CPropertyRestriction::SetValue(struct tagBLOB & __ptr64) __ptr64 +?SetValue@CPropertyRestriction@@QEAAXAEAUtagBLOB@@@Z +; public: void __cdecl CPropertyRestriction::SetValue(unsigned short * __ptr64) __ptr64 +?SetValue@CPropertyRestriction@@QEAAXPEAG@Z +; public: void __cdecl CPropertyRestriction::SetValue(struct _GUID * __ptr64) __ptr64 +?SetValue@CPropertyRestriction@@QEAAXPEAU_GUID@@@Z +; public: void __cdecl CDbCmdTreeNode::SetWeight(long) __ptr64 +?SetWeight@CDbCmdTreeNode@@QEAAXJ@Z +; public: void __cdecl CPropStoreManager::Setup(unsigned long,unsigned long,unsigned long,unsigned __int64,int,unsigned long) __ptr64 +?Setup@CPropStoreManager@@QEAAXKKK_KHK@Z +; public: void __cdecl CDynStream::Shrink(class PStorage & __ptr64,unsigned long) __ptr64 +?Shrink@CDynStream@@QEAAXAEAVPStorage@@K@Z +; public: unsigned long __cdecl CPhysStorage::ShrinkFromFront(unsigned long,unsigned long) __ptr64 +?ShrinkFromFront@CPhysStorage@@QEAAKKK@Z +; public: void __cdecl CPhysStorage::ShrinkToFit(void) __ptr64 +?ShrinkToFit@CPhysStorage@@QEAAXXZ +; public: static void __cdecl CCiOle::Shutdown(void) +?Shutdown@CCiOle@@SAXXZ +; public: void __cdecl CPropStoreManager::Shutdown(void) __ptr64 +?Shutdown@CPropStoreManager@@QEAAXXZ +; public: void __cdecl CWorkQueue::Shutdown(void) __ptr64 +?Shutdown@CWorkQueue@@QEAAXXZ +; public: unsigned long __cdecl CDbQueryResults::Size(void) __ptr64 +?Size@CDbQueryResults@@QEAAKXZ +; public: virtual long __cdecl CEnumString::Skip(unsigned long) __ptr64 +?Skip@CEnumString@@UEAAJK@Z +; public: virtual long __cdecl CEnumWorkid::Skip(unsigned long) __ptr64 +?Skip@CEnumWorkid@@UEAAJK@Z +; public: virtual void __cdecl CMemDeSerStream::SkipBlob(unsigned long) __ptr64 +?SkipBlob@CMemDeSerStream@@UEAAXK@Z +; public: virtual void __cdecl CMemDeSerStream::SkipByte(void) __ptr64 +?SkipByte@CMemDeSerStream@@UEAAXXZ +; public: virtual void __cdecl CMemDeSerStream::SkipChar(unsigned long) __ptr64 +?SkipChar@CMemDeSerStream@@UEAAXK@Z +; public: virtual void __cdecl CMemDeSerStream::SkipDouble(void) __ptr64 +?SkipDouble@CMemDeSerStream@@UEAAXXZ +; public: virtual void __cdecl CMemDeSerStream::SkipFloat(void) __ptr64 +?SkipFloat@CMemDeSerStream@@UEAAXXZ +; public: virtual void __cdecl CMemDeSerStream::SkipGUID(void) __ptr64 +?SkipGUID@CMemDeSerStream@@UEAAXXZ +; public: virtual void __cdecl CMemDeSerStream::SkipLong(void) __ptr64 +?SkipLong@CMemDeSerStream@@UEAAXXZ +; public: virtual void __cdecl CMemDeSerStream::SkipULong(void) __ptr64 +?SkipULong@CMemDeSerStream@@UEAAXXZ +; public: virtual void __cdecl CMemDeSerStream::SkipUShort(void) __ptr64 +?SkipUShort@CMemDeSerStream@@UEAAXXZ +; public: virtual void __cdecl CMemDeSerStream::SkipWChar(unsigned long) __ptr64 +?SkipWChar@CMemDeSerStream@@UEAAXK@Z +; public: int __cdecl CCatalogAdmin::Start(void) __ptr64 +?Start@CCatalogAdmin@@QEAAHXZ +; public: int __cdecl CMachineAdmin::StartCI(void) __ptr64 +?StartCI@CMachineAdmin@@QEAAHXZ +; public: int __cdecl CCatalogAdmin::Stop(void) __ptr64 +?Stop@CCatalogAdmin@@QEAAHXZ +; public: int __cdecl CMachineAdmin::StopCI(void) __ptr64 +?StopCI@CMachineAdmin@@QEAAHXZ +; public: void __cdecl CFilterDaemon::StopFiltering(void) __ptr64 +?StopFiltering@CFilterDaemon@@QEAAXXZ +; public: unsigned int __cdecl CKey::StrLen(void)const __ptr64 +?StrLen@CKey@@QEBAIXZ +; public: unsigned int __cdecl CKeyBuf::StrLen(void)const __ptr64 +?StrLen@CKeyBuf@@QEBAIXZ +; void __cdecl SystemExceptionTranslator(unsigned int,struct _EXCEPTION_POINTERS * __ptr64) +?SystemExceptionTranslator@@YAXIPEAU_EXCEPTION_POINTERS@@@Z +; public: unsigned long __cdecl CRestriction::TreeCount(void)const __ptr64 +?TreeCount@CRestriction@@QEBAKXZ +; public: void __cdecl CMachineAdmin::TunePerformance(int,unsigned short,unsigned short) __ptr64 +?TunePerformance@CMachineAdmin@@QEAAXHGG@Z +; void __cdecl URLEscapeW(unsigned short const * __ptr64,class CVirtualString & __ptr64,unsigned long,int) +?URLEscapeW@@YAXPEBGAEAVCVirtualString@@KH@Z +; public: int __cdecl CDbProperties::UnMarshall(class PDeSerStream & __ptr64) __ptr64 +?UnMarshall@CDbProperties@@QEAAHAEAVPDeSerStream@@@Z +; public: static class CRestriction * __ptr64 __cdecl CRestriction::UnMarshall(class PDeSerStream & __ptr64) +?UnMarshall@CRestriction@@SAPEAV1@AEAVPDeSerStream@@@Z +; public: static class CDbCmdTreeNode * __ptr64 __cdecl CDbCmdTreeNode::UnMarshallTree(class PDeSerStream & __ptr64) +?UnMarshallTree@CDbCmdTreeNode@@SAPEAV1@AEAVPDeSerStream@@@Z +; void __cdecl UnPickle(int,class XPtr & __ptr64,class XPtr & __ptr64,class XPtr & __ptr64,class XPtr & __ptr64,class CRowsetProperties & __ptr64,class XPtr & __ptr64,unsigned char * __ptr64,unsigned long) +?UnPickle@@YAXHAEAV?$XPtr@VCColumnSet@@@@AEAV?$XPtr@VCRestriction@@@@AEAV?$XPtr@VCSortSet@@@@AEAV?$XPtr@VCCategorizationSet@@@@AEAVCRowsetProperties@@AEAV?$XPtr@VCPidMapper@@@@PEAEK@Z +; protected: void __cdecl CRcovStrmTrans::Unmap(enum CRcovStorageHdr::DataCopyNum) __ptr64 +?Unmap@CRcovStrmTrans@@IEAAXW4DataCopyNum@CRcovStorageHdr@@@Z +; unsigned long __cdecl UpdateContentIndex(unsigned short const * __ptr64,unsigned short const * __ptr64,unsigned short const * __ptr64,int) +?UpdateContentIndex@@YAKPEBG00H@Z +; public: void __cdecl CDiskFreeStatus::UpdateDiskLowInfo(void) __ptr64 +?UpdateDiskLowInfo@CDiskFreeStatus@@QEAAXXZ +; int __cdecl VT_VARIANT_EQ(struct tagPROPVARIANT const & __ptr64,struct tagPROPVARIANT const & __ptr64) +?VT_VARIANT_EQ@@YAHAEBUtagPROPVARIANT@@0@Z +; int __cdecl VT_VARIANT_GE(struct tagPROPVARIANT const & __ptr64,struct tagPROPVARIANT const & __ptr64) +?VT_VARIANT_GE@@YAHAEBUtagPROPVARIANT@@0@Z +; int __cdecl VT_VARIANT_GT(struct tagPROPVARIANT const & __ptr64,struct tagPROPVARIANT const & __ptr64) +?VT_VARIANT_GT@@YAHAEBUtagPROPVARIANT@@0@Z +; int __cdecl VT_VARIANT_LE(struct tagPROPVARIANT const & __ptr64,struct tagPROPVARIANT const & __ptr64) +?VT_VARIANT_LE@@YAHAEBUtagPROPVARIANT@@0@Z +; int __cdecl VT_VARIANT_LT(struct tagPROPVARIANT const & __ptr64,struct tagPROPVARIANT const & __ptr64) +?VT_VARIANT_LT@@YAHAEBUtagPROPVARIANT@@0@Z +; int __cdecl VT_VARIANT_NE(struct tagPROPVARIANT const & __ptr64,struct tagPROPVARIANT const & __ptr64) +?VT_VARIANT_NE@@YAHAEBUtagPROPVARIANT@@0@Z +; int __cdecl ValidateScopeRestriction(class CRestriction * __ptr64) +?ValidateScopeRestriction@@YAHPEAVCRestriction@@@Z +; public: void __cdecl PRcovStorageObj::VerifyConsistency(void) __ptr64 +?VerifyConsistency@PRcovStorageObj@@QEAAXXZ +; void __cdecl VerifyThreadHasAdminPrivilege(void) +?VerifyThreadHasAdminPrivilege@@YAXXZ +; unsigned long __cdecl WideCharToXArrayMultiByte(unsigned short const * __ptr64,unsigned long,unsigned int,class XArray & __ptr64) +?WideCharToXArrayMultiByte@@YAKPEBGKIAEAV?$XArray@E@@@Z +; public: void __cdecl CDynStream::Write(void * __ptr64,unsigned long) __ptr64 +?Write@CDynStream@@QEAAXPEAXK@Z +; protected: void __cdecl CRcovStrmTrans::Write(void const * __ptr64,unsigned long) __ptr64 +?Write@CRcovStrmTrans@@IEAAXPEBXK@Z +; public: long __cdecl CPropStoreManager::WritePrimaryProperty(class CCompositePropRecordForWrites & __ptr64,unsigned long,class CStorageVariant const & __ptr64) __ptr64 +?WritePrimaryProperty@CPropStoreManager@@QEAAJAEAVCCompositePropRecordForWrites@@KAEBVCStorageVariant@@@Z +; public: long __cdecl CPropStoreManager::WritePrimaryProperty(unsigned long,unsigned long,class CStorageVariant const & __ptr64) __ptr64 +?WritePrimaryProperty@CPropStoreManager@@QEAAJKKAEBVCStorageVariant@@@Z +; public: long __cdecl CPropStoreManager::WriteProperty(class CCompositePropRecordForWrites & __ptr64,unsigned long,class CStorageVariant const & __ptr64) __ptr64 +?WriteProperty@CPropStoreManager@@QEAAJAEAVCCompositePropRecordForWrites@@KAEBVCStorageVariant@@@Z +; public: long __cdecl CPropStoreManager::WriteProperty(unsigned long,unsigned long,class CStorageVariant const & __ptr64) __ptr64 +?WriteProperty@CPropStoreManager@@QEAAJKKAEBVCStorageVariant@@@Z +; public: unsigned long __cdecl CPropStoreManager::WritePropertyInNewRecord(unsigned long,class CStorageVariant const & __ptr64) __ptr64 +?WritePropertyInNewRecord@CPropStoreManager@@QEAAKKAEBVCStorageVariant@@@Z +; private: class CDbProjectListAnchor * __ptr64 __cdecl CDbNestingNode::_FindGroupListAnchor(void) __ptr64 +?_FindGroupListAnchor@CDbNestingNode@@AEAAPEAVCDbProjectListAnchor@@XZ +; private: class CDbProjectListAnchor * __ptr64 __cdecl CDbProjectNode::_FindOrAddAnchor(void) __ptr64 +?_FindOrAddAnchor@CDbProjectNode@@AEAAPEAVCDbProjectListAnchor@@XZ +; private: class CDbSortListAnchor * __ptr64 __cdecl CDbSortNode::_FindOrAddAnchor(void) __ptr64 +?_FindOrAddAnchor@CDbSortNode@@AEAAPEAVCDbSortListAnchor@@XZ +; private: class CDbScalarValue * __ptr64 __cdecl CDbPropertyRestriction::_FindOrAddValueNode(void) __ptr64 +?_FindOrAddValueNode@CDbPropertyRestriction@@AEAAPEAVCDbScalarValue@@XZ +; private: int __cdecl CImpersonateRemoteAccess::_ImpersonateIf(unsigned short const * __ptr64,unsigned short const * __ptr64,unsigned long) __ptr64 +?_ImpersonateIf@CImpersonateRemoteAccess@@AEAAHPEBG0K@Z +; unsigned __int64 __cdecl _wcstoui64(unsigned short const * __ptr64,unsigned short * __ptr64 * __ptr64,int) +?_wcstoui64@@YA_KPEBGPEAPEAGH@Z +; void __cdecl ciDelete(void * __ptr64) +?ciDelete@@YAXPEAX@Z +; int __cdecl ciIsValidPointer(void const * __ptr64) +?ciIsValidPointer@@YAHPEBX@Z +; void * __ptr64 __cdecl ciNew(unsigned __int64) +?ciNew@@YAPEAX_K@Z +; public: unsigned long __cdecl CFileBuffer::fgetsw(class XGrowable & __ptr64) __ptr64 +?fgetsw@CFileBuffer@@QEAAKAEAV?$XGrowable@G$0BAE@@@@Z +; unsigned short * __ptr64 __cdecl wcsipattern(unsigned short * __ptr64,unsigned short const * __ptr64) +?wcsipattern@@YAPEAGPEAGPEBG@Z +AbortMerges +BeginCacheTransaction +BindIFilterFromStorage +BindIFilterFromStream +CIBuildQueryNode +CIBuildQueryTree +CICreateCommand +CIGetGlobalPropertyList +CIMakeICommand +CIRestrictionToFullTree +CIState +CITextToFullTree +CITextToFullTreeEx +CITextToSelectTree +CITextToSelectTreeEx +CiSvcMain +CollectCIISAPIPerformanceData +CollectCIPerformanceData +CollectFILTERPerformanceData +DllCanUnloadNow +DllGetClassObject +DllRegisterServer +DllUnregisterServer +DoneCIISAPIPerformanceData +DoneCIPerformanceData +DoneFILTERPerformanceData +EndCacheTransaction +ForceMasterMerge +InitializeCIISAPIPerformanceData +InitializeCIPerformanceData +InitializeFILTERPerformanceData +LoadBHIFilter +LoadBinaryFilter +LoadIFilter +LoadIFilterEx +LoadTextFilter +LocateCatalogs +LocateCatalogsA +LocateCatalogsW +SetCatalogState +SetupCache +SetupCacheEx +StartFWCiSvcWork +StopFWCiSvcWork +SvcEntry_CiSvc diff --git a/lib/libc/mingw/lib64/rasapi32.def b/lib/libc/mingw/lib64/rasapi32.def new file mode 100644 index 0000000000..effabee0f2 --- /dev/null +++ b/lib/libc/mingw/lib64/rasapi32.def @@ -0,0 +1,150 @@ +; +; Exports of file RASAPI32.dll +; +; Autogenerated by gen_exportdef +; Written by Kai Tietz, 2007 +; +LIBRARY RASAPI32.dll +EXPORTS +DDMFreePhonebookContext +DDMGetPhonebookInfo +DwCloneEntry +DwDeleteSubEntry +DwEnumEntriesForAllUsers +DwEnumEntryDetails +DwRasUninitialize +RasAutoDialSharedConnection +RasAutodialAddressToNetwork +RasAutodialEntryToNetwork +RasClearConnectionStatistics +RasClearLinkStatistics +RasConnectionNotificationA +RasConnectionNotificationW +RasCreatePhonebookEntryA +RasCreatePhonebookEntryW +RasDeleteEntryA +RasDeleteEntryW +RasDeleteSubEntryA +RasDeleteSubEntryW +RasDialA +RasDialW +RasDialWow +RasEditPhonebookEntryA +RasEditPhonebookEntryW +RasEnumAutodialAddressesA +RasEnumAutodialAddressesW +RasEnumConnectionsA +RasEnumConnectionsW +RasEnumConnectionsWow +RasEnumDevicesA +RasEnumDevicesW +RasEnumEntriesA +RasEnumEntriesW +RasEnumEntriesWow +RasFreeEapUserIdentityA +RasFreeEapUserIdentityW +RasGetAutodialAddressA +RasGetAutodialAddressW +RasGetAutodialEnableA +RasGetAutodialEnableW +RasGetAutodialParamA +RasGetAutodialParamW +RasGetConnectResponse +RasGetConnectStatusA +RasGetConnectStatusW +RasGetConnectStatusWow +RasGetConnectionStatistics +RasGetCountryInfoA +RasGetCountryInfoW +RasGetCredentialsA +RasGetCredentialsW +RasGetCustomAuthDataA +RasGetCustomAuthDataW +RasGetEapUserDataA +RasGetEapUserDataW +RasGetEapUserIdentityA +RasGetEapUserIdentityW +RasGetEntryDialParamsA +RasGetEntryDialParamsW +RasGetEntryHrasconnA +RasGetEntryHrasconnW +RasGetEntryPropertiesA +RasGetEntryPropertiesW +RasGetErrorStringA +RasGetErrorStringW +RasGetErrorStringWow +RasGetHport +RasGetLinkStatistics +RasGetProjectionInfoA +RasGetProjectionInfoW +RasGetSubEntryHandleA +RasGetSubEntryHandleW +RasGetSubEntryPropertiesA +RasGetSubEntryPropertiesW +RasHangUpA +RasHangUpW +RasHangUpWow +RasInvokeEapUI +RasIsRouterConnection +RasIsSharedConnection +RasQueryRedialOnLinkFailure +RasQuerySharedAutoDial +RasQuerySharedConnection +RasRenameEntryA +RasRenameEntryW +RasScriptExecute +RasScriptGetEventCode +RasScriptGetIpAddress +RasScriptInit +RasScriptReceive +RasScriptSend +RasScriptTerm +RasSetAutodialAddressA +RasSetAutodialAddressW +RasSetAutodialEnableA +RasSetAutodialEnableW +RasSetAutodialParamA +RasSetAutodialParamW +RasSetCredentialsA +RasSetCredentialsW +RasSetCustomAuthDataA +RasSetCustomAuthDataW +RasSetEapUserDataA +RasSetEapUserDataW +RasSetEntryDialParamsA +RasSetEntryDialParamsW +RasSetEntryPropertiesA +RasSetEntryPropertiesW +RasSetOldPassword +RasSetSharedAutoDial +RasSetSubEntryPropertiesA +RasSetSubEntryPropertiesW +RasValidateEntryNameA +RasValidateEntryNameW +RasfileClose +RasfileDeleteLine +RasfileFindFirstLine +RasfileFindLastLine +RasfileFindMarkedLine +RasfileFindNextKeyLine +RasfileFindNextLine +RasfileFindPrevLine +RasfileFindSectionLine +RasfileGetKeyValueFields +RasfileGetLine +RasfileGetLineMark +RasfileGetLineText +RasfileGetLineType +RasfileGetSectionName +RasfileInsertLine +RasfileLoad +RasfileLoadEx +RasfileLoadInfo +RasfilePutKeyValueFields +RasfilePutLineMark +RasfilePutLineText +RasfilePutSectionName +RasfileWrite +SharedAccessResponseListToString +SharedAccessResponseStringToList +UnInitializeRAS diff --git a/lib/libc/mingw/lib64/rasdlg.def b/lib/libc/mingw/lib64/rasdlg.def new file mode 100644 index 0000000000..b5a82d2227 --- /dev/null +++ b/lib/libc/mingw/lib64/rasdlg.def @@ -0,0 +1,45 @@ +; +; Exports of file RASDLG.dll +; +; Autogenerated by gen_exportdef +; Written by Kai Tietz, 2007 +; +LIBRARY RASDLG.dll +EXPORTS +DwTerminalDlg +GetRasDialOutProtocols +RasAutodialDisableDlgA +RasAutodialDisableDlgW +RasAutodialQueryDlgA +RasAutodialQueryDlgW +RasDialDlgA +RasDialDlgW +RasEntryDlgA +RasEntryDlgW +RasMonitorDlgA +RasMonitorDlgW +RasPhonebookDlgA +RasPhonebookDlgW +RasSrvAddPropPages +RasSrvAddWizPages +RasSrvAllowConnectionsConfig +RasSrvCleanupService +RasSrvEnumConnections +RasSrvHangupConnection +RasSrvInitializeService +RasSrvIsConnectionConnected +RasSrvIsICConfigured +RasSrvIsServiceRunning +RasSrvQueryShowIcon +RasUserEnableManualDial +RasUserGetManualDial +RasUserPrefsDlg +RasWizCreateNewEntry +RasWizGetNCCFlags +RasWizGetSuggestedEntryName +RasWizGetUserInputConnectionName +RasWizIsEntryRenamable +RasWizQueryMaxPageCount +RasWizSetEntryName +RouterEntryDlgA +RouterEntryDlgW diff --git a/lib/libc/mingw/lib64/rtm.def b/lib/libc/mingw/lib64/rtm.def new file mode 100644 index 0000000000..bbf9357e1e --- /dev/null +++ b/lib/libc/mingw/lib64/rtm.def @@ -0,0 +1,120 @@ +; +; Exports of file rtm.dll +; +; Autogenerated by gen_exportdef +; Written by Kai Tietz, 2007 +; +LIBRARY rtm.dll +EXPORTS +BestMatchInTable +CheckTable +CreateTable +DeleteFromTable +DestroyTable +DumpTable +EnumOverTable +InsertIntoTable +MgmAddGroupMembershipEntry +MgmDeInitialize +MgmDeRegisterMProtocol +MgmDeleteGroupMembershipEntry +MgmGetFirstMfe +MgmGetFirstMfeStats +MgmGetMfe +MgmGetMfeStats +MgmGetNextMfe +MgmGetNextMfeStats +MgmGetProtocolOnInterface +MgmGroupEnumerationEnd +MgmGroupEnumerationGetNext +MgmGroupEnumerationStart +MgmInitialize +MgmRegisterMProtocol +MgmReleaseInterfaceOwnership +MgmTakeInterfaceOwnership +NextMatchInTable +RtmAddNextHop +RtmAddRoute +RtmAddRouteToDest +RtmBlockConvertRoutesToStatic +RtmBlockDeleteRoutes +RtmBlockMethods +RtmBlockSetRouteEnable +RtmCloseEnumerationHandle +RtmCreateDestEnum +RtmCreateEnumerationHandle +RtmCreateNextHopEnum +RtmCreateRouteEnum +RtmCreateRouteList +RtmCreateRouteListEnum +RtmCreateRouteTable +RtmDeleteEnumHandle +RtmDeleteNextHop +RtmDeleteRoute +RtmDeleteRouteList +RtmDeleteRouteTable +RtmDeleteRouteToDest +RtmDequeueRouteChangeMessage +RtmDereferenceHandles +RtmDeregisterClient +RtmDeregisterEntity +RtmDeregisterFromChangeNotification +RtmEnumerateGetNextRoute +RtmFindNextHop +RtmGetAddressFamilyInfo +RtmGetChangeStatus +RtmGetChangedDests +RtmGetDestInfo +RtmGetEntityInfo +RtmGetEntityMethods +RtmGetEnumDests +RtmGetEnumNextHops +RtmGetEnumRoutes +RtmGetExactMatchDestination +RtmGetExactMatchRoute +RtmGetFirstRoute +RtmGetInstanceInfo +RtmGetInstances +RtmGetLessSpecificDestination +RtmGetListEnumRoutes +RtmGetMostSpecificDestination +RtmGetNetworkCount +RtmGetNextHopInfo +RtmGetNextHopPointer +RtmGetNextRoute +RtmGetOpaqueInformationPointer +RtmGetRegisteredEntities +RtmGetRouteAge +RtmGetRouteInfo +RtmGetRoutePointer +RtmHoldDestination +RtmIgnoreChangedDests +RtmInsertInRouteList +RtmInvokeMethod +RtmIsBestRoute +RtmIsMarkedForChangeNotification +RtmIsRoute +RtmLockDestination +RtmLockNextHop +RtmLockRoute +RtmLookupIPDestination +RtmMarkDestForChangeNotification +RtmReadAddressFamilyConfig +RtmReadInstanceConfig +RtmReferenceHandles +RtmRegisterClient +RtmRegisterEntity +RtmRegisterForChangeNotification +RtmReleaseChangedDests +RtmReleaseDestInfo +RtmReleaseDests +RtmReleaseEntities +RtmReleaseEntityInfo +RtmReleaseNextHopInfo +RtmReleaseNextHops +RtmReleaseRouteInfo +RtmReleaseRoutes +RtmUpdateAndUnlockRoute +RtmWriteAddressFamilyConfig +RtmWriteInstanceConfig +SearchInTable diff --git a/lib/libc/mingw/lib64/sfc.def b/lib/libc/mingw/lib64/sfc.def new file mode 100644 index 0000000000..f528a33964 --- /dev/null +++ b/lib/libc/mingw/lib64/sfc.def @@ -0,0 +1,16 @@ +; +; Exports of file sfc.dll +; +; Autogenerated by gen_exportdef +; Written by Kai Tietz, 2007 +; +LIBRARY sfc.dll +EXPORTS +SRSetRestorePoint +SRSetRestorePointA +SRSetRestorePointW +SfcGetNextProtectedFile +SfcIsFileProtected +SfcWLEventLogoff +SfcWLEventLogon +SfpVerifyFile diff --git a/lib/libc/mingw/lib64/shdocvw.def b/lib/libc/mingw/lib64/shdocvw.def new file mode 100644 index 0000000000..5adb045fc0 --- /dev/null +++ b/lib/libc/mingw/lib64/shdocvw.def @@ -0,0 +1,36 @@ +; +; Exports of file SHDOCVW.dll +; +; Autogenerated by gen_exportdef +; Written by Kai Tietz, 2007 +; +LIBRARY SHDOCVW.dll +EXPORTS +AddUrlToFavorites +DllCanUnloadNow +DllGetClassObject +DllGetVersion +DllInstall +DllRegisterServer +DllRegisterWindowClasses +DllUnregisterServer +DoAddToFavDlg +DoAddToFavDlgW +DoFileDownload +DoFileDownloadEx +DoOrganizeFavDlg +DoOrganizeFavDlgW +DoPrivacyDlg +HlinkFindFrame +HlinkFrameNavigate +HlinkFrameNavigateNHL +IEWriteErrorLog +ImportPrivacySettings +SHAddSubscribeFavorite +OpenURL +SHGetIDispatchForFolder +SetQueryNetSessionCount +SetShellOfflineState +SoftwareUpdateMessageBox +URLQualifyA +URLQualifyW diff --git a/lib/libc/mingw/lib64/slc.def b/lib/libc/mingw/lib64/slc.def new file mode 100644 index 0000000000..09e0dbd62d --- /dev/null +++ b/lib/libc/mingw/lib64/slc.def @@ -0,0 +1,55 @@ +; +; Definition file of slc.dll +; Automatic generated by gendef +; written by Kai Tietz 2008 +; +LIBRARY "slc.dll" +EXPORTS +SLpAuthenticateGenuineTicketResponse +SLpBeginGenuineTicketTransaction +SLpCheckProductKey +SLpDepositTokenActivationResponse +SLpGenerateTokenActivationChallenge +SLpGetGenuineBlob +SLpGetGenuineLocal +SLpGetLicenseAcquisitionInfo +SLpGetMachineUGUID +SLpGetTokenActivationGrantInfo +SLpVLActivateProduct +SLClose +SLConsumeRight +SLConsumeWindowsRight +SLDepositOfflineConfirmationId +SLFireEvent +SLGenerateOfflineInstallationId +SLGetGenuineInformation +SLGetInstalledProductKeyIds +SLGetInstalledSAMLicenseApplications +SLGetLicense +SLGetLicenseFileId +SLGetLicenseInformation +SLGetLicensingStatusInformation +SLGetPKeyId +SLGetPKeyInformation +SLGetPolicyInformation +SLGetPolicyInformationDWORD +SLGetProductSkuInformation +SLGetSAMLicense +SLGetSLIDList +SLGetServiceInformation +SLGetWindowsInformation +SLGetWindowsInformationDWORD +SLInstallLicense +SLInstallProofOfPurchase +SLInstallSAMLicense +SLOpen +SLReArmWindows +SLRegisterEvent +SLRegisterWindowsEvent +SLSetCurrentProductKey +SLSetGenuineInformation +SLUninstallLicense +SLUninstallProofOfPurchase +SLUninstallSAMLicense +SLUnregisterEvent +SLUnregisterWindowsEvent diff --git a/lib/libc/mingw/lib64/spoolss.def b/lib/libc/mingw/lib64/spoolss.def new file mode 100644 index 0000000000..d4d4e56520 --- /dev/null +++ b/lib/libc/mingw/lib64/spoolss.def @@ -0,0 +1,223 @@ +; +; Definition file of SPOOLSS.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008 +; +LIBRARY "SPOOLSS.DLL" +EXPORTS +OpenPrinterExW +RouterCorePrinterDriverInstalled +RouterCreatePrintAsyncNotificationChannel +RouterDeletePrinterDriverPackage +RouterGetCorePrinterDrivers +RouterGetPrintClassObject +RouterGetPrinterDriverPackagePath +RouterInstallPrinterDriverFromPackage +RouterRegisterForPrintAsyncNotifications +RouterUnregisterForPrintAsyncNotifications +RouterUploadPrinterDriverPackage +AbortPrinter +AddDriverCatalog +AddFormW +AddJobW +AddMonitorW +AddPerMachineConnectionW +AddPortExW +AddPortW +AddPrintProcessorW +AddPrintProvidorW +AddPrinterConnectionW +AddPrinterDriverExW +AddPrinterDriverW +AddPrinterExW +AddPrinterW +AdjustPointers +AdjustPointersInStructuresArray +AlignKMPtr +AlignRpcPtr +AllocSplStr +AllowRemoteCalls +AppendPrinterNotifyInfoData +BuildOtherNamesFromMachineName +CacheAddName +CacheCreateAndAddNode +CacheCreateAndAddNodeWithIPAddresses +CacheDeleteNode +CacheIsNameCluster +CacheIsNameInNodeList +CallDrvDevModeConversion +CallRouterFindFirstPrinterChangeNotification +CheckLocalCall +ClosePrinter +ClusterSplClose +ClusterSplIsAlive +ClusterSplOpen +ConfigurePortW +CreatePrinterIC +DbgGetPointers +DeleteFormW +DeleteMonitorW +DeletePerMachineConnectionW +DeletePortW +DeletePrintProcessorW +DeletePrintProvidorW +DeletePrinter +DeletePrinterConnectionW +DeletePrinterDataExW +DeletePrinterDataW +DeletePrinterDriverExW +DeletePrinterDriverW +DeletePrinterIC +DeletePrinterKeyW +DllAllocSplMem +DllAllocSplStr +DllCanUnloadNow +DllFreeSplMem +DllFreeSplStr +DllGetClassObject +DllMain +DllReallocSplMem +DllReallocSplStr +DllRegisterServer +DllUnregisterServer +EndDocPrinter +EndPagePrinter +EnumFormsW +EnumJobsW +EnumMonitorsW +EnumPerMachineConnectionsW +EnumPortsW +EnumPrintProcessorDatatypesW +EnumPrintProcessorsW +EnumPrinterDataExW +EnumPrinterDataW +EnumPrinterDriversW +EnumPrinterKeyW +EnumPrintersW +FindClosePrinterChangeNotification +FlushPrinter +FormatPrinterForRegistryKey +FormatRegistryKeyForPrinter +FreeOtherNames +GetClientUserHandle +GetBindingHandleIndex +GetFormW +GetJobAttributes +GetJobAttributesEx +GetJobW +GetNetworkId +GetPrintProcessorDirectoryW +GetPrinterDataExW +GetPrinterDataW +GetPrinterDriverDirectoryW +GetPrinterDriverExW +GetPrinterDriverW +GetPrinterW +GetServerPolicy +GetShrinkedSize +ImpersonatePrinterClient +InitializeRouter +IsNameTheLocalMachineOrAClusterSpooler +IsNamedPipeRpcCall +LoadDriver +LoadDriverFiletoConvertDevmode +LoadDriverWithVersion +LogWmiTraceEvent +MIDL_user_allocate1 +MIDL_user_free1 +MarshallDownStructure +MarshallDownStructuresArray +MarshallUpStructure +MarshallUpStructuresArray +OldGetPrinterDriverW +OpenPrinterExW +OpenPrinterPortW +OpenPrinter2W +OpenPrinterPort2W +OpenPrinterW +PackStrings +PartialReplyPrinterChangeNotification +PlayGdiScriptOnPrinterIC +PrinterHandleRundown +PrinterMessageBoxW +ProvidorFindClosePrinterChangeNotification +ProvidorFindFirstPrinterChangeNotification +ReadPrinter +ReallocSplMem +ReallocSplStr +RemoteFindFirstPrinterChangeNotification +ReplyClosePrinter +ReplyOpenPrinter +ReplyPrinterChangeNotification +ReplyPrinterChangeNotificationEx +ReportJobProcessingProgress +ResetPrinterW +RevertToPrinterSelf +RouterAddPrinterConnection2 +RouterAllocBidiMem +RouterAllocBidiResponseContainer +RouterAllocPrinterNotifyInfo +RouterBroadcastMessage +RouterFindCompatibleDriver +RouterFindFirstPrinterChangeNotification +RouterFindNextPrinterChangeNotification +RouterFreeBidiMem +RouterFreeBidiResponseContainer +RouterFreePrinterNotifyInfo +RouterInternalGetPrinterDriver +RouterRefreshPrinterChangeNotification +RouterReplyPrinter +RouterSpoolerSetPolicy +ScheduleJob +SeekPrinter +SendRecvBidiData +SetAllocFailCount +SetFormW +SetJobW +SetPortW +SetPrinterDataExW +SetPrinterDataW +SetPrinterW +SplCloseSpoolFileHandle +SplCommitSpoolData +SplDriverUnloadComplete +SplGetClientUserHandle +SplGetSpoolFileInfo +SplGetUserSidStringFromToken +SplInitializeWinSpoolDrv +SplIsSessionZero +SplIsUpgrade +SplPowerEvent +SplProcessPnPEvent +SplProcessSessionEvent +SplPromptUIInUsersSession +SplQueryUserInfo +SplReadPrinter +SplRegisterForDeviceEvents +SplRegisterForSessionEvents +SplShutDownRouter +SplUnregisterForDeviceEvents +SplUnregisterForSessionEvents +SplWerNotifyLogger +SpoolerFindClosePrinterChangeNotification +SpoolerFindFirstPrinterChangeNotification +SpoolerFindNextPrinterChangeNotification +SpoolerFreePrinterNotifyInfo +SpoolerHasInitialized +SpoolerInit +SpoolerRefreshPrinterChangeNotification +StartDocPrinterW +StartPagePrinter +UndoAlignKMPtr +UndoAlignRpcPtr +UnloadDriver +UnloadDriverFile +UpdateBufferSize +UpdatePrinterRegAll +UpdatePrinterRegUser +WaitForPrinterChange +WaitForSpoolerInitialization +WritePrinter +XcvDataW +bGetDevModePerUser +bSetDevModePerUser diff --git a/lib/libc/mingw/lib64/vssapi.def b/lib/libc/mingw/lib64/vssapi.def new file mode 100644 index 0000000000..bb784bf030 --- /dev/null +++ b/lib/libc/mingw/lib64/vssapi.def @@ -0,0 +1,160 @@ +; +; Definition file of VSSAPI.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008 +; +LIBRARY "VSSAPI.DLL" +EXPORTS +IsVolumeSnapshotted +VssFreeSnapshotProperties +ShouldBlockRevert +; public: __cdecl CVssJetWriter::CVssJetWriter(void)__ptr64 +??0CVssJetWriter@@QEAA@XZ +; public: __cdecl CVssWriter::CVssWriter(void)__ptr64 +??0CVssWriter@@QEAA@XZ +; public: virtual __cdecl CVssJetWriter::~CVssJetWriter(void)__ptr64 +??1CVssJetWriter@@UEAA@XZ +; public: virtual __cdecl CVssWriter::~CVssWriter(void)__ptr64 +??1CVssWriter@@UEAA@XZ +; protected: bool __cdecl CVssJetWriter::AreComponentsSelected(void)const __ptr64 +?AreComponentsSelected@CVssJetWriter@@IEBA_NXZ +; protected: bool __cdecl CVssWriter::AreComponentsSelected(void)const __ptr64 +?AreComponentsSelected@CVssWriter@@IEBA_NXZ +; long __cdecl CreateVssBackupComponents(class IVssBackupComponents *__ptr64 *__ptr64) +?CreateVssBackupComponents@@YAJPEAPEAVIVssBackupComponents@@@Z +; long __cdecl CreateVssExamineWriterMetadata(unsigned short *__ptr64,class IVssExamineWriterMetadata *__ptr64 *__ptr64) +?CreateVssExamineWriterMetadata@@YAJPEAGPEAPEAVIVssExamineWriterMetadata@@@Z +; long __cdecl CreateVssSnapshotSetDescription(struct _GUID,long,class IVssSnapshotSetDescription *__ptr64 *__ptr64) +?CreateVssSnapshotSetDescription@@YAJU_GUID@@JPEAPEAVIVssSnapshotSetDescription@@@Z +; protected: enum _VSS_BACKUP_TYPE __cdecl CVssJetWriter::GetBackupType(void)const __ptr64 +?GetBackupType@CVssJetWriter@@IEBA?AW4_VSS_BACKUP_TYPE@@XZ +; protected: enum _VSS_BACKUP_TYPE __cdecl CVssWriter::GetBackupType(void)const __ptr64 +?GetBackupType@CVssWriter@@IEBA?AW4_VSS_BACKUP_TYPE@@XZ +; protected: long __cdecl CVssJetWriter::GetContext(void)const __ptr64 +?GetContext@CVssJetWriter@@IEBAJXZ +; protected: long __cdecl CVssWriter::GetContext(void)const __ptr64 +?GetContext@CVssWriter@@IEBAJXZ +; protected: enum _VSS_APPLICATION_LEVEL __cdecl CVssJetWriter::GetCurrentLevel(void)const __ptr64 +?GetCurrentLevel@CVssJetWriter@@IEBA?AW4_VSS_APPLICATION_LEVEL@@XZ +; protected: enum _VSS_APPLICATION_LEVEL __cdecl CVssWriter::GetCurrentLevel(void)const __ptr64 +?GetCurrentLevel@CVssWriter@@IEBA?AW4_VSS_APPLICATION_LEVEL@@XZ +; protected: struct _GUID __cdecl CVssJetWriter::GetCurrentSnapshotSetId(void)const __ptr64 +?GetCurrentSnapshotSetId@CVssJetWriter@@IEBA?AU_GUID@@XZ +; protected: struct _GUID __cdecl CVssWriter::GetCurrentSnapshotSetId(void)const __ptr64 +?GetCurrentSnapshotSetId@CVssWriter@@IEBA?AU_GUID@@XZ +; protected: unsigned short const *__ptr64 *__ptr64 __cdecl CVssJetWriter::GetCurrentVolumeArray(void)const __ptr64 +?GetCurrentVolumeArray@CVssJetWriter@@IEBAPEAPEBGXZ +; protected: unsigned short const *__ptr64 *__ptr64 __cdecl CVssWriter::GetCurrentVolumeArray(void)const __ptr64 +?GetCurrentVolumeArray@CVssWriter@@IEBAPEAPEBGXZ +; protected: unsigned int __cdecl CVssJetWriter::GetCurrentVolumeCount(void)const __ptr64 +?GetCurrentVolumeCount@CVssJetWriter@@IEBAIXZ +; protected: unsigned int __cdecl CVssWriter::GetCurrentVolumeCount(void)const __ptr64 +?GetCurrentVolumeCount@CVssWriter@@IEBAIXZ +; protected: enum _VSS_RESTORE_TYPE __cdecl CVssJetWriter::GetRestoreType(void)const __ptr64 +?GetRestoreType@CVssJetWriter@@IEBA?AW4_VSS_RESTORE_TYPE@@XZ +; protected: enum _VSS_RESTORE_TYPE __cdecl CVssWriter::GetRestoreType(void)const __ptr64 +?GetRestoreType@CVssWriter@@IEBA?AW4_VSS_RESTORE_TYPE@@XZ +; protected: long __cdecl CVssJetWriter::GetSnapshotDeviceName(unsigned short const *__ptr64,unsigned short const *__ptr64 *__ptr64)const __ptr64 +?GetSnapshotDeviceName@CVssJetWriter@@IEBAJPEBGPEAPEBG@Z +; protected: long __cdecl CVssWriter::GetSnapshotDeviceName(unsigned short const *__ptr64,unsigned short const *__ptr64 *__ptr64)const __ptr64 +?GetSnapshotDeviceName@CVssWriter@@IEBAJPEBGPEAPEBG@Z +; public: long __cdecl CVssJetWriter::Initialize(struct _GUID,unsigned short const *__ptr64,bool,bool,unsigned short const *__ptr64,unsigned short const *__ptr64,unsigned long)__ptr64 +?Initialize@CVssJetWriter@@QEAAJU_GUID@@PEBG_N211K@Z +; public: long __cdecl CVssWriter::Initialize(struct _GUID,unsigned short const *__ptr64,enum VSS_USAGE_TYPE,enum VSS_SOURCE_TYPE,enum _VSS_APPLICATION_LEVEL,unsigned long,enum VSS_ALTERNATE_WRITER_STATE,bool,unsigned short const *__ptr64)__ptr64 +?Initialize@CVssWriter@@QEAAJU_GUID@@PEBGW4VSS_USAGE_TYPE@@W4VSS_SOURCE_TYPE@@W4_VSS_APPLICATION_LEVEL@@KW4VSS_ALTERNATE_WRITER_STATE@@_N1@Z +; public: long __cdecl CVssWriter::InstallAlternateWriter(struct _GUID,struct _GUID)__ptr64 +?InstallAlternateWriter@CVssWriter@@QEAAJU_GUID@@0@Z +; protected: bool __cdecl CVssJetWriter::IsBootableSystemStateBackedUp(void)const __ptr64 +?IsBootableSystemStateBackedUp@CVssJetWriter@@IEBA_NXZ +; protected: bool __cdecl CVssWriter::IsBootableSystemStateBackedUp(void)const __ptr64 +?IsBootableSystemStateBackedUp@CVssWriter@@IEBA_NXZ +; protected: bool __cdecl CVssJetWriter::IsPartialFileSupportEnabled(void)const __ptr64 +?IsPartialFileSupportEnabled@CVssJetWriter@@IEBA_NXZ +; protected: bool __cdecl CVssWriter::IsPartialFileSupportEnabled(void)const __ptr64 +?IsPartialFileSupportEnabled@CVssWriter@@IEBA_NXZ +; protected: bool __cdecl CVssJetWriter::IsPathAffected(unsigned short const *__ptr64)const __ptr64 +?IsPathAffected@CVssJetWriter@@IEBA_NPEBG@Z +; protected: bool __cdecl CVssWriter::IsPathAffected(unsigned short const *__ptr64)const __ptr64 +?IsPathAffected@CVssWriter@@IEBA_NPEBG@Z +; long __cdecl LoadVssSnapshotSetDescription(unsigned short const *__ptr64,class IVssSnapshotSetDescription *__ptr64 *__ptr64,struct _GUID) +?LoadVssSnapshotSetDescription@@YAJPEBGPEAPEAVIVssSnapshotSetDescription@@U_GUID@@@Z +; public: virtual void __cdecl CVssJetWriter::OnAbortBegin(void)__ptr64 +?OnAbortBegin@CVssJetWriter@@UEAAXXZ +; public: virtual void __cdecl CVssJetWriter::OnAbortEnd(void)__ptr64 +?OnAbortEnd@CVssJetWriter@@UEAAXXZ +; public: virtual bool __cdecl CVssWriter::OnBackOffIOOnVolume(unsigned short *__ptr64,struct _GUID,struct _GUID)__ptr64 +?OnBackOffIOOnVolume@CVssWriter@@UEAA_NPEAGU_GUID@@1@Z +; public: virtual bool __cdecl CVssWriter::OnBackupComplete(class IVssWriterComponents *__ptr64)__ptr64 +?OnBackupComplete@CVssWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssJetWriter::OnBackupCompleteBegin(class IVssWriterComponents *__ptr64)__ptr64 +?OnBackupCompleteBegin@CVssJetWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssJetWriter::OnBackupCompleteEnd(class IVssWriterComponents *__ptr64,bool)__ptr64 +?OnBackupCompleteEnd@CVssJetWriter@@UEAA_NPEAVIVssWriterComponents@@_N@Z +; public: virtual bool __cdecl CVssWriter::OnBackupShutdown(struct _GUID)__ptr64 +?OnBackupShutdown@CVssWriter@@UEAA_NU_GUID@@@Z +; public: virtual bool __cdecl CVssWriter::OnContinueIOOnVolume(unsigned short *__ptr64,struct _GUID,struct _GUID)__ptr64 +?OnContinueIOOnVolume@CVssWriter@@UEAA_NPEAGU_GUID@@1@Z +; public: virtual bool __cdecl CVssJetWriter::OnFreezeBegin(void)__ptr64 +?OnFreezeBegin@CVssJetWriter@@UEAA_NXZ +; public: virtual bool __cdecl CVssJetWriter::OnFreezeEnd(bool)__ptr64 +?OnFreezeEnd@CVssJetWriter@@UEAA_N_N@Z +; public: virtual bool __cdecl CVssJetWriter::OnIdentify(class IVssCreateWriterMetadata *__ptr64)__ptr64 +?OnIdentify@CVssJetWriter@@UEAA_NPEAVIVssCreateWriterMetadata@@@Z +; public: virtual bool __cdecl CVssWriter::OnIdentify(class IVssCreateWriterMetadata *__ptr64)__ptr64 +?OnIdentify@CVssWriter@@UEAA_NPEAVIVssCreateWriterMetadata@@@Z +; public: virtual bool __cdecl CVssWriter::OnPostRestore(class IVssWriterComponents *__ptr64)__ptr64 +?OnPostRestore@CVssWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssJetWriter::OnPostRestoreBegin(class IVssWriterComponents *__ptr64)__ptr64 +?OnPostRestoreBegin@CVssJetWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssJetWriter::OnPostRestoreEnd(class IVssWriterComponents *__ptr64,bool)__ptr64 +?OnPostRestoreEnd@CVssJetWriter@@UEAA_NPEAVIVssWriterComponents@@_N@Z +; public: virtual bool __cdecl CVssJetWriter::OnPostSnapshot(class IVssWriterComponents *__ptr64)__ptr64 +?OnPostSnapshot@CVssJetWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssWriter::OnPostSnapshot(class IVssWriterComponents *__ptr64)__ptr64 +?OnPostSnapshot@CVssWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssWriter::OnPreRestore(class IVssWriterComponents *__ptr64)__ptr64 +?OnPreRestore@CVssWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssJetWriter::OnPreRestoreBegin(class IVssWriterComponents *__ptr64)__ptr64 +?OnPreRestoreBegin@CVssJetWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssJetWriter::OnPreRestoreEnd(class IVssWriterComponents *__ptr64,bool)__ptr64 +?OnPreRestoreEnd@CVssJetWriter@@UEAA_NPEAVIVssWriterComponents@@_N@Z +; public: virtual bool __cdecl CVssWriter::OnPrepareBackup(class IVssWriterComponents *__ptr64)__ptr64 +?OnPrepareBackup@CVssWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssJetWriter::OnPrepareBackupBegin(class IVssWriterComponents *__ptr64)__ptr64 +?OnPrepareBackupBegin@CVssJetWriter@@UEAA_NPEAVIVssWriterComponents@@@Z +; public: virtual bool __cdecl CVssJetWriter::OnPrepareBackupEnd(class IVssWriterComponents *__ptr64,bool)__ptr64 +?OnPrepareBackupEnd@CVssJetWriter@@UEAA_NPEAVIVssWriterComponents@@_N@Z +; public: virtual bool __cdecl CVssJetWriter::OnPrepareSnapshotBegin(void)__ptr64 +?OnPrepareSnapshotBegin@CVssJetWriter@@UEAA_NXZ +; public: virtual bool __cdecl CVssJetWriter::OnPrepareSnapshotEnd(bool)__ptr64 +?OnPrepareSnapshotEnd@CVssJetWriter@@UEAA_N_N@Z +; public: virtual bool __cdecl CVssJetWriter::OnThawBegin(void)__ptr64 +?OnThawBegin@CVssJetWriter@@UEAA_NXZ +; public: virtual bool __cdecl CVssJetWriter::OnThawEnd(bool)__ptr64 +?OnThawEnd@CVssJetWriter@@UEAA_N_N@Z +; public: virtual bool __cdecl CVssWriter::OnVSSApplicationStartup(void)__ptr64 +?OnVSSApplicationStartup@CVssWriter@@UEAA_NXZ +; public: virtual bool __cdecl CVssWriter::OnVSSShutdown(void)__ptr64 +?OnVSSShutdown@CVssWriter@@UEAA_NXZ +; protected: long __cdecl CVssJetWriter::SetWriterFailure(long)__ptr64 +?SetWriterFailure@CVssJetWriter@@IEAAJJ@Z +; protected: long __cdecl CVssWriter::SetWriterFailure(long)__ptr64 +?SetWriterFailure@CVssWriter@@IEAAJJ@Z +; public: long __cdecl CVssWriter::Subscribe(unsigned long)__ptr64 +?Subscribe@CVssWriter@@QEAAJK@Z +; public: void __cdecl CVssJetWriter::Uninitialize(void)__ptr64 +?Uninitialize@CVssJetWriter@@QEAAXXZ +; public: long __cdecl CVssWriter::Unsubscribe(void)__ptr64 +?Unsubscribe@CVssWriter@@QEAAJXZ +CreateVssBackupComponentsInternal +CreateVssExamineWriterMetadataInternal +CreateVssExpressWriterInternal +CreateWriter +CreateWriterEx +;DllCanUnloadNow +;DllGetClassObject +GetProviderMgmtInterface +GetProviderMgmtInterfaceInternal +IsVolumeSnapshottedInternal +ShouldBlockRevertInternal +VssFreeSnapshotPropertiesInternal diff --git a/lib/libc/mingw/lib64/wdsclientapi.def b/lib/libc/mingw/lib64/wdsclientapi.def new file mode 100644 index 0000000000..78a236520d --- /dev/null +++ b/lib/libc/mingw/lib64/wdsclientapi.def @@ -0,0 +1,46 @@ +; +; Definition file of WDSCLIENTAPI.dll +; Automatic generated by gendef +; written by Kai Tietz 2008 +; +LIBRARY "WDSCLIENTAPI.dll" +EXPORTS +WdsCliAuthorizeSession +WdsCliCancelTransfer +WdsCliClose +WdsCliCreateSession +WdsCliFindFirstImage +WdsCliFindNextImage +WdsCliFreeDomainJoinInformation +WdsCliFreeStringArray +WdsCliFreeUnattendVariables +WdsCliGetClientUnattend +WdsCliGetDomainJoinInformation +WdsCliGetEnumerationFlags +WdsCliGetImageArchitecture +WdsCliGetImageDescription +WdsCliGetImageFiles +WdsCliGetImageGroup +WdsCliGetImageHalName +WdsCliGetImageHandleFromFindHandle +WdsCliGetImageHandleFromTransferHandle +WdsCliGetImageIndex +WdsCliGetImageLanguage +WdsCliGetImageLanguages +WdsCliGetImageLastModifiedTime +WdsCliGetImageName +WdsCliGetImageNamespace +WdsCliGetImageParameter +WdsCliGetImagePath +WdsCliGetImageSize +WdsCliGetImageType +WdsCliGetImageVersion +WdsCliGetTransferSize +WdsCliGetUnattendVariables +WdsCliInitializeLog +WdsCliLog +WdsCliObtainDriverPackages +WdsCliRegisterTrace +WdsCliTransferFile +WdsCliTransferImage +WdsCliWaitForTransfer diff --git a/lib/libc/mingw/lib64/wdstptc.def b/lib/libc/mingw/lib64/wdstptc.def new file mode 100644 index 0000000000..75c1765c7a --- /dev/null +++ b/lib/libc/mingw/lib64/wdstptc.def @@ -0,0 +1,22 @@ +; +; Definition file of WDSTPTC.dll +; Automatic generated by gendef +; written by Kai Tietz 2008 +; +LIBRARY "WDSTPTC.dll" +EXPORTS +WdsTptcDownload +WdsTransportClientRegisterTrace +WdsTransportClientAddRefBuffer +WdsTransportClientCancelSession +WdsTransportClientCancelSessionEx +WdsTransportClientCloseSession +WdsTransportClientCompleteReceive +WdsTransportClientInitialize +WdsTransportClientInitializeSession +WdsTransportClientQueryStatus +WdsTransportClientRegisterCallback +WdsTransportClientReleaseBuffer +WdsTransportClientShutdown +WdsTransportClientStartSession +WdsTransportClientWaitForCompletion diff --git a/lib/libc/mingw/lib64/wer.def b/lib/libc/mingw/lib64/wer.def new file mode 100644 index 0000000000..3f81b5b589 --- /dev/null +++ b/lib/libc/mingw/lib64/wer.def @@ -0,0 +1,84 @@ +; +; Definition file of wer.dll +; Automatic generated by gendef +; written by Kai Tietz 2008 +; +LIBRARY "wer.dll" +EXPORTS +WerSysprepCleanup +WerSysprepGeneralize +WerSysprepSpecialize +WerUnattendedSetup +WerpAddAppCompatData +WerpAddFile +WerpAddMemoryBlock +WerpAddRegisteredDataToReport +WerpAddSecondaryParameter +WerpAddTextToReport +WerpArchiveReport +WerpCancelResponseDownload +WerpCancelUpload +WerpCloseStore +WerpCreateMachineStore +WerpDeleteReport +WerpDestroyWerString +WerpDownloadResponse +WerpDownloadResponseTemplate +WerpEnumerateStoreNext +WerpEnumerateStoreStart +WerpExtractReportFiles +WerpGetBucketId +WerpGetDynamicParameter +WerpGetEventType +WerpGetFileByIndex +WerpGetFilePathByIndex +WerpGetNumFiles +WerpGetNumSecParams +WerpGetNumSigParams +WerpGetReportFinalConsent +WerpGetReportFlags +WerpGetReportInformation +WerpGetReportTime +WerpGetReportType +WerpGetResponseId +WerpGetResponseUrl +WerpGetSecParamByIndex +WerpGetSigParamByIndex +WerpGetStoreLocation +WerpGetStoreType +WerpGetTextFromReport +WerpGetUIParamByIndex +WerpGetUploadTime +WerpGetWerStringData +WerpIsTransportAvailable +WerpLoadReport +WerpOpenMachineArchive +WerpOpenMachineQueue +WerpOpenUserArchive +WerpReportCancel +WerpRestartApplication +WerpSetDynamicParameter +WerpSetEventName +WerpSetReportFlags +WerpSetReportInformation +WerpSetReportTime +WerpSetReportUploadContextToken +WerpShowNXNotification +WerpShowSecondLevelConsent +WerpShowUpsellUI +WerpSubmitReportFromStore +WerpSvcReportFromMachineQueue +WerAddExcludedApplication +WerRemoveExcludedApplication +WerReportAddDump +WerReportAddFile +WerReportCloseHandle +WerReportCreate +WerReportSetParameter +WerReportSetUIOption +WerReportSubmit +WerpGetReportConsent +WerpIsDisabled +WerpOpenUserQueue +WerpPromtUser +WerpSetCallBack diff --git a/lib/libc/mingw/lib64/winfax.def b/lib/libc/mingw/lib64/winfax.def new file mode 100644 index 0000000000..6f30ee050a --- /dev/null +++ b/lib/libc/mingw/lib64/winfax.def @@ -0,0 +1,64 @@ +; +; Exports of file WINFAX.dll +; +; Autogenerated by gen_exportdef +; Written by Kai Tietz, 2007 +; +LIBRARY WINFAX.dll +EXPORTS +FaxAbort +FaxAccessCheck +FaxClose +FaxCompleteJobParamsA +FaxCompleteJobParamsW +FaxConnectFaxServerA +FaxConnectFaxServerW +FaxEnableRoutingMethodA +FaxEnableRoutingMethodW +FaxEnumGlobalRoutingInfoA +FaxEnumGlobalRoutingInfoW +FaxEnumJobsA +FaxEnumJobsW +FaxEnumPortsA +FaxEnumPortsW +FaxEnumRoutingMethodsA +FaxEnumRoutingMethodsW +FaxFreeBuffer +FaxGetConfigurationA +FaxGetConfigurationW +FaxGetDeviceStatusA +FaxGetDeviceStatusW +FaxGetJobA +FaxGetJobW +FaxGetLoggingCategoriesA +FaxGetLoggingCategoriesW +FaxGetPageData +FaxGetPortA +FaxGetPortW +FaxGetRoutingInfoA +FaxGetRoutingInfoW +FaxInitializeEventQueue +FaxOpenPort +FaxPrintCoverPageA +FaxPrintCoverPageW +FaxRegisterRoutingExtensionW +FaxRegisterServiceProviderW +FaxSendDocumentA +FaxSendDocumentForBroadcastA +FaxSendDocumentForBroadcastW +FaxSendDocumentW +FaxSetConfigurationA +FaxSetConfigurationW +FaxSetGlobalRoutingInfoA +FaxSetGlobalRoutingInfoW +FaxSetJobA +FaxSetJobW +FaxSetLoggingCategoriesA +FaxSetLoggingCategoriesW +FaxSetPortA +FaxSetPortW +FaxSetRoutingInfoA +FaxSetRoutingInfoW +FaxStartPrintJobA +FaxStartPrintJobW +FaxUnregisterServiceProviderW diff --git a/lib/libc/mingw/lib64/winsta.def b/lib/libc/mingw/lib64/winsta.def new file mode 100644 index 0000000000..f07e3b541b --- /dev/null +++ b/lib/libc/mingw/lib64/winsta.def @@ -0,0 +1,111 @@ +; +; Exports of file WINSTA.dll +; +; Autogenerated by gen_exportdef +; Written by Kai Tietz, 2007 +; +LIBRARY WINSTA.dll +EXPORTS +LogonIdFromWinStationNameA +LogonIdFromWinStationNameW +RemoteAssistancePrepareSystemRestore +ServerGetInternetConnectorStatus +ServerLicensingClose +ServerLicensingDeactivateCurrentPolicy +ServerLicensingFreePolicyInformation +ServerLicensingGetAvailablePolicyIds +ServerLicensingGetPolicy +ServerLicensingGetPolicyInformationA +ServerLicensingGetPolicyInformationW +ServerLicensingLoadPolicy +ServerLicensingOpenA +ServerLicensingOpenW +ServerLicensingSetPolicy +ServerLicensingUnloadPolicy +ServerQueryInetConnectorInformationA +ServerQueryInetConnectorInformationW +ServerSetInternetConnectorStatus +WinStationActivateLicense +WinStationAutoReconnect +WinStationBroadcastSystemMessage +WinStationCanLogonProceed +WinStationCheckAccess +WinStationCheckLoopBack +WinStationCloseServer +WinStationConnectA +WinStationConnectCallback +WinStationConnectW +WinStationDisconnect +WinStationEnumerateA +WinStationEnumerateLicenses +WinStationEnumerateProcesses +WinStationEnumerateW +WinStationEnumerate_IndexedA +WinStationEnumerate_IndexedW +WinStationFreeGAPMemory +WinStationFreeMemory +WinStationGenerateLicense +WinStationGetAllProcesses +WinStationGetLanAdapterNameA +WinStationGetLanAdapterNameW +WinStationGetMachinePolicy +WinStationGetProcessSid +WinStationGetTermSrvCountersValue +WinStationInstallLicense +WinStationIsHelpAssistantSession +WinStationNameFromLogonIdA +WinStationNameFromLogonIdW +WinStationNtsdDebug +WinStationOpenServerA +WinStationOpenServerW +WinStationQueryInformationA +WinStationQueryInformationW +WinStationQueryLicense +WinStationQueryLogonCredentialsW +WinStationQueryUpdateRequired +WinStationRedirectErrorMessage +WinStationRegisterConsoleNotification +WinStationRegisterConsoleNotificationEx +WinStationRegisterNotificationEvent +WinStationRemoveLicense +WinStationRenameA +WinStationRenameW +WinStationReset +WinStationSendMessageA +WinStationSendMessageW +WinStationSendWindowMessage +WinStationServerPing +WinStationSetInformationA +WinStationSetInformationW +WinStationSetPoolCount +WinStationShadow +WinStationShadowStop +WinStationShutdownSystem +WinStationTerminateProcess +WinStationUnRegisterConsoleNotification +WinStationUnRegisterNotificationEvent +WinStationVirtualOpen +WinStationWaitSystemEvent +_NWLogonQueryAdmin +_NWLogonSetAdmin +_WinStationAnnoyancePopup +_WinStationBeepOpen +_WinStationBreakPoint +_WinStationCallback +_WinStationCheckForApplicationName +_WinStationFUSCanRemoteUserDisconnect +_WinStationGetApplicationInfo +_WinStationNotifyDisconnectPipe +_WinStationNotifyLogoff +_WinStationNotifyLogon +_WinStationNotifyNewSession +_WinStationOpenSessionDirectory +_WinStationReInitializeSecurity +_WinStationReadRegistry +_WinStationSessionInitialized +_WinStationShadowTarget +_WinStationShadowTargetSetup +_WinStationUpdateClientCachedCredentials +_WinStationUpdateSettings +_WinStationUpdateUserConfig +_WinStationWaitForConnect diff --git a/lib/libc/mingw/lib64/wsdapi.def b/lib/libc/mingw/lib64/wsdapi.def new file mode 100644 index 0000000000..a10b4cdc1c --- /dev/null +++ b/lib/libc/mingw/lib64/wsdapi.def @@ -0,0 +1,41 @@ +; +; Definition file of wsdapi.dll +; Automatic generated by gendef +; written by Kai Tietz 2008 +; +LIBRARY "wsdapi.dll" +EXPORTS +WSDCancelAddrChangeNotify +WSDCreateHttpAddressAdvanced +WSDNotifyAddrChange +WSDAllocateLinkedMemory +WSDAttachLinkedMemory +WSDCreateDeviceHost +WSDCreateDeviceHostAdvanced +WSDCreateDeviceProxy +WSDCreateDeviceProxyAdvanced +WSDCreateDiscoveryProvider +WSDCreateDiscoveryPublisher +WSDCreateHttpAddress +WSDCreateHttpMessageParameters +WSDCreateHttpTransport +WSDCreateMetadataAgent +WSDCreateOutboundAttachment +WSDCreateUdpAddress +WSDCreateUdpMessageParameters +WSDCreateUdpTransport +WSDDetachLinkedMemory +WSDFreeLinkedMemory +WSDGenerateFault +WSDGenerateFaultEx +WSDGenerateRandomDelay +WSDGetConfigurationOption +WSDProcessFault +WSDSetConfigurationOption +WSDXMLAddChild +WSDXMLAddSibling +WSDXMLBuildAnyForSingleElement +WSDXMLCleanupElement +WSDXMLCreateContext +WSDXMLGetNameFromBuiltinNamespace +WSDXMLGetValueFromAny diff --git a/lib/libc/mingw/libarm32/aclui.def b/lib/libc/mingw/libarm32/aclui.def new file mode 100644 index 0000000000..7a7961dfe8 --- /dev/null +++ b/lib/libc/mingw/libarm32/aclui.def @@ -0,0 +1,15 @@ +; +; Definition file of ACLUI.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "ACLUI.dll" +EXPORTS +CreateSecurityPage +EditSecurity +EditSecurityAdvanced +EditResourceCondition +EditConditionalAceClaims +GetLocalizedStringForCondition +GetTlsIndexForClaimDictionary +IID_ISecurityInformation diff --git a/lib/libc/mingw/libarm32/apphelp.def b/lib/libc/mingw/libarm32/apphelp.def new file mode 100644 index 0000000000..fc732ce675 --- /dev/null +++ b/lib/libc/mingw/libarm32/apphelp.def @@ -0,0 +1,260 @@ +; +; Definition file of apphelp.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "apphelp.dll" +EXPORTS +ord_1 @1 +ord_2 @2 +ord_3 @3 +ord_4 @4 +ord_5 @5 +ord_6 @6 +ord_7 @7 +ord_8 @8 +ord_9 @9 +ord_10 @10 +ord_11 @11 +ord_12 @12 +ord_13 @13 +ord_14 @14 +AllowPermLayer +ApphelpCheckExe +ord_17 @17 +ord_18 @18 +ord_19 @19 +ord_20 @20 +ord_21 @21 +ord_22 @22 +ord_23 @23 +ord_24 @24 +ord_25 @25 +ord_26 @26 +ord_27 @27 +ord_28 @28 +ord_29 @29 +ord_30 @30 +ord_31 @31 +ord_32 @32 +ord_33 @33 +ApphelpCheckIME +ApphelpCheckInstallShieldPackage +ApphelpCheckModule +ApphelpCheckMsiPackage +ApphelpCheckRunApp +ApphelpCheckRunAppEx +ApphelpCheckShellObject +ApphelpCreateAppcompatData +ApphelpDebugPrintf +ApphelpFixMsiPackage +ApphelpFixMsiPackageExe +ApphelpFreeFileAttributes +ApphelpGetFileAttributes +ApphelpGetMsiProperties +ApphelpGetNTVDMInfo +ApphelpGetShimDebugLevel +ApphelpIsPortMonAllowed +ApphelpParseModuleData +ApphelpQueryModuleData +ApphelpQueryModuleDataEx +ApphelpShowDialog +ApphelpUpdateCacheEntry +DlEnumChannels +DlGetStateEx +DlSetFlagsEx +DlSetLevelEx +DlSetStateEx +DlSnapshot +GetPermLayers +SE_AddHookset +SE_CALLBACK_AddHook +SE_CALLBACK_Lookup +SE_COM_AddHook +SE_COM_AddServer +SE_COM_HookInterface +SE_COM_HookObject +SE_COM_Lookup +SE_DllLoaded +SE_DllUnloaded +SE_DynamicShim +SE_GetHookAPIs +SE_GetMaxShimCount +SE_GetProcAddressForCaller +SE_GetProcAddressIgnoreIncExc +SE_GetProcAddressLoad +SE_GetShimCount +SE_GetShimId +SE_InitializeEngine +SE_InstallAfterInit +SE_InstallBeforeInit +SE_IsShimDll +SE_LdrEntryRemoved +SE_LdrResolveDllName +SE_LookupAddress +SE_LookupCaller +SE_ProcessDying +SE_ShimDPF +SE_ShimDllLoaded +SE_WINRT_AddHook +SE_WINRT_HookObject +SdbAddLayerTagRefToQuery +SdbApphelpNotify +SdbApphelpNotifyEx +SdbApphelpNotifyEx2 +SdbBeginWriteListTag +SdbBuildCompatEnvVariables +SdbCloseApphelpInformation +SdbCloseDatabase +SdbCloseDatabaseWrite +SdbCloseLocalDatabase +SdbCommitIndexes +SdbCreateDatabase +SdbCreateHelpCenterURL +SdbCreateMsiTransformFile +SdbDeclareIndex +SdbDeletePermLayerKeys +SdbDumpSearchPathPartCaches +SdbEndWriteListTag +SdbEnumMsiTransforms +SdbEscapeApphelpURL +SdbFindCustomActionForPackage +SdbFindFirstDWORDIndexedTag +SdbFindFirstGUIDIndexedTag +SdbFindFirstMsiPackage +SdbFindFirstMsiPackage_Str +SdbFindFirstNamedTag +SdbFindFirstStringIndexedTag +SdbFindFirstTag +SdbFindFirstTagRef +SdbFindMsiPackageByID +SdbFindNextDWORDIndexedTag +SdbFindNextGUIDIndexedTag +SdbFindNextMsiPackage +SdbFindNextStringIndexedTag +SdbFindNextTag +SdbFindNextTagRef +SdbFormatAttribute +SdbFreeDatabaseInformation +SdbFreeFileAttributes +SdbFreeFileInfo +SdbFreeFlagInfo +SdbGUIDFromString +SdbGUIDToString +SdbGetAppCompatDataSize +SdbGetAppPatchDir +SdbGetBinaryTagData +SdbGetDatabaseGUID +SdbGetDatabaseID +SdbGetDatabaseInformation +SdbGetDatabaseInformationByName +SdbGetDatabaseMatch +SdbGetDatabaseVersion +SdbGetDllPath +SdbGetEntryFlags +SdbGetFileAttributes +SdbGetFileImageType +SdbGetFileImageTypeEx +SdbGetFileInfo +SdbGetFirstChild +SdbGetImageType +SdbGetIndex +SdbGetItemFromItemRef +SdbGetLayerName +SdbGetLayerTagRef +SdbGetLocalPDB +SdbGetMatchingExe +SdbGetMsiPackageInformation +SdbGetNamedLayer +SdbGetNextChild +SdbGetNthUserSdb +SdbGetPDBFromGUID +SdbGetPermLayerKeys +SdbGetShowDebugInfoOption +SdbGetShowDebugInfoOptionValue +SdbGetStandardDatabaseGUID +SdbGetStringTagPtr +SdbGetTagDataSize +SdbGetTagFromTagID +SdbGrabMatchingInfo +SdbGrabMatchingInfoEx +SdbInitDatabase +SdbInitDatabaseEx +SdbIsNullGUID +SdbIsStandardDatabase +SdbIsTagrefFromLocalDB +SdbIsTagrefFromMainDB +SdbLoadString +SdbMakeIndexKeyFromString +SdbOpenApphelpDetailsDatabase +SdbOpenApphelpDetailsDatabaseSP +SdbOpenApphelpInformation +SdbOpenApphelpInformationByID +SdbOpenApphelpResourceFile +SdbOpenDatabase +SdbOpenDbFromGuid +SdbOpenLocalDatabase +SdbPackAppCompatData +SdbQueryApphelpInformation +SdbQueryBlockUpgrade +SdbQueryContext +SdbQueryData +SdbQueryDataEx +SdbQueryDataExTagID +SdbQueryFlagInfo +SdbQueryFlagMask +SdbQueryName +SdbQueryReinstallUpgrade +SdbReadApphelpData +SdbReadApphelpDetailsData +SdbReadBYTETag +SdbReadBYTETagRef +SdbReadBinaryTag +SdbReadDWORDTag +SdbReadDWORDTagRef +SdbReadEntryInformation +SdbReadMsiTransformInfo +SdbReadPatchBits +SdbReadQWORDTag +SdbReadQWORDTagRef +SdbReadStringTag +SdbReadStringTagRef +SdbReadWORDTag +SdbReadWORDTagRef +SdbRegisterDatabase +SdbRegisterDatabaseEx +SdbReleaseDatabase +SdbReleaseMatchingExe +SdbResolveDatabase +SdbSetApphelpDebugParameters +SdbSetEntryFlags +SdbSetImageType +SdbSetPermLayerKeys +SdbShowApphelpDialog +SdbShowApphelpFromQuery +SdbStartIndexing +SdbStopIndexing +SdbStringDuplicate +SdbStringReplace +SdbStringReplaceArray +SdbTagIDToTagRef +SdbTagRefToTagID +SdbTagToString +SdbUnpackAppCompatData +SdbUnregisterDatabase +SdbWriteBYTETag +SdbWriteBinaryTag +SdbWriteBinaryTagFromFile +SdbWriteDWORDTag +SdbWriteNULLTag +SdbWriteQWORDTag +SdbWriteStringRefTag +SdbWriteStringTag +SdbWriteStringTagDirect +SdbWriteWORDTag +SetPermLayerState +SetPermLayerStateEx +SetPermLayers +ShimDbgPrint +ShimDumpCache +ShimFlushCache diff --git a/lib/libc/mingw/libarm32/certpoleng.def b/lib/libc/mingw/libarm32/certpoleng.def new file mode 100644 index 0000000000..d3b22ef33d --- /dev/null +++ b/lib/libc/mingw/libarm32/certpoleng.def @@ -0,0 +1,15 @@ +; +; Definition file of certpoleng.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "certpoleng.dll" +EXPORTS +PstAcquirePrivateKey +PstGetCertificateChain +PstGetCertificates +PstGetTrustAnchors +PstGetTrustAnchorsEx +PstGetUserNameForCertificate +PstMapCertificate +PstValidate diff --git a/lib/libc/mingw/libarm32/clfsw32.def b/lib/libc/mingw/libarm32/clfsw32.def new file mode 100644 index 0000000000..dcec605438 --- /dev/null +++ b/lib/libc/mingw/libarm32/clfsw32.def @@ -0,0 +1,70 @@ +; +; Definition file of clfsw32.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "clfsw32.dll" +EXPORTS +LsnDecrement +AddLogContainer +AddLogContainerSet +AdvanceLogBase +AlignReservedLog +AllocReservedLog +CLFS_LSN_INVALID +CLFS_LSN_NULL +CloseAndResetLogFile +CreateLogContainerScanContext +CreateLogFile +CreateLogMarshallingArea +DeleteLogByHandle +DeleteLogFile +DeleteLogMarshallingArea +DeregisterManageableLogClient +DumpLogRecords +FlushLogBuffers +FlushLogToLsn +FreeReservedLog +GetLogContainerName +GetLogFileInformation +GetLogIoStatistics +GetLogReservationInfo +GetNextLogArchiveExtent +HandleLogFull +InstallLogPolicy +LogTailAdvanceFailure +LsnBlockOffset +LsnContainer +LsnCreate +LsnEqual +LsnGreater +LsnIncrement +LsnInvalid +LsnLess +LsnNull +LsnRecordSequence +PrepareLogArchive +QueryLogPolicy +ReadLogArchiveMetadata +ReadLogNotification +ReadLogRecord +ReadLogRestartArea +ReadNextLogRecord +ReadPreviousLogRestartArea +RegisterForLogWriteNotification +RegisterManageableLogClient +RemoveLogContainer +RemoveLogContainerSet +RemoveLogPolicy +ReserveAndAppendLog +ReserveAndAppendLogAligned +ScanLogContainers +SetEndOfLog +SetLogArchiveMode +SetLogArchiveTail +SetLogFileSizeWithPolicy +TerminateLogArchive +TerminateReadLog +TruncateLog +ValidateLog +WriteLogRestartArea diff --git a/lib/libc/mingw/libarm32/comsvcs.def b/lib/libc/mingw/libarm32/comsvcs.def new file mode 100644 index 0000000000..efb1ff3fbe --- /dev/null +++ b/lib/libc/mingw/libarm32/comsvcs.def @@ -0,0 +1,25 @@ +; +; Definition file of comsvcs.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "comsvcs.dll" +EXPORTS +CosGetCallContext +ord_6 @6 +ord_7 @7 +CoCreateActivity +CoEnterServiceDomain +CoLeaveServiceDomain +CoLoadServices +ComSvcsExceptionFilter +ComSvcsLogError +DispManGetContext +GetMTAThreadPoolMetrics +GetManagedExtensions +GetObjectContext +GetTrkSvrObject +MTSCreateActivity +MiniDumpW +RecycleSurrogate +SafeRef diff --git a/lib/libc/mingw/libarm32/d3d10_1.def b/lib/libc/mingw/libarm32/d3d10_1.def new file mode 100644 index 0000000000..98582a78fa --- /dev/null +++ b/lib/libc/mingw/libarm32/d3d10_1.def @@ -0,0 +1,37 @@ +; +; Definition file of d3d10_1.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "d3d10_1.dll" +EXPORTS +RevertToOldImplementation +D3D10CompileEffectFromMemory +D3D10CompileShader +D3D10CreateBlob +D3D10CreateDevice1 +D3D10CreateDeviceAndSwapChain1 +D3D10CreateEffectFromMemory +D3D10CreateEffectPoolFromMemory +D3D10CreateStateBlock +D3D10DisassembleEffect +D3D10DisassembleShader +D3D10GetGeometryShaderProfile +D3D10GetInputAndOutputSignatureBlob +D3D10GetInputSignatureBlob +D3D10GetOutputSignatureBlob +D3D10GetPixelShaderProfile +D3D10GetShaderDebugInfo +D3D10GetVersion +D3D10GetVertexShaderProfile +D3D10PreprocessShader +D3D10ReflectShader +D3D10RegisterLayers +D3D10StateBlockMaskDifference +D3D10StateBlockMaskDisableAll +D3D10StateBlockMaskDisableCapture +D3D10StateBlockMaskEnableAll +D3D10StateBlockMaskEnableCapture +D3D10StateBlockMaskGetSetting +D3D10StateBlockMaskIntersect +D3D10StateBlockMaskUnion diff --git a/lib/libc/mingw/libarm32/deviceaccess.def b/lib/libc/mingw/libarm32/deviceaccess.def new file mode 100644 index 0000000000..33570bb08c --- /dev/null +++ b/lib/libc/mingw/libarm32/deviceaccess.def @@ -0,0 +1,8 @@ +; +; Definition file of deviceaccess.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "deviceaccess.dll" +EXPORTS +CreateDeviceAccessInstance diff --git a/lib/libc/mingw/libarm32/dhcpcsvc6.def b/lib/libc/mingw/libarm32/dhcpcsvc6.def new file mode 100644 index 0000000000..3f80fbf6a9 --- /dev/null +++ b/lib/libc/mingw/libarm32/dhcpcsvc6.def @@ -0,0 +1,29 @@ +; +; Definition file of dhcpcsvc6.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "dhcpcsvc6.DLL" +EXPORTS +Dhcpv6AcquireParameters +Dhcpv6CApiCleanup +Dhcpv6CApiInitialize +Dhcpv6CancelOperation +Dhcpv6EnableDhcp +Dhcpv6EnableTracing +Dhcpv6FreeLeaseInfo +Dhcpv6FreeLeaseInfoArray +Dhcpv6GetTraceArray +Dhcpv6GetUserClasses +Dhcpv6IsEnabled +Dhcpv6QueryLeaseInfo +Dhcpv6QueryLeaseInfoArray +Dhcpv6ReleaseParameters +Dhcpv6ReleasePrefix +Dhcpv6ReleasePrefixEx +Dhcpv6RenewPrefix +Dhcpv6RenewPrefixEx +Dhcpv6RequestParams +Dhcpv6RequestPrefix +Dhcpv6RequestPrefixEx +Dhcpv6SetUserClass diff --git a/lib/libc/mingw/libarm32/drt.def b/lib/libc/mingw/libarm32/drt.def new file mode 100644 index 0000000000..ccfcecc4e4 --- /dev/null +++ b/lib/libc/mingw/libarm32/drt.def @@ -0,0 +1,28 @@ +; +; Definition file of drt.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "drt.dll" +EXPORTS +DrtFlushCache +DrtGetCacheStatsEx +DrtHandlePowerEvent +DrtPingPeer +DrtStartPartitionDetection +DrtClose +DrtContinueSearch +DrtEndSearch +DrtGetEventData +DrtGetEventDataSize +DrtGetInstanceName +DrtGetInstanceNameSize +DrtGetSearchPath +DrtGetSearchPathSize +DrtGetSearchResult +DrtGetSearchResultSize +DrtOpen +DrtRegisterKey +DrtStartSearch +DrtUnregisterKey +DrtUpdateKey diff --git a/lib/libc/mingw/libarm32/drtprov.def b/lib/libc/mingw/libarm32/drtprov.def new file mode 100644 index 0000000000..f884ba7294 --- /dev/null +++ b/lib/libc/mingw/libarm32/drtprov.def @@ -0,0 +1,16 @@ +; +; Definition file of drtprov.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "drtprov.dll" +EXPORTS +DrtCreateDerivedKey +DrtCreateDerivedKeySecurityProvider +DrtCreateDnsBootstrapResolver +DrtCreateNullSecurityProvider +DrtCreatePnrpBootstrapResolver +DrtDeleteDerivedKeySecurityProvider +DrtDeleteDnsBootstrapResolver +DrtDeleteNullSecurityProvider +DrtDeletePnrpBootstrapResolver diff --git a/lib/libc/mingw/libarm32/drttransport.def b/lib/libc/mingw/libarm32/drttransport.def new file mode 100644 index 0000000000..fec0329fea --- /dev/null +++ b/lib/libc/mingw/libarm32/drttransport.def @@ -0,0 +1,9 @@ +; +; Definition file of drttransport.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "drttransport.dll" +EXPORTS +DrtCreateIpv6UdpTransport +DrtDeleteIpv6UdpTransport diff --git a/lib/libc/mingw/libarm32/dsparse.def b/lib/libc/mingw/libarm32/dsparse.def new file mode 100644 index 0000000000..2642004bad --- /dev/null +++ b/lib/libc/mingw/libarm32/dsparse.def @@ -0,0 +1,26 @@ +; +; Definition file of DSPARSE.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "DSPARSE.dll" +EXPORTS +DsCrackSpn2A +DsCrackSpn2W +DsCrackSpn3W +DsCrackSpn4W +DsCrackSpnA +DsCrackSpnW +DsCrackUnquotedMangledRdnA +DsCrackUnquotedMangledRdnW +DsGetRdnW +DsIsMangledDnA +DsIsMangledDnW +DsIsMangledRdnValueA +DsIsMangledRdnValueW +DsMakeSpnA +DsMakeSpnW +DsQuoteRdnValueA +DsQuoteRdnValueW +DsUnquoteRdnValueA +DsUnquoteRdnValueW diff --git a/lib/libc/mingw/libarm32/efswrt.def b/lib/libc/mingw/libarm32/efswrt.def new file mode 100644 index 0000000000..e149d878ee --- /dev/null +++ b/lib/libc/mingw/libarm32/efswrt.def @@ -0,0 +1,11 @@ +; +; Definition file of efswrt.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "efswrt.dll" +EXPORTS +EnterpriseDataCopyProtection +EnterpriseDataGetStatus +EnterpriseDataProtect +EnterpriseDataRevoke diff --git a/lib/libc/mingw/libarm32/esent.def b/lib/libc/mingw/libarm32/esent.def new file mode 100644 index 0000000000..140c22f8a3 --- /dev/null +++ b/lib/libc/mingw/libarm32/esent.def @@ -0,0 +1,363 @@ +; +; Definition file of ESENT.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "ESENT.dll" +EXPORTS +DebugExtensionInitialize +DebugExtensionNotify +DebugExtensionUninitialize +JetAddColumn +JetAddColumnA +JetAddColumnW +JetAttachDatabase +JetAttachDatabase2 +JetAttachDatabase2A +JetAttachDatabase2W +JetAttachDatabaseA +JetAttachDatabaseW +JetAttachDatabaseWithStreaming +JetAttachDatabaseWithStreamingA +JetAttachDatabaseWithStreamingW +JetBackup +JetBackupA +JetBackupInstance +JetBackupInstanceA +JetBackupInstanceW +JetBackupW +JetBeginDatabaseIncrementalReseed +JetBeginDatabaseIncrementalReseedA +JetBeginDatabaseIncrementalReseedW +JetBeginExternalBackup +JetBeginExternalBackupInstance +JetBeginSession +JetBeginSessionA +JetBeginSessionW +JetBeginSurrogateBackup +JetBeginTransaction +JetBeginTransaction2 +JetBeginTransaction3 +JetCloseDatabase +JetCloseFile +JetCloseFileInstance +JetCloseTable +JetCommitTransaction +JetCommitTransaction2 +JetCompact +JetCompactA +JetCompactW +JetComputeStats +JetConfigureProcessForCrashDump +JetConsumeLogData +JetConvertDDL +JetConvertDDLA +JetConvertDDLW +JetCreateDatabase +JetCreateDatabase2 +JetCreateDatabase2A +JetCreateDatabase2W +JetCreateDatabaseA +JetCreateDatabaseW +JetCreateDatabaseWithStreaming +JetCreateDatabaseWithStreamingA +JetCreateDatabaseWithStreamingW +JetCreateIndex +JetCreateIndex2 +JetCreateIndex2A +JetCreateIndex2W +JetCreateIndex3A +JetCreateIndex3W +JetCreateIndex4A +JetCreateIndex4W +JetCreateIndexA +JetCreateIndexW +JetCreateInstance +JetCreateInstance2 +JetCreateInstance2A +JetCreateInstance2W +JetCreateInstanceA +JetCreateInstanceW +JetCreateTable +JetCreateTableA +JetCreateTableColumnIndex +JetCreateTableColumnIndex2 +JetCreateTableColumnIndex2A +JetCreateTableColumnIndex2W +JetCreateTableColumnIndex3A +JetCreateTableColumnIndex3W +JetCreateTableColumnIndex4A +JetCreateTableColumnIndex4W +JetCreateTableColumnIndexA +JetCreateTableColumnIndexW +JetCreateTableW +JetDBUtilities +JetDBUtilitiesA +JetDBUtilitiesW +JetDatabaseScan +JetDefragment +JetDefragment2 +JetDefragment2A +JetDefragment2W +JetDefragment3 +JetDefragment3A +JetDefragment3W +JetDefragmentA +JetDefragmentW +JetDelete +JetDeleteColumn +JetDeleteColumn2 +JetDeleteColumn2A +JetDeleteColumn2W +JetDeleteColumnA +JetDeleteColumnW +JetDeleteIndex +JetDeleteIndexA +JetDeleteIndexW +JetDeleteTable +JetDeleteTableA +JetDeleteTableW +JetDetachDatabase +JetDetachDatabase2 +JetDetachDatabase2A +JetDetachDatabase2W +JetDetachDatabaseA +JetDetachDatabaseW +JetDupCursor +JetDupSession +JetEnableMultiInstance +JetEnableMultiInstanceA +JetEnableMultiInstanceW +JetEndDatabaseIncrementalReseed +JetEndDatabaseIncrementalReseedA +JetEndDatabaseIncrementalReseedW +JetEndExternalBackup +JetEndExternalBackupInstance +JetEndExternalBackupInstance2 +JetEndSession +JetEndSurrogateBackup +JetEnumerateColumns +JetEscrowUpdate +JetExternalRestore +JetExternalRestore2 +JetExternalRestore2A +JetExternalRestore2W +JetExternalRestoreA +JetExternalRestoreW +JetFreeBuffer +JetGetAttachInfo +JetGetAttachInfoA +JetGetAttachInfoInstance +JetGetAttachInfoInstanceA +JetGetAttachInfoInstanceW +JetGetAttachInfoW +JetGetBookmark +JetGetColumnInfo +JetGetColumnInfoA +JetGetColumnInfoW +JetGetCounter +JetGetCurrentIndex +JetGetCurrentIndexA +JetGetCurrentIndexW +JetGetCursorInfo +JetGetDatabaseFileInfo +JetGetDatabaseFileInfoA +JetGetDatabaseFileInfoW +JetGetDatabaseInfo +JetGetDatabaseInfoA +JetGetDatabaseInfoW +JetGetDatabasePages +JetGetErrorInfoW +JetGetIndexInfo +JetGetIndexInfoA +JetGetIndexInfoW +JetGetInstanceInfo +JetGetInstanceInfoA +JetGetInstanceInfoW +JetGetInstanceMiscInfo +JetGetLS +JetGetLock +JetGetLogFileInfo +JetGetLogFileInfoA +JetGetLogFileInfoW +JetGetLogInfo +JetGetLogInfoA +JetGetLogInfoInstance +JetGetLogInfoInstance2 +JetGetLogInfoInstance2A +JetGetLogInfoInstance2W +JetGetLogInfoInstanceA +JetGetLogInfoInstanceW +JetGetLogInfoW +JetGetMaxDatabaseSize +JetGetObjectInfo +JetGetObjectInfoA +JetGetObjectInfoW +JetGetPageInfo +JetGetPageInfo2 +JetGetRecordPosition +JetGetRecordSize +JetGetRecordSize2 +JetGetResourceParam +JetGetSecondaryIndexBookmark +JetGetSessionInfo +JetGetSessionParameter +JetGetSystemParameter +JetGetSystemParameterA +JetGetSystemParameterW +JetGetTableColumnInfo +JetGetTableColumnInfoA +JetGetTableColumnInfoW +JetGetTableIndexInfo +JetGetTableIndexInfoA +JetGetTableIndexInfoW +JetGetTableInfo +JetGetTableInfoA +JetGetTableInfoW +JetGetThreadStats +JetGetTruncateLogInfoInstance +JetGetTruncateLogInfoInstanceA +JetGetTruncateLogInfoInstanceW +JetGetVersion +JetGotoBookmark +JetGotoPosition +JetGotoSecondaryIndexBookmark +JetGrowDatabase +JetIdle +JetIndexRecordCount +JetInit +JetInit2 +JetInit3 +JetInit3A +JetInit3W +JetInit4 +JetInit4A +JetInit4W +JetIntersectIndexes +JetMakeKey +JetMove +JetOSSnapshotAbort +JetOSSnapshotEnd +JetOSSnapshotFreeze +JetOSSnapshotFreezeA +JetOSSnapshotFreezeW +JetOSSnapshotGetFreezeInfo +JetOSSnapshotGetFreezeInfoA +JetOSSnapshotGetFreezeInfoW +JetOSSnapshotPrepare +JetOSSnapshotPrepareInstance +JetOSSnapshotThaw +JetOSSnapshotTruncateLog +JetOSSnapshotTruncateLogInstance +JetOnlinePatchDatabasePage +JetOpenDatabase +JetOpenDatabaseA +JetOpenDatabaseW +JetOpenFile +JetOpenFileA +JetOpenFileInstance +JetOpenFileInstanceA +JetOpenFileInstanceW +JetOpenFileSectionInstance +JetOpenFileSectionInstanceA +JetOpenFileSectionInstanceW +JetOpenFileW +JetOpenTable +JetOpenTableA +JetOpenTableW +JetOpenTempTable +JetOpenTempTable2 +JetOpenTempTable3 +JetOpenTemporaryTable +JetOpenTemporaryTable2 +JetPatchDatabasePages +JetPatchDatabasePagesA +JetPatchDatabasePagesW +JetPrepareToCommitTransaction +JetPrepareUpdate +JetPrereadIndexRanges +JetPrereadKeys +JetPrereadTablesW +JetReadFile +JetReadFileInstance +JetRegisterCallback +JetRemoveLogfileA +JetRemoveLogfileW +JetRenameColumn +JetRenameColumnA +JetRenameColumnW +JetRenameTable +JetRenameTableA +JetRenameTableW +JetResetCounter +JetResetSessionContext +JetResetTableSequential +JetResizeDatabase +JetRestore +JetRestore2 +JetRestore2A +JetRestore2W +JetRestoreA +JetRestoreInstance +JetRestoreInstanceA +JetRestoreInstanceW +JetRestoreW +JetRetrieveColumn +JetRetrieveColumns +JetRetrieveKey +JetRetrieveTaggedColumnList +JetRollback +JetSeek +JetSetColumn +JetSetColumnDefaultValue +JetSetColumnDefaultValueA +JetSetColumnDefaultValueW +JetSetColumns +JetSetCurrentIndex +JetSetCurrentIndex2 +JetSetCurrentIndex2A +JetSetCurrentIndex2W +JetSetCurrentIndex3 +JetSetCurrentIndex3A +JetSetCurrentIndex3W +JetSetCurrentIndex4 +JetSetCurrentIndex4A +JetSetCurrentIndex4W +JetSetCurrentIndexA +JetSetCurrentIndexW +JetSetCursorFilter +JetSetDatabaseSize +JetSetDatabaseSizeA +JetSetDatabaseSizeW +JetSetIndexRange +JetSetLS +JetSetMaxDatabaseSize +JetSetResourceParam +JetSetSessionContext +JetSetSessionParameter +JetSetSystemParameter +JetSetSystemParameterA +JetSetSystemParameterW +JetSetTableSequential +JetSnapshotStart +JetSnapshotStartA +JetSnapshotStartW +JetSnapshotStop +JetStopBackup +JetStopBackupInstance +JetStopService +JetStopServiceInstance +JetStopServiceInstance2 +JetTerm +JetTerm2 +JetTestHook +JetTracing +JetTruncateLog +JetTruncateLogInstance +JetUnregisterCallback +JetUpdate +JetUpdate2 +JetUpgradeDatabase +JetUpgradeDatabaseA +JetUpgradeDatabaseW +ese diff --git a/lib/libc/mingw/libarm32/faultrep.def b/lib/libc/mingw/libarm32/faultrep.def new file mode 100644 index 0000000000..bf6d970a22 --- /dev/null +++ b/lib/libc/mingw/libarm32/faultrep.def @@ -0,0 +1,17 @@ +; +; Definition file of faultrep.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "faultrep.dll" +EXPORTS +ord_1 @1 +CheckPerUserCrossProcessThrottle +UpdatePerUserLastCrossProcessCollectionTime +AddERExcludedApplicationA +AddERExcludedApplicationW +CancelHangReporting +ReportFault +ReportHang +WerReportHang +WerpInitiateCrashReporting diff --git a/lib/libc/mingw/libarm32/fhsvcctl.def b/lib/libc/mingw/libarm32/fhsvcctl.def new file mode 100644 index 0000000000..f6480a1b75 --- /dev/null +++ b/lib/libc/mingw/libarm32/fhsvcctl.def @@ -0,0 +1,20 @@ +; +; Definition file of fhsvcctl.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "fhsvcctl.dll" +EXPORTS +FhQueryConfiguredUsersCount +FhServiceBlockBackup +FhServiceClearProtectionState +FhServiceClosePipe +FhServiceEnterMaintenanceMode +FhServiceExitMaintenanceMode +FhServiceMigrationFinished +FhServiceMigrationStarting +FhServiceOpenPipe +FhServiceReloadConfiguration +FhServiceStartBackup +FhServiceStopBackup +FhServiceUnblockBackup diff --git a/lib/libc/mingw/libarm32/fwpuclnt.def b/lib/libc/mingw/libarm32/fwpuclnt.def new file mode 100644 index 0000000000..6f29ed7198 --- /dev/null +++ b/lib/libc/mingw/libarm32/fwpuclnt.def @@ -0,0 +1,259 @@ +; +; Definition file of fwpuclnt.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "fwpuclnt.dll" +EXPORTS +FwpiExpandCriteria0 +FwpiFreeCriteria0 +FwpiVpnTriggerAddAppSids +FwpiVpnTriggerAddFilePaths +FwpiVpnTriggerConfigureParameters +FwpiVpnTriggerEventSubscribe0 +FwpiVpnTriggerEventUnsubscribe0 +FwpiVpnTriggerInitializeNrptTriggering +FwpiVpnTriggerRemoveAppSids +FwpiVpnTriggerRemoveFilePaths +FwpiVpnTriggerResetNrptTriggering +FwpiVpnTriggerSetStateDisconnected +FwpiVpnTriggerUninitializeNrptTriggering +FwpmCalloutAdd0 +FwpmCalloutCreateEnumHandle0 +FwpmCalloutDeleteById0 +FwpmCalloutDeleteByKey0 +FwpmCalloutDestroyEnumHandle0 +FwpmCalloutEnum0 +FwpmCalloutGetById0 +FwpmCalloutGetByKey0 +FwpmCalloutGetSecurityInfoByKey0 +FwpmCalloutSetSecurityInfoByKey0 +FwpmCalloutSubscribeChanges0 +FwpmCalloutSubscriptionsGet0 +FwpmCalloutUnsubscribeChanges0 +FwpmConnectionCreateEnumHandle0 +FwpmConnectionDestroyEnumHandle0 +FwpmConnectionEnum0 +FwpmConnectionGetById0 +FwpmConnectionGetSecurityInfo0 +FwpmConnectionSetSecurityInfo0 +FwpmConnectionSubscribe0 +FwpmConnectionUnsubscribe0 +FwpmDiagnoseNetFailure0 +FwpmEngineClose0 +FwpmEngineGetOption0 +FwpmEngineGetSecurityInfo0 +FwpmEngineOpen0 +FwpmEngineSetOption0 +FwpmEngineSetSecurityInfo0 +FwpmEventProviderCreate0 +FwpmEventProviderDestroy0 +FwpmEventProviderFireNetEvent0 +FwpmEventProviderIsNetEventTypeEnabled0 +FwpmFilterAdd0 +FwpmFilterCreateEnumHandle0 +FwpmFilterDeleteById0 +FwpmFilterDeleteByKey0 +FwpmFilterDestroyEnumHandle0 +FwpmFilterEnum0 +FwpmFilterGetById0 +FwpmFilterGetByKey0 +FwpmFilterGetSecurityInfoByKey0 +FwpmFilterSetSecurityInfoByKey0 +FwpmFilterSubscribeChanges0 +FwpmFilterSubscriptionsGet0 +FwpmFilterUnsubscribeChanges0 +FwpmFreeMemory0 +FwpmGetAppIdFromFileName0 +FwpmGetSidFromOnlineId0 +FwpmIPsecTunnelAdd0 +FwpmIPsecTunnelAdd1 +FwpmIPsecTunnelAdd2 +FwpmIPsecTunnelAddConditions0 +FwpmIPsecTunnelDeleteByKey0 +FwpmLayerCreateEnumHandle0 +FwpmLayerDestroyEnumHandle0 +FwpmLayerEnum0 +FwpmLayerGetById0 +FwpmLayerGetByKey0 +FwpmLayerGetSecurityInfoByKey0 +FwpmLayerSetSecurityInfoByKey0 +FwpmNetEventCreateEnumHandle0 +FwpmNetEventDestroyEnumHandle0 +FwpmNetEventEnum0 +FwpmNetEventEnum1 +FwpmNetEventEnum2 +FwpmNetEventSubscribe0 +FwpmNetEventSubscribe1 +FwpmNetEventSubscriptionsGet0 +FwpmNetEventUnsubscribe0 +FwpmNetEventsGetSecurityInfo0 +FwpmNetEventsLost0 +FwpmNetEventsSetSecurityInfo0 +FwpmProcessNameResolutionEvent0 +FwpmProviderAdd0 +FwpmProviderContextAdd0 +FwpmProviderContextAdd1 +FwpmProviderContextAdd2 +FwpmProviderContextCreateEnumHandle0 +FwpmProviderContextDeleteById0 +FwpmProviderContextDeleteByKey0 +FwpmProviderContextDestroyEnumHandle0 +FwpmProviderContextEnum0 +FwpmProviderContextEnum1 +FwpmProviderContextEnum2 +FwpmProviderContextGetById0 +FwpmProviderContextGetById1 +FwpmProviderContextGetById2 +FwpmProviderContextGetByKey0 +FwpmProviderContextGetByKey1 +FwpmProviderContextGetByKey2 +FwpmProviderContextGetSecurityInfoByKey0 +FwpmProviderContextSetSecurityInfoByKey0 +FwpmProviderContextSubscribeChanges0 +FwpmProviderContextSubscriptionsGet0 +FwpmProviderContextUnsubscribeChanges0 +FwpmProviderCreateEnumHandle0 +FwpmProviderDeleteByKey0 +FwpmProviderDestroyEnumHandle0 +FwpmProviderEnum0 +FwpmProviderGetByKey0 +FwpmProviderGetSecurityInfoByKey0 +FwpmProviderSetSecurityInfoByKey0 +FwpmProviderSubscribeChanges0 +FwpmProviderSubscriptionsGet0 +FwpmProviderUnsubscribeChanges0 +FwpmSessionCreateEnumHandle0 +FwpmSessionDestroyEnumHandle0 +FwpmSessionEnum0 +FwpmSubLayerAdd0 +FwpmSubLayerCreateEnumHandle0 +FwpmSubLayerDeleteByKey0 +FwpmSubLayerDestroyEnumHandle0 +FwpmSubLayerEnum0 +FwpmSubLayerGetByKey0 +FwpmSubLayerGetSecurityInfoByKey0 +FwpmSubLayerSetSecurityInfoByKey0 +FwpmSubLayerSubscribeChanges0 +FwpmSubLayerSubscriptionsGet0 +FwpmSubLayerUnsubscribeChanges0 +FwpmSystemPortsGet0 +FwpmSystemPortsSubscribe0 +FwpmSystemPortsUnsubscribe0 +FwpmTraceRestoreDefaults0 +FwpmTransactionAbort0 +FwpmTransactionBegin0 +FwpmTransactionCommit0 +FwpmvSwitchEventSubscribe0 +FwpmvSwitchEventUnsubscribe0 +FwpmvSwitchEventsGetSecurityInfo0 +FwpmvSwitchEventsSetSecurityInfo0 +FwppConnectionGetByIPsecInfo +FwpsAleEndpointCreateEnumHandle0 +FwpsAleEndpointDestroyEnumHandle0 +FwpsAleEndpointEnum0 +FwpsAleEndpointGetById0 +FwpsAleEndpointGetSecurityInfo0 +FwpsAleEndpointSetSecurityInfo0 +FwpsAleExplicitCredentialsQuery0 +FwpsAleGetPortStatus0 +FwpsClassifyUser0 +FwpsFreeMemory0 +FwpsGetInProcReplicaOffset0 +FwpsLayerCreateInProcReplica0 +FwpsLayerReleaseInProcReplica0 +FwpsOpenToken0 +FwpsQueryIPsecDosFWUsed0 +FwpsQueryIPsecOffloadDone0 +GetUnifiedTraceHandle +IPsecDospGetSecurityInfo0 +IPsecDospGetStatistics0 +IPsecDospSetSecurityInfo0 +IPsecDospStateCreateEnumHandle0 +IPsecDospStateDestroyEnumHandle0 +IPsecDospStateEnum0 +IPsecGetKeyFromDictator0 +IPsecGetStatistics0 +IPsecGetStatistics1 +IPsecKeyDictationCheck0 +IPsecKeyManagerAddAndRegister0 +IPsecKeyManagerGetSecurityInfoByKey0 +IPsecKeyManagerSetSecurityInfoByKey0 +IPsecKeyManagerUnregisterAndDelete0 +IPsecKeyManagersGet0 +IPsecKeyModuleAdd0 +IPsecKeyModuleDelete0 +IPsecKeyModuleUpdateAcquire0 +IPsecKeyNotification0 +IPsecSaContextAddInbound0 +IPsecSaContextAddInbound1 +IPsecSaContextAddInboundAndTrackConnection +IPsecSaContextAddOutbound0 +IPsecSaContextAddOutbound1 +IPsecSaContextAddOutboundAndTrackConnection +IPsecSaContextCreate0 +IPsecSaContextCreate1 +IPsecSaContextCreateEnumHandle0 +IPsecSaContextDeleteById0 +IPsecSaContextDestroyEnumHandle0 +IPsecSaContextEnum0 +IPsecSaContextEnum1 +IPsecSaContextExpire0 +IPsecSaContextGetById0 +IPsecSaContextGetById1 +IPsecSaContextGetSpi0 +IPsecSaContextGetSpi1 +IPsecSaContextSetSpi0 +IPsecSaContextSubscribe0 +IPsecSaContextSubscriptionsGet0 +IPsecSaContextUnsubscribe0 +IPsecSaContextUpdate0 +IPsecSaCreateEnumHandle0 +IPsecSaDbGetSecurityInfo0 +IPsecSaDbSetSecurityInfo0 +IPsecSaDestroyEnumHandle0 +IPsecSaEnum0 +IPsecSaEnum1 +IPsecSaInitiateAsync0 +IkeextGetConfigParameters0 +IkeextGetStatistics0 +IkeextGetStatistics1 +IkeextSaCreateEnumHandle0 +IkeextSaDbGetSecurityInfo0 +IkeextSaDbSetSecurityInfo0 +IkeextSaDeleteById0 +IkeextSaDestroyEnumHandle0 +IkeextSaEnum0 +IkeextSaEnum1 +IkeextSaEnum2 +IkeextSaGetById0 +IkeextSaGetById1 +IkeextSaGetById2 +IkeextSaUpdateAdditionalAddressesByTunnelId0 +IkeextSaUpdatePreferredAddressesByTunnelId0 +IkeextSetConfigParameters0 +NamespaceCallout +WFPRIODequeueCompletion +WSADeleteSocketPeerTargetName +WSAImpersonateSocketPeer +WSAQuerySocketSecurity +WSARevertImpersonation +WSASetSocketPeerTargetName +WSASetSocketSecurity +WfpCloseDPConfigureHandle +WfpConfigureDPSecurityDescriptor +WfpCreateDPConfigureHandle +WfpRIOChannelClose +WfpRIOCleanupRequestQueue +WfpRIOCloseCompletionQueue +WfpRIOCreateChannel +WfpRIOCreateCompletionQueue +WfpRIOCreateRequestQueue +WfpRIODeregisterBuffer +WfpRIOIndicateActivityThreshold +WfpRIONotify +WfpRIOReceive +WfpRIORegisterBuffer +WfpRIOResume +WfpRIOSend +WfpRIOSuspend diff --git a/lib/libc/mingw/libarm32/httpapi.def b/lib/libc/mingw/libarm32/httpapi.def new file mode 100644 index 0000000000..2301238b82 --- /dev/null +++ b/lib/libc/mingw/libarm32/httpapi.def @@ -0,0 +1,46 @@ +; +; Definition file of HTTPAPI.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "HTTPAPI.dll" +EXPORTS +HttpAddFragmentToCache +HttpAddUrl +HttpAddUrlToUrlGroup +HttpCancelHttpRequest +HttpCloseRequestQueue +HttpCloseServerSession +HttpCloseUrlGroup +HttpControlService +HttpCreateHttpHandle +HttpCreateRequestQueue +HttpCreateServerSession +HttpCreateUrlGroup +HttpDeleteServiceConfiguration +HttpEvaluateRequest +HttpFlushResponseCache +HttpGetCounters +HttpInitialize +HttpPrepareUrl +HttpQueryRequestQueueProperty +HttpQueryServerSessionProperty +HttpQueryServiceConfiguration +HttpQueryUrlGroupProperty +HttpReadFragmentFromCache +HttpReceiveClientCertificate +HttpReceiveHttpRequest +HttpReceiveRequestEntityBody +HttpRemoveUrl +HttpRemoveUrlFromUrlGroup +HttpSendHttpResponse +HttpSendResponseEntityBody +HttpSetRequestQueueProperty +HttpSetServerSessionProperty +HttpSetServiceConfiguration +HttpSetUrlGroupProperty +HttpShutdownRequestQueue +HttpTerminate +HttpWaitForDemandStart +HttpWaitForDisconnect +HttpWaitForDisconnectEx diff --git a/lib/libc/mingw/libarm32/magnification.def b/lib/libc/mingw/libarm32/magnification.def new file mode 100644 index 0000000000..90f687dcd6 --- /dev/null +++ b/lib/libc/mingw/libarm32/magnification.def @@ -0,0 +1,26 @@ +; +; Definition file of MAGNIFICATION.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "MAGNIFICATION.dll" +EXPORTS +MagGetColorEffect +MagGetFullscreenColorEffect +MagGetFullscreenTransform +MagGetImageScalingCallback +MagGetInputTransform +MagGetWindowFilterList +MagGetWindowSource +MagGetWindowTransform +MagInitialize +MagSetColorEffect +MagSetFullscreenColorEffect +MagSetFullscreenTransform +MagSetImageScalingCallback +MagSetInputTransform +MagSetWindowFilterList +MagSetWindowSource +MagSetWindowTransform +MagShowSystemCursor +MagUninitialize diff --git a/lib/libc/mingw/libarm32/mdmregistration.def b/lib/libc/mingw/libarm32/mdmregistration.def new file mode 100644 index 0000000000..2ed00bb010 --- /dev/null +++ b/lib/libc/mingw/libarm32/mdmregistration.def @@ -0,0 +1,15 @@ +; +; Definition file of MDMRegistration.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "MDMRegistration.DLL" +EXPORTS +DiscoverManagementService +DiscoverManagementServiceEx +GetManagementAppHyperlink +IsDeviceRegisteredWithManagement +IsManagementRegistrationAllowed +RegisterDeviceWithManagement +SetManagedExternally +UnregisterDeviceWithManagement diff --git a/lib/libc/mingw/libarm32/mfcore.def b/lib/libc/mingw/libarm32/mfcore.def new file mode 100644 index 0000000000..7fdc76f260 --- /dev/null +++ b/lib/libc/mingw/libarm32/mfcore.def @@ -0,0 +1,49 @@ +; +; Definition file of MFCORE.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "MFCORE.dll" +EXPORTS +AppendPropVariant +ConvertPropVariant +CopyPropertyStore +CreateNamedPropertyStore +ExtractPropVariant +MFCopyMFMetadata +MFCreateAggregateSource +MFCreateAppSourceProxy +MFCreateAudioRenderer +MFCreateAudioRendererActivate +MFCreateDeviceSource +MFCreateDeviceSourceActivate +MFCreateFileSchemePlugin +MFCreateMFMetadataOnPropertyStore +MFCreateMediaProcessor +MFCreateMediaSession +MFCreatePMPHost +MFCreatePMPMediaSession +MFCreatePMPServer +MFCreatePresentationClock +MFCreateSampleCopierMFT +MFCreateSampleGrabberSinkActivate +MFCreateSequencerSegmentOffset +MFCreateSequencerSource +MFCreateSequencerSourceRemoteStream +MFCreateSimpleTypeHandler +MFCreateSoundEventSchemePlugin +MFCreateStandardQualityManager +MFCreateTopoLoader +MFCreateTopology +MFCreateTopologyNode +MFCreateTransformWrapper +MFCreateWMAEncoderActivate +MFCreateWMVEncoderActivate +MFEnumDeviceSources +MFGetMultipleServiceProviders +MFGetService +MFGetTopoNodeCurrentType +MFReadSequencerSegmentOffset +MFRequireProtectedEnvironment +MFShutdownObject +MergePropertyStore diff --git a/lib/libc/mingw/libarm32/mfplay.def b/lib/libc/mingw/libarm32/mfplay.def new file mode 100644 index 0000000000..42cdb16537 --- /dev/null +++ b/lib/libc/mingw/libarm32/mfplay.def @@ -0,0 +1,9 @@ +; +; Definition file of MFPlay.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "MFPlay.DLL" +EXPORTS +MFPCreateMediaPlayer +MFPCreateMediaPlayerEx diff --git a/lib/libc/mingw/libarm32/mfsrcsnk.def b/lib/libc/mingw/libarm32/mfsrcsnk.def new file mode 100644 index 0000000000..8eed55deb9 --- /dev/null +++ b/lib/libc/mingw/libarm32/mfsrcsnk.def @@ -0,0 +1,9 @@ +; +; Definition file of mfsrcsnk.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "mfsrcsnk.dll" +EXPORTS +MFCreateAVIMediaSink +MFCreateWAVEMediaSink diff --git a/lib/libc/mingw/libarm32/mprapi.def b/lib/libc/mingw/libarm32/mprapi.def new file mode 100644 index 0000000000..38cab0a873 --- /dev/null +++ b/lib/libc/mingw/libarm32/mprapi.def @@ -0,0 +1,164 @@ +; +; Definition file of MPRAPI.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "MPRAPI.dll" +EXPORTS +CompressPhoneNumber +MprAdminAddRoutingDomain +MprAdminBufferFree +MprAdminConnectionClearStats +MprAdminConnectionEnum +MprAdminConnectionEnumEx +MprAdminConnectionGetInfo +MprAdminConnectionGetInfoEx +MprAdminConnectionRemoveQuarantine +MprAdminDeleteRoutingDomain +MprAdminDeregisterConnectionNotification +MprAdminDeviceEnum +MprAdminEstablishDomainRasServer +MprAdminFreeRoutingDomainConfigEx +MprAdminGetErrorString +MprAdminGetPDCServer +MprAdminGetProtocolStatistics +MprAdminGetRoutingDomainId +MprAdminInterfaceClearStatisticsEx +MprAdminInterfaceConnect +MprAdminInterfaceCreate +MprAdminInterfaceCreateEx +MprAdminInterfaceDelete +MprAdminInterfaceDeviceGetInfo +MprAdminInterfaceDeviceSetInfo +MprAdminInterfaceDisconnect +MprAdminInterfaceEnum +MprAdminInterfaceEnumEx +MprAdminInterfaceGetCredentials +MprAdminInterfaceGetCredentialsEx +MprAdminInterfaceGetCustomInfoEx +MprAdminInterfaceGetHandle +MprAdminInterfaceGetInfo +MprAdminInterfaceGetInfoEx +MprAdminInterfaceGetStatisticsEx +MprAdminInterfaceQueryUpdateResult +MprAdminInterfaceSetCredentials +MprAdminInterfaceSetCredentialsEx +MprAdminInterfaceSetCustomInfoEx +MprAdminInterfaceSetInfo +MprAdminInterfaceSetInfoEx +MprAdminInterfaceTransportAdd +MprAdminInterfaceTransportGetInfo +MprAdminInterfaceTransportRemove +MprAdminInterfaceTransportSetInfo +MprAdminInterfaceUpdatePhonebookInfo +MprAdminInterfaceUpdateRoutes +MprAdminIsDomainRasServer +MprAdminIsMultiTenancyEnabled +MprAdminIsServiceInitialized +MprAdminIsServiceRunning +MprAdminMIBBufferFree +MprAdminMIBEntryCreate +MprAdminMIBEntryDelete +MprAdminMIBEntryGet +MprAdminMIBEntryGetFirst +MprAdminMIBEntryGetNext +MprAdminMIBEntrySet +MprAdminMIBServerConnect +MprAdminMIBServerDisconnect +MprAdminMarkServerOffline +MprAdminPortClearStats +MprAdminPortDisconnect +MprAdminPortEnum +MprAdminPortGetInfo +MprAdminPortReset +MprAdminProtocolAction +MprAdminRegisterConnectionNotification +MprAdminRoutingDomainConnectionEnumEx +MprAdminRoutingDomainGetConfigEx +MprAdminRoutingDomainSetConfigEx +MprAdminRoutingDomainsEnumEx +MprAdminSendUserMessage +MprAdminServerConnect +MprAdminServerDisconnect +MprAdminServerGetCredentials +MprAdminServerGetInfo +MprAdminServerGetInfoEx +MprAdminServerSetCredentials +MprAdminServerSetInfo +MprAdminServerSetInfoEx +MprAdminTransportCreate +MprAdminTransportGetInfo +MprAdminTransportSetInfo +MprAdminUpdateConnection +MprAdminUpgradeUsers +MprAdminUserClose +MprAdminUserGetInfo +MprAdminUserOpen +MprAdminUserRead +MprAdminUserReadProfFlags +MprAdminUserServerConnect +MprAdminUserServerDisconnect +MprAdminUserSetInfo +MprAdminUserWrite +MprAdminUserWriteProfFlags +MprConfigAddRoutingDomain +MprConfigBufferFree +MprConfigDeleteRoutingDomain +MprConfigFilterGetInfo +MprConfigFilterSetInfo +MprConfigFreeRoutingDomainConfigEx +MprConfigGetFriendlyName +MprConfigGetGuidName +MprConfigGetRoutingDomainId +MprConfigInterfaceCreate +MprConfigInterfaceCreateEx +MprConfigInterfaceDelete +MprConfigInterfaceEnum +MprConfigInterfaceEnumEx +MprConfigInterfaceGetCustomInfoEx +MprConfigInterfaceGetHandle +MprConfigInterfaceGetInfo +MprConfigInterfaceGetInfoEx +MprConfigInterfaceSetCustomInfoEx +MprConfigInterfaceSetInfo +MprConfigInterfaceSetInfoEx +MprConfigInterfaceTransportAdd +MprConfigInterfaceTransportEnum +MprConfigInterfaceTransportGetHandle +MprConfigInterfaceTransportGetInfo +MprConfigInterfaceTransportRemove +MprConfigInterfaceTransportSetInfo +MprConfigIsMultiTenancyEnabled +MprConfigRoutingDomainEnumEx +MprConfigRoutingDomainGetConfigEx +MprConfigRoutingDomainSetConfigEx +MprConfigServerBackup +MprConfigServerConnect +MprConfigServerDisconnect +MprConfigServerGetInfo +MprConfigServerGetInfoEx +MprConfigServerInstall +MprConfigServerRefresh +MprConfigServerRestore +MprConfigServerSetInfo +MprConfigServerSetInfoEx +MprConfigTransportCreate +MprConfigTransportDelete +MprConfigTransportEnum +MprConfigTransportGetHandle +MprConfigTransportGetInfo +MprConfigTransportSetInfo +MprDomainQueryRasServer +MprDomainRegisterRasServer +MprGetUsrParams +MprInfoBlockAdd +MprInfoBlockFind +MprInfoBlockQuerySize +MprInfoBlockRemove +MprInfoBlockSet +MprInfoCreate +MprInfoDelete +MprInfoDuplicate +MprInfoRemoveAll +MprPortSetUsage +RasPrivilegeAndCallBackNumber diff --git a/lib/libc/mingw/libarm32/mscms.def b/lib/libc/mingw/libarm32/mscms.def new file mode 100644 index 0000000000..5ee53d7d3f --- /dev/null +++ b/lib/libc/mingw/libarm32/mscms.def @@ -0,0 +1,113 @@ +; +; Definition file of mscms.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "mscms.dll" +EXPORTS +AssociateColorProfileWithDeviceA +AssociateColorProfileWithDeviceW +CheckBitmapBits +CheckColors +CloseColorProfile +CloseDisplay +ColorCplGetDefaultProfileScope +ColorCplGetDefaultRenderingIntentScope +ColorCplGetProfileProperties +ColorCplHasSystemWideAssociationListChanged +ColorCplInitialize +ColorCplLoadAssociationList +ColorCplMergeAssociationLists +ColorCplOverwritePerUserAssociationList +ColorCplReleaseProfileProperties +ColorCplResetSystemWideAssociationListChangedWarning +ColorCplSaveAssociationList +ColorCplSetUsePerUserProfiles +ColorCplUninitialize +ConvertColorNameToIndex +ConvertIndexToColorName +CreateColorTransformA +CreateColorTransformW +CreateDeviceLinkProfile +CreateMultiProfileTransform +CreateProfileFromLogColorSpaceA +CreateProfileFromLogColorSpaceW +DccwCreateDisplayProfileAssociationList +DccwGetDisplayProfileAssociationList +DccwGetGamutSize +DccwReleaseDisplayProfileAssociationList +DccwSetDisplayProfileAssociationList +DeleteColorTransform +DeviceRenameEvent +DisassociateColorProfileFromDeviceA +DisassociateColorProfileFromDeviceW +EnumColorProfilesA +EnumColorProfilesW +GenerateCopyFilePaths +GetCMMInfo +GetColorDirectoryA +GetColorDirectoryW +GetColorProfileElement +GetColorProfileElementTag +GetColorProfileFromHandle +GetColorProfileHeader +GetCountColorProfileElements +GetNamedProfileInfo +GetPS2ColorRenderingDictionary +GetPS2ColorRenderingIntent +GetPS2ColorSpaceArray +GetStandardColorSpaceProfileA +GetStandardColorSpaceProfileW +InstallColorProfileA +InstallColorProfileW +InternalGetDeviceConfig +InternalGetPS2CSAFromLCS +InternalGetPS2ColorRenderingDictionary +InternalGetPS2ColorSpaceArray +InternalGetPS2PreviewCRD +InternalRefreshCalibration +InternalSetDeviceConfig +InternalWcsAssociateColorProfileWithDevice +IsColorProfileTagPresent +IsColorProfileValid +OpenColorProfileA +OpenColorProfileW +OpenDisplay +RegisterCMMA +RegisterCMMW +SelectCMM +SetColorProfileElement +SetColorProfileElementReference +SetColorProfileElementSize +SetColorProfileHeader +SetStandardColorSpaceProfileA +SetStandardColorSpaceProfileW +SpoolerCopyFileEvent +TranslateBitmapBits +TranslateColors +UninstallColorProfileA +UninstallColorProfileW +UnregisterCMMA +UnregisterCMMW +WcsAssociateColorProfileWithDevice +WcsCheckColors +WcsCreateIccProfile +WcsDisassociateColorProfileFromDevice +WcsEnumColorProfiles +WcsEnumColorProfilesSize +WcsGetCalibrationManagementState +WcsGetDefaultColorProfile +WcsGetDefaultColorProfileSize +WcsGetDefaultRenderingIntent +WcsGetUsePerUserProfiles +WcsGpCanInstallOrUninstallProfiles +WcsOpenColorProfileA +WcsOpenColorProfileW +WcsSetCalibrationManagementState +WcsSetDefaultColorProfile +WcsSetDefaultRenderingIntent +WcsSetUsePerUserProfiles +WcsTranslateColors +InternalGetPS2ColorRenderingDictionary2 +InternalGetPS2PreviewCRD2 +InternalGetPS2ColorSpaceArray2 diff --git a/lib/libc/mingw/libarm32/msctfmonitor.def b/lib/libc/mingw/libarm32/msctfmonitor.def new file mode 100644 index 0000000000..c183c8b62c --- /dev/null +++ b/lib/libc/mingw/libarm32/msctfmonitor.def @@ -0,0 +1,10 @@ +; +; Definition file of MsCtfMonitor.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "MsCtfMonitor.DLL" +EXPORTS +DoMsCtfMonitor +InitLocalMsCtfMonitor +UninitLocalMsCtfMonitor diff --git a/lib/libc/mingw/libarm32/newdev.def b/lib/libc/mingw/libarm32/newdev.def new file mode 100644 index 0000000000..c205569c06 --- /dev/null +++ b/lib/libc/mingw/libarm32/newdev.def @@ -0,0 +1,27 @@ +; +; Definition file of newdev.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "newdev.dll" +EXPORTS +DeviceInternetSettingUiW +DiInstallDevice +DiInstallDriverA +DiInstallDriverW +DiRollbackDriver +DiShowUpdateDevice +DiUninstallDevice +GetInternetPolicies +InstallNewDevice +InstallSelectedDriver +InstallWindowsUpdateDriver +InstallWindowsUpdateDriverEx +InstallWindowsUpdateDrivers +QueryWindowsUpdateDriverStatus +SetInternetPolicies +UpdateDriverForPlugAndPlayDevicesA +UpdateDriverForPlugAndPlayDevicesW +pDiDoDeviceInstallAsAdmin +pDiDoNullDriverInstall +pDiRunFinishInstallOperations diff --git a/lib/libc/mingw/libarm32/ninput.def b/lib/libc/mingw/libarm32/ninput.def new file mode 100644 index 0000000000..7247627744 --- /dev/null +++ b/lib/libc/mingw/libarm32/ninput.def @@ -0,0 +1,37 @@ +; +; Definition file of NInput.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "NInput.dll" +EXPORTS +DefaultInputHandler +AddPointerInteractionContext +BufferPointerPacketsInteractionContext +CreateInteractionContext +DestroyInteractionContext +GetCrossSlideParameterInteractionContext +GetInertiaParameterInteractionContext +GetInteractionConfigurationInteractionContext +GetMouseWheelParameterInteractionContext +GetPropertyInteractionContext +GetStateInteractionContext +ProcessBufferedPacketsInteractionContext +ProcessInertiaInteractionContext +ProcessPointerFramesInteractionContext +RegisterOutputCallbackInteractionContext +RemovePointerInteractionContext +ResetInteractionContext +SetCrossSlideParametersInteractionContext +SetInertiaParameterInteractionContext +SetInteractionConfigurationInteractionContext +SetMouseWheelParameterInteractionContext +SetPivotInteractionContext +SetPropertyInteractionContext +StopInteractionContext +ord_2500 @2500 +ord_2501 @2501 +ord_2502 @2502 +ord_2503 @2503 +ord_2504 @2504 +ord_2505 @2505 diff --git a/lib/libc/mingw/libarm32/ntlanman.def b/lib/libc/mingw/libarm32/ntlanman.def new file mode 100644 index 0000000000..e62aeff106 --- /dev/null +++ b/lib/libc/mingw/libarm32/ntlanman.def @@ -0,0 +1,25 @@ +; +; Definition file of NTLANMAN.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "NTLANMAN.dll" +EXPORTS +NPGetConnection +NPGetCaps +I_SystemFocusDialog +NPGetUser +NPAddConnection +NPCancelConnection +RegisterAppInstance +NPOpenEnum +NPEnumResource +NPCloseEnum +NPFormatNetworkName +NPAddConnection3 +NPGetUniversalName +NPGetResourceParent +NPGetConnectionPerformance +NPGetResourceInformation +NPGetReconnectFlags +NPGetConnection3 diff --git a/lib/libc/mingw/libarm32/ondemandconnroutehelper.def b/lib/libc/mingw/libarm32/ondemandconnroutehelper.def new file mode 100644 index 0000000000..08c63d9bc2 --- /dev/null +++ b/lib/libc/mingw/libarm32/ondemandconnroutehelper.def @@ -0,0 +1,13 @@ +; +; Definition file of OnDemandConnRouteHelper.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "OnDemandConnRouteHelper.DLL" +EXPORTS +OnDemandAddRouteRequest +OnDemandGetRoutingHint +OnDemandRegisterNotification +OnDemandRemoveMatchingRoute +OnDemandRemoveRouteRequest +OnDemandUnRegisterNotification diff --git a/lib/libc/mingw/libarm32/pdh.def b/lib/libc/mingw/libarm32/pdh.def new file mode 100644 index 0000000000..8bb340c442 --- /dev/null +++ b/lib/libc/mingw/libarm32/pdh.def @@ -0,0 +1,136 @@ +; +; Definition file of pdh.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "pdh.dll" +EXPORTS +PdhAdd009CounterA +PdhAdd009CounterW +PdhAddCounterA +PdhAddCounterW +PdhAddEnglishCounterA +PdhAddEnglishCounterW +PdhAddRelogCounter +PdhAddV1Counter +PdhAddV2Counter +PdhBindInputDataSourceA +PdhBindInputDataSourceW +PdhBrowseCountersA +PdhBrowseCountersHA +PdhBrowseCountersHW +PdhBrowseCountersW +PdhCalculateCounterFromRawValue +PdhCloseLog +PdhCloseQuery +PdhCollectQueryData +PdhCollectQueryDataEx +PdhCollectQueryDataWithTime +PdhComputeCounterStatistics +PdhConnectMachineA +PdhConnectMachineW +PdhCreateSQLTablesA +PdhCreateSQLTablesW +PdhEnumLogSetNamesA +PdhEnumLogSetNamesW +PdhEnumMachinesA +PdhEnumMachinesHA +PdhEnumMachinesHW +PdhEnumMachinesW +PdhEnumObjectItemsA +PdhEnumObjectItemsHA +PdhEnumObjectItemsHW +PdhEnumObjectItemsW +PdhEnumObjectsA +PdhEnumObjectsHA +PdhEnumObjectsHW +PdhEnumObjectsW +PdhExpandCounterPathA +PdhExpandCounterPathW +PdhExpandWildCardPathA +PdhExpandWildCardPathHA +PdhExpandWildCardPathHW +PdhExpandWildCardPathW +PdhFormatFromRawValue +PdhGetCounterInfoA +PdhGetCounterInfoW +PdhGetCounterTimeBase +PdhGetDataSourceTimeRangeA +PdhGetDataSourceTimeRangeH +PdhGetDataSourceTimeRangeW +PdhGetDefaultPerfCounterA +PdhGetDefaultPerfCounterHA +PdhGetDefaultPerfCounterHW +PdhGetDefaultPerfCounterW +PdhGetDefaultPerfObjectA +PdhGetDefaultPerfObjectHA +PdhGetDefaultPerfObjectHW +PdhGetDefaultPerfObjectW +PdhGetDllVersion +PdhGetExplainText +PdhGetFormattedCounterArrayA +PdhGetFormattedCounterArrayW +PdhGetFormattedCounterValue +PdhGetLogFileSize +PdhGetLogFileTypeA +PdhGetLogFileTypeW +PdhGetLogSetGUID +PdhGetRawCounterArrayA +PdhGetRawCounterArrayW +PdhGetRawCounterValue +PdhIsRealTimeQuery +PdhListLogFileHeaderA +PdhListLogFileHeaderW +PdhLookupPerfIndexByNameA +PdhLookupPerfIndexByNameW +PdhLookupPerfNameByIndexA +PdhLookupPerfNameByIndexW +PdhMakeCounterPathA +PdhMakeCounterPathW +PdhOpenLogA +PdhOpenLogW +PdhOpenQuery +PdhOpenQueryA +PdhOpenQueryH +PdhOpenQueryW +PdhParseCounterPathA +PdhParseCounterPathW +PdhParseInstanceNameA +PdhParseInstanceNameW +PdhReadRawLogRecord +PdhRelogA +PdhRelogW +PdhRemoveCounter +PdhResetRelogCounterValues +PdhSelectDataSourceA +PdhSelectDataSourceW +PdhSetCounterScaleFactor +PdhSetCounterValue +PdhSetDefaultRealTimeDataSource +PdhSetLogSetRunID +PdhSetQueryTimeRange +PdhTranslate009CounterA +PdhTranslate009CounterW +PdhTranslateLocaleCounterA +PdhTranslateLocaleCounterW +PdhUpdateLogA +PdhUpdateLogFileCatalog +PdhUpdateLogW +PdhValidatePathA +PdhValidatePathExA +PdhValidatePathExW +PdhValidatePathW +PdhVbAddCounter +PdhVbCreateCounterPathList +PdhVbGetCounterPathElements +PdhVbGetCounterPathFromList +PdhVbGetDoubleCounterValue +PdhVbGetLogFileSize +PdhVbGetOneCounterPath +PdhVbIsGoodStatus +PdhVbOpenLog +PdhVbOpenQuery +PdhVbUpdateLog +PdhVerifySQLDBA +PdhVerifySQLDBW +PdhWriteRelogSample diff --git a/lib/libc/mingw/libarm32/query.def b/lib/libc/mingw/libarm32/query.def new file mode 100644 index 0000000000..091bd136aa --- /dev/null +++ b/lib/libc/mingw/libarm32/query.def @@ -0,0 +1,51 @@ +; +; Definition file of query.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "query.dll" +EXPORTS +BeginCacheTransaction +CIBuildQueryNode +CIBuildQueryTree +CICreateCommand +CIGetGlobalPropertyList +CIMakeICommand +CIRestrictionToFullTree +CIState +CITextToFullTree +CITextToFullTreeEx +CITextToSelectTree +CITextToSelectTreeEx +CiCreateSecurityDescriptor +CiSvcMain +CollectCIISAPIPerformanceData +CollectCIPerformanceData +CollectFILTERPerformanceData +DoneCIISAPIPerformanceData +DoneCIPerformanceData +DoneFILTERPerformanceData +EndCacheTransaction +FsCiShutdown +InitializeCIISAPIPerformanceData +InitializeCIPerformanceData +InitializeFILTERPerformanceData +LoadBinaryFilter +LoadTextFilter +SetCatalogState +SetupCache +SetupCacheEx +SvcEntry_CiSvc +BindIFilterFromStorage +BindIFilterFromStream +CIRevertToSelf +CIShutdown +InternalBindIFilterFromDocCLSID +InternalBindIFilterFromFileName +InternalBindIFilterFromStorage +InternalBindIFilterFromStream +LoadIFilter +LoadIFilterEx +LocateCatalogs +LocateCatalogsA +LocateCatalogsW diff --git a/lib/libc/mingw/libarm32/rasapi32.def b/lib/libc/mingw/libarm32/rasapi32.def new file mode 100644 index 0000000000..feb82e18fa --- /dev/null +++ b/lib/libc/mingw/libarm32/rasapi32.def @@ -0,0 +1,134 @@ +; +; Definition file of RASAPI32.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "RASAPI32.dll" +EXPORTS +DDMFreePhonebookContext +DDMFreeRemoteEndpoint +DDMGetAddressesFromPhonebook +DDMGetPhoneBookContext +DDMGetPhonebookInfo +DwCloneEntry +DwEnumEntryDetails +DwRasUninitialize +GetAutoTriggerProfileInfo +IsActiveAutoTriggerConnection +LaunchVanUIW +RasAutoDialSharedConnection +RasAutodialAddressToNetwork +RasAutodialEntryToNetwork +RasClearConnectionStatistics +RasClearLinkStatistics +RasCompleteDialMachineCleanup +RasConfigUserProxySettingsW +RasConnectionNotificationA +RasConnectionNotificationW +RasCreatePhonebookEntryA +RasCreatePhonebookEntryW +RasDeleteEntryA +RasDeleteEntryW +RasDeleteSubEntryA +RasDeleteSubEntryW +RasDialA +RasDialW +RasEditPhonebookEntryA +RasEditPhonebookEntryW +RasEnumAutodialAddressesA +RasEnumAutodialAddressesW +RasEnumConnectionsA +RasEnumConnectionsW +RasEnumDevicesA +RasEnumDevicesW +RasEnumEntriesA +RasEnumEntriesW +RasFreeEapUserIdentityA +RasFreeEapUserIdentityW +RasFreeEntryAdvancedProperties +RasGetAutoTriggerConnectStatus +RasGetAutodialAddressA +RasGetAutodialAddressW +RasGetAutodialEnableA +RasGetAutodialEnableW +RasGetAutodialParamA +RasGetAutodialParamW +RasGetConnectStatusA +RasGetConnectStatusW +RasGetConnectionErrorStringW +RasGetConnectionStatistics +RasGetCountryInfoA +RasGetCountryInfoW +RasGetCredentialsA +RasGetCredentialsW +RasGetCustomAuthDataA +RasGetCustomAuthDataW +RasGetEapUserDataA +RasGetEapUserDataW +RasGetEapUserIdentityA +RasGetEapUserIdentityW +RasGetEntryAdvancedProperties +RasGetEntryDialParamsA +RasGetEntryDialParamsW +RasGetEntryHrasconnW +RasGetEntryPropertiesA +RasGetEntryPropertiesW +RasGetErrorStringA +RasGetErrorStringW +RasGetHport +RasGetLinkStatistics +RasGetNapStatus +RasGetPbkPath +RasGetProjectionInfoA +RasGetProjectionInfoEx +RasGetProjectionInfoW +RasGetSubEntryHandleA +RasGetSubEntryHandleW +RasGetSubEntryPropertiesA +RasGetSubEntryPropertiesW +RasHandleTriggerConnDisconnect +RasHangUpA +RasHangUpW +RasInvokeEapUI +RasIsPublicPhonebook +RasIsSharedConnection +RasQueryRedialOnLinkFailure +RasQuerySharedAutoDial +RasQuerySharedConnection +RasRenameEntryA +RasRenameEntryW +RasScriptGetIpAddress +RasScriptInit +RasScriptReceive +RasScriptSend +RasScriptTerm +RasSetAutodialAddressA +RasSetAutodialAddressW +RasSetAutodialEnableA +RasSetAutodialEnableW +RasSetAutodialParamA +RasSetAutodialParamW +RasSetCredentialsA +RasSetCredentialsW +RasSetCustomAuthDataA +RasSetCustomAuthDataW +RasSetEapUserDataA +RasSetEapUserDataAEx +RasSetEapUserDataW +RasSetEapUserDataWEx +RasSetEntryAdvancedProperties +RasSetEntryDialParamsA +RasSetEntryDialParamsW +RasSetEntryPropertiesA +RasSetEntryPropertiesW +RasSetOldPassword +RasSetPerConnectionProxy +RasSetSharedAutoDial +RasSetSubEntryPropertiesA +RasSetSubEntryPropertiesW +RasTriggerConnection +RasUpdateConnection +RasValidateEntryNameA +RasValidateEntryNameW +RasWriteSharedPbkOptions +UnInitializeRAS diff --git a/lib/libc/mingw/libarm32/rasdlg.def b/lib/libc/mingw/libarm32/rasdlg.def new file mode 100644 index 0000000000..45af4c8536 --- /dev/null +++ b/lib/libc/mingw/libarm32/rasdlg.def @@ -0,0 +1,32 @@ +; +; Definition file of RASDLG.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "RASDLG.dll" +EXPORTS +RasHandleDiagnostics +DwTerminalDlg +GetRasDialOutProtocols +RasAutodialQueryDlgA +RasAutodialQueryDlgW +RasDialDlgA +RasDialDlgW +RasEntryDlgA +RasEntryDlgW +RasPhonebookDlgA +RasPhonebookDlgW +RasSrvAddPropPages +RasSrvAllowConnectionsConfig +RasSrvCleanupService +RasSrvEnumConnections +RasSrvHangupConnection +RasSrvInitializeService +RasSrvIsConnectionConnected +RasSrvIsICConfigured +RasSrvIsServiceRunning +RasUserEnableManualDial +RasUserGetManualDial +RasUserPrefsDlg +RouterEntryDlgA +RouterEntryDlgW diff --git a/lib/libc/mingw/libarm32/rometadata.def b/lib/libc/mingw/libarm32/rometadata.def new file mode 100644 index 0000000000..8aeef1fd44 --- /dev/null +++ b/lib/libc/mingw/libarm32/rometadata.def @@ -0,0 +1,8 @@ +; +; Definition file of RoMetadata.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "RoMetadata.dll" +EXPORTS +MetaDataGetDispenser diff --git a/lib/libc/mingw/libarm32/sas.def b/lib/libc/mingw/libarm32/sas.def new file mode 100644 index 0000000000..8e8fadf827 --- /dev/null +++ b/lib/libc/mingw/libarm32/sas.def @@ -0,0 +1,8 @@ +; +; Definition file of SAS.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "SAS.dll" +EXPORTS +SendSAS diff --git a/lib/libc/mingw/libarm32/sfc.def b/lib/libc/mingw/libarm32/sfc.def new file mode 100644 index 0000000000..07f3783ff5 --- /dev/null +++ b/lib/libc/mingw/libarm32/sfc.def @@ -0,0 +1,23 @@ +; +; Definition file of sfc.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "sfc.dll" +EXPORTS +ord_1 @1 +ord_2 @2 +ord_3 @3 +ord_4 @4 +ord_5 @5 +ord_6 @6 +ord_7 @7 +ord_8 @8 +ord_9 @9 +SRSetRestorePoint +SRSetRestorePointA +SRSetRestorePointW +SfcGetNextProtectedFile +SfcIsFileProtected +SfcIsKeyProtected +SfpVerifyFile diff --git a/lib/libc/mingw/libarm32/shdocvw.def b/lib/libc/mingw/libarm32/shdocvw.def new file mode 100644 index 0000000000..321c6ab257 --- /dev/null +++ b/lib/libc/mingw/libarm32/shdocvw.def @@ -0,0 +1,129 @@ +; +; Definition file of SHDOCVW.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "SHDOCVW.dll" +EXPORTS +ord_101 @101 +ord_102 @102 +ord_103 @103 +ord_104 @104 +ord_105 @105 +AddUrlToFavorites +ord_110 @110 +ord_111 @111 +DllRegisterWindowClasses +DoAddToFavDlg +DoAddToFavDlgW +ord_115 @115 +ord_116 @116 +ord_117 @117 +ord_118 @118 +ord_119 @119 +ord_120 @120 +ord_121 @121 +ord_122 @122 +ord_123 @123 +DoFileDownload +ord_125 @125 +DoFileDownloadEx +DoOrganizeFavDlg +DoOrganizeFavDlgW +DoPrivacyDlg +ord_130 @130 +ord_131 @131 +HlinkFindFrame +HlinkFrameNavigate +HlinkFrameNavigateNHL +ord_135 @135 +ord_136 @136 +ord_137 @137 +ord_138 @138 +ord_139 @139 +ord_140 @140 +ord_141 @141 +ord_142 @142 +ord_143 @143 +ImportPrivacySettings +ord_145 @145 +ord_146 @146 +ord_147 @147 +ord_148 @148 +ord_149 @149 +ord_150 @150 +ord_151 @151 +ord_152 @152 +ord_153 @153 +OpenURL +SHGetIDispatchForFolder +SetQueryNetSessionCount +SetShellOfflineState +ord_158 @158 +ord_159 @159 +ord_160 @160 +ord_161 @161 +ord_162 @162 +SHAddSubscribeFavorite +ord_164 @164 +ord_165 @165 +SoftwareUpdateMessageBox +ord_167 @167 +URLQualifyA +ord_169 @169 +ord_170 @170 +ord_171 @171 +ord_172 @172 +ord_173 @173 +ord_174 @174 +ord_175 @175 +ord_176 @176 +ord_177 @177 +ord_178 @178 +ord_179 @179 +ord_180 @180 +ord_181 @181 +URLQualifyW +ord_183 @183 +ord_185 @185 +ord_187 @187 +ord_188 @188 +ord_189 @189 +ord_190 @190 +ord_191 @191 +ord_192 @192 +ord_194 @194 +ord_195 @195 +ord_196 @196 +ord_197 @197 +ord_198 @198 +ord_199 @199 +ord_200 @200 +ord_203 @203 +ord_204 @204 +ord_208 @208 +ord_209 @209 +ord_210 @210 +ord_211 @211 +ord_212 @212 +ord_213 @213 +ord_214 @214 +ord_215 @215 +ord_216 @216 +ord_217 @217 +ord_218 @218 +ord_219 @219 +ord_221 @221 +ord_222 @222 +ord_223 @223 +ord_224 @224 +ord_225 @225 +ord_226 @226 +ord_227 @227 +ord_228 @228 +ord_229 @229 +ord_230 @230 +ord_231 @231 +ord_232 @232 +ord_233 @233 +ord_234 @234 diff --git a/lib/libc/mingw/libarm32/slc.def b/lib/libc/mingw/libarm32/slc.def new file mode 100644 index 0000000000..3bac8e5294 --- /dev/null +++ b/lib/libc/mingw/libarm32/slc.def @@ -0,0 +1,48 @@ +; +; Definition file of SLC.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "SLC.dll" +EXPORTS +SLpCheckProductKey +SLpGetGenuineLocal +SLpProcessOemProductKey +SLpUpdateComponentTokens +SLClose +SLConsumeRight +SLConsumeWindowsRight +SLDepositOfflineConfirmationId +SLDepositOfflineConfirmationIdEx +SLFireEvent +SLGenerateOfflineInstallationId +SLGenerateOfflineInstallationIdEx +SLGetApplicationInformation +SLGetGenuineInformation +SLGetInstalledProductKeyIds +SLGetLicense +SLGetLicenseFileId +SLGetLicenseInformation +SLGetLicensingStatusInformation +SLGetPKeyId +SLGetPKeyInformation +SLGetPolicyInformation +SLGetPolicyInformationDWORD +SLGetProductSkuInformation +SLGetSLIDList +SLGetServiceInformation +SLGetWindowsInformation +SLGetWindowsInformationDWORD +SLInstallLicense +SLInstallProofOfPurchase +SLIsWindowsGenuineLocal +SLOpen +SLReArmWindows +SLRegisterEvent +SLRegisterWindowsEvent +SLSetCurrentProductKey +SLSetGenuineInformation +SLUninstallLicense +SLUninstallProofOfPurchase +SLUnregisterEvent +SLUnregisterWindowsEvent diff --git a/lib/libc/mingw/libarm32/spoolss.def b/lib/libc/mingw/libarm32/spoolss.def new file mode 100644 index 0000000000..9635032c37 --- /dev/null +++ b/lib/libc/mingw/libarm32/spoolss.def @@ -0,0 +1,205 @@ +; +; Definition file of SPOOLSS.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "SPOOLSS.DLL" +EXPORTS +OpenPrinterExW +RouterCorePrinterDriverInstalled +RouterCreatePrintAsyncNotificationChannel +RouterDeletePrinterDriverPackage +RouterGetCorePrinterDrivers +RouterGetPrintClassObject +RouterGetPrinterDriverPackagePath +RouterInstallPrinterDriverFromPackage +RouterRegisterForPrintAsyncNotifications +RouterUnregisterForPrintAsyncNotifications +RouterUploadPrinterDriverPackage +AbortPrinter +AddFormW +AddJobW +AddMonitorW +AddPerMachineConnectionW +AddPortExW +AddPortW +AddPrintProcessorW +AddPrintProvidorW +AddPrinterConnectionW +AddPrinterDriverExW +AddPrinterDriverW +AddPrinterExW +AddPrinterW +AdjustPointers +AdjustPointersInStructuresArray +AlignKMPtr +AlignRpcPtr +AllocSplStr +AllowRemoteCalls +AppendPrinterNotifyInfoData +BuildOtherNamesFromMachineName +CacheAddName +CacheCreateAndAddNode +CacheCreateAndAddNodeWithIPAddresses +CacheDeleteNode +CacheIsNameCluster +CacheIsNameInNodeList +CallDrvDevModeConversion +CallRouterFindFirstPrinterChangeNotification +CheckLocalCall +ClosePrinter +ConfigurePortW +CreatePrinterIC +DeleteFormW +DeleteMonitorW +DeletePerMachineConnectionW +DeletePortW +DeletePrintProcessorW +DeletePrintProvidorW +DeletePrinter +DeletePrinterConnectionW +DeletePrinterDataExW +DeletePrinterDataW +DeletePrinterDriverExW +DeletePrinterDriverW +DeletePrinterIC +DeletePrinterKeyW +DllAllocSplMem +DllAllocSplStr +DllFreeSplMem +DllFreeSplStr +DllReallocSplMem +DllReallocSplStr +EndDocPrinter +EndPagePrinter +EnumFormsW +EnumJobsW +EnumMonitorsW +EnumPerMachineConnectionsW +EnumPortsW +EnumPrintProcessorDatatypesW +EnumPrintProcessorsW +EnumPrinterDataExW +EnumPrinterDataW +EnumPrinterDriversW +EnumPrinterKeyW +EnumPrintersW +FindClosePrinterChangeNotification +FlushPrinter +FormatPrinterForRegistryKey +FormatRegistryKeyForPrinter +FreeOtherNames +GetFormW +GetJobAttributes +GetJobAttributesEx +GetJobW +GetNetworkId +GetPrintProcessorDirectoryW +GetPrinterDataExW +GetPrinterDataW +GetPrinterDriverDirectoryW +GetPrinterDriverExW +GetPrinterDriverW +GetPrinterW +GetServerPolicy +GetShrinkedSize +GetSpoolerTlsIndexes +ImpersonatePrinterClient +InitializeRouter +IsNameTheLocalMachineOrAClusterSpooler +IsNamedPipeRpcCall +MIDL_user_allocate1 +MIDL_user_free1 +MakeOffset +MakePTR +MarshallDownStructure +MarshallDownStructuresArray +MarshallUpStructure +MarshallUpStructuresArray +OldGetPrinterDriverW +OpenPrinter2W +OpenPrinterPort2W +OpenPrinterW +PackStringToEOB +PackStrings +PartialReplyPrinterChangeNotification +PlayGdiScriptOnPrinterIC +PrinterHandleRundown +PrinterMessageBoxW +ProvidorFindClosePrinterChangeNotification +ProvidorFindFirstPrinterChangeNotification +ReadPrinter +ReallocSplMem +ReallocSplStr +RemoteFindFirstPrinterChangeNotification +ReplyClosePrinter +ReplyOpenPrinter +ReplyPrinterChangeNotification +ReplyPrinterChangeNotificationEx +ReportJobProcessingProgress +ResetPrinterW +RevertToPrinterSelf +RouterAddPrinterConnection2 +RouterAllocBidiMem +RouterAllocBidiResponseContainer +RouterAllocPrinterNotifyInfo +RouterBroadcastMessage +RouterFindCompatibleDriver +RouterFindFirstPrinterChangeNotification +RouterFindNextPrinterChangeNotification +RouterFreeBidiMem +RouterFreeBidiResponseContainer +RouterFreePrinterNotifyInfo +RouterInternalGetPrinterDriver +RouterRefreshPrinterChangeNotification +RouterReplyPrinter +RouterSpoolerSetPolicy +ScheduleJob +SeekPrinter +SendRecvBidiData +SetFormW +SetJobW +SetPortW +SetPrinterDataExW +SetPrinterDataW +SetPrinterW +SplCloseSpoolFileHandle +SplCommitSpoolData +SplDriverUnloadComplete +SplGetClientUserHandle +SplGetSpoolFileInfo +SplGetUserSidStringFromToken +SplInitializeWinSpoolDrv +SplIsSessionZero +SplIsUpgrade +SplProcessPnPEvent +SplProcessSessionEvent +SplPromptUIInUsersSession +SplQueryUserInfo +SplReadPrinter +SplRegisterForDeviceEvents +SplRegisterForSessionEvents +SplShutDownRouter +SplUalCollectData +SplUnregisterForDeviceEvents +SplUnregisterForSessionEvents +SpoolerFindClosePrinterChangeNotification +SpoolerFindFirstPrinterChangeNotification +SpoolerFindNextPrinterChangeNotification +SpoolerFreePrinterNotifyInfo +SpoolerHasInitialized +SpoolerInit +SpoolerRefreshPrinterChangeNotification +StartDocPrinterW +StartPagePrinter +UndoAlignKMPtr +UndoAlignRpcPtr +UpdateBufferSize +UpdatePrinterRegAll +UpdatePrinterRegUser +WaitForPrinterChange +WaitForSpoolerInitialization +WritePrinter +XcvDataW +bGetDevModePerUser +bSetDevModePerUser diff --git a/lib/libc/mingw/libarm32/uiautomationcore.def b/lib/libc/mingw/libarm32/uiautomationcore.def new file mode 100644 index 0000000000..6196bc3d98 --- /dev/null +++ b/lib/libc/mingw/libarm32/uiautomationcore.def @@ -0,0 +1,102 @@ +; +; Definition file of UIAutomationCore.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "UIAutomationCore.DLL" +EXPORTS +DockPattern_SetDockPosition +ExpandCollapsePattern_Collapse +ExpandCollapsePattern_Expand +GridPattern_GetItem +InvokePattern_Invoke +ItemContainerPattern_FindItemByProperty +LegacyIAccessiblePattern_DoDefaultAction +LegacyIAccessiblePattern_GetIAccessible +LegacyIAccessiblePattern_Select +LegacyIAccessiblePattern_SetValue +MultipleViewPattern_GetViewName +MultipleViewPattern_SetCurrentView +RangeValuePattern_SetValue +ScrollItemPattern_ScrollIntoView +ScrollPattern_Scroll +ScrollPattern_SetScrollPercent +SelectionItemPattern_AddToSelection +SelectionItemPattern_RemoveFromSelection +SelectionItemPattern_Select +SynchronizedInputPattern_Cancel +SynchronizedInputPattern_StartListening +TextPattern_GetSelection +TextPattern_GetVisibleRanges +TextPattern_RangeFromChild +TextPattern_RangeFromPoint +TextPattern_get_DocumentRange +TextPattern_get_SupportedTextSelection +TextRange_AddToSelection +TextRange_Clone +TextRange_Compare +TextRange_CompareEndpoints +TextRange_ExpandToEnclosingUnit +TextRange_FindAttribute +TextRange_FindText +TextRange_GetAttributeValue +TextRange_GetBoundingRectangles +TextRange_GetChildren +TextRange_GetEnclosingElement +TextRange_GetText +TextRange_Move +TextRange_MoveEndpointByRange +TextRange_MoveEndpointByUnit +TextRange_RemoveFromSelection +TextRange_ScrollIntoView +TextRange_Select +TogglePattern_Toggle +TransformPattern_Move +TransformPattern_Resize +TransformPattern_Rotate +UiaAddEvent +UiaClientsAreListening +UiaDisconnectAllProviders +UiaDisconnectProvider +UiaEventAddWindow +UiaEventRemoveWindow +UiaFind +UiaGetErrorDescription +UiaGetPatternProvider +UiaGetPropertyValue +UiaGetReservedMixedAttributeValue +UiaGetReservedNotSupportedValue +UiaGetRootNode +UiaGetRuntimeId +UiaGetUpdatedCache +UiaHPatternObjectFromVariant +UiaHTextRangeFromVariant +UiaHUiaNodeFromVariant +UiaHasServerSideProvider +UiaHostProviderFromHwnd +UiaIAccessibleFromProvider +UiaLookupId +UiaNavigate +UiaNodeFromFocus +UiaNodeFromHandle +UiaNodeFromPoint +UiaNodeFromProvider +UiaNodeRelease +UiaPatternRelease +UiaProviderForNonClient +UiaProviderFromIAccessible +UiaRaiseAsyncContentLoadedEvent +UiaRaiseAutomationEvent +UiaRaiseAutomationPropertyChangedEvent +UiaRaiseStructureChangedEvent +UiaRaiseTextEditTextChangedEvent +UiaRegisterProviderCallback +UiaRemoveEvent +UiaReturnRawElementProvider +UiaSetFocus +UiaTextRangeRelease +ValuePattern_SetValue +VirtualizedItemPattern_Realize +WindowPattern_Close +WindowPattern_SetWindowVisualState +WindowPattern_WaitForInputIdle diff --git a/lib/libc/mingw/libarm32/vssapi.def b/lib/libc/mingw/libarm32/vssapi.def new file mode 100644 index 0000000000..3aff0956b6 --- /dev/null +++ b/lib/libc/mingw/libarm32/vssapi.def @@ -0,0 +1,89 @@ +; +; Definition file of VSSAPI.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "VSSAPI.DLL" +EXPORTS +IsVolumeSnapshotted +VssFreeSnapshotProperties +ShouldBlockRevert +??0CVssJetWriter@@QAA@XZ +??0CVssWriter@@QAA@XZ +??1CVssJetWriter@@UAA@XZ +??1CVssWriter@@UAA@XZ +?AreComponentsSelected@CVssJetWriter@@IBA_NXZ +?AreComponentsSelected@CVssWriter@@IBA_NXZ +?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z +?CreateVssExamineWriterMetadata@@YGJPAGPAPAVIVssExamineWriterMetadata@@@Z +?CreateVssSnapshotSetDescription@@YAJU_GUID@@JPAPAVIVssSnapshotSetDescription@@@Z +?GetBackupType@CVssJetWriter@@IBA?AW4_VSS_BACKUP_TYPE@@XZ +?GetBackupType@CVssWriter@@IBA?AW4_VSS_BACKUP_TYPE@@XZ +?GetContext@CVssJetWriter@@IBAJXZ +?GetContext@CVssWriter@@IBAJXZ +?GetCurrentLevel@CVssJetWriter@@IBA?AW4_VSS_APPLICATION_LEVEL@@XZ +?GetCurrentLevel@CVssWriter@@IBA?AW4_VSS_APPLICATION_LEVEL@@XZ +?GetCurrentSnapshotSetId@CVssJetWriter@@IBA?AU_GUID@@XZ +?GetCurrentSnapshotSetId@CVssWriter@@IBA?AU_GUID@@XZ +?GetCurrentVolumeArray@CVssJetWriter@@IBAPAPBGXZ +?GetCurrentVolumeArray@CVssWriter@@IBAPAPBGXZ +?GetCurrentVolumeCount@CVssJetWriter@@IBAIXZ +?GetCurrentVolumeCount@CVssWriter@@IBAIXZ +?GetRestoreType@CVssJetWriter@@IBA?AW4_VSS_RESTORE_TYPE@@XZ +?GetRestoreType@CVssWriter@@IBA?AW4_VSS_RESTORE_TYPE@@XZ +?GetSnapshotDeviceName@CVssJetWriter@@IBAJPBGPAPBG@Z +?GetSnapshotDeviceName@CVssWriter@@IBAJPBGPAPBG@Z +?Initialize@CVssJetWriter@@QAAJU_GUID@@PBG_N211K@Z +?Initialize@CVssWriter@@QAAJU_GUID@@PBGW4VSS_USAGE_TYPE@@W4VSS_SOURCE_TYPE@@W4_VSS_APPLICATION_LEVEL@@KW4VSS_ALTERNATE_WRITER_STATE@@_N1@Z +?InstallAlternateWriter@CVssWriter@@QAAJU_GUID@@0@Z +?IsBootableSystemStateBackedUp@CVssJetWriter@@IBA_NXZ +?IsBootableSystemStateBackedUp@CVssWriter@@IBA_NXZ +?IsPartialFileSupportEnabled@CVssJetWriter@@IBA_NXZ +?IsPartialFileSupportEnabled@CVssWriter@@IBA_NXZ +?IsPathAffected@CVssJetWriter@@IBA_NPBG@Z +?IsPathAffected@CVssWriter@@IBA_NPBG@Z +?LoadVssSnapshotSetDescription@@YAJPBGPAPAVIVssSnapshotSetDescription@@U_GUID@@@Z +?OnAbortBegin@CVssJetWriter@@UAAXXZ +?OnAbortEnd@CVssJetWriter@@UAAXXZ +?OnBackOffIOOnVolume@CVssWriter@@UAA_NPAGU_GUID@@1@Z +?OnBackupComplete@CVssWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnBackupCompleteBegin@CVssJetWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnBackupCompleteEnd@CVssJetWriter@@UAA_NPAVIVssWriterComponents@@_N@Z +?OnBackupShutdown@CVssWriter@@UAA_NU_GUID@@@Z +?OnContinueIOOnVolume@CVssWriter@@UAA_NPAGU_GUID@@1@Z +?OnFreezeBegin@CVssJetWriter@@UAA_NXZ +?OnFreezeEnd@CVssJetWriter@@UAA_N_N@Z +?OnIdentify@CVssJetWriter@@UAA_NPAVIVssCreateWriterMetadata@@@Z +?OnIdentify@CVssWriter@@UAA_NPAVIVssCreateWriterMetadata@@@Z +?OnPostRestore@CVssWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnPostRestoreBegin@CVssJetWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnPostRestoreEnd@CVssJetWriter@@UAA_NPAVIVssWriterComponents@@_N@Z +?OnPostSnapshot@CVssJetWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnPostSnapshot@CVssWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnPreRestore@CVssWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnPreRestoreBegin@CVssJetWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnPreRestoreEnd@CVssJetWriter@@UAA_NPAVIVssWriterComponents@@_N@Z +?OnPrepareBackup@CVssWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnPrepareBackupBegin@CVssJetWriter@@UAA_NPAVIVssWriterComponents@@@Z +?OnPrepareBackupEnd@CVssJetWriter@@UAA_NPAVIVssWriterComponents@@_N@Z +?OnPrepareSnapshotBegin@CVssJetWriter@@UAA_NXZ +?OnPrepareSnapshotEnd@CVssJetWriter@@UAA_N_N@Z +?OnThawBegin@CVssJetWriter@@UAA_NXZ +?OnThawEnd@CVssJetWriter@@UAA_N_N@Z +?OnVSSApplicationStartup@CVssWriter@@UAA_NXZ +?OnVSSShutdown@CVssWriter@@UAA_NXZ +?SetWriterFailure@CVssJetWriter@@IAAJJ@Z +?SetWriterFailure@CVssWriter@@IAAJJ@Z +?Subscribe@CVssWriter@@QAAJK@Z +?Uninitialize@CVssJetWriter@@QAAXXZ +?Unsubscribe@CVssWriter@@QAAJXZ +CreateVssBackupComponentsInternal +CreateVssExamineWriterMetadataInternal +CreateVssExpressWriterInternal +CreateWriter +CreateWriterEx +GetProviderMgmtInterface +GetProviderMgmtInterfaceInternal +IsVolumeSnapshottedInternal +ShouldBlockRevertInternal +VssFreeSnapshotPropertiesInternal diff --git a/lib/libc/mingw/libarm32/wcmapi.def b/lib/libc/mingw/libarm32/wcmapi.def new file mode 100644 index 0000000000..e7b6eb4c58 --- /dev/null +++ b/lib/libc/mingw/libarm32/wcmapi.def @@ -0,0 +1,31 @@ +; +; Definition file of wcmapi.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "wcmapi.dll" +EXPORTS +WcmBeginIgnoreProfileList +WcmCancelOnDemandRequest +WcmCloseHandle +WcmCloseOnDemandRequestHandle +WcmEndIgnoreProfileList +WcmEnterConnectedStandby +WcmEnterNetQuiet +WcmEnumInterfaces +WcmExitConnectedStandby +WcmExitNetQuiet +WcmFreeMemory +WcmGetInterfaceToken +WcmGetProfileList +WcmOpenHandle +WcmOpenOnDemandRequestHandle +WcmOrderConnection +WcmQueryOnDemandRequestStateInfo +WcmQueryParameter +WcmQueryProperty +WcmResetIgnoreProfileList +WcmSetParameter +WcmSetProfileList +WcmSetProperty +WcmStartOnDemandRequest diff --git a/lib/libc/mingw/libarm32/webservices.def b/lib/libc/mingw/libarm32/webservices.def new file mode 100644 index 0000000000..45fb377b76 --- /dev/null +++ b/lib/libc/mingw/libarm32/webservices.def @@ -0,0 +1,200 @@ +; +; Definition file of webservices.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "webservices.dll" +EXPORTS +WsAbandonCall +WsAbandonMessage +WsAbortChannel +WsAbortListener +WsAbortServiceHost +WsAbortServiceProxy +WsAcceptChannel +WsAddCustomHeader +WsAddErrorString +WsAddMappedHeader +WsAddressMessage +WsAlloc +WsAsyncExecute +WsCall +WsCheckMustUnderstandHeaders +WsCloseChannel +WsCloseListener +WsCloseServiceHost +WsCloseServiceProxy +WsCombineUrl +WsCopyError +WsCopyNode +WsCreateChannel +WsCreateChannelForListener +WsCreateError +WsCreateFaultFromError +WsCreateHeap +WsCreateListener +WsCreateMessage +WsCreateMessageForChannel +WsCreateMetadata +WsCreateReader +WsCreateServiceEndpointFromTemplate +WsCreateServiceHost +WsCreateServiceProxy +WsCreateServiceProxyFromTemplate +WsCreateWriter +WsCreateXmlBuffer +WsCreateXmlSecurityToken +WsDateTimeToFileTime +WsDecodeUrl +WsEncodeUrl +WsEndReaderCanonicalization +WsEndWriterCanonicalization +WsFileTimeToDateTime +WsFillBody +WsFillReader +WsFindAttribute +WsFlushBody +WsFlushWriter +WsFreeChannel +WsFreeError +WsFreeHeap +WsFreeListener +WsFreeMessage +WsFreeMetadata +WsFreeReader +WsFreeSecurityToken +WsFreeServiceHost +WsFreeServiceProxy +WsFreeWriter +WsGetChannelProperty +WsGetCustomHeader +WsGetDictionary +WsGetErrorProperty +WsGetErrorString +WsGetFaultErrorDetail +WsGetFaultErrorProperty +WsGetHeader +WsGetHeaderAttributes +WsGetHeapProperty +WsGetListenerProperty +WsGetMappedHeader +WsGetMessageProperty +WsGetMetadataEndpoints +WsGetMetadataProperty +WsGetMissingMetadataDocumentAddress +WsGetNamespaceFromPrefix +WsGetOperationContextProperty +WsGetPolicyAlternativeCount +WsGetPolicyProperty +WsGetPrefixFromNamespace +WsGetReaderNode +WsGetReaderPosition +WsGetReaderProperty +WsGetSecurityContextProperty +WsGetSecurityTokenProperty +WsGetServiceHostProperty +WsGetServiceProxyProperty +WsGetWriterPosition +WsGetWriterProperty +WsGetXmlAttribute +WsInitializeMessage +WsMarkHeaderAsUnderstood +WsMatchPolicyAlternative +WsMoveReader +WsMoveWriter +WsOpenChannel +WsOpenListener +WsOpenServiceHost +WsOpenServiceProxy +WsPullBytes +WsPushBytes +WsReadArray +WsReadAttribute +WsReadBody +WsReadBytes +WsReadChars +WsReadCharsUtf8 +WsReadElement +WsReadEndAttribute +WsReadEndElement +WsReadEndpointAddressExtension +WsReadEnvelopeEnd +WsReadEnvelopeStart +WsReadMessageEnd +WsReadMessageStart +WsReadMetadata +WsReadNode +WsReadQualifiedName +WsReadStartAttribute +WsReadStartElement +WsReadToStartElement +WsReadType +WsReadValue +WsReadXmlBuffer +WsReadXmlBufferFromBytes +WsReceiveMessage +WsRegisterOperationForCancel +WsRemoveCustomHeader +WsRemoveHeader +WsRemoveMappedHeader +WsRemoveNode +WsRequestReply +WsRequestSecurityToken +WsResetChannel +WsResetError +WsResetHeap +WsResetListener +WsResetMessage +WsResetMetadata +WsResetServiceHost +WsResetServiceProxy +WsRevokeSecurityContext +WsSendFaultMessageForError +WsSendMessage +WsSendReplyMessage +WsSetChannelProperty +WsSetErrorProperty +WsSetFaultErrorDetail +WsSetFaultErrorProperty +WsSetHeader +WsSetInput +WsSetInputToBuffer +WsSetListenerProperty +WsSetMessageProperty +WsSetOutput +WsSetOutputToBuffer +WsSetReaderPosition +WsSetWriterPosition +WsShutdownSessionChannel +WsSkipNode +WsStartReaderCanonicalization +WsStartWriterCanonicalization +WsTrimXmlWhitespace +WsVerifyXmlNCName +WsWriteArray +WsWriteAttribute +WsWriteBody +WsWriteBytes +WsWriteChars +WsWriteCharsUtf8 +WsWriteElement +WsWriteEndAttribute +WsWriteEndCData +WsWriteEndElement +WsWriteEndStartElement +WsWriteEnvelopeEnd +WsWriteEnvelopeStart +WsWriteMessageEnd +WsWriteMessageStart +WsWriteNode +WsWriteQualifiedName +WsWriteStartAttribute +WsWriteStartCData +WsWriteStartElement +WsWriteText +WsWriteType +WsWriteValue +WsWriteXmlBuffer +WsWriteXmlBufferToBytes +WsWriteXmlnsAttribute +WsXmlStringEquals diff --git a/lib/libc/mingw/libarm32/wer.def b/lib/libc/mingw/libarm32/wer.def new file mode 100644 index 0000000000..f8a6f06718 --- /dev/null +++ b/lib/libc/mingw/libarm32/wer.def @@ -0,0 +1,129 @@ +; +; Definition file of wer.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "wer.dll" +EXPORTS +WerSysprepCleanup +WerSysprepGeneralize +WerSysprepSpecialize +WerUnattendedSetup +WerpAddAppCompatData +WerpAddMemoryBlock +WerpAddRegisteredDataToReport +WerpArchiveReport +WerpCancelResponseDownload +WerpCancelUpload +WerpCloseStore +WerpCreateMachineStore +WerpCreateUserStore +WerpDeleteReport +WerpDestroyWerString +WerpDownloadResponse +WerpDownloadResponseTemplate +WerpEnumerateStoreNext +WerpEnumerateStoreStart +WerpExtractReportFiles +WerpFlushImageCache +WerpForceDeferredCollection +WerpFreeUnmappedVaRanges +WerpGetBucketId +WerpGetDynamicParameter +WerpGetEventType +WerpGetExtendedDiagData +WerpGetFileByIndex +WerpGetFilePathByIndex +WerpGetLegacyBucketId +WerpGetLoadedModuleByIndex +WerpGetNumFiles +WerpGetNumLoadedModules +WerpGetNumSigParams +WerpGetReportFinalConsent +WerpGetReportFlags +WerpGetReportInformation +WerpGetReportSettings +WerpGetReportTime +WerpGetReportType +WerpGetResponseId +WerpGetResponseUrl +WerpGetSigParamByIndex +WerpGetStorePath +WerpGetStoreType +WerpGetTextFromReport +WerpGetUIParamByIndex +WerpGetUploadTime +WerpGetWerStringData +WerpGetWow64Process +WerpHashApplicationParameters +WerpInitializeImageCache +WerpIsOnBattery +WerpIsTransportAvailable +WerpLoadReport +WerpLoadReportFromBuffer +WerpOpenMachineArchive +WerpOpenMachineQueue +WerpOpenUserArchive +WerpPromptUser +WerpPruneStore +WerpReportCancel +WerpReportSprintfParameter +WerpReserveMachineQueueReportDir +WerpResetTransientImageCacheStatistics +WerpRestartApplication +WerpSetDynamicParameter +WerpSetEventName +WerpSetReportApplicationIdentity +WerpSetReportFlags +WerpSetReportInformation +WerpSetReportNamespaceParameter +WerpSetReportTime +WerpSetReportUploadContextToken +WerpShowUpsellUI +WerpStitchedMinidumpVmPostReadCallback +WerpStitchedMinidumpVmPreReadCallback +WerpStitchedMinidumpVmQueryCallback +WerpSubmitReportFromStore +WerpSvcReportFromMachineQueue +WerpTraceAuxMemDumpStatistics +WerpTraceDuration +WerpTraceImageCacheStatistics +WerpTraceSnapshotStatistics +WerpTraceStitchedDumpWriterStatistics +WerpTraceUnmappedVaRangesStatistics +WerpUnmapProcessViews +WerpUpdateReportResponse +WerpValidateReportKey +WerpWalkGatherBlocks +WerAddExcludedApplication +WerRemoveExcludedApplication +WerReportAddDump +WerReportAddFile +WerReportCloseHandle +WerReportCreate +WerReportSetParameter +WerReportSetUIOption +WerReportSubmit +WerpAddFile +WerpAddFileBuffer +WerpAddFileCallback +WerpAuxmdDumpProcessImages +WerpAuxmdDumpRegisteredBlocks +WerpAuxmdFree +WerpAuxmdFreeCopyBuffer +WerpAuxmdHashVaRanges +WerpAuxmdInitialize +WerpAuxmdMapFile +WerpCreateIntegratorReportId +WerpDownloadResponseOnly +WerpFreeString +WerpGetIntegratorReportId +WerpGetReportConsent +WerpGetStoreLocation +WerpIsDisabled +WerpLaunchResponse +WerpOpenUserQueue +WerpSetAuxiliaryArchivePath +WerpSetCallBack +WerpSetDefaultUserConsent +WerpSetIntegratorReportId diff --git a/lib/libc/mingw/libarm32/winbio.def b/lib/libc/mingw/libarm32/winbio.def new file mode 100644 index 0000000000..22a13baa26 --- /dev/null +++ b/lib/libc/mingw/libarm32/winbio.def @@ -0,0 +1,68 @@ +; +; Definition file of winbio.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "winbio.dll" +EXPORTS +WinBioNotifyPasswordChange +_BioLogonIdentifiedUser +WinBioAcquireFocus +WinBioAsyncEnumBiometricUnits +WinBioAsyncEnumDatabases +WinBioAsyncEnumServiceProviders +WinBioAsyncMonitorFrameworkChanges +WinBioAsyncOpenFramework +WinBioAsyncOpenSession +WinBioCancel +WinBioCaptureSample +WinBioCaptureSampleWithCallback +WinBioCloseFramework +WinBioCloseSession +WinBioControlUnit +WinBioControlUnitPrivileged +WinBioDeleteTemplate +WinBioEnrollBegin +WinBioEnrollCapture +WinBioEnrollCaptureWithCallback +WinBioEnrollCommit +WinBioEnrollDiscard +WinBioEnumBiometricUnits +WinBioEnumDatabases +WinBioEnumEnrollments +WinBioEnumServiceProviders +WinBioFree +WinBioGetCredentialState +WinBioGetCredentialWithTicket +WinBioGetDomainLogonSetting +WinBioGetEnabledSetting +WinBioGetLogonSetting +WinBioGetMSACredentialState +WinBioGetMSACredentialWithTicket +WinBioGetProperty +WinBioIdentify +WinBioIdentifyAndReleaseTicket +WinBioIdentifyWithCallback +WinBioLocateSensor +WinBioLocateSensorWithCallback +WinBioLockUnit +WinBioLogonIdentifiedUser +WinBioOpenSession +WinBioProtectData +WinBioRegisterEventMonitor +WinBioRegisterServiceMonitor +WinBioReleaseFocus +WinBioRemoveAllCredentials +WinBioRemoveAllDomainCredentials +WinBioRemoveCredential +WinBioRemoveMSACredential +WinBioSetCredential +WinBioSetMSACredential +WinBioUnlockUnit +WinBioUnprotectData +WinBioUnregisterEventMonitor +WinBioUnregisterServiceMonitor +WinBioVerify +WinBioVerifyAndReleaseTicket +WinBioVerifyWithCallback +WinBioWait diff --git a/lib/libc/mingw/libarm32/winsta.def b/lib/libc/mingw/libarm32/winsta.def new file mode 100644 index 0000000000..b7442fa6a3 --- /dev/null +++ b/lib/libc/mingw/libarm32/winsta.def @@ -0,0 +1,173 @@ +; +; Definition file of WINSTA.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "WINSTA.dll" +EXPORTS +WinStationRegisterConsoleNotificationEx2 +LogonIdFromWinStationNameA +LogonIdFromWinStationNameW +RemoteAssistancePrepareSystemRestore +ServerGetInternetConnectorStatus +ServerLicensingClose +ServerLicensingDeactivateCurrentPolicy +ServerLicensingFreePolicyInformation +ServerLicensingGetAvailablePolicyIds +ServerLicensingGetPolicy +ServerLicensingGetPolicyInformationA +ServerLicensingGetPolicyInformationW +ServerLicensingLoadPolicy +ServerLicensingOpenA +ServerLicensingOpenW +ServerLicensingSetPolicy +ServerLicensingUnloadPolicy +ServerQueryInetConnectorInformationA +ServerQueryInetConnectorInformationW +ServerSetInternetConnectorStatus +WTSRegisterSessionNotificationEx +WTSUnRegisterSessionNotificationEx +WinStationActivateLicense +WinStationAutoReconnect +WinStationBroadcastSystemMessage +WinStationCheckAccess +WinStationCheckLoopBack +WinStationCloseServer +WinStationConnectA +WinStationConnectAndLockDesktop +WinStationConnectCallback +WinStationConnectEx +WinStationConnectW +WinStationCreateChildSessionTransport +WinStationDisconnect +WinStationEnableChildSessions +WinStationEnumerateA +WinStationEnumerateExW +WinStationEnumerateLicenses +WinStationEnumerateProcesses +WinStationEnumerateW +WinStationEnumerate_IndexedA +WinStationEnumerate_IndexedW +WinStationFreeConsoleNotification +WinStationFreeEXECENVDATAEX +WinStationFreeGAPMemory +WinStationFreeMemory +WinStationFreePropertyValue +WinStationFreeUserCertificates +WinStationFreeUserCredentials +WinStationFreeUserSessionInfo +WinStationGenerateLicense +WinStationGetAllProcesses +WinStationGetAllSessionsEx +WinStationGetAllSessionsW +WinStationGetAllUserSessions +WinStationGetChildSessionId +WinStationGetConnectionProperty +WinStationGetCurrentSessionCapabilities +WinStationGetCurrentSessionConnectionProperty +WinStationGetCurrentSessionTerminalName +WinStationGetDeviceId +WinStationGetInitialApplication +WinStationGetLanAdapterNameA +WinStationGetLanAdapterNameW +WinStationGetLoggedOnCount +WinStationGetMachinePolicy +WinStationGetParentSessionId +WinStationGetProcessSid +WinStationGetRedirectAuthInfo +WinStationGetRestrictedLogonInfo +WinStationGetSessionIds +WinStationGetTermSrvCountersValue +WinStationGetUserCertificates +WinStationGetUserCredentials +WinStationGetUserProfile +WinStationInstallLicense +WinStationIsChildSessionsEnabled +WinStationIsCurrentSessionRemoteable +WinStationIsHelpAssistantSession +WinStationIsSessionPermitted +WinStationIsSessionRemoteable +WinStationNameFromLogonIdA +WinStationNameFromLogonIdW +WinStationNegotiateSession +WinStationNtsdDebug +WinStationOpenServerA +WinStationOpenServerExA +WinStationOpenServerExW +WinStationOpenServerW +WinStationPreCreateGlassReplacementSession +WinStationQueryAllowConcurrentConnections +WinStationQueryCurrentSessionInformation +WinStationQueryEnforcementCore +WinStationQueryInformationA +WinStationQueryInformationW +WinStationQueryLicense +WinStationQueryLogonCredentialsW +WinStationQuerySessionVirtualIP +WinStationQueryUpdateRequired +WinStationRcmShadow2 +WinStationRedirectErrorMessage +WinStationRedirectLogonBeginPainting +WinStationRedirectLogonError +WinStationRedirectLogonMessage +WinStationRedirectLogonStatus +WinStationRegisterConsoleNotification +WinStationRegisterConsoleNotificationEx +WinStationRegisterCurrentSessionNotificationEvent +WinStationRegisterNotificationEvent +WinStationRemoveLicense +WinStationRenameA +WinStationRenameW +WinStationReportUIResult +WinStationReset +WinStationRevertFromServicesSession +WinStationSendMessageA +WinStationSendMessageW +WinStationSendWindowMessage +WinStationServerPing +WinStationSetAutologonPassword +WinStationSetInformationA +WinStationSetInformationW +WinStationSetPoolCount +WinStationSetRenderHint +WinStationShadow +WinStationShadowAccessCheck +WinStationShadowStop +WinStationShadowStop2 +WinStationShutdownSystem +WinStationSwitchToServicesSession +WinStationSystemShutdownStarted +WinStationSystemShutdownWait +WinStationTerminateGlassReplacementSession +WinStationTerminateProcess +WinStationUnRegisterConsoleNotification +WinStationUnRegisterNotificationEvent +WinStationUserLoginAccessCheck +WinStationVerify +WinStationVirtualOpen +WinStationVirtualOpenEx +WinStationWaitSystemEvent +_NWLogonQueryAdmin +_NWLogonSetAdmin +_WinStationAnnoyancePopup +_WinStationBeepOpen +_WinStationBreakPoint +_WinStationCallback +_WinStationCheckForApplicationName +_WinStationFUSCanRemoteUserDisconnect +_WinStationGetApplicationInfo +_WinStationNotifyDisconnectPipe +_WinStationNotifyLogoff +_WinStationNotifyLogon +_WinStationNotifyNewSession +_WinStationOpenSessionDirectory +_WinStationReInitializeSecurity +_WinStationReadRegistry +_WinStationSessionInitialized +_WinStationShadowTarget +_WinStationShadowTarget2 +_WinStationShadowTargetSetup +_WinStationUpdateClientCachedCredentials +_WinStationUpdateSettings +_WinStationUpdateUserConfig +_WinStationWaitForConnect diff --git a/lib/libc/mingw/libarm32/wldp.def b/lib/libc/mingw/libarm32/wldp.def new file mode 100644 index 0000000000..384443d93b --- /dev/null +++ b/lib/libc/mingw/libarm32/wldp.def @@ -0,0 +1,12 @@ +; +; Definition file of Wldp.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "Wldp.dll" +EXPORTS +WldpCheckRetailConfiguration +WldpGetLockdownPolicy +WldpIsClassInApprovedList +WldpIsDebugAllowed +WldpIsRundll32Allowed diff --git a/lib/libc/mingw/libarm32/wofutil.def b/lib/libc/mingw/libarm32/wofutil.def new file mode 100644 index 0000000000..de3beb5d00 --- /dev/null +++ b/lib/libc/mingw/libarm32/wofutil.def @@ -0,0 +1,14 @@ +; +; Definition file of WOFUTIL.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "WOFUTIL.dll" +EXPORTS +WofEnumEntries +WofIsExternalFile +WofSetFileDataLocation +WofWimAddEntry +WofWimEnumFiles +WofWimRemoveEntry +WofWimUpdateEntry diff --git a/lib/libc/mingw/libarm32/wsclient.def b/lib/libc/mingw/libarm32/wsclient.def new file mode 100644 index 0000000000..6bfc84bea8 --- /dev/null +++ b/lib/libc/mingw/libarm32/wsclient.def @@ -0,0 +1,38 @@ +; +; Definition file of WSClient.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "WSClient.dll" +EXPORTS +WSpTLRW +AcquireDeveloperLicense +CheckDeveloperLicense +GetApplicationURL +RefreshBannedAppsList +RemoveDeveloperLicense +WSCallServer +WSCheckForConsumable +WSEvaluatePackage +WSGetEvaluatePackageAttempted +WSLicenseCleanUpState +WSLicenseClose +WSLicenseFilterValidAppCategoryIds +WSLicenseGetAllUserTokens +WSLicenseGetAllValidAppCategoryIds +WSLicenseGetDevInstalledApps +WSLicenseGetExtendedUserInfo +WSLicenseGetFeatureLicenseResults +WSLicenseGetLicensesForProducts +WSLicenseGetOAuthServiceTicket +WSLicenseGetProductLicenseResults +WSLicenseInstallLicense +WSLicenseOpen +WSLicenseRefreshLicense +WSLicenseRetrieveMachineID +WSLicenseRevokeLicenses +WSLicenseUninstallLicense +WSNotifyOOBECompletion +WSNotifyPackageInstalled +WSTriggerOOBEFileValidation +g_bPrintFromClientDLL DATA diff --git a/lib/libc/mingw/libarm32/wsdapi.def b/lib/libc/mingw/libarm32/wsdapi.def new file mode 100644 index 0000000000..45a9ade6ad --- /dev/null +++ b/lib/libc/mingw/libarm32/wsdapi.def @@ -0,0 +1,52 @@ +; +; Definition file of wsdapi.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "wsdapi.dll" +EXPORTS +WSDAddFirewallCheck +WSDCancelNetworkChangeNotify +WSDCopyNameList +WSDNotifyNetworkChange +WSDRemoveFirewallCheck +WSDXMLCompareNames +WSDAllocateLinkedMemory +WSDAttachLinkedMemory +WSDCompareEndpoints +WSDCopyEndpoint +WSDCreateDeviceHost +WSDCreateDeviceHost2 +WSDCreateDeviceHostAdvanced +WSDCreateDeviceProxy +WSDCreateDeviceProxy2 +WSDCreateDeviceProxyAdvanced +WSDCreateDiscoveryProvider +WSDCreateDiscoveryProvider2 +WSDCreateDiscoveryPublisher +WSDCreateDiscoveryPublisher2 +WSDCreateHttpAddress +WSDCreateHttpMessageParameters +WSDCreateHttpTransport +WSDCreateMetadataAgent +WSDCreateOutboundAttachment +WSDCreateUdpAddress +WSDCreateUdpMessageParameters +WSDCreateUdpTransport +WSDDetachLinkedMemory +WSDFreeLinkedMemory +WSDGenerateFault +WSDGenerateFaultEx +WSDGenerateRandomDelay +WSDGetConfigurationOption +WSDProcessFault +WSDSetConfigurationOption +WSDUriDecode +WSDUriEncode +WSDXMLAddChild +WSDXMLAddSibling +WSDXMLBuildAnyForSingleElement +WSDXMLCleanupElement +WSDXMLCreateContext +WSDXMLGetNameFromBuiltinNamespace +WSDXMLGetValueFromAny diff --git a/lib/libc/mingw/libarm32/wsmsvc.def b/lib/libc/mingw/libarm32/wsmsvc.def new file mode 100644 index 0000000000..c86b719aba --- /dev/null +++ b/lib/libc/mingw/libarm32/wsmsvc.def @@ -0,0 +1,3676 @@ +; +; Definition file of WsmSvc.DLL +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "WsmSvc.DLL" +EXPORTS +??0?$AutoCleanup@V?$AutoDelete@D@@PAD@@QAA@PAD@Z +??0?$AutoCleanup@V?$AutoDelete@G@@PAG@@QAA@PAG@Z +??0?$AutoCleanup@V?$AutoDelete@UIPRange@CWSManIPFilter@@@@PAUIPRange@CWSManIPFilter@@@@QAA@PAUIPRange@CWSManIPFilter@@@Z +??0?$AutoCleanup@V?$AutoDelete@U_SID@@@@PAU_SID@@@@QAA@PAU_SID@@@Z +??0?$AutoCleanup@V?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@PAU_WSMAN_STREAM_ID_SET@@@@QAA@PAU_WSMAN_STREAM_ID_SET@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$Handle@VISubscription@@@@@@PAV?$Handle@VISubscription@@@@@@QAA@PAV?$Handle@VISubscription@@@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@@QAA@PAV?$SafeSet@PAVCCertMapping@@@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@@QAA@PAV?$SafeSet@PAVCShellUriSettings@@@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$SimpleStack@VCListenerOperation@@@@@@PAV?$SimpleStack@VCListenerOperation@@@@@@QAA@PAV?$SimpleStack@VCListenerOperation@@@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$SimpleStack@VShellHostEntry@@@@@@PAV?$SimpleStack@VShellHostEntry@@@@@@QAA@PAV?$SimpleStack@VShellHostEntry@@@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAA@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@QAA@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@QAA@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@Z +??0?$AutoCleanup@V?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@QAA@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@Z +??0?$AutoCleanup@V?$AutoDelete@VAdminSid@CSecurity@@@@PAVAdminSid@CSecurity@@@@QAA@PAVAdminSid@CSecurity@@@Z +??0?$AutoCleanup@V?$AutoDelete@VBlockedRecord@@@@PAVBlockedRecord@@@@QAA@PAVBlockedRecord@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAA@PAVCBaseConfigCache@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCCertMapping@@@@PAVCCertMapping@@@@QAA@PAVCCertMapping@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCConfigChangeSource@@@@PAVCConfigChangeSource@@@@QAA@PAVCConfigChangeSource@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCListenerSettings@@@@PAVCListenerSettings@@@@QAA@PAVCListenerSettings@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCObserverConfigChangeErrors@@@@PAVCObserverConfigChangeErrors@@@@QAA@PAVCObserverConfigChangeErrors@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@PAVCServiceWatcher@CServiceConfigCache@@@@QAA@PAVCServiceWatcher@CServiceConfigCache@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCShellUriSettings@@@@PAVCShellUriSettings@@@@QAA@PAVCShellUriSettings@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCWSManEPR@@@@PAVCWSManEPR@@@@QAA@PAVCWSManEPR@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCWSManResource@@@@PAVCWSManResource@@@@QAA@PAVCWSManResource@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCertHash@@@@PAVCertHash@@@@QAA@PAVCertHash@@@Z +??0?$AutoCleanup@V?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@@QAA@PAVConfigUpdate@@@Z +??0?$AutoCleanup@V?$AutoDelete@VCredUIDllLoader@@@@PAVCredUIDllLoader@@@@QAA@PAVCredUIDllLoader@@@Z +??0?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAA@PAVEnumSinkEx@@@Z +??0?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoDelete@VEventHandler@WSMan@@@@PAVEventHandler@WSMan@@@@QAA@PAVEventHandler@WSMan@@@Z +??0?$AutoCleanup@V?$AutoDelete@VExpiredOperationIdRecord@@@@PAVExpiredOperationIdRecord@@@@QAA@PAVExpiredOperationIdRecord@@@Z +??0?$AutoCleanup@V?$AutoDelete@VGPApiManager@@@@PAVGPApiManager@@@@QAA@PAVGPApiManager@@@Z +??0?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAA@PAVGeneralSinkEx@@@Z +??0?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoDelete@VIChannelObserverFactory@@@@PAVIChannelObserverFactory@@@@QAA@PAVIChannelObserverFactory@@@Z +??0?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QAA@PAVIQueryDASHSMASHInterface@@@Z +??0?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QAA@PAVISpecification@@@Z +??0?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoDelete@VInteractiveSid@CSecurity@@@@PAVInteractiveSid@CSecurity@@@@QAA@PAVInteractiveSid@CSecurity@@@Z +??0?$AutoCleanup@V?$AutoDelete@VIpHlpApiDllLoader@@@@PAVIpHlpApiDllLoader@@@@QAA@PAVIpHlpApiDllLoader@@@Z +??0?$AutoCleanup@V?$AutoDelete@VMachineName@@@@PAVMachineName@@@@QAA@PAVMachineName@@@Z +??0?$AutoCleanup@V?$AutoDelete@VNetworkServiceSid@CSecurity@@@@PAVNetworkServiceSid@CSecurity@@@@QAA@PAVNetworkServiceSid@CSecurity@@@Z +??0?$AutoCleanup@V?$AutoDelete@VNtDsApiDllLoader@@@@PAVNtDsApiDllLoader@@@@QAA@PAVNtDsApiDllLoader@@@Z +??0?$AutoCleanup@V?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAA@PAVOptionValue@SessionOptions@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoDelete@VPacketCreator@@@@PAVPacketCreator@@@@QAA@PAVPacketCreator@@@Z +??0?$AutoCleanup@V?$AutoDelete@VPacketParser@@@@PAVPacketParser@@@@QAA@PAVPacketParser@@@Z +??0?$AutoCleanup@V?$AutoDelete@VResources@Locale@@@@PAVResources@Locale@@@@QAA@PAVResources@Locale@@@Z +??0?$AutoCleanup@V?$AutoDelete@VRunAsConfiguration@@@@PAVRunAsConfiguration@@@@QAA@PAVRunAsConfiguration@@@Z +??0?$AutoCleanup@V?$AutoDelete@VSecurityEntry@Catalog@@@@PAVSecurityEntry@Catalog@@@@QAA@PAVSecurityEntry@Catalog@@@Z +??0?$AutoCleanup@V?$AutoDelete@VSendPacketArgs@RobustConnectionBuffer@@@@PAVSendPacketArgs@RobustConnectionBuffer@@@@QAA@PAVSendPacketArgs@RobustConnectionBuffer@@@Z +??0?$AutoCleanup@V?$AutoDelete@VServiceSoapProcessor@@@@PAVServiceSoapProcessor@@@@QAA@PAVServiceSoapProcessor@@@Z +??0?$AutoCleanup@V?$AutoDelete@VShell32DllLoader@@@@PAVShell32DllLoader@@@@QAA@PAVShell32DllLoader@@@Z +??0?$AutoCleanup@V?$AutoDelete@VShlWApiDllLoader@@@@PAVShlWApiDllLoader@@@@QAA@PAVShlWApiDllLoader@@@Z +??0?$AutoCleanup@V?$AutoDelete@VSubscriptionEnumerator@@@@PAVSubscriptionEnumerator@@@@QAA@PAVSubscriptionEnumerator@@@Z +??0?$AutoCleanup@V?$AutoDelete@VSubscriptionManager@@@@PAVSubscriptionManager@@@@QAA@PAVSubscriptionManager@@@Z +??0?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QAA@PAVTSTRBUFFER@@@Z +??0?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoDelete@VUniqueStringOverflow@@@@PAVUniqueStringOverflow@@@@QAA@PAVUniqueStringOverflow@@@Z +??0?$AutoCleanup@V?$AutoDelete@VUser32DllLoader@@@@PAVUser32DllLoader@@@@QAA@PAVUser32DllLoader@@@Z +??0?$AutoCleanup@V?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@PAVWSMANCONFIGTABLE_IDENTITY@@@@QAA@PAVWSMANCONFIGTABLE_IDENTITY@@@Z +??0?$AutoCleanup@V?$AutoDelete@VWSManMemCryptManager@@@@PAVWSManMemCryptManager@@@@QAA@PAVWSManMemCryptManager@@@Z +??0?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QAA@PAVWmiEnumContext@@@Z +??0?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@@QAA@PAVXmlReader@@@Z +??0?$AutoCleanup@V?$AutoDeleteVector@$$CBG@@PBG@@QAA@PBG@Z +??0?$AutoCleanup@V?$AutoDeleteVector@D@@PAD@@QAA@PAD@Z +??0?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QAA@PAE@Z +??0?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QAA@XZ +??0?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QAA@PAG@Z +??0?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QAA@XZ +??0?$AutoCleanup@V?$AutoDeleteVector@H@@PAH@@QAA@PAH@Z +??0?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QAA@PAPAG@Z +??0?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QAA@XZ +??0?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QAA@PAPBG@Z +??0?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QAA@XZ +??0?$AutoCleanup@V?$AutoDeleteVector@U_CONFIG_UPDATE@@@@PAU_CONFIG_UPDATE@@@@QAA@PAU_CONFIG_UPDATE@@@Z +??0?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAA@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@Z +??0?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QAA@PAU_WINRS_RUN_COMMAND_ARG@@@Z +??0?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoDeleteVector@U_WSMAN_OPTION@@@@PAU_WSMAN_OPTION@@@@QAA@PAU_WSMAN_OPTION@@@Z +??0?$AutoCleanup@V?$AutoDeleteVector@X@@PAX@@QAA@PAX@Z +??0?$AutoCleanup@V?$AutoFree@E@@PAE@@QAA@PAE@Z +??0?$AutoCleanup@V?$AutoLocklessItemRecycle@VPacket@@@@PAVPacket@@@@QAA@PAVPacket@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIAppHostChildElementCollection@@@@PAUIAppHostChildElementCollection@@@@QAA@PAUIAppHostChildElementCollection@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIAppHostElement@@@@PAUIAppHostElement@@@@QAA@PAUIAppHostElement@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIAppHostElementCollection@@@@PAUIAppHostElementCollection@@@@QAA@PAUIAppHostElementCollection@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIAppHostProperty@@@@PAUIAppHostProperty@@@@QAA@PAUIAppHostProperty@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIAppHostPropertyCollection@@@@PAUIAppHostPropertyCollection@@@@QAA@PAUIAppHostPropertyCollection@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QAA@PAUIClientSecurity@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QAA@PAUIEnumWbemClassObject@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QAA@PAUIErrorInfo@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QAA@PAUIUnknown@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QAA@PAUIWbemClassObject@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QAA@PAUIWbemContext@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QAA@PAUIWbemLocator@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QAA@PAUIWbemObjectTextSrc@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QAA@PAUIWbemPath@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QAA@PAUIWbemPathKeyList@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QAA@PAUIWbemQualifierSet@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QAA@PAUIWbemQuery@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QAA@PAUIWbemServices@@@Z +??0?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@VApplication@Client@WSMan@@@@PAVApplication@Client@WSMan@@@@QAA@PAVApplication@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAA@PAVCBaseConfigCache@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@@QAA@PAVCClientConfigSettings@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCCommonConfigSettings@@@@PAVCCommonConfigSettings@@@@QAA@PAVCCommonConfigSettings@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@PAVCConfigCacheMap@CBaseConfigCache@@@@QAA@PAVCConfigCacheMap@CBaseConfigCache@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@@QAA@PAVCConfigManager@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCRemoteOperation@@@@PAVCRemoteOperation@@@@QAA@PAVCRemoteOperation@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@QAA@PAVCRemoteSession@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@@QAA@PAVCRequestContext@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCServiceCommonConfigSettings@@@@PAVCServiceCommonConfigSettings@@@@QAA@PAVCServiceCommonConfigSettings@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCServiceConfigCache@@@@PAVCServiceConfigCache@@@@QAA@PAVCServiceConfigCache@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCServiceConfigSettings@@@@PAVCServiceConfigSettings@@@@QAA@PAVCServiceConfigSettings@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QAA@PAVCWSManEPR@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyCache@@@@PAVCWSManGroupPolicyCache@@@@QAA@PAVCWSManGroupPolicyCache@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyManager@@@@PAVCWSManGroupPolicyManager@@@@QAA@PAVCWSManGroupPolicyManager@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCWSManObject@@@@PAVCWSManObject@@@@QAA@PAVCWSManObject@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@@QAA@PAVCWSManResource@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QAA@PAVCWinRSPluginConfigCache@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigSettings@@@@PAVCWinRSPluginConfigSettings@@@@QAA@PAVCWinRSPluginConfigSettings@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCommand@Client@WSMan@@@@PAVCommand@Client@WSMan@@@@QAA@PAVCommand@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VConfigNotification@@@@PAVConfigNotification@@@@QAA@PAVConfigNotification@@@Z +??0?$AutoCleanup@V?$AutoRelease@VConnectShellOperation@Client@WSMan@@@@PAVConnectShellOperation@Client@WSMan@@@@QAA@PAVConnectShellOperation@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VCreateShellOperation@Client@WSMan@@@@PAVCreateShellOperation@Client@WSMan@@@@QAA@PAVCreateShellOperation@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VDeleteShellOperation@Client@WSMan@@@@PAVDeleteShellOperation@Client@WSMan@@@@QAA@PAVDeleteShellOperation@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VDisconnectOperation@Client@WSMan@@@@PAVDisconnectOperation@Client@WSMan@@@@QAA@PAVDisconnectOperation@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAA@PAVEnumSinkEx@@@Z +??0?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAA@PAVGeneralSinkEx@@@Z +??0?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@VIISConfigSettings@@@@PAVIISConfigSettings@@@@QAA@PAVIISConfigSettings@@@Z +??0?$AutoCleanup@V?$AutoRelease@VIPCSoapProcessor@@@@PAVIPCSoapProcessor@@@@QAA@PAVIPCSoapProcessor@@@Z +??0?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QAA@PAVIRequestContext@@@Z +??0?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QAA@XZ +??0?$AutoCleanup@V?$AutoRelease@VISubscription@@@@PAVISubscription@@@@QAA@PAVISubscription@@@Z +??0?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@QAA@PAVInboundRequestDetails@@@Z +??0?$AutoCleanup@V?$AutoRelease@VReceiveOperation@Client@WSMan@@@@PAVReceiveOperation@Client@WSMan@@@@QAA@PAVReceiveOperation@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VReconnectOperation@Client@WSMan@@@@PAVReconnectOperation@Client@WSMan@@@@QAA@PAVReconnectOperation@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VSendOperation@Client@WSMan@@@@PAVSendOperation@Client@WSMan@@@@QAA@PAVSendOperation@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QAA@PAVShell@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VShellInfo@@@@PAVShellInfo@@@@QAA@PAVShellInfo@@@Z +??0?$AutoCleanup@V?$AutoRelease@VSignalOperation@Client@WSMan@@@@PAVSignalOperation@Client@WSMan@@@@QAA@PAVSignalOperation@Client@WSMan@@@Z +??0?$AutoCleanup@V?$AutoRelease@VUserRecord@@@@PAVUserRecord@@@@QAA@PAVUserRecord@@@Z +??0?$AutoCleanup@V?$AutoRelease@VWSManHttpListener@@@@PAVWSManHttpListener@@@@QAA@PAVWSManHttpListener@@@Z +??0?$AutoCleanup@V?$AutoReleaseEx@VHostMappingTableEntry@@@@PAVHostMappingTableEntry@@@@QAA@PAVHostMappingTableEntry@@@Z +??0?$AutoCleanup@V?$AutoReleaseEx@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QAA@PAVShell@Client@WSMan@@@Z +??0?$AutoCleanup@VAutoBstr@@PAG@@QAA@PAG@Z +??0?$AutoCleanup@VAutoBstr@@PAG@@QAA@XZ +??0?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QAA@PAG@Z +??0?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QAA@XZ +??0?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@QAA@PBU_CERT_CONTEXT@@@Z +??0?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@QAA@XZ +??0?$AutoCleanup@VAutoChainContext@@PBU_CERT_CHAIN_CONTEXT@@@@QAA@PBU_CERT_CHAIN_CONTEXT@@@Z +??0?$AutoCleanup@VAutoChainContext@@PBU_CERT_CHAIN_CONTEXT@@@@QAA@XZ +??0?$AutoCleanup@VAutoCoTaskMemFree@@PAX@@QAA@PAX@Z +??0?$AutoCleanup@VAutoCoTaskMemFree@@PAX@@QAA@XZ +??0?$AutoCleanup@VAutoEnvironmentBlock@@PAX@@QAA@PAX@Z +??0?$AutoCleanup@VAutoEnvironmentBlock@@PAX@@QAA@XZ +??0?$AutoCleanup@VAutoFwXmlCloseParser@@PAX@@QAA@PAX@Z +??0?$AutoCleanup@VAutoFwXmlCloseParser@@PAX@@QAA@XZ +??0?$AutoCleanup@VAutoHandle@@PAX@@QAA@PAX@Z +??0?$AutoCleanup@VAutoHandle@@PAX@@QAA@XZ +??0?$AutoCleanup@VAutoImpersonateUser@@PAX@@QAA@PAX@Z +??0?$AutoCleanup@VAutoImpersonateUser@@PAX@@QAA@XZ +??0?$AutoCleanup@VAutoLibrary@@PAUHINSTANCE__@@@@QAA@PAUHINSTANCE__@@@Z +??0?$AutoCleanup@VAutoLibrary@@PAUHINSTANCE__@@@@QAA@XZ +??0?$AutoCleanup@VAutoLocalFree@@PAX@@QAA@PAX@Z +??0?$AutoCleanup@VAutoLocalFree@@PAX@@QAA@XZ +??0?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@QAA@PAU_MI_Class@@@Z +??0?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@QAA@XZ +??0?$AutoCleanup@VAutoMIInstance@@PAU_MI_Instance@@@@QAA@PAU_MI_Instance@@@Z +??0?$AutoCleanup@VAutoMIInstance@@PAU_MI_Instance@@@@QAA@XZ +??0?$AutoCleanup@VAutoObject@@PAUWSMAN_OBJECT@@@@QAA@PAUWSMAN_OBJECT@@@Z +??0?$AutoCleanup@VAutoObject@@PAUWSMAN_OBJECT@@@@QAA@XZ +??0?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@QAA@PAUHKEY__@@@Z +??0?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@QAA@XZ +??0?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@QAA@PAX@Z +??0?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@QAA@XZ +??0?$AutoCleanup@VAutoWaitHandle@@PAX@@QAA@PAX@Z +??0?$AutoCleanup@VAutoWaitHandle@@PAX@@QAA@XZ +??0?$AutoDelete@D@@QAA@XZ +??0?$AutoDelete@G@@QAA@PAG@Z +??0?$AutoDelete@G@@QAA@XZ +??0?$AutoDelete@UIPRange@CWSManIPFilter@@@@QAA@XZ +??0?$AutoDelete@U_SID@@@@QAA@PAU_SID@@@Z +??0?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@QAA@PAU_WSMAN_STREAM_ID_SET@@@Z +??0?$AutoDelete@V?$Handle@VISubscription@@@@@@QAA@PAV?$Handle@VISubscription@@@@@Z +??0?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA@XZ +??0?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA@XZ +??0?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@QAA@PAV?$SafeSet@PAVCCertMapping@@@@@Z +??0?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@QAA@XZ +??0?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@QAA@PAV?$SafeSet@PAVCShellUriSettings@@@@@Z +??0?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@QAA@XZ +??0?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA@XZ +??0?$AutoDelete@V?$SimpleStack@VCListenerOperation@@@@@@QAA@XZ +??0?$AutoDelete@V?$SimpleStack@VShellHostEntry@@@@@@QAA@XZ +??0?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAA@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@Z +??0?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAA@XZ +??0?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@QAA@XZ +??0?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@QAA@XZ +??0?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@QAA@XZ +??0?$AutoDelete@VAdminSid@CSecurity@@@@QAA@PAVAdminSid@CSecurity@@@Z +??0?$AutoDelete@VBlockedRecord@@@@QAA@XZ +??0?$AutoDelete@VCBaseConfigCache@@@@QAA@PAVCBaseConfigCache@@@Z +??0?$AutoDelete@VCCertMapping@@@@QAA@PAVCCertMapping@@@Z +??0?$AutoDelete@VCConfigChangeSource@@@@QAA@XZ +??0?$AutoDelete@VCListenerSettings@@@@QAA@PAVCListenerSettings@@@Z +??0?$AutoDelete@VCObserverConfigChangeErrors@@@@QAA@XZ +??0?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@QAA@PAVCServiceWatcher@CServiceConfigCache@@@Z +??0?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@QAA@XZ +??0?$AutoDelete@VCShellUriSettings@@@@QAA@PAVCShellUriSettings@@@Z +??0?$AutoDelete@VCWSManEPR@@@@QAA@PAVCWSManEPR@@@Z +??0?$AutoDelete@VCWSManResource@@@@QAA@PAVCWSManResource@@@Z +??0?$AutoDelete@VCWSManResource@@@@QAA@XZ +??0?$AutoDelete@VCertHash@@@@QAA@PAVCertHash@@@Z +??0?$AutoDelete@VCertHash@@@@QAA@XZ +??0?$AutoDelete@VConfigUpdate@@@@QAA@PAVConfigUpdate@@@Z +??0?$AutoDelete@VConfigUpdate@@@@QAA@XZ +??0?$AutoDelete@VCredUIDllLoader@@@@QAA@PAVCredUIDllLoader@@@Z +??0?$AutoDelete@VEnumSinkEx@@@@QAA@PAVEnumSinkEx@@@Z +??0?$AutoDelete@VEnumSinkEx@@@@QAA@XZ +??0?$AutoDelete@VEventHandler@WSMan@@@@QAA@PAVEventHandler@WSMan@@@Z +??0?$AutoDelete@VExpiredOperationIdRecord@@@@QAA@PAVExpiredOperationIdRecord@@@Z +??0?$AutoDelete@VGPApiManager@@@@QAA@XZ +??0?$AutoDelete@VGeneralSinkEx@@@@QAA@PAVGeneralSinkEx@@@Z +??0?$AutoDelete@VGeneralSinkEx@@@@QAA@XZ +??0?$AutoDelete@VIChannelObserverFactory@@@@QAA@PAVIChannelObserverFactory@@@Z +??0?$AutoDelete@VIChannelObserverFactory@@@@QAA@XZ +??0?$AutoDelete@VIQueryDASHSMASHInterface@@@@QAA@PAVIQueryDASHSMASHInterface@@@Z +??0?$AutoDelete@VIQueryDASHSMASHInterface@@@@QAA@XZ +??0?$AutoDelete@VISpecification@@@@QAA@PAVISpecification@@@Z +??0?$AutoDelete@VISpecification@@@@QAA@XZ +??0?$AutoDelete@VInteractiveSid@CSecurity@@@@QAA@PAVInteractiveSid@CSecurity@@@Z +??0?$AutoDelete@VIpHlpApiDllLoader@@@@QAA@PAVIpHlpApiDllLoader@@@Z +??0?$AutoDelete@VMachineName@@@@QAA@PAVMachineName@@@Z +??0?$AutoDelete@VNetworkServiceSid@CSecurity@@@@QAA@PAVNetworkServiceSid@CSecurity@@@Z +??0?$AutoDelete@VNtDsApiDllLoader@@@@QAA@PAVNtDsApiDllLoader@@@Z +??0?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@QAA@PAVOptionValue@SessionOptions@Client@WSMan@@@Z +??0?$AutoDelete@VPacketCreator@@@@QAA@PAVPacketCreator@@@Z +??0?$AutoDelete@VPacketCreator@@@@QAA@XZ +??0?$AutoDelete@VPacketParser@@@@QAA@XZ +??0?$AutoDelete@VResources@Locale@@@@QAA@PAVResources@Locale@@@Z +??0?$AutoDelete@VRunAsConfiguration@@@@QAA@PAVRunAsConfiguration@@@Z +??0?$AutoDelete@VSecurityEntry@Catalog@@@@QAA@PAVSecurityEntry@Catalog@@@Z +??0?$AutoDelete@VSendPacketArgs@RobustConnectionBuffer@@@@QAA@PAVSendPacketArgs@RobustConnectionBuffer@@@Z +??0?$AutoDelete@VServiceSoapProcessor@@@@QAA@XZ +??0?$AutoDelete@VShell32DllLoader@@@@QAA@PAVShell32DllLoader@@@Z +??0?$AutoDelete@VShlWApiDllLoader@@@@QAA@PAVShlWApiDllLoader@@@Z +??0?$AutoDelete@VSubscriptionEnumerator@@@@QAA@XZ +??0?$AutoDelete@VSubscriptionManager@@@@QAA@PAVSubscriptionManager@@@Z +??0?$AutoDelete@VTSTRBUFFER@@@@QAA@PAVTSTRBUFFER@@@Z +??0?$AutoDelete@VTSTRBUFFER@@@@QAA@XZ +??0?$AutoDelete@VUniqueStringOverflow@@@@QAA@XZ +??0?$AutoDelete@VUser32DllLoader@@@@QAA@PAVUser32DllLoader@@@Z +??0?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@QAA@PAVWSMANCONFIGTABLE_IDENTITY@@@Z +??0?$AutoDelete@VWSManMemCryptManager@@@@QAA@PAVWSManMemCryptManager@@@Z +??0?$AutoDelete@VWmiEnumContext@@@@QAA@PAVWmiEnumContext@@@Z +??0?$AutoDelete@VWmiEnumContext@@@@QAA@XZ +??0?$AutoDelete@VXmlReader@@@@QAA@PAVXmlReader@@@Z +??0?$AutoDelete@VXmlReader@@@@QAA@XZ +??0?$AutoDeleteVector@$$CBG@@QAA@XZ +??0?$AutoDeleteVector@D@@QAA@PAD@Z +??0?$AutoDeleteVector@D@@QAA@XZ +??0?$AutoDeleteVector@E@@QAA@PAE@Z +??0?$AutoDeleteVector@E@@QAA@XZ +??0?$AutoDeleteVector@G@@QAA@PAG@Z +??0?$AutoDeleteVector@G@@QAA@XZ +??0?$AutoDeleteVector@H@@QAA@PAH@Z +??0?$AutoDeleteVector@PAG@@QAA@PAPAG@Z +??0?$AutoDeleteVector@PAG@@QAA@XZ +??0?$AutoDeleteVector@PBG@@QAA@PAPBG@Z +??0?$AutoDeleteVector@PBG@@QAA@XZ +??0?$AutoDeleteVector@U_CONFIG_UPDATE@@@@QAA@XZ +??0?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAA@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@Z +??0?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAA@XZ +??0?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@QAA@PAU_WINRS_RUN_COMMAND_ARG@@@Z +??0?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@QAA@XZ +??0?$AutoDeleteVector@U_WSMAN_OPTION@@@@QAA@PAU_WSMAN_OPTION@@@Z +??0?$AutoDeleteVector@U_WSMAN_OPTION@@@@QAA@XZ +??0?$AutoDeleteVector@X@@QAA@PAX@Z +??0?$AutoDeleteVector@X@@QAA@XZ +??0?$AutoFree@E@@QAA@PAE@Z +??0?$AutoFree@E@@QAA@XZ +??0?$AutoLocklessItemRecycle@VPacket@@@@QAA@PAVPacket@@@Z +??0?$AutoLocklessItemRecycle@VPacket@@@@QAA@XZ +??0?$AutoRelease@UIAppHostChildElementCollection@@@@QAA@XZ +??0?$AutoRelease@UIAppHostElement@@@@QAA@XZ +??0?$AutoRelease@UIAppHostElementCollection@@@@QAA@XZ +??0?$AutoRelease@UIAppHostProperty@@@@QAA@XZ +??0?$AutoRelease@UIAppHostPropertyCollection@@@@QAA@XZ +??0?$AutoRelease@UIClientSecurity@@@@QAA@PAUIClientSecurity@@@Z +??0?$AutoRelease@UIClientSecurity@@@@QAA@XZ +??0?$AutoRelease@UIEnumWbemClassObject@@@@QAA@PAUIEnumWbemClassObject@@@Z +??0?$AutoRelease@UIEnumWbemClassObject@@@@QAA@XZ +??0?$AutoRelease@UIErrorInfo@@@@QAA@PAUIErrorInfo@@@Z +??0?$AutoRelease@UIErrorInfo@@@@QAA@XZ +??0?$AutoRelease@UIUnknown@@@@QAA@PAUIUnknown@@@Z +??0?$AutoRelease@UIUnknown@@@@QAA@XZ +??0?$AutoRelease@UIWbemClassObject@@@@QAA@PAUIWbemClassObject@@@Z +??0?$AutoRelease@UIWbemClassObject@@@@QAA@XZ +??0?$AutoRelease@UIWbemContext@@@@QAA@PAUIWbemContext@@@Z +??0?$AutoRelease@UIWbemContext@@@@QAA@XZ +??0?$AutoRelease@UIWbemLocator@@@@QAA@PAUIWbemLocator@@@Z +??0?$AutoRelease@UIWbemLocator@@@@QAA@XZ +??0?$AutoRelease@UIWbemObjectTextSrc@@@@QAA@PAUIWbemObjectTextSrc@@@Z +??0?$AutoRelease@UIWbemObjectTextSrc@@@@QAA@XZ +??0?$AutoRelease@UIWbemPath@@@@QAA@PAUIWbemPath@@@Z +??0?$AutoRelease@UIWbemPath@@@@QAA@XZ +??0?$AutoRelease@UIWbemPathKeyList@@@@QAA@PAUIWbemPathKeyList@@@Z +??0?$AutoRelease@UIWbemPathKeyList@@@@QAA@XZ +??0?$AutoRelease@UIWbemQualifierSet@@@@QAA@PAUIWbemQualifierSet@@@Z +??0?$AutoRelease@UIWbemQualifierSet@@@@QAA@XZ +??0?$AutoRelease@UIWbemQuery@@@@QAA@PAUIWbemQuery@@@Z +??0?$AutoRelease@UIWbemQuery@@@@QAA@XZ +??0?$AutoRelease@UIWbemServices@@@@QAA@PAUIWbemServices@@@Z +??0?$AutoRelease@UIWbemServices@@@@QAA@XZ +??0?$AutoRelease@VApplication@Client@WSMan@@@@QAA@XZ +??0?$AutoRelease@VCBaseConfigCache@@@@QAA@PAVCBaseConfigCache@@@Z +??0?$AutoRelease@VCClientConfigSettings@@@@QAA@PAVCClientConfigSettings@@@Z +??0?$AutoRelease@VCClientConfigSettings@@@@QAA@XZ +??0?$AutoRelease@VCCommonConfigSettings@@@@QAA@PAVCCommonConfigSettings@@@Z +??0?$AutoRelease@VCCommonConfigSettings@@@@QAA@XZ +??0?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@QAA@PAVCConfigCacheMap@CBaseConfigCache@@@Z +??0?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@QAA@XZ +??0?$AutoRelease@VCConfigManager@@@@QAA@PAVCConfigManager@@@Z +??0?$AutoRelease@VCConfigManager@@@@QAA@XZ +??0?$AutoRelease@VCRemoteOperation@@@@QAA@PAVCRemoteOperation@@@Z +??0?$AutoRelease@VCRemoteSession@@@@QAA@PAVCRemoteSession@@@Z +??0?$AutoRelease@VCRemoteSession@@@@QAA@XZ +??0?$AutoRelease@VCRequestContext@@@@QAA@PAVCRequestContext@@@Z +??0?$AutoRelease@VCRequestContext@@@@QAA@XZ +??0?$AutoRelease@VCServiceCommonConfigSettings@@@@QAA@PAVCServiceCommonConfigSettings@@@Z +??0?$AutoRelease@VCServiceCommonConfigSettings@@@@QAA@XZ +??0?$AutoRelease@VCServiceConfigCache@@@@QAA@PAVCServiceConfigCache@@@Z +??0?$AutoRelease@VCServiceConfigCache@@@@QAA@XZ +??0?$AutoRelease@VCServiceConfigSettings@@@@QAA@PAVCServiceConfigSettings@@@Z +??0?$AutoRelease@VCServiceConfigSettings@@@@QAA@XZ +??0?$AutoRelease@VCWSManEPR@@@@QAA@PAVCWSManEPR@@@Z +??0?$AutoRelease@VCWSManEPR@@@@QAA@XZ +??0?$AutoRelease@VCWSManGroupPolicyCache@@@@QAA@PAVCWSManGroupPolicyCache@@@Z +??0?$AutoRelease@VCWSManGroupPolicyManager@@@@QAA@PAVCWSManGroupPolicyManager@@@Z +??0?$AutoRelease@VCWSManObject@@@@QAA@PAVCWSManObject@@@Z +??0?$AutoRelease@VCWSManResource@@@@QAA@PAVCWSManResource@@@Z +??0?$AutoRelease@VCWSManResource@@@@QAA@XZ +??0?$AutoRelease@VCWinRSPluginConfigCache@@@@QAA@PAVCWinRSPluginConfigCache@@@Z +??0?$AutoRelease@VCWinRSPluginConfigCache@@@@QAA@XZ +??0?$AutoRelease@VCWinRSPluginConfigSettings@@@@QAA@PAVCWinRSPluginConfigSettings@@@Z +??0?$AutoRelease@VCommand@Client@WSMan@@@@QAA@PAVCommand@Client@WSMan@@@Z +??0?$AutoRelease@VConfigNotification@@@@QAA@PAVConfigNotification@@@Z +??0?$AutoRelease@VConnectShellOperation@Client@WSMan@@@@QAA@PAVConnectShellOperation@Client@WSMan@@@Z +??0?$AutoRelease@VCreateShellOperation@Client@WSMan@@@@QAA@PAVCreateShellOperation@Client@WSMan@@@Z +??0?$AutoRelease@VDeleteShellOperation@Client@WSMan@@@@QAA@PAVDeleteShellOperation@Client@WSMan@@@Z +??0?$AutoRelease@VDisconnectOperation@Client@WSMan@@@@QAA@PAVDisconnectOperation@Client@WSMan@@@Z +??0?$AutoRelease@VEnumSinkEx@@@@QAA@PAVEnumSinkEx@@@Z +??0?$AutoRelease@VEnumSinkEx@@@@QAA@XZ +??0?$AutoRelease@VGeneralSinkEx@@@@QAA@PAVGeneralSinkEx@@@Z +??0?$AutoRelease@VGeneralSinkEx@@@@QAA@XZ +??0?$AutoRelease@VIISConfigSettings@@@@QAA@XZ +??0?$AutoRelease@VIPCSoapProcessor@@@@QAA@PAVIPCSoapProcessor@@@Z +??0?$AutoRelease@VIRequestContext@@@@QAA@PAVIRequestContext@@@Z +??0?$AutoRelease@VIRequestContext@@@@QAA@XZ +??0?$AutoRelease@VISubscription@@@@QAA@PAVISubscription@@@Z +??0?$AutoRelease@VInboundRequestDetails@@@@QAA@XZ +??0?$AutoRelease@VReceiveOperation@Client@WSMan@@@@QAA@PAVReceiveOperation@Client@WSMan@@@Z +??0?$AutoRelease@VReconnectOperation@Client@WSMan@@@@QAA@PAVReconnectOperation@Client@WSMan@@@Z +??0?$AutoRelease@VSendOperation@Client@WSMan@@@@QAA@PAVSendOperation@Client@WSMan@@@Z +??0?$AutoRelease@VShell@Client@WSMan@@@@QAA@PAVShell@Client@WSMan@@@Z +??0?$AutoRelease@VShellInfo@@@@QAA@XZ +??0?$AutoRelease@VSignalOperation@Client@WSMan@@@@QAA@PAVSignalOperation@Client@WSMan@@@Z +??0?$AutoRelease@VUserRecord@@@@QAA@XZ +??0?$AutoRelease@VWSManHttpListener@@@@QAA@PAVWSManHttpListener@@@Z +??0?$AutoReleaseEx@VHostMappingTableEntry@@@@QAA@XZ +??0?$AutoReleaseEx@VShell@Client@WSMan@@@@QAA@PAVShell@Client@WSMan@@@Z +??0?$ILoader@VAdminSid@CSecurity@@@@QAA@P8AdminSid@CSecurity@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VCredUIDllLoader@@@@QAA@P8CredUIDllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VEventHandler@WSMan@@@@QAA@P8EventHandler@WSMan@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VInteractiveSid@CSecurity@@@@QAA@P8InteractiveSid@CSecurity@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VIpHlpApiDllLoader@@@@QAA@P8IpHlpApiDllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VMachineName@@@@QAA@P8MachineName@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VNetworkServiceSid@CSecurity@@@@QAA@P8NetworkServiceSid@CSecurity@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VNtDsApiDllLoader@@@@QAA@P8NtDsApiDllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VResources@Locale@@@@QAA@P8Resources@Locale@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VShell32DllLoader@@@@QAA@P8Shell32DllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VShlWApiDllLoader@@@@QAA@P8ShlWApiDllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VSubscriptionManager@@@@QAA@P8SubscriptionManager@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VUser32DllLoader@@@@QAA@P8User32DllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$ILoader@VWSManMemCryptManager@@@@QAA@P8WSManMemCryptManager@@AA_NAAVIRequestContext@@@Z1@Z +??0?$Loader@VAdminSid@CSecurity@@$00@@QAA@XZ +??0?$Loader@VCredUIDllLoader@@$00@@QAA@XZ +??0?$Loader@VEventHandler@WSMan@@$00@@QAA@XZ +??0?$Loader@VInteractiveSid@CSecurity@@$00@@QAA@XZ +??0?$Loader@VIpHlpApiDllLoader@@$00@@QAA@XZ +??0?$Loader@VMachineName@@$00@@QAA@XZ +??0?$Loader@VNetworkServiceSid@CSecurity@@$00@@QAA@XZ +??0?$Loader@VNtDsApiDllLoader@@$00@@QAA@XZ +??0?$Loader@VResources@Locale@@$0A@@@QAA@XZ +??0?$Loader@VShell32DllLoader@@$00@@QAA@XZ +??0?$Loader@VShlWApiDllLoader@@$00@@QAA@XZ +??0?$Loader@VUser32DllLoader@@$00@@QAA@XZ +??0?$Loader@VWSManMemCryptManager@@$00@@QAA@XZ +??0?$LoaderSerializer@VAdminSid@CSecurity@@$00@@QAA@P8AdminSid@CSecurity@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VCredUIDllLoader@@$00@@QAA@P8CredUIDllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VEventHandler@WSMan@@$00@@QAA@P8EventHandler@WSMan@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VInteractiveSid@CSecurity@@$00@@QAA@P8InteractiveSid@CSecurity@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VIpHlpApiDllLoader@@$00@@QAA@P8IpHlpApiDllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VMachineName@@$00@@QAA@P8MachineName@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VNetworkServiceSid@CSecurity@@$00@@QAA@P8NetworkServiceSid@CSecurity@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VNtDsApiDllLoader@@$00@@QAA@P8NtDsApiDllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VResources@Locale@@$0A@@@QAA@P8Resources@Locale@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VShell32DllLoader@@$00@@QAA@P8Shell32DllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VShlWApiDllLoader@@$00@@QAA@P8ShlWApiDllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VSubscriptionManager@@$01@@QAA@P8SubscriptionManager@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VUser32DllLoader@@$00@@QAA@P8User32DllLoader@@AA_NAAVIRequestContext@@@Z1@Z +??0?$LoaderSerializer@VWSManMemCryptManager@@$00@@QAA@P8WSManMemCryptManager@@AA_NAAVIRequestContext@@@Z1@Z +??0?$PacketElement@K@PacketParser@@QAA@XZ +??0?$PacketElement@PAU_FWXML_ELEMENT@@@PacketParser@@QAA@XZ +??0?$PacketElement@PBG@PacketParser@@QAA@XZ +??0?$PacketElement@_K@PacketParser@@QAA@XZ +??0?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@QAA@XZ +??0?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA@XZ +??0?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@QAA@XZ +??0?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@QAA@XZ +??0?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAA@XZ +??0?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAA@XZ +??0?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAA@XZ +??0?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@QAA@XZ +??0?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA@XZ +??0?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAA@XZ +??0?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAA@XZ +??0?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAA@XZ +??0?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA@XZ +??0?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAA@XZ +??0?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@QAA@AAV?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@_N@Z +??0?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@QAA@AAV?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@_N@Z +??0?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@QAA@AAV?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@_N@Z +??0?$SafeMap_Iterator@PAXUEmpty@@@@QAA@AAV?$SafeMap@PAXUEmpty@@V?$SafeMap_Iterator@PAXUEmpty@@@@@@_N@Z +??0?$SafeMap_Iterator@UPluginKey@@K@@QAA@AAV?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@_N@Z +??0?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@QAA@AAV?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@_N@Z +??0?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QAA@AAV?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@_N@Z +??0?$SafeMap_Iterator@VKey@Locale@@K@@QAA@AAV?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@_N@Z +??0?$SafeMap_Iterator@VStringKeyCI@@K@@QAA@AAV?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@_N@Z +??0?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@QAA@AAV?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@_N@Z +??0?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QAA@AAV?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@_N@Z +??0?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@QAA@AAV?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@_N@Z +??0?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAA@AAV?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@_N@Z +??0?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@QAA@AAV?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@_N@Z +??0?$SafeMap_Lock@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@QAA@ABV?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@_N@Z +??0?$SafeMap_Lock@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@QAA@ABV?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@_N@Z +??0?$SafeMap_Lock@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@QAA@ABV?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@_N@Z +??0?$SafeMap_Lock@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA@ABV?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@_N@Z +??0?$SafeMap_Lock@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@QAA@ABV?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@_N@Z +??0?$SafeMap_Lock@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@QAA@ABV?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@_N@Z +??0?$SafeMap_Lock@PAXUEmpty@@V?$SafeMap_Iterator@PAXUEmpty@@@@@@QAA@ABV?$SafeMap@PAXUEmpty@@V?$SafeMap_Iterator@PAXUEmpty@@@@@@_N@Z +??0?$SafeMap_Lock@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@QAA@ABV?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@_N@Z +??0?$SafeMap_Lock@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAA@ABV?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@_N@Z +??0?$SafeMap_Lock@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAA@ABV?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@_N@Z +??0?$SafeMap_Lock@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAA@ABV?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@_N@Z +??0?$SafeMap_Lock@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@QAA@ABV?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@_N@Z +??0?$SafeMap_Lock@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA@ABV?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@_N@Z +??0?$SafeMap_Lock@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@QAA@ABV?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@_N@Z +??0?$SafeMap_Lock@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAA@ABV?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@_N@Z +??0?$SafeMap_Lock@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAA@ABV?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@_N@Z +??0?$SafeMap_Lock@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAA@ABV?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@_N@Z +??0?$SafeMap_Lock@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA@ABV?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@_N@Z +??0?$SafeMap_Lock@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAA@ABV?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@_N@Z +??0?$SafeSet@PAVCCertMapping@@@@QAA@XZ +??0?$SafeSet@PAVCListenerOperation@@@@QAA@XZ +??0?$SafeSet@PAVCShellUriSettings@@@@QAA@XZ +??0?$SafeSet@PAX@@QAA@XZ +??0?$SafeSet_Iterator@PAVCCertMapping@@@@QAA@AAV?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@_N@Z +??0?$SafeSet_Iterator@PAVCCertMapping@@@@QAA@AAV?$SafeSet@PAVCCertMapping@@@@@Z +??0?$SafeSet_Iterator@PAVCListenerOperation@@@@QAA@AAV?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@_N@Z +??0?$SafeSet_Iterator@PAVCListenerOperation@@@@QAA@AAV?$SafeSet@PAVCListenerOperation@@@@@Z +??0?$SafeSet_Iterator@PAVCShellUriSettings@@@@QAA@AAV?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@_N@Z +??0?$SafeSet_Iterator@PAX@@QAA@AAV?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@_N@Z +??0?$SimpleQueue@T_LARGE_INTEGER@@@@QAA@XZ +??0AutoBstr@@QAA@PAG@Z +??0AutoBstr@@QAA@XZ +??0AutoBstrNoAlloc@@QAA@PAG@Z +??0AutoBstrNoAlloc@@QAA@XZ +??0AutoCertContext@@QAA@PBU_CERT_CONTEXT@@@Z +??0AutoCertContext@@QAA@XZ +??0AutoChainContext@@QAA@PBU_CERT_CHAIN_CONTEXT@@@Z +??0AutoChainContext@@QAA@XZ +??0AutoCoTaskMemFree@@QAA@PAX@Z +??0AutoCoTaskMemFree@@QAA@XZ +??0AutoEnvironmentBlock@@QAA@PAX@Z +??0AutoEnvironmentBlock@@QAA@XZ +??0AutoFwXmlCloseParser@@QAA@PAX@Z +??0AutoFwXmlCloseParser@@QAA@XZ +??0AutoHandle@@QAA@PAX@Z +??0AutoHandle@@QAA@XZ +??0AutoImpersonateUser@@QAA@PAX@Z +??0AutoImpersonateUser@@QAA@XZ +??0AutoLibrary@@QAA@PAUHINSTANCE__@@@Z +??0AutoLibrary@@QAA@XZ +??0AutoLocalFree@@QAA@PAX@Z +??0AutoLocalFree@@QAA@XZ +??0AutoMIClass@@QAA@PAU_MI_Class@@@Z +??0AutoMIClass@@QAA@XZ +??0AutoMIInstance@@QAA@PAU_MI_Instance@@@Z +??0AutoMIInstance@@QAA@XZ +??0AutoObject@@QAA@PAUWSMAN_OBJECT@@@Z +??0AutoObject@@QAA@XZ +??0AutoRegKey@@QAA@PAUHKEY__@@@Z +??0AutoRegKey@@QAA@XZ +??0AutoSecurityDescriptor@@QAA@PAX@Z +??0AutoSecurityDescriptor@@QAA@XZ +??0AutoWaitHandle@@QAA@PAX@Z +??0AutoWaitHandle@@QAA@XZ +??0BufferFormatter@@QAA@PAEK@Z +??0BufferFormatter@@QAA@XZ +??0CBaseConfigCache@@IAA@W4ConfigLocation@CConfigChangeSource@@PAVFastLock@@PAVCConfigCacheMap@0@@Z +??0CClientConfigCache@@AAA@XZ +??0CConfigManager@@AAA@XZ +??0CErrorContext@@QAA@_N@Z +??0CRequestContext@@QAA@PBG@Z +??0CRequestContext@@QAA@XZ +??0CResourceAlias@@QAA@PBG@Z +??0CServiceConfigCache@@AAA@XZ +??0CServiceWatcher@CServiceConfigCache@@AAA@PAV1@PAVIServiceConfigObserver@@@Z +??0CWSManCriticalSection@@QAA@XZ +??0CWSManCriticalSectionWithConditionVar@@QAA@XZ +??0CWSManEPR@@QAA@H@Z +??0CWSManGroupPolicyManager@@AAA@XZ +??0CWSManResource@@QAA@H@Z +??0CWSManResourceNoResourceUri@@QAA@H@Z +??0CWSManSecurityUI@@QAA@XZ +??0CWinRSPluginConfigCache@@AAA@XZ +??0ChildLifeTimeManager@@QAA@XZ +??0CircularBufferFormatter@@QAA@XZ +??0ConfigRegistry@@IAA@XZ +??0EtwCorrelationHelper@@QAA@ABV0@@Z +??0EventHandler@WSMan@@QAA@XZ +??0ExtendedSemantic@@QAA@K@Z +??0FastLock@@QAA@XZ +??0Fragment@PacketParser@@QAA@XZ +??0IConfigChangeObserver@@QAA@ABV0@@Z +??0IConfigChangeObserver@@QAA@XZ +??0ILifeTimeMgmt@@QAA@ABV0@@Z +??0ILifeTimeMgmt@@QAA@XZ +??0IRequestContext@@IAA@XZ +??0IWSManGroupPolicyObserver@@QAA@ABV0@@Z +??0IWSManGroupPolicyObserver@@QAA@XZ +??0IWSManGroupPolicyPublisher@@QAA@ABV0@@Z +??0IWSManGroupPolicyPublisher@@QAA@XZ +??0Locale@@QAA@ABV0@@Z +??0Locale@@QAA@PAVIRequestContext@@@Z +??0Locale@@QAA@XZ +??0MessageId@PacketParser@@QAA@XZ +??0NotUnderstandSoapHeader@PacketParser@@QAA@XZ +??0OnHTTPInitialize@@QAA@XZ +??0OperationId@PacketParser@@QAA@XZ +??0OwnLock@@QAA@AAVFastLock@@@Z +??0PacketFormatter@@QAA@XZ +??0PacketParser@@QAA@XZ +??0RBUFFER@@QAA@I@Z +??0RBUFFER@@QAA@PAEI@Z +??0ReferenceParameters@PacketParser@@QAA@XZ +??0SBUFFER@@QAA@XZ +??0SessionId@PacketParser@@QAA@XZ +??0ShareLock@@QAA@AAVFastLock@@@Z +??0SoapSemanticConverter@@QAA@XZ +??0TSTRBUFFER@@QAA@XZ +??0UserAuthzRecord@@QAA@ABV0@@Z +??0UserAuthzRecord@@QAA@XZ +??0UserRecord@@QAA@XZ +??0XmlReader@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@D@@PAD@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@G@@PAG@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@UIPRange@CWSManIPFilter@@@@PAUIPRange@CWSManIPFilter@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@U_SID@@@@PAU_SID@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@PAU_WSMAN_STREAM_ID_SET@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$Handle@VISubscription@@@@@@PAV?$Handle@VISubscription@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@PAV?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCollector@@@@@@PAV?$SafeSet_Iterator@PAVCollector@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVHostOperation@@@@@@PAV?$SafeSet_Iterator@PAVHostOperation@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@PAV?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SimpleStack@VCListenerOperation@@@@@@PAV?$SimpleStack@VCListenerOperation@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$SimpleStack@VShellHostEntry@@@@@@PAV?$SimpleStack@VShellHostEntry@@@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$queue@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$deque@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$transport_allocator@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@@@@std@@@std@@@@PAV?$queue@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$deque@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$transport_allocator@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@@@@std@@@std@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$vector@PAVCWSManRequest@@V?$transport_allocator@PAVCWSManRequest@@@@@std@@@@PAV?$vector@PAVCWSManRequest@@V?$transport_allocator@PAVCWSManRequest@@@@@std@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@V?$vector@PAVWSManHttpSenderConnection@@V?$transport_allocator@PAVWSManHttpSenderConnection@@@@@std@@@@PAV?$vector@PAVWSManHttpSenderConnection@@V?$transport_allocator@PAVWSManHttpSenderConnection@@@@@std@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VAdminSid@CSecurity@@@@PAVAdminSid@CSecurity@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VBlockedRecord@@@@PAVBlockedRecord@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCCertMapping@@@@PAVCCertMapping@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCConfigChangeSource@@@@PAVCConfigChangeSource@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCListenerSettings@@@@PAVCListenerSettings@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCObserverConfigChangeErrors@@@@PAVCObserverConfigChangeErrors@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@PAVCServiceWatcher@CServiceConfigCache@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCShellUriSettings@@@@PAVCShellUriSettings@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCWSManEPR@@@@PAVCWSManEPR@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCWSManResource@@@@PAVCWSManResource@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCertHash@@@@PAVCertHash@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VCredUIDllLoader@@@@PAVCredUIDllLoader@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VEventHandler@WSMan@@@@PAVEventHandler@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VExpiredOperationIdRecord@@@@PAVExpiredOperationIdRecord@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VGPApiManager@@@@PAVGPApiManager@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VIChannelObserverFactory@@@@PAVIChannelObserverFactory@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VInteractiveSid@CSecurity@@@@PAVInteractiveSid@CSecurity@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VIpHlpApiDllLoader@@@@PAVIpHlpApiDllLoader@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VMachineName@@@@PAVMachineName@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VMasterReceiveData@CListenerReceive@@@@PAVMasterReceiveData@CListenerReceive@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VNetworkServiceSid@CSecurity@@@@PAVNetworkServiceSid@CSecurity@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VNtDsApiDllLoader@@@@PAVNtDsApiDllLoader@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VPacketCreator@@@@PAVPacketCreator@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VPacketParser@@@@PAVPacketParser@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VResources@Locale@@@@PAVResources@Locale@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VRunAsConfiguration@@@@PAVRunAsConfiguration@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VSecurityEntry@Catalog@@@@PAVSecurityEntry@Catalog@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VSendPacketArgs@RobustConnectionBuffer@@@@PAVSendPacketArgs@RobustConnectionBuffer@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VServiceSoapProcessor@@@@PAVServiceSoapProcessor@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VShell32DllLoader@@@@PAVShell32DllLoader@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VShlWApiDllLoader@@@@PAVShlWApiDllLoader@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VSubscriptionEnumerator@@@@PAVSubscriptionEnumerator@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VSubscriptionManager@@@@PAVSubscriptionManager@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VUniqueStringOverflow@@@@PAVUniqueStringOverflow@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VUser32DllLoader@@@@PAVUser32DllLoader@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@PAVWSMANCONFIGTABLE_IDENTITY@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VWSManMemCryptManager@@@@PAVWSManMemCryptManager@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@$$CBG@@PBG@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@D@@PAD@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@H@@PAH@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@U_CONFIG_UPDATE@@@@PAU_CONFIG_UPDATE@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@U_WSMAN_OPTION@@@@PAU_WSMAN_OPTION@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoDeleteVector@X@@PAX@@QAA@XZ +??1?$AutoCleanup@V?$AutoFree@E@@PAE@@QAA@XZ +??1?$AutoCleanup@V?$AutoLocklessItemRecycle@VPacket@@@@PAVPacket@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIAppHostChildElementCollection@@@@PAUIAppHostChildElementCollection@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIAppHostElement@@@@PAUIAppHostElement@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIAppHostElementCollection@@@@PAUIAppHostElementCollection@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIAppHostProperty@@@@PAUIAppHostProperty@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIAppHostPropertyCollection@@@@PAUIAppHostPropertyCollection@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VApplication@Client@WSMan@@@@PAVApplication@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCClientConfigCache@@@@PAVCClientConfigCache@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCCommonConfigSettings@@@@PAVCCommonConfigSettings@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@PAVCConfigCacheMap@CBaseConfigCache@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCListenerCommand@@@@PAVCListenerCommand@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCListenerMasterOperation@@@@PAVCListenerMasterOperation@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCListenerReceive@@@@PAVCListenerReceive@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCListenerShell@@@@PAVCListenerShell@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCRemoteOperation@@@@PAVCRemoteOperation@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCServiceCommonConfigSettings@@@@PAVCServiceCommonConfigSettings@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCServiceConfigCache@@@@PAVCServiceConfigCache@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCServiceConfigSettings@@@@PAVCServiceConfigSettings@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyCache@@@@PAVCWSManGroupPolicyCache@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyManager@@@@PAVCWSManGroupPolicyManager@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCWSManObject@@@@PAVCWSManObject@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCWSManSession@@@@PAVCWSManSession@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigSettings@@@@PAVCWinRSPluginConfigSettings@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCommand@Client@WSMan@@@@PAVCommand@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VConfigNotification@@@@PAVConfigNotification@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VConnectShellOperation@Client@WSMan@@@@PAVConnectShellOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VCreateShellOperation@Client@WSMan@@@@PAVCreateShellOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VDeleteShellOperation@Client@WSMan@@@@PAVDeleteShellOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VDisconnectOperation@Client@WSMan@@@@PAVDisconnectOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VHostMappingTable@@@@PAVHostMappingTable@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VIISConfigSettings@@@@PAVIISConfigSettings@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VIPCSoapProcessor@@@@PAVIPCSoapProcessor@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VISubscription@@@@PAVISubscription@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VProxyManager@Client@WSMan@@@@PAVProxyManager@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VProxySelection@Client@WSMan@@@@PAVProxySelection@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VPushSubscribeOperation@@@@PAVPushSubscribeOperation@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VPushSubscription@@@@PAVPushSubscription@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VReceiveOperation@Client@WSMan@@@@PAVReceiveOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VReconnectOperation@Client@WSMan@@@@PAVReconnectOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VSendOperation@Client@WSMan@@@@PAVSendOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VShellInfo@@@@PAVShellInfo@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VSignalOperation@Client@WSMan@@@@PAVSignalOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VUserRecord@@@@PAVUserRecord@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoRelease@VWSManHttpListener@@@@PAVWSManHttpListener@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoReleaseEx@VHostMappingTableEntry@@@@PAVHostMappingTableEntry@@@@QAA@XZ +??1?$AutoCleanup@V?$AutoReleaseEx@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QAA@XZ +??1?$AutoCleanup@VAutoBstr@@PAG@@QAA@XZ +??1?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QAA@XZ +??1?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@QAA@XZ +??1?$AutoCleanup@VAutoChainContext@@PBU_CERT_CHAIN_CONTEXT@@@@QAA@XZ +??1?$AutoCleanup@VAutoCoTaskMemFree@@PAX@@QAA@XZ +??1?$AutoCleanup@VAutoEnvironmentBlock@@PAX@@QAA@XZ +??1?$AutoCleanup@VAutoFwXmlCloseParser@@PAX@@QAA@XZ +??1?$AutoCleanup@VAutoHandle@@PAX@@QAA@XZ +??1?$AutoCleanup@VAutoImpersonateUser@@PAX@@QAA@XZ +??1?$AutoCleanup@VAutoLibrary@@PAUHINSTANCE__@@@@QAA@XZ +??1?$AutoCleanup@VAutoLocalFree@@PAX@@QAA@XZ +??1?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@QAA@XZ +??1?$AutoCleanup@VAutoMIInstance@@PAU_MI_Instance@@@@QAA@XZ +??1?$AutoCleanup@VAutoObject@@PAUWSMAN_OBJECT@@@@QAA@XZ +??1?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@QAA@XZ +??1?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@QAA@XZ +??1?$AutoCleanup@VAutoWaitHandle@@PAX@@QAA@XZ +??1?$AutoDelete@D@@QAA@XZ +??1?$AutoDelete@G@@QAA@XZ +??1?$AutoDelete@UIPRange@CWSManIPFilter@@@@QAA@XZ +??1?$AutoDelete@U_SID@@@@QAA@XZ +??1?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@QAA@XZ +??1?$AutoDelete@V?$Handle@VISubscription@@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA@XZ +??1?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeSet_Iterator@PAVCollector@@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeSet_Iterator@PAVHostOperation@@@@@@QAA@XZ +??1?$AutoDelete@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@QAA@XZ +??1?$AutoDelete@V?$SimpleStack@VCListenerOperation@@@@@@QAA@XZ +??1?$AutoDelete@V?$SimpleStack@VShellHostEntry@@@@@@QAA@XZ +??1?$AutoDelete@V?$queue@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$deque@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$transport_allocator@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@@@@std@@@std@@@@QAA@XZ +??1?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAA@XZ +??1?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@QAA@XZ +??1?$AutoDelete@V?$vector@PAVCWSManRequest@@V?$transport_allocator@PAVCWSManRequest@@@@@std@@@@QAA@XZ +??1?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@QAA@XZ +??1?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@QAA@XZ +??1?$AutoDelete@V?$vector@PAVWSManHttpSenderConnection@@V?$transport_allocator@PAVWSManHttpSenderConnection@@@@@std@@@@QAA@XZ +??1?$AutoDelete@VAdminSid@CSecurity@@@@QAA@XZ +??1?$AutoDelete@VBlockedRecord@@@@QAA@XZ +??1?$AutoDelete@VCBaseConfigCache@@@@QAA@XZ +??1?$AutoDelete@VCCertMapping@@@@QAA@XZ +??1?$AutoDelete@VCConfigChangeSource@@@@QAA@XZ +??1?$AutoDelete@VCListenerSettings@@@@QAA@XZ +??1?$AutoDelete@VCObserverConfigChangeErrors@@@@QAA@XZ +??1?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@QAA@XZ +??1?$AutoDelete@VCShellUriSettings@@@@QAA@XZ +??1?$AutoDelete@VCWSManEPR@@@@QAA@XZ +??1?$AutoDelete@VCWSManResource@@@@QAA@XZ +??1?$AutoDelete@VCertHash@@@@QAA@XZ +??1?$AutoDelete@VConfigUpdate@@@@QAA@XZ +??1?$AutoDelete@VCredUIDllLoader@@@@QAA@XZ +??1?$AutoDelete@VEnumSinkEx@@@@QAA@XZ +??1?$AutoDelete@VEventHandler@WSMan@@@@QAA@XZ +??1?$AutoDelete@VExpiredOperationIdRecord@@@@QAA@XZ +??1?$AutoDelete@VGPApiManager@@@@QAA@XZ +??1?$AutoDelete@VGeneralSinkEx@@@@QAA@XZ +??1?$AutoDelete@VIChannelObserverFactory@@@@QAA@XZ +??1?$AutoDelete@VIQueryDASHSMASHInterface@@@@QAA@XZ +??1?$AutoDelete@VISpecification@@@@QAA@XZ +??1?$AutoDelete@VInteractiveSid@CSecurity@@@@QAA@XZ +??1?$AutoDelete@VIpHlpApiDllLoader@@@@QAA@XZ +??1?$AutoDelete@VMachineName@@@@QAA@XZ +??1?$AutoDelete@VMasterReceiveData@CListenerReceive@@@@QAA@XZ +??1?$AutoDelete@VNetworkServiceSid@CSecurity@@@@QAA@XZ +??1?$AutoDelete@VNtDsApiDllLoader@@@@QAA@XZ +??1?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@QAA@XZ +??1?$AutoDelete@VPacketCreator@@@@QAA@XZ +??1?$AutoDelete@VPacketParser@@@@QAA@XZ +??1?$AutoDelete@VResources@Locale@@@@QAA@XZ +??1?$AutoDelete@VRunAsConfiguration@@@@QAA@XZ +??1?$AutoDelete@VSecurityEntry@Catalog@@@@QAA@XZ +??1?$AutoDelete@VSendPacketArgs@RobustConnectionBuffer@@@@QAA@XZ +??1?$AutoDelete@VServiceSoapProcessor@@@@QAA@XZ +??1?$AutoDelete@VShell32DllLoader@@@@QAA@XZ +??1?$AutoDelete@VShlWApiDllLoader@@@@QAA@XZ +??1?$AutoDelete@VSubscriptionEnumerator@@@@QAA@XZ +??1?$AutoDelete@VSubscriptionManager@@@@QAA@XZ +??1?$AutoDelete@VTSTRBUFFER@@@@QAA@XZ +??1?$AutoDelete@VUniqueStringOverflow@@@@QAA@XZ +??1?$AutoDelete@VUser32DllLoader@@@@QAA@XZ +??1?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@QAA@XZ +??1?$AutoDelete@VWSManMemCryptManager@@@@QAA@XZ +??1?$AutoDelete@VWmiEnumContext@@@@QAA@XZ +??1?$AutoDelete@VXmlReader@@@@QAA@XZ +??1?$AutoDeleteVector@$$CBG@@QAA@XZ +??1?$AutoDeleteVector@D@@QAA@XZ +??1?$AutoDeleteVector@E@@QAA@XZ +??1?$AutoDeleteVector@G@@QAA@XZ +??1?$AutoDeleteVector@H@@QAA@XZ +??1?$AutoDeleteVector@PAG@@QAA@XZ +??1?$AutoDeleteVector@PBG@@QAA@XZ +??1?$AutoDeleteVector@U_CONFIG_UPDATE@@@@QAA@XZ +??1?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAA@XZ +??1?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@QAA@XZ +??1?$AutoDeleteVector@U_WSMAN_OPTION@@@@QAA@XZ +??1?$AutoDeleteVector@X@@QAA@XZ +??1?$AutoFree@E@@QAA@XZ +??1?$AutoLocklessItemRecycle@VPacket@@@@QAA@XZ +??1?$AutoRelease@UIAppHostChildElementCollection@@@@QAA@XZ +??1?$AutoRelease@UIAppHostElement@@@@QAA@XZ +??1?$AutoRelease@UIAppHostElementCollection@@@@QAA@XZ +??1?$AutoRelease@UIAppHostProperty@@@@QAA@XZ +??1?$AutoRelease@UIAppHostPropertyCollection@@@@QAA@XZ +??1?$AutoRelease@UIClientSecurity@@@@QAA@XZ +??1?$AutoRelease@UIEnumWbemClassObject@@@@QAA@XZ +??1?$AutoRelease@UIErrorInfo@@@@QAA@XZ +??1?$AutoRelease@UIUnknown@@@@QAA@XZ +??1?$AutoRelease@UIWbemClassObject@@@@QAA@XZ +??1?$AutoRelease@UIWbemContext@@@@QAA@XZ +??1?$AutoRelease@UIWbemLocator@@@@QAA@XZ +??1?$AutoRelease@UIWbemObjectTextSrc@@@@QAA@XZ +??1?$AutoRelease@UIWbemPath@@@@QAA@XZ +??1?$AutoRelease@UIWbemPathKeyList@@@@QAA@XZ +??1?$AutoRelease@UIWbemQualifierSet@@@@QAA@XZ +??1?$AutoRelease@UIWbemQuery@@@@QAA@XZ +??1?$AutoRelease@UIWbemServices@@@@QAA@XZ +??1?$AutoRelease@VApplication@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VCBaseConfigCache@@@@QAA@XZ +??1?$AutoRelease@VCClientConfigCache@@@@QAA@XZ +??1?$AutoRelease@VCClientConfigSettings@@@@QAA@XZ +??1?$AutoRelease@VCCommonConfigSettings@@@@QAA@XZ +??1?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@QAA@XZ +??1?$AutoRelease@VCConfigManager@@@@QAA@XZ +??1?$AutoRelease@VCListenerCommand@@@@QAA@XZ +??1?$AutoRelease@VCListenerMasterOperation@@@@QAA@XZ +??1?$AutoRelease@VCListenerReceive@@@@QAA@XZ +??1?$AutoRelease@VCListenerShell@@@@QAA@XZ +??1?$AutoRelease@VCRemoteOperation@@@@QAA@XZ +??1?$AutoRelease@VCRemoteSession@@@@QAA@XZ +??1?$AutoRelease@VCRequestContext@@@@QAA@XZ +??1?$AutoRelease@VCServiceCommonConfigSettings@@@@QAA@XZ +??1?$AutoRelease@VCServiceConfigCache@@@@QAA@XZ +??1?$AutoRelease@VCServiceConfigSettings@@@@QAA@XZ +??1?$AutoRelease@VCWSManEPR@@@@QAA@XZ +??1?$AutoRelease@VCWSManGroupPolicyCache@@@@QAA@XZ +??1?$AutoRelease@VCWSManGroupPolicyManager@@@@QAA@XZ +??1?$AutoRelease@VCWSManObject@@@@QAA@XZ +??1?$AutoRelease@VCWSManResource@@@@QAA@XZ +??1?$AutoRelease@VCWSManSession@@@@QAA@XZ +??1?$AutoRelease@VCWinRSPluginConfigCache@@@@QAA@XZ +??1?$AutoRelease@VCWinRSPluginConfigSettings@@@@QAA@XZ +??1?$AutoRelease@VCommand@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VConfigNotification@@@@QAA@XZ +??1?$AutoRelease@VConnectShellOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VCreateShellOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VDeleteShellOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VDisconnectOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VEnumSinkEx@@@@QAA@XZ +??1?$AutoRelease@VGeneralSinkEx@@@@QAA@XZ +??1?$AutoRelease@VHostMappingTable@@@@QAA@XZ +??1?$AutoRelease@VIISConfigSettings@@@@QAA@XZ +??1?$AutoRelease@VIPCSoapProcessor@@@@QAA@XZ +??1?$AutoRelease@VIRequestContext@@@@QAA@XZ +??1?$AutoRelease@VISubscription@@@@QAA@XZ +??1?$AutoRelease@VInboundRequestDetails@@@@QAA@XZ +??1?$AutoRelease@VProxyManager@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VProxySelection@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VPushSubscribeOperation@@@@QAA@XZ +??1?$AutoRelease@VPushSubscription@@@@QAA@XZ +??1?$AutoRelease@VReceiveOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VReconnectOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VSendOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VShell@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VShellInfo@@@@QAA@XZ +??1?$AutoRelease@VSignalOperation@Client@WSMan@@@@QAA@XZ +??1?$AutoRelease@VUserRecord@@@@QAA@XZ +??1?$AutoRelease@VWSManHttpListener@@@@QAA@XZ +??1?$AutoReleaseEx@VHostMappingTableEntry@@@@QAA@XZ +??1?$AutoReleaseEx@VShell@Client@WSMan@@@@QAA@XZ +??1?$ILoader@VAdminSid@CSecurity@@@@QAA@XZ +??1?$ILoader@VCredUIDllLoader@@@@QAA@XZ +??1?$ILoader@VEventHandler@WSMan@@@@QAA@XZ +??1?$ILoader@VInteractiveSid@CSecurity@@@@QAA@XZ +??1?$ILoader@VIpHlpApiDllLoader@@@@QAA@XZ +??1?$ILoader@VMachineName@@@@QAA@XZ +??1?$ILoader@VNetworkServiceSid@CSecurity@@@@QAA@XZ +??1?$ILoader@VNtDsApiDllLoader@@@@QAA@XZ +??1?$ILoader@VResources@Locale@@@@QAA@XZ +??1?$ILoader@VShell32DllLoader@@@@QAA@XZ +??1?$ILoader@VShlWApiDllLoader@@@@QAA@XZ +??1?$ILoader@VSubscriptionManager@@@@QAA@XZ +??1?$ILoader@VUser32DllLoader@@@@QAA@XZ +??1?$ILoader@VWSManMemCryptManager@@@@QAA@XZ +??1?$Loader@VAdminSid@CSecurity@@$00@@QAA@XZ +??1?$Loader@VCredUIDllLoader@@$00@@QAA@XZ +??1?$Loader@VEventHandler@WSMan@@$00@@QAA@XZ +??1?$Loader@VInteractiveSid@CSecurity@@$00@@QAA@XZ +??1?$Loader@VIpHlpApiDllLoader@@$00@@QAA@XZ +??1?$Loader@VMachineName@@$00@@QAA@XZ +??1?$Loader@VNetworkServiceSid@CSecurity@@$00@@QAA@XZ +??1?$Loader@VNtDsApiDllLoader@@$00@@QAA@XZ +??1?$Loader@VResources@Locale@@$0A@@@QAA@XZ +??1?$Loader@VShell32DllLoader@@$00@@QAA@XZ +??1?$Loader@VShlWApiDllLoader@@$00@@QAA@XZ +??1?$Loader@VSubscriptionManager@@$01@@QAA@XZ +??1?$Loader@VUser32DllLoader@@$00@@QAA@XZ +??1?$Loader@VWSManMemCryptManager@@$00@@QAA@XZ +??1?$LoaderSerializer@VAdminSid@CSecurity@@$00@@QAA@XZ +??1?$LoaderSerializer@VCredUIDllLoader@@$00@@QAA@XZ +??1?$LoaderSerializer@VEventHandler@WSMan@@$00@@QAA@XZ +??1?$LoaderSerializer@VInteractiveSid@CSecurity@@$00@@QAA@XZ +??1?$LoaderSerializer@VIpHlpApiDllLoader@@$00@@QAA@XZ +??1?$LoaderSerializer@VMachineName@@$00@@QAA@XZ +??1?$LoaderSerializer@VNetworkServiceSid@CSecurity@@$00@@QAA@XZ +??1?$LoaderSerializer@VNtDsApiDllLoader@@$00@@QAA@XZ +??1?$LoaderSerializer@VResources@Locale@@$0A@@@QAA@XZ +??1?$LoaderSerializer@VShell32DllLoader@@$00@@QAA@XZ +??1?$LoaderSerializer@VShlWApiDllLoader@@$00@@QAA@XZ +??1?$LoaderSerializer@VSubscriptionManager@@$01@@QAA@XZ +??1?$LoaderSerializer@VUser32DllLoader@@$00@@QAA@XZ +??1?$LoaderSerializer@VWSManMemCryptManager@@$00@@QAA@XZ +??1?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@QAA@XZ +??1?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA@XZ +??1?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@QAA@XZ +??1?$SafeMap@PAVCollector@@UEmpty@@V?$SafeSet_Iterator@PAVCollector@@@@@@QAA@XZ +??1?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeSet_Iterator@PAVHostOperation@@@@@@QAA@XZ +??1?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeSet_Iterator@PAVIOperation@@@@@@QAA@XZ +??1?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@QAA@XZ +??1?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVPushSubscription@@@@@@QAA@XZ +??1?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@QAA@XZ +??1?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAA@XZ +??1?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAA@XZ +??1?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAA@XZ +??1?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@QAA@XZ +??1?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA@XZ +??1?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@QAA@XZ +??1?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAA@XZ +??1?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAA@XZ +??1?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAA@XZ +??1?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA@XZ +??1?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAA@XZ +??1?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@QAA@XZ +??1?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@QAA@XZ +??1?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@QAA@XZ +??1?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@QAA@XZ +??1?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@PAXUEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@UPluginKey@@K@@QAA@XZ +??1?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@QAA@XZ +??1?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QAA@XZ +??1?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@QAA@XZ +??1?$SafeMap_Iterator@VKey@Locale@@K@@QAA@XZ +??1?$SafeMap_Iterator@VStringKeyCI@@K@@QAA@XZ +??1?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@QAA@XZ +??1?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@QAA@XZ +??1?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QAA@XZ +??1?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@QAA@XZ +??1?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAA@XZ +??1?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCListenerConnect@@PAV1@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCListenerReceive@@PAV1@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCListenerSend@@PAV1@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCListenerSignal@@PAV1@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVCollector@@UEmpty@@V?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVHostOperation@@UEmpty@@V?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVIOperation@@UEmpty@@V?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVListenerSourceSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAVPushSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAXUEmpty@@V?$SafeMap_Iterator@PAXUEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@QAA@XZ +??1?$SafeMap_Lock@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAA@XZ +??1?$SafeMap_Lock@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAA@XZ +??1?$SafeMap_Lock@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAA@XZ +??1?$SafeMap_Lock@VGuidKey@@PAVCListenerCommand@@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@QAA@XZ +??1?$SafeMap_Lock@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@QAA@XZ +??1?$SafeMap_Lock@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA@XZ +??1?$SafeMap_Lock@VStringKeyCI@@UEmpty@@V?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@@@QAA@XZ +??1?$SafeMap_Lock@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@QAA@XZ +??1?$SafeMap_Lock@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAA@XZ +??1?$SafeMap_Lock@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAA@XZ +??1?$SafeMap_Lock@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAA@XZ +??1?$SafeMap_Lock@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA@XZ +??1?$SafeMap_Lock@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAA@XZ +??1?$SafeSet@PAVCCertMapping@@@@QAA@XZ +??1?$SafeSet@PAVCListenerOperation@@@@QAA@XZ +??1?$SafeSet@PAVCShellUriSettings@@@@QAA@XZ +??1?$SafeSet@PAVCollector@@@@QAA@XZ +??1?$SafeSet@PAVHostOperation@@@@QAA@XZ +??1?$SafeSet@PAVIOperation@@@@QAA@XZ +??1?$SafeSet@PAVListenerSourceSubscription@@@@QAA@XZ +??1?$SafeSet@PAVPushSubscription@@@@QAA@XZ +??1?$SafeSet@PAX@@QAA@XZ +??1?$SafeSet@VStringKeyCI@@@@QAA@XZ +??1?$SafeSet_Iterator@PAVCCertMapping@@@@QAA@XZ +??1?$SafeSet_Iterator@PAVCListenerOperation@@@@QAA@XZ +??1?$SafeSet_Iterator@PAVCShellUriSettings@@@@QAA@XZ +??1?$SafeSet_Iterator@PAVCollector@@@@QAA@XZ +??1?$SafeSet_Iterator@PAVHostOperation@@@@QAA@XZ +??1?$SafeSet_Iterator@PAVIOperation@@@@QAA@XZ +??1?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@QAA@XZ +??1?$SafeSet_Iterator@PAVPushSubscription@@@@QAA@XZ +??1?$SafeSet_Iterator@PAX@@QAA@XZ +??1?$SafeSet_Iterator@VStringKeyCI@@@@QAA@XZ +??1?$SimpleQueue@T_LARGE_INTEGER@@@@QAA@XZ +??1AutoBstr@@QAA@XZ +??1AutoBstrNoAlloc@@QAA@XZ +??1AutoCertContext@@QAA@XZ +??1AutoChainContext@@QAA@XZ +??1AutoCoTaskMemFree@@QAA@XZ +??1AutoEnvironmentBlock@@QAA@XZ +??1AutoFwXmlCloseParser@@QAA@XZ +??1AutoHandle@@QAA@XZ +??1AutoImpersonateUser@@QAA@XZ +??1AutoLibrary@@QAA@XZ +??1AutoLocalFree@@QAA@XZ +??1AutoMIClass@@QAA@XZ +??1AutoMIInstance@@QAA@XZ +??1AutoObject@@QAA@XZ +??1AutoRegKey@@QAA@XZ +??1AutoSecurityDescriptor@@QAA@XZ +??1AutoWaitHandle@@QAA@XZ +??1BufferFormatter@@UAA@XZ +??1CBaseConfigCache@@UAA@XZ +??1CClientConfigCache@@UAA@XZ +??1CCommonConfigSettings@@UAA@XZ +??1CConfigManager@@UAA@XZ +??1CErrorContext@@UAA@XZ +??1CRequestContext@@UAA@XZ +??1CResourceAlias@@QAA@XZ +??1CServiceConfigCache@@EAA@XZ +??1CServiceWatcher@CServiceConfigCache@@QAA@XZ +??1CWSManCriticalSection@@QAA@XZ +??1CWSManCriticalSectionWithConditionVar@@QAA@XZ +??1CWSManEPR@@UAA@XZ +??1CWSManGroupPolicyManager@@EAA@XZ +??1CWSManResource@@UAA@XZ +??1CWSManResourceNoResourceUri@@UAA@XZ +??1CWSManSecurityUI@@QAA@XZ +??1CWinRSPluginConfigCache@@EAA@XZ +??1ChildLifeTimeManager@@QAA@XZ +??1CircularBufferFormatter@@UAA@XZ +??1ConfigRegistry@@IAA@XZ +??1EtwCorrelationHelper@@UAA@XZ +??1EventHandler@WSMan@@QAA@XZ +??1IConfigChangeObserver@@UAA@XZ +??1ILifeTimeMgmt@@UAA@XZ +??1IRequestContext@@UAA@XZ +??1IWSManGroupPolicyObserver@@UAA@XZ +??1IWSManGroupPolicyPublisher@@UAA@XZ +??1MessageId@PacketParser@@QAA@XZ +??1OnHTTPInitialize@@QAA@XZ +??1OperationId@PacketParser@@QAA@XZ +??1OwnLock@@QAA@XZ +??1PacketParser@@QAA@XZ +??1RBUFFER@@QAA@XZ +??1ReferenceParameters@PacketParser@@QAA@XZ +??1SBUFFER@@QAA@XZ +??1ShareLock@@QAA@XZ +??1SoapSemanticConverter@@QAA@XZ +??1TSTRBUFFER@@QAA@XZ +??1UserRecord@@QAA@XZ +??1XmlReader@@QAA@XZ +??4?$AutoCleanup@V?$AutoDelete@D@@PAD@@QAAAAV?$AutoDelete@D@@PAD@Z +??4?$AutoCleanup@V?$AutoDelete@G@@PAG@@QAAAAV?$AutoDelete@G@@PAG@Z +??4?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAAAAV?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@Z +??4?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAAAAV?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@Z +??4?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@@QAAAAV?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@Z +??4?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@@QAAAAV?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@Z +??4?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAAAAV?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@Z +??4?$AutoCleanup@V?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAAAAV?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@Z +??4?$AutoCleanup@V?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@QAAAAV?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@Z +??4?$AutoCleanup@V?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@QAAAAV?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@Z +??4?$AutoCleanup@V?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@QAAAAV?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@Z +??4?$AutoCleanup@V?$AutoDelete@VBlockedRecord@@@@PAVBlockedRecord@@@@QAAAAV?$AutoDelete@VBlockedRecord@@@@PAVBlockedRecord@@@Z +??4?$AutoCleanup@V?$AutoDelete@VCConfigChangeSource@@@@PAVCConfigChangeSource@@@@QAAAAV?$AutoDelete@VCConfigChangeSource@@@@PAVCConfigChangeSource@@@Z +??4?$AutoCleanup@V?$AutoDelete@VCObserverConfigChangeErrors@@@@PAVCObserverConfigChangeErrors@@@@QAAAAV?$AutoDelete@VCObserverConfigChangeErrors@@@@PAVCObserverConfigChangeErrors@@@Z +??4?$AutoCleanup@V?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@PAVCServiceWatcher@CServiceConfigCache@@@@QAAAAV?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@PAVCServiceWatcher@CServiceConfigCache@@@Z +??4?$AutoCleanup@V?$AutoDelete@VCWSManResource@@@@PAVCWSManResource@@@@QAAAAV?$AutoDelete@VCWSManResource@@@@PAVCWSManResource@@@Z +??4?$AutoCleanup@V?$AutoDelete@VCertHash@@@@PAVCertHash@@@@QAAAAV?$AutoDelete@VCertHash@@@@PAVCertHash@@@Z +??4?$AutoCleanup@V?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@@QAAAAV?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@Z +??4?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAAAV?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@Z +??4?$AutoCleanup@V?$AutoDelete@VGPApiManager@@@@PAVGPApiManager@@@@QAAAAV?$AutoDelete@VGPApiManager@@@@PAVGPApiManager@@@Z +??4?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAAAV?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@Z +??4?$AutoCleanup@V?$AutoDelete@VIChannelObserverFactory@@@@PAVIChannelObserverFactory@@@@QAAAAV?$AutoDelete@VIChannelObserverFactory@@@@PAVIChannelObserverFactory@@@Z +??4?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QAAAAV?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@Z +??4?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QAAAAV?$AutoDelete@VISpecification@@@@PAVISpecification@@@Z +??4?$AutoCleanup@V?$AutoDelete@VPacketCreator@@@@PAVPacketCreator@@@@QAAAAV?$AutoDelete@VPacketCreator@@@@PAVPacketCreator@@@Z +??4?$AutoCleanup@V?$AutoDelete@VPacketParser@@@@PAVPacketParser@@@@QAAAAV?$AutoDelete@VPacketParser@@@@PAVPacketParser@@@Z +??4?$AutoCleanup@V?$AutoDelete@VRunAsConfiguration@@@@PAVRunAsConfiguration@@@@QAAAAV?$AutoDelete@VRunAsConfiguration@@@@PAVRunAsConfiguration@@@Z +??4?$AutoCleanup@V?$AutoDelete@VSecurityEntry@Catalog@@@@PAVSecurityEntry@Catalog@@@@QAAAAV?$AutoDelete@VSecurityEntry@Catalog@@@@PAVSecurityEntry@Catalog@@@Z +??4?$AutoCleanup@V?$AutoDelete@VServiceSoapProcessor@@@@PAVServiceSoapProcessor@@@@QAAAAV?$AutoDelete@VServiceSoapProcessor@@@@PAVServiceSoapProcessor@@@Z +??4?$AutoCleanup@V?$AutoDelete@VSubscriptionEnumerator@@@@PAVSubscriptionEnumerator@@@@QAAAAV?$AutoDelete@VSubscriptionEnumerator@@@@PAVSubscriptionEnumerator@@@Z +??4?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QAAAAV?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@Z +??4?$AutoCleanup@V?$AutoDelete@VUniqueStringOverflow@@@@PAVUniqueStringOverflow@@@@QAAAAV?$AutoDelete@VUniqueStringOverflow@@@@PAVUniqueStringOverflow@@@Z +??4?$AutoCleanup@V?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@PAVWSMANCONFIGTABLE_IDENTITY@@@@QAAAAV?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@PAVWSMANCONFIGTABLE_IDENTITY@@@Z +??4?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QAAAAV?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@Z +??4?$AutoCleanup@V?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@@QAAAAV?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@Z +??4?$AutoCleanup@V?$AutoDeleteVector@$$CBG@@PBG@@QAAAAV?$AutoDeleteVector@$$CBG@@PBG@Z +??4?$AutoCleanup@V?$AutoDeleteVector@D@@PAD@@QAAAAV?$AutoDeleteVector@D@@PAD@Z +??4?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QAAAAV?$AutoDeleteVector@E@@PAE@Z +??4?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QAAAAV?$AutoDeleteVector@G@@PAG@Z +??4?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QAAAAV?$AutoDeleteVector@PAG@@PAPAG@Z +??4?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QAAAAV?$AutoDeleteVector@PBG@@PAPBG@Z +??4?$AutoCleanup@V?$AutoDeleteVector@U_CONFIG_UPDATE@@@@PAU_CONFIG_UPDATE@@@@QAAAAV?$AutoDeleteVector@U_CONFIG_UPDATE@@@@PAU_CONFIG_UPDATE@@@Z +??4?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAAAAV?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@Z +??4?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QAAAAV?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@Z +??4?$AutoCleanup@V?$AutoDeleteVector@U_WSMAN_OPTION@@@@PAU_WSMAN_OPTION@@@@QAAAAV?$AutoDeleteVector@U_WSMAN_OPTION@@@@PAU_WSMAN_OPTION@@@Z +??4?$AutoCleanup@V?$AutoDeleteVector@X@@PAX@@QAAAAV?$AutoDeleteVector@X@@PAX@Z +??4?$AutoCleanup@V?$AutoFree@E@@PAE@@QAAAAV?$AutoFree@E@@PAE@Z +??4?$AutoCleanup@V?$AutoLocklessItemRecycle@VPacket@@@@PAVPacket@@@@QAAAAV?$AutoLocklessItemRecycle@VPacket@@@@PAVPacket@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QAAAAV?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QAAAAV?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QAAAAV?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QAAAAV?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QAAAAV?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QAAAAV?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QAAAAV?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QAAAAV?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QAAAAV?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QAAAAV?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QAAAAV?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QAAAAV?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@Z +??4?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QAAAAV?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@Z +??4?$AutoCleanup@V?$AutoRelease@VApplication@Client@WSMan@@@@PAVApplication@Client@WSMan@@@@QAAAAV?$AutoRelease@VApplication@Client@WSMan@@@@PAVApplication@Client@WSMan@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAAAAV?$AutoRelease@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@@QAAAAV?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCCommonConfigSettings@@@@PAVCCommonConfigSettings@@@@QAAAAV?$AutoRelease@VCCommonConfigSettings@@@@PAVCCommonConfigSettings@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@PAVCConfigCacheMap@CBaseConfigCache@@@@QAAAAV?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@PAVCConfigCacheMap@CBaseConfigCache@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@@QAAAAV?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCRemoteOperation@@@@PAVCRemoteOperation@@@@QAAAAV?$AutoRelease@VCRemoteOperation@@@@PAVCRemoteOperation@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@QAAAAV?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@@QAAAAV?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCServiceCommonConfigSettings@@@@PAVCServiceCommonConfigSettings@@@@QAAAAV?$AutoRelease@VCServiceCommonConfigSettings@@@@PAVCServiceCommonConfigSettings@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCServiceConfigCache@@@@PAVCServiceConfigCache@@@@QAAAAV?$AutoRelease@VCServiceConfigCache@@@@PAVCServiceConfigCache@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCServiceConfigSettings@@@@PAVCServiceConfigSettings@@@@QAAAAV?$AutoRelease@VCServiceConfigSettings@@@@PAVCServiceConfigSettings@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QAAAAV?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyManager@@@@PAVCWSManGroupPolicyManager@@@@QAAAAV?$AutoRelease@VCWSManGroupPolicyManager@@@@PAVCWSManGroupPolicyManager@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@@QAAAAV?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QAAAAV?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@Z +??4?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigSettings@@@@PAVCWinRSPluginConfigSettings@@@@QAAAAV?$AutoRelease@VCWinRSPluginConfigSettings@@@@PAVCWinRSPluginConfigSettings@@@Z +??4?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAAAV?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@Z +??4?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAAAV?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@Z +??4?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QAAAAV?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@Z +??4?$AutoCleanup@V?$AutoRelease@VISubscription@@@@PAVISubscription@@@@QAAAAV?$AutoRelease@VISubscription@@@@PAVISubscription@@@Z +??4?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@QAAAAV?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@Z +??4?$AutoCleanup@V?$AutoRelease@VUserRecord@@@@PAVUserRecord@@@@QAAAAV?$AutoRelease@VUserRecord@@@@PAVUserRecord@@@Z +??4?$AutoCleanup@V?$AutoRelease@VWSManHttpListener@@@@PAVWSManHttpListener@@@@QAAAAV?$AutoRelease@VWSManHttpListener@@@@PAVWSManHttpListener@@@Z +??4?$AutoCleanup@V?$AutoReleaseEx@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QAAAAV?$AutoReleaseEx@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@Z +??4?$AutoCleanup@VAutoBstr@@PAG@@QAAAAVAutoBstr@@PAG@Z +??4?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QAAAAVAutoBstrNoAlloc@@PAG@Z +??4?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@QAAAAVAutoCertContext@@PBU_CERT_CONTEXT@@@Z +??4?$AutoCleanup@VAutoChainContext@@PBU_CERT_CHAIN_CONTEXT@@@@QAAAAVAutoChainContext@@PBU_CERT_CHAIN_CONTEXT@@@Z +??4?$AutoCleanup@VAutoCoTaskMemFree@@PAX@@QAAAAVAutoCoTaskMemFree@@PAX@Z +??4?$AutoCleanup@VAutoEnvironmentBlock@@PAX@@QAAAAVAutoEnvironmentBlock@@PAX@Z +??4?$AutoCleanup@VAutoFwXmlCloseParser@@PAX@@QAAAAVAutoFwXmlCloseParser@@PAX@Z +??4?$AutoCleanup@VAutoHandle@@PAX@@QAAAAVAutoHandle@@PAX@Z +??4?$AutoCleanup@VAutoImpersonateUser@@PAX@@QAAAAVAutoImpersonateUser@@PAX@Z +??4?$AutoCleanup@VAutoLibrary@@PAUHINSTANCE__@@@@QAAAAVAutoLibrary@@PAUHINSTANCE__@@@Z +??4?$AutoCleanup@VAutoLocalFree@@PAX@@QAAAAVAutoLocalFree@@PAX@Z +??4?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@QAAAAVAutoMIClass@@PAU_MI_Class@@@Z +??4?$AutoCleanup@VAutoMIInstance@@PAU_MI_Instance@@@@QAAAAVAutoMIInstance@@PAU_MI_Instance@@@Z +??4?$AutoCleanup@VAutoObject@@PAUWSMAN_OBJECT@@@@QAAAAVAutoObject@@PAUWSMAN_OBJECT@@@Z +??4?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@QAAAAVAutoRegKey@@PAUHKEY__@@@Z +??4?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@QAAAAVAutoSecurityDescriptor@@PAX@Z +??4?$AutoCleanup@VAutoWaitHandle@@PAX@@QAAAAVAutoWaitHandle@@PAX@Z +??4?$AutoDelete@D@@QAAAAV0@PAD@Z +??4?$AutoDelete@G@@QAAAAV0@PAG@Z +??4?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAAAAV0@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@Z +??4?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAAAAV0@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@Z +??4?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@QAAAAV0@PAV?$SafeSet@PAVCCertMapping@@@@@Z +??4?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@QAAAAV0@PAV?$SafeSet@PAVCShellUriSettings@@@@@Z +??4?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAAAAV0@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@Z +??4?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAAAAV0@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@Z +??4?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@QAAAAV0@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@Z +??4?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@QAAAAV0@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@Z +??4?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@QAAAAV0@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@Z +??4?$AutoDelete@VBlockedRecord@@@@QAAAAV0@PAVBlockedRecord@@@Z +??4?$AutoDelete@VCConfigChangeSource@@@@QAAAAV0@PAVCConfigChangeSource@@@Z +??4?$AutoDelete@VCObserverConfigChangeErrors@@@@QAAAAV0@PAVCObserverConfigChangeErrors@@@Z +??4?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@QAAAAV0@PAVCServiceWatcher@CServiceConfigCache@@@Z +??4?$AutoDelete@VCWSManResource@@@@QAAAAV0@PAVCWSManResource@@@Z +??4?$AutoDelete@VCertHash@@@@QAAAAV0@PAVCertHash@@@Z +??4?$AutoDelete@VConfigUpdate@@@@QAAAAV0@PAVConfigUpdate@@@Z +??4?$AutoDelete@VEnumSinkEx@@@@QAAAAV0@PAVEnumSinkEx@@@Z +??4?$AutoDelete@VGPApiManager@@@@QAAAAV0@PAVGPApiManager@@@Z +??4?$AutoDelete@VGeneralSinkEx@@@@QAAAAV0@PAVGeneralSinkEx@@@Z +??4?$AutoDelete@VIChannelObserverFactory@@@@QAAAAV0@PAVIChannelObserverFactory@@@Z +??4?$AutoDelete@VIQueryDASHSMASHInterface@@@@QAAAAV0@PAVIQueryDASHSMASHInterface@@@Z +??4?$AutoDelete@VISpecification@@@@QAAAAV0@PAVISpecification@@@Z +??4?$AutoDelete@VPacketCreator@@@@QAAAAV0@PAVPacketCreator@@@Z +??4?$AutoDelete@VPacketParser@@@@QAAAAV0@PAVPacketParser@@@Z +??4?$AutoDelete@VRunAsConfiguration@@@@QAAAAV0@PAVRunAsConfiguration@@@Z +??4?$AutoDelete@VSecurityEntry@Catalog@@@@QAAAAV0@PAVSecurityEntry@Catalog@@@Z +??4?$AutoDelete@VServiceSoapProcessor@@@@QAAAAV0@PAVServiceSoapProcessor@@@Z +??4?$AutoDelete@VSubscriptionEnumerator@@@@QAAAAV0@PAVSubscriptionEnumerator@@@Z +??4?$AutoDelete@VTSTRBUFFER@@@@QAAAAV0@PAVTSTRBUFFER@@@Z +??4?$AutoDelete@VUniqueStringOverflow@@@@QAAAAV0@PAVUniqueStringOverflow@@@Z +??4?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@QAAAAV0@PAVWSMANCONFIGTABLE_IDENTITY@@@Z +??4?$AutoDelete@VWmiEnumContext@@@@QAAAAV0@PAVWmiEnumContext@@@Z +??4?$AutoDelete@VXmlReader@@@@QAAAAV0@PAVXmlReader@@@Z +??4?$AutoDeleteVector@$$CBG@@QAAAAV0@PBG@Z +??4?$AutoDeleteVector@D@@QAAAAV0@PAD@Z +??4?$AutoDeleteVector@E@@QAAAAV0@PAE@Z +??4?$AutoDeleteVector@G@@QAAAAV0@PAG@Z +??4?$AutoDeleteVector@PAG@@QAAAAV0@PAPAG@Z +??4?$AutoDeleteVector@PBG@@QAAAAV0@PAPBG@Z +??4?$AutoDeleteVector@U_CONFIG_UPDATE@@@@QAAAAV0@PAU_CONFIG_UPDATE@@@Z +??4?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAAAAV0@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@Z +??4?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@QAAAAV0@PAU_WINRS_RUN_COMMAND_ARG@@@Z +??4?$AutoDeleteVector@U_WSMAN_OPTION@@@@QAAAAV0@PAU_WSMAN_OPTION@@@Z +??4?$AutoDeleteVector@X@@QAAAAV0@PAX@Z +??4?$AutoFree@E@@QAAAAV0@PAE@Z +??4?$AutoLocklessItemRecycle@VPacket@@@@QAAAAV0@PAVPacket@@@Z +??4?$AutoRelease@UIClientSecurity@@@@QAAAAV0@PAUIClientSecurity@@@Z +??4?$AutoRelease@UIEnumWbemClassObject@@@@QAAAAV0@PAUIEnumWbemClassObject@@@Z +??4?$AutoRelease@UIErrorInfo@@@@QAAAAV0@PAUIErrorInfo@@@Z +??4?$AutoRelease@UIUnknown@@@@QAAAAV0@PAUIUnknown@@@Z +??4?$AutoRelease@UIWbemClassObject@@@@QAAAAV0@PAUIWbemClassObject@@@Z +??4?$AutoRelease@UIWbemContext@@@@QAAAAV0@PAUIWbemContext@@@Z +??4?$AutoRelease@UIWbemLocator@@@@QAAAAV0@PAUIWbemLocator@@@Z +??4?$AutoRelease@UIWbemObjectTextSrc@@@@QAAAAV0@PAUIWbemObjectTextSrc@@@Z +??4?$AutoRelease@UIWbemPath@@@@QAAAAV0@PAUIWbemPath@@@Z +??4?$AutoRelease@UIWbemPathKeyList@@@@QAAAAV0@PAUIWbemPathKeyList@@@Z +??4?$AutoRelease@UIWbemQualifierSet@@@@QAAAAV0@PAUIWbemQualifierSet@@@Z +??4?$AutoRelease@UIWbemQuery@@@@QAAAAV0@PAUIWbemQuery@@@Z +??4?$AutoRelease@UIWbemServices@@@@QAAAAV0@PAUIWbemServices@@@Z +??4?$AutoRelease@VApplication@Client@WSMan@@@@QAAAAV0@PAVApplication@Client@WSMan@@@Z +??4?$AutoRelease@VCBaseConfigCache@@@@QAAAAV0@PAVCBaseConfigCache@@@Z +??4?$AutoRelease@VCClientConfigSettings@@@@QAAAAV0@PAVCClientConfigSettings@@@Z +??4?$AutoRelease@VCCommonConfigSettings@@@@QAAAAV0@PAVCCommonConfigSettings@@@Z +??4?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@QAAAAV0@PAVCConfigCacheMap@CBaseConfigCache@@@Z +??4?$AutoRelease@VCConfigManager@@@@QAAAAV0@PAVCConfigManager@@@Z +??4?$AutoRelease@VCRemoteOperation@@@@QAAAAV0@PAVCRemoteOperation@@@Z +??4?$AutoRelease@VCRemoteSession@@@@QAAAAV0@PAVCRemoteSession@@@Z +??4?$AutoRelease@VCRequestContext@@@@QAAAAV0@PAVCRequestContext@@@Z +??4?$AutoRelease@VCServiceCommonConfigSettings@@@@QAAAAV0@PAVCServiceCommonConfigSettings@@@Z +??4?$AutoRelease@VCServiceConfigCache@@@@QAAAAV0@PAVCServiceConfigCache@@@Z +??4?$AutoRelease@VCServiceConfigSettings@@@@QAAAAV0@PAVCServiceConfigSettings@@@Z +??4?$AutoRelease@VCWSManEPR@@@@QAAAAV0@PAVCWSManEPR@@@Z +??4?$AutoRelease@VCWSManGroupPolicyManager@@@@QAAAAV0@PAVCWSManGroupPolicyManager@@@Z +??4?$AutoRelease@VCWSManResource@@@@QAAAAV0@PAVCWSManResource@@@Z +??4?$AutoRelease@VCWinRSPluginConfigCache@@@@QAAAAV0@PAVCWinRSPluginConfigCache@@@Z +??4?$AutoRelease@VCWinRSPluginConfigSettings@@@@QAAAAV0@PAVCWinRSPluginConfigSettings@@@Z +??4?$AutoRelease@VEnumSinkEx@@@@QAAAAV0@PAVEnumSinkEx@@@Z +??4?$AutoRelease@VGeneralSinkEx@@@@QAAAAV0@PAVGeneralSinkEx@@@Z +??4?$AutoRelease@VIRequestContext@@@@QAAAAV0@PAVIRequestContext@@@Z +??4?$AutoRelease@VISubscription@@@@QAAAAV0@PAVISubscription@@@Z +??4?$AutoRelease@VInboundRequestDetails@@@@QAAAAV0@PAVInboundRequestDetails@@@Z +??4?$AutoRelease@VUserRecord@@@@QAAAAV0@PAVUserRecord@@@Z +??4?$AutoRelease@VWSManHttpListener@@@@QAAAAV0@PAVWSManHttpListener@@@Z +??4?$AutoReleaseEx@VShell@Client@WSMan@@@@QAAAAV0@PAVShell@Client@WSMan@@@Z +??4?$PacketElement@K@PacketParser@@QAAAAV01@ABV01@@Z +??4?$PacketElement@PAU_FWXML_ELEMENT@@@PacketParser@@QAAAAV01@ABV01@@Z +??4?$PacketElement@PBG@PacketParser@@QAAAAV01@ABV01@@Z +??4?$PacketElement@_K@PacketParser@@QAAAAV01@ABV01@@Z +??4?$SimpleQueue@T_LARGE_INTEGER@@@@QAAAAV0@ABV0@@Z +??4AutoBstr@@QAAAAV0@PAG@Z +??4AutoBstrNoAlloc@@QAAAAV0@PAG@Z +??4AutoCertContext@@QAAAAV0@PBU_CERT_CONTEXT@@@Z +??4AutoChainContext@@QAAAAV0@PBU_CERT_CHAIN_CONTEXT@@@Z +??4AutoCoTaskMemFree@@QAAAAV0@PAX@Z +??4AutoEnvironmentBlock@@QAAAAV0@PAX@Z +??4AutoFwXmlCloseParser@@QAAAAV0@PAX@Z +??4AutoHandle@@QAAAAV0@PAX@Z +??4AutoImpersonateUser@@QAAAAV0@PAX@Z +??4AutoLibrary@@QAAAAV0@PAUHINSTANCE__@@@Z +??4AutoLocalFree@@QAAAAV0@PAX@Z +??4AutoMIClass@@QAAAAV0@PAU_MI_Class@@@Z +??4AutoMIInstance@@QAAAAV0@PAU_MI_Instance@@@Z +??4AutoObject@@QAAAAV0@PAUWSMAN_OBJECT@@@Z +??4AutoRegKey@@QAAAAV0@PAUHKEY__@@@Z +??4AutoSecurityDescriptor@@QAAAAV0@PAX@Z +??4AutoWaitHandle@@QAAAAV0@PAX@Z +??4ChildLifeTimeManager@@QAAAAV0@ABV0@@Z +??4ConfigRegistry@@QAAAAV0@ABV0@@Z +??4EtwCorrelationHelper@@QAAAAV0@ABV0@@Z +??4EventLog@@QAAAAV0@ABV0@@Z +??4ExtendedSemantic@@QAAAAV0@ABV0@@Z +??4FastLock@@QAAAAV0@ABV0@@Z +??4Fragment@PacketParser@@QAAAAV01@ABV01@@Z +??4IConfigChangeObserver@@QAAAAV0@ABV0@@Z +??4ILifeTimeMgmt@@QAAAAV0@ABV0@@Z +??4IWSManGroupPolicyObserver@@QAAAAV0@ABV0@@Z +??4IWSManGroupPolicyPublisher@@QAAAAV0@ABV0@@Z +??4Locale@@QAAAAV0@ABV0@@Z +??4NotUnderstandSoapHeader@PacketParser@@QAAAAV01@ABV01@@Z +??4PacketFormatter@@QAAAAV0@ABV0@@Z +??4RBUFFER@@QAAAAV0@ABV0@@Z +??4SBUFFER@@QAAAAV0@ABV0@@Z +??4SessionId@PacketParser@@QAAAAV01@ABV01@@Z +??4SoapSemanticConverter@@QAAAAV0@ABV0@@Z +??4UserAuthzRecord@@QAAAAV0@ABV0@@Z +??6BufferFormatter@@UAAAAV0@AAVBufferFormatterDataFormatDWORD@@@Z +??6BufferFormatter@@UAAAAV0@AAVBufferFormatterDataFormatULONGLONG@@@Z +??6BufferFormatter@@UAAAAV0@AAVBufferFormatterDataPCWSTR@@@Z +??6BufferFormatter@@UAAAAV0@AAVBufferFormatterDataPUCHAR@@@Z +??6BufferFormatter@@UAAAAV0@AAVBufferFormatterDataXmlEscape@@@Z +??6BufferFormatter@@UAAAAV0@K@Z +??6BufferFormatter@@UAAAAV0@PAU_FWXML_ELEMENT@@@Z +??7?$AutoCleanup@V?$AutoDelete@G@@PAG@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@VRunAsConfiguration@@@@PAVRunAsConfiguration@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@VSubscriptionEnumerator@@@@PAVSubscriptionEnumerator@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDeleteVector@D@@PAD@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoDeleteVector@X@@PAX@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QBA_NXZ +??7?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@QBA_NXZ +??7?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QBA_NXZ +??7?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@QBA_NXZ +??7?$AutoCleanup@VAutoHandle@@PAX@@QBA_NXZ +??7?$AutoCleanup@VAutoImpersonateUser@@PAX@@QBA_NXZ +??7?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@QBA_NXZ +??7?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@QBA_NXZ +??7?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@QBA_NXZ +??A?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAAPAKABUPluginKey@@@Z +??A?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAAPAPAVBlockedRecord@@ABUUserKey@@@Z +??A?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAAPAVCertThumbprintMappedSet@CServiceConfigSettings@@ABVCertThumbprintKey@@@Z +??A?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAAPAKABVStringKeyCI@@@Z +??A?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAAPAUUSER_CONTEXT_INFO@WSManHttpListener@@ABVStringKeyCI@@@Z +??A?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAAPAPAVExpiredOperationIdRecord@@ABVStringKeyStore@@@Z +??A?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAAPAPAVServerFullDuplexChannel@@ABVStringKeyStore@@@Z +??A?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAAPAPAVOptionValue@SessionOptions@Client@WSMan@@ABW4WSManSessionOption@@@Z +??A?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAAPAPAVSendPacketArgs@RobustConnectionBuffer@@AB_K@Z +??A?$SafeSet@PAX@@QBAPBQAXABQAX@Z +??B?$AutoCleanup@V?$AutoDelete@D@@PAD@@QAAPADXZ +??B?$AutoCleanup@V?$AutoDelete@G@@PAG@@QAAPAGXZ +??B?$AutoCleanup@V?$AutoDelete@G@@PAG@@QBAQAGXZ +??B?$AutoCleanup@V?$AutoDelete@UIPRange@CWSManIPFilter@@@@PAUIPRange@CWSManIPFilter@@@@QAAPAUIPRange@CWSManIPFilter@@XZ +??B?$AutoCleanup@V?$AutoDelete@U_SID@@@@PAU_SID@@@@QAAPAU_SID@@XZ +??B?$AutoCleanup@V?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@PAU_WSMAN_STREAM_ID_SET@@@@QAAPAU_WSMAN_STREAM_ID_SET@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$Handle@VISubscription@@@@@@PAV?$Handle@VISubscription@@@@@@QAAPAV?$Handle@VISubscription@@@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAAPAV?$SafeMap_Iterator@VStringKeyCI@@K@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAAPAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@@QAAPAV?$SafeSet@PAVCCertMapping@@@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@@QAAPAV?$SafeSet@PAVCShellUriSettings@@@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAAPAV?$SafeSet_Iterator@PAVCListenerOperation@@@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAAPAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@QAAPAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@QAAPAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@QBAQAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@XZ +??B?$AutoCleanup@V?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@QAAPAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@XZ +??B?$AutoCleanup@V?$AutoDelete@VAdminSid@CSecurity@@@@PAVAdminSid@CSecurity@@@@QAAPAVAdminSid@CSecurity@@XZ +??B?$AutoCleanup@V?$AutoDelete@VBlockedRecord@@@@PAVBlockedRecord@@@@QAAPAVBlockedRecord@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAAPAVCBaseConfigCache@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCCertMapping@@@@PAVCCertMapping@@@@QAAPAVCCertMapping@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCConfigChangeSource@@@@PAVCConfigChangeSource@@@@QAAPAVCConfigChangeSource@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCListenerSettings@@@@PAVCListenerSettings@@@@QAAPAVCListenerSettings@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCObserverConfigChangeErrors@@@@PAVCObserverConfigChangeErrors@@@@QAAPAVCObserverConfigChangeErrors@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@PAVCServiceWatcher@CServiceConfigCache@@@@QAAPAVCServiceWatcher@CServiceConfigCache@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCShellUriSettings@@@@PAVCShellUriSettings@@@@QAAPAVCShellUriSettings@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCWSManEPR@@@@PAVCWSManEPR@@@@QAAPAVCWSManEPR@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCWSManResource@@@@PAVCWSManResource@@@@QAAPAVCWSManResource@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCertHash@@@@PAVCertHash@@@@QAAPAVCertHash@@XZ +??B?$AutoCleanup@V?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@@QAAPAVConfigUpdate@@XZ +??B?$AutoCleanup@V?$AutoDelete@VCredUIDllLoader@@@@PAVCredUIDllLoader@@@@QAAPAVCredUIDllLoader@@XZ +??B?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAPAVEnumSinkEx@@XZ +??B?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QBAQAVEnumSinkEx@@XZ +??B?$AutoCleanup@V?$AutoDelete@VEventHandler@WSMan@@@@PAVEventHandler@WSMan@@@@QAAPAVEventHandler@WSMan@@XZ +??B?$AutoCleanup@V?$AutoDelete@VExpiredOperationIdRecord@@@@PAVExpiredOperationIdRecord@@@@QAAPAVExpiredOperationIdRecord@@XZ +??B?$AutoCleanup@V?$AutoDelete@VGPApiManager@@@@PAVGPApiManager@@@@QAAPAVGPApiManager@@XZ +??B?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAPAVGeneralSinkEx@@XZ +??B?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QBAQAVGeneralSinkEx@@XZ +??B?$AutoCleanup@V?$AutoDelete@VIChannelObserverFactory@@@@PAVIChannelObserverFactory@@@@QAAPAVIChannelObserverFactory@@XZ +??B?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QAAPAVIQueryDASHSMASHInterface@@XZ +??B?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QBAQAVIQueryDASHSMASHInterface@@XZ +??B?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QAAPAVISpecification@@XZ +??B?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QBAQAVISpecification@@XZ +??B?$AutoCleanup@V?$AutoDelete@VInteractiveSid@CSecurity@@@@PAVInteractiveSid@CSecurity@@@@QAAPAVInteractiveSid@CSecurity@@XZ +??B?$AutoCleanup@V?$AutoDelete@VIpHlpApiDllLoader@@@@PAVIpHlpApiDllLoader@@@@QAAPAVIpHlpApiDllLoader@@XZ +??B?$AutoCleanup@V?$AutoDelete@VMachineName@@@@PAVMachineName@@@@QAAPAVMachineName@@XZ +??B?$AutoCleanup@V?$AutoDelete@VNetworkServiceSid@CSecurity@@@@PAVNetworkServiceSid@CSecurity@@@@QAAPAVNetworkServiceSid@CSecurity@@XZ +??B?$AutoCleanup@V?$AutoDelete@VNtDsApiDllLoader@@@@PAVNtDsApiDllLoader@@@@QAAPAVNtDsApiDllLoader@@XZ +??B?$AutoCleanup@V?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAAPAVOptionValue@SessionOptions@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoDelete@VPacketCreator@@@@PAVPacketCreator@@@@QAAPAVPacketCreator@@XZ +??B?$AutoCleanup@V?$AutoDelete@VPacketParser@@@@PAVPacketParser@@@@QAAPAVPacketParser@@XZ +??B?$AutoCleanup@V?$AutoDelete@VResources@Locale@@@@PAVResources@Locale@@@@QAAPAVResources@Locale@@XZ +??B?$AutoCleanup@V?$AutoDelete@VSecurityEntry@Catalog@@@@PAVSecurityEntry@Catalog@@@@QAAPAVSecurityEntry@Catalog@@XZ +??B?$AutoCleanup@V?$AutoDelete@VServiceSoapProcessor@@@@PAVServiceSoapProcessor@@@@QAAPAVServiceSoapProcessor@@XZ +??B?$AutoCleanup@V?$AutoDelete@VShell32DllLoader@@@@PAVShell32DllLoader@@@@QAAPAVShell32DllLoader@@XZ +??B?$AutoCleanup@V?$AutoDelete@VShlWApiDllLoader@@@@PAVShlWApiDllLoader@@@@QAAPAVShlWApiDllLoader@@XZ +??B?$AutoCleanup@V?$AutoDelete@VSubscriptionManager@@@@PAVSubscriptionManager@@@@QAAPAVSubscriptionManager@@XZ +??B?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QAAPAVTSTRBUFFER@@XZ +??B?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QBAQAVTSTRBUFFER@@XZ +??B?$AutoCleanup@V?$AutoDelete@VUniqueStringOverflow@@@@PAVUniqueStringOverflow@@@@QAAPAVUniqueStringOverflow@@XZ +??B?$AutoCleanup@V?$AutoDelete@VUser32DllLoader@@@@PAVUser32DllLoader@@@@QAAPAVUser32DllLoader@@XZ +??B?$AutoCleanup@V?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@PAVWSMANCONFIGTABLE_IDENTITY@@@@QAAPAVWSMANCONFIGTABLE_IDENTITY@@XZ +??B?$AutoCleanup@V?$AutoDelete@VWSManMemCryptManager@@@@PAVWSManMemCryptManager@@@@QAAPAVWSManMemCryptManager@@XZ +??B?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QAAPAVWmiEnumContext@@XZ +??B?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QBAQAVWmiEnumContext@@XZ +??B?$AutoCleanup@V?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@@QAAPAVXmlReader@@XZ +??B?$AutoCleanup@V?$AutoDeleteVector@$$CBG@@PBG@@QAAPBGXZ +??B?$AutoCleanup@V?$AutoDeleteVector@D@@PAD@@QAAPADXZ +??B?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QAAPAEXZ +??B?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QBAQAEXZ +??B?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QAAPAGXZ +??B?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QBAQAGXZ +??B?$AutoCleanup@V?$AutoDeleteVector@H@@PAH@@QAAPAHXZ +??B?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QAAPAPAGXZ +??B?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QBAQAPAGXZ +??B?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QAAPAPBGXZ +??B?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QBAQAPBGXZ +??B?$AutoCleanup@V?$AutoDeleteVector@U_CONFIG_UPDATE@@@@PAU_CONFIG_UPDATE@@@@QAAPAU_CONFIG_UPDATE@@XZ +??B?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAAPAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@XZ +??B?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QBAQAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@XZ +??B?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QAAPAU_WINRS_RUN_COMMAND_ARG@@XZ +??B?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QBAQAU_WINRS_RUN_COMMAND_ARG@@XZ +??B?$AutoCleanup@V?$AutoDeleteVector@U_WSMAN_OPTION@@@@PAU_WSMAN_OPTION@@@@QAAPAU_WSMAN_OPTION@@XZ +??B?$AutoCleanup@V?$AutoDeleteVector@X@@PAX@@QAAPAXXZ +??B?$AutoCleanup@V?$AutoFree@E@@PAE@@QAAPAEXZ +??B?$AutoCleanup@V?$AutoFree@E@@PAE@@QBAQAEXZ +??B?$AutoCleanup@V?$AutoLocklessItemRecycle@VPacket@@@@PAVPacket@@@@QAAPAVPacket@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIAppHostChildElementCollection@@@@PAUIAppHostChildElementCollection@@@@QAAPAUIAppHostChildElementCollection@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIAppHostElement@@@@PAUIAppHostElement@@@@QAAPAUIAppHostElement@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIAppHostElementCollection@@@@PAUIAppHostElementCollection@@@@QAAPAUIAppHostElementCollection@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QAAPAUIClientSecurity@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QBAQAUIClientSecurity@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QAAPAUIEnumWbemClassObject@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QBAQAUIEnumWbemClassObject@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QAAPAUIErrorInfo@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QBAQAUIErrorInfo@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QAAPAUIUnknown@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QBAQAUIUnknown@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QAAPAUIWbemClassObject@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QBAQAUIWbemClassObject@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QAAPAUIWbemContext@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QBAQAUIWbemContext@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QAAPAUIWbemLocator@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QBAQAUIWbemLocator@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QAAPAUIWbemObjectTextSrc@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QBAQAUIWbemObjectTextSrc@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QAAPAUIWbemPath@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QBAQAUIWbemPath@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QAAPAUIWbemPathKeyList@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QBAQAUIWbemPathKeyList@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QAAPAUIWbemQualifierSet@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QBAQAUIWbemQualifierSet@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QAAPAUIWbemQuery@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QBAQAUIWbemQuery@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QAAPAUIWbemServices@@XZ +??B?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QBAQAUIWbemServices@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAAPAVCBaseConfigCache@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@@QAAPAVCClientConfigSettings@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCCommonConfigSettings@@@@PAVCCommonConfigSettings@@@@QAAPAVCCommonConfigSettings@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@PAVCConfigCacheMap@CBaseConfigCache@@@@QAAPAVCConfigCacheMap@CBaseConfigCache@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@@QAAPAVCConfigManager@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@QAAPAVCRemoteSession@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@@QAAPAVCRequestContext@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCServiceCommonConfigSettings@@@@PAVCServiceCommonConfigSettings@@@@QAAPAVCServiceCommonConfigSettings@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCServiceConfigCache@@@@PAVCServiceConfigCache@@@@QAAPAVCServiceConfigCache@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCServiceConfigSettings@@@@PAVCServiceConfigSettings@@@@QAAPAVCServiceConfigSettings@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QAAPAVCWSManEPR@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QBAQAVCWSManEPR@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyCache@@@@PAVCWSManGroupPolicyCache@@@@QAAPAVCWSManGroupPolicyCache@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyManager@@@@PAVCWSManGroupPolicyManager@@@@QAAPAVCWSManGroupPolicyManager@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWSManObject@@@@PAVCWSManObject@@@@QAAPAVCWSManObject@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@@QAAPAVCWSManResource@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@@QBAQAVCWSManResource@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QAAPAVCWinRSPluginConfigCache@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QBAQAVCWinRSPluginConfigCache@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigSettings@@@@PAVCWinRSPluginConfigSettings@@@@QAAPAVCWinRSPluginConfigSettings@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCommand@Client@WSMan@@@@PAVCommand@Client@WSMan@@@@QAAPAVCommand@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VConfigNotification@@@@PAVConfigNotification@@@@QAAPAVConfigNotification@@XZ +??B?$AutoCleanup@V?$AutoRelease@VConnectShellOperation@Client@WSMan@@@@PAVConnectShellOperation@Client@WSMan@@@@QAAPAVConnectShellOperation@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VCreateShellOperation@Client@WSMan@@@@PAVCreateShellOperation@Client@WSMan@@@@QAAPAVCreateShellOperation@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VDeleteShellOperation@Client@WSMan@@@@PAVDeleteShellOperation@Client@WSMan@@@@QAAPAVDeleteShellOperation@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VDisconnectOperation@Client@WSMan@@@@PAVDisconnectOperation@Client@WSMan@@@@QAAPAVDisconnectOperation@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAPAVEnumSinkEx@@XZ +??B?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QBAQAVEnumSinkEx@@XZ +??B?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAPAVGeneralSinkEx@@XZ +??B?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QBAQAVGeneralSinkEx@@XZ +??B?$AutoCleanup@V?$AutoRelease@VIISConfigSettings@@@@PAVIISConfigSettings@@@@QAAPAVIISConfigSettings@@XZ +??B?$AutoCleanup@V?$AutoRelease@VIPCSoapProcessor@@@@PAVIPCSoapProcessor@@@@QAAPAVIPCSoapProcessor@@XZ +??B?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QAAPAVIRequestContext@@XZ +??B?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QBAQAVIRequestContext@@XZ +??B?$AutoCleanup@V?$AutoRelease@VISubscription@@@@PAVISubscription@@@@QAAPAVISubscription@@XZ +??B?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@QAAPAVInboundRequestDetails@@XZ +??B?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@QBAQAVInboundRequestDetails@@XZ +??B?$AutoCleanup@V?$AutoRelease@VReceiveOperation@Client@WSMan@@@@PAVReceiveOperation@Client@WSMan@@@@QAAPAVReceiveOperation@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VReconnectOperation@Client@WSMan@@@@PAVReconnectOperation@Client@WSMan@@@@QAAPAVReconnectOperation@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VSendOperation@Client@WSMan@@@@PAVSendOperation@Client@WSMan@@@@QAAPAVSendOperation@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QAAPAVShell@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QBAQAVShell@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VSignalOperation@Client@WSMan@@@@PAVSignalOperation@Client@WSMan@@@@QAAPAVSignalOperation@Client@WSMan@@XZ +??B?$AutoCleanup@V?$AutoRelease@VUserRecord@@@@PAVUserRecord@@@@QAAPAVUserRecord@@XZ +??B?$AutoCleanup@V?$AutoRelease@VUserRecord@@@@PAVUserRecord@@@@QBAQAVUserRecord@@XZ +??B?$AutoCleanup@VAutoBstr@@PAG@@QAAPAGXZ +??B?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QAAPAGXZ +??B?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QBAQAGXZ +??B?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@QAAPBU_CERT_CONTEXT@@XZ +??B?$AutoCleanup@VAutoHandle@@PAX@@QAAPAXXZ +??B?$AutoCleanup@VAutoHandle@@PAX@@QBAQAXXZ +??B?$AutoCleanup@VAutoImpersonateUser@@PAX@@QAAPAXXZ +??B?$AutoCleanup@VAutoImpersonateUser@@PAX@@QBAQAXXZ +??B?$AutoCleanup@VAutoLibrary@@PAUHINSTANCE__@@@@QAAPAUHINSTANCE__@@XZ +??B?$AutoCleanup@VAutoLocalFree@@PAX@@QAAPAXXZ +??B?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@QAAPAU_MI_Class@@XZ +??B?$AutoCleanup@VAutoMIInstance@@PAU_MI_Instance@@@@QAAPAU_MI_Instance@@XZ +??B?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@QAAPAUHKEY__@@XZ +??B?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@QAAPAXXZ +??B?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@QBA_NXZ +??B?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@QBA_NXZ +??B?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@QBA_NXZ +??B?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QBA_NXZ +??B?$SafeMap_Iterator@VKey@Locale@@K@@QBA_NXZ +??B?$SafeMap_Iterator@VStringKeyCI@@K@@QBA_NXZ +??B?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@QBA_NXZ +??B?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QBA_NXZ +??B?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QBA_NXZ +??C?$AutoCleanup@V?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@PAU_WSMAN_STREAM_ID_SET@@@@QAAPAU_WSMAN_STREAM_ID_SET@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$Handle@VISubscription@@@@@@PAV?$Handle@VISubscription@@@@@@QAAPAV?$Handle@VISubscription@@@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAAPAV?$SafeMap_Iterator@VStringKeyCI@@K@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAAPAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@@QAAPAV?$SafeSet@PAVCCertMapping@@@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@@QAAPAV?$SafeSet@PAVCShellUriSettings@@@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAAPAV?$SafeSet_Iterator@PAVCListenerOperation@@@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAAPAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@QAAPAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@QAAPAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@XZ +??C?$AutoCleanup@V?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@QAAPAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@XZ +??C?$AutoCleanup@V?$AutoDelete@VBlockedRecord@@@@PAVBlockedRecord@@@@QAAPAVBlockedRecord@@XZ +??C?$AutoCleanup@V?$AutoDelete@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAAPAVCBaseConfigCache@@XZ +??C?$AutoCleanup@V?$AutoDelete@VCCertMapping@@@@PAVCCertMapping@@@@QAAPAVCCertMapping@@XZ +??C?$AutoCleanup@V?$AutoDelete@VCConfigChangeSource@@@@PAVCConfigChangeSource@@@@QAAPAVCConfigChangeSource@@XZ +??C?$AutoCleanup@V?$AutoDelete@VCListenerSettings@@@@PAVCListenerSettings@@@@QAAPAVCListenerSettings@@XZ +??C?$AutoCleanup@V?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@PAVCServiceWatcher@CServiceConfigCache@@@@QAAPAVCServiceWatcher@CServiceConfigCache@@XZ +??C?$AutoCleanup@V?$AutoDelete@VCShellUriSettings@@@@PAVCShellUriSettings@@@@QAAPAVCShellUriSettings@@XZ +??C?$AutoCleanup@V?$AutoDelete@VCWSManEPR@@@@PAVCWSManEPR@@@@QAAPAVCWSManEPR@@XZ +??C?$AutoCleanup@V?$AutoDelete@VCWSManResource@@@@PAVCWSManResource@@@@QAAPAVCWSManResource@@XZ +??C?$AutoCleanup@V?$AutoDelete@VCertHash@@@@PAVCertHash@@@@QAAPAVCertHash@@XZ +??C?$AutoCleanup@V?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@@QAAPAVConfigUpdate@@XZ +??C?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAPAVEnumSinkEx@@XZ +??C?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QBAQAVEnumSinkEx@@XZ +??C?$AutoCleanup@V?$AutoDelete@VExpiredOperationIdRecord@@@@PAVExpiredOperationIdRecord@@@@QAAPAVExpiredOperationIdRecord@@XZ +??C?$AutoCleanup@V?$AutoDelete@VGPApiManager@@@@PAVGPApiManager@@@@QAAPAVGPApiManager@@XZ +??C?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAPAVGeneralSinkEx@@XZ +??C?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QBAQAVGeneralSinkEx@@XZ +??C?$AutoCleanup@V?$AutoDelete@VIChannelObserverFactory@@@@PAVIChannelObserverFactory@@@@QAAPAVIChannelObserverFactory@@XZ +??C?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QAAPAVIQueryDASHSMASHInterface@@XZ +??C?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QBAQAVIQueryDASHSMASHInterface@@XZ +??C?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QAAPAVISpecification@@XZ +??C?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QBAQAVISpecification@@XZ +??C?$AutoCleanup@V?$AutoDelete@VMasterReceiveData@CListenerReceive@@@@PAVMasterReceiveData@CListenerReceive@@@@QAAPAVMasterReceiveData@CListenerReceive@@XZ +??C?$AutoCleanup@V?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAAPAVOptionValue@SessionOptions@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoDelete@VPacketCreator@@@@PAVPacketCreator@@@@QAAPAVPacketCreator@@XZ +??C?$AutoCleanup@V?$AutoDelete@VPacketParser@@@@PAVPacketParser@@@@QAAPAVPacketParser@@XZ +??C?$AutoCleanup@V?$AutoDelete@VRunAsConfiguration@@@@PAVRunAsConfiguration@@@@QAAPAVRunAsConfiguration@@XZ +??C?$AutoCleanup@V?$AutoDelete@VSecurityEntry@Catalog@@@@PAVSecurityEntry@Catalog@@@@QAAPAVSecurityEntry@Catalog@@XZ +??C?$AutoCleanup@V?$AutoDelete@VSendPacketArgs@RobustConnectionBuffer@@@@PAVSendPacketArgs@RobustConnectionBuffer@@@@QAAPAVSendPacketArgs@RobustConnectionBuffer@@XZ +??C?$AutoCleanup@V?$AutoDelete@VServiceSoapProcessor@@@@PAVServiceSoapProcessor@@@@QAAPAVServiceSoapProcessor@@XZ +??C?$AutoCleanup@V?$AutoDelete@VSubscriptionEnumerator@@@@PAVSubscriptionEnumerator@@@@QAAPAVSubscriptionEnumerator@@XZ +??C?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QAAPAVTSTRBUFFER@@XZ +??C?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QBAQAVTSTRBUFFER@@XZ +??C?$AutoCleanup@V?$AutoDelete@VUniqueStringOverflow@@@@PAVUniqueStringOverflow@@@@QAAPAVUniqueStringOverflow@@XZ +??C?$AutoCleanup@V?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@PAVWSMANCONFIGTABLE_IDENTITY@@@@QAAPAVWSMANCONFIGTABLE_IDENTITY@@XZ +??C?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QAAPAVWmiEnumContext@@XZ +??C?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QBAQAVWmiEnumContext@@XZ +??C?$AutoCleanup@V?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@@QAAPAVXmlReader@@XZ +??C?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QAAPAEXZ +??C?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QBAQAEXZ +??C?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QAAPAGXZ +??C?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QBAQAGXZ +??C?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QAAPAPAGXZ +??C?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QBAQAPAGXZ +??C?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QAAPAPBGXZ +??C?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QBAQAPBGXZ +??C?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAAPAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@XZ +??C?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QBAQAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@XZ +??C?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QAAPAU_WINRS_RUN_COMMAND_ARG@@XZ +??C?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QBAQAU_WINRS_RUN_COMMAND_ARG@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIAppHostChildElementCollection@@@@PAUIAppHostChildElementCollection@@@@QAAPAUIAppHostChildElementCollection@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIAppHostElementCollection@@@@PAUIAppHostElementCollection@@@@QAAPAUIAppHostElementCollection@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIAppHostProperty@@@@PAUIAppHostProperty@@@@QAAPAUIAppHostProperty@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIAppHostPropertyCollection@@@@PAUIAppHostPropertyCollection@@@@QAAPAUIAppHostPropertyCollection@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QAAPAUIClientSecurity@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QBAQAUIClientSecurity@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QAAPAUIEnumWbemClassObject@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QBAQAUIEnumWbemClassObject@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QAAPAUIErrorInfo@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QBAQAUIErrorInfo@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QAAPAUIUnknown@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QBAQAUIUnknown@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QAAPAUIWbemClassObject@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QBAQAUIWbemClassObject@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QAAPAUIWbemContext@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QBAQAUIWbemContext@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QAAPAUIWbemLocator@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QBAQAUIWbemLocator@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QAAPAUIWbemObjectTextSrc@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QBAQAUIWbemObjectTextSrc@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QAAPAUIWbemPath@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QBAQAUIWbemPath@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QAAPAUIWbemPathKeyList@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QBAQAUIWbemPathKeyList@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QAAPAUIWbemQualifierSet@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QBAQAUIWbemQualifierSet@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QAAPAUIWbemQuery@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QBAQAUIWbemQuery@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QAAPAUIWbemServices@@XZ +??C?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QBAQAUIWbemServices@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAAPAVCBaseConfigCache@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@@QAAPAVCClientConfigSettings@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@PAVCConfigCacheMap@CBaseConfigCache@@@@QAAPAVCConfigCacheMap@CBaseConfigCache@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@@QAAPAVCConfigManager@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCListenerReceive@@@@PAVCListenerReceive@@@@QAAPAVCListenerReceive@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@QAAPAVCRemoteSession@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@QBAQAVCRemoteSession@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@@QAAPAVCRequestContext@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCServiceCommonConfigSettings@@@@PAVCServiceCommonConfigSettings@@@@QAAPAVCServiceCommonConfigSettings@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCServiceConfigCache@@@@PAVCServiceConfigCache@@@@QAAPAVCServiceConfigCache@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCServiceConfigSettings@@@@PAVCServiceConfigSettings@@@@QAAPAVCServiceConfigSettings@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QAAPAVCWSManEPR@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QBAQAVCWSManEPR@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyCache@@@@PAVCWSManGroupPolicyCache@@@@QAAPAVCWSManGroupPolicyCache@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyManager@@@@PAVCWSManGroupPolicyManager@@@@QAAPAVCWSManGroupPolicyManager@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCWSManObject@@@@PAVCWSManObject@@@@QAAPAVCWSManObject@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@@QAAPAVCWSManResource@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QAAPAVCWinRSPluginConfigCache@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QBAQAVCWinRSPluginConfigCache@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigSettings@@@@PAVCWinRSPluginConfigSettings@@@@QAAPAVCWinRSPluginConfigSettings@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCommand@Client@WSMan@@@@PAVCommand@Client@WSMan@@@@QAAPAVCommand@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VConfigNotification@@@@PAVConfigNotification@@@@QAAPAVConfigNotification@@XZ +??C?$AutoCleanup@V?$AutoRelease@VConnectShellOperation@Client@WSMan@@@@PAVConnectShellOperation@Client@WSMan@@@@QAAPAVConnectShellOperation@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VCreateShellOperation@Client@WSMan@@@@PAVCreateShellOperation@Client@WSMan@@@@QAAPAVCreateShellOperation@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VDeleteShellOperation@Client@WSMan@@@@PAVDeleteShellOperation@Client@WSMan@@@@QAAPAVDeleteShellOperation@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VDisconnectOperation@Client@WSMan@@@@PAVDisconnectOperation@Client@WSMan@@@@QAAPAVDisconnectOperation@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAPAVEnumSinkEx@@XZ +??C?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QBAQAVEnumSinkEx@@XZ +??C?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAPAVGeneralSinkEx@@XZ +??C?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QBAQAVGeneralSinkEx@@XZ +??C?$AutoCleanup@V?$AutoRelease@VIPCSoapProcessor@@@@PAVIPCSoapProcessor@@@@QAAPAVIPCSoapProcessor@@XZ +??C?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QAAPAVIRequestContext@@XZ +??C?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QBAQAVIRequestContext@@XZ +??C?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@QAAPAVInboundRequestDetails@@XZ +??C?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@QBAQAVInboundRequestDetails@@XZ +??C?$AutoCleanup@V?$AutoRelease@VReceiveOperation@Client@WSMan@@@@PAVReceiveOperation@Client@WSMan@@@@QAAPAVReceiveOperation@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VReconnectOperation@Client@WSMan@@@@PAVReconnectOperation@Client@WSMan@@@@QAAPAVReconnectOperation@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VSendOperation@Client@WSMan@@@@PAVSendOperation@Client@WSMan@@@@QAAPAVSendOperation@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QAAPAVShell@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QBAQAVShell@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VSignalOperation@Client@WSMan@@@@PAVSignalOperation@Client@WSMan@@@@QAAPAVSignalOperation@Client@WSMan@@XZ +??C?$AutoCleanup@V?$AutoRelease@VUserRecord@@@@PAVUserRecord@@@@QAAPAVUserRecord@@XZ +??C?$AutoCleanup@V?$AutoRelease@VWSManHttpListener@@@@PAVWSManHttpListener@@@@QAAPAVWSManHttpListener@@XZ +??C?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QAAPAGXZ +??C?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QBAQAGXZ +??C?$AutoCleanup@VAutoChainContext@@PBU_CERT_CHAIN_CONTEXT@@@@QAAPBU_CERT_CHAIN_CONTEXT@@XZ +??C?$AutoCleanup@VAutoImpersonateUser@@PAX@@QAAPAXXZ +??C?$AutoCleanup@VAutoImpersonateUser@@PAX@@QBAQAXXZ +??C?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@QAAPAU_MI_Class@@XZ +??C?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QBAAAPAVExpiredOperationIdRecord@@XZ +??C?$SafeSet_Iterator@PAVCListenerOperation@@@@QBAABQAVCListenerOperation@@XZ +??D?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QBAAAVCertThumbprintMappedSet@CServiceConfigSettings@@XZ +??D?$SafeMap_Iterator@VKey@Locale@@K@@QBAAAKXZ +??D?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QBAAAPAVExpiredOperationIdRecord@@XZ +??D?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QBAAAPAVOptionValue@SessionOptions@Client@WSMan@@XZ +??D?$SafeSet_Iterator@PAVCCertMapping@@@@QBAABQAVCCertMapping@@XZ +??D?$SafeSet_Iterator@PAVCListenerOperation@@@@QBAABQAVCListenerOperation@@XZ +??D?$SafeSet_Iterator@PAVCShellUriSettings@@@@QBAABQAVCShellUriSettings@@XZ +??E?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@QAAXH@Z +??E?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@QAAXH@Z +??E?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@QAAXH@Z +??E?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QAAXH@Z +??E?$SafeMap_Iterator@VStringKeyCI@@K@@QAAXH@Z +??E?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@QAAXH@Z +??E?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QAAXH@Z +??E?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAAXH@Z +??_7?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@6B@ DATA +??_7?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@6B@ DATA +??_7?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@6B@ DATA +??_7?$SafeMap@PAVCollector@@UEmpty@@V?$SafeSet_Iterator@PAVCollector@@@@@@6B@ DATA +??_7?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeSet_Iterator@PAVHostOperation@@@@@@6B@ DATA +??_7?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeSet_Iterator@PAVIOperation@@@@@@6B@ DATA +??_7?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@6B@ DATA +??_7?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVPushSubscription@@@@@@6B@ DATA +??_7?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@6B@ DATA +??_7?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@6B@ DATA +??_7?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@6B@ DATA +??_7?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@6B@ DATA +??_7?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@6B@ DATA +??_7?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@6B@ DATA +??_7?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@6B@ DATA +??_7?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@6B@ DATA +??_7?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@6B@ DATA +??_7?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@6B@ DATA +??_7?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@6B@ DATA +??_7?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@6B@ DATA +??_7?$SafeSet@PAVCCertMapping@@@@6B@ DATA +??_7?$SafeSet@PAVCListenerOperation@@@@6B@ DATA +??_7?$SafeSet@PAVCShellUriSettings@@@@6B@ DATA +??_7?$SafeSet@PAX@@6B@ DATA +??_7BufferFormatter@@6B@ DATA +??_7CBaseConfigCache@@6BIConfigChangeObserver@@@ DATA +??_7CBaseConfigCache@@6BILifeTimeMgmt@@@ DATA +??_7CClientConfigCache@@6BIConfigChangeObserver@@@ DATA +??_7CClientConfigCache@@6BILifeTimeMgmt@@@ DATA +??_7CConfigManager@@6B@ DATA +??_7CErrorContext@@6B@ DATA +??_7CRequestContext@@6BCErrorContext@@@ DATA +??_7CRequestContext@@6BEtwCorrelationHelper@@@ DATA +??_7CServiceConfigCache@@6BIConfigChangeObserver@@@ DATA +??_7CServiceConfigCache@@6BILifeTimeMgmt@@@ DATA +??_7CWSManEPR@@6B@ DATA +??_7CWSManGroupPolicyManager@@6B@ DATA +??_7CWSManResource@@6B@ DATA +??_7CWSManResourceNoResourceUri@@6B@ DATA +??_7CWSManSecurityUI@@6B@ DATA +??_7CWinRSPluginConfigCache@@6BIConfigChangeObserver@@@ DATA +??_7CWinRSPluginConfigCache@@6BILifeTimeMgmt@@@ DATA +??_7CircularBufferFormatter@@6B@ DATA +??_7EtwCorrelationHelper@@6B@ DATA +??_7IConfigChangeObserver@@6B@ DATA +??_7ILifeTimeMgmt@@6B@ DATA +??_7IRequestContext@@6B@ DATA +??_7IWSManGroupPolicyObserver@@6B@ DATA +??_7IWSManGroupPolicyPublisher@@6B@ DATA +??_7PacketParser@@6B@ DATA +??_7UserAuthzRecord@@6B@ DATA +??_7UserRecord@@6B@ DATA +??_FCErrorContext@@QAAXXZ +??_FRBUFFER@@QAAXXZ +?Acquire@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCListenerConnect@@PAV1@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCListenerReceive@@PAV1@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCListenerSend@@PAV1@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCListenerSignal@@PAV1@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCollector@@UEmpty@@V?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVCollector@@UEmpty@@V?$SafeSet_Iterator@PAVCollector@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeSet_Iterator@PAVHostOperation@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeSet_Iterator@PAVIOperation@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVPushSubscription@@@@@@UBAXXZ +?Acquire@?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@UBAXXZ +?Acquire@?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@UBAXXZ +?Acquire@?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@UBAXXZ +?Acquire@?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@UBAXXZ +?Acquire@?$SafeMap@VGuidKey@@PAVCListenerCommand@@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@UBAXXZ +?Acquire@?$SafeMap@VKey@CWmiPtrCache@@VMapping@2@V?$SafeMap_Iterator@VKey@CWmiPtrCache@@VMapping@2@@@@@UBAXXZ +?Acquire@?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKey@@PAVListenerEvents@@V?$SafeMap_Iterator@VStringKey@@PAVListenerEvents@@@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKey@@PAVListenerSourceSubscription@@V?$SafeMap_Iterator@VStringKey@@PAVListenerSourceSubscription@@@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKey@@UOption@WinRM_OperationOptions@@V?$SafeMap_Iterator@VStringKey@@UOption@WinRM_OperationOptions@@@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKeyCI@@PAVIISEndpoint@@V?$SafeMap_Iterator@VStringKeyCI@@PAVIISEndpoint@@@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@UBAXXZ +?Acquire@?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@UBAXXZ +?Acquire@?$SafeMap@VTokenCacheKey@ServiceSoapProcessor@@VTokenCacheMapping@2@V?$SafeMap_Iterator@VTokenCacheKey@ServiceSoapProcessor@@VTokenCacheMapping@2@@@@@UBAXXZ +?Acquire@?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@UBAXXZ +?Acquire@?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@UBAXXZ +?Acquire@?$SafeMap_Lock@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@PAXUEmpty@@V?$SafeMap_Iterator@PAXUEmpty@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAAXXZ +?Acquire@?$SafeMap_Lock@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAAXXZ +?Acquire@CWSManCriticalSection@@QAAXXZ +?AcquireExclusive@FastLock@@QAAXXZ +?AcquireShared@FastLock@@QAAXXZ +?Acquired@?$SafeMap_Lock@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVCListenerConnect@@PAV1@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVCListenerReceive@@PAV1@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVCListenerSend@@PAV1@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVCListenerSignal@@PAV1@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVCollector@@UEmpty@@V?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVHostOperation@@UEmpty@@V?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVIOperation@@UEmpty@@V?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVListenerSourceSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAVPushSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@PAXUEmpty@@V?$SafeMap_Iterator@PAXUEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@VGuidKey@@PAVCListenerCommand@@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@VStringKeyCI@@UEmpty@@V?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA_NXZ +?Acquired@?$SafeMap_Lock@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAA_NXZ +?Add@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@QAA_NABQAVCCertMapping@@ABUEmpty@@AAVIRequestContext@@@Z +?Add@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA_NABQAVCListenerOperation@@ABUEmpty@@AAVIRequestContext@@@Z +?Add@?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@QAA_NABQAVCShellUriSettings@@ABUEmpty@@AAVIRequestContext@@@Z +?Add@?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@QAA_NABQAXABUEmpty@@AAVIRequestContext@@@Z +?Add@?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAA_NABUPluginKey@@ABKAAVIRequestContext@@@Z +?Add@?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAA_NABUUserKey@@ABQAVBlockedRecord@@AAVIRequestContext@@@Z +?Add@?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAA_NABVCertThumbprintKey@@ABVCertThumbprintMappedSet@CServiceConfigSettings@@AAVIRequestContext@@@Z +?Add@?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@QAA_NABVKey@Locale@@ABKAAVIRequestContext@@@Z +?Add@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA_NABVStringKeyCI@@ABKAAVIRequestContext@@@Z +?Add@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@QAA_NABVStringKeyCI@@ABUEmpty@@AAVIRequestContext@@@Z +?Add@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAA_NABVStringKeyCI@@ABUUSER_CONTEXT_INFO@WSManHttpListener@@AAVIRequestContext@@@Z +?Add@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAA_NABVStringKeyStore@@ABQAVExpiredOperationIdRecord@@AAVIRequestContext@@@Z +?Add@?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAA_NABVStringKeyStore@@ABQAVServerFullDuplexChannel@@AAVIRequestContext@@@Z +?Add@?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAA_NABW4WSManSessionOption@@ABQAVOptionValue@SessionOptions@Client@WSMan@@AAVIRequestContext@@@Z +?Add@?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAA_NAB_KABQAVSendPacketArgs@RobustConnectionBuffer@@AAVIRequestContext@@@Z +?Add@?$SafeSet@PAVCCertMapping@@@@QAA_NABQAVCCertMapping@@AAVIRequestContext@@@Z +?Add@?$SafeSet@PAVCListenerOperation@@@@QAA_NABQAVCListenerOperation@@AAVIRequestContext@@@Z +?Add@?$SafeSet@PAVCShellUriSettings@@@@QAA_NABQAVCShellUriSettings@@AAVIRequestContext@@@Z +?Add@?$SafeSet@PAX@@QAA_NABQAXAAVIRequestContext@@@Z +?Add@?$SafeSet@VStringKeyCI@@@@QAA_NABVStringKeyCI@@AAVIRequestContext@@@Z +?AddDefaultPlugins@ConfigUpdate@@SAHPAVIRequestContext@@H@Z +?AddKey@CWSManResourceNoResourceUri@@QAAHPBG0PAVIRequestContext@@@Z +?AddMessage@CRequestContext@@AAAHPBGPAPAD1@Z +?AddOption@CWSManResourceNoResourceUri@@QAAHPBG0HPAVIRequestContext@@@Z +?AddOptionSet@CWSManResourceNoResourceUri@@QAAHPAU_WSMAN_OPTION_SET@@PAVIRequestContext@@@Z +?AddPacket@PacketParser@@QAA_NPAVPacket@@_N11@Z +?AddRef@CWSManSecurityUI@@UAAKXZ +?AddRef@ILifeTimeMgmt@@UAAJXZ +?AddRef@UserRecord@@QAA_NAAVIRequestContext@@@Z +?AddSource@CBaseConfigCache@@IAAHPAVIRequestContext@@PAVCConfigChangeSource@@@Z +?AddToMap@CBaseConfigCache@@AAAHPAVIRequestContext@@AAVAutoLocalFree@@@Z +?Alloc@WSManMemory@@SAPAXIHW4_NitsFaultMode@@@Z +?AllocBstr@WSManMemory@@SAPAGPBGHH@Z +?AllocBstrLen@WSManMemory@@SAPAGPBGIHH@Z +?AllocCache@CClientConfigCache@@CAPAVCBaseConfigCache@@XZ +?AllocCache@CServiceConfigCache@@CAPAVCBaseConfigCache@@XZ +?AllocCache@CWinRSPluginConfigCache@@CAPAVCBaseConfigCache@@XZ +?AllocSysString@TSTRBUFFER@@QBAJPAPAG@Z +?AllowBasic@CCommonConfigSettings@@UBAHXZ +?AllowClientCertificate@CCommonConfigSettings@@UBAHXZ +?AllowCredSsp@CCommonConfigSettings@@UBAHXZ +?AllowKerberos@CCommonConfigSettings@@UBAHXZ +?AllowNegotiate@CCommonConfigSettings@@UBAHXZ +?AllowUnencrypted@CCommonConfigSettings@@UBAHXZ +?Append@SBUFFER@@QAAJPAEI@Z +?Append@SBUFFER@@QAAJPAV1@@Z +?Append@TSTRBUFFER@@QAAJPBG@Z +?Append@TSTRBUFFER@@QAAJPBGII@Z +?AppendChar@TSTRBUFFER@@QAAJG@Z +?AppendEscapeXmlAttribute@TSTRBUFFER@@QAAJPBGG@Z +?AppendEscapeXmlContent@TSTRBUFFER@@QAAJPBG_N@Z +?AppendXmlElem@TSTRBUFFER@@QAAJPBG0HKPAU_XML_ATTRIB@@@Z +?AppendXmlElemWithNamespace@TSTRBUFFER@@QAAJPBG00HKPAU_XML_ATTRIB@@@Z +?AppendXmlElemWithNamespaceAndPrefix@TSTRBUFFER@@QAAJPBG000HKPAU_XML_ATTRIB@@@Z +?AppendXmlElemWithPrefix@TSTRBUFFER@@QAAJPBG00HKPAU_XML_ATTRIB@@@Z +?AppendXmlEndElem@TSTRBUFFER@@QAAJPBG@Z +?AppendXmlEndElemWithPrefix@TSTRBUFFER@@QAAJPBG0@Z +?AppendXmlEndFragment@TSTRBUFFER@@QAAJXZ +?AppendXmlEndItem@TSTRBUFFER@@QAAJXZ +?AppendXmlStartElem@TSTRBUFFER@@QAAJPBGHKPAU_XML_ATTRIB@@@Z +?AppendXmlStartElemWithNamespace@TSTRBUFFER@@QAAJPBG0HKPAU_XML_ATTRIB@@@Z +?AppendXmlStartElemWithNamespaceAndPrefix@TSTRBUFFER@@QAAJPBG00HKPAU_XML_ATTRIB@@@Z +?AppendXmlStartElemWithNamespaces@TSTRBUFFER@@QAAJPBGKPAU_XML_NAMESPACE_PREFIX@@HKPAU_XML_ATTRIB@@@Z +?AppendXmlStartElemWithNamespacesAndPrefixes@TSTRBUFFER@@QAAJPBG0KPAU_XML_NAMESPACE_PREFIX@@HKPAU_XML_ATTRIB@@@Z +?AppendXmlStartElemWithPrefix@TSTRBUFFER@@QAAJPBG0HKPAU_XML_ATTRIB@@@Z +?AppendXmlStartFragment@TSTRBUFFER@@QAAJXZ +?AppendXmlStartItem@TSTRBUFFER@@QAAJXZ +?ApplyQuota@UserRecord@@QAA_NW4OperationType@@AAVIRequestContext@@PBVProvider@Catalog@@PAVCServiceConfigSettings@@@Z +?ApplySecurity@ConfigRegistry@@IAAHPAVIRequestContext@@PAUHKEY__@@PBG2@Z +?AsReference@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAAAAV1@XZ +?AsReference@?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAAAAV1@XZ +?AuthzComplete@UserRecord@@UAAKPAX0W4AdministratorType@UserAuthzRecord@@KPBG@Z +?BOMS@PacketFormatter@@0QBUBOMInfo@1@B DATA +?BeginRevertToSelf@CSecurity@@SAHPAPAXK@Z +?BuildFragmentTransfer@CWSManResourceNoResourceUri@@UAAHAAVBufferFormatter@@@Z +?BuildOptionSet@CWSManResourceNoResourceUri@@QAAHAAVBufferFormatter@@@Z +?BuildSelectorSet@CWSManEPR@@UAAHAAVBufferFormatter@@@Z +?BuildSelectorSet@CWSManResourceNoResourceUri@@UAAHAAVBufferFormatter@@@Z +?CHARSETS@PacketFormatter@@0QBUCharsetInfo@1@B DATA +?ChangeLogging@CServiceConfigCache@@QAAXW4ErrorLogging@@@Z +?CheckSharedSSLConfiguration@ConfigRegistry@@IAAHPAVIRequestContext@@PBG1HPAH@Z +?Clear@?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QAAXXZ +?Clear@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAAXXZ +?Clear@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAAXXZ +?Clear@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAAXXZ +?ClearKeys@CWSManResourceNoResourceUri@@QAAHXZ +?ClearOptions@CWSManResourceNoResourceUri@@QAAHXZ +?ClearRegistryKeys@ConfigRegistry@@IAAHPAVIRequestContext@@@Z +?ClearSubKeys@@YAHPAUHKEY__@@PAVIRequestContext@@@Z +?CompleteWithErrorContext@CRequestContext@@QAAXPAU_WSMAN_PLUGIN_REQUEST@@@Z +?Confirm@ExtendedSemantic@@2KB +?Copy@TSTRBUFFER@@QAAJPBG@Z +?CopyString@@YAPAGPAVIRequestContext@@W4CallSiteId@@PBG@Z +?CopyString@@YAPAGPBGABHAAVIRequestContext@@@Z +?CopyString@MessageId@PacketParser@@QAAKPBGH@Z +?CopyTo@CErrorContext@@UBAXPAVIRequestContext@@@Z +?CopyTo@CRequestContext@@UBAXPAVIRequestContext@@@Z +?CreateActivityId@EventHandler@WSMan@@SAXAAU_GUID@@@Z +?CreateAnEvent@SoapSemanticConverter@@QAAKKPAVSemanticMessage@@AAVBufferFormatter@@PAVIRequestContext@@@Z +?CreateAutoConfiguredListener@CConfigManager@@AAAHPAVIRequestContext@@PAVLISTENER_IDENTITY@@@Z +?CreateInstance@?$ILoader@VAdminSid@CSecurity@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VCredUIDllLoader@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VEventHandler@WSMan@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VInteractiveSid@CSecurity@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VIpHlpApiDllLoader@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VMachineName@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VNetworkServiceSid@CSecurity@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VNtDsApiDllLoader@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VResources@Locale@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VShell32DllLoader@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VShlWApiDllLoader@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VSubscriptionManager@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VUser32DllLoader@@@@IAA_NAAVIRequestContext@@@Z +?CreateInstance@?$ILoader@VWSManMemCryptManager@@@@IAA_NAAVIRequestContext@@@Z +?CreateKey@ConfigRegistry@@IAAHPAVIRequestContext@@PBGPAPAUHKEY__@@1KPAK@Z +?CreateNew@CBaseConfigCache@@CAPAV1@PAVIRequestContext@@PAVCConfigCacheMap@1@P6APAV1@XZW4ErrorLogging@@H@Z +CreateProvHost +?CreateRenderingInformation@CWSManSecurityUI@@AAAHPAVIRequestContext@@@Z +?CreateResponse@SoapSemanticConverter@@QAAKKW4_MI_OperationCallback_ResponseType@@AAVBufferFormatter@@PAVIRequestContext@@@Z +?CreateSessionGuid@SessionId@PacketParser@@QAAKPBGH@Z +?Data@?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@IBAAAV?$STLMap@PAVCCertMapping@@UEmpty@@@@XZ +?Data@?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@IBAAAV?$STLMap@PAVCListenerOperation@@UEmpty@@@@XZ +?Data@?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@IBAAAV?$STLMap@PAVCShellUriSettings@@UEmpty@@@@XZ +?Data@?$SafeMap_Iterator@PAXUEmpty@@@@IBAAAV?$STLMap@PAXUEmpty@@@@XZ +?Data@?$SafeMap_Iterator@UPluginKey@@K@@IBAAAV?$STLMap@UPluginKey@@K@@XZ +?Data@?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@IBAAAV?$STLMap@UUserKey@@PAVBlockedRecord@@@@XZ +?Data@?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@IBAAAV?$STLMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@XZ +?Data@?$SafeMap_Iterator@VKey@Locale@@K@@IBAAAV?$STLMap@VKey@Locale@@K@@XZ +?Data@?$SafeMap_Iterator@VStringKeyCI@@K@@IBAAAV?$STLMap@VStringKeyCI@@K@@XZ +?Data@?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@IBAAAV?$STLMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@XZ +?Data@?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@IBAAAV?$STLMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@XZ +?Data@?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@IBAAAV?$STLMap@VStringKeyStore@@PAVServerFullDuplexChannel@@@@XZ +?Data@?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@IBAAAV?$STLMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@XZ +?Data@?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@IBAAAV?$STLMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@XZ +?DeInitialize@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCListenerConnect@@PAV1@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCListenerReceive@@PAV1@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCListenerSend@@PAV1@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCListenerSignal@@PAV1@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCollector@@UEmpty@@V?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVCollector@@UEmpty@@V?$SafeSet_Iterator@PAVCollector@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeSet_Iterator@PAVHostOperation@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeSet_Iterator@PAVIOperation@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVPushSubscription@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VGuidKey@@PAVCListenerCommand@@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VKey@CWmiPtrCache@@VMapping@2@V?$SafeMap_Iterator@VKey@CWmiPtrCache@@VMapping@2@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKey@@PAVListenerEvents@@V?$SafeMap_Iterator@VStringKey@@PAVListenerEvents@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKey@@PAVListenerSourceSubscription@@V?$SafeMap_Iterator@VStringKey@@PAVListenerSourceSubscription@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKey@@UOption@WinRM_OperationOptions@@V?$SafeMap_Iterator@VStringKey@@UOption@WinRM_OperationOptions@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKeyCI@@PAVIISEndpoint@@V?$SafeMap_Iterator@VStringKeyCI@@PAVIISEndpoint@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@VTokenCacheKey@ServiceSoapProcessor@@VTokenCacheMapping@2@V?$SafeMap_Iterator@VTokenCacheKey@ServiceSoapProcessor@@VTokenCacheMapping@2@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@UAA_NAAVIRequestContext@@@Z +?DeInitialize@CWSManGroupPolicyManager@@AAAHXZ +?DeInitialize@EventHandler@WSMan@@QAA_NAAVIRequestContext@@@Z +?Debug@ExtendedSemantic@@2KB +?Decode@PacketFormatter@@QBAKPAPAVPacket@@@Z +?DecodeFaultObject@CRequestContext@@AAAKPAU_FWXML_ELEMENT@@AAPBG11@Z +?DecodeFaultObject@CRequestContext@@AAAKPBGKAAPBG11@Z +?DecodeFaultObjectProvider@CRequestContext@@AAAKPAU_FWXML_ELEMENT@@AAPBG1@Z +?DecodeFaultObjectProviderMessage@CRequestContext@@AAAKPAU_FWXML_ELEMENT@@AAPBG@Z +?DecodeFaultReason@CRequestContext@@AAAKPAU_FWXML_ELEMENT@@AAPBG@Z +?DecreaseProfileCount@UserRecord@@QAAXXZ +?DeleteConfigKey@ConfigRegistry@@KAHPAVIRequestContext@@PBG1H@Z +?DeleteCredentialsFromCredmanStore@CConfigManager@@SAHPAVIRequestContext@@PAG@Z +?DeleteKey@@YAHPAVIRequestContext@@PBG1@Z +?DeleteKey@ConfigRegistry@@KAHPAVIRequestContext@@PBGH@Z +?DeleteSubkeys@ConfigRegistry@@KAHPAVIRequestContext@@PAUHKEY__@@PBGHH@Z +?DeleteValues@ConfigRegistry@@KAHPAVIRequestContext@@PAUHKEY__@@@Z +?Detach@?$AutoCleanup@V?$AutoDelete@G@@PAG@@QAAPAGXZ +?Detach@?$AutoCleanup@V?$AutoDelete@UIPRange@CWSManIPFilter@@@@PAUIPRange@CWSManIPFilter@@@@QAAPAUIPRange@CWSManIPFilter@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@PAU_WSMAN_STREAM_ID_SET@@@@QAAPAU_WSMAN_STREAM_ID_SET@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@V?$Handle@VISubscription@@@@@@PAV?$Handle@VISubscription@@@@@@QAAPAV?$Handle@VISubscription@@@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@@QAAPAV?$SafeSet@PAVCCertMapping@@@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@@QAAPAV?$SafeSet@PAVCShellUriSettings@@@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@QAAPAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VAdminSid@CSecurity@@@@PAVAdminSid@CSecurity@@@@QAAPAVAdminSid@CSecurity@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VBlockedRecord@@@@PAVBlockedRecord@@@@QAAPAVBlockedRecord@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAAPAVCBaseConfigCache@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VCCertMapping@@@@PAVCCertMapping@@@@QAAPAVCCertMapping@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VCListenerSettings@@@@PAVCListenerSettings@@@@QAAPAVCListenerSettings@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@PAVCServiceWatcher@CServiceConfigCache@@@@QAAPAVCServiceWatcher@CServiceConfigCache@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VCShellUriSettings@@@@PAVCShellUriSettings@@@@QAAPAVCShellUriSettings@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VCWSManEPR@@@@PAVCWSManEPR@@@@QAAPAVCWSManEPR@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VCWSManResource@@@@PAVCWSManResource@@@@QAAPAVCWSManResource@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VCertHash@@@@PAVCertHash@@@@QAAPAVCertHash@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@@QAAPAVConfigUpdate@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VCredUIDllLoader@@@@PAVCredUIDllLoader@@@@QAAPAVCredUIDllLoader@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAPAVEnumSinkEx@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VEventHandler@WSMan@@@@PAVEventHandler@WSMan@@@@QAAPAVEventHandler@WSMan@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VExpiredOperationIdRecord@@@@PAVExpiredOperationIdRecord@@@@QAAPAVExpiredOperationIdRecord@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAPAVGeneralSinkEx@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QAAPAVIQueryDASHSMASHInterface@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QAAPAVISpecification@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VInteractiveSid@CSecurity@@@@PAVInteractiveSid@CSecurity@@@@QAAPAVInteractiveSid@CSecurity@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VIpHlpApiDllLoader@@@@PAVIpHlpApiDllLoader@@@@QAAPAVIpHlpApiDllLoader@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VMachineName@@@@PAVMachineName@@@@QAAPAVMachineName@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VNetworkServiceSid@CSecurity@@@@PAVNetworkServiceSid@CSecurity@@@@QAAPAVNetworkServiceSid@CSecurity@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VNtDsApiDllLoader@@@@PAVNtDsApiDllLoader@@@@QAAPAVNtDsApiDllLoader@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAAPAVOptionValue@SessionOptions@Client@WSMan@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VResources@Locale@@@@PAVResources@Locale@@@@QAAPAVResources@Locale@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VSecurityEntry@Catalog@@@@PAVSecurityEntry@Catalog@@@@QAAPAVSecurityEntry@Catalog@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VServiceSoapProcessor@@@@PAVServiceSoapProcessor@@@@QAAPAVServiceSoapProcessor@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VShell32DllLoader@@@@PAVShell32DllLoader@@@@QAAPAVShell32DllLoader@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VShlWApiDllLoader@@@@PAVShlWApiDllLoader@@@@QAAPAVShlWApiDllLoader@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VSubscriptionManager@@@@PAVSubscriptionManager@@@@QAAPAVSubscriptionManager@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QAAPAVTSTRBUFFER@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VUser32DllLoader@@@@PAVUser32DllLoader@@@@QAAPAVUser32DllLoader@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VWSManMemCryptManager@@@@PAVWSManMemCryptManager@@@@QAAPAVWSManMemCryptManager@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QAAPAVWmiEnumContext@@XZ +?Detach@?$AutoCleanup@V?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@@QAAPAVXmlReader@@XZ +?Detach@?$AutoCleanup@V?$AutoDeleteVector@$$CBG@@PBG@@QAAPBGXZ +?Detach@?$AutoCleanup@V?$AutoDeleteVector@D@@PAD@@QAAPADXZ +?Detach@?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QAAPAEXZ +?Detach@?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QAAPAGXZ +?Detach@?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QAAPAPAGXZ +?Detach@?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QAAPAPBGXZ +?Detach@?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAAPAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@XZ +?Detach@?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QAAPAU_WINRS_RUN_COMMAND_ARG@@XZ +?Detach@?$AutoCleanup@V?$AutoDeleteVector@U_WSMAN_OPTION@@@@PAU_WSMAN_OPTION@@@@QAAPAU_WSMAN_OPTION@@XZ +?Detach@?$AutoCleanup@V?$AutoFree@E@@PAE@@QAAPAEXZ +?Detach@?$AutoCleanup@V?$AutoLocklessItemRecycle@VPacket@@@@PAVPacket@@@@QAAPAVPacket@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QAAPAUIClientSecurity@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QAAPAUIEnumWbemClassObject@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QAAPAUIErrorInfo@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QAAPAUIUnknown@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QAAPAUIWbemClassObject@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QAAPAUIWbemContext@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QAAPAUIWbemLocator@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QAAPAUIWbemObjectTextSrc@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QAAPAUIWbemPath@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QAAPAUIWbemPathKeyList@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QAAPAUIWbemQualifierSet@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QAAPAUIWbemQuery@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QAAPAUIWbemServices@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VApplication@Client@WSMan@@@@PAVApplication@Client@WSMan@@@@QAAPAVApplication@Client@WSMan@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@QAAPAVCBaseConfigCache@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@@QAAPAVCClientConfigSettings@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCCommonConfigSettings@@@@PAVCCommonConfigSettings@@@@QAAPAVCCommonConfigSettings@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@@QAAPAVCConfigManager@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@QAAPAVCRemoteSession@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@@QAAPAVCRequestContext@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCServiceConfigSettings@@@@PAVCServiceConfigSettings@@@@QAAPAVCServiceConfigSettings@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QAAPAVCWSManEPR@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyCache@@@@PAVCWSManGroupPolicyCache@@@@QAAPAVCWSManGroupPolicyCache@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyManager@@@@PAVCWSManGroupPolicyManager@@@@QAAPAVCWSManGroupPolicyManager@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCWSManObject@@@@PAVCWSManObject@@@@QAAPAVCWSManObject@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QAAPAVCWinRSPluginConfigCache@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigSettings@@@@PAVCWinRSPluginConfigSettings@@@@QAAPAVCWinRSPluginConfigSettings@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VCommand@Client@WSMan@@@@PAVCommand@Client@WSMan@@@@QAAPAVCommand@Client@WSMan@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAPAVEnumSinkEx@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAPAVGeneralSinkEx@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VIPCSoapProcessor@@@@PAVIPCSoapProcessor@@@@QAAPAVIPCSoapProcessor@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QAAPAVIRequestContext@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VReceiveOperation@Client@WSMan@@@@PAVReceiveOperation@Client@WSMan@@@@QAAPAVReceiveOperation@Client@WSMan@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VSendOperation@Client@WSMan@@@@PAVSendOperation@Client@WSMan@@@@QAAPAVSendOperation@Client@WSMan@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QAAPAVShell@Client@WSMan@@XZ +?Detach@?$AutoCleanup@V?$AutoRelease@VSignalOperation@Client@WSMan@@@@PAVSignalOperation@Client@WSMan@@@@QAAPAVSignalOperation@Client@WSMan@@XZ +?Detach@?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QAAPAGXZ +?Detach@?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@QAAPBU_CERT_CONTEXT@@XZ +?Detach@?$AutoCleanup@VAutoHandle@@PAX@@QAAPAXXZ +?Detach@?$AutoCleanup@VAutoImpersonateUser@@PAX@@QAAPAXXZ +?Detach@?$AutoCleanup@VAutoLocalFree@@PAX@@QAAPAXXZ +?Detach@?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@QAAPAU_MI_Class@@XZ +?Detach@?$AutoCleanup@VAutoMIInstance@@PAU_MI_Instance@@@@QAAPAU_MI_Instance@@XZ +?Detach@?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@QAAPAUHKEY__@@XZ +?Detach@?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@QAAPAXXZ +?Detach@?$AutoCleanup@VAutoWaitHandle@@PAX@@QAAPAXXZ +?Detach@BufferFormatter@@QAAPAEXZ +?Discard@CServiceWatcher@CServiceConfigCache@@QAAXXZ +?DoOnChange@CBaseConfigCache@@IAAXW4ConfigChangeSources@@KW4ConfigChangeSeverityType@@@Z +?DoesThreadOwnLock@CWSManCriticalSection@@QAAHXZ +?Down@?$LoaderSerializer@VSubscriptionManager@@$01@@AAAJXZ +?DropData@CircularBufferFormatter@@QAAXK@Z +?DuplicateCurrentToken@CSecurity@@SAHPAPAXKPAU_SECURITY_ATTRIBUTES@@W4_SECURITY_IMPERSONATION_LEVEL@@W4_TOKEN_TYPE@@H@Z +?EnableAllPrivileges@@YAHPAPAE@Z +?Encode@PacketFormatter@@QBAKPAPAVPacket@@@Z +?Encode@PacketFormatter@@QBAKPBGKPAEKPAPAEPAK_N@Z +?EndOfStream@PacketParser@@QAAXK@Z +?EndRevertToSelf@CSecurity@@SAHPAX@Z +?EnsureActivityIdOnThread@EventHandler@WSMan@@SAXXZ +?EnsureNoActiveCaches@CClientConfigCache@@SAXXZ +?EnsureNoActiveCaches@CServiceConfigCache@@SAXXZ +?Error@EventLog@@SAXK@Z +?Error@EventLog@@SAXKGPAPBG@Z +?Error@EventLog@@SAXKPBG@Z +?ErrorAction@ExtendedSemantic@@2KB +?EventEnabled@EventHandler@WSMan@@AAA_NABU_EVENT_DESCRIPTOR@@@Z +?EventProviderEnabled@EventHandler@WSMan@@AAA_NXZ +?EventWrite@EventHandler@WSMan@@AAAXABU_EVENT_DESCRIPTOR@@KPAU_EVENT_DATA_DESCRIPTOR@@@Z +?ExtractContextId@PacketParser@@QAAHPAPBGKPBG@Z +?ExtractShellId@PacketParser@@QAAHPAVCRequestContext@@PAGK@Z +?ExtractSidFromToken@CSecurity@@SAHPAVIRequestContext@@PAXAAVAutoLocalFree@@@Z +?FindExisting@CBaseConfigCache@@CAPAV1@PAVCConfigCacheMap@1@PBGW4ErrorLogging@@@Z +?FindMatch@CResourceAlias@@AAAPAU_ALIAS_INFORMATION@@PBG@Z +?First@TSTRBUFFER@@QBAPBGXZ +?Format@Locale@@ABA_NKPAPADPAPAXPAGKGW4CallSiteId@@@Z +?FormatDataDescriptor@EventHandler@WSMan@@SAXAAU_EVENT_DATA_DESCRIPTOR@@AAG@Z +?FormatDataDescriptor@EventHandler@WSMan@@SAXAAU_EVENT_DATA_DESCRIPTOR@@AAJ@Z +?FormatDataDescriptor@EventHandler@WSMan@@SAXAAU_EVENT_DATA_DESCRIPTOR@@AAK@Z +?FormatDataDescriptor@EventHandler@WSMan@@SAXAAU_EVENT_DATA_DESCRIPTOR@@PBD@Z +?FormatDataDescriptor@EventHandler@WSMan@@SAXAAU_EVENT_DATA_DESCRIPTOR@@PBG@Z +?FormatWithFallback@Locale@@ABA_NKPAPAD0PAPAXPAGK@Z +?Free@WSManMemory@@SAXPAXH@Z +?FreeBstr@WSManMemory@@SAXPAGHH@Z +?FreeInstance@?$ILoader@VAdminSid@CSecurity@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VCredUIDllLoader@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VEventHandler@WSMan@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VInteractiveSid@CSecurity@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VIpHlpApiDllLoader@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VMachineName@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VNetworkServiceSid@CSecurity@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VNtDsApiDllLoader@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VResources@Locale@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VShell32DllLoader@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VShlWApiDllLoader@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VSubscriptionManager@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VUser32DllLoader@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$ILoader@VWSManMemCryptManager@@@@QAA_NAAVIRequestContext@@_N@Z +?FreeInstance@?$LoaderSerializer@VSubscriptionManager@@$01@@QAA_NAAVIRequestContext@@_N@Z +?FreeMemory@RBUFFER@@QAAXXZ +?FreeMemory@SBUFFER@@QAAXXZ +?FreePacket@PacketParser@@QAAXXZ +?FreeXmlStructure@PacketParser@@QAAXXZ +?GenerateTransferId@EventHandler@WSMan@@SAXABU_EVENT_DESCRIPTOR@@PBU_GUID@@1@Z +?GenerateTransferIdImp@EventHandler@WSMan@@AAAXABU_EVENT_DESCRIPTOR@@PBU_GUID@@1@Z +?GetAccessRights@CWSManSecurityUI@@UAAJPBU_GUID@@KPAPAU_SI_ACCESS@@PAK2@Z +?GetAction@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetActionType@SoapSemanticConverter@@AAA_NPBGPAW4_MI_OperationCallback_ResponseType@@PAW4_MI_CallbackMode@@PAVIRequestContext@@@Z +?GetActivityIdOnCurrentThread@EventHandler@WSMan@@SAXAAU_GUID@@@Z +?GetBaseUri@CWSManResource@@QAAPBGXZ +?GetBomIndex@PacketFormatter@@QBA?AW4Charset@1@XZ +?GetBookmarkXml@PacketParser@@QAAABV?$PacketElement@PAU_FWXML_ELEMENT@@@1@XZ +?GetBool@CConfigManager@@QAAHPAVIRequestContext@@W4ConfigSetting@@PAHPAW4WSManConfigSource@@@Z +?GetBool@CWSManGroupPolicyManager@@QAAHPAVIRequestContext@@W4WSManGroupPolicySetting@@PAHPAW4WSManGroupPolicySettingState@@@Z +?GetBuffer@BufferFormatter@@UAAPAEXZ +?GetBuffer@BufferFormatter@@UBAPBEXZ +?GetBuffer@CircularBufferFormatter@@UAAPAEXZ +?GetBuffer@CircularBufferFormatter@@UBAPBEXZ +?GetBuffer@XmlReader@@QAAPBGXZ +?GetBufferLength@PacketParser@@UAAKXZ +?GetBufferPtr@PacketParser@@UAAPAPAGXZ +?GetBufferSize@BufferFormatter@@QBAKXZ +?GetCacheCount@CClientConfigCache@@SAKXZ +?GetCacheCount@CServiceConfigCache@@SAKXZ +?GetCalculationSize@BufferFormatter@@UBAK_N@Z +?GetCalculationSize@CircularBufferFormatter@@UBAK_N@Z +?GetCharInUse@TSTRBUFFER@@QBAIXZ +?GetCharset@PacketFormatter@@QBA?AW4Charset@1@XZ +?GetCharsetLen@PacketFormatter@@QBAKXZ +?GetCharsetName@PacketFormatter@@QBAPBDXZ +?GetChildCount@ChildLifeTimeManager@@QBAJXZ +?GetConfigCache@CBaseConfigCache@@KAPAV1@PAVIRequestContext@@W4ErrorLogging@@P6APAV1@XZPAVFastLock@@AAV?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@H@Z +?GetConfigCache@CClientConfigCache@@SAPAV1@PAVIRequestContext@@H@Z +?GetConfigCache@CServiceConfigCache@@SAPAV1@PAVIRequestContext@@W4ErrorLogging@@H@Z +?GetConfigCache@CWinRSPluginConfigCache@@SAPAV1@PAVIRequestContext@@W4ErrorLogging@@H@Z +?GetConfigManager@CConfigManager@@SAPAV1@XZ +?GetConfigManagerForCertMapping@CConfigManager@@SAPAV1@PAVCERTMAPPING_IDENTITY@@PAVIRequestContext@@@Z +?GetConfigManagerForListener@CConfigManager@@SAPAV1@PAVLISTENER_IDENTITY@@PAVIRequestContext@@@Z +?GetConfigManagerForShellUri@CConfigManager@@SAPAV1@PAVSHELLURI_IDENTITY@@PAVIRequestContext@@@Z +?GetConfigManagerForTable@CConfigManager@@SAPAV1@PAVWSMANCONFIGTABLE_IDENTITY@@PAVIRequestContext@@@Z +?GetConfigXml@CConfigManager@@QAAHPAVIRequestContext@@PAPBGPAPAVXmlReader@@PAH@Z +?GetCorrelationId@PacketParser@@QAAAAU_GUID@@XZ +?GetCurrentCertMappingIdentity@CConfigManager@@QAAHPAVCERTMAPPING_IDENTITY@@PAVIRequestContext@@@Z +?GetCurrentListenerIdentity@CConfigManager@@QAAHPAVLISTENER_IDENTITY@@PAVIRequestContext@@@Z +?GetCurrentSettings@CBaseConfigCache@@IAAPAVCCommonConfigSettings@@PAVIRequestContext@@@Z +?GetCurrentSettings@CClientConfigCache@@QAAPAVCClientConfigSettings@@PAVIRequestContext@@@Z +?GetCurrentSettings@CServiceConfigCache@@QAAPAVCServiceConfigSettings@@PAVIRequestContext@@@Z +?GetCurrentSettings@CWinRSPluginConfigCache@@QAAPAVCWinRSPluginConfigSettings@@PAVIRequestContext@@@Z +?GetCurrentShellUriIdentity@CConfigManager@@QAAHPAVSHELLURI_IDENTITY@@PAVIRequestContext@@@Z +?GetCurrentTableIdentity@CConfigManager@@QAAHPAVWSMANCONFIGTABLE_IDENTITY@@PAVIRequestContext@@@Z +?GetDataLocale@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetDataLocaleHelper@PacketParser@@QAAAAVLocale@@XZ +?GetDescriptionElement@SoapSemanticConverter@@QAAPAU_FWXML_ELEMENT@@PAU2@PAVIRequestContext@@@Z +?GetDestructorIter@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@QAAAAV?$SafeSet_Iterator@PAVCCertMapping@@@@XZ +?GetDestructorIter@?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@QAAAAV?$SafeSet_Iterator@PAVCShellUriSettings@@@@XZ +?GetDestructorIter@?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAAAAV?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@XZ +?GetDestructorIter@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAAAAV?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@XZ +?GetDestructorIter@?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAAAAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@XZ +?GetDialect@Fragment@PacketParser@@QBAPBGXZ +?GetError@BufferFormatter@@QBAKXZ +?GetErrorCode@CErrorContext@@UBAKXZ +?GetEventType@SoapSemanticConverter@@AAAKPBGPAVIRequestContext@@@Z +?GetEventTypeAndResponseElement@SoapSemanticConverter@@AAAPAU_FWXML_ELEMENT@@PAU2@PAKPAVIRequestContext@@@Z +?GetExtendedErrorString@CErrorContext@@UAAPAGXZ +?GetExtendedErrorString@CRequestContext@@UAAPAGXZ +?GetFaultToXml@PacketParser@@QBAABVReferenceParameters@1@XZ +?GetFaultXML@CErrorContext@@UBAPBGXZ +?GetFaultXML@CRequestContext@@UBAPBGXZ +?GetFaultXMLPrivate@CRequestContext@@AAAXPAPAD0KHKKPBG11@Z +?GetFirstConfigManagerForCertMapping@CConfigManager@@SAPAV1@PBG@Z +?GetFirstConfigManagerForListener@CConfigManager@@SAPAV1@PBG@Z +?GetFirstConfigManagerForShellUri@CConfigManager@@SAPAV1@PBG@Z +?GetFirstConfigManagerForTable@CConfigManager@@SAPAV1@W4WSMANTableConfigType@@PBG@Z +?GetFormat@PacketFormatter@@QBA?AW4Charset@1@XZ +?GetFormatterMode@BufferFormatter@@QAA?AW4Charset@PacketFormatter@@XZ +?GetFragment@PacketParser@@QBAABVFragment@1@XZ +?GetFragmentDialect@CWSManResourceNoResourceUri@@QAAPBGXZ +?GetFragmentPath@CWSManResourceNoResourceUri@@QAAPBGXZ +?GetGroupPolicyManager@CWSManGroupPolicyManager@@SAPAV1@PAVIRequestContext@@PBG@Z +?GetHeap@WSManMemory@@SAPAXXZ +?GetIISConfiguration@CConfigManager@@SAHPAVIRequestContext@@PBGPAPAVXmlReader@@@Z +?GetImpersonationToken@UserRecord@@QAAPAXXZ +?GetInheritTypes@CWSManSecurityUI@@UAAJPAPAU_SI_INHERIT_TYPE@@PAK@Z +?GetInitError@CWSManCriticalSection@@QBAKXZ +?GetInstance@?$LoaderSerializer@VAdminSid@CSecurity@@$00@@QAAPAVAdminSid@CSecurity@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VCredUIDllLoader@@$00@@QAAPAVCredUIDllLoader@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VEventHandler@WSMan@@$00@@QAAPAVEventHandler@WSMan@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VInteractiveSid@CSecurity@@$00@@QAAPAVInteractiveSid@CSecurity@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VIpHlpApiDllLoader@@$00@@QAAPAVIpHlpApiDllLoader@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VMachineName@@$00@@QAAPAVMachineName@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VNetworkServiceSid@CSecurity@@$00@@QAAPAVNetworkServiceSid@CSecurity@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VNtDsApiDllLoader@@$00@@QAAPAVNtDsApiDllLoader@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VResources@Locale@@$0A@@@QAAPAVResources@Locale@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VShell32DllLoader@@$00@@QAAPAVShell32DllLoader@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VShlWApiDllLoader@@$00@@QAAPAVShlWApiDllLoader@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VSubscriptionManager@@$01@@QAAPAVSubscriptionManager@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VUser32DllLoader@@$00@@QAAPAVUser32DllLoader@@AAVIRequestContext@@@Z +?GetInstance@?$LoaderSerializer@VWSManMemCryptManager@@$00@@QAAPAVWSManMemCryptManager@@AAVIRequestContext@@@Z +?GetInt@CConfigManager@@QAAHPAVIRequestContext@@W4ConfigSetting@@PAKPAW4WSManConfigSource@@@Z +?GetInt@CWSManGroupPolicyManager@@QAAHPAVIRequestContext@@W4WSManGroupPolicySetting@@PAKPAW4WSManGroupPolicySettingState@@@Z +?GetKey@UserRecord@@QBA?AUUserKey@@XZ +?GetKeyCount@CWSManResourceNoResourceUri@@QAAKXZ +?GetKeyValue@CWSManResourceNoResourceUri@@QAAPBGPBG@Z +?GetKeys@CWSManResourceNoResourceUri@@QAAPAU_WSMAN_KEY@@XZ +?GetLCID@Locale@@QAAKXZ +?GetLength@XmlReader@@QAAIXZ +?GetLocale@CRequestContext@@QAAAAVLocale@@XZ +?GetLocale@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetLocaleHelper@PacketParser@@QAAAAVLocale@@XZ +?GetLocaleString@CRequestContext@@QAAPBGXZ +?GetLocator@CWSManResource@@QAAPAU_WSMAN_RESOURCE_LOCATOR@@XZ +?GetMachineId@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetMap@?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@QBAAAV?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@QBAAAV?$SafeMap@PAVCListenerConnect@@PAV1@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@QBAAAV?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@QBAAAV?$SafeMap@PAVCListenerReceive@@PAV1@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@QBAAAV?$SafeMap@PAVCListenerSend@@PAV1@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@QBAAAV?$SafeMap@PAVCListenerSignal@@PAV1@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@QBAAAV?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@QBAAAV?$SafeMap@PAVCollector@@UEmpty@@V?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@QBAAAV?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@QBAAAV?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@QBAAAV?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@QBAAAV?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@PAXUEmpty@@@@QBAAAV?$SafeMap@PAXUEmpty@@V?$SafeMap_Iterator@PAXUEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@UPluginKey@@K@@QBAAAV?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@XZ +?GetMap@?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@QBAAAV?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@XZ +?GetMap@?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QBAAAV?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@XZ +?GetMap@?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@QBAAAV?$SafeMap@VGuidKey@@PAVCListenerCommand@@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@XZ +?GetMap@?$SafeMap_Iterator@VKey@Locale@@K@@QBAAAV?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@XZ +?GetMap@?$SafeMap_Iterator@VStringKeyCI@@K@@QBAAAV?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@XZ +?GetMap@?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@QBAAAV?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@QBAAAV?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@XZ +?GetMap@?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QBAAAV?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@XZ +?GetMap@?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@QBAAAV?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@XZ +?GetMap@?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QBAAAV?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@XZ +?GetMap@?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@QBAAAV?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@QBAABV?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVCListenerConnect@@PAV1@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@QBAABV?$SafeMap@PAVCListenerConnect@@PAV1@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@QBAABV?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVCListenerReceive@@PAV1@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@QBAABV?$SafeMap@PAVCListenerReceive@@PAV1@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVCListenerSend@@PAV1@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@QBAABV?$SafeMap@PAVCListenerSend@@PAV1@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVCListenerSignal@@PAV1@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@QBAABV?$SafeMap@PAVCListenerSignal@@PAV1@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@QBAABV?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVCollector@@UEmpty@@V?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@@@QBAABV?$SafeMap@PAVCollector@@UEmpty@@V?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVHostOperation@@UEmpty@@V?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@@@QBAABV?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVIOperation@@UEmpty@@V?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@@@QBAABV?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVListenerSourceSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@@@QBAABV?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@PAVPushSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@@@QBAABV?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@PAXUEmpty@@V?$SafeMap_Iterator@PAXUEmpty@@@@@@QBAABV?$SafeMap@PAXUEmpty@@V?$SafeMap_Iterator@PAXUEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QBAABV?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@XZ +?GetMap@?$SafeMap_Lock@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QBAABV?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@XZ +?GetMap@?$SafeMap_Lock@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QBAABV?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@XZ +?GetMap@?$SafeMap_Lock@VGuidKey@@PAVCListenerCommand@@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@QBAABV?$SafeMap@VGuidKey@@PAVCListenerCommand@@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@XZ +?GetMap@?$SafeMap_Lock@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@QBAABV?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@XZ +?GetMap@?$SafeMap_Lock@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QBAABV?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@XZ +?GetMap@?$SafeMap_Lock@VStringKeyCI@@UEmpty@@V?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@@@QBAABV?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@@@XZ +?GetMap@?$SafeMap_Lock@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QBAABV?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@XZ +?GetMap@?$SafeMap_Lock@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QBAABV?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@XZ +?GetMap@?$SafeMap_Lock@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QBAABV?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@XZ +?GetMap@?$SafeMap_Lock@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QBAABV?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@XZ +?GetMap@?$SafeMap_Lock@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QBAABV?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@XZ +?GetMaxBatchItems@CCommonConfigSettings@@UAAKXZ +?GetMaxBatchSize@CCommonConfigSettings@@UAAKXZ +?GetMaxEnvelopeSize@CCommonConfigSettings@@UAAKXZ +?GetMaxEnvelopeSize@PacketParser@@QBAABV?$PacketElement@K@1@XZ +?GetMaxTimeOut@CCommonConfigSettings@@UAAKXZ +?GetMessageAlloc@Locale@@QBAPBGAAVAutoLocalFree@@KZZ +?GetMessageEmpty@Locale@@QBAPBGAAVAutoLocalFree@@K@Z +?GetMessageId@CErrorContext@@UBAKXZ +?GetMessageId@CRequestContext@@UBAKXZ +?GetMessageId@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetMessageW@Locale@@QBA_NKPAPAD0PAGK@Z +?GetMinBatchItems@CCommonConfigSettings@@UAAKXZ +?GetMinBatchSize@CCommonConfigSettings@@UAAKXZ +?GetMinBatchTimeout@CCommonConfigSettings@@UAAKXZ +?GetMinEnvelopeSize@CCommonConfigSettings@@UAAKXZ +?GetMinTimeOut@CCommonConfigSettings@@UAAKXZ +?GetNamespacePrefix@NotUnderstandSoapHeader@PacketParser@@QBAPBGXZ +?GetNamespaceUrl@NotUnderstandSoapHeader@PacketParser@@QBAPBGXZ +?GetNewStorage@RBUFFER@@IAAHI@Z +?GetNotUnderstandHeader@PacketParser@@QBAABVNotUnderstandSoapHeader@1@XZ +?GetObjectInformation@CWSManSecurityUI@@UAAJPAU_SI_OBJECT_INFO@@@Z +?GetObjectW@?$ILoader@VAdminSid@CSecurity@@@@IBAPAVAdminSid@CSecurity@@XZ +?GetObjectW@?$ILoader@VCredUIDllLoader@@@@IBAPAVCredUIDllLoader@@XZ +?GetObjectW@?$ILoader@VEventHandler@WSMan@@@@IBAPAVEventHandler@WSMan@@XZ +?GetObjectW@?$ILoader@VInteractiveSid@CSecurity@@@@IBAPAVInteractiveSid@CSecurity@@XZ +?GetObjectW@?$ILoader@VIpHlpApiDllLoader@@@@IBAPAVIpHlpApiDllLoader@@XZ +?GetObjectW@?$ILoader@VMachineName@@@@IBAPAVMachineName@@XZ +?GetObjectW@?$ILoader@VNetworkServiceSid@CSecurity@@@@IBAPAVNetworkServiceSid@CSecurity@@XZ +?GetObjectW@?$ILoader@VNtDsApiDllLoader@@@@IBAPAVNtDsApiDllLoader@@XZ +?GetObjectW@?$ILoader@VResources@Locale@@@@IBAPAVResources@Locale@@XZ +?GetObjectW@?$ILoader@VShell32DllLoader@@@@IBAPAVShell32DllLoader@@XZ +?GetObjectW@?$ILoader@VShlWApiDllLoader@@@@IBAPAVShlWApiDllLoader@@XZ +?GetObjectW@?$ILoader@VSubscriptionManager@@@@IBAPAVSubscriptionManager@@XZ +?GetObjectW@?$ILoader@VUser32DllLoader@@@@IBAPAVUser32DllLoader@@XZ +?GetObjectW@?$ILoader@VWSManMemCryptManager@@@@IBAPAVWSManMemCryptManager@@XZ +?GetOperationId@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetOptionCount@CWSManResourceNoResourceUri@@QAAKXZ +?GetOptionTypes@CWSManResourceNoResourceUri@@QAAPAPBGXZ +?GetOptionValue@CWSManResourceNoResourceUri@@QAAPBGPBG@Z +?GetOptions@CWSManResourceNoResourceUri@@QAAPAU_WSMAN_OPTION@@XZ +?GetOptionsMustUnderstandValue@CWSManResourceNoResourceUri@@QAAHXZ +?GetOptionsSetXml@PacketParser@@QAAABV?$PacketElement@PAU_FWXML_ELEMENT@@@1@XZ +?GetOriginalUri@CWSManResource@@QAAPBGXZ +?GetPacket@PacketParser@@QAAPAVPacket@@XZ +?GetPacketPool@PacketParser@@QAAAAVPacketPool@@XZ +?GetParser@XmlReader@@QAAPAXXZ +?GetPath@Fragment@PacketParser@@QBAPBGXZ +?GetPolicyLocation@CWSManGroupPolicyManager@@AAAPBGPBU_WSMAN_POLICY_INFO@@@Z +?GetPolicyValueForConfigSetting@CConfigManager@@AAAJW4ConfigSetting@@KPAGPAKPAW4WSManGroupPolicySettingState@@PAVIRequestContext@@@Z +?GetPolicyValueForConfigSetting@CConfigManager@@AAAJW4ConfigSetting@@PAKPAW4WSManGroupPolicySettingState@@PAVIRequestContext@@@Z +?GetProfileCount@UserRecord@@QAAJXZ +?GetProfileHandle@UserRecord@@QAA_JXZ +?GetPromptType@SoapSemanticConverter@@AAA_NPBGPAW4_MI_PromptType@@PAVIRequestContext@@@Z +?GetQuotaRecord@UserRecord@@QBAPBVQuotaRecord@@XZ +?GetRefCount@ILifeTimeMgmt@@QAAJXZ +?GetReferenceParameters@ReferenceParameters@PacketParser@@QBAPBGXZ +?GetReferenceProperties@ReferenceParameters@PacketParser@@QBAPBGXZ +?GetRemainderPacket@PacketParser@@QAAPAVPacket@@PAVIRequestContext@@@Z +?GetReplyToXml@PacketParser@@QBAABVReferenceParameters@1@XZ +?GetRequestedDataLocale@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetRequestedLocale@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetResourceUri@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetRoot@XmlReader@@QAAPAU_FWXML_ELEMENT@@XZ +?GetSecurity@CWSManSecurityUI@@UAAJKPAPAXH@Z +?GetSecurityDescriptor@CConfigManager@@QAAHPAVIRequestContext@@W4ConfigSetting@@PAPAXPAW4WSManConfigSource@@@Z +?GetSelectorSetXml@PacketParser@@QAAABV?$PacketElement@PAU_FWXML_ELEMENT@@@1@XZ +?GetSequenceId@PacketParser@@QBAABV?$PacketElement@_K@1@XZ +?GetServiceCatalog@@YAPAVCatalog@@XZ +?GetSessionId@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetSessionIdGuid@PacketParser@@QAAAAU_GUID@@XZ +?GetSessionIdGuid@SessionId@PacketParser@@QAAAAU_GUID@@XZ +?GetSetting@CConfigManager@@QAAHPAVIRequestContext@@W4ConfigSetting@@KPAGPAKPAW4WSManConfigSource@@@Z +?GetShellCompressionType@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetSid@CSecurity@@SAPAXXZ +?GetSizeInUse@SBUFFER@@QBAIXZ +?GetSoapBody@PacketParser@@QAAPAU_FWXML_ELEMENT@@XZ +?GetSoapHeaders@PacketParser@@QAAPAU_FWXML_ELEMENT@@XZ +?GetSourceSubscriptionId@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetSpaceUsed@BufferFormatter@@UBAK_N@Z +?GetSpaceUsed@CircularBufferFormatter@@UBAK_N@Z +?GetStrPtr@TSTRBUFFER@@QAAPAGXZ +?GetString@CConfigManager@@QAAHPAVIRequestContext@@W4ConfigSetting@@KPAGPAKPAW4WSManConfigSource@@@Z +?GetString@CWSManGroupPolicyManager@@QAAHPAVIRequestContext@@W4WSManGroupPolicySetting@@KPAGPAKPAW4WSManGroupPolicySettingState@@@Z +?GetString@Locale@@QAAPBGXZ +?GetStringInternal@CConfigManager@@AAAHPAVIRequestContext@@W4ConfigSetting@@KKPAGPAKPAW4WSManConfigSource@@@Z +?GetStringInternal@CWSManGroupPolicyManager@@AAAHPAVIRequestContext@@W4WSManGroupPolicySetting@@KKPAGPAKPAW4WSManGroupPolicySettingState@@@Z +?GetSubscriptionId@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetSuccessCode@OnHTTPInitialize@@QBAKXZ +?GetTimeout@PacketParser@@QBAABV?$PacketElement@K@1@XZ +?GetTo@PacketParser@@QBAABV?$PacketElement@PBG@1@XZ +?GetToken@CSecurity@@SAPAXXZ +?GetToken@UserRecord@@QAAPAXXZ +?GetUpdatedSDDL@CWSManSecurityUI@@QAAPAGPAVIRequestContext@@@Z +?GetUri@CWSManResource@@QAAPBGXZ +?GetUserAdministratorType@UserRecord@@QBA?AW4AdministratorType@UserAuthzRecord@@XZ +?GetUserNameW@UserRecord@@QAAPBGXZ +?GetValue@?$PacketElement@K@PacketParser@@QBAKXZ +?GetValue@?$PacketElement@PAU_FWXML_ELEMENT@@@PacketParser@@QBAPAU_FWXML_ELEMENT@@XZ +?GetValue@?$PacketElement@PBG@PacketParser@@QBAPBGXZ +?GetValue@?$PacketElement@_K@PacketParser@@QBA_KXZ +?GetWsmanData@TSTRBUFFER@@QAAXPAU_WSMAN_DATA@@@Z +?GetXmlDoc@PacketParser@@QAAPAUFWXML_DOCUMENT@@XZ +?GrowBuffer@BufferFormatter@@UAAKK@Z +?GrowBuffer@BufferFormatter@@UAAKXZ +?GrowBuffer@CircularBufferFormatter@@UAAKK@Z +?GrowBuffer@CircularBufferFormatter@@UAAKXZ +?HandleAutoConfiguredListener@CConfigManager@@QAAHPAVIRequestContext@@PAVLISTENER_IDENTITY@@@Z +?HandleMigration@@YAHPAVWSManMigrationContext@@@Z +?HasFaultXML@CRequestContext@@QBAHXZ +?HasHtmlError@CRequestContext@@ABAHXZ +?HasOption@CWSManResourceNoResourceUri@@QAAHPBG@Z +?ImpersonateUserOrSelf@CSecurity@@SAHW4CallSiteId@@PAX@Z +?IncreaseProfileCount@UserRecord@@QAAXXZ +?Info@EventLog@@SAXK@Z +?Info@EventLog@@SAXKGPAPBG@Z +?Info@EventLog@@SAXKPBG@Z +?Init@CBaseConfigCache@@IAAHPAVIRequestContext@@H@Z +?Init@CWSManSecurityUI@@QAAHPAG0PAVIRequestContext@@@Z +?Init@ConfigRegistry@@IAAHXZ +?Init@XmlReader@@QAAHPAVIRequestContext@@PAUWSMAN_OBJECT@@@Z +?Init@XmlReader@@QAAHPAVIRequestContext@@PBG@Z +?InitCfgMgr@CConfigManager@@AAAHPAVWSMANCONFIGTABLE_IDENTITY@@@Z +?InitCfgMgr@CConfigManager@@AAAHPAVWSMANCONFIGTABLE_IDENTITY@@PAUHKEY__@@1@Z +?InitMap@CBaseConfigCache@@CAHPAVIRequestContext@@AAV?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@@Z +?Initialize@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCListenerConnect@@PAV1@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCListenerReceive@@PAV1@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCListenerSend@@PAV1@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCListenerSignal@@PAV1@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCollector@@UEmpty@@V?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVCollector@@UEmpty@@V?$SafeSet_Iterator@PAVCollector@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeSet_Iterator@PAVHostOperation@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeSet_Iterator@PAVIOperation@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVPushSubscription@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VGuidKey@@PAVCListenerCommand@@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VKey@CWmiPtrCache@@VMapping@2@V?$SafeMap_Iterator@VKey@CWmiPtrCache@@VMapping@2@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKey@@PAVListenerEvents@@V?$SafeMap_Iterator@VStringKey@@PAVListenerEvents@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKey@@PAVListenerSourceSubscription@@V?$SafeMap_Iterator@VStringKey@@PAVListenerSourceSubscription@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKey@@UOption@WinRM_OperationOptions@@V?$SafeMap_Iterator@VStringKey@@UOption@WinRM_OperationOptions@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKeyCI@@PAVIISEndpoint@@V?$SafeMap_Iterator@VStringKeyCI@@PAVIISEndpoint@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@VTokenCacheKey@ServiceSoapProcessor@@VTokenCacheMapping@2@V?$SafeMap_Iterator@VTokenCacheKey@ServiceSoapProcessor@@VTokenCacheMapping@2@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@UAA_NAAVIRequestContext@@@Z +?Initialize@?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@QAAAAV1@XZ +?Initialize@?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@QAAAAV1@XZ +?Initialize@?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@QAAAAV1@XZ +?Initialize@?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QAAAAV1@XZ +?Initialize@?$SafeMap_Iterator@VStringKeyCI@@K@@QAAAAV1@XZ +?Initialize@?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QAAAAV1@XZ +?Initialize@?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAAAAV1@XZ +?Initialize@CWSManGroupPolicyManager@@AAAHPAVIRequestContext@@PBG@Z +?Initialize@EventHandler@WSMan@@QAA_NAAVIRequestContext@@@Z +?Initialize@UserRecord@@SAXAAV1@ABUInitializer@1@@Z +?InitializeSources@CBaseConfigCache@@IAAHPAVIRequestContext@@HH@Z +?InitializeSourcesHelper@CBaseConfigCache@@MAAHPAVIRequestContext@@H@Z +?InitializeSourcesHelper@CClientConfigCache@@EAAHPAVIRequestContext@@H@Z +?InsertAtPosition@TSTRBUFFER@@QAAJPBGI@Z +?InternalFailure@CErrorContext@@UAAXKZZ +?InternalFailure@CRequestContext@@UAAXKZZ +?InternalHResult@CErrorContext@@UAAXKKZZ +?InternalHResult@CRequestContext@@UAAXKKZZ +?InternalParse@CWSManEPR@@MAAHPAVIRequestContext@@@Z +?InternalParse@CWSManResource@@MAAHPAVIRequestContext@@@Z +?IsActive@ChildLifeTimeManager@@QAA_NXZ +?IsAdmin@UserRecord@@QBA_NXZ +?IsAutoListenerConfigurationOn@CConfigManager@@SAHPAVIRequestContext@@PAH@Z +?IsCIM_Error@CRequestContext@@QAAHXZ +?IsCurrentListenerAutoConfigured@CConfigManager@@QAAHPAVIRequestContext@@PAH@Z +?IsCurrentListenerCompat@CConfigManager@@QBA_NXZ +?IsDynAlloced@RBUFFER@@IBAHXZ +?IsEPR@CWSManEPR@@UAAHXZ +?IsEPR@CWSManResourceNoResourceUri@@UAAHXZ +?IsEmpty@?$ILoader@VAdminSid@CSecurity@@@@QBA_NXZ +?IsEmpty@?$ILoader@VCredUIDllLoader@@@@QBA_NXZ +?IsEmpty@?$ILoader@VEventHandler@WSMan@@@@QBA_NXZ +?IsEmpty@?$ILoader@VInteractiveSid@CSecurity@@@@QBA_NXZ +?IsEmpty@?$ILoader@VIpHlpApiDllLoader@@@@QBA_NXZ +?IsEmpty@?$ILoader@VMachineName@@@@QBA_NXZ +?IsEmpty@?$ILoader@VNetworkServiceSid@CSecurity@@@@QBA_NXZ +?IsEmpty@?$ILoader@VNtDsApiDllLoader@@@@QBA_NXZ +?IsEmpty@?$ILoader@VResources@Locale@@@@QBA_NXZ +?IsEmpty@?$ILoader@VShell32DllLoader@@@@QBA_NXZ +?IsEmpty@?$ILoader@VShlWApiDllLoader@@@@QBA_NXZ +?IsEmpty@?$ILoader@VSubscriptionManager@@@@QBA_NXZ +?IsEmpty@?$ILoader@VUser32DllLoader@@@@QBA_NXZ +?IsEmpty@?$ILoader@VWSManMemCryptManager@@@@QBA_NXZ +?IsEmpty@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QBA_NXZ +?IsEmpty@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QBA_NXZ +?IsEmpty@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@QBA_NXZ +?IsEvent@SoapSemanticConverter@@QAA_NPAU_FWXML_ELEMENT@@@Z +?IsEventEnabled@EventHandler@WSMan@@SA_NABU_EVENT_DESCRIPTOR@@@Z +?IsEventProviderEnabled@EventHandler@WSMan@@SA_NXZ +?IsFound@?$PacketElement@K@PacketParser@@QBAHXZ +?IsFound@?$PacketElement@PAU_FWXML_ELEMENT@@@PacketParser@@QBAHXZ +?IsFound@?$PacketElement@PBG@PacketParser@@QBAHXZ +?IsFound@?$PacketElement@_K@PacketParser@@QBAHXZ +?IsGeneratingError@CErrorContext@@UBA_NXZ +?IsIdentifyPacket@PacketParser@@QBAHXZ +?IsInCommitMode@BufferFormatter@@QAA_NXZ +?IsInteractive@UserRecord@@QBA_NXZ +?IsLocalSystemSid@CSecurity@@SAHPAX@Z +?IsMustUnderstand@?$PacketElement@PBG@PacketParser@@QBAHXZ +?IsNonOperativePacket@PacketParser@@QBAHXZ +?IsPolicyControlledSetting@CConfigManager@@QAAHPAVIRequestContext@@W4ConfigSetting@@PAH@Z +?IsRobustConnectionPacket@PacketParser@@QBAHXZ +?IsStreamingEvent@SoapSemanticConverter@@QAA_NPAU_FWXML_ELEMENT@@PAVIRequestContext@@@Z +?IsStringNullOrEmpty@@YAHPBG@Z +?IsValid@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QBA_NXZ +?IsValid@?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@QBA_NXZ +?IsValid@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QBA_NXZ +?IsValid@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QBA_NXZ +?IsValid@?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QBA_NXZ +?IsValid@?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@PAXUEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@UPluginKey@@K@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VKey@CWmiPtrCache@@VMapping@2@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VKey@Locale@@K@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VStringKey@@PAVListenerEvents@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VStringKey@@PAVListenerSourceSubscription@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VStringKey@@UOption@WinRM_OperationOptions@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VStringKeyCI@@K@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VStringKeyCI@@PAVIISEndpoint@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@VTokenCacheKey@ServiceSoapProcessor@@VTokenCacheMapping@2@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QBA_NXZ +?IsValid@?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@QBA_NXZ +?IsValid@CWSManCriticalSection@@QBAHXZ +?IsValid@RBUFFER@@IBAHXZ +?Key@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QBAPBVStringKeyCI@@ABV2@@Z +?Key@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QBAPBVStringKeyCI@@ABV2@@Z +?Key@?$SafeMap_Iterator@VKey@Locale@@K@@QBAABV0Locale@@XZ +?Key@?$SafeMap_Iterator@VStringKeyCI@@K@@QBAABVStringKeyCI@@XZ +?Key@?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@QBAABVStringKeyCI@@XZ +?LogError@CBaseConfigCache@@UAAXKK@Z +?LogErrorCode@CErrorContext@@QAAXXZ +?LogErrorCode@CRequestContext@@QAAXXZ +?LogErrorMessage@CRequestContext@@QAAXXZ +?LogNotificationEvent@CWSManGroupPolicyManager@@CAXK@Z +?LogReadErrors@CBaseConfigCache@@IAA?AW4ErrorLogging@@W4ConfigChangeSources@@@Z +?LowerBound@?$SafeMap_Iterator@VKey@Locale@@K@@QAAXABVKey@Locale@@@Z +?MakeUrlBinding@@YAHKPAGPAKPBG222@Z +?MakeUrlBinding@@YAPAGPAVIRequestContext@@PBG111@Z +?MapGeneric@CWSManSecurityUI@@UAAJPBU_GUID@@PAEPAK@Z +?Me@?$AutoCleanup@V?$AutoDelete@D@@PAD@@AAAAAV?$AutoDelete@D@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@G@@PAG@@AAAAAV?$AutoDelete@G@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@UIPRange@CWSManIPFilter@@@@PAUIPRange@CWSManIPFilter@@@@AAAAAV?$AutoDelete@UIPRange@CWSManIPFilter@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@U_SID@@@@PAU_SID@@@@AAAAAV?$AutoDelete@U_SID@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@PAU_WSMAN_STREAM_ID_SET@@@@AAAAAV?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$Handle@VISubscription@@@@@@PAV?$Handle@VISubscription@@@@@@AAAAAV?$AutoDelete@V?$Handle@VISubscription@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@AAAAAV?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@AAAAAV?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@AAAAAV?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@AAAAAV?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@PAV?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@AAAAAV?$AutoDelete@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@@AAAAAV?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@AAAAAV?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@@AAAAAV?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@@AAAAAV?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@@AAAAAV?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCollector@@@@@@PAV?$SafeSet_Iterator@PAVCollector@@@@@@AAAAAV?$AutoDelete@V?$SafeSet_Iterator@PAVCollector@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVHostOperation@@@@@@PAV?$SafeSet_Iterator@PAVHostOperation@@@@@@AAAAAV?$AutoDelete@V?$SafeSet_Iterator@PAVHostOperation@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@PAV?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@AAAAAV?$AutoDelete@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SimpleStack@VCListenerOperation@@@@@@PAV?$SimpleStack@VCListenerOperation@@@@@@AAAAAV?$AutoDelete@V?$SimpleStack@VCListenerOperation@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$SimpleStack@VShellHostEntry@@@@@@PAV?$SimpleStack@VShellHostEntry@@@@@@AAAAAV?$AutoDelete@V?$SimpleStack@VShellHostEntry@@@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$queue@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$deque@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$transport_allocator@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@@@@std@@@std@@@@PAV?$queue@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$deque@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$transport_allocator@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@@@@std@@@std@@@@AAAAAV?$AutoDelete@V?$queue@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$deque@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$transport_allocator@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@@@@std@@@std@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@AAAAAV?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@AAAAAV?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$vector@PAVCWSManRequest@@V?$transport_allocator@PAVCWSManRequest@@@@@std@@@@PAV?$vector@PAVCWSManRequest@@V?$transport_allocator@PAVCWSManRequest@@@@@std@@@@AAAAAV?$AutoDelete@V?$vector@PAVCWSManRequest@@V?$transport_allocator@PAVCWSManRequest@@@@@std@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@AAAAAV?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@AAAAAV?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@V?$vector@PAVWSManHttpSenderConnection@@V?$transport_allocator@PAVWSManHttpSenderConnection@@@@@std@@@@PAV?$vector@PAVWSManHttpSenderConnection@@V?$transport_allocator@PAVWSManHttpSenderConnection@@@@@std@@@@AAAAAV?$AutoDelete@V?$vector@PAVWSManHttpSenderConnection@@V?$transport_allocator@PAVWSManHttpSenderConnection@@@@@std@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VAdminSid@CSecurity@@@@PAVAdminSid@CSecurity@@@@AAAAAV?$AutoDelete@VAdminSid@CSecurity@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VBlockedRecord@@@@PAVBlockedRecord@@@@AAAAAV?$AutoDelete@VBlockedRecord@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@AAAAAV?$AutoDelete@VCBaseConfigCache@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCCertMapping@@@@PAVCCertMapping@@@@AAAAAV?$AutoDelete@VCCertMapping@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCConfigChangeSource@@@@PAVCConfigChangeSource@@@@AAAAAV?$AutoDelete@VCConfigChangeSource@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCListenerSettings@@@@PAVCListenerSettings@@@@AAAAAV?$AutoDelete@VCListenerSettings@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCObserverConfigChangeErrors@@@@PAVCObserverConfigChangeErrors@@@@AAAAAV?$AutoDelete@VCObserverConfigChangeErrors@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@PAVCServiceWatcher@CServiceConfigCache@@@@AAAAAV?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCShellUriSettings@@@@PAVCShellUriSettings@@@@AAAAAV?$AutoDelete@VCShellUriSettings@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCWSManEPR@@@@PAVCWSManEPR@@@@AAAAAV?$AutoDelete@VCWSManEPR@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCWSManResource@@@@PAVCWSManResource@@@@AAAAAV?$AutoDelete@VCWSManResource@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCertHash@@@@PAVCertHash@@@@AAAAAV?$AutoDelete@VCertHash@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@@AAAAAV?$AutoDelete@VConfigUpdate@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VCredUIDllLoader@@@@PAVCredUIDllLoader@@@@AAAAAV?$AutoDelete@VCredUIDllLoader@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@AAAAAV?$AutoDelete@VEnumSinkEx@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VEventHandler@WSMan@@@@PAVEventHandler@WSMan@@@@AAAAAV?$AutoDelete@VEventHandler@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VExpiredOperationIdRecord@@@@PAVExpiredOperationIdRecord@@@@AAAAAV?$AutoDelete@VExpiredOperationIdRecord@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VGPApiManager@@@@PAVGPApiManager@@@@AAAAAV?$AutoDelete@VGPApiManager@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@AAAAAV?$AutoDelete@VGeneralSinkEx@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VIChannelObserverFactory@@@@PAVIChannelObserverFactory@@@@AAAAAV?$AutoDelete@VIChannelObserverFactory@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@AAAAAV?$AutoDelete@VIQueryDASHSMASHInterface@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@AAAAAV?$AutoDelete@VISpecification@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VInteractiveSid@CSecurity@@@@PAVInteractiveSid@CSecurity@@@@AAAAAV?$AutoDelete@VInteractiveSid@CSecurity@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VIpHlpApiDllLoader@@@@PAVIpHlpApiDllLoader@@@@AAAAAV?$AutoDelete@VIpHlpApiDllLoader@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VMachineName@@@@PAVMachineName@@@@AAAAAV?$AutoDelete@VMachineName@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VMasterReceiveData@CListenerReceive@@@@PAVMasterReceiveData@CListenerReceive@@@@AAAAAV?$AutoDelete@VMasterReceiveData@CListenerReceive@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VNetworkServiceSid@CSecurity@@@@PAVNetworkServiceSid@CSecurity@@@@AAAAAV?$AutoDelete@VNetworkServiceSid@CSecurity@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VNtDsApiDllLoader@@@@PAVNtDsApiDllLoader@@@@AAAAAV?$AutoDelete@VNtDsApiDllLoader@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@PAVOptionValue@SessionOptions@Client@WSMan@@@@AAAAAV?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VPacketCreator@@@@PAVPacketCreator@@@@AAAAAV?$AutoDelete@VPacketCreator@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VPacketParser@@@@PAVPacketParser@@@@AAAAAV?$AutoDelete@VPacketParser@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VResources@Locale@@@@PAVResources@Locale@@@@AAAAAV?$AutoDelete@VResources@Locale@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VRunAsConfiguration@@@@PAVRunAsConfiguration@@@@AAAAAV?$AutoDelete@VRunAsConfiguration@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VSecurityEntry@Catalog@@@@PAVSecurityEntry@Catalog@@@@AAAAAV?$AutoDelete@VSecurityEntry@Catalog@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VSendPacketArgs@RobustConnectionBuffer@@@@PAVSendPacketArgs@RobustConnectionBuffer@@@@AAAAAV?$AutoDelete@VSendPacketArgs@RobustConnectionBuffer@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VServiceSoapProcessor@@@@PAVServiceSoapProcessor@@@@AAAAAV?$AutoDelete@VServiceSoapProcessor@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VShell32DllLoader@@@@PAVShell32DllLoader@@@@AAAAAV?$AutoDelete@VShell32DllLoader@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VShlWApiDllLoader@@@@PAVShlWApiDllLoader@@@@AAAAAV?$AutoDelete@VShlWApiDllLoader@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VSubscriptionEnumerator@@@@PAVSubscriptionEnumerator@@@@AAAAAV?$AutoDelete@VSubscriptionEnumerator@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VSubscriptionManager@@@@PAVSubscriptionManager@@@@AAAAAV?$AutoDelete@VSubscriptionManager@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@AAAAAV?$AutoDelete@VTSTRBUFFER@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VUniqueStringOverflow@@@@PAVUniqueStringOverflow@@@@AAAAAV?$AutoDelete@VUniqueStringOverflow@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VUser32DllLoader@@@@PAVUser32DllLoader@@@@AAAAAV?$AutoDelete@VUser32DllLoader@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@PAVWSMANCONFIGTABLE_IDENTITY@@@@AAAAAV?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VWSManMemCryptManager@@@@PAVWSManMemCryptManager@@@@AAAAAV?$AutoDelete@VWSManMemCryptManager@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@AAAAAV?$AutoDelete@VWmiEnumContext@@@@XZ +?Me@?$AutoCleanup@V?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@@AAAAAV?$AutoDelete@VXmlReader@@@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@$$CBG@@PBG@@AAAAAV?$AutoDeleteVector@$$CBG@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@D@@PAD@@AAAAAV?$AutoDeleteVector@D@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@AAAAAV?$AutoDeleteVector@E@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@AAAAAV?$AutoDeleteVector@G@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@H@@PAH@@AAAAAV?$AutoDeleteVector@H@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@AAAAAV?$AutoDeleteVector@PAG@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@AAAAAV?$AutoDeleteVector@PBG@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@U_CONFIG_UPDATE@@@@PAU_CONFIG_UPDATE@@@@AAAAAV?$AutoDeleteVector@U_CONFIG_UPDATE@@@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@AAAAAV?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@AAAAAV?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@U_WSMAN_OPTION@@@@PAU_WSMAN_OPTION@@@@AAAAAV?$AutoDeleteVector@U_WSMAN_OPTION@@@@XZ +?Me@?$AutoCleanup@V?$AutoDeleteVector@X@@PAX@@AAAAAV?$AutoDeleteVector@X@@XZ +?Me@?$AutoCleanup@V?$AutoFree@E@@PAE@@AAAAAV?$AutoFree@E@@XZ +?Me@?$AutoCleanup@V?$AutoLocklessItemRecycle@VPacket@@@@PAVPacket@@@@AAAAAV?$AutoLocklessItemRecycle@VPacket@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIAppHostChildElementCollection@@@@PAUIAppHostChildElementCollection@@@@AAAAAV?$AutoRelease@UIAppHostChildElementCollection@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIAppHostElement@@@@PAUIAppHostElement@@@@AAAAAV?$AutoRelease@UIAppHostElement@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIAppHostElementCollection@@@@PAUIAppHostElementCollection@@@@AAAAAV?$AutoRelease@UIAppHostElementCollection@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIAppHostProperty@@@@PAUIAppHostProperty@@@@AAAAAV?$AutoRelease@UIAppHostProperty@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIAppHostPropertyCollection@@@@PAUIAppHostPropertyCollection@@@@AAAAAV?$AutoRelease@UIAppHostPropertyCollection@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@AAAAAV?$AutoRelease@UIClientSecurity@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@AAAAAV?$AutoRelease@UIEnumWbemClassObject@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@AAAAAV?$AutoRelease@UIErrorInfo@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@AAAAAV?$AutoRelease@UIUnknown@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@AAAAAV?$AutoRelease@UIWbemClassObject@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@AAAAAV?$AutoRelease@UIWbemContext@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@AAAAAV?$AutoRelease@UIWbemLocator@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@AAAAAV?$AutoRelease@UIWbemObjectTextSrc@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@AAAAAV?$AutoRelease@UIWbemPath@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@AAAAAV?$AutoRelease@UIWbemPathKeyList@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@AAAAAV?$AutoRelease@UIWbemQualifierSet@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@AAAAAV?$AutoRelease@UIWbemQuery@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@AAAAAV?$AutoRelease@UIWbemServices@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VApplication@Client@WSMan@@@@PAVApplication@Client@WSMan@@@@AAAAAV?$AutoRelease@VApplication@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@AAAAAV?$AutoRelease@VCBaseConfigCache@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCClientConfigCache@@@@PAVCClientConfigCache@@@@AAAAAV?$AutoRelease@VCClientConfigCache@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@@AAAAAV?$AutoRelease@VCClientConfigSettings@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCCommonConfigSettings@@@@PAVCCommonConfigSettings@@@@AAAAAV?$AutoRelease@VCCommonConfigSettings@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@PAVCConfigCacheMap@CBaseConfigCache@@@@AAAAAV?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@@AAAAAV?$AutoRelease@VCConfigManager@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCListenerCommand@@@@PAVCListenerCommand@@@@AAAAAV?$AutoRelease@VCListenerCommand@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCListenerMasterOperation@@@@PAVCListenerMasterOperation@@@@AAAAAV?$AutoRelease@VCListenerMasterOperation@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCListenerReceive@@@@PAVCListenerReceive@@@@AAAAAV?$AutoRelease@VCListenerReceive@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCListenerShell@@@@PAVCListenerShell@@@@AAAAAV?$AutoRelease@VCListenerShell@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCRemoteOperation@@@@PAVCRemoteOperation@@@@AAAAAV?$AutoRelease@VCRemoteOperation@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@AAAAAV?$AutoRelease@VCRemoteSession@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@@AAAAAV?$AutoRelease@VCRequestContext@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCServiceCommonConfigSettings@@@@PAVCServiceCommonConfigSettings@@@@AAAAAV?$AutoRelease@VCServiceCommonConfigSettings@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCServiceConfigCache@@@@PAVCServiceConfigCache@@@@AAAAAV?$AutoRelease@VCServiceConfigCache@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCServiceConfigSettings@@@@PAVCServiceConfigSettings@@@@AAAAAV?$AutoRelease@VCServiceConfigSettings@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@AAAAAV?$AutoRelease@VCWSManEPR@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyCache@@@@PAVCWSManGroupPolicyCache@@@@AAAAAV?$AutoRelease@VCWSManGroupPolicyCache@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyManager@@@@PAVCWSManGroupPolicyManager@@@@AAAAAV?$AutoRelease@VCWSManGroupPolicyManager@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCWSManObject@@@@PAVCWSManObject@@@@AAAAAV?$AutoRelease@VCWSManObject@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@@AAAAAV?$AutoRelease@VCWSManResource@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCWSManSession@@@@PAVCWSManSession@@@@AAAAAV?$AutoRelease@VCWSManSession@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@AAAAAV?$AutoRelease@VCWinRSPluginConfigCache@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigSettings@@@@PAVCWinRSPluginConfigSettings@@@@AAAAAV?$AutoRelease@VCWinRSPluginConfigSettings@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCommand@Client@WSMan@@@@PAVCommand@Client@WSMan@@@@AAAAAV?$AutoRelease@VCommand@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VConfigNotification@@@@PAVConfigNotification@@@@AAAAAV?$AutoRelease@VConfigNotification@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VConnectShellOperation@Client@WSMan@@@@PAVConnectShellOperation@Client@WSMan@@@@AAAAAV?$AutoRelease@VConnectShellOperation@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VCreateShellOperation@Client@WSMan@@@@PAVCreateShellOperation@Client@WSMan@@@@AAAAAV?$AutoRelease@VCreateShellOperation@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VDeleteShellOperation@Client@WSMan@@@@PAVDeleteShellOperation@Client@WSMan@@@@AAAAAV?$AutoRelease@VDeleteShellOperation@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VDisconnectOperation@Client@WSMan@@@@PAVDisconnectOperation@Client@WSMan@@@@AAAAAV?$AutoRelease@VDisconnectOperation@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@AAAAAV?$AutoRelease@VEnumSinkEx@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@AAAAAV?$AutoRelease@VGeneralSinkEx@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VHostMappingTable@@@@PAVHostMappingTable@@@@AAAAAV?$AutoRelease@VHostMappingTable@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VIISConfigSettings@@@@PAVIISConfigSettings@@@@AAAAAV?$AutoRelease@VIISConfigSettings@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VIPCSoapProcessor@@@@PAVIPCSoapProcessor@@@@AAAAAV?$AutoRelease@VIPCSoapProcessor@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@AAAAAV?$AutoRelease@VIRequestContext@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VISubscription@@@@PAVISubscription@@@@AAAAAV?$AutoRelease@VISubscription@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@AAAAAV?$AutoRelease@VInboundRequestDetails@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VProxyManager@Client@WSMan@@@@PAVProxyManager@Client@WSMan@@@@AAAAAV?$AutoRelease@VProxyManager@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VProxySelection@Client@WSMan@@@@PAVProxySelection@Client@WSMan@@@@AAAAAV?$AutoRelease@VProxySelection@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VPushSubscribeOperation@@@@PAVPushSubscribeOperation@@@@AAAAAV?$AutoRelease@VPushSubscribeOperation@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VPushSubscription@@@@PAVPushSubscription@@@@AAAAAV?$AutoRelease@VPushSubscription@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VReceiveOperation@Client@WSMan@@@@PAVReceiveOperation@Client@WSMan@@@@AAAAAV?$AutoRelease@VReceiveOperation@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VReconnectOperation@Client@WSMan@@@@PAVReconnectOperation@Client@WSMan@@@@AAAAAV?$AutoRelease@VReconnectOperation@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VSendOperation@Client@WSMan@@@@PAVSendOperation@Client@WSMan@@@@AAAAAV?$AutoRelease@VSendOperation@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@AAAAAV?$AutoRelease@VShell@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VShellInfo@@@@PAVShellInfo@@@@AAAAAV?$AutoRelease@VShellInfo@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VSignalOperation@Client@WSMan@@@@PAVSignalOperation@Client@WSMan@@@@AAAAAV?$AutoRelease@VSignalOperation@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VUserRecord@@@@PAVUserRecord@@@@AAAAAV?$AutoRelease@VUserRecord@@@@XZ +?Me@?$AutoCleanup@V?$AutoRelease@VWSManHttpListener@@@@PAVWSManHttpListener@@@@AAAAAV?$AutoRelease@VWSManHttpListener@@@@XZ +?Me@?$AutoCleanup@V?$AutoReleaseEx@VHostMappingTableEntry@@@@PAVHostMappingTableEntry@@@@AAAAAV?$AutoReleaseEx@VHostMappingTableEntry@@@@XZ +?Me@?$AutoCleanup@V?$AutoReleaseEx@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@AAAAAV?$AutoReleaseEx@VShell@Client@WSMan@@@@XZ +?Me@?$AutoCleanup@VAutoBstr@@PAG@@AAAAAVAutoBstr@@XZ +?Me@?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@AAAAAVAutoBstrNoAlloc@@XZ +?Me@?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@AAAAAVAutoCertContext@@XZ +?Me@?$AutoCleanup@VAutoChainContext@@PBU_CERT_CHAIN_CONTEXT@@@@AAAAAVAutoChainContext@@XZ +?Me@?$AutoCleanup@VAutoCoTaskMemFree@@PAX@@AAAAAVAutoCoTaskMemFree@@XZ +?Me@?$AutoCleanup@VAutoEnvironmentBlock@@PAX@@AAAAAVAutoEnvironmentBlock@@XZ +?Me@?$AutoCleanup@VAutoFwXmlCloseParser@@PAX@@AAAAAVAutoFwXmlCloseParser@@XZ +?Me@?$AutoCleanup@VAutoHandle@@PAX@@AAAAAVAutoHandle@@XZ +?Me@?$AutoCleanup@VAutoImpersonateUser@@PAX@@AAAAAVAutoImpersonateUser@@XZ +?Me@?$AutoCleanup@VAutoLibrary@@PAUHINSTANCE__@@@@AAAAAVAutoLibrary@@XZ +?Me@?$AutoCleanup@VAutoLocalFree@@PAX@@AAAAAVAutoLocalFree@@XZ +?Me@?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@AAAAAVAutoMIClass@@XZ +?Me@?$AutoCleanup@VAutoMIInstance@@PAU_MI_Instance@@@@AAAAAVAutoMIInstance@@XZ +?Me@?$AutoCleanup@VAutoObject@@PAUWSMAN_OBJECT@@@@AAAAAVAutoObject@@XZ +?Me@?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@AAAAAVAutoRegKey@@XZ +?Me@?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@AAAAAVAutoSecurityDescriptor@@XZ +?Me@?$AutoCleanup@VAutoWaitHandle@@PAX@@AAAAAVAutoWaitHandle@@XZ +?MoveSettingsToMigrationKey@@YAHPAVIRequestContext@@_N@Z +?NUM_BOMS@PacketFormatter@@0HB +?NUM_CHARSETS@PacketFormatter@@0HB +?Next@TSTRBUFFER@@QBAPBGPBG@Z +?NextCertMapping@CConfigManager@@QAAHXZ +?NextListener@CConfigManager@@QAAHXZ +?NextRow@CConfigManager@@QAAHXZ +?NextShellUri@CConfigManager@@QAAHXZ +?NoSemantics@ExtendedSemantic@@2KB +?NotifyObservers@CWSManGroupPolicyManager@@UAAHPAVIRequestContext@@PAVIWSManGroupPolicyCacheDataProvider@@@Z +?OnChange@CBaseConfigCache@@UAAXW4ConfigChangeSources@@KW4ConfigChangeSeverityType@@@Z +?OpenRegKey@ConfigRegistry@@IAAJPAU_CONFIG_INFO@@KPAVWSMANCONFIGTABLE_IDENTITY@@PAVAutoRegKey@@PAUHKEY__@@@Z +?OverrideMaxEnvelopeSize@PacketParser@@QAAXK@Z +?OverrideTimeout@PacketParser@@QAAXK@Z +?Parse@CWSManResource@@SAPAV1@PAVIRequestContext@@PBG11PAU_WSMAN_SELECTOR_SET@@PAU_WSMAN_OPTION_SET@@H@Z +?Parse@CWSManResource@@SAPAV1@PAVIRequestContext@@PBGH@Z +?Parse@XmlReader@@AAAHPAVIRequestContext@@@Z +?ParseAction@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@_N@Z +?ParseActivityId@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseBookmark@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseDataLocale@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseEprElement@CWSManEPR@@SAPAV1@PAVIRequestContext@@PAU_FWXML_ELEMENT@@@Z +?ParseEvent@SoapSemanticConverter@@QAAPAVSemanticMessage@@PAU_FWXML_ELEMENT@@PAKPAVIRequestContext@@@Z +?ParseFaultTo@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseFragment@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseHeader@PacketParser@@AAAHPAVCRequestContext@@PAU_FWXML_ELEMENT@@HPAVCServiceCommonConfigSettings@@@Z +?ParseHeaders@CWSManResourceNoResourceUri@@QAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@11@Z +?ParseHeaders@PacketParser@@AAAHPAVCRequestContext@@PAVCServiceCommonConfigSettings@@@Z +?ParseLocale@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseMachineID@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@@Z +?ParseMaxEnvelopeSize@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@HPAVCServiceCommonConfigSettings@@@Z +?ParseMessageId@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@_N@Z +?ParseOperationId@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseOptionSet@CWSManResourceNoResourceUri@@QAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@@Z +?ParseOptions@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParsePacket@PacketParser@@QAAHPAVCRequestContext@@PAVPacket@@PAVCServiceCommonConfigSettings@@@Z +?ParsePacketInternal@PacketParser@@AAAHPAVCRequestContext@@PAU_FWXML_ELEMENT@@PAVCServiceCommonConfigSettings@@@Z +?ParseReplyTo@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@@Z +?ParseResourceLocator@CWSManResource@@SAPAV1@PAVIRequestContext@@PAU_WSMAN_RESOURCE_LOCATOR@@@Z +?ParseResourceUri@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseResponse@SoapSemanticConverter@@QAA_NPAU_FWXML_ELEMENT@@PAKPA_NPAVIRequestContext@@@Z +?ParseRobustConnectionAckSequenceId@PacketParser@@AAAKPA_K@Z +?ParseRobustConnectionMessages@PacketParser@@QAAKPAW4PacketType@1@PA_NPA_K2@Z +?ParseSelectors@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseSequenceId@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@@Z +?ParseSessionId@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseShellCompression@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseStream@PacketParser@@QAAXPAVCRequestContext@@PAVITransportReceiver@@PAVPacket@@PAVCServiceCommonConfigSettings@@@Z +?ParseSubscriptionAgentPacket@PacketParser@@QAAHPAVCRequestContext@@PAVPacket@@PAVCServiceConfigSettings@@@Z +?ParseSubscriptionID@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@H@Z +?ParseTimeout@PacketParser@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@HPAVCServiceCommonConfigSettings@@@Z +?ParseToAddress@PacketParser@@AAAHPAVCRequestContext@@PAU_FWXML_ELEMENT@@@Z +?Passed@CErrorContext@@UBAHXZ +?PolicyChanged@CWSManGroupPolicyManager@@AAAXE@Z +?PostChange@CBaseConfigCache@@MAAHPAVIRequestContext@@PAVCCommonConfigSettings@@1@Z +?PostChange@CServiceConfigCache@@EAAHPAVIRequestContext@@PAVCCommonConfigSettings@@1@Z +?PostError@CBaseConfigCache@@MAAXK@Z +?PostError@CServiceConfigCache@@EAAXK@Z +?PrepareToCommitWithSize@BufferFormatter@@UAAKK@Z +?PrepareToCommitWithSize@CircularBufferFormatter@@UAAKK@Z +?PrintHandleTrace@@YAXPAX@Z +?PrintReleaseTrace@@YAXPAXJ@Z +?PrintUnregisterWaitTrace@@YAXPAX@Z +?ProcessContext@CErrorContext@@UAAHHPAKPAU_WSMAN_FAULT_OBJECT@@@Z +?ProcessContext@CErrorContext@@UAAHHPAU_WSMAN_ERROR@@@Z +?ProcessContext@CRequestContext@@QAAHHPAU_WSMAN_ENUMERATOR_RESULT@@@Z +?ProcessContext@CRequestContext@@QAAHHPAU_WSMAN_EVENTS_RESULT@@@Z +?ProcessContext@CRequestContext@@QAAHHPAU_WSMAN_RESULT@@@Z +?ProcessContext@CRequestContext@@QAAHHPAU_WSMAN_STATUS@@@Z +?ProcessContext@CRequestContext@@UAAHHPAKPAU_WSMAN_FAULT_OBJECT@@@Z +?ProcessContext@CRequestContext@@UAAHHPAU_WSMAN_ERROR@@@Z +?ProcessEPR@CWSManEPR@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@@Z +?ProcessFragmentDialect@CWSManResourceNoResourceUri@@IAAHPAVIRequestContext@@PBGK@Z +?ProcessFragmentPath@CWSManResourceNoResourceUri@@IAAHPAVIRequestContext@@PBGK@Z +?ProcessKey@CWSManResourceNoResourceUri@@IAAHPAVIRequestContext@@PBG1@Z +?ProcessNestedEPR@CWSManResourceNoResourceUri@@IAAHPAVIRequestContext@@PBGPAU_FWXML_ELEMENT@@@Z +?ProcessOption@CWSManResourceNoResourceUri@@IAAHPAVIRequestContext@@PBG11H@Z +?ProcessRefParameters@CWSManEPR@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@@Z +?ProcessRefProperties@CWSManEPR@@AAAHPAVIRequestContext@@PAU_FWXML_ELEMENT@@@Z +?ProcessUri@CWSManResource@@QAAHPAVIRequestContext@@PBGK@Z +?Progress@ExtendedSemantic@@2KB +?PropertySheetPageCallback@CWSManSecurityUI@@UAAJPAUHWND__@@IW4_SI_PAGE_TYPE@@@Z +?ProviderFailure@CErrorContext@@UBAHXZ +?ProviderShutdownCleanup@CWinRSPluginConfigCache@@SAXXZ +?PutOverrideValue@?$PacketElement@K@PacketParser@@QAAXK@Z +?PutOverrideValue@?$PacketElement@PBG@PacketParser@@QAAXPBG@Z +?PutValue@?$PacketElement@K@PacketParser@@QAAXKH@Z +?PutValue@?$PacketElement@PAU_FWXML_ELEMENT@@@PacketParser@@QAAXPAU_FWXML_ELEMENT@@H@Z +?PutValue@?$PacketElement@PBG@PacketParser@@QAAXPBGH@Z +?PutValue@?$PacketElement@_K@PacketParser@@QAAX_KH@Z +?PutValue@Fragment@PacketParser@@QAAXPBG0H@Z +?PutValue@NotUnderstandSoapHeader@PacketParser@@QAAXPBG00@Z +?PutValue@ReferenceParameters@PacketParser@@QAAKPAU_FWXML_ELEMENT@@H@Z +?QueryInterface@CWSManSecurityUI@@UAAJABU_GUID@@PAPAX@Z +?QueryPtr@RBUFFER@@QBAPAXXZ +?QueryRegValue@CConfigManager@@AAAJPAU_CONFIG_INFO@@PAKKPAE1@Z +?QueryRegValue@CWSManGroupPolicyManager@@AAAJPAVIRequestContext@@PBU_WSMAN_POLICY_INFO@@PAKKPAE2@Z +?QuerySize@RBUFFER@@QBAIXZ +?QueryStr@TSTRBUFFER@@QBAPBGXZ +?QuotaComplete@UserRecord@@UAAXPAU_WSMAN_AUTHZ_QUOTA@@KPBG@Z +?ReAlloc@WSManMemory@@SAPAXPAXIHW4_NitsFaultMode@@@Z +?ReadCertMappingRegistryKey@CConfigManager@@SAHPAVIRequestContext@@PAVCERTMAPPING_IDENTITY@@PAG@Z +?ReadCredentialsFromCredmanStore@CConfigManager@@SAHPAVIRequestContext@@PAG1@Z +?ReadCurrentSettings@CClientConfigCache@@EAAPAVCCommonConfigSettings@@PAVIRequestContext@@W4ErrorLogging@@@Z +?ReadCurrentSettings@CServiceConfigCache@@EAAPAVCCommonConfigSettings@@PAVIRequestContext@@W4ErrorLogging@@@Z +?ReadCurrentSettings@CWinRSPluginConfigCache@@EAAPAVCCommonConfigSettings@@PAVIRequestContext@@W4ErrorLogging@@@Z +?ReadDefaultSettings@CClientConfigCache@@EAAPAVCCommonConfigSettings@@PAVIRequestContext@@@Z +?ReadDefaultSettings@CServiceConfigCache@@EAAPAVCCommonConfigSettings@@PAVIRequestContext@@@Z +?ReadDefaultSettings@CWinRSPluginConfigCache@@EAAPAVCCommonConfigSettings@@PAVIRequestContext@@@Z +?ReadShellUriRegistryKey@CConfigManager@@SAHPAVIRequestContext@@PAVSHELLURI_IDENTITY@@PAG@Z +?ReadTableRegistryKey@CConfigManager@@SAHPAVIRequestContext@@PAVWSMANCONFIGTABLE_IDENTITY@@PAG@Z +?ReallocStorage@RBUFFER@@IAAHI@Z +?RecordAccessDenied@CErrorContext@@UAAXXZ +?RecordAccessDenied@CRequestContext@@UAAXXZ +?RecordAccessDeniedWithDetail@CErrorContext@@UAAXKZZ +?RecordAccessDeniedWithDetail@CRequestContext@@UAAXKZZ +?RecordFailure@CErrorContext@@UAAXK@Z +?RecordFailure@CErrorContext@@UAAXKKZZ +?RecordFailure@CErrorContext@@UAAXPAU_WSMAN_FAULT_OBJECT@@@Z +?RecordFailure@CErrorContext@@UAAXW4_MI_Result@@KKZZ +?RecordFailure@CRequestContext@@AAAXKKPAPAD0@Z +?RecordFailure@CRequestContext@@UAAXK@Z +?RecordFailure@CRequestContext@@UAAXKKZZ +?RecordFailure@CRequestContext@@UAAXPAU_WSMAN_FAULT_OBJECT@@@Z +?RecordFailure@CRequestContext@@UAAXW4_MI_Result@@KKZZ +?RecordHresult@CErrorContext@@UAAXKKZZ +?RecordHresult@CRequestContext@@UAAXKKZZ +?RecordHtmlError@CRequestContext@@QAAHKPAU_FWXML_ELEMENT@@@Z +?RecordHtmlError@CRequestContext@@QAAHKPBGK@Z +?RecordMIFailure@IRequestContext@@QAAXW4_MI_Result@@K@Z +?RecordOutOfMemory@CErrorContext@@UAAXXZ +?RecordOutOfMemory@CRequestContext@@UAAXXZ +?RecordProviderFailure@CErrorContext@@UAAXPAU_WSMAN_FAULT_OBJECT@@PBG1@Z +?RecordProviderFailure@CRequestContext@@QAAXKHPBG00@Z +?RecordProviderFailure@CRequestContext@@UAAXPAU_WSMAN_FAULT_OBJECT@@PBG1@Z +?RecordSoapError@CErrorContext@@UAAHKPBG@Z +?RecordSoapError@CRequestContext@@QAAHKPAU_FWXML_ELEMENT@@@Z +?RecordSoapError@CRequestContext@@UAAHKPBG@Z +?RecordText@CRequestContext@@AAAHKPBGIK@Z +?RecordXml@CRequestContext@@AAAHKPAU_FWXML_ELEMENT@@K@Z +?Refresh@UserRecord@@QAAXXZ +?RegisterChild@ChildLifeTimeManager@@QAA_NXZ +?RegisterChunkBoundary@CircularBufferFormatter@@QAAKXZ +?RegisterConfigChangeNotification@CConfigManager@@QAAPAVConfigNotification@@PAX@Z +?RegisterForPolicyNotification@CWSManGroupPolicyManager@@AAAHPAVIRequestContext@@H@Z +RegisterModule +?Release@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@UBAXXZ +?Release@?$SafeMap@PAVCCertMapping@@UEmpty@@V?$SafeSet_Iterator@PAVCCertMapping@@@@@@UBAXXZ +?Release@?$SafeMap@PAVCListenerConnect@@PAV1@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@UBAXXZ +?Release@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@UBAXXZ +?Release@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@UBAXXZ +?Release@?$SafeMap@PAVCListenerReceive@@PAV1@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@UBAXXZ +?Release@?$SafeMap@PAVCListenerSend@@PAV1@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@UBAXXZ +?Release@?$SafeMap@PAVCListenerSignal@@PAV1@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@UBAXXZ +?Release@?$SafeMap@PAVCShellUriSettings@@UEmpty@@V?$SafeSet_Iterator@PAVCShellUriSettings@@@@@@UBAXXZ +?Release@?$SafeMap@PAVCollector@@UEmpty@@V?$SafeMap_Iterator@PAVCollector@@UEmpty@@@@@@UBAXXZ +?Release@?$SafeMap@PAVCollector@@UEmpty@@V?$SafeSet_Iterator@PAVCollector@@@@@@UBAXXZ +?Release@?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeMap_Iterator@PAVHostOperation@@UEmpty@@@@@@UBAXXZ +?Release@?$SafeMap@PAVHostOperation@@UEmpty@@V?$SafeSet_Iterator@PAVHostOperation@@@@@@UBAXXZ +?Release@?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeMap_Iterator@PAVIOperation@@UEmpty@@@@@@UBAXXZ +?Release@?$SafeMap@PAVIOperation@@UEmpty@@V?$SafeSet_Iterator@PAVIOperation@@@@@@UBAXXZ +?Release@?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVListenerSourceSubscription@@UEmpty@@@@@@UBAXXZ +?Release@?$SafeMap@PAVListenerSourceSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@UBAXXZ +?Release@?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeMap_Iterator@PAVPushSubscription@@UEmpty@@@@@@UBAXXZ +?Release@?$SafeMap@PAVPushSubscription@@UEmpty@@V?$SafeSet_Iterator@PAVPushSubscription@@@@@@UBAXXZ +?Release@?$SafeMap@PAXUEmpty@@V?$SafeSet_Iterator@PAX@@@@UBAXXZ +?Release@?$SafeMap@UPluginKey@@KV?$SafeMap_Iterator@UPluginKey@@K@@@@UBAXXZ +?Release@?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@UBAXXZ +?Release@?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@UBAXXZ +?Release@?$SafeMap@VGuidKey@@PAVCListenerCommand@@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@UBAXXZ +?Release@?$SafeMap@VKey@CWmiPtrCache@@VMapping@2@V?$SafeMap_Iterator@VKey@CWmiPtrCache@@VMapping@2@@@@@UBAXXZ +?Release@?$SafeMap@VKey@Locale@@KV?$SafeMap_Iterator@VKey@Locale@@K@@@@UBAXXZ +?Release@?$SafeMap@VStringKey@@PAVListenerEvents@@V?$SafeMap_Iterator@VStringKey@@PAVListenerEvents@@@@@@UBAXXZ +?Release@?$SafeMap@VStringKey@@PAVListenerSourceSubscription@@V?$SafeMap_Iterator@VStringKey@@PAVListenerSourceSubscription@@@@@@UBAXXZ +?Release@?$SafeMap@VStringKey@@UOption@WinRM_OperationOptions@@V?$SafeMap_Iterator@VStringKey@@UOption@WinRM_OperationOptions@@@@@@UBAXXZ +?Release@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@UBAXXZ +?Release@?$SafeMap@VStringKeyCI@@PAVIISEndpoint@@V?$SafeMap_Iterator@VStringKeyCI@@PAVIISEndpoint@@@@@@UBAXXZ +?Release@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeMap_Iterator@VStringKeyCI@@UEmpty@@@@@@UBAXXZ +?Release@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@UBAXXZ +?Release@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@UBAXXZ +?Release@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@UBAXXZ +?Release@?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@UBAXXZ +?Release@?$SafeMap@VTokenCacheKey@ServiceSoapProcessor@@VTokenCacheMapping@2@V?$SafeMap_Iterator@VTokenCacheKey@ServiceSoapProcessor@@VTokenCacheMapping@2@@@@@UBAXXZ +?Release@?$SafeMap@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@UBAXXZ +?Release@?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@UBAXXZ +?Release@?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@QAAXXZ +?Release@?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@QAAXXZ +?Release@?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@QAAXXZ +?Release@?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QAAXXZ +?Release@?$SafeMap_Iterator@VStringKeyCI@@K@@QAAXXZ +?Release@?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QAAXXZ +?Release@?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAAXXZ +?Release@?$SafeMap_Lock@PAVCCertMapping@@UEmpty@@V?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@@@QAAXXZ +?Release@?$SafeMap_Lock@PAVCListenerOperation@@UEmpty@@V?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@@@QAAXXZ +?Release@?$SafeMap_Lock@PAVCShellUriSettings@@UEmpty@@V?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@@@QAAXXZ +?Release@?$SafeMap_Lock@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QAAXXZ +?Release@?$SafeMap_Lock@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAAXXZ +?Release@?$SafeMap_Lock@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAAXXZ +?Release@?$SafeMap_Lock@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@QAAXXZ +?Release@CBaseConfigCache@@UAAJP6AXPAX@Z0@Z +?Release@CWSManCriticalSection@@QAAXXZ +?Release@CWSManSecurityUI@@UAAKXZ +?Release@ILifeTimeMgmt@@UAAJP6AXPAX@Z0@Z +?Release@UserRecord@@QAAJXZ +?ReleaseExclusive@FastLock@@QAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@D@@PAD@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@G@@PAG@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@UIPRange@CWSManIPFilter@@@@PAUIPRange@CWSManIPFilter@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@U_SID@@@@PAU_SID@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@U_WSMAN_STREAM_ID_SET@@@@PAU_WSMAN_STREAM_ID_SET@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$Handle@VISubscription@@@@@@PAV?$Handle@VISubscription@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerConnect@@PAV1@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerReceive@@PAV1@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerSend@@PAV1@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@PAV?$SafeMap_Iterator@PAVCListenerSignal@@PAV1@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@PAV?$SafeMap_Iterator@VGuidKey@@PAVCListenerCommand@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@VStringKeyCI@@K@@@@PAV?$SafeMap_Iterator@VStringKeyCI@@K@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@PAV?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCCertMapping@@@@@@PAV?$SafeSet@PAVCCertMapping@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeSet@PAVCShellUriSettings@@@@@@PAV?$SafeSet@PAVCShellUriSettings@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@PAV?$SafeSet_Iterator@PAVCListenerOperation@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVCollector@@@@@@PAV?$SafeSet_Iterator@PAVCollector@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVHostOperation@@@@@@PAV?$SafeSet_Iterator@PAVHostOperation@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@PAV?$SafeSet_Iterator@PAVListenerSourceSubscription@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SimpleStack@VCListenerOperation@@@@@@PAV?$SimpleStack@VCListenerOperation@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$SimpleStack@VShellHostEntry@@@@@@PAV?$SimpleStack@VShellHostEntry@@@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$queue@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$deque@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$transport_allocator@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@@@@std@@@std@@@@PAV?$queue@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$deque@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@V?$transport_allocator@PAU_WSMAN_PUBLISHER_EVENT_STRUCT@@@@@std@@@std@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@PAV?$set@PAVCListenerSettings@@VCListenerSettingsLessFunctor@CServiceConfigSettings@@V?$transport_allocator@PAVCListenerSettings@@@@@std@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@PAV?$set@Usockaddr_storage@@VSockAddrLessFunctor@CListenerSettings@@V?$transport_allocator@Usockaddr_storage@@@@@std@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$vector@PAVCWSManRequest@@V?$transport_allocator@PAVCWSManRequest@@@@@std@@@@PAV?$vector@PAVCWSManRequest@@V?$transport_allocator@PAVCWSManRequest@@@@@std@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@PAV?$vector@PAVHandleImpl@Client@WSMan@@V?$transport_allocator@PAVHandleImpl@Client@WSMan@@@@@std@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@PAV?$vector@PAVIServiceConfigObserver@@V?$transport_allocator@PAVIServiceConfigObserver@@@@@std@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@V?$vector@PAVWSManHttpSenderConnection@@V?$transport_allocator@PAVWSManHttpSenderConnection@@@@@std@@@@PAV?$vector@PAVWSManHttpSenderConnection@@V?$transport_allocator@PAVWSManHttpSenderConnection@@@@@std@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VAdminSid@CSecurity@@@@PAVAdminSid@CSecurity@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VBlockedRecord@@@@PAVBlockedRecord@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCCertMapping@@@@PAVCCertMapping@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCConfigChangeSource@@@@PAVCConfigChangeSource@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCListenerSettings@@@@PAVCListenerSettings@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCObserverConfigChangeErrors@@@@PAVCObserverConfigChangeErrors@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCServiceWatcher@CServiceConfigCache@@@@PAVCServiceWatcher@CServiceConfigCache@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCShellUriSettings@@@@PAVCShellUriSettings@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCWSManEPR@@@@PAVCWSManEPR@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCWSManResource@@@@PAVCWSManResource@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCertHash@@@@PAVCertHash@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VConfigUpdate@@@@PAVConfigUpdate@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VCredUIDllLoader@@@@PAVCredUIDllLoader@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VEventHandler@WSMan@@@@PAVEventHandler@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VExpiredOperationIdRecord@@@@PAVExpiredOperationIdRecord@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VGPApiManager@@@@PAVGPApiManager@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VIChannelObserverFactory@@@@PAVIChannelObserverFactory@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VInteractiveSid@CSecurity@@@@PAVInteractiveSid@CSecurity@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VIpHlpApiDllLoader@@@@PAVIpHlpApiDllLoader@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VMachineName@@@@PAVMachineName@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VMasterReceiveData@CListenerReceive@@@@PAVMasterReceiveData@CListenerReceive@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VNetworkServiceSid@CSecurity@@@@PAVNetworkServiceSid@CSecurity@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VNtDsApiDllLoader@@@@PAVNtDsApiDllLoader@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VOptionValue@SessionOptions@Client@WSMan@@@@PAVOptionValue@SessionOptions@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VPacketCreator@@@@PAVPacketCreator@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VPacketParser@@@@PAVPacketParser@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VResources@Locale@@@@PAVResources@Locale@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VRunAsConfiguration@@@@PAVRunAsConfiguration@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VSecurityEntry@Catalog@@@@PAVSecurityEntry@Catalog@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VSendPacketArgs@RobustConnectionBuffer@@@@PAVSendPacketArgs@RobustConnectionBuffer@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VServiceSoapProcessor@@@@PAVServiceSoapProcessor@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VShell32DllLoader@@@@PAVShell32DllLoader@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VShlWApiDllLoader@@@@PAVShlWApiDllLoader@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VSubscriptionEnumerator@@@@PAVSubscriptionEnumerator@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VSubscriptionManager@@@@PAVSubscriptionManager@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VUniqueStringOverflow@@@@PAVUniqueStringOverflow@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VUser32DllLoader@@@@PAVUser32DllLoader@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VWSMANCONFIGTABLE_IDENTITY@@@@PAVWSMANCONFIGTABLE_IDENTITY@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VWSManMemCryptManager@@@@PAVWSManMemCryptManager@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@$$CBG@@PBG@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@D@@PAD@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@H@@PAH@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@U_CONFIG_UPDATE@@@@PAU_CONFIG_UPDATE@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@U_WSMAN_OPTION@@@@PAU_WSMAN_OPTION@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoDeleteVector@X@@PAX@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoFree@E@@PAE@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoLocklessItemRecycle@VPacket@@@@PAVPacket@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIAppHostChildElementCollection@@@@PAUIAppHostChildElementCollection@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIAppHostElement@@@@PAUIAppHostElement@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIAppHostElementCollection@@@@PAUIAppHostElementCollection@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIAppHostProperty@@@@PAUIAppHostProperty@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIAppHostPropertyCollection@@@@PAUIAppHostPropertyCollection@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VApplication@Client@WSMan@@@@PAVApplication@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCBaseConfigCache@@@@PAVCBaseConfigCache@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCClientConfigCache@@@@PAVCClientConfigCache@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCClientConfigSettings@@@@PAVCClientConfigSettings@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCCommonConfigSettings@@@@PAVCCommonConfigSettings@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@PAVCConfigCacheMap@CBaseConfigCache@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCConfigManager@@@@PAVCConfigManager@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCListenerCommand@@@@PAVCListenerCommand@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCListenerMasterOperation@@@@PAVCListenerMasterOperation@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCListenerReceive@@@@PAVCListenerReceive@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCListenerShell@@@@PAVCListenerShell@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCRemoteOperation@@@@PAVCRemoteOperation@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCRemoteSession@@@@PAVCRemoteSession@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCRequestContext@@@@PAVCRequestContext@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCServiceCommonConfigSettings@@@@PAVCServiceCommonConfigSettings@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCServiceConfigCache@@@@PAVCServiceConfigCache@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCServiceConfigSettings@@@@PAVCServiceConfigSettings@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyCache@@@@PAVCWSManGroupPolicyCache@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCWSManGroupPolicyManager@@@@PAVCWSManGroupPolicyManager@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCWSManObject@@@@PAVCWSManObject@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCWSManResource@@@@PAVCWSManResource@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCWSManSession@@@@PAVCWSManSession@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigSettings@@@@PAVCWinRSPluginConfigSettings@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCommand@Client@WSMan@@@@PAVCommand@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VConfigNotification@@@@PAVConfigNotification@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VConnectShellOperation@Client@WSMan@@@@PAVConnectShellOperation@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VCreateShellOperation@Client@WSMan@@@@PAVCreateShellOperation@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VDeleteShellOperation@Client@WSMan@@@@PAVDeleteShellOperation@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VDisconnectOperation@Client@WSMan@@@@PAVDisconnectOperation@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VHostMappingTable@@@@PAVHostMappingTable@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VIISConfigSettings@@@@PAVIISConfigSettings@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VIPCSoapProcessor@@@@PAVIPCSoapProcessor@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VISubscription@@@@PAVISubscription@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VInboundRequestDetails@@@@PAVInboundRequestDetails@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VProxyManager@Client@WSMan@@@@PAVProxyManager@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VProxySelection@Client@WSMan@@@@PAVProxySelection@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VPushSubscribeOperation@@@@PAVPushSubscribeOperation@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VPushSubscription@@@@PAVPushSubscription@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VReceiveOperation@Client@WSMan@@@@PAVReceiveOperation@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VReconnectOperation@Client@WSMan@@@@PAVReconnectOperation@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VSendOperation@Client@WSMan@@@@PAVSendOperation@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VShellInfo@@@@PAVShellInfo@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VSignalOperation@Client@WSMan@@@@PAVSignalOperation@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VUserRecord@@@@PAVUserRecord@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoRelease@VWSManHttpListener@@@@PAVWSManHttpListener@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoReleaseEx@VHostMappingTableEntry@@@@PAVHostMappingTableEntry@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@V?$AutoReleaseEx@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoBstr@@PAG@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoChainContext@@PBU_CERT_CHAIN_CONTEXT@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoCoTaskMemFree@@PAX@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoEnvironmentBlock@@PAX@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoFwXmlCloseParser@@PAX@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoHandle@@PAX@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoImpersonateUser@@PAX@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoLibrary@@PAUHINSTANCE__@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoLocalFree@@PAX@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoMIInstance@@PAU_MI_Instance@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoObject@@PAUWSMAN_OBJECT@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@AAAXXZ +?ReleasePtr@?$AutoCleanup@VAutoWaitHandle@@PAX@@AAAXXZ +?ReleaseQuota@UserRecord@@QAAXW4OperationType@@PBVProvider@Catalog@@@Z +?ReleaseShared@FastLock@@QAAXXZ +?Remove@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QAA_NABQAVCListenerOperation@@@Z +?Remove@?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QAA_NABUUserKey@@@Z +?Remove@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QAA_NABVStringKeyCI@@@Z +?Remove@?$SafeMap@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@V?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@@@QAA_NABVStringKeyCI@@@Z +?Remove@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QAA_NABVStringKeyStore@@@Z +?Remove@?$SafeMap@VStringKeyStore@@PAVServerFullDuplexChannel@@V?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@@@QAA_NABVStringKeyStore@@@Z +?Remove@?$SafeMap@_KPAVSendPacketArgs@RobustConnectionBuffer@@V?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@@@QAA_NAB_K@Z +?RemoveAll@CBaseConfigCache@@KAXPAVFastLock@@AAV?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@@Z +?RemoveFromMap@CBaseConfigCache@@AAAHXZ +?RemoveHttpsBinding@@YAXPBG@Z +?RemoveHttpsCertificate@@YAXPBG0@Z +?RemoveObserver@CServiceConfigCache@@AAAHPAVIServiceConfigObserver@@@Z +?ReportEventW@EventLog@@SAXGKGPAPBG@Z +?Reset@?$PacketElement@K@PacketParser@@QAAX_N@Z +?Reset@?$PacketElement@PAU_FWXML_ELEMENT@@@PacketParser@@QAAX_N@Z +?Reset@?$PacketElement@PBG@PacketParser@@QAAX_N@Z +?Reset@?$PacketElement@_K@PacketParser@@QAAX_N@Z +?Reset@?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@PAXUEmpty@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@UPluginKey@@K@@QAAXXZ +?Reset@?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@VKey@Locale@@K@@QAAXXZ +?Reset@?$SafeMap_Iterator@VStringKeyCI@@K@@QAAXXZ +?Reset@?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@QAAXXZ +?Reset@?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@QAAXXZ +?Reset@BufferFormatter@@UAAXXZ +?Reset@CErrorContext@@UAAXH@Z +?Reset@CRequestContext@@UAAXH@Z +?Reset@CircularBufferFormatter@@UAAXXZ +?Reset@Locale@@QAAXXZ +?Reset@TSTRBUFFER@@QAAXXZ +?Reset@UserRecord@@QAAXXZ +?ResetProfileCount@UserRecord@@QAAXXZ +?ResetRobustConnectionHeaders@PacketParser@@AAAXXZ +?Resize@RBUFFER@@QAAHI@Z +?Resize@RBUFFER@@QAAHII@Z +?ResizeOptionList@CWSManResourceNoResourceUri@@IAA_NIAAVIRequestContext@@@Z +?RestoreAllPrivileges@@YAHPAU_TOKEN_PRIVILEGES@@@Z +?RetrieveCertMappingIdentity@CConfigManager@@AAAHPAUHKEY__@@PAVCERTMAPPING_IDENTITY@@@Z +?RetrieveListenerIdentity@CConfigManager@@AAAHPAUHKEY__@@PAGPAPAGPAVLISTENER_IDENTITY@@@Z +?RetrieveShellUriIdentity@CConfigManager@@AAAHPAUHKEY__@@PAVSHELLURI_IDENTITY@@@Z +?RetrieveTableIdentity@CConfigManager@@AAAHPAUHKEY__@@PAVWSMANCONFIGTABLE_IDENTITY@@@Z +?RevertToSelf@CSecurity@@SAHXZ +?RtlSecureZeroMemory@XmlReader@@QAAXXZ +?SafeStringToUI64@@YAJPBGEHPA_KPAVIRequestContext@@K@Z +?SetBOM@PacketFormatter@@QAA_NPAVPacket@@@Z +?SetBOM@PacketFormatter@@QAA_NPBEK@Z +?SetCIM_Error@CErrorContext@@UAAXXZ +?SetCIM_Error@CRequestContext@@UAAXXZ +?SetCharset@PacketFormatter@@QAAXW4Charset@1@@Z +?SetCharset@PacketFormatter@@QAA_NPBDK_NPA_N@Z +?SetCharsetAndBom@PacketFormatter@@QAAXW4Charset@1@0@Z +?SetConfigToUseDefaults@CErrorContext@@UAAXH@Z +?SetErrorAction@ExtendedSemantic@@QAAXW4_MI_OperationCallback_ResponseType@@W4_MI_CallbackMode@@@Z +?SetErrorState@CBaseConfigCache@@AAAXPAVCRequestContext@@K@Z +?SetExactCharSize@TSTRBUFFER@@QAAJI@Z +?SetExtendedErrorString@CErrorContext@@UAAXPAG@Z +?SetExtendedErrorString@CRequestContext@@UAAXPAG@Z +?SetExtraLogInfo@CErrorContext@@QAAXPBG000@Z +?SetFault@CErrorContext@@UAAXKKKPBG@Z +?SetFault@CRequestContext@@EAAXKKKPBG@Z +?SetFinishValue@ConfigRegistry@@IAAHPAVIRequestContext@@@Z +?SetFormatterMode@BufferFormatter@@QAAXW4Charset@PacketFormatter@@0@Z +?SetFragmentDialect@CWSManResourceNoResourceUri@@QAAHPBGPAVIRequestContext@@@Z +?SetFragmentPath@CWSManResourceNoResourceUri@@QAAHPBGPAVIRequestContext@@@Z +?SetGeneratingError@CErrorContext@@UAAXXZ +?SetLocale@CRequestContext@@QAA_NPBGK@Z +?SetLocale@Locale@@QAA_NKPBGPAVIRequestContext@@@Z +?SetMachineName@CRequestContext@@QAAKPBG@Z +?SetMachineName@CRequestContext@@QAAKPBGI@Z +?SetMachineName@CRequestContext@@QAAKXZ +?SetMaxEnvelopeSize@CircularBufferFormatter@@QAAXK@Z +?SetOptionsMustUnderstandValue@CWSManResourceNoResourceUri@@QAAXH@Z +?SetProfileHandle@UserRecord@@QAAX_J@Z +?SetProviderFailure@CErrorContext@@UAAXH@Z +?SetSecurity@CWSManSecurityUI@@UAAJKPAX@Z +?SetSize@TSTRBUFFER@@QAAJII@Z +?SetSizeInUse@SBUFFER@@QAAXI@Z +?SetThreadUILanguage@Locale@@QAA_NPAVIRequestContext@@@Z +?SetUpdateMode@BufferFormatter@@UAAXW4Mode@1@@Z +?SetUpdateMode@CircularBufferFormatter@@UAAXW4Mode@BufferFormatter@@@Z +?SetUri@CWSManResource@@QAAHPBGPAVIRequestContext@@@Z +?SetValid@RBUFFER@@IAAXH@Z +?SetXml@ReferenceParameters@PacketParser@@AAAKAAVBufferFormatter@@PAU_FWXML_ELEMENT@@@Z +?Shutdown@CBaseConfigCache@@IAAXXZ +?Shutdown@CConfigManager@@SAHXZ +?Shutdown@CWSManGroupPolicyManager@@SAHXZ +?Shutdown@ChildLifeTimeManager@@QAAXXZ +?ShutdownLocaleMap@Locale@@SAXXZ +?Size@?$SafeMap@PAVCListenerOperation@@UEmpty@@V?$SafeSet_Iterator@PAVCListenerOperation@@@@@@QBAHXZ +?Size@?$SafeMap@UUserKey@@PAVBlockedRecord@@V?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@@@QBAHXZ +?Size@?$SafeMap@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@V?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@@@QBAHXZ +?Size@?$SafeMap@VStringKeyCI@@KV?$SafeMap_Iterator@VStringKeyCI@@K@@@@QBAHXZ +?Size@?$SafeMap@VStringKeyCI@@UEmpty@@V?$SafeSet_Iterator@VStringKeyCI@@@@@@QBAHXZ +?Size@?$SafeMap@VStringKeyStore@@PAVExpiredOperationIdRecord@@V?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@@@QBAHXZ +?SkipOrphans@?$SafeMap_Iterator@PAVCCertMapping@@UEmpty@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@PAVCListenerOperation@@UEmpty@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@PAVCShellUriSettings@@UEmpty@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@PAXUEmpty@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@UPluginKey@@K@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@UUserKey@@PAVBlockedRecord@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@VCertThumbprintKey@@VCertThumbprintMappedSet@CServiceConfigSettings@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@VKey@Locale@@K@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@VStringKeyCI@@K@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@VStringKeyCI@@UUSER_CONTEXT_INFO@WSManHttpListener@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@VStringKeyStore@@PAVExpiredOperationIdRecord@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@VStringKeyStore@@PAVServerFullDuplexChannel@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@W4WSManSessionOption@@PAVOptionValue@SessionOptions@Client@WSMan@@@@IAAXXZ +?SkipOrphans@?$SafeMap_Iterator@_KPAVSendPacketArgs@RobustConnectionBuffer@@@@IAAXXZ +StartSoapProcessor +StopSoapProcessor +?Storage@?$AutoCleanup@V?$AutoDelete@G@@PAG@@QAAPAPAGXZ +?Storage@?$AutoCleanup@V?$AutoDelete@UIPRange@CWSManIPFilter@@@@PAUIPRange@CWSManIPFilter@@@@QAAPAPAUIPRange@CWSManIPFilter@@XZ +?Storage@?$AutoCleanup@V?$AutoDelete@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAPAPAVEnumSinkEx@@XZ +?Storage@?$AutoCleanup@V?$AutoDelete@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAPAPAVGeneralSinkEx@@XZ +?Storage@?$AutoCleanup@V?$AutoDelete@VIQueryDASHSMASHInterface@@@@PAVIQueryDASHSMASHInterface@@@@QAAPAPAVIQueryDASHSMASHInterface@@XZ +?Storage@?$AutoCleanup@V?$AutoDelete@VISpecification@@@@PAVISpecification@@@@QAAPAPAVISpecification@@XZ +?Storage@?$AutoCleanup@V?$AutoDelete@VPacketCreator@@@@PAVPacketCreator@@@@QAAPAPAVPacketCreator@@XZ +?Storage@?$AutoCleanup@V?$AutoDelete@VTSTRBUFFER@@@@PAVTSTRBUFFER@@@@QAAPAPAVTSTRBUFFER@@XZ +?Storage@?$AutoCleanup@V?$AutoDelete@VWmiEnumContext@@@@PAVWmiEnumContext@@@@QAAPAPAVWmiEnumContext@@XZ +?Storage@?$AutoCleanup@V?$AutoDelete@VXmlReader@@@@PAVXmlReader@@@@QAAPAPAVXmlReader@@XZ +?Storage@?$AutoCleanup@V?$AutoDeleteVector@$$CBG@@PBG@@QAAPAPBGXZ +?Storage@?$AutoCleanup@V?$AutoDeleteVector@E@@PAE@@QAAPAPAEXZ +?Storage@?$AutoCleanup@V?$AutoDeleteVector@G@@PAG@@QAAPAPAGXZ +?Storage@?$AutoCleanup@V?$AutoDeleteVector@PAG@@PAPAG@@QAAPAPAPAGXZ +?Storage@?$AutoCleanup@V?$AutoDeleteVector@PBG@@PAPBG@@QAAPAPAPBGXZ +?Storage@?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@PAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@@@QAAPAPAU_WINRS_CREATE_SHELL_ENVIRONMENT_VARIABLE@@XZ +?Storage@?$AutoCleanup@V?$AutoDeleteVector@U_WINRS_RUN_COMMAND_ARG@@@@PAU_WINRS_RUN_COMMAND_ARG@@@@QAAPAPAU_WINRS_RUN_COMMAND_ARG@@XZ +?Storage@?$AutoCleanup@V?$AutoDeleteVector@X@@PAX@@QAAPAPAXXZ +?Storage@?$AutoCleanup@V?$AutoFree@E@@PAE@@QAAPAPAEXZ +?Storage@?$AutoCleanup@V?$AutoLocklessItemRecycle@VPacket@@@@PAVPacket@@@@QAAPAPAVPacket@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIAppHostChildElementCollection@@@@PAUIAppHostChildElementCollection@@@@QAAPAPAUIAppHostChildElementCollection@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIAppHostElement@@@@PAUIAppHostElement@@@@QAAPAPAUIAppHostElement@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIAppHostElementCollection@@@@PAUIAppHostElementCollection@@@@QAAPAPAUIAppHostElementCollection@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIAppHostProperty@@@@PAUIAppHostProperty@@@@QAAPAPAUIAppHostProperty@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIAppHostPropertyCollection@@@@PAUIAppHostPropertyCollection@@@@QAAPAPAUIAppHostPropertyCollection@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIClientSecurity@@@@PAUIClientSecurity@@@@QAAPAPAUIClientSecurity@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIEnumWbemClassObject@@@@PAUIEnumWbemClassObject@@@@QAAPAPAUIEnumWbemClassObject@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIErrorInfo@@@@PAUIErrorInfo@@@@QAAPAPAUIErrorInfo@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIUnknown@@@@PAUIUnknown@@@@QAAPAPAUIUnknown@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIWbemClassObject@@@@PAUIWbemClassObject@@@@QAAPAPAUIWbemClassObject@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIWbemContext@@@@PAUIWbemContext@@@@QAAPAPAUIWbemContext@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIWbemLocator@@@@PAUIWbemLocator@@@@QAAPAPAUIWbemLocator@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIWbemObjectTextSrc@@@@PAUIWbemObjectTextSrc@@@@QAAPAPAUIWbemObjectTextSrc@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIWbemPath@@@@PAUIWbemPath@@@@QAAPAPAUIWbemPath@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIWbemPathKeyList@@@@PAUIWbemPathKeyList@@@@QAAPAPAUIWbemPathKeyList@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIWbemQualifierSet@@@@PAUIWbemQualifierSet@@@@QAAPAPAUIWbemQualifierSet@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIWbemQuery@@@@PAUIWbemQuery@@@@QAAPAPAUIWbemQuery@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@UIWbemServices@@@@PAUIWbemServices@@@@QAAPAPAUIWbemServices@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VCWSManEPR@@@@PAVCWSManEPR@@@@QAAPAPAVCWSManEPR@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VCWinRSPluginConfigCache@@@@PAVCWinRSPluginConfigCache@@@@QAAPAPAVCWinRSPluginConfigCache@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VCommand@Client@WSMan@@@@PAVCommand@Client@WSMan@@@@QAAPAPAVCommand@Client@WSMan@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VEnumSinkEx@@@@PAVEnumSinkEx@@@@QAAPAPAVEnumSinkEx@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VGeneralSinkEx@@@@PAVGeneralSinkEx@@@@QAAPAPAVGeneralSinkEx@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VIRequestContext@@@@PAVIRequestContext@@@@QAAPAPAVIRequestContext@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VReceiveOperation@Client@WSMan@@@@PAVReceiveOperation@Client@WSMan@@@@QAAPAPAVReceiveOperation@Client@WSMan@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VSendOperation@Client@WSMan@@@@PAVSendOperation@Client@WSMan@@@@QAAPAPAVSendOperation@Client@WSMan@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VShell@Client@WSMan@@@@PAVShell@Client@WSMan@@@@QAAPAPAVShell@Client@WSMan@@XZ +?Storage@?$AutoCleanup@V?$AutoRelease@VSignalOperation@Client@WSMan@@@@PAVSignalOperation@Client@WSMan@@@@QAAPAPAVSignalOperation@Client@WSMan@@XZ +?Storage@?$AutoCleanup@VAutoBstr@@PAG@@QAAPAPAGXZ +?Storage@?$AutoCleanup@VAutoBstrNoAlloc@@PAG@@QAAPAPAGXZ +?Storage@?$AutoCleanup@VAutoCertContext@@PBU_CERT_CONTEXT@@@@QAAPAPBU_CERT_CONTEXT@@XZ +?Storage@?$AutoCleanup@VAutoChainContext@@PBU_CERT_CHAIN_CONTEXT@@@@QAAPAPBU_CERT_CHAIN_CONTEXT@@XZ +?Storage@?$AutoCleanup@VAutoHandle@@PAX@@QAAPAPAXXZ +?Storage@?$AutoCleanup@VAutoImpersonateUser@@PAX@@QAAPAPAXXZ +?Storage@?$AutoCleanup@VAutoLocalFree@@PAX@@QAAPAPAXXZ +?Storage@?$AutoCleanup@VAutoMIClass@@PAU_MI_Class@@@@QAAPAPAU_MI_Class@@XZ +?Storage@?$AutoCleanup@VAutoMIInstance@@PAU_MI_Instance@@@@QAAPAPAU_MI_Instance@@XZ +?Storage@?$AutoCleanup@VAutoRegKey@@PAUHKEY__@@@@QAAPAPAUHKEY__@@XZ +?Storage@?$AutoCleanup@VAutoSecurityDescriptor@@PAX@@QAAPAPAXXZ +?Storage@?$AutoCleanup@VAutoWaitHandle@@PAX@@QAAPAPAXXZ +?StoreData@CWSManResource@@AAAHPAVIRequestContext@@PBG11PAU_WSMAN_SELECTOR_SET@@PAU_WSMAN_OPTION_SET@@@Z +?StoreData@CWSManResource@@QAAHPAVIRequestContext@@PBG@Z +?StoreDataFromResourceLocator@CWSManResource@@AAAHPAVIRequestContext@@PAU_WSMAN_RESOURCE_LOCATOR@@@Z +?StoreExpansion@CResourceAlias@@AAAXPBGPAU_ALIAS_INFORMATION@@@Z +?StreamingOutput@ExtendedSemantic@@2KB +?StringCchEndsWithCI@@YAHPBG0@Z +?StringCchEquals@@YAHPBG0@Z +?StringCchEqualsCI@@YAHPBG0@Z +?StringCchStartsWith@@YAHPBG0@Z +?StringCchStartsWithCI@@YAHPBG0@Z +?StringConcatenate@CWSManResourceNoResourceUri@@IAAHAAPAGAAKKPAG@Z +?StringIsBlank@@YAHPBG@Z +?StringToDword@@YAHPBDPAK@Z +?StringToDword@@YAHPBGPAK@Z +?StringTrimWhitespace@@YAPAGPAG@Z +?Subscribe@CWSManGroupPolicyManager@@UAAHPAVIRequestContext@@PAVIWSManGroupPolicyObserver@@H@Z +?TruncateAt@TSTRBUFFER@@QAAXI@Z +?TryAcquire@CWSManCriticalSection@@QAAHXZ +?UnSubscribe@CWSManGroupPolicyManager@@UAAHPAVIRequestContext@@PAVIWSManGroupPolicyObserver@@@Z +?UninstallMigration@@YAHPAVIRequestContext@@@Z +?UnregisterChild@ChildLifeTimeManager@@QAAXXZ +?UnregisterPolicyNotification@CWSManGroupPolicyManager@@AAAHXZ +?Up@?$LoaderSerializer@VSubscriptionManager@@$01@@AAAJXZ +?UpdateCredentialsInCredmanStore@CConfigManager@@SAHPAVIRequestContext@@PAG1@Z +?UpdateHttpsBinding@@YAHPAVIRequestContext@@PBG1PAH@Z +?UpdateHttpsCertificate@@YAHPAVIRequestContext@@PBG11PAHHU_GUID@@@Z +?UpdateKey@CWSManResourceNoResourceUri@@QAAHPAVIRequestContext@@PBG1@Z +?Uri@CResourceAlias@@QAAPBGXZ +?UseClientToken@UserRecord@@QAA_NXZ +?UseDefaultConfig@CErrorContext@@UBAHXZ +?UsingDefaultLCID@Locale@@QAA_NXZ +?Validate@Locale@@SA_NPAU_WSMAN_DATA@@@Z +?Validate@Locale@@SA_NPBG@Z +?ValidateCBTHardeningLevel@ConfigRegistry@@IAAHPAVIRequestContext@@PBG@Z +?ValidateCertificateHash@ConfigRegistry@@IAAHPAVIRequestContext@@PBG111@Z +?ValidateHeaders@PacketParser@@QAAHPAVIRequestContext@@K@Z +?ValidateHostnameAndCertificateCN@ConfigRegistry@@IAAHPAVIRequestContext@@PBG1@Z +?ValidateIPFilter@ConfigRegistry@@IAAHPAVIRequestContext@@W4ConfigSetting@@PBG@Z +?ValidateInt@CWSManGroupPolicyManager@@AAAHPAVIRequestContext@@PBU_WSMAN_POLICY_INFO@@K@Z +?ValidateInt@ConfigRegistry@@IAAHPAVIRequestContext@@PAU_CONFIG_INFO@@KPBG@Z +?ValidateString@CWSManGroupPolicyManager@@AAAHPAVIRequestContext@@PBU_WSMAN_POLICY_INFO@@PBG@Z +?ValidateString@ConfigRegistry@@IAAHPAVIRequestContext@@PAU_CONFIG_INFO@@PBG@Z +?ValidateTrustedHosts@ConfigRegistry@@IAAHPAVIRequestContext@@PBG@Z +?ValidateUrlPrefix@ConfigRegistry@@IAAHPAVIRequestContext@@PBG@Z +?Verbose@ExtendedSemantic@@2KB +?VerifyState@RBUFFER@@IBAXXZ +?WSManError@@YAXPBGK0KPAVIRequestContext@@@Z +?WSManMemoryOperation@@YAHW4WSMANMEMOPERATION@@PAXKK@Z +?WSManPostThreadMessageW@@YAHKIIJ@Z +?WaitForAllChildrenToUnregister@ChildLifeTimeManager@@QAAXK@Z +?WaitForConditionVar@CWSManCriticalSectionWithConditionVar@@QAAKK@Z +?WaitForMore@PacketParser@@UAA_NXZ +?WakeAllWaitingForConditionVar@CWSManCriticalSectionWithConditionVar@@QAAXXZ +?WakeAllWaitingOnNoOfChildren@ChildLifeTimeManager@@AAAXXZ +?Warning@EventLog@@SAXK@Z +?Warning@EventLog@@SAXKGPAPBG@Z +?Warning@EventLog@@SAXKPBG@Z +?Warning@ExtendedSemantic@@2KB +?WatchForChanges@CServiceConfigCache@@QAAPAVCServiceWatcher@1@PAVIRequestContext@@PAVIServiceConfigObserver@@@Z +?WrapperCoSetProxyBlanket@@YAJPAUIUnknown@@KKPAGKKPAXKW4BehaviourForNoInterfaceError@@@Z +?Write@EventHandler@WSMan@@SAXABU_EVENT_DESCRIPTOR@@KPAU_EVENT_DATA_DESCRIPTOR@@@Z +?WriteCredentialsToCredmanStore@CConfigManager@@SAHPAVIRequestContext@@PAG1H@Z +?WriteSoapA@EventHandler@WSMan@@SAXABU_EVENT_DESCRIPTOR@@PBDK@Z +?WriteSoapMessageA@EventHandler@WSMan@@AAAXABU_EVENT_DESCRIPTOR@@PBDK@Z +?WriteSoapMessageW@EventHandler@WSMan@@AAAXABU_EVENT_DESCRIPTOR@@PBGK@Z +?WriteSoapMessageW_BE@EventHandler@WSMan@@AAAXABU_EVENT_DESCRIPTOR@@PBGK@Z +?WriteSoapW@EventHandler@WSMan@@SAXABU_EVENT_DESCRIPTOR@@PBGK@Z +?WriteSoapW_BE@EventHandler@WSMan@@SAXABU_EVENT_DESCRIPTOR@@PBGK@Z +?_PolicyChangedCallback@CWSManGroupPolicyManager@@CAXPAXE@Z +?back@?$SimpleQueue@T_LARGE_INTEGER@@@@QBA?BT_LARGE_INTEGER@@XZ +?empty@?$SimpleQueue@T_LARGE_INTEGER@@@@QBA_NXZ +?front@?$SimpleQueue@T_LARGE_INTEGER@@@@QBA?BT_LARGE_INTEGER@@XZ +?g_Resources@Locale@@0V?$Loader@VResources@Locale@@$0A@@@A DATA +?pop@?$SimpleQueue@T_LARGE_INTEGER@@@@QAAXXZ +?push@?$SimpleQueue@T_LARGE_INTEGER@@@@QAAKT_LARGE_INTEGER@@@Z +?s_cacheMap@CClientConfigCache@@0V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@A DATA +?s_cacheMap@CServiceConfigCache@@0V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@A DATA +?s_cacheMap@CWinRSPluginConfigCache@@0V?$AutoRelease@VCConfigCacheMap@CBaseConfigCache@@@@A DATA +?s_config@CConfigManager@@0V?$AutoRelease@VCConfigManager@@@@A DATA +?s_lock@CConfigManager@@0VFastLock@@A DATA +?s_lock@CWSManGroupPolicyManager@@0VFastLock@@A DATA +?s_mapLock@CClientConfigCache@@0VFastLock@@A DATA +?s_mapLock@CServiceConfigCache@@0VFastLock@@A DATA +?s_mapLock@CWinRSPluginConfigCache@@0VFastLock@@A DATA +?s_policyManager@CWSManGroupPolicyManager@@0V?$AutoRelease@VCWSManGroupPolicyManager@@@@A DATA +EnumServiceUserResources +FwGetParsedDocument +FwGetRootElement +FwIsXmlEscapedProperly +FwXmlAddAttributeToAttributeList +FwXmlCloseParser +FwXmlCompareAttributeName +FwXmlCompareAttributeNameEx +FwXmlCompareElementName +FwXmlCompareElementNameEx +FwXmlCompareElementNameLen +FwXmlCompareElementNameSpace +FwXmlCompareName +FwXmlCreateXmlFromElement +FwXmlDecodeXmlEscapes +FwXmlEncodeXmlEscapes +FwXmlFindAttribute +FwXmlFindAttributeEx +FwXmlFindChildElement +FwXmlFindChildElementEx +FwXmlGetAttribute +FwXmlGetAttributeNameEx +FwXmlGetAttributeNamespacePrefix +FwXmlGetAttributeValue +FwXmlGetAttributeValueDWord +FwXmlGetBooleanValue +FwXmlGetBuffer +FwXmlGetChild +FwXmlGetElementName +FwXmlGetElementNameEx +FwXmlGetElementNamespacePrefix +FwXmlGetElementNamespaceUrl +FwXmlGetEntryNameEx +FwXmlGetNamespaceForPrefix +FwXmlGetNormalizedString +FwXmlGetReferenceXmlFromElement +FwXmlGetRemainder +FwXmlGetSimpleContent +FwXmlGetSimpleContentEx +FwXmlGetSimpleContentEx2 +FwXmlHasText +FwXmlIsEmpty +FwXmlIsMustUnderstand +FwXmlIsNull +FwXmlIsSimpleContent +FwXmlIsSimpleContentOrEmpty +FwXmlIsTrueValue +FwXmlNumAttributes +FwXmlNumChildren +FwXmlNumChildrenWithName +FwXmlNumConsecutiveChildrenWithName +FwXmlParsePrefixedXML +FwXmlParseStream +FwXmlParseText +FwXmlParserCreate +FwXmlUpdatePrefixes +GetServiceSecurity +MI_Application_InitializeV1 +ServiceMain +SetServiceSecurity +SubscriptionsProvEnumerate +SvchostPushServiceGlobals +WSManAckEvents +WSManAddSubscriptionManagerInternal +WSManCloseCommand +WSManCloseEnumerationHandle +WSManCloseEnumeratorHandle +WSManCloseObjectHandle +WSManCloseOperation +WSManClosePublisherHandle +WSManCloseSession +WSManCloseSessionHandle +WSManCloseShell +WSManCloseSubscriptionHandle +WSManConnectShell +WSManConnectShellCommand +WSManConstructError +WSManCreateEnumeratorInternal +WSManCreateInternal +WSManCreateInternalEx +WSManCreatePullSubscription +WSManCreatePushSubscription +WSManCreateSession +WSManCreateSessionInternal +WSManCreateShell +WSManCreateShellEx +WSManDecodeObject +WSManDeinitialize +WSManDeleteInternal +WSManDeleteInternalEx +WSManDeliverEndSubscriptionNotification +WSManDeliverEvent +WSManDisconnectShell +WSManEncodeObject +WSManEncodeObjectEx +WSManEncodeObjectInternal +WSManEnumerateInternal +WSManEnumerateInternalEx +WSManEnumeratorAddEvent +WSManEnumeratorAddObject +WSManEnumeratorBatchPolicyViolated +WSManEnumeratorNextObject +WSManEnumeratorObjectCount +WSManGetErrorMessage +WSManGetInternal +WSManGetInternalEx +WSManGetSessionOptionAsDword +WSManGetSessionOptionAsString +WSManIdentifyInternal +WSManInitialize +WSManInvokeInternal +WSManInvokeInternalEx +WSManPluginAuthzOperationComplete +WSManPluginAuthzQueryQuotaComplete +WSManPluginAuthzUserComplete +WSManPluginFreeRequestDetails +WSManPluginGetConfiguration +WSManPluginGetOperationParameters +WSManPluginInteractiveCallback +WSManPluginObjectAndBookmarkResult +WSManPluginObjectAndEprResult +WSManPluginObjectResult +WSManPluginOperationComplete +WSManPluginReceiveResult +WSManPluginReportCompletion +WSManPluginReportContext +WSManPluginShutdown +WSManPluginStartup +WSManProvCreate +WSManProvDelete +WSManProvEnumerate +WSManProvGet +WSManProvInvoke +WSManProvPut +WSManPull +WSManPullEvents +WSManPutInternal +WSManPutInternalEx +WSManReceiveShellOutput +WSManReconnectShell +WSManReconnectShellCommand +WSManRemoveSubscriptionManagerInternal +WSManRunShellCommand +WSManRunShellCommandEx +WSManSendShellInput +WSManSetSessionOption +WSManSignalShell +mi_clientFT_V1 DATA diff --git a/lib/libc/mingw/libarm32/wsnmp32.def b/lib/libc/mingw/libarm32/wsnmp32.def new file mode 100644 index 0000000000..61e704a901 --- /dev/null +++ b/lib/libc/mingw/libarm32/wsnmp32.def @@ -0,0 +1,58 @@ +; +; Definition file of wsnmp32.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "wsnmp32.dll" +EXPORTS +SnmpGetTranslateMode +SnmpSetTranslateMode +SnmpGetRetransmitMode +SnmpSetRetransmitMode +SnmpGetTimeout +SnmpSetTimeout +SnmpGetRetry +SnmpSetRetry +SnmpConveyAgentAddress +SnmpSetAgentAddress +SnmpGetVendorInfo +SnmpStartup +SnmpCleanup +SnmpOpen +SnmpClose +SnmpSendMsg +SnmpRecvMsg +SnmpRegister +SnmpCreateSession +SnmpListen +SnmpCancelMsg +SnmpStartupEx +SnmpCleanupEx +SnmpListenEx +SnmpStrToEntity +SnmpEntityToStr +SnmpFreeEntity +SnmpSetPort +SnmpStrToContext +SnmpContextToStr +SnmpFreeContext +SnmpCreatePdu +SnmpGetPduData +SnmpSetPduData +SnmpDuplicatePdu +SnmpFreePdu +SnmpCreateVbl +SnmpDuplicateVbl +SnmpFreeVbl +SnmpCountVbl +SnmpGetVb +SnmpSetVb +SnmpDeleteVb +SnmpFreeDescriptor +SnmpEncodeMsg +SnmpDecodeMsg +SnmpStrToOid +SnmpOidToStr +SnmpOidCopy +SnmpOidCompare +SnmpGetLastError diff --git a/lib/libc/mingw/libarm32/xmllite.def b/lib/libc/mingw/libarm32/xmllite.def new file mode 100644 index 0000000000..2cf21b845b --- /dev/null +++ b/lib/libc/mingw/libarm32/xmllite.def @@ -0,0 +1,13 @@ +; +; Definition file of XmlLite.dll +; Automatic generated by gendef +; written by Kai Tietz 2008-2014 +; +LIBRARY "XmlLite.dll" +EXPORTS +CreateXmlReader +CreateXmlReaderInputWithEncodingCodePage +CreateXmlReaderInputWithEncodingName +CreateXmlWriter +CreateXmlWriterOutputWithEncodingCodePage +CreateXmlWriterOutputWithEncodingName diff --git a/lib/libc/musl/arch/aarch64/bits/hwcap.h b/lib/libc/musl/arch/aarch64/bits/hwcap.h index a7484028e0..7ab73f99b6 100644 --- a/lib/libc/musl/arch/aarch64/bits/hwcap.h +++ b/lib/libc/musl/arch/aarch64/bits/hwcap.h @@ -38,3 +38,13 @@ #define HWCAP2_SVEBITPERM (1 << 4) #define HWCAP2_SVESHA3 (1 << 5) #define HWCAP2_SVESM4 (1 << 6) +#define HWCAP2_FLAGM2 (1 << 7) +#define HWCAP2_FRINT (1 << 8) +#define HWCAP2_SVEI8MM (1 << 9) +#define HWCAP2_SVEF32MM (1 << 10) +#define HWCAP2_SVEF64MM (1 << 11) +#define HWCAP2_SVEBF16 (1 << 12) +#define HWCAP2_I8MM (1 << 13) +#define HWCAP2_BF16 (1 << 14) +#define HWCAP2_DGH (1 << 15) +#define HWCAP2_RNG (1 << 16) diff --git a/lib/libc/musl/arch/aarch64/bits/signal.h b/lib/libc/musl/arch/aarch64/bits/signal.h index b71261f568..5098c7341d 100644 --- a/lib/libc/musl/arch/aarch64/bits/signal.h +++ b/lib/libc/musl/arch/aarch64/bits/signal.h @@ -11,7 +11,7 @@ typedef unsigned long greg_t; typedef unsigned long gregset_t[34]; typedef struct { - long double vregs[32]; + __uint128_t vregs[32]; unsigned int fpsr; unsigned int fpcr; } fpregset_t; @@ -34,7 +34,7 @@ struct fpsimd_context { struct _aarch64_ctx head; unsigned int fpsr; unsigned int fpcr; - long double vregs[32]; + __uint128_t vregs[32]; }; struct esr_context { struct _aarch64_ctx head; diff --git a/lib/libc/musl/arch/aarch64/bits/syscall.h.in b/lib/libc/musl/arch/aarch64/bits/syscall.h.in index 93648afdfe..f9457c184a 100644 --- a/lib/libc/musl/arch/aarch64/bits/syscall.h.in +++ b/lib/libc/musl/arch/aarch64/bits/syscall.h.in @@ -289,4 +289,8 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 diff --git a/lib/libc/musl/arch/aarch64/bits/user.h b/lib/libc/musl/arch/aarch64/bits/user.h index d12cdf7fe5..8a1002aa67 100644 --- a/lib/libc/musl/arch/aarch64/bits/user.h +++ b/lib/libc/musl/arch/aarch64/bits/user.h @@ -6,7 +6,7 @@ struct user_regs_struct { }; struct user_fpsimd_struct { - long double vregs[32]; + __uint128_t vregs[32]; unsigned int fpsr; unsigned int fpcr; }; diff --git a/lib/libc/musl/arch/aarch64/pthread_arch.h b/lib/libc/musl/arch/aarch64/pthread_arch.h index e64b126d2c..3909616c37 100644 --- a/lib/libc/musl/arch/aarch64/pthread_arch.h +++ b/lib/libc/musl/arch/aarch64/pthread_arch.h @@ -1,12 +1,11 @@ -static inline struct pthread *__pthread_self() +static inline uintptr_t __get_tp() { - char *self; - __asm__ ("mrs %0,tpidr_el0" : "=r"(self)); - return (void*)(self - sizeof(struct pthread)); + uintptr_t tp; + __asm__ ("mrs %0,tpidr_el0" : "=r"(tp)); + return tp; } #define TLS_ABOVE_TP #define GAP_ABOVE_TP 16 -#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread)) #define MC_PC pc diff --git a/lib/libc/musl/arch/arm/bits/syscall.h.in b/lib/libc/musl/arch/arm/bits/syscall.h.in index 11d677635b..7e2fc26697 100644 --- a/lib/libc/musl/arch/arm/bits/syscall.h.in +++ b/lib/libc/musl/arch/arm/bits/syscall.h.in @@ -389,6 +389,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define __ARM_NR_breakpoint 0x0f0001 #define __ARM_NR_cacheflush 0x0f0002 diff --git a/lib/libc/musl/arch/arm/pthread_arch.h b/lib/libc/musl/arch/arm/pthread_arch.h index e689ea212a..157e2eae66 100644 --- a/lib/libc/musl/arch/arm/pthread_arch.h +++ b/lib/libc/musl/arch/arm/pthread_arch.h @@ -1,11 +1,11 @@ #if ((__ARM_ARCH_6K__ || __ARM_ARCH_6KZ__ || __ARM_ARCH_6ZK__) && !__thumb__) \ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH >= 7 -static inline pthread_t __pthread_self() +static inline uintptr_t __get_tp() { - char *p; - __asm__ ( "mrc p15,0,%0,c13,c0,3" : "=r"(p) ); - return (void *)(p-sizeof(struct pthread)); + uintptr_t tp; + __asm__ ( "mrc p15,0,%0,c13,c0,3" : "=r"(tp) ); + return tp; } #else @@ -16,18 +16,17 @@ static inline pthread_t __pthread_self() #define BLX "blx" #endif -static inline pthread_t __pthread_self() +static inline uintptr_t __get_tp() { extern hidden uintptr_t __a_gettp_ptr; - register uintptr_t p __asm__("r0"); - __asm__ ( BLX " %1" : "=r"(p) : "r"(__a_gettp_ptr) : "cc", "lr" ); - return (void *)(p-sizeof(struct pthread)); + register uintptr_t tp __asm__("r0"); + __asm__ ( BLX " %1" : "=r"(tp) : "r"(__a_gettp_ptr) : "cc", "lr" ); + return tp; } #endif #define TLS_ABOVE_TP #define GAP_ABOVE_TP 8 -#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread)) #define MC_PC arm_pc diff --git a/lib/libc/musl/arch/generic/bits/fcntl.h b/lib/libc/musl/arch/generic/bits/fcntl.h index ae233cc003..730a98cfe6 100644 --- a/lib/libc/musl/arch/generic/bits/fcntl.h +++ b/lib/libc/musl/arch/generic/bits/fcntl.h @@ -30,9 +30,15 @@ #define F_SETSIG 10 #define F_GETSIG 11 +#if __LONG_MAX == 0x7fffffffL #define F_GETLK 12 #define F_SETLK 13 #define F_SETLKW 14 +#else +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 +#endif #define F_SETOWN_EX 15 #define F_GETOWN_EX 16 diff --git a/lib/libc/musl/arch/i386/bits/syscall.h.in b/lib/libc/musl/arch/i386/bits/syscall.h.in index 1ae4e48a8f..abdb210d39 100644 --- a/lib/libc/musl/arch/i386/bits/syscall.h.in +++ b/lib/libc/musl/arch/i386/bits/syscall.h.in @@ -426,4 +426,8 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 diff --git a/lib/libc/musl/arch/i386/pthread_arch.h b/lib/libc/musl/arch/i386/pthread_arch.h index 6f600b9e01..a639c382ac 100644 --- a/lib/libc/musl/arch/i386/pthread_arch.h +++ b/lib/libc/musl/arch/i386/pthread_arch.h @@ -1,10 +1,8 @@ -static inline struct pthread *__pthread_self() +static inline uintptr_t __get_tp() { - struct pthread *self; - __asm__ ("movl %%gs:0,%0" : "=r" (self) ); - return self; + uintptr_t tp; + __asm__ ("movl %%gs:0,%0" : "=r" (tp) ); + return tp; } -#define TP_ADJ(p) (p) - #define MC_PC gregs[REG_EIP] diff --git a/lib/libc/musl/arch/i386/syscall_arch.h b/lib/libc/musl/arch/i386/syscall_arch.h index 69642e578a..f92b7aa9f4 100644 --- a/lib/libc/musl/arch/i386/syscall_arch.h +++ b/lib/libc/musl/arch/i386/syscall_arch.h @@ -87,5 +87,3 @@ static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a #define VDSO_CGT32_VER "LINUX_2.6" #define VDSO_CGT_SYM "__vdso_clock_gettime64" #define VDSO_CGT_VER "LINUX_2.6" - -#define SYSCALL_USE_SOCKETCALL diff --git a/lib/libc/musl/arch/mips/bits/syscall.h.in b/lib/libc/musl/arch/mips/bits/syscall.h.in index 86251bf31b..2bb03f067a 100644 --- a/lib/libc/musl/arch/mips/bits/syscall.h.in +++ b/lib/libc/musl/arch/mips/bits/syscall.h.in @@ -408,4 +408,8 @@ #define __NR_fspick 4433 #define __NR_pidfd_open 4434 #define __NR_clone3 4435 +#define __NR_close_range 4436 +#define __NR_openat2 4437 +#define __NR_pidfd_getfd 4438 +#define __NR_faccessat2 4439 diff --git a/lib/libc/musl/arch/mips/pthread_arch.h b/lib/libc/musl/arch/mips/pthread_arch.h index 1e7839ea67..c45347ab92 100644 --- a/lib/libc/musl/arch/mips/pthread_arch.h +++ b/lib/libc/musl/arch/mips/pthread_arch.h @@ -1,19 +1,19 @@ -static inline struct pthread *__pthread_self() +static inline uintptr_t __get_tp() { #if __mips_isa_rev < 2 - register char *tp __asm__("$3"); + register uintptr_t tp __asm__("$3"); __asm__ (".word 0x7c03e83b" : "=r" (tp) ); #else - char *tp; + uintptr_t tp; __asm__ ("rdhwr %0, $29" : "=r" (tp) ); #endif - return (pthread_t)(tp - 0x7000 - sizeof(struct pthread)); + return tp; } #define TLS_ABOVE_TP #define GAP_ABOVE_TP 0 -#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) +#define TP_OFFSET 0x7000 #define DTP_OFFSET 0x8000 #define MC_PC pc diff --git a/lib/libc/musl/arch/mips/syscall_arch.h b/lib/libc/musl/arch/mips/syscall_arch.h index 380a94b366..5b7c38de20 100644 --- a/lib/libc/musl/arch/mips/syscall_arch.h +++ b/lib/libc/musl/arch/mips/syscall_arch.h @@ -149,3 +149,5 @@ static inline long __syscall7(long n, long a, long b, long c, long d, long e, lo #define SO_SNDTIMEO_OLD 0x1005 #define SO_RCVTIMEO_OLD 0x1006 + +#undef SYS_socketcall diff --git a/lib/libc/musl/arch/mips64/bits/fcntl.h b/lib/libc/musl/arch/mips64/bits/fcntl.h index 3bcec15e0d..5da1eef80c 100644 --- a/lib/libc/musl/arch/mips64/bits/fcntl.h +++ b/lib/libc/musl/arch/mips64/bits/fcntl.h @@ -13,7 +13,7 @@ #define O_ASYNC 010000 #define O_DIRECT 0100000 -#define O_LARGEFILE 0 +#define O_LARGEFILE 020000 #define O_NOATIME 01000000 #define O_PATH 010000000 #define O_TMPFILE 020200000 diff --git a/lib/libc/musl/arch/mips64/bits/syscall.h.in b/lib/libc/musl/arch/mips64/bits/syscall.h.in index 9b406e9a4d..045e8238ad 100644 --- a/lib/libc/musl/arch/mips64/bits/syscall.h.in +++ b/lib/libc/musl/arch/mips64/bits/syscall.h.in @@ -338,4 +338,8 @@ #define __NR_fspick 5433 #define __NR_pidfd_open 5434 #define __NR_clone3 5435 +#define __NR_close_range 5436 +#define __NR_openat2 5437 +#define __NR_pidfd_getfd 5438 +#define __NR_faccessat2 5439 diff --git a/lib/libc/musl/arch/mips64/pthread_arch.h b/lib/libc/musl/arch/mips64/pthread_arch.h index 1e7839ea67..c45347ab92 100644 --- a/lib/libc/musl/arch/mips64/pthread_arch.h +++ b/lib/libc/musl/arch/mips64/pthread_arch.h @@ -1,19 +1,19 @@ -static inline struct pthread *__pthread_self() +static inline uintptr_t __get_tp() { #if __mips_isa_rev < 2 - register char *tp __asm__("$3"); + register uintptr_t tp __asm__("$3"); __asm__ (".word 0x7c03e83b" : "=r" (tp) ); #else - char *tp; + uintptr_t tp; __asm__ ("rdhwr %0, $29" : "=r" (tp) ); #endif - return (pthread_t)(tp - 0x7000 - sizeof(struct pthread)); + return tp; } #define TLS_ABOVE_TP #define GAP_ABOVE_TP 0 -#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) +#define TP_OFFSET 0x7000 #define DTP_OFFSET 0x8000 #define MC_PC pc diff --git a/lib/libc/musl/arch/powerpc/bits/syscall.h.in b/lib/libc/musl/arch/powerpc/bits/syscall.h.in index 8d4f79b524..5c6fae3e58 100644 --- a/lib/libc/musl/arch/powerpc/bits/syscall.h.in +++ b/lib/libc/musl/arch/powerpc/bits/syscall.h.in @@ -415,4 +415,8 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 diff --git a/lib/libc/musl/arch/powerpc/pthread_arch.h b/lib/libc/musl/arch/powerpc/pthread_arch.h index ae0f28d6d1..42e88b07e8 100644 --- a/lib/libc/musl/arch/powerpc/pthread_arch.h +++ b/lib/libc/musl/arch/powerpc/pthread_arch.h @@ -1,18 +1,16 @@ -static inline struct pthread *__pthread_self() +static inline uintptr_t __get_tp() { - register char *tp __asm__("r2"); + register uintptr_t tp __asm__("r2"); __asm__ ("" : "=r" (tp) ); - return (pthread_t)(tp - 0x7000 - sizeof(struct pthread)); + return tp; } #define TLS_ABOVE_TP #define GAP_ABOVE_TP 0 -#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) +#define TP_OFFSET 0x7000 #define DTP_OFFSET 0x8000 // the kernel calls the ip "nip", it's the first saved value after the 32 // GPRs. #define MC_PC gregs[32] - -#define CANARY canary_at_end diff --git a/lib/libc/musl/arch/powerpc64/bits/syscall.h.in b/lib/libc/musl/arch/powerpc64/bits/syscall.h.in index b935864c41..edf73d3d6b 100644 --- a/lib/libc/musl/arch/powerpc64/bits/syscall.h.in +++ b/lib/libc/musl/arch/powerpc64/bits/syscall.h.in @@ -387,4 +387,8 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 diff --git a/lib/libc/musl/arch/powerpc64/pthread_arch.h b/lib/libc/musl/arch/powerpc64/pthread_arch.h index 79c3ecd8af..1b7b90797f 100644 --- a/lib/libc/musl/arch/powerpc64/pthread_arch.h +++ b/lib/libc/musl/arch/powerpc64/pthread_arch.h @@ -1,18 +1,16 @@ -static inline struct pthread *__pthread_self() +static inline uintptr_t __get_tp() { - register char *tp __asm__("r13"); + register uintptr_t tp __asm__("r13"); __asm__ ("" : "=r" (tp) ); - return (pthread_t)(tp - 0x7000 - sizeof(struct pthread)); + return tp; } #define TLS_ABOVE_TP #define GAP_ABOVE_TP 0 -#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + 0x7000) +#define TP_OFFSET 0x7000 #define DTP_OFFSET 0x8000 // the kernel calls the ip "nip", it's the first saved value after the 32 // GPRs. #define MC_PC gp_regs[32] - -#define CANARY canary_at_end diff --git a/lib/libc/musl/arch/riscv64/bits/fcntl.h b/lib/libc/musl/arch/riscv64/bits/fcntl.h deleted file mode 100644 index ecb4d18fd1..0000000000 --- a/lib/libc/musl/arch/riscv64/bits/fcntl.h +++ /dev/null @@ -1,38 +0,0 @@ -#define O_CREAT 0100 -#define O_EXCL 0200 -#define O_NOCTTY 0400 -#define O_TRUNC 01000 -#define O_APPEND 02000 -#define O_NONBLOCK 04000 -#define O_DSYNC 010000 -#define O_SYNC 04010000 -#define O_RSYNC 04010000 -#define O_DIRECTORY 0200000 -#define O_NOFOLLOW 0400000 -#define O_CLOEXEC 02000000 - -#define O_ASYNC 020000 -#define O_DIRECT 040000 -#define O_LARGEFILE 0100000 -#define O_NOATIME 01000000 -#define O_PATH 010000000 -#define O_TMPFILE 020200000 -#define O_NDELAY O_NONBLOCK - -#define F_DUPFD 0 -#define F_GETFD 1 -#define F_SETFD 2 -#define F_GETFL 3 -#define F_SETFL 4 -#define F_GETLK 5 -#define F_SETLK 6 -#define F_SETLKW 7 -#define F_SETOWN 8 -#define F_GETOWN 9 -#define F_SETSIG 10 -#define F_GETSIG 11 - -#define F_SETOWN_EX 15 -#define F_GETOWN_EX 16 - -#define F_GETOWNER_UIDS 17 diff --git a/lib/libc/musl/arch/riscv64/bits/signal.h b/lib/libc/musl/arch/riscv64/bits/signal.h index b006334f78..287367db73 100644 --- a/lib/libc/musl/arch/riscv64/bits/signal.h +++ b/lib/libc/musl/arch/riscv64/bits/signal.h @@ -60,10 +60,10 @@ struct sigaltstack { size_t ss_size; }; -typedef struct ucontext_t +typedef struct __ucontext { unsigned long uc_flags; - struct ucontext_t *uc_link; + struct __ucontext *uc_link; stack_t uc_stack; sigset_t uc_sigmask; mcontext_t uc_mcontext; diff --git a/lib/libc/musl/arch/riscv64/bits/syscall.h.in b/lib/libc/musl/arch/riscv64/bits/syscall.h.in index 0043eeba3c..5def016b12 100644 --- a/lib/libc/musl/arch/riscv64/bits/syscall.h.in +++ b/lib/libc/musl/arch/riscv64/bits/syscall.h.in @@ -289,6 +289,10 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 #define __NR_sysriscv __NR_arch_specific_syscall #define __NR_riscv_flush_icache (__NR_sysriscv + 15) diff --git a/lib/libc/musl/arch/riscv64/pthread_arch.h b/lib/libc/musl/arch/riscv64/pthread_arch.h index db414b1702..a20d7fba0d 100644 --- a/lib/libc/musl/arch/riscv64/pthread_arch.h +++ b/lib/libc/musl/arch/riscv64/pthread_arch.h @@ -1,13 +1,12 @@ -static inline struct pthread *__pthread_self() +static inline uintptr_t __get_tp() { - char *tp; + uintptr_t tp; __asm__ __volatile__("mv %0, tp" : "=r"(tp)); - return (void *)(tp - sizeof(struct pthread)); + return tp; } #define TLS_ABOVE_TP #define GAP_ABOVE_TP 0 -#define TP_ADJ(p) ((char *)p + sizeof(struct pthread)) #define DTP_OFFSET 0x800 diff --git a/lib/libc/musl/arch/s390x/bits/alltypes.h.in b/lib/libc/musl/arch/s390x/bits/alltypes.h.in index 15d18c8f4a..6c0eb7f4b8 100644 --- a/lib/libc/musl/arch/s390x/bits/alltypes.h.in +++ b/lib/libc/musl/arch/s390x/bits/alltypes.h.in @@ -9,7 +9,11 @@ TYPEDEF int wchar_t; #endif +#if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 1 TYPEDEF double float_t; +#else +TYPEDEF float float_t; +#endif TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; diff --git a/lib/libc/musl/arch/s390x/bits/float.h b/lib/libc/musl/arch/s390x/bits/float.h index 90b73beed4..e188cb6197 100644 --- a/lib/libc/musl/arch/s390x/bits/float.h +++ b/lib/libc/musl/arch/s390x/bits/float.h @@ -1,4 +1,8 @@ -#define FLT_EVAL_METHOD 1 +#ifdef __FLT_EVAL_METHOD__ +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#else +#define FLT_EVAL_METHOD 0 +#endif #define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L #define LDBL_MIN 3.36210314311209350626267781732175260e-4932L diff --git a/lib/libc/musl/arch/s390x/bits/syscall.h.in b/lib/libc/musl/arch/s390x/bits/syscall.h.in index e89f378299..fb2e60e30b 100644 --- a/lib/libc/musl/arch/s390x/bits/syscall.h.in +++ b/lib/libc/musl/arch/s390x/bits/syscall.h.in @@ -352,4 +352,8 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 diff --git a/lib/libc/musl/arch/s390x/pthread_arch.h b/lib/libc/musl/arch/s390x/pthread_arch.h index e2251f1fa4..e54fec3fe6 100644 --- a/lib/libc/musl/arch/s390x/pthread_arch.h +++ b/lib/libc/musl/arch/s390x/pthread_arch.h @@ -1,14 +1,12 @@ -static inline struct pthread *__pthread_self() +static inline uintptr_t __get_tp() { - struct pthread *self; + uintptr_t tp; __asm__ ( "ear %0, %%a0\n" "sllg %0, %0, 32\n" "ear %0, %%a1\n" - : "=r"(self)); - return self; + : "=r"(tp)); + return tp; } -#define TP_ADJ(p) (p) - #define MC_PC psw.addr diff --git a/lib/libc/musl/arch/s390x/syscall_arch.h b/lib/libc/musl/arch/s390x/syscall_arch.h index afb99852eb..83cc9a27c6 100644 --- a/lib/libc/musl/arch/s390x/syscall_arch.h +++ b/lib/libc/musl/arch/s390x/syscall_arch.h @@ -72,5 +72,3 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo register long r7 __asm__("r7") = f; __asm_syscall("+r"(r2), "r"(r1), "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7)); } - -#define SYSCALL_USE_SOCKETCALL diff --git a/lib/libc/musl/arch/x86_64/bits/syscall.h.in b/lib/libc/musl/arch/x86_64/bits/syscall.h.in index 6a646ad346..a611795104 100644 --- a/lib/libc/musl/arch/x86_64/bits/syscall.h.in +++ b/lib/libc/musl/arch/x86_64/bits/syscall.h.in @@ -345,4 +345,8 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 +#define __NR_openat2 437 +#define __NR_pidfd_getfd 438 +#define __NR_faccessat2 439 diff --git a/lib/libc/musl/arch/x86_64/pthread_arch.h b/lib/libc/musl/arch/x86_64/pthread_arch.h index 65e880c62e..c8c63f2e7a 100644 --- a/lib/libc/musl/arch/x86_64/pthread_arch.h +++ b/lib/libc/musl/arch/x86_64/pthread_arch.h @@ -1,10 +1,8 @@ -static inline struct pthread *__pthread_self() +static inline uintptr_t __get_tp() { - struct pthread *self; - __asm__ ("mov %%fs:0,%0" : "=r" (self) ); - return self; + uintptr_t tp; + __asm__ ("mov %%fs:0,%0" : "=r" (tp) ); + return tp; } -#define TP_ADJ(p) (p) - #define MC_PC gregs[REG_RIP] diff --git a/lib/libc/musl/include/alltypes.h.in b/lib/libc/musl/include/alltypes.h.in index d9ff462e1e..d47aeea9aa 100644 --- a/lib/libc/musl/include/alltypes.h.in +++ b/lib/libc/musl/include/alltypes.h.in @@ -77,6 +77,8 @@ TYPEDEF struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t; STRUCT iovec { void *iov_base; size_t iov_len; }; +STRUCT winsize { unsigned short ws_row, ws_col, ws_xpixel, ws_ypixel; }; + TYPEDEF unsigned socklen_t; TYPEDEF unsigned short sa_family_t; diff --git a/lib/libc/musl/include/elf.h b/lib/libc/musl/include/elf.h index 549f92c1aa..b5e7befb02 100644 --- a/lib/libc/musl/include/elf.h +++ b/lib/libc/musl/include/elf.h @@ -603,6 +603,7 @@ typedef struct { #define PT_GNU_EH_FRAME 0x6474e550 #define PT_GNU_STACK 0x6474e551 #define PT_GNU_RELRO 0x6474e552 +#define PT_GNU_PROPERTY 0x6474e553 #define PT_LOSUNW 0x6ffffffa #define PT_SUNWBSS 0x6ffffffa #define PT_SUNWSTACK 0x6ffffffb @@ -1085,6 +1086,7 @@ typedef struct { #define NT_GNU_BUILD_ID 3 #define NT_GNU_GOLD_VERSION 4 +#define NT_GNU_PROPERTY_TYPE_0 5 diff --git a/lib/libc/musl/include/netinet/if_ether.h b/lib/libc/musl/include/netinet/if_ether.h index a08485e7f7..55a2ff1b17 100644 --- a/lib/libc/musl/include/netinet/if_ether.h +++ b/lib/libc/musl/include/netinet/if_ether.h @@ -59,6 +59,7 @@ #define ETH_P_PREAUTH 0x88C7 #define ETH_P_TIPC 0x88CA #define ETH_P_LLDP 0x88CC +#define ETH_P_MRP 0x88E3 #define ETH_P_MACSEC 0x88E5 #define ETH_P_8021AH 0x88E7 #define ETH_P_MVRP 0x88F5 diff --git a/lib/libc/musl/include/netinet/in.h b/lib/libc/musl/include/netinet/in.h index 103d2e044c..f9594339f0 100644 --- a/lib/libc/musl/include/netinet/in.h +++ b/lib/libc/musl/include/netinet/in.h @@ -101,8 +101,10 @@ uint16_t ntohs(uint16_t); #define IPPROTO_MH 135 #define IPPROTO_UDPLITE 136 #define IPPROTO_MPLS 137 +#define IPPROTO_ETHERNET 143 #define IPPROTO_RAW 255 -#define IPPROTO_MAX 256 +#define IPPROTO_MPTCP 262 +#define IPPROTO_MAX 263 #define IN6_IS_ADDR_UNSPECIFIED(a) \ (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && \ @@ -200,6 +202,7 @@ uint16_t ntohs(uint16_t); #define IP_CHECKSUM 23 #define IP_BIND_ADDRESS_NO_PORT 24 #define IP_RECVFRAGSIZE 25 +#define IP_RECVERR_RFC4884 26 #define IP_MULTICAST_IF 32 #define IP_MULTICAST_TTL 33 #define IP_MULTICAST_LOOP 34 diff --git a/lib/libc/musl/include/netinet/tcp.h b/lib/libc/musl/include/netinet/tcp.h index 44a007aaf5..b7b997f5fd 100644 --- a/lib/libc/musl/include/netinet/tcp.h +++ b/lib/libc/musl/include/netinet/tcp.h @@ -78,6 +78,8 @@ enum { TCP_NLA_DSACK_DUPS, TCP_NLA_REORD_SEEN, TCP_NLA_SRTT, + TCP_NLA_TIMEOUT_REHASH, + TCP_NLA_BYTES_NOTSENT, }; #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) @@ -181,6 +183,13 @@ struct tcphdr { #define TCP_CA_Recovery 3 #define TCP_CA_Loss 4 +enum tcp_fastopen_client_fail { + TFO_STATUS_UNSPEC, + TFO_COOKIE_UNAVAILABLE, + TFO_DATA_NOT_ACKED, + TFO_SYN_RETRANSMITTED, +}; + struct tcp_info { uint8_t tcpi_state; uint8_t tcpi_ca_state; @@ -189,7 +198,7 @@ struct tcp_info { uint8_t tcpi_backoff; uint8_t tcpi_options; uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; - uint8_t tcpi_delivery_rate_app_limited : 1; + uint8_t tcpi_delivery_rate_app_limited : 1, tcpi_fastopen_client_fail : 2; uint32_t tcpi_rto; uint32_t tcpi_ato; uint32_t tcpi_snd_mss; @@ -240,14 +249,15 @@ struct tcp_info { #define TCP_MD5SIG_MAXKEYLEN 80 -#define TCP_MD5SIG_FLAG_PREFIX 1 +#define TCP_MD5SIG_FLAG_PREFIX 0x1 +#define TCP_MD5SIG_FLAG_IFINDEX 0x2 struct tcp_md5sig { struct sockaddr_storage tcpm_addr; uint8_t tcpm_flags; uint8_t tcpm_prefixlen; uint16_t tcpm_keylen; - uint32_t __tcpm_pad; + int tcpm_ifindex; uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; }; @@ -275,6 +285,8 @@ struct tcp_zerocopy_receive { uint64_t address; uint32_t length; uint32_t recv_skip_hint; + uint32_t inq; + int32_t err; }; #endif diff --git a/lib/libc/musl/include/netinet/udp.h b/lib/libc/musl/include/netinet/udp.h index ffd8907962..40c3f2034d 100644 --- a/lib/libc/musl/include/netinet/udp.h +++ b/lib/libc/musl/include/netinet/udp.h @@ -35,6 +35,7 @@ struct udphdr { #define UDP_ENCAP_GTP0 4 #define UDP_ENCAP_GTP1U 5 #define UDP_ENCAP_RXRPC 6 +#define TCP_ENCAP_ESPINTCP 7 #define SOL_UDP 17 diff --git a/lib/libc/musl/include/sched.h b/lib/libc/musl/include/sched.h index 822f464efd..fda4b48460 100644 --- a/lib/libc/musl/include/sched.h +++ b/lib/libc/musl/include/sched.h @@ -49,6 +49,7 @@ int sched_yield(void); #ifdef _GNU_SOURCE #define CSIGNAL 0x000000ff +#define CLONE_NEWTIME 0x00000080 #define CLONE_VM 0x00000100 #define CLONE_FS 0x00000200 #define CLONE_FILES 0x00000400 diff --git a/lib/libc/musl/include/signal.h b/lib/libc/musl/include/signal.h index fbdf667b2f..9ed929e4f2 100644 --- a/lib/libc/musl/include/signal.h +++ b/lib/libc/musl/include/signal.h @@ -180,14 +180,24 @@ struct sigevent { union sigval sigev_value; int sigev_signo; int sigev_notify; - void (*sigev_notify_function)(union sigval); - pthread_attr_t *sigev_notify_attributes; - char __pad[56-3*sizeof(long)]; + union { + char __pad[64 - 2*sizeof(int) - sizeof(union sigval)]; + pid_t sigev_notify_thread_id; + struct { + void (*sigev_notify_function)(union sigval); + pthread_attr_t *sigev_notify_attributes; + } __sev_thread; + } __sev_fields; }; +#define sigev_notify_thread_id __sev_fields.sigev_notify_thread_id +#define sigev_notify_function __sev_fields.__sev_thread.sigev_notify_function +#define sigev_notify_attributes __sev_fields.__sev_thread.sigev_notify_attributes + #define SIGEV_SIGNAL 0 #define SIGEV_NONE 1 #define SIGEV_THREAD 2 +#define SIGEV_THREAD_ID 4 int __libc_current_sigrtmin(void); int __libc_current_sigrtmax(void); diff --git a/lib/libc/musl/include/stdlib.h b/lib/libc/musl/include/stdlib.h index 194c20339e..b54a051fe9 100644 --- a/lib/libc/musl/include/stdlib.h +++ b/lib/libc/musl/include/stdlib.h @@ -145,6 +145,7 @@ int getloadavg(double *, int); int clearenv(void); #define WCOREDUMP(s) ((s) & 0x80) #define WIFCONTINUED(s) ((s) == 0xffff) +void *reallocarray (void *, size_t, size_t); #endif #ifdef _GNU_SOURCE diff --git a/lib/libc/musl/include/sys/fanotify.h b/lib/libc/musl/include/sys/fanotify.h index b637c8f58a..10e5f15e24 100644 --- a/lib/libc/musl/include/sys/fanotify.h +++ b/lib/libc/musl/include/sys/fanotify.h @@ -55,8 +55,9 @@ struct fanotify_response { #define FAN_OPEN_PERM 0x10000 #define FAN_ACCESS_PERM 0x20000 #define FAN_OPEN_EXEC_PERM 0x40000 -#define FAN_ONDIR 0x40000000 +#define FAN_DIR_MODIFY 0x00080000 #define FAN_EVENT_ON_CHILD 0x08000000 +#define FAN_ONDIR 0x40000000 #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) #define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO) #define FAN_CLOEXEC 0x01 @@ -70,6 +71,9 @@ struct fanotify_response { #define FAN_ENABLE_AUDIT 0x40 #define FAN_REPORT_TID 0x100 #define FAN_REPORT_FID 0x200 +#define FAN_REPORT_DIR_FID 0x00000400 +#define FAN_REPORT_NAME 0x00000800 +#define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME) #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS) #define FAN_MARK_ADD 0x01 #define FAN_MARK_REMOVE 0x02 @@ -88,6 +92,8 @@ struct fanotify_response { #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW) #define FANOTIFY_METADATA_VERSION 3 #define FAN_EVENT_INFO_TYPE_FID 1 +#define FAN_EVENT_INFO_TYPE_DFID_NAME 2 +#define FAN_EVENT_INFO_TYPE_DFID 3 #define FAN_ALLOW 0x01 #define FAN_DENY 0x02 #define FAN_AUDIT 0x10 diff --git a/lib/libc/musl/include/sys/ioctl.h b/lib/libc/musl/include/sys/ioctl.h index c2ce3b4840..a9a2346ee7 100644 --- a/lib/libc/musl/include/sys/ioctl.h +++ b/lib/libc/musl/include/sys/ioctl.h @@ -4,6 +4,8 @@ extern "C" { #endif +#define __NEED_struct_winsize + #include #include @@ -47,13 +49,6 @@ extern "C" { #define TIOCSER_TEMT 1 -struct winsize { - unsigned short ws_row; - unsigned short ws_col; - unsigned short ws_xpixel; - unsigned short ws_ypixel; -}; - #define SIOCADDRT 0x890B #define SIOCDELRT 0x890C #define SIOCRTMSG 0x890D diff --git a/lib/libc/musl/include/sys/mman.h b/lib/libc/musl/include/sys/mman.h index 3bade72720..4d603e9104 100644 --- a/lib/libc/musl/include/sys/mman.h +++ b/lib/libc/musl/include/sys/mman.h @@ -101,6 +101,7 @@ extern "C" { #ifdef _GNU_SOURCE #define MREMAP_MAYMOVE 1 #define MREMAP_FIXED 2 +#define MREMAP_DONTUNMAP 4 #define MLOCK_ONFAULT 0x01 diff --git a/lib/libc/musl/include/sys/personality.h b/lib/libc/musl/include/sys/personality.h index 31d43dfe13..411dc47563 100644 --- a/lib/libc/musl/include/sys/personality.h +++ b/lib/libc/musl/include/sys/personality.h @@ -5,7 +5,9 @@ extern "C" { #endif +#define UNAME26 0x0020000 #define ADDR_NO_RANDOMIZE 0x0040000 +#define FDPIC_FUNCPTRS 0x0080000 #define MMAP_PAGE_ZERO 0x0100000 #define ADDR_COMPAT_LAYOUT 0x0200000 #define READ_IMPLIES_EXEC 0x0400000 @@ -17,6 +19,7 @@ extern "C" { #define PER_LINUX 0 #define PER_LINUX_32BIT ADDR_LIMIT_32BIT +#define PER_LINUX_FDPIC FDPIC_FUNCPTRS #define PER_SVR4 (1 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO) #define PER_SVR3 (2 | STICKY_TIMEOUTS | SHORT_INODE) #define PER_SCOSVR3 (3 | STICKY_TIMEOUTS | WHOLE_SECONDS | SHORT_INODE) diff --git a/lib/libc/musl/include/sys/prctl.h b/lib/libc/musl/include/sys/prctl.h index d9c846e9c2..4b9fcc0508 100644 --- a/lib/libc/musl/include/sys/prctl.h +++ b/lib/libc/musl/include/sys/prctl.h @@ -158,6 +158,9 @@ struct prctl_mm_map { #define PR_GET_TAGGED_ADDR_CTRL 56 #define PR_TAGGED_ADDR_ENABLE (1UL << 0) +#define PR_SET_IO_FLUSHER 57 +#define PR_GET_IO_FLUSHER 58 + int prctl (int, ...); #ifdef __cplusplus diff --git a/lib/libc/musl/include/sys/random.h b/lib/libc/musl/include/sys/random.h index 4ee7bf2cc4..59e40ab897 100644 --- a/lib/libc/musl/include/sys/random.h +++ b/lib/libc/musl/include/sys/random.h @@ -10,6 +10,7 @@ extern "C" { #define GRND_NONBLOCK 0x0001 #define GRND_RANDOM 0x0002 +#define GRND_INSECURE 0x0004 ssize_t getrandom(void *, size_t, unsigned); diff --git a/lib/libc/musl/include/termios.h b/lib/libc/musl/include/termios.h index d73c780d41..cbb533010e 100644 --- a/lib/libc/musl/include/termios.h +++ b/lib/libc/musl/include/termios.h @@ -8,6 +8,7 @@ extern "C" { #include #define __NEED_pid_t +#define __NEED_struct_winsize #include @@ -27,6 +28,9 @@ int cfsetispeed (struct termios *, speed_t); int tcgetattr (int, struct termios *); int tcsetattr (int, int, const struct termios *); +int tcgetwinsize (int, struct winsize *); +int tcsetwinsize (int, const struct winsize *); + int tcsendbreak (int, int); int tcdrain (int); int tcflush (int, int); diff --git a/lib/libc/musl/include/unistd.h b/lib/libc/musl/include/unistd.h index 7bcbff943d..1306402603 100644 --- a/lib/libc/musl/include/unistd.h +++ b/lib/libc/musl/include/unistd.h @@ -82,6 +82,7 @@ unsigned sleep(unsigned); int pause(void); pid_t fork(void); +pid_t _Fork(void); int execve(const char *, char *const [], char *const []); int execv(const char *, char *const []); int execle(const char *, const char *, ...); @@ -190,6 +191,7 @@ int syncfs(int); int euidaccess(const char *, int); int eaccess(const char *, int); ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); +pid_t gettid(void); #endif #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) diff --git a/lib/libc/musl/libc.s b/lib/libc/musl/libc.s index 142c027db5..d00dea9f9f 100644 --- a/lib/libc/musl/libc.s +++ b/lib/libc/musl/libc.s @@ -1,110 +1,113 @@ .bss .weak ___environ -.type ___environ, @object; +.type ___environ, %object; ___environ: .globl __daylight -.type __daylight, @object; +.type __daylight, %object; __daylight: .globl __environ -.type __environ, @object; +.type __environ, %object; __environ: .globl __optpos -.type __optpos, @object; +.type __optpos, %object; __optpos: .globl __optreset -.type __optreset, @object; +.type __optreset, %object; __optreset: .globl __progname -.type __progname, @object; +.type __progname, %object; __progname: .globl __progname_full -.type __progname_full, @object; +.type __progname_full, %object; __progname_full: .globl __signgam -.type __signgam, @object; +.type __signgam, %object; __signgam: .globl __stack_chk_guard -.type __stack_chk_guard, @object; +.type __stack_chk_guard, %object; __stack_chk_guard: .globl __timezone -.type __timezone, @object; +.type __timezone, %object; __timezone: .globl __tzname -.type __tzname, @object; +.type __tzname, %object; __tzname: .weak _environ -.type _environ, @object; +.type _environ, %object; _environ: .weak daylight -.type daylight, @object; +.type daylight, %object; daylight: .weak environ -.type environ, @object; +.type environ, %object; environ: .globl getdate_err -.type getdate_err, @object; +.type getdate_err, %object; getdate_err: .globl h_errno -.type h_errno, @object; +.type h_errno, %object; h_errno: .globl optarg -.type optarg, @object; +.type optarg, %object; optarg: .globl optopt -.type optopt, @object; +.type optopt, %object; optopt: .weak optreset -.type optreset, @object; +.type optreset, %object; optreset: .weak program_invocation_name -.type program_invocation_name, @object; +.type program_invocation_name, %object; program_invocation_name: .weak program_invocation_short_name -.type program_invocation_short_name, @object; +.type program_invocation_short_name, %object; program_invocation_short_name: .weak signgam -.type signgam, @object; +.type signgam, %object; signgam: .weak timezone -.type timezone, @object; +.type timezone, %object; timezone: .weak tzname -.type tzname, @object; +.type tzname, %object; tzname: .data .globl _dl_debug_addr -.type _dl_debug_addr, @object; +.type _dl_debug_addr, %object; _dl_debug_addr: .globl opterr -.type opterr, @object; +.type opterr, %object; opterr: .globl optind -.type optind, @object; +.type optind, %object; optind: .data.rel.ro .globl stderr -.type stderr, @object; +.type stderr, %object; stderr: .globl stdin -.type stdin, @object; +.type stdin, %object; stdin: .globl stdout -.type stdout, @object; +.type stdout, %object; stdout: .rodata .globl _ns_flagdata -.type _ns_flagdata, @object; +.type _ns_flagdata, %object; _ns_flagdata: .globl in6addr_any -.type in6addr_any, @object; +.type in6addr_any, %object; in6addr_any: .globl in6addr_loopback -.type in6addr_loopback, @object; +.type in6addr_loopback, %object; in6addr_loopback: .text .globl _Exit .type _Exit, %function; _Exit: +.globl _Fork +.type _Fork, %function; +_Fork: .weak _IO_feof_unlocked .type _IO_feof_unlocked, %function; _IO_feof_unlocked: @@ -2116,6 +2119,9 @@ getsubopt: .globl gettext .type gettext, %function; gettext: +.globl gettid +.type gettid, %function; +gettid: .globl gettimeofday .type gettimeofday, %function; gettimeofday: @@ -2728,7 +2734,7 @@ lutimes: .weak madvise .type madvise, %function; madvise: -.globl malloc +.weak malloc .type malloc, %function; malloc: .globl malloc_usable_size @@ -3709,6 +3715,9 @@ readv: .globl realloc .type realloc, %function; realloc: +.globl reallocarray +.type reallocarray, %function; +reallocarray: .globl realpath .type realpath, %function; realpath: @@ -4543,6 +4552,9 @@ tcgetpgrp: .globl tcgetsid .type tcgetsid, %function; tcgetsid: +.globl tcgetwinsize +.type tcgetwinsize, %function; +tcgetwinsize: .globl tcsendbreak .type tcsendbreak, %function; tcsendbreak: @@ -4552,6 +4564,9 @@ tcsetattr: .globl tcsetpgrp .type tcsetpgrp, %function; tcsetpgrp: +.globl tcsetwinsize +.type tcsetwinsize, %function; +tcsetwinsize: .globl tdelete .type tdelete, %function; tdelete: diff --git a/lib/libc/musl/src/aio/aio.c b/lib/libc/musl/src/aio/aio.c index 6d34fa8693..a1a3e7914b 100644 --- a/lib/libc/musl/src/aio/aio.c +++ b/lib/libc/musl/src/aio/aio.c @@ -9,6 +9,12 @@ #include "syscall.h" #include "atomic.h" #include "pthread_impl.h" +#include "aio_impl.h" + +#define malloc __libc_malloc +#define calloc __libc_calloc +#define realloc __libc_realloc +#define free __libc_free /* The following is a threads-based implementation of AIO with minimal * dependence on implementation details. Most synchronization is @@ -70,6 +76,10 @@ static struct aio_queue *****map; static volatile int aio_fd_cnt; volatile int __aio_fut; +static size_t io_thread_stack_size; + +#define MAX(a,b) ((a)>(b) ? (a) : (b)) + static struct aio_queue *__aio_get_queue(int fd, int need) { if (fd < 0) { @@ -84,6 +94,10 @@ static struct aio_queue *__aio_get_queue(int fd, int need) pthread_rwlock_unlock(&maplock); if (fcntl(fd, F_GETFD) < 0) return 0; pthread_rwlock_wrlock(&maplock); + if (!io_thread_stack_size) { + unsigned long val = __getauxval(AT_MINSIGSTKSZ); + io_thread_stack_size = MAX(MINSIGSTKSZ+2048, val+512); + } if (!map) map = calloc(sizeof *map, (-1U/2+1)>>24); if (!map) goto out; if (!map[a]) map[a] = calloc(sizeof **map, 256); @@ -259,15 +273,6 @@ static void *io_thread_func(void *ctx) return 0; } -static size_t io_thread_stack_size = MINSIGSTKSZ+2048; -static pthread_once_t init_stack_size_once; - -static void init_stack_size() -{ - unsigned long val = __getauxval(AT_MINSIGSTKSZ); - if (val > MINSIGSTKSZ) io_thread_stack_size = val + 512; -} - static int submit(struct aiocb *cb, int op) { int ret = 0; @@ -293,7 +298,6 @@ static int submit(struct aiocb *cb, int op) else pthread_attr_init(&a); } else { - pthread_once(&init_stack_size_once, init_stack_size); pthread_attr_init(&a); pthread_attr_setstacksize(&a, io_thread_stack_size); pthread_attr_setguardsize(&a, 0); @@ -392,6 +396,20 @@ int __aio_close(int fd) return fd; } +void __aio_atfork(int who) +{ + if (who<0) { + pthread_rwlock_rdlock(&maplock); + return; + } + if (who>0 && map) for (int a=0; a<(-1U/2+1)>>24; a++) + if (map[a]) for (int b=0; b<256; b++) + if (map[a][b]) for (int c=0; c<256; c++) + if (map[a][b][c]) for (int d=0; d<256; d++) + map[a][b][c][d] = 0; + pthread_rwlock_unlock(&maplock); +} + weak_alias(aio_cancel, aio_cancel64); weak_alias(aio_error, aio_error64); weak_alias(aio_fsync, aio_fsync64); diff --git a/lib/libc/musl/src/aio/aio_suspend.c b/lib/libc/musl/src/aio/aio_suspend.c index 34b66f8787..1c1060e340 100644 --- a/lib/libc/musl/src/aio/aio_suspend.c +++ b/lib/libc/musl/src/aio/aio_suspend.c @@ -3,6 +3,7 @@ #include #include "atomic.h" #include "pthread_impl.h" +#include "aio_impl.h" int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec *ts) { diff --git a/lib/libc/musl/src/crypt/crypt_blowfish.c b/lib/libc/musl/src/crypt/crypt_blowfish.c index d3f798517e..d722607b02 100644 --- a/lib/libc/musl/src/crypt/crypt_blowfish.c +++ b/lib/libc/musl/src/crypt/crypt_blowfish.c @@ -15,7 +15,7 @@ * No copyright is claimed, and the software is hereby placed in the public * domain. In case this attempt to disclaim copyright and place the software * in the public domain is deemed null and void, then the software is - * Copyright (c) 1998-2012 Solar Designer and it is hereby released to the + * Copyright (c) 1998-2014 Solar Designer and it is hereby released to the * general public under the following terms: * * Redistribution and use in source and binary forms, with or without @@ -31,12 +31,12 @@ * you place this code and any modifications you make under a license * of your choice. * - * This implementation is mostly compatible with OpenBSD's bcrypt.c (prefix - * "$2a$") by Niels Provos , and uses some of his - * ideas. The password hashing algorithm was designed by David Mazieres - * . For more information on the level of compatibility, - * please refer to the comments in BF_set_key() below and to the included - * crypt(3) man page. + * This implementation is fully compatible with OpenBSD's bcrypt.c for prefix + * "$2b$", originally by Niels Provos , and it uses + * some of his ideas. The password hashing algorithm was designed by David + * Mazieres . For information on the level of + * compatibility for bcrypt hash prefixes other than "$2b$", please refer to + * the comments in BF_set_key() below and to the included crypt(3) man page. * * There's a paper on the algorithm that explains its design decisions: * @@ -533,6 +533,7 @@ static void BF_set_key(const char *key, BF_key expanded, BF_key initial, * Valid combinations of settings are: * * Prefix "$2a$": bug = 0, safety = 0x10000 + * Prefix "$2b$": bug = 0, safety = 0 * Prefix "$2x$": bug = 1, safety = 0 * Prefix "$2y$": bug = 0, safety = 0 */ @@ -596,12 +597,14 @@ static void BF_set_key(const char *key, BF_key expanded, BF_key initial, initial[0] ^= sign; } +static const unsigned char flags_by_subtype[26] = { + 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0 +}; + static char *BF_crypt(const char *key, const char *setting, char *output, BF_word min) { - static const unsigned char flags_by_subtype[26] = - {2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0}; struct { BF_ctx ctx; BF_key expanded_key; @@ -746,9 +749,11 @@ char *__crypt_blowfish(const char *key, const char *setting, char *output) { const char *test_key = "8b \xd0\xc1\xd2\xcf\xcc\xd8"; const char *test_setting = "$2a$00$abcdefghijklmnopqrstuu"; - static const char test_hash[2][34] = - {"VUrPmXD6q/nVSSp7pNDhCR9071IfIRe\0\x55", /* $2x$ */ - "i1D709vfamulimlGcq0qq3UvuUasvEa\0\x55"}; /* $2a$, $2y$ */ + static const char test_hashes[2][34] = { + "i1D709vfamulimlGcq0qq3UvuUasvEa\0\x55", /* 'a', 'b', 'y' */ + "VUrPmXD6q/nVSSp7pNDhCR9071IfIRe\0\x55", /* 'x' */ + }; + const char *test_hash = test_hashes[0]; char *retval; const char *p; int ok; @@ -768,8 +773,11 @@ char *__crypt_blowfish(const char *key, const char *setting, char *output) * detected by the self-test. */ memcpy(buf.s, test_setting, sizeof(buf.s)); - if (retval) + if (retval) { + unsigned int flags = flags_by_subtype[setting[2] - 'a']; + test_hash = test_hashes[flags & 1]; buf.s[2] = setting[2]; + } memset(buf.o, 0x55, sizeof(buf.o)); buf.o[sizeof(buf.o) - 1] = 0; p = BF_crypt(test_key, buf.s, buf.o, 1); @@ -777,7 +785,7 @@ char *__crypt_blowfish(const char *key, const char *setting, char *output) ok = (p == buf.o && !memcmp(p, buf.s, 7 + 22) && !memcmp(p + (7 + 22), - test_hash[buf.s[2] & 1], + test_hash, 31 + 1 + 1 + 1)); { diff --git a/lib/libc/musl/src/env/__init_tls.c b/lib/libc/musl/src/env/__init_tls.c index 772baba32d..a93141ed36 100644 --- a/lib/libc/musl/src/env/__init_tls.c +++ b/lib/libc/musl/src/env/__init_tls.c @@ -67,7 +67,7 @@ void *__copy_tls(unsigned char *mem) } #endif dtv[0] = libc.tls_cnt; - td->dtv = td->dtv_copy = dtv; + td->dtv = dtv; return td; } diff --git a/lib/libc/musl/src/env/__stack_chk_fail.c b/lib/libc/musl/src/env/__stack_chk_fail.c index e32596d10f..bf5a280ad9 100644 --- a/lib/libc/musl/src/env/__stack_chk_fail.c +++ b/lib/libc/musl/src/env/__stack_chk_fail.c @@ -9,7 +9,7 @@ void __init_ssp(void *entropy) if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t)); else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245; - __pthread_self()->CANARY = __stack_chk_guard; + __pthread_self()->canary = __stack_chk_guard; } void __stack_chk_fail(void) diff --git a/lib/libc/musl/src/exit/abort.c b/lib/libc/musl/src/exit/abort.c index e1980f10a5..f21f458eca 100644 --- a/lib/libc/musl/src/exit/abort.c +++ b/lib/libc/musl/src/exit/abort.c @@ -6,8 +6,6 @@ #include "lock.h" #include "ksigaction.h" -hidden volatile int __abort_lock[1]; - _Noreturn void abort(void) { raise(SIGABRT); diff --git a/lib/libc/musl/src/exit/abort_lock.c b/lib/libc/musl/src/exit/abort_lock.c new file mode 100644 index 0000000000..3af72c7b6a --- /dev/null +++ b/lib/libc/musl/src/exit/abort_lock.c @@ -0,0 +1,3 @@ +#include "pthread_impl.h" + +volatile int __abort_lock[1]; diff --git a/lib/libc/musl/src/exit/assert.c b/lib/libc/musl/src/exit/assert.c index 49b0dc3ec4..94edd82727 100644 --- a/lib/libc/musl/src/exit/assert.c +++ b/lib/libc/musl/src/exit/assert.c @@ -4,6 +4,5 @@ _Noreturn void __assert_fail(const char *expr, const char *file, int line, const char *func) { fprintf(stderr, "Assertion failed: %s (%s: %s: %d)\n", expr, file, func, line); - fflush(NULL); abort(); } diff --git a/lib/libc/musl/src/exit/at_quick_exit.c b/lib/libc/musl/src/exit/at_quick_exit.c index d3ce6522df..e4b5d78dbb 100644 --- a/lib/libc/musl/src/exit/at_quick_exit.c +++ b/lib/libc/musl/src/exit/at_quick_exit.c @@ -1,12 +1,14 @@ #include #include "libc.h" #include "lock.h" +#include "fork_impl.h" #define COUNT 32 static void (*funcs[COUNT])(void); static int count; static volatile int lock[1]; +volatile int *const __at_quick_exit_lockptr = lock; void __funcs_on_quick_exit() { diff --git a/lib/libc/musl/src/exit/atexit.c b/lib/libc/musl/src/exit/atexit.c index 160d277aeb..854e9fddbe 100644 --- a/lib/libc/musl/src/exit/atexit.c +++ b/lib/libc/musl/src/exit/atexit.c @@ -2,6 +2,12 @@ #include #include "libc.h" #include "lock.h" +#include "fork_impl.h" + +#define malloc __libc_malloc +#define calloc __libc_calloc +#define realloc undef +#define free undef /* Ensure that at least 32 atexit handlers can be registered without malloc */ #define COUNT 32 @@ -15,6 +21,7 @@ static struct fl static int slot; static volatile int lock[1]; +volatile int *const __atexit_lockptr = lock; void __funcs_on_exit() { diff --git a/lib/libc/musl/src/include/stdlib.h b/lib/libc/musl/src/include/stdlib.h index d38a5417f1..e9da20158c 100644 --- a/lib/libc/musl/src/include/stdlib.h +++ b/lib/libc/musl/src/include/stdlib.h @@ -9,4 +9,10 @@ hidden int __mkostemps(char *, int, int); hidden int __ptsname_r(int, char *, size_t); hidden char *__randname(char *); +hidden void *__libc_malloc(size_t); +hidden void *__libc_malloc_impl(size_t); +hidden void *__libc_calloc(size_t, size_t); +hidden void *__libc_realloc(void *, size_t); +hidden void __libc_free(void *); + #endif diff --git a/lib/libc/musl/src/include/unistd.h b/lib/libc/musl/src/include/unistd.h index 1b4605c7c6..7b52a9249e 100644 --- a/lib/libc/musl/src/include/unistd.h +++ b/lib/libc/musl/src/include/unistd.h @@ -8,7 +8,6 @@ extern char **__environ; hidden int __dup3(int, int, int); hidden int __mkostemps(char *, int, int); hidden int __execvpe(const char *, char *const *, char *const *); -hidden int __aio_close(int); hidden off_t __lseek(int, off_t, int); #endif diff --git a/lib/libc/musl/src/internal/aio_impl.h b/lib/libc/musl/src/internal/aio_impl.h new file mode 100644 index 0000000000..a865766544 --- /dev/null +++ b/lib/libc/musl/src/internal/aio_impl.h @@ -0,0 +1,9 @@ +#ifndef AIO_IMPL_H +#define AIO_IMPL_H + +extern hidden volatile int __aio_fut; + +extern hidden int __aio_close(int); +extern hidden void __aio_atfork(int); + +#endif diff --git a/lib/libc/musl/src/internal/fork_impl.h b/lib/libc/musl/src/internal/fork_impl.h new file mode 100644 index 0000000000..5892c13bf9 --- /dev/null +++ b/lib/libc/musl/src/internal/fork_impl.h @@ -0,0 +1,19 @@ +#include + +extern hidden volatile int *const __at_quick_exit_lockptr; +extern hidden volatile int *const __atexit_lockptr; +extern hidden volatile int *const __dlerror_lockptr; +extern hidden volatile int *const __gettext_lockptr; +extern hidden volatile int *const __locale_lockptr; +extern hidden volatile int *const __random_lockptr; +extern hidden volatile int *const __sem_open_lockptr; +extern hidden volatile int *const __stdio_ofl_lockptr; +extern hidden volatile int *const __syslog_lockptr; +extern hidden volatile int *const __timezone_lockptr; + +extern hidden volatile int *const __bump_lockptr; + +extern hidden volatile int *const __vmlock_lockptr; + +hidden void __malloc_atfork(int); +hidden void __ldso_atfork(int); diff --git a/lib/libc/musl/src/internal/libm.h b/lib/libc/musl/src/internal/libm.h index 7533f6baef..72ad17d8eb 100644 --- a/lib/libc/musl/src/internal/libm.h +++ b/lib/libc/musl/src/internal/libm.h @@ -267,5 +267,8 @@ hidden double __math_uflow(uint32_t); hidden double __math_oflow(uint32_t); hidden double __math_divzero(uint32_t); hidden double __math_invalid(double); +#if LDBL_MANT_DIG != DBL_MANT_DIG +hidden long double __math_invalidl(long double); +#endif #endif diff --git a/lib/libc/musl/src/internal/locale_impl.h b/lib/libc/musl/src/internal/locale_impl.h index 741a71c4d1..4431a92eb7 100644 --- a/lib/libc/musl/src/internal/locale_impl.h +++ b/lib/libc/musl/src/internal/locale_impl.h @@ -15,6 +15,8 @@ struct __locale_map { const struct __locale_map *next; }; +extern hidden volatile int __locale_lock[1]; + extern hidden const struct __locale_map __c_dot_utf8; extern hidden const struct __locale_struct __c_locale; extern hidden const struct __locale_struct __c_dot_utf8_locale; diff --git a/lib/libc/musl/src/internal/pthread_impl.h b/lib/libc/musl/src/internal/pthread_impl.h index 5742dfc55c..de2b9d8b47 100644 --- a/lib/libc/musl/src/internal/pthread_impl.h +++ b/lib/libc/musl/src/internal/pthread_impl.h @@ -11,16 +11,25 @@ #include "atomic.h" #include "futex.h" +#include "pthread_arch.h" + #define pthread __pthread struct pthread { /* Part 1 -- these fields may be external or * internal (accessed via asm) ABI. Do not change. */ struct pthread *self; +#ifndef TLS_ABOVE_TP uintptr_t *dtv; +#endif struct pthread *prev, *next; /* non-ABI */ uintptr_t sysinfo; - uintptr_t canary, canary2; +#ifndef TLS_ABOVE_TP +#ifdef CANARY_PAD + uintptr_t canary_pad; +#endif + uintptr_t canary; +#endif /* Part 2 -- implementation details, non-ABI. */ int tid; @@ -43,6 +52,7 @@ struct pthread { long off; volatile void *volatile pending; } robust_list; + int h_errno_val; volatile int timer_id; locale_t locale; volatile int killlock[1]; @@ -51,21 +61,19 @@ struct pthread { /* Part 3 -- the positions of these fields relative to * the end of the structure is external and internal ABI. */ - uintptr_t canary_at_end; - uintptr_t *dtv_copy; +#ifdef TLS_ABOVE_TP + uintptr_t canary; + uintptr_t *dtv; +#endif }; enum { - DT_EXITING = 0, + DT_EXITED = 0, + DT_EXITING, DT_JOINABLE, DT_DETACHED, }; -struct __timer { - int timerid; - pthread_t thread; -}; - #define __SU (sizeof(size_t)/sizeof(int)) #define _a_stacksize __u.__s[0] @@ -98,16 +106,22 @@ struct __timer { #define _b_waiters2 __u.__vi[4] #define _b_inst __u.__p[3] -#include "pthread_arch.h" - -#ifndef CANARY -#define CANARY canary +#ifndef TP_OFFSET +#define TP_OFFSET 0 #endif #ifndef DTP_OFFSET #define DTP_OFFSET 0 #endif +#ifdef TLS_ABOVE_TP +#define TP_ADJ(p) ((char *)(p) + sizeof(struct pthread) + TP_OFFSET) +#define __pthread_self() ((pthread_t)(__get_tp() - sizeof(struct __pthread) - TP_OFFSET)) +#else +#define TP_ADJ(p) (p) +#define __pthread_self() ((pthread_t)__get_tp()) +#endif + #ifndef tls_mod_off_t #define tls_mod_off_t size_t #endif @@ -141,7 +155,6 @@ hidden int __pthread_key_delete_impl(pthread_key_t); extern hidden volatile size_t __pthread_tsd_size; extern hidden void *__pthread_tsd_main[]; -extern hidden volatile int __aio_fut; extern hidden volatile int __eintr_valid_flag; hidden int __clone(int (*)(void *), void *, int, void *, ...); @@ -176,6 +189,8 @@ hidden void __tl_sync(pthread_t); extern hidden volatile int __thread_list_lock; +extern hidden volatile int __abort_lock[1]; + extern hidden unsigned __default_stacksize; extern hidden unsigned __default_guardsize; diff --git a/lib/libc/musl/src/internal/syscall.h b/lib/libc/musl/src/internal/syscall.h index 975a0031d4..d5f294d437 100644 --- a/lib/libc/musl/src/internal/syscall.h +++ b/lib/libc/musl/src/internal/syscall.h @@ -2,6 +2,7 @@ #define _INTERNAL_SYSCALL_H #include +#include #include #include "syscall_arch.h" @@ -57,15 +58,22 @@ hidden long __syscall_ret(unsigned long), #define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__) #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__)) -#ifndef SYSCALL_USE_SOCKETCALL -#define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_##nm, a, b, c, d, e, f) -#define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_##nm, a, b, c, d, e, f) -#else -#define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_socketcall, __SC_##nm, \ - ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) -#define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_socketcall, __SC_##nm, \ - ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) +static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, long c, long d, long e, long f) +{ + long r; + if (cp) r = __syscall_cp(sys, a, b, c, d, e, f); + else r = __syscall(sys, a, b, c, d, e, f); + if (r != -ENOSYS) return r; +#ifdef SYS_socketcall + if (cp) r = __syscall_cp(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f})); + else r = __syscall(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f})); #endif + return r; +} +#define __socketcall(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 0, \ + (long)(a), (long)(b), (long)(c), (long)(d), (long)(e), (long)(f)) +#define __socketcall_cp(nm, a, b, c, d, e, f) __alt_socketcall(SYS_##nm, __SC_##nm, 1, \ + (long)(a), (long)(b), (long)(c), (long)(d), (long)(e), (long)(f)) /* fixup legacy 16-bit junk */ @@ -338,6 +346,12 @@ hidden long __syscall_ret(unsigned long), #define __SC_recvmmsg 19 #define __SC_sendmmsg 20 +/* This is valid only because all socket syscalls are made via + * socketcall, which always fills unused argument slots with zeros. */ +#ifndef SYS_accept +#define SYS_accept SYS_accept4 +#endif + #ifndef SO_RCVTIMEO_OLD #define SO_RCVTIMEO_OLD 20 #endif diff --git a/lib/libc/musl/src/internal/version.h b/lib/libc/musl/src/internal/version.h index 78b418ff72..b23e8e2963 100644 --- a/lib/libc/musl/src/internal/version.h +++ b/lib/libc/musl/src/internal/version.h @@ -1 +1 @@ -#define VERSION "1.2.1" +#define VERSION "1.2.2" diff --git a/lib/libc/musl/src/ldso/dlerror.c b/lib/libc/musl/src/ldso/dlerror.c index 3fcc777953..afe59253ea 100644 --- a/lib/libc/musl/src/ldso/dlerror.c +++ b/lib/libc/musl/src/ldso/dlerror.c @@ -4,6 +4,12 @@ #include "pthread_impl.h" #include "dynlink.h" #include "lock.h" +#include "fork_impl.h" + +#define malloc __libc_malloc +#define calloc __libc_calloc +#define realloc __libc_realloc +#define free __libc_free char *dlerror() { @@ -19,6 +25,7 @@ char *dlerror() static volatile int freebuf_queue_lock[1]; static void **freebuf_queue; +volatile int *const __dlerror_lockptr = freebuf_queue_lock; void __dl_thread_cleanup(void) { @@ -35,13 +42,16 @@ void __dl_thread_cleanup(void) hidden void __dl_vseterr(const char *fmt, va_list ap) { LOCK(freebuf_queue_lock); - while (freebuf_queue) { - void **p = freebuf_queue; - freebuf_queue = *p; - free(p); - } + void **q = freebuf_queue; + freebuf_queue = 0; UNLOCK(freebuf_queue_lock); + while (q) { + void **p = *q; + free(q); + q = p; + } + va_list ap2; va_copy(ap2, ap); pthread_t self = __pthread_self(); diff --git a/lib/libc/musl/src/legacy/lutimes.c b/lib/libc/musl/src/legacy/lutimes.c index 2e5502d1e3..dd465923ad 100644 --- a/lib/libc/musl/src/legacy/lutimes.c +++ b/lib/libc/musl/src/legacy/lutimes.c @@ -6,9 +6,11 @@ int lutimes(const char *filename, const struct timeval tv[2]) { struct timespec times[2]; - times[0].tv_sec = tv[0].tv_sec; - times[0].tv_nsec = tv[0].tv_usec * 1000; - times[1].tv_sec = tv[1].tv_sec; - times[1].tv_nsec = tv[1].tv_usec * 1000; - return utimensat(AT_FDCWD, filename, times, AT_SYMLINK_NOFOLLOW); + if (tv) { + times[0].tv_sec = tv[0].tv_sec; + times[0].tv_nsec = tv[0].tv_usec * 1000; + times[1].tv_sec = tv[1].tv_sec; + times[1].tv_nsec = tv[1].tv_usec * 1000; + } + return utimensat(AT_FDCWD, filename, tv ? times : 0, AT_SYMLINK_NOFOLLOW); } diff --git a/lib/libc/musl/src/linux/gettid.c b/lib/libc/musl/src/linux/gettid.c new file mode 100644 index 0000000000..70767137e9 --- /dev/null +++ b/lib/libc/musl/src/linux/gettid.c @@ -0,0 +1,8 @@ +#define _GNU_SOURCE +#include +#include "pthread_impl.h" + +pid_t gettid(void) +{ + return __pthread_self()->tid; +} diff --git a/lib/libc/musl/src/linux/membarrier.c b/lib/libc/musl/src/linux/membarrier.c index 9ebe906ed8..343f7360ee 100644 --- a/lib/libc/musl/src/linux/membarrier.c +++ b/lib/libc/musl/src/linux/membarrier.c @@ -9,13 +9,8 @@ static void dummy_0(void) { } -static void dummy_1(pthread_t t) -{ -} - weak_alias(dummy_0, __tl_lock); weak_alias(dummy_0, __tl_unlock); -weak_alias(dummy_1, __tl_sync); static sem_t barrier_sem; diff --git a/lib/libc/musl/src/linux/setgroups.c b/lib/libc/musl/src/linux/setgroups.c index 1248fdbfdc..47142f141f 100644 --- a/lib/libc/musl/src/linux/setgroups.c +++ b/lib/libc/musl/src/linux/setgroups.c @@ -1,8 +1,36 @@ #define _GNU_SOURCE #include +#include #include "syscall.h" +#include "libc.h" + +struct ctx { + size_t count; + const gid_t *list; + int ret; +}; + +static void do_setgroups(void *p) +{ + struct ctx *c = p; + if (c->ret<0) return; + int ret = __syscall(SYS_setgroups, c->count, c->list); + if (ret && !c->ret) { + /* If one thread fails to set groups after another has already + * succeeded, forcibly killing the process is the only safe + * thing to do. State is inconsistent and dangerous. Use + * SIGKILL because it is uncatchable. */ + __block_all_sigs(0); + __syscall(SYS_kill, __syscall(SYS_getpid), SIGKILL); + } + c->ret = ret; +} int setgroups(size_t count, const gid_t list[]) { - return syscall(SYS_setgroups, count, list); + /* ret is initially nonzero so that failure of the first thread does not + * trigger the safety kill above. */ + struct ctx c = { .count = count, .list = list, .ret = 1 }; + __synccall(do_setgroups, &c); + return __syscall_ret(c.ret); } diff --git a/lib/libc/musl/src/locale/dcngettext.c b/lib/libc/musl/src/locale/dcngettext.c index 4c30439389..d1e6c6d13a 100644 --- a/lib/libc/musl/src/locale/dcngettext.c +++ b/lib/libc/musl/src/locale/dcngettext.c @@ -10,6 +10,12 @@ #include "atomic.h" #include "pleval.h" #include "lock.h" +#include "fork_impl.h" + +#define malloc __libc_malloc +#define calloc __libc_calloc +#define realloc undef +#define free undef struct binding { struct binding *next; @@ -34,9 +40,11 @@ static char *gettextdir(const char *domainname, size_t *dirlen) return 0; } +static volatile int lock[1]; +volatile int *const __gettext_lockptr = lock; + char *bindtextdomain(const char *domainname, const char *dirname) { - static volatile int lock[1]; struct binding *p, *q; if (!domainname) return 0; diff --git a/lib/libc/musl/src/locale/freelocale.c b/lib/libc/musl/src/locale/freelocale.c index 802b8bfe1c..385d12069d 100644 --- a/lib/libc/musl/src/locale/freelocale.c +++ b/lib/libc/musl/src/locale/freelocale.c @@ -1,6 +1,11 @@ #include #include "locale_impl.h" +#define malloc undef +#define calloc undef +#define realloc undef +#define free __libc_free + void freelocale(locale_t l) { if (__loc_is_allocated(l)) free(l); diff --git a/lib/libc/musl/src/locale/locale_map.c b/lib/libc/musl/src/locale/locale_map.c index 2321bac0ea..da61f7fc03 100644 --- a/lib/libc/musl/src/locale/locale_map.c +++ b/lib/libc/musl/src/locale/locale_map.c @@ -1,9 +1,16 @@ #include #include #include +#include #include "locale_impl.h" #include "libc.h" #include "lock.h" +#include "fork_impl.h" + +#define malloc __libc_malloc +#define calloc undef +#define realloc undef +#define free undef const char *__lctrans_impl(const char *msg, const struct __locale_map *lm) { @@ -21,9 +28,11 @@ static const char envvars[][12] = { "LC_MESSAGES", }; +volatile int __locale_lock[1]; +volatile int *const __locale_lockptr = __locale_lock; + const struct __locale_map *__get_locale(int cat, const char *val) { - static volatile int lock[1]; static void *volatile loc_head; const struct __locale_map *p; struct __locale_map *new = 0; @@ -54,20 +63,12 @@ const struct __locale_map *__get_locale(int cat, const char *val) for (p=loc_head; p; p=p->next) if (!strcmp(val, p->name)) return p; - LOCK(lock); - - for (p=loc_head; p; p=p->next) - if (!strcmp(val, p->name)) { - UNLOCK(lock); - return p; - } - if (!libc.secure) path = getenv("MUSL_LOCPATH"); /* FIXME: add a default path? */ if (path) for (; *path; path=z+!!*z) { z = __strchrnul(path, ':'); - l = z - path - !!*z; + l = z - path; if (l >= sizeof buf - n - 2) continue; memcpy(buf, path, l); buf[l] = '/'; @@ -108,6 +109,5 @@ const struct __locale_map *__get_locale(int cat, const char *val) * requested name was "C" or "POSIX". */ if (!new && cat == LC_CTYPE) new = (void *)&__c_dot_utf8; - UNLOCK(lock); return new; } diff --git a/lib/libc/musl/src/locale/newlocale.c b/lib/libc/musl/src/locale/newlocale.c index d20a848983..9ac3cd386f 100644 --- a/lib/libc/musl/src/locale/newlocale.c +++ b/lib/libc/musl/src/locale/newlocale.c @@ -2,24 +2,23 @@ #include #include #include "locale_impl.h" +#include "lock.h" -static pthread_once_t default_locale_once; +#define malloc __libc_malloc +#define calloc undef +#define realloc undef +#define free undef + +static int default_locale_init_done; static struct __locale_struct default_locale, default_ctype_locale; -static void default_locale_init(void) -{ - for (int i=0; i LC_ALL) return 0; - LOCK(lock); + LOCK(__locale_lock); /* For LC_ALL, setlocale is required to return a string which * encodes the current setting for all categories. The format of @@ -36,7 +35,7 @@ char *setlocale(int cat, const char *name) } lm = __get_locale(i, part); if (lm == LOC_MAP_FAILED) { - UNLOCK(lock); + UNLOCK(__locale_lock); return 0; } tmp_locale.cat[i] = lm; @@ -57,14 +56,14 @@ char *setlocale(int cat, const char *name) s += l+1; } *--s = 0; - UNLOCK(lock); + UNLOCK(__locale_lock); return same==LC_ALL ? (char *)part : buf; } if (name) { lm = __get_locale(cat, name); if (lm == LOC_MAP_FAILED) { - UNLOCK(lock); + UNLOCK(__locale_lock); return 0; } libc.global_locale.cat[cat] = lm; @@ -73,7 +72,7 @@ char *setlocale(int cat, const char *name) } char *ret = lm ? (char *)lm->name : "C"; - UNLOCK(lock); + UNLOCK(__locale_lock); return ret; } diff --git a/lib/libc/musl/src/malloc/free.c b/lib/libc/musl/src/malloc/free.c new file mode 100644 index 0000000000..f17a952cb4 --- /dev/null +++ b/lib/libc/musl/src/malloc/free.c @@ -0,0 +1,6 @@ +#include + +void free(void *p) +{ + return __libc_free(p); +} diff --git a/lib/libc/musl/src/malloc/libc_calloc.c b/lib/libc/musl/src/malloc/libc_calloc.c new file mode 100644 index 0000000000..d25eabea47 --- /dev/null +++ b/lib/libc/musl/src/malloc/libc_calloc.c @@ -0,0 +1,4 @@ +#define calloc __libc_calloc +#define malloc __libc_malloc + +#include "calloc.c" diff --git a/lib/libc/musl/src/malloc/lite_malloc.c b/lib/libc/musl/src/malloc/lite_malloc.c index f8931ba597..43a988fbb8 100644 --- a/lib/libc/musl/src/malloc/lite_malloc.c +++ b/lib/libc/musl/src/malloc/lite_malloc.c @@ -6,6 +6,7 @@ #include "libc.h" #include "lock.h" #include "syscall.h" +#include "fork_impl.h" #define ALIGN 16 @@ -31,10 +32,12 @@ static int traverses_stack_p(uintptr_t old, uintptr_t new) return 0; } +static volatile int lock[1]; +volatile int *const __bump_lockptr = lock; + static void *__simple_malloc(size_t n) { static uintptr_t brk, cur, end; - static volatile int lock[1]; static unsigned mmap_step; size_t align=1; void *p; @@ -100,4 +103,16 @@ static void *__simple_malloc(size_t n) return p; } -weak_alias(__simple_malloc, malloc); +weak_alias(__simple_malloc, __libc_malloc_impl); + +void *__libc_malloc(size_t n) +{ + return __libc_malloc_impl(n); +} + +static void *default_malloc(size_t n) +{ + return __libc_malloc_impl(n); +} + +weak_alias(default_malloc, malloc); diff --git a/lib/libc/musl/src/malloc/mallocng/glue.h b/lib/libc/musl/src/malloc/mallocng/glue.h index 16acd1ea3b..151c48b804 100644 --- a/lib/libc/musl/src/malloc/mallocng/glue.h +++ b/lib/libc/musl/src/malloc/mallocng/glue.h @@ -20,6 +20,10 @@ #define is_allzero __malloc_allzerop #define dump_heap __dump_heap +#define malloc __libc_malloc_impl +#define realloc __libc_realloc +#define free __libc_free + #if USE_REAL_ASSERT #include #else @@ -56,7 +60,8 @@ __attribute__((__visibility__("hidden"))) extern int __malloc_lock[1]; #define LOCK_OBJ_DEF \ -int __malloc_lock[1]; +int __malloc_lock[1]; \ +void __malloc_atfork(int who) { malloc_atfork(who); } static inline void rdlock() { @@ -73,5 +78,16 @@ static inline void unlock() static inline void upgradelock() { } +static inline void resetlock() +{ + __malloc_lock[0] = 0; +} + +static inline void malloc_atfork(int who) +{ + if (who<0) rdlock(); + else if (who>0) resetlock(); + else unlock(); +} #endif diff --git a/lib/libc/musl/src/malloc/mallocng/malloc_usable_size.c b/lib/libc/musl/src/malloc/mallocng/malloc_usable_size.c index a440a4eab2..ce6a960c6f 100644 --- a/lib/libc/musl/src/malloc/mallocng/malloc_usable_size.c +++ b/lib/libc/musl/src/malloc/mallocng/malloc_usable_size.c @@ -3,6 +3,7 @@ size_t malloc_usable_size(void *p) { + if (!p) return 0; struct meta *g = get_meta(p); int idx = get_slot_index(p); size_t stride = get_stride(g); diff --git a/lib/libc/musl/src/malloc/oldmalloc/aligned_alloc.c b/lib/libc/musl/src/malloc/oldmalloc/aligned_alloc.c new file mode 100644 index 0000000000..4adca3b4f6 --- /dev/null +++ b/lib/libc/musl/src/malloc/oldmalloc/aligned_alloc.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include "malloc_impl.h" + +void *aligned_alloc(size_t align, size_t len) +{ + unsigned char *mem, *new; + + if ((align & -align) != align) { + errno = EINVAL; + return 0; + } + + if (len > SIZE_MAX - align || + (__malloc_replaced && !__aligned_alloc_replaced)) { + errno = ENOMEM; + return 0; + } + + if (align <= SIZE_ALIGN) + return malloc(len); + + if (!(mem = malloc(len + align-1))) + return 0; + + new = (void *)((uintptr_t)mem + align-1 & -align); + if (new == mem) return mem; + + struct chunk *c = MEM_TO_CHUNK(mem); + struct chunk *n = MEM_TO_CHUNK(new); + + if (IS_MMAPPED(c)) { + /* Apply difference between aligned and original + * address to the "extra" field of mmapped chunk. */ + n->psize = c->psize + (new-mem); + n->csize = c->csize - (new-mem); + return new; + } + + struct chunk *t = NEXT_CHUNK(c); + + /* Split the allocated chunk into two chunks. The aligned part + * that will be used has the size in its footer reduced by the + * difference between the aligned and original addresses, and + * the resulting size copied to its header. A new header and + * footer are written for the split-off part to be freed. */ + n->psize = c->csize = C_INUSE | (new-mem); + n->csize = t->psize -= new-mem; + + __bin_chunk(c); + return new; +} diff --git a/lib/libc/musl/src/malloc/oldmalloc/malloc.c b/lib/libc/musl/src/malloc/oldmalloc/malloc.c new file mode 100644 index 0000000000..53f5f959ec --- /dev/null +++ b/lib/libc/musl/src/malloc/oldmalloc/malloc.c @@ -0,0 +1,552 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include "libc.h" +#include "atomic.h" +#include "pthread_impl.h" +#include "malloc_impl.h" +#include "fork_impl.h" + +#define malloc __libc_malloc +#define realloc __libc_realloc +#define free __libc_free + +#if defined(__GNUC__) && defined(__PIC__) +#define inline inline __attribute__((always_inline)) +#endif + +static struct { + volatile uint64_t binmap; + struct bin bins[64]; + volatile int split_merge_lock[2]; +} mal; + +/* Synchronization tools */ + +static inline void lock(volatile int *lk) +{ + int need_locks = libc.need_locks; + if (need_locks) { + while(a_swap(lk, 1)) __wait(lk, lk+1, 1, 1); + if (need_locks < 0) libc.need_locks = 0; + } +} + +static inline void unlock(volatile int *lk) +{ + if (lk[0]) { + a_store(lk, 0); + if (lk[1]) __wake(lk, 1, 1); + } +} + +static inline void lock_bin(int i) +{ + lock(mal.bins[i].lock); + if (!mal.bins[i].head) + mal.bins[i].head = mal.bins[i].tail = BIN_TO_CHUNK(i); +} + +static inline void unlock_bin(int i) +{ + unlock(mal.bins[i].lock); +} + +static int first_set(uint64_t x) +{ +#if 1 + return a_ctz_64(x); +#else + static const char debruijn64[64] = { + 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28, + 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11, + 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10, + 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12 + }; + static const char debruijn32[32] = { + 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, + 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14 + }; + if (sizeof(long) < 8) { + uint32_t y = x; + if (!y) { + y = x>>32; + return 32 + debruijn32[(y&-y)*0x076be629 >> 27]; + } + return debruijn32[(y&-y)*0x076be629 >> 27]; + } + return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58]; +#endif +} + +static const unsigned char bin_tab[60] = { + 32,33,34,35,36,36,37,37,38,38,39,39, + 40,40,40,40,41,41,41,41,42,42,42,42,43,43,43,43, + 44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45, + 46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47, +}; + +static int bin_index(size_t x) +{ + x = x / SIZE_ALIGN - 1; + if (x <= 32) return x; + if (x < 512) return bin_tab[x/8-4]; + if (x > 0x1c00) return 63; + return bin_tab[x/128-4] + 16; +} + +static int bin_index_up(size_t x) +{ + x = x / SIZE_ALIGN - 1; + if (x <= 32) return x; + x--; + if (x < 512) return bin_tab[x/8-4] + 1; + return bin_tab[x/128-4] + 17; +} + +#if 0 +void __dump_heap(int x) +{ + struct chunk *c; + int i; + for (c = (void *)mal.heap; CHUNK_SIZE(c); c = NEXT_CHUNK(c)) + fprintf(stderr, "base %p size %zu (%d) flags %d/%d\n", + c, CHUNK_SIZE(c), bin_index(CHUNK_SIZE(c)), + c->csize & 15, + NEXT_CHUNK(c)->psize & 15); + for (i=0; i<64; i++) { + if (mal.bins[i].head != BIN_TO_CHUNK(i) && mal.bins[i].head) { + fprintf(stderr, "bin %d: %p\n", i, mal.bins[i].head); + if (!(mal.binmap & 1ULL< len ? b-len : 0; + if (new>a && old len ? b-len : 0; + if (new>a && old SIZE_MAX/2 - PAGE_SIZE) { + errno = ENOMEM; + return 0; + } + n += -n & PAGE_SIZE-1; + + if (!brk) { + brk = __syscall(SYS_brk, 0); + brk += -brk & PAGE_SIZE-1; + } + + if (n < SIZE_MAX-brk && !traverses_stack_p(brk, brk+n) + && __syscall(SYS_brk, brk+n)==brk+n) { + *pn = n; + brk += n; + return (void *)(brk-n); + } + + size_t min = (size_t)PAGE_SIZE << mmap_step/2; + if (n < min) n = min; + void *area = __mmap(0, n, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (area == MAP_FAILED) return 0; + *pn = n; + mmap_step++; + return area; +} + +static struct chunk *expand_heap(size_t n) +{ + static void *end; + void *p; + struct chunk *w; + + /* The argument n already accounts for the caller's chunk + * overhead needs, but if the heap can't be extended in-place, + * we need room for an extra zero-sized sentinel chunk. */ + n += SIZE_ALIGN; + + p = __expand_heap(&n); + if (!p) return 0; + + /* If not just expanding existing space, we need to make a + * new sentinel chunk below the allocated space. */ + if (p != end) { + /* Valid/safe because of the prologue increment. */ + n -= SIZE_ALIGN; + p = (char *)p + SIZE_ALIGN; + w = MEM_TO_CHUNK(p); + w->psize = 0 | C_INUSE; + } + + /* Record new heap end and fill in footer. */ + end = (char *)p + n; + w = MEM_TO_CHUNK(end); + w->psize = n | C_INUSE; + w->csize = 0 | C_INUSE; + + /* Fill in header, which may be new or may be replacing a + * zero-size sentinel header at the old end-of-heap. */ + w = MEM_TO_CHUNK(p); + w->csize = n | C_INUSE; + + return w; +} + +static int adjust_size(size_t *n) +{ + /* Result of pointer difference must fit in ptrdiff_t. */ + if (*n-1 > PTRDIFF_MAX - SIZE_ALIGN - PAGE_SIZE) { + if (*n) { + errno = ENOMEM; + return -1; + } else { + *n = SIZE_ALIGN; + return 0; + } + } + *n = (*n + OVERHEAD + SIZE_ALIGN - 1) & SIZE_MASK; + return 0; +} + +static void unbin(struct chunk *c, int i) +{ + if (c->prev == c->next) + a_and_64(&mal.binmap, ~(1ULL<prev->next = c->next; + c->next->prev = c->prev; + c->csize |= C_INUSE; + NEXT_CHUNK(c)->psize |= C_INUSE; +} + +static void bin_chunk(struct chunk *self, int i) +{ + self->next = BIN_TO_CHUNK(i); + self->prev = mal.bins[i].tail; + self->next->prev = self; + self->prev->next = self; + if (self->prev == BIN_TO_CHUNK(i)) + a_or_64(&mal.binmap, 1ULL<= n1 - DONTCARE) return; + + next = NEXT_CHUNK(self); + split = (void *)((char *)self + n); + + split->psize = n | C_INUSE; + split->csize = n1-n; + next->psize = n1-n; + self->csize = n | C_INUSE; + + int i = bin_index(n1-n); + lock_bin(i); + + bin_chunk(split, i); + + unlock_bin(i); +} + +void *malloc(size_t n) +{ + struct chunk *c; + int i, j; + uint64_t mask; + + if (adjust_size(&n) < 0) return 0; + + if (n > MMAP_THRESHOLD) { + size_t len = n + OVERHEAD + PAGE_SIZE - 1 & -PAGE_SIZE; + char *base = __mmap(0, len, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + if (base == (void *)-1) return 0; + c = (void *)(base + SIZE_ALIGN - OVERHEAD); + c->csize = len - (SIZE_ALIGN - OVERHEAD); + c->psize = SIZE_ALIGN - OVERHEAD; + return CHUNK_TO_MEM(c); + } + + i = bin_index_up(n); + if (i<63 && (mal.binmap & (1ULL<psize; + char *base = (char *)self - extra; + size_t oldlen = n0 + extra; + size_t newlen = n + extra; + /* Crash on realloc of freed chunk */ + if (extra & 1) a_crash(); + if (newlen < PAGE_SIZE && (new = malloc(n-OVERHEAD))) { + n0 = n; + goto copy_free_ret; + } + newlen = (newlen + PAGE_SIZE-1) & -PAGE_SIZE; + if (oldlen == newlen) return p; + base = __mremap(base, oldlen, newlen, MREMAP_MAYMOVE); + if (base == (void *)-1) + goto copy_realloc; + self = (void *)(base + extra); + self->csize = newlen - extra; + return CHUNK_TO_MEM(self); + } + + next = NEXT_CHUNK(self); + + /* Crash on corrupted footer (likely from buffer overflow) */ + if (next->psize != self->csize) a_crash(); + + if (n < n0) { + int i = bin_index_up(n); + int j = bin_index(n0); + if (icsize = split->psize = n | C_INUSE; + split->csize = next->psize = n0-n | C_INUSE; + __bin_chunk(split); + return CHUNK_TO_MEM(self); + } + + lock(mal.split_merge_lock); + + size_t nsize = next->csize & C_INUSE ? 0 : CHUNK_SIZE(next); + if (n0+nsize >= n) { + int i = bin_index(nsize); + lock_bin(i); + if (!(next->csize & C_INUSE)) { + unbin(next, i); + unlock_bin(i); + next = NEXT_CHUNK(next); + self->csize = next->psize = n0+nsize | C_INUSE; + trim(self, n); + unlock(mal.split_merge_lock); + return CHUNK_TO_MEM(self); + } + unlock_bin(i); + } + unlock(mal.split_merge_lock); + +copy_realloc: + /* As a last resort, allocate a new chunk and copy to it. */ + new = malloc(n-OVERHEAD); + if (!new) return 0; +copy_free_ret: + memcpy(new, p, (npsize != self->csize) a_crash(); + + lock(mal.split_merge_lock); + + size_t osize = CHUNK_SIZE(self), size = osize; + + /* Since we hold split_merge_lock, only transition from free to + * in-use can race; in-use to free is impossible */ + size_t psize = self->psize & C_INUSE ? 0 : CHUNK_PSIZE(self); + size_t nsize = next->csize & C_INUSE ? 0 : CHUNK_SIZE(next); + + if (psize) { + int i = bin_index(psize); + lock_bin(i); + if (!(self->psize & C_INUSE)) { + struct chunk *prev = PREV_CHUNK(self); + unbin(prev, i); + self = prev; + size += psize; + } + unlock_bin(i); + } + if (nsize) { + int i = bin_index(nsize); + lock_bin(i); + if (!(next->csize & C_INUSE)) { + unbin(next, i); + next = NEXT_CHUNK(next); + size += nsize; + } + unlock_bin(i); + } + + int i = bin_index(size); + lock_bin(i); + + self->csize = size; + next->psize = size; + bin_chunk(self, i); + unlock(mal.split_merge_lock); + + /* Replace middle of large chunks with fresh zero pages */ + if (size > RECLAIM && (size^(size-osize)) > size-osize) { + uintptr_t a = (uintptr_t)self + SIZE_ALIGN+PAGE_SIZE-1 & -PAGE_SIZE; + uintptr_t b = (uintptr_t)next - SIZE_ALIGN & -PAGE_SIZE; +#if 1 + __madvise((void *)a, b-a, MADV_DONTNEED); +#else + __mmap((void *)a, b-a, PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0); +#endif + } + + unlock_bin(i); +} + +static void unmap_chunk(struct chunk *self) +{ + size_t extra = self->psize; + char *base = (char *)self - extra; + size_t len = CHUNK_SIZE(self) + extra; + /* Crash on double free */ + if (extra & 1) a_crash(); + __munmap(base, len); +} + +void free(void *p) +{ + if (!p) return; + + struct chunk *self = MEM_TO_CHUNK(p); + + if (IS_MMAPPED(self)) + unmap_chunk(self); + else + __bin_chunk(self); +} + +void __malloc_donate(char *start, char *end) +{ + size_t align_start_up = (SIZE_ALIGN-1) & (-(uintptr_t)start - OVERHEAD); + size_t align_end_down = (SIZE_ALIGN-1) & (uintptr_t)end; + + /* Getting past this condition ensures that the padding for alignment + * and header overhead will not overflow and will leave a nonzero + * multiple of SIZE_ALIGN bytes between start and end. */ + if (end - start <= OVERHEAD + align_start_up + align_end_down) + return; + start += align_start_up + OVERHEAD; + end -= align_end_down; + + struct chunk *c = MEM_TO_CHUNK(start), *n = MEM_TO_CHUNK(end); + c->psize = n->csize = C_INUSE; + c->csize = n->psize = C_INUSE | (end-start); + __bin_chunk(c); +} + +void __malloc_atfork(int who) +{ + if (who<0) { + lock(mal.split_merge_lock); + for (int i=0; i<64; i++) + lock(mal.bins[i].lock); + } else if (!who) { + for (int i=0; i<64; i++) + unlock(mal.bins[i].lock); + unlock(mal.split_merge_lock); + } else { + for (int i=0; i<64; i++) + mal.bins[i].lock[0] = mal.bins[i].lock[1] = 0; + mal.split_merge_lock[1] = 0; + mal.split_merge_lock[0] = 0; + } +} diff --git a/lib/libc/musl/src/malloc/oldmalloc/malloc_impl.h b/lib/libc/musl/src/malloc/oldmalloc/malloc_impl.h new file mode 100644 index 0000000000..e1cf4774c1 --- /dev/null +++ b/lib/libc/musl/src/malloc/oldmalloc/malloc_impl.h @@ -0,0 +1,39 @@ +#ifndef MALLOC_IMPL_H +#define MALLOC_IMPL_H + +#include +#include "dynlink.h" + +struct chunk { + size_t psize, csize; + struct chunk *next, *prev; +}; + +struct bin { + volatile int lock[2]; + struct chunk *head; + struct chunk *tail; +}; + +#define SIZE_ALIGN (4*sizeof(size_t)) +#define SIZE_MASK (-SIZE_ALIGN) +#define OVERHEAD (2*sizeof(size_t)) +#define MMAP_THRESHOLD (0x1c00*SIZE_ALIGN) +#define DONTCARE 16 +#define RECLAIM 163840 + +#define CHUNK_SIZE(c) ((c)->csize & -2) +#define CHUNK_PSIZE(c) ((c)->psize & -2) +#define PREV_CHUNK(c) ((struct chunk *)((char *)(c) - CHUNK_PSIZE(c))) +#define NEXT_CHUNK(c) ((struct chunk *)((char *)(c) + CHUNK_SIZE(c))) +#define MEM_TO_CHUNK(p) (struct chunk *)((char *)(p) - OVERHEAD) +#define CHUNK_TO_MEM(c) (void *)((char *)(c) + OVERHEAD) +#define BIN_TO_CHUNK(i) (MEM_TO_CHUNK(&mal.bins[i].head)) + +#define C_INUSE ((size_t)1) + +#define IS_MMAPPED(c) !((c)->csize & (C_INUSE)) + +hidden void __bin_chunk(struct chunk *); + +#endif diff --git a/lib/libc/musl/src/malloc/oldmalloc/malloc_usable_size.c b/lib/libc/musl/src/malloc/oldmalloc/malloc_usable_size.c new file mode 100644 index 0000000000..672b518ad0 --- /dev/null +++ b/lib/libc/musl/src/malloc/oldmalloc/malloc_usable_size.c @@ -0,0 +1,9 @@ +#include +#include "malloc_impl.h" + +hidden void *(*const __realloc_dep)(void *, size_t) = realloc; + +size_t malloc_usable_size(void *p) +{ + return p ? CHUNK_SIZE(MEM_TO_CHUNK(p)) - OVERHEAD : 0; +} diff --git a/lib/libc/musl/src/malloc/realloc.c b/lib/libc/musl/src/malloc/realloc.c new file mode 100644 index 0000000000..fb0e8b7c47 --- /dev/null +++ b/lib/libc/musl/src/malloc/realloc.c @@ -0,0 +1,6 @@ +#include + +void *realloc(void *p, size_t n) +{ + return __libc_realloc(p, n); +} diff --git a/lib/libc/musl/src/malloc/reallocarray.c b/lib/libc/musl/src/malloc/reallocarray.c new file mode 100644 index 0000000000..4a6ebe4604 --- /dev/null +++ b/lib/libc/musl/src/malloc/reallocarray.c @@ -0,0 +1,13 @@ +#define _BSD_SOURCE +#include +#include + +void *reallocarray(void *ptr, size_t m, size_t n) +{ + if (n && m > -1 / n) { + errno = ENOMEM; + return 0; + } + + return realloc(ptr, m * n); +} diff --git a/lib/libc/musl/src/math/__math_invalidl.c b/lib/libc/musl/src/math/__math_invalidl.c new file mode 100644 index 0000000000..1fca99de4f --- /dev/null +++ b/lib/libc/musl/src/math/__math_invalidl.c @@ -0,0 +1,9 @@ +#include +#include "libm.h" + +#if LDBL_MANT_DIG != DBL_MANT_DIG +long double __math_invalidl(long double x) +{ + return (x - x) / (x - x); +} +#endif diff --git a/lib/libc/musl/src/math/arm/fabs.c b/lib/libc/musl/src/math/arm/fabs.c index f890520a5c..6e1d367d3d 100644 --- a/lib/libc/musl/src/math/arm/fabs.c +++ b/lib/libc/musl/src/math/arm/fabs.c @@ -1,6 +1,6 @@ #include -#if __ARM_PCS_VFP +#if __ARM_PCS_VFP && __ARM_FP&8 double fabs(double x) { diff --git a/lib/libc/musl/src/math/arm/sqrt.c b/lib/libc/musl/src/math/arm/sqrt.c index 874af9606c..567e2e9101 100644 --- a/lib/libc/musl/src/math/arm/sqrt.c +++ b/lib/libc/musl/src/math/arm/sqrt.c @@ -1,6 +1,6 @@ #include -#if __ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__) +#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && (__ARM_FP&8) double sqrt(double x) { diff --git a/lib/libc/musl/src/math/sqrt.c b/lib/libc/musl/src/math/sqrt.c index f1f6d76c78..5ba2655962 100644 --- a/lib/libc/musl/src/math/sqrt.c +++ b/lib/libc/musl/src/math/sqrt.c @@ -1,184 +1,158 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_sqrt.c */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunSoft, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ -/* sqrt(x) - * Return correctly rounded sqrt. - * ------------------------------------------ - * | Use the hardware sqrt if you have one | - * ------------------------------------------ - * Method: - * Bit by bit method using integer arithmetic. (Slow, but portable) - * 1. Normalization - * Scale x to y in [1,4) with even powers of 2: - * find an integer k such that 1 <= (y=x*2^(2k)) < 4, then - * sqrt(x) = 2^k * sqrt(y) - * 2. Bit by bit computation - * Let q = sqrt(y) truncated to i bit after binary point (q = 1), - * i 0 - * i+1 2 - * s = 2*q , and y = 2 * ( y - q ). (1) - * i i i i - * - * To compute q from q , one checks whether - * i+1 i - * - * -(i+1) 2 - * (q + 2 ) <= y. (2) - * i - * -(i+1) - * If (2) is false, then q = q ; otherwise q = q + 2 . - * i+1 i i+1 i - * - * With some algebric manipulation, it is not difficult to see - * that (2) is equivalent to - * -(i+1) - * s + 2 <= y (3) - * i i - * - * The advantage of (3) is that s and y can be computed by - * i i - * the following recurrence formula: - * if (3) is false - * - * s = s , y = y ; (4) - * i+1 i i+1 i - * - * otherwise, - * -i -(i+1) - * s = s + 2 , y = y - s - 2 (5) - * i+1 i i+1 i i - * - * One may easily use induction to prove (4) and (5). - * Note. Since the left hand side of (3) contain only i+2 bits, - * it does not necessary to do a full (53-bit) comparison - * in (3). - * 3. Final rounding - * After generating the 53 bits result, we compute one more bit. - * Together with the remainder, we can decide whether the - * result is exact, bigger than 1/2ulp, or less than 1/2ulp - * (it will never equal to 1/2ulp). - * The rounding mode can be detected by checking whether - * huge + tiny is equal to huge, and whether huge - tiny is - * equal to huge for some floating point number "huge" and "tiny". - * - * Special cases: - * sqrt(+-0) = +-0 ... exact - * sqrt(inf) = inf - * sqrt(-ve) = NaN ... with invalid signal - * sqrt(NaN) = NaN ... with invalid signal for signaling NaN - */ - +#include +#include #include "libm.h" +#include "sqrt_data.h" -static const double tiny = 1.0e-300; +#define FENV_SUPPORT 1 + +/* returns a*b*2^-32 - e, with error 0 <= e < 1. */ +static inline uint32_t mul32(uint32_t a, uint32_t b) +{ + return (uint64_t)a*b >> 32; +} + +/* returns a*b*2^-64 - e, with error 0 <= e < 3. */ +static inline uint64_t mul64(uint64_t a, uint64_t b) +{ + uint64_t ahi = a>>32; + uint64_t alo = a&0xffffffff; + uint64_t bhi = b>>32; + uint64_t blo = b&0xffffffff; + return ahi*bhi + (ahi*blo >> 32) + (alo*bhi >> 32); +} double sqrt(double x) { - double z; - int32_t sign = (int)0x80000000; - int32_t ix0,s0,q,m,t,i; - uint32_t r,t1,s1,ix1,q1; + uint64_t ix, top, m; - EXTRACT_WORDS(ix0, ix1, x); - - /* take care of Inf and NaN */ - if ((ix0&0x7ff00000) == 0x7ff00000) { - return x*x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf, sqrt(-inf)=sNaN */ - } - /* take care of zero */ - if (ix0 <= 0) { - if (((ix0&~sign)|ix1) == 0) - return x; /* sqrt(+-0) = +-0 */ - if (ix0 < 0) - return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ - } - /* normalize x */ - m = ix0>>20; - if (m == 0) { /* subnormal x */ - while (ix0 == 0) { - m -= 21; - ix0 |= (ix1>>11); - ix1 <<= 21; - } - for (i=0; (ix0&0x00100000) == 0; i++) - ix0<<=1; - m -= i - 1; - ix0 |= ix1>>(32-i); - ix1 <<= i; - } - m -= 1023; /* unbias exponent */ - ix0 = (ix0&0x000fffff)|0x00100000; - if (m & 1) { /* odd m, double x to make it even */ - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - } - m >>= 1; /* m = [m/2] */ - - /* generate sqrt(x) bit by bit */ - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - q = q1 = s0 = s1 = 0; /* [q,q1] = sqrt(x) */ - r = 0x00200000; /* r = moving bit from right to left */ - - while (r != 0) { - t = s0 + r; - if (t <= ix0) { - s0 = t + r; - ix0 -= t; - q += r; - } - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - r >>= 1; + /* special case handling. */ + ix = asuint64(x); + top = ix >> 52; + if (predict_false(top - 0x001 >= 0x7ff - 0x001)) { + /* x < 0x1p-1022 or inf or nan. */ + if (ix * 2 == 0) + return x; + if (ix == 0x7ff0000000000000) + return x; + if (ix > 0x7ff0000000000000) + return __math_invalid(x); + /* x is subnormal, normalize it. */ + ix = asuint64(x * 0x1p52); + top = ix >> 52; + top -= 52; } - r = sign; - while (r != 0) { - t1 = s1 + r; - t = s0; - if (t < ix0 || (t == ix0 && t1 <= ix1)) { - s1 = t1 + r; - if ((t1&sign) == sign && (s1&sign) == 0) - s0++; - ix0 -= t; - if (ix1 < t1) - ix0--; - ix1 -= t1; - q1 += r; - } - ix0 += ix0 + ((ix1&sign)>>31); - ix1 += ix1; - r >>= 1; - } + /* argument reduction: + x = 4^e m; with integer e, and m in [1, 4) + m: fixed point representation [2.62] + 2^e is the exponent part of the result. */ + int even = top & 1; + m = (ix << 11) | 0x8000000000000000; + if (even) m >>= 1; + top = (top + 0x3ff) >> 1; - /* use floating add to find out rounding direction */ - if ((ix0|ix1) != 0) { - z = 1.0 - tiny; /* raise inexact flag */ - if (z >= 1.0) { - z = 1.0 + tiny; - if (q1 == (uint32_t)0xffffffff) { - q1 = 0; - q++; - } else if (z > 1.0) { - if (q1 == (uint32_t)0xfffffffe) - q++; - q1 += 2; - } else - q1 += q1 & 1; - } + /* approximate r ~ 1/sqrt(m) and s ~ sqrt(m) when m in [1,4) + + initial estimate: + 7bit table lookup (1bit exponent and 6bit significand). + + iterative approximation: + using 2 goldschmidt iterations with 32bit int arithmetics + and a final iteration with 64bit int arithmetics. + + details: + + the relative error (e = r0 sqrt(m)-1) of a linear estimate + (r0 = a m + b) is |e| < 0.085955 ~ 0x1.6p-4 at best, + a table lookup is faster and needs one less iteration + 6 bit lookup table (128b) gives |e| < 0x1.f9p-8 + 7 bit lookup table (256b) gives |e| < 0x1.fdp-9 + for single and double prec 6bit is enough but for quad + prec 7bit is needed (or modified iterations). to avoid + one more iteration >=13bit table would be needed (16k). + + a newton-raphson iteration for r is + w = r*r + u = 3 - m*w + r = r*u/2 + can use a goldschmidt iteration for s at the end or + s = m*r + + first goldschmidt iteration is + s = m*r + u = 3 - s*r + r = r*u/2 + s = s*u/2 + next goldschmidt iteration is + u = 3 - s*r + r = r*u/2 + s = s*u/2 + and at the end r is not computed only s. + + they use the same amount of operations and converge at the + same quadratic rate, i.e. if + r1 sqrt(m) - 1 = e, then + r2 sqrt(m) - 1 = -3/2 e^2 - 1/2 e^3 + the advantage of goldschmidt is that the mul for s and r + are independent (computed in parallel), however it is not + "self synchronizing": it only uses the input m in the + first iteration so rounding errors accumulate. at the end + or when switching to larger precision arithmetics rounding + errors dominate so the first iteration should be used. + + the fixed point representations are + m: 2.30 r: 0.32, s: 2.30, d: 2.30, u: 2.30, three: 2.30 + and after switching to 64 bit + m: 2.62 r: 0.64, s: 2.62, d: 2.62, u: 2.62, three: 2.62 */ + + static const uint64_t three = 0xc0000000; + uint64_t r, s, d, u, i; + + i = (ix >> 46) % 128; + r = (uint32_t)__rsqrt_tab[i] << 16; + /* |r sqrt(m) - 1| < 0x1.fdp-9 */ + s = mul32(m>>32, r); + /* |s/sqrt(m) - 1| < 0x1.fdp-9 */ + d = mul32(s, r); + u = three - d; + r = mul32(r, u) << 1; + /* |r sqrt(m) - 1| < 0x1.7bp-16 */ + s = mul32(s, u) << 1; + /* |s/sqrt(m) - 1| < 0x1.7bp-16 */ + d = mul32(s, r); + u = three - d; + r = mul32(r, u) << 1; + /* |r sqrt(m) - 1| < 0x1.3704p-29 (measured worst-case) */ + r = r << 32; + s = mul64(m, r); + d = mul64(s, r); + u = (three<<32) - d; + s = mul64(s, u); /* repr: 3.61 */ + /* -0x1p-57 < s - sqrt(m) < 0x1.8001p-61 */ + s = (s - 2) >> 9; /* repr: 12.52 */ + /* -0x1.09p-52 < s - sqrt(m) < -0x1.fffcp-63 */ + + /* s < sqrt(m) < s + 0x1.09p-52, + compute nearest rounded result: + the nearest result to 52 bits is either s or s+0x1p-52, + we can decide by comparing (2^52 s + 0.5)^2 to 2^104 m. */ + uint64_t d0, d1, d2; + double y, t; + d0 = (m << 42) - s*s; + d1 = s - d0; + d2 = d1 + s + 1; + s += d1 >> 63; + s &= 0x000fffffffffffff; + s |= top << 52; + y = asdouble(s); + if (FENV_SUPPORT) { + /* handle rounding modes and inexact exception: + only (s+1)^2 == 2^42 m case is exact otherwise + add a tiny value to cause the fenv effects. */ + uint64_t tiny = predict_false(d2==0) ? 0 : 0x0010000000000000; + tiny |= (d1^d2) & 0x8000000000000000; + t = asdouble(tiny); + y = eval_as_double(y + t); } - ix0 = (q>>1) + 0x3fe00000; - ix1 = q1>>1; - if (q&1) - ix1 |= sign; - INSERT_WORDS(z, ix0 + ((uint32_t)m << 20), ix1); - return z; + return y; } diff --git a/lib/libc/musl/src/math/sqrt_data.c b/lib/libc/musl/src/math/sqrt_data.c new file mode 100644 index 0000000000..61bc22f430 --- /dev/null +++ b/lib/libc/musl/src/math/sqrt_data.c @@ -0,0 +1,19 @@ +#include "sqrt_data.h" +const uint16_t __rsqrt_tab[128] = { +0xb451,0xb2f0,0xb196,0xb044,0xaef9,0xadb6,0xac79,0xab43, +0xaa14,0xa8eb,0xa7c8,0xa6aa,0xa592,0xa480,0xa373,0xa26b, +0xa168,0xa06a,0x9f70,0x9e7b,0x9d8a,0x9c9d,0x9bb5,0x9ad1, +0x99f0,0x9913,0x983a,0x9765,0x9693,0x95c4,0x94f8,0x9430, +0x936b,0x92a9,0x91ea,0x912e,0x9075,0x8fbe,0x8f0a,0x8e59, +0x8daa,0x8cfe,0x8c54,0x8bac,0x8b07,0x8a64,0x89c4,0x8925, +0x8889,0x87ee,0x8756,0x86c0,0x862b,0x8599,0x8508,0x8479, +0x83ec,0x8361,0x82d8,0x8250,0x81c9,0x8145,0x80c2,0x8040, +0xff02,0xfd0e,0xfb25,0xf947,0xf773,0xf5aa,0xf3ea,0xf234, +0xf087,0xeee3,0xed47,0xebb3,0xea27,0xe8a3,0xe727,0xe5b2, +0xe443,0xe2dc,0xe17a,0xe020,0xdecb,0xdd7d,0xdc34,0xdaf1, +0xd9b3,0xd87b,0xd748,0xd61a,0xd4f1,0xd3cd,0xd2ad,0xd192, +0xd07b,0xcf69,0xce5b,0xcd51,0xcc4a,0xcb48,0xca4a,0xc94f, +0xc858,0xc764,0xc674,0xc587,0xc49d,0xc3b7,0xc2d4,0xc1f4, +0xc116,0xc03c,0xbf65,0xbe90,0xbdbe,0xbcef,0xbc23,0xbb59, +0xba91,0xb9cc,0xb90a,0xb84a,0xb78c,0xb6d0,0xb617,0xb560, +}; diff --git a/lib/libc/musl/src/math/sqrt_data.h b/lib/libc/musl/src/math/sqrt_data.h new file mode 100644 index 0000000000..260c7f9c29 --- /dev/null +++ b/lib/libc/musl/src/math/sqrt_data.h @@ -0,0 +1,13 @@ +#ifndef _SQRT_DATA_H +#define _SQRT_DATA_H + +#include +#include + +/* if x in [1,2): i = (int)(64*x); + if x in [2,4): i = (int)(32*x-64); + __rsqrt_tab[i]*2^-16 is estimating 1/sqrt(x) with small relative error: + |__rsqrt_tab[i]*0x1p-16*sqrt(x) - 1| < -0x1.fdp-9 < 2^-8 */ +extern hidden const uint16_t __rsqrt_tab[128]; + +#endif diff --git a/lib/libc/musl/src/math/sqrtf.c b/lib/libc/musl/src/math/sqrtf.c index d6ace38aa6..740d81cbab 100644 --- a/lib/libc/musl/src/math/sqrtf.c +++ b/lib/libc/musl/src/math/sqrtf.c @@ -1,83 +1,83 @@ -/* origin: FreeBSD /usr/src/lib/msun/src/e_sqrtf.c */ -/* - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - +#include +#include #include "libm.h" +#include "sqrt_data.h" -static const float tiny = 1.0e-30; +#define FENV_SUPPORT 1 + +static inline uint32_t mul32(uint32_t a, uint32_t b) +{ + return (uint64_t)a*b >> 32; +} + +/* see sqrt.c for more detailed comments. */ float sqrtf(float x) { - float z; - int32_t sign = (int)0x80000000; - int32_t ix,s,q,m,t,i; - uint32_t r; + uint32_t ix, m, m1, m0, even, ey; - GET_FLOAT_WORD(ix, x); - - /* take care of Inf and NaN */ - if ((ix&0x7f800000) == 0x7f800000) - return x*x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf, sqrt(-inf)=sNaN */ - - /* take care of zero */ - if (ix <= 0) { - if ((ix&~sign) == 0) - return x; /* sqrt(+-0) = +-0 */ - if (ix < 0) - return (x-x)/(x-x); /* sqrt(-ve) = sNaN */ - } - /* normalize x */ - m = ix>>23; - if (m == 0) { /* subnormal x */ - for (i = 0; (ix&0x00800000) == 0; i++) - ix<<=1; - m -= i - 1; - } - m -= 127; /* unbias exponent */ - ix = (ix&0x007fffff)|0x00800000; - if (m&1) /* odd m, double x to make it even */ - ix += ix; - m >>= 1; /* m = [m/2] */ - - /* generate sqrt(x) bit by bit */ - ix += ix; - q = s = 0; /* q = sqrt(x) */ - r = 0x01000000; /* r = moving bit from right to left */ - - while (r != 0) { - t = s + r; - if (t <= ix) { - s = t+r; - ix -= t; - q += r; - } - ix += ix; - r >>= 1; + ix = asuint(x); + if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000)) { + /* x < 0x1p-126 or inf or nan. */ + if (ix * 2 == 0) + return x; + if (ix == 0x7f800000) + return x; + if (ix > 0x7f800000) + return __math_invalidf(x); + /* x is subnormal, normalize it. */ + ix = asuint(x * 0x1p23f); + ix -= 23 << 23; } - /* use floating add to find out rounding direction */ - if (ix != 0) { - z = 1.0f - tiny; /* raise inexact flag */ - if (z >= 1.0f) { - z = 1.0f + tiny; - if (z > 1.0f) - q += 2; - else - q += q & 1; - } + /* x = 4^e m; with int e and m in [1, 4). */ + even = ix & 0x00800000; + m1 = (ix << 8) | 0x80000000; + m0 = (ix << 7) & 0x7fffffff; + m = even ? m0 : m1; + + /* 2^e is the exponent part of the return value. */ + ey = ix >> 1; + ey += 0x3f800000 >> 1; + ey &= 0x7f800000; + + /* compute r ~ 1/sqrt(m), s ~ sqrt(m) with 2 goldschmidt iterations. */ + static const uint32_t three = 0xc0000000; + uint32_t r, s, d, u, i; + i = (ix >> 17) % 128; + r = (uint32_t)__rsqrt_tab[i] << 16; + /* |r*sqrt(m) - 1| < 0x1p-8 */ + s = mul32(m, r); + /* |s/sqrt(m) - 1| < 0x1p-8 */ + d = mul32(s, r); + u = three - d; + r = mul32(r, u) << 1; + /* |r*sqrt(m) - 1| < 0x1.7bp-16 */ + s = mul32(s, u) << 1; + /* |s/sqrt(m) - 1| < 0x1.7bp-16 */ + d = mul32(s, r); + u = three - d; + s = mul32(s, u); + /* -0x1.03p-28 < s/sqrt(m) - 1 < 0x1.fp-31 */ + s = (s - 1)>>6; + /* s < sqrt(m) < s + 0x1.08p-23 */ + + /* compute nearest rounded result. */ + uint32_t d0, d1, d2; + float y, t; + d0 = (m << 16) - s*s; + d1 = s - d0; + d2 = d1 + s + 1; + s += d1 >> 31; + s &= 0x007fffff; + s |= ey; + y = asfloat(s); + if (FENV_SUPPORT) { + /* handle rounding and inexact exception. */ + uint32_t tiny = predict_false(d2==0) ? 0 : 0x01000000; + tiny |= (d1^d2) & 0x80000000; + t = asfloat(tiny); + y = eval_as_float(y + t); } - ix = (q>>1) + 0x3f000000; - SET_FLOAT_WORD(z, ix + ((uint32_t)m << 23)); - return z; + return y; } diff --git a/lib/libc/musl/src/math/sqrtl.c b/lib/libc/musl/src/math/sqrtl.c index 83a8f80c99..1b9f19c7d4 100644 --- a/lib/libc/musl/src/math/sqrtl.c +++ b/lib/libc/musl/src/math/sqrtl.c @@ -1,7 +1,259 @@ +#include #include +#include +#include "libm.h" + +#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +long double sqrtl(long double x) +{ + return sqrt(x); +} +#elif (LDBL_MANT_DIG == 113 || LDBL_MANT_DIG == 64) && LDBL_MAX_EXP == 16384 +#include "sqrt_data.h" + +#define FENV_SUPPORT 1 + +typedef struct { + uint64_t hi; + uint64_t lo; +} u128; + +/* top: 16 bit sign+exponent, x: significand. */ +static inline long double mkldbl(uint64_t top, u128 x) +{ + union ldshape u; +#if LDBL_MANT_DIG == 113 + u.i2.hi = x.hi; + u.i2.lo = x.lo; + u.i2.hi &= 0x0000ffffffffffff; + u.i2.hi |= top << 48; +#elif LDBL_MANT_DIG == 64 + u.i.se = top; + u.i.m = x.lo; + /* force the top bit on non-zero (and non-subnormal) results. */ + if (top & 0x7fff) + u.i.m |= 0x8000000000000000; +#endif + return u.f; +} + +/* return: top 16 bit is sign+exp and following bits are the significand. */ +static inline u128 asu128(long double x) +{ + union ldshape u = {.f=x}; + u128 r; +#if LDBL_MANT_DIG == 113 + r.hi = u.i2.hi; + r.lo = u.i2.lo; +#elif LDBL_MANT_DIG == 64 + r.lo = u.i.m<<49; + /* ignore the top bit: pseudo numbers are not handled. */ + r.hi = u.i.m>>15; + r.hi &= 0x0000ffffffffffff; + r.hi |= (uint64_t)u.i.se << 48; +#endif + return r; +} + +/* returns a*b*2^-32 - e, with error 0 <= e < 1. */ +static inline uint32_t mul32(uint32_t a, uint32_t b) +{ + return (uint64_t)a*b >> 32; +} + +/* returns a*b*2^-64 - e, with error 0 <= e < 3. */ +static inline uint64_t mul64(uint64_t a, uint64_t b) +{ + uint64_t ahi = a>>32; + uint64_t alo = a&0xffffffff; + uint64_t bhi = b>>32; + uint64_t blo = b&0xffffffff; + return ahi*bhi + (ahi*blo >> 32) + (alo*bhi >> 32); +} + +static inline u128 add64(u128 a, uint64_t b) +{ + u128 r; + r.lo = a.lo + b; + r.hi = a.hi; + if (r.lo < a.lo) + r.hi++; + return r; +} + +static inline u128 add128(u128 a, u128 b) +{ + u128 r; + r.lo = a.lo + b.lo; + r.hi = a.hi + b.hi; + if (r.lo < a.lo) + r.hi++; + return r; +} + +static inline u128 sub64(u128 a, uint64_t b) +{ + u128 r; + r.lo = a.lo - b; + r.hi = a.hi; + if (a.lo < b) + r.hi--; + return r; +} + +static inline u128 sub128(u128 a, u128 b) +{ + u128 r; + r.lo = a.lo - b.lo; + r.hi = a.hi - b.hi; + if (a.lo < b.lo) + r.hi--; + return r; +} + +/* a<= 64) { + a.hi = a.lo<<(n-64); + a.lo = 0; + } else { + a.hi = (a.hi<>(64-n)); + a.lo = a.lo<>n, 0 <= n <= 127 */ +static inline u128 rsh(u128 a, int n) +{ + if (n == 0) + return a; + if (n >= 64) { + a.lo = a.hi>>(n-64); + a.hi = 0; + } else { + a.lo = (a.lo>>n) | (a.hi<<(64-n)); + a.hi = a.hi>>n; + } + return a; +} + +/* returns a*b exactly. */ +static inline u128 mul64_128(uint64_t a, uint64_t b) +{ + u128 r; + uint64_t ahi = a>>32; + uint64_t alo = a&0xffffffff; + uint64_t bhi = b>>32; + uint64_t blo = b&0xffffffff; + uint64_t lo1 = ((ahi*blo)&0xffffffff) + ((alo*bhi)&0xffffffff) + (alo*blo>>32); + uint64_t lo2 = (alo*blo)&0xffffffff; + r.hi = ahi*bhi + (ahi*blo>>32) + (alo*bhi>>32) + (lo1>>32); + r.lo = (lo1<<32) + lo2; + return r; +} + +/* returns a*b*2^-128 - e, with error 0 <= e < 7. */ +static inline u128 mul128(u128 a, u128 b) +{ + u128 hi = mul64_128(a.hi, b.hi); + uint64_t m1 = mul64(a.hi, b.lo); + uint64_t m2 = mul64(a.lo, b.hi); + return add64(add64(hi, m1), m2); +} + +/* returns a*b % 2^128. */ +static inline u128 mul128_tail(u128 a, u128 b) +{ + u128 lo = mul64_128(a.lo, b.lo); + lo.hi += a.hi*b.lo + a.lo*b.hi; + return lo; +} + + +/* see sqrt.c for detailed comments. */ long double sqrtl(long double x) { - /* FIXME: implement in C, this is for LDBL_MANT_DIG == 64 only */ - return sqrt(x); + u128 ix, ml; + uint64_t top; + + ix = asu128(x); + top = ix.hi >> 48; + if (predict_false(top - 0x0001 >= 0x7fff - 0x0001)) { + /* x < 0x1p-16382 or inf or nan. */ + if (2*ix.hi == 0 && ix.lo == 0) + return x; + if (ix.hi == 0x7fff000000000000 && ix.lo == 0) + return x; + if (top >= 0x7fff) + return __math_invalidl(x); + /* x is subnormal, normalize it. */ + ix = asu128(x * 0x1p112); + top = ix.hi >> 48; + top -= 112; + } + + /* x = 4^e m; with int e and m in [1, 4) */ + int even = top & 1; + ml = lsh(ix, 15); + ml.hi |= 0x8000000000000000; + if (even) ml = rsh(ml, 1); + top = (top + 0x3fff) >> 1; + + /* r ~ 1/sqrt(m) */ + static const uint64_t three = 0xc0000000; + uint64_t r, s, d, u, i; + i = (ix.hi >> 42) % 128; + r = (uint32_t)__rsqrt_tab[i] << 16; + /* |r sqrt(m) - 1| < 0x1p-8 */ + s = mul32(ml.hi>>32, r); + d = mul32(s, r); + u = three - d; + r = mul32(u, r) << 1; + /* |r sqrt(m) - 1| < 0x1.7bp-16, switch to 64bit */ + r = r<<32; + s = mul64(ml.hi, r); + d = mul64(s, r); + u = (three<<32) - d; + r = mul64(u, r) << 1; + /* |r sqrt(m) - 1| < 0x1.a5p-31 */ + s = mul64(u, s) << 1; + d = mul64(s, r); + u = (three<<32) - d; + r = mul64(u, r) << 1; + /* |r sqrt(m) - 1| < 0x1.c001p-59, switch to 128bit */ + + static const u128 threel = {.hi=three<<32, .lo=0}; + u128 rl, sl, dl, ul; + rl.hi = r; + rl.lo = 0; + sl = mul128(ml, rl); + dl = mul128(sl, rl); + ul = sub128(threel, dl); + sl = mul128(ul, sl); /* repr: 3.125 */ + /* -0x1p-116 < s - sqrt(m) < 0x3.8001p-125 */ + sl = rsh(sub64(sl, 4), 125-(LDBL_MANT_DIG-1)); + /* s < sqrt(m) < s + 1 ULP + tiny */ + + long double y; + u128 d2, d1, d0; + d0 = sub128(lsh(ml, 2*(LDBL_MANT_DIG-1)-126), mul128_tail(sl,sl)); + d1 = sub128(sl, d0); + d2 = add128(add64(sl, 1), d1); + sl = add64(sl, d1.hi >> 63); + y = mkldbl(top, sl); + if (FENV_SUPPORT) { + /* handle rounding modes and inexact exception. */ + top = predict_false((d2.hi|d2.lo)==0) ? 0 : 1; + top |= ((d1.hi^d2.hi)&0x8000000000000000) >> 48; + y += mkldbl(top, (u128){0}); + } + return y; } +#else +#error unsupported long double format +#endif diff --git a/lib/libc/musl/src/misc/ioctl.c b/lib/libc/musl/src/misc/ioctl.c index 8947751147..492828119a 100644 --- a/lib/libc/musl/src/misc/ioctl.c +++ b/lib/libc/musl/src/misc/ioctl.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "syscall.h" @@ -28,6 +29,12 @@ struct ioctl_compat_map { * number producing macros; only size of result is meaningful. */ #define new_misaligned(n) struct { int i; time_t t; char c[(n)-4]; } +struct v4l2_event { + uint32_t a; + uint64_t b[8]; + uint32_t c[2], ts[2], d[9]; +}; + static const struct ioctl_compat_map compat_map[] = { { SIOCGSTAMP, SIOCGSTAMP_OLD, 8, R, 0, OFFS(0, 4) }, { SIOCGSTAMPNS, SIOCGSTAMPNS_OLD, 8, R, 0, OFFS(0, 4) }, @@ -49,13 +56,14 @@ static const struct ioctl_compat_map compat_map[] = { { 0, 0, 8, WR, 1, OFFS(0,4) }, /* snd_pcm_mmap_control */ /* VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF */ - { _IOWR('V', 9, new_misaligned(72)), _IOWR('V', 9, char[72]), 72, WR, 0, OFFS(20) }, - { _IOWR('V', 15, new_misaligned(72)), _IOWR('V', 15, char[72]), 72, WR, 0, OFFS(20) }, - { _IOWR('V', 17, new_misaligned(72)), _IOWR('V', 17, char[72]), 72, WR, 0, OFFS(20) }, - { _IOWR('V', 93, new_misaligned(72)), _IOWR('V', 93, char[72]), 72, WR, 0, OFFS(20) }, + { _IOWR('V', 9, new_misaligned(68)), _IOWR('V', 9, char[68]), 68, WR, 1, OFFS(20, 24) }, + { _IOWR('V', 15, new_misaligned(68)), _IOWR('V', 15, char[68]), 68, WR, 1, OFFS(20, 24) }, + { _IOWR('V', 17, new_misaligned(68)), _IOWR('V', 17, char[68]), 68, WR, 1, OFFS(20, 24) }, + { _IOWR('V', 93, new_misaligned(68)), _IOWR('V', 93, char[68]), 68, WR, 1, OFFS(20, 24) }, /* VIDIOC_DQEVENT */ - { _IOR('V', 89, new_misaligned(96)), _IOR('V', 89, char[96]), 96, R, 0, OFFS(76,80) }, + { _IOR('V', 89, new_misaligned(120)), _IOR('V', 89, struct v4l2_event), sizeof(struct v4l2_event), + R, 0, OFFS(offsetof(struct v4l2_event, ts[0]), offsetof(struct v4l2_event, ts[1])) }, /* VIDIOC_OMAP3ISP_STAT_REQ */ { _IOWR('V', 192+6, char[32]), _IOWR('V', 192+6, char[24]), 22, WR, 0, OFFS(0,4) }, diff --git a/lib/libc/musl/src/misc/realpath.c b/lib/libc/musl/src/misc/realpath.c index d2708e59da..db8b74dc8d 100644 --- a/lib/libc/musl/src/misc/realpath.c +++ b/lib/libc/musl/src/misc/realpath.c @@ -1,43 +1,156 @@ #include #include -#include -#include #include #include #include -#include "syscall.h" + +static size_t slash_len(const char *s) +{ + const char *s0 = s; + while (*s == '/') s++; + return s-s0; +} char *realpath(const char *restrict filename, char *restrict resolved) { - int fd; - ssize_t r; - struct stat st1, st2; - char buf[15+3*sizeof(int)]; - char tmp[PATH_MAX]; + char stack[PATH_MAX+1]; + char output[PATH_MAX]; + size_t p, q, l, l0, cnt=0, nup=0; + int check_dir=0; if (!filename) { errno = EINVAL; return 0; } + l = strnlen(filename, sizeof stack); + if (!l) { + errno = ENOENT; + return 0; + } + if (l >= PATH_MAX) goto toolong; + p = sizeof stack - l - 1; + q = 0; + memcpy(stack+p, filename, l+1); - fd = sys_open(filename, O_PATH|O_NONBLOCK|O_CLOEXEC); - if (fd < 0) return 0; - __procfdname(buf, fd); + /* Main loop. Each iteration pops the next part from stack of + * remaining path components and consumes any slashes that follow. + * If not a link, it's moved to output; if a link, contents are + * pushed to the stack. */ +restart: + for (; ; p+=slash_len(stack+p)) { + /* If stack starts with /, the whole component is / or // + * and the output state must be reset. */ + if (stack[p] == '/') { + check_dir=0; + nup=0; + q=0; + output[q++] = '/'; + p++; + /* Initial // is special. */ + if (stack[p] == '/' && stack[p+1] != '/') + output[q++] = '/'; + continue; + } - r = readlink(buf, tmp, sizeof tmp - 1); - if (r < 0) goto err; - tmp[r] = 0; + char *z = __strchrnul(stack+p, '/'); + l0 = l = z-(stack+p); - fstat(fd, &st1); - r = stat(tmp, &st2); - if (r<0 || st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino) { - if (!r) errno = ELOOP; - goto err; + if (!l && !check_dir) break; + + /* Skip any . component but preserve check_dir status. */ + if (l==1 && stack[p]=='.') { + p += l; + continue; + } + + /* Copy next component onto output at least temporarily, to + * call readlink, but wait to advance output position until + * determining it's not a link. */ + if (q && output[q-1] != '/') { + if (!p) goto toolong; + stack[--p] = '/'; + l++; + } + if (q+l >= PATH_MAX) goto toolong; + memcpy(output+q, stack+p, l); + output[q+l] = 0; + p += l; + + int up = 0; + if (l0==2 && stack[p-2]=='.' && stack[p-1]=='.') { + up = 1; + /* Any non-.. path components we could cancel start + * after nup repetitions of the 3-byte string "../"; + * if there are none, accumulate .. components to + * later apply to cwd, if needed. */ + if (q <= 3*nup) { + nup++; + q += l; + continue; + } + /* When previous components are already known to be + * directories, processing .. can skip readlink. */ + if (!check_dir) goto skip_readlink; + } + ssize_t k = readlink(output, stack, p); + if (k==p) goto toolong; + if (!k) { + errno = ENOENT; + return 0; + } + if (k<0) { + if (errno != EINVAL) return 0; +skip_readlink: + check_dir = 0; + if (up) { + while(q && output[q-1]!='/') q--; + if (q>1 && (q>2 || output[0]!='/')) q--; + continue; + } + if (l0) q += l; + check_dir = stack[p]; + continue; + } + if (++cnt == SYMLOOP_MAX) { + errno = ELOOP; + return 0; + } + + /* If link contents end in /, strip any slashes already on + * stack to avoid /->// or //->/// or spurious toolong. */ + if (stack[k-1]=='/') while (stack[p]=='/') p++; + p -= k; + memmove(stack+p, stack, k); + + /* Skip the stack advancement in case we have a new + * absolute base path. */ + goto restart; } - __syscall(SYS_close, fd); - return resolved ? strcpy(resolved, tmp) : strdup(tmp); -err: - __syscall(SYS_close, fd); + output[q] = 0; + + if (output[0] != '/') { + if (!getcwd(stack, sizeof stack)) return 0; + l = strlen(stack); + /* Cancel any initial .. components. */ + p = 0; + while (nup--) { + while(l>1 && stack[l-1]!='/') l--; + if (l>1) l--; + p += 2; + if (p= PATH_MAX) goto toolong; + memmove(output + l, output + p, q - p + 1); + memcpy(output, stack, l); + q = l + q-p; + } + + if (resolved) return memcpy(resolved, output, q+1); + else return strdup(output); + +toolong: + errno = ENAMETOOLONG; return 0; } diff --git a/lib/libc/musl/src/misc/setrlimit.c b/lib/libc/musl/src/misc/setrlimit.c index 7a66ab2975..8340aee096 100644 --- a/lib/libc/musl/src/misc/setrlimit.c +++ b/lib/libc/musl/src/misc/setrlimit.c @@ -6,25 +6,8 @@ #define MIN(a, b) ((a)<(b) ? (a) : (b)) #define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0) -static int __setrlimit(int resource, const struct rlimit *rlim) -{ - unsigned long k_rlim[2]; - struct rlimit tmp; - if (SYSCALL_RLIM_INFINITY != RLIM_INFINITY) { - tmp = *rlim; - FIX(tmp.rlim_cur); - FIX(tmp.rlim_max); - rlim = &tmp; - } - int ret = __syscall(SYS_prlimit64, 0, resource, rlim, 0); - if (ret != -ENOSYS) return ret; - k_rlim[0] = MIN(rlim->rlim_cur, MIN(-1UL, SYSCALL_RLIM_INFINITY)); - k_rlim[1] = MIN(rlim->rlim_max, MIN(-1UL, SYSCALL_RLIM_INFINITY)); - return __syscall(SYS_setrlimit, resource, k_rlim); -} - struct ctx { - const struct rlimit *rlim; + unsigned long lim[2]; int res; int err; }; @@ -33,12 +16,26 @@ static void do_setrlimit(void *p) { struct ctx *c = p; if (c->err>0) return; - c->err = -__setrlimit(c->res, c->rlim); + c->err = -__syscall(SYS_setrlimit, c->res, c->lim); } int setrlimit(int resource, const struct rlimit *rlim) { - struct ctx c = { .res = resource, .rlim = rlim, .err = -1 }; + struct rlimit tmp; + if (SYSCALL_RLIM_INFINITY != RLIM_INFINITY) { + tmp = *rlim; + FIX(tmp.rlim_cur); + FIX(tmp.rlim_max); + rlim = &tmp; + } + int ret = __syscall(SYS_prlimit64, 0, resource, rlim, 0); + if (ret != -ENOSYS) return __syscall_ret(ret); + + struct ctx c = { + .lim[0] = MIN(rlim->rlim_cur, MIN(-1UL, SYSCALL_RLIM_INFINITY)), + .lim[1] = MIN(rlim->rlim_max, MIN(-1UL, SYSCALL_RLIM_INFINITY)), + .res = resource, .err = -1 + }; __synccall(do_setrlimit, &c); if (c.err) { if (c.err>0) errno = c.err; diff --git a/lib/libc/musl/src/misc/syslog.c b/lib/libc/musl/src/misc/syslog.c index 13d4b0a6d7..7dc0c1be50 100644 --- a/lib/libc/musl/src/misc/syslog.c +++ b/lib/libc/musl/src/misc/syslog.c @@ -10,6 +10,7 @@ #include #include #include "lock.h" +#include "fork_impl.h" static volatile int lock[1]; static char log_ident[32]; @@ -17,6 +18,7 @@ static int log_opt; static int log_facility = LOG_USER; static int log_mask = 0xff; static int log_fd = -1; +volatile int *const __syslog_lockptr = lock; int setlogmask(int maskpri) { diff --git a/lib/libc/musl/src/multibyte/wcsnrtombs.c b/lib/libc/musl/src/multibyte/wcsnrtombs.c index 676932b5dc..95e25e708d 100644 --- a/lib/libc/musl/src/multibyte/wcsnrtombs.c +++ b/lib/libc/musl/src/multibyte/wcsnrtombs.c @@ -1,41 +1,33 @@ #include +#include +#include size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, size_t n, mbstate_t *restrict st) { - size_t l, cnt=0, n2; - char *s, buf[256]; const wchar_t *ws = *wcs; - const wchar_t *tmp_ws; - - if (!dst) s = buf, n = sizeof buf; - else s = dst; - - while ( ws && n && ( (n2=wn)>=n || n2>32 ) ) { - if (n2>=n) n2=n; - tmp_ws = ws; - l = wcsrtombs(s, &ws, n2, 0); - if (!(l+1)) { - cnt = l; - n = 0; + size_t cnt = 0; + if (!dst) n=0; + while (ws && wn) { + char tmp[MB_LEN_MAX]; + size_t l = wcrtomb(nn) break; + memcpy(dst, tmp, l); + } + dst += l; n -= l; } - wn = ws ? wn - (ws - tmp_ws) : 0; - cnt += l; - } - if (ws) while (n && wn) { - l = wcrtomb(s, *ws, 0); - if ((l+1)<=1) { - if (!l) ws = 0; - else cnt = l; + if (!*ws) { + ws = 0; break; } - ws++; wn--; - /* safe - this loop runs fewer than sizeof(buf) times */ - s+=l; n-=l; + ws++; + wn--; cnt += l; } if (dst) *wcs = ws; diff --git a/lib/libc/musl/src/network/h_errno.c b/lib/libc/musl/src/network/h_errno.c index 4f700ceaf1..638f771803 100644 --- a/lib/libc/musl/src/network/h_errno.c +++ b/lib/libc/musl/src/network/h_errno.c @@ -1,9 +1,11 @@ #include +#include "pthread_impl.h" #undef h_errno int h_errno; int *__h_errno_location(void) { - return &h_errno; + if (!__pthread_self()->stack) return &h_errno; + return &__pthread_self()->h_errno_val; } diff --git a/lib/libc/musl/src/network/herror.c b/lib/libc/musl/src/network/herror.c index 65f25ff3f4..87f8cff4fd 100644 --- a/lib/libc/musl/src/network/herror.c +++ b/lib/libc/musl/src/network/herror.c @@ -4,5 +4,5 @@ void herror(const char *msg) { - fprintf(stderr, "%s%s%s", msg?msg:"", msg?": ":"", hstrerror(h_errno)); + fprintf(stderr, "%s%s%s\n", msg?msg:"", msg?": ":"", hstrerror(h_errno)); } diff --git a/lib/libc/musl/src/network/lookup_name.c b/lib/libc/musl/src/network/lookup_name.c index aae0d95a04..aa558c197a 100644 --- a/lib/libc/musl/src/network/lookup_name.c +++ b/lib/libc/musl/src/network/lookup_name.c @@ -50,7 +50,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati { char line[512]; size_t l = strlen(name); - int cnt = 0, badfam = 0; + int cnt = 0, badfam = 0, have_canon = 0; unsigned char _buf[1032]; FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf); if (!f) switch (errno) { @@ -80,14 +80,19 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati continue; default: badfam = EAI_NONAME; - continue; + break; } + if (have_canon) continue; + /* Extract first name as canonical name */ for (; *p && isspace(*p); p++); for (z=p; *z && !isspace(*z); z++); *z = 0; - if (is_valid_hostname(p)) memcpy(canon, p, z-p+1); + if (is_valid_hostname(p)) { + have_canon = 1; + memcpy(canon, p, z-p+1); + } } __fclose_ca(f); return cnt ? cnt : badfam; diff --git a/lib/libc/musl/src/network/res_query.c b/lib/libc/musl/src/network/res_query.c index 2f4da2e2e7..506dc23126 100644 --- a/lib/libc/musl/src/network/res_query.c +++ b/lib/libc/musl/src/network/res_query.c @@ -1,3 +1,4 @@ +#define _BSD_SOURCE #include #include @@ -6,7 +7,20 @@ int res_query(const char *name, int class, int type, unsigned char *dest, int le unsigned char q[280]; int ql = __res_mkquery(0, name, class, type, 0, 0, 0, q, sizeof q); if (ql < 0) return ql; - return __res_send(q, ql, dest, len); + int r = __res_send(q, ql, dest, len); + if (r<12) { + h_errno = TRY_AGAIN; + return -1; + } + if ((dest[3] & 15) == 3) { + h_errno = HOST_NOT_FOUND; + return -1; + } + if ((dest[3] & 15) == 0 && !dest[6] && !dest[7]) { + h_errno = NO_DATA; + return -1; + } + return r; } weak_alias(res_query, res_search); diff --git a/lib/libc/musl/src/passwd/getgrouplist.c b/lib/libc/musl/src/passwd/getgrouplist.c index 43e518245f..301824cec5 100644 --- a/lib/libc/musl/src/passwd/getgrouplist.c +++ b/lib/libc/musl/src/passwd/getgrouplist.c @@ -31,7 +31,8 @@ int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups) if (resp[INITGRFOUND]) { nscdbuf = calloc(resp[INITGRNGRPS], sizeof(uint32_t)); if (!nscdbuf) goto cleanup; - if (!fread(nscdbuf, sizeof(*nscdbuf)*resp[INITGRNGRPS], 1, f)) { + size_t nbytes = sizeof(*nscdbuf)*resp[INITGRNGRPS]; + if (nbytes && !fread(nscdbuf, nbytes, 1, f)) { if (!ferror(f)) errno = EIO; goto cleanup; } diff --git a/lib/libc/musl/src/prng/random.c b/lib/libc/musl/src/prng/random.c index 633a17f690..d3780fa7ea 100644 --- a/lib/libc/musl/src/prng/random.c +++ b/lib/libc/musl/src/prng/random.c @@ -1,6 +1,7 @@ #include #include #include "lock.h" +#include "fork_impl.h" /* this code uses the same lagged fibonacci generator as the @@ -23,6 +24,7 @@ static int i = 3; static int j = 0; static uint32_t *x = init+1; static volatile int lock[1]; +volatile int *const __random_lockptr = lock; static uint32_t lcg31(uint32_t x) { return (1103515245*x + 12345) & 0x7fffffff; diff --git a/lib/libc/musl/src/process/_Fork.c b/lib/libc/musl/src/process/_Fork.c new file mode 100644 index 0000000000..da06386815 --- /dev/null +++ b/lib/libc/musl/src/process/_Fork.c @@ -0,0 +1,38 @@ +#include +#include +#include "syscall.h" +#include "libc.h" +#include "lock.h" +#include "pthread_impl.h" +#include "aio_impl.h" + +static void dummy(int x) { } +weak_alias(dummy, __aio_atfork); + +pid_t _Fork(void) +{ + pid_t ret; + sigset_t set; + __block_all_sigs(&set); + __aio_atfork(-1); + LOCK(__abort_lock); +#ifdef SYS_fork + ret = __syscall(SYS_fork); +#else + ret = __syscall(SYS_clone, SIGCHLD, 0); +#endif + if (!ret) { + pthread_t self = __pthread_self(); + self->tid = __syscall(SYS_gettid); + self->robust_list.off = 0; + self->robust_list.pending = 0; + self->next = self->prev = self; + __thread_list_lock = 0; + libc.threads_minus_1 = 0; + if (libc.need_locks) libc.need_locks = -1; + } + UNLOCK(__abort_lock); + __aio_atfork(!ret); + __restore_sigs(&set); + return __syscall_ret(ret); +} diff --git a/lib/libc/musl/src/process/fork.c b/lib/libc/musl/src/process/fork.c index 7e984ff8c3..54bc289202 100644 --- a/lib/libc/musl/src/process/fork.c +++ b/lib/libc/musl/src/process/fork.c @@ -1,38 +1,86 @@ #include -#include -#include -#include "syscall.h" +#include #include "libc.h" +#include "lock.h" #include "pthread_impl.h" +#include "fork_impl.h" -static void dummy(int x) -{ -} +static volatile int *const dummy_lockptr = 0; +weak_alias(dummy_lockptr, __at_quick_exit_lockptr); +weak_alias(dummy_lockptr, __atexit_lockptr); +weak_alias(dummy_lockptr, __dlerror_lockptr); +weak_alias(dummy_lockptr, __gettext_lockptr); +weak_alias(dummy_lockptr, __locale_lockptr); +weak_alias(dummy_lockptr, __random_lockptr); +weak_alias(dummy_lockptr, __sem_open_lockptr); +weak_alias(dummy_lockptr, __stdio_ofl_lockptr); +weak_alias(dummy_lockptr, __syslog_lockptr); +weak_alias(dummy_lockptr, __timezone_lockptr); +weak_alias(dummy_lockptr, __bump_lockptr); + +weak_alias(dummy_lockptr, __vmlock_lockptr); + +static volatile int *const *const atfork_locks[] = { + &__at_quick_exit_lockptr, + &__atexit_lockptr, + &__dlerror_lockptr, + &__gettext_lockptr, + &__locale_lockptr, + &__random_lockptr, + &__sem_open_lockptr, + &__stdio_ofl_lockptr, + &__syslog_lockptr, + &__timezone_lockptr, + &__bump_lockptr, +}; + +static void dummy(int x) { } weak_alias(dummy, __fork_handler); +weak_alias(dummy, __malloc_atfork); +weak_alias(dummy, __ldso_atfork); + +static void dummy_0(void) { } +weak_alias(dummy_0, __tl_lock); +weak_alias(dummy_0, __tl_unlock); pid_t fork(void) { - pid_t ret; sigset_t set; __fork_handler(-1); - __block_all_sigs(&set); -#ifdef SYS_fork - ret = __syscall(SYS_fork); -#else - ret = __syscall(SYS_clone, SIGCHLD, 0); -#endif - if (!ret) { - pthread_t self = __pthread_self(); - self->tid = __syscall(SYS_gettid); - self->robust_list.off = 0; - self->robust_list.pending = 0; - self->next = self->prev = self; - __thread_list_lock = 0; - libc.threads_minus_1 = 0; - if (libc.need_locks) libc.need_locks = -1; + __block_app_sigs(&set); + int need_locks = libc.need_locks > 0; + if (need_locks) { + __ldso_atfork(-1); + __inhibit_ptc(); + for (int i=0; inext; + pid_t ret = _Fork(); + int errno_save = errno; + if (need_locks) { + if (!ret) { + for (pthread_t td=next; td!=self; td=td->next) + td->tid = -1; + if (__vmlock_lockptr) { + __vmlock_lockptr[0] = 0; + __vmlock_lockptr[1] = 0; + } + } + __tl_unlock(); + __malloc_atfork(!ret); + for (int i=0; i #include #include "syscall.h" +#include "lock.h" #include "pthread_impl.h" #include "fdop.h" @@ -170,9 +171,6 @@ int posix_spawn(pid_t *restrict res, const char *restrict path, int ec=0, cs; struct args args; - if (pipe2(args.p, O_CLOEXEC)) - return errno; - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); args.path = path; @@ -182,9 +180,20 @@ int posix_spawn(pid_t *restrict res, const char *restrict path, args.envp = envp; pthread_sigmask(SIG_BLOCK, SIGALL_SET, &args.oldmask); + /* The lock guards both against seeing a SIGABRT disposition change + * by abort and against leaking the pipe fd to fork-without-exec. */ + LOCK(__abort_lock); + + if (pipe2(args.p, O_CLOEXEC)) { + UNLOCK(__abort_lock); + ec = errno; + goto fail; + } + pid = __clone(child, stack+sizeof stack, CLONE_VM|CLONE_VFORK|SIGCHLD, &args); close(args.p[1]); + UNLOCK(__abort_lock); if (pid > 0) { if (read(args.p[0], &ec, sizeof ec) != sizeof ec) ec = 0; @@ -197,6 +206,7 @@ int posix_spawn(pid_t *restrict res, const char *restrict path, if (!ec && res) *res = pid; +fail: pthread_sigmask(SIG_SETMASK, &args.oldmask, 0); pthread_setcancelstate(cs, 0); diff --git a/lib/libc/musl/src/setjmp/aarch64/longjmp.s b/lib/libc/musl/src/setjmp/aarch64/longjmp.s index 7c4655fa96..0af9c50ee5 100644 --- a/lib/libc/musl/src/setjmp/aarch64/longjmp.s +++ b/lib/libc/musl/src/setjmp/aarch64/longjmp.s @@ -18,7 +18,6 @@ longjmp: ldp d12, d13, [x0,#144] ldp d14, d15, [x0,#160] - mov x0, x1 - cbnz x1, 1f - mov x0, #1 -1: br x30 + cmp w1, 0 + csinc w0, w1, wzr, ne + br x30 diff --git a/lib/libc/musl/src/setjmp/i386/longjmp.s b/lib/libc/musl/src/setjmp/i386/longjmp.s index 772d28ddb2..8188f06bcd 100644 --- a/lib/libc/musl/src/setjmp/i386/longjmp.s +++ b/lib/libc/musl/src/setjmp/i386/longjmp.s @@ -6,15 +6,11 @@ _longjmp: longjmp: mov 4(%esp),%edx mov 8(%esp),%eax - test %eax,%eax - jnz 1f - inc %eax -1: + cmp $1,%eax + adc $0, %al mov (%edx),%ebx mov 4(%edx),%esi mov 8(%edx),%edi mov 12(%edx),%ebp - mov 16(%edx),%ecx - mov %ecx,%esp - mov 20(%edx),%ecx - jmp *%ecx + mov 16(%edx),%esp + jmp *20(%edx) diff --git a/lib/libc/musl/src/setjmp/x32/longjmp.s b/lib/libc/musl/src/setjmp/x32/longjmp.s index e175a4b960..1b2661c3e5 100644 --- a/lib/libc/musl/src/setjmp/x32/longjmp.s +++ b/lib/libc/musl/src/setjmp/x32/longjmp.s @@ -5,18 +5,14 @@ .type longjmp,@function _longjmp: longjmp: - mov %rsi,%rax /* val will be longjmp return */ - test %rax,%rax - jnz 1f - inc %rax /* if val==0, val=1 per longjmp semantics */ -1: + xor %eax,%eax + cmp $1,%esi /* CF = val ? 0 : 1 */ + adc %esi,%eax /* eax = val + !val */ mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */ mov 8(%rdi),%rbp mov 16(%rdi),%r12 mov 24(%rdi),%r13 mov 32(%rdi),%r14 mov 40(%rdi),%r15 - mov 48(%rdi),%rdx /* this ends up being the stack pointer */ - mov %rdx,%rsp - mov 56(%rdi),%rdx /* this is the instruction pointer */ - jmp *%rdx /* goto saved address without altering rsp */ + mov 48(%rdi),%rsp + jmp *56(%rdi) /* goto saved address without altering rsp */ diff --git a/lib/libc/musl/src/setjmp/x32/setjmp.s b/lib/libc/musl/src/setjmp/x32/setjmp.s index 98f58b8d65..d95e485355 100644 --- a/lib/libc/musl/src/setjmp/x32/setjmp.s +++ b/lib/libc/musl/src/setjmp/x32/setjmp.s @@ -18,5 +18,5 @@ setjmp: mov %rdx,48(%rdi) mov (%rsp),%rdx /* save return addr ptr for new rip */ mov %rdx,56(%rdi) - xor %rax,%rax /* always return 0 */ + xor %eax,%eax /* always return 0 */ ret diff --git a/lib/libc/musl/src/setjmp/x86_64/longjmp.s b/lib/libc/musl/src/setjmp/x86_64/longjmp.s index e175a4b960..1b2661c3e5 100644 --- a/lib/libc/musl/src/setjmp/x86_64/longjmp.s +++ b/lib/libc/musl/src/setjmp/x86_64/longjmp.s @@ -5,18 +5,14 @@ .type longjmp,@function _longjmp: longjmp: - mov %rsi,%rax /* val will be longjmp return */ - test %rax,%rax - jnz 1f - inc %rax /* if val==0, val=1 per longjmp semantics */ -1: + xor %eax,%eax + cmp $1,%esi /* CF = val ? 0 : 1 */ + adc %esi,%eax /* eax = val + !val */ mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */ mov 8(%rdi),%rbp mov 16(%rdi),%r12 mov 24(%rdi),%r13 mov 32(%rdi),%r14 mov 40(%rdi),%r15 - mov 48(%rdi),%rdx /* this ends up being the stack pointer */ - mov %rdx,%rsp - mov 56(%rdi),%rdx /* this is the instruction pointer */ - jmp *%rdx /* goto saved address without altering rsp */ + mov 48(%rdi),%rsp + jmp *56(%rdi) /* goto saved address without altering rsp */ diff --git a/lib/libc/musl/src/setjmp/x86_64/setjmp.s b/lib/libc/musl/src/setjmp/x86_64/setjmp.s index 98f58b8d65..d95e485355 100644 --- a/lib/libc/musl/src/setjmp/x86_64/setjmp.s +++ b/lib/libc/musl/src/setjmp/x86_64/setjmp.s @@ -18,5 +18,5 @@ setjmp: mov %rdx,48(%rdi) mov (%rsp),%rdx /* save return addr ptr for new rip */ mov %rdx,56(%rdi) - xor %rax,%rax /* always return 0 */ + xor %eax,%eax /* always return 0 */ ret diff --git a/lib/libc/musl/src/signal/sigaction.c b/lib/libc/musl/src/signal/sigaction.c index c109bea0cf..2203471b24 100644 --- a/lib/libc/musl/src/signal/sigaction.c +++ b/lib/libc/musl/src/signal/sigaction.c @@ -7,12 +7,6 @@ #include "lock.h" #include "ksigaction.h" -static volatile int dummy_lock[1] = { 0 }; - -extern hidden volatile int __abort_lock[1]; - -weak_alias(dummy_lock, __abort_lock); - static int unmask_done; static unsigned long handler_set[_NSIG/(8*sizeof(long))]; @@ -26,7 +20,6 @@ volatile int __eintr_valid_flag; int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) { struct k_sigaction ksa, ksa_old; - unsigned long set[_NSIG/(8*sizeof(long))]; if (sa) { if ((uintptr_t)sa->sa_handler > 1UL) { a_or_l(handler_set+(sig-1)/(8*sizeof(long)), @@ -50,24 +43,12 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact a_store(&__eintr_valid_flag, 1); } } - /* Changing the disposition of SIGABRT to anything but - * SIG_DFL requires a lock, so that it cannot be changed - * while abort is terminating the process after simply - * calling raise(SIGABRT) failed to do so. */ - if (sa->sa_handler != SIG_DFL && sig == SIGABRT) { - __block_all_sigs(&set); - LOCK(__abort_lock); - } ksa.handler = sa->sa_handler; ksa.flags = sa->sa_flags | SA_RESTORER; ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore; memcpy(&ksa.mask, &sa->sa_mask, _NSIG/8); } int r = __syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa_old:0, _NSIG/8); - if (sig == SIGABRT && sa && sa->sa_handler != SIG_DFL) { - UNLOCK(__abort_lock); - __restore_sigs(&set); - } if (old && !r) { old->sa_handler = ksa_old.handler; old->sa_flags = ksa_old.flags; @@ -78,11 +59,26 @@ int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigact int __sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) { + unsigned long set[_NSIG/(8*sizeof(long))]; + if (sig-32U < 3 || sig-1U >= _NSIG-1) { errno = EINVAL; return -1; } - return __libc_sigaction(sig, sa, old); + + /* Doing anything with the disposition of SIGABRT requires a lock, + * so that it cannot be changed while abort is terminating the + * process and so any change made by abort can't be observed. */ + if (sig == SIGABRT) { + __block_all_sigs(&set); + LOCK(__abort_lock); + } + int r = __libc_sigaction(sig, sa, old); + if (sig == SIGABRT) { + UNLOCK(__abort_lock); + __restore_sigs(&set); + } + return r; } weak_alias(__sigaction, sigaction); diff --git a/lib/libc/musl/src/stdio/__stdio_close.c b/lib/libc/musl/src/stdio/__stdio_close.c index 79452bdb64..3029132851 100644 --- a/lib/libc/musl/src/stdio/__stdio_close.c +++ b/lib/libc/musl/src/stdio/__stdio_close.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include "aio_impl.h" static int dummy(int fd) { diff --git a/lib/libc/musl/src/stdio/ofl.c b/lib/libc/musl/src/stdio/ofl.c index f2d3215a9e..aad3d171df 100644 --- a/lib/libc/musl/src/stdio/ofl.c +++ b/lib/libc/musl/src/stdio/ofl.c @@ -1,8 +1,10 @@ #include "stdio_impl.h" #include "lock.h" +#include "fork_impl.h" static FILE *ofl_head; static volatile int ofl_lock[1]; +volatile int *const __stdio_ofl_lockptr = ofl_lock; FILE **__ofl_lock() { diff --git a/lib/libc/musl/src/string/strstr.c b/lib/libc/musl/src/string/strstr.c index 43a0207a72..96657bc231 100644 --- a/lib/libc/musl/src/string/strstr.c +++ b/lib/libc/musl/src/string/strstr.c @@ -96,7 +96,7 @@ static char *twoway_strstr(const unsigned char *h, const unsigned char *n) for (;;) { /* Update incremental end-of-haystack pointer */ if (z-h < l) { - /* Fast estimate for MIN(l,63) */ + /* Fast estimate for MAX(l,63) */ size_t grow = l | 63; const unsigned char *z2 = memchr(z, 0, grow); if (z2) { diff --git a/lib/libc/musl/src/termios/tcgetwinsize.c b/lib/libc/musl/src/termios/tcgetwinsize.c new file mode 100644 index 0000000000..9b3a65a40d --- /dev/null +++ b/lib/libc/musl/src/termios/tcgetwinsize.c @@ -0,0 +1,8 @@ +#include +#include +#include "syscall.h" + +int tcgetwinsize(int fd, struct winsize *wsz) +{ + return syscall(SYS_ioctl, fd, TIOCGWINSZ, wsz); +} diff --git a/lib/libc/musl/src/termios/tcsetwinsize.c b/lib/libc/musl/src/termios/tcsetwinsize.c new file mode 100644 index 0000000000..e01d0e2546 --- /dev/null +++ b/lib/libc/musl/src/termios/tcsetwinsize.c @@ -0,0 +1,8 @@ +#include +#include +#include "syscall.h" + +int tcsetwinsize(int fd, const struct winsize *wsz) +{ + return syscall(SYS_ioctl, fd, TIOCSWINSZ, wsz); +} diff --git a/lib/libc/musl/src/thread/i386/__set_thread_area.s b/lib/libc/musl/src/thread/i386/__set_thread_area.s index c2c21dd5d6..aa6852beb6 100644 --- a/lib/libc/musl/src/thread/i386/__set_thread_area.s +++ b/lib/libc/musl/src/thread/i386/__set_thread_area.s @@ -28,6 +28,7 @@ __set_thread_area: ret 2: mov %ebx,%ecx + xor %eax,%eax xor %ebx,%ebx xor %edx,%edx mov %ebx,(%esp) diff --git a/lib/libc/musl/src/thread/pthread_attr_get.c b/lib/libc/musl/src/thread/pthread_attr_get.c index 4aa5afdb28..f12ff44254 100644 --- a/lib/libc/musl/src/thread/pthread_attr_get.c +++ b/lib/libc/musl/src/thread/pthread_attr_get.c @@ -70,7 +70,7 @@ int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restr int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict a, int *restrict protocol) { - *protocol = PTHREAD_PRIO_NONE; + *protocol = a->__attr / 8U % 2; return 0; } int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared) diff --git a/lib/libc/musl/src/thread/pthread_cond_timedwait.c b/lib/libc/musl/src/thread/pthread_cond_timedwait.c index d15012406d..6b761455c4 100644 --- a/lib/libc/musl/src/thread/pthread_cond_timedwait.c +++ b/lib/libc/musl/src/thread/pthread_cond_timedwait.c @@ -146,14 +146,18 @@ relock: if (oldstate == WAITING) goto done; - if (!node.next) a_inc(&m->_m_waiters); + if (!node.next && !(m->_m_type & 8)) + a_inc(&m->_m_waiters); /* Unlock the barrier that's holding back the next waiter, and * either wake it or requeue it to the mutex. */ - if (node.prev) - unlock_requeue(&node.prev->barrier, &m->_m_lock, m->_m_type & 128); - else - a_dec(&m->_m_waiters); + if (node.prev) { + int val = m->_m_lock; + if (val>0) a_cas(&m->_m_lock, val, val|0x80000000); + unlock_requeue(&node.prev->barrier, &m->_m_lock, m->_m_type & (8|128)); + } else if (!(m->_m_type & 8)) { + a_dec(&m->_m_waiters); + } /* Since a signal was consumed, cancellation is not permitted. */ if (e == ECANCELED) e = 0; diff --git a/lib/libc/musl/src/thread/pthread_create.c b/lib/libc/musl/src/thread/pthread_create.c index 10f1b7d8cd..6f187ee89d 100644 --- a/lib/libc/musl/src/thread/pthread_create.c +++ b/lib/libc/musl/src/thread/pthread_create.c @@ -69,12 +69,25 @@ _Noreturn void __pthread_exit(void *result) __pthread_tsd_run_dtors(); + __block_app_sigs(&set); + + /* This atomic potentially competes with a concurrent pthread_detach + * call; the loser is responsible for freeing thread resources. */ + int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING); + + if (state==DT_DETACHED && self->map_base) { + /* Since __unmapself bypasses the normal munmap code path, + * explicitly wait for vmlock holders first. This must be + * done before any locks are taken, to avoid lock ordering + * issues that could lead to deadlock. */ + __vm_wait(); + } + /* Access to target the exiting thread with syscalls that use * its kernel tid is controlled by killlock. For detached threads, * any use past this point would have undefined behavior, but for * joinable threads it's a valid usage that must be handled. * Signals must be blocked since pthread_kill must be AS-safe. */ - __block_app_sigs(&set); LOCK(self->killlock); /* The thread list lock must be AS-safe, and thus depends on @@ -87,6 +100,7 @@ _Noreturn void __pthread_exit(void *result) if (self->next == self) { __tl_unlock(); UNLOCK(self->killlock); + self->detach_state = state; __restore_sigs(&set); exit(0); } @@ -125,10 +139,6 @@ _Noreturn void __pthread_exit(void *result) self->prev->next = self->next; self->prev = self->next = self; - /* This atomic potentially competes with a concurrent pthread_detach - * call; the loser is responsible for freeing thread resources. */ - int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING); - if (state==DT_DETACHED && self->map_base) { /* Detached threads must block even implementation-internal * signals, since they will not have a stack in their last @@ -140,16 +150,13 @@ _Noreturn void __pthread_exit(void *result) if (self->robust_list.off) __syscall(SYS_set_robust_list, 0, 3*sizeof(long)); - /* Since __unmapself bypasses the normal munmap code path, - * explicitly wait for vmlock holders first. */ - __vm_wait(); - /* The following call unmaps the thread's stack mapping * and then exits without touching the stack. */ __unmapself(self->map_base, self->map_size); } /* Wake any joiner. */ + a_store(&self->detach_state, DT_EXITED); __wake(&self->detach_state, 1, 1); /* After the kernel thread exits, its tid may be reused. Clear it @@ -314,7 +321,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att new->detach_state = DT_JOINABLE; } new->robust_list.head = &new->robust_list.head; - new->CANARY = self->CANARY; + new->canary = self->canary; new->sysinfo = self->sysinfo; /* Setup argument structure for the new thread on its stack. diff --git a/lib/libc/musl/src/thread/pthread_mutex_destroy.c b/lib/libc/musl/src/thread/pthread_mutex_destroy.c index 6d49e68989..8d1bf77b87 100644 --- a/lib/libc/musl/src/thread/pthread_mutex_destroy.c +++ b/lib/libc/musl/src/thread/pthread_mutex_destroy.c @@ -1,6 +1,10 @@ -#include +#include "pthread_impl.h" int pthread_mutex_destroy(pthread_mutex_t *mutex) { + /* If the mutex being destroyed is process-shared and has nontrivial + * type (tracking ownership), it might be in the pending slot of a + * robust_list; wait for quiescence. */ + if (mutex->_m_type > 128) __vm_wait(); return 0; } diff --git a/lib/libc/musl/src/thread/pthread_mutexattr_setprotocol.c b/lib/libc/musl/src/thread/pthread_mutexattr_setprotocol.c index 511cc32d8f..8b80c1ce9b 100644 --- a/lib/libc/musl/src/thread/pthread_mutexattr_setprotocol.c +++ b/lib/libc/musl/src/thread/pthread_mutexattr_setprotocol.c @@ -1,24 +1,23 @@ #include "pthread_impl.h" #include "syscall.h" -static pthread_once_t check_pi_once; -static int check_pi_result; - -static void check_pi() -{ - volatile int lk = 0; - check_pi_result = -__syscall(SYS_futex, &lk, FUTEX_LOCK_PI, 0, 0); -} +static volatile int check_pi_result = -1; int pthread_mutexattr_setprotocol(pthread_mutexattr_t *a, int protocol) { + int r; switch (protocol) { case PTHREAD_PRIO_NONE: a->__attr &= ~8; return 0; case PTHREAD_PRIO_INHERIT: - pthread_once(&check_pi_once, check_pi); - if (check_pi_result) return check_pi_result; + r = check_pi_result; + if (r < 0) { + volatile int lk = 0; + r = -__syscall(SYS_futex, &lk, FUTEX_LOCK_PI, 0, 0); + a_store(&check_pi_result, r); + } + if (r) return r; a->__attr |= 8; return 0; case PTHREAD_PRIO_PROTECT: diff --git a/lib/libc/musl/src/thread/pthread_mutexattr_setrobust.c b/lib/libc/musl/src/thread/pthread_mutexattr_setrobust.c index 04db92a626..30a9ac3bea 100644 --- a/lib/libc/musl/src/thread/pthread_mutexattr_setrobust.c +++ b/lib/libc/musl/src/thread/pthread_mutexattr_setrobust.c @@ -1,22 +1,20 @@ #include "pthread_impl.h" #include "syscall.h" -static pthread_once_t check_robust_once; -static int check_robust_result; - -static void check_robust() -{ - void *p; - size_t l; - check_robust_result = -__syscall(SYS_get_robust_list, 0, &p, &l); -} +static volatile int check_robust_result = -1; int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust) { if (robust > 1U) return EINVAL; if (robust) { - pthread_once(&check_robust_once, check_robust); - if (check_robust_result) return check_robust_result; + int r = check_robust_result; + if (r < 0) { + void *p; + size_t l; + r = -__syscall(SYS_get_robust_list, 0, &p, &l); + a_store(&check_robust_result, r); + } + if (r) return r; a->__attr |= 4; return 0; } diff --git a/lib/libc/musl/src/thread/s390x/clone.s b/lib/libc/musl/src/thread/s390x/clone.s index 577748eab3..2125f20b83 100644 --- a/lib/libc/musl/src/thread/s390x/clone.s +++ b/lib/libc/musl/src/thread/s390x/clone.s @@ -17,6 +17,9 @@ __clone: # if (!tid) syscall(SYS_exit, a(d)); # return tid; + # preserve call-saved register used as syscall arg + stg %r6, 48(%r15) + # create initial stack frame for new thread nill %r3, 0xfff8 aghi %r3, -160 @@ -35,6 +38,9 @@ __clone: lg %r6, 160(%r15) svc 120 + # restore call-saved register + lg %r6, 48(%r15) + # if error or if we're the parent, return ltgr %r2, %r2 bnzr %r14 diff --git a/lib/libc/musl/src/thread/s390x/syscall_cp.s b/lib/libc/musl/src/thread/s390x/syscall_cp.s index c1da40de88..d094cbf5ae 100644 --- a/lib/libc/musl/src/thread/s390x/syscall_cp.s +++ b/lib/libc/musl/src/thread/s390x/syscall_cp.s @@ -14,6 +14,7 @@ __cp_begin: icm %r2, 15, 0(%r2) jne __cp_cancel + stg %r6, 48(%r15) stg %r7, 56(%r15) lgr %r1, %r3 lgr %r2, %r4 @@ -26,6 +27,7 @@ __cp_begin: __cp_end: lg %r7, 56(%r15) + lg %r6, 48(%r15) br %r14 __cp_cancel: diff --git a/lib/libc/musl/src/thread/sem_open.c b/lib/libc/musl/src/thread/sem_open.c index de8555c5a6..0ad29de96c 100644 --- a/lib/libc/musl/src/thread/sem_open.c +++ b/lib/libc/musl/src/thread/sem_open.c @@ -12,6 +12,12 @@ #include #include #include "lock.h" +#include "fork_impl.h" + +#define malloc __libc_malloc +#define calloc __libc_calloc +#define realloc undef +#define free undef static struct { ino_t ino; @@ -19,6 +25,7 @@ static struct { int refcnt; } *semtab; static volatile int lock[1]; +volatile int *const __sem_open_lockptr = lock; #define FLAGS (O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK) @@ -163,10 +170,12 @@ int sem_close(sem_t *sem) int i; LOCK(lock); for (i=0; itid) + goto single_threaded; callback = func; context = ctx; diff --git a/lib/libc/musl/src/thread/vmlock.c b/lib/libc/musl/src/thread/vmlock.c index 75f3cb7619..fa0a8e3c2e 100644 --- a/lib/libc/musl/src/thread/vmlock.c +++ b/lib/libc/musl/src/thread/vmlock.c @@ -1,6 +1,8 @@ #include "pthread_impl.h" +#include "fork_impl.h" static volatile int vmlock[2]; +volatile int *const __vmlock_lockptr = vmlock; void __vm_wait() { diff --git a/lib/libc/musl/src/time/__tz.c b/lib/libc/musl/src/time/__tz.c index 49a7371ebc..09a6317e6b 100644 --- a/lib/libc/musl/src/time/__tz.c +++ b/lib/libc/musl/src/time/__tz.c @@ -6,6 +6,12 @@ #include #include "libc.h" #include "lock.h" +#include "fork_impl.h" + +#define malloc __libc_malloc +#define calloc undef +#define realloc undef +#define free undef long __timezone = 0; int __daylight = 0; @@ -30,6 +36,7 @@ static char *old_tz = old_tz_buf; static size_t old_tz_size = sizeof old_tz_buf; static volatile int lock[1]; +volatile int *const __timezone_lockptr = lock; static int getint(const char **p) { @@ -178,7 +185,7 @@ static void do_tzset() zi = map; if (map) { int scale = 2; - if (sizeof(time_t) > 4 && map[4]=='2') { + if (map[4]!='1') { size_t skip = zi_dotprod(zi+20, VEC(1,1,8,5,6,1), 6); trans = zi+skip+44+44; scale++; diff --git a/lib/libc/musl/src/time/timer_create.c b/lib/libc/musl/src/time/timer_create.c index 455d49fc50..4bef239051 100644 --- a/lib/libc/musl/src/time/timer_create.c +++ b/lib/libc/musl/src/time/timer_create.c @@ -2,6 +2,7 @@ #include #include #include "pthread_impl.h" +#include "atomic.h" struct ksigevent { union sigval sigev_value; @@ -32,19 +33,6 @@ static void cleanup_fromsig(void *p) longjmp(p, 1); } -static void timer_handler(int sig, siginfo_t *si, void *ctx) -{ -} - -static void install_handler() -{ - struct sigaction sa = { - .sa_sigaction = timer_handler, - .sa_flags = SA_SIGINFO | SA_RESTART - }; - __libc_sigaction(SIGTIMER, &sa, 0); -} - static void *start(void *arg) { pthread_t self = __pthread_self(); @@ -71,7 +59,7 @@ static void *start(void *arg) int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict res) { - static pthread_once_t once = PTHREAD_ONCE_INIT; + volatile static int init = 0; pthread_t td; pthread_attr_t attr; int r; @@ -83,11 +71,15 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict switch (evp ? evp->sigev_notify : SIGEV_SIGNAL) { case SIGEV_NONE: case SIGEV_SIGNAL: + case SIGEV_THREAD_ID: if (evp) { ksev.sigev_value = evp->sigev_value; ksev.sigev_signo = evp->sigev_signo; ksev.sigev_notify = evp->sigev_notify; - ksev.sigev_tid = 0; + if (evp->sigev_notify == SIGEV_THREAD_ID) + ksev.sigev_tid = evp->sigev_notify_thread_id; + else + ksev.sigev_tid = 0; ksevp = &ksev; } if (syscall(SYS_timer_create, clk, ksevp, &timerid) < 0) @@ -95,7 +87,11 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict *res = (void *)(intptr_t)timerid; break; case SIGEV_THREAD: - pthread_once(&once, install_handler); + if (!init) { + struct sigaction sa = { .sa_handler = SIG_DFL }; + __libc_sigaction(SIGTIMER, &sa, 0); + a_store(&init, 1); + } if (evp->sigev_notify_attributes) attr = *evp->sigev_notify_attributes; else @@ -115,7 +111,7 @@ int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict ksev.sigev_value.sival_ptr = 0; ksev.sigev_signo = SIGTIMER; - ksev.sigev_notify = 4; /* SIGEV_THREAD_ID */ + ksev.sigev_notify = SIGEV_THREAD_ID; ksev.sigev_tid = td->tid; if (syscall(SYS_timer_create, clk, &ksev, &timerid) < 0) timerid = -1; diff --git a/lib/libc/musl/src/unistd/close.c b/lib/libc/musl/src/unistd/close.c index 5b38e01946..a2105f5060 100644 --- a/lib/libc/musl/src/unistd/close.c +++ b/lib/libc/musl/src/unistd/close.c @@ -1,5 +1,6 @@ #include #include +#include "aio_impl.h" #include "syscall.h" static int dummy(int fd) diff --git a/lib/libc/musl/src/unistd/faccessat.c b/lib/libc/musl/src/unistd/faccessat.c index 76bbd4c72a..557503eb6d 100644 --- a/lib/libc/musl/src/unistd/faccessat.c +++ b/lib/libc/musl/src/unistd/faccessat.c @@ -25,12 +25,17 @@ static int checker(void *p) int faccessat(int fd, const char *filename, int amode, int flag) { - if (!flag || (flag==AT_EACCESS && getuid()==geteuid() && getgid()==getegid())) - return syscall(SYS_faccessat, fd, filename, amode, flag); + if (flag) { + int ret = __syscall(SYS_faccessat2, fd, filename, amode, flag); + if (ret != -ENOSYS) return __syscall_ret(ret); + } - if (flag != AT_EACCESS) + if (flag & ~AT_EACCESS) return __syscall_ret(-EINVAL); + if (!flag || (getuid()==geteuid() && getgid()==getegid())) + return syscall(SYS_faccessat, fd, filename, amode); + char stack[1024]; sigset_t set; pid_t pid; diff --git a/lib/libc/musl/src/unistd/readlink.c b/lib/libc/musl/src/unistd/readlink.c index a152d52492..32f4537f97 100644 --- a/lib/libc/musl/src/unistd/readlink.c +++ b/lib/libc/musl/src/unistd/readlink.c @@ -4,9 +4,16 @@ ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize) { + char dummy[1]; + if (!bufsize) { + buf = dummy; + bufsize = 1; + } #ifdef SYS_readlink - return syscall(SYS_readlink, path, buf, bufsize); + int r = __syscall(SYS_readlink, path, buf, bufsize); #else - return syscall(SYS_readlinkat, AT_FDCWD, path, buf, bufsize); + int r = __syscall(SYS_readlinkat, AT_FDCWD, path, buf, bufsize); #endif + if (buf == dummy && r > 0) r = 0; + return __syscall_ret(r); } diff --git a/lib/libc/musl/src/unistd/readlinkat.c b/lib/libc/musl/src/unistd/readlinkat.c index 9af45cd5a4..f79d3d1428 100644 --- a/lib/libc/musl/src/unistd/readlinkat.c +++ b/lib/libc/musl/src/unistd/readlinkat.c @@ -3,5 +3,12 @@ ssize_t readlinkat(int fd, const char *restrict path, char *restrict buf, size_t bufsize) { - return syscall(SYS_readlinkat, fd, path, buf, bufsize); + char dummy[1]; + if (!bufsize) { + buf = dummy; + bufsize = 1; + } + int r = __syscall(SYS_readlinkat, fd, path, buf, bufsize); + if (buf == dummy && r > 0) r = 0; + return __syscall_ret(r); } diff --git a/lib/libc/musl/src/unistd/setxid.c b/lib/libc/musl/src/unistd/setxid.c index 0239f8afa9..487c1a160a 100644 --- a/lib/libc/musl/src/unistd/setxid.c +++ b/lib/libc/musl/src/unistd/setxid.c @@ -1,20 +1,19 @@ #include -#include +#include #include "syscall.h" #include "libc.h" -#include "pthread_impl.h" struct ctx { int id, eid, sid; - int nr, err; + int nr, ret; }; static void do_setxid(void *p) { struct ctx *c = p; - if (c->err>0) return; - int ret = -__syscall(c->nr, c->id, c->eid, c->sid); - if (ret && !c->err) { + if (c->ret<0) return; + int ret = __syscall(c->nr, c->id, c->eid, c->sid); + if (ret && !c->ret) { /* If one thread fails to set ids after another has already * succeeded, forcibly killing the process is the only safe * thing to do. State is inconsistent and dangerous. Use @@ -22,18 +21,14 @@ static void do_setxid(void *p) __block_all_sigs(0); __syscall(SYS_kill, __syscall(SYS_getpid), SIGKILL); } - c->err = ret; + c->ret = ret; } int __setxid(int nr, int id, int eid, int sid) { - /* err is initially nonzero so that failure of the first thread does not + /* ret is initially nonzero so that failure of the first thread does not * trigger the safety kill above. */ - struct ctx c = { .nr = nr, .id = id, .eid = eid, .sid = sid, .err = -1 }; + struct ctx c = { .nr = nr, .id = id, .eid = eid, .sid = sid, .ret = 1 }; __synccall(do_setxid, &c); - if (c.err) { - if (c.err>0) errno = c.err; - return -1; - } - return 0; + return __syscall_ret(c.ret); } diff --git a/lib/libunwind/src/gcc_personality_v0.c b/lib/libunwind/src/gcc_personality_v0.c new file mode 100644 index 0000000000..c946497d75 --- /dev/null +++ b/lib/libunwind/src/gcc_personality_v0.c @@ -0,0 +1,234 @@ +//===-- gcc_personality_v0.c - Implement __gcc_personality_v0 -------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#if __ARM_EABI__ +#ifdef COMPILER_RT_ARMHF_TARGET +#define COMPILER_RT_ABI +#else +#define COMPILER_RT_ABI __attribute__((__pcs__("aapcs"))) +#endif +#else +#define COMPILER_RT_ABI +#endif + +#define compilerrt_abort() __builtin_unreachable() + +#include + +// Pointer encodings documented at: +// http://refspecs.freestandards.org/LSB_1.3.0/gLSB/gLSB/ehframehdr.html + +#define DW_EH_PE_omit 0xff // no data follows + +#define DW_EH_PE_absptr 0x00 +#define DW_EH_PE_uleb128 0x01 +#define DW_EH_PE_udata2 0x02 +#define DW_EH_PE_udata4 0x03 +#define DW_EH_PE_udata8 0x04 +#define DW_EH_PE_sleb128 0x09 +#define DW_EH_PE_sdata2 0x0A +#define DW_EH_PE_sdata4 0x0B +#define DW_EH_PE_sdata8 0x0C + +#define DW_EH_PE_pcrel 0x10 +#define DW_EH_PE_textrel 0x20 +#define DW_EH_PE_datarel 0x30 +#define DW_EH_PE_funcrel 0x40 +#define DW_EH_PE_aligned 0x50 +#define DW_EH_PE_indirect 0x80 // gcc extension + +// read a uleb128 encoded value and advance pointer +static uintptr_t readULEB128(const uint8_t **data) { + uintptr_t result = 0; + uintptr_t shift = 0; + unsigned char byte; + const uint8_t *p = *data; + do { + byte = *p++; + result |= (byte & 0x7f) << shift; + shift += 7; + } while (byte & 0x80); + *data = p; + return result; +} + +// read a pointer encoded value and advance pointer +static uintptr_t readEncodedPointer(const uint8_t **data, uint8_t encoding) { + const uint8_t *p = *data; + uintptr_t result = 0; + + if (encoding == DW_EH_PE_omit) + return 0; + + // first get value + switch (encoding & 0x0F) { + case DW_EH_PE_absptr: + result = *((const uintptr_t *)p); + p += sizeof(uintptr_t); + break; + case DW_EH_PE_uleb128: + result = readULEB128(&p); + break; + case DW_EH_PE_udata2: + result = *((const uint16_t *)p); + p += sizeof(uint16_t); + break; + case DW_EH_PE_udata4: + result = *((const uint32_t *)p); + p += sizeof(uint32_t); + break; + case DW_EH_PE_udata8: + result = *((const uint64_t *)p); + p += sizeof(uint64_t); + break; + case DW_EH_PE_sdata2: + result = *((const int16_t *)p); + p += sizeof(int16_t); + break; + case DW_EH_PE_sdata4: + result = *((const int32_t *)p); + p += sizeof(int32_t); + break; + case DW_EH_PE_sdata8: + result = *((const int64_t *)p); + p += sizeof(int64_t); + break; + case DW_EH_PE_sleb128: + default: + // not supported + compilerrt_abort(); + break; + } + + // then add relative offset + switch (encoding & 0x70) { + case DW_EH_PE_absptr: + // do nothing + break; + case DW_EH_PE_pcrel: + result += (uintptr_t)(*data); + break; + case DW_EH_PE_textrel: + case DW_EH_PE_datarel: + case DW_EH_PE_funcrel: + case DW_EH_PE_aligned: + default: + // not supported + compilerrt_abort(); + break; + } + + // then apply indirection + if (encoding & DW_EH_PE_indirect) { + result = *((const uintptr_t *)result); + } + + *data = p; + return result; +} + +#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ + !defined(__ARM_DWARF_EH__) +#define USING_ARM_EHABI 1 +_Unwind_Reason_Code __gnu_unwind_frame(struct _Unwind_Exception *, + struct _Unwind_Context *); +#endif + +static inline _Unwind_Reason_Code +continueUnwind(struct _Unwind_Exception *exceptionObject, + struct _Unwind_Context *context) { +#if USING_ARM_EHABI + // On ARM EHABI the personality routine is responsible for actually + // unwinding a single stack frame before returning (ARM EHABI Sec. 6.1). + if (__gnu_unwind_frame(exceptionObject, context) != _URC_OK) + return _URC_FAILURE; +#endif + return _URC_CONTINUE_UNWIND; +} + +// The C compiler makes references to __gcc_personality_v0 in +// the dwarf unwind information for translation units that use +// __attribute__((cleanup(xx))) on local variables. +// This personality routine is called by the system unwinder +// on each frame as the stack is unwound during a C++ exception +// throw through a C function compiled with -fexceptions. +#if __USING_SJLJ_EXCEPTIONS__ +// the setjump-longjump based exceptions personality routine has a +// different name +COMPILER_RT_ABI _Unwind_Reason_Code __gcc_personality_sj0( + int version, _Unwind_Action actions, uint64_t exceptionClass, + struct _Unwind_Exception *exceptionObject, struct _Unwind_Context *context) +#elif USING_ARM_EHABI +// The ARM EHABI personality routine has a different signature. +COMPILER_RT_ABI _Unwind_Reason_Code __gcc_personality_v0( + _Unwind_State state, struct _Unwind_Exception *exceptionObject, + struct _Unwind_Context *context) +#else +COMPILER_RT_ABI _Unwind_Reason_Code __gcc_personality_v0( + int version, _Unwind_Action actions, uint64_t exceptionClass, + struct _Unwind_Exception *exceptionObject, struct _Unwind_Context *context) +#endif +{ + // Since C does not have catch clauses, there is nothing to do during + // phase 1 (the search phase). +#if USING_ARM_EHABI + // After resuming from a cleanup we should also continue on to the next + // frame straight away. + if ((state & _US_ACTION_MASK) != _US_UNWIND_FRAME_STARTING) +#else + if (actions & _UA_SEARCH_PHASE) +#endif + return continueUnwind(exceptionObject, context); + + // There is nothing to do if there is no LSDA for this frame. + const uint8_t *lsda = (uint8_t *)_Unwind_GetLanguageSpecificData(context); + if (lsda == (uint8_t *)0) + return continueUnwind(exceptionObject, context); + + uintptr_t pc = (uintptr_t)_Unwind_GetIP(context) - 1; + uintptr_t funcStart = (uintptr_t)_Unwind_GetRegionStart(context); + uintptr_t pcOffset = pc - funcStart; + + // Parse LSDA header. + uint8_t lpStartEncoding = *lsda++; + if (lpStartEncoding != DW_EH_PE_omit) { + readEncodedPointer(&lsda, lpStartEncoding); + } + uint8_t ttypeEncoding = *lsda++; + if (ttypeEncoding != DW_EH_PE_omit) { + readULEB128(&lsda); + } + // Walk call-site table looking for range that includes current PC. + uint8_t callSiteEncoding = *lsda++; + uint32_t callSiteTableLength = readULEB128(&lsda); + const uint8_t *callSiteTableStart = lsda; + const uint8_t *callSiteTableEnd = callSiteTableStart + callSiteTableLength; + const uint8_t *p = callSiteTableStart; + while (p < callSiteTableEnd) { + uintptr_t start = readEncodedPointer(&p, callSiteEncoding); + uintptr_t length = readEncodedPointer(&p, callSiteEncoding); + uintptr_t landingPad = readEncodedPointer(&p, callSiteEncoding); + readULEB128(&p); // action value not used for C code + if (landingPad == 0) + continue; // no landing pad for this entry + if ((start <= pcOffset) && (pcOffset < (start + length))) { + // Found landing pad for the PC. + // Set Instruction Pointer to so we re-enter function + // at landing pad. The landing pad is created by the compiler + // to take two parameters in registers. + _Unwind_SetGR(context, __builtin_eh_return_data_regno(0), + (uintptr_t)exceptionObject); + _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0); + _Unwind_SetIP(context, (funcStart + landingPad)); + return _URC_INSTALL_CONTEXT; + } + } + + // No landing pad found, continue unwinding. + return continueUnwind(exceptionObject, context); +} diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig new file mode 100644 index 0000000000..4afd191b93 --- /dev/null +++ b/lib/std/Progress.zig @@ -0,0 +1,366 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! This API non-allocating, non-fallible, and thread-safe. +//! The tradeoff is that users of this API must provide the storage +//! for each `Progress.Node`. +//! +//! Initialize the struct directly, overriding these fields as desired: +//! * `refresh_rate_ms` +//! * `initial_delay_ms` + +const std = @import("std"); +const windows = std.os.windows; +const testing = std.testing; +const assert = std.debug.assert; +const Progress = @This(); + +/// `null` if the current node (and its children) should +/// not print on update() +terminal: ?std.fs.File = undefined, + +/// Whether the terminal supports ANSI escape codes. +supports_ansi_escape_codes: bool = false, + +/// If the terminal is "dumb", don't print output. +/// This can be useful if you don't want to print all +/// the stages of code generation if there are a lot. +/// You should not use it if the user should see output +/// for example showing the user what tests run. +dont_print_on_dumb: bool = false, + +root: Node = undefined, + +/// Keeps track of how much time has passed since the beginning. +/// Used to compare with `initial_delay_ms` and `refresh_rate_ms`. +timer: std.time.Timer = undefined, + +/// When the previous refresh was written to the terminal. +/// Used to compare with `refresh_rate_ms`. +prev_refresh_timestamp: u64 = undefined, + +/// This buffer represents the maximum number of bytes written to the terminal +/// with each refresh. +output_buffer: [100]u8 = undefined, + +/// How many nanoseconds between writing updates to the terminal. +refresh_rate_ns: u64 = 50 * std.time.ns_per_ms, + +/// How many nanoseconds to keep the output hidden +initial_delay_ns: u64 = 500 * std.time.ns_per_ms, + +done: bool = true, + +/// Protects the `refresh` function, as well as `node.recently_updated_child`. +/// Without this, callsites would call `Node.end` and then free `Node` memory +/// while it was still being accessed by the `refresh` function. +update_lock: std.Thread.Mutex = .{}, + +/// Keeps track of how many columns in the terminal have been output, so that +/// we can move the cursor back later. +columns_written: usize = undefined, + +/// Represents one unit of progress. Each node can have children nodes, or +/// one can use integers with `update`. +pub const Node = struct { + context: *Progress, + parent: ?*Node, + name: []const u8, + /// Must be handled atomically to be thread-safe. + recently_updated_child: ?*Node = null, + /// Must be handled atomically to be thread-safe. 0 means null. + unprotected_estimated_total_items: usize, + /// Must be handled atomically to be thread-safe. + unprotected_completed_items: usize, + + /// Create a new child progress node. Thread-safe. + /// Call `Node.end` when done. + /// TODO solve https://github.com/ziglang/zig/issues/2765 and then change this + /// API to set `self.parent.recently_updated_child` with the return value. + /// Until that is fixed you probably want to call `activate` on the return value. + /// Passing 0 for `estimated_total_items` means unknown. + pub fn start(self: *Node, name: []const u8, estimated_total_items: usize) Node { + return Node{ + .context = self.context, + .parent = self, + .name = name, + .unprotected_estimated_total_items = estimated_total_items, + .unprotected_completed_items = 0, + }; + } + + /// This is the same as calling `start` and then `end` on the returned `Node`. Thread-safe. + pub fn completeOne(self: *Node) void { + self.activate(); + _ = @atomicRmw(usize, &self.unprotected_completed_items, .Add, 1, .Monotonic); + self.context.maybeRefresh(); + } + + /// Finish a started `Node`. Thread-safe. + pub fn end(self: *Node) void { + self.context.maybeRefresh(); + if (self.parent) |parent| { + { + const held = self.context.update_lock.acquire(); + defer held.release(); + _ = @cmpxchgStrong(?*Node, &parent.recently_updated_child, self, null, .Monotonic, .Monotonic); + } + parent.completeOne(); + } else { + const held = self.context.update_lock.acquire(); + defer held.release(); + self.context.done = true; + self.context.refreshWithHeldLock(); + } + } + + /// Tell the parent node that this node is actively being worked on. Thread-safe. + pub fn activate(self: *Node) void { + if (self.parent) |parent| { + @atomicStore(?*Node, &parent.recently_updated_child, self, .Release); + } + } + + /// Thread-safe. 0 means unknown. + pub fn setEstimatedTotalItems(self: *Node, count: usize) void { + @atomicStore(usize, &self.unprotected_estimated_total_items, count, .Monotonic); + } + + /// Thread-safe. + pub fn setCompletedItems(self: *Node, completed_items: usize) void { + @atomicStore(usize, &self.unprotected_completed_items, completed_items, .Monotonic); + } +}; + +/// Create a new progress node. +/// Call `Node.end` when done. +/// TODO solve https://github.com/ziglang/zig/issues/2765 and then change this +/// API to return Progress rather than accept it as a parameter. +/// `estimated_total_items` value of 0 means unknown. +pub fn start(self: *Progress, name: []const u8, estimated_total_items: usize) !*Node { + const stderr = std.io.getStdErr(); + self.terminal = null; + if (stderr.supportsAnsiEscapeCodes()) { + self.terminal = stderr; + self.supports_ansi_escape_codes = true; + } else if (std.builtin.os.tag == .windows and stderr.isTty()) { + self.terminal = stderr; + } else if (std.builtin.os.tag != .windows) { + // we are in a "dumb" terminal like in acme or writing to a file + self.terminal = stderr; + } + self.root = Node{ + .context = self, + .parent = null, + .name = name, + .unprotected_estimated_total_items = estimated_total_items, + .unprotected_completed_items = 0, + }; + self.columns_written = 0; + self.prev_refresh_timestamp = 0; + self.timer = try std.time.Timer.start(); + self.done = false; + return &self.root; +} + +/// Updates the terminal if enough time has passed since last update. Thread-safe. +pub fn maybeRefresh(self: *Progress) void { + const now = self.timer.read(); + if (now < self.initial_delay_ns) return; + const held = self.update_lock.tryAcquire() orelse return; + defer held.release(); + // TODO I have observed this to happen sometimes. I think we need to follow Rust's + // lead and guarantee monotonically increasing times in the std lib itself. + if (now < self.prev_refresh_timestamp) return; + if (now - self.prev_refresh_timestamp < self.refresh_rate_ns) return; + return self.refreshWithHeldLock(); +} + +/// Updates the terminal and resets `self.next_refresh_timestamp`. Thread-safe. +pub fn refresh(self: *Progress) void { + const held = self.update_lock.tryAcquire() orelse return; + defer held.release(); + + return self.refreshWithHeldLock(); +} + +fn refreshWithHeldLock(self: *Progress) void { + const is_dumb = !self.supports_ansi_escape_codes and !(std.builtin.os.tag == .windows); + if (is_dumb and self.dont_print_on_dumb) return; + const file = self.terminal orelse return; + + const prev_columns_written = self.columns_written; + var end: usize = 0; + if (self.columns_written > 0) { + // restore the cursor position by moving the cursor + // `columns_written` cells to the left, then clear the rest of the + // line + if (self.supports_ansi_escape_codes) { + end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{d}D", .{self.columns_written}) catch unreachable).len; + end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len; + } else if (std.builtin.os.tag == .windows) winapi: { + var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; + if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) + unreachable; + + var cursor_pos = windows.COORD{ + .X = info.dwCursorPosition.X - @intCast(windows.SHORT, self.columns_written), + .Y = info.dwCursorPosition.Y, + }; + + if (cursor_pos.X < 0) + cursor_pos.X = 0; + + const fill_chars = @intCast(windows.DWORD, info.dwSize.X - cursor_pos.X); + + var written: windows.DWORD = undefined; + if (windows.kernel32.FillConsoleOutputAttribute( + file.handle, + info.wAttributes, + fill_chars, + cursor_pos, + &written, + ) != windows.TRUE) { + // Stop trying to write to this file. + self.terminal = null; + break :winapi; + } + if (windows.kernel32.FillConsoleOutputCharacterA( + file.handle, + ' ', + fill_chars, + cursor_pos, + &written, + ) != windows.TRUE) unreachable; + + if (windows.kernel32.SetConsoleCursorPosition(file.handle, cursor_pos) != windows.TRUE) + unreachable; + } else { + // we are in a "dumb" terminal like in acme or writing to a file + self.output_buffer[end] = '\n'; + end += 1; + } + + self.columns_written = 0; + } + + if (!self.done) { + var need_ellipse = false; + var maybe_node: ?*Node = &self.root; + while (maybe_node) |node| { + if (need_ellipse) { + self.bufWrite(&end, "... ", .{}); + } + need_ellipse = false; + const eti = @atomicLoad(usize, &node.unprotected_estimated_total_items, .Monotonic); + const completed_items = @atomicLoad(usize, &node.unprotected_completed_items, .Monotonic); + if (node.name.len != 0 or eti > 0) { + if (node.name.len != 0) { + self.bufWrite(&end, "{s}", .{node.name}); + need_ellipse = true; + } + if (eti > 0) { + if (need_ellipse) self.bufWrite(&end, " ", .{}); + self.bufWrite(&end, "[{d}/{d}] ", .{ completed_items + 1, eti }); + need_ellipse = false; + } else if (completed_items != 0) { + if (need_ellipse) self.bufWrite(&end, " ", .{}); + self.bufWrite(&end, "[{d}] ", .{completed_items + 1}); + need_ellipse = false; + } + } + maybe_node = @atomicLoad(?*Node, &node.recently_updated_child, .Acquire); + } + if (need_ellipse) { + self.bufWrite(&end, "... ", .{}); + } + } + + _ = file.write(self.output_buffer[0..end]) catch |e| { + // Stop trying to write to this file once it errors. + self.terminal = null; + }; + self.prev_refresh_timestamp = self.timer.read(); +} + +pub fn log(self: *Progress, comptime format: []const u8, args: anytype) void { + const file = self.terminal orelse return; + self.refresh(); + file.writer().print(format, args) catch { + self.terminal = null; + return; + }; + self.columns_written = 0; +} + +fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: anytype) void { + if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| { + const amt = written.len; + end.* += amt; + self.columns_written += amt; + } else |err| switch (err) { + error.NoSpaceLeft => { + self.columns_written += self.output_buffer.len - end.*; + end.* = self.output_buffer.len; + }, + } + const bytes_needed_for_esc_codes_at_end = if (std.builtin.os.tag == .windows) 0 else 11; + const max_end = self.output_buffer.len - bytes_needed_for_esc_codes_at_end; + if (end.* > max_end) { + const suffix = "... "; + self.columns_written = self.columns_written - (end.* - max_end) + suffix.len; + std.mem.copy(u8, self.output_buffer[max_end..], suffix); + end.* = max_end + suffix.len; + } +} + +test "basic functionality" { + var disable = true; + if (disable) { + // This test is disabled because it uses time.sleep() and is therefore slow. It also + // prints bogus progress data to stderr. + return error.SkipZigTest; + } + var progress = Progress{}; + const root_node = try progress.start("", 100); + defer root_node.end(); + + const sub_task_names = [_][]const u8{ + "reticulating splines", + "adjusting shoes", + "climbing towers", + "pouring juice", + }; + var next_sub_task: usize = 0; + + var i: usize = 0; + while (i < 100) : (i += 1) { + var node = root_node.start(sub_task_names[next_sub_task], 5); + node.activate(); + next_sub_task = (next_sub_task + 1) % sub_task_names.len; + + node.completeOne(); + std.time.sleep(5 * std.time.ns_per_ms); + node.completeOne(); + node.completeOne(); + std.time.sleep(5 * std.time.ns_per_ms); + node.completeOne(); + node.completeOne(); + std.time.sleep(5 * std.time.ns_per_ms); + + node.end(); + + std.time.sleep(5 * std.time.ns_per_ms); + } + { + var node = root_node.start("this is a really long name designed to activate the truncation code. let's find out if it works", 0); + node.activate(); + std.time.sleep(10 * std.time.ns_per_ms); + progress.refresh(); + std.time.sleep(10 * std.time.ns_per_ms); + node.end(); + } +} diff --git a/lib/std/SemanticVersion.zig b/lib/std/SemanticVersion.zig index 74e515f9d1..52c3ae59df 100644 --- a/lib/std/SemanticVersion.zig +++ b/lib/std/SemanticVersion.zig @@ -102,7 +102,7 @@ pub fn parse(text: []const u8) !Version { if (extra_index == null) return ver; // Slice optional pre-release or build metadata components. - const extra = text[extra_index.?..text.len]; + const extra: []const u8 = text[extra_index.?..text.len]; if (extra[0] == '-') { const build_index = std.mem.indexOfScalar(u8, extra, '+'); ver.pre = extra[1..(build_index orelse extra.len)]; @@ -163,9 +163,9 @@ pub fn format( out_stream: anytype, ) !void { if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'"); - try std.fmt.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch }); - if (self.pre) |pre| try std.fmt.format(out_stream, "-{}", .{pre}); - if (self.build) |build| try std.fmt.format(out_stream, "+{}", .{build}); + try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch }); + if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre}); + if (self.build) |build| try std.fmt.format(out_stream, "+{s}", .{build}); } const expect = std.testing.expect; @@ -205,7 +205,7 @@ test "SemanticVersion format" { "1.2.3----R-S.12.9.1--.12+meta", "1.2.3----RC-SNAPSHOT.12.9.1--.12", "1.0.0+0.build.1-rc.10000aaa-kk-0.1", - }) |valid| try testFmt(valid, "{}", .{try parse(valid)}); + }) |valid| try std.testing.expectFmt(valid, "{}", .{try parse(valid)}); // Invalid version strings should be rejected. for ([_][]const u8{ @@ -253,7 +253,9 @@ test "SemanticVersion format" { // Valid version string that may overflow. const big_valid = "99999999999999999999999.999999999999999999.99999999999999999"; - if (parse(big_valid)) |ver| try testFmt(big_valid, "{}", .{ver}) else |err| expect(err == error.Overflow); + if (parse(big_valid)) |ver| { + try std.testing.expectFmt(big_valid, "{}", .{ver}); + } else |err| expect(err == error.Overflow); // Invalid version string that may overflow. const big_invalid = "99999999999999999999999.999999999999999999.99999999999999999----RC-SNAPSHOT.12.09.1--------------------------------..12"; @@ -280,16 +282,11 @@ test "SemanticVersion precedence" { expect(order(try parse("1.0.0-rc.1"), try parse("1.0.0")) == .lt); } -// This is copy-pasted from fmt.zig since it is not public. -fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) !void { - var buf: [100]u8 = undefined; - const result = try std.fmt.bufPrint(buf[0..], template, args); - if (std.mem.eql(u8, result, expected)) return; +test "zig_version" { + // An approximate Zig build that predates this test. + const older_version = .{ .major = 0, .minor = 8, .patch = 0, .pre = "dev.874" }; - std.debug.warn("\n====== expected this output: =========\n", .{}); - std.debug.warn("{}", .{expected}); - std.debug.warn("\n======== instead found this: =========\n", .{}); - std.debug.warn("{}", .{result}); - std.debug.warn("\n======================================\n", .{}); - return error.TestFailed; + // Simulated compatibility check using Zig version. + const compatible = comptime @import("builtin").zig_version.order(older_version) == .gt; + if (!compatible) @compileError("zig_version test failed"); } diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig new file mode 100644 index 0000000000..77277bd154 --- /dev/null +++ b/lib/std/Thread.zig @@ -0,0 +1,565 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! This struct represents a kernel thread, and acts as a namespace for concurrency +//! primitives that operate on kernel threads. For concurrency primitives that support +//! both evented I/O and async I/O, see the respective names in the top level std namespace. + +data: Data, + +pub const AutoResetEvent = @import("Thread/AutoResetEvent.zig"); +pub const ResetEvent = @import("Thread/ResetEvent.zig"); +pub const StaticResetEvent = @import("Thread/StaticResetEvent.zig"); +pub const Mutex = @import("Thread/Mutex.zig"); +pub const Semaphore = @import("Thread/Semaphore.zig"); +pub const Condition = @import("Thread/Condition.zig"); + +pub const use_pthreads = std.Target.current.os.tag != .windows and builtin.link_libc; + +const Thread = @This(); +const std = @import("std.zig"); +const builtin = std.builtin; +const os = std.os; +const mem = std.mem; +const windows = std.os.windows; +const c = std.c; +const assert = std.debug.assert; + +const bad_startfn_ret = "expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'"; + +/// Represents a kernel thread handle. +/// May be an integer or a pointer depending on the platform. +/// On Linux and POSIX, this is the same as Id. +pub const Handle = if (use_pthreads) + c.pthread_t +else switch (std.Target.current.os.tag) { + .linux => i32, + .windows => windows.HANDLE, + else => void, +}; + +/// Represents a unique ID per thread. +/// May be an integer or pointer depending on the platform. +/// On Linux and POSIX, this is the same as Handle. +pub const Id = switch (std.Target.current.os.tag) { + .windows => windows.DWORD, + else => Handle, +}; + +pub const Data = if (use_pthreads) + struct { + handle: Thread.Handle, + memory: []u8, + } +else switch (std.Target.current.os.tag) { + .linux => struct { + handle: Thread.Handle, + memory: []align(mem.page_size) u8, + }, + .windows => struct { + handle: Thread.Handle, + alloc_start: *c_void, + heap_handle: windows.HANDLE, + }, + else => struct {}, +}; + +/// Signals the processor that it is inside a busy-wait spin-loop ("spin lock"). +pub fn spinLoopHint() void { + switch (std.Target.current.cpu.arch) { + .i386, .x86_64 => asm volatile ("pause" ::: "memory"), + .arm, .aarch64 => asm volatile ("yield" ::: "memory"), + else => {}, + } +} + +/// Returns the ID of the calling thread. +/// Makes a syscall every time the function is called. +/// On Linux and POSIX, this Id is the same as a Handle. +pub fn getCurrentId() Id { + if (use_pthreads) { + return c.pthread_self(); + } else return switch (std.Target.current.os.tag) { + .linux => os.linux.gettid(), + .windows => windows.kernel32.GetCurrentThreadId(), + else => @compileError("Unsupported OS"), + }; +} + +/// Returns the handle of this thread. +/// On Linux and POSIX, this is the same as Id. +/// On Linux, it is possible that the thread spawned with `spawn` +/// finishes executing entirely before the clone syscall completes. In this +/// case, this function will return 0 rather than the no-longer-existing thread's +/// pid. +pub fn handle(self: Thread) Handle { + return self.data.handle; +} + +pub fn wait(self: *Thread) void { + if (use_pthreads) { + const err = c.pthread_join(self.data.handle, null); + switch (err) { + 0 => {}, + os.EINVAL => unreachable, + os.ESRCH => unreachable, + os.EDEADLK => unreachable, + else => unreachable, + } + std.heap.c_allocator.free(self.data.memory); + std.heap.c_allocator.destroy(self); + } else switch (std.Target.current.os.tag) { + .linux => { + while (true) { + const pid_value = @atomicLoad(i32, &self.data.handle, .SeqCst); + if (pid_value == 0) break; + const rc = os.linux.futex_wait(&self.data.handle, os.linux.FUTEX_WAIT, pid_value, null); + switch (os.linux.getErrno(rc)) { + 0 => continue, + os.EINTR => continue, + os.EAGAIN => continue, + else => unreachable, + } + } + os.munmap(self.data.memory); + }, + .windows => { + windows.WaitForSingleObjectEx(self.data.handle, windows.INFINITE, false) catch unreachable; + windows.CloseHandle(self.data.handle); + windows.HeapFree(self.data.heap_handle, 0, self.data.alloc_start); + }, + else => @compileError("Unsupported OS"), + } +} + +pub const SpawnError = error{ + /// A system-imposed limit on the number of threads was encountered. + /// There are a number of limits that may trigger this error: + /// * the RLIMIT_NPROC soft resource limit (set via setrlimit(2)), + /// which limits the number of processes and threads for a real + /// user ID, was reached; + /// * the kernel's system-wide limit on the number of processes and + /// threads, /proc/sys/kernel/threads-max, was reached (see + /// proc(5)); + /// * the maximum number of PIDs, /proc/sys/kernel/pid_max, was + /// reached (see proc(5)); or + /// * the PID limit (pids.max) imposed by the cgroup "process num‐ + /// ber" (PIDs) controller was reached. + ThreadQuotaExceeded, + + /// The kernel cannot allocate sufficient memory to allocate a task structure + /// for the child, or to copy those parts of the caller's context that need to + /// be copied. + SystemResources, + + /// Not enough userland memory to spawn the thread. + OutOfMemory, + + /// `mlockall` is enabled, and the memory needed to spawn the thread + /// would exceed the limit. + LockedMemoryLimitExceeded, + + Unexpected, +}; + +/// caller must call wait on the returned thread +/// fn startFn(@TypeOf(context)) T +/// where T is u8, noreturn, void, or !void +/// caller must call wait on the returned thread +pub fn spawn(context: anytype, comptime startFn: anytype) SpawnError!*Thread { + if (builtin.single_threaded) @compileError("cannot spawn thread when building in single-threaded mode"); + // TODO compile-time call graph analysis to determine stack upper bound + // https://github.com/ziglang/zig/issues/157 + const default_stack_size = 16 * 1024 * 1024; + + const Context = @TypeOf(context); + comptime assert(@typeInfo(@TypeOf(startFn)).Fn.args[0].arg_type.? == Context); + + if (std.Target.current.os.tag == .windows) { + const WinThread = struct { + const OuterContext = struct { + thread: Thread, + inner: Context, + }; + fn threadMain(raw_arg: windows.LPVOID) callconv(.C) windows.DWORD { + const arg = if (@sizeOf(Context) == 0) {} else @ptrCast(*Context, @alignCast(@alignOf(Context), raw_arg)).*; + + switch (@typeInfo(@typeInfo(@TypeOf(startFn)).Fn.return_type.?)) { + .NoReturn => { + startFn(arg); + }, + .Void => { + startFn(arg); + return 0; + }, + .Int => |info| { + if (info.bits != 8) { + @compileError(bad_startfn_ret); + } + return startFn(arg); + }, + .ErrorUnion => |info| { + if (info.payload != void) { + @compileError(bad_startfn_ret); + } + startFn(arg) catch |err| { + std.debug.warn("error: {s}\n", .{@errorName(err)}); + if (@errorReturnTrace()) |trace| { + std.debug.dumpStackTrace(trace.*); + } + }; + return 0; + }, + else => @compileError(bad_startfn_ret), + } + } + }; + + const heap_handle = windows.kernel32.GetProcessHeap() orelse return error.OutOfMemory; + const byte_count = @alignOf(WinThread.OuterContext) + @sizeOf(WinThread.OuterContext); + const bytes_ptr = windows.kernel32.HeapAlloc(heap_handle, 0, byte_count) orelse return error.OutOfMemory; + errdefer assert(windows.kernel32.HeapFree(heap_handle, 0, bytes_ptr) != 0); + const bytes = @ptrCast([*]u8, bytes_ptr)[0..byte_count]; + const outer_context = std.heap.FixedBufferAllocator.init(bytes).allocator.create(WinThread.OuterContext) catch unreachable; + outer_context.* = WinThread.OuterContext{ + .thread = Thread{ + .data = Thread.Data{ + .heap_handle = heap_handle, + .alloc_start = bytes_ptr, + .handle = undefined, + }, + }, + .inner = context, + }; + + const parameter = if (@sizeOf(Context) == 0) null else @ptrCast(*c_void, &outer_context.inner); + outer_context.thread.data.handle = windows.kernel32.CreateThread(null, default_stack_size, WinThread.threadMain, parameter, 0, null) orelse { + switch (windows.kernel32.GetLastError()) { + else => |err| return windows.unexpectedError(err), + } + }; + return &outer_context.thread; + } + + const MainFuncs = struct { + fn linuxThreadMain(ctx_addr: usize) callconv(.C) u8 { + const arg = if (@sizeOf(Context) == 0) {} else @intToPtr(*const Context, ctx_addr).*; + + switch (@typeInfo(@typeInfo(@TypeOf(startFn)).Fn.return_type.?)) { + .NoReturn => { + startFn(arg); + }, + .Void => { + startFn(arg); + return 0; + }, + .Int => |info| { + if (info.bits != 8) { + @compileError(bad_startfn_ret); + } + return startFn(arg); + }, + .ErrorUnion => |info| { + if (info.payload != void) { + @compileError(bad_startfn_ret); + } + startFn(arg) catch |err| { + std.debug.warn("error: {s}\n", .{@errorName(err)}); + if (@errorReturnTrace()) |trace| { + std.debug.dumpStackTrace(trace.*); + } + }; + return 0; + }, + else => @compileError(bad_startfn_ret), + } + } + fn posixThreadMain(ctx: ?*c_void) callconv(.C) ?*c_void { + const arg = if (@sizeOf(Context) == 0) {} else @ptrCast(*Context, @alignCast(@alignOf(Context), ctx)).*; + + switch (@typeInfo(@typeInfo(@TypeOf(startFn)).Fn.return_type.?)) { + .NoReturn => { + startFn(arg); + }, + .Void => { + startFn(arg); + return null; + }, + .Int => |info| { + if (info.bits != 8) { + @compileError(bad_startfn_ret); + } + // pthreads don't support exit status, ignore value + _ = startFn(arg); + return null; + }, + .ErrorUnion => |info| { + if (info.payload != void) { + @compileError(bad_startfn_ret); + } + startFn(arg) catch |err| { + std.debug.warn("error: {s}\n", .{@errorName(err)}); + if (@errorReturnTrace()) |trace| { + std.debug.dumpStackTrace(trace.*); + } + }; + return null; + }, + else => @compileError(bad_startfn_ret), + } + } + }; + + if (Thread.use_pthreads) { + var attr: c.pthread_attr_t = undefined; + if (c.pthread_attr_init(&attr) != 0) return error.SystemResources; + defer assert(c.pthread_attr_destroy(&attr) == 0); + + const thread_obj = try std.heap.c_allocator.create(Thread); + errdefer std.heap.c_allocator.destroy(thread_obj); + if (@sizeOf(Context) > 0) { + thread_obj.data.memory = try std.heap.c_allocator.allocAdvanced( + u8, + @alignOf(Context), + @sizeOf(Context), + .at_least, + ); + errdefer std.heap.c_allocator.free(thread_obj.data.memory); + mem.copy(u8, thread_obj.data.memory, mem.asBytes(&context)); + } else { + thread_obj.data.memory = @as([*]u8, undefined)[0..0]; + } + + // Use the same set of parameters used by the libc-less impl. + assert(c.pthread_attr_setstacksize(&attr, default_stack_size) == 0); + assert(c.pthread_attr_setguardsize(&attr, mem.page_size) == 0); + + const err = c.pthread_create( + &thread_obj.data.handle, + &attr, + MainFuncs.posixThreadMain, + thread_obj.data.memory.ptr, + ); + switch (err) { + 0 => return thread_obj, + os.EAGAIN => return error.SystemResources, + os.EPERM => unreachable, + os.EINVAL => unreachable, + else => return os.unexpectedErrno(@intCast(usize, err)), + } + + return thread_obj; + } + + var guard_end_offset: usize = undefined; + var stack_end_offset: usize = undefined; + var thread_start_offset: usize = undefined; + var context_start_offset: usize = undefined; + var tls_start_offset: usize = undefined; + const mmap_len = blk: { + var l: usize = mem.page_size; + // Allocate a guard page right after the end of the stack region + guard_end_offset = l; + // The stack itself, which grows downwards. + l = mem.alignForward(l + default_stack_size, mem.page_size); + stack_end_offset = l; + // Above the stack, so that it can be in the same mmap call, put the Thread object. + l = mem.alignForward(l, @alignOf(Thread)); + thread_start_offset = l; + l += @sizeOf(Thread); + // Next, the Context object. + if (@sizeOf(Context) != 0) { + l = mem.alignForward(l, @alignOf(Context)); + context_start_offset = l; + l += @sizeOf(Context); + } + // Finally, the Thread Local Storage, if any. + l = mem.alignForward(l, os.linux.tls.tls_image.alloc_align); + tls_start_offset = l; + l += os.linux.tls.tls_image.alloc_size; + // Round the size to the page size. + break :blk mem.alignForward(l, mem.page_size); + }; + + const mmap_slice = mem: { + // Map the whole stack with no rw permissions to avoid + // committing the whole region right away + const mmap_slice = os.mmap( + null, + mmap_len, + os.PROT_NONE, + os.MAP_PRIVATE | os.MAP_ANONYMOUS, + -1, + 0, + ) catch |err| switch (err) { + error.MemoryMappingNotSupported => unreachable, + error.AccessDenied => unreachable, + error.PermissionDenied => unreachable, + else => |e| return e, + }; + errdefer os.munmap(mmap_slice); + + // Map everything but the guard page as rw + os.mprotect( + mmap_slice[guard_end_offset..], + os.PROT_READ | os.PROT_WRITE, + ) catch |err| switch (err) { + error.AccessDenied => unreachable, + else => |e| return e, + }; + + break :mem mmap_slice; + }; + + const mmap_addr = @ptrToInt(mmap_slice.ptr); + + const thread_ptr = @alignCast(@alignOf(Thread), @intToPtr(*Thread, mmap_addr + thread_start_offset)); + thread_ptr.data.memory = mmap_slice; + + var arg: usize = undefined; + if (@sizeOf(Context) != 0) { + arg = mmap_addr + context_start_offset; + const context_ptr = @alignCast(@alignOf(Context), @intToPtr(*Context, arg)); + context_ptr.* = context; + } + + if (std.Target.current.os.tag == .linux) { + const flags: u32 = os.CLONE_VM | os.CLONE_FS | os.CLONE_FILES | + os.CLONE_SIGHAND | os.CLONE_THREAD | os.CLONE_SYSVSEM | + os.CLONE_PARENT_SETTID | os.CLONE_CHILD_CLEARTID | + os.CLONE_DETACHED | os.CLONE_SETTLS; + // This structure is only needed when targeting i386 + var user_desc: if (std.Target.current.cpu.arch == .i386) os.linux.user_desc else void = undefined; + + const tls_area = mmap_slice[tls_start_offset..]; + const tp_value = os.linux.tls.prepareTLS(tls_area); + + const newtls = blk: { + if (std.Target.current.cpu.arch == .i386) { + user_desc = os.linux.user_desc{ + .entry_number = os.linux.tls.tls_image.gdt_entry_number, + .base_addr = tp_value, + .limit = 0xfffff, + .seg_32bit = 1, + .contents = 0, // Data + .read_exec_only = 0, + .limit_in_pages = 1, + .seg_not_present = 0, + .useable = 1, + }; + break :blk @ptrToInt(&user_desc); + } else { + break :blk tp_value; + } + }; + + const rc = os.linux.clone( + MainFuncs.linuxThreadMain, + mmap_addr + stack_end_offset, + flags, + arg, + &thread_ptr.data.handle, + newtls, + &thread_ptr.data.handle, + ); + switch (os.errno(rc)) { + 0 => return thread_ptr, + os.EAGAIN => return error.ThreadQuotaExceeded, + os.EINVAL => unreachable, + os.ENOMEM => return error.SystemResources, + os.ENOSPC => unreachable, + os.EPERM => unreachable, + os.EUSERS => unreachable, + else => |err| return os.unexpectedErrno(err), + } + } else { + @compileError("Unsupported OS"); + } +} + +pub const CpuCountError = error{ + PermissionDenied, + SystemResources, + Unexpected, +}; + +pub fn cpuCount() CpuCountError!usize { + switch (std.Target.current.os.tag) { + .linux => { + const cpu_set = try os.sched_getaffinity(0); + return @as(usize, os.CPU_COUNT(cpu_set)); // TODO should not need this usize cast + }, + .windows => { + return os.windows.peb().NumberOfProcessors; + }, + .openbsd => { + var count: c_int = undefined; + var count_size: usize = @sizeOf(c_int); + const mib = [_]c_int{ os.CTL_HW, os.HW_NCPUONLINE }; + os.sysctl(&mib, &count, &count_size, null, 0) catch |err| switch (err) { + error.NameTooLong, error.UnknownName => unreachable, + else => |e| return e, + }; + return @intCast(usize, count); + }, + .haiku => { + var count: u32 = undefined; + var system_info: os.system_info = undefined; + const rc = os.system.get_system_info(&system_info); + count = system_info.cpu_count; + return @intCast(usize, count); + }, + else => { + var count: c_int = undefined; + var count_len: usize = @sizeOf(c_int); + const name = if (comptime std.Target.current.isDarwin()) "hw.logicalcpu" else "hw.ncpu"; + os.sysctlbynameZ(name, &count, &count_len, null, 0) catch |err| switch (err) { + error.NameTooLong, error.UnknownName => unreachable, + else => |e| return e, + }; + return @intCast(usize, count); + }, + } +} + +pub fn getCurrentThreadId() u64 { + switch (std.Target.current.os.tag) { + .linux => { + // Use the syscall directly as musl doesn't provide a wrapper. + return @bitCast(u32, os.linux.gettid()); + }, + .windows => { + return os.windows.kernel32.GetCurrentThreadId(); + }, + .macos, .ios, .watchos, .tvos => { + var thread_id: u64 = undefined; + // Pass thread=null to get the current thread ID. + assert(c.pthread_threadid_np(null, &thread_id) == 0); + return thread_id; + }, + .netbsd => { + return @bitCast(u32, c._lwp_self()); + }, + .freebsd => { + return @bitCast(u32, c.pthread_getthreadid_np()); + }, + .openbsd => { + return @bitCast(u32, c.getthrid()); + }, + .haiku => { + return @bitCast(u32, c.find_thread(null)); + }, + else => { + @compileError("getCurrentThreadId not implemented for this platform"); + }, + } +} + +test { + if (!builtin.single_threaded) { + std.testing.refAllDecls(@This()); + } +} diff --git a/lib/std/Thread/AutoResetEvent.zig b/lib/std/Thread/AutoResetEvent.zig new file mode 100644 index 0000000000..8b8b5658bf --- /dev/null +++ b/lib/std/Thread/AutoResetEvent.zig @@ -0,0 +1,228 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! Similar to `StaticResetEvent` but on `set()` it also (atomically) does `reset()`. +//! Unlike StaticResetEvent, `wait()` can only be called by one thread (MPSC-like). +//! +//! AutoResetEvent has 3 possible states: +//! - UNSET: the AutoResetEvent is currently unset +//! - SET: the AutoResetEvent was notified before a wait() was called +//! - : there is an active waiter waiting for a notification. +//! +//! When attempting to wait: +//! if the event is unset, it registers a ResetEvent pointer to be notified when the event is set +//! if the event is already set, then it consumes the notification and resets the event. +//! +//! When attempting to notify: +//! if the event is unset, then we set the event +//! if theres a waiting ResetEvent, then we unset the event and notify the ResetEvent +//! +//! This ensures that the event is automatically reset after a wait() has been issued +//! and avoids the race condition when using StaticResetEvent in the following scenario: +//! thread 1 | thread 2 +//! StaticResetEvent.wait() | +//! | StaticResetEvent.set() +//! | StaticResetEvent.set() +//! StaticResetEvent.reset() | +//! StaticResetEvent.wait() | (missed the second .set() notification above) + +state: usize = UNSET, + +const std = @import("../std.zig"); +const builtin = @import("builtin"); +const testing = std.testing; +const assert = std.debug.assert; +const StaticResetEvent = std.Thread.StaticResetEvent; +const AutoResetEvent = @This(); + +const UNSET = 0; +const SET = 1; + +/// the minimum alignment for the `*StaticResetEvent` created by wait*() +const event_align = std.math.max(@alignOf(StaticResetEvent), 2); + +pub fn wait(self: *AutoResetEvent) void { + self.waitFor(null) catch unreachable; +} + +pub fn timedWait(self: *AutoResetEvent, timeout: u64) error{TimedOut}!void { + return self.waitFor(timeout); +} + +fn waitFor(self: *AutoResetEvent, timeout: ?u64) error{TimedOut}!void { + // lazily initialized StaticResetEvent + var reset_event: StaticResetEvent align(event_align) = undefined; + var has_reset_event = false; + + var state = @atomicLoad(usize, &self.state, .SeqCst); + while (true) { + // consume a notification if there is any + if (state == SET) { + @atomicStore(usize, &self.state, UNSET, .SeqCst); + return; + } + + // check if theres currently a pending ResetEvent pointer already registered + if (state != UNSET) { + unreachable; // multiple waiting threads on the same AutoResetEvent + } + + // lazily initialize the ResetEvent if it hasn't been already + if (!has_reset_event) { + has_reset_event = true; + reset_event = .{}; + } + + // Since the AutoResetEvent currently isnt set, + // try to register our ResetEvent on it to wait + // for a set() call from another thread. + if (@cmpxchgWeak( + usize, + &self.state, + UNSET, + @ptrToInt(&reset_event), + .SeqCst, + .SeqCst, + )) |new_state| { + state = new_state; + continue; + } + + // if no timeout was specified, then just wait forever + const timeout_ns = timeout orelse { + reset_event.wait(); + return; + }; + + // wait with a timeout and return if signalled via set() + switch (reset_event.timedWait(timeout_ns)) { + .event_set => return, + .timed_out => {}, + } + + // If we timed out, we need to transition the AutoResetEvent back to UNSET. + // If we don't, then when we return, a set() thread could observe a pointer to an invalid ResetEvent. + state = @cmpxchgStrong( + usize, + &self.state, + @ptrToInt(&reset_event), + UNSET, + .SeqCst, + .SeqCst, + ) orelse return error.TimedOut; + + // We didn't manage to unregister ourselves from the state. + if (state == SET) { + unreachable; // AutoResetEvent notified without waking up the waiting thread + } else if (state != UNSET) { + unreachable; // multiple waiting threads on the same AutoResetEvent observed when timing out + } + + // This menas a set() thread saw our ResetEvent pointer, acquired it, and is trying to wake it up. + // We need to wait for it to wake up our ResetEvent before we can return and invalidate it. + // We don't return error.TimedOut here as it technically notified us while we were "timing out". + reset_event.wait(); + return; + } +} + +pub fn set(self: *AutoResetEvent) void { + var state = @atomicLoad(usize, &self.state, .SeqCst); + while (true) { + // If the AutoResetEvent is already set, there is nothing else left to do + if (state == SET) { + return; + } + + // If the AutoResetEvent isn't set, + // then try to leave a notification for the wait() thread that we set() it. + if (state == UNSET) { + state = @cmpxchgWeak( + usize, + &self.state, + UNSET, + SET, + .SeqCst, + .SeqCst, + ) orelse return; + continue; + } + + // There is a ResetEvent pointer registered on the AutoResetEvent event thats waiting. + // Try to acquire ownership of it so that we can wake it up. + // This also resets the AutoResetEvent so that there is no race condition as defined above. + if (@cmpxchgWeak( + usize, + &self.state, + state, + UNSET, + .SeqCst, + .SeqCst, + )) |new_state| { + state = new_state; + continue; + } + + const reset_event = @intToPtr(*align(event_align) StaticResetEvent, state); + reset_event.set(); + return; + } +} + +test "basic usage" { + // test local code paths + { + var event = AutoResetEvent{}; + testing.expectError(error.TimedOut, event.timedWait(1)); + event.set(); + event.wait(); + } + + // test cross-thread signaling + if (builtin.single_threaded) + return; + + const Context = struct { + value: u128 = 0, + in: AutoResetEvent = AutoResetEvent{}, + out: AutoResetEvent = AutoResetEvent{}, + + const Self = @This(); + + fn sender(self: *Self) void { + testing.expect(self.value == 0); + self.value = 1; + self.out.set(); + + self.in.wait(); + testing.expect(self.value == 2); + self.value = 3; + self.out.set(); + + self.in.wait(); + testing.expect(self.value == 4); + } + + fn receiver(self: *Self) void { + self.out.wait(); + testing.expect(self.value == 1); + self.value = 2; + self.in.set(); + + self.out.wait(); + testing.expect(self.value == 3); + self.value = 4; + self.in.set(); + } + }; + + var context = Context{}; + const send_thread = try std.Thread.spawn(&context, Context.sender); + const recv_thread = try std.Thread.spawn(&context, Context.receiver); + + send_thread.wait(); + recv_thread.wait(); +} diff --git a/lib/std/Thread/Condition.zig b/lib/std/Thread/Condition.zig new file mode 100644 index 0000000000..a14b57f6b4 --- /dev/null +++ b/lib/std/Thread/Condition.zig @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! A condition provides a way for a kernel thread to block until it is signaled +//! to wake up. Spurious wakeups are possible. +//! This API supports static initialization and does not require deinitialization. + +impl: Impl = .{}, + +const std = @import("../std.zig"); +const Condition = @This(); +const windows = std.os.windows; +const linux = std.os.linux; +const Mutex = std.Thread.Mutex; +const assert = std.debug.assert; + +pub fn wait(cond: *Condition, mutex: *Mutex) void { + cond.impl.wait(mutex); +} + +pub fn signal(cond: *Condition) void { + cond.impl.signal(); +} + +pub fn broadcast(cond: *Condition) void { + cond.impl.broadcast(); +} + +const Impl = if (std.builtin.single_threaded) + SingleThreadedCondition +else if (std.Target.current.os.tag == .windows) + WindowsCondition +else if (std.Thread.use_pthreads) + PthreadCondition +else + AtomicCondition; + +pub const SingleThreadedCondition = struct { + pub fn wait(cond: *SingleThreadedCondition, mutex: *Mutex) void { + unreachable; // deadlock detected + } + + pub fn signal(cond: *SingleThreadedCondition) void {} + + pub fn broadcast(cond: *SingleThreadedCondition) void {} +}; + +pub const WindowsCondition = struct { + cond: windows.CONDITION_VARIABLE = windows.CONDITION_VARIABLE_INIT, + + pub fn wait(cond: *WindowsCondition, mutex: *Mutex) void { + const rc = windows.kernel32.SleepConditionVariableSRW( + &cond.cond, + &mutex.srwlock, + windows.INFINITE, + @as(windows.ULONG, 0), + ); + assert(rc != windows.FALSE); + } + + pub fn signal(cond: *WindowsCondition) void { + windows.kernel32.WakeConditionVariable(&cond.cond); + } + + pub fn broadcast(cond: *WindowsCondition) void { + windows.kernel32.WakeAllConditionVariable(&cond.cond); + } +}; + +pub const PthreadCondition = struct { + cond: std.c.pthread_cond_t = .{}, + + pub fn wait(cond: *PthreadCondition, mutex: *Mutex) void { + const rc = std.c.pthread_cond_wait(&cond.cond, &mutex.impl.pthread_mutex); + assert(rc == 0); + } + + pub fn signal(cond: *PthreadCondition) void { + const rc = std.c.pthread_cond_signal(&cond.cond); + assert(rc == 0); + } + + pub fn broadcast(cond: *PthreadCondition) void { + const rc = std.c.pthread_cond_broadcast(&cond.cond); + assert(rc == 0); + } +}; + +pub const AtomicCondition = struct { + pending: bool = false, + queue_mutex: Mutex = .{}, + queue_list: QueueList = .{}, + + pub const QueueList = std.SinglyLinkedList(QueueItem); + + pub const QueueItem = struct { + futex: i32 = 0, + + fn wait(cond: *@This()) void { + while (@atomicLoad(i32, &cond.futex, .Acquire) == 0) { + switch (std.Target.current.os.tag) { + .linux => { + switch (linux.getErrno(linux.futex_wait( + &cond.futex, + linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT, + 0, + null, + ))) { + 0 => {}, + std.os.EINTR => {}, + std.os.EAGAIN => {}, + else => unreachable, + } + }, + else => spinLoopHint(), + } + } + } + + fn notify(cond: *@This()) void { + @atomicStore(i32, &cond.futex, 1, .Release); + + switch (std.Target.current.os.tag) { + .linux => { + switch (linux.getErrno(linux.futex_wake( + &cond.futex, + linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE, + 1, + ))) { + 0 => {}, + std.os.EFAULT => {}, + else => unreachable, + } + }, + else => {}, + } + } + }; + + pub fn wait(cond: *AtomicCondition, mutex: *Mutex) void { + var waiter = QueueList.Node{ .data = .{} }; + + { + const held = cond.queue_mutex.acquire(); + defer held.release(); + + cond.queue_list.prepend(&waiter); + @atomicStore(bool, &cond.pending, true, .SeqCst); + } + + mutex.unlock(); + waiter.data.wait(); + mutex.lock(); + } + + pub fn signal(cond: *AtomicCondition) void { + if (@atomicLoad(bool, &cond.pending, .SeqCst) == false) + return; + + const maybe_waiter = blk: { + const held = cond.queue_mutex.acquire(); + defer held.release(); + + const maybe_waiter = cond.queue_list.popFirst(); + @atomicStore(bool, &cond.pending, cond.queue_list.first != null, .SeqCst); + break :blk maybe_waiter; + }; + + if (maybe_waiter) |waiter| + waiter.data.notify(); + } + + pub fn broadcast(cond: *AtomicCondition) void { + if (@atomicLoad(bool, &cond.pending, .SeqCst) == false) + return; + + @atomicStore(bool, &cond.pending, false, .SeqCst); + + var waiters = blk: { + const held = cond.queue_mutex.acquire(); + defer held.release(); + + const waiters = cond.queue_list; + cond.queue_list = .{}; + break :blk waiters; + }; + + while (waiters.popFirst()) |waiter| + waiter.data.notify(); + } +}; diff --git a/lib/std/Thread/Mutex.zig b/lib/std/Thread/Mutex.zig new file mode 100644 index 0000000000..94711bcda0 --- /dev/null +++ b/lib/std/Thread/Mutex.zig @@ -0,0 +1,319 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! Lock may be held only once. If the same thread tries to acquire +//! the same mutex twice, it deadlocks. This type supports static +//! initialization and is at most `@sizeOf(usize)` in size. When an +//! application is built in single threaded release mode, all the +//! functions are no-ops. In single threaded debug mode, there is +//! deadlock detection. +//! +//! Example usage: +//! var m = Mutex{}; +//! +//! const lock = m.acquire(); +//! defer lock.release(); +//! ... critical code +//! +//! Non-blocking: +//! if (m.tryAcquire) |lock| { +//! defer lock.release(); +//! // ... critical section +//! } else { +//! // ... lock not acquired +//! } + +impl: Impl = .{}, + +const Mutex = @This(); +const std = @import("../std.zig"); +const builtin = std.builtin; +const os = std.os; +const assert = std.debug.assert; +const windows = os.windows; +const linux = os.linux; +const testing = std.testing; +const StaticResetEvent = std.thread.StaticResetEvent; + +/// Try to acquire the mutex without blocking. Returns `null` if the mutex is +/// unavailable. Otherwise returns `Held`. Call `release` on `Held`. +pub fn tryAcquire(m: *Mutex) ?Impl.Held { + return m.impl.tryAcquire(); +} + +/// Acquire the mutex. Deadlocks if the mutex is already +/// held by the calling thread. +pub fn acquire(m: *Mutex) Impl.Held { + return m.impl.acquire(); +} + +const Impl = if (builtin.single_threaded) + Dummy +else if (builtin.os.tag == .windows) + WindowsMutex +else if (std.Thread.use_pthreads) + PthreadMutex +else + AtomicMutex; + +pub const AtomicMutex = struct { + state: State = .unlocked, + + const State = enum(i32) { + unlocked, + locked, + waiting, + }; + + pub const Held = struct { + mutex: *AtomicMutex, + + pub fn release(held: Held) void { + switch (@atomicRmw(State, &held.mutex.state, .Xchg, .unlocked, .Release)) { + .unlocked => unreachable, + .locked => {}, + .waiting => held.mutex.unlockSlow(), + } + } + }; + + pub fn tryAcquire(m: *AtomicMutex) ?Held { + if (@cmpxchgStrong( + State, + &m.state, + .unlocked, + .locked, + .Acquire, + .Monotonic, + ) == null) { + return Held{ .mutex = m }; + } else { + return null; + } + } + + pub fn acquire(m: *AtomicMutex) Held { + switch (@atomicRmw(State, &m.state, .Xchg, .locked, .Acquire)) { + .unlocked => {}, + else => |s| m.lockSlow(s), + } + return Held{ .mutex = m }; + } + + fn lockSlow(m: *AtomicMutex, current_state: State) void { + @setCold(true); + var new_state = current_state; + + var spin: u8 = 0; + while (spin < 100) : (spin += 1) { + const state = @cmpxchgWeak( + State, + &m.state, + .unlocked, + new_state, + .Acquire, + .Monotonic, + ) orelse return; + + switch (state) { + .unlocked => {}, + .locked => {}, + .waiting => break, + } + + var iter = std.math.min(32, spin + 1); + while (iter > 0) : (iter -= 1) + std.Thread.spinLoopHint(); + } + + new_state = .waiting; + while (true) { + switch (@atomicRmw(State, &m.state, .Xchg, new_state, .Acquire)) { + .unlocked => return, + else => {}, + } + switch (std.Target.current.os.tag) { + .linux => { + switch (linux.getErrno(linux.futex_wait( + @ptrCast(*const i32, &m.state), + linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAIT, + @enumToInt(new_state), + null, + ))) { + 0 => {}, + std.os.EINTR => {}, + std.os.EAGAIN => {}, + else => unreachable, + } + }, + else => std.Thread.spinLoopHint(), + } + } + } + + fn unlockSlow(m: *AtomicMutex) void { + @setCold(true); + + switch (std.Target.current.os.tag) { + .linux => { + switch (linux.getErrno(linux.futex_wake( + @ptrCast(*const i32, &m.state), + linux.FUTEX_PRIVATE_FLAG | linux.FUTEX_WAKE, + 1, + ))) { + 0 => {}, + std.os.EFAULT => {}, + else => unreachable, + } + }, + else => {}, + } + } +}; + +pub const PthreadMutex = struct { + pthread_mutex: std.c.pthread_mutex_t = .{}, + + pub const Held = struct { + mutex: *PthreadMutex, + + pub fn release(held: Held) void { + switch (std.c.pthread_mutex_unlock(&held.mutex.pthread_mutex)) { + 0 => return, + std.c.EINVAL => unreachable, + std.c.EAGAIN => unreachable, + std.c.EPERM => unreachable, + else => unreachable, + } + } + }; + + /// Try to acquire the mutex without blocking. Returns null if + /// the mutex is unavailable. Otherwise returns Held. Call + /// release on Held. + pub fn tryAcquire(m: *PthreadMutex) ?Held { + if (std.c.pthread_mutex_trylock(&m.pthread_mutex) == 0) { + return Held{ .mutex = m }; + } else { + return null; + } + } + + /// Acquire the mutex. Will deadlock if the mutex is already + /// held by the calling thread. + pub fn acquire(m: *PthreadMutex) Held { + switch (std.c.pthread_mutex_lock(&m.pthread_mutex)) { + 0 => return Held{ .mutex = m }, + std.c.EINVAL => unreachable, + std.c.EBUSY => unreachable, + std.c.EAGAIN => unreachable, + std.c.EDEADLK => unreachable, + std.c.EPERM => unreachable, + else => unreachable, + } + } +}; + +/// This has the sematics as `Mutex`, however it does not actually do any +/// synchronization. Operations are safety-checked no-ops. +pub const Dummy = struct { + lock: @TypeOf(lock_init) = lock_init, + + const lock_init = if (std.debug.runtime_safety) false else {}; + + pub const Held = struct { + mutex: *Dummy, + + pub fn release(held: Held) void { + if (std.debug.runtime_safety) { + held.mutex.lock = false; + } + } + }; + + /// Try to acquire the mutex without blocking. Returns null if + /// the mutex is unavailable. Otherwise returns Held. Call + /// release on Held. + pub fn tryAcquire(m: *Dummy) ?Held { + if (std.debug.runtime_safety) { + if (m.lock) return null; + m.lock = true; + } + return Held{ .mutex = m }; + } + + /// Acquire the mutex. Will deadlock if the mutex is already + /// held by the calling thread. + pub fn acquire(m: *Dummy) Held { + return m.tryAcquire() orelse @panic("deadlock detected"); + } +}; + +const WindowsMutex = struct { + srwlock: windows.SRWLOCK = windows.SRWLOCK_INIT, + + pub const Held = struct { + mutex: *WindowsMutex, + + pub fn release(held: Held) void { + windows.kernel32.ReleaseSRWLockExclusive(&held.mutex.srwlock); + } + }; + + pub fn tryAcquire(m: *WindowsMutex) ?Held { + if (windows.kernel32.TryAcquireSRWLockExclusive(&m.srwlock) != windows.FALSE) { + return Held{ .mutex = m }; + } else { + return null; + } + } + + pub fn acquire(m: *WindowsMutex) Held { + windows.kernel32.AcquireSRWLockExclusive(&m.srwlock); + return Held{ .mutex = m }; + } +}; + +const TestContext = struct { + mutex: *Mutex, + data: i128, + + const incr_count = 10000; +}; + +test "basic usage" { + var mutex = Mutex{}; + + var context = TestContext{ + .mutex = &mutex, + .data = 0, + }; + + if (builtin.single_threaded) { + worker(&context); + testing.expect(context.data == TestContext.incr_count); + } else { + const thread_count = 10; + var threads: [thread_count]*std.Thread = undefined; + for (threads) |*t| { + t.* = try std.Thread.spawn(&context, worker); + } + for (threads) |t| + t.wait(); + + testing.expect(context.data == thread_count * TestContext.incr_count); + } +} + +fn worker(ctx: *TestContext) void { + var i: usize = 0; + while (i != TestContext.incr_count) : (i += 1) { + const held = ctx.mutex.acquire(); + defer held.release(); + + ctx.data += 1; + } +} diff --git a/lib/std/Thread/ResetEvent.zig b/lib/std/Thread/ResetEvent.zig new file mode 100644 index 0000000000..622f9be98e --- /dev/null +++ b/lib/std/Thread/ResetEvent.zig @@ -0,0 +1,297 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! A thread-safe resource which supports blocking until signaled. +//! This API is for kernel threads, not evented I/O. +//! This API requires being initialized at runtime, and initialization +//! can fail. Once initialized, the core operations cannot fail. +//! If you need an abstraction that cannot fail to be initialized, see +//! `std.Thread.StaticResetEvent`. However if you can handle initialization failure, +//! it is preferred to use `ResetEvent`. + +const ResetEvent = @This(); +const std = @import("../std.zig"); +const builtin = std.builtin; +const testing = std.testing; +const assert = std.debug.assert; +const c = std.c; +const os = std.os; +const time = std.time; + +impl: Impl, + +pub const Impl = if (builtin.single_threaded) + std.Thread.StaticResetEvent.DebugEvent +else if (std.Target.current.isDarwin()) + DarwinEvent +else if (std.Thread.use_pthreads) + PosixEvent +else + std.Thread.StaticResetEvent.AtomicEvent; + +pub const InitError = error{SystemResources}; + +/// After `init`, it is legal to call any other function. +pub fn init(ev: *ResetEvent) InitError!void { + return ev.impl.init(); +} + +/// This function is not thread-safe. +/// After `deinit`, the only legal function to call is `init`. +pub fn deinit(ev: *ResetEvent) void { + return ev.impl.deinit(); +} + +/// Sets the event if not already set and wakes up all the threads waiting on +/// the event. It is safe to call `set` multiple times before calling `wait`. +/// However it is illegal to call `set` after `wait` is called until the event +/// is `reset`. This function is thread-safe. +pub fn set(ev: *ResetEvent) void { + return ev.impl.set(); +} + +/// Resets the event to its original, unset state. +/// This function is *not* thread-safe. It is equivalent to calling +/// `deinit` followed by `init` but without the possibility of failure. +pub fn reset(ev: *ResetEvent) void { + return ev.impl.reset(); +} + +/// Wait for the event to be set by blocking the current thread. +/// Thread-safe. No spurious wakeups. +/// Upon return from `wait`, the only functions available to be called +/// in `ResetEvent` are `reset` and `deinit`. +pub fn wait(ev: *ResetEvent) void { + return ev.impl.wait(); +} + +pub const TimedWaitResult = enum { event_set, timed_out }; + +/// Wait for the event to be set by blocking the current thread. +/// A timeout in nanoseconds can be provided as a hint for how +/// long the thread should block on the unset event before returning +/// `TimedWaitResult.timed_out`. +/// Thread-safe. No precision of timing is guaranteed. +/// Upon return from `wait`, the only functions available to be called +/// in `ResetEvent` are `reset` and `deinit`. +pub fn timedWait(ev: *ResetEvent, timeout_ns: u64) TimedWaitResult { + return ev.impl.timedWait(timeout_ns); +} + +/// Apple has decided to not support POSIX semaphores, so we go with a +/// different approach using Grand Central Dispatch. This API is exposed +/// by libSystem so it is guaranteed to be available on all Darwin platforms. +pub const DarwinEvent = struct { + sem: c.dispatch_semaphore_t = undefined, + + pub fn init(ev: *DarwinEvent) !void { + ev.* = .{ + .sem = c.dispatch_semaphore_create(0) orelse return error.SystemResources, + }; + } + + pub fn deinit(ev: *DarwinEvent) void { + c.dispatch_release(ev.sem); + ev.* = undefined; + } + + pub fn set(ev: *DarwinEvent) void { + // Empirically this returns the numerical value of the semaphore. + _ = c.dispatch_semaphore_signal(ev.sem); + } + + pub fn wait(ev: *DarwinEvent) void { + assert(c.dispatch_semaphore_wait(ev.sem, c.DISPATCH_TIME_FOREVER) == 0); + } + + pub fn timedWait(ev: *DarwinEvent, timeout_ns: u64) TimedWaitResult { + const t = c.dispatch_time(c.DISPATCH_TIME_NOW, @intCast(i64, timeout_ns)); + if (c.dispatch_semaphore_wait(ev.sem, t) != 0) { + return .timed_out; + } else { + return .event_set; + } + } + + pub fn reset(ev: *DarwinEvent) void { + // Keep calling until the semaphore goes back down to 0. + while (c.dispatch_semaphore_wait(ev.sem, c.DISPATCH_TIME_NOW) == 0) {} + } +}; + +/// POSIX semaphores must be initialized at runtime because they are allowed to +/// be implemented as file descriptors, in which case initialization would require +/// a syscall to open the fd. +pub const PosixEvent = struct { + sem: c.sem_t = undefined, + + pub fn init(ev: *PosixEvent) !void { + switch (c.getErrno(c.sem_init(&ev.sem, 0, 0))) { + 0 => return, + else => return error.SystemResources, + } + } + + pub fn deinit(ev: *PosixEvent) void { + assert(c.sem_destroy(&ev.sem) == 0); + ev.* = undefined; + } + + pub fn set(ev: *PosixEvent) void { + assert(c.sem_post(&ev.sem) == 0); + } + + pub fn wait(ev: *PosixEvent) void { + while (true) { + switch (c.getErrno(c.sem_wait(&ev.sem))) { + 0 => return, + c.EINTR => continue, + c.EINVAL => unreachable, + else => unreachable, + } + } + } + + pub fn timedWait(ev: *PosixEvent, timeout_ns: u64) TimedWaitResult { + var ts: os.timespec = undefined; + var timeout_abs = timeout_ns; + os.clock_gettime(os.CLOCK_REALTIME, &ts) catch return .timed_out; + timeout_abs += @intCast(u64, ts.tv_sec) * time.ns_per_s; + timeout_abs += @intCast(u64, ts.tv_nsec); + ts.tv_sec = @intCast(@TypeOf(ts.tv_sec), @divFloor(timeout_abs, time.ns_per_s)); + ts.tv_nsec = @intCast(@TypeOf(ts.tv_nsec), @mod(timeout_abs, time.ns_per_s)); + while (true) { + switch (c.getErrno(c.sem_timedwait(&ev.sem, &ts))) { + 0 => return .event_set, + c.EINTR => continue, + c.EINVAL => unreachable, + c.ETIMEDOUT => return .timed_out, + else => unreachable, + } + } + } + + pub fn reset(ev: *PosixEvent) void { + while (true) { + switch (c.getErrno(c.sem_trywait(&ev.sem))) { + 0 => continue, // Need to make it go to zero. + c.EINTR => continue, + c.EINVAL => unreachable, + c.EAGAIN => return, // The semaphore currently has the value zero. + else => unreachable, + } + } + } +}; + +test "basic usage" { + var event: ResetEvent = undefined; + try event.init(); + defer event.deinit(); + + // test event setting + event.set(); + + // test event resetting + event.reset(); + + // test event waiting (non-blocking) + event.set(); + event.wait(); + event.reset(); + + event.set(); + testing.expectEqual(TimedWaitResult.event_set, event.timedWait(1)); + + // test cross-thread signaling + if (builtin.single_threaded) + return; + + const Context = struct { + const Self = @This(); + + value: u128, + in: ResetEvent, + out: ResetEvent, + + fn init(self: *Self) !void { + self.* = .{ + .value = 0, + .in = undefined, + .out = undefined, + }; + try self.in.init(); + try self.out.init(); + } + + fn deinit(self: *Self) void { + self.in.deinit(); + self.out.deinit(); + self.* = undefined; + } + + fn sender(self: *Self) void { + // update value and signal input + testing.expect(self.value == 0); + self.value = 1; + self.in.set(); + + // wait for receiver to update value and signal output + self.out.wait(); + testing.expect(self.value == 2); + + // update value and signal final input + self.value = 3; + self.in.set(); + } + + fn receiver(self: *Self) void { + // wait for sender to update value and signal input + self.in.wait(); + assert(self.value == 1); + + // update value and signal output + self.in.reset(); + self.value = 2; + self.out.set(); + + // wait for sender to update value and signal final input + self.in.wait(); + assert(self.value == 3); + } + + fn sleeper(self: *Self) void { + self.in.set(); + time.sleep(time.ns_per_ms * 2); + self.value = 5; + self.out.set(); + } + + fn timedWaiter(self: *Self) !void { + self.in.wait(); + testing.expectEqual(TimedWaitResult.timed_out, self.out.timedWait(time.ns_per_us)); + try self.out.timedWait(time.ns_per_ms * 100); + testing.expect(self.value == 5); + } + }; + + var context: Context = undefined; + try context.init(); + defer context.deinit(); + const receiver = try std.Thread.spawn(&context, Context.receiver); + defer receiver.wait(); + context.sender(); + + if (false) { + // I have now observed this fail on macOS, Windows, and Linux. + // https://github.com/ziglang/zig/issues/7009 + var timed = Context.init(); + defer timed.deinit(); + const sleeper = try std.Thread.spawn(&timed, Context.sleeper); + defer sleeper.wait(); + try timed.timedWaiter(); + } +} diff --git a/lib/std/Thread/RwLock.zig b/lib/std/Thread/RwLock.zig new file mode 100644 index 0000000000..1d606a9cf1 --- /dev/null +++ b/lib/std/Thread/RwLock.zig @@ -0,0 +1,308 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! A lock that supports one writer or many readers. +//! This API is for kernel threads, not evented I/O. +//! This API requires being initialized at runtime, and initialization +//! can fail. Once initialized, the core operations cannot fail. + +impl: Impl, + +const RwLock = @This(); +const std = @import("../std.zig"); +const builtin = std.builtin; +const assert = std.debug.assert; +const Mutex = std.Thread.Mutex; +const Semaphore = std.Semaphore; +const CondVar = std.CondVar; + +pub const Impl = if (builtin.single_threaded) + SingleThreadedRwLock +else if (std.Thread.use_pthreads) + PthreadRwLock +else + DefaultRwLock; + +pub fn init(rwl: *RwLock) void { + return rwl.impl.init(); +} + +pub fn deinit(rwl: *RwLock) void { + return rwl.impl.deinit(); +} + +/// Attempts to obtain exclusive lock ownership. +/// Returns `true` if the lock is obtained, `false` otherwise. +pub fn tryLock(rwl: *RwLock) bool { + return rwl.impl.tryLock(); +} + +/// Blocks until exclusive lock ownership is acquired. +pub fn lock(rwl: *RwLock) void { + return rwl.impl.lock(); +} + +/// Releases a held exclusive lock. +/// Asserts the lock is held exclusively. +pub fn unlock(rwl: *RwLock) void { + return rwl.impl.unlock(); +} + +/// Attempts to obtain shared lock ownership. +/// Returns `true` if the lock is obtained, `false` otherwise. +pub fn tryLockShared(rwl: *RwLock) bool { + return rwl.impl.tryLockShared(); +} + +/// Blocks until shared lock ownership is acquired. +pub fn lockShared(rwl: *RwLock) void { + return rwl.impl.lockShared(); +} + +/// Releases a held shared lock. +pub fn unlockShared(rwl: *RwLock) void { + return rwl.impl.unlockShared(); +} + +/// Single-threaded applications use this for deadlock checks in +/// debug mode, and no-ops in release modes. +pub const SingleThreadedRwLock = struct { + state: enum { unlocked, locked_exclusive, locked_shared }, + shared_count: usize, + + pub fn init(rwl: *SingleThreadedRwLock) void { + rwl.* = .{ + .state = .unlocked, + .shared_count = 0, + }; + } + + pub fn deinit(rwl: *SingleThreadedRwLock) void { + assert(rwl.state == .unlocked); + assert(rwl.shared_count == 0); + } + + /// Attempts to obtain exclusive lock ownership. + /// Returns `true` if the lock is obtained, `false` otherwise. + pub fn tryLock(rwl: *SingleThreadedRwLock) bool { + switch (rwl.state) { + .unlocked => { + assert(rwl.shared_count == 0); + rwl.state = .locked_exclusive; + return true; + }, + .locked_exclusive, .locked_shared => return false, + } + } + + /// Blocks until exclusive lock ownership is acquired. + pub fn lock(rwl: *SingleThreadedRwLock) void { + assert(rwl.state == .unlocked); // deadlock detected + assert(rwl.shared_count == 0); // corrupted state detected + rwl.state = .locked_exclusive; + } + + /// Releases a held exclusive lock. + /// Asserts the lock is held exclusively. + pub fn unlock(rwl: *SingleThreadedRwLock) void { + assert(rwl.state == .locked_exclusive); + assert(rwl.shared_count == 0); // corrupted state detected + rwl.state = .unlocked; + } + + /// Attempts to obtain shared lock ownership. + /// Returns `true` if the lock is obtained, `false` otherwise. + pub fn tryLockShared(rwl: *SingleThreadedRwLock) bool { + switch (rwl.state) { + .unlocked => { + rwl.state = .locked_shared; + assert(rwl.shared_count == 0); + rwl.shared_count = 1; + return true; + }, + .locked_exclusive, .locked_shared => return false, + } + } + + /// Blocks until shared lock ownership is acquired. + pub fn lockShared(rwl: *SingleThreadedRwLock) void { + switch (rwl.state) { + .unlocked => { + rwl.state = .locked_shared; + assert(rwl.shared_count == 0); + rwl.shared_count = 1; + }, + .locked_shared => { + rwl.shared_count += 1; + }, + .locked_exclusive => unreachable, // deadlock detected + } + } + + /// Releases a held shared lock. + pub fn unlockShared(rwl: *SingleThreadedRwLock) void { + switch (rwl.state) { + .unlocked => unreachable, // too many calls to `unlockShared` + .locked_exclusive => unreachable, // exclusively held lock + .locked_shared => { + rwl.shared_count -= 1; + if (rwl.shared_count == 0) { + rwl.state = .unlocked; + } + }, + } + } +}; + +pub const PthreadRwLock = struct { + rwlock: pthread_rwlock_t, + + pub fn init(rwl: *PthreadRwLock) void { + rwl.* = .{ .rwlock = .{} }; + } + + pub fn deinit(rwl: *PthreadRwLock) void { + const safe_rc = switch (std.builtin.os.tag) { + .dragonfly, .netbsd => std.os.EAGAIN, + else => 0, + }; + + const rc = std.c.pthread_rwlock_destroy(&rwl.rwlock); + assert(rc == 0 or rc == safe_rc); + + rwl.* = undefined; + } + + pub fn tryLock(rwl: *PthreadRwLock) bool { + return pthread_rwlock_trywrlock(&rwl.rwlock) == 0; + } + + pub fn lock(rwl: *PthreadRwLock) void { + const rc = pthread_rwlock_wrlock(&rwl.rwlock); + assert(rc == 0); + } + + pub fn unlock(rwl: *PthreadRwLock) void { + const rc = pthread_rwlock_unlock(&rwl.rwlock); + assert(rc == 0); + } + + pub fn tryLockShared(rwl: *PthreadRwLock) bool { + return pthread_rwlock_tryrdlock(&rwl.rwlock) == 0; + } + + pub fn lockShared(rwl: *PthreadRwLock) void { + const rc = pthread_rwlock_rdlock(&rwl.rwlock); + assert(rc == 0); + } + + pub fn unlockShared(rwl: *PthreadRwLock) void { + const rc = pthread_rwlock_unlock(&rwl.rwlock); + assert(rc == 0); + } +}; + +pub const DefaultRwLock = struct { + state: usize, + mutex: Mutex, + semaphore: Semaphore, + + const IS_WRITING: usize = 1; + const WRITER: usize = 1 << 1; + const READER: usize = 1 << (1 + std.meta.bitCount(Count)); + const WRITER_MASK: usize = std.math.maxInt(Count) << @ctz(usize, WRITER); + const READER_MASK: usize = std.math.maxInt(Count) << @ctz(usize, READER); + const Count = std.meta.Int(.unsigned, @divFloor(std.meta.bitCount(usize) - 1, 2)); + + pub fn init(rwl: *DefaultRwLock) void { + rwl.* = .{ + .state = 0, + .mutex = Mutex.init(), + .semaphore = Semaphore.init(0), + }; + } + + pub fn deinit(rwl: *DefaultRwLock) void { + rwl.semaphore.deinit(); + rwl.mutex.deinit(); + rwl.* = undefined; + } + + pub fn tryLock(rwl: *DefaultRwLock) bool { + if (rwl.mutex.tryLock()) { + const state = @atomicLoad(usize, &rwl.state, .SeqCst); + if (state & READER_MASK == 0) { + _ = @atomicRmw(usize, &rwl.state, .Or, IS_WRITING, .SeqCst); + return true; + } + + rwl.mutex.unlock(); + } + + return false; + } + + pub fn lock(rwl: *DefaultRwLock) void { + _ = @atomicRmw(usize, &rwl.state, .Add, WRITER, .SeqCst); + rwl.mutex.lock(); + + const state = @atomicRmw(usize, &rwl.state, .Or, IS_WRITING, .SeqCst); + if (state & READER_MASK != 0) + rwl.semaphore.wait(); + } + + pub fn unlock(rwl: *DefaultRwLock) void { + _ = @atomicRmw(usize, &rwl.state, .And, ~IS_WRITING, .SeqCst); + rwl.mutex.unlock(); + } + + pub fn tryLockShared(rwl: *DefaultRwLock) bool { + const state = @atomicLoad(usize, &rwl.state, .SeqCst); + if (state & (IS_WRITING | WRITER_MASK) == 0) { + _ = @cmpxchgStrong( + usize, + &rwl.state, + state, + state + READER, + .SeqCst, + .SeqCst, + ) orelse return true; + } + + if (rwl.mutex.tryLock()) { + _ = @atomicRmw(usize, &rwl.state, .Add, READER, .SeqCst); + rwl.mutex.unlock(); + return true; + } + + return false; + } + + pub fn lockShared(rwl: *DefaultRwLock) void { + var state = @atomicLoad(usize, &rwl.state, .SeqCst); + while (state & (IS_WRITING | WRITER_MASK) == 0) { + state = @cmpxchgWeak( + usize, + &rwl.state, + state, + state + READER, + .SeqCst, + .SeqCst, + ) orelse return; + } + + rwl.mutex.lock(); + _ = @atomicRmw(usize, &rwl.state, .Add, READER, .SeqCst); + rwl.mutex.unlock(); + } + + pub fn unlockShared(rwl: *DefaultRwLock) void { + const state = @atomicRmw(usize, &rwl.state, .Sub, READER, .SeqCst); + + if ((state & READER_MASK == READER) and (state & IS_WRITING != 0)) + rwl.semaphore.post(); + } +}; diff --git a/lib/std/Thread/Semaphore.zig b/lib/std/Thread/Semaphore.zig new file mode 100644 index 0000000000..169975b362 --- /dev/null +++ b/lib/std/Thread/Semaphore.zig @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! A semaphore is an unsigned integer that blocks the kernel thread if +//! the number would become negative. +//! This API supports static initialization and does not require deinitialization. + +mutex: Mutex = .{}, +cond: Condition = .{}, +/// It is OK to initialize this field to any value. +permits: usize = 0, + +const Semaphore = @This(); +const std = @import("../std.zig"); +const Mutex = std.Thread.Mutex; +const Condition = std.Thread.Condition; + +pub fn wait(sem: *Semaphore) void { + const held = sem.mutex.acquire(); + defer held.release(); + + while (sem.permits == 0) + sem.cond.wait(&sem.mutex); + + sem.permits -= 1; + if (sem.permits > 0) + sem.cond.signal(); +} + +pub fn post(sem: *Semaphore) void { + const held = sem.mutex.acquire(); + defer held.release(); + + sem.permits += 1; + sem.cond.signal(); +} diff --git a/lib/std/reset_event.zig b/lib/std/Thread/StaticResetEvent.zig similarity index 52% rename from lib/std/reset_event.zig rename to lib/std/Thread/StaticResetEvent.zig index 5da53985c6..6d90d7cf9a 100644 --- a/lib/std/reset_event.zig +++ b/lib/std/Thread/StaticResetEvent.zig @@ -1,245 +1,188 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -const std = @import("std.zig"); -const builtin = @import("builtin"); -const testing = std.testing; -const SpinLock = std.SpinLock; + +//! A thread-safe resource which supports blocking until signaled. +//! This API is for kernel threads, not evented I/O. +//! This API is statically initializable. It cannot fail to be initialized +//! and it requires no deinitialization. The downside is that it may not +//! integrate as cleanly into other synchronization APIs, or, in a worst case, +//! may be forced to fall back on spin locking. As a rule of thumb, prefer +//! to use `std.Thread.ResetEvent` when possible, and use `StaticResetEvent` when +//! the logic needs stronger API guarantees. + +const std = @import("../std.zig"); +const StaticResetEvent = @This(); const assert = std.debug.assert; -const c = std.c; const os = std.os; const time = std.time; -const linux = os.linux; -const windows = os.windows; +const linux = std.os.linux; +const windows = std.os.windows; +const testing = std.testing; -/// A resource object which supports blocking until signaled. -/// Once finished, the `deinit()` method should be called for correctness. -pub const ResetEvent = struct { - os_event: OsEvent, +impl: Impl = .{}, - pub const OsEvent = if (builtin.single_threaded) - DebugEvent - else if (builtin.link_libc and builtin.os.tag != .windows and builtin.os.tag != .linux) - PosixEvent - else - AtomicEvent; +pub const Impl = if (std.builtin.single_threaded) + DebugEvent +else + AtomicEvent; - pub fn init() ResetEvent { - return ResetEvent{ .os_event = OsEvent.init() }; +/// Sets the event if not already set and wakes up all the threads waiting on +/// the event. It is safe to call `set` multiple times before calling `wait`. +/// However it is illegal to call `set` after `wait` is called until the event +/// is `reset`. This function is thread-safe. +pub fn set(ev: *StaticResetEvent) void { + return ev.impl.set(); +} + +/// Wait for the event to be set by blocking the current thread. +/// Thread-safe. No spurious wakeups. +/// Upon return from `wait`, the only function available to be called +/// in `StaticResetEvent` is `reset`. +pub fn wait(ev: *StaticResetEvent) void { + return ev.impl.wait(); +} + +/// Resets the event to its original, unset state. +/// This function is *not* thread-safe. It is equivalent to calling +/// `deinit` followed by `init` but without the possibility of failure. +pub fn reset(ev: *StaticResetEvent) void { + return ev.impl.reset(); +} + +pub const TimedWaitResult = std.Thread.ResetEvent.TimedWaitResult; + +/// Wait for the event to be set by blocking the current thread. +/// A timeout in nanoseconds can be provided as a hint for how +/// long the thread should block on the unset event before returning +/// `TimedWaitResult.timed_out`. +/// Thread-safe. No precision of timing is guaranteed. +/// Upon return from `timedWait`, the only function available to be called +/// in `StaticResetEvent` is `reset`. +pub fn timedWait(ev: *StaticResetEvent, timeout_ns: u64) TimedWaitResult { + return ev.impl.timedWait(timeout_ns); +} + +/// For single-threaded builds, we use this to detect deadlocks. +/// In unsafe modes this ends up being no-ops. +pub const DebugEvent = struct { + state: State = State.unset, + + const State = enum { + unset, + set, + waited, + }; + + /// This function is provided so that this type can be re-used inside + /// `std.Thread.ResetEvent`. + pub fn init(ev: *DebugEvent) void { + ev.* = .{}; } - pub fn deinit(self: *ResetEvent) void { - self.os_event.deinit(); + /// This function is provided so that this type can be re-used inside + /// `std.Thread.ResetEvent`. + pub fn deinit(ev: *DebugEvent) void { + ev.* = undefined; } - /// Returns whether or not the event is currenetly set - pub fn isSet(self: *ResetEvent) bool { - return self.os_event.isSet(); - } - - /// Sets the event if not already set and - /// wakes up all the threads waiting on the event. - pub fn set(self: *ResetEvent) void { - return self.os_event.set(); - } - - /// Resets the event to its original, unset state. - pub fn reset(self: *ResetEvent) void { - return self.os_event.reset(); - } - - /// Wait for the event to be set by blocking the current thread. - pub fn wait(self: *ResetEvent) void { - return self.os_event.wait(null) catch unreachable; - } - - /// Wait for the event to be set by blocking the current thread. - /// A timeout in nanoseconds can be provided as a hint for how - /// long the thread should block on the unset event before throwing error.TimedOut. - pub fn timedWait(self: *ResetEvent, timeout_ns: u64) !void { - return self.os_event.wait(timeout_ns); - } -}; - -const DebugEvent = struct { - is_set: bool, - - fn init() DebugEvent { - return DebugEvent{ .is_set = false }; - } - - fn deinit(self: *DebugEvent) void { - self.* = undefined; - } - - fn isSet(self: *DebugEvent) bool { - return self.is_set; - } - - fn reset(self: *DebugEvent) void { - self.is_set = false; - } - - fn set(self: *DebugEvent) void { - self.is_set = true; - } - - fn wait(self: *DebugEvent, timeout: ?u64) !void { - if (self.is_set) - return; - if (timeout != null) - return error.TimedOut; - @panic("deadlock detected"); - } -}; - -const PosixEvent = struct { - is_set: bool, - cond: c.pthread_cond_t, - mutex: c.pthread_mutex_t, - - fn init() PosixEvent { - return PosixEvent{ - .is_set = false, - .cond = c.PTHREAD_COND_INITIALIZER, - .mutex = c.PTHREAD_MUTEX_INITIALIZER, - }; - } - - fn deinit(self: *PosixEvent) void { - // on dragonfly or openbsd, *destroy() functions can return EINVAL - // for statically initialized pthread structures - const err = if (builtin.os.tag == .dragonfly or builtin.os.tag == .openbsd) - os.EINVAL - else - 0; - - const retm = c.pthread_mutex_destroy(&self.mutex); - assert(retm == 0 or retm == err); - const retc = c.pthread_cond_destroy(&self.cond); - assert(retc == 0 or retc == err); - } - - fn isSet(self: *PosixEvent) bool { - assert(c.pthread_mutex_lock(&self.mutex) == 0); - defer assert(c.pthread_mutex_unlock(&self.mutex) == 0); - - return self.is_set; - } - - fn reset(self: *PosixEvent) void { - assert(c.pthread_mutex_lock(&self.mutex) == 0); - defer assert(c.pthread_mutex_unlock(&self.mutex) == 0); - - self.is_set = false; - } - - fn set(self: *PosixEvent) void { - assert(c.pthread_mutex_lock(&self.mutex) == 0); - defer assert(c.pthread_mutex_unlock(&self.mutex) == 0); - - if (!self.is_set) { - self.is_set = true; - assert(c.pthread_cond_broadcast(&self.cond) == 0); + pub fn set(ev: *DebugEvent) void { + switch (ev.state) { + .unset => ev.state = .set, + .set => {}, + .waited => unreachable, // Not allowed to call `set` until `reset`. } } - fn wait(self: *PosixEvent, timeout: ?u64) !void { - assert(c.pthread_mutex_lock(&self.mutex) == 0); - defer assert(c.pthread_mutex_unlock(&self.mutex) == 0); - - // quick guard before possibly calling time syscalls below - if (self.is_set) - return; - - var ts: os.timespec = undefined; - if (timeout) |timeout_ns| { - var timeout_abs = timeout_ns; - if (comptime std.Target.current.isDarwin()) { - var tv: os.darwin.timeval = undefined; - assert(os.darwin.gettimeofday(&tv, null) == 0); - timeout_abs += @intCast(u64, tv.tv_sec) * time.ns_per_s; - timeout_abs += @intCast(u64, tv.tv_usec) * time.ns_per_us; - } else { - os.clock_gettime(os.CLOCK_REALTIME, &ts) catch unreachable; - timeout_abs += @intCast(u64, ts.tv_sec) * time.ns_per_s; - timeout_abs += @intCast(u64, ts.tv_nsec); - } - ts.tv_sec = @intCast(@TypeOf(ts.tv_sec), @divFloor(timeout_abs, time.ns_per_s)); - ts.tv_nsec = @intCast(@TypeOf(ts.tv_nsec), @mod(timeout_abs, time.ns_per_s)); + pub fn wait(ev: *DebugEvent) void { + switch (ev.state) { + .unset => unreachable, // Deadlock detected. + .set => return, + .waited => unreachable, // Not allowed to call `wait` until `reset`. } + } - while (!self.is_set) { - const rc = switch (timeout == null) { - true => c.pthread_cond_wait(&self.cond, &self.mutex), - else => c.pthread_cond_timedwait(&self.cond, &self.mutex, &ts), - }; - switch (rc) { - 0 => {}, - os.ETIMEDOUT => return error.TimedOut, - os.EINVAL => unreachable, - os.EPERM => unreachable, - else => unreachable, - } + pub fn timedWait(ev: *DebugEvent, timeout: u64) TimedWaitResult { + switch (ev.state) { + .unset => return .timed_out, + .set => return .event_set, + .waited => unreachable, // Not allowed to call `wait` until `reset`. } } + + pub fn reset(ev: *DebugEvent) void { + ev.state = .unset; + } }; -const AtomicEvent = struct { - waiters: u32, +pub const AtomicEvent = struct { + waiters: u32 = 0, const WAKE = 1 << 0; const WAIT = 1 << 1; - fn init() AtomicEvent { - return AtomicEvent{ .waiters = 0 }; + /// This function is provided so that this type can be re-used inside + /// `std.Thread.ResetEvent`. + pub fn init(ev: *AtomicEvent) void { + ev.* = .{}; } - fn deinit(self: *AtomicEvent) void { - self.* = undefined; + /// This function is provided so that this type can be re-used inside + /// `std.Thread.ResetEvent`. + pub fn deinit(ev: *AtomicEvent) void { + ev.* = undefined; } - fn isSet(self: *const AtomicEvent) bool { - return @atomicLoad(u32, &self.waiters, .Acquire) == WAKE; - } - - fn reset(self: *AtomicEvent) void { - @atomicStore(u32, &self.waiters, 0, .Monotonic); - } - - fn set(self: *AtomicEvent) void { - const waiters = @atomicRmw(u32, &self.waiters, .Xchg, WAKE, .Release); + pub fn set(ev: *AtomicEvent) void { + const waiters = @atomicRmw(u32, &ev.waiters, .Xchg, WAKE, .Release); if (waiters >= WAIT) { - return Futex.wake(&self.waiters, waiters >> 1); + return Futex.wake(&ev.waiters, waiters >> 1); } } - fn wait(self: *AtomicEvent, timeout: ?u64) !void { - var waiters = @atomicLoad(u32, &self.waiters, .Acquire); + pub fn wait(ev: *AtomicEvent) void { + switch (ev.timedWait(null)) { + .timed_out => unreachable, + .event_set => return, + } + } + + pub fn timedWait(ev: *AtomicEvent, timeout: ?u64) TimedWaitResult { + var waiters = @atomicLoad(u32, &ev.waiters, .Acquire); while (waiters != WAKE) { - waiters = @cmpxchgWeak(u32, &self.waiters, waiters, waiters + WAIT, .Acquire, .Acquire) orelse return Futex.wait(&self.waiters, timeout); + waiters = @cmpxchgWeak(u32, &ev.waiters, waiters, waiters + WAIT, .Acquire, .Acquire) orelse { + if (Futex.wait(&ev.waiters, timeout)) |_| { + return .event_set; + } else |_| { + return .timed_out; + } + }; } + return .event_set; } - pub const Futex = switch (builtin.os.tag) { + pub fn reset(ev: *AtomicEvent) void { + @atomicStore(u32, &ev.waiters, 0, .Monotonic); + } + + pub const Futex = switch (std.Target.current.os.tag) { .windows => WindowsFutex, .linux => LinuxFutex, else => SpinFutex, }; - const SpinFutex = struct { + pub const SpinFutex = struct { fn wake(waiters: *u32, wake_count: u32) void {} fn wait(waiters: *u32, timeout: ?u64) !void { - // TODO: handle platforms where a monotonic timer isnt available var timer: time.Timer = undefined; if (timeout != null) - timer = time.Timer.start() catch unreachable; + timer = time.Timer.start() catch return error.TimedOut; while (@atomicLoad(u32, waiters, .Acquire) != WAKE) { - SpinLock.yield(); + std.os.sched_yield() catch std.Thread.spinLoopHint(); if (timeout) |timeout_ns| { if (timer.read() >= timeout_ns) return error.TimedOut; @@ -248,7 +191,7 @@ const AtomicEvent = struct { } }; - const LinuxFutex = struct { + pub const LinuxFutex = struct { fn wake(waiters: *u32, wake_count: u32) void { const waiting = std.math.maxInt(i32); // wake_count const ptr = @ptrCast(*const i32, waiters); @@ -283,7 +226,7 @@ const AtomicEvent = struct { } }; - const WindowsFutex = struct { + pub const WindowsFutex = struct { pub fn wake(waiters: *u32, wake_count: u32) void { const handle = getEventHandle() orelse return SpinFutex.wake(waiters, wake_count); const key = @ptrCast(*const c_void, waiters); @@ -350,7 +293,7 @@ const AtomicEvent = struct { return @intToPtr(?windows.HANDLE, handle); }, LOADING => { - SpinLock.yield(); + std.os.sched_yield() catch std.Thread.spinLoopHint(); handle = @atomicLoad(usize, &event_handle, .Monotonic); }, else => { @@ -362,48 +305,33 @@ const AtomicEvent = struct { }; }; -test "ResetEvent" { - var event = ResetEvent.init(); - defer event.deinit(); +test "basic usage" { + var event = StaticResetEvent{}; // test event setting - testing.expect(event.isSet() == false); event.set(); - testing.expect(event.isSet() == true); // test event resetting event.reset(); - testing.expect(event.isSet() == false); // test event waiting (non-blocking) event.set(); event.wait(); - try event.timedWait(1); + event.reset(); + + event.set(); + testing.expectEqual(TimedWaitResult.event_set, event.timedWait(1)); // test cross-thread signaling - if (builtin.single_threaded) + if (std.builtin.single_threaded) return; const Context = struct { const Self = @This(); - value: u128, - in: ResetEvent, - out: ResetEvent, - - fn init() Self { - return Self{ - .value = 0, - .in = ResetEvent.init(), - .out = ResetEvent.init(), - }; - } - - fn deinit(self: *Self) void { - self.in.deinit(); - self.out.deinit(); - self.* = undefined; - } + value: u128 = 0, + in: StaticResetEvent = .{}, + out: StaticResetEvent = .{}, fn sender(self: *Self) void { // update value and signal input @@ -444,14 +372,13 @@ test "ResetEvent" { fn timedWaiter(self: *Self) !void { self.in.wait(); - testing.expectError(error.TimedOut, self.out.timedWait(time.ns_per_us)); + testing.expectEqual(TimedWaitResult.timed_out, self.out.timedWait(time.ns_per_us)); try self.out.timedWait(time.ns_per_ms * 100); testing.expect(self.value == 5); } }; - var context = Context.init(); - defer context.deinit(); + var context = Context{}; const receiver = try std.Thread.spawn(&context, Context.receiver); defer receiver.wait(); context.sender(); diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index e5ad26cb45..7b0d9ea4dd 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -99,6 +99,16 @@ pub fn ArrayHashMap( }; } + /// `ArrayHashMap` takes ownership of the passed in array list. The array list must have + /// been allocated with `allocator`. + /// Deinitialize with `deinit`. + pub fn fromOwnedArrayList(allocator: *Allocator, entries: std.ArrayListUnmanaged(Entry)) !Self { + return Self{ + .unmanaged = try Unmanaged.fromOwnedArrayList(allocator, entries), + .allocator = allocator, + }; + } + pub fn deinit(self: *Self) void { self.unmanaged.deinit(self.allocator); self.* = undefined; @@ -214,17 +224,38 @@ pub fn ArrayHashMap( } /// If there is an `Entry` with a matching key, it is deleted from - /// the hash map, and then returned from this function. - pub fn remove(self: *Self, key: K) ?Entry { - return self.unmanaged.remove(key); + /// the hash map, and then returned from this function. The entry is + /// removed from the underlying array by swapping it with the last + /// element. + pub fn swapRemove(self: *Self, key: K) ?Entry { + return self.unmanaged.swapRemove(key); } - /// Asserts there is an `Entry` with matching key, deletes it from the hash map, - /// and discards it. + /// If there is an `Entry` with a matching key, it is deleted from + /// the hash map, and then returned from this function. The entry is + /// removed from the underlying array by shifting all elements forward + /// thereby maintaining the current ordering. + pub fn orderedRemove(self: *Self, key: K) ?Entry { + return self.unmanaged.orderedRemove(key); + } + + /// TODO: deprecated: call swapRemoveAssertDiscard instead. pub fn removeAssertDiscard(self: *Self, key: K) void { return self.unmanaged.removeAssertDiscard(key); } + /// Asserts there is an `Entry` with matching key, deletes it from the hash map + /// by swapping it with the last element, and discards it. + pub fn swapRemoveAssertDiscard(self: *Self, key: K) void { + return self.unmanaged.swapRemoveAssertDiscard(key); + } + + /// Asserts there is an `Entry` with matching key, deletes it from the hash map + /// by by shifting all elements forward thereby maintaining the current ordering. + pub fn orderedRemoveAssertDiscard(self: *Self, key: K) void { + return self.unmanaged.orderedRemoveAssertDiscard(key); + } + pub fn items(self: Self) []Entry { return self.unmanaged.items(); } @@ -233,6 +264,29 @@ pub fn ArrayHashMap( var other = try self.unmanaged.clone(self.allocator); return other.promote(self.allocator); } + + /// Rebuilds the key indexes. If the underlying entries has been modified directly, users + /// can call `reIndex` to update the indexes to account for these new entries. + pub fn reIndex(self: *Self) !void { + return self.unmanaged.reIndex(self.allocator); + } + + /// Shrinks the underlying `Entry` array to `new_len` elements and discards any associated + /// index entries. Keeps capacity the same. + pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void { + return self.unmanaged.shrinkRetainingCapacity(new_len); + } + + /// Shrinks the underlying `Entry` array to `new_len` elements and discards any associated + /// index entries. Reduces allocated capacity. + pub fn shrinkAndFree(self: *Self, new_len: usize) void { + return self.unmanaged.shrinkAndFree(self.allocator, new_len); + } + + /// Removes the last inserted `Entry` in the hash map and returns it. + pub fn pop(self: *Self) Entry { + return self.unmanaged.pop(); + } }; } @@ -286,6 +340,7 @@ pub fn ArrayHashMapUnmanaged( pub const GetOrPutResult = struct { entry: *Entry, found_existing: bool, + index: usize, }; pub const Managed = ArrayHashMap(K, V, hash, eql, store_hash); @@ -294,6 +349,12 @@ pub fn ArrayHashMapUnmanaged( const linear_scan_max = 8; + const RemovalType = enum { + swap, + ordered, + index_only, + }; + pub fn promote(self: Self, allocator: *Allocator) Managed { return .{ .unmanaged = self, @@ -301,6 +362,15 @@ pub fn ArrayHashMapUnmanaged( }; } + /// `ArrayHashMapUnmanaged` takes ownership of the passed in array list. The array list must + /// have been allocated with `allocator`. + /// Deinitialize with `deinit`. + pub fn fromOwnedArrayList(allocator: *Allocator, entries: std.ArrayListUnmanaged(Entry)) !Self { + var array_hash_map = Self{ .entries = entries }; + try array_hash_map.reIndex(allocator); + return array_hash_map; + } + pub fn deinit(self: *Self, allocator: *Allocator) void { self.entries.deinit(allocator); if (self.index_header) |header| { @@ -323,7 +393,7 @@ pub fn ArrayHashMapUnmanaged( } pub fn clearAndFree(self: *Self, allocator: *Allocator) void { - self.entries.shrink(allocator, 0); + self.entries.shrinkAndFree(allocator, 0); if (self.index_header) |header| { header.free(allocator); self.index_header = null; @@ -343,9 +413,11 @@ pub fn ArrayHashMapUnmanaged( pub fn getOrPut(self: *Self, allocator: *Allocator, key: K) !GetOrPutResult { self.ensureCapacity(allocator, self.entries.items.len + 1) catch |err| { // "If key exists this function cannot fail." + const index = self.getIndex(key) orelse return err; return GetOrPutResult{ - .entry = self.getEntry(key) orelse return err, + .entry = &self.entries.items[index], .found_existing = true, + .index = index, }; }; return self.getOrPutAssumeCapacity(key); @@ -362,11 +434,12 @@ pub fn ArrayHashMapUnmanaged( const header = self.index_header orelse { // Linear scan. const h = if (store_hash) hash(key) else {}; - for (self.entries.items) |*item| { + for (self.entries.items) |*item, i| { if (item.hash == h and eql(key, item.key)) { return GetOrPutResult{ .entry = item, .found_existing = true, + .index = i, }; } } @@ -379,6 +452,7 @@ pub fn ArrayHashMapUnmanaged( return GetOrPutResult{ .entry = new_entry, .found_existing = false, + .index = self.entries.items.len - 1, }; }; @@ -524,30 +598,36 @@ pub fn ArrayHashMapUnmanaged( } /// If there is an `Entry` with a matching key, it is deleted from - /// the hash map, and then returned from this function. - pub fn remove(self: *Self, key: K) ?Entry { - const header = self.index_header orelse { - // Linear scan. - const h = if (store_hash) hash(key) else {}; - for (self.entries.items) |item, i| { - if (item.hash == h and eql(key, item.key)) { - return self.entries.swapRemove(i); - } - } - return null; - }; - switch (header.capacityIndexType()) { - .u8 => return self.removeInternal(key, header, u8), - .u16 => return self.removeInternal(key, header, u16), - .u32 => return self.removeInternal(key, header, u32), - .usize => return self.removeInternal(key, header, usize), - } + /// the hash map, and then returned from this function. The entry is + /// removed from the underlying array by swapping it with the last + /// element. + pub fn swapRemove(self: *Self, key: K) ?Entry { + return self.removeInternal(key, .swap); } - /// Asserts there is an `Entry` with matching key, deletes it from the hash map, - /// and discards it. + /// If there is an `Entry` with a matching key, it is deleted from + /// the hash map, and then returned from this function. The entry is + /// removed from the underlying array by shifting all elements forward + /// thereby maintaining the current ordering. + pub fn orderedRemove(self: *Self, key: K) ?Entry { + return self.removeInternal(key, .ordered); + } + + /// TODO deprecated: call swapRemoveAssertDiscard instead. pub fn removeAssertDiscard(self: *Self, key: K) void { - assert(self.remove(key) != null); + return self.swapRemoveAssertDiscard(key); + } + + /// Asserts there is an `Entry` with matching key, deletes it from the hash map + /// by swapping it with the last element, and discards it. + pub fn swapRemoveAssertDiscard(self: *Self, key: K) void { + assert(self.swapRemove(key) != null); + } + + /// Asserts there is an `Entry` with matching key, deletes it from the hash map + /// by by shifting all elements forward thereby maintaining the current ordering. + pub fn orderedRemoveAssertDiscard(self: *Self, key: K) void { + assert(self.orderedRemove(key) != null); } pub fn items(self: Self) []Entry { @@ -566,9 +646,85 @@ pub fn ArrayHashMapUnmanaged( return other; } - fn removeInternal(self: *Self, key: K, header: *IndexHeader, comptime I: type) ?Entry { + /// Rebuilds the key indexes. If the underlying entries has been modified directly, users + /// can call `reIndex` to update the indexes to account for these new entries. + pub fn reIndex(self: *Self, allocator: *Allocator) !void { + if (self.entries.capacity <= linear_scan_max) return; + // We're going to rebuild the index header and replace the existing one (if any). The + // indexes should sized such that they will be at most 60% full. + const needed_len = self.entries.capacity * 5 / 3; + const new_indexes_len = math.ceilPowerOfTwo(usize, needed_len) catch unreachable; + const new_header = try IndexHeader.alloc(allocator, new_indexes_len); + self.insertAllEntriesIntoNewHeader(new_header); + if (self.index_header) |header| + header.free(allocator); + self.index_header = new_header; + } + + /// Shrinks the underlying `Entry` array to `new_len` elements and discards any associated + /// index entries. Keeps capacity the same. + pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void { + // Remove index entries from the new length onwards. + // Explicitly choose to ONLY remove index entries and not the underlying array list + // entries as we're going to remove them in the subsequent shrink call. + var i: usize = new_len; + while (i < self.entries.items.len) : (i += 1) + _ = self.removeWithHash(self.entries.items[i].key, self.entries.items[i].hash, .index_only); + self.entries.shrinkRetainingCapacity(new_len); + } + + /// Shrinks the underlying `Entry` array to `new_len` elements and discards any associated + /// index entries. Reduces allocated capacity. + pub fn shrinkAndFree(self: *Self, allocator: *Allocator, new_len: usize) void { + // Remove index entries from the new length onwards. + // Explicitly choose to ONLY remove index entries and not the underlying array list + // entries as we're going to remove them in the subsequent shrink call. + var i: usize = new_len; + while (i < self.entries.items.len) : (i += 1) + _ = self.removeWithHash(self.entries.items[i].key, self.entries.items[i].hash, .index_only); + self.entries.shrinkAndFree(allocator, new_len); + } + + /// Removes the last inserted `Entry` in the hash map and returns it. + pub fn pop(self: *Self) Entry { + const top = self.entries.pop(); + _ = self.removeWithHash(top.key, top.hash, .index_only); + return top; + } + + fn removeInternal(self: *Self, key: K, comptime removal_type: RemovalType) ?Entry { + const key_hash = if (store_hash) hash(key) else {}; + return self.removeWithHash(key, key_hash, removal_type); + } + + fn removeWithHash(self: *Self, key: K, key_hash: Hash, comptime removal_type: RemovalType) ?Entry { + const header = self.index_header orelse { + // If we're only removing index entries and we have no index header, there's no need + // to continue. + if (removal_type == .index_only) return null; + // Linear scan. + for (self.entries.items) |item, i| { + if (item.hash == key_hash and eql(key, item.key)) { + switch (removal_type) { + .swap => return self.entries.swapRemove(i), + .ordered => return self.entries.orderedRemove(i), + .index_only => unreachable, + } + } + } + return null; + }; + switch (header.capacityIndexType()) { + .u8 => return self.removeWithIndex(key, key_hash, header, u8, removal_type), + .u16 => return self.removeWithIndex(key, key_hash, header, u16, removal_type), + .u32 => return self.removeWithIndex(key, key_hash, header, u32, removal_type), + .usize => return self.removeWithIndex(key, key_hash, header, usize, removal_type), + } + } + + fn removeWithIndex(self: *Self, key: K, key_hash: Hash, header: *IndexHeader, comptime I: type, comptime removal_type: RemovalType) ?Entry { const indexes = header.indexes(I); - const h = hash(key); + const h = if (store_hash) key_hash else hash(key); const start_index = header.constrainIndex(h); var roll_over: usize = 0; while (roll_over <= header.max_distance_from_start_index) : (roll_over += 1) { @@ -583,11 +739,26 @@ pub fn ArrayHashMapUnmanaged( if (!hash_match or !eql(key, entry.key)) continue; - const removed_entry = self.entries.swapRemove(index.entry_index); - if (self.entries.items.len > 0 and self.entries.items.len != index.entry_index) { - // Because of the swap remove, now we need to update the index that was - // pointing to the last entry and is now pointing to this removed item slot. - self.updateEntryIndex(header, self.entries.items.len, index.entry_index, I, indexes); + var removed_entry: ?Entry = undefined; + switch (removal_type) { + .swap => { + removed_entry = self.entries.swapRemove(index.entry_index); + if (self.entries.items.len > 0 and self.entries.items.len != index.entry_index) { + // Because of the swap remove, now we need to update the index that was + // pointing to the last entry and is now pointing to this removed item slot. + self.updateEntryIndex(header, self.entries.items.len, index.entry_index, I, indexes); + } + }, + .ordered => { + removed_entry = self.entries.orderedRemove(index.entry_index); + var i: usize = index.entry_index; + while (i < self.entries.items.len) : (i += 1) { + // Because of the ordered remove, everything from the entry index onwards has + // been shifted forward so we'll need to update the index entries. + self.updateEntryIndex(header, i + 1, i, I, indexes); + } + }, + .index_only => removed_entry = null, } // Now we have to shift over the following indexes. @@ -658,6 +829,7 @@ pub fn ArrayHashMapUnmanaged( return .{ .found_existing = false, .entry = new_entry, + .index = self.entries.items.len - 1, }; } @@ -669,6 +841,7 @@ pub fn ArrayHashMapUnmanaged( return .{ .found_existing = true, .entry = entry, + .index = index.entry_index, }; } if (index.distance_from_start_index < distance_from_start_index) { @@ -710,6 +883,7 @@ pub fn ArrayHashMapUnmanaged( return .{ .found_existing = false, .entry = new_entry, + .index = self.entries.items.len - 1, }; } if (next_index.distance_from_start_index < distance_from_start_index) { @@ -901,11 +1075,13 @@ test "basic hash map usage" { const gop1 = try map.getOrPut(5); testing.expect(gop1.found_existing == true); testing.expect(gop1.entry.value == 55); + testing.expect(gop1.index == 4); gop1.entry.value = 77; testing.expect(map.getEntry(5).?.value == 77); const gop2 = try map.getOrPut(99); testing.expect(gop2.found_existing == false); + testing.expect(gop2.index == 5); gop2.entry.value = 42; testing.expect(map.getEntry(99).?.value == 42); @@ -919,13 +1095,32 @@ test "basic hash map usage" { testing.expect(map.getEntry(2).?.value == 22); testing.expect(map.get(2).? == 22); - const rmv1 = map.remove(2); + const rmv1 = map.swapRemove(2); testing.expect(rmv1.?.key == 2); testing.expect(rmv1.?.value == 22); - testing.expect(map.remove(2) == null); + testing.expect(map.swapRemove(2) == null); testing.expect(map.getEntry(2) == null); testing.expect(map.get(2) == null); + // Since we've used `swapRemove` above, the index of this entry should remain unchanged. + testing.expect(map.getIndex(100).? == 1); + const gop5 = try map.getOrPut(5); + testing.expect(gop5.found_existing == true); + testing.expect(gop5.entry.value == 77); + testing.expect(gop5.index == 4); + + // Whereas, if we do an `orderedRemove`, it should move the index forward one spot. + const rmv2 = map.orderedRemove(100); + testing.expect(rmv2.?.key == 100); + testing.expect(rmv2.?.value == 41); + testing.expect(map.orderedRemove(100) == null); + testing.expect(map.getEntry(100) == null); + testing.expect(map.get(100) == null); + const gop6 = try map.getOrPut(5); + testing.expect(gop6.found_existing == true); + testing.expect(gop6.entry.value == 77); + testing.expect(gop6.index == 3); + map.removeAssertDiscard(3); } @@ -1019,6 +1214,130 @@ test "clone" { } } +test "shrink" { + var map = AutoArrayHashMap(i32, i32).init(std.testing.allocator); + defer map.deinit(); + + // This test is more interesting if we insert enough entries to allocate the index header. + const num_entries = 20; + var i: i32 = 0; + while (i < num_entries) : (i += 1) + testing.expect((try map.fetchPut(i, i * 10)) == null); + + testing.expect(map.unmanaged.index_header != null); + testing.expect(map.count() == num_entries); + + // Test `shrinkRetainingCapacity`. + map.shrinkRetainingCapacity(17); + testing.expect(map.count() == 17); + testing.expect(map.capacity() == 20); + i = 0; + while (i < num_entries) : (i += 1) { + const gop = try map.getOrPut(i); + if (i < 17) { + testing.expect(gop.found_existing == true); + testing.expect(gop.entry.value == i * 10); + } else testing.expect(gop.found_existing == false); + } + + // Test `shrinkAndFree`. + map.shrinkAndFree(15); + testing.expect(map.count() == 15); + testing.expect(map.capacity() == 15); + i = 0; + while (i < num_entries) : (i += 1) { + const gop = try map.getOrPut(i); + if (i < 15) { + testing.expect(gop.found_existing == true); + testing.expect(gop.entry.value == i * 10); + } else testing.expect(gop.found_existing == false); + } +} + +test "pop" { + var map = AutoArrayHashMap(i32, i32).init(std.testing.allocator); + defer map.deinit(); + + testing.expect((try map.fetchPut(1, 11)) == null); + testing.expect((try map.fetchPut(2, 22)) == null); + testing.expect((try map.fetchPut(3, 33)) == null); + testing.expect((try map.fetchPut(4, 44)) == null); + + const pop1 = map.pop(); + testing.expect(pop1.key == 4 and pop1.value == 44); + const pop2 = map.pop(); + testing.expect(pop2.key == 3 and pop2.value == 33); + const pop3 = map.pop(); + testing.expect(pop3.key == 2 and pop3.value == 22); + const pop4 = map.pop(); + testing.expect(pop4.key == 1 and pop4.value == 11); +} + +test "reIndex" { + var map = AutoArrayHashMap(i32, i32).init(std.testing.allocator); + defer map.deinit(); + + // Populate via the API. + const num_indexed_entries = 20; + var i: i32 = 0; + while (i < num_indexed_entries) : (i += 1) + testing.expect((try map.fetchPut(i, i * 10)) == null); + + // Make sure we allocated an index header. + testing.expect(map.unmanaged.index_header != null); + + // Now write to the underlying array list directly. + const num_unindexed_entries = 20; + const hash = getAutoHashFn(i32); + var al = &map.unmanaged.entries; + while (i < num_indexed_entries + num_unindexed_entries) : (i += 1) { + try al.append(std.testing.allocator, .{ + .key = i, + .value = i * 10, + .hash = hash(i), + }); + } + + // After reindexing, we should see everything. + try map.reIndex(); + i = 0; + while (i < num_indexed_entries + num_unindexed_entries) : (i += 1) { + const gop = try map.getOrPut(i); + testing.expect(gop.found_existing == true); + testing.expect(gop.entry.value == i * 10); + testing.expect(gop.index == i); + } +} + +test "fromOwnedArrayList" { + comptime const array_hash_map_type = AutoArrayHashMap(i32, i32); + var al = std.ArrayListUnmanaged(array_hash_map_type.Entry){}; + const hash = getAutoHashFn(i32); + + // Populate array list. + const num_entries = 20; + var i: i32 = 0; + while (i < num_entries) : (i += 1) { + try al.append(std.testing.allocator, .{ + .key = i, + .value = i * 10, + .hash = hash(i), + }); + } + + // Now instantiate using `fromOwnedArrayList`. + var map = try array_hash_map_type.fromOwnedArrayList(std.testing.allocator, al); + defer map.deinit(); + + i = 0; + while (i < num_entries) : (i += 1) { + const gop = try map.getOrPut(i); + testing.expect(gop.found_existing == true); + testing.expect(gop.entry.value == i * 10); + testing.expect(gop.index == i); + } +} + pub fn getHashPtrAddrFn(comptime K: type) (fn (K) u32) { return struct { fn hash(key: K) u32 { diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig index ab47510cb7..f30a86d8f7 100644 --- a/lib/std/array_list.zig +++ b/lib/std/array_list.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -12,10 +12,20 @@ const Allocator = mem.Allocator; /// A contiguous, growable list of items in memory. /// This is a wrapper around an array of T values. Initialize with `init`. +/// +/// This struct internally stores a `std.mem.Allocator` for memory management. +/// To manually specify an allocator with each method call see `ArrayListUnmanaged`. pub fn ArrayList(comptime T: type) type { return ArrayListAligned(T, null); } +/// A contiguous, growable list of arbitrarily aligned items in memory. +/// This is a wrapper around an array of T values aligned to `alignment`-byte +/// addresses. If the specified alignment is `null`, then `@alignOf(T)` is used. +/// Initialize with `init`. +/// +/// This struct internally stores a `std.mem.Allocator` for memory management. +/// To manually specify an allocator with each method call see `ArrayListAlignedUnmanaged`. pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { if (alignment) |a| { if (a == @alignOf(T)) { @@ -24,9 +34,18 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { } return struct { const Self = @This(); - - /// Content of the ArrayList + /// Contents of the list. Pointers to elements in this slice are + /// **invalid after resizing operations** on the ArrayList, unless the + /// operation explicitly either: (1) states otherwise or (2) lists the + /// invalidated pointers. + /// + /// The allocator used determines how element pointers are + /// invalidated, so the behavior may vary between lists. To avoid + /// illegal behavior, take into account the above paragraph plus the + /// explicit statements given in each method. items: Slice, + /// How many T values this list can hold without allocating + /// additional memory. capacity: usize, allocator: *Allocator, @@ -42,7 +61,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { }; } - /// Initialize with capacity to hold at least num elements. + /// Initialize with capacity to hold at least `num` elements. /// Deinitialize with `deinit` or use `toOwnedSlice`. pub fn initCapacity(allocator: *Allocator, num: usize) !Self { var self = Self.init(allocator); @@ -79,11 +98,23 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { }; } + /// Initializes an ArrayListUnmanaged with the `items` and `capacity` fields + /// of this ArrayList. This ArrayList retains ownership of underlying memory. + /// Deprecated: use `moveToUnmanaged` which has different semantics. pub fn toUnmanaged(self: Self) ArrayListAlignedUnmanaged(T, alignment) { return .{ .items = self.items, .capacity = self.capacity }; } - /// The caller owns the returned memory. ArrayList becomes empty. + /// Initializes an ArrayListUnmanaged with the `items` and `capacity` fields + /// of this ArrayList. Empties this ArrayList. + pub fn moveToUnmanaged(self: *Self) ArrayListAlignedUnmanaged(T, alignment) { + const allocator = self.allocator; + const result = .{ .items = self.items, .capacity = self.capacity }; + self.* = init(allocator); + return result; + } + + /// The caller owns the returned memory. Empties this ArrayList. pub fn toOwnedSlice(self: *Self) Slice { const allocator = self.allocator; const result = allocator.shrink(self.allocatedSlice(), self.items.len); @@ -91,6 +122,13 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { return result; } + /// The caller owns the returned memory. Empties this ArrayList. + pub fn toOwnedSliceSentinel(self: *Self, comptime sentinel: T) ![:sentinel]T { + try self.append(sentinel); + const result = self.toOwnedSlice(); + return result[0 .. result.len - 1 :sentinel]; + } + /// Insert `item` at index `n` by moving `list[n .. list.len]` to make room. /// This operation is O(N). pub fn insert(self: *Self, n: usize, item: T) !void { @@ -111,9 +149,10 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { mem.copy(T, self.items[i .. i + items.len], items); } - /// Replace range of elements `list[start..start+len]` with `new_items` - /// grows list if `len < new_items.len`. may allocate - /// shrinks list if `len > new_items.len` + /// Replace range of elements `list[start..start+len]` with `new_items`. + /// Grows list if `len < new_items.len`. + /// Shrinks list if `len > new_items.len`. + /// Invalidates pointers if this ArrayList is resized. pub fn replaceRange(self: *Self, start: usize, len: usize, new_items: SliceConst) !void { const after_range = start + len; const range = self.items[start..after_range]; @@ -144,15 +183,18 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { new_item_ptr.* = item; } - /// Extend the list by 1 element, but asserting `self.capacity` - /// is sufficient to hold an additional item. + /// Extend the list by 1 element, but assert `self.capacity` + /// is sufficient to hold an additional item. **Does not** + /// invalidate pointers. pub fn appendAssumeCapacity(self: *Self, item: T) void { const new_item_ptr = self.addOneAssumeCapacity(); new_item_ptr.* = item; } - /// Remove the element at index `i` from the list and return its value. + /// Remove the element at index `i`, shift elements after index + /// `i` forward, and return the removed element. /// Asserts the array has at least one item. + /// Invalidates pointers to end of list. /// This operation is O(N). pub fn orderedRemove(self: *Self, i: usize) T { const newlen = self.items.len - 1; @@ -184,7 +226,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { } /// Append the slice of items to the list, asserting the capacity is already - /// enough to store the new items. + /// enough to store the new items. **Does not** invalidate pointers. pub fn appendSliceAssumeCapacity(self: *Self, items: SliceConst) void { const oldlen = self.items.len; const newlen = self.items.len + items.len; @@ -200,9 +242,6 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { return .{ .context = self }; } - /// Deprecated: use `writer` - pub const outStream = writer; - /// Same as `append` except it returns the number of bytes written, which is always the same /// as `m.len`. The purpose of this function existing is to match `std.io.Writer` API. fn appendWrite(self: *Self, m: []const u8) !usize { @@ -220,7 +259,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { } /// Append a value to the list `n` times. - /// Asserts the capacity is enough. + /// Asserts the capacity is enough. **Does not** invalidate pointers. pub fn appendNTimesAssumeCapacity(self: *Self, value: T, n: usize) void { const new_len = self.items.len + n; assert(new_len <= self.capacity); @@ -236,8 +275,8 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { } /// Reduce allocated capacity to `new_len`. - /// Invalidates element pointers. - pub fn shrink(self: *Self, new_len: usize) void { + /// May invalidate element pointers. + pub fn shrinkAndFree(self: *Self, new_len: usize) void { assert(new_len <= self.items.len); self.items = self.allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) { @@ -250,13 +289,14 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { } /// Reduce length to `new_len`. - /// Invalidates element pointers. - /// Keeps capacity the same. + /// Invalidates pointers for the elements `items[new_len..]`. pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void { assert(new_len <= self.items.len); self.items.len = new_len; } + /// Modify the array so that it can hold at least `new_capacity` items. + /// Invalidates pointers if additional memory is needed. pub fn ensureCapacity(self: *Self, new_capacity: usize) !void { var better_capacity = self.capacity; if (better_capacity >= new_capacity) return; @@ -273,14 +313,13 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { } /// Increases the array's length to match the full capacity that is already allocated. - /// The new elements have `undefined` values. This operation does not invalidate any - /// element pointers. + /// The new elements have `undefined` values. **Does not** invalidate pointers. pub fn expandToCapacity(self: *Self) void { self.items.len = self.capacity; } /// Increase length by 1, returning pointer to the new item. - /// The returned pointer becomes invalid when the list is resized. + /// The returned pointer becomes invalid when the list resized. pub fn addOne(self: *Self) !*T { const newlen = self.items.len + 1; try self.ensureCapacity(newlen); @@ -290,6 +329,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { /// Increase length by 1, returning pointer to the new item. /// Asserts that there is already space for the new item without allocating more. /// The returned pointer becomes invalid when the list is resized. + /// **Does not** invalidate element pointers. pub fn addOneAssumeCapacity(self: *Self) *T { assert(self.items.len < self.capacity); @@ -299,6 +339,8 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { /// Resize the array, adding `n` new elements, which have `undefined` values. /// The return value is an array pointing to the newly allocated elements. + /// The returned pointer becomes invalid when the list is resized. + /// Resizes list if `self.capacity` is not large enough. pub fn addManyAsArray(self: *Self, comptime n: usize) !*[n]T { const prev_len = self.items.len; try self.resize(self.items.len + n); @@ -308,6 +350,8 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { /// Resize the array, adding `n` new elements, which have `undefined` values. /// The return value is an array pointing to the newly allocated elements. /// Asserts that there is already space for the new item without allocating more. + /// **Does not** invalidate element pointers. + /// The returned pointer becomes invalid when the list is resized. pub fn addManyAsArrayAssumeCapacity(self: *Self, comptime n: usize) *[n]T { assert(self.items.len + n <= self.capacity); const prev_len = self.items.len; @@ -317,33 +361,51 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { /// Remove and return the last element from the list. /// Asserts the list has at least one item. + /// Invalidates pointers to the removed element. pub fn pop(self: *Self) T { const val = self.items[self.items.len - 1]; self.items.len -= 1; return val; } - /// Remove and return the last element from the list. - /// If the list is empty, returns `null`. + /// Remove and return the last element from the list, or + /// return `null` if list is empty. + /// Invalidates pointers to the removed element, if any. pub fn popOrNull(self: *Self) ?T { if (self.items.len == 0) return null; return self.pop(); } - // For a nicer API, `items.len` is the length, not the capacity. - // This requires "unsafe" slicing. - fn allocatedSlice(self: Self) Slice { + /// Returns a slice of all the items plus the extra capacity, whose memory + /// contents are `undefined`. + pub fn allocatedSlice(self: Self) Slice { + // For a nicer API, `items.len` is the length, not the capacity. + // This requires "unsafe" slicing. return self.items.ptr[0..self.capacity]; } + + /// Returns a slice of only the extra capacity after items. + /// This can be useful for writing directly into an ArrayList. + /// Note that such an operation must be followed up with a direct + /// modification of `self.items.len`. + pub fn unusedCapacitySlice(self: Self) Slice { + return self.allocatedSlice()[self.items.len..]; + } }; } -/// Bring-your-own allocator with every function call. -/// Initialize directly and deinitialize with `deinit` or use `toOwnedSlice`. +/// An ArrayList, but the allocator is passed as a parameter to the relevant functions +/// rather than stored in the struct itself. The same allocator **must** be used throughout +/// the entire lifetime of an ArrayListUnmanaged. Initialize directly or with +/// `initCapacity`, and deinitialize with `deinit` or use `toOwnedSlice`. pub fn ArrayListUnmanaged(comptime T: type) type { return ArrayListAlignedUnmanaged(T, null); } +/// An ArrayListAligned, but the allocator is passed as a parameter to the relevant +/// functions rather than stored in the struct itself. The same allocator **must** +/// be used throughout the entire lifetime of an ArrayListAlignedUnmanaged. +/// Initialize directly or with `initCapacity`, and deinitialize with `deinit` or use `toOwnedSlice`. pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) type { if (alignment) |a| { if (a == @alignOf(T)) { @@ -352,9 +414,18 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ } return struct { const Self = @This(); - - /// Content of the ArrayList. + /// Contents of the list. Pointers to elements in this slice are + /// **invalid after resizing operations** on the ArrayList, unless the + /// operation explicitly either: (1) states otherwise or (2) lists the + /// invalidated pointers. + /// + /// The allocator used determines how element pointers are + /// invalidated, so the behavior may vary between lists. To avoid + /// illegal behavior, take into account the above paragraph plus the + /// explicit statements given in each method. items: Slice = &[_]T{}, + /// How many T values this list can hold without allocating + /// additional memory. capacity: usize = 0, pub const Slice = if (alignment) |a| ([]align(a) T) else []T; @@ -378,6 +449,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ self.* = undefined; } + /// Convert this list into an analogous memory-managed one. + /// The returned list has ownership of the underlying memory. pub fn toManaged(self: *Self, allocator: *Allocator) ArrayListAligned(T, alignment) { return .{ .items = self.items, .capacity = self.capacity, .allocator = allocator }; } @@ -389,8 +462,16 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ return result; } + /// The caller owns the returned memory. ArrayList becomes empty. + pub fn toOwnedSliceSentinel(self: *Self, allocator: *Allocator, comptime sentinel: T) ![:sentinel]T { + try self.append(allocator, sentinel); + const result = self.toOwnedSlice(allocator); + return result[0 .. result.len - 1 :sentinel]; + } + /// Insert `item` at index `n`. Moves `list[n .. list.len]` - /// to make room. + /// to higher indices to make room. + /// This operation is O(N). pub fn insert(self: *Self, allocator: *Allocator, n: usize, item: T) !void { try self.ensureCapacity(allocator, self.items.len + 1); self.items.len += 1; @@ -399,8 +480,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ self.items[n] = item; } - /// Insert slice `items` at index `i`. Moves - /// `list[i .. list.len]` to make room. + /// Insert slice `items` at index `i`. Moves `list[i .. list.len]` to + /// higher indicices make room. /// This operation is O(N). pub fn insertSlice(self: *Self, allocator: *Allocator, i: usize, items: SliceConst) !void { try self.ensureCapacity(allocator, self.items.len + items.len); @@ -411,8 +492,9 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ } /// Replace range of elements `list[start..start+len]` with `new_items` - /// grows list if `len < new_items.len`. may allocate - /// shrinks list if `len > new_items.len` + /// Grows list if `len < new_items.len`. + /// Shrinks list if `len > new_items.len` + /// Invalidates pointers if this ArrayList is resized. pub fn replaceRange(self: *Self, allocator: *Allocator, start: usize, len: usize, new_items: SliceConst) !void { var managed = self.toManaged(allocator); try managed.replaceRange(start, len, new_items); @@ -433,7 +515,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ } /// Remove the element at index `i` from the list and return its value. - /// Asserts the array has at least one item. + /// Asserts the array has at least one item. Invalidates pointers to + /// last element. /// This operation is O(N). pub fn orderedRemove(self: *Self, i: usize) T { const newlen = self.items.len - 1; @@ -448,6 +531,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Removes the element at the specified index and returns it. /// The empty slot is filled from the end of the list. + /// Invalidates pointers to last element. /// This operation is O(1). pub fn swapRemove(self: *Self, i: usize) T { if (self.items.len - 1 == i) return self.pop(); @@ -474,14 +558,6 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ mem.copy(T, self.items[oldlen..], items); } - /// Same as `append` except it returns the number of bytes written, which is always the same - /// as `m.len`. The purpose of this function existing is to match `std.io.OutStream` API. - /// This function may be called only when `T` is `u8`. - fn appendWrite(self: *Self, allocator: *Allocator, m: []const u8) !usize { - try self.appendSlice(allocator, m); - return m.len; - } - /// Append a value to the list `n` times. /// Allocates more memory as necessary. pub fn appendNTimes(self: *Self, allocator: *Allocator, value: T, n: usize) !void { @@ -491,6 +567,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ } /// Append a value to the list `n` times. + /// **Does not** invalidate pointers. /// Asserts the capacity is enough. pub fn appendNTimesAssumeCapacity(self: *Self, value: T, n: usize) void { const new_len = self.items.len + n; @@ -500,15 +577,14 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ } /// Adjust the list's length to `new_len`. - /// Does not initialize added items if any. + /// Does not initialize added items, if any. pub fn resize(self: *Self, allocator: *Allocator, new_len: usize) !void { try self.ensureCapacity(allocator, new_len); self.items.len = new_len; } /// Reduce allocated capacity to `new_len`. - /// Invalidates element pointers. - pub fn shrink(self: *Self, allocator: *Allocator, new_len: usize) void { + pub fn shrinkAndFree(self: *Self, allocator: *Allocator, new_len: usize) void { assert(new_len <= self.items.len); self.items = allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) { @@ -521,13 +597,15 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ } /// Reduce length to `new_len`. - /// Invalidates element pointers. + /// Invalidates pointers to elements `items[new_len..]`. /// Keeps capacity the same. pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void { assert(new_len <= self.items.len); self.items.len = new_len; } + /// Modify the array so that it can hold at least `new_capacity` items. + /// Invalidates pointers if additional memory is needed. pub fn ensureCapacity(self: *Self, allocator: *Allocator, new_capacity: usize) !void { var better_capacity = self.capacity; if (better_capacity >= new_capacity) return; @@ -544,13 +622,13 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Increases the array's length to match the full capacity that is already allocated. /// The new elements have `undefined` values. - /// This operation does not invalidate any element pointers. + /// **Does not** invalidate pointers. pub fn expandToCapacity(self: *Self) void { self.items.len = self.capacity; } /// Increase length by 1, returning pointer to the new item. - /// The returned pointer becomes invalid when the list is resized. + /// The returned pointer becomes invalid when the list resized. pub fn addOne(self: *Self, allocator: *Allocator) !*T { const newlen = self.items.len + 1; try self.ensureCapacity(allocator, newlen); @@ -559,8 +637,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Increase length by 1, returning pointer to the new item. /// Asserts that there is already space for the new item without allocating more. - /// The returned pointer becomes invalid when the list is resized. - /// This operation does not invalidate any element pointers. + /// **Does not** invalidate pointers. + /// The returned pointer becomes invalid when the list resized. pub fn addOneAssumeCapacity(self: *Self) *T { assert(self.items.len < self.capacity); @@ -570,6 +648,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Resize the array, adding `n` new elements, which have `undefined` values. /// The return value is an array pointing to the newly allocated elements. + /// The returned pointer becomes invalid when the list is resized. pub fn addManyAsArray(self: *Self, allocator: *Allocator, comptime n: usize) !*[n]T { const prev_len = self.items.len; try self.resize(allocator, self.items.len + n); @@ -579,6 +658,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Resize the array, adding `n` new elements, which have `undefined` values. /// The return value is an array pointing to the newly allocated elements. /// Asserts that there is already space for the new item without allocating more. + /// **Does not** invalidate pointers. + /// The returned pointer becomes invalid when the list is resized. pub fn addManyAsArrayAssumeCapacity(self: *Self, comptime n: usize) *[n]T { assert(self.items.len + n <= self.capacity); const prev_len = self.items.len; @@ -588,7 +669,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Remove and return the last element from the list. /// Asserts the list has at least one item. - /// This operation does not invalidate any element pointers. + /// Invalidates pointers to last element. pub fn pop(self: *Self) T { const val = self.items[self.items.len - 1]; self.items.len -= 1; @@ -597,7 +678,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Remove and return the last element from the list. /// If the list is empty, returns `null`. - /// This operation does not invalidate any element pointers. + /// Invalidates pointers to last element. pub fn popOrNull(self: *Self) ?T { if (self.items.len == 0) return null; return self.pop(); @@ -1047,13 +1128,13 @@ test "std.ArrayList/ArrayListUnmanaged: ArrayList(T) of struct T" { } } -test "std.ArrayList(u8) implements outStream" { +test "std.ArrayList(u8) implements writer" { var buffer = ArrayList(u8).init(std.testing.allocator); defer buffer.deinit(); const x: i32 = 42; const y: i32 = 1234; - try buffer.outStream().print("x: {}\ny: {}\n", .{ x, y }); + try buffer.writer().print("x: {}\ny: {}\n", .{ x, y }); testing.expectEqualSlices(u8, "x: 42\ny: 1234\n", buffer.items); } @@ -1071,7 +1152,7 @@ test "std.ArrayList/ArrayListUnmanaged.shrink still sets length on error.OutOfMe try list.append(2); try list.append(3); - list.shrink(1); + list.shrinkAndFree(1); testing.expect(list.items.len == 1); } { @@ -1081,7 +1162,7 @@ test "std.ArrayList/ArrayListUnmanaged.shrink still sets length on error.OutOfMe try list.append(a, 2); try list.append(a, 3); - list.shrink(a, 1); + list.shrinkAndFree(a, 1); testing.expect(list.items.len == 1); } } @@ -1121,3 +1202,27 @@ test "std.ArrayList/ArrayListUnmanaged.addManyAsArray" { testing.expectEqualSlices(u8, list.items, "aoeuasdf"); } } + +test "std.ArrayList/ArrayListUnmanaged.toOwnedSliceSentinel" { + const a = testing.allocator; + { + var list = ArrayList(u8).init(a); + defer list.deinit(); + + try list.appendSlice("foobar"); + + const result = try list.toOwnedSliceSentinel(0); + defer a.free(result); + testing.expectEqualStrings(result, mem.spanZ(result.ptr)); + } + { + var list = ArrayListUnmanaged(u8){}; + defer list.deinit(a); + + try list.appendSlice(a, "foobar"); + + const result = try list.toOwnedSliceSentinel(a, 0); + defer a.free(result); + testing.expectEqualStrings(result, mem.spanZ(result.ptr)); + } +} diff --git a/lib/std/array_list_sentineled.zig b/lib/std/array_list_sentineled.zig deleted file mode 100644 index 31f8f4fd80..0000000000 --- a/lib/std/array_list_sentineled.zig +++ /dev/null @@ -1,229 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -const std = @import("std.zig"); -const debug = std.debug; -const mem = std.mem; -const Allocator = mem.Allocator; -const assert = debug.assert; -const testing = std.testing; -const ArrayList = std.ArrayList; - -/// A contiguous, growable list of items in memory, with a sentinel after them. -/// The sentinel is maintained when appending, resizing, etc. -/// If you do not need a sentinel, consider using `ArrayList` instead. -pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type { - return struct { - list: ArrayList(T), - - const Self = @This(); - - /// Must deinitialize with deinit. - pub fn init(allocator: *Allocator, m: []const T) !Self { - var self = try initSize(allocator, m.len); - mem.copy(T, self.list.items, m); - return self; - } - - /// Initialize memory to size bytes of undefined values. - /// Must deinitialize with deinit. - pub fn initSize(allocator: *Allocator, size: usize) !Self { - var self = initNull(allocator); - try self.resize(size); - return self; - } - - /// Initialize with capacity to hold at least num bytes. - /// Must deinitialize with deinit. - pub fn initCapacity(allocator: *Allocator, num: usize) !Self { - var self = Self{ .list = try ArrayList(T).initCapacity(allocator, num + 1) }; - self.list.appendAssumeCapacity(sentinel); - return self; - } - - /// Must deinitialize with deinit. - /// None of the other operations are valid until you do one of these: - /// * `replaceContents` - /// * `resize` - pub fn initNull(allocator: *Allocator) Self { - return Self{ .list = ArrayList(T).init(allocator) }; - } - - /// Must deinitialize with deinit. - pub fn initFromBuffer(buffer: Self) !Self { - return Self.init(buffer.list.allocator, buffer.span()); - } - - /// Takes ownership of the passed in slice. The slice must have been - /// allocated with `allocator`. - /// Must deinitialize with deinit. - pub fn fromOwnedSlice(allocator: *Allocator, slice: []T) !Self { - var self = Self{ .list = ArrayList(T).fromOwnedSlice(allocator, slice) }; - try self.list.append(sentinel); - return self; - } - - /// The caller owns the returned memory. The list becomes null and is safe to `deinit`. - pub fn toOwnedSlice(self: *Self) [:sentinel]T { - const allocator = self.list.allocator; - const result = self.list.toOwnedSlice(); - self.* = initNull(allocator); - return result[0 .. result.len - 1 :sentinel]; - } - - /// Only works when `T` is `u8`. - pub fn allocPrint(allocator: *Allocator, comptime format: []const u8, args: anytype) !Self { - const size = std.math.cast(usize, std.fmt.count(format, args)) catch |err| switch (err) { - error.Overflow => return error.OutOfMemory, - }; - var self = try Self.initSize(allocator, size); - assert((std.fmt.bufPrint(self.list.items, format, args) catch unreachable).len == size); - return self; - } - - pub fn deinit(self: *Self) void { - self.list.deinit(); - } - - pub fn span(self: anytype) @TypeOf(self.list.items[0..:sentinel]) { - return self.list.items[0..self.len() :sentinel]; - } - - pub fn shrink(self: *Self, new_len: usize) void { - assert(new_len <= self.len()); - self.list.shrink(new_len + 1); - self.list.items[self.len()] = sentinel; - } - - pub fn resize(self: *Self, new_len: usize) !void { - try self.list.resize(new_len + 1); - self.list.items[self.len()] = sentinel; - } - - pub fn isNull(self: Self) bool { - return self.list.items.len == 0; - } - - pub fn len(self: Self) usize { - return self.list.items.len - 1; - } - - pub fn capacity(self: Self) usize { - return if (self.list.capacity > 0) - self.list.capacity - 1 - else - 0; - } - - pub fn appendSlice(self: *Self, m: []const T) !void { - const old_len = self.len(); - try self.resize(old_len + m.len); - mem.copy(T, self.list.items[old_len..], m); - } - - pub fn append(self: *Self, byte: T) !void { - const old_len = self.len(); - try self.resize(old_len + 1); - self.list.items[old_len] = byte; - } - - pub fn eql(self: Self, m: []const T) bool { - return mem.eql(T, self.span(), m); - } - - pub fn startsWith(self: Self, m: []const T) bool { - if (self.len() < m.len) return false; - return mem.eql(T, self.list.items[0..m.len], m); - } - - pub fn endsWith(self: Self, m: []const T) bool { - const l = self.len(); - if (l < m.len) return false; - const start = l - m.len; - return mem.eql(T, self.list.items[start..l], m); - } - - pub fn replaceContents(self: *Self, m: []const T) !void { - try self.resize(m.len); - mem.copy(T, self.list.items, m); - } - - /// Initializes an OutStream which will append to the list. - /// This function may be called only when `T` is `u8`. - pub fn outStream(self: *Self) std.io.OutStream(*Self, error{OutOfMemory}, appendWrite) { - return .{ .context = self }; - } - - /// Same as `append` except it returns the number of bytes written, which is always the same - /// as `m.len`. The purpose of this function existing is to match `std.io.OutStream` API. - /// This function may be called only when `T` is `u8`. - pub fn appendWrite(self: *Self, m: []const u8) !usize { - try self.appendSlice(m); - return m.len; - } - }; -} - -test "simple" { - var buf = try ArrayListSentineled(u8, 0).init(testing.allocator, ""); - defer buf.deinit(); - - testing.expect(buf.len() == 0); - try buf.appendSlice("hello"); - try buf.appendSlice(" "); - try buf.appendSlice("world"); - testing.expect(buf.eql("hello world")); - testing.expect(mem.eql(u8, mem.spanZ(buf.span().ptr), buf.span())); - - var buf2 = try ArrayListSentineled(u8, 0).initFromBuffer(buf); - defer buf2.deinit(); - testing.expect(buf.eql(buf2.span())); - - testing.expect(buf.startsWith("hell")); - testing.expect(buf.endsWith("orld")); - - try buf2.resize(4); - testing.expect(buf.startsWith(buf2.span())); -} - -test "initSize" { - var buf = try ArrayListSentineled(u8, 0).initSize(testing.allocator, 3); - defer buf.deinit(); - testing.expect(buf.len() == 3); - try buf.appendSlice("hello"); - testing.expect(mem.eql(u8, buf.span()[3..], "hello")); -} - -test "initCapacity" { - var buf = try ArrayListSentineled(u8, 0).initCapacity(testing.allocator, 10); - defer buf.deinit(); - testing.expect(buf.len() == 0); - testing.expect(buf.capacity() >= 10); - const old_cap = buf.capacity(); - try buf.appendSlice("hello"); - testing.expect(buf.len() == 5); - testing.expect(buf.capacity() == old_cap); - testing.expect(mem.eql(u8, buf.span(), "hello")); -} - -test "print" { - var buf = try ArrayListSentineled(u8, 0).init(testing.allocator, ""); - defer buf.deinit(); - - try buf.outStream().print("Hello {} the {}", .{ 2, "world" }); - testing.expect(buf.eql("Hello 2 the world")); -} - -test "outStream" { - var buffer = try ArrayListSentineled(u8, 0).initSize(testing.allocator, 0); - defer buffer.deinit(); - const buf_stream = buffer.outStream(); - - const x: i32 = 42; - const y: i32 = 1234; - try buf_stream.print("x: {}\ny: {}\n", .{ x, y }); - - testing.expect(mem.eql(u8, buffer.span(), "x: 42\ny: 1234\n")); -} diff --git a/lib/std/ascii.zig b/lib/std/ascii.zig index c8dc37c99c..7d391b7c4b 100644 --- a/lib/std/ascii.zig +++ b/lib/std/ascii.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/atomic.zig b/lib/std/atomic.zig index 4402ca462b..ab80fce872 100644 --- a/lib/std/atomic.zig +++ b/lib/std/atomic.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/atomic/bool.zig b/lib/std/atomic/bool.zig index 27a265bbc1..c968b862b9 100644 --- a/lib/std/atomic/bool.zig +++ b/lib/std/atomic/bool.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/atomic/int.zig b/lib/std/atomic/int.zig index b06575e05f..1a3bead2df 100644 --- a/lib/std/atomic/int.zig +++ b/lib/std/atomic/int.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/atomic/queue.zig b/lib/std/atomic/queue.zig index dd139106b4..f5f63944ab 100644 --- a/lib/std/atomic/queue.zig +++ b/lib/std/atomic/queue.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -16,7 +16,7 @@ pub fn Queue(comptime T: type) type { return struct { head: ?*Node, tail: ?*Node, - mutex: std.Mutex, + mutex: std.Thread.Mutex, pub const Self = @This(); pub const Node = std.TailQueue(T).Node; @@ -27,7 +27,7 @@ pub fn Queue(comptime T: type) type { return Self{ .head = null, .tail = null, - .mutex = std.Mutex{}, + .mutex = std.Thread.Mutex{}, }; } @@ -122,7 +122,7 @@ pub fn Queue(comptime T: type) type { /// Dumps the contents of the queue to `stderr`. pub fn dump(self: *Self) void { - self.dumpToStream(std.io.getStdErr().outStream()) catch return; + self.dumpToStream(std.io.getStdErr().writer()) catch return; } /// Dumps the contents of the queue to `stream`. @@ -351,7 +351,7 @@ test "std.atomic.Queue dump" { // Test empty stream fbs.reset(); - try queue.dumpToStream(fbs.outStream()); + try queue.dumpToStream(fbs.writer()); expect(mem.eql(u8, buffer[0..fbs.pos], \\head: (null) \\tail: (null) @@ -367,7 +367,7 @@ test "std.atomic.Queue dump" { queue.put(&node_0); fbs.reset(); - try queue.dumpToStream(fbs.outStream()); + try queue.dumpToStream(fbs.writer()); var expected = try std.fmt.bufPrint(expected_buffer[0..], \\head: 0x{x}=1 @@ -387,7 +387,7 @@ test "std.atomic.Queue dump" { queue.put(&node_1); fbs.reset(); - try queue.dumpToStream(fbs.outStream()); + try queue.dumpToStream(fbs.writer()); expected = try std.fmt.bufPrint(expected_buffer[0..], \\head: 0x{x}=1 diff --git a/lib/std/atomic/stack.zig b/lib/std/atomic/stack.zig index 1e289bae70..d55a8f81a3 100644 --- a/lib/std/atomic/stack.zig +++ b/lib/std/atomic/stack.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/auto_reset_event.zig b/lib/std/auto_reset_event.zig deleted file mode 100644 index 7e13dc1aba..0000000000 --- a/lib/std/auto_reset_event.zig +++ /dev/null @@ -1,227 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -const std = @import("std.zig"); -const builtin = @import("builtin"); -const testing = std.testing; -const assert = std.debug.assert; - -/// Similar to std.ResetEvent but on `set()` it also (atomically) does `reset()`. -/// Unlike std.ResetEvent, `wait()` can only be called by one thread (MPSC-like). -pub const AutoResetEvent = struct { - // AutoResetEvent has 3 possible states: - // - UNSET: the AutoResetEvent is currently unset - // - SET: the AutoResetEvent was notified before a wait() was called - // - : there is an active waiter waiting for a notification. - // - // When attempting to wait: - // if the event is unset, it registers a ResetEvent pointer to be notified when the event is set - // if the event is already set, then it consumes the notification and resets the event. - // - // When attempting to notify: - // if the event is unset, then we set the event - // if theres a waiting ResetEvent, then we unset the event and notify the ResetEvent - // - // This ensures that the event is automatically reset after a wait() has been issued - // and avoids the race condition when using std.ResetEvent in the following scenario: - // thread 1 | thread 2 - // std.ResetEvent.wait() | - // | std.ResetEvent.set() - // | std.ResetEvent.set() - // std.ResetEvent.reset() | - // std.ResetEvent.wait() | (missed the second .set() notification above) - state: usize = UNSET, - - const UNSET = 0; - const SET = 1; - - // the minimum alignment for the `*std.ResetEvent` created by wait*() - const event_align = std.math.max(@alignOf(std.ResetEvent), 2); - - pub fn wait(self: *AutoResetEvent) void { - self.waitFor(null) catch unreachable; - } - - pub fn timedWait(self: *AutoResetEvent, timeout: u64) error{TimedOut}!void { - return self.waitFor(timeout); - } - - fn waitFor(self: *AutoResetEvent, timeout: ?u64) error{TimedOut}!void { - // lazily initialized std.ResetEvent - var reset_event: std.ResetEvent align(event_align) = undefined; - var has_reset_event = false; - defer if (has_reset_event) { - reset_event.deinit(); - }; - - var state = @atomicLoad(usize, &self.state, .SeqCst); - while (true) { - // consume a notification if there is any - if (state == SET) { - @atomicStore(usize, &self.state, UNSET, .SeqCst); - return; - } - - // check if theres currently a pending ResetEvent pointer already registered - if (state != UNSET) { - unreachable; // multiple waiting threads on the same AutoResetEvent - } - - // lazily initialize the ResetEvent if it hasn't been already - if (!has_reset_event) { - has_reset_event = true; - reset_event = std.ResetEvent.init(); - } - - // Since the AutoResetEvent currently isnt set, - // try to register our ResetEvent on it to wait - // for a set() call from another thread. - if (@cmpxchgWeak( - usize, - &self.state, - UNSET, - @ptrToInt(&reset_event), - .SeqCst, - .SeqCst, - )) |new_state| { - state = new_state; - continue; - } - - // if no timeout was specified, then just wait forever - const timeout_ns = timeout orelse { - reset_event.wait(); - return; - }; - - // wait with a timeout and return if signalled via set() - if (reset_event.timedWait(timeout_ns)) |_| { - return; - } else |timed_out| {} - - // If we timed out, we need to transition the AutoResetEvent back to UNSET. - // If we don't, then when we return, a set() thread could observe a pointer to an invalid ResetEvent. - state = @cmpxchgStrong( - usize, - &self.state, - @ptrToInt(&reset_event), - UNSET, - .SeqCst, - .SeqCst, - ) orelse return error.TimedOut; - - // We didn't manage to unregister ourselves from the state. - if (state == SET) { - unreachable; // AutoResetEvent notified without waking up the waiting thread - } else if (state != UNSET) { - unreachable; // multiple waiting threads on the same AutoResetEvent observed when timing out - } - - // This menas a set() thread saw our ResetEvent pointer, acquired it, and is trying to wake it up. - // We need to wait for it to wake up our ResetEvent before we can return and invalidate it. - // We don't return error.TimedOut here as it technically notified us while we were "timing out". - reset_event.wait(); - return; - } - } - - pub fn set(self: *AutoResetEvent) void { - var state = @atomicLoad(usize, &self.state, .SeqCst); - while (true) { - // If the AutoResetEvent is already set, there is nothing else left to do - if (state == SET) { - return; - } - - // If the AutoResetEvent isn't set, - // then try to leave a notification for the wait() thread that we set() it. - if (state == UNSET) { - state = @cmpxchgWeak( - usize, - &self.state, - UNSET, - SET, - .SeqCst, - .SeqCst, - ) orelse return; - continue; - } - - // There is a ResetEvent pointer registered on the AutoResetEvent event thats waiting. - // Try to acquire ownership of it so that we can wake it up. - // This also resets the AutoResetEvent so that there is no race condition as defined above. - if (@cmpxchgWeak( - usize, - &self.state, - state, - UNSET, - .SeqCst, - .SeqCst, - )) |new_state| { - state = new_state; - continue; - } - - const reset_event = @intToPtr(*align(event_align) std.ResetEvent, state); - reset_event.set(); - return; - } - } -}; - -test "std.AutoResetEvent" { - // test local code paths - { - var event = AutoResetEvent{}; - testing.expectError(error.TimedOut, event.timedWait(1)); - event.set(); - event.wait(); - } - - // test cross-thread signaling - if (builtin.single_threaded) - return; - - const Context = struct { - value: u128 = 0, - in: AutoResetEvent = AutoResetEvent{}, - out: AutoResetEvent = AutoResetEvent{}, - - const Self = @This(); - - fn sender(self: *Self) void { - testing.expect(self.value == 0); - self.value = 1; - self.out.set(); - - self.in.wait(); - testing.expect(self.value == 2); - self.value = 3; - self.out.set(); - - self.in.wait(); - testing.expect(self.value == 4); - } - - fn receiver(self: *Self) void { - self.out.wait(); - testing.expect(self.value == 1); - self.value = 2; - self.in.set(); - - self.out.wait(); - testing.expect(self.value == 3); - self.value = 4; - self.in.set(); - } - }; - - var context = Context{}; - const send_thread = try std.Thread.spawn(&context, Context.sender); - const recv_thread = try std.Thread.spawn(&context, Context.receiver); - - send_thread.wait(); - recv_thread.wait(); -} diff --git a/lib/std/base64.zig b/lib/std/base64.zig index 0b91a1cf0a..e6a780c239 100644 --- a/lib/std/base64.zig +++ b/lib/std/base64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -38,8 +38,8 @@ pub const Base64Encoder = struct { } /// dest.len must be what you get from ::calcSize. - pub fn encode(encoder: *const Base64Encoder, dest: []u8, source: []const u8) void { - assert(dest.len == Base64Encoder.calcSize(source.len)); + pub fn encode(encoder: *const Base64Encoder, dest: []u8, source: []const u8) []const u8 { + assert(dest.len >= Base64Encoder.calcSize(source.len)); var i: usize = 0; var out_index: usize = 0; @@ -78,6 +78,7 @@ pub const Base64Encoder = struct { dest[out_index] = encoder.pad_char; out_index += 1; } + return dest[0..out_index]; } }; @@ -221,12 +222,10 @@ pub const Base64DecoderWithIgnore = struct { } else if (decoder_with_ignore.char_is_ignored[c]) { // we can even ignore chars during the padding continue; - } else - return error.InvalidCharacter; + } else return error.InvalidCharacter; } break; - } else - return error.InvalidCharacter; + } else return error.InvalidCharacter; } switch (available_chars) { @@ -398,8 +397,7 @@ fn testAllApis(expected_decoded: []const u8, expected_encoded: []const u8) !void // Base64Encoder { var buffer: [0x100]u8 = undefined; - var encoded = buffer[0..Base64Encoder.calcSize(expected_decoded.len)]; - standard_encoder.encode(encoded, expected_decoded); + const encoded = standard_encoder.encode(&buffer, expected_decoded); testing.expectEqualSlices(u8, expected_encoded, encoded); } diff --git a/lib/std/buf_map.zig b/lib/std/buf_map.zig index 3be724e10e..29d1ac4876 100644 --- a/lib/std/buf_map.zig +++ b/lib/std/buf_map.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/buf_set.zig b/lib/std/buf_set.zig index f48e6c594c..75c5ae742d 100644 --- a/lib/std/buf_set.zig +++ b/lib/std/buf_set.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/build.zig b/lib/std/build.zig index dacfaf5f75..e11402e493 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -272,15 +272,57 @@ pub const Builder = struct { return LibExeObjStep.createSharedLibrary(self, name, root_src_param, kind); } + pub fn addSharedLibraryFromWriteFileStep( + self: *Builder, + name: []const u8, + wfs: *WriteFileStep, + basename: []const u8, + kind: LibExeObjStep.SharedLibKind, + ) *LibExeObjStep { + return LibExeObjStep.createSharedLibrary(self, name, @as(FileSource, .{ + .write_file = .{ + .step = wfs, + .basename = basename, + }, + }), kind); + } + pub fn addStaticLibrary(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep { const root_src_param = if (root_src) |p| @as(FileSource, .{ .path = p }) else null; return LibExeObjStep.createStaticLibrary(self, name, root_src_param); } + pub fn addStaticLibraryFromWriteFileStep( + self: *Builder, + name: []const u8, + wfs: *WriteFileStep, + basename: []const u8, + ) *LibExeObjStep { + return LibExeObjStep.createStaticLibrary(self, name, @as(FileSource, .{ + .write_file = .{ + .step = wfs, + .basename = basename, + }, + })); + } + pub fn addTest(self: *Builder, root_src: []const u8) *LibExeObjStep { return LibExeObjStep.createTest(self, "test", .{ .path = root_src }); } + pub fn addTestFromWriteFileStep( + self: *Builder, + wfs: *WriteFileStep, + basename: []const u8, + ) *LibExeObjStep { + return LibExeObjStep.createTest(self, "test", @as(FileSource, .{ + .write_file = .{ + .step = wfs, + .basename = basename, + }, + })); + } + pub fn addAssemble(self: *Builder, name: []const u8, src: []const u8) *LibExeObjStep { const obj_step = LibExeObjStep.createObject(self, name, null); obj_step.addAssemblyFile(src); @@ -294,7 +336,7 @@ pub const Builder = struct { /// To run an executable built with zig build, see `LibExeObjStep.run`. pub fn addSystemCommand(self: *Builder, argv: []const []const u8) *RunStep { assert(argv.len >= 1); - const run_step = RunStep.create(self, self.fmt("run {}", .{argv[0]})); + const run_step = RunStep.create(self, self.fmt("run {s}", .{argv[0]})); run_step.addArgs(argv); return run_step; } @@ -303,6 +345,14 @@ pub const Builder = struct { return self.allocator.dupe(u8, bytes) catch unreachable; } + pub fn dupeStrings(self: *Builder, strings: []const []const u8) [][]u8 { + const array = self.allocator.alloc([]u8, strings.len) catch unreachable; + for (strings) |s, i| { + array[i] = self.dupe(s); + } + return array; + } + pub fn dupePath(self: *Builder, bytes: []const u8) []u8 { const the_copy = self.dupe(bytes); for (the_copy) |*byte| { @@ -409,7 +459,7 @@ pub const Builder = struct { for (self.installed_files.items) |installed_file| { const full_path = self.getInstallPath(installed_file.dir, installed_file.path); if (self.verbose) { - warn("rm {}\n", .{full_path}); + warn("rm {s}\n", .{full_path}); } fs.cwd().deleteTree(full_path) catch {}; } @@ -419,7 +469,7 @@ pub const Builder = struct { fn makeOneStep(self: *Builder, s: *Step) anyerror!void { if (s.loop_flag) { - warn("Dependency loop detected:\n {}\n", .{s.name}); + warn("Dependency loop detected:\n {s}\n", .{s.name}); return error.DependencyLoopDetected; } s.loop_flag = true; @@ -427,7 +477,7 @@ pub const Builder = struct { for (s.dependencies.items) |dep| { self.makeOneStep(dep) catch |err| { if (err == error.DependencyLoopDetected) { - warn(" {}\n", .{s.name}); + warn(" {s}\n", .{s.name}); } return err; }; @@ -444,11 +494,13 @@ pub const Builder = struct { return &top_level_step.step; } } - warn("Cannot run step '{}' because it does not exist\n", .{name}); + warn("Cannot run step '{s}' because it does not exist\n", .{name}); return error.InvalidStepName; } - pub fn option(self: *Builder, comptime T: type, name: []const u8, description: []const u8) ?T { + pub fn option(self: *Builder, comptime T: type, name_raw: []const u8, description_raw: []const u8) ?T { + const name = self.dupe(name_raw); + const description = self.dupe(description_raw); const type_id = comptime typeToEnum(T); const available_option = AvailableOption{ .name = name, @@ -456,7 +508,7 @@ pub const Builder = struct { .description = description, }; if ((self.available_options_map.fetchPut(name, available_option) catch unreachable) != null) { - panic("Option '{}' declared twice", .{name}); + panic("Option '{s}' declared twice", .{name}); } self.available_options_list.append(available_option) catch unreachable; @@ -471,32 +523,32 @@ pub const Builder = struct { } else if (mem.eql(u8, s, "false")) { return false; } else { - warn("Expected -D{} to be a boolean, but received '{}'\n", .{ name, s }); + warn("Expected -D{s} to be a boolean, but received '{s}'\n\n", .{ name, s }); self.markInvalidUserInput(); return null; } }, .List => { - warn("Expected -D{} to be a boolean, but received a list.\n", .{name}); + warn("Expected -D{s} to be a boolean, but received a list.\n\n", .{name}); self.markInvalidUserInput(); return null; }, }, .Int => switch (entry.value.value) { .Flag => { - warn("Expected -D{} to be an integer, but received a boolean.\n", .{name}); + warn("Expected -D{s} to be an integer, but received a boolean.\n\n", .{name}); self.markInvalidUserInput(); return null; }, .Scalar => |s| { const n = std.fmt.parseInt(T, s, 10) catch |err| switch (err) { error.Overflow => { - warn("-D{} value {} cannot fit into type {}.\n", .{ name, s, @typeName(T) }); + warn("-D{s} value {s} cannot fit into type {s}.\n\n", .{ name, s, @typeName(T) }); self.markInvalidUserInput(); return null; }, else => { - warn("Expected -D{} to be an integer of type {}.\n", .{ name, @typeName(T) }); + warn("Expected -D{s} to be an integer of type {s}.\n\n", .{ name, @typeName(T) }); self.markInvalidUserInput(); return null; }, @@ -504,15 +556,34 @@ pub const Builder = struct { return n; }, .List => { - warn("Expected -D{} to be an integer, but received a list.\n", .{name}); + warn("Expected -D{s} to be an integer, but received a list.\n\n", .{name}); + self.markInvalidUserInput(); + return null; + }, + }, + .Float => switch (entry.value.value) { + .Flag => { + warn("Expected -D{s} to be a float, but received a boolean.\n\n", .{name}); + self.markInvalidUserInput(); + return null; + }, + .Scalar => |s| { + const n = std.fmt.parseFloat(T, s) catch |err| { + warn("Expected -D{s} to be a float of type {s}.\n\n", .{ name, @typeName(T) }); + self.markInvalidUserInput(); + return null; + }; + return n; + }, + .List => { + warn("Expected -D{s} to be a float, but received a list.\n\n", .{name}); self.markInvalidUserInput(); return null; }, }, - .Float => panic("TODO float options to build script", .{}), .Enum => switch (entry.value.value) { .Flag => { - warn("Expected -D{} to be a string, but received a boolean.\n", .{name}); + warn("Expected -D{s} to be a string, but received a boolean.\n\n", .{name}); self.markInvalidUserInput(); return null; }, @@ -520,25 +591,25 @@ pub const Builder = struct { if (std.meta.stringToEnum(T, s)) |enum_lit| { return enum_lit; } else { - warn("Expected -D{} to be of type {}.\n", .{ name, @typeName(T) }); + warn("Expected -D{s} to be of type {s}.\n\n", .{ name, @typeName(T) }); self.markInvalidUserInput(); return null; } }, .List => { - warn("Expected -D{} to be a string, but received a list.\n", .{name}); + warn("Expected -D{s} to be a string, but received a list.\n\n", .{name}); self.markInvalidUserInput(); return null; }, }, .String => switch (entry.value.value) { .Flag => { - warn("Expected -D{} to be a string, but received a boolean.\n", .{name}); + warn("Expected -D{s} to be a string, but received a boolean.\n\n", .{name}); self.markInvalidUserInput(); return null; }, .List => { - warn("Expected -D{} to be a string, but received a list.\n", .{name}); + warn("Expected -D{s} to be a string, but received a list.\n\n", .{name}); self.markInvalidUserInput(); return null; }, @@ -546,7 +617,7 @@ pub const Builder = struct { }, .List => switch (entry.value.value) { .Flag => { - warn("Expected -D{} to be a list, but received a boolean.\n", .{name}); + warn("Expected -D{s} to be a list, but received a boolean.\n\n", .{name}); self.markInvalidUserInput(); return null; }, @@ -562,7 +633,7 @@ pub const Builder = struct { const step_info = self.allocator.create(TopLevelStep) catch unreachable; step_info.* = TopLevelStep{ .step = Step.initNoOp(.TopLevel, name, self.allocator), - .description = description, + .description = self.dupe(description), }; self.top_level_steps.append(step_info) catch unreachable; return &step_info.step; @@ -573,7 +644,7 @@ pub const Builder = struct { if (self.release_mode != null) { @panic("setPreferredReleaseMode must be called before standardReleaseOptions and may not be called twice"); } - const description = self.fmt("Create a release build ({})", .{@tagName(mode)}); + const description = self.fmt("Create a release build ({s})", .{@tagName(mode)}); self.is_release = self.option(bool, "release", description) orelse false; self.release_mode = if (self.is_release) mode else builtin.Mode.Debug; } @@ -596,7 +667,7 @@ pub const Builder = struct { else if (!release_fast and !release_safe and !release_small) builtin.Mode.Debug else x: { - warn("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)", .{}); + warn("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)\n\n", .{}); self.markInvalidUserInput(); break :x builtin.Mode.Debug; }; @@ -627,43 +698,50 @@ pub const Builder = struct { .diagnostics = &diags, }) catch |err| switch (err) { error.UnknownCpuModel => { - std.debug.warn("Unknown CPU: '{}'\nAvailable CPUs for architecture '{}':\n", .{ + warn("Unknown CPU: '{s}'\nAvailable CPUs for architecture '{s}':\n", .{ diags.cpu_name.?, @tagName(diags.arch.?), }); for (diags.arch.?.allCpuModels()) |cpu| { - std.debug.warn(" {}\n", .{cpu.name}); + warn(" {s}\n", .{cpu.name}); } - process.exit(1); + warn("\n", .{}); + self.markInvalidUserInput(); + return args.default_target; }, error.UnknownCpuFeature => { - std.debug.warn( - \\Unknown CPU feature: '{}' - \\Available CPU features for architecture '{}': + warn( + \\Unknown CPU feature: '{s}' + \\Available CPU features for architecture '{s}': \\ , .{ diags.unknown_feature_name, @tagName(diags.arch.?), }); for (diags.arch.?.allFeaturesList()) |feature| { - std.debug.warn(" {}: {}\n", .{ feature.name, feature.description }); + warn(" {s}: {s}\n", .{ feature.name, feature.description }); } - process.exit(1); + warn("\n", .{}); + self.markInvalidUserInput(); + return args.default_target; }, error.UnknownOperatingSystem => { - std.debug.warn( - \\Unknown OS: '{}' + warn( + \\Unknown OS: '{s}' \\Available operating systems: \\ , .{diags.os_name}); inline for (std.meta.fields(std.Target.Os.Tag)) |field| { - std.debug.warn(" {}\n", .{field.name}); + warn(" {s}\n", .{field.name}); } - process.exit(1); + warn("\n", .{}); + self.markInvalidUserInput(); + return args.default_target; }, else => |e| { - std.debug.warn("Unable to parse target '{}': {}\n", .{ triple, @errorName(e) }); - process.exit(1); + warn("Unable to parse target '{s}': {s}\n\n", .{ triple, @errorName(e) }); + self.markInvalidUserInput(); + return args.default_target; }, }; @@ -677,22 +755,24 @@ pub const Builder = struct { break :whitelist_check; } } - std.debug.warn("Chosen target '{}' does not match one of the supported targets:\n", .{ + warn("Chosen target '{s}' does not match one of the supported targets:\n", .{ selected_canonicalized_triple, }); for (list) |t| { const t_triple = t.zigTriple(self.allocator) catch unreachable; - std.debug.warn(" {}\n", .{t_triple}); + warn(" {s}\n", .{t_triple}); } - // TODO instead of process exit, return error and have a zig build flag implemented by - // the build runner that turns process exits into error return traces - process.exit(1); + warn("\n", .{}); + self.markInvalidUserInput(); + return args.default_target; } return selected_target; } - pub fn addUserInputOption(self: *Builder, name: []const u8, value: []const u8) !bool { + pub fn addUserInputOption(self: *Builder, name_raw: []const u8, value_raw: []const u8) !bool { + const name = self.dupe(name_raw); + const value = self.dupe(value_raw); const gop = try self.user_input_options.getOrPut(name); if (!gop.found_existing) { gop.entry.value = UserInputOption{ @@ -726,14 +806,15 @@ pub const Builder = struct { }) catch unreachable; }, UserValue.Flag => { - warn("Option '-D{}={}' conflicts with flag '-D{}'.\n", .{ name, value, name }); + warn("Option '-D{s}={s}' conflicts with flag '-D{s}'.\n", .{ name, value, name }); return true; }, } return false; } - pub fn addUserInputFlag(self: *Builder, name: []const u8) !bool { + pub fn addUserInputFlag(self: *Builder, name_raw: []const u8) !bool { + const name = self.dupe(name_raw); const gop = try self.user_input_options.getOrPut(name); if (!gop.found_existing) { gop.entry.value = UserInputOption{ @@ -747,11 +828,11 @@ pub const Builder = struct { // option already exists switch (gop.entry.value.value) { UserValue.Scalar => |s| { - warn("Flag '-D{}' conflicts with option '-D{}={}'.\n", .{ name, name, s }); + warn("Flag '-D{s}' conflicts with option '-D{s}={s}'.\n", .{ name, name, s }); return true; }, UserValue.List => { - warn("Flag '-D{}' conflicts with multiple options of the same name.\n", .{name}); + warn("Flag '-D{s}' conflicts with multiple options of the same name.\n", .{name}); return true; }, UserValue.Flag => {}, @@ -794,7 +875,7 @@ pub const Builder = struct { while (true) { const entry = it.next() orelse break; if (!entry.value.used) { - warn("Invalid option: -D{}\n\n", .{entry.key}); + warn("Invalid option: -D{s}\n\n", .{entry.key}); self.markInvalidUserInput(); } } @@ -807,9 +888,9 @@ pub const Builder = struct { } fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void { - if (cwd) |yes_cwd| warn("cd {} && ", .{yes_cwd}); + if (cwd) |yes_cwd| warn("cd {s} && ", .{yes_cwd}); for (argv) |arg| { - warn("{} ", .{arg}); + warn("{s} ", .{arg}); } warn("\n", .{}); } @@ -826,7 +907,7 @@ pub const Builder = struct { child.env_map = env_map; const term = child.spawnAndWait() catch |err| { - warn("Unable to spawn {}: {}\n", .{ argv[0], @errorName(err) }); + warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) }); return err; }; @@ -849,7 +930,7 @@ pub const Builder = struct { pub fn makePath(self: *Builder, path: []const u8) !void { fs.cwd().makePath(self.pathFromRoot(path)) catch |err| { - warn("Unable to create path {}: {}\n", .{ path, @errorName(err) }); + warn("Unable to create path {s}: {s}\n", .{ path, @errorName(err) }); return err; }; } @@ -925,15 +1006,16 @@ pub const Builder = struct { } pub fn pushInstalledFile(self: *Builder, dir: InstallDir, dest_rel_path: []const u8) void { - self.installed_files.append(InstalledFile{ + const file = InstalledFile{ .dir = dir, .path = dest_rel_path, - }) catch unreachable; + }; + self.installed_files.append(file.dupe(self)) catch unreachable; } pub fn updateFile(self: *Builder, source_path: []const u8, dest_path: []const u8) !void { if (self.verbose) { - warn("cp {} {} ", .{ source_path, dest_path }); + warn("cp {s} {s} ", .{ source_path, dest_path }); } const cwd = fs.cwd(); const prev_status = try fs.Dir.updateFile(cwd, source_path, cwd, dest_path, .{}); @@ -962,7 +1044,7 @@ pub const Builder = struct { const full_path = try fs.path.join(self.allocator, &[_][]const u8{ search_prefix, "bin", - self.fmt("{}{}", .{ name, exe_extension }), + self.fmt("{s}{s}", .{ name, exe_extension }), }); return fs.realpathAlloc(self.allocator, full_path) catch continue; } @@ -976,7 +1058,7 @@ pub const Builder = struct { while (it.next()) |path| { const full_path = try fs.path.join(self.allocator, &[_][]const u8{ path, - self.fmt("{}{}", .{ name, exe_extension }), + self.fmt("{s}{s}", .{ name, exe_extension }), }); return fs.realpathAlloc(self.allocator, full_path) catch continue; } @@ -989,7 +1071,7 @@ pub const Builder = struct { for (paths) |path| { const full_path = try fs.path.join(self.allocator, &[_][]const u8{ path, - self.fmt("{}{}", .{ name, exe_extension }), + self.fmt("{s}{s}", .{ name, exe_extension }), }); return fs.realpathAlloc(self.allocator, full_path) catch continue; } @@ -1012,10 +1094,11 @@ pub const Builder = struct { child.stdin_behavior = .Ignore; child.stdout_behavior = .Pipe; child.stderr_behavior = stderr_behavior; + child.env_map = self.env_map; try child.spawn(); - const stdout = try child.stdout.?.inStream().readAllAlloc(self.allocator, max_output_size); + const stdout = try child.stdout.?.reader().readAllAlloc(self.allocator, max_output_size); errdefer self.allocator.free(stdout); const term = try child.wait(); @@ -1044,19 +1127,19 @@ pub const Builder = struct { var code: u8 = undefined; return self.execAllowFail(argv, &code, .Inherit) catch |err| switch (err) { error.FileNotFound => { - if (src_step) |s| warn("{}...", .{s.name}); + if (src_step) |s| warn("{s}...", .{s.name}); warn("Unable to spawn the following command: file not found\n", .{}); printCmd(null, argv); std.os.exit(@truncate(u8, code)); }, error.ExitCodeFailure => { - if (src_step) |s| warn("{}...", .{s.name}); - warn("The following command exited with error code {}:\n", .{code}); + if (src_step) |s| warn("{s}...", .{s.name}); + warn("The following command exited with error code {d}:\n", .{code}); printCmd(null, argv); std.os.exit(@truncate(u8, code)); }, error.ProcessTerminated => { - if (src_step) |s| warn("{}...", .{s.name}); + if (src_step) |s| warn("{s}...", .{s.name}); warn("The following command terminated unexpectedly:\n", .{}); printCmd(null, argv); std.os.exit(@truncate(u8, code)); @@ -1070,10 +1153,11 @@ pub const Builder = struct { } pub fn addSearchPrefix(self: *Builder, search_prefix: []const u8) void { - self.search_prefixes.append(search_prefix) catch unreachable; + self.search_prefixes.append(self.dupePath(search_prefix)) catch unreachable; } pub fn getInstallPath(self: *Builder, dir: InstallDir, dest_rel_path: []const u8) []const u8 { + assert(!fs.path.isAbsolute(dest_rel_path)); // Install paths must be relative to the prefix const base_dir = switch (dir) { .Prefix => self.install_path, .Bin => self.exe_dir, @@ -1090,6 +1174,7 @@ pub const Builder = struct { fn execPkgConfigList(self: *Builder, out_code: *u8) ![]const PkgConfigPkg { const stdout = try self.execAllowFail(&[_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore); var list = ArrayList(PkgConfigPkg).init(self.allocator); + errdefer list.deinit(); var line_it = mem.tokenize(stdout, "\r\n"); while (line_it.next()) |line| { if (mem.trim(u8, line, " \t").len == 0) continue; @@ -1099,7 +1184,7 @@ pub const Builder = struct { .desc = tok_it.rest(), }); } - return list.items; + return list.toOwnedSlice(); } fn getPkgConfigList(self: *Builder) ![]const PkgConfigPkg { @@ -1154,9 +1239,16 @@ pub const Pkg = struct { dependencies: ?[]const Pkg = null, }; -const CSourceFile = struct { +pub const CSourceFile = struct { source: FileSource, args: []const []const u8, + + fn dupe(self: CSourceFile, b: *Builder) CSourceFile { + return .{ + .source = self.source.dupe(b), + .args = b.dupeStrings(self.args), + }; + } }; const CSourceFiles = struct { @@ -1198,6 +1290,17 @@ pub const FileSource = union(enum) { .translate_c => |tc| tc.getOutputPath(), }; } + + pub fn dupe(self: FileSource, b: *Builder) FileSource { + return switch (self) { + .path => |p| .{ .path = b.dupe(p) }, + .write_file => |wf| .{ .write_file = .{ + .step = wf.step, + .basename = b.dupe(wf.basename), + } }, + .translate_c => |tc| .{ .translate_c = tc }, + }; + } }; const BuildOptionArtifactArg = struct { @@ -1205,6 +1308,12 @@ const BuildOptionArtifactArg = struct { artifact: *LibExeObjStep, }; +const BuildOptionWriteFileArg = struct { + name: []const u8, + write_file: *WriteFileStep, + basename: []const u8, +}; + pub const LibExeObjStep = struct { step: Step, builder: *Builder, @@ -1233,6 +1342,7 @@ pub const LibExeObjStep = struct { bundle_compiler_rt: ?bool = null, disable_stack_probing: bool, disable_sanitize_c: bool, + sanitize_thread: bool, rdynamic: bool, c_std: Builder.CStd, override_lib_dir: ?[]const u8, @@ -1251,6 +1361,7 @@ pub const LibExeObjStep = struct { packages: ArrayList(Pkg), build_options_contents: std.ArrayList(u8), build_options_artifact_args: std.ArrayList(BuildOptionArtifactArg), + build_options_write_file_args: std.ArrayList(BuildOptionWriteFileArg), object_src: []const u8, @@ -1303,11 +1414,15 @@ pub const LibExeObjStep = struct { /// Position Independent Executable pie: ?bool = null, + red_zone: ?bool = null, + subsystem: ?builtin.SubSystem = null, /// Overrides the default stack size stack_size: ?u64 = null, + want_lto: ?bool = null, + const LinkObject = union(enum) { StaticPath: []const u8, OtherStep: *LibExeObjStep, @@ -1370,14 +1485,16 @@ pub const LibExeObjStep = struct { fn initExtraArgs( builder: *Builder, - name: []const u8, - root_src: ?FileSource, + name_raw: []const u8, + root_src_raw: ?FileSource, kind: Kind, is_dynamic: bool, ver: ?Version, ) LibExeObjStep { + const name = builder.dupe(name_raw); + const root_src: ?FileSource = if (root_src_raw) |rsrc| rsrc.dupe(builder) else null; if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) { - panic("invalid name: '{}'. It looks like a file path, but it is supposed to be the library or application name.", .{name}); + panic("invalid name: '{s}'. It looks like a file path, but it is supposed to be the library or application name.", .{name}); } var self = LibExeObjStep{ .strip = false, @@ -1393,9 +1510,9 @@ pub const LibExeObjStep = struct { .step = Step.init(.LibExeObj, name, builder.allocator, make), .version = ver, .out_filename = undefined, - .out_h_filename = builder.fmt("{}.h", .{name}), + .out_h_filename = builder.fmt("{s}.h", .{name}), .out_lib_filename = undefined, - .out_pdb_filename = builder.fmt("{}.pdb", .{name}), + .out_pdb_filename = builder.fmt("{s}.pdb", .{name}), .major_only_filename = undefined, .name_only_filename = undefined, .packages = ArrayList(Pkg).init(builder.allocator), @@ -1407,6 +1524,7 @@ pub const LibExeObjStep = struct { .object_src = undefined, .build_options_contents = std.ArrayList(u8).init(builder.allocator), .build_options_artifact_args = std.ArrayList(BuildOptionArtifactArg).init(builder.allocator), + .build_options_write_file_args = std.ArrayList(BuildOptionWriteFileArg).init(builder.allocator), .c_std = Builder.CStd.C99, .override_lib_dir = null, .main_pkg_path = null, @@ -1415,6 +1533,7 @@ pub const LibExeObjStep = struct { .filter = null, .disable_stack_probing = false, .disable_sanitize_c = false, + .sanitize_thread = false, .rdynamic = false, .output_dir = null, .single_threaded = false, @@ -1500,7 +1619,7 @@ pub const LibExeObjStep = struct { // It doesn't have to be native. We catch that if you actually try to run it. // Consider that this is declarative; the run step may not be run unless a user // option is supplied. - const run_step = RunStep.create(exe.builder, exe.builder.fmt("run {}", .{exe.step.name})); + const run_step = RunStep.create(exe.builder, exe.builder.fmt("run {s}", .{exe.step.name})); run_step.addArtifactArg(exe); if (exe.vcpkg_bin_path) |path| { @@ -1511,12 +1630,12 @@ pub const LibExeObjStep = struct { } pub fn setLinkerScriptPath(self: *LibExeObjStep, path: []const u8) void { - self.linker_script = path; + self.linker_script = self.builder.dupePath(path); } pub fn linkFramework(self: *LibExeObjStep, framework_name: []const u8) void { assert(self.target.isDarwin()); - self.frameworks.put(framework_name) catch unreachable; + self.frameworks.put(self.builder.dupe(framework_name)) catch unreachable; } /// Returns whether the library, executable, or object depends on a particular system library. @@ -1651,7 +1770,7 @@ pub const LibExeObjStep = struct { } else if (mem.eql(u8, tok, "-pthread")) { self.linkLibC(); } else if (self.builder.verbose) { - warn("Ignoring pkg-config flag '{}'\n", .{tok}); + warn("Ignoring pkg-config flag '{s}'\n", .{tok}); } } } @@ -1680,25 +1799,23 @@ pub const LibExeObjStep = struct { pub fn setNamePrefix(self: *LibExeObjStep, text: []const u8) void { assert(self.kind == Kind.Test); - self.name_prefix = text; + self.name_prefix = self.builder.dupe(text); } pub fn setFilter(self: *LibExeObjStep, text: ?[]const u8) void { assert(self.kind == Kind.Test); - self.filter = text; + self.filter = if (text) |t| self.builder.dupe(t) else null; } /// Handy when you have many C/C++ source files and want them all to have the same flags. pub fn addCSourceFiles(self: *LibExeObjStep, files: []const []const u8, flags: []const []const u8) void { const c_source_files = self.builder.allocator.create(CSourceFiles) catch unreachable; - const flags_copy = self.builder.allocator.alloc([]u8, flags.len) catch unreachable; - for (flags) |flag, i| { - flags_copy[i] = self.builder.dupe(flag); - } + const files_copy = self.builder.dupeStrings(files); + const flags_copy = self.builder.dupeStrings(flags); c_source_files.* = .{ - .files = files, + .files = files_copy, .flags = flags_copy, }; self.link_objects.append(LinkObject{ .CSourceFiles = c_source_files }) catch unreachable; @@ -1713,14 +1830,7 @@ pub const LibExeObjStep = struct { pub fn addCSourceFileSource(self: *LibExeObjStep, source: CSourceFile) void { const c_source_file = self.builder.allocator.create(CSourceFile) catch unreachable; - - const args_copy = self.builder.allocator.alloc([]u8, source.args.len) catch unreachable; - for (source.args) |arg, i| { - args_copy[i] = self.builder.dupe(arg); - } - - c_source_file.* = source; - c_source_file.args = args_copy; + c_source_file.* = source.dupe(self.builder); self.link_objects.append(LinkObject{ .CSourceFile = c_source_file }) catch unreachable; } @@ -1737,15 +1847,15 @@ pub const LibExeObjStep = struct { } pub fn overrideZigLibDir(self: *LibExeObjStep, dir_path: []const u8) void { - self.override_lib_dir = self.builder.dupe(dir_path); + self.override_lib_dir = self.builder.dupePath(dir_path); } pub fn setMainPkgPath(self: *LibExeObjStep, dir_path: []const u8) void { - self.main_pkg_path = dir_path; + self.main_pkg_path = self.builder.dupePath(dir_path); } pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void { - self.libc_file = libc_file; + self.libc_file = if (libc_file) |f| self.builder.dupe(f) else null; } /// Unless setOutputDir was called, this function must be called only in @@ -1805,8 +1915,9 @@ pub const LibExeObjStep = struct { } pub fn addAssemblyFileSource(self: *LibExeObjStep, source: FileSource) void { - self.link_objects.append(LinkObject{ .AssemblyFile = source }) catch unreachable; - source.addStepDependencies(&self.step); + const source_duped = source.dupe(self.builder); + self.link_objects.append(LinkObject{ .AssemblyFile = source_duped }) catch unreachable; + source_duped.addStepDependencies(&self.step); } pub fn addObjectFile(self: *LibExeObjStep, path: []const u8) void { @@ -1819,28 +1930,28 @@ pub const LibExeObjStep = struct { } pub fn addBuildOption(self: *LibExeObjStep, comptime T: type, name: []const u8, value: T) void { - const out = self.build_options_contents.outStream(); + const out = self.build_options_contents.writer(); switch (T) { []const []const u8 => { - out.print("pub const {z}: []const []const u8 = &[_][]const u8{{\n", .{name}) catch unreachable; + out.print("pub const {}: []const []const u8 = &[_][]const u8{{\n", .{std.zig.fmtId(name)}) catch unreachable; for (value) |slice| { - out.print(" \"{Z}\",\n", .{slice}) catch unreachable; + out.print(" \"{}\",\n", .{std.zig.fmtEscapes(slice)}) catch unreachable; } out.writeAll("};\n") catch unreachable; return; }, [:0]const u8 => { - out.print("pub const {z}: [:0]const u8 = \"{Z}\";\n", .{ name, value }) catch unreachable; + out.print("pub const {}: [:0]const u8 = \"{}\";\n", .{ std.zig.fmtId(name), std.zig.fmtEscapes(value) }) catch unreachable; return; }, []const u8 => { - out.print("pub const {z}: []const u8 = \"{Z}\";\n", .{ name, value }) catch unreachable; + out.print("pub const {}: []const u8 = \"{}\";\n", .{ std.zig.fmtId(name), std.zig.fmtEscapes(value) }) catch unreachable; return; }, ?[]const u8 => { - out.print("pub const {z}: ?[]const u8 = ", .{name}) catch unreachable; + out.print("pub const {}: ?[]const u8 = ", .{std.zig.fmtId(name)}) catch unreachable; if (value) |payload| { - out.print("\"{Z}\";\n", .{payload}) catch unreachable; + out.print("\"{}\";\n", .{std.zig.fmtEscapes(payload)}) catch unreachable; } else { out.writeAll("null;\n") catch unreachable; } @@ -1848,14 +1959,14 @@ pub const LibExeObjStep = struct { }, std.builtin.Version => { out.print( - \\pub const {z}: @import("builtin").Version = .{{ + \\pub const {}: @import("builtin").Version = .{{ \\ .major = {d}, \\ .minor = {d}, \\ .patch = {d}, \\}}; \\ , .{ - name, + std.zig.fmtId(name), value.major, value.minor, @@ -1864,23 +1975,23 @@ pub const LibExeObjStep = struct { }, std.SemanticVersion => { out.print( - \\pub const {z}: @import("std").SemanticVersion = .{{ + \\pub const {}: @import("std").SemanticVersion = .{{ \\ .major = {d}, \\ .minor = {d}, \\ .patch = {d}, \\ , .{ - name, + std.zig.fmtId(name), value.major, value.minor, value.patch, }) catch unreachable; if (value.pre) |some| { - out.print(" .pre = \"{Z}\",\n", .{some}) catch unreachable; + out.print(" .pre = \"{}\",\n", .{std.zig.fmtEscapes(some)}) catch unreachable; } if (value.build) |some| { - out.print(" .build = \"{Z}\",\n", .{some}) catch unreachable; + out.print(" .build = \"{}\",\n", .{std.zig.fmtEscapes(some)}) catch unreachable; } out.writeAll("};\n") catch unreachable; return; @@ -1889,24 +2000,41 @@ pub const LibExeObjStep = struct { } switch (@typeInfo(T)) { .Enum => |enum_info| { - out.print("pub const {z} = enum {{\n", .{@typeName(T)}) catch unreachable; + out.print("pub const {} = enum {{\n", .{std.zig.fmtId(@typeName(T))}) catch unreachable; inline for (enum_info.fields) |field| { - out.print(" {z},\n", .{field.name}) catch unreachable; + out.print(" {},\n", .{std.zig.fmtId(field.name)}) catch unreachable; } out.writeAll("};\n") catch unreachable; }, else => {}, } - out.print("pub const {z}: {} = {};\n", .{ name, @typeName(T), value }) catch unreachable; + out.print("pub const {}: {s} = {};\n", .{ std.zig.fmtId(name), @typeName(T), value }) catch unreachable; } /// The value is the path in the cache dir. /// Adds a dependency automatically. pub fn addBuildOptionArtifact(self: *LibExeObjStep, name: []const u8, artifact: *LibExeObjStep) void { - self.build_options_artifact_args.append(.{ .name = name, .artifact = artifact }) catch unreachable; + self.build_options_artifact_args.append(.{ .name = self.builder.dupe(name), .artifact = artifact }) catch unreachable; self.step.dependOn(&artifact.step); } + /// The value is the path in the cache dir. + /// Adds a dependency automatically. + /// basename refers to the basename of the WriteFileStep + pub fn addBuildOptionWriteFile( + self: *LibExeObjStep, + name: []const u8, + write_file: *WriteFileStep, + basename: []const u8, + ) void { + self.build_options_write_file_args.append(.{ + .name = name, + .write_file = write_file, + .basename = basename, + }) catch unreachable; + self.step.dependOn(&write_file.step); + } + pub fn addSystemIncludeDir(self: *LibExeObjStep, path: []const u8) void { self.include_dirs.append(IncludeDir{ .RawPathSystem = self.builder.dupe(path) }) catch unreachable; } @@ -1973,7 +2101,11 @@ pub const LibExeObjStep = struct { pub fn setExecCmd(self: *LibExeObjStep, args: []const ?[]const u8) void { assert(self.kind == Kind.Test); - self.exec_cmd_args = args; + const duped_args = self.builder.allocator.alloc(?[]u8, args.len) catch unreachable; + for (args) |arg, i| { + duped_args[i] = if (arg) |a| self.builder.dupe(a) else null; + } + self.exec_cmd_args = duped_args; } fn linkLibraryOrObject(self: *LibExeObjStep, other: *LibExeObjStep) void { @@ -2019,7 +2151,7 @@ pub const LibExeObjStep = struct { const builder = self.builder; if (self.root_src == null and self.link_objects.items.len == 0) { - warn("{}: linker needs 1 or more objects to link\n", .{self.step.name}); + warn("{s}: linker needs 1 or more objects to link\n", .{self.step.name}); return error.NeedAnObject; } @@ -2123,16 +2255,32 @@ pub const LibExeObjStep = struct { } } - if (self.build_options_contents.items.len > 0 or self.build_options_artifact_args.items.len > 0) { - // Render build artifact options at the last minute, now that the path is known. + if (self.build_options_contents.items.len > 0 or + self.build_options_artifact_args.items.len > 0 or + self.build_options_write_file_args.items.len > 0) + { + // Render build artifact and write file options at the last minute, now that the path is known. + // + // Note that pathFromRoot uses resolve path, so this will have + // correct behavior even if getOutputPath is already absolute. for (self.build_options_artifact_args.items) |item| { - const out = self.build_options_contents.writer(); - out.print("pub const {}: []const u8 = \"{Z}\";\n", .{ item.name, item.artifact.getOutputPath() }) catch unreachable; + self.addBuildOption( + []const u8, + item.name, + self.builder.pathFromRoot(item.artifact.getOutputPath()), + ); + } + for (self.build_options_write_file_args.items) |item| { + self.addBuildOption( + []const u8, + item.name, + self.builder.pathFromRoot(item.write_file.getOutputPath(item.basename)), + ); } const build_options_file = try fs.path.join( builder.allocator, - &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) }, + &[_][]const u8{ builder.cache_root, builder.fmt("{s}_build_options.zig", .{self.name}) }, ); const path_from_root = builder.pathFromRoot(build_options_file); try fs.cwd().writeFile(path_from_root, self.build_options_contents.items); @@ -2230,9 +2378,19 @@ pub const LibExeObjStep = struct { if (self.disable_stack_probing) { try zig_args.append("-fno-stack-check"); } + if (self.red_zone) |red_zone| { + if (red_zone) { + try zig_args.append("-mred-zone"); + } else { + try zig_args.append("-mno-red-zone"); + } + } if (self.disable_sanitize_c) { try zig_args.append("-fno-sanitize-c"); } + if (self.sanitize_thread) { + try zig_args.append("-fsanitize-thread"); + } if (self.rdynamic) { try zig_args.append("-rdynamic"); } @@ -2262,16 +2420,16 @@ pub const LibExeObjStep = struct { } else { var mcpu_buffer = std.ArrayList(u8).init(builder.allocator); - try mcpu_buffer.outStream().print("-mcpu={}", .{cross.cpu.model.name}); + try mcpu_buffer.writer().print("-mcpu={s}", .{cross.cpu.model.name}); for (all_features) |feature, i_usize| { const i = @intCast(std.Target.Cpu.Feature.Set.Index, i_usize); const in_cpu_set = populated_cpu_features.isEnabled(i); const in_actual_set = cross.cpu.features.isEnabled(i); if (in_cpu_set and !in_actual_set) { - try mcpu_buffer.outStream().print("-{}", .{feature.name}); + try mcpu_buffer.writer().print("-{s}", .{feature.name}); } else if (!in_cpu_set and in_actual_set) { - try mcpu_buffer.outStream().print("+{}", .{feature.name}); + try mcpu_buffer.writer().print("+{s}", .{feature.name}); } } @@ -2433,6 +2591,14 @@ pub const LibExeObjStep = struct { } } + if (self.want_lto) |lto| { + if (lto) { + try zig_args.append("-flto"); + } else { + try zig_args.append("-fno-lto"); + } + } + if (self.subsystem) |subsystem| { try zig_args.append("--subsystem"); try zig_args.append(switch (subsystem) { @@ -2504,7 +2670,7 @@ pub const InstallArtifactStep = struct { const self = builder.allocator.create(Self) catch unreachable; self.* = Self{ .builder = builder, - .step = Step.init(.InstallArtifact, builder.fmt("install {}", .{artifact.step.name}), builder.allocator, make), + .step = Step.init(.InstallArtifact, builder.fmt("install {s}", .{artifact.step.name}), builder.allocator, make), .artifact = artifact, .dest_dir = artifact.override_dest_dir orelse switch (artifact.kind) { .Obj => unreachable, @@ -2580,10 +2746,10 @@ pub const InstallFileStep = struct { builder.pushInstalledFile(dir, dest_rel_path); return InstallFileStep{ .builder = builder, - .step = Step.init(.InstallFile, builder.fmt("install {}", .{src_path}), builder.allocator, make), - .src_path = src_path, - .dir = dir, - .dest_rel_path = dest_rel_path, + .step = Step.init(.InstallFile, builder.fmt("install {s}", .{src_path}), builder.allocator, make), + .src_path = builder.dupePath(src_path), + .dir = dir.dupe(builder), + .dest_rel_path = builder.dupePath(dest_rel_path), }; } @@ -2600,6 +2766,18 @@ pub const InstallDirectoryOptions = struct { install_dir: InstallDir, install_subdir: []const u8, exclude_extensions: ?[]const []const u8 = null, + + fn dupe(self: InstallDirectoryOptions, b: *Builder) InstallDirectoryOptions { + return .{ + .source_dir = b.dupe(self.source_dir), + .install_dir = self.install_dir.dupe(b), + .install_subdir = b.dupe(self.install_subdir), + .exclude_extensions = if (self.exclude_extensions) |extensions| + b.dupeStrings(extensions) + else + null, + }; + } }; pub const InstallDirStep = struct { @@ -2614,8 +2792,8 @@ pub const InstallDirStep = struct { builder.pushInstalledFile(options.install_dir, options.install_subdir); return InstallDirStep{ .builder = builder, - .step = Step.init(.InstallDir, builder.fmt("install {}/", .{options.source_dir}), builder.allocator, make), - .options = options, + .step = Step.init(.InstallDir, builder.fmt("install {s}/", .{options.source_dir}), builder.allocator, make), + .options = options.dupe(builder), }; } @@ -2650,14 +2828,14 @@ pub const LogStep = struct { pub fn init(builder: *Builder, data: []const u8) LogStep { return LogStep{ .builder = builder, - .step = Step.init(.Log, builder.fmt("log {}", .{data}), builder.allocator, make), - .data = data, + .step = Step.init(.Log, builder.fmt("log {s}", .{data}), builder.allocator, make), + .data = builder.dupe(data), }; } fn make(step: *Step) anyerror!void { const self = @fieldParentPtr(LogStep, "step", step); - warn("{}", .{self.data}); + warn("{s}", .{self.data}); } }; @@ -2669,8 +2847,8 @@ pub const RemoveDirStep = struct { pub fn init(builder: *Builder, dir_path: []const u8) RemoveDirStep { return RemoveDirStep{ .builder = builder, - .step = Step.init(.RemoveDir, builder.fmt("RemoveDir {}", .{dir_path}), builder.allocator, make), - .dir_path = dir_path, + .step = Step.init(.RemoveDir, builder.fmt("RemoveDir {s}", .{dir_path}), builder.allocator, make), + .dir_path = builder.dupePath(dir_path), }; } @@ -2679,7 +2857,7 @@ pub const RemoveDirStep = struct { const full_path = self.builder.pathFromRoot(self.dir_path); fs.cwd().deleteTree(full_path) catch |err| { - warn("Unable to remove {}: {}\n", .{ full_path, @errorName(err) }); + warn("Unable to remove {s}: {s}\n", .{ full_path, @errorName(err) }); return err; }; } @@ -2714,7 +2892,7 @@ pub const Step = struct { pub fn init(id: Id, name: []const u8, allocator: *Allocator, makeFn: fn (*Step) anyerror!void) Step { return Step{ .id = id, - .name = name, + .name = allocator.dupe(u8, name) catch unreachable, .makeFn = makeFn, .dependencies = ArrayList(*Step).init(allocator), .loop_flag = false, @@ -2767,7 +2945,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj &[_][]const u8{ out_dir, filename_major_only }, ) catch unreachable; fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| { - warn("Unable to symlink {} -> {}\n", .{ major_only_path, out_basename }); + warn("Unable to symlink {s} -> {s}\n", .{ major_only_path, out_basename }); return err; }; // sym link for libfoo.so to libfoo.so.1 @@ -2776,7 +2954,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj &[_][]const u8{ out_dir, filename_name_only }, ) catch unreachable; fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| { - warn("Unable to symlink {} -> {}\n", .{ name_only_path, filename_major_only }); + warn("Unable to symlink {s} -> {s}\n", .{ name_only_path, filename_major_only }); return err; }; } @@ -2821,11 +2999,28 @@ pub const InstallDir = union(enum) { Header: void, /// A path relative to the prefix Custom: []const u8, + + fn dupe(self: InstallDir, builder: *Builder) InstallDir { + if (self == .Custom) { + // Written with this temporary to avoid RLS problems + const duped_path = builder.dupe(self.Custom); + return .{ .Custom = duped_path }; + } else { + return self; + } + } }; pub const InstalledFile = struct { dir: InstallDir, path: []const u8, + + pub fn dupe(self: InstalledFile, builder: *Builder) InstalledFile { + return .{ + .dir = self.dir.dupe(builder), + .path = builder.dupe(self.path), + }; + } }; test "Builder.dupePkg()" { @@ -2943,7 +3138,7 @@ test "LibExeObjStep.addPackage" { std.testing.expectEqualStrings(pkg_top.name, dupe.name); } -test "" { +test { // The only purpose of this test is to get all these untested functions // to be referenced to avoid regression so it is okay to skip some targets. if (comptime std.Target.current.cpu.arch.ptrBitWidth() == 64) { diff --git a/lib/std/build/check_file.zig b/lib/std/build/check_file.zig index e1372c0fe9..28c98547b7 100644 --- a/lib/std/build/check_file.zig +++ b/lib/std/build/check_file.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -27,8 +27,8 @@ pub const CheckFileStep = struct { self.* = CheckFileStep{ .builder = builder, .step = Step.init(.CheckFile, "CheckFile", builder.allocator, make), - .source = source, - .expected_matches = expected_matches, + .source = source.dupe(builder), + .expected_matches = builder.dupeStrings(expected_matches), }; self.source.addStepDependencies(&self.step); return self; @@ -45,9 +45,9 @@ pub const CheckFileStep = struct { warn( \\ \\========= Expected to find: =================== - \\{} + \\{s} \\========= But file does not contain it: ======= - \\{} + \\{s} \\ , .{ expected_match, contents }); return error.TestFailed; diff --git a/lib/std/build/emit_raw.zig b/lib/std/build/emit_raw.zig index ce2b6dfe2a..721b38b7a2 100644 --- a/lib/std/build/emit_raw.zig +++ b/lib/std/build/emit_raw.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -189,7 +189,7 @@ pub const InstallRawStep = struct { pub fn create(builder: *Builder, artifact: *LibExeObjStep, dest_filename: []const u8) *Self { const self = builder.allocator.create(Self) catch unreachable; self.* = Self{ - .step = Step.init(.InstallRaw, builder.fmt("install raw binary {}", .{artifact.step.name}), builder.allocator, make), + .step = Step.init(.InstallRaw, builder.fmt("install raw binary {s}", .{artifact.step.name}), builder.allocator, make), .builder = builder, .artifact = artifact, .dest_dir = switch (artifact.kind) { @@ -223,6 +223,6 @@ pub const InstallRawStep = struct { } }; -test "" { +test { std.testing.refAllDecls(InstallRawStep); } diff --git a/lib/std/build/fmt.zig b/lib/std/build/fmt.zig index 8f0176c00e..069cd348bc 100644 --- a/lib/std/build/fmt.zig +++ b/lib/std/build/fmt.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/build/run.zig b/lib/std/build/run.zig index 137d11f9b5..ca39b0216e 100644 --- a/lib/std/build/run.zig +++ b/lib/std/build/run.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -76,7 +76,7 @@ pub const RunStep = struct { self.argv.append(Arg{ .WriteFile = .{ .step = write_file, - .file_name = file_name, + .file_name = self.builder.dupePath(file_name), }, }) catch unreachable; self.step.dependOn(&write_file.step); @@ -116,10 +116,10 @@ pub const RunStep = struct { } if (prev_path) |pp| { - const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", .{ pp, search_path }); + const new_path = self.builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path }); env_map.set(key, new_path) catch unreachable; } else { - env_map.set(key, search_path) catch unreachable; + env_map.set(key, self.builder.dupePath(search_path)) catch unreachable; } } @@ -134,15 +134,18 @@ pub const RunStep = struct { pub fn setEnvironmentVariable(self: *RunStep, key: []const u8, value: []const u8) void { const env_map = self.getEnvMap(); - env_map.set(key, value) catch unreachable; + env_map.set( + self.builder.dupe(key), + self.builder.dupe(value), + ) catch unreachable; } pub fn expectStdErrEqual(self: *RunStep, bytes: []const u8) void { - self.stderr_action = .{ .expect_exact = bytes }; + self.stderr_action = .{ .expect_exact = self.builder.dupe(bytes) }; } pub fn expectStdOutEqual(self: *RunStep, bytes: []const u8) void { - self.stdout_action = .{ .expect_exact = bytes }; + self.stdout_action = .{ .expect_exact = self.builder.dupe(bytes) }; } fn stdIoActionToBehavior(action: StdIoAction) std.ChildProcess.StdIo { @@ -189,7 +192,7 @@ pub const RunStep = struct { child.stderr_behavior = stdIoActionToBehavior(self.stderr_action); child.spawn() catch |err| { - warn("Unable to spawn {}: {}\n", .{ argv[0], @errorName(err) }); + warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) }); return err; }; @@ -200,7 +203,7 @@ pub const RunStep = struct { switch (self.stdout_action) { .expect_exact, .expect_matches => { - stdout = child.stdout.?.inStream().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable; + stdout = child.stdout.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable; }, .inherit, .ignore => {}, } @@ -210,13 +213,13 @@ pub const RunStep = struct { switch (self.stderr_action) { .expect_exact, .expect_matches => { - stderr = child.stderr.?.inStream().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable; + stderr = child.stderr.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable; }, .inherit, .ignore => {}, } const term = child.wait() catch |err| { - warn("Unable to spawn {}: {}\n", .{ argv[0], @errorName(err) }); + warn("Unable to spawn {s}: {s}\n", .{ argv[0], @errorName(err) }); return err; }; @@ -245,9 +248,9 @@ pub const RunStep = struct { warn( \\ \\========= Expected this stderr: ========= - \\{} + \\{s} \\========= But found: ==================== - \\{} + \\{s} \\ , .{ expected_bytes, stderr.? }); printCmd(cwd, argv); @@ -259,9 +262,9 @@ pub const RunStep = struct { warn( \\ \\========= Expected to find in stderr: ========= - \\{} + \\{s} \\========= But stderr does not contain it: ===== - \\{} + \\{s} \\ , .{ match, stderr.? }); printCmd(cwd, argv); @@ -277,9 +280,9 @@ pub const RunStep = struct { warn( \\ \\========= Expected this stdout: ========= - \\{} + \\{s} \\========= But found: ==================== - \\{} + \\{s} \\ , .{ expected_bytes, stdout.? }); printCmd(cwd, argv); @@ -291,9 +294,9 @@ pub const RunStep = struct { warn( \\ \\========= Expected to find in stdout: ========= - \\{} + \\{s} \\========= But stdout does not contain it: ===== - \\{} + \\{s} \\ , .{ match, stdout.? }); printCmd(cwd, argv); @@ -304,9 +307,9 @@ pub const RunStep = struct { } fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void { - if (cwd) |yes_cwd| warn("cd {} && ", .{yes_cwd}); + if (cwd) |yes_cwd| warn("cd {s} && ", .{yes_cwd}); for (argv) |arg| { - warn("{} ", .{arg}); + warn("{s} ", .{arg}); } warn("\n", .{}); } diff --git a/lib/std/build/translate_c.zig b/lib/std/build/translate_c.zig index 688a7df419..4009079e3d 100644 --- a/lib/std/build/translate_c.zig +++ b/lib/std/build/translate_c.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -57,11 +57,11 @@ pub const TranslateCStep = struct { } pub fn addIncludeDir(self: *TranslateCStep, include_dir: []const u8) void { - self.include_dirs.append(include_dir) catch unreachable; + self.include_dirs.append(self.builder.dupePath(include_dir)) catch unreachable; } pub fn addCheckFile(self: *TranslateCStep, expected_matches: []const []const u8) *CheckFileStep { - return CheckFileStep.create(self.builder, .{ .translate_c = self }, expected_matches); + return CheckFileStep.create(self.builder, .{ .translate_c = self }, self.builder.dupeStrings(expected_matches)); } fn make(step: *Step) !void { diff --git a/lib/std/build/write_file.zig b/lib/std/build/write_file.zig index 923df960de..6e88aa5633 100644 --- a/lib/std/build/write_file.zig +++ b/lib/std/build/write_file.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -32,7 +32,10 @@ pub const WriteFileStep = struct { } pub fn add(self: *WriteFileStep, basename: []const u8, bytes: []const u8) void { - self.files.append(.{ .basename = basename, .bytes = bytes }) catch unreachable; + self.files.append(.{ + .basename = self.builder.dupePath(basename), + .bytes = self.builder.dupe(bytes), + }) catch unreachable; } /// Unless setOutputDir was called, this function must be called only in @@ -72,7 +75,7 @@ pub const WriteFileStep = struct { var digest: [48]u8 = undefined; hash.final(&digest); var hash_basename: [64]u8 = undefined; - fs.base64_encoder.encode(&hash_basename, &digest); + _ = fs.base64_encoder.encode(&hash_basename, &digest); self.output_dir = try fs.path.join(self.builder.allocator, &[_][]const u8{ self.builder.cache_root, "o", @@ -80,14 +83,14 @@ pub const WriteFileStep = struct { }); // TODO replace with something like fs.makePathAndOpenDir fs.cwd().makePath(self.output_dir) catch |err| { - warn("unable to make path {}: {}\n", .{ self.output_dir, @errorName(err) }); + warn("unable to make path {s}: {s}\n", .{ self.output_dir, @errorName(err) }); return err; }; var dir = try fs.cwd().openDir(self.output_dir, .{}); defer dir.close(); for (self.files.items) |file| { dir.writeFile(file.basename, file.bytes) catch |err| { - warn("unable to write {} into {}: {}\n", .{ + warn("unable to write {s} into {s}: {s}\n", .{ file.basename, self.output_dir, @errorName(err), diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index fa6b2ab6b4..93de8ae3b9 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -67,12 +67,12 @@ pub const StackTrace = struct { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const debug_info = std.debug.getSelfDebugInfo() catch |err| { - return writer.print("\nUnable to print stack trace: Unable to open debug info: {}\n", .{@errorName(err)}); + return writer.print("\nUnable to print stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}); }; const tty_config = std.debug.detectTTYConfig(); try writer.writeAll("\n"); std.debug.writeStackTrace(self, writer, &arena.allocator, debug_info, tty_config) catch |err| { - try writer.print("Unable to print stack trace: {}\n", .{@errorName(err)}); + try writer.print("Unable to print stack trace: {s}\n", .{@errorName(err)}); }; try writer.writeAll("\n"); } @@ -155,6 +155,7 @@ pub const CallingConvention = enum { C, Naked, Async, + Inline, Interrupt, Signal, Stdcall, @@ -175,7 +176,7 @@ pub const SourceLocation = struct { column: u32, }; -pub const TypeId = @TagType(TypeInfo); +pub const TypeId = std.meta.Tag(TypeInfo); /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. @@ -404,21 +405,13 @@ pub const TypeInfo = union(enum) { /// therefore must be kept in sync with the compiler implementation. pub const FnDecl = struct { fn_type: type, - inline_type: Inline, + is_noinline: bool, is_var_args: bool, is_extern: bool, is_export: bool, lib_name: ?[]const u8, return_type: type, arg_names: []const []const u8, - - /// This data structure is used by the Zig language code generation and - /// therefore must be kept in sync with the compiler implementation. - pub const Inline = enum { - Auto, - Always, - Never, - }; }; }; }; @@ -529,12 +522,12 @@ pub const Version = struct { if (fmt.len == 0) { if (self.patch == 0) { if (self.minor == 0) { - return std.fmt.format(out_stream, "{}", .{self.major}); + return std.fmt.format(out_stream, "{d}", .{self.major}); } else { - return std.fmt.format(out_stream, "{}.{}", .{ self.major, self.minor }); + return std.fmt.format(out_stream, "{d}.{d}", .{ self.major, self.minor }); } } else { - return std.fmt.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch }); + return std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch }); } } else { @compileError("Unknown format string: '" ++ fmt ++ "'"); @@ -683,7 +676,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn } }, .wasi => { - std.debug.warn("{}", .{msg}); + std.debug.warn("{s}", .{msg}); std.os.abort(); }, .uefi => { @@ -692,7 +685,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn }, else => { const first_trace_addr = @returnAddress(); - std.debug.panicExtra(error_return_trace, first_trace_addr, "{}", .{msg}); + std.debug.panicExtra(error_return_trace, first_trace_addr, "{s}", .{msg}); }, } } diff --git a/lib/std/c.zig b/lib/std/c.zig index a8ac19053d..1688824dd9 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -12,8 +12,9 @@ pub const Token = tokenizer.Token; pub const Tokenizer = tokenizer.Tokenizer; pub const parse = @import("c/parse.zig").parse; pub const ast = @import("c/ast.zig"); +pub const builtins = @import("c/builtins.zig"); -test "" { +test { _ = tokenizer; } @@ -72,14 +73,15 @@ pub fn versionCheck(glibc_version: builtin.Version) type { pub extern "c" var environ: [*:null]?[*:0]u8; -pub extern "c" fn fopen(filename: [*:0]const u8, modes: [*:0]const u8) ?*FILE; +pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE; pub extern "c" fn fclose(stream: *FILE) c_int; -pub extern "c" fn fwrite(ptr: [*]const u8, size_of_type: usize, item_count: usize, stream: *FILE) usize; -pub extern "c" fn fread(ptr: [*]u8, size_of_type: usize, item_count: usize, stream: *FILE) usize; +pub extern "c" fn fwrite(noalias ptr: [*]const u8, size_of_type: usize, item_count: usize, noalias stream: *FILE) usize; +pub extern "c" fn fread(noalias ptr: [*]u8, size_of_type: usize, item_count: usize, noalias stream: *FILE) usize; pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; pub extern "c" fn abort() noreturn; pub extern "c" fn exit(code: c_int) noreturn; +pub extern "c" fn _exit(code: c_int) noreturn; pub extern "c" fn isatty(fd: fd_t) c_int; pub extern "c" fn close(fd: fd_t) c_int; pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t; @@ -98,6 +100,8 @@ pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: u64) pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: u64) *c_void; pub extern "c" fn munmap(addr: *align(page_size) c_void, len: usize) c_int; pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int; +pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: c_int) c_int; +pub extern "c" fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: c_int) c_int; pub extern "c" fn unlink(path: [*:0]const u8) c_int; pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int; pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8; @@ -106,7 +110,6 @@ pub extern "c" fn fork() c_int; pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int; pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int; pub extern "c" fn pipe(fds: *[2]fd_t) c_int; -pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; pub extern "c" fn mkdir(path: [*:0]const u8, mode: c_uint) c_int; pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: u32) c_int; pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int; @@ -151,9 +154,9 @@ pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int; pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int; pub extern "c" fn connect(sockfd: fd_t, sock_addr: *const sockaddr, addrlen: socklen_t) c_int; -pub extern "c" fn accept(sockfd: fd_t, addr: ?*sockaddr, addrlen: ?*socklen_t) c_int; -pub extern "c" fn accept4(sockfd: fd_t, addr: ?*sockaddr, addrlen: ?*socklen_t, flags: c_uint) c_int; -pub extern "c" fn getsockopt(sockfd: fd_t, level: u32, optname: u32, optval: ?*c_void, optlen: *socklen_t) c_int; +pub extern "c" fn accept(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t) c_int; +pub extern "c" fn accept4(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t, flags: c_uint) c_int; +pub extern "c" fn getsockopt(sockfd: fd_t, level: u32, optname: u32, noalias optval: ?*c_void, noalias optlen: *socklen_t) c_int; pub extern "c" fn setsockopt(sockfd: fd_t, level: u32, optname: u32, optval: ?*const c_void, optlen: socklen_t) c_int; pub extern "c" fn send(sockfd: fd_t, buf: *const c_void, len: usize, flags: u32) isize; pub extern "c" fn sendto( @@ -264,6 +267,22 @@ pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: us pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) c_int; pub extern "c" fn pthread_self() pthread_t; pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c_int; +pub extern "c" fn pthread_atfork( + prepare: ?fn () callconv(.C) void, + parent: ?fn () callconv(.C) void, + child: ?fn () callconv(.C) void, +) c_int; +pub extern "c" fn pthread_key_create(key: *pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) c_int; +pub extern "c" fn pthread_key_delete(key: pthread_key_t) c_int; +pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*c_void; +pub extern "c" fn pthread_setspecific(key: pthread_key_t, value: ?*c_void) c_int; +pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int; +pub extern "c" fn sem_destroy(sem: *sem_t) c_int; +pub extern "c" fn sem_post(sem: *sem_t) c_int; +pub extern "c" fn sem_wait(sem: *sem_t) c_int; +pub extern "c" fn sem_trywait(sem: *sem_t) c_int; +pub extern "c" fn sem_timedwait(sem: *sem_t, abs_timeout: *const timespec) c_int; +pub extern "c" fn sem_getvalue(sem: *sem_t, sval: *c_int) c_int; pub extern "c" fn kqueue() c_int; pub extern "c" fn kevent( @@ -310,6 +329,7 @@ pub extern "c" fn dn_expand( pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{}; pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) c_int; pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) c_int; +pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) c_int; pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) c_int; pub const PTHREAD_COND_INITIALIZER = pthread_cond_t{}; @@ -319,6 +339,13 @@ pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) c_int; pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) c_int; pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) c_int; +pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) c_int; +pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; +pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; +pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; +pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; +pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) c_int; + pub const pthread_t = *opaque {}; pub const FILE = opaque {}; @@ -336,6 +363,13 @@ pub extern "c" fn prctl(option: c_int, ...) c_int; pub extern "c" fn getrlimit(resource: rlimit_resource, rlim: *rlimit) c_int; pub extern "c" fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) c_int; +pub extern "c" fn fmemopen(noalias buf: ?*c_void, size: usize, noalias mode: [*:0]const u8) ?*FILE; + +pub extern "c" fn syslog(priority: c_int, message: [*:0]const u8, ...) void; +pub extern "c" fn openlog(ident: [*:0]const u8, logopt: c_int, facility: c_int) void; +pub extern "c" fn closelog() void; +pub extern "c" fn setlogmask(maskpri: c_int) c_int; + pub const max_align_t = if (std.Target.current.abi == .msvc) f64 else if (std.Target.current.isDarwin()) diff --git a/lib/std/c/ast.zig b/lib/std/c/ast.zig index 274481f66e..71455c0ea3 100644 --- a/lib/std/c/ast.zig +++ b/lib/std/c/ast.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -110,15 +110,15 @@ pub const Error = union(enum) { pub const ExpectedToken = struct { token: TokenIndex, - expected_id: @TagType(Token.Id), + expected_id: std.meta.Tag(Token.Id), pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void { const found_token = tree.tokens.at(self.token); if (found_token.id == .Invalid) { - return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()}); + return stream.print("expected '{s}', found invalid bytes", .{self.expected_id.symbol()}); } else { const token_name = found_token.id.symbol(); - return stream.print("expected '{}', found '{}'", .{ self.expected_id.symbol(), token_name }); + return stream.print("expected '{s}', found '{s}'", .{ self.expected_id.symbol(), token_name }); } } }; @@ -131,7 +131,7 @@ pub const Error = union(enum) { try stream.write("invalid type specifier '"); try type_spec.spec.print(tree, stream); const token_name = tree.tokens.at(self.token).id.symbol(); - return stream.print("{}'", .{token_name}); + return stream.print("{s}'", .{token_name}); } }; @@ -140,7 +140,7 @@ pub const Error = union(enum) { name: TokenIndex, pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void { - return stream.print("must use '{}' tag to refer to type '{}'", .{ tree.slice(kw), tree.slice(name) }); + return stream.print("must use '{s}' tag to refer to type '{s}'", .{ tree.slice(kw), tree.slice(name) }); } }; diff --git a/lib/std/c/builtins.zig b/lib/std/c/builtins.zig new file mode 100644 index 0000000000..c11bf0a391 --- /dev/null +++ b/lib/std/c/builtins.zig @@ -0,0 +1,184 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +const std = @import("std"); + +pub fn __builtin_bswap16(val: u16) callconv(.Inline) u16 { + return @byteSwap(u16, val); +} +pub fn __builtin_bswap32(val: u32) callconv(.Inline) u32 { + return @byteSwap(u32, val); +} +pub fn __builtin_bswap64(val: u64) callconv(.Inline) u64 { + return @byteSwap(u64, val); +} + +pub fn __builtin_signbit(val: f64) callconv(.Inline) c_int { + return @boolToInt(std.math.signbit(val)); +} +pub fn __builtin_signbitf(val: f32) callconv(.Inline) c_int { + return @boolToInt(std.math.signbit(val)); +} + +pub fn __builtin_popcount(val: c_uint) callconv(.Inline) c_int { + // popcount of a c_uint will never exceed the capacity of a c_int + @setRuntimeSafety(false); + return @bitCast(c_int, @as(c_uint, @popCount(c_uint, val))); +} +pub fn __builtin_ctz(val: c_uint) callconv(.Inline) c_int { + // Returns the number of trailing 0-bits in val, starting at the least significant bit position. + // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint + @setRuntimeSafety(false); + return @bitCast(c_int, @as(c_uint, @ctz(c_uint, val))); +} +pub fn __builtin_clz(val: c_uint) callconv(.Inline) c_int { + // Returns the number of leading 0-bits in x, starting at the most significant bit position. + // In C if `val` is 0, the result is undefined; in zig it's the number of bits in a c_uint + @setRuntimeSafety(false); + return @bitCast(c_int, @as(c_uint, @clz(c_uint, val))); +} + +pub fn __builtin_sqrt(val: f64) callconv(.Inline) f64 { + return @sqrt(val); +} +pub fn __builtin_sqrtf(val: f32) callconv(.Inline) f32 { + return @sqrt(val); +} + +pub fn __builtin_sin(val: f64) callconv(.Inline) f64 { + return @sin(val); +} +pub fn __builtin_sinf(val: f32) callconv(.Inline) f32 { + return @sin(val); +} +pub fn __builtin_cos(val: f64) callconv(.Inline) f64 { + return @cos(val); +} +pub fn __builtin_cosf(val: f32) callconv(.Inline) f32 { + return @cos(val); +} + +pub fn __builtin_exp(val: f64) callconv(.Inline) f64 { + return @exp(val); +} +pub fn __builtin_expf(val: f32) callconv(.Inline) f32 { + return @exp(val); +} +pub fn __builtin_exp2(val: f64) callconv(.Inline) f64 { + return @exp2(val); +} +pub fn __builtin_exp2f(val: f32) callconv(.Inline) f32 { + return @exp2(val); +} +pub fn __builtin_log(val: f64) callconv(.Inline) f64 { + return @log(val); +} +pub fn __builtin_logf(val: f32) callconv(.Inline) f32 { + return @log(val); +} +pub fn __builtin_log2(val: f64) callconv(.Inline) f64 { + return @log2(val); +} +pub fn __builtin_log2f(val: f32) callconv(.Inline) f32 { + return @log2(val); +} +pub fn __builtin_log10(val: f64) callconv(.Inline) f64 { + return @log10(val); +} +pub fn __builtin_log10f(val: f32) callconv(.Inline) f32 { + return @log10(val); +} + +// Standard C Library bug: The absolute value of the most negative integer remains negative. +pub fn __builtin_abs(val: c_int) callconv(.Inline) c_int { + return std.math.absInt(val) catch std.math.minInt(c_int); +} +pub fn __builtin_fabs(val: f64) callconv(.Inline) f64 { + return @fabs(val); +} +pub fn __builtin_fabsf(val: f32) callconv(.Inline) f32 { + return @fabs(val); +} + +pub fn __builtin_floor(val: f64) callconv(.Inline) f64 { + return @floor(val); +} +pub fn __builtin_floorf(val: f32) callconv(.Inline) f32 { + return @floor(val); +} +pub fn __builtin_ceil(val: f64) callconv(.Inline) f64 { + return @ceil(val); +} +pub fn __builtin_ceilf(val: f32) callconv(.Inline) f32 { + return @ceil(val); +} +pub fn __builtin_trunc(val: f64) callconv(.Inline) f64 { + return @trunc(val); +} +pub fn __builtin_truncf(val: f32) callconv(.Inline) f32 { + return @trunc(val); +} +pub fn __builtin_round(val: f64) callconv(.Inline) f64 { + return @round(val); +} +pub fn __builtin_roundf(val: f32) callconv(.Inline) f32 { + return @round(val); +} + +pub fn __builtin_strlen(s: [*c]const u8) callconv(.Inline) usize { + return std.mem.lenZ(s); +} +pub fn __builtin_strcmp(s1: [*c]const u8, s2: [*c]const u8) callconv(.Inline) c_int { + return @as(c_int, std.cstr.cmp(s1, s2)); +} + +pub fn __builtin_object_size(ptr: ?*const c_void, ty: c_int) callconv(.Inline) usize { + // clang semantics match gcc's: https://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html + // If it is not possible to determine which objects ptr points to at compile time, + // __builtin_object_size should return (size_t) -1 for type 0 or 1 and (size_t) 0 + // for type 2 or 3. + if (ty == 0 or ty == 1) return @bitCast(usize, -@as(c_long, 1)); + if (ty == 2 or ty == 3) return 0; + unreachable; +} + +pub fn __builtin___memset_chk( + dst: ?*c_void, + val: c_int, + len: usize, + remaining: usize, +) callconv(.Inline) ?*c_void { + if (len > remaining) @panic("std.c.builtins.memset_chk called with len > remaining"); + return __builtin_memset(dst, val, len); +} + +pub fn __builtin_memset(dst: ?*c_void, val: c_int, len: usize) callconv(.Inline) ?*c_void { + const dst_cast = @ptrCast([*c]u8, dst); + @memset(dst_cast, @bitCast(u8, @truncate(i8, val)), len); + return dst; +} + +pub fn __builtin___memcpy_chk( + noalias dst: ?*c_void, + noalias src: ?*const c_void, + len: usize, + remaining: usize, +) callconv(.Inline) ?*c_void { + if (len > remaining) @panic("std.c.builtins.memcpy_chk called with len > remaining"); + return __builtin_memcpy(dst, src, len); +} + +pub fn __builtin_memcpy( + noalias dst: ?*c_void, + noalias src: ?*const c_void, + len: usize, +) callconv(.Inline) ?*c_void { + const dst_cast = @ptrCast([*c]u8, dst); + const src_cast = @ptrCast([*c]const u8, src); + + @memcpy(dst_cast, src_cast, len); + return dst; +} diff --git a/lib/std/c/darwin.zig b/lib/std/c/darwin.zig index 635e0f97d4..b5c3fbf977 100644 --- a/lib/std/c/darwin.zig +++ b/lib/std/c/darwin.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -177,6 +177,11 @@ pub const pthread_cond_t = extern struct { __sig: c_long = 0x3CB0B1BB, __opaque: [__PTHREAD_COND_SIZE__]u8 = [_]u8{0} ** __PTHREAD_COND_SIZE__, }; +pub const pthread_rwlock_t = extern struct { + __sig: c_long = 0x2DA8B3B4, + __opaque: [192]u8 = [_]u8{0} ** 192, +}; +pub const sem_t = c_int; const __PTHREAD_MUTEX_SIZE__ = if (@sizeOf(usize) == 8) 56 else 40; const __PTHREAD_COND_SIZE__ = if (@sizeOf(usize) == 8) 40 else 24; @@ -185,4 +190,19 @@ pub const pthread_attr_t = extern struct { __opaque: [56]u8, }; +const pthread_t = std.c.pthread_t; +pub extern "c" fn pthread_threadid_np(thread: ?pthread_t, thread_id: *u64) c_int; + pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; + +// Grand Central Dispatch is exposed by libSystem. +pub const dispatch_semaphore_t = *opaque {}; +pub const dispatch_time_t = u64; +pub const DISPATCH_TIME_NOW = @as(dispatch_time_t, 0); +pub const DISPATCH_TIME_FOREVER = ~@as(dispatch_time_t, 0); +pub extern "c" fn dispatch_semaphore_create(value: isize) ?dispatch_semaphore_t; +pub extern "c" fn dispatch_semaphore_wait(dsema: dispatch_semaphore_t, timeout: dispatch_time_t) isize; +pub extern "c" fn dispatch_semaphore_signal(dsema: dispatch_semaphore_t) isize; + +pub extern "c" fn dispatch_release(object: *c_void) void; +pub extern "c" fn dispatch_time(when: dispatch_time_t, delta: i64) dispatch_time_t; diff --git a/lib/std/c/dragonfly.zig b/lib/std/c/dragonfly.zig index 3261d34b78..4e6650094b 100644 --- a/lib/std/c/dragonfly.zig +++ b/lib/std/c/dragonfly.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -13,6 +13,7 @@ pub fn _errno() *c_int { pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; +pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int; pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; diff --git a/lib/std/c/emscripten.zig b/lib/std/c/emscripten.zig index e94a6f1004..526eb9e99c 100644 --- a/lib/std/c/emscripten.zig +++ b/lib/std/c/emscripten.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -9,5 +9,8 @@ pub const pthread_mutex_t = extern struct { pub const pthread_cond_t = extern struct { size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T, }; +pub const pthread_rwlock_t = extern struct { + size: [32]u8 align(4) = [_]u8{0} ** 32, +}; const __SIZEOF_PTHREAD_COND_T = 48; const __SIZEOF_PTHREAD_MUTEX_T = 28; diff --git a/lib/std/c/freebsd.zig b/lib/std/c/freebsd.zig index 8fa78b0d6f..795b36dc68 100644 --- a/lib/std/c/freebsd.zig +++ b/lib/std/c/freebsd.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -13,6 +13,9 @@ pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; pub extern "c" fn getrandom(buf_ptr: [*]u8, buf_len: usize, flags: c_uint) isize; +pub extern "c" fn pthread_getthreadid_np() c_int; +pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; + pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int; pub extern "c" fn malloc_usable_size(?*const c_void) usize; @@ -41,12 +44,24 @@ pub const pthread_mutex_t = extern struct { pub const pthread_cond_t = extern struct { inner: ?*c_void = null, }; +pub const pthread_rwlock_t = extern struct { + ptr: ?*c_void = null, +}; pub const pthread_attr_t = extern struct { __size: [56]u8, __align: c_long, }; +pub const sem_t = extern struct { + _magic: u32, + _kern: extern struct { + _count: u32, + _flags: u32, + }, + _padding: u32, +}; + pub const EAI = extern enum(c_int) { /// address family for hostname not supported ADDRFAMILY = 1, diff --git a/lib/std/c/fuchsia.zig b/lib/std/c/fuchsia.zig index ceeb34a763..fc34f49d22 100644 --- a/lib/std/c/fuchsia.zig +++ b/lib/std/c/fuchsia.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -9,5 +9,8 @@ pub const pthread_mutex_t = extern struct { pub const pthread_cond_t = extern struct { size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T, }; +pub const pthread_rwlock_t = extern struct { + size: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56, +}; const __SIZEOF_PTHREAD_COND_T = 48; const __SIZEOF_PTHREAD_MUTEX_T = 40; diff --git a/lib/std/c/haiku.zig b/lib/std/c/haiku.zig index 6b56e163c8..e361a7520e 100644 --- a/lib/std/c/haiku.zig +++ b/lib/std/c/haiku.zig @@ -1,8 +1,51 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. + +// +const std = @import("../std.zig"); +const builtin = std.builtin; + +usingnamespace std.c; + +extern "c" fn _errnop() *c_int; + +pub const _errno = _errnop; + +pub extern "c" fn find_directory(which: c_int, volume: i32, createIt: bool, path_ptr: [*]u8, length: i32) u64; + +pub extern "c" fn find_thread(thread_name: ?*c_void) i32; + +pub extern "c" fn get_system_info(system_info: *system_info) usize; + +// TODO revisit if abi changes or better option becomes apparent +pub extern "c" fn _get_next_image_info(team: c_int, cookie: *i32, image_info: *image_info) usize; + +pub extern "c" fn _kern_read_dir(fd: c_int, buf_ptr: [*]u8, nbytes: usize, maxcount: u32) usize; + +pub extern "c" fn _kern_read_stat(fd: c_int, path_ptr: [*]u8, traverse_link: bool, libc_stat: *libc_stat, stat_size: i32) usize; + +pub extern "c" fn _kern_get_current_team() i32; + +pub const sem_t = extern struct { + _magic: u32, + _kern: extern struct { + _count: u32, + _flags: u32, + }, + _padding: u32, +}; + +pub const pthread_attr_t = extern struct { + __detach_state: i32, + __sched_priority: i32, + __stack_size: i32, + __guard_size: i32, + __stack_address: ?*c_void, +}; + pub const pthread_mutex_t = extern struct { flags: u32 = 0, lock: i32 = 0, @@ -17,3 +60,12 @@ pub const pthread_cond_t = extern struct { waiter_count: i32 = 0, lock: i32 = 0, }; +pub const pthread_rwlock_t = extern struct { + flags: u32 = 0, + owner: i32 = -1, + lock_sem: i32 = 0, + lock_count: i32 = 0, + reader_count: i32 = 0, + writer_count: i32 = 0, + waiters: [2]?*c_void = [_]?*c_void{ null, null }, +}; diff --git a/lib/std/c/hermit.zig b/lib/std/c/hermit.zig index 6762e60962..a159395ab3 100644 --- a/lib/std/c/hermit.zig +++ b/lib/std/c/hermit.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -9,3 +9,6 @@ pub const pthread_mutex_t = extern struct { pub const pthread_cond_t = extern struct { inner: usize = ~@as(usize, 0), }; +pub const pthread_rwlock_t = extern struct { + ptr: usize = std.math.maxInt(usize), +}; diff --git a/lib/std/c/linux.zig b/lib/std/c/linux.zig index 21124d1030..d2018f6f79 100644 --- a/lib/std/c/linux.zig +++ b/lib/std/c/linux.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -86,6 +86,7 @@ pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_ pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; pub extern "c" fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int; +pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; pub extern "c" fn fallocate(fd: fd_t, mode: c_int, offset: off_t, len: off_t) c_int; @@ -106,6 +107,12 @@ pub extern "c" fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: *con pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int; pub extern "c" fn malloc_usable_size(?*const c_void) usize; +pub extern "c" fn madvise( + addr: *align(std.mem.page_size) c_void, + length: usize, + advice: c_uint, +) c_int; + pub const pthread_attr_t = extern struct { __size: [56]u8, __align: c_long, @@ -117,6 +124,36 @@ pub const pthread_mutex_t = extern struct { pub const pthread_cond_t = extern struct { size: [__SIZEOF_PTHREAD_COND_T]u8 align(@alignOf(usize)) = [_]u8{0} ** __SIZEOF_PTHREAD_COND_T, }; +pub const pthread_rwlock_t = switch (std.builtin.abi) { + .android => switch (@sizeOf(usize)) { + 4 => extern struct { + lock: std.c.pthread_mutex_t = std.c.PTHREAD_MUTEX_INITIALIZER, + cond: std.c.pthread_cond_t = std.c.PTHREAD_COND_INITIALIZER, + numLocks: c_int = 0, + writerThreadId: c_int = 0, + pendingReaders: c_int = 0, + pendingWriters: c_int = 0, + attr: i32 = 0, + __reserved: [12]u8 = [_]u8{0} ** 2, + }, + 8 => extern struct { + numLocks: c_int = 0, + writerThreadId: c_int = 0, + pendingReaders: c_int = 0, + pendingWriters: c_int = 0, + attr: i32 = 0, + __reserved: [36]u8 = [_]u8{0} ** 36, + }, + else => unreachable, + }, + else => extern struct { + size: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56, + }, +}; +pub const sem_t = extern struct { + __size: [__SIZEOF_SEM_T]u8 align(@alignOf(usize)), +}; + const __SIZEOF_PTHREAD_COND_T = 48; const __SIZEOF_PTHREAD_MUTEX_T = if (builtin.os.tag == .fuchsia) 40 else switch (builtin.abi) { .musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24, @@ -128,6 +165,7 @@ const __SIZEOF_PTHREAD_MUTEX_T = if (builtin.os.tag == .fuchsia) 40 else switch }, else => unreachable, }; +const __SIZEOF_SEM_T = 4 * @sizeOf(usize); pub const RTLD_LAZY = 1; pub const RTLD_NOW = 2; diff --git a/lib/std/c/minix.zig b/lib/std/c/minix.zig index 2bc1bac47a..6cf5684079 100644 --- a/lib/std/c/minix.zig +++ b/lib/std/c/minix.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/c/netbsd.zig b/lib/std/c/netbsd.zig index e6d7e86bee..7169095197 100644 --- a/lib/std/c/netbsd.zig +++ b/lib/std/c/netbsd.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -14,6 +14,9 @@ pub const _errno = __errno; pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int; pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int; +pub extern "c" fn _lwp_self() lwpid_t; + +pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int; pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int; @@ -52,6 +55,22 @@ pub const pthread_cond_t = extern struct { ptc_private: ?*c_void = null, }; +pub const pthread_rwlock_t = extern struct { + ptr_magic: c_uint = 0x99990009, + ptr_interlock: switch (std.builtin.arch) { + .aarch64, .sparc, .x86_64, .i386 => u8, + .arm, .powerpc => c_int, + else => unreachable, + } = 0, + ptr_rblocked_first: ?*u8 = null, + ptr_rblocked_last: ?*u8 = null, + ptr_wblocked_first: ?*u8 = null, + ptr_wblocked_last: ?*u8 = null, + ptr_nreaders: c_uint = 0, + ptr_owner: std.c.pthread_t = null, + ptr_private: ?*c_void = null, +}; + const pthread_spin_t = switch (builtin.arch) { .aarch64, .aarch64_be, .aarch64_32 => u8, .mips, .mipsel, .mips64, .mips64el => u32, diff --git a/lib/std/c/openbsd.zig b/lib/std/c/openbsd.zig index ab193abb6b..cac3df867d 100644 --- a/lib/std/c/openbsd.zig +++ b/lib/std/c/openbsd.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -16,6 +16,9 @@ pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_ pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void; +pub extern "c" fn getthrid() pid_t; +pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; + pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize; pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int; @@ -25,12 +28,20 @@ pub const pthread_mutex_t = extern struct { pub const pthread_cond_t = extern struct { inner: ?*c_void = null, }; +pub const pthread_rwlock_t = extern struct { + ptr: ?*c_void = null, +}; pub const pthread_spinlock_t = extern struct { inner: ?*c_void = null, }; - pub const pthread_attr_t = extern struct { inner: ?*c_void = null, }; +pub const pthread_key_t = c_int; + +pub const sem_t = ?*opaque {}; pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int; + +pub extern "c" fn pledge(promises: ?[*:0]const u8, execpromises: ?[*:0]const u8) c_int; +pub extern "c" fn unveil(path: ?[*:0]const u8, permissions: ?[*:0]const u8) c_int; diff --git a/lib/std/c/parse.zig b/lib/std/c/parse.zig index d5b1a4a01e..29d4ba2fe1 100644 --- a/lib/std/c/parse.zig +++ b/lib/std/c/parse.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -26,7 +26,7 @@ pub const Options = struct { None, /// Some warnings are errors - Some: []@TagType(ast.Error), + Some: []std.meta.Tag(ast.Error), /// All warnings are errors All, @@ -300,8 +300,7 @@ const Parser = struct { try node.initializers.push((try parser.initializer(dr)) orelse return parser.err(.{ .ExpectedInitializer = .{ .token = parser.it.index }, })); - } else - try node.initializers.push(&dr.base); + } else try node.initializers.push(&dr.base); if (parser.eatToken(.Comma) != null) break; dr = @fieldParentPtr(Node.Declarator, "base", (try parser.declarator(.Must)) orelse return parser.err(.{ .ExpectedDeclarator = .{ .token = parser.it.index }, @@ -1363,7 +1362,7 @@ const Parser = struct { return &node.base; } - fn eatToken(parser: *Parser, id: @TagType(Token.Id)) ?TokenIndex { + fn eatToken(parser: *Parser, id: std.meta.Tag(Token.Id)) ?TokenIndex { while (true) { switch ((parser.it.next() orelse return null).id) { .LineComment, .MultiLineComment, .Nl => continue, @@ -1377,7 +1376,7 @@ const Parser = struct { } } - fn expectToken(parser: *Parser, id: @TagType(Token.Id)) Error!TokenIndex { + fn expectToken(parser: *Parser, id: std.meta.Tag(Token.Id)) Error!TokenIndex { while (true) { switch ((parser.it.next() orelse return error.ParseError).id) { .LineComment, .MultiLineComment, .Nl => continue, diff --git a/lib/std/c/solaris.zig b/lib/std/c/solaris.zig index 49ce0886f7..ed043018d0 100644 --- a/lib/std/c/solaris.zig +++ b/lib/std/c/solaris.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/c/tokenizer.zig b/lib/std/c/tokenizer.zig index 9e9b5f4147..2e1969e269 100644 --- a/lib/std/c/tokenizer.zig +++ b/lib/std/c/tokenizer.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -131,7 +131,7 @@ pub const Token = struct { Keyword_error, Keyword_pragma, - pub fn symbol(id: @TagType(Id)) []const u8 { + pub fn symbol(id: std.meta.TagType(Id)) []const u8 { return switch (id) { .Invalid => "Invalid", .Eof => "Eof", @@ -347,7 +347,7 @@ pub const Token = struct { pub const Tokenizer = struct { buffer: []const u8, index: usize = 0, - prev_tok_id: @TagType(Token.Id) = .Invalid, + prev_tok_id: std.meta.TagType(Token.Id) = .Invalid, pp_directive: bool = false, pub fn next(self: *Tokenizer) Token { @@ -446,7 +446,7 @@ pub const Tokenizer = struct { 'L' => { state = .L; }, - 'a'...'t', 'v'...'z', 'A'...'K', 'M'...'T', 'V'...'Z', '_' => { + 'a'...'t', 'v'...'z', 'A'...'K', 'M'...'T', 'V'...'Z', '_', '$' => { state = .Identifier; }, '=' => { @@ -776,7 +776,7 @@ pub const Tokenizer = struct { }, }, .Identifier => switch (c) { - 'a'...'z', 'A'...'Z', '_', '0'...'9' => {}, + 'a'...'z', 'A'...'Z', '_', '0'...'9', '$' => {}, else => { result.id = Token.getKeyword(self.buffer[result.start..self.index], self.prev_tok_id == .Hash and !self.pp_directive) orelse .Identifier; if (self.prev_tok_id == .Hash) @@ -1552,7 +1552,7 @@ fn expectTokens(source: []const u8, expected_tokens: []const Token.Id) void { for (expected_tokens) |expected_token_id| { const token = tokenizer.next(); if (!std.meta.eql(token.id, expected_token_id)) { - std.debug.panic("expected {}, found {}\n", .{ @tagName(expected_token_id), @tagName(token.id) }); + std.debug.panic("expected {s}, found {s}\n", .{ @tagName(expected_token_id), @tagName(token.id) }); } } const last_token = tokenizer.next(); diff --git a/lib/std/c/windows.zig b/lib/std/c/windows.zig index f96da56c1f..bed2e421ff 100644 --- a/lib/std/c/windows.zig +++ b/lib/std/c/windows.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index b61fe9470d..d37dd9fdf5 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -15,11 +15,11 @@ const windows = os.windows; const mem = std.mem; const debug = std.debug; const BufMap = std.BufMap; -const ArrayListSentineled = std.ArrayListSentineled; const builtin = @import("builtin"); const Os = builtin.Os; const TailQueue = std.TailQueue; const maxInt = std.math.maxInt; +const assert = std.debug.assert; pub const ChildProcess = struct { pid: if (builtin.os.tag == .windows) void else i32, @@ -186,6 +186,58 @@ pub const ChildProcess = struct { pub const exec2 = @compileError("deprecated: exec2 is renamed to exec"); + fn collectOutputPosix( + child: *const ChildProcess, + stdout: *std.ArrayList(u8), + stderr: *std.ArrayList(u8), + max_output_bytes: usize, + ) !void { + var poll_fds = [_]os.pollfd{ + .{ .fd = child.stdout.?.handle, .events = os.POLLIN, .revents = undefined }, + .{ .fd = child.stderr.?.handle, .events = os.POLLIN, .revents = undefined }, + }; + + var dead_fds: usize = 0; + // We ask for ensureCapacity with this much extra space. This has more of an + // effect on small reads because once the reads start to get larger the amount + // of space an ArrayList will allocate grows exponentially. + const bump_amt = 512; + + while (dead_fds < poll_fds.len) { + const events = try os.poll(&poll_fds, std.math.maxInt(i32)); + if (events == 0) continue; + + // Try reading whatever is available before checking the error + // conditions. + if (poll_fds[0].revents & os.POLLIN != 0) { + // stdout is ready. + const new_capacity = std.math.min(stdout.items.len + bump_amt, max_output_bytes); + try stdout.ensureCapacity(new_capacity); + const buf = stdout.unusedCapacitySlice(); + if (buf.len == 0) return error.StdoutStreamTooLong; + stdout.items.len += try os.read(poll_fds[0].fd, buf); + } + if (poll_fds[1].revents & os.POLLIN != 0) { + // stderr is ready. + const new_capacity = std.math.min(stderr.items.len + bump_amt, max_output_bytes); + try stderr.ensureCapacity(new_capacity); + const buf = stderr.unusedCapacitySlice(); + if (buf.len == 0) return error.StderrStreamTooLong; + stderr.items.len += try os.read(poll_fds[1].fd, buf); + } + + // Exclude the fds that signaled an error. + if (poll_fds[0].revents & (os.POLLERR | os.POLLNVAL | os.POLLHUP) != 0) { + poll_fds[0].fd = -1; + dead_fds += 1; + } + if (poll_fds[1].revents & (os.POLLERR | os.POLLNVAL | os.POLLHUP) != 0) { + poll_fds[1].fd = -1; + dead_fds += 1; + } + } + } + /// Spawns a child process, waits for it, collecting stdout and stderr, and then returns. /// If it succeeds, the caller owns result.stdout and result.stderr memory. pub fn exec(args: struct { @@ -210,19 +262,33 @@ pub const ChildProcess = struct { try child.spawn(); - const stdout_in = child.stdout.?.reader(); - const stderr_in = child.stderr.?.reader(); + // TODO collect output in a deadlock-avoiding way on Windows. + // https://github.com/ziglang/zig/issues/6343 + if (builtin.os.tag == .windows) { + const stdout_in = child.stdout.?.reader(); + const stderr_in = child.stderr.?.reader(); - // TODO https://github.com/ziglang/zig/issues/6343 - const stdout = try stdout_in.readAllAlloc(args.allocator, args.max_output_bytes); - errdefer args.allocator.free(stdout); - const stderr = try stderr_in.readAllAlloc(args.allocator, args.max_output_bytes); - errdefer args.allocator.free(stderr); + const stdout = try stdout_in.readAllAlloc(args.allocator, args.max_output_bytes); + errdefer args.allocator.free(stdout); + const stderr = try stderr_in.readAllAlloc(args.allocator, args.max_output_bytes); + errdefer args.allocator.free(stderr); + + return ExecResult{ + .term = try child.wait(), + .stdout = stdout, + .stderr = stderr, + }; + } + + var stdout = std.ArrayList(u8).init(args.allocator); + var stderr = std.ArrayList(u8).init(args.allocator); + + try collectOutputPosix(child, &stdout, &stderr, args.max_output_bytes); return ExecResult{ .term = try child.wait(), - .stdout = stdout, - .stderr = stderr, + .stdout = stdout.toOwnedSlice(), + .stderr = stderr.toOwnedSlice(), }; } @@ -377,19 +443,37 @@ pub const ChildProcess = struct { if (any_ignore) os.close(dev_null_fd); } - var env_map_owned: BufMap = undefined; - var we_own_env_map: bool = undefined; - const env_map = if (self.env_map) |env_map| x: { - we_own_env_map = false; - break :x env_map; - } else x: { - we_own_env_map = true; - env_map_owned = try process.getEnvMap(self.allocator); - break :x &env_map_owned; + var arena_allocator = std.heap.ArenaAllocator.init(self.allocator); + defer arena_allocator.deinit(); + const arena = &arena_allocator.allocator; + + // The POSIX standard does not allow malloc() between fork() and execve(), + // and `self.allocator` may be a libc allocator. + // I have personally observed the child process deadlocking when it tries + // to call malloc() due to a heap allocation between fork() and execve(), + // in musl v1.1.24. + // Additionally, we want to reduce the number of possible ways things + // can fail between fork() and execve(). + // Therefore, we do all the allocation for the execve() before the fork(). + // This means we must do the null-termination of argv and env vars here. + const argv_buf = try arena.allocSentinel(?[*:0]u8, self.argv.len, null); + for (self.argv) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr; + + const envp = m: { + if (self.env_map) |env_map| { + const envp_buf = try createNullDelimitedEnvMap(arena, env_map); + break :m envp_buf.ptr; + } else if (std.builtin.link_libc) { + break :m std.c.environ; + } else if (std.builtin.output_mode == .Exe) { + // Then we have Zig start code and this works. + // TODO type-safety for null-termination of `os.environ`. + break :m @ptrCast([*:null]?[*:0]u8, os.environ.ptr); + } else { + // TODO come up with a solution for this. + @compileError("missing std lib enhancement: ChildProcess implementation has no way to collect the environment variables to forward to the child process"); + } }; - defer { - if (we_own_env_map) env_map_owned.deinit(); - } // This pipe is used to communicate errors between the time of fork // and execve from the child process to the parent process. @@ -439,7 +523,10 @@ pub const ChildProcess = struct { os.setreuid(uid, uid) catch |err| forkChildErrReport(err_pipe[1], err); } - const err = os.execvpe_expandArg0(self.allocator, self.expand_arg0, self.argv, env_map); + const err = switch (self.expand_arg0) { + .expand => os.execvpeZ_expandArg0(.expand, argv_buf.ptr[0].?, argv_buf.ptr, envp), + .no_expand => os.execvpeZ_expandArg0(.no_expand, argv_buf.ptr[0].?, argv_buf.ptr, envp), + }; forkChildErrReport(err_pipe[1], err); } @@ -749,38 +836,37 @@ fn windowsCreateProcess(app_name: [*:0]u16, cmd_line: [*:0]u16, envp_ptr: ?[*]u1 /// Caller must dealloc. fn windowsCreateCommandLine(allocator: *mem.Allocator, argv: []const []const u8) ![:0]u8 { - var buf = try ArrayListSentineled(u8, 0).initSize(allocator, 0); + var buf = std.ArrayList(u8).init(allocator); defer buf.deinit(); - const buf_stream = buf.outStream(); for (argv) |arg, arg_i| { - if (arg_i != 0) try buf_stream.writeByte(' '); + if (arg_i != 0) try buf.append(' '); if (mem.indexOfAny(u8, arg, " \t\n\"") == null) { - try buf_stream.writeAll(arg); + try buf.appendSlice(arg); continue; } - try buf_stream.writeByte('"'); + try buf.append('"'); var backslash_count: usize = 0; for (arg) |byte| { switch (byte) { '\\' => backslash_count += 1, '"' => { - try buf_stream.writeByteNTimes('\\', backslash_count * 2 + 1); - try buf_stream.writeByte('"'); + try buf.appendNTimes('\\', backslash_count * 2 + 1); + try buf.append('"'); backslash_count = 0; }, else => { - try buf_stream.writeByteNTimes('\\', backslash_count); - try buf_stream.writeByte(byte); + try buf.appendNTimes('\\', backslash_count); + try buf.append(byte); backslash_count = 0; }, } } - try buf_stream.writeByteNTimes('\\', backslash_count * 2); - try buf_stream.writeByte('"'); + try buf.appendNTimes('\\', backslash_count * 2); + try buf.append('"'); } - return buf.toOwnedSlice(); + return buf.toOwnedSliceSentinel(0); } fn windowsDestroyPipe(rd: ?windows.HANDLE, wr: ?windows.HANDLE) void { @@ -821,8 +907,9 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn { // which we really do not want to run in the fork child. I caught LLVM doing this and // it caused a deadlock instead of doing an exit syscall. In the words of Avril Lavigne, // "Why'd you have to go and make things so complicated?" - if (std.Target.current.os.tag == .linux) { - std.os.linux.exit(1); // By-pass libc regardless of whether it is linked. + if (builtin.link_libc) { + // The _exit(2) function does nothing but make the exit syscall, unlike exit(3) + std.c._exit(1); } os.exit(1); } @@ -835,7 +922,7 @@ fn writeIntFd(fd: i32, value: ErrInt) !void { .capable_io_mode = .blocking, .intended_io_mode = .blocking, }; - file.outStream().writeIntNative(u64, @intCast(u64, value)) catch return error.SystemResources; + file.writer().writeIntNative(u64, @intCast(u64, value)) catch return error.SystemResources; } fn readIntFd(fd: i32) !ErrInt { @@ -883,3 +970,54 @@ pub fn createWindowsEnvBlock(allocator: *mem.Allocator, env_map: *const BufMap) i += 1; return allocator.shrink(result, i); } + +pub fn createNullDelimitedEnvMap(arena: *mem.Allocator, env_map: *const std.BufMap) ![:null]?[*:0]u8 { + const envp_count = env_map.count(); + const envp_buf = try arena.allocSentinel(?[*:0]u8, envp_count, null); + { + var it = env_map.iterator(); + var i: usize = 0; + while (it.next()) |pair| : (i += 1) { + const env_buf = try arena.allocSentinel(u8, pair.key.len + pair.value.len + 1, 0); + mem.copy(u8, env_buf, pair.key); + env_buf[pair.key.len] = '='; + mem.copy(u8, env_buf[pair.key.len + 1 ..], pair.value); + envp_buf[i] = env_buf.ptr; + } + assert(i == envp_count); + } + return envp_buf; +} + +test "createNullDelimitedEnvMap" { + const testing = std.testing; + const allocator = testing.allocator; + var envmap = BufMap.init(allocator); + defer envmap.deinit(); + + try envmap.set("HOME", "/home/ifreund"); + try envmap.set("WAYLAND_DISPLAY", "wayland-1"); + try envmap.set("DISPLAY", ":1"); + try envmap.set("DEBUGINFOD_URLS", " "); + try envmap.set("XCURSOR_SIZE", "24"); + + var arena = std.heap.ArenaAllocator.init(allocator); + defer arena.deinit(); + const environ = try createNullDelimitedEnvMap(&arena.allocator, &envmap); + + testing.expectEqual(@as(usize, 5), environ.len); + + inline for (.{ + "HOME=/home/ifreund", + "WAYLAND_DISPLAY=wayland-1", + "DISPLAY=:1", + "DEBUGINFOD_URLS= ", + "XCURSOR_SIZE=24", + }) |target| { + for (environ) |variable| { + if (mem.eql(u8, mem.span(variable orelse continue), target)) break; + } else { + testing.expect(false); // Environment variable not found + } + } +} diff --git a/lib/std/coff.zig b/lib/std/coff.zig index 1fdf3f8893..edeff89cc5 100644 --- a/lib/std/coff.zig +++ b/lib/std/coff.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -127,7 +127,7 @@ pub const Coff = struct { pub fn loadHeader(self: *Coff) !void { const pe_pointer_offset = 0x3C; - const in = self.in_file.inStream(); + const in = self.in_file.reader(); var magic: [2]u8 = undefined; try in.readNoEof(magic[0..]); @@ -163,7 +163,7 @@ pub const Coff = struct { } fn loadOptionalHeader(self: *Coff) !void { - const in = self.in_file.inStream(); + const in = self.in_file.reader(); self.pe_header.magic = try in.readIntLittle(u16); // For now we're only interested in finding the reference to the .pdb, // so we'll skip most of this header, which size is different in 32 @@ -173,8 +173,7 @@ pub const Coff = struct { skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 18 * @sizeOf(u32); } else if (self.pe_header.magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) { skip_size = 2 * @sizeOf(u8) + 8 * @sizeOf(u16) + 12 * @sizeOf(u32) + 5 * @sizeOf(u64); - } else - return error.InvalidPEMagic; + } else return error.InvalidPEMagic; try self.in_file.seekBy(skip_size); @@ -206,7 +205,7 @@ pub const Coff = struct { const debug_dir = &self.pe_header.data_directory[DEBUG_DIRECTORY]; const file_offset = debug_dir.virtual_address - header.virtual_address + header.pointer_to_raw_data; - const in = self.in_file.inStream(); + const in = self.in_file.reader(); try self.in_file.seekTo(file_offset); // Find the correct DebugDirectoryEntry, and where its data is stored. @@ -257,7 +256,7 @@ pub const Coff = struct { try self.sections.ensureCapacity(self.coff_header.number_of_sections); - const in = self.in_file.inStream(); + const in = self.in_file.reader(); var name: [8]u8 = undefined; diff --git a/lib/std/compress.zig b/lib/std/compress.zig index 95f496021e..972031c182 100644 --- a/lib/std/compress.zig +++ b/lib/std/compress.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -9,7 +9,7 @@ pub const deflate = @import("compress/deflate.zig"); pub const gzip = @import("compress/gzip.zig"); pub const zlib = @import("compress/zlib.zig"); -test "" { +test { _ = gzip; _ = zlib; } diff --git a/lib/std/compress/deflate.zig b/lib/std/compress/deflate.zig index addd1b1a27..e680dc9e6f 100644 --- a/lib/std/compress/deflate.zig +++ b/lib/std/compress/deflate.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -209,7 +209,7 @@ pub fn InflateStream(comptime ReaderType: type) type { // Insert a single byte into the window. // Assumes there's enough space. - inline fn appendUnsafe(self: *WSelf, value: u8) void { + fn appendUnsafe(self: *WSelf, value: u8) callconv(.Inline) void { self.buf[self.wi] = value; self.wi = (self.wi + 1) & (self.buf.len - 1); self.el += 1; diff --git a/lib/std/compress/gzip.zig b/lib/std/compress/gzip.zig index aad1731393..89aa12207b 100644 --- a/lib/std/compress/gzip.zig +++ b/lib/std/compress/gzip.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/compress/zlib.zig b/lib/std/compress/zlib.zig index 63ef6c2aee..7ef644ef6d 100644 --- a/lib/std/compress/zlib.zig +++ b/lib/std/compress/zlib.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/comptime_string_map.zig b/lib/std/comptime_string_map.zig index ed647124a8..4882924ae5 100644 --- a/lib/std/comptime_string_map.zig +++ b/lib/std/comptime_string_map.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto.zig b/lib/std/crypto.zig index 6eb934473f..da6ec2edf0 100644 --- a/lib/std/crypto.zig +++ b/lib/std/crypto.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -134,10 +134,15 @@ pub const nacl = struct { pub const utils = @import("crypto/utils.zig"); +/// This is a thread-local, cryptographically secure pseudo random number generator. +pub const random = &@import("crypto/tlcsprng.zig").interface; + const std = @import("std.zig"); -pub const randomBytes = std.os.getrandom; test "crypto" { + const please_windows_dont_oom = std.Target.current.os.tag == .windows; + if (please_windows_dont_oom) return error.SkipZigTest; + inline for (std.meta.declarations(@This())) |decl| { switch (decl.data) { .Type => |t| { @@ -178,6 +183,13 @@ test "crypto" { _ = @import("crypto/25519/ristretto255.zig"); } +test "CSPRNG" { + const a = random.int(u64); + const b = random.int(u64); + const c = random.int(u64); + std.testing.expect(a ^ b ^ c != 0); +} + test "issue #4532: no index out of bounds" { const types = [_]type{ hash.Md5, diff --git a/lib/std/crypto/25519/curve25519.zig b/lib/std/crypto/25519/curve25519.zig index 3ca7af7a41..765ffa1629 100644 --- a/lib/std/crypto/25519/curve25519.zig +++ b/lib/std/crypto/25519/curve25519.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -15,12 +15,12 @@ pub const Curve25519 = struct { x: Fe, /// Decode a Curve25519 point from its compressed (X) coordinates. - pub inline fn fromBytes(s: [32]u8) Curve25519 { + pub fn fromBytes(s: [32]u8) callconv(.Inline) Curve25519 { return .{ .x = Fe.fromBytes(s) }; } /// Encode a Curve25519 point. - pub inline fn toBytes(p: Curve25519) [32]u8 { + pub fn toBytes(p: Curve25519) callconv(.Inline) [32]u8 { return p.x.toBytes(); } diff --git a/lib/std/crypto/25519/ed25519.zig b/lib/std/crypto/25519/ed25519.zig index 842b08d706..5c7ec0cdac 100644 --- a/lib/std/crypto/25519/ed25519.zig +++ b/lib/std/crypto/25519/ed25519.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -43,7 +43,7 @@ pub const Ed25519 = struct { pub fn create(seed: ?[seed_length]u8) !KeyPair { const ss = seed orelse ss: { var random_seed: [seed_length]u8 = undefined; - try crypto.randomBytes(&random_seed); + crypto.random.bytes(&random_seed); break :ss random_seed; }; var az: [Sha512.digest_length]u8 = undefined; @@ -179,7 +179,7 @@ pub const Ed25519 = struct { var z_batch: [count]Curve.scalar.CompressedScalar = undefined; for (z_batch) |*z| { - try std.crypto.randomBytes(z[0..16]); + std.crypto.random.bytes(z[0..16]); mem.set(u8, z[16..], 0); } @@ -207,7 +207,7 @@ pub const Ed25519 = struct { test "ed25519 key pair creation" { var seed: [32]u8 = undefined; - try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); + _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); const key_pair = try Ed25519.KeyPair.create(seed); var buf: [256]u8 = undefined; std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{key_pair.secret_key}), "8052030376D47112BE7F73ED7A019293DD12AD910B654455798B4667D73DE1662D6F7455D97B4A3A10D7293909D1A4F2058CB9A370E43FA8154BB280DB839083"); @@ -216,7 +216,7 @@ test "ed25519 key pair creation" { test "ed25519 signature" { var seed: [32]u8 = undefined; - try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); + _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); const key_pair = try Ed25519.KeyPair.create(seed); const sig = try Ed25519.sign("test", key_pair, null); @@ -232,8 +232,8 @@ test "ed25519 batch verification" { const key_pair = try Ed25519.KeyPair.create(null); var msg1: [32]u8 = undefined; var msg2: [32]u8 = undefined; - try std.crypto.randomBytes(&msg1); - try std.crypto.randomBytes(&msg2); + std.crypto.random.bytes(&msg1); + std.crypto.random.bytes(&msg2); const sig1 = try Ed25519.sign(&msg1, key_pair, null); const sig2 = try Ed25519.sign(&msg2, key_pair, null); var signature_batch = [_]Ed25519.BatchElement{ @@ -339,11 +339,11 @@ test "ed25519 test vectors" { }; for (entries) |entry, i| { var msg: [entry.msg_hex.len / 2]u8 = undefined; - try fmt.hexToBytes(&msg, entry.msg_hex); + _ = try fmt.hexToBytes(&msg, entry.msg_hex); var public_key: [32]u8 = undefined; - try fmt.hexToBytes(&public_key, entry.public_key_hex); + _ = try fmt.hexToBytes(&public_key, entry.public_key_hex); var sig: [64]u8 = undefined; - try fmt.hexToBytes(&sig, entry.sig_hex); + _ = try fmt.hexToBytes(&sig, entry.sig_hex); if (entry.expected) |error_type| { std.testing.expectError(error_type, Ed25519.verify(sig, &msg, public_key)); } else { diff --git a/lib/std/crypto/25519/edwards25519.zig b/lib/std/crypto/25519/edwards25519.zig index 008a4535b3..d4238f87bb 100644 --- a/lib/std/crypto/25519/edwards25519.zig +++ b/lib/std/crypto/25519/edwards25519.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -92,7 +92,7 @@ pub const Edwards25519 = struct { } /// Flip the sign of the X coordinate. - pub inline fn neg(p: Edwards25519) Edwards25519 { + pub fn neg(p: Edwards25519) callconv(.Inline) Edwards25519 { return .{ .x = p.x.neg(), .y = p.y, .z = p.z, .t = p.t.neg() }; } @@ -137,14 +137,14 @@ pub const Edwards25519 = struct { return p.add(q.neg()); } - inline fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) void { + fn cMov(p: *Edwards25519, a: Edwards25519, c: u64) callconv(.Inline) void { p.x.cMov(a.x, c); p.y.cMov(a.y, c); p.z.cMov(a.z, c); p.t.cMov(a.t, c); } - inline fn pcSelect(comptime n: usize, pc: [n]Edwards25519, b: u8) Edwards25519 { + fn pcSelect(comptime n: usize, pc: [n]Edwards25519, b: u8) callconv(.Inline) Edwards25519 { var t = Edwards25519.identityElement; comptime var i: u8 = 1; inline while (i < pc.len) : (i += 1) { @@ -484,8 +484,8 @@ test "edwards25519 packing/unpacking" { test "edwards25519 point addition/substraction" { var s1: [32]u8 = undefined; var s2: [32]u8 = undefined; - try std.crypto.randomBytes(&s1); - try std.crypto.randomBytes(&s2); + std.crypto.random.bytes(&s1); + std.crypto.random.bytes(&s2); const p = try Edwards25519.basePoint.clampedMul(s1); const q = try Edwards25519.basePoint.clampedMul(s2); const r = p.add(q).add(q).sub(q).sub(q); diff --git a/lib/std/crypto/25519/field.zig b/lib/std/crypto/25519/field.zig index d2002ce52d..320cb1bb51 100644 --- a/lib/std/crypto/25519/field.zig +++ b/lib/std/crypto/25519/field.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -52,7 +52,7 @@ pub const Fe = struct { pub const edwards25519sqrtam2 = Fe{ .limbs = .{ 1693982333959686, 608509411481997, 2235573344831311, 947681270984193, 266558006233600 } }; /// Return true if the field element is zero - pub inline fn isZero(fe: Fe) bool { + pub fn isZero(fe: Fe) callconv(.Inline) bool { var reduced = fe; reduced.reduce(); const limbs = reduced.limbs; @@ -60,7 +60,7 @@ pub const Fe = struct { } /// Return true if both field elements are equivalent - pub inline fn equivalent(a: Fe, b: Fe) bool { + pub fn equivalent(a: Fe, b: Fe) callconv(.Inline) bool { return a.sub(b).isZero(); } @@ -164,7 +164,7 @@ pub const Fe = struct { } /// Add a field element - pub inline fn add(a: Fe, b: Fe) Fe { + pub fn add(a: Fe, b: Fe) callconv(.Inline) Fe { var fe: Fe = undefined; comptime var i = 0; inline while (i < 5) : (i += 1) { @@ -174,7 +174,7 @@ pub const Fe = struct { } /// Substract a field elememnt - pub inline fn sub(a: Fe, b: Fe) Fe { + pub fn sub(a: Fe, b: Fe) callconv(.Inline) Fe { var fe = b; comptime var i = 0; inline while (i < 4) : (i += 1) { @@ -193,17 +193,17 @@ pub const Fe = struct { } /// Negate a field element - pub inline fn neg(a: Fe) Fe { + pub fn neg(a: Fe) callconv(.Inline) Fe { return zero.sub(a); } /// Return true if a field element is negative - pub inline fn isNegative(a: Fe) bool { + pub fn isNegative(a: Fe) callconv(.Inline) bool { return (a.toBytes()[0] & 1) != 0; } /// Conditonally replace a field element with `a` if `c` is positive - pub inline fn cMov(fe: *Fe, a: Fe, c: u64) void { + pub fn cMov(fe: *Fe, a: Fe, c: u64) callconv(.Inline) void { const mask: u64 = 0 -% c; var x = fe.*; comptime var i = 0; @@ -244,7 +244,7 @@ pub const Fe = struct { } } - inline fn _carry128(r: *[5]u128) Fe { + fn _carry128(r: *[5]u128) callconv(.Inline) Fe { var rs: [5]u64 = undefined; comptime var i = 0; inline while (i < 4) : (i += 1) { @@ -265,7 +265,7 @@ pub const Fe = struct { } /// Multiply two field elements - pub inline fn mul(a: Fe, b: Fe) Fe { + pub fn mul(a: Fe, b: Fe) callconv(.Inline) Fe { var ax: [5]u128 = undefined; var bx: [5]u128 = undefined; var a19: [5]u128 = undefined; @@ -288,7 +288,7 @@ pub const Fe = struct { return _carry128(&r); } - inline fn _sq(a: Fe, double: comptime bool) Fe { + fn _sq(a: Fe, double: comptime bool) callconv(.Inline) Fe { var ax: [5]u128 = undefined; var r: [5]u128 = undefined; comptime var i = 0; @@ -317,17 +317,17 @@ pub const Fe = struct { } /// Square a field element - pub inline fn sq(a: Fe) Fe { + pub fn sq(a: Fe) callconv(.Inline) Fe { return _sq(a, false); } /// Square and double a field element - pub inline fn sq2(a: Fe) Fe { + pub fn sq2(a: Fe) callconv(.Inline) Fe { return _sq(a, true); } /// Multiply a field element with a small (32-bit) integer - pub inline fn mul32(a: Fe, comptime n: u32) Fe { + pub fn mul32(a: Fe, comptime n: u32) callconv(.Inline) Fe { const sn = @intCast(u128, n); var fe: Fe = undefined; var x: u128 = 0; @@ -342,7 +342,7 @@ pub const Fe = struct { } /// Square a field element `n` times - inline fn sqn(a: Fe, comptime n: comptime_int) Fe { + fn sqn(a: Fe, comptime n: comptime_int) callconv(.Inline) Fe { var i: usize = 0; var fe = a; while (i < n) : (i += 1) { diff --git a/lib/std/crypto/25519/ristretto255.zig b/lib/std/crypto/25519/ristretto255.zig index 16d301592a..df85422f65 100644 --- a/lib/std/crypto/25519/ristretto255.zig +++ b/lib/std/crypto/25519/ristretto255.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -42,7 +42,7 @@ pub const Ristretto255 = struct { } /// Reject the neutral element. - pub inline fn rejectIdentity(p: Ristretto255) !void { + pub fn rejectIdentity(p: Ristretto255) callconv(.Inline) !void { return p.p.rejectIdentity(); } @@ -141,19 +141,19 @@ pub const Ristretto255 = struct { } /// Double a Ristretto255 element. - pub inline fn dbl(p: Ristretto255) Ristretto255 { + pub fn dbl(p: Ristretto255) callconv(.Inline) Ristretto255 { return .{ .p = p.p.dbl() }; } /// Add two Ristretto255 elements. - pub inline fn add(p: Ristretto255, q: Ristretto255) Ristretto255 { + pub fn add(p: Ristretto255, q: Ristretto255) callconv(.Inline) Ristretto255 { return .{ .p = p.p.add(q.p) }; } /// Multiply a Ristretto255 element with a scalar. /// Return error.WeakPublicKey if the resulting element is /// the identity element. - pub inline fn mul(p: Ristretto255, s: [encoded_length]u8) !Ristretto255 { + pub fn mul(p: Ristretto255, s: [encoded_length]u8) callconv(.Inline) !Ristretto255 { return Ristretto255{ .p = try p.p.mul(s) }; } @@ -173,7 +173,7 @@ test "ristretto255" { std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{p.toBytes()}), "E2F2AE0A6ABC4E71A884A961C500515F58E30B6AA582DD8DB6A65945E08D2D76"); var r: [Ristretto255.encoded_length]u8 = undefined; - try fmt.hexToBytes(r[0..], "6a493210f7499cd17fecb510ae0cea23a110e8d5b901f8acadd3095c73a3b919"); + _ = try fmt.hexToBytes(r[0..], "6a493210f7499cd17fecb510ae0cea23a110e8d5b901f8acadd3095c73a3b919"); var q = try Ristretto255.fromBytes(r); q = q.dbl().add(p); std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{q.toBytes()}), "E882B131016B52C1D3337080187CF768423EFCCBB517BB495AB812C4160FF44E"); diff --git a/lib/std/crypto/25519/scalar.zig b/lib/std/crypto/25519/scalar.zig index c5e460d29e..ceff153bff 100644 --- a/lib/std/crypto/25519/scalar.zig +++ b/lib/std/crypto/25519/scalar.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -46,7 +46,7 @@ pub fn reduce64(s: [64]u8) [32]u8 { /// Perform the X25519 "clamping" operation. /// The scalar is then guaranteed to be a multiple of the cofactor. -pub inline fn clamp(s: *[32]u8) void { +pub fn clamp(s: *[32]u8) callconv(.Inline) void { s[0] &= 248; s[31] = (s[31] & 127) | 64; } diff --git a/lib/std/crypto/25519/x25519.zig b/lib/std/crypto/25519/x25519.zig index 3b3ff551fe..5d0479bd4d 100644 --- a/lib/std/crypto/25519/x25519.zig +++ b/lib/std/crypto/25519/x25519.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -34,7 +34,7 @@ pub const X25519 = struct { pub fn create(seed: ?[seed_length]u8) !KeyPair { const sk = seed orelse sk: { var random_seed: [seed_length]u8 = undefined; - try crypto.randomBytes(&random_seed); + crypto.random.bytes(&random_seed); break :sk random_seed; }; var kp: KeyPair = undefined; @@ -85,8 +85,8 @@ const htest = @import("../test.zig"); test "x25519 public key calculation from secret key" { var sk: [32]u8 = undefined; var pk_expected: [32]u8 = undefined; - try fmt.hexToBytes(sk[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); - try fmt.hexToBytes(pk_expected[0..], "f1814f0e8ff1043d8a44d25babff3cedcae6c22c3edaa48f857ae70de2baae50"); + _ = try fmt.hexToBytes(sk[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); + _ = try fmt.hexToBytes(pk_expected[0..], "f1814f0e8ff1043d8a44d25babff3cedcae6c22c3edaa48f857ae70de2baae50"); const pk_calculated = try X25519.recoverPublicKey(sk); std.testing.expectEqual(pk_calculated, pk_expected); } diff --git a/lib/std/crypto/aegis.zig b/lib/std/crypto/aegis.zig index f3060ef615..2983f68ce8 100644 --- a/lib/std/crypto/aegis.zig +++ b/lib/std/crypto/aegis.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -35,7 +35,7 @@ const State128L = struct { return state; } - inline fn update(state: *State128L, d1: AesBlock, d2: AesBlock) void { + fn update(state: *State128L, d1: AesBlock, d2: AesBlock) callconv(.Inline) void { const blocks = &state.blocks; const tmp = blocks[7]; comptime var i: usize = 7; @@ -81,8 +81,8 @@ const State128L = struct { while (i < 7) : (i += 1) { state.update(tmp, tmp); } - return blocks[0].xorBlocks(blocks[1]).xorBlocks(blocks[2]).xorBlocks(blocks[3]).xorBlocks(blocks[4]). - xorBlocks(blocks[5]).xorBlocks(blocks[6]).toBytes(); + return blocks[0].xorBlocks(blocks[1]).xorBlocks(blocks[2]).xorBlocks(blocks[3]).xorBlocks(blocks[4]) + .xorBlocks(blocks[5]).xorBlocks(blocks[6]).toBytes(); } }; @@ -207,7 +207,7 @@ const State256 = struct { return state; } - inline fn update(state: *State256, d: AesBlock) void { + fn update(state: *State256, d: AesBlock) callconv(.Inline) void { const blocks = &state.blocks; const tmp = blocks[5].encrypt(blocks[0]); comptime var i: usize = 5; @@ -244,8 +244,8 @@ const State256 = struct { while (i < 7) : (i += 1) { state.update(tmp); } - return blocks[0].xorBlocks(blocks[1]).xorBlocks(blocks[2]).xorBlocks(blocks[3]).xorBlocks(blocks[4]). - xorBlocks(blocks[5]).toBytes(); + return blocks[0].xorBlocks(blocks[1]).xorBlocks(blocks[2]).xorBlocks(blocks[3]).xorBlocks(blocks[4]) + .xorBlocks(blocks[5]).toBytes(); } }; diff --git a/lib/std/crypto/aes.zig b/lib/std/crypto/aes.zig index ada55fa975..2a81492c8a 100644 --- a/lib/std/crypto/aes.zig +++ b/lib/std/crypto/aes.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -122,11 +122,11 @@ test "expand 128-bit key" { var exp: [16]u8 = undefined; for (enc.key_schedule.round_keys) |round_key, i| { - try std.fmt.hexToBytes(&exp, exp_enc[i]); + _ = try std.fmt.hexToBytes(&exp, exp_enc[i]); testing.expectEqualSlices(u8, &exp, &round_key.toBytes()); } for (enc.key_schedule.round_keys) |round_key, i| { - try std.fmt.hexToBytes(&exp, exp_dec[i]); + _ = try std.fmt.hexToBytes(&exp, exp_dec[i]); testing.expectEqualSlices(u8, &exp, &round_key.toBytes()); } } @@ -144,11 +144,11 @@ test "expand 256-bit key" { var exp: [16]u8 = undefined; for (enc.key_schedule.round_keys) |round_key, i| { - try std.fmt.hexToBytes(&exp, exp_enc[i]); + _ = try std.fmt.hexToBytes(&exp, exp_enc[i]); testing.expectEqualSlices(u8, &exp, &round_key.toBytes()); } for (dec.key_schedule.round_keys) |round_key, i| { - try std.fmt.hexToBytes(&exp, exp_dec[i]); + _ = try std.fmt.hexToBytes(&exp, exp_dec[i]); testing.expectEqualSlices(u8, &exp, &round_key.toBytes()); } } diff --git a/lib/std/crypto/aes/aesni.zig b/lib/std/crypto/aes/aesni.zig index 3d694875bf..13b3f8e527 100644 --- a/lib/std/crypto/aes/aesni.zig +++ b/lib/std/crypto/aes/aesni.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -19,24 +19,24 @@ pub const Block = struct { repr: BlockVec, /// Convert a byte sequence into an internal representation. - pub inline fn fromBytes(bytes: *const [16]u8) Block { + pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block { const repr = mem.bytesToValue(BlockVec, bytes); return Block{ .repr = repr }; } /// Convert the internal representation of a block into a byte sequence. - pub inline fn toBytes(block: Block) [16]u8 { + pub fn toBytes(block: Block) callconv(.Inline) [16]u8 { return mem.toBytes(block.repr); } /// XOR the block with a byte sequence. - pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 { + pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 { const x = block.repr ^ fromBytes(bytes).repr; return mem.toBytes(x); } /// Encrypt a block with a round key. - pub inline fn encrypt(block: Block, round_key: Block) Block { + pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block { return Block{ .repr = asm ( \\ vaesenc %[rk], %[in], %[out] @@ -48,7 +48,7 @@ pub const Block = struct { } /// Encrypt a block with the last round key. - pub inline fn encryptLast(block: Block, round_key: Block) Block { + pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block { return Block{ .repr = asm ( \\ vaesenclast %[rk], %[in], %[out] @@ -60,7 +60,7 @@ pub const Block = struct { } /// Decrypt a block with a round key. - pub inline fn decrypt(block: Block, inv_round_key: Block) Block { + pub fn decrypt(block: Block, inv_round_key: Block) callconv(.Inline) Block { return Block{ .repr = asm ( \\ vaesdec %[rk], %[in], %[out] @@ -72,7 +72,7 @@ pub const Block = struct { } /// Decrypt a block with the last round key. - pub inline fn decryptLast(block: Block, inv_round_key: Block) Block { + pub fn decryptLast(block: Block, inv_round_key: Block) callconv(.Inline) Block { return Block{ .repr = asm ( \\ vaesdeclast %[rk], %[in], %[out] @@ -84,17 +84,17 @@ pub const Block = struct { } /// Apply the bitwise XOR operation to the content of two blocks. - pub inline fn xorBlocks(block1: Block, block2: Block) Block { + pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block { return Block{ .repr = block1.repr ^ block2.repr }; } /// Apply the bitwise AND operation to the content of two blocks. - pub inline fn andBlocks(block1: Block, block2: Block) Block { + pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block { return Block{ .repr = block1.repr & block2.repr }; } /// Apply the bitwise OR operation to the content of two blocks. - pub inline fn orBlocks(block1: Block, block2: Block) Block { + pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block { return Block{ .repr = block1.repr | block2.repr }; } @@ -114,7 +114,7 @@ pub const Block = struct { }; /// Encrypt multiple blocks in parallel, each their own round key. - pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { + pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -124,7 +124,7 @@ pub const Block = struct { } /// Decrypt multiple blocks in parallel, each their own round key. - pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { + pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -134,7 +134,7 @@ pub const Block = struct { } /// Encrypt multiple blocks in parallel with the same round key. - pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { + pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -144,7 +144,7 @@ pub const Block = struct { } /// Decrypt multiple blocks in parallel with the same round key. - pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { + pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -154,7 +154,7 @@ pub const Block = struct { } /// Encrypt multiple blocks in parallel with the same last round key. - pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { + pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -164,7 +164,7 @@ pub const Block = struct { } /// Decrypt multiple blocks in parallel with the same last round key. - pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { + pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { diff --git a/lib/std/crypto/aes/armcrypto.zig b/lib/std/crypto/aes/armcrypto.zig index 79eb9dda75..d331783284 100644 --- a/lib/std/crypto/aes/armcrypto.zig +++ b/lib/std/crypto/aes/armcrypto.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -19,18 +19,18 @@ pub const Block = struct { repr: BlockVec, /// Convert a byte sequence into an internal representation. - pub inline fn fromBytes(bytes: *const [16]u8) Block { + pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block { const repr = mem.bytesToValue(BlockVec, bytes); return Block{ .repr = repr }; } /// Convert the internal representation of a block into a byte sequence. - pub inline fn toBytes(block: Block) [16]u8 { + pub fn toBytes(block: Block) callconv(.Inline) [16]u8 { return mem.toBytes(block.repr); } /// XOR the block with a byte sequence. - pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 { + pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 { const x = block.repr ^ fromBytes(bytes).repr; return mem.toBytes(x); } @@ -38,7 +38,7 @@ pub const Block = struct { const zero = Vector(2, u64){ 0, 0 }; /// Encrypt a block with a round key. - pub inline fn encrypt(block: Block, round_key: Block) Block { + pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block { return Block{ .repr = asm ( \\ mov %[out].16b, %[in].16b @@ -54,7 +54,7 @@ pub const Block = struct { } /// Encrypt a block with the last round key. - pub inline fn encryptLast(block: Block, round_key: Block) Block { + pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block { return Block{ .repr = asm ( \\ mov %[out].16b, %[in].16b @@ -69,7 +69,7 @@ pub const Block = struct { } /// Decrypt a block with a round key. - pub inline fn decrypt(block: Block, inv_round_key: Block) Block { + pub fn decrypt(block: Block, inv_round_key: Block) callconv(.Inline) Block { return Block{ .repr = asm ( \\ mov %[out].16b, %[in].16b @@ -85,7 +85,7 @@ pub const Block = struct { } /// Decrypt a block with the last round key. - pub inline fn decryptLast(block: Block, inv_round_key: Block) Block { + pub fn decryptLast(block: Block, inv_round_key: Block) callconv(.Inline) Block { return Block{ .repr = asm ( \\ mov %[out].16b, %[in].16b @@ -100,17 +100,17 @@ pub const Block = struct { } /// Apply the bitwise XOR operation to the content of two blocks. - pub inline fn xorBlocks(block1: Block, block2: Block) Block { + pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block { return Block{ .repr = block1.repr ^ block2.repr }; } /// Apply the bitwise AND operation to the content of two blocks. - pub inline fn andBlocks(block1: Block, block2: Block) Block { + pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block { return Block{ .repr = block1.repr & block2.repr }; } /// Apply the bitwise OR operation to the content of two blocks. - pub inline fn orBlocks(block1: Block, block2: Block) Block { + pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block { return Block{ .repr = block1.repr | block2.repr }; } @@ -120,7 +120,7 @@ pub const Block = struct { pub const optimal_parallel_blocks = 8; /// Encrypt multiple blocks in parallel, each their own round key. - pub inline fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { + pub fn encryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -130,7 +130,7 @@ pub const Block = struct { } /// Decrypt multiple blocks in parallel, each their own round key. - pub inline fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) [count]Block { + pub fn decryptParallel(comptime count: usize, blocks: [count]Block, round_keys: [count]Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -140,7 +140,7 @@ pub const Block = struct { } /// Encrypt multiple blocks in parallel with the same round key. - pub inline fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { + pub fn encryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -150,7 +150,7 @@ pub const Block = struct { } /// Decrypt multiple blocks in parallel with the same round key. - pub inline fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { + pub fn decryptWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -160,7 +160,7 @@ pub const Block = struct { } /// Encrypt multiple blocks in parallel with the same last round key. - pub inline fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { + pub fn encryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { @@ -170,7 +170,7 @@ pub const Block = struct { } /// Decrypt multiple blocks in parallel with the same last round key. - pub inline fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) [count]Block { + pub fn decryptLastWide(comptime count: usize, blocks: [count]Block, round_key: Block) callconv(.Inline) [count]Block { comptime var i = 0; var out: [count]Block = undefined; inline while (i < count) : (i += 1) { diff --git a/lib/std/crypto/aes/soft.zig b/lib/std/crypto/aes/soft.zig index e9108820b1..6f305b4050 100644 --- a/lib/std/crypto/aes/soft.zig +++ b/lib/std/crypto/aes/soft.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -18,7 +18,7 @@ pub const Block = struct { repr: BlockVec align(16), /// Convert a byte sequence into an internal representation. - pub inline fn fromBytes(bytes: *const [16]u8) Block { + pub fn fromBytes(bytes: *const [16]u8) callconv(.Inline) Block { const s0 = mem.readIntBig(u32, bytes[0..4]); const s1 = mem.readIntBig(u32, bytes[4..8]); const s2 = mem.readIntBig(u32, bytes[8..12]); @@ -27,7 +27,7 @@ pub const Block = struct { } /// Convert the internal representation of a block into a byte sequence. - pub inline fn toBytes(block: Block) [16]u8 { + pub fn toBytes(block: Block) callconv(.Inline) [16]u8 { var bytes: [16]u8 = undefined; mem.writeIntBig(u32, bytes[0..4], block.repr[0]); mem.writeIntBig(u32, bytes[4..8], block.repr[1]); @@ -37,7 +37,7 @@ pub const Block = struct { } /// XOR the block with a byte sequence. - pub inline fn xorBytes(block: Block, bytes: *const [16]u8) [16]u8 { + pub fn xorBytes(block: Block, bytes: *const [16]u8) callconv(.Inline) [16]u8 { const block_bytes = block.toBytes(); var x: [16]u8 = undefined; comptime var i: usize = 0; @@ -48,7 +48,7 @@ pub const Block = struct { } /// Encrypt a block with a round key. - pub inline fn encrypt(block: Block, round_key: Block) Block { + pub fn encrypt(block: Block, round_key: Block) callconv(.Inline) Block { const src = &block.repr; const s0 = block.repr[0]; @@ -65,7 +65,7 @@ pub const Block = struct { } /// Encrypt a block with the last round key. - pub inline fn encryptLast(block: Block, round_key: Block) Block { + pub fn encryptLast(block: Block, round_key: Block) callconv(.Inline) Block { const src = &block.repr; const t0 = block.repr[0]; @@ -87,7 +87,7 @@ pub const Block = struct { } /// Decrypt a block with a round key. - pub inline fn decrypt(block: Block, round_key: Block) Block { + pub fn decrypt(block: Block, round_key: Block) callconv(.Inline) Block { const src = &block.repr; const s0 = block.repr[0]; @@ -104,7 +104,7 @@ pub const Block = struct { } /// Decrypt a block with the last round key. - pub inline fn decryptLast(block: Block, round_key: Block) Block { + pub fn decryptLast(block: Block, round_key: Block) callconv(.Inline) Block { const src = &block.repr; const t0 = block.repr[0]; @@ -126,7 +126,7 @@ pub const Block = struct { } /// Apply the bitwise XOR operation to the content of two blocks. - pub inline fn xorBlocks(block1: Block, block2: Block) Block { + pub fn xorBlocks(block1: Block, block2: Block) callconv(.Inline) Block { var x: BlockVec = undefined; comptime var i = 0; inline while (i < 4) : (i += 1) { @@ -136,7 +136,7 @@ pub const Block = struct { } /// Apply the bitwise AND operation to the content of two blocks. - pub inline fn andBlocks(block1: Block, block2: Block) Block { + pub fn andBlocks(block1: Block, block2: Block) callconv(.Inline) Block { var x: BlockVec = undefined; comptime var i = 0; inline while (i < 4) : (i += 1) { @@ -146,7 +146,7 @@ pub const Block = struct { } /// Apply the bitwise OR operation to the content of two blocks. - pub inline fn orBlocks(block1: Block, block2: Block) Block { + pub fn orBlocks(block1: Block, block2: Block) callconv(.Inline) Block { var x: BlockVec = undefined; comptime var i = 0; inline while (i < 4) : (i += 1) { diff --git a/lib/std/crypto/aes_gcm.zig b/lib/std/crypto/aes_gcm.zig index e57decb2b2..5ef3f93963 100644 --- a/lib/std/crypto/aes_gcm.zig +++ b/lib/std/crypto/aes_gcm.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/bcrypt.zig b/lib/std/crypto/bcrypt.zig index 4cec59961b..caceb6d7b9 100644 --- a/lib/std/crypto/bcrypt.zig +++ b/lib/std/crypto/bcrypt.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -109,9 +109,7 @@ const State = struct { } } - const Halves = struct { - l: u32, r: u32 - }; + const Halves = struct { l: u32, r: u32 }; fn feistelF(state: State, x: u32) u32 { var r = state.sboxes[0][@truncate(u8, x >> 24)]; @@ -247,7 +245,7 @@ fn strHashInternal(password: []const u8, rounds_log: u6, salt: [salt_length]u8) Codec.encode(ct_str[0..], ct[0 .. ct.len - 1]); var s_buf: [hash_length]u8 = undefined; - const s = fmt.bufPrint(s_buf[0..], "$2b${}{}${}{}", .{ rounds_log / 10, rounds_log % 10, salt_str, ct_str }) catch unreachable; + const s = fmt.bufPrint(s_buf[0..], "$2b${d}{d}${s}{s}", .{ rounds_log / 10, rounds_log % 10, salt_str, ct_str }) catch unreachable; debug.assert(s.len == s_buf.len); return s_buf; } @@ -262,7 +260,7 @@ fn strHashInternal(password: []const u8, rounds_log: u6, salt: [salt_length]u8) /// and then use the resulting hash as the password parameter for bcrypt. pub fn strHash(password: []const u8, rounds_log: u6) ![hash_length]u8 { var salt: [salt_length]u8 = undefined; - try crypto.randomBytes(&salt); + crypto.random.bytes(&salt); return strHashInternal(password, rounds_log, salt); } @@ -283,7 +281,7 @@ pub fn strVerify(h: [hash_length]u8, password: []const u8) BcryptError!void { test "bcrypt codec" { var salt: [salt_length]u8 = undefined; - try crypto.randomBytes(&salt); + crypto.random.bytes(&salt); var salt_str: [salt_str_length]u8 = undefined; Codec.encode(salt_str[0..], salt[0..]); var salt2: [salt_length]u8 = undefined; diff --git a/lib/std/crypto/benchmark.zig b/lib/std/crypto/benchmark.zig index 7a0253861b..00336aef87 100644 --- a/lib/std/crypto/benchmark.zig +++ b/lib/std/crypto/benchmark.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -314,7 +314,7 @@ fn mode(comptime x: comptime_int) comptime_int { } pub fn main() !void { - const stdout = std.io.getStdOut().outStream(); + const stdout = std.io.getStdOut().writer(); var buffer: [1024]u8 = undefined; var fixed = std.heap.FixedBufferAllocator.init(buffer[0..]); diff --git a/lib/std/crypto/blake2.zig b/lib/std/crypto/blake2.zig index b90661aa19..4203a99459 100644 --- a/lib/std/crypto/blake2.zig +++ b/lib/std/crypto/blake2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -33,6 +33,7 @@ fn roundParam(a: usize, b: usize, c: usize, d: usize, x: usize, y: usize) RoundP // Blake2s pub const Blake2s128 = Blake2s(128); +pub const Blake2s160 = Blake2s(160); pub const Blake2s224 = Blake2s(224); pub const Blake2s256 = Blake2s(256); @@ -137,12 +138,8 @@ pub fn Blake2s(comptime out_bits: usize) type { mem.set(u8, d.buf[d.buf_len..], 0); d.t += d.buf_len; d.round(d.buf[0..], true); - - const rr = d.h[0 .. digest_length / 4]; - - for (rr) |s, j| { - mem.writeIntSliceLittle(u32, out[4 * j ..], s); - } + for (d.h) |*x| x.* = mem.nativeToLittle(u32, x.*); + mem.copy(u8, out[0..], @ptrCast(*[digest_length]u8, &d.h)); } fn round(d: *Self, b: *const [64]u8, last: bool) void { @@ -195,6 +192,89 @@ pub fn Blake2s(comptime out_bits: usize) type { }; } +test "blake2s160 single" { + const h1 = "354c9c33f735962418bdacb9479873429c34916f"; + htest.assertEqualHash(Blake2s160, h1, ""); + + const h2 = "5ae3b99be29b01834c3b508521ede60438f8de17"; + htest.assertEqualHash(Blake2s160, h2, "abc"); + + const h3 = "5a604fec9713c369e84b0ed68daed7d7504ef240"; + htest.assertEqualHash(Blake2s160, h3, "The quick brown fox jumps over the lazy dog"); + + const h4 = "b60c4dc60e2681e58fbc24e77f07e02c69e72ed0"; + htest.assertEqualHash(Blake2s160, h4, "a" ** 32 ++ "b" ** 32); +} + +test "blake2s160 streaming" { + var h = Blake2s160.init(.{}); + var out: [20]u8 = undefined; + + const h1 = "354c9c33f735962418bdacb9479873429c34916f"; + + h.final(out[0..]); + htest.assertEqual(h1, out[0..]); + + const h2 = "5ae3b99be29b01834c3b508521ede60438f8de17"; + + h = Blake2s160.init(.{}); + h.update("abc"); + h.final(out[0..]); + htest.assertEqual(h2, out[0..]); + + h = Blake2s160.init(.{}); + h.update("a"); + h.update("b"); + h.update("c"); + h.final(out[0..]); + htest.assertEqual(h2, out[0..]); + + const h3 = "b60c4dc60e2681e58fbc24e77f07e02c69e72ed0"; + + h = Blake2s160.init(.{}); + h.update("a" ** 32); + h.update("b" ** 32); + h.final(out[0..]); + htest.assertEqual(h3, out[0..]); + + h = Blake2s160.init(.{}); + h.update("a" ** 32 ++ "b" ** 32); + h.final(out[0..]); + htest.assertEqual(h3, out[0..]); + + const h4 = "4667fd60791a7fe41f939bca646b4529e296bd68"; + + h = Blake2s160.init(.{ .context = [_]u8{0x69} ** 8, .salt = [_]u8{0x42} ** 8 }); + h.update("a" ** 32); + h.update("b" ** 32); + h.final(out[0..]); + htest.assertEqual(h4, out[0..]); + + h = Blake2s160.init(.{ .context = [_]u8{0x69} ** 8, .salt = [_]u8{0x42} ** 8 }); + h.update("a" ** 32 ++ "b" ** 32); + h.final(out[0..]); + htest.assertEqual(h4, out[0..]); +} + +test "comptime blake2s160" { + //comptime + { + @setEvalBranchQuota(10000); + var block = [_]u8{0} ** Blake2s160.block_length; + var out: [Blake2s160.digest_length]u8 = undefined; + + const h1 = "2c56ad9d0b2c8b474aafa93ab307db2f0940105f"; + + htest.assertEqualHash(Blake2s160, h1, block[0..]); + + var h = Blake2s160.init(.{}); + h.update(&block); + h.final(out[0..]); + + htest.assertEqual(h1, out[0..]); + } +} + test "blake2s224 single" { const h1 = "1fa1291e65248b37b3433475b2a0dd63d54a11ecc4e3e034e7bc1ef4"; htest.assertEqualHash(Blake2s224, h1, ""); @@ -373,6 +453,7 @@ test "comptime blake2s256" { // Blake2b pub const Blake2b128 = Blake2b(128); +pub const Blake2b160 = Blake2b(160); pub const Blake2b256 = Blake2b(256); pub const Blake2b384 = Blake2b(384); pub const Blake2b512 = Blake2b(512); @@ -480,12 +561,8 @@ pub fn Blake2b(comptime out_bits: usize) type { mem.set(u8, d.buf[d.buf_len..], 0); d.t += d.buf_len; d.round(d.buf[0..], true); - - const rr = d.h[0 .. digest_length / 8]; - - for (rr) |s, j| { - mem.writeIntSliceLittle(u64, out[8 * j ..], s); - } + for (d.h) |*x| x.* = mem.nativeToLittle(u64, x.*); + mem.copy(u8, out[0..], @ptrCast(*[digest_length]u8, &d.h)); } fn round(d: *Self, b: *const [128]u8, last: bool) void { @@ -538,6 +615,95 @@ pub fn Blake2b(comptime out_bits: usize) type { }; } +test "blake2b160 single" { + const h1 = "3345524abf6bbe1809449224b5972c41790b6cf2"; + htest.assertEqualHash(Blake2b160, h1, ""); + + const h2 = "384264f676f39536840523f284921cdc68b6846b"; + htest.assertEqualHash(Blake2b160, h2, "abc"); + + const h3 = "3c523ed102ab45a37d54f5610d5a983162fde84f"; + htest.assertEqualHash(Blake2b160, h3, "The quick brown fox jumps over the lazy dog"); + + const h4 = "43758f5de1740f651f1ae39de92260fe8bd5a11f"; + htest.assertEqualHash(Blake2b160, h4, "a" ** 64 ++ "b" ** 64); +} + +test "blake2b160 streaming" { + var h = Blake2b160.init(.{}); + var out: [20]u8 = undefined; + + const h1 = "3345524abf6bbe1809449224b5972c41790b6cf2"; + + h.final(out[0..]); + htest.assertEqual(h1, out[0..]); + + const h2 = "384264f676f39536840523f284921cdc68b6846b"; + + h = Blake2b160.init(.{}); + h.update("abc"); + h.final(out[0..]); + htest.assertEqual(h2, out[0..]); + + h = Blake2b160.init(.{}); + h.update("a"); + h.update("b"); + h.update("c"); + h.final(out[0..]); + htest.assertEqual(h2, out[0..]); + + const h3 = "43758f5de1740f651f1ae39de92260fe8bd5a11f"; + + h = Blake2b160.init(.{}); + h.update("a" ** 64 ++ "b" ** 64); + h.final(out[0..]); + htest.assertEqual(h3, out[0..]); + + h = Blake2b160.init(.{}); + h.update("a" ** 64); + h.update("b" ** 64); + h.final(out[0..]); + htest.assertEqual(h3, out[0..]); + + h = Blake2b160.init(.{}); + h.update("a" ** 64); + h.update("b" ** 64); + h.final(out[0..]); + htest.assertEqual(h3, out[0..]); + + const h4 = "72328f8a8200663752fc302d372b5dd9b49dd8dc"; + + h = Blake2b160.init(.{ .context = [_]u8{0x69} ** 16, .salt = [_]u8{0x42} ** 16 }); + h.update("a" ** 64); + h.update("b" ** 64); + h.final(out[0..]); + htest.assertEqual(h4, out[0..]); + + h = Blake2b160.init(.{ .context = [_]u8{0x69} ** 16, .salt = [_]u8{0x42} ** 16 }); + h.update("a" ** 64); + h.update("b" ** 64); + h.final(out[0..]); + htest.assertEqual(h4, out[0..]); +} + +test "comptime blake2b160" { + comptime { + @setEvalBranchQuota(10000); + var block = [_]u8{0} ** Blake2b160.block_length; + var out: [Blake2b160.digest_length]u8 = undefined; + + const h1 = "8d26f158f564e3293b42f5e3d34263cb173aa9c9"; + + htest.assertEqualHash(Blake2b160, h1, block[0..]); + + var h = Blake2b160.init(.{}); + h.update(&block); + h.final(out[0..]); + + htest.assertEqual(h1, out[0..]); + } +} + test "blake2b384 single" { const h1 = "b32811423377f52d7862286ee1a72ee540524380fda1724a6f25d7978c6fd3244a6caf0498812673c5e05ef583825100"; htest.assertEqualHash(Blake2b384, h1, ""); diff --git a/lib/std/crypto/blake3.zig b/lib/std/crypto/blake3.zig index b22429b8e2..a10c50b074 100644 --- a/lib/std/crypto/blake3.zig +++ b/lib/std/crypto/blake3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -66,7 +66,7 @@ const CompressVectorized = struct { const Lane = Vector(4, u32); const Rows = [4]Lane; - inline fn g(comptime even: bool, rows: *Rows, m: Lane) void { + fn g(comptime even: bool, rows: *Rows, m: Lane) callconv(.Inline) void { rows[0] +%= rows[1] +% m; rows[3] ^= rows[0]; rows[3] = math.rotr(Lane, rows[3], if (even) 8 else 16); @@ -75,13 +75,13 @@ const CompressVectorized = struct { rows[1] = math.rotr(Lane, rows[1], if (even) 7 else 12); } - inline fn diagonalize(rows: *Rows) void { + fn diagonalize(rows: *Rows) callconv(.Inline) void { rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 3, 0, 1, 2 }); rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 }); rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 1, 2, 3, 0 }); } - inline fn undiagonalize(rows: *Rows) void { + fn undiagonalize(rows: *Rows) callconv(.Inline) void { rows[0] = @shuffle(u32, rows[0], undefined, [_]i32{ 1, 2, 3, 0 }); rows[3] = @shuffle(u32, rows[3], undefined, [_]i32{ 2, 3, 0, 1 }); rows[2] = @shuffle(u32, rows[2], undefined, [_]i32{ 3, 0, 1, 2 }); @@ -663,7 +663,7 @@ fn testBlake3(hasher: *Blake3, input_len: usize, expected_hex: [262]u8) void { // Compare to expected value var expected_bytes: [expected_hex.len / 2]u8 = undefined; - fmt.hexToBytes(expected_bytes[0..], expected_hex[0..]) catch unreachable; + _ = fmt.hexToBytes(expected_bytes[0..], expected_hex[0..]) catch unreachable; testing.expectEqual(actual_bytes, expected_bytes); // Restore initial state diff --git a/lib/std/crypto/chacha20.zig b/lib/std/crypto/chacha20.zig index 5acd2bd4f5..0f79707279 100644 --- a/lib/std/crypto/chacha20.zig +++ b/lib/std/crypto/chacha20.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -35,7 +35,7 @@ const ChaCha20VecImpl = struct { }; } - inline fn chacha20Core(x: *BlockVec, input: BlockVec) void { + fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void { x.* = input; var r: usize = 0; @@ -80,7 +80,7 @@ const ChaCha20VecImpl = struct { } } - inline fn hashToBytes(out: *[64]u8, x: BlockVec) void { + fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void { var i: usize = 0; while (i < 4) : (i += 1) { mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]); @@ -90,7 +90,7 @@ const ChaCha20VecImpl = struct { } } - inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void { + fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void { x[0] +%= ctx[0]; x[1] +%= ctx[1]; x[2] +%= ctx[2]; @@ -190,7 +190,7 @@ const ChaCha20NonVecImpl = struct { }; } - inline fn chacha20Core(x: *BlockVec, input: BlockVec) void { + fn chacha20Core(x: *BlockVec, input: BlockVec) callconv(.Inline) void { x.* = input; const rounds = comptime [_]QuarterRound{ @@ -219,7 +219,7 @@ const ChaCha20NonVecImpl = struct { } } - inline fn hashToBytes(out: *[64]u8, x: BlockVec) void { + fn hashToBytes(out: *[64]u8, x: BlockVec) callconv(.Inline) void { var i: usize = 0; while (i < 4) : (i += 1) { mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i * 4 + 0]); @@ -229,7 +229,7 @@ const ChaCha20NonVecImpl = struct { } } - inline fn contextFeedback(x: *BlockVec, ctx: BlockVec) void { + fn contextFeedback(x: *BlockVec, ctx: BlockVec) callconv(.Inline) void { var i: usize = 0; while (i < 16) : (i += 1) { x[i] +%= ctx[i]; diff --git a/lib/std/crypto/ghash.zig b/lib/std/crypto/ghash.zig index d5d4ae98ea..ffc9ef41ae 100644 --- a/lib/std/crypto/ghash.zig +++ b/lib/std/crypto/ghash.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -95,7 +95,7 @@ pub const Ghash = struct { } } - inline fn clmul_pclmul(x: u64, y: u64) u64 { + fn clmul_pclmul(x: u64, y: u64) callconv(.Inline) u64 { const Vector = std.meta.Vector; const product = asm ( \\ vpclmulqdq $0x00, %[x], %[y], %[out] @@ -106,7 +106,7 @@ pub const Ghash = struct { return product[0]; } - inline fn clmul_pmull(x: u64, y: u64) u64 { + fn clmul_pmull(x: u64, y: u64) callconv(.Inline) u64 { const Vector = std.meta.Vector; const product = asm ( \\ pmull %[out].1q, %[x].1d, %[y].1d diff --git a/lib/std/crypto/gimli.zig b/lib/std/crypto/gimli.zig index 78ab88b9cf..1c1d6c79db 100644 --- a/lib/std/crypto/gimli.zig +++ b/lib/std/crypto/gimli.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -48,7 +48,7 @@ pub const State = struct { return mem.asBytes(&self.data); } - inline fn endianSwap(self: *Self) void { + fn endianSwap(self: *Self) callconv(.Inline) void { for (self.data) |*w| { w.* = mem.littleToNative(u32, w.*); } @@ -116,7 +116,7 @@ pub const State = struct { const Lane = Vector(4, u32); - inline fn shift(x: Lane, comptime n: comptime_int) Lane { + fn shift(x: Lane, comptime n: comptime_int) callconv(.Inline) Lane { return x << @splat(4, @as(u5, n)); } @@ -229,18 +229,17 @@ pub const Hash = struct { const buf = self.state.toSlice(); var in = data; while (in.len > 0) { - var left = State.RATE - self.buf_off; - if (left == 0) { - self.state.permute(); - self.buf_off = 0; - left = State.RATE; - } + const left = State.RATE - self.buf_off; const ps = math.min(in.len, left); for (buf[self.buf_off .. self.buf_off + ps]) |*p, i| { p.* ^= in[i]; } self.buf_off += ps; in = in[ps..]; + if (self.buf_off == State.RATE) { + self.state.permute(); + self.buf_off = 0; + } } } @@ -271,12 +270,28 @@ pub fn hash(out: []u8, in: []const u8, options: Hash.Options) void { test "hash" { // a test vector (30) from NIST KAT submission. var msg: [58 / 2]u8 = undefined; - try std.fmt.hexToBytes(&msg, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C"); + _ = try std.fmt.hexToBytes(&msg, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C"); var md: [32]u8 = undefined; hash(&md, &msg, .{}); htest.assertEqual("1C9A03DC6A5DDC5444CFC6F4B154CFF5CF081633B2CEA4D7D0AE7CCFED5AAA44", &md); } +test "hash test vector 17" { + var msg: [32 / 2]u8 = undefined; + _ = try std.fmt.hexToBytes(&msg, "000102030405060708090A0B0C0D0E0F"); + var md: [32]u8 = undefined; + hash(&md, &msg, .{}); + htest.assertEqual("404C130AF1B9023A7908200919F690FFBB756D5176E056FFDE320016A37C7282", &md); +} + +test "hash test vector 33" { + var msg: [32]u8 = undefined; + _ = try std.fmt.hexToBytes(&msg, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); + var md: [32]u8 = undefined; + hash(&md, &msg, .{}); + htest.assertEqual("A8F4FA28708BDA7EFB4C1914CA4AFA9E475B82D588D36504F87DBB0ED9AB3C4B", &md); +} + pub const Aead = struct { pub const tag_length = State.RATE; pub const nonce_length = 16; @@ -421,9 +436,9 @@ pub const Aead = struct { test "cipher" { var key: [32]u8 = undefined; - try std.fmt.hexToBytes(&key, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); + _ = try std.fmt.hexToBytes(&key, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); var nonce: [16]u8 = undefined; - try std.fmt.hexToBytes(&nonce, "000102030405060708090A0B0C0D0E0F"); + _ = try std.fmt.hexToBytes(&nonce, "000102030405060708090A0B0C0D0E0F"); { // test vector (1) from NIST KAT submission. const ad: [0]u8 = undefined; const pt: [0]u8 = undefined; @@ -441,7 +456,7 @@ test "cipher" { { // test vector (34) from NIST KAT submission. const ad: [0]u8 = undefined; var pt: [2 / 2]u8 = undefined; - try std.fmt.hexToBytes(&pt, "00"); + _ = try std.fmt.hexToBytes(&pt, "00"); var ct: [pt.len]u8 = undefined; var tag: [16]u8 = undefined; @@ -455,9 +470,9 @@ test "cipher" { } { // test vector (106) from NIST KAT submission. var ad: [12 / 2]u8 = undefined; - try std.fmt.hexToBytes(&ad, "000102030405"); + _ = try std.fmt.hexToBytes(&ad, "000102030405"); var pt: [6 / 2]u8 = undefined; - try std.fmt.hexToBytes(&pt, "000102"); + _ = try std.fmt.hexToBytes(&pt, "000102"); var ct: [pt.len]u8 = undefined; var tag: [16]u8 = undefined; @@ -471,9 +486,9 @@ test "cipher" { } { // test vector (790) from NIST KAT submission. var ad: [60 / 2]u8 = undefined; - try std.fmt.hexToBytes(&ad, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D"); + _ = try std.fmt.hexToBytes(&ad, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D"); var pt: [46 / 2]u8 = undefined; - try std.fmt.hexToBytes(&pt, "000102030405060708090A0B0C0D0E0F10111213141516"); + _ = try std.fmt.hexToBytes(&pt, "000102030405060708090A0B0C0D0E0F10111213141516"); var ct: [pt.len]u8 = undefined; var tag: [16]u8 = undefined; @@ -488,7 +503,7 @@ test "cipher" { { // test vector (1057) from NIST KAT submission. const ad: [0]u8 = undefined; var pt: [64 / 2]u8 = undefined; - try std.fmt.hexToBytes(&pt, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); + _ = try std.fmt.hexToBytes(&pt, "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"); var ct: [pt.len]u8 = undefined; var tag: [16]u8 = undefined; diff --git a/lib/std/crypto/hkdf.zig b/lib/std/crypto/hkdf.zig index b1c6f58acd..c0f919ef82 100644 --- a/lib/std/crypto/hkdf.zig +++ b/lib/std/crypto/hkdf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/hmac.zig b/lib/std/crypto/hmac.zig index 3978ff6b81..7f29c62941 100644 --- a/lib/std/crypto/hmac.zig +++ b/lib/std/crypto/hmac.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/md5.zig b/lib/std/crypto/md5.zig index 8b454c52a7..78454ce3c1 100644 --- a/lib/std/crypto/md5.zig +++ b/lib/std/crypto/md5.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/modes.zig b/lib/std/crypto/modes.zig index a81d30e50f..a74704d1ae 100644 --- a/lib/std/crypto/modes.zig +++ b/lib/std/crypto/modes.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/pbkdf2.zig b/lib/std/crypto/pbkdf2.zig index 85c8e01105..25df1ba440 100644 --- a/lib/std/crypto/pbkdf2.zig +++ b/lib/std/crypto/pbkdf2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/poly1305.zig b/lib/std/crypto/poly1305.zig index 0b7b4cd64a..739c057178 100644 --- a/lib/std/crypto/poly1305.zig +++ b/lib/std/crypto/poly1305.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/salsa20.zig b/lib/std/crypto/salsa20.zig index dd3e4fe99b..e22668f998 100644 --- a/lib/std/crypto/salsa20.zig +++ b/lib/std/crypto/salsa20.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -37,7 +37,7 @@ const Salsa20VecImpl = struct { }; } - inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) void { + fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) callconv(.Inline) void { const n1n2n3n0 = Lane{ input[3][1], input[3][2], input[3][3], input[3][0] }; const n1n2 = Half{ n1n2n3n0[0], n1n2n3n0[1] }; const n3n0 = Half{ n1n2n3n0[2], n1n2n3n0[3] }; @@ -146,9 +146,9 @@ const Salsa20VecImpl = struct { while (j < 64) : (j += 1) { xout[j] ^= buf[j]; } - ctx[2][0] +%= 1; - if (ctx[2][0] == 0) { - ctx[2][1] += 1; + ctx[3][2] +%= 1; + if (ctx[3][2] == 0) { + ctx[3][3] += 1; } } if (i < in.len) { @@ -211,7 +211,7 @@ const Salsa20NonVecImpl = struct { d: u6, }; - inline fn Rp(a: usize, b: usize, c: usize, d: u6) QuarterRound { + fn Rp(a: usize, b: usize, c: usize, d: u6) callconv(.Inline) QuarterRound { return QuarterRound{ .a = a, .b = b, @@ -220,7 +220,7 @@ const Salsa20NonVecImpl = struct { }; } - inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) void { + fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) callconv(.Inline) void { const arx_steps = comptime [_]QuarterRound{ Rp(4, 0, 12, 7), Rp(8, 4, 0, 9), Rp(12, 8, 4, 13), Rp(0, 12, 8, 18), Rp(9, 5, 1, 7), Rp(13, 9, 5, 9), Rp(1, 13, 9, 13), Rp(5, 1, 13, 18), @@ -571,9 +571,9 @@ test "xsalsa20poly1305" { var key: [XSalsa20Poly1305.key_length]u8 = undefined; var nonce: [XSalsa20Poly1305.nonce_length]u8 = undefined; var tag: [XSalsa20Poly1305.tag_length]u8 = undefined; - try crypto.randomBytes(&msg); - try crypto.randomBytes(&key); - try crypto.randomBytes(&nonce); + crypto.random.bytes(&msg); + crypto.random.bytes(&key); + crypto.random.bytes(&nonce); XSalsa20Poly1305.encrypt(c[0..], &tag, msg[0..], "ad", nonce, key); try XSalsa20Poly1305.decrypt(msg2[0..], c[0..], tag, "ad", nonce, key); @@ -585,9 +585,9 @@ test "xsalsa20poly1305 secretbox" { var key: [XSalsa20Poly1305.key_length]u8 = undefined; var nonce: [Box.nonce_length]u8 = undefined; var boxed: [msg.len + Box.tag_length]u8 = undefined; - try crypto.randomBytes(&msg); - try crypto.randomBytes(&key); - try crypto.randomBytes(&nonce); + crypto.random.bytes(&msg); + crypto.random.bytes(&key); + crypto.random.bytes(&nonce); SecretBox.seal(boxed[0..], msg[0..], nonce, key); try SecretBox.open(msg2[0..], boxed[0..], nonce, key); @@ -598,8 +598,8 @@ test "xsalsa20poly1305 box" { var msg2: [msg.len]u8 = undefined; var nonce: [Box.nonce_length]u8 = undefined; var boxed: [msg.len + Box.tag_length]u8 = undefined; - try crypto.randomBytes(&msg); - try crypto.randomBytes(&nonce); + crypto.random.bytes(&msg); + crypto.random.bytes(&nonce); var kp1 = try Box.KeyPair.create(null); var kp2 = try Box.KeyPair.create(null); @@ -611,9 +611,18 @@ test "xsalsa20poly1305 sealedbox" { var msg: [100]u8 = undefined; var msg2: [msg.len]u8 = undefined; var boxed: [msg.len + SealedBox.seal_length]u8 = undefined; - try crypto.randomBytes(&msg); + crypto.random.bytes(&msg); var kp = try Box.KeyPair.create(null); try SealedBox.seal(boxed[0..], msg[0..], kp.public_key); try SealedBox.open(msg2[0..], boxed[0..], kp); } + +test "secretbox twoblocks" { + const key = [_]u8{ 0xc9, 0xc9, 0x4d, 0xcf, 0x68, 0xbe, 0x00, 0xe4, 0x7f, 0xe6, 0x13, 0x26, 0xfc, 0xc4, 0x2f, 0xd0, 0xdb, 0x93, 0x91, 0x1c, 0x09, 0x94, 0x89, 0xe1, 0x1b, 0x88, 0x63, 0x18, 0x86, 0x64, 0x8b, 0x7b }; + const nonce = [_]u8{ 0xa4, 0x33, 0xe9, 0x0a, 0x07, 0x68, 0x6e, 0x9a, 0x2b, 0x6d, 0xd4, 0x59, 0x04, 0x72, 0x3e, 0xd3, 0x8a, 0x67, 0x55, 0xc7, 0x9e, 0x3e, 0x77, 0xdc }; + const msg = [_]u8{'a'} ** 97; + var ciphertext: [msg.len + SecretBox.tag_length]u8 = undefined; + SecretBox.seal(&ciphertext, &msg, nonce, key); + htest.assertEqual("b05760e217288ba079caa2fd57fd3701784974ffcfda20fe523b89211ad8af065a6eb37cdb29d51aca5bd75dafdd21d18b044c54bb7c526cf576c94ee8900f911ceab0147e82b667a28c52d58ceb29554ff45471224d37b03256b01c119b89ff6d36855de8138d103386dbc9d971f52261", &ciphertext); +} diff --git a/lib/std/crypto/sha1.zig b/lib/std/crypto/sha1.zig index c2ae0a6544..ac699f0ef1 100644 --- a/lib/std/crypto/sha1.zig +++ b/lib/std/crypto/sha1.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/sha2.zig b/lib/std/crypto/sha2.zig index 4e06a214dd..5a37004e8c 100644 --- a/lib/std/crypto/sha2.zig +++ b/lib/std/crypto/sha2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/sha3.zig b/lib/std/crypto/sha3.zig index 3aecf25e5b..d68821133e 100644 --- a/lib/std/crypto/sha3.zig +++ b/lib/std/crypto/sha3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -13,6 +13,8 @@ pub const Sha3_224 = Keccak(224, 0x06); pub const Sha3_256 = Keccak(256, 0x06); pub const Sha3_384 = Keccak(384, 0x06); pub const Sha3_512 = Keccak(512, 0x06); +pub const Keccak_256 = Keccak(256, 0x01); +pub const Keccak_512 = Keccak(512, 0x01); fn Keccak(comptime bits: usize, comptime delim: u8) type { return struct { @@ -297,3 +299,15 @@ test "sha3-512 aligned final" { h.update(&block); h.final(out[0..]); } + +test "keccak-256 single" { + htest.assertEqualHash(Keccak_256, "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", ""); + htest.assertEqualHash(Keccak_256, "4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45", "abc"); + htest.assertEqualHash(Keccak_256, "f519747ed599024f3882238e5ab43960132572b7345fbeb9a90769dafd21ad67", "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"); +} + +test "keccak-512 single" { + htest.assertEqualHash(Keccak_512, "0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e", ""); + htest.assertEqualHash(Keccak_512, "18587dc2ea106b9a1563e32b3312421ca164c7f1f07bc922a9c83d77cea3a1e5d0c69910739025372dc14ac9642629379540c17e2a65b19d77aa511a9d00bb96", "abc"); + htest.assertEqualHash(Keccak_512, "ac2fb35251825d3aa48468a9948c0a91b8256f6d97d8fa4160faff2dd9dfcc24f3f1db7a983dad13d53439ccac0b37e24037e7b95f80f59f37a2f683c4ba4682", "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"); +} diff --git a/lib/std/crypto/siphash.zig b/lib/std/crypto/siphash.zig index 5dfd2bf326..67bb2a329a 100644 --- a/lib/std/crypto/siphash.zig +++ b/lib/std/crypto/siphash.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -7,10 +7,10 @@ // SipHash is a moderately fast pseudorandom function, returning a 64-bit or 128-bit tag for an arbitrary long input. // // Typical use cases include: -// - protection against against DoS attacks for hash tables and bloom filters +// - protection against DoS attacks for hash tables and bloom filters // - authentication of short-lived messages in online protocols // -// https://131002.net/siphash/ +// https://www.aumasson.jp/siphash/siphash.pdf const std = @import("../std.zig"); const assert = std.debug.assert; const testing = std.testing; diff --git a/lib/std/crypto/test.zig b/lib/std/crypto/test.zig index 692e331e39..cab07c50ec 100644 --- a/lib/std/crypto/test.zig +++ b/lib/std/crypto/test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/crypto/tlcsprng.zig b/lib/std/crypto/tlcsprng.zig new file mode 100644 index 0000000000..115a7ab882 --- /dev/null +++ b/lib/std/crypto/tlcsprng.zig @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! Thread-local cryptographically secure pseudo-random number generator. +//! This file has public declarations that are intended to be used internally +//! by the standard library; this namespace is not intended to be exposed +//! directly to standard library users. + +const std = @import("std"); +const root = @import("root"); +const mem = std.mem; + +/// We use this as a layer of indirection because global const pointers cannot +/// point to thread-local variables. +pub var interface = std.rand.Random{ .fillFn = tlsCsprngFill }; + +const os_has_fork = switch (std.Target.current.os.tag) { + .dragonfly, + .freebsd, + .ios, + .kfreebsd, + .linux, + .macos, + .netbsd, + .openbsd, + .solaris, + .tvos, + .watchos, + .haiku, + => true, + + else => false, +}; +const os_has_arc4random = std.builtin.link_libc and @hasDecl(std.c, "arc4random_buf"); +const want_fork_safety = os_has_fork and !os_has_arc4random and + (std.meta.globalOption("crypto_fork_safety", bool) orelse true); +const maybe_have_wipe_on_fork = std.Target.current.os.isAtLeast(.linux, .{ + .major = 4, + .minor = 14, +}) orelse true; + +const WipeMe = struct { + init_state: enum { uninitialized, initialized, failed }, + gimli: std.crypto.core.Gimli, +}; +const wipe_align = if (maybe_have_wipe_on_fork) mem.page_size else @alignOf(WipeMe); + +threadlocal var wipe_me: WipeMe align(wipe_align) = .{ + .gimli = undefined, + .init_state = .uninitialized, +}; + +fn tlsCsprngFill(_: *const std.rand.Random, buffer: []u8) void { + if (std.builtin.link_libc and @hasDecl(std.c, "arc4random_buf")) { + // arc4random is already a thread-local CSPRNG. + return std.c.arc4random_buf(buffer.ptr, buffer.len); + } + // Allow applications to decide they would prefer to have every call to + // std.crypto.random always make an OS syscall, rather than rely on an + // application implementation of a CSPRNG. + if (comptime std.meta.globalOption("crypto_always_getrandom", bool) orelse false) { + return fillWithOsEntropy(buffer); + } + switch (wipe_me.init_state) { + .uninitialized => { + if (want_fork_safety) { + if (maybe_have_wipe_on_fork) { + if (std.os.madvise( + @ptrCast([*]align(mem.page_size) u8, &wipe_me), + @sizeOf(@TypeOf(wipe_me)), + std.os.MADV_WIPEONFORK, + )) |_| { + return initAndFill(buffer); + } else |_| if (std.Thread.use_pthreads) { + return setupPthreadAtforkAndFill(buffer); + } else { + // Since we failed to set up fork safety, we fall back to always + // calling getrandom every time. + wipe_me.init_state = .failed; + return fillWithOsEntropy(buffer); + } + } else if (std.Thread.use_pthreads) { + return setupPthreadAtforkAndFill(buffer); + } else { + // We have no mechanism to provide fork safety, but we want fork safety, + // so we fall back to calling getrandom every time. + wipe_me.init_state = .failed; + return fillWithOsEntropy(buffer); + } + } else { + return initAndFill(buffer); + } + }, + .initialized => { + return fillWithCsprng(buffer); + }, + .failed => { + if (want_fork_safety) { + return fillWithOsEntropy(buffer); + } else { + unreachable; + } + }, + } +} + +fn setupPthreadAtforkAndFill(buffer: []u8) void { + const failed = std.c.pthread_atfork(null, null, childAtForkHandler) != 0; + if (failed) { + wipe_me.init_state = .failed; + return fillWithOsEntropy(buffer); + } else { + return initAndFill(buffer); + } +} + +fn childAtForkHandler() callconv(.C) void { + const wipe_slice = @ptrCast([*]u8, &wipe_me)[0..@sizeOf(@TypeOf(wipe_me))]; + std.crypto.utils.secureZero(u8, wipe_slice); +} + +fn fillWithCsprng(buffer: []u8) void { + if (buffer.len != 0) { + wipe_me.gimli.squeeze(buffer); + } else { + wipe_me.gimli.permute(); + } + mem.set(u8, wipe_me.gimli.toSlice()[0..std.crypto.core.Gimli.RATE], 0); +} + +fn fillWithOsEntropy(buffer: []u8) void { + std.os.getrandom(buffer) catch @panic("getrandom() failed to provide entropy"); +} + +fn initAndFill(buffer: []u8) void { + var seed: [std.crypto.core.Gimli.BLOCKBYTES]u8 = undefined; + // Because we panic on getrandom() failing, we provide the opportunity + // to override the default seed function. This also makes + // `std.crypto.random` available on freestanding targets, provided that + // the `cryptoRandomSeed` function is provided. + if (@hasDecl(root, "cryptoRandomSeed")) { + root.cryptoRandomSeed(&seed); + } else { + fillWithOsEntropy(&seed); + } + + wipe_me.gimli = std.crypto.core.Gimli.init(seed); + + // This is at the end so that accidental recursive dependencies result + // in stack overflows instead of invalid random data. + wipe_me.init_state = .initialized; + + return fillWithCsprng(buffer); +} diff --git a/lib/std/crypto/utils.zig b/lib/std/crypto/utils.zig index 33ad6360f6..08271ac9f4 100644 --- a/lib/std/crypto/utils.zig +++ b/lib/std/crypto/utils.zig @@ -51,8 +51,8 @@ pub fn secureZero(comptime T: type, s: []T) void { test "crypto.utils.timingSafeEql" { var a: [100]u8 = undefined; var b: [100]u8 = undefined; - try std.crypto.randomBytes(a[0..]); - try std.crypto.randomBytes(b[0..]); + std.crypto.random.bytes(a[0..]); + std.crypto.random.bytes(b[0..]); testing.expect(!timingSafeEql([100]u8, a, b)); mem.copy(u8, a[0..], b[0..]); testing.expect(timingSafeEql([100]u8, a, b)); @@ -61,8 +61,8 @@ test "crypto.utils.timingSafeEql" { test "crypto.utils.timingSafeEql (vectors)" { var a: [100]u8 = undefined; var b: [100]u8 = undefined; - try std.crypto.randomBytes(a[0..]); - try std.crypto.randomBytes(b[0..]); + std.crypto.random.bytes(a[0..]); + std.crypto.random.bytes(b[0..]); const v1: std.meta.Vector(100, u8) = a; const v2: std.meta.Vector(100, u8) = b; testing.expect(!timingSafeEql(std.meta.Vector(100, u8), v1, v2)); diff --git a/lib/std/cstr.zig b/lib/std/cstr.zig index 4e11ad9201..33f32ae892 100644 --- a/lib/std/cstr.zig +++ b/lib/std/cstr.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/debug.zig b/lib/std/debug.zig index be5635ee8f..f32c1a6156 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -50,7 +50,7 @@ pub const LineInfo = struct { } }; -var stderr_mutex = std.Mutex{}; +var stderr_mutex = std.Thread.Mutex{}; /// Deprecated. Use `std.log` functions for logging or `std.debug.print` for /// "printf debugging". @@ -65,7 +65,7 @@ pub fn print(comptime fmt: []const u8, args: anytype) void { nosuspend stderr.print(fmt, args) catch return; } -pub fn getStderrMutex() *std.Mutex { +pub fn getStderrMutex() *std.Thread.Mutex { return &stderr_mutex; } @@ -108,11 +108,11 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { return; } const debug_info = getSelfDebugInfo() catch |err| { - stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", .{@errorName(err)}) catch return; + stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; return; }; writeCurrentStackTrace(stderr, debug_info, detectTTYConfig(), start_addr) catch |err| { - stderr.print("Unable to dump stack trace: {}\n", .{@errorName(err)}) catch return; + stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; return; }; } @@ -129,7 +129,7 @@ pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { return; } const debug_info = getSelfDebugInfo() catch |err| { - stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", .{@errorName(err)}) catch return; + stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; return; }; const tty_config = detectTTYConfig(); @@ -199,11 +199,11 @@ pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void { return; } const debug_info = getSelfDebugInfo() catch |err| { - stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", .{@errorName(err)}) catch return; + stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; return; }; writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, detectTTYConfig()) catch |err| { - stderr.print("Unable to dump stack trace: {}\n", .{@errorName(err)}) catch return; + stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return; return; }; } @@ -235,7 +235,7 @@ pub fn panic(comptime format: []const u8, args: anytype) noreturn { var panicking: u8 = 0; // Locked to avoid interleaving panic messages from multiple threads. -var panic_mutex = std.Mutex{}; +var panic_mutex = std.Thread.Mutex{}; /// Counts how many times the panic handler is invoked by this thread. /// This is used to catch and handle panics triggered by the panic handler. @@ -250,6 +250,24 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c resetSegfaultHandler(); } + if (comptime std.Target.current.isDarwin() and std.Target.current.cpu.arch == .aarch64) + nosuspend { + // As a workaround for not having threadlocal variable support in LLD for this target, + // we have a simpler panic implementation that does not use threadlocal variables. + // TODO https://github.com/ziglang/zig/issues/7527 + const stderr = io.getStdErr().writer(); + if (@atomicRmw(u8, &panicking, .Add, 1, .SeqCst) == 0) { + stderr.print("panic: " ++ format ++ "\n", args) catch os.abort(); + if (trace) |t| { + dumpStackTrace(t.*); + } + dumpCurrentStackTrace(first_trace_addr); + } else { + stderr.print("Panicked during a panic. Aborting.\n", .{}) catch os.abort(); + } + os.abort(); + }; + nosuspend switch (panic_stage) { 0 => { panic_stage = 1; @@ -262,6 +280,12 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c defer held.release(); const stderr = io.getStdErr().writer(); + if (builtin.single_threaded) { + stderr.print("panic: ", .{}) catch os.abort(); + } else { + const current_thread_id = std.Thread.getCurrentThreadId(); + stderr.print("thread {d} panic: ", .{current_thread_id}) catch os.abort(); + } stderr.print(format ++ "\n", args) catch os.abort(); if (trace) |t| { dumpStackTrace(t.*); @@ -274,9 +298,8 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c // and call abort() // Sleep forever without hammering the CPU - var event = std.ResetEvent.init(); + var event: std.Thread.StaticResetEvent = .{}; event.wait(); - unreachable; } }, @@ -512,15 +535,15 @@ fn populateModule(di: *ModuleDebugInfo, mod: *Module) !void { const modi = di.pdb.getStreamById(mod.mod_info.ModuleSymStream) orelse return error.MissingDebugInfo; - const signature = try modi.inStream().readIntLittle(u32); + const signature = try modi.reader().readIntLittle(u32); if (signature != 4) return error.InvalidDebugInfo; mod.symbols = try allocator.alloc(u8, mod.mod_info.SymByteSize - 4); - try modi.inStream().readNoEof(mod.symbols); + try modi.reader().readNoEof(mod.symbols); mod.subsect_info = try allocator.alloc(u8, mod.mod_info.C13ByteSize); - try modi.inStream().readNoEof(mod.subsect_info); + try modi.reader().readNoEof(mod.subsect_info); var sect_offset: usize = 0; var skip_len: usize = undefined; @@ -606,7 +629,7 @@ fn printLineInfo( tty_config.setColor(out_stream, .White); if (line_info) |*li| { - try out_stream.print("{}:{}:{}", .{ li.file_name, li.line, li.column }); + try out_stream.print("{s}:{d}:{d}", .{ li.file_name, li.line, li.column }); } else { try out_stream.writeAll("???:?:?"); } @@ -614,7 +637,7 @@ fn printLineInfo( tty_config.setColor(out_stream, .Reset); try out_stream.writeAll(": "); tty_config.setColor(out_stream, .Dim); - try out_stream.print("0x{x} in {} ({})", .{ address, symbol_name, compile_unit_name }); + try out_stream.print("0x{x} in {s} ({s})", .{ address, symbol_name, compile_unit_name }); tty_config.setColor(out_stream, .Reset); try out_stream.writeAll("\n"); @@ -634,6 +657,7 @@ fn printLineInfo( } else |err| switch (err) { error.EndOfFile, error.FileNotFound => {}, error.BadPathName => {}, + error.AccessDenied => {}, else => return err, } } @@ -699,11 +723,11 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf try di.pdb.openFile(di.coff, path); var pdb_stream = di.pdb.getStream(pdb.StreamType.Pdb) orelse return error.InvalidDebugInfo; - const version = try pdb_stream.inStream().readIntLittle(u32); - const signature = try pdb_stream.inStream().readIntLittle(u32); - const age = try pdb_stream.inStream().readIntLittle(u32); + const version = try pdb_stream.reader().readIntLittle(u32); + const signature = try pdb_stream.reader().readIntLittle(u32); + const age = try pdb_stream.reader().readIntLittle(u32); var guid: [16]u8 = undefined; - try pdb_stream.inStream().readNoEof(&guid); + try pdb_stream.reader().readNoEof(&guid); if (version != 20000404) // VC70, only value observed by LLVM team return error.UnknownPDBVersion; if (!mem.eql(u8, &di.coff.guid, &guid) or di.coff.age != age) @@ -711,9 +735,9 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf // We validated the executable and pdb match. const string_table_index = str_tab_index: { - const name_bytes_len = try pdb_stream.inStream().readIntLittle(u32); + const name_bytes_len = try pdb_stream.reader().readIntLittle(u32); const name_bytes = try allocator.alloc(u8, name_bytes_len); - try pdb_stream.inStream().readNoEof(name_bytes); + try pdb_stream.reader().readNoEof(name_bytes); const HashTableHeader = packed struct { Size: u32, @@ -723,17 +747,17 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf return cap * 2 / 3 + 1; } }; - const hash_tbl_hdr = try pdb_stream.inStream().readStruct(HashTableHeader); + const hash_tbl_hdr = try pdb_stream.reader().readStruct(HashTableHeader); if (hash_tbl_hdr.Capacity == 0) return error.InvalidDebugInfo; if (hash_tbl_hdr.Size > HashTableHeader.maxLoad(hash_tbl_hdr.Capacity)) return error.InvalidDebugInfo; - const present = try readSparseBitVector(&pdb_stream.inStream(), allocator); + const present = try readSparseBitVector(&pdb_stream.reader(), allocator); if (present.len != hash_tbl_hdr.Size) return error.InvalidDebugInfo; - const deleted = try readSparseBitVector(&pdb_stream.inStream(), allocator); + const deleted = try readSparseBitVector(&pdb_stream.reader(), allocator); const Bucket = struct { first: u32, @@ -741,8 +765,8 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf }; const bucket_list = try allocator.alloc(Bucket, present.len); for (present) |_| { - const name_offset = try pdb_stream.inStream().readIntLittle(u32); - const name_index = try pdb_stream.inStream().readIntLittle(u32); + const name_offset = try pdb_stream.reader().readIntLittle(u32); + const name_index = try pdb_stream.reader().readIntLittle(u32); const name = mem.spanZ(std.meta.assumeSentinel(name_bytes.ptr + name_offset, 0)); if (mem.eql(u8, name, "/names")) { break :str_tab_index name_index; @@ -757,7 +781,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf const dbi = di.pdb.dbi; // Dbi Header - const dbi_stream_header = try dbi.inStream().readStruct(pdb.DbiStreamHeader); + const dbi_stream_header = try dbi.reader().readStruct(pdb.DbiStreamHeader); if (dbi_stream_header.VersionHeader != 19990903) // V70, only value observed by LLVM team return error.UnknownPDBVersion; if (dbi_stream_header.Age != age) @@ -771,7 +795,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf // Module Info Substream var mod_info_offset: usize = 0; while (mod_info_offset != mod_info_size) { - const mod_info = try dbi.inStream().readStruct(pdb.ModInfo); + const mod_info = try dbi.reader().readStruct(pdb.ModInfo); var this_record_len: usize = @sizeOf(pdb.ModInfo); const module_name = try dbi.readNullTermString(allocator); @@ -809,14 +833,14 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf var sect_contribs = ArrayList(pdb.SectionContribEntry).init(allocator); var sect_cont_offset: usize = 0; if (section_contrib_size != 0) { - const ver = @intToEnum(pdb.SectionContrSubstreamVersion, try dbi.inStream().readIntLittle(u32)); + const ver = @intToEnum(pdb.SectionContrSubstreamVersion, try dbi.reader().readIntLittle(u32)); if (ver != pdb.SectionContrSubstreamVersion.Ver60) return error.InvalidDebugInfo; sect_cont_offset += @sizeOf(u32); } while (sect_cont_offset != section_contrib_size) { const entry = try sect_contribs.addOne(); - entry.* = try dbi.inStream().readStruct(pdb.SectionContribEntry); + entry.* = try dbi.reader().readStruct(pdb.SectionContribEntry); sect_cont_offset += @sizeOf(pdb.SectionContribEntry); if (sect_cont_offset > section_contrib_size) @@ -1101,12 +1125,15 @@ pub const DebugInfo = struct { } pub fn getModuleForAddress(self: *DebugInfo, address: usize) !*ModuleDebugInfo { - if (comptime std.Target.current.isDarwin()) - return self.lookupModuleDyld(address) - else if (builtin.os.tag == .windows) - return self.lookupModuleWin32(address) - else + if (comptime std.Target.current.isDarwin()) { + return self.lookupModuleDyld(address); + } else if (builtin.os.tag == .windows) { + return self.lookupModuleWin32(address); + } else if (builtin.os.tag == .haiku) { + return self.lookupModuleHaiku(address); + } else { return self.lookupModuleDl(address); + } } fn lookupModuleDyld(self: *DebugInfo, address: usize) !*ModuleDebugInfo { @@ -1312,6 +1339,10 @@ pub const DebugInfo = struct { return obj_di; } + + fn lookupModuleHaiku(self: *DebugInfo, address: usize) !*ModuleDebugInfo { + @panic("TODO implement lookup module for Haiku"); + } }; const SymbolInfo = struct { @@ -1696,6 +1727,7 @@ fn getDebugInfoAllocator() *mem.Allocator { pub const have_segfault_handling_support = switch (builtin.os.tag) { .linux, .netbsd => true, .windows => true, + .freebsd, .openbsd => @hasDecl(os, "ucontext_t"), else => false, }; pub const enable_segfault_handler: bool = if (@hasDecl(root, "enable_segfault_handler")) @@ -1757,7 +1789,9 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v const addr = switch (builtin.os.tag) { .linux => @ptrToInt(info.fields.sigfault.addr), + .freebsd => @ptrToInt(info.addr), .netbsd => @ptrToInt(info.info.reason.fault.addr), + .openbsd => @ptrToInt(info.data.fault.addr), else => unreachable, }; @@ -1781,8 +1815,18 @@ fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const c_v }, .x86_64 => { const ctx = @ptrCast(*const os.ucontext_t, @alignCast(@alignOf(os.ucontext_t), ctx_ptr)); - const ip = @intCast(usize, ctx.mcontext.gregs[os.REG_RIP]); - const bp = @intCast(usize, ctx.mcontext.gregs[os.REG_RBP]); + const ip = switch (builtin.os.tag) { + .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RIP]), + .freebsd => @intCast(usize, ctx.mcontext.rip), + .openbsd => @intCast(usize, ctx.sc_rip), + else => unreachable, + }; + const bp = switch (builtin.os.tag) { + .linux, .netbsd => @intCast(usize, ctx.mcontext.gregs[os.REG_RBP]), + .openbsd => @intCast(usize, ctx.sc_rbp), + .freebsd => @intCast(usize, ctx.mcontext.rbp), + else => unreachable, + }; dumpStackTraceFromBase(bp, ip); }, .arm => { diff --git a/lib/std/dwarf.zig b/lib/std/dwarf.zig index 3ef0540bdd..7df3a1bff6 100644 --- a/lib/std/dwarf.zig +++ b/lib/std/dwarf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -213,13 +213,11 @@ const LineNumberProgram = struct { return error.MissingDebugInfo; } else if (self.prev_file - 1 >= self.file_entries.items.len) { return error.InvalidDebugInfo; - } else - &self.file_entries.items[self.prev_file - 1]; + } else &self.file_entries.items[self.prev_file - 1]; const dir_name = if (file_entry.dir_index >= self.include_dirs.len) { return error.InvalidDebugInfo; - } else - self.include_dirs[file_entry.dir_index]; + } else self.include_dirs[file_entry.dir_index]; const file_name = try fs.path.join(self.file_entries.allocator, &[_][]const u8{ dir_name, file_entry.file_name }); errdefer self.file_entries.allocator.free(file_name); return debug.LineInfo{ @@ -408,15 +406,12 @@ pub const DwarfInfo = struct { fn scanAllFunctions(di: *DwarfInfo) !void { var stream = io.fixedBufferStream(di.debug_info); - const in = &stream.inStream(); + const in = &stream.reader(); const seekable = &stream.seekableStream(); var this_unit_offset: u64 = 0; while (this_unit_offset < try seekable.getEndPos()) { - seekable.seekTo(this_unit_offset) catch |err| switch (err) { - error.EndOfStream => unreachable, - else => return err, - }; + try seekable.seekTo(this_unit_offset); var is_64: bool = undefined; const unit_length = try readUnitLength(in, di.endian, &is_64); @@ -515,15 +510,12 @@ pub const DwarfInfo = struct { fn scanAllCompileUnits(di: *DwarfInfo) !void { var stream = io.fixedBufferStream(di.debug_info); - const in = &stream.inStream(); + const in = &stream.reader(); const seekable = &stream.seekableStream(); var this_unit_offset: u64 = 0; while (this_unit_offset < try seekable.getEndPos()) { - seekable.seekTo(this_unit_offset) catch |err| switch (err) { - error.EndOfStream => unreachable, - else => return err, - }; + try seekable.seekTo(this_unit_offset); var is_64: bool = undefined; const unit_length = try readUnitLength(in, di.endian, &is_64); @@ -591,7 +583,7 @@ pub const DwarfInfo = struct { if (di.debug_ranges) |debug_ranges| { if (compile_unit.die.getAttrSecOffset(AT_ranges)) |ranges_offset| { var stream = io.fixedBufferStream(debug_ranges); - const in = &stream.inStream(); + const in = &stream.reader(); const seekable = &stream.seekableStream(); // All the addresses in the list are relative to the value @@ -646,7 +638,7 @@ pub const DwarfInfo = struct { fn parseAbbrevTable(di: *DwarfInfo, offset: u64) !AbbrevTable { var stream = io.fixedBufferStream(di.debug_abbrev); - const in = &stream.inStream(); + const in = &stream.reader(); const seekable = &stream.seekableStream(); try seekable.seekTo(offset); @@ -697,7 +689,7 @@ pub const DwarfInfo = struct { pub fn getLineNumberInfo(di: *DwarfInfo, compile_unit: CompileUnit, target_address: usize) !debug.LineInfo { var stream = io.fixedBufferStream(di.debug_line); - const in = &stream.inStream(); + const in = &stream.reader(); const seekable = &stream.seekableStream(); const compile_unit_cwd = try compile_unit.die.getAttrString(di, AT_comp_dir); diff --git a/lib/std/dwarf_bits.zig b/lib/std/dwarf_bits.zig index bf9c97154c..99e268beb7 100644 --- a/lib/std/dwarf_bits.zig +++ b/lib/std/dwarf_bits.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/dynamic_library.zig b/lib/std/dynamic_library.zig index f2e138c3f3..98c59d4105 100644 --- a/lib/std/dynamic_library.zig +++ b/lib/std/dynamic_library.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/elf.zig b/lib/std/elf.zig index a28780fd03..cfb6b448c0 100644 --- a/lib/std/elf.zig +++ b/lib/std/elf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -720,10 +720,10 @@ pub const Elf32_Rel = extern struct { r_offset: Elf32_Addr, r_info: Elf32_Word, - pub inline fn r_sym(self: @This()) u24 { + pub fn r_sym(self: @This()) callconv(.Inline) u24 { return @truncate(u24, self.r_info >> 8); } - pub inline fn r_type(self: @This()) u8 { + pub fn r_type(self: @This()) callconv(.Inline) u8 { return @truncate(u8, self.r_info & 0xff); } }; @@ -731,10 +731,10 @@ pub const Elf64_Rel = extern struct { r_offset: Elf64_Addr, r_info: Elf64_Xword, - pub inline fn r_sym(self: @This()) u32 { + pub fn r_sym(self: @This()) callconv(.Inline) u32 { return @truncate(u32, self.r_info >> 32); } - pub inline fn r_type(self: @This()) u32 { + pub fn r_type(self: @This()) callconv(.Inline) u32 { return @truncate(u32, self.r_info & 0xffffffff); } }; @@ -743,10 +743,10 @@ pub const Elf32_Rela = extern struct { r_info: Elf32_Word, r_addend: Elf32_Sword, - pub inline fn r_sym(self: @This()) u24 { + pub fn r_sym(self: @This()) callconv(.Inline) u24 { return @truncate(u24, self.r_info >> 8); } - pub inline fn r_type(self: @This()) u8 { + pub fn r_type(self: @This()) callconv(.Inline) u8 { return @truncate(u8, self.r_info & 0xff); } }; @@ -755,10 +755,10 @@ pub const Elf64_Rela = extern struct { r_info: Elf64_Xword, r_addend: Elf64_Sxword, - pub inline fn r_sym(self: @This()) u32 { + pub fn r_sym(self: @This()) callconv(.Inline) u32 { return @truncate(u32, self.r_info >> 32); } - pub inline fn r_type(self: @This()) u32 { + pub fn r_type(self: @This()) callconv(.Inline) u32 { return @truncate(u32, self.r_info & 0xffffffff); } }; diff --git a/lib/std/event.zig b/lib/std/event.zig index bba17a3388..cd4af07d64 100644 --- a/lib/std/event.zig +++ b/lib/std/event.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/event/batch.zig b/lib/std/event/batch.zig index 2ace2f7914..5368c5336d 100644 --- a/lib/std/event/batch.zig +++ b/lib/std/event/batch.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -98,15 +98,16 @@ pub fn Batch( /// This function is *not* thread-safe. It must be called from one thread at /// a time, however, it need not be the same thread. pub fn wait(self: *Self) CollectedResult { - for (self.jobs) |*job| if (job.frame) |f| { - job.result = if (async_ok) await f else nosuspend await f; - if (CollectedResult != void) { - job.result catch |err| { - self.collected_result = err; - }; - } - job.frame = null; - }; + for (self.jobs) |*job| + if (job.frame) |f| { + job.result = if (async_ok) await f else nosuspend await f; + if (CollectedResult != void) { + job.result catch |err| { + self.collected_result = err; + }; + } + job.frame = null; + }; return self.collected_result; } }; diff --git a/lib/std/event/channel.zig b/lib/std/event/channel.zig index b7c55360d7..2711488705 100644 --- a/lib/std/event/channel.zig +++ b/lib/std/event/channel.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/event/future.zig b/lib/std/event/future.zig index 40c7845d53..30a2e46ec5 100644 --- a/lib/std/event/future.zig +++ b/lib/std/event/future.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/event/group.zig b/lib/std/event/group.zig index e91adbbe8c..b052c15704 100644 --- a/lib/std/event/group.zig +++ b/lib/std/event/group.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/event/lock.zig b/lib/std/event/lock.zig index 6819e413d2..d48c6c1520 100644 --- a/lib/std/event/lock.zig +++ b/lib/std/event/lock.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -16,7 +16,7 @@ const Loop = std.event.Loop; /// Allows only one actor to hold the lock. /// TODO: make this API also work in blocking I/O mode. pub const Lock = struct { - mutex: std.Mutex = std.Mutex{}, + mutex: std.Thread.Mutex = std.Thread.Mutex{}, head: usize = UNLOCKED, const UNLOCKED = 0; diff --git a/lib/std/event/locked.zig b/lib/std/event/locked.zig index 9a53116fd6..c9303274a9 100644 --- a/lib/std/event/locked.zig +++ b/lib/std/event/locked.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index a000820348..912f99e961 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -29,7 +29,7 @@ pub const Loop = struct { fs_thread: *Thread, fs_queue: std.atomic.Queue(Request), fs_end_request: Request.Node, - fs_thread_wakeup: std.ResetEvent, + fs_thread_wakeup: std.Thread.ResetEvent, /// For resources that have the same lifetime as the `Loop`. /// This is only used by `Loop` for the thread pool and associated resources. @@ -164,9 +164,10 @@ pub const Loop = struct { .fs_end_request = .{ .data = .{ .msg = .end, .finish = .NoAction } }, .fs_queue = std.atomic.Queue(Request).init(), .fs_thread = undefined, - .fs_thread_wakeup = std.ResetEvent.init(), + .fs_thread_wakeup = undefined, .delay_queue = undefined, }; + try self.fs_thread_wakeup.init(); errdefer self.fs_thread_wakeup.deinit(); errdefer self.arena.deinit(); @@ -439,13 +440,11 @@ pub const Loop = struct { .overlapped = ResumeNode.overlapped_init, }, }; - var need_to_delete = false; + var need_to_delete = true; defer if (need_to_delete) self.linuxRemoveFd(fd); suspend { - if (self.linuxAddFd(fd, &resume_node.base, flags)) |_| { - need_to_delete = true; - } else |err| switch (err) { + self.linuxAddFd(fd, &resume_node.base, flags) catch |err| switch (err) { error.FileDescriptorNotRegistered => unreachable, error.OperationCausesCircularLoop => unreachable, error.FileDescriptorIncompatibleWithEpoll => unreachable, @@ -455,6 +454,7 @@ pub const Loop = struct { error.UserResourceLimitReached, error.Unexpected, => { + need_to_delete = false; // Fall back to a blocking poll(). Ideally this codepath is never hit, since // epoll should be just fine. But this is better than incorrect behavior. var poll_flags: i16 = 0; @@ -478,7 +478,7 @@ pub const Loop = struct { }; resume @frame(); }, - } + }; } } @@ -784,7 +784,7 @@ pub const Loop = struct { timer: std.time.Timer, waiters: Waiters, thread: *std.Thread, - event: std.AutoResetEvent, + event: std.Thread.AutoResetEvent, is_running: bool, /// Initialize the delay queue by spawning the timer thread @@ -795,9 +795,10 @@ pub const Loop = struct { .waiters = DelayQueue.Waiters{ .entries = std.atomic.Queue(anyframe).init(), }, - .thread = try std.Thread.spawn(self, DelayQueue.run), - .event = std.AutoResetEvent{}, + .event = std.Thread.AutoResetEvent{}, .is_running = true, + // Must be last so that it can read the other state, such as `is_running`. + .thread = try std.Thread.spawn(self, DelayQueue.run), }; } @@ -1261,7 +1262,7 @@ pub const Loop = struct { flags: u32, dest_addr: ?*const os.sockaddr, addrlen: os.socklen_t, - ) os.SendError!usize { + ) os.SendToError!usize { while (true) { return os.sendto(sockfd, buf, flags, dest_addr, addrlen) catch |err| switch (err) { error.WouldBlock => { diff --git a/lib/std/event/rwlock.zig b/lib/std/event/rwlock.zig index 3e3928d379..750131beda 100644 --- a/lib/std/event/rwlock.zig +++ b/lib/std/event/rwlock.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/event/rwlocked.zig b/lib/std/event/rwlocked.zig index 4fb25b59a1..0272ca39c7 100644 --- a/lib/std/event/rwlocked.zig +++ b/lib/std/event/rwlocked.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/event/wait_group.zig b/lib/std/event/wait_group.zig index c59e3b233d..0b83c18c74 100644 --- a/lib/std/event/wait_group.zig +++ b/lib/std/event/wait_group.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -30,7 +30,7 @@ pub fn WaitGroupGeneric(comptime counter_size: u16) type { return struct { counter: CounterType = 0, max_counter: CounterType = std.math.maxInt(CounterType), - mutex: std.Mutex = .{}, + mutex: std.Thread.Mutex = .{}, waiters: ?*Waiter = null, const Waiter = struct { next: ?*Waiter, diff --git a/lib/std/fifo.zig b/lib/std/fifo.zig index 9a7d2209f5..b0771bba16 100644 --- a/lib/std/fifo.zig +++ b/lib/std/fifo.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -44,6 +44,8 @@ pub fn LinearFifo( count: usize, const Self = @This(); + pub const Reader = std.io.Reader(*Self, error{}, readFn); + pub const Writer = std.io.Writer(*Self, error{OutOfMemory}, appendWrite); // Type of Self argument for slice operations. // If buffer is inline (Static) then we need to ensure we haven't @@ -153,7 +155,7 @@ pub fn LinearFifo( var start = self.head + offset; if (start >= self.buf.len) { start -= self.buf.len; - return self.buf[start .. self.count - offset]; + return self.buf[start .. start + (self.count - offset)]; } else { const end = math.min(self.head + self.count, self.buf.len); return self.buf[start..end]; @@ -228,12 +230,7 @@ pub fn LinearFifo( return self.read(dest); } - pub fn reader(self: *Self) std.io.Reader(*Self, error{}, readFn) { - return .{ .context = self }; - } - - /// Deprecated: `use reader` - pub fn inStream(self: *Self) std.io.InStream(*Self, error{}, readFn) { + pub fn reader(self: *Self) Reader { return .{ .context = self }; } @@ -317,18 +314,13 @@ pub fn LinearFifo( } /// Same as `write` except it returns the number of bytes written, which is always the same - /// as `bytes.len`. The purpose of this function existing is to match `std.io.OutStream` API. + /// as `bytes.len`. The purpose of this function existing is to match `std.io.Writer` API. fn appendWrite(self: *Self, bytes: []const u8) error{OutOfMemory}!usize { try self.write(bytes); return bytes.len; } - pub fn writer(self: *Self) std.io.Writer(*Self, error{OutOfMemory}, appendWrite) { - return .{ .context = self }; - } - - /// Deprecated: `use writer` - pub fn outStream(self: *Self) std.io.OutStream(*Self, error{OutOfMemory}, appendWrite) { + pub fn writer(self: *Self) Writer { return .{ .context = self }; } @@ -437,6 +429,8 @@ test "LinearFifo(u8, .Dynamic)" { fifo.writeAssumeCapacity("6 |info| { + try writer.writeAll(@typeName(info.child) ++ "@"); + if (info.size == .Slice) + try formatInt(@ptrToInt(value.ptr), 16, false, FormatOptions{}, writer) + else + try formatInt(@ptrToInt(value), 16, false, FormatOptions{}, writer); + return; + }, + .Optional => |info| { + if (@typeInfo(info.child) == .Pointer) { + try writer.writeAll(@typeName(info.child) ++ "@"); + try formatInt(@ptrToInt(value), 16, false, FormatOptions{}, writer); + return; + } + }, + else => {}, + } + + @compileError("Cannot format non-pointer type " ++ @typeName(T) ++ " with * specifier"); +} + +// This ANY const is a workaround for: https://github.com/ziglang/zig/issues/7948 +const ANY = "any"; + +fn defaultSpec(comptime T: type) [:0]const u8 { + switch (@typeInfo(T)) { + .Array => |_| return ANY, + .Pointer => |ptr_info| switch (ptr_info.size) { + .One => switch (@typeInfo(ptr_info.child)) { + .Array => |_| return "*", + else => {}, + }, + .Many, .C => return "*", + .Slice => return ANY, + }, + .Optional => |info| return defaultSpec(info.child), + else => {}, + } + return ""; +} + pub fn formatType( value: anytype, comptime fmt: []const u8, @@ -374,21 +421,19 @@ pub fn formatType( writer: anytype, max_depth: usize, ) @TypeOf(writer).Error!void { - if (comptime std.mem.eql(u8, fmt, "*")) { - try writer.writeAll(@typeName(std.meta.Child(@TypeOf(value)))); - try writer.writeAll("@"); - try formatInt(@ptrToInt(value), 16, false, FormatOptions{}, writer); - return; + const actual_fmt = comptime if (std.mem.eql(u8, fmt, ANY)) defaultSpec(@TypeOf(value)) else fmt; + if (comptime std.mem.eql(u8, actual_fmt, "*")) { + return formatAddress(value, options, writer); } const T = @TypeOf(value); if (comptime std.meta.trait.hasFn("format")(T)) { - return try value.format(fmt, options, writer); + return try value.format(actual_fmt, options, writer); } switch (@typeInfo(T)) { .ComptimeInt, .Int, .ComptimeFloat, .Float => { - return formatValue(value, fmt, options, writer); + return formatValue(value, actual_fmt, options, writer); }, .Void => { return formatBuf("void", options, writer); @@ -398,16 +443,16 @@ pub fn formatType( }, .Optional => { if (value) |payload| { - return formatType(payload, fmt, options, writer, max_depth); + return formatType(payload, actual_fmt, options, writer, max_depth); } else { return formatBuf("null", options, writer); } }, .ErrorUnion => { if (value) |payload| { - return formatType(payload, fmt, options, writer, max_depth); + return formatType(payload, actual_fmt, options, writer, max_depth); } else |err| { - return formatType(err, fmt, options, writer, max_depth); + return formatType(err, actual_fmt, options, writer, max_depth); } }, .ErrorSet => { @@ -433,22 +478,21 @@ pub fn formatType( } try writer.writeAll("("); - try formatType(@enumToInt(value), fmt, options, writer, max_depth); + try formatType(@enumToInt(value), actual_fmt, options, writer, max_depth); try writer.writeAll(")"); }, - .Union => { + .Union => |info| { try writer.writeAll(@typeName(T)); if (max_depth == 0) { return writer.writeAll("{ ... }"); } - const info = @typeInfo(T).Union; if (info.tag_type) |UnionTagType| { try writer.writeAll("{ ."); try writer.writeAll(@tagName(@as(UnionTagType, value))); try writer.writeAll(" = "); inline for (info.fields) |u_field| { if (value == @field(UnionTagType, u_field.name)) { - try formatType(@field(value, u_field.name), fmt, options, writer, max_depth - 1); + try formatType(@field(value, u_field.name), ANY, options, writer, max_depth - 1); } } try writer.writeAll(" }"); @@ -456,13 +500,13 @@ pub fn formatType( try format(writer, "@{x}", .{@ptrToInt(&value)}); } }, - .Struct => |StructT| { + .Struct => |info| { try writer.writeAll(@typeName(T)); if (max_depth == 0) { return writer.writeAll("{ ... }"); } try writer.writeAll("{"); - inline for (StructT.fields) |f, i| { + inline for (info.fields) |f, i| { if (i == 0) { try writer.writeAll(" ."); } else { @@ -470,77 +514,99 @@ pub fn formatType( } try writer.writeAll(f.name); try writer.writeAll(" = "); - try formatType(@field(value, f.name), fmt, options, writer, max_depth - 1); + try formatType(@field(value, f.name), ANY, options, writer, max_depth - 1); } try writer.writeAll(" }"); }, .Pointer => |ptr_info| switch (ptr_info.size) { .One => switch (@typeInfo(ptr_info.child)) { .Array => |info| { + if (actual_fmt.len == 0) + @compileError("cannot format array ref without a specifier (i.e. {s} or {*})"); if (info.child == u8) { - return formatText(value, fmt, options, writer); + if (comptime mem.indexOfScalar(u8, "sxXeE", actual_fmt[0]) != null) { + return formatText(value, actual_fmt, options, writer); + } } - return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) }); + @compileError("Unknown format string: '" ++ actual_fmt ++ "'"); }, .Enum, .Union, .Struct => { - return formatType(value.*, fmt, options, writer, max_depth); + return formatType(value.*, actual_fmt, options, writer, max_depth); }, - else => return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) }), + else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value) }), }, .Many, .C => { + if (actual_fmt.len == 0) + @compileError("cannot format pointer without a specifier (i.e. {s} or {*})"); if (ptr_info.sentinel) |sentinel| { - return formatType(mem.span(value), fmt, options, writer, max_depth); + return formatType(mem.span(value), actual_fmt, options, writer, max_depth); } if (ptr_info.child == u8) { - if (fmt.len > 0 and fmt[0] == 's') { - return formatText(mem.span(value), fmt, options, writer); + if (comptime mem.indexOfScalar(u8, "sxXeE", actual_fmt[0]) != null) { + return formatText(mem.span(value), actual_fmt, options, writer); } } - return format(writer, "{}@{x}", .{ @typeName(@typeInfo(T).Pointer.child), @ptrToInt(value) }); + @compileError("Unknown format string: '" ++ actual_fmt ++ "'"); }, .Slice => { - if (fmt.len > 0 and ((fmt[0] == 'x') or (fmt[0] == 'X'))) { - return formatText(value, fmt, options, writer); + if (actual_fmt.len == 0) + @compileError("cannot format slice without a specifier (i.e. {s} or {any})"); + if (max_depth == 0) { + return writer.writeAll("{ ... }"); } if (ptr_info.child == u8) { - return formatText(value, fmt, options, writer); + if (comptime mem.indexOfScalar(u8, "sxXeE", actual_fmt[0]) != null) { + return formatText(value, actual_fmt, options, writer); + } } - return format(writer, "{}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value.ptr) }); + try writer.writeAll("{ "); + for (value) |elem, i| { + try formatType(elem, actual_fmt, options, writer, max_depth - 1); + if (i != value.len - 1) { + try writer.writeAll(", "); + } + } + try writer.writeAll(" }"); }, }, .Array => |info| { - const Slice = @Type(builtin.TypeInfo{ - .Pointer = .{ - .size = .Slice, - .is_const = true, - .is_volatile = false, - .is_allowzero = false, - .alignment = @alignOf(info.child), - .child = info.child, - .sentinel = null, - }, - }); - return formatType(@as(Slice, &value), fmt, options, writer, max_depth); + if (actual_fmt.len == 0) + @compileError("cannot format array without a specifier (i.e. {s} or {any})"); + if (max_depth == 0) { + return writer.writeAll("{ ... }"); + } + if (info.child == u8) { + if (comptime mem.indexOfScalar(u8, "sxXeE", actual_fmt[0]) != null) { + return formatText(&value, actual_fmt, options, writer); + } + } + try writer.writeAll("{ "); + for (value) |elem, i| { + try formatType(elem, actual_fmt, options, writer, max_depth - 1); + if (i < value.len - 1) { + try writer.writeAll(", "); + } + } + try writer.writeAll(" }"); }, - .Vector => { - const len = @typeInfo(T).Vector.len; + .Vector => |info| { try writer.writeAll("{ "); var i: usize = 0; - while (i < len) : (i += 1) { - try formatValue(value[i], fmt, options, writer); - if (i < len - 1) { + while (i < info.len) : (i += 1) { + try formatValue(value[i], actual_fmt, options, writer); + if (i < info.len - 1) { try writer.writeAll(", "); } } try writer.writeAll(" }"); }, .Fn => { - return format(writer, "{}@{x}", .{ @typeName(T), @ptrToInt(value) }); + return format(writer, "{s}@{x}", .{ @typeName(T), @ptrToInt(value) }); }, .Type => return formatBuf(@typeName(value), options, writer), .EnumLiteral => { const buffer = [_]u8{'.'} ++ @tagName(value); - return formatType(buffer, fmt, options, writer, max_depth); + return formatBuf(buffer, options, writer); }, .Null => return formatBuf("null", options, writer), else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"), @@ -580,8 +646,7 @@ pub fn formatIntValue( const int_value = if (@TypeOf(value) == comptime_int) blk: { const Int = math.IntFittingRange(value, value); break :blk @as(Int, value); - } else - value; + } else value; if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "d")) { radix = 10; @@ -592,13 +657,6 @@ pub fn formatIntValue( } else { @compileError("Cannot print integer that is larger than 8 bits as a ascii"); } - } else if (comptime std.mem.eql(u8, fmt, "Z")) { - if (@typeInfo(@TypeOf(int_value)).Int.bits <= 8) { - const c: u8 = int_value; - return formatZigEscapes(@as(*const [1]u8, &c), options, writer); - } else { - @compileError("Cannot escape character with more than 8 bits"); - } } else if (comptime std.mem.eql(u8, fmt, "u")) { if (@typeInfo(@TypeOf(int_value)).Int.bits <= 21) { return formatUnicodeCodepoint(@as(u21, int_value), options, writer); @@ -618,7 +676,7 @@ pub fn formatIntValue( radix = 8; uppercase = false; } else { - @compileError("Unknown format string: '" ++ fmt ++ "'"); + @compileError("Unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'"); } return formatInt(int_value, radix, uppercase, options, writer); @@ -645,7 +703,7 @@ fn formatFloatValue( else => |e| return e, }; } else { - @compileError("Unknown format string: '" ++ fmt ++ "'"); + @compileError("Unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'"); } return formatBuf(buf_stream.getWritten(), options, writer); @@ -657,7 +715,7 @@ pub fn formatText( options: FormatOptions, writer: anytype, ) !void { - if (comptime std.mem.eql(u8, fmt, "s") or (fmt.len == 0)) { + if (comptime std.mem.eql(u8, fmt, "s")) { return formatBuf(bytes, options, writer); } else if (comptime (std.mem.eql(u8, fmt, "x") or std.mem.eql(u8, fmt, "X"))) { for (bytes) |c| { @@ -674,12 +732,8 @@ pub fn formatText( } } return; - } else if (comptime std.mem.eql(u8, fmt, "z")) { - return formatZigIdentifier(bytes, options, writer); - } else if (comptime std.mem.eql(u8, fmt, "Z")) { - return formatZigEscapes(bytes, options, writer); } else { - @compileError("Unknown format string: '" ++ fmt ++ "'"); + @compileError("Unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'"); } } @@ -742,52 +796,6 @@ pub fn formatBuf( } } -/// Print the string as a Zig identifier escaping it with @"" syntax if needed. -pub fn formatZigIdentifier( - bytes: []const u8, - options: FormatOptions, - writer: anytype, -) !void { - if (isValidZigIdentifier(bytes)) { - return writer.writeAll(bytes); - } - try writer.writeAll("@\""); - try formatZigEscapes(bytes, options, writer); - try writer.writeByte('"'); -} - -fn isValidZigIdentifier(bytes: []const u8) bool { - for (bytes) |c, i| { - switch (c) { - '_', 'a'...'z', 'A'...'Z' => {}, - '0'...'9' => if (i == 0) return false, - else => return false, - } - } - return std.zig.Token.getKeyword(bytes) == null; -} - -pub fn formatZigEscapes( - bytes: []const u8, - options: FormatOptions, - writer: anytype, -) !void { - for (bytes) |byte| switch (byte) { - '\n' => try writer.writeAll("\\n"), - '\r' => try writer.writeAll("\\r"), - '\t' => try writer.writeAll("\\t"), - '\\' => try writer.writeAll("\\\\"), - '"' => try writer.writeAll("\\\""), - '\'' => try writer.writeAll("\\'"), - ' ', '!', '#'...'&', '('...'[', ']'...'~' => try writer.writeByte(byte), - // Use hex escapes for rest any unprintable characters. - else => { - try writer.writeAll("\\x"); - try formatInt(byte, 16, false, .{ .width = 2, .fill = '0' }, writer); - }, - }; -} - /// Print a float in scientific notation to the specified precision. Null uses full precision. /// It should be the case that every full precision, printed value can be re-parsed back to the /// same type unambiguously. @@ -1078,8 +1086,7 @@ pub fn formatInt( const int_value = if (@TypeOf(value) == comptime_int) blk: { const Int = math.IntFittingRange(value, value); break :blk @as(Int, value); - } else - value; + } else value; const value_info = @typeInfo(@TypeOf(int_value)).Int; @@ -1125,6 +1132,103 @@ pub fn formatIntBuf(out_buf: []u8, value: anytype, base: u8, uppercase: bool, op return fbs.pos; } +/// Formats a number of nanoseconds according to its magnitude: +/// +/// - #ns +/// - [#y][#w][#d][#h][#m]#[.###][u|m]s +pub fn formatDuration(ns: u64, writer: anytype) !void { + var ns_remaining = ns; + inline for (.{ + .{ .ns = 365 * std.time.ns_per_day, .sep = 'y' }, + .{ .ns = std.time.ns_per_week, .sep = 'w' }, + .{ .ns = std.time.ns_per_day, .sep = 'd' }, + .{ .ns = std.time.ns_per_hour, .sep = 'h' }, + .{ .ns = std.time.ns_per_min, .sep = 'm' }, + }) |unit| { + if (ns_remaining >= unit.ns) { + const units = ns_remaining / unit.ns; + try formatInt(units, 10, false, .{}, writer); + try writer.writeByte(unit.sep); + ns_remaining -= units * unit.ns; + if (ns_remaining == 0) return; + } + } + + inline for (.{ + .{ .ns = std.time.ns_per_s, .sep = "s" }, + .{ .ns = std.time.ns_per_ms, .sep = "ms" }, + .{ .ns = std.time.ns_per_us, .sep = "us" }, + }) |unit| { + const kunits = ns_remaining * 1000 / unit.ns; + if (kunits >= 1000) { + try formatInt(kunits / 1000, 10, false, .{}, writer); + if (kunits > 1000) { + // Write up to 3 decimal places + const frac = kunits % 1000; + var buf = [_]u8{ '.', 0, 0, 0 }; + _ = formatIntBuf(buf[1..], frac, 10, false, .{ .fill = '0', .width = 3 }); + var end: usize = 4; + while (end > 1) : (end -= 1) { + if (buf[end - 1] != '0') break; + } + try writer.writeAll(buf[0..end]); + } + try writer.writeAll(unit.sep); + return; + } + } + + try formatInt(ns, 10, false, .{}, writer); + try writer.writeAll("ns"); + return; +} + +test "formatDuration" { + var buf: [24]u8 = undefined; + inline for (.{ + .{ .s = "0ns", .d = 0 }, + .{ .s = "1ns", .d = 1 }, + .{ .s = "999ns", .d = std.time.ns_per_us - 1 }, + .{ .s = "1us", .d = std.time.ns_per_us }, + .{ .s = "1.45us", .d = 1450 }, + .{ .s = "1.5us", .d = 3 * std.time.ns_per_us / 2 }, + .{ .s = "999.999us", .d = std.time.ns_per_ms - 1 }, + .{ .s = "1ms", .d = std.time.ns_per_ms + 1 }, + .{ .s = "1.5ms", .d = 3 * std.time.ns_per_ms / 2 }, + .{ .s = "999.999ms", .d = std.time.ns_per_s - 1 }, + .{ .s = "1s", .d = std.time.ns_per_s }, + .{ .s = "59.999s", .d = std.time.ns_per_min - 1 }, + .{ .s = "1m", .d = std.time.ns_per_min }, + .{ .s = "1h", .d = std.time.ns_per_hour }, + .{ .s = "1d", .d = std.time.ns_per_day }, + .{ .s = "1w", .d = std.time.ns_per_week }, + .{ .s = "1y", .d = 365 * std.time.ns_per_day }, + .{ .s = "1y52w23h59m59.999s", .d = 730 * std.time.ns_per_day - 1 }, // 365d = 52w1d + .{ .s = "1y1h1.001s", .d = 365 * std.time.ns_per_day + std.time.ns_per_hour + std.time.ns_per_s + std.time.ns_per_ms }, + .{ .s = "1y1h1s", .d = 365 * std.time.ns_per_day + std.time.ns_per_hour + std.time.ns_per_s + 999 * std.time.ns_per_us }, + .{ .s = "1y1h999.999us", .d = 365 * std.time.ns_per_day + std.time.ns_per_hour + std.time.ns_per_ms - 1 }, + .{ .s = "1y1h1ms", .d = 365 * std.time.ns_per_day + std.time.ns_per_hour + std.time.ns_per_ms }, + .{ .s = "1y1h1ms", .d = 365 * std.time.ns_per_day + std.time.ns_per_hour + std.time.ns_per_ms + 1 }, + }) |tc| { + const slice = try bufPrint(&buf, "{}", .{duration(tc.d)}); + std.testing.expectEqualStrings(tc.s, slice); + } +} + +/// Wraps a `u64` to format with `formatDuration`. +const Duration = struct { + ns: u64, + + pub fn format(self: Duration, comptime fmt: []const u8, options: FormatOptions, writer: anytype) !void { + return formatDuration(self.ns, writer); + } +}; + +/// Formats a number of nanoseconds according to its magnitude. See `formatDuration`. +pub fn duration(ns: u64) Duration { + return Duration{ .ns = ns }; +} + pub const ParseIntError = error{ /// The result cannot fit in the type specified Overflow, @@ -1133,6 +1237,32 @@ pub const ParseIntError = error{ InvalidCharacter, }; +/// Creates a Formatter type from a format function. Wrapping data in Formatter(func) causes +/// the data to be formatted using the given function `func`. `func` must be of the following +/// form: +/// +/// fn formatExample( +/// data: T, +/// comptime fmt: []const u8, +/// options: std.fmt.FormatOptions, +/// writer: anytype, +/// ) !void; +/// +pub fn Formatter(comptime format_fn: anytype) type { + const Data = @typeInfo(@TypeOf(format_fn)).Fn.args[0].arg_type.?; + return struct { + data: Data, + pub fn format( + self: @This(), + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, + ) @TypeOf(writer).Error!void { + try format_fn(self.data, fmt, options, writer); + } + }; +} + /// Parses the string `buf` as signed or unsigned representation in the /// specified radix of an integral value of type `T`. /// @@ -1414,91 +1544,91 @@ test "parse unsigned comptime" { } test "escaped braces" { - try testFmt("escaped: {{foo}}\n", "escaped: {{{{foo}}}}\n", .{}); - try testFmt("escaped: {foo}\n", "escaped: {{foo}}\n", .{}); + try expectFmt("escaped: {{foo}}\n", "escaped: {{{{foo}}}}\n", .{}); + try expectFmt("escaped: {foo}\n", "escaped: {{foo}}\n", .{}); } test "optional" { { const value: ?i32 = 1234; - try testFmt("optional: 1234\n", "optional: {}\n", .{value}); + try expectFmt("optional: 1234\n", "optional: {}\n", .{value}); } { const value: ?i32 = null; - try testFmt("optional: null\n", "optional: {}\n", .{value}); + try expectFmt("optional: null\n", "optional: {}\n", .{value}); } { const value = @intToPtr(?*i32, 0xf000d000); - try testFmt("optional: *i32@f000d000\n", "optional: {*}\n", .{value}); + try expectFmt("optional: *i32@f000d000\n", "optional: {*}\n", .{value}); } } test "error" { { const value: anyerror!i32 = 1234; - try testFmt("error union: 1234\n", "error union: {}\n", .{value}); + try expectFmt("error union: 1234\n", "error union: {}\n", .{value}); } { const value: anyerror!i32 = error.InvalidChar; - try testFmt("error union: error.InvalidChar\n", "error union: {}\n", .{value}); + try expectFmt("error union: error.InvalidChar\n", "error union: {}\n", .{value}); } } test "int.small" { { const value: u3 = 0b101; - try testFmt("u3: 5\n", "u3: {}\n", .{value}); + try expectFmt("u3: 5\n", "u3: {}\n", .{value}); } } test "int.specifier" { { const value: u8 = 'a'; - try testFmt("u8: a\n", "u8: {c}\n", .{value}); + try expectFmt("u8: a\n", "u8: {c}\n", .{value}); } { const value: u8 = 0b1100; - try testFmt("u8: 0b1100\n", "u8: 0b{b}\n", .{value}); + try expectFmt("u8: 0b1100\n", "u8: 0b{b}\n", .{value}); } { const value: u16 = 0o1234; - try testFmt("u16: 0o1234\n", "u16: 0o{o}\n", .{value}); + try expectFmt("u16: 0o1234\n", "u16: 0o{o}\n", .{value}); } { const value: u8 = 'a'; - try testFmt("UTF-8: a\n", "UTF-8: {u}\n", .{value}); + try expectFmt("UTF-8: a\n", "UTF-8: {u}\n", .{value}); } { const value: u21 = 0x1F310; - try testFmt("UTF-8: 🌐\n", "UTF-8: {u}\n", .{value}); + try expectFmt("UTF-8: 🌐\n", "UTF-8: {u}\n", .{value}); } { const value: u21 = 0xD800; - try testFmt("UTF-8: �\n", "UTF-8: {u}\n", .{value}); + try expectFmt("UTF-8: �\n", "UTF-8: {u}\n", .{value}); } { const value: u21 = 0x110001; - try testFmt("UTF-8: �\n", "UTF-8: {u}\n", .{value}); + try expectFmt("UTF-8: �\n", "UTF-8: {u}\n", .{value}); } } test "int.padded" { - try testFmt("u8: ' 1'", "u8: '{:4}'", .{@as(u8, 1)}); - try testFmt("u8: '1000'", "u8: '{:0<4}'", .{@as(u8, 1)}); - try testFmt("u8: '0001'", "u8: '{:0>4}'", .{@as(u8, 1)}); - try testFmt("u8: '0100'", "u8: '{:0^4}'", .{@as(u8, 1)}); - try testFmt("i8: '-1 '", "i8: '{:<4}'", .{@as(i8, -1)}); - try testFmt("i8: ' -1'", "i8: '{:>4}'", .{@as(i8, -1)}); - try testFmt("i8: ' -1 '", "i8: '{:^4}'", .{@as(i8, -1)}); - try testFmt("i16: '-1234'", "i16: '{:4}'", .{@as(i16, -1234)}); - try testFmt("i16: '+1234'", "i16: '{:4}'", .{@as(i16, 1234)}); - try testFmt("i16: '-12345'", "i16: '{:4}'", .{@as(i16, -12345)}); - try testFmt("i16: '+12345'", "i16: '{:4}'", .{@as(i16, 12345)}); - try testFmt("u16: '12345'", "u16: '{:4}'", .{@as(u16, 12345)}); + try expectFmt("u8: ' 1'", "u8: '{:4}'", .{@as(u8, 1)}); + try expectFmt("u8: '1000'", "u8: '{:0<4}'", .{@as(u8, 1)}); + try expectFmt("u8: '0001'", "u8: '{:0>4}'", .{@as(u8, 1)}); + try expectFmt("u8: '0100'", "u8: '{:0^4}'", .{@as(u8, 1)}); + try expectFmt("i8: '-1 '", "i8: '{:<4}'", .{@as(i8, -1)}); + try expectFmt("i8: ' -1'", "i8: '{:>4}'", .{@as(i8, -1)}); + try expectFmt("i8: ' -1 '", "i8: '{:^4}'", .{@as(i8, -1)}); + try expectFmt("i16: '-1234'", "i16: '{:4}'", .{@as(i16, -1234)}); + try expectFmt("i16: '+1234'", "i16: '{:4}'", .{@as(i16, 1234)}); + try expectFmt("i16: '-12345'", "i16: '{:4}'", .{@as(i16, -12345)}); + try expectFmt("i16: '+12345'", "i16: '{:4}'", .{@as(i16, 12345)}); + try expectFmt("u16: '12345'", "u16: '{:4}'", .{@as(u16, 12345)}); - try testFmt("UTF-8: 'ü '", "UTF-8: '{u:<4}'", .{'ü'}); - try testFmt("UTF-8: ' ü'", "UTF-8: '{u:>4}'", .{'ü'}); - try testFmt("UTF-8: ' ü '", "UTF-8: '{u:^4}'", .{'ü'}); + try expectFmt("UTF-8: 'ü '", "UTF-8: '{u:<4}'", .{'ü'}); + try expectFmt("UTF-8: ' ü'", "UTF-8: '{u:>4}'", .{'ü'}); + try expectFmt("UTF-8: ' ü '", "UTF-8: '{u:^4}'", .{'ü'}); } test "buffer" { @@ -1521,11 +1651,12 @@ test "buffer" { test "array" { { const value: [3]u8 = "abc".*; - try testFmt("array: abc\n", "array: {}\n", .{value}); - try testFmt("array: abc\n", "array: {}\n", .{&value}); + try expectFmt("array: abc\n", "array: {s}\n", .{value}); + try expectFmt("array: abc\n", "array: {s}\n", .{&value}); + try expectFmt("array: { 97, 98, 99 }\n", "array: {d}\n", .{value}); var buf: [100]u8 = undefined; - try testFmt( + try expectFmt( try bufPrint(buf[0..], "array: [3]u8@{x}\n", .{@ptrToInt(&value)}), "array: {*}\n", .{&value}, @@ -1536,62 +1667,60 @@ test "array" { test "slice" { { const value: []const u8 = "abc"; - try testFmt("slice: abc\n", "slice: {}\n", .{value}); + try expectFmt("slice: abc\n", "slice: {s}\n", .{value}); } { var runtime_zero: usize = 0; const value = @intToPtr([*]align(1) const []const u8, 0xdeadbeef)[runtime_zero..runtime_zero]; - try testFmt("slice: []const u8@deadbeef\n", "slice: {}\n", .{value}); + try expectFmt("slice: []const u8@deadbeef\n", "slice: {*}\n", .{value}); } { const null_term_slice: [:0]const u8 = "\x00hello\x00"; - try testFmt("buf: \x00hello\x00\n", "buf: {s}\n", .{null_term_slice}); + try expectFmt("buf: \x00hello\x00\n", "buf: {s}\n", .{null_term_slice}); } - try testFmt("buf: Test\n", "buf: {s:5}\n", .{"Test"}); - try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", .{"Test"}); + try expectFmt("buf: Test\n", "buf: {s:5}\n", .{"Test"}); + try expectFmt("buf: Test\n Other text", "buf: {s}\n Other text", .{"Test"}); + + { + var int_slice = [_]u32{ 1, 4096, 391891, 1111111111 }; + var runtime_zero: usize = 0; + try expectFmt("int: { 1, 4096, 391891, 1111111111 }", "int: {any}", .{int_slice[runtime_zero..]}); + try expectFmt("int: { 1, 4096, 391891, 1111111111 }", "int: {d}", .{int_slice[runtime_zero..]}); + try expectFmt("int: { 1, 1000, 5fad3, 423a35c7 }", "int: {x}", .{int_slice[runtime_zero..]}); + try expectFmt("int: { 00001, 01000, 5fad3, 423a35c7 }", "int: {x:0>5}", .{int_slice[runtime_zero..]}); + } } test "escape non-printable" { - try testFmt("abc", "{e}", .{"abc"}); - try testFmt("ab\\xffc", "{e}", .{"ab\xffc"}); - try testFmt("ab\\xFFc", "{E}", .{"ab\xffc"}); -} - -test "escape invalid identifiers" { - try testFmt("@\"while\"", "{z}", .{"while"}); - try testFmt("hello", "{z}", .{"hello"}); - try testFmt("@\"11\\\"23\"", "{z}", .{"11\"23"}); - try testFmt("@\"11\\x0f23\"", "{z}", .{"11\x0F23"}); - try testFmt("\\x0f", "{Z}", .{0x0f}); - try testFmt( - \\" \\ hi \x07 \x11 \" derp \'" - , "\"{Z}\"", .{" \\ hi \x07 \x11 \" derp '"}); + try expectFmt("abc", "{e}", .{"abc"}); + try expectFmt("ab\\xffc", "{e}", .{"ab\xffc"}); + try expectFmt("ab\\xFFc", "{E}", .{"ab\xffc"}); } test "pointer" { { const value = @intToPtr(*align(1) i32, 0xdeadbeef); - try testFmt("pointer: i32@deadbeef\n", "pointer: {}\n", .{value}); - try testFmt("pointer: i32@deadbeef\n", "pointer: {*}\n", .{value}); + try expectFmt("pointer: i32@deadbeef\n", "pointer: {}\n", .{value}); + try expectFmt("pointer: i32@deadbeef\n", "pointer: {*}\n", .{value}); } { const value = @intToPtr(fn () void, 0xdeadbeef); - try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value}); + try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value}); } { const value = @intToPtr(fn () void, 0xdeadbeef); - try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value}); + try expectFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value}); } } test "cstr" { - try testFmt( + try expectFmt( "cstr: Test C\n", "cstr: {s}\n", .{@ptrCast([*c]const u8, "Test C")}, ); - try testFmt( + try expectFmt( "cstr: Test C\n", "cstr: {s:10}\n", .{@ptrCast([*c]const u8, "Test C")}, @@ -1599,8 +1728,8 @@ test "cstr" { } test "filesize" { - try testFmt("file size: 63MiB\n", "file size: {Bi}\n", .{@as(usize, 63 * 1024 * 1024)}); - try testFmt("file size: 66.06MB\n", "file size: {B:.2}\n", .{@as(usize, 63 * 1024 * 1024)}); + try expectFmt("file size: 63MiB\n", "file size: {Bi}\n", .{@as(usize, 63 * 1024 * 1024)}); + try expectFmt("file size: 66.06MB\n", "file size: {B:.2}\n", .{@as(usize, 63 * 1024 * 1024)}); } test "struct" { @@ -1609,8 +1738,8 @@ test "struct" { field: u8, }; const value = Struct{ .field = 42 }; - try testFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", .{value}); - try testFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", .{&value}); + try expectFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", .{value}); + try expectFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", .{&value}); } { const Struct = struct { @@ -1618,7 +1747,7 @@ test "struct" { b: u1, }; const value = Struct{ .a = 0, .b = 1 }; - try testFmt("struct: Struct{ .a = 0, .b = 1 }\n", "struct: {}\n", .{value}); + try expectFmt("struct: Struct{ .a = 0, .b = 1 }\n", "struct: {}\n", .{value}); } } @@ -1628,13 +1757,13 @@ test "enum" { Two, }; const value = Enum.Two; - try testFmt("enum: Enum.Two\n", "enum: {}\n", .{value}); - try testFmt("enum: Enum.Two\n", "enum: {}\n", .{&value}); - try testFmt("enum: Enum.One\n", "enum: {x}\n", .{Enum.One}); - try testFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two}); + try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{value}); + try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{&value}); + try expectFmt("enum: Enum.One\n", "enum: {x}\n", .{Enum.One}); + try expectFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two}); // test very large enum to verify ct branch quota is large enough - try testFmt("enum: Win32Error.INVALID_FUNCTION\n", "enum: {}\n", .{std.os.windows.Win32Error.INVALID_FUNCTION}); + try expectFmt("enum: Win32Error.INVALID_FUNCTION\n", "enum: {}\n", .{std.os.windows.Win32Error.INVALID_FUNCTION}); } test "non-exhaustive enum" { @@ -1643,78 +1772,78 @@ test "non-exhaustive enum" { Two = 0xbeef, _, }; - try testFmt("enum: Enum.One\n", "enum: {}\n", .{Enum.One}); - try testFmt("enum: Enum.Two\n", "enum: {}\n", .{Enum.Two}); - try testFmt("enum: Enum(4660)\n", "enum: {}\n", .{@intToEnum(Enum, 0x1234)}); - try testFmt("enum: Enum.One\n", "enum: {x}\n", .{Enum.One}); - try testFmt("enum: Enum.Two\n", "enum: {x}\n", .{Enum.Two}); - try testFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two}); - try testFmt("enum: Enum(1234)\n", "enum: {x}\n", .{@intToEnum(Enum, 0x1234)}); + try expectFmt("enum: Enum.One\n", "enum: {}\n", .{Enum.One}); + try expectFmt("enum: Enum.Two\n", "enum: {}\n", .{Enum.Two}); + try expectFmt("enum: Enum(4660)\n", "enum: {}\n", .{@intToEnum(Enum, 0x1234)}); + try expectFmt("enum: Enum.One\n", "enum: {x}\n", .{Enum.One}); + try expectFmt("enum: Enum.Two\n", "enum: {x}\n", .{Enum.Two}); + try expectFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two}); + try expectFmt("enum: Enum(1234)\n", "enum: {x}\n", .{@intToEnum(Enum, 0x1234)}); } test "float.scientific" { - try testFmt("f32: 1.34000003e+00", "f32: {e}", .{@as(f32, 1.34)}); - try testFmt("f32: 1.23400001e+01", "f32: {e}", .{@as(f32, 12.34)}); - try testFmt("f64: -1.234e+11", "f64: {e}", .{@as(f64, -12.34e10)}); - try testFmt("f64: 9.99996e-40", "f64: {e}", .{@as(f64, 9.999960e-40)}); + try expectFmt("f32: 1.34000003e+00", "f32: {e}", .{@as(f32, 1.34)}); + try expectFmt("f32: 1.23400001e+01", "f32: {e}", .{@as(f32, 12.34)}); + try expectFmt("f64: -1.234e+11", "f64: {e}", .{@as(f64, -12.34e10)}); + try expectFmt("f64: 9.99996e-40", "f64: {e}", .{@as(f64, 9.999960e-40)}); } test "float.scientific.precision" { - try testFmt("f64: 1.40971e-42", "f64: {e:.5}", .{@as(f64, 1.409706e-42)}); - try testFmt("f64: 1.00000e-09", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 814313563)))}); - try testFmt("f64: 7.81250e-03", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1006632960)))}); + try expectFmt("f64: 1.40971e-42", "f64: {e:.5}", .{@as(f64, 1.409706e-42)}); + try expectFmt("f64: 1.00000e-09", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 814313563)))}); + try expectFmt("f64: 7.81250e-03", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1006632960)))}); // libc rounds 1.000005e+05 to 1.00000e+05 but zig does 1.00001e+05. // In fact, libc doesn't round a lot of 5 cases up when one past the precision point. - try testFmt("f64: 1.00001e+05", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1203982400)))}); + try expectFmt("f64: 1.00001e+05", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1203982400)))}); } test "float.special" { - try testFmt("f64: nan", "f64: {}", .{math.nan_f64}); + try expectFmt("f64: nan", "f64: {}", .{math.nan_f64}); // negative nan is not defined by IEE 754, // and ARM thus normalizes it to positive nan if (builtin.arch != builtin.Arch.arm) { - try testFmt("f64: -nan", "f64: {}", .{-math.nan_f64}); + try expectFmt("f64: -nan", "f64: {}", .{-math.nan_f64}); } - try testFmt("f64: inf", "f64: {}", .{math.inf_f64}); - try testFmt("f64: -inf", "f64: {}", .{-math.inf_f64}); + try expectFmt("f64: inf", "f64: {}", .{math.inf_f64}); + try expectFmt("f64: -inf", "f64: {}", .{-math.inf_f64}); } test "float.decimal" { - try testFmt("f64: 152314000000000000000000000000", "f64: {d}", .{@as(f64, 1.52314e+29)}); - try testFmt("f32: 0", "f32: {d}", .{@as(f32, 0.0)}); - try testFmt("f32: 1.1", "f32: {d:.1}", .{@as(f32, 1.1234)}); - try testFmt("f32: 1234.57", "f32: {d:.2}", .{@as(f32, 1234.567)}); + try expectFmt("f64: 152314000000000000000000000000", "f64: {d}", .{@as(f64, 1.52314e+29)}); + try expectFmt("f32: 0", "f32: {d}", .{@as(f32, 0.0)}); + try expectFmt("f32: 1.1", "f32: {d:.1}", .{@as(f32, 1.1234)}); + try expectFmt("f32: 1234.57", "f32: {d:.2}", .{@as(f32, 1234.567)}); // -11.1234 is converted to f64 -11.12339... internally (errol3() function takes f64). // -11.12339... is rounded back up to -11.1234 - try testFmt("f32: -11.1234", "f32: {d:.4}", .{@as(f32, -11.1234)}); - try testFmt("f32: 91.12345", "f32: {d:.5}", .{@as(f32, 91.12345)}); - try testFmt("f64: 91.1234567890", "f64: {d:.10}", .{@as(f64, 91.12345678901235)}); - try testFmt("f64: 0.00000", "f64: {d:.5}", .{@as(f64, 0.0)}); - try testFmt("f64: 6", "f64: {d:.0}", .{@as(f64, 5.700)}); - try testFmt("f64: 10.0", "f64: {d:.1}", .{@as(f64, 9.999)}); - try testFmt("f64: 1.000", "f64: {d:.3}", .{@as(f64, 1.0)}); - try testFmt("f64: 0.00030000", "f64: {d:.8}", .{@as(f64, 0.0003)}); - try testFmt("f64: 0.00000", "f64: {d:.5}", .{@as(f64, 1.40130e-45)}); - try testFmt("f64: 0.00000", "f64: {d:.5}", .{@as(f64, 9.999960e-40)}); + try expectFmt("f32: -11.1234", "f32: {d:.4}", .{@as(f32, -11.1234)}); + try expectFmt("f32: 91.12345", "f32: {d:.5}", .{@as(f32, 91.12345)}); + try expectFmt("f64: 91.1234567890", "f64: {d:.10}", .{@as(f64, 91.12345678901235)}); + try expectFmt("f64: 0.00000", "f64: {d:.5}", .{@as(f64, 0.0)}); + try expectFmt("f64: 6", "f64: {d:.0}", .{@as(f64, 5.700)}); + try expectFmt("f64: 10.0", "f64: {d:.1}", .{@as(f64, 9.999)}); + try expectFmt("f64: 1.000", "f64: {d:.3}", .{@as(f64, 1.0)}); + try expectFmt("f64: 0.00030000", "f64: {d:.8}", .{@as(f64, 0.0003)}); + try expectFmt("f64: 0.00000", "f64: {d:.5}", .{@as(f64, 1.40130e-45)}); + try expectFmt("f64: 0.00000", "f64: {d:.5}", .{@as(f64, 9.999960e-40)}); } test "float.libc.sanity" { - try testFmt("f64: 0.00001", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 916964781)))}); - try testFmt("f64: 0.00001", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 925353389)))}); - try testFmt("f64: 0.10000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1036831278)))}); - try testFmt("f64: 1.00000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1065353133)))}); - try testFmt("f64: 10.00000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1092616192)))}); + try expectFmt("f64: 0.00001", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 916964781)))}); + try expectFmt("f64: 0.00001", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 925353389)))}); + try expectFmt("f64: 0.10000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1036831278)))}); + try expectFmt("f64: 1.00000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1065353133)))}); + try expectFmt("f64: 10.00000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1092616192)))}); // libc differences // // This is 0.015625 exactly according to gdb. We thus round down, // however glibc rounds up for some reason. This occurs for all // floats of the form x.yyyy25 on a precision point. - try testFmt("f64: 0.01563", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1015021568)))}); + try expectFmt("f64: 0.01563", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1015021568)))}); // errol3 rounds to ... 630 but libc rounds to ...632. Grisu3 // also rounds to 630 so I'm inclined to believe libc is not // optimal here. - try testFmt("f64: 18014400656965630.00000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1518338049)))}); + try expectFmt("f64: 18014400656965630.00000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1518338049)))}); } test "custom" { @@ -1744,12 +1873,12 @@ test "custom" { .x = 10.2, .y = 2.22, }; - try testFmt("point: (10.200,2.220)\n", "point: {}\n", .{&value}); - try testFmt("dim: 10.200x2.220\n", "dim: {d}\n", .{&value}); + try expectFmt("point: (10.200,2.220)\n", "point: {}\n", .{&value}); + try expectFmt("dim: 10.200x2.220\n", "dim: {d}\n", .{&value}); // same thing but not passing a pointer - try testFmt("point: (10.200,2.220)\n", "point: {}\n", .{value}); - try testFmt("dim: 10.200x2.220\n", "dim: {d}\n", .{value}); + try expectFmt("point: (10.200,2.220)\n", "point: {}\n", .{value}); + try expectFmt("dim: 10.200x2.220\n", "dim: {d}\n", .{value}); } test "struct" { @@ -1763,7 +1892,7 @@ test "struct" { .b = error.Unused, }; - try testFmt("S{ .a = 456, .b = error.Unused }", "{}", .{inst}); + try expectFmt("S{ .a = 456, .b = error.Unused }", "{}", .{inst}); } test "union" { @@ -1786,7 +1915,7 @@ test "union" { const uu_inst = UU{ .int = 456 }; const eu_inst = EU{ .float = 321.123 }; - try testFmt("TU{ .int = 123 }", "{}", .{tu_inst}); + try expectFmt("TU{ .int = 123 }", "{}", .{tu_inst}); var buf: [100]u8 = undefined; const uu_result = try bufPrint(buf[0..], "{}", .{uu_inst}); @@ -1805,7 +1934,7 @@ test "enum" { const inst = E.Two; - try testFmt("E.Two", "{}", .{inst}); + try expectFmt("E.Two", "{}", .{inst}); } test "struct.self-referential" { @@ -1819,7 +1948,7 @@ test "struct.self-referential" { }; inst.a = &inst; - try testFmt("S{ .a = S{ .a = S{ .a = S{ ... } } } }", "{}", .{inst}); + try expectFmt("S{ .a = S{ .a = S{ .a = S{ ... } } } }", "{}", .{inst}); } test "struct.zero-size" { @@ -1834,53 +1963,51 @@ test "struct.zero-size" { const a = A{}; const b = B{ .a = a, .c = 0 }; - try testFmt("B{ .a = A{ }, .c = 0 }", "{}", .{b}); + try expectFmt("B{ .a = A{ }, .c = 0 }", "{}", .{b}); } test "bytes.hex" { const some_bytes = "\xCA\xFE\xBA\xBE"; - try testFmt("lowercase: cafebabe\n", "lowercase: {x}\n", .{some_bytes}); - try testFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", .{some_bytes}); + try expectFmt("lowercase: cafebabe\n", "lowercase: {x}\n", .{some_bytes}); + try expectFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", .{some_bytes}); //Test Slices - try testFmt("uppercase: CAFE\n", "uppercase: {X}\n", .{some_bytes[0..2]}); - try testFmt("lowercase: babe\n", "lowercase: {x}\n", .{some_bytes[2..]}); + try expectFmt("uppercase: CAFE\n", "uppercase: {X}\n", .{some_bytes[0..2]}); + try expectFmt("lowercase: babe\n", "lowercase: {x}\n", .{some_bytes[2..]}); const bytes_with_zeros = "\x00\x0E\xBA\xBE"; - try testFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", .{bytes_with_zeros}); -} - -fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) !void { - var buf: [100]u8 = undefined; - const result = try bufPrint(buf[0..], template, args); - if (mem.eql(u8, result, expected)) return; - - std.debug.warn("\n====== expected this output: =========\n", .{}); - std.debug.warn("{}", .{expected}); - std.debug.warn("\n======== instead found this: =========\n", .{}); - std.debug.warn("{}", .{result}); - std.debug.warn("\n======================================\n", .{}); - return error.TestFailed; + try expectFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", .{bytes_with_zeros}); } pub const trim = @compileError("deprecated; use std.mem.trim with std.ascii.spaces instead"); pub const isWhiteSpace = @compileError("deprecated; use std.ascii.isSpace instead"); -pub fn hexToBytes(out: []u8, input: []const u8) !void { - if (out.len * 2 < input.len) +/// Decodes the sequence of bytes represented by the specified string of +/// hexadecimal characters. +/// Returns a slice of the output buffer containing the decoded bytes. +pub fn hexToBytes(out: []u8, input: []const u8) ![]u8 { + // Expect 0 or n pairs of hexadecimal digits. + if (input.len & 1 != 0) return error.InvalidLength; + if (out.len * 2 < input.len) + return error.NoSpaceLeft; var in_i: usize = 0; - while (in_i != input.len) : (in_i += 2) { + while (in_i < input.len) : (in_i += 2) { const hi = try charToDigit(input[in_i], 16); const lo = try charToDigit(input[in_i + 1], 16); out[in_i / 2] = (hi << 4) | lo; } + + return out[0 .. in_i / 2]; } test "hexToBytes" { - const test_hex_str = "909A312BB12ED1F819B3521AC4C1E896F2160507FFC1C8381E3B07BB16BD1706"; - var pb: [32]u8 = undefined; - try hexToBytes(pb[0..], test_hex_str); - try testFmt(test_hex_str, "{X}", .{pb}); + var buf: [32]u8 = undefined; + try expectFmt("90" ** 32, "{X}", .{try hexToBytes(&buf, "90" ** 32)}); + try expectFmt("ABCD", "{X}", .{try hexToBytes(&buf, "ABCD")}); + try expectFmt("", "{X}", .{try hexToBytes(&buf, "")}); + std.testing.expectError(error.InvalidCharacter, hexToBytes(&buf, "012Z")); + std.testing.expectError(error.InvalidLength, hexToBytes(&buf, "AAA")); + std.testing.expectError(error.NoSpaceLeft, hexToBytes(buf[0..1], "ABAB")); } test "formatIntValue with comptime_int" { @@ -1900,8 +2027,8 @@ test "formatFloatValue with comptime_float" { try formatFloatValue(value, "", FormatOptions{}, fbs.writer()); std.testing.expect(mem.eql(u8, fbs.getWritten(), "1.0e+00")); - try testFmt("1.0e+00", "{}", .{value}); - try testFmt("1.0e+00", "{}", .{1.0}); + try expectFmt("1.0e+00", "{}", .{value}); + try expectFmt("1.0e+00", "{}", .{1.0}); } test "formatType max_depth" { @@ -1970,19 +2097,19 @@ test "formatType max_depth" { } test "positional" { - try testFmt("2 1 0", "{2} {1} {0}", .{ @as(usize, 0), @as(usize, 1), @as(usize, 2) }); - try testFmt("2 1 0", "{2} {1} {}", .{ @as(usize, 0), @as(usize, 1), @as(usize, 2) }); - try testFmt("0 0", "{0} {0}", .{@as(usize, 0)}); - try testFmt("0 1", "{} {1}", .{ @as(usize, 0), @as(usize, 1) }); - try testFmt("1 0 0 1", "{1} {} {0} {}", .{ @as(usize, 0), @as(usize, 1) }); + try expectFmt("2 1 0", "{2} {1} {0}", .{ @as(usize, 0), @as(usize, 1), @as(usize, 2) }); + try expectFmt("2 1 0", "{2} {1} {}", .{ @as(usize, 0), @as(usize, 1), @as(usize, 2) }); + try expectFmt("0 0", "{0} {0}", .{@as(usize, 0)}); + try expectFmt("0 1", "{} {1}", .{ @as(usize, 0), @as(usize, 1) }); + try expectFmt("1 0 0 1", "{1} {} {0} {}", .{ @as(usize, 0), @as(usize, 1) }); } test "positional with specifier" { - try testFmt("10.0", "{0d:.1}", .{@as(f64, 9.999)}); + try expectFmt("10.0", "{0d:.1}", .{@as(f64, 9.999)}); } test "positional/alignment/width/precision" { - try testFmt("10.0", "{0d: >3.1}", .{@as(f64, 9.999)}); + try expectFmt("10.0", "{0d: >3.1}", .{@as(f64, 9.999)}); } test "vector" { @@ -2003,76 +2130,76 @@ test "vector" { const vi64: std.meta.Vector(4, i64) = [_]i64{ -2, -1, 0, 1 }; const vu64: std.meta.Vector(4, u64) = [_]u64{ 1000, 2000, 3000, 4000 }; - try testFmt("{ true, false, true, false }", "{}", .{vbool}); - try testFmt("{ -2, -1, 0, 1 }", "{}", .{vi64}); - try testFmt("{ -2, -1, +0, +1 }", "{d:5}", .{vi64}); - try testFmt("{ 1000, 2000, 3000, 4000 }", "{}", .{vu64}); - try testFmt("{ 3e8, 7d0, bb8, fa0 }", "{x}", .{vu64}); - try testFmt("{ 1kB, 2kB, 3kB, 4kB }", "{B}", .{vu64}); - try testFmt("{ 1000B, 1.953125KiB, 2.9296875KiB, 3.90625KiB }", "{Bi}", .{vu64}); + try expectFmt("{ true, false, true, false }", "{}", .{vbool}); + try expectFmt("{ -2, -1, 0, 1 }", "{}", .{vi64}); + try expectFmt("{ -2, -1, +0, +1 }", "{d:5}", .{vi64}); + try expectFmt("{ 1000, 2000, 3000, 4000 }", "{}", .{vu64}); + try expectFmt("{ 3e8, 7d0, bb8, fa0 }", "{x}", .{vu64}); + try expectFmt("{ 1kB, 2kB, 3kB, 4kB }", "{B}", .{vu64}); + try expectFmt("{ 1000B, 1.953125KiB, 2.9296875KiB, 3.90625KiB }", "{Bi}", .{vu64}); } test "enum-literal" { - try testFmt(".hello_world", "{}", .{.hello_world}); + try expectFmt(".hello_world", "{s}", .{.hello_world}); } test "padding" { - try testFmt("Simple", "{}", .{"Simple"}); - try testFmt(" true", "{:10}", .{true}); - try testFmt(" true", "{:>10}", .{true}); - try testFmt("======true", "{:=>10}", .{true}); - try testFmt("true======", "{:=<10}", .{true}); - try testFmt(" true ", "{:^10}", .{true}); - try testFmt("===true===", "{:=^10}", .{true}); - try testFmt(" Minimum width", "{:18} width", .{"Minimum"}); - try testFmt("==================Filled", "{:=>24}", .{"Filled"}); - try testFmt(" Centered ", "{:^24}", .{"Centered"}); - try testFmt("-", "{:-^1}", .{""}); - try testFmt("==crêpe===", "{:=^10}", .{"crêpe"}); - try testFmt("=====crêpe", "{:=>10}", .{"crêpe"}); - try testFmt("crêpe=====", "{:=<10}", .{"crêpe"}); + try expectFmt("Simple", "{s}", .{"Simple"}); + try expectFmt(" true", "{:10}", .{true}); + try expectFmt(" true", "{:>10}", .{true}); + try expectFmt("======true", "{:=>10}", .{true}); + try expectFmt("true======", "{:=<10}", .{true}); + try expectFmt(" true ", "{:^10}", .{true}); + try expectFmt("===true===", "{:=^10}", .{true}); + try expectFmt(" Minimum width", "{s:18} width", .{"Minimum"}); + try expectFmt("==================Filled", "{s:=>24}", .{"Filled"}); + try expectFmt(" Centered ", "{s:^24}", .{"Centered"}); + try expectFmt("-", "{s:-^1}", .{""}); + try expectFmt("==crêpe===", "{s:=^10}", .{"crêpe"}); + try expectFmt("=====crêpe", "{s:=>10}", .{"crêpe"}); + try expectFmt("crêpe=====", "{s:=<10}", .{"crêpe"}); } test "decimal float padding" { var number: f32 = 3.1415; - try testFmt("left-pad: **3.141\n", "left-pad: {d:*>7.3}\n", .{number}); - try testFmt("center-pad: *3.141*\n", "center-pad: {d:*^7.3}\n", .{number}); - try testFmt("right-pad: 3.141**\n", "right-pad: {d:*<7.3}\n", .{number}); + try expectFmt("left-pad: **3.141\n", "left-pad: {d:*>7.3}\n", .{number}); + try expectFmt("center-pad: *3.141*\n", "center-pad: {d:*^7.3}\n", .{number}); + try expectFmt("right-pad: 3.141**\n", "right-pad: {d:*<7.3}\n", .{number}); } test "sci float padding" { var number: f32 = 3.1415; - try testFmt("left-pad: **3.141e+00\n", "left-pad: {e:*>11.3}\n", .{number}); - try testFmt("center-pad: *3.141e+00*\n", "center-pad: {e:*^11.3}\n", .{number}); - try testFmt("right-pad: 3.141e+00**\n", "right-pad: {e:*<11.3}\n", .{number}); + try expectFmt("left-pad: **3.141e+00\n", "left-pad: {e:*>11.3}\n", .{number}); + try expectFmt("center-pad: *3.141e+00*\n", "center-pad: {e:*^11.3}\n", .{number}); + try expectFmt("right-pad: 3.141e+00**\n", "right-pad: {e:*<11.3}\n", .{number}); } test "null" { const inst = null; - try testFmt("null", "{}", .{inst}); + try expectFmt("null", "{}", .{inst}); } test "type" { - try testFmt("u8", "{}", .{u8}); - try testFmt("?f32", "{}", .{?f32}); - try testFmt("[]const u8", "{}", .{[]const u8}); + try expectFmt("u8", "{}", .{u8}); + try expectFmt("?f32", "{}", .{?f32}); + try expectFmt("[]const u8", "{}", .{[]const u8}); } test "named arguments" { - try testFmt("hello world!", "{} world{c}", .{ "hello", '!' }); - try testFmt("hello world!", "{[greeting]} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" }); - try testFmt("hello world!", "{[1]} world{[0]c}", .{ '!', "hello" }); + try expectFmt("hello world!", "{s} world{c}", .{ "hello", '!' }); + try expectFmt("hello world!", "{[greeting]s} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" }); + try expectFmt("hello world!", "{[1]s} world{[0]c}", .{ '!', "hello" }); } test "runtime width specifier" { var width: usize = 9; - try testFmt("~~hello~~", "{:~^[1]}", .{ "hello", width }); - try testFmt("~~hello~~", "{:~^[width]}", .{ .string = "hello", .width = width }); + try expectFmt("~~hello~~", "{s:~^[1]}", .{ "hello", width }); + try expectFmt("~~hello~~", "{s:~^[width]}", .{ .string = "hello", .width = width }); } test "runtime precision specifier" { var number: f32 = 3.1415; var precision: usize = 2; - try testFmt("3.14e+00", "{:1.[1]}", .{ number, precision }); - try testFmt("3.14e+00", "{:1.[precision]}", .{ .number = number, .precision = precision }); + try expectFmt("3.14e+00", "{:1.[1]}", .{ number, precision }); + try expectFmt("3.14e+00", "{:1.[precision]}", .{ .number = number, .precision = precision }); } diff --git a/lib/std/fmt/errol.zig b/lib/std/fmt/errol.zig index 6a0a2256d8..a4f46e7f13 100644 --- a/lib/std/fmt/errol.zig +++ b/lib/std/fmt/errol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/fmt/errol/enum3.zig b/lib/std/fmt/errol/enum3.zig index 9dbe27c072..db671b8d25 100644 --- a/lib/std/fmt/errol/enum3.zig +++ b/lib/std/fmt/errol/enum3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/fmt/errol/lookup.zig b/lib/std/fmt/errol/lookup.zig index 85a4234bca..4499d3fdef 100644 --- a/lib/std/fmt/errol/lookup.zig +++ b/lib/std/fmt/errol/lookup.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig index 4396676d9e..324b06898e 100644 --- a/lib/std/fmt/parse_float.zig +++ b/lib/std/fmt/parse_float.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -52,21 +52,21 @@ const Z96 = struct { d2: u32, // d = s >> 1 - inline fn shiftRight1(d: *Z96, s: Z96) void { + fn shiftRight1(d: *Z96, s: Z96) callconv(.Inline) void { d.d0 = (s.d0 >> 1) | ((s.d1 & 1) << 31); d.d1 = (s.d1 >> 1) | ((s.d2 & 1) << 31); d.d2 = s.d2 >> 1; } // d = s << 1 - inline fn shiftLeft1(d: *Z96, s: Z96) void { + fn shiftLeft1(d: *Z96, s: Z96) callconv(.Inline) void { d.d2 = (s.d2 << 1) | ((s.d1 & (1 << 31)) >> 31); d.d1 = (s.d1 << 1) | ((s.d0 & (1 << 31)) >> 31); d.d0 = s.d0 << 1; } // d += s - inline fn add(d: *Z96, s: Z96) void { + fn add(d: *Z96, s: Z96) callconv(.Inline) void { var w = @as(u64, d.d0) + @as(u64, s.d0); d.d0 = @truncate(u32, w); @@ -80,7 +80,7 @@ const Z96 = struct { } // d -= s - inline fn sub(d: *Z96, s: Z96) void { + fn sub(d: *Z96, s: Z96) callconv(.Inline) void { var w = @as(u64, d.d0) -% @as(u64, s.d0); d.d0 = @truncate(u32, w); diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 8b949a57f1..79385708af 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -39,7 +39,7 @@ pub const Watch = @import("fs/watch.zig").Watch; /// fit into a UTF-8 encoded array of this length. /// The byte count includes room for a null sentinel byte. pub const MAX_PATH_BYTES = switch (builtin.os.tag) { - .linux, .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd => os.PATH_MAX, + .linux, .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd, .haiku => os.PATH_MAX, // Each UTF-16LE character may be expanded to 3 UTF-8 bytes. // If it would require 4 UTF-8 bytes, then there would be a surrogate // pair in the UTF-16LE, and we (over)account 3 bytes for it that way. @@ -82,8 +82,8 @@ pub fn atomicSymLink(allocator: *Allocator, existing_path: []const u8, new_path: mem.copy(u8, tmp_path[0..], dirname); tmp_path[dirname.len] = path.sep; while (true) { - try crypto.randomBytes(rand_buf[0..]); - base64_encoder.encode(tmp_path[dirname.len + 1 ..], &rand_buf); + crypto.random.bytes(rand_buf[0..]); + _ = base64_encoder.encode(tmp_path[dirname.len + 1 ..], &rand_buf); if (cwd().symLink(existing_path, tmp_path, .{})) { return cwd().rename(tmp_path, new_path); @@ -153,15 +153,14 @@ pub const AtomicFile = struct { ) InitError!AtomicFile { var rand_buf: [RANDOM_BYTES]u8 = undefined; var tmp_path_buf: [TMP_PATH_LEN:0]u8 = undefined; - // TODO: should be able to use TMP_PATH_LEN here. - tmp_path_buf[base64.Base64Encoder.calcSize(RANDOM_BYTES)] = 0; while (true) { - try crypto.randomBytes(rand_buf[0..]); - base64_encoder.encode(&tmp_path_buf, &rand_buf); + crypto.random.bytes(rand_buf[0..]); + const tmp_path = base64_encoder.encode(&tmp_path_buf, &rand_buf); + tmp_path_buf[tmp_path.len] = 0; const file = dir.createFile( - &tmp_path_buf, + tmp_path, .{ .mode = mode, .exclusive = true }, ) catch |err| switch (err) { error.PathAlreadyExists => continue, @@ -428,6 +427,78 @@ pub const Dir = struct { } } }, + .haiku => struct { + dir: Dir, + buf: [8192]u8, // TODO align(@alignOf(os.dirent64)), + index: usize, + end_index: usize, + + const Self = @This(); + + pub const Error = IteratorError; + + /// Memory such as file names referenced in this returned entry becomes invalid + /// with subsequent calls to `next`, as well as when this `Dir` is deinitialized. + pub fn next(self: *Self) Error!?Entry { + start_over: while (true) { + // TODO: find a better max + const HAIKU_MAX_COUNT = 10000; + if (self.index >= self.end_index) { + const rc = os.system._kern_read_dir( + self.dir.fd, + &self.buf, + self.buf.len, + HAIKU_MAX_COUNT, + ); + if (rc == 0) return null; + if (rc < 0) { + switch (os.errno(rc)) { + os.EBADF => unreachable, // Dir is invalid or was opened without iteration ability + os.EFAULT => unreachable, + os.ENOTDIR => unreachable, + os.EINVAL => unreachable, + else => |err| return os.unexpectedErrno(err), + } + } + self.index = 0; + self.end_index = @intCast(usize, rc); + } + const haiku_entry = @ptrCast(*align(1) os.dirent, &self.buf[self.index]); + const next_index = self.index + haiku_entry.reclen(); + self.index = next_index; + const name = mem.spanZ(@ptrCast([*:0]u8, &haiku_entry.d_name)); + + if (mem.eql(u8, name, ".") or mem.eql(u8, name, "..") or (haiku_entry.d_ino == 0)) { + continue :start_over; + } + + var stat_info: os.libc_stat = undefined; + const rc2 = os.system._kern_read_stat( + self.dir.fd, + &haiku_entry.d_name, + false, + &stat_info, + 0, + ); + const statmode = stat_info.mode & os.S_IFMT; + + const entry_kind = switch (statmode) { + os.S_IFDIR => Entry.Kind.Directory, + os.S_IFBLK => Entry.Kind.BlockDevice, + os.S_IFCHR => Entry.Kind.CharacterDevice, + os.S_IFLNK => Entry.Kind.SymLink, + os.S_IFREG => Entry.Kind.File, + os.S_IFIFO => Entry.Kind.NamedPipe, + else => Entry.Kind.Unknown, + }; + + return Entry{ + .name = name, + .kind = entry_kind, + }; + } + } + }, .linux => struct { dir: Dir, buf: [8192]u8, // TODO align(@alignOf(os.dirent64)), @@ -622,14 +693,20 @@ pub const Dir = struct { pub fn iterate(self: Dir) Iterator { switch (builtin.os.tag) { - .macos, .ios, .freebsd, .netbsd, .dragonfly, .openbsd => return Iterator{ + .macos, + .ios, + .freebsd, + .netbsd, + .dragonfly, + .openbsd, + => return Iterator{ .dir = self, .seek = 0, .index = 0, .end_index = 0, .buf = undefined, }, - .linux => return Iterator{ + .linux, .haiku => return Iterator{ .dir = self, .index = 0, .end_index = 0, @@ -2184,10 +2261,10 @@ pub const Walker = struct { while (true) { if (self.stack.items.len == 0) return null; // `top` becomes invalid after appending to `self.stack`. - const top = &self.stack.items[self.stack.items.len - 1]; + var top = &self.stack.items[self.stack.items.len - 1]; const dirname_len = top.dirname_len; if (try top.dir_it.next()) |base| { - self.name_buffer.shrink(dirname_len); + self.name_buffer.shrinkRetainingCapacity(dirname_len); try self.name_buffer.append(path.sep); try self.name_buffer.appendSlice(base.name); if (base.kind == .Directory) { @@ -2201,6 +2278,7 @@ pub const Walker = struct { .dir_it = new_dir.iterate(), .dirname_len = self.name_buffer.items.len, }); + top = &self.stack.items[self.stack.items.len - 1]; } } return Entry{ @@ -2339,7 +2417,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { // TODO could this slice from 0 to out_len instead? return mem.spanZ(std.meta.assumeSentinel(out_buffer.ptr, 0)); }, - .openbsd => { + .openbsd, .haiku => { // OpenBSD doesn't support getting the path of a running process, so try to guess it if (os.argv.len == 0) return error.FileNotFound; @@ -2475,7 +2553,7 @@ fn copy_file(fd_in: os.fd_t, fd_out: os.fd_t) CopyFileError!void { } } -test "" { +test { if (builtin.os.tag != .wasi) { _ = makeDirAbsolute; _ = makeDirAbsoluteZ; diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig index dc7b39eef1..baea3b4e7f 100644 --- a/lib/std/fs/file.zig +++ b/lib/std/fs/file.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -117,7 +117,7 @@ pub const File = struct { truncate: bool = true, /// Ensures that this open call creates the file, otherwise causes - /// `error.FileAlreadyExists` to be returned. + /// `error.PathAlreadyExists` to be returned. exclusive: bool = false, /// Open the file with a lock to prevent other processes from accessing it at the @@ -459,6 +459,7 @@ pub const File = struct { return index; } + /// See https://github.com/ziglang/zig/issues/7699 pub fn readv(self: File, iovecs: []const os.iovec) ReadError!usize { if (is_windows) { // TODO improve this to use ReadFileScatter @@ -479,6 +480,7 @@ pub const File = struct { /// is not an error condition. /// The `iovecs` parameter is mutable because this function needs to mutate the fields in /// order to handle partial reads from the underlying OS layer. + /// See https://github.com/ziglang/zig/issues/7699 pub fn readvAll(self: File, iovecs: []os.iovec) ReadError!usize { if (iovecs.len == 0) return; @@ -500,6 +502,7 @@ pub const File = struct { } } + /// See https://github.com/ziglang/zig/issues/7699 pub fn preadv(self: File, iovecs: []const os.iovec, offset: u64) PReadError!usize { if (is_windows) { // TODO improve this to use ReadFileScatter @@ -520,6 +523,7 @@ pub const File = struct { /// is not an error condition. /// The `iovecs` parameter is mutable because this function needs to mutate the fields in /// order to handle partial reads from the underlying OS layer. + /// See https://github.com/ziglang/zig/issues/7699 pub fn preadvAll(self: File, iovecs: []const os.iovec, offset: u64) PReadError!void { if (iovecs.len == 0) return; @@ -582,6 +586,8 @@ pub const File = struct { } } + /// See https://github.com/ziglang/zig/issues/7699 + /// See equivalent function: `std.net.Stream.writev`. pub fn writev(self: File, iovecs: []const os.iovec_const) WriteError!usize { if (is_windows) { // TODO improve this to use WriteFileScatter @@ -599,6 +605,8 @@ pub const File = struct { /// The `iovecs` parameter is mutable because this function needs to mutate the fields in /// order to handle partial writes from the underlying OS layer. + /// See https://github.com/ziglang/zig/issues/7699 + /// See equivalent function: `std.net.Stream.writevAll`. pub fn writevAll(self: File, iovecs: []os.iovec_const) WriteError!void { if (iovecs.len == 0) return; @@ -615,6 +623,7 @@ pub const File = struct { } } + /// See https://github.com/ziglang/zig/issues/7699 pub fn pwritev(self: File, iovecs: []os.iovec_const, offset: u64) PWriteError!usize { if (is_windows) { // TODO improve this to use WriteFileScatter @@ -632,6 +641,7 @@ pub const File = struct { /// The `iovecs` parameter is mutable because this function needs to mutate the fields in /// order to handle partial writes from the underlying OS layer. + /// See https://github.com/ziglang/zig/issues/7699 pub fn pwritevAll(self: File, iovecs: []os.iovec_const, offset: u64) PWriteError!void { if (iovecs.len == 0) return; @@ -690,7 +700,7 @@ pub const File = struct { header_count: usize = 0, }; - pub const WriteFileError = ReadError || WriteError; + pub const WriteFileError = ReadError || error{EndOfStream} || WriteError; pub fn writeFileAll(self: File, in_file: File, args: WriteFileOptions) WriteFileError!void { return self.writeFileAllSendfile(in_file, args) catch |err| switch (err) { @@ -698,6 +708,8 @@ pub const File = struct { error.FastOpenAlreadyInProgress, error.MessageTooBig, error.FileDescriptorNotASocket, + error.NetworkUnreachable, + error.NetworkSubsystemFailed, => return self.writeFileAllUnseekable(in_file, args), else => |e| return e, @@ -712,23 +724,14 @@ pub const File = struct { try self.writevAll(headers); - var buffer: [4096]u8 = undefined; - { - var index: usize = 0; - // Skip in_offset bytes. - while (index < args.in_offset) { - const ask = math.min(buffer.len, args.in_offset - index); - const amt = try in_file.read(buffer[0..ask]); - index += amt; - } - } - const in_len = args.in_len orelse math.maxInt(u64); - var index: usize = 0; - while (index < in_len) { - const ask = math.min(buffer.len, in_len - index); - const amt = try in_file.read(buffer[0..ask]); - if (amt == 0) break; - index += try self.write(buffer[0..amt]); + try in_file.reader().skipBytes(args.in_offset, .{ .buf_size = 4096 }); + + var fifo = std.fifo.LinearFifo(u8, .{ .Static = 4096 }).init(); + if (args.in_len) |len| { + var stream = std.io.limitedReader(in_file.reader(), len); + try fifo.pump(stream.reader(), self.writer()); + } else { + try fifo.pump(in_file.reader(), self.writer()); } try self.writevAll(trailers); @@ -803,32 +806,16 @@ pub const File = struct { pub const Reader = io.Reader(File, ReadError, read); - /// Deprecated: use `Reader` - pub const InStream = Reader; - pub fn reader(file: File) Reader { return .{ .context = file }; } - /// Deprecated: use `reader` - pub fn inStream(file: File) Reader { - return .{ .context = file }; - } - pub const Writer = io.Writer(File, WriteError, write); - /// Deprecated: use `Writer` - pub const OutStream = Writer; - pub fn writer(file: File) Writer { return .{ .context = file }; } - /// Deprecated: use `writer` - pub fn outStream(file: File) Writer { - return .{ .context = file }; - } - pub const SeekableStream = io.SeekableStream( File, SeekError, diff --git a/lib/std/fs/get_app_data_dir.zig b/lib/std/fs/get_app_data_dir.zig index 9e7e54e1b5..18f8458eb2 100644 --- a/lib/std/fs/get_app_data_dir.zig +++ b/lib/std/fs/get_app_data_dir.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -56,6 +56,18 @@ pub fn getAppDataDir(allocator: *mem.Allocator, appname: []const u8) GetAppDataD }; return fs.path.join(allocator, &[_][]const u8{ home_dir, ".local", "share", appname }); }, + .haiku => { + var dir_path_ptr: [*:0]u8 = undefined; + // TODO look into directory_which + const be_user_settings = 0xbbe; + const rc = os.system.find_directory(be_user_settings, -1, true, dir_path_ptr, 1) ; + const settings_dir = try allocator.dupeZ(u8, mem.spanZ(dir_path_ptr)); + defer allocator.free(settings_dir); + switch (rc) { + 0 => return fs.path.join(allocator, &[_][]const u8{ settings_dir, appname }), + else => return error.AppDataDirUnavailable, + } + }, else => @compileError("Unsupported OS"), } } diff --git a/lib/std/fs/path.zig b/lib/std/fs/path.zig index 9043889aa9..c04b9dff66 100644 --- a/lib/std/fs/path.zig +++ b/lib/std/fs/path.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -39,7 +39,7 @@ pub fn isSep(byte: u8) bool { /// This is different from mem.join in that the separator will not be repeated if /// it is found at the end or beginning of a pair of consecutive paths. -fn joinSep(allocator: *Allocator, separator: u8, paths: []const []const u8) ![]u8 { +fn joinSep(allocator: *Allocator, separator: u8, sepPredicate: fn (u8) bool, paths: []const []const u8) ![]u8 { if (paths.len == 0) return &[0]u8{}; const total_len = blk: { @@ -48,8 +48,8 @@ fn joinSep(allocator: *Allocator, separator: u8, paths: []const []const u8) ![]u while (i < paths.len) : (i += 1) { const prev_path = paths[i - 1]; const this_path = paths[i]; - const prev_sep = (prev_path.len != 0 and prev_path[prev_path.len - 1] == separator); - const this_sep = (this_path.len != 0 and this_path[0] == separator); + const prev_sep = (prev_path.len != 0 and sepPredicate(prev_path[prev_path.len - 1])); + const this_sep = (this_path.len != 0 and sepPredicate(this_path[0])); sum += @boolToInt(!prev_sep and !this_sep); sum += if (prev_sep and this_sep) this_path.len - 1 else this_path.len; } @@ -65,8 +65,8 @@ fn joinSep(allocator: *Allocator, separator: u8, paths: []const []const u8) ![]u while (i < paths.len) : (i += 1) { const prev_path = paths[i - 1]; const this_path = paths[i]; - const prev_sep = (prev_path.len != 0 and prev_path[prev_path.len - 1] == separator); - const this_sep = (this_path.len != 0 and this_path[0] == separator); + const prev_sep = (prev_path.len != 0 and sepPredicate(prev_path[prev_path.len - 1])); + const this_sep = (this_path.len != 0 and sepPredicate(this_path[0])); if (!prev_sep and !this_sep) { buf[buf_index] = separator; buf_index += 1; @@ -80,28 +80,30 @@ fn joinSep(allocator: *Allocator, separator: u8, paths: []const []const u8) ![]u return buf; } -pub const join = if (builtin.os.tag == .windows) joinWindows else joinPosix; - /// Naively combines a series of paths with the native path seperator. /// Allocates memory for the result, which must be freed by the caller. -pub fn joinWindows(allocator: *Allocator, paths: []const []const u8) ![]u8 { - return joinSep(allocator, sep_windows, paths); -} - -/// Naively combines a series of paths with the native path seperator. -/// Allocates memory for the result, which must be freed by the caller. -pub fn joinPosix(allocator: *Allocator, paths: []const []const u8) ![]u8 { - return joinSep(allocator, sep_posix, paths); +pub fn join(allocator: *Allocator, paths: []const []const u8) ![]u8 { + return joinSep(allocator, sep, isSep, paths); } fn testJoinWindows(paths: []const []const u8, expected: []const u8) void { - const actual = joinWindows(testing.allocator, paths) catch @panic("fail"); + const windowsIsSep = struct { + fn isSep(byte: u8) bool { + return byte == '/' or byte == '\\'; + } + }.isSep; + const actual = joinSep(testing.allocator, sep_windows, windowsIsSep, paths) catch @panic("fail"); defer testing.allocator.free(actual); testing.expectEqualSlices(u8, expected, actual); } fn testJoinPosix(paths: []const []const u8, expected: []const u8) void { - const actual = joinPosix(testing.allocator, paths) catch @panic("fail"); + const posixIsSep = struct { + fn isSep(byte: u8) bool { + return byte == '/'; + } + }.isSep; + const actual = joinSep(testing.allocator, sep_posix, posixIsSep, paths) catch @panic("fail"); defer testing.allocator.free(actual); testing.expectEqualSlices(u8, expected, actual); } @@ -119,6 +121,9 @@ test "join" { "c:\\home\\andy\\dev\\zig\\build\\lib\\zig\\std\\io.zig", ); + testJoinWindows(&[_][]const u8{ "c:\\", "a", "b/", "c" }, "c:\\a\\b/c"); + testJoinWindows(&[_][]const u8{ "c:\\a/", "b\\", "/c" }, "c:\\a/b\\c"); + testJoinPosix(&[_][]const u8{ "/a/b", "c" }, "/a/b/c"); testJoinPosix(&[_][]const u8{ "/a/b/", "c" }, "/a/b/c"); diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index 61df39be0c..e9f28a0b60 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -750,7 +750,7 @@ test "open file with exclusive lock twice, make sure it waits" { errdefer file.close(); const S = struct { - const C = struct { dir: *fs.Dir, evt: *std.ResetEvent }; + const C = struct { dir: *fs.Dir, evt: *std.Thread.ResetEvent }; fn checkFn(ctx: C) !void { const file1 = try ctx.dir.createFile(filename, .{ .lock = .Exclusive }); defer file1.close(); @@ -758,7 +758,8 @@ test "open file with exclusive lock twice, make sure it waits" { } }; - var evt = std.ResetEvent.init(); + var evt: std.Thread.ResetEvent = undefined; + try evt.init(); defer evt.deinit(); const t = try std.Thread.spawn(S.C{ .dir = &tmp.dir, .evt = &evt }, S.checkFn); @@ -771,8 +772,6 @@ test "open file with exclusive lock twice, make sure it waits" { std.time.sleep(SLEEP_TIMEOUT_NS); if (timer.read() >= SLEEP_TIMEOUT_NS) break; } - // Check that createFile is still waiting for the lock to be released. - testing.expect(!evt.isSet()); file.close(); // No timeout to avoid failures on heavily loaded systems. evt.wait(); @@ -795,3 +794,42 @@ test "open file with exclusive nonblocking lock twice (absolute paths)" { try fs.deleteFileAbsolute(filename); } + +test "walker" { + if (builtin.os.tag == .wasi) return error.SkipZigTest; + + var arena = ArenaAllocator.init(testing.allocator); + defer arena.deinit(); + var allocator = &arena.allocator; + + var tmp = tmpDir(.{}); + defer tmp.cleanup(); + + const nb_dirs = 8; + + var i: usize = 0; + var sub_dir = tmp.dir; + while (i < nb_dirs) : (i += 1) { + const dir_name = try std.fmt.allocPrint(allocator, "{}", .{i}); + try sub_dir.makeDir(dir_name); + sub_dir = try sub_dir.openDir(dir_name, .{}); + } + + const tmp_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] }); + + var walker = try fs.walkPath(testing.allocator, tmp_path); + defer walker.deinit(); + + i = 0; + var expected_dir_name: []const u8 = ""; + while (i < nb_dirs) : (i += 1) { + const name = try std.fmt.allocPrint(allocator, "{}", .{i}); + expected_dir_name = if (expected_dir_name.len == 0) + name + else + try fs.path.join(allocator, &[_][]const u8{ expected_dir_name, name }); + + var entry = (try walker.next()).?; + testing.expectEqualStrings(expected_dir_name, try fs.path.relative(allocator, tmp_path, entry.path)); + } +} diff --git a/lib/std/fs/wasi.zig b/lib/std/fs/wasi.zig index cad86e2314..cf5431f994 100644 --- a/lib/std/fs/wasi.zig +++ b/lib/std/fs/wasi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -38,7 +38,7 @@ pub const PreopenType = union(PreopenTypeTag) { pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void { try out_stream.print("PreopenType{{ ", .{}); switch (self) { - PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{path}), + PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{std.zig.fmtId(path)}), } return out_stream.print(" }}", .{}); } diff --git a/lib/std/fs/watch.zig b/lib/std/fs/watch.zig index 2e75b865cf..1c7cb68b32 100644 --- a/lib/std/fs/watch.zig +++ b/lib/std/fs/watch.zig @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -const std = @import("../std.zig"); +const std = @import("std"); const builtin = @import("builtin"); const event = std.event; const assert = std.debug.assert; @@ -24,16 +24,6 @@ const WatchEventId = enum { Delete, }; -fn eqlString(a: []const u16, b: []const u16) bool { - if (a.len != b.len) return false; - if (a.ptr == b.ptr) return true; - return mem.compare(u16, a, b) == .Equal; -} - -fn hashString(s: []const u16) u32 { - return @truncate(u32, std.hash.Wyhash.hash(0, mem.sliceAsBytes(s))); -} - const WatchEventError = error{ UserResourceLimitReached, SystemResources, @@ -43,7 +33,7 @@ const WatchEventError = error{ pub fn Watch(comptime V: type) type { return struct { - channel: *event.Channel(Event.Error!Event), + channel: event.Channel(Event.Error!Event), os_data: OsData, allocator: *Allocator, @@ -57,10 +47,10 @@ pub fn Watch(comptime V: type) type { }; const KqOsData = struct { - file_table: FileTable, table_lock: event.Lock, + file_table: FileTable, - const FileTable = std.StringHashMap(*Put); + const FileTable = std.StringHashMapUnmanaged(*Put); const Put = struct { putter_frame: @Frame(kqPutEvents), cancelled: bool = false, @@ -71,21 +61,15 @@ pub fn Watch(comptime V: type) type { const WindowsOsData = struct { table_lock: event.Lock, dir_table: DirTable, - all_putters: std.atomic.Queue(Put), - ref_count: std.atomic.Int(usize), + cancelled: bool = false, - const Put = struct { - putter: anyframe, - cancelled: bool = false, - }; - - const DirTable = std.StringHashMap(*Dir); - const FileTable = std.HashMap([]const u16, V, hashString, eqlString); + const DirTable = std.StringHashMapUnmanaged(*Dir); + const FileTable = std.StringHashMapUnmanaged(V); const Dir = struct { putter_frame: @Frame(windowsDirReader), file_table: FileTable, - table_lock: event.Lock, + dir_handle: os.windows.HANDLE, }; }; @@ -96,8 +80,8 @@ pub fn Watch(comptime V: type) type { table_lock: event.Lock, cancelled: bool = false, - const WdTable = std.AutoHashMap(i32, Dir); - const FileTable = std.StringHashMap(V); + const WdTable = std.AutoHashMapUnmanaged(i32, Dir); + const FileTable = std.StringHashMapUnmanaged(V); const Dir = struct { dirname: []const u8, @@ -110,19 +94,14 @@ pub fn Watch(comptime V: type) type { pub const Event = struct { id: Id, data: V, + dirname: []const u8, + basename: []const u8, pub const Id = WatchEventId; pub const Error = WatchEventError; }; pub fn init(allocator: *Allocator, event_buf_count: usize) !*Self { - const channel = try allocator.create(event.Channel(Event.Error!Event)); - errdefer allocator.destroy(channel); - var buf = try allocator.alloc(Event.Error!Event, event_buf_count); - errdefer allocator.free(buf); - channel.init(buf); - errdefer channel.deinit(); - const self = try allocator.create(Self); errdefer allocator.destroy(self); @@ -133,15 +112,17 @@ pub fn Watch(comptime V: type) type { self.* = Self{ .allocator = allocator, - .channel = channel, + .channel = undefined, .os_data = OsData{ .putter_frame = undefined, .inotify_fd = inotify_fd, .wd_table = OsData.WdTable.init(allocator), - .table_lock = event.Lock.init(), + .table_lock = event.Lock{}, }, }; + var buf = try allocator.alloc(Event.Error!Event, event_buf_count); + self.channel.init(buf); self.os_data.putter_frame = async self.linuxEventPutter(); return self; }, @@ -149,82 +130,93 @@ pub fn Watch(comptime V: type) type { .windows => { self.* = Self{ .allocator = allocator, - .channel = channel, + .channel = undefined, .os_data = OsData{ - .table_lock = event.Lock.init(), + .table_lock = event.Lock{}, .dir_table = OsData.DirTable.init(allocator), - .ref_count = std.atomic.Int(usize).init(1), - .all_putters = std.atomic.Queue(anyframe).init(), }, }; + + var buf = try allocator.alloc(Event.Error!Event, event_buf_count); + self.channel.init(buf); return self; }, .macos, .freebsd, .netbsd, .dragonfly, .openbsd => { self.* = Self{ .allocator = allocator, - .channel = channel, + .channel = undefined, .os_data = OsData{ - .table_lock = event.Lock.init(), + .table_lock = event.Lock{}, .file_table = OsData.FileTable.init(allocator), }, }; + + var buf = try allocator.alloc(Event.Error!Event, event_buf_count); + self.channel.init(buf); return self; }, else => @compileError("Unsupported OS"), } } - /// All addFile calls and removeFile calls must have completed. pub fn deinit(self: *Self) void { switch (builtin.os.tag) { .macos, .freebsd, .netbsd, .dragonfly, .openbsd => { - // TODO we need to cancel the frames before destroying the lock - self.os_data.table_lock.deinit(); var it = self.os_data.file_table.iterator(); while (it.next()) |entry| { - entry.cancelled = true; - await entry.value.putter; + entry.value.cancelled = true; + // @TODO Close the fd here? + await entry.value.putter_frame; self.allocator.free(entry.key); - self.allocator.free(entry.value); + self.allocator.destroy(entry.value); } - self.channel.deinit(); - self.allocator.destroy(self.channel.buffer_nodes); - self.allocator.destroy(self); }, .linux => { self.os_data.cancelled = true; + { + // Remove all directory watches linuxEventPutter will take care of + // cleaning up the memory and closing the inotify fd. + var dir_it = self.os_data.wd_table.iterator(); + while (dir_it.next()) |wd_entry| { + const rc = os.linux.inotify_rm_watch(self.os_data.inotify_fd, wd_entry.key); + // Errno can only be EBADF, EINVAL if either the inotify fs or the wd are invalid + std.debug.assert(rc == 0); + } + } await self.os_data.putter_frame; - self.allocator.destroy(self); }, .windows => { - while (self.os_data.all_putters.get()) |putter_node| { - putter_node.cancelled = true; - await putter_node.frame; + self.os_data.cancelled = true; + var dir_it = self.os_data.dir_table.iterator(); + while (dir_it.next()) |dir_entry| { + if (windows.kernel32.CancelIoEx(dir_entry.value.dir_handle, null) != 0) { + // We canceled the pending ReadDirectoryChangesW operation, but our + // frame is still suspending, now waiting indefinitely. + // Thus, it is safe to resume it ourslves + resume dir_entry.value.putter_frame; + } else { + std.debug.assert(windows.kernel32.GetLastError() == .NOT_FOUND); + // We are at another suspend point, we can await safely for the + // function to exit the loop + await dir_entry.value.putter_frame; + } + + self.allocator.free(dir_entry.key); + var file_it = dir_entry.value.file_table.iterator(); + while (file_it.next()) |file_entry| { + self.allocator.free(file_entry.key); + } + dir_entry.value.file_table.deinit(self.allocator); + self.allocator.destroy(dir_entry.value); } - self.deref(); + self.os_data.dir_table.deinit(self.allocator); }, else => @compileError("Unsupported OS"), } - } - - fn ref(self: *Self) void { - _ = self.os_data.ref_count.incr(); - } - - fn deref(self: *Self) void { - if (self.os_data.ref_count.decr() == 1) { - self.os_data.table_lock.deinit(); - var it = self.os_data.dir_table.iterator(); - while (it.next()) |entry| { - self.allocator.free(entry.key); - self.allocator.destroy(entry.value); - } - self.os_data.dir_table.deinit(); - self.channel.deinit(); - self.allocator.destroy(self.channel.buffer_nodes); - self.allocator.destroy(self); - } + self.allocator.free(self.channel.buffer_nodes); + self.channel.deinit(); + self.allocator.destroy(self); } pub fn addFile(self: *Self, file_path: []const u8, value: V) !?V { @@ -237,217 +229,208 @@ pub fn Watch(comptime V: type) type { } fn addFileKEvent(self: *Self, file_path: []const u8, value: V) !?V { - const resolved_path = try std.fs.path.resolve(self.allocator, [_][]const u8{file_path}); - var resolved_path_consumed = false; - defer if (!resolved_path_consumed) self.allocator.free(resolved_path); + var realpath_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; + const realpath = try os.realpath(file_path, &realpath_buf); - var close_op = try CloseOperation.start(self.allocator); - var close_op_consumed = false; - defer if (!close_op_consumed) close_op.finish(); + const held = self.os_data.table_lock.acquire(); + defer held.release(); - const flags = if (comptime std.Target.current.isDarwin()) os.O_SYMLINK | os.O_EVTONLY else 0; - const mode = 0; - const fd = try openPosix(self.allocator, resolved_path, flags, mode); - close_op.setHandle(fd); - - var put = try self.allocator.create(OsData.Put); - errdefer self.allocator.destroy(put); - put.* = OsData.Put{ - .value = value, - .putter_frame = undefined, - }; - put.putter_frame = async self.kqPutEvents(close_op, put); - close_op_consumed = true; - errdefer { - put.cancelled = true; - await put.putter_frame; + const gop = try self.os_data.file_table.getOrPut(self.allocator, realpath); + errdefer self.os_data.file_table.removeAssertDiscard(realpath); + if (gop.found_existing) { + const prev_value = gop.entry.value.value; + gop.entry.value.value = value; + return prev_value; } - const result = blk: { - const held = self.os_data.table_lock.acquire(); - defer held.release(); - - const gop = try self.os_data.file_table.getOrPut(resolved_path); - if (gop.found_existing) { - const prev_value = gop.kv.value.value; - await gop.kv.value.putter_frame; - gop.kv.value = put; - break :blk prev_value; - } else { - resolved_path_consumed = true; - gop.kv.value = put; - break :blk null; - } + gop.entry.key = try self.allocator.dupe(u8, realpath); + errdefer self.allocator.free(gop.entry.key); + gop.entry.value = try self.allocator.create(OsData.Put); + errdefer self.allocator.destroy(gop.entry.value); + gop.entry.value.* = .{ + .putter_frame = undefined, + .value = value, }; - return result; + // @TODO Can I close this fd and get an error from bsdWaitKev? + const flags = if (comptime std.Target.current.isDarwin()) os.O_SYMLINK | os.O_EVTONLY else 0; + const fd = try os.open(realpath, flags, 0); + gop.entry.value.putter_frame = async self.kqPutEvents(fd, gop.entry.key, gop.entry.value); + return null; } - fn kqPutEvents(self: *Self, close_op: *CloseOperation, put: *OsData.Put) void { + fn kqPutEvents(self: *Self, fd: os.fd_t, file_path: []const u8, put: *OsData.Put) void { global_event_loop.beginOneEvent(); - defer { - close_op.finish(); global_event_loop.finishOneEvent(); + // @TODO: Remove this if we force close otherwise + os.close(fd); } + // We need to manually do a bsdWaitKev to access the fflags. + var resume_node = event.Loop.ResumeNode.Basic{ + .base = .{ + .id = .Basic, + .handle = @frame(), + .overlapped = event.Loop.ResumeNode.overlapped_init, + }, + .kev = undefined, + }; + + var kevs = [1]os.Kevent{undefined}; + const kev = &kevs[0]; + while (!put.cancelled) { - if (global_event_loop.bsdWaitKev( - @intCast(usize, close_op.getHandle()), - os.EVFILT_VNODE, - os.NOTE_WRITE | os.NOTE_DELETE, - )) |kev| { - // TODO handle EV_ERROR - if (kev.fflags & os.NOTE_DELETE != 0) { - self.channel.put(Self.Event{ - .id = Event.Id.Delete, - .data = put.value, - }); - } else if (kev.fflags & os.NOTE_WRITE != 0) { - self.channel.put(Self.Event{ - .id = Event.Id.CloseWrite, - .data = put.value, - }); - } - } else |err| switch (err) { - error.EventNotFound => unreachable, - error.ProcessNotFound => unreachable, - error.Overflow => unreachable, - error.AccessDenied, error.SystemResources => |casted_err| { - self.channel.put(casted_err); - }, + kev.* = os.Kevent{ + .ident = @intCast(usize, fd), + .filter = os.EVFILT_VNODE, + .flags = os.EV_ADD | os.EV_ENABLE | os.EV_CLEAR | os.EV_ONESHOT | + os.NOTE_WRITE | os.NOTE_DELETE | os.NOTE_REVOKE, + .fflags = 0, + .data = 0, + .udata = @ptrToInt(&resume_node.base), + }; + suspend { + global_event_loop.beginOneEvent(); + errdefer global_event_loop.finishOneEvent(); + + const empty_kevs = &[0]os.Kevent{}; + _ = os.kevent(global_event_loop.os_data.kqfd, &kevs, empty_kevs, null) catch |err| switch (err) { + error.EventNotFound, + error.ProcessNotFound, + error.Overflow, + => unreachable, + error.AccessDenied, error.SystemResources => |e| { + self.channel.put(e); + continue; + }, + }; + } + + if (kev.flags & os.EV_ERROR != 0) { + self.channel.put(os.unexpectedErrno(os.errno(kev.data))); + continue; + } + + if (kev.fflags & os.NOTE_DELETE != 0 or kev.fflags & os.NOTE_REVOKE != 0) { + self.channel.put(Self.Event{ + .id = .Delete, + .data = put.value, + .dirname = std.fs.path.dirname(file_path) orelse "/", + .basename = std.fs.path.basename(file_path), + }); + } else if (kev.fflags & os.NOTE_WRITE != 0) { + self.channel.put(Self.Event{ + .id = .CloseWrite, + .data = put.value, + .dirname = std.fs.path.dirname(file_path) orelse "/", + .basename = std.fs.path.basename(file_path), + }); } } } fn addFileLinux(self: *Self, file_path: []const u8, value: V) !?V { - const dirname = std.fs.path.dirname(file_path) orelse "."; - const dirname_with_null = try std.cstr.addNullByte(self.allocator, dirname); - var dirname_with_null_consumed = false; - defer if (!dirname_with_null_consumed) self.channel.free(dirname_with_null); - + const dirname = std.fs.path.dirname(file_path) orelse if (file_path[0] == '/') "/" else "."; const basename = std.fs.path.basename(file_path); - const basename_with_null = try std.cstr.addNullByte(self.allocator, basename); - var basename_with_null_consumed = false; - defer if (!basename_with_null_consumed) self.allocator.free(basename_with_null); - const wd = try os.inotify_add_watchZ( + const wd = try os.inotify_add_watch( self.os_data.inotify_fd, - dirname_with_null.ptr, - os.linux.IN_CLOSE_WRITE | os.linux.IN_ONLYDIR | os.linux.IN_EXCL_UNLINK, + dirname, + os.linux.IN_CLOSE_WRITE | os.linux.IN_ONLYDIR | os.linux.IN_DELETE | os.linux.IN_EXCL_UNLINK, ); // wd is either a newly created watch or an existing one. const held = self.os_data.table_lock.acquire(); defer held.release(); - const gop = try self.os_data.wd_table.getOrPut(wd); + const gop = try self.os_data.wd_table.getOrPut(self.allocator, wd); + errdefer self.os_data.wd_table.removeAssertDiscard(wd); if (!gop.found_existing) { - gop.kv.value = OsData.Dir{ - .dirname = dirname_with_null, + gop.entry.value = OsData.Dir{ + .dirname = try self.allocator.dupe(u8, dirname), .file_table = OsData.FileTable.init(self.allocator), }; - dirname_with_null_consumed = true; } - const dir = &gop.kv.value; - const file_table_gop = try dir.file_table.getOrPut(basename_with_null); + const dir = &gop.entry.value; + const file_table_gop = try dir.file_table.getOrPut(self.allocator, basename); + errdefer dir.file_table.removeAssertDiscard(basename); if (file_table_gop.found_existing) { - const prev_value = file_table_gop.kv.value; - file_table_gop.kv.value = value; + const prev_value = file_table_gop.entry.value; + file_table_gop.entry.value = value; return prev_value; } else { - file_table_gop.kv.value = value; - basename_with_null_consumed = true; + file_table_gop.entry.key = try self.allocator.dupe(u8, basename); + file_table_gop.entry.value = value; return null; } } fn addFileWindows(self: *Self, file_path: []const u8, value: V) !?V { // TODO we might need to convert dirname and basename to canonical file paths ("short"?) - const dirname = try self.allocator.dupe(u8, std.fs.path.dirname(file_path) orelse "."); - var dirname_consumed = false; - defer if (!dirname_consumed) self.allocator.free(dirname); + const dirname = std.fs.path.dirname(file_path) orelse if (file_path[0] == '/') "/" else "."; + var dirname_path_space: windows.PathSpace = undefined; + dirname_path_space.len = try std.unicode.utf8ToUtf16Le(&dirname_path_space.data, dirname); + dirname_path_space.data[dirname_path_space.len] = 0; - const dirname_utf16le = try std.unicode.utf8ToUtf16LeWithNull(self.allocator, dirname); - defer self.allocator.free(dirname_utf16le); - - // TODO https://github.com/ziglang/zig/issues/265 const basename = std.fs.path.basename(file_path); - const basename_utf16le_null = try std.unicode.utf8ToUtf16LeWithNull(self.allocator, basename); - var basename_utf16le_null_consumed = false; - defer if (!basename_utf16le_null_consumed) self.allocator.free(basename_utf16le_null); - const basename_utf16le_no_null = basename_utf16le_null[0 .. basename_utf16le_null.len - 1]; - - const dir_handle = try windows.OpenFile(dirname_utf16le, .{ - .dir = std.fs.cwd().fd, - .access_mask = windows.FILE_LIST_DIRECTORY, - .creation = windows.FILE_OPEN, - .io_mode = .blocking, - .open_dir = true, - }); - var dir_handle_consumed = false; - defer if (!dir_handle_consumed) windows.CloseHandle(dir_handle); + var basename_path_space: windows.PathSpace = undefined; + basename_path_space.len = try std.unicode.utf8ToUtf16Le(&basename_path_space.data, basename); + basename_path_space.data[basename_path_space.len] = 0; const held = self.os_data.table_lock.acquire(); defer held.release(); - const gop = try self.os_data.dir_table.getOrPut(dirname); + const gop = try self.os_data.dir_table.getOrPut(self.allocator, dirname); + errdefer self.os_data.dir_table.removeAssertDiscard(dirname); if (gop.found_existing) { - const dir = gop.kv.value; - const held_dir_lock = dir.table_lock.acquire(); - defer held_dir_lock.release(); + const dir = gop.entry.value; - const file_gop = try dir.file_table.getOrPut(basename_utf16le_no_null); + const file_gop = try dir.file_table.getOrPut(self.allocator, basename); + errdefer dir.file_table.removeAssertDiscard(basename); if (file_gop.found_existing) { - const prev_value = file_gop.kv.value; - file_gop.kv.value = value; + const prev_value = file_gop.entry.value; + file_gop.entry.value = value; return prev_value; } else { - file_gop.kv.value = value; - basename_utf16le_null_consumed = true; + file_gop.entry.value = value; + file_gop.entry.key = try self.allocator.dupe(u8, basename); return null; } } else { - errdefer _ = self.os_data.dir_table.remove(dirname); + const dir_handle = try windows.OpenFile(dirname_path_space.span(), .{ + .dir = std.fs.cwd().fd, + .access_mask = windows.FILE_LIST_DIRECTORY, + .creation = windows.FILE_OPEN, + .io_mode = .evented, + .open_dir = true, + }); + errdefer windows.CloseHandle(dir_handle); + const dir = try self.allocator.create(OsData.Dir); errdefer self.allocator.destroy(dir); + gop.entry.key = try self.allocator.dupe(u8, dirname); + errdefer self.allocator.free(gop.entry.key); + dir.* = OsData.Dir{ .file_table = OsData.FileTable.init(self.allocator), - .table_lock = event.Lock.init(), .putter_frame = undefined, + .dir_handle = dir_handle, }; - gop.kv.value = dir; - assert((try dir.file_table.put(basename_utf16le_no_null, value)) == null); - basename_utf16le_null_consumed = true; - - dir.putter_frame = async self.windowsDirReader(dir_handle, dir); - dir_handle_consumed = true; - - dirname_consumed = true; - + gop.entry.value = dir; + try dir.file_table.put(self.allocator, try self.allocator.dupe(u8, basename), value); + dir.putter_frame = async self.windowsDirReader(dir, gop.entry.key); return null; } } - fn windowsDirReader(self: *Self, dir_handle: windows.HANDLE, dir: *OsData.Dir) void { - self.ref(); - defer self.deref(); - - defer os.close(dir_handle); - - var putter_node = std.atomic.Queue(anyframe).Node{ - .data = .{ .putter = @frame() }, - .prev = null, - .next = null, - }; - self.os_data.all_putters.put(&putter_node); - defer _ = self.os_data.all_putters.remove(&putter_node); - + fn windowsDirReader(self: *Self, dir: *OsData.Dir, dirname: []const u8) void { + defer os.close(dir.dir_handle); var resume_node = Loop.ResumeNode.Basic{ .base = Loop.ResumeNode{ - .id = Loop.ResumeNode.Id.Basic, + .id = .Basic, .handle = @frame(), .overlapped = windows.OVERLAPPED{ .Internal = 0, @@ -458,157 +441,193 @@ pub fn Watch(comptime V: type) type { }, }, }; + var event_buf: [4096]u8 align(@alignOf(windows.FILE_NOTIFY_INFORMATION)) = undefined; - // TODO handle this error not in the channel but in the setup - _ = windows.CreateIoCompletionPort( - dir_handle, - global_event_loop.os_data.io_port, - undefined, - undefined, - ) catch |err| { - self.channel.put(err); - return; - }; + global_event_loop.beginOneEvent(); + defer global_event_loop.finishOneEvent(); - while (!putter_node.data.cancelled) { - { - // TODO only 1 beginOneEvent for the whole function - global_event_loop.beginOneEvent(); - errdefer global_event_loop.finishOneEvent(); - errdefer { - _ = windows.kernel32.CancelIoEx(dir_handle, &resume_node.base.overlapped); - } - suspend { - _ = windows.kernel32.ReadDirectoryChangesW( - dir_handle, - &event_buf, - @intCast(windows.DWORD, event_buf.len), - windows.FALSE, // watch subtree - windows.FILE_NOTIFY_CHANGE_FILE_NAME | windows.FILE_NOTIFY_CHANGE_DIR_NAME | - windows.FILE_NOTIFY_CHANGE_ATTRIBUTES | windows.FILE_NOTIFY_CHANGE_SIZE | - windows.FILE_NOTIFY_CHANGE_LAST_WRITE | windows.FILE_NOTIFY_CHANGE_LAST_ACCESS | - windows.FILE_NOTIFY_CHANGE_CREATION | windows.FILE_NOTIFY_CHANGE_SECURITY, - null, // number of bytes transferred (unused for async) - &resume_node.base.overlapped, - null, // completion routine - unused because we use IOCP - ); - } + while (!self.os_data.cancelled) main_loop: { + suspend { + _ = windows.kernel32.ReadDirectoryChangesW( + dir.dir_handle, + &event_buf, + event_buf.len, + windows.FALSE, // watch subtree + windows.FILE_NOTIFY_CHANGE_FILE_NAME | windows.FILE_NOTIFY_CHANGE_DIR_NAME | + windows.FILE_NOTIFY_CHANGE_ATTRIBUTES | windows.FILE_NOTIFY_CHANGE_SIZE | + windows.FILE_NOTIFY_CHANGE_LAST_WRITE | windows.FILE_NOTIFY_CHANGE_LAST_ACCESS | + windows.FILE_NOTIFY_CHANGE_CREATION | windows.FILE_NOTIFY_CHANGE_SECURITY, + null, // number of bytes transferred (unused for async) + &resume_node.base.overlapped, + null, // completion routine - unused because we use IOCP + ); } + var bytes_transferred: windows.DWORD = undefined; - if (windows.kernel32.GetOverlappedResult(dir_handle, &resume_node.base.overlapped, &bytes_transferred, windows.FALSE) == 0) { - const err = switch (windows.kernel32.GetLastError()) { + if (windows.kernel32.GetOverlappedResult( + dir.dir_handle, + &resume_node.base.overlapped, + &bytes_transferred, + windows.FALSE, + ) == 0) { + const potential_error = windows.kernel32.GetLastError(); + const err = switch (potential_error) { + .OPERATION_ABORTED, .IO_INCOMPLETE => err_blk: { + if (self.os_data.cancelled) + break :main_loop + else + break :err_blk windows.unexpectedError(potential_error); + }, else => |err| windows.unexpectedError(err), }; self.channel.put(err); } else { - // can't use @bytesToSlice because of the special variable length name field - var ptr = event_buf[0..].ptr; + var ptr: [*]u8 = &event_buf; const end_ptr = ptr + bytes_transferred; - var ev: *windows.FILE_NOTIFY_INFORMATION = undefined; - while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) : (ptr += ev.NextEntryOffset) { - ev = @ptrCast(*windows.FILE_NOTIFY_INFORMATION, ptr); + while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) { + const ev = @ptrCast(*const windows.FILE_NOTIFY_INFORMATION, ptr); const emit = switch (ev.Action) { windows.FILE_ACTION_REMOVED => WatchEventId.Delete, - windows.FILE_ACTION_MODIFIED => WatchEventId.CloseWrite, + windows.FILE_ACTION_MODIFIED => .CloseWrite, else => null, }; if (emit) |id| { - const basename_utf16le = ([*]u16)(&ev.FileName)[0 .. ev.FileNameLength / 2]; - const user_value = blk: { - const held = dir.table_lock.acquire(); - defer held.release(); + const basename_ptr = @ptrCast([*]u16, ptr + @sizeOf(windows.FILE_NOTIFY_INFORMATION)); + const basename_utf16le = basename_ptr[0 .. ev.FileNameLength / 2]; + var basename_data: [std.fs.MAX_PATH_BYTES]u8 = undefined; + const basename = basename_data[0 .. std.unicode.utf16leToUtf8(&basename_data, basename_utf16le) catch unreachable]; - if (dir.file_table.get(basename_utf16le)) |entry| { - break :blk entry.value; - } else { - break :blk null; - } - }; - if (user_value) |v| { + if (dir.file_table.getEntry(basename)) |entry| { self.channel.put(Event{ .id = id, - .data = v, + .data = entry.value, + .dirname = dirname, + .basename = entry.key, }); } } + if (ev.NextEntryOffset == 0) break; + ptr = @alignCast(@alignOf(windows.FILE_NOTIFY_INFORMATION), ptr + ev.NextEntryOffset); } } } } - pub fn removeFile(self: *Self, file_path: []const u8) ?V { - @panic("TODO"); + pub fn removeFile(self: *Self, file_path: []const u8) !?V { + switch (builtin.os.tag) { + .linux => { + const dirname = std.fs.path.dirname(file_path) orelse if (file_path[0] == '/') "/" else "."; + const basename = std.fs.path.basename(file_path); + + const held = self.os_data.table_lock.acquire(); + defer held.release(); + + const dir = self.os_data.wd_table.get(dirname) orelse return null; + if (dir.file_table.remove(basename)) |file_entry| { + self.allocator.free(file_entry.key); + return file_entry.value; + } + return null; + }, + .windows => { + const dirname = std.fs.path.dirname(file_path) orelse if (file_path[0] == '/') "/" else "."; + const basename = std.fs.path.basename(file_path); + + const held = self.os_data.table_lock.acquire(); + defer held.release(); + + const dir = self.os_data.dir_table.get(dirname) orelse return null; + if (dir.file_table.remove(basename)) |file_entry| { + self.allocator.free(file_entry.key); + return file_entry.value; + } + return null; + }, + .macos, .freebsd, .netbsd, .dragonfly, .openbsd => { + var realpath_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; + const realpath = try os.realpath(file_path, &realpath_buf); + + const held = self.os_data.table_lock.acquire(); + defer held.release(); + + const entry = self.os_data.file_table.get(realpath) orelse return null; + entry.value.cancelled = true; + // @TODO Close the fd here? + await entry.value.putter_frame; + self.allocator.free(entry.key); + self.allocator.destroy(entry.value); + + self.os_data.file_table.removeAssertDiscard(realpath); + }, + else => @compileError("Unsupported OS"), + } } fn linuxEventPutter(self: *Self) void { global_event_loop.beginOneEvent(); defer { - self.os_data.table_lock.deinit(); - var wd_it = self.os_data.wd_table.iterator(); - while (wd_it.next()) |wd_entry| { - var file_it = wd_entry.value.file_table.iterator(); - while (file_it.next()) |file_entry| { - self.allocator.free(file_entry.key); - } - self.allocator.free(wd_entry.value.dirname); - wd_entry.value.file_table.deinit(); - } - self.os_data.wd_table.deinit(); - global_event_loop.finishOneEvent(); + std.debug.assert(self.os_data.wd_table.count() == 0); + self.os_data.wd_table.deinit(self.allocator); os.close(self.os_data.inotify_fd); - self.channel.deinit(); self.allocator.free(self.channel.buffer_nodes); + self.channel.deinit(); + global_event_loop.finishOneEvent(); } var event_buf: [4096]u8 align(@alignOf(os.linux.inotify_event)) = undefined; while (!self.os_data.cancelled) { - const rc = os.linux.read(self.os_data.inotify_fd, &event_buf, event_buf.len); - const errno = os.linux.getErrno(rc); - switch (errno) { - 0 => { - // can't use @bytesToSlice because of the special variable length name field - var ptr = event_buf[0..].ptr; - const end_ptr = ptr + event_buf.len; - var ev: *os.linux.inotify_event = undefined; - while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) { - ev = @ptrCast(*os.linux.inotify_event, ptr); - if (ev.mask & os.linux.IN_CLOSE_WRITE == os.linux.IN_CLOSE_WRITE) { - const basename_ptr = ptr + @sizeOf(os.linux.inotify_event); - // `ev.len` counts all bytes in `ev.name` including terminating null byte. - const basename_with_null = basename_ptr[0..ev.len]; - const user_value = blk: { - const held = self.os_data.table_lock.acquire(); - defer held.release(); + const bytes_read = global_event_loop.read(self.os_data.inotify_fd, &event_buf, false) catch unreachable; - const dir = &self.os_data.wd_table.get(ev.wd).?.value; - if (dir.file_table.get(basename_with_null)) |entry| { - break :blk entry.value; - } else { - break :blk null; - } - }; - if (user_value) |v| { - self.channel.put(Event{ - .id = WatchEventId.CloseWrite, - .data = v, - }); - } - } + var ptr: [*]u8 = &event_buf; + const end_ptr = ptr + bytes_read; + while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) { + const ev = @ptrCast(*const os.linux.inotify_event, ptr); + if (ev.mask & os.linux.IN_CLOSE_WRITE == os.linux.IN_CLOSE_WRITE) { + const basename_ptr = ptr + @sizeOf(os.linux.inotify_event); + const basename = std.mem.span(@ptrCast([*:0]u8, basename_ptr)); - ptr = @alignCast(@alignOf(os.linux.inotify_event), ptr + @sizeOf(os.linux.inotify_event) + ev.len); + const dir = &self.os_data.wd_table.get(ev.wd).?; + if (dir.file_table.getEntry(basename)) |file_value| { + self.channel.put(Event{ + .id = .CloseWrite, + .data = file_value.value, + .dirname = dir.dirname, + .basename = file_value.key, + }); } - }, - os.linux.EINTR => continue, - os.linux.EINVAL => unreachable, - os.linux.EFAULT => unreachable, - os.linux.EAGAIN => { - global_event_loop.linuxWaitFd(self.os_data.inotify_fd, os.linux.EPOLLET | os.linux.EPOLLIN | os.EPOLLONESHOT); - }, - else => unreachable, + } else if (ev.mask & os.linux.IN_IGNORED == os.linux.IN_IGNORED) { + // Directory watch was removed + const held = self.os_data.table_lock.acquire(); + defer held.release(); + if (self.os_data.wd_table.remove(ev.wd)) |*wd_entry| { + var file_it = wd_entry.value.file_table.iterator(); + while (file_it.next()) |file_entry| { + self.allocator.free(file_entry.key); + } + self.allocator.free(wd_entry.value.dirname); + wd_entry.value.file_table.deinit(self.allocator); + } + } else if (ev.mask & os.linux.IN_DELETE == os.linux.IN_DELETE) { + // File or directory was removed or deleted + const basename_ptr = ptr + @sizeOf(os.linux.inotify_event); + const basename = std.mem.span(@ptrCast([*:0]u8, basename_ptr)); + + const dir = &self.os_data.wd_table.get(ev.wd).?; + if (dir.file_table.getEntry(basename)) |file_value| { + self.channel.put(Event{ + .id = .Delete, + .data = file_value.value, + .dirname = dir.dirname, + .basename = file_value.key, + }); + } + } + + ptr = @alignCast(@alignOf(os.linux.inotify_event), ptr + @sizeOf(os.linux.inotify_event) + ev.len); } } } @@ -617,19 +636,19 @@ pub fn Watch(comptime V: type) type { const test_tmp_dir = "std_event_fs_test"; -test "write a file, watch it, write it again" { - // TODO re-enable this test - if (true) return error.SkipZigTest; +test "write a file, watch it, write it again, delete it" { + if (!std.io.is_async) return error.SkipZigTest; + // TODO https://github.com/ziglang/zig/issues/1908 + if (builtin.single_threaded) return error.SkipZigTest; - try fs.cwd().makePath(test_tmp_dir); - defer fs.cwd().deleteTree(test_tmp_dir) catch {}; + try std.fs.cwd().makePath(test_tmp_dir); + defer std.fs.cwd().deleteTree(test_tmp_dir) catch {}; - const allocator = std.heap.page_allocator; - return testFsWatch(&allocator); + return testWriteWatchWriteDelete(std.testing.allocator); } -fn testFsWatch(allocator: *Allocator) !void { - const file_path = try std.fs.path.join(allocator, [_][]const u8{ test_tmp_dir, "file.txt" }); +fn testWriteWatchWriteDelete(allocator: *Allocator) !void { + const file_path = try std.fs.path.join(allocator, &[_][]const u8{ test_tmp_dir, "file.txt" }); defer allocator.free(file_path); const contents = @@ -639,9 +658,10 @@ fn testFsWatch(allocator: *Allocator) !void { const line2_offset = 7; // first just write then read the file - try writeFile(allocator, file_path, contents); + try std.fs.cwd().writeFile(file_path, contents); - const read_contents = try readFile(allocator, file_path, 1024 * 1024); + const read_contents = try std.fs.cwd().readFileAlloc(allocator, file_path, 1024 * 1024); + defer allocator.free(read_contents); testing.expectEqualSlices(u8, contents, read_contents); // now watch the file @@ -650,28 +670,49 @@ fn testFsWatch(allocator: *Allocator) !void { testing.expect((try watch.addFile(file_path, {})) == null); - const ev = watch.channel.get(); + var ev = async watch.channel.get(); var ev_consumed = false; - defer if (!ev_consumed) await ev; + defer if (!ev_consumed) { + _ = await ev; + }; // overwrite line 2 - const fd = try await openReadWrite(file_path, File.default_mode); + const file = try std.fs.cwd().openFile(file_path, .{ .read = true, .write = true }); { - defer os.close(fd); - - try pwritev(allocator, fd, []const []const u8{"lorem ipsum"}, line2_offset); + defer file.close(); + const write_contents = "lorem ipsum"; + var iovec = [_]os.iovec_const{.{ + .iov_base = write_contents, + .iov_len = write_contents.len, + }}; + _ = try file.pwritevAll(&iovec, line2_offset); } - ev_consumed = true; switch ((try await ev).id) { - WatchEventId.CloseWrite => {}, - WatchEventId.Delete => @panic("wrong event"), + .CloseWrite => { + ev_consumed = true; + }, + .Delete => @panic("wrong event"), } - const contents_updated = try readFile(allocator, file_path, 1024 * 1024); + + const contents_updated = try std.fs.cwd().readFileAlloc(allocator, file_path, 1024 * 1024); + defer allocator.free(contents_updated); + testing.expectEqualSlices(u8, \\line 1 \\lorem ipsum , contents_updated); - // TODO test deleting the file and then re-adding it. we should get events for both + ev = async watch.channel.get(); + ev_consumed = false; + + try std.fs.cwd().deleteFile(file_path); + switch ((try await ev).id) { + .Delete => { + ev_consumed = true; + }, + .CloseWrite => @panic("wrong event"), + } } + +// TODO Test: Add another file watch, remove the old file watch, get an event in the new diff --git a/lib/std/hash.zig b/lib/std/hash.zig index 7bac378316..f5b94725e2 100644 --- a/lib/std/hash.zig +++ b/lib/std/hash.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/hash/adler.zig b/lib/std/hash/adler.zig index a3fc915f76..9cd85ba7cf 100644 --- a/lib/std/hash/adler.zig +++ b/lib/std/hash/adler.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/hash/auto_hash.zig b/lib/std/hash/auto_hash.zig index 2e707d5450..4afc2b425b 100644 --- a/lib/std/hash/auto_hash.zig +++ b/lib/std/hash/auto_hash.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -99,7 +99,16 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { // Help the optimizer see that hashing an int is easy by inlining! // TODO Check if the situation is better after #561 is resolved. - .Int => @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)}), + .Int => { + if (comptime meta.trait.hasUniqueRepresentation(Key)) { + @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)}); + } else { + // Take only the part containing the key value, the remaining + // bytes are undefined and must not be hashed! + const byte_size = comptime std.math.divCeil(comptime_int, @bitSizeOf(Key), 8) catch unreachable; + @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)[0..byte_size]}); + } + }, .Bool => hash(hasher, @boolToInt(key), strat), .Enum => hash(hasher, @enumToInt(key), strat), @@ -160,21 +169,38 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { } } +fn typeContainsSlice(comptime K: type) bool { + comptime { + if (meta.trait.isSlice(K)) { + return true; + } + if (meta.trait.is(.Struct)(K)) { + inline for (@typeInfo(K).Struct.fields) |field| { + if (typeContainsSlice(field.field_type)) { + return true; + } + } + } + if (meta.trait.is(.Union)(K)) { + inline for (@typeInfo(K).Union.fields) |field| { + if (typeContainsSlice(field.field_type)) { + return true; + } + } + } + return false; + } +} + /// Provides generic hashing for any eligible type. /// Only hashes `key` itself, pointers are not followed. -/// Slices are rejected to avoid ambiguity on the user's intention. +/// Slices as well as unions and structs containing slices are rejected to avoid +/// ambiguity on the user's intention. pub fn autoHash(hasher: anytype, key: anytype) void { const Key = @TypeOf(key); - if (comptime meta.trait.isSlice(Key)) { - comptime assert(@hasDecl(std, "StringHashMap")); // detect when the following message needs updated - const extra_help = if (Key == []const u8) - " Consider std.StringHashMap for hashing the contents of []const u8." - else - ""; - - @compileError("std.auto_hash.autoHash does not allow slices (here " ++ @typeName(Key) ++ - ") because the intent is unclear. Consider using std.auto_hash.hash or providing your own hash function instead." ++ - extra_help); + if (comptime typeContainsSlice(Key)) { + @compileError("std.auto_hash.autoHash does not allow slices as well as unions and structs containing slices here (" ++ @typeName(Key) ++ + ") because the intent is unclear. Consider using std.auto_hash.hash or providing your own hash function instead."); } hash(hasher, key, .Shallow); @@ -211,6 +237,23 @@ fn testHashDeepRecursive(key: anytype) u64 { return hasher.final(); } +test "typeContainsSlice" { + comptime { + testing.expect(!typeContainsSlice(meta.Tag(std.builtin.TypeInfo))); + + testing.expect(typeContainsSlice([]const u8)); + testing.expect(!typeContainsSlice(u8)); + const A = struct { x: []const u8 }; + const B = struct { a: A }; + const C = struct { b: B }; + const D = struct { x: u8 }; + testing.expect(typeContainsSlice(A)); + testing.expect(typeContainsSlice(B)); + testing.expect(typeContainsSlice(C)); + testing.expect(!typeContainsSlice(D)); + } +} + test "hash pointer" { const array = [_]u32{ 123, 123, 123 }; const a = &array[0]; diff --git a/lib/std/hash/benchmark.zig b/lib/std/hash/benchmark.zig index f0cafa9971..19bb9aa8bf 100644 --- a/lib/std/hash/benchmark.zig +++ b/lib/std/hash/benchmark.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/hash/cityhash.zig b/lib/std/hash/cityhash.zig index 38e62d88ef..d7f2f1a9eb 100644 --- a/lib/std/hash/cityhash.zig +++ b/lib/std/hash/cityhash.zig @@ -1,11 +1,24 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. const std = @import("std"); const builtin = @import("builtin"); +fn offsetPtr(ptr: [*]const u8, offset: usize) callconv(.Inline) [*]const u8 { + // ptr + offset doesn't work at comptime so we need this instead. + return @ptrCast([*]const u8, &ptr[offset]); +} + +fn fetch32(ptr: [*]const u8, offset: usize) u32 { + return std.mem.readIntLittle(u32, offsetPtr(ptr, offset)[0..4]); +} + +fn fetch64(ptr: [*]const u8, offset: usize) u64 { + return std.mem.readIntLittle(u64, offsetPtr(ptr, offset)[0..8]); +} + pub const CityHash32 = struct { const Self = @This(); @@ -13,14 +26,6 @@ pub const CityHash32 = struct { const c1: u32 = 0xcc9e2d51; const c2: u32 = 0x1b873593; - fn fetch32(ptr: [*]const u8) u32 { - var v: u32 = undefined; - @memcpy(@ptrCast([*]u8, &v), ptr, 4); - if (builtin.endian == .Big) - return @byteSwap(u32, v); - return v; - } - // A 32-bit to 32-bit integer hash copied from Murmur3. fn fmix(h: u32) u32 { var h1: u32 = h; @@ -66,21 +71,21 @@ pub const CityHash32 = struct { var c: u32 = 9; const d: u32 = b; - a +%= fetch32(str.ptr); - b +%= fetch32(str.ptr + str.len - 4); - c +%= fetch32(str.ptr + ((str.len >> 1) & 4)); + a +%= fetch32(str.ptr, 0); + b +%= fetch32(str.ptr, str.len - 4); + c +%= fetch32(str.ptr, (str.len >> 1) & 4); return fmix(mur(c, mur(b, mur(a, d)))); } fn hash32Len13To24(str: []const u8) u32 { const len: u32 = @truncate(u32, str.len); - const a: u32 = fetch32(str.ptr + (str.len >> 1) - 4); - const b: u32 = fetch32(str.ptr + 4); - const c: u32 = fetch32(str.ptr + str.len - 8); - const d: u32 = fetch32(str.ptr + (str.len >> 1)); - const e: u32 = fetch32(str.ptr); - const f: u32 = fetch32(str.ptr + str.len - 4); + const a: u32 = fetch32(str.ptr, (str.len >> 1) - 4); + const b: u32 = fetch32(str.ptr, 4); + const c: u32 = fetch32(str.ptr, str.len - 8); + const d: u32 = fetch32(str.ptr, str.len >> 1); + const e: u32 = fetch32(str.ptr, 0); + const f: u32 = fetch32(str.ptr, str.len - 4); return fmix(mur(f, mur(e, mur(d, mur(c, mur(b, mur(a, len))))))); } @@ -101,11 +106,11 @@ pub const CityHash32 = struct { var g: u32 = c1 *% len; var f: u32 = g; - const a0: u32 = rotr32(fetch32(str.ptr + str.len - 4) *% c1, 17) *% c2; - const a1: u32 = rotr32(fetch32(str.ptr + str.len - 8) *% c1, 17) *% c2; - const a2: u32 = rotr32(fetch32(str.ptr + str.len - 16) *% c1, 17) *% c2; - const a3: u32 = rotr32(fetch32(str.ptr + str.len - 12) *% c1, 17) *% c2; - const a4: u32 = rotr32(fetch32(str.ptr + str.len - 20) *% c1, 17) *% c2; + const a0: u32 = rotr32(fetch32(str.ptr, str.len - 4) *% c1, 17) *% c2; + const a1: u32 = rotr32(fetch32(str.ptr, str.len - 8) *% c1, 17) *% c2; + const a2: u32 = rotr32(fetch32(str.ptr, str.len - 16) *% c1, 17) *% c2; + const a3: u32 = rotr32(fetch32(str.ptr, str.len - 12) *% c1, 17) *% c2; + const a4: u32 = rotr32(fetch32(str.ptr, str.len - 20) *% c1, 17) *% c2; h ^= a0; h = rotr32(h, 19); @@ -125,11 +130,11 @@ pub const CityHash32 = struct { var iters = (str.len - 1) / 20; var ptr = str.ptr; while (iters != 0) : (iters -= 1) { - const b0: u32 = rotr32(fetch32(ptr) *% c1, 17) *% c2; - const b1: u32 = fetch32(ptr + 4); - const b2: u32 = rotr32(fetch32(ptr + 8) *% c1, 17) *% c2; - const b3: u32 = rotr32(fetch32(ptr + 12) *% c1, 17) *% c2; - const b4: u32 = fetch32(ptr + 16); + const b0: u32 = rotr32(fetch32(ptr, 0) *% c1, 17) *% c2; + const b1: u32 = fetch32(ptr, 4); + const b2: u32 = rotr32(fetch32(ptr, 8) *% c1, 17) *% c2; + const b3: u32 = rotr32(fetch32(ptr, 12) *% c1, 17) *% c2; + const b4: u32 = fetch32(ptr, 16); h ^= b0; h = rotr32(h, 18); @@ -152,7 +157,7 @@ pub const CityHash32 = struct { h = f; f = g; g = t; - ptr += 20; + ptr = offsetPtr(ptr, 20); } g = rotr32(g, 11) *% c1; g = rotr32(g, 17) *% c1; @@ -176,22 +181,6 @@ pub const CityHash64 = struct { const k1: u64 = 0xb492b66fbe98f273; const k2: u64 = 0x9ae16a3b2f90404f; - fn fetch32(ptr: [*]const u8) u32 { - var v: u32 = undefined; - @memcpy(@ptrCast([*]u8, &v), ptr, 4); - if (builtin.endian == .Big) - return @byteSwap(u32, v); - return v; - } - - fn fetch64(ptr: [*]const u8) u64 { - var v: u64 = undefined; - @memcpy(@ptrCast([*]u8, &v), ptr, 8); - if (builtin.endian == .Big) - return @byteSwap(u64, v); - return v; - } - // Rotate right helper fn rotr64(x: u64, comptime r: u64) u64 { return (x >> r) | (x << (64 - r)); @@ -222,16 +211,16 @@ pub const CityHash64 = struct { const len: u64 = @as(u64, str.len); if (len >= 8) { const mul: u64 = k2 +% len *% 2; - const a: u64 = fetch64(str.ptr) +% k2; - const b: u64 = fetch64(str.ptr + str.len - 8); + const a: u64 = fetch64(str.ptr, 0) +% k2; + const b: u64 = fetch64(str.ptr, str.len - 8); const c: u64 = rotr64(b, 37) *% mul +% a; const d: u64 = (rotr64(a, 25) +% b) *% mul; return hashLen16Mul(c, d, mul); } if (len >= 4) { const mul: u64 = k2 +% len *% 2; - const a: u64 = fetch32(str.ptr); - return hashLen16Mul(len +% (a << 3), fetch32(str.ptr + str.len - 4), mul); + const a: u64 = fetch32(str.ptr, 0); + return hashLen16Mul(len +% (a << 3), fetch32(str.ptr, str.len - 4), mul); } if (len > 0) { const a: u8 = str[0]; @@ -247,10 +236,10 @@ pub const CityHash64 = struct { fn hashLen17To32(str: []const u8) u64 { const len: u64 = @as(u64, str.len); const mul: u64 = k2 +% len *% 2; - const a: u64 = fetch64(str.ptr) *% k1; - const b: u64 = fetch64(str.ptr + 8); - const c: u64 = fetch64(str.ptr + str.len - 8) *% mul; - const d: u64 = fetch64(str.ptr + str.len - 16) *% k2; + const a: u64 = fetch64(str.ptr, 0) *% k1; + const b: u64 = fetch64(str.ptr, 8); + const c: u64 = fetch64(str.ptr, str.len - 8) *% mul; + const d: u64 = fetch64(str.ptr, str.len - 16) *% k2; return hashLen16Mul(rotr64(a +% b, 43) +% rotr64(c, 30) +% d, a +% rotr64(b +% k2, 18) +% c, mul); } @@ -258,14 +247,14 @@ pub const CityHash64 = struct { fn hashLen33To64(str: []const u8) u64 { const len: u64 = @as(u64, str.len); const mul: u64 = k2 +% len *% 2; - const a: u64 = fetch64(str.ptr) *% k2; - const b: u64 = fetch64(str.ptr + 8); - const c: u64 = fetch64(str.ptr + str.len - 24); - const d: u64 = fetch64(str.ptr + str.len - 32); - const e: u64 = fetch64(str.ptr + 16) *% k2; - const f: u64 = fetch64(str.ptr + 24) *% 9; - const g: u64 = fetch64(str.ptr + str.len - 8); - const h: u64 = fetch64(str.ptr + str.len - 16) *% mul; + const a: u64 = fetch64(str.ptr, 0) *% k2; + const b: u64 = fetch64(str.ptr, 8); + const c: u64 = fetch64(str.ptr, str.len - 24); + const d: u64 = fetch64(str.ptr, str.len - 32); + const e: u64 = fetch64(str.ptr, 16) *% k2; + const f: u64 = fetch64(str.ptr, 24) *% 9; + const g: u64 = fetch64(str.ptr, str.len - 8); + const h: u64 = fetch64(str.ptr, str.len - 16) *% mul; const u: u64 = rotr64(a +% g, 43) +% (rotr64(b, 30) +% c) *% 9; const v: u64 = ((a +% g) ^ d) +% f +% 1; @@ -297,10 +286,10 @@ pub const CityHash64 = struct { fn weakHashLen32WithSeeds(ptr: [*]const u8, a: u64, b: u64) WeakPair { return @call(.{ .modifier = .always_inline }, weakHashLen32WithSeedsHelper, .{ - fetch64(ptr), - fetch64(ptr + 8), - fetch64(ptr + 16), - fetch64(ptr + 24), + fetch64(ptr, 0), + fetch64(ptr, 8), + fetch64(ptr, 16), + fetch64(ptr, 24), a, b, }); @@ -319,29 +308,29 @@ pub const CityHash64 = struct { var len: u64 = @as(u64, str.len); - var x: u64 = fetch64(str.ptr + str.len - 40); - var y: u64 = fetch64(str.ptr + str.len - 16) +% fetch64(str.ptr + str.len - 56); - var z: u64 = hashLen16(fetch64(str.ptr + str.len - 48) +% len, fetch64(str.ptr + str.len - 24)); - var v: WeakPair = weakHashLen32WithSeeds(str.ptr + str.len - 64, len, z); - var w: WeakPair = weakHashLen32WithSeeds(str.ptr + str.len - 32, y +% k1, x); + var x: u64 = fetch64(str.ptr, str.len - 40); + var y: u64 = fetch64(str.ptr, str.len - 16) +% fetch64(str.ptr, str.len - 56); + var z: u64 = hashLen16(fetch64(str.ptr, str.len - 48) +% len, fetch64(str.ptr, str.len - 24)); + var v: WeakPair = weakHashLen32WithSeeds(offsetPtr(str.ptr, str.len - 64), len, z); + var w: WeakPair = weakHashLen32WithSeeds(offsetPtr(str.ptr, str.len - 32), y +% k1, x); - x = x *% k1 +% fetch64(str.ptr); + x = x *% k1 +% fetch64(str.ptr, 0); len = (len - 1) & ~@intCast(u64, 63); var ptr: [*]const u8 = str.ptr; while (true) { - x = rotr64(x +% y +% v.first +% fetch64(ptr + 8), 37) *% k1; - y = rotr64(y +% v.second +% fetch64(ptr + 48), 42) *% k1; + x = rotr64(x +% y +% v.first +% fetch64(ptr, 8), 37) *% k1; + y = rotr64(y +% v.second +% fetch64(ptr, 48), 42) *% k1; x ^= w.second; - y +%= v.first +% fetch64(ptr + 40); + y +%= v.first +% fetch64(ptr, 40); z = rotr64(z +% w.first, 33) *% k1; v = weakHashLen32WithSeeds(ptr, v.second *% k1, x +% w.first); - w = weakHashLen32WithSeeds(ptr + 32, z +% w.second, y +% fetch64(ptr + 16)); + w = weakHashLen32WithSeeds(offsetPtr(ptr, 32), z +% w.second, y +% fetch64(ptr, 16)); const t: u64 = z; z = x; x = t; - ptr += 64; + ptr = offsetPtr(ptr, 64); len -= 64; if (len == 0) break; @@ -359,27 +348,31 @@ pub const CityHash64 = struct { } }; -fn SMHasherTest(comptime hash_fn: anytype, comptime hashbits: u32) u32 { - const hashbytes = hashbits / 8; - var key: [256]u8 = undefined; - var hashes: [hashbytes * 256]u8 = undefined; - var final: [hashbytes]u8 = undefined; +fn SMHasherTest(comptime hash_fn: anytype) u32 { + const HashResult = @typeInfo(@TypeOf(hash_fn)).Fn.return_type.?; - @memset(@ptrCast([*]u8, &key[0]), 0, @sizeOf(@TypeOf(key))); - @memset(@ptrCast([*]u8, &hashes[0]), 0, @sizeOf(@TypeOf(hashes))); - @memset(@ptrCast([*]u8, &final[0]), 0, @sizeOf(@TypeOf(final))); + var key: [256]u8 = undefined; + var hashes_bytes: [256 * @sizeOf(HashResult)]u8 = undefined; + var final: HashResult = 0; + + std.mem.set(u8, &key, 0); + std.mem.set(u8, &hashes_bytes, 0); var i: u32 = 0; while (i < 256) : (i += 1) { key[i] = @intCast(u8, i); - var h = hash_fn(key[0..i], 256 - i); - if (builtin.endian == .Big) - h = @byteSwap(@TypeOf(h), h); - @memcpy(@ptrCast([*]u8, &hashes[i * hashbytes]), @ptrCast([*]u8, &h), hashbytes); + var h: HashResult = hash_fn(key[0..i], 256 - i); + + // comptime can't really do reinterpret casting yet, + // so we need to write the bytes manually. + for (hashes_bytes[i * @sizeOf(HashResult) ..][0..@sizeOf(HashResult)]) |*byte| { + byte.* = @truncate(u8, h); + h = h >> 8; + } } - return @truncate(u32, hash_fn(&hashes, 0)); + return @truncate(u32, hash_fn(&hashes_bytes, 0)); } fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 { @@ -387,13 +380,32 @@ fn CityHash32hashIgnoreSeed(str: []const u8, seed: u32) u32 { } test "cityhash32" { - // Note: SMHasher doesn't provide a 32bit version of the algorithm. - // Note: The implementation was verified against the Google Abseil version. - std.testing.expectEqual(SMHasherTest(CityHash32hashIgnoreSeed, 32), 0x68254F81); + const Test = struct { + fn doTest() void { + // Note: SMHasher doesn't provide a 32bit version of the algorithm. + // Note: The implementation was verified against the Google Abseil version. + std.testing.expectEqual(SMHasherTest(CityHash32hashIgnoreSeed), 0x68254F81); + std.testing.expectEqual(SMHasherTest(CityHash32hashIgnoreSeed), 0x68254F81); + } + }; + Test.doTest(); + // TODO This is uncommented to prevent OOM on the CI server. Re-enable this test + // case once we ship stage2. + //@setEvalBranchQuota(50000); + //comptime Test.doTest(); } test "cityhash64" { - // Note: This is not compliant with the SMHasher implementation of CityHash64! - // Note: The implementation was verified against the Google Abseil version. - std.testing.expectEqual(SMHasherTest(CityHash64.hashWithSeed, 64), 0x5FABC5C5); + const Test = struct { + fn doTest() void { + // Note: This is not compliant with the SMHasher implementation of CityHash64! + // Note: The implementation was verified against the Google Abseil version. + std.testing.expectEqual(SMHasherTest(CityHash64.hashWithSeed), 0x5FABC5C5); + } + }; + Test.doTest(); + // TODO This is uncommented to prevent OOM on the CI server. Re-enable this test + // case once we ship stage2. + //@setEvalBranchQuota(50000); + //comptime Test.doTest(); } diff --git a/lib/std/hash/crc.zig b/lib/std/hash/crc.zig index 6290369fca..a2d6ed429c 100644 --- a/lib/std/hash/crc.zig +++ b/lib/std/hash/crc.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -102,7 +102,11 @@ pub fn Crc32WithPoly(comptime poly: Polynomial) type { }; } +const please_windows_dont_oom = std.Target.current.os.tag == .windows; + test "crc32 ieee" { + if (please_windows_dont_oom) return error.SkipZigTest; + const Crc32Ieee = Crc32WithPoly(.IEEE); testing.expect(Crc32Ieee.hash("") == 0x00000000); @@ -111,6 +115,8 @@ test "crc32 ieee" { } test "crc32 castagnoli" { + if (please_windows_dont_oom) return error.SkipZigTest; + const Crc32Castagnoli = Crc32WithPoly(.Castagnoli); testing.expect(Crc32Castagnoli.hash("") == 0x00000000); @@ -167,6 +173,8 @@ pub fn Crc32SmallWithPoly(comptime poly: Polynomial) type { } test "small crc32 ieee" { + if (please_windows_dont_oom) return error.SkipZigTest; + const Crc32Ieee = Crc32SmallWithPoly(.IEEE); testing.expect(Crc32Ieee.hash("") == 0x00000000); @@ -175,6 +183,8 @@ test "small crc32 ieee" { } test "small crc32 castagnoli" { + if (please_windows_dont_oom) return error.SkipZigTest; + const Crc32Castagnoli = Crc32SmallWithPoly(.Castagnoli); testing.expect(Crc32Castagnoli.hash("") == 0x00000000); diff --git a/lib/std/hash/fnv.zig b/lib/std/hash/fnv.zig index 81285be9a8..99e3bd482d 100644 --- a/lib/std/hash/fnv.zig +++ b/lib/std/hash/fnv.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/hash/murmur.zig b/lib/std/hash/murmur.zig index 1e9156be4b..65dd523396 100644 --- a/lib/std/hash/murmur.zig +++ b/lib/std/hash/murmur.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/hash/wyhash.zig b/lib/std/hash/wyhash.zig index 8799a36b39..45530eccff 100644 --- a/lib/std/hash/wyhash.zig +++ b/lib/std/hash/wyhash.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index d330863277..679575875d 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -17,6 +17,17 @@ const Allocator = mem.Allocator; const Wyhash = std.hash.Wyhash; pub fn getAutoHashFn(comptime K: type) (fn (K) u64) { + comptime { + assert(@hasDecl(std, "StringHashMap")); // detect when the following message needs updated + if (K == []const u8) { + @compileError("std.auto_hash.autoHash does not allow slices here (" ++ + @typeName(K) ++ + ") because the intent is unclear. " ++ + "Consider using std.StringHashMap for hashing the contents of []const u8. " ++ + "Alternatively, consider using std.auto_hash.hash or providing your own hash function instead."); + } + } + return struct { fn hash(key: K) u64 { if (comptime trait.hasUniqueRepresentation(K)) { diff --git a/lib/std/heap.zig b/lib/std/heap.zig index a0484d4fdc..3e1a24beea 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -160,8 +160,8 @@ var c_allocator_state = Allocator{ /// Asserts allocations are within `@alignOf(std.c.max_align_t)` and directly calls /// `malloc`/`free`. Does not attempt to utilize `malloc_usable_size`. /// This allocator is safe to use as the backing allocator with -/// `ArenaAllocator` and `GeneralPurposeAllocator`, and is more optimal in these cases -/// than to using `c_allocator`. +/// `ArenaAllocator` for example and is more optimal in such a case +/// than `c_allocator`. pub const raw_c_allocator = &raw_c_allocator_state; var raw_c_allocator_state = Allocator{ .allocFn = rawCAlloc, @@ -789,7 +789,7 @@ pub fn stackFallback(comptime size: usize, fallback_allocator: *Allocator) Stack .fallback_allocator = fallback_allocator, .fixed_buffer_allocator = undefined, .allocator = Allocator{ - .allocFn = StackFallbackAllocator(size).realloc, + .allocFn = StackFallbackAllocator(size).alloc, .resizeFn = StackFallbackAllocator(size).resize, }, }; @@ -815,25 +815,25 @@ pub fn StackFallbackAllocator(comptime size: usize) type { ptr_align: u29, len_align: u29, return_address: usize, - ) error{OutOfMemory}![*]u8 { + ) error{OutOfMemory}![]u8 { const self = @fieldParentPtr(Self, "allocator", allocator); - return FixedBufferAllocator.alloc(&self.fixed_buffer_allocator, len, ptr_align) catch - return fallback_allocator.alloc(len, ptr_align); + return FixedBufferAllocator.alloc(&self.fixed_buffer_allocator.allocator, len, ptr_align, len_align, return_address) catch + return self.fallback_allocator.allocFn(self.fallback_allocator, len, ptr_align, len_align, return_address); } fn resize( - self: *Allocator, + allocator: *Allocator, buf: []u8, buf_align: u29, new_len: usize, len_align: u29, return_address: usize, - ) error{OutOfMemory}!void { + ) error{OutOfMemory}!usize { const self = @fieldParentPtr(Self, "allocator", allocator); if (self.fixed_buffer_allocator.ownsPtr(buf.ptr)) { - try self.fixed_buffer_allocator.resize(buf, new_len); + return FixedBufferAllocator.resize(&self.fixed_buffer_allocator.allocator, buf, buf_align, new_len, len_align, return_address); } else { - try self.fallback_allocator.resize(buf, new_len); + return self.fallback_allocator.resizeFn(self.fallback_allocator, buf, buf_align, new_len, len_align, return_address); } } }; @@ -970,6 +970,16 @@ test "FixedBufferAllocator.reset" { testing.expect(y.* == Y); } +test "StackFallbackAllocator" { + const fallback_allocator = page_allocator; + var stack_allocator = stackFallback(4096, fallback_allocator); + + try testAllocator(stack_allocator.get()); + try testAllocatorAligned(stack_allocator.get()); + try testAllocatorLargeAlignment(stack_allocator.get()); + try testAllocatorAlignedShrink(stack_allocator.get()); +} + test "FixedBufferAllocator Reuse memory on realloc" { var small_fixed_buffer: [10]u8 = undefined; // check if we re-use the memory diff --git a/lib/std/heap/arena_allocator.zig b/lib/std/heap/arena_allocator.zig index b7ee1d54c1..1b301bbb50 100644 --- a/lib/std/heap/arena_allocator.zig +++ b/lib/std/heap/arena_allocator.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/heap/general_purpose_allocator.zig b/lib/std/heap/general_purpose_allocator.zig index acda1e116e..c731f22d66 100644 --- a/lib/std/heap/general_purpose_allocator.zig +++ b/lib/std/heap/general_purpose_allocator.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -98,7 +98,7 @@ //! in a `std.HashMap` using the backing allocator. const std = @import("std"); -const log = std.log.scoped(.std); +const log = std.log.scoped(.gpa); const math = std.math; const assert = std.debug.assert; const mem = std.mem; @@ -149,19 +149,22 @@ pub const Config = struct { thread_safe: bool = !std.builtin.single_threaded, /// What type of mutex you'd like to use, for thread safety. - /// when specfied, the mutex type must have the same shape as `std.Mutex` and - /// `std.mutex.Dummy`, and have no required fields. Specifying this field causes + /// when specfied, the mutex type must have the same shape as `std.Thread.Mutex` and + /// `std.Thread.Mutex.Dummy`, and have no required fields. Specifying this field causes /// the `thread_safe` field to be ignored. /// /// when null (default): - /// * the mutex type defaults to `std.Mutex` when thread_safe is enabled. - /// * the mutex type defaults to `std.mutex.Dummy` otherwise. + /// * the mutex type defaults to `std.Thread.Mutex` when thread_safe is enabled. + /// * the mutex type defaults to `std.Thread.Mutex.Dummy` otherwise. MutexType: ?type = null, /// This is a temporary debugging trick you can use to turn segfaults into more helpful /// logged error messages with stack trace details. The downside is that every allocation /// will be leaked! never_unmap: bool = false, + + /// Enables emitting info messages with the size and address of every allocation. + verbose_log: bool = false, }; pub fn GeneralPurposeAllocator(comptime config: Config) type { @@ -187,9 +190,9 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { const mutex_init = if (config.MutexType) |T| T{} else if (config.thread_safe) - std.Mutex{} + std.Thread.Mutex{} else - std.mutex.Dummy{}; + std.Thread.Mutex.Dummy{}; const stack_n = config.stack_trace_frames; const one_trace_size = @sizeOf(usize) * stack_n; @@ -314,7 +317,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { if (is_used) { const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index); const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc); - log.err("Memory leak detected: {}", .{stack_trace}); + log.err("Memory leak detected: {s}", .{stack_trace}); leaks = true; } if (bit_index == math.maxInt(u3)) @@ -342,7 +345,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { } var it = self.large_allocations.iterator(); while (it.next()) |large_alloc| { - log.err("Memory leak detected: {}", .{large_alloc.value.getStackTrace()}); + log.err("Memory leak detected: {s}", .{large_alloc.value.getStackTrace()}); leaks = true; } return leaks; @@ -443,7 +446,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { .index = 0, }; std.debug.captureStackTrace(ret_addr, &free_stack_trace); - log.err("Allocation size {} bytes does not match free size {}. Allocation: {} Free: {}", .{ + log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {s} Free: {s}", .{ entry.value.bytes.len, old_mem.len, entry.value.getStackTrace(), @@ -454,10 +457,19 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { const result_len = try self.backing_allocator.resizeFn(self.backing_allocator, old_mem, old_align, new_size, len_align, ret_addr); if (result_len == 0) { + if (config.verbose_log) { + log.info("large free {d} bytes at {*}", .{ old_mem.len, old_mem.ptr }); + } + self.large_allocations.removeAssertDiscard(@ptrToInt(old_mem.ptr)); return 0; } + if (config.verbose_log) { + log.info("large resize {d} bytes at {*} to {d}", .{ + old_mem.len, old_mem.ptr, new_size, + }); + } entry.value.bytes = old_mem.ptr[0..result_len]; collectStackTrace(ret_addr, &entry.value.stack_addresses); return result_len; @@ -526,7 +538,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { .index = 0, }; std.debug.captureStackTrace(ret_addr, &second_free_stack_trace); - log.err("Double free detected. Allocation: {} First free: {} Second free: {}", .{ + log.err("Double free detected. Allocation: {s} First free: {s} Second free: {s}", .{ alloc_stack_trace, free_stack_trace, second_free_stack_trace, @@ -568,6 +580,9 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { } else { @memset(old_mem.ptr, undefined, old_mem.len); } + if (config.verbose_log) { + log.info("small free {d} bytes at {*}", .{ old_mem.len, old_mem.ptr }); + } return @as(usize, 0); } const new_aligned_size = math.max(new_size, old_align); @@ -576,6 +591,11 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { if (old_mem.len > new_size) { @memset(old_mem.ptr + new_size, undefined, old_mem.len - new_size); } + if (config.verbose_log) { + log.info("small resize {d} bytes at {*} to {d}", .{ + old_mem.len, old_mem.ptr, new_size, + }); + } return new_size; } return error.OutOfMemory; @@ -623,6 +643,9 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { gop.entry.value.bytes = slice; collectStackTrace(ret_addr, &gop.entry.value.stack_addresses); + if (config.verbose_log) { + log.info("large alloc {d} bytes at {*}", .{ slice.len, slice.ptr }); + } return slice; } @@ -632,6 +655,9 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { const new_size_class = math.ceilPowerOfTwoAssert(usize, new_aligned_size); const ptr = try self.allocSlot(new_size_class, ret_addr); + if (config.verbose_log) { + log.info("small alloc {d} bytes at {*}", .{ len, ptr }); + } return ptr[0..len]; } @@ -869,9 +895,9 @@ test "realloc large object to small object" { } test "overrideable mutexes" { - var gpa = GeneralPurposeAllocator(.{ .MutexType = std.Mutex }){ + var gpa = GeneralPurposeAllocator(.{ .MutexType = std.Thread.Mutex }){ .backing_allocator = std.testing.allocator, - .mutex = std.Mutex{}, + .mutex = std.Thread.Mutex{}, }; defer std.testing.expect(!gpa.deinit()); const allocator = &gpa.allocator; diff --git a/lib/std/heap/logging_allocator.zig b/lib/std/heap/logging_allocator.zig index f4e0ada764..7885571ab3 100644 --- a/lib/std/heap/logging_allocator.zig +++ b/lib/std/heap/logging_allocator.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -9,22 +9,22 @@ const Allocator = std.mem.Allocator; /// This allocator is used in front of another allocator and logs to the provided stream /// on every call to the allocator. Stream errors are ignored. /// If https://github.com/ziglang/zig/issues/2586 is implemented, this API can be improved. -pub fn LoggingAllocator(comptime OutStreamType: type) type { +pub fn LoggingAllocator(comptime Writer: type) type { return struct { allocator: Allocator, parent_allocator: *Allocator, - out_stream: OutStreamType, + writer: Writer, const Self = @This(); - pub fn init(parent_allocator: *Allocator, out_stream: OutStreamType) Self { + pub fn init(parent_allocator: *Allocator, writer: Writer) Self { return Self{ .allocator = Allocator{ .allocFn = alloc, .resizeFn = resize, }, .parent_allocator = parent_allocator, - .out_stream = out_stream, + .writer = writer, }; } @@ -36,12 +36,12 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type { ra: usize, ) error{OutOfMemory}![]u8 { const self = @fieldParentPtr(Self, "allocator", allocator); - self.out_stream.print("alloc : {}", .{len}) catch {}; + self.writer.print("alloc : {}", .{len}) catch {}; const result = self.parent_allocator.allocFn(self.parent_allocator, len, ptr_align, len_align, ra); if (result) |buff| { - self.out_stream.print(" success!\n", .{}) catch {}; + self.writer.print(" success!\n", .{}) catch {}; } else |err| { - self.out_stream.print(" failure!\n", .{}) catch {}; + self.writer.print(" failure!\n", .{}) catch {}; } return result; } @@ -56,20 +56,20 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type { ) error{OutOfMemory}!usize { const self = @fieldParentPtr(Self, "allocator", allocator); if (new_len == 0) { - self.out_stream.print("free : {}\n", .{buf.len}) catch {}; + self.writer.print("free : {}\n", .{buf.len}) catch {}; } else if (new_len <= buf.len) { - self.out_stream.print("shrink: {} to {}\n", .{ buf.len, new_len }) catch {}; + self.writer.print("shrink: {} to {}\n", .{ buf.len, new_len }) catch {}; } else { - self.out_stream.print("expand: {} to {}", .{ buf.len, new_len }) catch {}; + self.writer.print("expand: {} to {}", .{ buf.len, new_len }) catch {}; } if (self.parent_allocator.resizeFn(self.parent_allocator, buf, buf_align, new_len, len_align, ra)) |resized_len| { if (new_len > buf.len) { - self.out_stream.print(" success!\n", .{}) catch {}; + self.writer.print(" success!\n", .{}) catch {}; } return resized_len; } else |e| { std.debug.assert(new_len > buf.len); - self.out_stream.print(" failure!\n", .{}) catch {}; + self.writer.print(" failure!\n", .{}) catch {}; return e; } } @@ -78,9 +78,9 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type { pub fn loggingAllocator( parent_allocator: *Allocator, - out_stream: anytype, -) LoggingAllocator(@TypeOf(out_stream)) { - return LoggingAllocator(@TypeOf(out_stream)).init(parent_allocator, out_stream); + writer: anytype, +) LoggingAllocator(@TypeOf(writer)) { + return LoggingAllocator(@TypeOf(writer)).init(parent_allocator, writer); } test "LoggingAllocator" { @@ -89,7 +89,7 @@ test "LoggingAllocator" { var allocator_buf: [10]u8 = undefined; var fixedBufferAllocator = std.mem.validationWrap(std.heap.FixedBufferAllocator.init(&allocator_buf)); - const allocator = &loggingAllocator(&fixedBufferAllocator.allocator, fbs.outStream()).allocator; + const allocator = &loggingAllocator(&fixedBufferAllocator.allocator, fbs.writer()).allocator; var a = try allocator.alloc(u8, 10); a = allocator.shrink(a, 5); diff --git a/lib/std/io.zig b/lib/std/io.zig index 3f02128a6c..b529c57866 100644 --- a/lib/std/io.zig +++ b/lib/std/io.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -107,26 +107,14 @@ pub fn getStdIn() File { } pub const Reader = @import("io/reader.zig").Reader; -/// Deprecated: use `Reader` -pub const InStream = Reader; pub const Writer = @import("io/writer.zig").Writer; -/// Deprecated: use `Writer` -pub const OutStream = Writer; pub const SeekableStream = @import("io/seekable_stream.zig").SeekableStream; pub const BufferedWriter = @import("io/buffered_writer.zig").BufferedWriter; pub const bufferedWriter = @import("io/buffered_writer.zig").bufferedWriter; -/// Deprecated: use `BufferedWriter` -pub const BufferedOutStream = BufferedWriter; -/// Deprecated: use `bufferedWriter` -pub const bufferedOutStream = bufferedWriter; pub const BufferedReader = @import("io/buffered_reader.zig").BufferedReader; pub const bufferedReader = @import("io/buffered_reader.zig").bufferedReader; -/// Deprecated: use `BufferedReader` -pub const BufferedInStream = BufferedReader; -/// Deprecated: use `bufferedReader` -pub const bufferedInStream = bufferedReader; pub const PeekStream = @import("io/peek_stream.zig").PeekStream; pub const peekStream = @import("io/peek_stream.zig").peekStream; @@ -136,55 +124,33 @@ pub const fixedBufferStream = @import("io/fixed_buffer_stream.zig").fixedBufferS pub const CWriter = @import("io/c_writer.zig").CWriter; pub const cWriter = @import("io/c_writer.zig").cWriter; -/// Deprecated: use `CWriter` -pub const COutStream = CWriter; -/// Deprecated: use `cWriter` -pub const cOutStream = cWriter; + +pub const LimitedReader = @import("io/limited_reader.zig").LimitedReader; +pub const limitedReader = @import("io/limited_reader.zig").limitedReader; pub const CountingWriter = @import("io/counting_writer.zig").CountingWriter; pub const countingWriter = @import("io/counting_writer.zig").countingWriter; -/// Deprecated: use `CountingWriter` -pub const CountingOutStream = CountingWriter; -/// Deprecated: use `countingWriter` -pub const countingOutStream = countingWriter; +pub const CountingReader = @import("io/counting_reader.zig").CountingReader; +pub const countingReader = @import("io/counting_reader.zig").countingReader; pub const MultiWriter = @import("io/multi_writer.zig").MultiWriter; pub const multiWriter = @import("io/multi_writer.zig").multiWriter; -/// Deprecated: use `MultiWriter` -pub const MultiOutStream = MultiWriter; -/// Deprecated: use `multiWriter` -pub const multiOutStream = multiWriter; pub const BitReader = @import("io/bit_reader.zig").BitReader; pub const bitReader = @import("io/bit_reader.zig").bitReader; -/// Deprecated: use `BitReader` -pub const BitInStream = BitReader; -/// Deprecated: use `bitReader` -pub const bitInStream = bitReader; pub const BitWriter = @import("io/bit_writer.zig").BitWriter; pub const bitWriter = @import("io/bit_writer.zig").bitWriter; -/// Deprecated: use `BitWriter` -pub const BitOutStream = BitWriter; -/// Deprecated: use `bitWriter` -pub const bitOutStream = bitWriter; - -pub const AutoIndentingStream = @import("io/auto_indenting_stream.zig").AutoIndentingStream; -pub const autoIndentingStream = @import("io/auto_indenting_stream.zig").autoIndentingStream; pub const ChangeDetectionStream = @import("io/change_detection_stream.zig").ChangeDetectionStream; pub const changeDetectionStream = @import("io/change_detection_stream.zig").changeDetectionStream; -pub const FindByteOutStream = @import("io/find_byte_out_stream.zig").FindByteOutStream; -pub const findByteOutStream = @import("io/find_byte_out_stream.zig").findByteOutStream; - -pub const Packing = @import("io/serialization.zig").Packing; - -pub const Serializer = @import("io/serialization.zig").Serializer; -pub const serializer = @import("io/serialization.zig").serializer; - -pub const Deserializer = @import("io/serialization.zig").Deserializer; -pub const deserializer = @import("io/serialization.zig").deserializer; +pub const FindByteWriter = @import("io/find_byte_writer.zig").FindByteWriter; +pub const findByteWriter = @import("io/find_byte_writer.zig").findByteWriter; +/// Deprecated: use `FindByteWriter`. +pub const FindByteOutStream = FindByteWriter; +/// Deprecated: use `findByteWriter`. +pub const findByteOutStream = findByteWriter; pub const BufferedAtomicFile = @import("io/buffered_atomic_file.zig").BufferedAtomicFile; @@ -193,12 +159,7 @@ pub const StreamSource = @import("io/stream_source.zig").StreamSource; /// A Writer that doesn't write to anything. pub const null_writer = @as(NullWriter, .{ .context = {} }); -/// Deprecated: use `null_writer` -pub const null_out_stream = null_writer; - const NullWriter = Writer(void, error{}, dummyWrite); -/// Deprecated: use NullWriter -const NullOutStream = NullWriter; fn dummyWrite(context: void, data: []const u8) error{}!usize { return data.len; } @@ -207,7 +168,7 @@ test "null_writer" { null_writer.writeAll("yay" ** 10) catch |err| switch (err) {}; } -test "" { +test { _ = @import("io/bit_reader.zig"); _ = @import("io/bit_writer.zig"); _ = @import("io/buffered_atomic_file.zig"); @@ -215,12 +176,12 @@ test "" { _ = @import("io/buffered_writer.zig"); _ = @import("io/c_writer.zig"); _ = @import("io/counting_writer.zig"); + _ = @import("io/counting_reader.zig"); _ = @import("io/fixed_buffer_stream.zig"); _ = @import("io/reader.zig"); _ = @import("io/writer.zig"); _ = @import("io/peek_stream.zig"); _ = @import("io/seekable_stream.zig"); - _ = @import("io/serialization.zig"); _ = @import("io/stream_source.zig"); _ = @import("io/test.zig"); } diff --git a/lib/std/io/auto_indenting_stream.zig b/lib/std/io/auto_indenting_stream.zig deleted file mode 100644 index bea4af7519..0000000000 --- a/lib/std/io/auto_indenting_stream.zig +++ /dev/null @@ -1,154 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. - -const std = @import("../std.zig"); -const io = std.io; -const mem = std.mem; -const assert = std.debug.assert; - -/// Automatically inserts indentation of written data by keeping -/// track of the current indentation level -pub fn AutoIndentingStream(comptime UnderlyingWriter: type) type { - return struct { - const Self = @This(); - pub const Error = UnderlyingWriter.Error; - pub const Writer = io.Writer(*Self, Error, write); - - underlying_writer: UnderlyingWriter, - - indent_count: usize = 0, - indent_delta: usize, - current_line_empty: bool = true, - indent_one_shot_count: usize = 0, // automatically popped when applied - applied_indent: usize = 0, // the most recently applied indent - indent_next_line: usize = 0, // not used until the next line - - pub fn writer(self: *Self) Writer { - return .{ .context = self }; - } - - pub fn write(self: *Self, bytes: []const u8) Error!usize { - if (bytes.len == 0) - return @as(usize, 0); - - try self.applyIndent(); - return self.writeNoIndent(bytes); - } - - // Change the indent delta without changing the final indentation level - pub fn setIndentDelta(self: *Self, indent_delta: usize) void { - if (self.indent_delta == indent_delta) { - return; - } else if (self.indent_delta > indent_delta) { - assert(self.indent_delta % indent_delta == 0); - self.indent_count = self.indent_count * (self.indent_delta / indent_delta); - } else { - // assert that the current indentation (in spaces) in a multiple of the new delta - assert((self.indent_count * self.indent_delta) % indent_delta == 0); - self.indent_count = self.indent_count / (indent_delta / self.indent_delta); - } - self.indent_delta = indent_delta; - } - - fn writeNoIndent(self: *Self, bytes: []const u8) Error!usize { - if (bytes.len == 0) - return @as(usize, 0); - - try self.underlying_writer.writeAll(bytes); - if (bytes[bytes.len - 1] == '\n') - self.resetLine(); - return bytes.len; - } - - pub fn insertNewline(self: *Self) Error!void { - _ = try self.writeNoIndent("\n"); - } - - fn resetLine(self: *Self) void { - self.current_line_empty = true; - self.indent_next_line = 0; - } - - /// Insert a newline unless the current line is blank - pub fn maybeInsertNewline(self: *Self) Error!void { - if (!self.current_line_empty) - try self.insertNewline(); - } - - /// Push default indentation - pub fn pushIndent(self: *Self) void { - // Doesn't actually write any indentation. - // Just primes the stream to be able to write the correct indentation if it needs to. - self.indent_count += 1; - } - - /// Push an indent that is automatically popped after being applied - pub fn pushIndentOneShot(self: *Self) void { - self.indent_one_shot_count += 1; - self.pushIndent(); - } - - /// Turns all one-shot indents into regular indents - /// Returns number of indents that must now be manually popped - pub fn lockOneShotIndent(self: *Self) usize { - var locked_count = self.indent_one_shot_count; - self.indent_one_shot_count = 0; - return locked_count; - } - - /// Push an indent that should not take effect until the next line - pub fn pushIndentNextLine(self: *Self) void { - self.indent_next_line += 1; - self.pushIndent(); - } - - pub fn popIndent(self: *Self) void { - assert(self.indent_count != 0); - self.indent_count -= 1; - - if (self.indent_next_line > 0) - self.indent_next_line -= 1; - } - - /// Writes ' ' bytes if the current line is empty - fn applyIndent(self: *Self) Error!void { - const current_indent = self.currentIndent(); - if (self.current_line_empty and current_indent > 0) { - try self.underlying_writer.writeByteNTimes(' ', current_indent); - self.applied_indent = current_indent; - } - - self.indent_count -= self.indent_one_shot_count; - self.indent_one_shot_count = 0; - self.current_line_empty = false; - } - - /// Checks to see if the most recent indentation exceeds the currently pushed indents - pub fn isLineOverIndented(self: *Self) bool { - if (self.current_line_empty) return false; - return self.applied_indent > self.currentIndent(); - } - - fn currentIndent(self: *Self) usize { - var indent_current: usize = 0; - if (self.indent_count > 0) { - const indent_count = self.indent_count - self.indent_next_line; - indent_current = indent_count * self.indent_delta; - } - return indent_current; - } - }; -} - -pub fn autoIndentingStream( - indent_delta: usize, - underlying_writer: anytype, -) AutoIndentingStream(@TypeOf(underlying_writer)) { - return AutoIndentingStream(@TypeOf(underlying_writer)){ - .underlying_writer = underlying_writer, - .indent_delta = indent_delta, - }; -} diff --git a/lib/std/io/bit_in_stream.zig b/lib/std/io/bit_in_stream.zig deleted file mode 100644 index a027deb802..0000000000 --- a/lib/std/io/bit_in_stream.zig +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -/// Deprecated: use `std.io.bit_reader.BitReader` -pub const BitInStream = @import("./bit_reader.zig").BitReader; - -/// Deprecated: use `std.io.bit_reader.bitReader` -pub const bitInStream = @import("./bit_reader.zig").bitReader; diff --git a/lib/std/io/bit_out_stream.zig b/lib/std/io/bit_out_stream.zig deleted file mode 100644 index 171fb542da..0000000000 --- a/lib/std/io/bit_out_stream.zig +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -/// Deprecated: use `std.io.bit_writer.BitWriter` -pub const BitOutStream = @import("./bit_writer.zig").BitWriter; - -/// Deprecated: use `std.io.bit_writer.bitWriter` -pub const bitOutStream = @import("./bit_writer.zig").bitWriter; diff --git a/lib/std/io/bit_reader.zig b/lib/std/io/bit_reader.zig index 75d217068e..213cd2b503 100644 --- a/lib/std/io/bit_reader.zig +++ b/lib/std/io/bit_reader.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -21,8 +21,6 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type { pub const Error = ReaderType.Error; pub const Reader = io.Reader(*Self, Error, read); - /// Deprecated: use `Reader` - pub const InStream = io.InStream(*Self, Error, read); const Self = @This(); const u8_bit_count = comptime meta.bitCount(u8); @@ -165,11 +163,6 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type { pub fn reader(self: *Self) Reader { return .{ .context = self }; } - - /// Deprecated: use `reader` - pub fn inStream(self: *Self) InStream { - return .{ .context = self }; - } }; } diff --git a/lib/std/io/bit_writer.zig b/lib/std/io/bit_writer.zig index d2ea9b525e..3ad2b75efb 100644 --- a/lib/std/io/bit_writer.zig +++ b/lib/std/io/bit_writer.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -21,8 +21,6 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type { pub const Error = WriterType.Error; pub const Writer = io.Writer(*Self, Error, write); - /// Deprecated: use `Writer` - pub const OutStream = io.OutStream(*Self, Error, write); const Self = @This(); const u8_bit_count = comptime meta.bitCount(u8); @@ -141,10 +139,6 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type { pub fn writer(self: *Self) Writer { return .{ .context = self }; } - /// Deprecated: use `writer` - pub fn outStream(self: *Self) OutStream { - return .{ .context = self }; - } }; } diff --git a/lib/std/io/buffered_atomic_file.zig b/lib/std/io/buffered_atomic_file.zig index 6284d4e44f..1aed190a47 100644 --- a/lib/std/io/buffered_atomic_file.zig +++ b/lib/std/io/buffered_atomic_file.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -10,13 +10,13 @@ const File = std.fs.File; pub const BufferedAtomicFile = struct { atomic_file: fs.AtomicFile, - file_stream: File.OutStream, - buffered_stream: BufferedOutStream, + file_writer: File.Writer, + buffered_writer: BufferedWriter, allocator: *mem.Allocator, pub const buffer_size = 4096; - pub const BufferedOutStream = std.io.BufferedOutStream(buffer_size, File.OutStream); - pub const OutStream = std.io.OutStream(*BufferedOutStream, BufferedOutStream.Error, BufferedOutStream.write); + pub const BufferedWriter = std.io.BufferedWriter(buffer_size, File.Writer); + pub const Writer = std.io.Writer(*BufferedWriter, BufferedWriter.Error, BufferedWriter.write); /// TODO when https://github.com/ziglang/zig/issues/2761 is solved /// this API will not need an allocator @@ -29,8 +29,8 @@ pub const BufferedAtomicFile = struct { var self = try allocator.create(BufferedAtomicFile); self.* = BufferedAtomicFile{ .atomic_file = undefined, - .file_stream = undefined, - .buffered_stream = undefined, + .file_writer = undefined, + .buffered_writer = undefined, .allocator = allocator, }; errdefer allocator.destroy(self); @@ -38,8 +38,8 @@ pub const BufferedAtomicFile = struct { self.atomic_file = try dir.atomicFile(dest_path, atomic_file_options); errdefer self.atomic_file.deinit(); - self.file_stream = self.atomic_file.file.outStream(); - self.buffered_stream = .{ .unbuffered_writer = self.file_stream }; + self.file_writer = self.atomic_file.file.writer(); + self.buffered_writer = .{ .unbuffered_writer = self.file_writer }; return self; } @@ -50,11 +50,11 @@ pub const BufferedAtomicFile = struct { } pub fn finish(self: *BufferedAtomicFile) !void { - try self.buffered_stream.flush(); + try self.buffered_writer.flush(); try self.atomic_file.finish(); } - pub fn stream(self: *BufferedAtomicFile) OutStream { - return .{ .context = &self.buffered_stream }; + pub fn writer(self: *BufferedAtomicFile) Writer { + return .{ .context = &self.buffered_writer }; } }; diff --git a/lib/std/io/buffered_in_stream.zig b/lib/std/io/buffered_in_stream.zig deleted file mode 100644 index f055978152..0000000000 --- a/lib/std/io/buffered_in_stream.zig +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -/// Deprecated: use `std.io.buffered_reader.BufferedReader` -pub const BufferedInStream = @import("./buffered_reader.zig").BufferedReader; - -/// Deprecated: use `std.io.buffered_reader.bufferedReader` -pub const bufferedInStream = @import("./buffered_reader.zig").bufferedReader; diff --git a/lib/std/io/buffered_out_stream.zig b/lib/std/io/buffered_out_stream.zig deleted file mode 100644 index 5f1eaa6faf..0000000000 --- a/lib/std/io/buffered_out_stream.zig +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -/// Deprecated: use `std.io.buffered_writer.BufferedWriter` -pub const BufferedOutStream = @import("./buffered_writer.zig").BufferedWriter; - -/// Deprecated: use `std.io.buffered_writer.bufferedWriter` -pub const bufferedOutStream = @import("./buffered_writer.zig").bufferedWriter; diff --git a/lib/std/io/buffered_reader.zig b/lib/std/io/buffered_reader.zig index 58c4f3b4fc..5fda7f2741 100644 --- a/lib/std/io/buffered_reader.zig +++ b/lib/std/io/buffered_reader.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -15,8 +15,6 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty pub const Error = ReaderType.Error; pub const Reader = io.Reader(*Self, Error, read); - /// Deprecated: use `Reader` - pub const InStream = Reader; const Self = @This(); const FifoType = std.fifo.LinearFifo(u8, std.fifo.LinearFifoBufferType{ .Static = buffer_size }); @@ -45,11 +43,6 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty pub fn reader(self: *Self) Reader { return .{ .context = self }; } - - /// Deprecated: use `reader` - pub fn inStream(self: *Self) InStream { - return .{ .context = self }; - } }; } diff --git a/lib/std/io/buffered_writer.zig b/lib/std/io/buffered_writer.zig index bee3ff48af..056ff08987 100644 --- a/lib/std/io/buffered_writer.zig +++ b/lib/std/io/buffered_writer.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -13,8 +13,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty pub const Error = WriterType.Error; pub const Writer = io.Writer(*Self, Error, write); - /// Deprecated: use `Writer` - pub const OutStream = Writer; const Self = @This(); const FifoType = std.fifo.LinearFifo(u8, std.fifo.LinearFifoBufferType{ .Static = buffer_size }); @@ -32,11 +30,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty return .{ .context = self }; } - /// Deprecated: use writer - pub fn outStream(self: *Self) Writer { - return .{ .context = self }; - } - pub fn write(self: *Self, bytes: []const u8) Error!usize { if (bytes.len >= self.fifo.writableLength()) { try self.flush(); diff --git a/lib/std/io/c_out_stream.zig b/lib/std/io/c_out_stream.zig deleted file mode 100644 index 69f4d9f5af..0000000000 --- a/lib/std/io/c_out_stream.zig +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -/// Deprecated: use `std.io.c_writer.CWriter` -pub const COutStream = @import("./c_writer.zig").CWriter; - -/// Deprecated: use `std.io.c_writer.cWriter` -pub const cOutStream = @import("./c_writer.zig").cWriter; diff --git a/lib/std/io/c_writer.zig b/lib/std/io/c_writer.zig index 9fd10d827e..fa7d7eb13a 100644 --- a/lib/std/io/c_writer.zig +++ b/lib/std/io/c_writer.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -34,7 +34,7 @@ fn cWriterWrite(c_file: *std.c.FILE, bytes: []const u8) std.fs.File.WriteError!u } } -test "" { +test { if (!builtin.link_libc) return error.SkipZigTest; const filename = "tmp_io_test_file.txt"; diff --git a/lib/std/io/change_detection_stream.zig b/lib/std/io/change_detection_stream.zig index 52c3372094..57ef8a82bd 100644 --- a/lib/std/io/change_detection_stream.zig +++ b/lib/std/io/change_detection_stream.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/io/counting_out_stream.zig b/lib/std/io/counting_out_stream.zig deleted file mode 100644 index fecdf8adb0..0000000000 --- a/lib/std/io/counting_out_stream.zig +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -/// Deprecated: use `std.io.counting_writer.CountingWriter` -pub const CountingOutStream = @import("./counting_writer.zig").CountingWriter; - -/// Deprecated: use `std.io.counting_writer.countingWriter` -pub const countingOutStream = @import("./counting_writer.zig").countingWriter; diff --git a/lib/std/io/counting_reader.zig b/lib/std/io/counting_reader.zig new file mode 100644 index 0000000000..1369155a73 --- /dev/null +++ b/lib/std/io/counting_reader.zig @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. +const std = @import("../std.zig"); +const io = std.io; +const testing = std.testing; + +/// A Reader that counts how many bytes has been read from it. +pub fn CountingReader(comptime ReaderType: anytype) type { + return struct { + child_reader: ReaderType, + bytes_read: u64 = 0, + + pub const Error = ReaderType.Error; + pub const Reader = io.Reader(*@This(), Error, read); + + pub fn read(self: *@This(), buf: []u8) Error!usize { + const amt = try self.child_reader.read(buf); + self.bytes_read += amt; + return amt; + } + + pub fn reader(self: *@This()) Reader { + return .{ .context = self }; + } + }; +} + +pub fn countingReader(reader: anytype) CountingReader(@TypeOf(reader)) { + return .{ .child_reader = reader }; +} + +test "io.CountingReader" { + const bytes = "yay" ** 100; + var fbs = io.fixedBufferStream(bytes); + + var counting_stream = countingReader(fbs.reader()); + const stream = counting_stream.reader(); + + //read and discard all bytes + while (stream.readByte()) |_| {} else |err| { + testing.expect(err == error.EndOfStream); + } + + testing.expect(counting_stream.bytes_read == bytes.len); +} diff --git a/lib/std/io/counting_writer.zig b/lib/std/io/counting_writer.zig index aefd459b90..f68c257486 100644 --- a/lib/std/io/counting_writer.zig +++ b/lib/std/io/counting_writer.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -15,8 +15,6 @@ pub fn CountingWriter(comptime WriterType: type) type { pub const Error = WriterType.Error; pub const Writer = io.Writer(*Self, Error, write); - /// Deprecated: use `Writer` - pub const OutStream = Writer; const Self = @This(); @@ -29,11 +27,6 @@ pub fn CountingWriter(comptime WriterType: type) type { pub fn writer(self: *Self) Writer { return .{ .context = self }; } - - /// Deprecated: use `writer` - pub fn outStream(self: *Self) OutStream { - return .{ .context = self }; - } }; } diff --git a/lib/std/io/find_byte_out_stream.zig b/lib/std/io/find_byte_writer.zig similarity index 76% rename from lib/std/io/find_byte_out_stream.zig rename to lib/std/io/find_byte_writer.zig index 70e1e190b1..db45114d3e 100644 --- a/lib/std/io/find_byte_out_stream.zig +++ b/lib/std/io/find_byte_writer.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -8,9 +8,9 @@ const std = @import("../std.zig"); const io = std.io; const assert = std.debug.assert; -/// An OutStream that returns whether the given character has been written to it. +/// A Writer that returns whether the given character has been written to it. /// The contents are not written to anything. -pub fn FindByteOutStream(comptime UnderlyingWriter: type) type { +pub fn FindByteWriter(comptime UnderlyingWriter: type) type { return struct { const Self = @This(); pub const Error = UnderlyingWriter.Error; @@ -37,8 +37,8 @@ pub fn FindByteOutStream(comptime UnderlyingWriter: type) type { }; } -pub fn findByteOutStream(byte: u8, underlying_writer: anytype) FindByteOutStream(@TypeOf(underlying_writer)) { - return FindByteOutStream(@TypeOf(underlying_writer)){ +pub fn findByteWriter(byte: u8, underlying_writer: anytype) FindByteWriter(@TypeOf(underlying_writer)) { + return FindByteWriter(@TypeOf(underlying_writer)){ .underlying_writer = underlying_writer, .byte = byte, .byte_found = false, diff --git a/lib/std/io/fixed_buffer_stream.zig b/lib/std/io/fixed_buffer_stream.zig index b1d2aaf89a..f86fd5a8d8 100644 --- a/lib/std/io/fixed_buffer_stream.zig +++ b/lib/std/io/fixed_buffer_stream.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -23,11 +23,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type { pub const GetSeekPosError = error{}; pub const Reader = io.Reader(*Self, ReadError, read); - /// Deprecated: use `Reader` - pub const InStream = io.InStream(*Self, ReadError, read); pub const Writer = io.Writer(*Self, WriteError, write); - /// Deprecated: use `Writer` - pub const OutStream = Writer; pub const SeekableStream = io.SeekableStream( *Self, @@ -45,20 +41,10 @@ pub fn FixedBufferStream(comptime Buffer: type) type { return .{ .context = self }; } - /// Deprecated: use `inStream` - pub fn inStream(self: *Self) InStream { - return .{ .context = self }; - } - pub fn writer(self: *Self) Writer { return .{ .context = self }; } - /// Deprecated: use `writer` - pub fn outStream(self: *Self) OutStream { - return .{ .context = self }; - } - pub fn seekableStream(self: *Self) SeekableStream { return .{ .context = self }; } @@ -147,7 +133,7 @@ test "FixedBufferStream output" { var fbs = fixedBufferStream(&buf); const stream = fbs.writer(); - try stream.print("{}{}!", .{ "Hello", "World" }); + try stream.print("{s}{s}!", .{ "Hello", "World" }); testing.expectEqualSlices(u8, "HelloWorld!", fbs.getWritten()); } diff --git a/lib/std/io/in_stream.zig b/lib/std/io/in_stream.zig deleted file mode 100644 index 4583591d42..0000000000 --- a/lib/std/io/in_stream.zig +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -/// Deprecated: use `std.io.reader.Reader` -pub const InStream = @import("./reader.zig").Reader; diff --git a/lib/std/io/limited_reader.zig b/lib/std/io/limited_reader.zig new file mode 100644 index 0000000000..734558b1e6 --- /dev/null +++ b/lib/std/io/limited_reader.zig @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2020 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. +const std = @import("../std.zig"); +const io = std.io; +const assert = std.debug.assert; +const testing = std.testing; + +pub fn LimitedReader(comptime ReaderType: type) type { + return struct { + inner_reader: ReaderType, + bytes_left: u64, + + pub const Error = ReaderType.Error; + pub const Reader = io.Reader(*Self, Error, read); + + const Self = @This(); + + pub fn read(self: *Self, dest: []u8) Error!usize { + const max_read = std.math.min(self.bytes_left, dest.len); + const n = try self.inner_reader.read(dest[0..max_read]); + self.bytes_left -= n; + return n; + } + + pub fn reader(self: *Self) Reader { + return .{ .context = self }; + } + }; +} + +/// Returns an initialised `LimitedReader` +/// `bytes_left` is a `u64` to be able to take 64 bit file offsets +pub fn limitedReader(inner_reader: anytype, bytes_left: u64) LimitedReader(@TypeOf(inner_reader)) { + return .{ .inner_reader = inner_reader, .bytes_left = bytes_left }; +} + +test "basic usage" { + const data = "hello world"; + var fbs = std.io.fixedBufferStream(data); + var early_stream = limitedReader(fbs.reader(), 3); + + var buf: [5]u8 = undefined; + testing.expectEqual(@as(usize, 3), try early_stream.reader().read(&buf)); + testing.expectEqualSlices(u8, data[0..3], buf[0..3]); + testing.expectEqual(@as(usize, 0), try early_stream.reader().read(&buf)); + testing.expectError(error.EndOfStream, early_stream.reader().skipBytes(10, .{})); +} diff --git a/lib/std/io/multi_out_stream.zig b/lib/std/io/multi_out_stream.zig deleted file mode 100644 index 7b96cc3d15..0000000000 --- a/lib/std/io/multi_out_stream.zig +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -/// Deprecated: use `std.io.multi_writer.MultiWriter` -pub const MultiOutStream = @import("./multi_writer.zig").MultiWriter; - -/// Deprecated: use `std.io.multi_writer.multiWriter` -pub const multiOutStream = @import("./multi_writer.zig").multiWriter; diff --git a/lib/std/io/multi_writer.zig b/lib/std/io/multi_writer.zig index 7ee43eddeb..639dd3cd18 100644 --- a/lib/std/io/multi_writer.zig +++ b/lib/std/io/multi_writer.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -22,18 +22,11 @@ pub fn MultiWriter(comptime Writers: type) type { pub const Error = ErrSet; pub const Writer = io.Writer(*Self, Error, write); - /// Deprecated: use `Writer` - pub const OutStream = Writer; pub fn writer(self: *Self) Writer { return .{ .context = self }; } - /// Deprecated: use `writer` - pub fn outStream(self: *Self) OutStream { - return .{ .context = self }; - } - pub fn write(self: *Self, bytes: []const u8) Error!usize { var batch = std.event.Batch(Error!void, self.streams.len, .auto_async).init(); comptime var i = 0; diff --git a/lib/std/io/peek_stream.zig b/lib/std/io/peek_stream.zig index 82554d05ca..b431b0184d 100644 --- a/lib/std/io/peek_stream.zig +++ b/lib/std/io/peek_stream.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -16,13 +16,11 @@ pub fn PeekStream( comptime ReaderType: type, ) type { return struct { - unbuffered_in_stream: ReaderType, + unbuffered_reader: ReaderType, fifo: FifoType, pub const Error = ReaderType.Error; pub const Reader = io.Reader(*Self, Error, read); - /// Deprecated: use `Reader` - pub const InStream = Reader; const Self = @This(); const FifoType = std.fifo.LinearFifo(u8, buffer_type); @@ -31,7 +29,7 @@ pub fn PeekStream( .Static => struct { pub fn init(base: ReaderType) Self { return .{ - .unbuffered_in_stream = base, + .unbuffered_reader = base, .fifo = FifoType.init(), }; } @@ -39,7 +37,7 @@ pub fn PeekStream( .Slice => struct { pub fn init(base: ReaderType, buf: []u8) Self { return .{ - .unbuffered_in_stream = base, + .unbuffered_reader = base, .fifo = FifoType.init(buf), }; } @@ -47,7 +45,7 @@ pub fn PeekStream( .Dynamic => struct { pub fn init(base: ReaderType, allocator: *mem.Allocator) Self { return .{ - .unbuffered_in_stream = base, + .unbuffered_reader = base, .fifo = FifoType.init(allocator), }; } @@ -68,18 +66,13 @@ pub fn PeekStream( if (dest_index == dest.len) return dest_index; // ask the backing stream for more - dest_index += try self.unbuffered_in_stream.read(dest[dest_index..]); + dest_index += try self.unbuffered_reader.read(dest[dest_index..]); return dest_index; } pub fn reader(self: *Self) Reader { return .{ .context = self }; } - - /// Deprecated: use `reader` - pub fn inStream(self: *Self) InStream { - return .{ .context = self }; - } }; } diff --git a/lib/std/io/reader.zig b/lib/std/io/reader.zig index b9a9eb3eeb..916e2155fa 100644 --- a/lib/std/io/reader.zig +++ b/lib/std/io/reader.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -76,12 +76,12 @@ pub fn Reader( start_index += bytes_read; if (start_index - original_len > max_append_size) { - array_list.shrink(original_len + max_append_size); + array_list.shrinkAndFree(original_len + max_append_size); return error.StreamTooLong; } if (bytes_read != dest_slice.len) { - array_list.shrink(start_index); + array_list.shrinkAndFree(start_index); return; } @@ -101,35 +101,6 @@ pub fn Reader( return array_list.toOwnedSlice(); } - /// Replaces the `std.ArrayList` contents by reading from the stream until `delimiter` or end-of-stream is found. - /// Does not include the delimiter in the result. - /// If the `std.ArrayList` length would exceed `max_size`, `error.StreamTooLong` is returned and the - /// `std.ArrayList` is populated with `max_size` bytes from the stream. - pub fn readUntilDelimiterOrEofArrayList( - self: Self, - array_list: *std.ArrayList(u8), - delimiter: u8, - max_size: usize, - ) !void { - array_list.shrink(0); - while (true) { - var byte: u8 = self.readByte() catch |err| switch (err) { - error.EndOfStream => return, - else => |e| return e, - }; - - if (byte == delimiter) { - return; - } - - if (array_list.items.len == max_size) { - return error.StreamTooLong; - } - - try array_list.append(byte); - } - } - /// Replaces the `std.ArrayList` contents by reading from the stream until `delimiter` is found. /// Does not include the delimiter in the result. /// If the `std.ArrayList` length would exceed `max_size`, `error.StreamTooLong` is returned and the @@ -140,7 +111,7 @@ pub fn Reader( delimiter: u8, max_size: usize, ) !void { - array_list.shrink(0); + array_list.shrinkRetainingCapacity(0); while (true) { var byte: u8 = try self.readByte(); @@ -173,7 +144,10 @@ pub fn Reader( } /// Allocates enough memory to read until `delimiter` or end-of-stream. - /// If the allocated memory would be greater than `max_size`, returns `error.StreamTooLong`. + /// If the allocated memory would be greater than `max_size`, returns + /// `error.StreamTooLong`. If end-of-stream is found, returns the rest + /// of the stream. If this function is called again after that, returns + /// null. /// Caller owns returned memory. /// If this function returns an error, the contents from the stream read so far are lost. pub fn readUntilDelimiterOrEofAlloc( @@ -181,10 +155,17 @@ pub fn Reader( allocator: *mem.Allocator, delimiter: u8, max_size: usize, - ) ![]u8 { + ) !?[]u8 { var array_list = std.ArrayList(u8).init(allocator); defer array_list.deinit(); - try self.readUntilDelimiterOrEofArrayList(&array_list, delimiter, max_size); + self.readUntilDelimiterArrayList(&array_list, delimiter, max_size) catch |err| switch (err) { + error.EndOfStream => if (array_list.items.len == 0) { + return null; + } else { + return array_list.toOwnedSlice(); + }, + else => |e| return e, + }; return array_list.toOwnedSlice(); } @@ -290,8 +271,9 @@ pub fn Reader( buf_size: usize = 512, }; + // `num_bytes` is a `u64` to match `off_t` /// Reads `num_bytes` bytes from the stream and discards them - pub fn skipBytes(self: Self, num_bytes: usize, comptime options: SkipBytesOptions) !void { + pub fn skipBytes(self: Self, num_bytes: u64, comptime options: SkipBytesOptions) !void { var buf: [options.buf_size]u8 = undefined; var remaining = num_bytes; diff --git a/lib/std/io/seekable_stream.zig b/lib/std/io/seekable_stream.zig index 15e537baa2..4ba39fff42 100644 --- a/lib/std/io/seekable_stream.zig +++ b/lib/std/io/seekable_stream.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/io/serialization.zig b/lib/std/io/serialization.zig deleted file mode 100644 index 3fbc203242..0000000000 --- a/lib/std/io/serialization.zig +++ /dev/null @@ -1,616 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -const std = @import("../std.zig"); -const builtin = std.builtin; -const io = std.io; -const assert = std.debug.assert; -const math = std.math; -const meta = std.meta; -const trait = meta.trait; -const testing = std.testing; - -pub const Packing = enum { - /// Pack data to byte alignment - Byte, - - /// Pack data to bit alignment - Bit, -}; - -/// Creates a deserializer that deserializes types from any stream. -/// If `is_packed` is true, the data stream is treated as bit-packed, -/// otherwise data is expected to be packed to the smallest byte. -/// Types may implement a custom deserialization routine with a -/// function named `deserialize` in the form of: -/// ``` -/// pub fn deserialize(self: *Self, deserializer: anytype) !void -/// ``` -/// which will be called when the deserializer is used to deserialize -/// that type. It will pass a pointer to the type instance to deserialize -/// into and a pointer to the deserializer struct. -pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime ReaderType: type) type { - return struct { - in_stream: if (packing == .Bit) io.BitReader(endian, ReaderType) else ReaderType, - - const Self = @This(); - - pub fn init(in_stream: ReaderType) Self { - return Self{ - .in_stream = switch (packing) { - .Bit => io.bitReader(endian, in_stream), - .Byte => in_stream, - }, - }; - } - - pub fn alignToByte(self: *Self) void { - if (packing == .Byte) return; - self.in_stream.alignToByte(); - } - - //@BUG: inferred error issue. See: #1386 - fn deserializeInt(self: *Self, comptime T: type) (ReaderType.Error || error{EndOfStream})!T { - comptime assert(trait.is(.Int)(T) or trait.is(.Float)(T)); - - const u8_bit_count = 8; - const t_bit_count = comptime meta.bitCount(T); - - const U = std.meta.Int(.unsigned, t_bit_count); - const Log2U = math.Log2Int(U); - const int_size = (t_bit_count + 7) / 8; - - if (packing == .Bit) { - const result = try self.in_stream.readBitsNoEof(U, t_bit_count); - return @bitCast(T, result); - } - - var buffer: [int_size]u8 = undefined; - const read_size = try self.in_stream.read(buffer[0..]); - if (read_size < int_size) return error.EndOfStream; - - if (int_size == 1) { - if (t_bit_count == 8) return @bitCast(T, buffer[0]); - const PossiblySignedByte = std.meta.Int(@typeInfo(T).Int.signedness, 8); - return @truncate(T, @bitCast(PossiblySignedByte, buffer[0])); - } - - var result = @as(U, 0); - for (buffer) |byte, i| { - switch (endian) { - .Big => { - result = (result << u8_bit_count) | byte; - }, - .Little => { - result |= @as(U, byte) << @intCast(Log2U, u8_bit_count * i); - }, - } - } - - return @bitCast(T, result); - } - - /// Deserializes and returns data of the specified type from the stream - pub fn deserialize(self: *Self, comptime T: type) !T { - var value: T = undefined; - try self.deserializeInto(&value); - return value; - } - - /// Deserializes data into the type pointed to by `ptr` - pub fn deserializeInto(self: *Self, ptr: anytype) !void { - const T = @TypeOf(ptr); - comptime assert(trait.is(.Pointer)(T)); - - if (comptime trait.isSlice(T) or comptime trait.isPtrTo(.Array)(T)) { - for (ptr) |*v| - try self.deserializeInto(v); - return; - } - - comptime assert(trait.isSingleItemPtr(T)); - - const C = comptime meta.Child(T); - const child_type_id = @typeInfo(C); - - //custom deserializer: fn(self: *Self, deserializer: anytype) !void - if (comptime trait.hasFn("deserialize")(C)) return C.deserialize(ptr, self); - - if (comptime trait.isPacked(C) and packing != .Bit) { - var packed_deserializer = deserializer(endian, .Bit, self.in_stream); - return packed_deserializer.deserializeInto(ptr); - } - - switch (child_type_id) { - .Void => return, - .Bool => ptr.* = (try self.deserializeInt(u1)) > 0, - .Float, .Int => ptr.* = try self.deserializeInt(C), - .Struct => { - const info = @typeInfo(C).Struct; - - inline for (info.fields) |*field_info| { - const name = field_info.name; - const FieldType = field_info.field_type; - - if (FieldType == void or FieldType == u0) continue; - - //it doesn't make any sense to read pointers - if (comptime trait.is(.Pointer)(FieldType)) { - @compileError("Will not " ++ "read field " ++ name ++ " of struct " ++ - @typeName(C) ++ " because it " ++ "is of pointer-type " ++ - @typeName(FieldType) ++ "."); - } - - try self.deserializeInto(&@field(ptr, name)); - } - }, - .Union => { - const info = @typeInfo(C).Union; - if (info.tag_type) |TagType| { - //we avoid duplicate iteration over the enum tags - // by getting the int directly and casting it without - // safety. If it is bad, it will be caught anyway. - const TagInt = @TagType(TagType); - const tag = try self.deserializeInt(TagInt); - - inline for (info.fields) |field_info| { - if (@enumToInt(@field(TagType, field_info.name)) == tag) { - const name = field_info.name; - const FieldType = field_info.field_type; - ptr.* = @unionInit(C, name, undefined); - try self.deserializeInto(&@field(ptr, name)); - return; - } - } - //This is reachable if the enum data is bad - return error.InvalidEnumTag; - } - @compileError("Cannot meaningfully deserialize " ++ @typeName(C) ++ - " because it is an untagged union. Use a custom deserialize()."); - }, - .Optional => { - const OC = comptime meta.Child(C); - const exists = (try self.deserializeInt(u1)) > 0; - if (!exists) { - ptr.* = null; - return; - } - - ptr.* = @as(OC, undefined); //make it non-null so the following .? is guaranteed safe - const val_ptr = &ptr.*.?; - try self.deserializeInto(val_ptr); - }, - .Enum => { - var value = try self.deserializeInt(@TagType(C)); - ptr.* = try meta.intToEnum(C, value); - }, - else => { - @compileError("Cannot deserialize " ++ @tagName(child_type_id) ++ " types (unimplemented)."); - }, - } - } - }; -} - -pub fn deserializer( - comptime endian: builtin.Endian, - comptime packing: Packing, - in_stream: anytype, -) Deserializer(endian, packing, @TypeOf(in_stream)) { - return Deserializer(endian, packing, @TypeOf(in_stream)).init(in_stream); -} - -/// Creates a serializer that serializes types to any stream. -/// If `is_packed` is true, the data will be bit-packed into the stream. -/// Note that the you must call `serializer.flush()` when you are done -/// writing bit-packed data in order ensure any unwritten bits are committed. -/// If `is_packed` is false, data is packed to the smallest byte. In the case -/// of packed structs, the struct will written bit-packed and with the specified -/// endianess, after which data will resume being written at the next byte boundary. -/// Types may implement a custom serialization routine with a -/// function named `serialize` in the form of: -/// ``` -/// pub fn serialize(self: Self, serializer: anytype) !void -/// ``` -/// which will be called when the serializer is used to serialize that type. It will -/// pass a const pointer to the type instance to be serialized and a pointer -/// to the serializer struct. -pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime OutStreamType: type) type { - return struct { - out_stream: if (packing == .Bit) io.BitOutStream(endian, OutStreamType) else OutStreamType, - - const Self = @This(); - pub const Error = OutStreamType.Error; - - pub fn init(out_stream: OutStreamType) Self { - return Self{ - .out_stream = switch (packing) { - .Bit => io.bitOutStream(endian, out_stream), - .Byte => out_stream, - }, - }; - } - - /// Flushes any unwritten bits to the stream - pub fn flush(self: *Self) Error!void { - if (packing == .Bit) return self.out_stream.flushBits(); - } - - fn serializeInt(self: *Self, value: anytype) Error!void { - const T = @TypeOf(value); - comptime assert(trait.is(.Int)(T) or trait.is(.Float)(T)); - - const t_bit_count = comptime meta.bitCount(T); - const u8_bit_count = comptime meta.bitCount(u8); - - const U = std.meta.Int(.unsigned, t_bit_count); - const Log2U = math.Log2Int(U); - const int_size = (t_bit_count + 7) / 8; - - const u_value = @bitCast(U, value); - - if (packing == .Bit) return self.out_stream.writeBits(u_value, t_bit_count); - - var buffer: [int_size]u8 = undefined; - if (int_size == 1) buffer[0] = u_value; - - for (buffer) |*byte, i| { - const idx = switch (endian) { - .Big => int_size - i - 1, - .Little => i, - }; - const shift = @intCast(Log2U, idx * u8_bit_count); - const v = u_value >> shift; - byte.* = if (t_bit_count < u8_bit_count) v else @truncate(u8, v); - } - - try self.out_stream.writeAll(&buffer); - } - - /// Serializes the passed value into the stream - pub fn serialize(self: *Self, value: anytype) Error!void { - const T = comptime @TypeOf(value); - - if (comptime trait.isIndexable(T)) { - for (value) |v| - try self.serialize(v); - return; - } - - //custom serializer: fn(self: Self, serializer: anytype) !void - if (comptime trait.hasFn("serialize")(T)) return T.serialize(value, self); - - if (comptime trait.isPacked(T) and packing != .Bit) { - var packed_serializer = Serializer(endian, .Bit, OutStreamType).init(self.out_stream); - try packed_serializer.serialize(value); - try packed_serializer.flush(); - return; - } - - switch (@typeInfo(T)) { - .Void => return, - .Bool => try self.serializeInt(@as(u1, @boolToInt(value))), - .Float, .Int => try self.serializeInt(value), - .Struct => { - const info = @typeInfo(T); - - inline for (info.Struct.fields) |*field_info| { - const name = field_info.name; - const FieldType = field_info.field_type; - - if (FieldType == void or FieldType == u0) continue; - - //It doesn't make sense to write pointers - if (comptime trait.is(.Pointer)(FieldType)) { - @compileError("Will not " ++ "serialize field " ++ name ++ - " of struct " ++ @typeName(T) ++ " because it " ++ - "is of pointer-type " ++ @typeName(FieldType) ++ "."); - } - try self.serialize(@field(value, name)); - } - }, - .Union => { - const info = @typeInfo(T).Union; - if (info.tag_type) |TagType| { - const active_tag = meta.activeTag(value); - try self.serialize(active_tag); - //This inline loop is necessary because active_tag is a runtime - // value, but @field requires a comptime value. Our alternative - // is to check each field for a match - inline for (info.fields) |field_info| { - if (@field(TagType, field_info.name) == active_tag) { - const name = field_info.name; - const FieldType = field_info.field_type; - try self.serialize(@field(value, name)); - return; - } - } - unreachable; - } - @compileError("Cannot meaningfully serialize " ++ @typeName(T) ++ - " because it is an untagged union. Use a custom serialize()."); - }, - .Optional => { - if (value == null) { - try self.serializeInt(@as(u1, @boolToInt(false))); - return; - } - try self.serializeInt(@as(u1, @boolToInt(true))); - - const OC = comptime meta.Child(T); - const val_ptr = &value.?; - try self.serialize(val_ptr.*); - }, - .Enum => { - try self.serializeInt(@enumToInt(value)); - }, - else => @compileError("Cannot serialize " ++ @tagName(@typeInfo(T)) ++ " types (unimplemented)."), - } - } - }; -} - -pub fn serializer( - comptime endian: builtin.Endian, - comptime packing: Packing, - out_stream: anytype, -) Serializer(endian, packing, @TypeOf(out_stream)) { - return Serializer(endian, packing, @TypeOf(out_stream)).init(out_stream); -} - -fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packing: io.Packing) !void { - @setEvalBranchQuota(1500); - //@NOTE: if this test is taking too long, reduce the maximum tested bitsize - const max_test_bitsize = 128; - - const total_bytes = comptime blk: { - var bytes = 0; - comptime var i = 0; - while (i <= max_test_bitsize) : (i += 1) bytes += (i / 8) + @boolToInt(i % 8 > 0); - break :blk bytes * 2; - }; - - var data_mem: [total_bytes]u8 = undefined; - var out = io.fixedBufferStream(&data_mem); - var _serializer = serializer(endian, packing, out.outStream()); - - var in = io.fixedBufferStream(&data_mem); - var _deserializer = deserializer(endian, packing, in.reader()); - - comptime var i = 0; - inline while (i <= max_test_bitsize) : (i += 1) { - const U = std.meta.Int(.unsigned, i); - const S = std.meta.Int(.signed, i); - try _serializer.serializeInt(@as(U, i)); - if (i != 0) try _serializer.serializeInt(@as(S, -1)) else try _serializer.serialize(@as(S, 0)); - } - try _serializer.flush(); - - i = 0; - inline while (i <= max_test_bitsize) : (i += 1) { - const U = std.meta.Int(.unsigned, i); - const S = std.meta.Int(.signed, i); - const x = try _deserializer.deserializeInt(U); - const y = try _deserializer.deserializeInt(S); - testing.expect(x == @as(U, i)); - if (i != 0) testing.expect(y == @as(S, -1)) else testing.expect(y == 0); - } - - const u8_bit_count = comptime meta.bitCount(u8); - //0 + 1 + 2 + ... n = (n * (n + 1)) / 2 - //and we have each for unsigned and signed, so * 2 - const total_bits = (max_test_bitsize * (max_test_bitsize + 1)); - const extra_packed_byte = @boolToInt(total_bits % u8_bit_count > 0); - const total_packed_bytes = (total_bits / u8_bit_count) + extra_packed_byte; - - testing.expect(in.pos == if (packing == .Bit) total_packed_bytes else total_bytes); - - //Verify that empty error set works with serializer. - //deserializer is covered by FixedBufferStream - var null_serializer = io.serializer(endian, packing, std.io.null_out_stream); - try null_serializer.serialize(data_mem[0..]); - try null_serializer.flush(); -} - -test "Serializer/Deserializer Int" { - try testIntSerializerDeserializer(.Big, .Byte); - try testIntSerializerDeserializer(.Little, .Byte); - // TODO these tests are disabled due to tripping an LLVM assertion - // https://github.com/ziglang/zig/issues/2019 - //try testIntSerializerDeserializer(builtin.Endian.Big, true); - //try testIntSerializerDeserializer(builtin.Endian.Little, true); -} - -fn testIntSerializerDeserializerInfNaN( - comptime endian: builtin.Endian, - comptime packing: io.Packing, -) !void { - const mem_size = (16 * 2 + 32 * 2 + 64 * 2 + 128 * 2) / comptime meta.bitCount(u8); - var data_mem: [mem_size]u8 = undefined; - - var out = io.fixedBufferStream(&data_mem); - var _serializer = serializer(endian, packing, out.outStream()); - - var in = io.fixedBufferStream(&data_mem); - var _deserializer = deserializer(endian, packing, in.reader()); - - //@TODO: isInf/isNan not currently implemented for f128. - try _serializer.serialize(std.math.nan(f16)); - try _serializer.serialize(std.math.inf(f16)); - try _serializer.serialize(std.math.nan(f32)); - try _serializer.serialize(std.math.inf(f32)); - try _serializer.serialize(std.math.nan(f64)); - try _serializer.serialize(std.math.inf(f64)); - //try serializer.serialize(std.math.nan(f128)); - //try serializer.serialize(std.math.inf(f128)); - const nan_check_f16 = try _deserializer.deserialize(f16); - const inf_check_f16 = try _deserializer.deserialize(f16); - const nan_check_f32 = try _deserializer.deserialize(f32); - _deserializer.alignToByte(); - const inf_check_f32 = try _deserializer.deserialize(f32); - const nan_check_f64 = try _deserializer.deserialize(f64); - const inf_check_f64 = try _deserializer.deserialize(f64); - //const nan_check_f128 = try deserializer.deserialize(f128); - //const inf_check_f128 = try deserializer.deserialize(f128); - testing.expect(std.math.isNan(nan_check_f16)); - testing.expect(std.math.isInf(inf_check_f16)); - testing.expect(std.math.isNan(nan_check_f32)); - testing.expect(std.math.isInf(inf_check_f32)); - testing.expect(std.math.isNan(nan_check_f64)); - testing.expect(std.math.isInf(inf_check_f64)); - //expect(std.math.isNan(nan_check_f128)); - //expect(std.math.isInf(inf_check_f128)); -} - -test "Serializer/Deserializer Int: Inf/NaN" { - try testIntSerializerDeserializerInfNaN(.Big, .Byte); - try testIntSerializerDeserializerInfNaN(.Little, .Byte); - try testIntSerializerDeserializerInfNaN(.Big, .Bit); - try testIntSerializerDeserializerInfNaN(.Little, .Bit); -} - -fn testAlternateSerializer(self: anytype, _serializer: anytype) !void { - try _serializer.serialize(self.f_f16); -} - -fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing: io.Packing) !void { - const ColorType = enum(u4) { - RGB8 = 1, - RA16 = 2, - R32 = 3, - }; - - const TagAlign = union(enum(u32)) { - A: u8, - B: u8, - C: u8, - }; - - const Color = union(ColorType) { - RGB8: struct { - r: u8, - g: u8, - b: u8, - a: u8, - }, - RA16: struct { - r: u16, - a: u16, - }, - R32: u32, - }; - - const PackedStruct = packed struct { - f_i3: i3, - f_u2: u2, - }; - - //to test custom serialization - const Custom = struct { - f_f16: f16, - f_unused_u32: u32, - - pub fn deserialize(self: *@This(), _deserializer: anytype) !void { - try _deserializer.deserializeInto(&self.f_f16); - self.f_unused_u32 = 47; - } - - pub const serialize = testAlternateSerializer; - }; - - const MyStruct = struct { - f_i3: i3, - f_u8: u8, - f_tag_align: TagAlign, - f_u24: u24, - f_i19: i19, - f_void: void, - f_f32: f32, - f_f128: f128, - f_packed_0: PackedStruct, - f_i7arr: [10]i7, - f_of64n: ?f64, - f_of64v: ?f64, - f_color_type: ColorType, - f_packed_1: PackedStruct, - f_custom: Custom, - f_color: Color, - }; - - const my_inst = MyStruct{ - .f_i3 = -1, - .f_u8 = 8, - .f_tag_align = TagAlign{ .B = 148 }, - .f_u24 = 24, - .f_i19 = 19, - .f_void = {}, - .f_f32 = 32.32, - .f_f128 = 128.128, - .f_packed_0 = PackedStruct{ .f_i3 = -1, .f_u2 = 2 }, - .f_i7arr = [10]i7{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, - .f_of64n = null, - .f_of64v = 64.64, - .f_color_type = ColorType.R32, - .f_packed_1 = PackedStruct{ .f_i3 = 1, .f_u2 = 1 }, - .f_custom = Custom{ .f_f16 = 38.63, .f_unused_u32 = 47 }, - .f_color = Color{ .R32 = 123822 }, - }; - - var data_mem: [@sizeOf(MyStruct)]u8 = undefined; - var out = io.fixedBufferStream(&data_mem); - var _serializer = serializer(endian, packing, out.outStream()); - - var in = io.fixedBufferStream(&data_mem); - var _deserializer = deserializer(endian, packing, in.reader()); - - try _serializer.serialize(my_inst); - - const my_copy = try _deserializer.deserialize(MyStruct); - testing.expect(meta.eql(my_copy, my_inst)); -} - -test "Serializer/Deserializer generic" { - try testSerializerDeserializer(builtin.Endian.Big, .Byte); - try testSerializerDeserializer(builtin.Endian.Little, .Byte); - try testSerializerDeserializer(builtin.Endian.Big, .Bit); - try testSerializerDeserializer(builtin.Endian.Little, .Bit); -} - -fn testBadData(comptime endian: builtin.Endian, comptime packing: io.Packing) !void { - const E = enum(u14) { - One = 1, - Two = 2, - }; - - const A = struct { - e: E, - }; - - const C = union(E) { - One: u14, - Two: f16, - }; - - var data_mem: [4]u8 = undefined; - var out = io.fixedBufferStream(&data_mem); - var _serializer = serializer(endian, packing, out.outStream()); - - var in = io.fixedBufferStream(&data_mem); - var _deserializer = deserializer(endian, packing, in.reader()); - - try _serializer.serialize(@as(u14, 3)); - testing.expectError(error.InvalidEnumTag, _deserializer.deserialize(A)); - out.pos = 0; - try _serializer.serialize(@as(u14, 3)); - try _serializer.serialize(@as(u14, 88)); - testing.expectError(error.InvalidEnumTag, _deserializer.deserialize(C)); -} - -test "Deserializer bad data" { - try testBadData(.Big, .Byte); - try testBadData(.Little, .Byte); - try testBadData(.Big, .Bit); - try testBadData(.Little, .Bit); -} diff --git a/lib/std/io/stream_source.zig b/lib/std/io/stream_source.zig index 3bfe0d2e64..df0d6cd352 100644 --- a/lib/std/io/stream_source.zig +++ b/lib/std/io/stream_source.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -9,7 +9,7 @@ const testing = std.testing; /// Provides `io.Reader`, `io.Writer`, and `io.SeekableStream` for in-memory buffers as /// well as files. -/// For memory sources, if the supplied byte buffer is const, then `io.OutStream` is not available. +/// For memory sources, if the supplied byte buffer is const, then `io.Writer` is not available. /// The error set of the stream functions is the error set of the corresponding file functions. pub const StreamSource = union(enum) { buffer: io.FixedBufferStream([]u8), @@ -22,11 +22,7 @@ pub const StreamSource = union(enum) { pub const GetSeekPosError = std.fs.File.GetPosError; pub const Reader = io.Reader(*StreamSource, ReadError, read); - /// Deprecated: use `Reader` - pub const InStream = Reader; pub const Writer = io.Writer(*StreamSource, WriteError, write); - /// Deprecated: use `Writer` - pub const OutStream = Writer; pub const SeekableStream = io.SeekableStream( *StreamSource, SeekError, @@ -89,20 +85,10 @@ pub const StreamSource = union(enum) { return .{ .context = self }; } - /// Deprecated: use `reader` - pub fn inStream(self: *StreamSource) InStream { - return .{ .context = self }; - } - pub fn writer(self: *StreamSource) Writer { return .{ .context = self }; } - /// Deprecated: use `writer` - pub fn outStream(self: *StreamSource) OutStream { - return .{ .context = self }; - } - pub fn seekableStream(self: *StreamSource) SeekableStream { return .{ .context = self }; } diff --git a/lib/std/io/test.zig b/lib/std/io/test.zig index 584369966b..9fdef0de1d 100644 --- a/lib/std/io/test.zig +++ b/lib/std/io/test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -30,8 +30,8 @@ test "write a file, read it, then delete it" { var file = try tmp.dir.createFile(tmp_file_name, .{}); defer file.close(); - var buf_stream = io.bufferedOutStream(file.outStream()); - const st = buf_stream.outStream(); + var buf_stream = io.bufferedWriter(file.writer()); + const st = buf_stream.writer(); try st.print("begin", .{}); try st.writeAll(data[0..]); try st.print("end", .{}); @@ -72,7 +72,7 @@ test "BitStreams with File Stream" { var file = try tmp.dir.createFile(tmp_file_name, .{}); defer file.close(); - var bit_stream = io.bitOutStream(builtin.endian, file.outStream()); + var bit_stream = io.bitWriter(builtin.endian, file.writer()); try bit_stream.writeBits(@as(u2, 1), 1); try bit_stream.writeBits(@as(u5, 2), 2); diff --git a/lib/std/io/writer.zig b/lib/std/io/writer.zig index 770cd5f0fa..0a9edb425a 100644 --- a/lib/std/io/writer.zig +++ b/lib/std/io/writer.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/json.zig b/lib/std/json.zig index ac1047d1a9..f9fc371049 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -246,7 +246,7 @@ pub const StreamingParser = struct { // Only call this function to generate array/object final state. pub fn fromInt(x: anytype) State { debug.assert(x == 0 or x == 1); - const T = @TagType(State); + const T = std.meta.Tag(State); return @intToEnum(State, @intCast(T, x)); } }; @@ -1138,7 +1138,7 @@ pub const TokenStream = struct { } }; -fn checkNext(p: *TokenStream, id: std.meta.TagType(Token)) void { +fn checkNext(p: *TokenStream, id: std.meta.Tag(Token)) void { const token = (p.next() catch unreachable).?; debug.assert(std.meta.activeTag(token) == id); } @@ -1255,6 +1255,7 @@ pub const Value = union(enum) { Bool: bool, Integer: i64, Float: f64, + NumberString: []const u8, String: []const u8, Array: Array, Object: ObjectMap, @@ -1269,6 +1270,7 @@ pub const Value = union(enum) { .Bool => |inner| try stringify(inner, options, out_stream), .Integer => |inner| try stringify(inner, options, out_stream), .Float => |inner| try stringify(inner, options, out_stream), + .NumberString => |inner| try out_stream.writeAll(inner), .String => |inner| try stringify(inner, options, out_stream), .Array => |inner| try stringify(inner.items, options, out_stream), .Object => |inner| { @@ -1323,31 +1325,37 @@ test "Value.jsonStringify" { { var buffer: [10]u8 = undefined; var fbs = std.io.fixedBufferStream(&buffer); - try @as(Value, .Null).jsonStringify(.{}, fbs.outStream()); + try @as(Value, .Null).jsonStringify(.{}, fbs.writer()); testing.expectEqualSlices(u8, fbs.getWritten(), "null"); } { var buffer: [10]u8 = undefined; var fbs = std.io.fixedBufferStream(&buffer); - try (Value{ .Bool = true }).jsonStringify(.{}, fbs.outStream()); + try (Value{ .Bool = true }).jsonStringify(.{}, fbs.writer()); testing.expectEqualSlices(u8, fbs.getWritten(), "true"); } { var buffer: [10]u8 = undefined; var fbs = std.io.fixedBufferStream(&buffer); - try (Value{ .Integer = 42 }).jsonStringify(.{}, fbs.outStream()); + try (Value{ .Integer = 42 }).jsonStringify(.{}, fbs.writer()); testing.expectEqualSlices(u8, fbs.getWritten(), "42"); } { var buffer: [10]u8 = undefined; var fbs = std.io.fixedBufferStream(&buffer); - try (Value{ .Float = 42 }).jsonStringify(.{}, fbs.outStream()); + try (Value{ .NumberString = "43" }).jsonStringify(.{}, fbs.writer()); + testing.expectEqualSlices(u8, fbs.getWritten(), "43"); + } + { + var buffer: [10]u8 = undefined; + var fbs = std.io.fixedBufferStream(&buffer); + try (Value{ .Float = 42 }).jsonStringify(.{}, fbs.writer()); testing.expectEqualSlices(u8, fbs.getWritten(), "4.2e+01"); } { var buffer: [10]u8 = undefined; var fbs = std.io.fixedBufferStream(&buffer); - try (Value{ .String = "weeee" }).jsonStringify(.{}, fbs.outStream()); + try (Value{ .String = "weeee" }).jsonStringify(.{}, fbs.writer()); testing.expectEqualSlices(u8, fbs.getWritten(), "\"weeee\""); } { @@ -1356,11 +1364,11 @@ test "Value.jsonStringify" { var vals = [_]Value{ .{ .Integer = 1 }, .{ .Integer = 2 }, - .{ .Integer = 3 }, + .{ .NumberString = "3" }, }; try (Value{ .Array = Array.fromOwnedSlice(undefined, &vals), - }).jsonStringify(.{}, fbs.outStream()); + }).jsonStringify(.{}, fbs.writer()); testing.expectEqualSlices(u8, fbs.getWritten(), "[1,2,3]"); } { @@ -1369,11 +1377,70 @@ test "Value.jsonStringify" { var obj = ObjectMap.init(testing.allocator); defer obj.deinit(); try obj.putNoClobber("a", .{ .String = "b" }); - try (Value{ .Object = obj }).jsonStringify(.{}, fbs.outStream()); + try (Value{ .Object = obj }).jsonStringify(.{}, fbs.writer()); testing.expectEqualSlices(u8, fbs.getWritten(), "{\"a\":\"b\"}"); } } +/// parse tokens from a stream, returning `false` if they do not decode to `value` +fn parsesTo(comptime T: type, value: T, tokens: *TokenStream, options: ParseOptions) !bool { + // TODO: should be able to write this function to not require an allocator + const tmp = try parse(T, tokens, options); + defer parseFree(T, tmp, options); + + return parsedEqual(tmp, value); +} + +/// Returns if a value returned by `parse` is deep-equal to another value +fn parsedEqual(a: anytype, b: @TypeOf(a)) bool { + switch (@typeInfo(@TypeOf(a))) { + .Optional => { + if (a == null and b == null) return true; + if (a == null or b == null) return false; + return parsedEqual(a.?, b.?); + }, + .Union => |unionInfo| { + if (info.tag_type) |UnionTag| { + const tag_a = std.meta.activeTag(a); + const tag_b = std.meta.activeTag(b); + if (tag_a != tag_b) return false; + + inline for (info.fields) |field_info| { + if (@field(UnionTag, field_info.name) == tag_a) { + return parsedEqual(@field(a, field_info.name), @field(b, field_info.name)); + } + } + return false; + } else { + unreachable; + } + }, + .Array => { + for (a) |e, i| + if (!parsedEqual(e, b[i])) return false; + return true; + }, + .Struct => |info| { + inline for (info.fields) |field_info| { + if (!parsedEqual(@field(a, field_info.name), @field(b, field_info.name))) return false; + } + return true; + }, + .Pointer => |ptrInfo| switch (ptrInfo.size) { + .One => return parsedEqual(a.*, b.*), + .Slice => { + if (a.len != b.len) return false; + for (a) |e, i| + if (!parsedEqual(e, b[i])) return false; + return true; + }, + .Many, .C => unreachable, + }, + else => return a == b, + } + unreachable; +} + pub const ParseOptions = struct { allocator: ?*Allocator = null, @@ -1454,6 +1521,8 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: // Parsing some types won't have OutOfMemory in their // error-sets, for the condition to be valid, merge it in. if (@as(@TypeOf(err) || error{OutOfMemory}, err) == error.OutOfMemory) return err; + // Bubble up AllocatorRequired, as it indicates missing option + if (@as(@TypeOf(err) || error{AllocatorRequired}, err) == error.AllocatorRequired) return err; // otherwise continue through the `inline for` } } @@ -1471,7 +1540,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: var fields_seen = [_]bool{false} ** structInfo.fields.len; errdefer { inline for (structInfo.fields) |field, i| { - if (fields_seen[i]) { + if (fields_seen[i] and !field.is_comptime) { parseFree(field.field_type, @field(r, field.name), options); } } @@ -1504,7 +1573,13 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: parseFree(field.field_type, @field(r, field.name), options); } } - @field(r, field.name) = try parse(field.field_type, tokens, options); + if (field.is_comptime) { + if (!try parsesTo(field.field_type, field.default_value.?, tokens, options)) { + return error.UnexpectedValue; + } + } else { + @field(r, field.name) = try parse(field.field_type, tokens, options); + } fields_seen[i] = true; found = true; break; @@ -1518,7 +1593,9 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: inline for (structInfo.fields) |field, i| { if (!fields_seen[i]) { if (field.default_value) |default| { - @field(r, field.name) = default; + if (!field.is_comptime) { + @field(r, field.name) = default; + } } else { return error.MissingField; } @@ -1553,7 +1630,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: const source_slice = stringToken.slice(tokens.slice, tokens.i - 1); switch (stringToken.escapes) { .None => mem.copy(u8, &r, source_slice), - .Some => try unescapeString(&r, source_slice), + .Some => try unescapeValidString(&r, source_slice), } return r; }, @@ -1600,7 +1677,7 @@ fn parseInternal(comptime T: type, token: Token, tokens: *TokenStream, options: .Some => |some_escapes| { const output = try allocator.alloc(u8, stringToken.decodedLength()); errdefer allocator.free(output); - try unescapeString(output, source_slice); + try unescapeValidString(output, source_slice); return output; }, } @@ -1731,18 +1808,6 @@ test "parse into tagged union" { testing.expectEqual(T{ .float = 1.5 }, try parse(T, &TokenStream.init("1.5"), ParseOptions{})); } - { // if union matches string member, fails with NoUnionMembersMatched rather than AllocatorRequired - // Note that this behaviour wasn't necessarily by design, but was - // what fell out of the implementation and may result in interesting - // API breakage if changed - const T = union(enum) { - int: i32, - float: f64, - string: []const u8, - }; - testing.expectError(error.NoUnionMembersMatched, parse(T, &TokenStream.init("\"foo\""), ParseOptions{})); - } - { // failing allocations should be bubbled up instantly without trying next member var fail_alloc = testing.FailingAllocator.init(testing.allocator, 0); const options = ParseOptions{ .allocator = &fail_alloc.allocator }; @@ -1772,6 +1837,25 @@ test "parse into tagged union" { } } +test "parse union bubbles up AllocatorRequired" { + { // string member first in union (and not matching) + const T = union(enum) { + string: []const u8, + int: i32, + }; + testing.expectError(error.AllocatorRequired, parse(T, &TokenStream.init("42"), ParseOptions{})); + } + + { // string member not first in union (and matching) + const T = union(enum) { + int: i32, + float: f64, + string: []const u8, + }; + testing.expectError(error.AllocatorRequired, parse(T, &TokenStream.init("\"foo\""), ParseOptions{})); + } +} + test "parseFree descends into tagged union" { var fail_alloc = testing.FailingAllocator.init(testing.allocator, 1); const options = ParseOptions{ .allocator = &fail_alloc.allocator }; @@ -1782,13 +1866,50 @@ test "parseFree descends into tagged union" { }; // use a string with unicode escape so we know result can't be a reference to global constant const r = try parse(T, &TokenStream.init("\"with\\u0105unicode\""), options); - testing.expectEqual(@TagType(T).string, @as(@TagType(T), r)); + testing.expectEqual(std.meta.Tag(T).string, @as(std.meta.Tag(T), r)); testing.expectEqualSlices(u8, "withąunicode", r.string); testing.expectEqual(@as(usize, 0), fail_alloc.deallocations); parseFree(T, r, options); testing.expectEqual(@as(usize, 1), fail_alloc.deallocations); } +test "parse with comptime field" { + { + const T = struct { + comptime a: i32 = 0, + b: bool, + }; + testing.expectEqual(T{ .a = 0, .b = true }, try parse(T, &TokenStream.init( + \\{ + \\ "a": 0, + \\ "b": true + \\} + ), ParseOptions{})); + } + + { // string comptime values currently require an allocator + const T = union(enum) { + foo: struct { + comptime kind: []const u8 = "boolean", + b: bool, + }, + bar: struct { + comptime kind: []const u8 = "float", + b: f64, + }, + }; + + const r = try std.json.parse(T, &std.json.TokenStream.init( + \\{ + \\ "kind": "float", + \\ "b": 1.0 + \\} + ), .{ + .allocator = std.testing.allocator, + }); + } +} + test "parse into struct with no fields" { const T = struct {}; testing.expectEqual(T{}, try parse(T, &TokenStream.init("{}"), ParseOptions{})); @@ -1897,7 +2018,7 @@ pub const Parser = struct { pub fn reset(p: *Parser) void { p.state = .Simple; - p.stack.shrink(0); + p.stack.shrinkRetainingCapacity(0); } pub fn parse(p: *Parser, input: []const u8) !ValueTree { @@ -2077,31 +2198,36 @@ pub const Parser = struct { } } - fn parseString(p: *Parser, allocator: *Allocator, s: std.meta.TagPayloadType(Token, Token.String), input: []const u8, i: usize) !Value { + fn parseString(p: *Parser, allocator: *Allocator, s: std.meta.TagPayload(Token, Token.String), input: []const u8, i: usize) !Value { const slice = s.slice(input, i); switch (s.escapes) { .None => return Value{ .String = if (p.copy_strings) try allocator.dupe(u8, slice) else slice }, .Some => |some_escapes| { const output = try allocator.alloc(u8, s.decodedLength()); errdefer allocator.free(output); - try unescapeString(output, slice); + try unescapeValidString(output, slice); return Value{ .String = output }; }, } } - fn parseNumber(p: *Parser, n: std.meta.TagPayloadType(Token, Token.Number), input: []const u8, i: usize) !Value { + fn parseNumber(p: *Parser, n: std.meta.TagPayload(Token, Token.Number), input: []const u8, i: usize) !Value { return if (n.is_integer) - Value{ .Integer = try std.fmt.parseInt(i64, n.slice(input, i), 10) } + Value{ + .Integer = std.fmt.parseInt(i64, n.slice(input, i), 10) catch |e| switch (e) { + error.Overflow => return Value{ .NumberString = n.slice(input, i) }, + error.InvalidCharacter => |err| return err, + }, + } else Value{ .Float = try std.fmt.parseFloat(f64, n.slice(input, i)) }; } }; -// Unescape a JSON string -// Only to be used on strings already validated by the parser -// (note the unreachable statements and lack of bounds checking) -pub fn unescapeString(output: []u8, input: []const u8) !void { +/// Unescape a JSON string +/// Only to be used on strings already validated by the parser +/// (note the unreachable statements and lack of bounds checking) +pub fn unescapeValidString(output: []u8, input: []const u8) !void { var inIndex: usize = 0; var outIndex: usize = 0; @@ -2180,7 +2306,8 @@ test "json.parser.dynamic" { \\ "Animated" : false, \\ "IDs": [116, 943, 234, 38793], \\ "ArrayOfObject": [{"n": "m"}], - \\ "double": 1.3412 + \\ "double": 1.3412, + \\ "LargeInt": 18446744073709551615 \\ } \\} ; @@ -2212,6 +2339,9 @@ test "json.parser.dynamic" { const double = image.Object.get("double").?; testing.expect(double.Float == 1.3412); + + const large_int = image.Object.get("LargeInt").?; + testing.expect(mem.eql(u8, large_int.NumberString, "18446744073709551615")); } test "import more json tests" { @@ -2223,7 +2353,7 @@ test "write json then parse it" { var out_buffer: [1000]u8 = undefined; var fixed_buffer_stream = std.io.fixedBufferStream(&out_buffer); - const out_stream = fixed_buffer_stream.outStream(); + const out_stream = fixed_buffer_stream.writer(); var jw = writeStream(out_stream, 4); try jw.beginObject(); @@ -2620,9 +2750,9 @@ pub fn stringify( } fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions) !void { - const ValidationOutStream = struct { + const ValidationWriter = struct { const Self = @This(); - pub const OutStream = std.io.OutStream(*Self, Error, write); + pub const Writer = std.io.Writer(*Self, Error, write); pub const Error = error{ TooMuchData, DifferentData, @@ -2634,7 +2764,7 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions return .{ .expected_remaining = exp }; } - pub fn outStream(self: *Self) OutStream { + pub fn writer(self: *Self) Writer { return .{ .context = self }; } @@ -2642,9 +2772,9 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions if (self.expected_remaining.len < bytes.len) { std.debug.warn( \\====== expected this output: ========= - \\{} + \\{s} \\======== instead found this: ========= - \\{} + \\{s} \\====================================== , .{ self.expected_remaining, @@ -2655,9 +2785,9 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions if (!mem.eql(u8, self.expected_remaining[0..bytes.len], bytes)) { std.debug.warn( \\====== expected this output: ========= - \\{} + \\{s} \\======== instead found this: ========= - \\{} + \\{s} \\====================================== , .{ self.expected_remaining[0..bytes.len], @@ -2670,8 +2800,8 @@ fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions } }; - var vos = ValidationOutStream.init(expected); - try stringify(value, options, vos.outStream()); + var vos = ValidationWriter.init(expected); + try stringify(value, options, vos.writer()); if (vos.expected_remaining.len > 0) return error.NotEnoughData; } diff --git a/lib/std/json/test.zig b/lib/std/json/test.zig index f1f351e84f..897e2e3364 100644 --- a/lib/std/json/test.zig +++ b/lib/std/json/test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/json/write_stream.zig b/lib/std/json/write_stream.zig index ee2c12154f..b4a8aed84c 100644 --- a/lib/std/json/write_stream.zig +++ b/lib/std/json/write_stream.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -238,7 +238,7 @@ pub fn writeStream( test "json write stream" { var out_buf: [1024]u8 = undefined; var slice_stream = std.io.fixedBufferStream(&out_buf); - const out = slice_stream.outStream(); + const out = slice_stream.writer(); var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator); defer arena_allocator.deinit(); diff --git a/lib/std/leb128.zig b/lib/std/leb128.zig index 2a8a6fc2ff..90a329545f 100644 --- a/lib/std/leb128.zig +++ b/lib/std/leb128.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/linked_list.zig b/lib/std/linked_list.zig index 870b823aac..2a6b58c8c9 100644 --- a/lib/std/linked_list.zig +++ b/lib/std/linked_list.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -62,7 +62,7 @@ pub fn SinglyLinkedList(comptime T: type) type { /// This operation is O(N). pub fn countChildren(node: *const Node) usize { var count: usize = 0; - var it: ?*const Node = node; + var it: ?*const Node = node.next; while (it) |n| : (it = n.next) { count += 1; } @@ -123,6 +123,8 @@ test "basic SinglyLinkedList test" { const L = SinglyLinkedList(u32); var list = L{}; + testing.expect(list.len() == 0); + var one = L.Node{ .data = 1 }; var two = L.Node{ .data = 2 }; var three = L.Node{ .data = 3 }; @@ -135,6 +137,8 @@ test "basic SinglyLinkedList test" { two.insertAfter(&three); // {1, 2, 3, 5} three.insertAfter(&four); // {1, 2, 3, 4, 5} + testing.expect(list.len() == 5); + // Traverse forwards. { var it = list.first; diff --git a/lib/std/log.zig b/lib/std/log.zig index 0cc2b54452..215e611bc1 100644 --- a/lib/std/log.zig +++ b/lib/std/log.zig @@ -1,11 +1,8 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -const std = @import("std.zig"); -const builtin = std.builtin; -const root = @import("root"); //! std.log is a standardized interface for logging which allows for the logging //! of programs and libraries using this interface to be formatted and filtered @@ -77,6 +74,10 @@ const root = @import("root"); //! [err] (nice_library): Something went very wrong, sorry //! ``` +const std = @import("std.zig"); +const builtin = std.builtin; +const root = @import("root"); + pub const Level = enum { /// Emergency: a condition that cannot be handled, usually followed by a /// panic. diff --git a/lib/std/macho.zig b/lib/std/macho.zig index ec0d23cd92..6785abffca 100644 --- a/lib/std/macho.zig +++ b/lib/std/macho.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -1257,6 +1257,51 @@ pub const VM_PROT_WRITE: vm_prot_t = 0x2; /// VM execute permission pub const VM_PROT_EXECUTE: vm_prot_t = 0x4; +// The following are used to encode rebasing information +pub const REBASE_TYPE_POINTER: u8 = 1; +pub const REBASE_TYPE_TEXT_ABSOLUTE32: u8 = 2; +pub const REBASE_TYPE_TEXT_PCREL32: u8 = 3; + +pub const REBASE_OPCODE_MASK: u8 = 0xF0; +pub const REBASE_IMMEDIATE_MASK: u8 = 0x0F; +pub const REBASE_OPCODE_DONE: u8 = 0x00; +pub const REBASE_OPCODE_SET_TYPE_IMM: u8 = 0x10; +pub const REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: u8 = 0x20; +pub const REBASE_OPCODE_ADD_ADDR_ULEB: u8 = 0x30; +pub const REBASE_OPCODE_ADD_ADDR_IMM_SCALED: u8 = 0x40; +pub const REBASE_OPCODE_DO_REBASE_IMM_TIMES: u8 = 0x50; +pub const REBASE_OPCODE_DO_REBASE_ULEB_TIMES: u8 = 0x60; +pub const REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB: u8 = 0x70; +pub const REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB: u8 = 0x80; + +// The following are used to encode binding information +pub const BIND_TYPE_POINTER: u8 = 1; +pub const BIND_TYPE_TEXT_ABSOLUTE32: u8 = 2; +pub const BIND_TYPE_TEXT_PCREL32: u8 = 3; + +pub const BIND_SPECIAL_DYLIB_SELF: i8 = 0; +pub const BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE: i8 = -1; +pub const BIND_SPECIAL_DYLIB_FLAT_LOOKUP: i8 = -2; + +pub const BIND_SYMBOL_FLAGS_WEAK_IMPORT: u8 = 0x1; +pub const BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION: u8 = 0x8; + +pub const BIND_OPCODE_MASK: u8 = 0xf0; +pub const BIND_IMMEDIATE_MASK: u8 = 0x0f; +pub const BIND_OPCODE_DONE: u8 = 0x00; +pub const BIND_OPCODE_SET_DYLIB_ORDINAL_IMM: u8 = 0x10; +pub const BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB: u8 = 0x20; +pub const BIND_OPCODE_SET_DYLIB_SPECIAL_IMM: u8 = 0x30; +pub const BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: u8 = 0x40; +pub const BIND_OPCODE_SET_TYPE_IMM: u8 = 0x50; +pub const BIND_OPCODE_SET_ADDEND_SLEB: u8 = 0x60; +pub const BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB: u8 = 0x70; +pub const BIND_OPCODE_ADD_ADDR_ULEB: 0x80; +pub const BIND_OPCODE_DO_BIND: u8 = 0x90; +pub const BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB: u8 = 0xa0; +pub const BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED: u8 = 0xb0; +pub const BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB: u8 = xc0; + pub const reloc_type_x86_64 = packed enum(u4) { /// for absolute addresses X86_64_RELOC_UNSIGNED = 0, @@ -1289,6 +1334,41 @@ pub const reloc_type_x86_64 = packed enum(u4) { X86_64_RELOC_TLV, }; +pub const reloc_type_arm64 = packed enum(u4) { + /// For pointers. + ARM64_RELOC_UNSIGNED = 0, + + /// Must be followed by a ARM64_RELOC_UNSIGNED. + ARM64_RELOC_SUBTRACTOR, + + /// A B/BL instruction with 26-bit displacement. + ARM64_RELOC_BRANCH26, + + /// Pc-rel distance to page of target. + ARM64_RELOC_PAGE21, + + /// Offset within page, scaled by r_length. + ARM64_RELOC_PAGEOFF12, + + /// Pc-rel distance to page of GOT slot. + ARM64_RELOC_GOT_LOAD_PAGE21, + + /// Offset within page of GOT slot, scaled by r_length. + ARM64_RELOC_GOT_LOAD_PAGEOFF12, + + /// For pointers to GOT slots. + ARM64_RELOC_POINTER_TO_GOT, + + /// Pc-rel distance to page of TLVP slot. + ARM64_RELOC_TLVP_LOAD_PAGE21, + + /// Offset within page of TLVP slot, scaled by r_length. + ARM64_RELOC_TLVP_LOAD_PAGEOFF12, + + /// Must be followed by PAGE21 or PAGEOFF12. + ARM64_RELOC_ADDEND, +}; + /// This symbol is a reference to an external non-lazy (data) symbol. pub const REFERENCE_FLAG_UNDEFINED_NON_LAZY: u16 = 0x0; @@ -1333,7 +1413,7 @@ pub const N_WEAK_DEF: u16 = 0x80; /// This bit is only available in .o files (MH_OBJECT filetype) pub const N_SYMBOL_RESOLVER: u16 = 0x100; -// The following are used on the flags byte of a terminal node // in the export information. +// The following are used on the flags byte of a terminal node in the export information. pub const EXPORT_SYMBOL_FLAGS_KIND_MASK: u8 = 0x03; pub const EXPORT_SYMBOL_FLAGS_KIND_REGULAR: u8 = 0x00; pub const EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL: u8 = 0x01; diff --git a/lib/std/math.zig b/lib/std/math.zig index a51cac6e7d..6e7c5c0915 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -278,7 +278,7 @@ pub const Complex = complex.Complex; pub const big = @import("math/big.zig"); -test "" { +test { std.testing.refAllDecls(@This()); } @@ -415,6 +415,7 @@ pub fn mul(comptime T: type, a: T, b: T) (error{Overflow}!T) { } pub fn add(comptime T: type, a: T, b: T) (error{Overflow}!T) { + if (T == comptime_int) return a + b; var answer: T = undefined; return if (@addWithOverflow(T, a, b, &answer)) error.Overflow else answer; } @@ -1070,16 +1071,52 @@ test "std.math.log2_int_ceil" { testing.expect(log2_int_ceil(u32, 10) == 4); } +///Cast a value to a different type. If the value doesn't fit in, or can't be perfectly represented by, +///the new type, it will be converted to the closest possible representation. pub fn lossyCast(comptime T: type, value: anytype) T { - switch (@typeInfo(@TypeOf(value))) { - .Int => return @intToFloat(T, value), - .Float => return @floatCast(T, value), - .ComptimeInt => return @as(T, value), - .ComptimeFloat => return @as(T, value), - else => @compileError("bad type"), + switch (@typeInfo(T)) { + .Float => { + switch (@typeInfo(@TypeOf(value))) { + .Int => return @intToFloat(T, value), + .Float => return @floatCast(T, value), + .ComptimeInt => return @as(T, value), + .ComptimeFloat => return @as(T, value), + else => @compileError("bad type"), + } + }, + .Int => { + switch (@typeInfo(@TypeOf(value))) { + .Int, .ComptimeInt => { + if (value > maxInt(T)) { + return @as(T, maxInt(T)); + } else if (value < minInt(T)) { + return @as(T, minInt(T)); + } else { + return @intCast(T, value); + } + }, + .Float, .ComptimeFloat => { + if (value > maxInt(T)) { + return @as(T, maxInt(T)); + } else if (value < minInt(T)) { + return @as(T, minInt(T)); + } else { + return @floatToInt(T, value); + } + }, + else => @compileError("bad type"), + } + }, + else => @compileError("bad result type"), } } +test "math.lossyCast" { + testing.expect(lossyCast(i16, 70000.0) == @as(i16, 32767)); + testing.expect(lossyCast(u32, @as(i16, -255)) == @as(u32, 0)); + testing.expect(lossyCast(i9, @as(u32, 200)) == @as(i9, 200)); +} + test "math.f64_min" { const f64_min_u64 = 0x0010000000000000; const fmin: f64 = f64_min; diff --git a/lib/std/math/acos.zig b/lib/std/math/acos.zig index 0153fd6835..7f3d4bfe9b 100644 --- a/lib/std/math/acos.zig +++ b/lib/std/math/acos.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/acosh.zig b/lib/std/math/acosh.zig index 773b125bea..0993989d47 100644 --- a/lib/std/math/acosh.zig +++ b/lib/std/math/acosh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/asin.zig b/lib/std/math/asin.zig index 38602a76d2..c4fca95c10 100644 --- a/lib/std/math/asin.zig +++ b/lib/std/math/asin.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/asinh.zig b/lib/std/math/asinh.zig index 4dc0702a0a..a2c8ee3583 100644 --- a/lib/std/math/asinh.zig +++ b/lib/std/math/asinh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/atan.zig b/lib/std/math/atan.zig index 1608328579..59dda307cc 100644 --- a/lib/std/math/atan.zig +++ b/lib/std/math/atan.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/atan2.zig b/lib/std/math/atan2.zig index cb4c28e713..3ecabe9e31 100644 --- a/lib/std/math/atan2.zig +++ b/lib/std/math/atan2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/atanh.zig b/lib/std/math/atanh.zig index ffebc58ed4..87d92a9fa5 100644 --- a/lib/std/math/atanh.zig +++ b/lib/std/math/atanh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/big.zig b/lib/std/math/big.zig index 5e2073954c..8ae214c666 100644 --- a/lib/std/math/big.zig +++ b/lib/std/math/big.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -20,7 +20,7 @@ comptime { assert(limb_info.signedness == .unsigned); } -test "" { +test { _ = int; _ = Rational; _ = Limb; diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index dd0b925692..d1d7b33508 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -549,8 +549,8 @@ pub const Mutable = struct { return; } - const r_len = llshr(r.limbs[0..], a.limbs[0..a.limbs.len], shift); - r.len = a.limbs.len - (shift / limb_bits); + llshr(r.limbs[0..], a.limbs[0..a.limbs.len], shift); + r.normalize(a.limbs.len - (shift / limb_bits)); r.positive = a.positive; } @@ -607,7 +607,7 @@ pub const Mutable = struct { /// it will have the same length as it had when the function was called. pub fn gcd(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void { const prev_len = limbs_buffer.items.len; - defer limbs_buffer.shrink(prev_len); + defer limbs_buffer.shrinkRetainingCapacity(prev_len); const x_copy = if (rma.limbs.ptr == x.limbs.ptr) blk: { const start = limbs_buffer.items.len; try limbs_buffer.appendSlice(x.limbs); @@ -1348,7 +1348,9 @@ pub const Const = struct { /// Returns true if `a == 0`. pub fn eqZero(a: Const) bool { - return a.limbs.len == 1 and a.limbs[0] == 0; + var d: Limb = 0; + for (a.limbs) |limb| d |= limb; + return d == 0; } /// Returns true if `|a| == |b|`. @@ -2344,6 +2346,6 @@ fn fixedIntFromSignedDoubleLimb(A: SignedDoubleLimb, storage: []Limb) Mutable { }; } -test "" { +test { _ = @import("int_test.zig"); } diff --git a/lib/std/math/big/int_test.zig b/lib/std/math/big/int_test.zig index 1f4bd65974..179e55ff69 100644 --- a/lib/std/math/big/int_test.zig +++ b/lib/std/math/big/int_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -1287,6 +1287,12 @@ test "big.int shift-right multi" { try a.shiftRight(a, 67); testing.expect((try a.to(u64)) == 0x1fffe0001dddc222); + + try a.set(0xffff0000eeee1111dddd2222cccc3333); + try a.shiftRight(a, 63); + try a.shiftRight(a, 63); + try a.shiftRight(a, 2); + testing.expect(a.eqZero()); } test "big.int shift-left single" { diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index 8eb1d9f2b3..2299205e7b 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/cbrt.zig b/lib/std/math/cbrt.zig index c516cae73b..a876e0a9d1 100644 --- a/lib/std/math/cbrt.zig +++ b/lib/std/math/cbrt.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/ceil.zig b/lib/std/math/ceil.zig index 2f043300b1..d313475717 100644 --- a/lib/std/math/ceil.zig +++ b/lib/std/math/ceil.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex.zig b/lib/std/math/complex.zig index f9f13a1161..e046ed9fa9 100644 --- a/lib/std/math/complex.zig +++ b/lib/std/math/complex.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/abs.zig b/lib/std/math/complex/abs.zig index 228b56c286..609cdba5a7 100644 --- a/lib/std/math/complex/abs.zig +++ b/lib/std/math/complex/abs.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/acos.zig b/lib/std/math/complex/acos.zig index 47130c8a98..b7c43e9381 100644 --- a/lib/std/math/complex/acos.zig +++ b/lib/std/math/complex/acos.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/acosh.zig b/lib/std/math/complex/acosh.zig index 51626b10a4..d7d596e084 100644 --- a/lib/std/math/complex/acosh.zig +++ b/lib/std/math/complex/acosh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/arg.zig b/lib/std/math/complex/arg.zig index 43c1d93874..7c3b00bd5d 100644 --- a/lib/std/math/complex/arg.zig +++ b/lib/std/math/complex/arg.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/asin.zig b/lib/std/math/complex/asin.zig index 4911ccc2b2..0ed352b3b7 100644 --- a/lib/std/math/complex/asin.zig +++ b/lib/std/math/complex/asin.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/asinh.zig b/lib/std/math/complex/asinh.zig index e93a2dabd7..762a601fbf 100644 --- a/lib/std/math/complex/asinh.zig +++ b/lib/std/math/complex/asinh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/atan.zig b/lib/std/math/complex/atan.zig index e838751d73..af40c05a81 100644 --- a/lib/std/math/complex/atan.zig +++ b/lib/std/math/complex/atan.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/atanh.zig b/lib/std/math/complex/atanh.zig index f3d378315f..2c3708f57f 100644 --- a/lib/std/math/complex/atanh.zig +++ b/lib/std/math/complex/atanh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/conj.zig b/lib/std/math/complex/conj.zig index 159469da86..b79c7de6ca 100644 --- a/lib/std/math/complex/conj.zig +++ b/lib/std/math/complex/conj.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/cos.zig b/lib/std/math/complex/cos.zig index 2abfce58c6..66fd5b9b7b 100644 --- a/lib/std/math/complex/cos.zig +++ b/lib/std/math/complex/cos.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/cosh.zig b/lib/std/math/complex/cosh.zig index 0a6be49e3e..e43cd1d665 100644 --- a/lib/std/math/complex/cosh.zig +++ b/lib/std/math/complex/cosh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/exp.zig b/lib/std/math/complex/exp.zig index 156a947a32..eb738a6d88 100644 --- a/lib/std/math/complex/exp.zig +++ b/lib/std/math/complex/exp.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/ldexp.zig b/lib/std/math/complex/ldexp.zig index b1cf8a0e42..3ae0382fe3 100644 --- a/lib/std/math/complex/ldexp.zig +++ b/lib/std/math/complex/ldexp.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/log.zig b/lib/std/math/complex/log.zig index 88175d00cc..90124af2eb 100644 --- a/lib/std/math/complex/log.zig +++ b/lib/std/math/complex/log.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/pow.zig b/lib/std/math/complex/pow.zig index 30636dd10d..a6589262cd 100644 --- a/lib/std/math/complex/pow.zig +++ b/lib/std/math/complex/pow.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/proj.zig b/lib/std/math/complex/proj.zig index 67f087f8ba..42886d8263 100644 --- a/lib/std/math/complex/proj.zig +++ b/lib/std/math/complex/proj.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/sin.zig b/lib/std/math/complex/sin.zig index d5e2713b13..4288dbb1a1 100644 --- a/lib/std/math/complex/sin.zig +++ b/lib/std/math/complex/sin.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/sinh.zig b/lib/std/math/complex/sinh.zig index 8c8930c0ba..2861d99f9a 100644 --- a/lib/std/math/complex/sinh.zig +++ b/lib/std/math/complex/sinh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/sqrt.zig b/lib/std/math/complex/sqrt.zig index a01473a5ea..e03ed221eb 100644 --- a/lib/std/math/complex/sqrt.zig +++ b/lib/std/math/complex/sqrt.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/tan.zig b/lib/std/math/complex/tan.zig index 8d6e5da313..04d900bd99 100644 --- a/lib/std/math/complex/tan.zig +++ b/lib/std/math/complex/tan.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/complex/tanh.zig b/lib/std/math/complex/tanh.zig index cf82f04f41..19fda8d82f 100644 --- a/lib/std/math/complex/tanh.zig +++ b/lib/std/math/complex/tanh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/copysign.zig b/lib/std/math/copysign.zig index 1547382cbd..2804d10495 100644 --- a/lib/std/math/copysign.zig +++ b/lib/std/math/copysign.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/cos.zig b/lib/std/math/cos.zig index f8135e5d4f..21804a8e5e 100644 --- a/lib/std/math/cos.zig +++ b/lib/std/math/cos.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/cosh.zig b/lib/std/math/cosh.zig index c3736415d3..25d22057ef 100644 --- a/lib/std/math/cosh.zig +++ b/lib/std/math/cosh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/epsilon.zig b/lib/std/math/epsilon.zig index 3243b085ad..61758f1ee0 100644 --- a/lib/std/math/epsilon.zig +++ b/lib/std/math/epsilon.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/exp.zig b/lib/std/math/exp.zig index 87e1031a24..1156cc6c5a 100644 --- a/lib/std/math/exp.zig +++ b/lib/std/math/exp.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/exp2.zig b/lib/std/math/exp2.zig index 1c25504de9..155d10c7f1 100644 --- a/lib/std/math/exp2.zig +++ b/lib/std/math/exp2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/expm1.zig b/lib/std/math/expm1.zig index 1c22db342a..8389b01eb9 100644 --- a/lib/std/math/expm1.zig +++ b/lib/std/math/expm1.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/expo2.zig b/lib/std/math/expo2.zig index a81c9920e0..b88d4c2236 100644 --- a/lib/std/math/expo2.zig +++ b/lib/std/math/expo2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/fabs.zig b/lib/std/math/fabs.zig index f263bfbc58..d59d185b99 100644 --- a/lib/std/math/fabs.zig +++ b/lib/std/math/fabs.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/floor.zig b/lib/std/math/floor.zig index d28b5e102c..6e0b99f47c 100644 --- a/lib/std/math/floor.zig +++ b/lib/std/math/floor.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/fma.zig b/lib/std/math/fma.zig index 852bbe9d75..1b04e1aa18 100644 --- a/lib/std/math/fma.zig +++ b/lib/std/math/fma.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/frexp.zig b/lib/std/math/frexp.zig index 3f73c9eec3..5f7bafb494 100644 --- a/lib/std/math/frexp.zig +++ b/lib/std/math/frexp.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/hypot.zig b/lib/std/math/hypot.zig index f04a42d1d5..78aef476f9 100644 --- a/lib/std/math/hypot.zig +++ b/lib/std/math/hypot.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/ilogb.zig b/lib/std/math/ilogb.zig index a6fb031973..e43012b831 100644 --- a/lib/std/math/ilogb.zig +++ b/lib/std/math/ilogb.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/inf.zig b/lib/std/math/inf.zig index f2e0283e03..5011193e95 100644 --- a/lib/std/math/inf.zig +++ b/lib/std/math/inf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/isfinite.zig b/lib/std/math/isfinite.zig index 938c495d65..5266b918df 100644 --- a/lib/std/math/isfinite.zig +++ b/lib/std/math/isfinite.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/isinf.zig b/lib/std/math/isinf.zig index 2ecd9c2b9c..b7c3199f15 100644 --- a/lib/std/math/isinf.zig +++ b/lib/std/math/isinf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/isnan.zig b/lib/std/math/isnan.zig index fc58e7334c..498d181118 100644 --- a/lib/std/math/isnan.zig +++ b/lib/std/math/isnan.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/isnormal.zig b/lib/std/math/isnormal.zig index b9ff515bdc..6317535203 100644 --- a/lib/std/math/isnormal.zig +++ b/lib/std/math/isnormal.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/ln.zig b/lib/std/math/ln.zig index cb5c966ab8..e0ce32a7e1 100644 --- a/lib/std/math/ln.zig +++ b/lib/std/math/ln.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/log.zig b/lib/std/math/log.zig index 240ef759d1..ef4d4bbb97 100644 --- a/lib/std/math/log.zig +++ b/lib/std/math/log.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/log10.zig b/lib/std/math/log10.zig index 269bc1d228..719e0cf51d 100644 --- a/lib/std/math/log10.zig +++ b/lib/std/math/log10.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/log1p.zig b/lib/std/math/log1p.zig index c0ca027ffb..4eaee2c43f 100644 --- a/lib/std/math/log1p.zig +++ b/lib/std/math/log1p.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/log2.zig b/lib/std/math/log2.zig index 201364a8cf..c44672751e 100644 --- a/lib/std/math/log2.zig +++ b/lib/std/math/log2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/modf.zig b/lib/std/math/modf.zig index fe73f0ce75..390b3e4f49 100644 --- a/lib/std/math/modf.zig +++ b/lib/std/math/modf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/nan.zig b/lib/std/math/nan.zig index b8e3b517e2..98051b155a 100644 --- a/lib/std/math/nan.zig +++ b/lib/std/math/nan.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/pow.zig b/lib/std/math/pow.zig index d4ea8876cc..5c49c95865 100644 --- a/lib/std/math/pow.zig +++ b/lib/std/math/pow.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/powi.zig b/lib/std/math/powi.zig index 8846ee8833..e415b74d87 100644 --- a/lib/std/math/powi.zig +++ b/lib/std/math/powi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/round.zig b/lib/std/math/round.zig index 0855b11cbb..9167bcfc82 100644 --- a/lib/std/math/round.zig +++ b/lib/std/math/round.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/scalbn.zig b/lib/std/math/scalbn.zig index 7243084dd4..cf8ff9003d 100644 --- a/lib/std/math/scalbn.zig +++ b/lib/std/math/scalbn.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/signbit.zig b/lib/std/math/signbit.zig index defd02aa3a..9fb245c3c6 100644 --- a/lib/std/math/signbit.zig +++ b/lib/std/math/signbit.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/sin.zig b/lib/std/math/sin.zig index 0f30e6749f..d051e3f88a 100644 --- a/lib/std/math/sin.zig +++ b/lib/std/math/sin.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/sinh.zig b/lib/std/math/sinh.zig index d39c7ee002..16329a9108 100644 --- a/lib/std/math/sinh.zig +++ b/lib/std/math/sinh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/sqrt.zig b/lib/std/math/sqrt.zig index 54c2fff13a..38609115d8 100644 --- a/lib/std/math/sqrt.zig +++ b/lib/std/math/sqrt.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/tan.zig b/lib/std/math/tan.zig index b80e2fbb27..d0e8a0d4f8 100644 --- a/lib/std/math/tan.zig +++ b/lib/std/math/tan.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/tanh.zig b/lib/std/math/tanh.zig index 81df2aed35..c53f03122b 100644 --- a/lib/std/math/tanh.zig +++ b/lib/std/math/tanh.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/math/trunc.zig b/lib/std/math/trunc.zig index 935da85013..69c300efee 100644 --- a/lib/std/math/trunc.zig +++ b/lib/std/math/trunc.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 22e340810e..5f23a10401 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -991,6 +991,40 @@ test "mem.count" { testing.expect(count(u8, "owowowu", "owowu") == 1); } +/// Returns true if the haystack contains expected_count or more needles +/// needle.len must be > 0 +/// does not count overlapping needles +pub fn containsAtLeast(comptime T: type, haystack: []const T, expected_count: usize, needle: []const T) bool { + assert(needle.len > 0); + if (expected_count == 0) return true; + + var i: usize = 0; + var found: usize = 0; + + while (indexOfPos(T, haystack, i, needle)) |idx| { + i = idx + needle.len; + found += 1; + if (found == expected_count) return true; + } + return false; +} + +test "mem.containsAtLeast" { + testing.expect(containsAtLeast(u8, "aa", 0, "a")); + testing.expect(containsAtLeast(u8, "aa", 1, "a")); + testing.expect(containsAtLeast(u8, "aa", 2, "a")); + testing.expect(!containsAtLeast(u8, "aa", 3, "a")); + + testing.expect(containsAtLeast(u8, "radaradar", 1, "radar")); + testing.expect(!containsAtLeast(u8, "radaradar", 2, "radar")); + + testing.expect(containsAtLeast(u8, "radarradaradarradar", 3, "radar")); + testing.expect(!containsAtLeast(u8, "radarradaradarradar", 4, "radar")); + + testing.expect(containsAtLeast(u8, " radar radar ", 2, "radar")); + testing.expect(!containsAtLeast(u8, " radar radar ", 3, "radar")); +} + /// Reads an integer from memory with size equal to bytes.len. /// T specifies the return type, which must be large enough to store /// the result. @@ -1473,7 +1507,7 @@ pub fn joinZ(allocator: *Allocator, separator: []const u8, slices: []const []con } fn joinMaybeZ(allocator: *Allocator, separator: []const u8, slices: []const []const u8, zero: bool) ![]u8 { - if (slices.len == 0) return &[0]u8{}; + if (slices.len == 0) return if (zero) try allocator.dupe(u8, &[1]u8{0}) else &[0]u8{}; const total_len = blk: { var sum: usize = separator.len * (slices.len - 1); @@ -1501,6 +1535,11 @@ fn joinMaybeZ(allocator: *Allocator, separator: []const u8, slices: []const []co } test "mem.join" { + { + const str = try join(testing.allocator, ",", &[_][]const u8{}); + defer testing.allocator.free(str); + testing.expect(eql(u8, str, "")); + } { const str = try join(testing.allocator, ",", &[_][]const u8{ "a", "b", "c" }); defer testing.allocator.free(str); @@ -1519,6 +1558,12 @@ test "mem.join" { } test "mem.joinZ" { + { + const str = try joinZ(testing.allocator, ",", &[_][]const u8{}); + defer testing.allocator.free(str); + testing.expect(eql(u8, str, "")); + testing.expectEqual(str[str.len], 0); + } { const str = try joinZ(testing.allocator, ",", &[_][]const u8{ "a", "b", "c" }); defer testing.allocator.free(str); @@ -2402,3 +2447,46 @@ test "freeing empty string with null-terminated sentinel" { const empty_string = try dupeZ(testing.allocator, u8, ""); testing.allocator.free(empty_string); } + +/// Returns a slice with the given new alignment, +/// all other pointer attributes copied from `AttributeSource`. +fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: u29) type { + const info = @typeInfo(AttributeSource).Pointer; + return @Type(.{ + .Pointer = .{ + .size = .Slice, + .is_const = info.is_const, + .is_volatile = info.is_volatile, + .is_allowzero = info.is_allowzero, + .alignment = new_alignment, + .child = info.child, + .sentinel = null, + }, + }); +} + +/// Returns the largest slice in the given bytes that conforms to the new alignment, +/// or `null` if the given bytes contain no conforming address. +pub fn alignInBytes(bytes: []u8, comptime new_alignment: usize) ?[]align(new_alignment) u8 { + const begin_address = @ptrToInt(bytes.ptr); + const end_address = begin_address + bytes.len; + + const begin_address_aligned = mem.alignForward(begin_address, new_alignment); + const new_length = std.math.sub(usize, end_address, begin_address_aligned) catch |e| switch (e) { + error.Overflow => return null, + }; + const alignment_offset = begin_address_aligned - begin_address; + return @alignCast(new_alignment, bytes[alignment_offset .. alignment_offset + new_length]); +} + +/// Returns the largest sub-slice within the given slice that conforms to the new alignment, +/// or `null` if the given slice contains no conforming address. +pub fn alignInSlice(slice: anytype, comptime new_alignment: usize) ?AlignedSlice(@TypeOf(slice), new_alignment) { + const bytes = sliceAsBytes(slice); + const aligned_bytes = alignInBytes(bytes, new_alignment) orelse return null; + + const Element = @TypeOf(slice[0]); + const slice_length_bytes = aligned_bytes.len - (aligned_bytes.len % @sizeOf(Element)); + const aligned_slice = bytesAsSlice(Element, aligned_bytes[0..slice_length_bytes]); + return @alignCast(new_alignment, aligned_slice); +} diff --git a/lib/std/mem/Allocator.zig b/lib/std/mem/Allocator.zig index 4511acb275..6cc888fa10 100644 --- a/lib/std/mem/Allocator.zig +++ b/lib/std/mem/Allocator.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -146,12 +146,8 @@ fn moveBytes( assert(new_len > 0); const new_mem = try self.allocFn(self, new_len, new_alignment, len_align, return_address); @memcpy(new_mem.ptr, old_mem.ptr, math.min(new_len, old_mem.len)); - // TODO DISABLED TO AVOID BUGS IN TRANSLATE C - // TODO see also https://github.com/ziglang/zig/issues/4298 - // use './zig build test-translate-c' to reproduce, some of the symbols in the - // generated C code will be a sequence of 0xaa (the undefined value), meaning - // it is printing data that has been freed - //@memset(old_mem.ptr, undefined, old_mem.len); + // TODO https://github.com/ziglang/zig/issues/4298 + @memset(old_mem.ptr, undefined, old_mem.len); _ = self.shrinkBytes(old_mem, old_align, 0, 0, return_address); return new_mem; } diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 2cf7f6de81..7ec29dcd0e 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -9,6 +9,7 @@ const debug = std.debug; const mem = std.mem; const math = std.math; const testing = std.testing; +const root = @import("root"); pub const trait = @import("meta/trait.zig"); pub const TrailerFlags = @import("meta/trailer_flags.zig").TrailerFlags; @@ -486,19 +487,14 @@ test "std.meta.fields" { testing.expect(comptime uf[0].field_type == u8); } -pub fn fieldInfo(comptime T: type, comptime field_name: []const u8) switch (@typeInfo(T)) { +pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) { .Struct => TypeInfo.StructField, .Union => TypeInfo.UnionField, .ErrorSet => TypeInfo.Error, .Enum => TypeInfo.EnumField, else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"), } { - inline for (comptime fields(T)) |field| { - if (comptime mem.eql(u8, field.name, field_name)) - return field; - } - - @compileError("'" ++ @typeName(T) ++ "' has no field '" ++ field_name ++ "'"); + return fields(T)[@enumToInt(field)]; } test "std.meta.fieldInfo" { @@ -513,10 +509,10 @@ test "std.meta.fieldInfo" { a: u8, }; - const e1f = comptime fieldInfo(E1, "A"); - const e2f = comptime fieldInfo(E2, "A"); - const sf = comptime fieldInfo(S1, "a"); - const uf = comptime fieldInfo(U1, "a"); + const e1f = fieldInfo(E1, .A); + const e2f = fieldInfo(E2, .A); + const sf = fieldInfo(S1, .a); + const uf = fieldInfo(U1, .a); testing.expect(mem.eql(u8, e1f.name, "A")); testing.expect(mem.eql(u8, e2f.name, "A")); @@ -538,9 +534,7 @@ pub fn fieldNames(comptime T: type) *const [fields(T).len][]const u8 { } test "std.meta.fieldNames" { - const E1 = enum { - A, B - }; + const E1 = enum { A, B }; const E2 = error{A}; const S1 = struct { a: u8, @@ -567,15 +561,55 @@ test "std.meta.fieldNames" { testing.expectEqualSlices(u8, u1names[1], "b"); } -pub fn TagType(comptime T: type) type { +pub fn FieldEnum(comptime T: type) type { + const fieldInfos = fields(T); + var enumFields: [fieldInfos.len]std.builtin.TypeInfo.EnumField = undefined; + var decls = [_]std.builtin.TypeInfo.Declaration{}; + inline for (fieldInfos) |field, i| { + enumFields[i] = .{ + .name = field.name, + .value = i, + }; + } + return @Type(.{ + .Enum = .{ + .layout = .Auto, + .tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1), + .fields = &enumFields, + .decls = &decls, + .is_exhaustive = true, + }, + }); +} + +fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) void { + // TODO: https://github.com/ziglang/zig/issues/7419 + // testing.expectEqual(@typeInfo(expected).Enum, @typeInfo(actual).Enum); + testing.expectEqual(@typeInfo(expected).Enum.layout, @typeInfo(actual).Enum.layout); + testing.expectEqual(@typeInfo(expected).Enum.tag_type, @typeInfo(actual).Enum.tag_type); + comptime testing.expectEqualSlices(std.builtin.TypeInfo.EnumField, @typeInfo(expected).Enum.fields, @typeInfo(actual).Enum.fields); + comptime testing.expectEqualSlices(std.builtin.TypeInfo.Declaration, @typeInfo(expected).Enum.decls, @typeInfo(actual).Enum.decls); + testing.expectEqual(@typeInfo(expected).Enum.is_exhaustive, @typeInfo(actual).Enum.is_exhaustive); +} + +test "std.meta.FieldEnum" { + expectEqualEnum(enum { a }, FieldEnum(struct { a: u8 })); + expectEqualEnum(enum { a, b, c }, FieldEnum(struct { a: u8, b: void, c: f32 })); + expectEqualEnum(enum { a, b, c }, FieldEnum(union { a: u8, b: void, c: f32 })); +} + +// Deprecated: use Tag +pub const TagType = Tag; + +pub fn Tag(comptime T: type) type { return switch (@typeInfo(T)) { .Enum => |info| info.tag_type, - .Union => |info| if (info.tag_type) |Tag| Tag else null, + .Union => |info| info.tag_type orelse @compileError(@typeName(T) ++ " has no tag type"), else => @compileError("expected enum or union type, found '" ++ @typeName(T) ++ "'"), }; } -test "std.meta.TagType" { +test "std.meta.Tag" { const E = enum(u8) { C = 33, D, @@ -585,14 +619,14 @@ test "std.meta.TagType" { D: u16, }; - testing.expect(TagType(E) == u8); - testing.expect(TagType(U) == E); + testing.expect(Tag(E) == u8); + testing.expect(Tag(U) == E); } ///Returns the active tag of a tagged union -pub fn activeTag(u: anytype) @TagType(@TypeOf(u)) { +pub fn activeTag(u: anytype) Tag(@TypeOf(u)) { const T = @TypeOf(u); - return @as(@TagType(T), u); + return @as(Tag(T), u); } test "std.meta.activeTag" { @@ -613,13 +647,15 @@ test "std.meta.activeTag" { testing.expect(activeTag(u) == UE.Float); } +const TagPayloadType = TagPayload; + ///Given a tagged union type, and an enum, return the type of the union /// field corresponding to the enum tag. -pub fn TagPayloadType(comptime U: type, tag: @TagType(U)) type { +pub fn TagPayload(comptime U: type, tag: Tag(U)) type { testing.expect(trait.is(.Union)(U)); const info = @typeInfo(U).Union; - const tag_info = @typeInfo(@TagType(U)).Enum; + const tag_info = @typeInfo(Tag(U)).Enum; inline for (info.fields) |field_info| { if (comptime mem.eql(u8, field_info.name, @tagName(tag))) @@ -629,14 +665,14 @@ pub fn TagPayloadType(comptime U: type, tag: @TagType(U)) type { unreachable; } -test "std.meta.TagPayloadType" { +test "std.meta.TagPayload" { const Event = union(enum) { Moved: struct { from: i32, to: i32, }, }; - const MovedEvent = TagPayloadType(Event, Event.Moved); + const MovedEvent = TagPayload(Event, Event.Moved); var e: Event = undefined; testing.expect(MovedEvent == @TypeOf(e.Moved)); } @@ -661,13 +697,13 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool { } }, .Union => |info| { - if (info.tag_type) |Tag| { + if (info.tag_type) |UnionTag| { const tag_a = activeTag(a); const tag_b = activeTag(b); if (tag_a != tag_b) return false; inline for (info.fields) |field_info| { - if (@field(Tag, field_info.name) == tag_a) { + if (@field(UnionTag, field_info.name) == tag_a) { return eql(@field(a, field_info.name), @field(b, field_info.name)); } } @@ -789,9 +825,9 @@ test "intToEnum with error return" { pub const IntToEnumError = error{InvalidEnumTag}; -pub fn intToEnum(comptime Tag: type, tag_int: anytype) IntToEnumError!Tag { - inline for (@typeInfo(Tag).Enum.fields) |f| { - const this_tag_value = @field(Tag, f.name); +pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag { + inline for (@typeInfo(EnumTag).Enum.fields) |f| { + const this_tag_value = @field(EnumTag, f.name); if (tag_int == @enumToInt(this_tag_value)) { return this_tag_value; } @@ -946,9 +982,60 @@ test "std.meta.cast" { /// Given a value returns its size as C's sizeof operator would. /// This is for translate-c and is not intended for general use. pub fn sizeof(target: anytype) usize { - switch (@typeInfo(@TypeOf(target))) { - .Type => return @sizeOf(target), - .Float, .Int, .Struct, .Union, .Enum => return @sizeOf(@TypeOf(target)), + const T: type = if (@TypeOf(target) == type) target else @TypeOf(target); + switch (@typeInfo(T)) { + .Float, .Int, .Struct, .Union, .Enum, .Array, .Bool, .Vector => return @sizeOf(T), + .Fn => { + // sizeof(main) returns 1, sizeof(&main) returns pointer size. + // We cannot distinguish those types in Zig, so use pointer size. + return @sizeOf(T); + }, + .Null => return @sizeOf(*c_void), + .Void => { + // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC. + return 1; + }, + .Opaque => { + if (T == c_void) { + // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC. + return 1; + } else { + @compileError("Cannot use C sizeof on opaque type " ++ @typeName(T)); + } + }, + .Optional => |opt| { + if (@typeInfo(opt.child) == .Pointer) { + return sizeof(opt.child); + } else { + @compileError("Cannot use C sizeof on non-pointer optional " ++ @typeName(T)); + } + }, + .Pointer => |ptr| { + if (ptr.size == .Slice) { + @compileError("Cannot use C sizeof on slice type " ++ @typeName(T)); + } + // for strings, sizeof("a") returns 2. + // normal pointer decay scenarios from C are handled + // in the .Array case above, but strings remain literals + // and are therefore always pointers, so they need to be + // specially handled here. + if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .Array) { + const array_info = @typeInfo(ptr.child).Array; + if ((array_info.child == u8 or array_info.child == u16) and + array_info.sentinel != null and + array_info.sentinel.? == 0) + { + // length of the string plus one for the null terminator. + return (array_info.len + 1) * @sizeOf(array_info.child); + } + } + // When zero sized pointers are removed, this case will no + // longer be reachable and can be deleted. + if (@sizeOf(T) == 0) { + return @sizeOf(*c_void); + } + return @sizeOf(T); + }, .ComptimeFloat => return @sizeOf(f64), // TODO c_double #3999 .ComptimeInt => { // TODO to get the correct result we have to translate @@ -958,7 +1045,7 @@ pub fn sizeof(target: anytype) usize { // TODO test if target fits in int, long or long long return @sizeOf(c_int); }, - else => @compileError("TODO implement std.meta.sizeof for type " ++ @typeName(@TypeOf(target))), + else => @compileError("std.meta.sizeof does not support type " ++ @typeName(T)), } } @@ -966,12 +1053,45 @@ test "sizeof" { const E = extern enum(c_int) { One, _ }; const S = extern struct { a: u32 }; + const ptr_size = @sizeOf(*c_void); + testing.expect(sizeof(u32) == 4); testing.expect(sizeof(@as(u32, 2)) == 4); testing.expect(sizeof(2) == @sizeOf(c_int)); + + testing.expect(sizeof(2.0) == @sizeOf(f64)); + testing.expect(sizeof(E) == @sizeOf(c_int)); testing.expect(sizeof(E.One) == @sizeOf(c_int)); + testing.expect(sizeof(S) == 4); + + testing.expect(sizeof([_]u32{ 4, 5, 6 }) == 12); + testing.expect(sizeof([3]u32) == 12); + testing.expect(sizeof([3:0]u32) == 16); + testing.expect(sizeof(&[_]u32{ 4, 5, 6 }) == ptr_size); + + testing.expect(sizeof(*u32) == ptr_size); + testing.expect(sizeof([*]u32) == ptr_size); + testing.expect(sizeof([*c]u32) == ptr_size); + testing.expect(sizeof(?*u32) == ptr_size); + testing.expect(sizeof(?[*]u32) == ptr_size); + testing.expect(sizeof(*c_void) == ptr_size); + testing.expect(sizeof(*void) == ptr_size); + testing.expect(sizeof(null) == ptr_size); + + testing.expect(sizeof("foobar") == 7); + testing.expect(sizeof(&[_:0]u16{ 'f', 'o', 'o', 'b', 'a', 'r' }) == 14); + testing.expect(sizeof(*const [4:0]u8) == 5); + testing.expect(sizeof(*[4:0]u8) == ptr_size); + testing.expect(sizeof([*]const [4:0]u8) == ptr_size); + testing.expect(sizeof(*const *const [4:0]u8) == ptr_size); + testing.expect(sizeof(*const [4]u8) == ptr_size); + + testing.expect(sizeof(sizeof) == @sizeOf(@TypeOf(sizeof))); + + testing.expect(sizeof(void) == 1); + testing.expect(sizeof(c_void) == 1); } /// For a given function type, returns a tuple type which fields will @@ -1085,3 +1205,10 @@ test "Tuple" { TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 })); TupleTester.assertTuple(.{ u32, f16, []const u8, void }, Tuple(&[_]type{ u32, f16, []const u8, void })); } + +/// TODO: https://github.com/ziglang/zig/issues/425 +pub fn globalOption(comptime name: []const u8, comptime T: type) ?T { + if (!@hasDecl(root, name)) + return null; + return @as(T, @field(root, name)); +} diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig index 505afdb3c8..1697e9fe43 100644 --- a/lib/std/meta/trailer_flags.zig +++ b/lib/std/meta/trailer_flags.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -21,20 +21,7 @@ pub fn TrailerFlags(comptime Fields: type) type { pub const Int = meta.Int(.unsigned, bit_count); pub const bit_count = @typeInfo(Fields).Struct.fields.len; - pub const FieldEnum = blk: { - comptime var fields: [bit_count]TypeInfo.EnumField = undefined; - inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| - fields[i] = .{ .name = struct_field.name, .value = i }; - break :blk @Type(.{ - .Enum = .{ - .layout = .Auto, - .tag_type = std.math.IntFittingRange(0, bit_count - 1), - .fields = &fields, - .decls = &[_]TypeInfo.Declaration{}, - .is_exhaustive = true, - }, - }); - }; + pub const FieldEnum = std.meta.FieldEnum(Fields); pub const InitStruct = blk: { comptime var fields: [bit_count]TypeInfo.StructField = undefined; @@ -135,10 +122,7 @@ pub fn TrailerFlags(comptime Fields: type) type { } pub fn Field(comptime field: FieldEnum) type { - inline for (@typeInfo(Fields).Struct.fields) |field_info, i| { - if (i == @enumToInt(field)) - return field_info.field_type; - } + return @typeInfo(Fields).Struct.fields[@enumToInt(field)].field_type; } pub fn sizeInBytes(self: Self) usize { @@ -162,7 +146,7 @@ test "TrailerFlags" { b: bool, c: u64, }); - testing.expectEqual(u2, @TagType(Flags.FieldEnum)); + testing.expectEqual(u2, meta.Tag(Flags.FieldEnum)); var flags = Flags.init(.{ .b = true, diff --git a/lib/std/meta/trait.zig b/lib/std/meta/trait.zig index eb294a857c..e67f9b9bc4 100644 --- a/lib/std/meta/trait.zig +++ b/lib/std/meta/trait.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -298,6 +298,20 @@ pub fn isNumber(comptime T: type) bool { }; } +pub fn isIntegerNumber(comptime T: type) bool { + return switch (@typeInfo(T)) { + .Int, .ComptimeInt => true, + else => false, + }; +} + +pub fn isFloatingNumber(comptime T: type) bool { + return switch (@typeInfo(T)) { + .Float, .ComptimeFloat => true, + else => false, + }; +} + test "std.meta.trait.isNumber" { const NotANumber = struct { number: u8, @@ -476,15 +490,20 @@ pub fn hasUniqueRepresentation(comptime T: type) bool { else => return false, // TODO can we know if it's true for some of these types ? .AnyFrame, - .Bool, .BoundFn, .Enum, .ErrorSet, .Fn, - .Int, // TODO check that it is still true - .Pointer, => return true, + .Bool => return false, + + // The padding bits are undefined. + .Int => |info| return (info.bits % 8) == 0 and + (info.bits == 0 or std.math.isPowerOfTwo(info.bits)), + + .Pointer => |info| return info.size != .Slice, + .Array => |info| return comptime hasUniqueRepresentation(info.child), .Struct => |info| { @@ -525,14 +544,49 @@ test "std.meta.trait.hasUniqueRepresentation" { testing.expect(hasUniqueRepresentation(TestStruct3)); - testing.expect(hasUniqueRepresentation(i1)); - testing.expect(hasUniqueRepresentation(u2)); - testing.expect(hasUniqueRepresentation(i3)); - testing.expect(hasUniqueRepresentation(u4)); - testing.expect(hasUniqueRepresentation(i5)); - testing.expect(hasUniqueRepresentation(u6)); - testing.expect(hasUniqueRepresentation(i7)); - testing.expect(hasUniqueRepresentation(u8)); - testing.expect(hasUniqueRepresentation(i9)); - testing.expect(hasUniqueRepresentation(u10)); + const TestStruct4 = struct { a: []const u8 }; + + testing.expect(!hasUniqueRepresentation(TestStruct4)); + + const TestStruct5 = struct { a: TestStruct4 }; + + testing.expect(!hasUniqueRepresentation(TestStruct5)); + + const TestUnion1 = packed union { + a: u32, + b: u16, + }; + + testing.expect(!hasUniqueRepresentation(TestUnion1)); + + const TestUnion2 = extern union { + a: u32, + b: u16, + }; + + testing.expect(!hasUniqueRepresentation(TestUnion2)); + + const TestUnion3 = union { + a: u32, + b: u16, + }; + + testing.expect(!hasUniqueRepresentation(TestUnion3)); + + const TestUnion4 = union(enum) { + a: u32, + b: u16, + }; + + testing.expect(!hasUniqueRepresentation(TestUnion4)); + + inline for ([_]type{ i0, u8, i16, u32, i64 }) |T| { + testing.expect(hasUniqueRepresentation(T)); + } + inline for ([_]type{ i1, u9, i17, u33, i24 }) |T| { + testing.expect(!hasUniqueRepresentation(T)); + } + + testing.expect(!hasUniqueRepresentation([]u8)); + testing.expect(!hasUniqueRepresentation([]const u8)); } diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig new file mode 100644 index 0000000000..3306fd3ef0 --- /dev/null +++ b/lib/std/multi_array_list.zig @@ -0,0 +1,446 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. +const std = @import("std.zig"); +const assert = std.debug.assert; +const meta = std.meta; +const mem = std.mem; +const Allocator = mem.Allocator; + +pub fn MultiArrayList(comptime S: type) type { + return struct { + bytes: [*]align(@alignOf(S)) u8 = undefined, + len: usize = 0, + capacity: usize = 0, + + pub const Elem = S; + + pub const Field = meta.FieldEnum(S); + + pub const Slice = struct { + /// This array is indexed by the field index which can be obtained + /// by using @enumToInt() on the Field enum + ptrs: [fields.len][*]u8, + len: usize, + capacity: usize, + + pub fn items(self: Slice, comptime field: Field) []FieldType(field) { + const byte_ptr = self.ptrs[@enumToInt(field)]; + const F = FieldType(field); + const casted_ptr = @ptrCast([*]F, @alignCast(@alignOf(F), byte_ptr)); + return casted_ptr[0..self.len]; + } + + pub fn toMultiArrayList(self: Slice) Self { + if (self.ptrs.len == 0) { + return .{}; + } + const unaligned_ptr = self.ptrs[sizes.fields[0]]; + const aligned_ptr = @alignCast(@alignOf(S), unaligned_ptr); + const casted_ptr = @ptrCast([*]align(@alignOf(S)) u8, aligned_ptr); + return .{ + .bytes = casted_ptr, + .len = self.len, + .capacity = self.capacity, + }; + } + + pub fn deinit(self: *Slice, gpa: *Allocator) void { + var other = self.toMultiArrayList(); + other.deinit(gpa); + self.* = undefined; + } + }; + + const Self = @This(); + + const fields = meta.fields(S); + /// `sizes.bytes` is an array of @sizeOf each S field. Sorted by alignment, descending. + /// `sizes.fields` is an array mapping from `sizes.bytes` array index to field index. + const sizes = blk: { + const Data = struct { + size: usize, + size_index: usize, + alignment: usize, + }; + var data: [fields.len]Data = undefined; + for (fields) |field_info, i| { + data[i] = .{ + .size = @sizeOf(field_info.field_type), + .size_index = i, + .alignment = field_info.alignment, + }; + } + const Sort = struct { + fn lessThan(trash: *i32, lhs: Data, rhs: Data) bool { + return lhs.alignment >= rhs.alignment; + } + }; + var trash: i32 = undefined; // workaround for stage1 compiler bug + std.sort.sort(Data, &data, &trash, Sort.lessThan); + var sizes_bytes: [fields.len]usize = undefined; + var field_indexes: [fields.len]usize = undefined; + for (data) |elem, i| { + sizes_bytes[i] = elem.size; + field_indexes[i] = elem.size_index; + } + break :blk .{ + .bytes = sizes_bytes, + .fields = field_indexes, + }; + }; + + /// Release all allocated memory. + pub fn deinit(self: *Self, gpa: *Allocator) void { + gpa.free(self.allocatedBytes()); + self.* = undefined; + } + + /// The caller owns the returned memory. Empties this MultiArrayList. + pub fn toOwnedSlice(self: *Self) Slice { + const result = self.slice(); + self.* = .{}; + return result; + } + + pub fn slice(self: Self) Slice { + var result: Slice = .{ + .ptrs = undefined, + .len = self.len, + .capacity = self.capacity, + }; + var ptr: [*]u8 = self.bytes; + for (sizes.bytes) |field_size, i| { + result.ptrs[sizes.fields[i]] = ptr; + ptr += field_size * self.capacity; + } + return result; + } + + pub fn items(self: Self, comptime field: Field) []FieldType(field) { + return self.slice().items(field); + } + + /// Overwrite one array element with new data. + pub fn set(self: *Self, index: usize, elem: S) void { + const slices = self.slice(); + inline for (fields) |field_info, i| { + slices.items(@intToEnum(Field, i))[index] = @field(elem, field_info.name); + } + } + + /// Obtain all the data for one array element. + pub fn get(self: *Self, index: usize) S { + const slices = self.slice(); + var result: S = undefined; + inline for (fields) |field_info, i| { + @field(elem, field_info.name) = slices.items(@intToEnum(Field, i))[index]; + } + return result; + } + + /// Extend the list by 1 element. Allocates more memory as necessary. + pub fn append(self: *Self, gpa: *Allocator, elem: S) !void { + try self.ensureCapacity(gpa, self.len + 1); + self.appendAssumeCapacity(elem); + } + + /// Extend the list by 1 element, but asserting `self.capacity` + /// is sufficient to hold an additional item. + pub fn appendAssumeCapacity(self: *Self, elem: S) void { + assert(self.len < self.capacity); + self.len += 1; + self.set(self.len - 1, elem); + } + + /// Adjust the list's length to `new_len`. + /// Does not initialize added items, if any. + pub fn resize(self: *Self, gpa: *Allocator, new_len: usize) !void { + try self.ensureCapacity(gpa, new_len); + self.len = new_len; + } + + /// Attempt to reduce allocated capacity to `new_len`. + /// If `new_len` is greater than zero, this may fail to reduce the capacity, + /// but the data remains intact and the length is updated to new_len. + pub fn shrinkAndFree(self: *Self, gpa: *Allocator, new_len: usize) void { + if (new_len == 0) { + gpa.free(self.allocatedBytes()); + self.* = .{}; + return; + } + assert(new_len <= self.capacity); + assert(new_len <= self.len); + + const other_bytes = gpa.allocAdvanced( + u8, + @alignOf(S), + capacityInBytes(new_len), + .exact, + ) catch { + const self_slice = self.slice(); + inline for (fields) |field_info, i| { + const field = @intToEnum(Field, i); + const dest_slice = self_slice.items(field)[new_len..]; + const byte_count = dest_slice.len * @sizeOf(field_info.field_type); + // We use memset here for more efficient codegen in safety-checked, + // valgrind-enabled builds. Otherwise the valgrind client request + // will be repeated for every element. + @memset(@ptrCast([*]u8, dest_slice.ptr), undefined, byte_count); + } + self.len = new_len; + return; + }; + var other = Self{ + .bytes = other_bytes.ptr, + .capacity = new_len, + .len = new_len, + }; + self.len = new_len; + const self_slice = self.slice(); + const other_slice = other.slice(); + inline for (fields) |field_info, i| { + const field = @intToEnum(Field, i); + // TODO we should be able to use std.mem.copy here but it causes a + // test failure on aarch64 with -OReleaseFast + const src_slice = mem.sliceAsBytes(self_slice.items(field)); + const dst_slice = mem.sliceAsBytes(other_slice.items(field)); + @memcpy(dst_slice.ptr, src_slice.ptr, src_slice.len); + } + gpa.free(self.allocatedBytes()); + self.* = other; + } + + /// Reduce length to `new_len`. + /// Invalidates pointers to elements `items[new_len..]`. + /// Keeps capacity the same. + pub fn shrinkRetainingCapacity(self: *Self, new_len: usize) void { + self.len = new_len; + } + + /// Modify the array so that it can hold at least `new_capacity` items. + /// Implements super-linear growth to achieve amortized O(1) append operations. + /// Invalidates pointers if additional memory is needed. + pub fn ensureCapacity(self: *Self, gpa: *Allocator, new_capacity: usize) !void { + var better_capacity = self.capacity; + if (better_capacity >= new_capacity) return; + + while (true) { + better_capacity += better_capacity / 2 + 8; + if (better_capacity >= new_capacity) break; + } + + return self.setCapacity(gpa, better_capacity); + } + + /// Modify the array so that it can hold exactly `new_capacity` items. + /// Invalidates pointers if additional memory is needed. + /// `new_capacity` must be greater or equal to `len`. + pub fn setCapacity(self: *Self, gpa: *Allocator, new_capacity: usize) !void { + assert(new_capacity >= self.len); + const new_bytes = try gpa.allocAdvanced( + u8, + @alignOf(S), + capacityInBytes(new_capacity), + .exact, + ); + if (self.len == 0) { + self.bytes = new_bytes.ptr; + self.capacity = new_capacity; + return; + } + var other = Self{ + .bytes = new_bytes.ptr, + .capacity = new_capacity, + .len = self.len, + }; + const self_slice = self.slice(); + const other_slice = other.slice(); + inline for (fields) |field_info, i| { + const field = @intToEnum(Field, i); + // TODO we should be able to use std.mem.copy here but it causes a + // test failure on aarch64 with -OReleaseFast + const src_slice = mem.sliceAsBytes(self_slice.items(field)); + const dst_slice = mem.sliceAsBytes(other_slice.items(field)); + @memcpy(dst_slice.ptr, src_slice.ptr, src_slice.len); + } + gpa.free(self.allocatedBytes()); + self.* = other; + } + + fn capacityInBytes(capacity: usize) usize { + const sizes_vector: std.meta.Vector(sizes.bytes.len, usize) = sizes.bytes; + const capacity_vector = @splat(sizes.bytes.len, capacity); + return @reduce(.Add, capacity_vector * sizes_vector); + } + + fn allocatedBytes(self: Self) []align(@alignOf(S)) u8 { + return self.bytes[0..capacityInBytes(self.capacity)]; + } + + fn FieldType(field: Field) type { + return meta.fieldInfo(S, field).field_type; + } + }; +} + +test "basic usage" { + const testing = std.testing; + const ally = testing.allocator; + + const Foo = struct { + a: u32, + b: []const u8, + c: u8, + }; + + var list = MultiArrayList(Foo){}; + defer list.deinit(ally); + + try list.ensureCapacity(ally, 2); + + list.appendAssumeCapacity(.{ + .a = 1, + .b = "foobar", + .c = 'a', + }); + + list.appendAssumeCapacity(.{ + .a = 2, + .b = "zigzag", + .c = 'b', + }); + + testing.expectEqualSlices(u32, list.items(.a), &[_]u32{ 1, 2 }); + testing.expectEqualSlices(u8, list.items(.c), &[_]u8{ 'a', 'b' }); + + testing.expectEqual(@as(usize, 2), list.items(.b).len); + testing.expectEqualStrings("foobar", list.items(.b)[0]); + testing.expectEqualStrings("zigzag", list.items(.b)[1]); + + try list.append(ally, .{ + .a = 3, + .b = "fizzbuzz", + .c = 'c', + }); + + testing.expectEqualSlices(u32, list.items(.a), &[_]u32{ 1, 2, 3 }); + testing.expectEqualSlices(u8, list.items(.c), &[_]u8{ 'a', 'b', 'c' }); + + testing.expectEqual(@as(usize, 3), list.items(.b).len); + testing.expectEqualStrings("foobar", list.items(.b)[0]); + testing.expectEqualStrings("zigzag", list.items(.b)[1]); + testing.expectEqualStrings("fizzbuzz", list.items(.b)[2]); + + // Add 6 more things to force a capacity increase. + var i: usize = 0; + while (i < 6) : (i += 1) { + try list.append(ally, .{ + .a = @intCast(u32, 4 + i), + .b = "whatever", + .c = @intCast(u8, 'd' + i), + }); + } + + testing.expectEqualSlices( + u32, + &[_]u32{ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, + list.items(.a), + ); + testing.expectEqualSlices( + u8, + &[_]u8{ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' }, + list.items(.c), + ); + + list.shrinkAndFree(ally, 3); + + testing.expectEqualSlices(u32, list.items(.a), &[_]u32{ 1, 2, 3 }); + testing.expectEqualSlices(u8, list.items(.c), &[_]u8{ 'a', 'b', 'c' }); + + testing.expectEqual(@as(usize, 3), list.items(.b).len); + testing.expectEqualStrings("foobar", list.items(.b)[0]); + testing.expectEqualStrings("zigzag", list.items(.b)[1]); + testing.expectEqualStrings("fizzbuzz", list.items(.b)[2]); +} + +// This was observed to fail on aarch64 with LLVM 11, when the capacityInBytes +// function used the @reduce code path. +test "regression test for @reduce bug" { + const ally = std.testing.allocator; + var list = MultiArrayList(struct { + tag: std.zig.Token.Tag, + start: u32, + }){}; + defer list.deinit(ally); + + try list.ensureCapacity(ally, 20); + + try list.append(ally, .{ .tag = .keyword_const, .start = 0 }); + try list.append(ally, .{ .tag = .identifier, .start = 6 }); + try list.append(ally, .{ .tag = .equal, .start = 10 }); + try list.append(ally, .{ .tag = .builtin, .start = 12 }); + try list.append(ally, .{ .tag = .l_paren, .start = 19 }); + try list.append(ally, .{ .tag = .string_literal, .start = 20 }); + try list.append(ally, .{ .tag = .r_paren, .start = 25 }); + try list.append(ally, .{ .tag = .semicolon, .start = 26 }); + try list.append(ally, .{ .tag = .keyword_pub, .start = 29 }); + try list.append(ally, .{ .tag = .keyword_fn, .start = 33 }); + try list.append(ally, .{ .tag = .identifier, .start = 36 }); + try list.append(ally, .{ .tag = .l_paren, .start = 40 }); + try list.append(ally, .{ .tag = .r_paren, .start = 41 }); + try list.append(ally, .{ .tag = .identifier, .start = 43 }); + try list.append(ally, .{ .tag = .bang, .start = 51 }); + try list.append(ally, .{ .tag = .identifier, .start = 52 }); + try list.append(ally, .{ .tag = .l_brace, .start = 57 }); + try list.append(ally, .{ .tag = .identifier, .start = 63 }); + try list.append(ally, .{ .tag = .period, .start = 66 }); + try list.append(ally, .{ .tag = .identifier, .start = 67 }); + try list.append(ally, .{ .tag = .period, .start = 70 }); + try list.append(ally, .{ .tag = .identifier, .start = 71 }); + try list.append(ally, .{ .tag = .l_paren, .start = 75 }); + try list.append(ally, .{ .tag = .string_literal, .start = 76 }); + try list.append(ally, .{ .tag = .comma, .start = 113 }); + try list.append(ally, .{ .tag = .period, .start = 115 }); + try list.append(ally, .{ .tag = .l_brace, .start = 116 }); + try list.append(ally, .{ .tag = .r_brace, .start = 117 }); + try list.append(ally, .{ .tag = .r_paren, .start = 118 }); + try list.append(ally, .{ .tag = .semicolon, .start = 119 }); + try list.append(ally, .{ .tag = .r_brace, .start = 121 }); + try list.append(ally, .{ .tag = .eof, .start = 123 }); + + const tags = list.items(.tag); + std.testing.expectEqual(tags[1], .identifier); + std.testing.expectEqual(tags[2], .equal); + std.testing.expectEqual(tags[3], .builtin); + std.testing.expectEqual(tags[4], .l_paren); + std.testing.expectEqual(tags[5], .string_literal); + std.testing.expectEqual(tags[6], .r_paren); + std.testing.expectEqual(tags[7], .semicolon); + std.testing.expectEqual(tags[8], .keyword_pub); + std.testing.expectEqual(tags[9], .keyword_fn); + std.testing.expectEqual(tags[10], .identifier); + std.testing.expectEqual(tags[11], .l_paren); + std.testing.expectEqual(tags[12], .r_paren); + std.testing.expectEqual(tags[13], .identifier); + std.testing.expectEqual(tags[14], .bang); + std.testing.expectEqual(tags[15], .identifier); + std.testing.expectEqual(tags[16], .l_brace); + std.testing.expectEqual(tags[17], .identifier); + std.testing.expectEqual(tags[18], .period); + std.testing.expectEqual(tags[19], .identifier); + std.testing.expectEqual(tags[20], .period); + std.testing.expectEqual(tags[21], .identifier); + std.testing.expectEqual(tags[22], .l_paren); + std.testing.expectEqual(tags[23], .string_literal); + std.testing.expectEqual(tags[24], .comma); + std.testing.expectEqual(tags[25], .period); + std.testing.expectEqual(tags[26], .l_brace); + std.testing.expectEqual(tags[27], .r_brace); + std.testing.expectEqual(tags[28], .r_paren); + std.testing.expectEqual(tags[29], .semicolon); + std.testing.expectEqual(tags[30], .r_brace); + std.testing.expectEqual(tags[31], .eof); +} diff --git a/lib/std/mutex.zig b/lib/std/mutex.zig deleted file mode 100644 index fb54e04289..0000000000 --- a/lib/std/mutex.zig +++ /dev/null @@ -1,330 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -const std = @import("std.zig"); -const builtin = @import("builtin"); -const os = std.os; -const assert = std.debug.assert; -const windows = os.windows; -const testing = std.testing; -const SpinLock = std.SpinLock; -const ResetEvent = std.ResetEvent; - -/// Lock may be held only once. If the same thread tries to acquire -/// the same mutex twice, it deadlocks. This type supports static -/// initialization and is at most `@sizeOf(usize)` in size. When an -/// application is built in single threaded release mode, all the -/// functions are no-ops. In single threaded debug mode, there is -/// deadlock detection. -/// -/// Example usage: -/// var m = Mutex{}; -/// -/// const lock = m.acquire(); -/// defer lock.release(); -/// ... critical code -/// -/// Non-blocking: -/// if (m.tryAcquire) |lock| { -/// defer lock.release(); -/// // ... critical section -/// } else { -/// // ... lock not acquired -/// } -pub const Mutex = if (builtin.single_threaded) - Dummy -else if (builtin.os.tag == .windows) - WindowsMutex -else if (builtin.link_libc or builtin.os.tag == .linux) - // stack-based version of https://github.com/Amanieu/parking_lot/blob/master/core/src/word_lock.rs - struct { - state: usize = 0, - - /// number of times to spin trying to acquire the lock. - /// https://webkit.org/blog/6161/locking-in-webkit/ - const SPIN_COUNT = 40; - - const MUTEX_LOCK: usize = 1 << 0; - const QUEUE_LOCK: usize = 1 << 1; - const QUEUE_MASK: usize = ~(MUTEX_LOCK | QUEUE_LOCK); - - const Node = struct { - next: ?*Node, - event: ResetEvent, - }; - - pub fn tryAcquire(self: *Mutex) ?Held { - if (@cmpxchgWeak(usize, &self.state, 0, MUTEX_LOCK, .Acquire, .Monotonic) != null) - return null; - return Held{ .mutex = self }; - } - - pub fn acquire(self: *Mutex) Held { - return self.tryAcquire() orelse { - self.acquireSlow(); - return Held{ .mutex = self }; - }; - } - - fn acquireSlow(self: *Mutex) void { - // inlining the fast path and hiding *Slow() - // calls behind a @setCold(true) appears to - // improve performance in release builds. - @setCold(true); - while (true) { - - // try and spin for a bit to acquire the mutex if theres currently no queue - var spin_count: u32 = SPIN_COUNT; - var state = @atomicLoad(usize, &self.state, .Monotonic); - while (spin_count != 0) : (spin_count -= 1) { - if (state & MUTEX_LOCK == 0) { - _ = @cmpxchgWeak(usize, &self.state, state, state | MUTEX_LOCK, .Acquire, .Monotonic) orelse return; - } else if (state & QUEUE_MASK == 0) { - break; - } - SpinLock.yield(); - state = @atomicLoad(usize, &self.state, .Monotonic); - } - - // create the ResetEvent node on the stack - // (faster than threadlocal on platforms like OSX) - var node: Node = undefined; - node.event = ResetEvent.init(); - defer node.event.deinit(); - - // we've spun too long, try and add our node to the LIFO queue. - // if the mutex becomes available in the process, try and grab it instead. - while (true) { - if (state & MUTEX_LOCK == 0) { - _ = @cmpxchgWeak(usize, &self.state, state, state | MUTEX_LOCK, .Acquire, .Monotonic) orelse return; - } else { - node.next = @intToPtr(?*Node, state & QUEUE_MASK); - const new_state = @ptrToInt(&node) | (state & ~QUEUE_MASK); - _ = @cmpxchgWeak(usize, &self.state, state, new_state, .Release, .Monotonic) orelse { - node.event.wait(); - break; - }; - } - SpinLock.yield(); - state = @atomicLoad(usize, &self.state, .Monotonic); - } - } - } - - /// Returned when the lock is acquired. Call release to - /// release. - pub const Held = struct { - mutex: *Mutex, - - /// Release the held lock. - pub fn release(self: Held) void { - // first, remove the lock bit so another possibly parallel acquire() can succeed. - // use .Sub since it can be usually compiled down more efficiency - // (`lock sub` on x86) vs .And ~MUTEX_LOCK (`lock cmpxchg` loop on x86) - const state = @atomicRmw(usize, &self.mutex.state, .Sub, MUTEX_LOCK, .Release); - - // if the LIFO queue isnt locked and it has a node, try and wake up the node. - if ((state & QUEUE_LOCK) == 0 and (state & QUEUE_MASK) != 0) - self.mutex.releaseSlow(); - } - }; - - fn releaseSlow(self: *Mutex) void { - @setCold(true); - - // try and lock the LFIO queue to pop a node off, - // stopping altogether if its already locked or the queue is empty - var state = @atomicLoad(usize, &self.state, .Monotonic); - while (true) : (SpinLock.loopHint(1)) { - if (state & QUEUE_LOCK != 0 or state & QUEUE_MASK == 0) - return; - state = @cmpxchgWeak(usize, &self.state, state, state | QUEUE_LOCK, .Acquire, .Monotonic) orelse break; - } - - // acquired the QUEUE_LOCK, try and pop a node to wake it. - // if the mutex is locked, then unset QUEUE_LOCK and let - // the thread who holds the mutex do the wake-up on unlock() - while (true) : (SpinLock.loopHint(1)) { - if ((state & MUTEX_LOCK) != 0) { - state = @cmpxchgWeak(usize, &self.state, state, state & ~QUEUE_LOCK, .Release, .Acquire) orelse return; - } else { - const node = @intToPtr(*Node, state & QUEUE_MASK); - const new_state = @ptrToInt(node.next); - state = @cmpxchgWeak(usize, &self.state, state, new_state, .Release, .Acquire) orelse { - node.event.set(); - return; - }; - } - } - } - } - - // for platforms without a known OS blocking - // primitive, default to SpinLock for correctness -else - SpinLock; - -/// This has the sematics as `Mutex`, however it does not actually do any -/// synchronization. Operations are safety-checked no-ops. -pub const Dummy = struct { - lock: @TypeOf(lock_init) = lock_init, - - const lock_init = if (std.debug.runtime_safety) false else {}; - - pub const Held = struct { - mutex: *Dummy, - - pub fn release(self: Held) void { - if (std.debug.runtime_safety) { - self.mutex.lock = false; - } - } - }; - - /// Create a new mutex in unlocked state. - pub const init = Dummy{}; - - /// Try to acquire the mutex without blocking. Returns null if - /// the mutex is unavailable. Otherwise returns Held. Call - /// release on Held. - pub fn tryAcquire(self: *Dummy) ?Held { - if (std.debug.runtime_safety) { - if (self.lock) return null; - self.lock = true; - } - return Held{ .mutex = self }; - } - - /// Acquire the mutex. Will deadlock if the mutex is already - /// held by the calling thread. - pub fn acquire(self: *Dummy) Held { - return self.tryAcquire() orelse @panic("deadlock detected"); - } -}; - -// https://locklessinc.com/articles/keyed_events/ -const WindowsMutex = struct { - state: State = State{ .waiters = 0 }, - - const State = extern union { - locked: u8, - waiters: u32, - }; - - const WAKE = 1 << 8; - const WAIT = 1 << 9; - - pub fn tryAcquire(self: *WindowsMutex) ?Held { - if (@atomicRmw(u8, &self.state.locked, .Xchg, 1, .Acquire) != 0) - return null; - return Held{ .mutex = self }; - } - - pub fn acquire(self: *WindowsMutex) Held { - return self.tryAcquire() orelse self.acquireSlow(); - } - - fn acquireSpinning(self: *WindowsMutex) Held { - @setCold(true); - while (true) : (SpinLock.yield()) { - return self.tryAcquire() orelse continue; - } - } - - fn acquireSlow(self: *WindowsMutex) Held { - // try to use NT keyed events for blocking, falling back to spinlock if unavailable - @setCold(true); - const handle = ResetEvent.OsEvent.Futex.getEventHandle() orelse return self.acquireSpinning(); - const key = @ptrCast(*const c_void, &self.state.waiters); - - while (true) : (SpinLock.loopHint(1)) { - const waiters = @atomicLoad(u32, &self.state.waiters, .Monotonic); - - // try and take lock if unlocked - if ((waiters & 1) == 0) { - if (@atomicRmw(u8, &self.state.locked, .Xchg, 1, .Acquire) == 0) { - return Held{ .mutex = self }; - } - - // otherwise, try and update the waiting count. - // then unset the WAKE bit so that another unlocker can wake up a thread. - } else if (@cmpxchgWeak(u32, &self.state.waiters, waiters, (waiters + WAIT) | 1, .Monotonic, .Monotonic) == null) { - const rc = windows.ntdll.NtWaitForKeyedEvent(handle, key, windows.FALSE, null); - assert(rc == .SUCCESS); - _ = @atomicRmw(u32, &self.state.waiters, .Sub, WAKE, .Monotonic); - } - } - } - - pub const Held = struct { - mutex: *WindowsMutex, - - pub fn release(self: Held) void { - // unlock without a rmw/cmpxchg instruction - @atomicStore(u8, @ptrCast(*u8, &self.mutex.state.locked), 0, .Release); - const handle = ResetEvent.OsEvent.Futex.getEventHandle() orelse return; - const key = @ptrCast(*const c_void, &self.mutex.state.waiters); - - while (true) : (SpinLock.loopHint(1)) { - const waiters = @atomicLoad(u32, &self.mutex.state.waiters, .Monotonic); - - // no one is waiting - if (waiters < WAIT) return; - // someone grabbed the lock and will do the wake instead - if (waiters & 1 != 0) return; - // someone else is currently waking up - if (waiters & WAKE != 0) return; - - // try to decrease the waiter count & set the WAKE bit meaning a thread is waking up - if (@cmpxchgWeak(u32, &self.mutex.state.waiters, waiters, waiters - WAIT + WAKE, .Release, .Monotonic) == null) { - const rc = windows.ntdll.NtReleaseKeyedEvent(handle, key, windows.FALSE, null); - assert(rc == .SUCCESS); - return; - } - } - } - }; -}; - -const TestContext = struct { - mutex: *Mutex, - data: i128, - - const incr_count = 10000; -}; - -test "std.Mutex" { - var mutex = Mutex{}; - - var context = TestContext{ - .mutex = &mutex, - .data = 0, - }; - - if (builtin.single_threaded) { - worker(&context); - testing.expect(context.data == TestContext.incr_count); - } else { - const thread_count = 10; - var threads: [thread_count]*std.Thread = undefined; - for (threads) |*t| { - t.* = try std.Thread.spawn(&context, worker); - } - for (threads) |t| - t.wait(); - - testing.expect(context.data == thread_count * TestContext.incr_count); - } -} - -fn worker(ctx: *TestContext) void { - var i: usize = 0; - while (i != TestContext.incr_count) : (i += 1) { - const held = ctx.mutex.acquire(); - defer held.release(); - - ctx.data += 1; - } -} diff --git a/lib/std/net.zig b/lib/std/net.zig index 7e285b1fac..636596c117 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -10,8 +10,13 @@ const net = @This(); const mem = std.mem; const os = std.os; const fs = std.fs; +const io = std.io; -pub const has_unix_sockets = @hasDecl(os, "sockaddr_un"); +// Windows 10 added support for unix sockets in build 17063, redstone 4 is the +// first release to support them. +pub const has_unix_sockets = @hasDecl(os, "sockaddr_un") and + (builtin.os.tag != .windows or + std.Target.current.os.version_range.windows.isAtLeast(.win10_rs4) orelse false); pub const Address = extern union { any: os.sockaddr, @@ -154,7 +159,7 @@ pub const Address = extern union { unreachable; } - try std.fmt.format(out_stream, "{}", .{&self.un.path}); + try std.fmt.format(out_stream, "{s}", .{&self.un.path}); }, else => unreachable, } @@ -596,7 +601,7 @@ pub const Ip6Address = extern struct { } }; -pub fn connectUnixSocket(path: []const u8) !fs.File { +pub fn connectUnixSocket(path: []const u8) !Stream { const opt_non_block = if (std.io.is_async) os.SOCK_NONBLOCK else 0; const sockfd = try os.socket( os.AF_UNIX, @@ -614,7 +619,7 @@ pub fn connectUnixSocket(path: []const u8) !fs.File { try os.connect(sockfd, &addr.any, addr.getOsSockLen()); } - return fs.File{ + return Stream{ .handle = sockfd, }; } @@ -648,7 +653,7 @@ pub const AddressList = struct { }; /// All memory allocated with `allocator` will be freed before this function returns. -pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16) !fs.File { +pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16) !Stream { const list = try getAddressList(allocator, name, port); defer list.deinit(); @@ -665,7 +670,7 @@ pub fn tcpConnectToHost(allocator: *mem.Allocator, name: []const u8, port: u16) return std.os.ConnectError.ConnectionRefused; } -pub fn tcpConnectToAddress(address: Address) !fs.File { +pub fn tcpConnectToAddress(address: Address) !Stream { const nonblock = if (std.io.is_async) os.SOCK_NONBLOCK else 0; const sock_flags = os.SOCK_STREAM | nonblock | (if (builtin.os.tag == .windows) 0 else os.SOCK_CLOEXEC); @@ -679,7 +684,7 @@ pub fn tcpConnectToAddress(address: Address) !fs.File { try os.connect(sockfd, &address.any, address.getOsSockLen()); } - return fs.File{ .handle = sockfd }; + return Stream{ .handle = sockfd }; } /// Call `AddressList.deinit` on the result. @@ -783,13 +788,13 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !* var lookup_addrs = std.ArrayList(LookupAddr).init(allocator); defer lookup_addrs.deinit(); - var canon = std.ArrayListSentineled(u8, 0).initNull(arena); + var canon = std.ArrayList(u8).init(arena); defer canon.deinit(); try linuxLookupName(&lookup_addrs, &canon, name, family, flags, port); result.addrs = try arena.alloc(Address, lookup_addrs.items.len); - if (!canon.isNull()) { + if (canon.items.len != 0) { result.canon_name = canon.toOwnedSlice(); } @@ -818,7 +823,7 @@ const DAS_ORDER_SHIFT = 0; fn linuxLookupName( addrs: *std.ArrayList(LookupAddr), - canon: *std.ArrayListSentineled(u8, 0), + canon: *std.ArrayList(u8), opt_name: ?[]const u8, family: os.sa_family_t, flags: u32, @@ -826,7 +831,8 @@ fn linuxLookupName( ) !void { if (opt_name) |name| { // reject empty name and check len so it fits into temp bufs - try canon.replaceContents(name); + canon.items.len = 0; + try canon.appendSlice(name); if (Address.parseExpectingFamily(name, family, port)) |addr| { try addrs.append(LookupAddr{ .addr = addr }); } else |name_err| if ((flags & std.c.AI_NUMERICHOST) != 0) { @@ -1091,7 +1097,7 @@ fn linuxLookupNameFromNull( fn linuxLookupNameFromHosts( addrs: *std.ArrayList(LookupAddr), - canon: *std.ArrayListSentineled(u8, 0), + canon: *std.ArrayList(u8), name: []const u8, family: os.sa_family_t, port: u16, @@ -1105,7 +1111,7 @@ fn linuxLookupNameFromHosts( }; defer file.close(); - const stream = std.io.bufferedInStream(file.inStream()).inStream(); + const stream = std.io.bufferedReader(file.reader()).reader(); var line_buf: [512]u8 = undefined; while (stream.readUntilDelimiterOrEof(&line_buf, '\n') catch |err| switch (err) { error.StreamTooLong => blk: { @@ -1142,7 +1148,8 @@ fn linuxLookupNameFromHosts( // first name is canonical name const name_text = first_name_text.?; if (isValidHostName(name_text)) { - try canon.replaceContents(name_text); + canon.items.len = 0; + try canon.appendSlice(name_text); } } } @@ -1161,7 +1168,7 @@ pub fn isValidHostName(hostname: []const u8) bool { fn linuxLookupNameFromDnsSearch( addrs: *std.ArrayList(LookupAddr), - canon: *std.ArrayListSentineled(u8, 0), + canon: *std.ArrayList(u8), name: []const u8, family: os.sa_family_t, port: u16, @@ -1177,10 +1184,10 @@ fn linuxLookupNameFromDnsSearch( if (byte == '.') dots += 1; } - const search = if (rc.search.isNull() or dots >= rc.ndots or mem.endsWith(u8, name, ".")) + const search = if (dots >= rc.ndots or mem.endsWith(u8, name, ".")) "" else - rc.search.span(); + rc.search.items; var canon_name = name; @@ -1193,30 +1200,30 @@ fn linuxLookupNameFromDnsSearch( // name is not a CNAME record) and serves as a buffer for passing // the full requested name to name_from_dns. try canon.resize(canon_name.len); - mem.copy(u8, canon.span(), canon_name); + mem.copy(u8, canon.items, canon_name); try canon.append('.'); var tok_it = mem.tokenize(search, " \t"); while (tok_it.next()) |tok| { - canon.shrink(canon_name.len + 1); + canon.shrinkRetainingCapacity(canon_name.len + 1); try canon.appendSlice(tok); - try linuxLookupNameFromDns(addrs, canon, canon.span(), family, rc, port); + try linuxLookupNameFromDns(addrs, canon, canon.items, family, rc, port); if (addrs.items.len != 0) return; } - canon.shrink(canon_name.len); + canon.shrinkRetainingCapacity(canon_name.len); return linuxLookupNameFromDns(addrs, canon, name, family, rc, port); } const dpc_ctx = struct { addrs: *std.ArrayList(LookupAddr), - canon: *std.ArrayListSentineled(u8, 0), + canon: *std.ArrayList(u8), port: u16, }; fn linuxLookupNameFromDns( addrs: *std.ArrayList(LookupAddr), - canon: *std.ArrayListSentineled(u8, 0), + canon: *std.ArrayList(u8), name: []const u8, family: os.sa_family_t, rc: ResolvConf, @@ -1271,7 +1278,7 @@ const ResolvConf = struct { attempts: u32, ndots: u32, timeout: u32, - search: std.ArrayListSentineled(u8, 0), + search: std.ArrayList(u8), ns: std.ArrayList(LookupAddr), fn deinit(rc: *ResolvConf) void { @@ -1286,7 +1293,7 @@ const ResolvConf = struct { fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void { rc.* = ResolvConf{ .ns = std.ArrayList(LookupAddr).init(allocator), - .search = std.ArrayListSentineled(u8, 0).initNull(allocator), + .search = std.ArrayList(u8).init(allocator), .ndots = 1, .timeout = 5, .attempts = 2, @@ -1302,7 +1309,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void { }; defer file.close(); - const stream = std.io.bufferedInStream(file.inStream()).inStream(); + const stream = std.io.bufferedReader(file.reader()).reader(); var line_buf: [512]u8 = undefined; while (stream.readUntilDelimiterOrEof(&line_buf, '\n') catch |err| switch (err) { error.StreamTooLong => blk: { @@ -1338,7 +1345,8 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void { const ip_txt = line_it.next() orelse continue; try linuxLookupNameFromNumericUnspec(&rc.ns, ip_txt, 53); } else if (mem.eql(u8, token, "domain") or mem.eql(u8, token, "search")) { - try rc.search.replaceContents(line_it.rest()); + rc.search.items.len = 0; + try rc.search.appendSlice(line_it.rest()); } } @@ -1569,13 +1577,100 @@ fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8) _ = try os.dn_expand(packet, data, &tmp); const canon_name = mem.spanZ(std.meta.assumeSentinel(&tmp, 0)); if (isValidHostName(canon_name)) { - try ctx.canon.replaceContents(canon_name); + ctx.canon.items.len = 0; + try ctx.canon.appendSlice(canon_name); } }, else => return, } } +pub const Stream = struct { + // Underlying socket descriptor. + // Note that on some platforms this may not be interchangeable with a + // regular files descriptor. + handle: os.socket_t, + + pub fn close(self: Stream) void { + os.closeSocket(self.handle); + } + + pub const ReadError = os.ReadError; + pub const WriteError = os.WriteError; + + pub const Reader = io.Reader(Stream, ReadError, read); + pub const Writer = io.Writer(Stream, WriteError, write); + + pub fn reader(self: Stream) Reader { + return .{ .context = self }; + } + + pub fn writer(self: Stream) Writer { + return .{ .context = self }; + } + + pub fn read(self: Stream, buffer: []u8) ReadError!usize { + if (std.Target.current.os.tag == .windows) { + return os.windows.ReadFile(self.handle, buffer, null, io.default_mode); + } + + if (std.io.is_async) { + return std.event.Loop.instance.?.read(self.handle, buffer, false); + } else { + return os.read(self.handle, buffer); + } + } + + /// TODO in evented I/O mode, this implementation incorrectly uses the event loop's + /// file system thread instead of non-blocking. It needs to be reworked to properly + /// use non-blocking I/O. + pub fn write(self: Stream, buffer: []const u8) WriteError!usize { + if (std.Target.current.os.tag == .windows) { + return os.windows.WriteFile(self.handle, buffer, null, io.default_mode); + } + + if (std.io.is_async) { + return std.event.Loop.instance.?.write(self.handle, buffer, false); + } else { + return os.write(self.handle, buffer); + } + } + + /// See https://github.com/ziglang/zig/issues/7699 + /// See equivalent function: `std.fs.File.writev`. + pub fn writev(self: Stream, iovecs: []const os.iovec_const) WriteError!usize { + if (std.io.is_async) { + // TODO improve to actually take advantage of writev syscall, if available. + if (iovecs.len == 0) return 0; + const first_buffer = iovecs[0].iov_base[0..iovecs[0].iov_len]; + try self.write(first_buffer); + return first_buffer.len; + } else { + return os.writev(self.handle, iovecs); + } + } + + /// The `iovecs` parameter is mutable because this function needs to mutate the fields in + /// order to handle partial writes from the underlying OS layer. + /// See https://github.com/ziglang/zig/issues/7699 + /// See equivalent function: `std.fs.File.writevAll`. + pub fn writevAll(self: Stream, iovecs: []os.iovec_const) WriteError!void { + if (iovecs.len == 0) return; + + var i: usize = 0; + while (true) { + var amt = try self.writev(iovecs[i..]); + while (amt >= iovecs[i].iov_len) { + amt -= iovecs[i].iov_len; + i += 1; + if (i >= iovecs.len) return; + } + iovecs[i].iov_base += amt; + iovecs[i].iov_len -= amt; + } + } +}; + pub const StreamServer = struct { /// Copied from `Options` on `init`. kernel_backlog: u31, @@ -1682,7 +1777,7 @@ pub const StreamServer = struct { } || os.UnexpectedError; pub const Connection = struct { - file: fs.File, + stream: Stream, address: Address, }; @@ -1701,7 +1796,7 @@ pub const StreamServer = struct { if (accept_result) |fd| { return Connection{ - .file = fs.File{ .handle = fd }, + .stream = Stream{ .handle = fd }, .address = accepted_addr, }; } else |err| switch (err) { @@ -1711,6 +1806,6 @@ pub const StreamServer = struct { } }; -test "" { +test { _ = @import("net/test.zig"); } diff --git a/lib/std/net/test.zig b/lib/std/net/test.zig index 9f40bb5a3b..10a9c4e18b 100644 --- a/lib/std/net/test.zig +++ b/lib/std/net/test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -145,7 +145,7 @@ test "listen on a port, send bytes, receive bytes" { // Try only the IPv4 variant as some CI builders have no IPv6 localhost // configured. - const localhost = try net.Address.parseIp("127.0.0.1", 8080); + const localhost = try net.Address.parseIp("127.0.0.1", 0); var server = net.StreamServer.init(.{}); defer server.deinit(); @@ -165,8 +165,9 @@ test "listen on a port, send bytes, receive bytes" { defer t.wait(); var client = try server.accept(); + defer client.stream.close(); var buf: [16]u8 = undefined; - const n = try client.file.reader().read(&buf); + const n = try client.stream.reader().read(&buf); testing.expectEqual(@as(usize, 12), n); testing.expectEqualSlices(u8, "Hello world!", buf[0..n]); @@ -249,6 +250,49 @@ fn testServer(server: *net.StreamServer) anyerror!void { var client = try server.accept(); - const stream = client.file.outStream(); + const stream = client.stream.writer(); try stream.print("hello from server\n", .{}); } + +test "listen on a unix socket, send bytes, receive bytes" { + if (builtin.single_threaded) return error.SkipZigTest; + if (!net.has_unix_sockets) return error.SkipZigTest; + + if (std.builtin.os.tag == .windows) { + _ = try std.os.windows.WSAStartup(2, 2); + } + defer { + if (std.builtin.os.tag == .windows) { + std.os.windows.WSACleanup() catch unreachable; + } + } + + var server = net.StreamServer.init(.{}); + defer server.deinit(); + + const socket_path = "socket.unix"; + + var socket_addr = try net.Address.initUnix(socket_path); + defer std.fs.cwd().deleteFile(socket_path) catch {}; + try server.listen(socket_addr); + + const S = struct { + fn clientFn(_: void) !void { + const socket = try net.connectUnixSocket(socket_path); + defer socket.close(); + + _ = try socket.writer().writeAll("Hello world!"); + } + }; + + const t = try std.Thread.spawn({}, S.clientFn); + defer t.wait(); + + var client = try server.accept(); + defer client.stream.close(); + var buf: [16]u8 = undefined; + const n = try client.stream.reader().read(&buf); + + testing.expectEqual(@as(usize, 12), n); + testing.expectEqualSlices(u8, "Hello world!", buf[0..n]); +} diff --git a/lib/std/once.zig b/lib/std/once.zig index 6e0e4867d8..efa99060d3 100644 --- a/lib/std/once.zig +++ b/lib/std/once.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -15,7 +15,7 @@ pub fn once(comptime f: fn () void) Once(f) { pub fn Once(comptime f: fn () void) type { return struct { done: bool = false, - mutex: std.Mutex = std.Mutex{}, + mutex: std.Thread.Mutex = std.Thread.Mutex{}, /// Call the function `f`. /// If `call` is invoked multiple times `f` will be executed only the diff --git a/lib/std/os.zig b/lib/std/os.zig index b42cdf756f..24d9041639 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -32,6 +32,7 @@ const MAX_PATH_BYTES = std.fs.MAX_PATH_BYTES; pub const darwin = @import("os/darwin.zig"); pub const dragonfly = @import("os/dragonfly.zig"); pub const freebsd = @import("os/freebsd.zig"); +pub const haiku = @import("os/haiku.zig"); pub const netbsd = @import("os/netbsd.zig"); pub const openbsd = @import("os/openbsd.zig"); pub const linux = @import("os/linux.zig"); @@ -43,7 +44,7 @@ comptime { assert(@import("std") == std); // std lib tests require --override-lib-dir } -test "" { +test { _ = darwin; _ = freebsd; _ = linux; @@ -52,6 +53,7 @@ test "" { _ = uefi; _ = wasi; _ = windows; + _ = haiku; _ = @import("os/test.zig"); } @@ -66,6 +68,7 @@ else if (builtin.link_libc) else switch (builtin.os.tag) { .macos, .ios, .watchos, .tvos => darwin, .freebsd => freebsd, + .haiku => haiku, .linux => linux, .netbsd => netbsd, .openbsd => openbsd, @@ -191,7 +194,7 @@ fn getRandomBytesDevURandom(buf: []u8) !void { .capable_io_mode = .blocking, .intended_io_mode = .blocking, }; - const stream = file.inStream(); + const stream = file.reader(); stream.readNoEof(buf) catch return error.Unexpected; } @@ -324,7 +327,7 @@ pub const ReadError = error{ /// on both 64-bit and 32-bit systems. This is due to using a signed C int as the return value, as /// well as stuffing the errno codes into the last `4096` values. This is noted on the `read` man page. /// The limit on Darwin is `0x7fffffff`, trying to read more than that returns EINVAL. -/// For POSIX the limit is `math.maxInt(isize)`. +/// The corresponding POSIX limit is `math.maxInt(isize)`. pub fn read(fd: fd_t, buf: []u8) ReadError!usize { if (builtin.os.tag == .windows) { return windows.ReadFile(fd, buf, null, std.io.default_mode); @@ -447,6 +450,12 @@ pub const PReadError = ReadError || error{Unseekable}; /// return error.WouldBlock when EAGAIN is received. /// On Windows, if the application has a global event loop enabled, I/O Completion Ports are /// used to perform the I/O. `error.WouldBlock` is not possible on Windows. +/// +/// Linux has a limit on how many bytes may be transferred in one `pread` call, which is `0x7ffff000` +/// on both 64-bit and 32-bit systems. This is due to using a signed C int as the return value, as +/// well as stuffing the errno codes into the last `4096` values. This is noted on the `read` man page. +/// The limit on Darwin is `0x7fffffff`, trying to read more than that returns EINVAL. +/// The corresponding POSIX limit is `math.maxInt(isize)`. pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { if (builtin.os.tag == .windows) { return windows.ReadFile(fd, buf, offset, std.io.default_mode); @@ -478,8 +487,16 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { } } + // Prevent EINVAL. + const max_count = switch (std.Target.current.os.tag) { + .linux => 0x7ffff000, + .macos, .ios, .watchos, .tvos => math.maxInt(i32), + else => math.maxInt(isize), + }; + const adjusted_len = math.min(max_count, buf.len); + while (true) { - const rc = system.pread(fd, buf.ptr, buf.len, offset); + const rc = system.pread(fd, buf.ptr, adjusted_len, offset); switch (errno(rc)) { 0 => return @intCast(usize, rc), EINTR => continue, @@ -585,7 +602,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { /// On these systems, the read races with concurrent writes to the same file descriptor. pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { const have_pread_but_not_preadv = switch (std.Target.current.os.tag) { - .windows, .macos, .ios, .watchos, .tvos => true, + .windows, .macos, .ios, .watchos, .tvos, .haiku => true, else => false, }; if (have_pread_but_not_preadv) { @@ -918,7 +935,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { /// If `iov.len` is larger than will fit in a `u31`, a partial write will occur. pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usize { const have_pwrite_but_not_pwritev = switch (std.Target.current.os.tag) { - .windows, .macos, .ios, .watchos, .tvos => true, + .windows, .macos, .ios, .watchos, .tvos, .haiku => true, else => false, }; @@ -1348,89 +1365,10 @@ pub fn execvpeZ_expandArg0( /// If `file` is an absolute path, this is the same as `execveZ`. pub fn execvpeZ( file: [*:0]const u8, - argv: [*:null]const ?[*:0]const u8, + argv_ptr: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8, ) ExecveError { - return execvpeZ_expandArg0(.no_expand, file, argv, envp); -} - -/// This is the same as `execvpe` except if the `arg0_expand` parameter is set to `.expand`, -/// then argv[0] will be replaced with the expanded version of it, after resolving in accordance -/// with the PATH environment variable. -pub fn execvpe_expandArg0( - allocator: *mem.Allocator, - arg0_expand: Arg0Expand, - argv_slice: []const []const u8, - env_map: *const std.BufMap, -) (ExecveError || error{OutOfMemory}) { - const argv_buf = try allocator.alloc(?[*:0]u8, argv_slice.len + 1); - mem.set(?[*:0]u8, argv_buf, null); - defer { - for (argv_buf) |arg| { - const arg_buf = mem.spanZ(arg) orelse break; - allocator.free(arg_buf); - } - allocator.free(argv_buf); - } - for (argv_slice) |arg, i| { - const arg_buf = try allocator.alloc(u8, arg.len + 1); - @memcpy(arg_buf.ptr, arg.ptr, arg.len); - arg_buf[arg.len] = 0; - argv_buf[i] = arg_buf[0..arg.len :0].ptr; - } - argv_buf[argv_slice.len] = null; - const argv_ptr = argv_buf[0..argv_slice.len :null].ptr; - - const envp_buf = try createNullDelimitedEnvMap(allocator, env_map); - defer freeNullDelimitedEnvMap(allocator, envp_buf); - - switch (arg0_expand) { - .expand => return execvpeZ_expandArg0(.expand, argv_buf.ptr[0].?, argv_ptr, envp_buf.ptr), - .no_expand => return execvpeZ_expandArg0(.no_expand, argv_buf.ptr[0].?, argv_ptr, envp_buf.ptr), - } -} - -/// This function must allocate memory to add a null terminating bytes on path and each arg. -/// It must also convert to KEY=VALUE\0 format for environment variables, and include null -/// pointers after the args and after the environment variables. -/// `argv_slice[0]` is the executable path. -/// This function also uses the PATH environment variable to get the full path to the executable. -pub fn execvpe( - allocator: *mem.Allocator, - argv_slice: []const []const u8, - env_map: *const std.BufMap, -) (ExecveError || error{OutOfMemory}) { - return execvpe_expandArg0(allocator, .no_expand, argv_slice, env_map); -} - -pub fn createNullDelimitedEnvMap(allocator: *mem.Allocator, env_map: *const std.BufMap) ![:null]?[*:0]u8 { - const envp_count = env_map.count(); - const envp_buf = try allocator.alloc(?[*:0]u8, envp_count + 1); - mem.set(?[*:0]u8, envp_buf, null); - errdefer freeNullDelimitedEnvMap(allocator, envp_buf); - { - var it = env_map.iterator(); - var i: usize = 0; - while (it.next()) |pair| : (i += 1) { - const env_buf = try allocator.alloc(u8, pair.key.len + pair.value.len + 2); - @memcpy(env_buf.ptr, pair.key.ptr, pair.key.len); - env_buf[pair.key.len] = '='; - @memcpy(env_buf.ptr + pair.key.len + 1, pair.value.ptr, pair.value.len); - const len = env_buf.len - 1; - env_buf[len] = 0; - envp_buf[i] = env_buf[0..len :0].ptr; - } - assert(i == envp_count); - } - return envp_buf[0..envp_count :null]; -} - -pub fn freeNullDelimitedEnvMap(allocator: *mem.Allocator, envp_buf: []?[*:0]u8) void { - for (envp_buf) |env| { - const env_buf = if (env) |ptr| ptr[0 .. mem.len(ptr) + 1] else break; - allocator.free(env_buf); - } - allocator.free(envp_buf); + return execvpeZ_expandArg0(.no_expand, file, argv_ptr, envp); } /// Get an environment variable. @@ -1699,6 +1637,92 @@ pub fn symlinkatZ(target_path: [*:0]const u8, newdirfd: fd_t, sym_link_path: [*: } } +pub const LinkError = UnexpectedError || error{ + AccessDenied, + DiskQuota, + PathAlreadyExists, + FileSystem, + SymLinkLoop, + LinkQuotaExceeded, + NameTooLong, + FileNotFound, + SystemResources, + NoSpaceLeft, + ReadOnlyFileSystem, + NotSameFileSystem, +}; + +pub fn linkZ(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: i32) LinkError!void { + switch (errno(system.link(oldpath, newpath, flags))) { + 0 => return, + EACCES => return error.AccessDenied, + EDQUOT => return error.DiskQuota, + EEXIST => return error.PathAlreadyExists, + EFAULT => unreachable, + EIO => return error.FileSystem, + ELOOP => return error.SymLinkLoop, + EMLINK => return error.LinkQuotaExceeded, + ENAMETOOLONG => return error.NameTooLong, + ENOENT => return error.FileNotFound, + ENOMEM => return error.SystemResources, + ENOSPC => return error.NoSpaceLeft, + EPERM => return error.AccessDenied, + EROFS => return error.ReadOnlyFileSystem, + EXDEV => return error.NotSameFileSystem, + EINVAL => unreachable, + else => |err| return unexpectedErrno(err), + } +} + +pub fn link(oldpath: []const u8, newpath: []const u8, flags: i32) LinkError!void { + const old = try toPosixPath(oldpath); + const new = try toPosixPath(newpath); + return try linkZ(&old, &new, flags); +} + +pub const LinkatError = LinkError || error{NotDir}; + +pub fn linkatZ( + olddir: fd_t, + oldpath: [*:0]const u8, + newdir: fd_t, + newpath: [*:0]const u8, + flags: i32, +) LinkatError!void { + switch (errno(system.linkat(olddir, oldpath, newdir, newpath, flags))) { + 0 => return, + EACCES => return error.AccessDenied, + EDQUOT => return error.DiskQuota, + EEXIST => return error.PathAlreadyExists, + EFAULT => unreachable, + EIO => return error.FileSystem, + ELOOP => return error.SymLinkLoop, + EMLINK => return error.LinkQuotaExceeded, + ENAMETOOLONG => return error.NameTooLong, + ENOENT => return error.FileNotFound, + ENOMEM => return error.SystemResources, + ENOSPC => return error.NoSpaceLeft, + ENOTDIR => return error.NotDir, + EPERM => return error.AccessDenied, + EROFS => return error.ReadOnlyFileSystem, + EXDEV => return error.NotSameFileSystem, + EINVAL => unreachable, + else => |err| return unexpectedErrno(err), + } +} + +pub fn linkat( + olddir: fd_t, + oldpath: []const u8, + newdir: fd_t, + newpath: []const u8, + flags: i32, +) LinkatError!void { + const old = try toPosixPath(oldpath); + const new = try toPosixPath(newpath); + return try linkatZ(olddir, &old, newdir, &new, flags); +} + pub const UnlinkError = error{ FileNotFound, @@ -3225,6 +3249,9 @@ pub const ConnectError = error{ /// The given path for the unix socket does not exist. FileNotFound, + + /// Connection was reset by peer before connect could complete. + ConnectionResetByPeer, } || UnexpectedError; /// Initiate a connection on a socket. @@ -3239,8 +3266,9 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne .WSAEADDRNOTAVAIL => return error.AddressNotAvailable, .WSAECONNREFUSED => return error.ConnectionRefused, .WSAETIMEDOUT => return error.ConnectionTimedOut, - .WSAEHOSTUNREACH // TODO: should we return NetworkUnreachable in this case as well? - , .WSAENETUNREACH => return error.NetworkUnreachable, + .WSAEHOSTUNREACH, // TODO: should we return NetworkUnreachable in this case as well? + .WSAENETUNREACH, + => return error.NetworkUnreachable, .WSAEFAULT => unreachable, .WSAEINVAL => unreachable, .WSAEISCONN => unreachable, @@ -3302,6 +3330,7 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void { ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. EPROTOTYPE => unreachable, // The socket type does not support the requested communications protocol. ETIMEDOUT => return error.ConnectionTimedOut, + ECONNRESET => return error.ConnectionResetByPeer, else => |err| return unexpectedErrno(err), }, EBADF => unreachable, // The argument sockfd is not a valid file descriptor. @@ -3830,31 +3859,54 @@ pub fn pipe() PipeError![2]fd_t { } pub fn pipe2(flags: u32) PipeError![2]fd_t { - if (comptime std.Target.current.isDarwin()) { - var fds: [2]fd_t = try pipe(); - if (flags == 0) return fds; - errdefer { - close(fds[0]); - close(fds[1]); - } - for (fds) |fd| switch (errno(system.fcntl(fd, F_SETFL, flags))) { - 0 => {}, + if (@hasDecl(system, "pipe2")) { + var fds: [2]fd_t = undefined; + switch (errno(system.pipe2(&fds, flags))) { + 0 => return fds, EINVAL => unreachable, // Invalid flags - EBADF => unreachable, // Always a race condition + EFAULT => unreachable, // Invalid fds pointer + ENFILE => return error.SystemFdQuotaExceeded, + EMFILE => return error.ProcessFdQuotaExceeded, else => |err| return unexpectedErrno(err), - }; - return fds; + } } - var fds: [2]fd_t = undefined; - switch (errno(system.pipe2(&fds, flags))) { - 0 => return fds, - EINVAL => unreachable, // Invalid flags - EFAULT => unreachable, // Invalid fds pointer - ENFILE => return error.SystemFdQuotaExceeded, - EMFILE => return error.ProcessFdQuotaExceeded, - else => |err| return unexpectedErrno(err), + var fds: [2]fd_t = try pipe(); + errdefer { + close(fds[0]); + close(fds[1]); } + + if (flags == 0) + return fds; + + // O_CLOEXEC is special, it's a file descriptor flag and must be set using + // F_SETFD. + if (flags & O_CLOEXEC != 0) { + for (fds) |fd| { + switch (errno(system.fcntl(fd, F_SETFD, @as(u32, FD_CLOEXEC)))) { + 0 => {}, + EINVAL => unreachable, // Invalid flags + EBADF => unreachable, // Always a race condition + else => |err| return unexpectedErrno(err), + } + } + } + + const new_flags = flags & ~@as(u32, O_CLOEXEC); + // Set every other flag affecting the file status using F_SETFL. + if (new_flags != 0) { + for (fds) |fd| { + switch (errno(system.fcntl(fd, F_SETFL, new_flags))) { + 0 => {}, + EINVAL => unreachable, // Invalid flags + EBADF => unreachable, // Always a race condition + else => |err| return unexpectedErrno(err), + } + } + } + + return fds; } pub const SysCtlError = error{ @@ -3872,7 +3924,10 @@ pub fn sysctl( newlen: usize, ) SysCtlError!void { if (builtin.os.tag == .wasi) { - @panic("unsupported"); + @panic("unsupported"); // TODO should be compile error, not panic + } + if (builtin.os.tag == .haiku) { + @panic("unsupported"); // TODO should be compile error, not panic } const name_len = math.cast(c_uint, name.len) catch return error.NameTooLong; @@ -3896,7 +3951,10 @@ pub fn sysctlbynameZ( newlen: usize, ) SysCtlError!void { if (builtin.os.tag == .wasi) { - @panic("unsupported"); + @panic("unsupported"); // TODO should be compile error, not panic + } + if (builtin.os.tag == .haiku) { + @panic("unsupported"); // TODO should be compile error, not panic } switch (errno(system.sysctlbyname(name, oldp, oldlenp, newp, newlen))) { @@ -4335,7 +4393,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 { }, .linux => { var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined; - const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable; + const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{d}\x00", .{fd}) catch unreachable; const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| { switch (err) { @@ -4566,7 +4624,7 @@ pub const UnexpectedError = error{ /// and you get an unexpected error. pub fn unexpectedErrno(err: usize) UnexpectedError { if (unexpected_error_tracing) { - std.debug.warn("unexpected errno: {}\n", .{err}); + std.debug.warn("unexpected errno: {d}\n", .{err}); std.debug.dumpCurrentStackTrace(null); } return error.Unexpected; @@ -4774,6 +4832,12 @@ pub const SendError = error{ BrokenPipe, FileDescriptorNotASocket, + + /// Network is unreachable. + NetworkUnreachable, + + /// The local network interface used to reach the destination is down. + NetworkSubsystemFailed, } || UnexpectedError; pub const SendToError = SendError || error{ @@ -4790,15 +4854,8 @@ pub const SendToError = SendError || error{ FileNotFound, NotDir, - /// Network is unreachable. - NetworkUnreachable, - - /// Insufficient memory was available to fulfill the request. - SystemResources, - /// The socket is not connected (connection-oriented sockets only). SocketNotConnected, - WouldBlock, AddressNotAvailable, }; @@ -4853,7 +4910,7 @@ pub fn sendto( .WSAEHOSTUNREACH => return error.NetworkUnreachable, // TODO: WSAEINPROGRESS, WSAEINTR .WSAEINVAL => unreachable, - .WSAENETDOWN => return error.NetworkUnreachable, + .WSAENETDOWN => return error.NetworkSubsystemFailed, .WSAENETRESET => return error.ConnectionResetByPeer, .WSAENETUNREACH => return error.NetworkUnreachable, .WSAENOTCONN => return error.SocketNotConnected, @@ -4882,7 +4939,6 @@ pub fn sendto( EMSGSIZE => return error.MessageTooBig, ENOBUFS => return error.SystemResources, ENOMEM => return error.SystemResources, - ENOTCONN => unreachable, // The socket is not connected, and no target has been given. ENOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. EOPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. EPIPE => return error.BrokenPipe, @@ -4892,6 +4948,9 @@ pub fn sendto( ENOENT => return error.FileNotFound, ENOTDIR => return error.NotDir, EHOSTUNREACH => return error.NetworkUnreachable, + ENETUNREACH => return error.NetworkUnreachable, + ENOTCONN => return error.SocketNotConnected, + ENETDOWN => return error.NetworkSubsystemFailed, else => |err| return unexpectedErrno(err), } } @@ -4923,7 +4982,17 @@ pub fn send( buf: []const u8, flags: u32, ) SendError!usize { - return sendto(sockfd, buf, flags, null, 0); + return sendto(sockfd, buf, flags, null, 0) catch |err| switch (err) { + error.AddressFamilyNotSupported => unreachable, + error.SymLinkLoop => unreachable, + error.NameTooLong => unreachable, + error.FileNotFound => unreachable, + error.NotDir => unreachable, + error.NetworkUnreachable => unreachable, + error.AddressNotAvailable => unreachable, + error.SocketNotConnected => unreachable, + else => |e| return e, + }; } pub const SendFileError = PReadError || WriteError || SendError; @@ -4967,7 +5036,7 @@ fn count_iovec_bytes(iovs: []const iovec_const) usize { /// /// Linux has a limit on how many bytes may be transferred in one `sendfile` call, which is `0x7ffff000` /// on both 64-bit and 32-bit systems. This is due to using a signed C int as the return value, as -/// well as stuffing the errno codes into the last `4096` values. This is cited on the `sendfile` man page. +/// well as stuffing the errno codes into the last `4096` values. This is noted on the `sendfile` man page. /// The limit on Darwin is `0x7fffffff`, trying to write more than that returns EINVAL. /// The corresponding POSIX limit on this is `math.maxInt(isize)`. pub fn sendfile( @@ -5338,7 +5407,8 @@ pub const PollError = error{ pub fn poll(fds: []pollfd, timeout: i32) PollError!usize { while (true) { - const rc = system.poll(fds.ptr, fds.len, timeout); + const fds_count = math.cast(nfds_t, fds.len) catch return error.SystemResources; + const rc = system.poll(fds.ptr, fds_count, timeout); if (builtin.os.tag == .windows) { if (rc == windows.ws2_32.SOCKET_ERROR) { switch (windows.ws2_32.WSAGetLastError()) { @@ -5549,6 +5619,9 @@ pub const SetSockOptError = error{ /// Insufficient resources are available in the system to complete the call. SystemResources, + // Setting the socket option requires more elevated permissions. + PermissionDenied, + NetworkSubsystemFailed, FileDescriptorNotASocket, SocketNotBound, @@ -5581,6 +5654,7 @@ pub fn setsockopt(fd: socket_t, level: u32, optname: u32, opt: []const u8) SetSo ENOPROTOOPT => return error.InvalidProtocolOption, ENOMEM => return error.SystemResources, ENOBUFS => return error.SystemResources, + EPERM => return error.PermissionDenied, else => |err| return unexpectedErrno(err), } } @@ -5845,3 +5919,51 @@ pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void else => |err| return unexpectedErrno(err), } } + +pub const MadviseError = error{ + /// advice is MADV_REMOVE, but the specified address range is not a shared writable mapping. + AccessDenied, + /// advice is MADV_HWPOISON, but the caller does not have the CAP_SYS_ADMIN capability. + PermissionDenied, + /// A kernel resource was temporarily unavailable. + SystemResources, + /// One of the following: + /// * addr is not page-aligned or length is negative + /// * advice is not valid + /// * advice is MADV_DONTNEED or MADV_REMOVE and the specified address range + /// includes locked, Huge TLB pages, or VM_PFNMAP pages. + /// * advice is MADV_MERGEABLE or MADV_UNMERGEABLE, but the kernel was not + /// configured with CONFIG_KSM. + /// * advice is MADV_FREE or MADV_WIPEONFORK but the specified address range + /// includes file, Huge TLB, MAP_SHARED, or VM_PFNMAP ranges. + InvalidSyscall, + /// (for MADV_WILLNEED) Paging in this area would exceed the process's + /// maximum resident set size. + WouldExceedMaximumResidentSetSize, + /// One of the following: + /// * (for MADV_WILLNEED) Not enough memory: paging in failed. + /// * Addresses in the specified range are not currently mapped, or + /// are outside the address space of the process. + OutOfMemory, + /// The madvise syscall is not available on this version and configuration + /// of the Linux kernel. + MadviseUnavailable, + /// The operating system returned an undocumented error code. + Unexpected, +}; + +/// Give advice about use of memory. +/// This syscall is optional and is sometimes configured to be disabled. +pub fn madvise(ptr: [*]align(mem.page_size) u8, length: usize, advice: u32) MadviseError!void { + switch (errno(system.madvise(ptr, length, advice))) { + 0 => return, + EACCES => return error.AccessDenied, + EAGAIN => return error.SystemResources, + EBADF => unreachable, // The map exists, but the area maps something that isn't a file. + EINVAL => return error.InvalidSyscall, + EIO => return error.WouldExceedMaximumResidentSetSize, + ENOMEM => return error.OutOfMemory, + ENOSYS => return error.MadviseUnavailable, + else => |err| return unexpectedErrno(err), + } +} diff --git a/lib/std/os/bits.zig b/lib/std/os/bits.zig index a9d65370ad..5d1de28bad 100644 --- a/lib/std/os/bits.zig +++ b/lib/std/os/bits.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -15,6 +15,7 @@ pub usingnamespace switch (std.Target.current.os.tag) { .macos, .ios, .tvos, .watchos => @import("bits/darwin.zig"), .dragonfly => @import("bits/dragonfly.zig"), .freebsd => @import("bits/freebsd.zig"), + .haiku => @import("bits/haiku.zig"), .linux => @import("bits/linux.zig"), .netbsd => @import("bits/netbsd.zig"), .openbsd => @import("bits/openbsd.zig"), @@ -34,3 +35,22 @@ pub const iovec_const = extern struct { iov_base: [*]const u8, iov_len: usize, }; + +// syslog + +/// system is unusable +pub const LOG_EMERG = 0; +/// action must be taken immediately +pub const LOG_ALERT = 1; +/// critical conditions +pub const LOG_CRIT = 2; +/// error conditions +pub const LOG_ERR = 3; +/// warning conditions +pub const LOG_WARNING = 4; +/// normal but significant condition +pub const LOG_NOTICE = 5; +/// informational +pub const LOG_INFO = 6; +/// debug-level messages +pub const LOG_DEBUG = 7; diff --git a/lib/std/os/bits/darwin.zig b/lib/std/os/bits/darwin.zig index 8bd40ed9a3..aca24b1c0c 100644 --- a/lib/std/os/bits/darwin.zig +++ b/lib/std/os/bits/darwin.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -1461,7 +1461,7 @@ pub const LOCK_EX = 2; pub const LOCK_UN = 8; pub const LOCK_NB = 4; -pub const nfds_t = usize; +pub const nfds_t = u32; pub const pollfd = extern struct { fd: fd_t, events: i16, @@ -1554,3 +1554,186 @@ pub const rlimit = extern struct { pub const SHUT_RD = 0; pub const SHUT_WR = 1; pub const SHUT_RDWR = 2; + +// Term +pub const VEOF = 0; +pub const VEOL = 1; +pub const VEOL2 = 2; +pub const VERASE = 3; +pub const VWERASE = 4; +pub const VKILL = 5; +pub const VREPRINT = 6; +pub const VINTR = 8; +pub const VQUIT = 9; +pub const VSUSP = 10; +pub const VDSUSP = 11; +pub const VSTART = 12; +pub const VSTOP = 13; +pub const VLNEXT = 14; +pub const VDISCARD = 15; +pub const VMIN = 16; +pub const VTIME = 17; +pub const VSTATUS = 18; +pub const NCCS = 20; // 2 spares (7, 19) + +pub const IGNBRK = 0x00000001; // ignore BREAK condition +pub const BRKINT = 0x00000002; // map BREAK to SIGINTR +pub const IGNPAR = 0x00000004; // ignore (discard) parity errors +pub const PARMRK = 0x00000008; // mark parity and framing errors +pub const INPCK = 0x00000010; // enable checking of parity errors +pub const ISTRIP = 0x00000020; // strip 8th bit off chars +pub const INLCR = 0x00000040; // map NL into CR +pub const IGNCR = 0x00000080; // ignore CR +pub const ICRNL = 0x00000100; // map CR to NL (ala CRMOD) +pub const IXON = 0x00000200; // enable output flow control +pub const IXOFF = 0x00000400; // enable input flow control +pub const IXANY = 0x00000800; // any char will restart after stop +pub const IMAXBEL = 0x00002000; // ring bell on input queue full +pub const IUTF8 = 0x00004000; // maintain state for UTF-8 VERASE + +pub const OPOST = 0x00000001; //enable following output processing +pub const ONLCR = 0x00000002; // map NL to CR-NL (ala CRMOD) +pub const OXTABS = 0x00000004; // expand tabs to spaces +pub const ONOEOT = 0x00000008; // discard EOT's (^D) on output) + +pub const OCRNL = 0x00000010; // map CR to NL on output +pub const ONOCR = 0x00000020; // no CR output at column 0 +pub const ONLRET = 0x00000040; // NL performs CR function +pub const OFILL = 0x00000080; // use fill characters for delay +pub const NLDLY = 0x00000300; // \n delay +pub const TABDLY = 0x00000c04; // horizontal tab delay +pub const CRDLY = 0x00003000; // \r delay +pub const FFDLY = 0x00004000; // form feed delay +pub const BSDLY = 0x00008000; // \b delay +pub const VTDLY = 0x00010000; // vertical tab delay +pub const OFDEL = 0x00020000; // fill is DEL, else NUL + +pub const NL0 = 0x00000000; +pub const NL1 = 0x00000100; +pub const NL2 = 0x00000200; +pub const NL3 = 0x00000300; +pub const TAB0 = 0x00000000; +pub const TAB1 = 0x00000400; +pub const TAB2 = 0x00000800; +pub const TAB3 = 0x00000004; +pub const CR0 = 0x00000000; +pub const CR1 = 0x00001000; +pub const CR2 = 0x00002000; +pub const CR3 = 0x00003000; +pub const FF0 = 0x00000000; +pub const FF1 = 0x00004000; +pub const BS0 = 0x00000000; +pub const BS1 = 0x00008000; +pub const VT0 = 0x00000000; +pub const VT1 = 0x00010000; + +pub const CIGNORE = 0x00000001; // ignore control flags +pub const CSIZE = 0x00000300; // character size mask +pub const CS5 = 0x00000000; // 5 bits (pseudo) +pub const CS6 = 0x00000100; // 6 bits +pub const CS7 = 0x00000200; // 7 bits +pub const CS8 = 0x00000300; // 8 bits +pub const CSTOPB = 0x0000040; // send 2 stop bits +pub const CREAD = 0x00000800; // enable receiver +pub const PARENB = 0x00001000; // parity enable +pub const PARODD = 0x00002000; // odd parity, else even +pub const HUPCL = 0x00004000; // hang up on last close +pub const CLOCAL = 0x00008000; // ignore modem status lines +pub const CCTS_OFLOW = 0x00010000; // CTS flow control of output +pub const CRTSCTS = (CCTS_OFLOW | CRTS_IFLOW); +pub const CRTS_IFLOW = 0x00020000; // RTS flow control of input +pub const CDTR_IFLOW = 0x00040000; // DTR flow control of input +pub const CDSR_OFLOW = 0x00080000; // DSR flow control of output +pub const CCAR_OFLOW = 0x00100000; // DCD flow control of output +pub const MDMBUF = 0x00100000; // old name for CCAR_OFLOW + +pub const ECHOKE = 0x00000001; // visual erase for line kill +pub const ECHOE = 0x00000002; // visually erase chars +pub const ECHOK = 0x00000004; // echo NL after line kill +pub const ECHO = 0x00000008; // enable echoing +pub const ECHONL = 0x00000010; // echo NL even if ECHO is off +pub const ECHOPRT = 0x00000020; // visual erase mode for hardcopy +pub const ECHOCTL = 0x00000040; // echo control chars as ^(Char) +pub const ISIG = 0x00000080; // enable signals INTR, QUIT, [D]SUSP +pub const ICANON = 0x00000100; // canonicalize input lines +pub const ALTWERASE = 0x00000200; // use alternate WERASE algorithm +pub const IEXTEN = 0x00000400; // enable DISCARD and LNEXT +pub const EXTPROC = 0x00000800; // external processing +pub const TOSTOP = 0x00400000; // stop background jobs from output +pub const FLUSHO = 0x00800000; // output being flushed (state) +pub const NOKERNINFO = 0x02000000; // no kernel output from VSTATUS +pub const PENDIN = 0x20000000; // XXX retype pending input (state) +pub const NOFLSH = 0x80000000; // don't flush after interrupt + +pub const TCSANOW = 0; // make change immediate +pub const TCSADRAIN = 1; // drain output, then change +pub const TCSAFLUSH = 2; // drain output, flush input +pub const TCSASOFT = 0x10; // flag - don't alter h.w. state +pub const TCSA = extern enum(c_uint) { + NOW, + DRAIN, + FLUSH, + _, +}; + +pub const B0 = 0; +pub const B50 = 50; +pub const B75 = 75; +pub const B110 = 110; +pub const B134 = 134; +pub const B150 = 150; +pub const B200 = 200; +pub const B300 = 300; +pub const B600 = 600; +pub const B1200 = 1200; +pub const B1800 = 1800; +pub const B2400 = 2400; +pub const B4800 = 4800; +pub const B9600 = 9600; +pub const B19200 = 19200; +pub const B38400 = 38400; +pub const B7200 = 7200; +pub const B14400 = 14400; +pub const B28800 = 28800; +pub const B57600 = 57600; +pub const B76800 = 76800; +pub const B115200 = 115200; +pub const B230400 = 230400; +pub const EXTA = 19200; +pub const EXTB = 38400; + +pub const TCIFLUSH = 1; +pub const TCOFLUSH = 2; +pub const TCIOFLUSH = 3; +pub const TCOOFF = 1; +pub const TCOON = 2; +pub const TCIOFF = 3; +pub const TCION = 4; + +pub const cc_t = u8; +pub const speed_t = u64; +pub const tcflag_t = u64; + +pub const termios = extern struct { + iflag: tcflag_t, // input flags + oflag: tcflag_t, // output flags + cflag: tcflag_t, // control flags + lflag: tcflag_t, // local flags + cc: [NCCS]cc_t, // control chars + ispeed: speed_t align(8), // input speed + ospeed: speed_t, // output speed +}; + +pub const winsize = extern struct { + ws_row: u16, + ws_col: u16, + ws_xpixel: u16, + ws_ypixel: u16, +}; + +pub const TIOCGWINSZ = ior(0x40000000, 't', 104, @sizeOf(winsize)); +pub const IOCPARM_MASK = 0x1fff; + +fn ior(inout: u32, group: usize, num: usize, len: usize) usize { + return (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)); +} diff --git a/lib/std/os/bits/dragonfly.zig b/lib/std/os/bits/dragonfly.zig index 61b6b9f363..3df6eb43de 100644 --- a/lib/std/os/bits/dragonfly.zig +++ b/lib/std/os/bits/dragonfly.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -20,6 +20,7 @@ pub const off_t = c_long; pub const mode_t = c_uint; pub const uid_t = u32; pub const gid_t = u32; +pub const suseconds_t = c_long; pub const ENOTSUP = EOPNOTSUPP; pub const EWOULDBLOCK = EAGAIN; @@ -190,6 +191,13 @@ pub const timespec = extern struct { tv_nsec: c_long, }; +pub const timeval = extern struct { + /// seconds + tv_sec: time_t, + /// microseconds + tv_usec: suseconds_t, +}; + pub const CTL_UNSPEC = 0; pub const CTL_KERN = 1; pub const CTL_VM = 2; diff --git a/lib/std/os/bits/freebsd.zig b/lib/std/os/bits/freebsd.zig index 6378dcaf8d..8529c5e3db 100644 --- a/lib/std/os/bits/freebsd.zig +++ b/lib/std/os/bits/freebsd.zig @@ -1,20 +1,32 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. const std = @import("../../std.zig"); +const builtin = std.builtin; const maxInt = std.math.maxInt; -// See https://svnweb.freebsd.org/base/head/sys/sys/_types.h?view=co -// TODO: audit pid_t/mode_t. They should likely be i32 and u16, respectively -pub const fd_t = c_int; -pub const pid_t = c_int; +pub const blksize_t = i32; +pub const blkcnt_t = i64; +pub const clockid_t = i32; +pub const fsblkcnt_t = u64; +pub const fsfilcnt_t = u64; +pub const nlink_t = u64; +pub const fd_t = i32; +pub const pid_t = i32; pub const uid_t = u32; pub const gid_t = u32; -pub const mode_t = c_uint; +pub const mode_t = u16; +pub const off_t = i64; +pub const ino_t = u64; +pub const dev_t = u64; +pub const time_t = i64; +// The signedness is not constant across different architectures. +pub const clock_t = isize; pub const socklen_t = u32; +pub const suseconds_t = c_long; /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. pub const Kevent = extern struct { @@ -116,20 +128,17 @@ pub const msghdr_const = extern struct { msg_flags: i32, }; -pub const off_t = i64; -pub const ino_t = u64; - pub const libc_stat = extern struct { - dev: u64, + dev: dev_t, ino: ino_t, - nlink: usize, + nlink: nlink_t, - mode: u16, + mode: mode_t, __pad0: u16, uid: uid_t, gid: gid_t, __pad1: u32, - rdev: u64, + rdev: dev_t, atim: timespec, mtim: timespec, @@ -161,6 +170,13 @@ pub const timespec = extern struct { tv_nsec: isize, }; +pub const timeval = extern struct { + /// seconds + tv_sec: time_t, + /// microseconds + tv_usec: suseconds_t, +}; + pub const dirent = extern struct { d_fileno: usize, d_off: i64, @@ -553,6 +569,9 @@ pub const EV_ONESHOT = 0x0010; /// clear event state after reporting pub const EV_CLEAR = 0x0020; +/// error, event data contains errno +pub const EV_ERROR = 0x4000; + /// force immediate event output /// ... with or without EV_ERROR /// ... use KEVENT_FLAG_ERROR_EVENTS @@ -796,16 +815,16 @@ pub const sigval = extern union { pub const _SIG_WORDS = 4; pub const _SIG_MAXSIG = 128; -pub inline fn _SIG_IDX(sig: usize) usize { +pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize { return sig - 1; } -pub inline fn _SIG_WORD(sig: usize) usize { +pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize { return_SIG_IDX(sig) >> 5; } -pub inline fn _SIG_BIT(sig: usize) usize { +pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize { return 1 << (_SIG_IDX(sig) & 31); } -pub inline fn _SIG_VALID(sig: usize) usize { +pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize { return sig <= _SIG_MAXSIG and sig > 0; } @@ -815,6 +834,53 @@ pub const sigset_t = extern struct { pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS }; +pub usingnamespace switch (builtin.arch) { + .x86_64 => struct { + pub const ucontext_t = extern struct { + sigmask: sigset_t, + mcontext: mcontext_t, + link: ?*ucontext_t, + stack: stack_t, + flags: c_int, + __spare__: [4]c_int, + }; + + /// XXX x86_64 specific + pub const mcontext_t = extern struct { + onstack: u64, + rdi: u64, + rsi: u64, + rdx: u64, + rcx: u64, + r8: u64, + r9: u64, + rax: u64, + rbx: u64, + rbp: u64, + r10: u64, + r11: u64, + r12: u64, + r13: u64, + r14: u64, + r15: u64, + trapno: u32, + fs: u16, + gs: u16, + addr: u64, + flags: u32, + es: u16, + ds: u16, + err: u64, + rip: u64, + cs: u64, + rflags: u64, + rsp: u64, + ss: u64, + }; + }, + else => struct {}, +}; + pub const EPERM = 1; // Operation not permitted pub const ENOENT = 2; // No such file or directory pub const ESRCH = 3; // No such process @@ -1432,3 +1498,37 @@ pub const rlimit = extern struct { pub const SHUT_RD = 0; pub const SHUT_WR = 1; pub const SHUT_RDWR = 2; + +pub const nfds_t = u32; + +pub const pollfd = extern struct { + fd: fd_t, + events: i16, + revents: i16, +}; + +/// any readable data available. +pub const POLLIN = 0x0001; +/// OOB/Urgent readable data. +pub const POLLPRI = 0x0002; +/// file descriptor is writeable. +pub const POLLOUT = 0x0004; +/// non-OOB/URG data available. +pub const POLLRDNORM = 0x0040; +/// no write type differentiation. +pub const POLLWRNORM = POLLOUT; +/// OOB/Urgent readable data. +pub const POLLRDBAND = 0x0080; +/// OOB/Urgent data can be written. +pub const POLLWRBAND = 0x0100; +/// like POLLIN, except ignore EOF. +pub const POLLINIGNEOF = 0x2000; +/// some poll error occurred. +pub const POLLERR = 0x0008; +/// file descriptor was "hung up". +pub const POLLHUP = 0x0010; +/// requested events "invalid". +pub const POLLNVAL = 0x0020; + +pub const POLLSTANDARD = POLLIN | POLLPRI | POLLOUT | POLLRDNORM | POLLRDBAND | + POLLWRBAND | POLLERR | POLLHUP | POLLNVAL; diff --git a/lib/std/os/bits/haiku.zig b/lib/std/os/bits/haiku.zig new file mode 100644 index 0000000000..59631fd40e --- /dev/null +++ b/lib/std/os/bits/haiku.zig @@ -0,0 +1,1450 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2020 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. +const std = @import("../../std.zig"); +const maxInt = std.math.maxInt; + +pub const fd_t = c_int; +pub const pid_t = c_int; +pub const uid_t = u32; +pub const gid_t = u32; +pub const mode_t = c_uint; + +pub const socklen_t = u32; + +/// Renamed from `kevent` to `Kevent` to avoid conflict with function name. +pub const Kevent = extern struct { + ident: usize, + filter: i16, + flags: u16, + fflags: u32, + data: i64, + udata: usize, + // TODO ext +}; + +// Modes and flags for dlopen() +// include/dlfcn.h + +pub const POLLIN = 0x0001; +pub const POLLERR = 0x0004; +pub const POLLNVAL = 0x1000; +pub const POLLHUP = 0x0080; + +/// Bind function calls lazily. +pub const RTLD_LAZY = 1; + +/// Bind function calls immediately. +pub const RTLD_NOW = 2; + +pub const RTLD_MODEMASK = 0x3; + +/// Make symbols globally available. +pub const RTLD_GLOBAL = 0x100; + +/// Opposite of RTLD_GLOBAL, and the default. +pub const RTLD_LOCAL = 0; + +/// Trace loaded objects and exit. +pub const RTLD_TRACE = 0x200; + +/// Do not remove members. +pub const RTLD_NODELETE = 0x01000; + +/// Do not load if not already loaded. +pub const RTLD_NOLOAD = 0x02000; + +pub const dl_phdr_info = extern struct { + dlpi_addr: usize, + dlpi_name: ?[*:0]const u8, + dlpi_phdr: [*]std.elf.Phdr, + dlpi_phnum: u16, +}; + +pub const Flock = extern struct { + l_start: off_t, + l_len: off_t, + l_pid: pid_t, + l_type: i16, + l_whence: i16, + l_sysid: i32, + __unused: [4]u8, +}; + +pub const msghdr = extern struct { + /// optional address + msg_name: ?*sockaddr, + + /// size of address + msg_namelen: socklen_t, + + /// scatter/gather array + msg_iov: [*]iovec, + + /// # elements in msg_iov + msg_iovlen: i32, + + /// ancillary data + msg_control: ?*c_void, + + /// ancillary data buffer len + msg_controllen: socklen_t, + + /// flags on received message + msg_flags: i32, +}; + +pub const msghdr_const = extern struct { + /// optional address + msg_name: ?*const sockaddr, + + /// size of address + msg_namelen: socklen_t, + + /// scatter/gather array + msg_iov: [*]iovec_const, + + /// # elements in msg_iov + msg_iovlen: i32, + + /// ancillary data + msg_control: ?*c_void, + + /// ancillary data buffer len + msg_controllen: socklen_t, + + /// flags on received message + msg_flags: i32, +}; + +pub const off_t = i64; +pub const ino_t = u64; + +pub const nfds_t = u32; + +pub const pollfd = extern struct { + fd: i32, + events: i16, + revents: i16, +}; + +pub const libc_stat = extern struct { + dev: i32, + ino: u64, + mode: u32, + nlink: i32, + uid: i32, + gid: i32, + size: i64, + rdev: i32, + blksize: i32, + atim: timespec, + mtim: timespec, + ctim: timespec, + crtim: timespec, + st_type: u32, + blocks: i64, + + pub fn atime(self: @This()) timespec { + return self.atim; + } + pub fn mtime(self: @This()) timespec { + return self.mtim; + } + pub fn ctime(self: @This()) timespec { + return self.ctim; + } + pub fn crtime(self: @This()) timespec { + return self.crtim; + } +}; + +pub const timespec = extern struct { + tv_sec: isize, + tv_nsec: isize, +}; + +pub const dirent = extern struct { + d_dev: i32, + d_pdev: i32, + d_ino: i64, + d_pino: i64, + d_reclen: u16, + d_name: [256]u8, + + pub fn reclen(self: dirent) u16 { + return self.d_reclen; + } +}; + +pub const image_info = extern struct { + id: u32, //image_id + type: u32, // image_type + sequence: i32, + init_order: i32, + init_routine: *c_void, + term_routine: *c_void, + device: i32, + node: i32, + name: [1024]u8, + text: *c_void, + data: *c_void, + text_size: i32, + data_size: i32, + api_version: i32, + abi: i32, +}; + +pub const system_info = extern struct { + boot_time: i64, + cpu_count: u32, + max_pages: u64, + used_pages: u64, + cached_pages: u64, + block_cache_pages: u64, + ignored_pages: u64, + needed_memory: u64, + free_memory: u64, + max_swap_pages: u64, + free_swap_pages: u64, + page_faults: u32, + max_sems: u32, + used_sems: u32, + max_ports: u32, + used_ports: u32, + max_threads: u32, + used_threads: u32, + max_teams: u32, + used_teams: u32, + kernel_name: [256]u8, + kernel_build_date: [32]u8, + kernel_build_time: [32]u8, + kernel_version: i64, + abi: u32, +}; + +pub const in_port_t = u16; +pub const sa_family_t = u8; + +pub const sockaddr = extern struct { + /// total length + len: u8, + + /// address family + family: sa_family_t, + + /// actually longer; address value + data: [14]u8, +}; + +pub const sockaddr_in = extern struct { + len: u8 = @sizeOf(sockaddr_in), + family: sa_family_t = AF_INET, + port: in_port_t, + addr: u32, + zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, +}; + +pub const sockaddr_in6 = extern struct { + len: u8 = @sizeOf(sockaddr_in6), + family: sa_family_t = AF_INET6, + port: in_port_t, + flowinfo: u32, + addr: [16]u8, + scope_id: u32, +}; + +pub const sockaddr_un = extern struct { + len: u8 = @sizeOf(sockaddr_un), + family: sa_family_t = AF_UNIX, + path: [104]u8, +}; + +pub const CTL_KERN = 1; +pub const CTL_DEBUG = 5; + +pub const KERN_PROC = 14; // struct: process entries +pub const KERN_PROC_PATHNAME = 12; // path to executable + +pub const PATH_MAX = 1024; + +pub const STDIN_FILENO = 0; +pub const STDOUT_FILENO = 1; +pub const STDERR_FILENO = 2; + +pub const PROT_NONE = 0; +pub const PROT_READ = 1; +pub const PROT_WRITE = 2; +pub const PROT_EXEC = 4; + +pub const CLOCK_REALTIME = 0; +pub const CLOCK_VIRTUAL = 1; +pub const CLOCK_PROF = 2; +pub const CLOCK_MONOTONIC = 4; +pub const CLOCK_UPTIME = 5; +pub const CLOCK_UPTIME_PRECISE = 7; +pub const CLOCK_UPTIME_FAST = 8; +pub const CLOCK_REALTIME_PRECISE = 9; +pub const CLOCK_REALTIME_FAST = 10; +pub const CLOCK_MONOTONIC_PRECISE = 11; +pub const CLOCK_MONOTONIC_FAST = 12; +pub const CLOCK_SECOND = 13; +pub const CLOCK_THREAD_CPUTIME_ID = 14; +pub const CLOCK_PROCESS_CPUTIME_ID = 15; + +pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); +pub const MAP_SHARED = 0x0001; +pub const MAP_PRIVATE = 0x0002; +pub const MAP_FIXED = 0x0010; +pub const MAP_STACK = 0x0400; +pub const MAP_NOSYNC = 0x0800; +pub const MAP_ANON = 0x1000; +pub const MAP_ANONYMOUS = MAP_ANON; +pub const MAP_FILE = 0; + +pub const MAP_GUARD = 0x00002000; +pub const MAP_EXCL = 0x00004000; +pub const MAP_NOCORE = 0x00020000; +pub const MAP_PREFAULT_READ = 0x00040000; +pub const MAP_32BIT = 0x00080000; + +pub const WNOHANG = 1; +pub const WUNTRACED = 2; +pub const WSTOPPED = WUNTRACED; +pub const WCONTINUED = 4; +pub const WNOWAIT = 8; +pub const WEXITED = 16; +pub const WTRAPPED = 32; + +pub const SA_ONSTACK = 0x0001; +pub const SA_RESTART = 0x0002; +pub const SA_RESETHAND = 0x0004; +pub const SA_NOCLDSTOP = 0x0008; +pub const SA_NODEFER = 0x0010; +pub const SA_NOCLDWAIT = 0x0020; +pub const SA_SIGINFO = 0x0040; + +pub const SIGHUP = 1; +pub const SIGINT = 2; +pub const SIGQUIT = 3; +pub const SIGILL = 4; +pub const SIGTRAP = 5; +pub const SIGABRT = 6; +pub const SIGIOT = SIGABRT; +pub const SIGEMT = 7; +pub const SIGFPE = 8; +pub const SIGKILL = 9; +pub const SIGBUS = 10; +pub const SIGSEGV = 11; +pub const SIGSYS = 12; +pub const SIGPIPE = 13; +pub const SIGALRM = 14; +pub const SIGTERM = 15; +pub const SIGURG = 16; +pub const SIGSTOP = 17; +pub const SIGTSTP = 18; +pub const SIGCONT = 19; +pub const SIGCHLD = 20; +pub const SIGTTIN = 21; +pub const SIGTTOU = 22; +pub const SIGIO = 23; +pub const SIGXCPU = 24; +pub const SIGXFSZ = 25; +pub const SIGVTALRM = 26; +pub const SIGPROF = 27; +pub const SIGWINCH = 28; +pub const SIGINFO = 29; +pub const SIGUSR1 = 30; +pub const SIGUSR2 = 31; +pub const SIGTHR = 32; +pub const SIGLWP = SIGTHR; +pub const SIGLIBRT = 33; + +pub const SIGRTMIN = 65; +pub const SIGRTMAX = 126; + +// access function +pub const F_OK = 0; // test for existence of file +pub const X_OK = 1; // test for execute or search permission +pub const W_OK = 2; // test for write permission +pub const R_OK = 4; // test for read permission + +pub const O_RDONLY = 0x0000; +pub const O_WRONLY = 0x0001; +pub const O_RDWR = 0x0002; +pub const O_ACCMODE = 0x0003; + +pub const O_SHLOCK = 0x0010; +pub const O_EXLOCK = 0x0020; + +pub const O_CREAT = 0x0200; +pub const O_EXCL = 0x0800; +pub const O_NOCTTY = 0x8000; +pub const O_TRUNC = 0x0400; +pub const O_APPEND = 0x0008; +pub const O_NONBLOCK = 0x0004; +pub const O_DSYNC = 0o10000; +pub const O_SYNC = 0x0080; +pub const O_RSYNC = 0o4010000; +pub const O_DIRECTORY = 0x20000; +pub const O_NOFOLLOW = 0x0100; +pub const O_CLOEXEC = 0x00100000; + +pub const O_ASYNC = 0x0040; +pub const O_DIRECT = 0x00010000; +pub const O_NOATIME = 0o1000000; +pub const O_PATH = 0o10000000; +pub const O_TMPFILE = 0o20200000; +pub const O_NDELAY = O_NONBLOCK; + +pub const F_DUPFD = 0; +pub const F_GETFD = 1; +pub const F_SETFD = 2; +pub const F_GETFL = 3; +pub const F_SETFL = 4; + +pub const F_GETOWN = 5; +pub const F_SETOWN = 6; + +pub const F_GETLK = 11; +pub const F_SETLK = 12; +pub const F_SETLKW = 13; + +pub const F_RDLCK = 1; +pub const F_WRLCK = 3; +pub const F_UNLCK = 2; + +pub const LOCK_SH = 1; +pub const LOCK_EX = 2; +pub const LOCK_UN = 8; +pub const LOCK_NB = 4; + +pub const F_SETOWN_EX = 15; +pub const F_GETOWN_EX = 16; + +pub const F_GETOWNER_UIDS = 17; + +pub const FD_CLOEXEC = 1; + +pub const SEEK_SET = 0; +pub const SEEK_CUR = 1; +pub const SEEK_END = 2; + +pub const SIG_BLOCK = 1; +pub const SIG_UNBLOCK = 2; +pub const SIG_SETMASK = 3; + +pub const SOCK_STREAM = 1; +pub const SOCK_DGRAM = 2; +pub const SOCK_RAW = 3; +pub const SOCK_RDM = 4; +pub const SOCK_SEQPACKET = 5; + +pub const SOCK_CLOEXEC = 0x10000000; +pub const SOCK_NONBLOCK = 0x20000000; + +pub const SO_DEBUG = 0x00000001; +pub const SO_ACCEPTCONN = 0x00000002; +pub const SO_REUSEADDR = 0x00000004; +pub const SO_KEEPALIVE = 0x00000008; +pub const SO_DONTROUTE = 0x00000010; +pub const SO_BROADCAST = 0x00000020; +pub const SO_USELOOPBACK = 0x00000040; +pub const SO_LINGER = 0x00000080; +pub const SO_OOBINLINE = 0x00000100; +pub const SO_REUSEPORT = 0x00000200; +pub const SO_TIMESTAMP = 0x00000400; +pub const SO_NOSIGPIPE = 0x00000800; +pub const SO_ACCEPTFILTER = 0x00001000; +pub const SO_BINTIME = 0x00002000; +pub const SO_NO_OFFLOAD = 0x00004000; +pub const SO_NO_DDP = 0x00008000; +pub const SO_REUSEPORT_LB = 0x00010000; + +pub const SO_SNDBUF = 0x1001; +pub const SO_RCVBUF = 0x1002; +pub const SO_SNDLOWAT = 0x1003; +pub const SO_RCVLOWAT = 0x1004; +pub const SO_SNDTIMEO = 0x1005; +pub const SO_RCVTIMEO = 0x1006; +pub const SO_ERROR = 0x1007; +pub const SO_TYPE = 0x1008; +pub const SO_LABEL = 0x1009; +pub const SO_PEERLABEL = 0x1010; +pub const SO_LISTENQLIMIT = 0x1011; +pub const SO_LISTENQLEN = 0x1012; +pub const SO_LISTENINCQLEN = 0x1013; +pub const SO_SETFIB = 0x1014; +pub const SO_USER_COOKIE = 0x1015; +pub const SO_PROTOCOL = 0x1016; +pub const SO_PROTOTYPE = SO_PROTOCOL; +pub const SO_TS_CLOCK = 0x1017; +pub const SO_MAX_PACING_RATE = 0x1018; +pub const SO_DOMAIN = 0x1019; + +pub const SOL_SOCKET = 0xffff; + +pub const PF_UNSPEC = AF_UNSPEC; +pub const PF_LOCAL = AF_LOCAL; +pub const PF_UNIX = PF_LOCAL; +pub const PF_INET = AF_INET; +pub const PF_IMPLINK = AF_IMPLINK; +pub const PF_PUP = AF_PUP; +pub const PF_CHAOS = AF_CHAOS; +pub const PF_NETBIOS = AF_NETBIOS; +pub const PF_ISO = AF_ISO; +pub const PF_OSI = AF_ISO; +pub const PF_ECMA = AF_ECMA; +pub const PF_DATAKIT = AF_DATAKIT; +pub const PF_CCITT = AF_CCITT; +pub const PF_DECnet = AF_DECnet; +pub const PF_DLI = AF_DLI; +pub const PF_LAT = AF_LAT; +pub const PF_HYLINK = AF_HYLINK; +pub const PF_APPLETALK = AF_APPLETALK; +pub const PF_ROUTE = AF_ROUTE; +pub const PF_LINK = AF_LINK; +pub const PF_XTP = pseudo_AF_XTP; +pub const PF_COIP = AF_COIP; +pub const PF_CNT = AF_CNT; +pub const PF_SIP = AF_SIP; +pub const PF_IPX = AF_IPX; +pub const PF_RTIP = pseudo_AF_RTIP; +pub const PF_PIP = psuedo_AF_PIP; +pub const PF_ISDN = AF_ISDN; +pub const PF_KEY = pseudo_AF_KEY; +pub const PF_INET6 = pseudo_AF_INET6; +pub const PF_NATM = AF_NATM; +pub const PF_ATM = AF_ATM; +pub const PF_NETGRAPH = AF_NETGRAPH; +pub const PF_SLOW = AF_SLOW; +pub const PF_SCLUSTER = AF_SCLUSTER; +pub const PF_ARP = AF_ARP; +pub const PF_BLUETOOTH = AF_BLUETOOTH; +pub const PF_IEEE80211 = AF_IEEE80211; +pub const PF_INET_SDP = AF_INET_SDP; +pub const PF_INET6_SDP = AF_INET6_SDP; +pub const PF_MAX = AF_MAX; + +pub const AF_UNSPEC = 0; +pub const AF_UNIX = 1; +pub const AF_LOCAL = AF_UNIX; +pub const AF_FILE = AF_LOCAL; +pub const AF_INET = 2; +pub const AF_IMPLINK = 3; +pub const AF_PUP = 4; +pub const AF_CHAOS = 5; +pub const AF_NETBIOS = 6; +pub const AF_ISO = 7; +pub const AF_OSI = AF_ISO; +pub const AF_ECMA = 8; +pub const AF_DATAKIT = 9; +pub const AF_CCITT = 10; +pub const AF_SNA = 11; +pub const AF_DECnet = 12; +pub const AF_DLI = 13; +pub const AF_LAT = 14; +pub const AF_HYLINK = 15; +pub const AF_APPLETALK = 16; +pub const AF_ROUTE = 17; +pub const AF_LINK = 18; +pub const pseudo_AF_XTP = 19; +pub const AF_COIP = 20; +pub const AF_CNT = 21; +pub const pseudo_AF_RTIP = 22; +pub const AF_IPX = 23; +pub const AF_SIP = 24; +pub const pseudo_AF_PIP = 25; +pub const AF_ISDN = 26; +pub const AF_E164 = AF_ISDN; +pub const pseudo_AF_KEY = 27; +pub const AF_INET6 = 28; +pub const AF_NATM = 29; +pub const AF_ATM = 30; +pub const pseudo_AF_HDRCMPLT = 31; +pub const AF_NETGRAPH = 32; +pub const AF_SLOW = 33; +pub const AF_SCLUSTER = 34; +pub const AF_ARP = 35; +pub const AF_BLUETOOTH = 36; +pub const AF_IEEE80211 = 37; +pub const AF_INET_SDP = 40; +pub const AF_INET6_SDP = 42; +pub const AF_MAX = 42; + +pub const DT_UNKNOWN = 0; +pub const DT_FIFO = 1; +pub const DT_CHR = 2; +pub const DT_DIR = 4; +pub const DT_BLK = 6; +pub const DT_REG = 8; +pub const DT_LNK = 10; +pub const DT_SOCK = 12; +pub const DT_WHT = 14; + +/// add event to kq (implies enable) +pub const EV_ADD = 0x0001; + +/// delete event from kq +pub const EV_DELETE = 0x0002; + +/// enable event +pub const EV_ENABLE = 0x0004; + +/// disable event (not reported) +pub const EV_DISABLE = 0x0008; + +/// only report one occurrence +pub const EV_ONESHOT = 0x0010; + +/// clear event state after reporting +pub const EV_CLEAR = 0x0020; + +/// force immediate event output +/// ... with or without EV_ERROR +/// ... use KEVENT_FLAG_ERROR_EVENTS +/// on syscalls supporting flags +pub const EV_RECEIPT = 0x0040; + +/// disable event after reporting +pub const EV_DISPATCH = 0x0080; + +pub const EVFILT_READ = -1; +pub const EVFILT_WRITE = -2; + +/// attached to aio requests +pub const EVFILT_AIO = -3; + +/// attached to vnodes +pub const EVFILT_VNODE = -4; + +/// attached to struct proc +pub const EVFILT_PROC = -5; + +/// attached to struct proc +pub const EVFILT_SIGNAL = -6; + +/// timers +pub const EVFILT_TIMER = -7; + +/// Process descriptors +pub const EVFILT_PROCDESC = -8; + +/// Filesystem events +pub const EVFILT_FS = -9; + +pub const EVFILT_LIO = -10; + +/// User events +pub const EVFILT_USER = -11; + +/// Sendfile events +pub const EVFILT_SENDFILE = -12; + +pub const EVFILT_EMPTY = -13; + +/// On input, NOTE_TRIGGER causes the event to be triggered for output. +pub const NOTE_TRIGGER = 0x01000000; + +/// ignore input fflags +pub const NOTE_FFNOP = 0x00000000; + +/// and fflags +pub const NOTE_FFAND = 0x40000000; + +/// or fflags +pub const NOTE_FFOR = 0x80000000; + +/// copy fflags +pub const NOTE_FFCOPY = 0xc0000000; + +/// mask for operations +pub const NOTE_FFCTRLMASK = 0xc0000000; +pub const NOTE_FFLAGSMASK = 0x00ffffff; + +/// low water mark +pub const NOTE_LOWAT = 0x00000001; + +/// behave like poll() +pub const NOTE_FILE_POLL = 0x00000002; + +/// vnode was removed +pub const NOTE_DELETE = 0x00000001; + +/// data contents changed +pub const NOTE_WRITE = 0x00000002; + +/// size increased +pub const NOTE_EXTEND = 0x00000004; + +/// attributes changed +pub const NOTE_ATTRIB = 0x00000008; + +/// link count changed +pub const NOTE_LINK = 0x00000010; + +/// vnode was renamed +pub const NOTE_RENAME = 0x00000020; + +/// vnode access was revoked +pub const NOTE_REVOKE = 0x00000040; + +/// vnode was opened +pub const NOTE_OPEN = 0x00000080; + +/// file closed, fd did not allow write +pub const NOTE_CLOSE = 0x00000100; + +/// file closed, fd did allow write +pub const NOTE_CLOSE_WRITE = 0x00000200; + +/// file was read +pub const NOTE_READ = 0x00000400; + +/// process exited +pub const NOTE_EXIT = 0x80000000; + +/// process forked +pub const NOTE_FORK = 0x40000000; + +/// process exec'd +pub const NOTE_EXEC = 0x20000000; + +/// mask for signal & exit status +pub const NOTE_PDATAMASK = 0x000fffff; +pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); + +/// data is seconds +pub const NOTE_SECONDS = 0x00000001; + +/// data is milliseconds +pub const NOTE_MSECONDS = 0x00000002; + +/// data is microseconds +pub const NOTE_USECONDS = 0x00000004; + +/// data is nanoseconds +pub const NOTE_NSECONDS = 0x00000008; + +/// timeout is absolute +pub const NOTE_ABSTIME = 0x00000010; + +pub const TIOCEXCL = 0x2000740d; +pub const TIOCNXCL = 0x2000740e; +pub const TIOCSCTTY = 0x20007461; +pub const TIOCGPGRP = 0x40047477; +pub const TIOCSPGRP = 0x80047476; +pub const TIOCOUTQ = 0x40047473; +pub const TIOCSTI = 0x80017472; +pub const TIOCGWINSZ = 0x40087468; +pub const TIOCSWINSZ = 0x80087467; +pub const TIOCMGET = 0x4004746a; +pub const TIOCMBIS = 0x8004746c; +pub const TIOCMBIC = 0x8004746b; +pub const TIOCMSET = 0x8004746d; +pub const FIONREAD = 0x4004667f; +pub const TIOCCONS = 0x80047462; +pub const TIOCPKT = 0x80047470; +pub const FIONBIO = 0x8004667e; +pub const TIOCNOTTY = 0x20007471; +pub const TIOCSETD = 0x8004741b; +pub const TIOCGETD = 0x4004741a; +pub const TIOCSBRK = 0x2000747b; +pub const TIOCCBRK = 0x2000747a; +pub const TIOCGSID = 0x40047463; +pub const TIOCGPTN = 0x4004740f; +pub const TIOCSIG = 0x2004745f; + +pub fn WEXITSTATUS(s: u32) u32 { + return (s & 0xff00) >> 8; +} +pub fn WTERMSIG(s: u32) u32 { + return s & 0x7f; +} +pub fn WSTOPSIG(s: u32) u32 { + return WEXITSTATUS(s); +} +pub fn WIFEXITED(s: u32) bool { + return WTERMSIG(s) == 0; +} +pub fn WIFSTOPPED(s: u32) bool { + return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; +} +pub fn WIFSIGNALED(s: u32) bool { + return (s & 0xffff) -% 1 < 0xff; +} + +pub const winsize = extern struct { + ws_row: u16, + ws_col: u16, + ws_xpixel: u16, + ws_ypixel: u16, +}; + +const NSIG = 32; + +pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize)); +pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0); +pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1); + +/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. +pub const Sigaction = extern struct { + /// signal handler + __sigaction_u: extern union { + __sa_handler: fn (i32) callconv(.C) void, + __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void, + }, + + /// see signal options + sa_flags: u32, + + /// signal mask to apply + sa_mask: sigset_t, +}; + +pub const _SIG_WORDS = 4; +pub const _SIG_MAXSIG = 128; + +pub inline fn _SIG_IDX(sig: usize) usize { + return sig - 1; +} +pub inline fn _SIG_WORD(sig: usize) usize { + return_SIG_IDX(sig) >> 5; +} +pub inline fn _SIG_BIT(sig: usize) usize { + return 1 << (_SIG_IDX(sig) & 31); +} +pub inline fn _SIG_VALID(sig: usize) usize { + return sig <= _SIG_MAXSIG and sig > 0; +} + +pub const sigset_t = extern struct { + __bits: [_SIG_WORDS]u32, +}; + +pub const EPERM = 1; // Operation not permitted +pub const ENOENT = 2; // No such file or directory +pub const ESRCH = 3; // No such process +pub const EINTR = 4; // Interrupted system call +pub const EIO = 5; // Input/output error +pub const ENXIO = 6; // Device not configured +pub const E2BIG = 7; // Argument list too long +pub const ENOEXEC = 8; // Exec format error +pub const EBADF = 9; // Bad file descriptor +pub const ECHILD = 10; // No child processes +pub const EDEADLK = 11; // Resource deadlock avoided +// 11 was EAGAIN +pub const ENOMEM = 12; // Cannot allocate memory +pub const EACCES = 13; // Permission denied +pub const EFAULT = 14; // Bad address +pub const ENOTBLK = 15; // Block device required +pub const EBUSY = 16; // Device busy +pub const EEXIST = 17; // File exists +pub const EXDEV = 18; // Cross-device link +pub const ENODEV = 19; // Operation not supported by device +pub const ENOTDIR = 20; // Not a directory +pub const EISDIR = 21; // Is a directory +pub const EINVAL = 22; // Invalid argument +pub const ENFILE = 23; // Too many open files in system +pub const EMFILE = 24; // Too many open files +pub const ENOTTY = 25; // Inappropriate ioctl for device +pub const ETXTBSY = 26; // Text file busy +pub const EFBIG = 27; // File too large +pub const ENOSPC = 28; // No space left on device +pub const ESPIPE = 29; // Illegal seek +pub const EROFS = 30; // Read-only filesystem +pub const EMLINK = 31; // Too many links +pub const EPIPE = 32; // Broken pipe + +// math software +pub const EDOM = 33; // Numerical argument out of domain +pub const ERANGE = 34; // Result too large + +// non-blocking and interrupt i/o +pub const EAGAIN = 35; // Resource temporarily unavailable +pub const EWOULDBLOCK = EAGAIN; // Operation would block +pub const EINPROGRESS = 36; // Operation now in progress +pub const EALREADY = 37; // Operation already in progress + +// ipc/network software -- argument errors +pub const ENOTSOCK = 38; // Socket operation on non-socket +pub const EDESTADDRREQ = 39; // Destination address required +pub const EMSGSIZE = 40; // Message too long +pub const EPROTOTYPE = 41; // Protocol wrong type for socket +pub const ENOPROTOOPT = 42; // Protocol not available +pub const EPROTONOSUPPORT = 43; // Protocol not supported +pub const ESOCKTNOSUPPORT = 44; // Socket type not supported +pub const EOPNOTSUPP = 45; // Operation not supported +pub const ENOTSUP = EOPNOTSUPP; // Operation not supported +pub const EPFNOSUPPORT = 46; // Protocol family not supported +pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family +pub const EADDRINUSE = 48; // Address already in use +pub const EADDRNOTAVAIL = 49; // Can't assign requested address + +// ipc/network software -- operational errors +pub const ENETDOWN = 50; // Network is down +pub const ENETUNREACH = 51; // Network is unreachable +pub const ENETRESET = 52; // Network dropped connection on reset +pub const ECONNABORTED = 53; // Software caused connection abort +pub const ECONNRESET = 54; // Connection reset by peer +pub const ENOBUFS = 55; // No buffer space available +pub const EISCONN = 56; // Socket is already connected +pub const ENOTCONN = 57; // Socket is not connected +pub const ESHUTDOWN = 58; // Can't send after socket shutdown +pub const ETOOMANYREFS = 59; // Too many references: can't splice +pub const ETIMEDOUT = 60; // Operation timed out +pub const ECONNREFUSED = 61; // Connection refused + +pub const ELOOP = 62; // Too many levels of symbolic links +pub const ENAMETOOLONG = 63; // File name too long + +// should be rearranged +pub const EHOSTDOWN = 64; // Host is down +pub const EHOSTUNREACH = 65; // No route to host +pub const ENOTEMPTY = 66; // Directory not empty + +// quotas & mush +pub const EPROCLIM = 67; // Too many processes +pub const EUSERS = 68; // Too many users +pub const EDQUOT = 69; // Disc quota exceeded + +// Network File System +pub const ESTALE = 70; // Stale NFS file handle +pub const EREMOTE = 71; // Too many levels of remote in path +pub const EBADRPC = 72; // RPC struct is bad +pub const ERPCMISMATCH = 73; // RPC version wrong +pub const EPROGUNAVAIL = 74; // RPC prog. not avail +pub const EPROGMISMATCH = 75; // Program version wrong +pub const EPROCUNAVAIL = 76; // Bad procedure for program + +pub const ENOLCK = 77; // No locks available +pub const ENOSYS = 78; // Function not implemented + +pub const EFTYPE = 79; // Inappropriate file type or format +pub const EAUTH = 80; // Authentication error +pub const ENEEDAUTH = 81; // Need authenticator +pub const EIDRM = 82; // Identifier removed +pub const ENOMSG = 83; // No message of desired type +pub const EOVERFLOW = 84; // Value too large to be stored in data type +pub const ECANCELED = 85; // Operation canceled +pub const EILSEQ = 86; // Illegal byte sequence +pub const ENOATTR = 87; // Attribute not found + +pub const EDOOFUS = 88; // Programming error + +pub const EBADMSG = 89; // Bad message +pub const EMULTIHOP = 90; // Multihop attempted +pub const ENOLINK = 91; // Link has been severed +pub const EPROTO = 92; // Protocol error + +pub const ENOTCAPABLE = 93; // Capabilities insufficient +pub const ECAPMODE = 94; // Not permitted in capability mode +pub const ENOTRECOVERABLE = 95; // State not recoverable +pub const EOWNERDEAD = 96; // Previous owner died + +pub const ELAST = 96; // Must be equal largest errno + +pub const MINSIGSTKSZ = switch (builtin.arch) { + .i386, .x86_64 => 2048, + .arm, .aarch64 => 4096, + else => @compileError("MINSIGSTKSZ not defined for this architecture"), +}; +pub const SIGSTKSZ = MINSIGSTKSZ + 32768; + +pub const SS_ONSTACK = 1; +pub const SS_DISABLE = 4; + +pub const stack_t = extern struct { + ss_sp: [*]u8, + ss_size: isize, + ss_flags: i32, +}; + +pub const S_IFMT = 0o170000; + +pub const S_IFIFO = 0o010000; +pub const S_IFCHR = 0o020000; +pub const S_IFDIR = 0o040000; +pub const S_IFBLK = 0o060000; +pub const S_IFREG = 0o100000; +pub const S_IFLNK = 0o120000; +pub const S_IFSOCK = 0o140000; +pub const S_IFWHT = 0o160000; + +pub const S_ISUID = 0o4000; +pub const S_ISGID = 0o2000; +pub const S_ISVTX = 0o1000; +pub const S_IRWXU = 0o700; +pub const S_IRUSR = 0o400; +pub const S_IWUSR = 0o200; +pub const S_IXUSR = 0o100; +pub const S_IRWXG = 0o070; +pub const S_IRGRP = 0o040; +pub const S_IWGRP = 0o020; +pub const S_IXGRP = 0o010; +pub const S_IRWXO = 0o007; +pub const S_IROTH = 0o004; +pub const S_IWOTH = 0o002; +pub const S_IXOTH = 0o001; + +pub fn S_ISFIFO(m: u32) bool { + return m & S_IFMT == S_IFIFO; +} + +pub fn S_ISCHR(m: u32) bool { + return m & S_IFMT == S_IFCHR; +} + +pub fn S_ISDIR(m: u32) bool { + return m & S_IFMT == S_IFDIR; +} + +pub fn S_ISBLK(m: u32) bool { + return m & S_IFMT == S_IFBLK; +} + +pub fn S_ISREG(m: u32) bool { + return m & S_IFMT == S_IFREG; +} + +pub fn S_ISLNK(m: u32) bool { + return m & S_IFMT == S_IFLNK; +} + +pub fn S_ISSOCK(m: u32) bool { + return m & S_IFMT == S_IFSOCK; +} + +pub fn S_IWHT(m: u32) bool { + return m & S_IFMT == S_IFWHT; +} + +pub const HOST_NAME_MAX = 255; + +/// Magic value that specify the use of the current working directory +/// to determine the target of relative file paths in the openat() and +/// similar syscalls. +pub const AT_FDCWD = -100; + +/// Check access using effective user and group ID +pub const AT_EACCESS = 0x0100; + +/// Do not follow symbolic links +pub const AT_SYMLINK_NOFOLLOW = 0x0200; + +/// Follow symbolic link +pub const AT_SYMLINK_FOLLOW = 0x0400; + +/// Remove directory instead of file +pub const AT_REMOVEDIR = 0x0800; + +pub const addrinfo = extern struct { + flags: i32, + family: i32, + socktype: i32, + protocol: i32, + addrlen: socklen_t, + canonname: ?[*:0]u8, + addr: ?*sockaddr, + next: ?*addrinfo, +}; + +/// Fail if not under dirfd +pub const AT_BENEATH = 0x1000; + +/// dummy for IP +pub const IPPROTO_IP = 0; + +/// control message protocol +pub const IPPROTO_ICMP = 1; + +/// tcp +pub const IPPROTO_TCP = 6; + +/// user datagram protocol +pub const IPPROTO_UDP = 17; + +/// IP6 header +pub const IPPROTO_IPV6 = 41; + +/// raw IP packet +pub const IPPROTO_RAW = 255; + +/// IP6 hop-by-hop options +pub const IPPROTO_HOPOPTS = 0; + +/// group mgmt protocol +pub const IPPROTO_IGMP = 2; + +/// gateway^2 (deprecated) +pub const IPPROTO_GGP = 3; + +/// IPv4 encapsulation +pub const IPPROTO_IPV4 = 4; + +/// for compatibility +pub const IPPROTO_IPIP = IPPROTO_IPV4; + +/// Stream protocol II +pub const IPPROTO_ST = 7; + +/// exterior gateway protocol +pub const IPPROTO_EGP = 8; + +/// private interior gateway +pub const IPPROTO_PIGP = 9; + +/// BBN RCC Monitoring +pub const IPPROTO_RCCMON = 10; + +/// network voice protocol +pub const IPPROTO_NVPII = 11; + +/// pup +pub const IPPROTO_PUP = 12; + +/// Argus +pub const IPPROTO_ARGUS = 13; + +/// EMCON +pub const IPPROTO_EMCON = 14; + +/// Cross Net Debugger +pub const IPPROTO_XNET = 15; + +/// Chaos +pub const IPPROTO_CHAOS = 16; + +/// Multiplexing +pub const IPPROTO_MUX = 18; + +/// DCN Measurement Subsystems +pub const IPPROTO_MEAS = 19; + +/// Host Monitoring +pub const IPPROTO_HMP = 20; + +/// Packet Radio Measurement +pub const IPPROTO_PRM = 21; + +/// xns idp +pub const IPPROTO_IDP = 22; + +/// Trunk-1 +pub const IPPROTO_TRUNK1 = 23; + +/// Trunk-2 +pub const IPPROTO_TRUNK2 = 24; + +/// Leaf-1 +pub const IPPROTO_LEAF1 = 25; + +/// Leaf-2 +pub const IPPROTO_LEAF2 = 26; + +/// Reliable Data +pub const IPPROTO_RDP = 27; + +/// Reliable Transaction +pub const IPPROTO_IRTP = 28; + +/// tp-4 w/ class negotiation +pub const IPPROTO_TP = 29; + +/// Bulk Data Transfer +pub const IPPROTO_BLT = 30; + +/// Network Services +pub const IPPROTO_NSP = 31; + +/// Merit Internodal +pub const IPPROTO_INP = 32; + +/// Datagram Congestion Control Protocol +pub const IPPROTO_DCCP = 33; + +/// Third Party Connect +pub const IPPROTO_3PC = 34; + +/// InterDomain Policy Routing +pub const IPPROTO_IDPR = 35; + +/// XTP +pub const IPPROTO_XTP = 36; + +/// Datagram Delivery +pub const IPPROTO_DDP = 37; + +/// Control Message Transport +pub const IPPROTO_CMTP = 38; + +/// TP++ Transport +pub const IPPROTO_TPXX = 39; + +/// IL transport protocol +pub const IPPROTO_IL = 40; + +/// Source Demand Routing +pub const IPPROTO_SDRP = 42; + +/// IP6 routing header +pub const IPPROTO_ROUTING = 43; + +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT = 44; + +/// InterDomain Routing +pub const IPPROTO_IDRP = 45; + +/// resource reservation +pub const IPPROTO_RSVP = 46; + +/// General Routing Encap. +pub const IPPROTO_GRE = 47; + +/// Mobile Host Routing +pub const IPPROTO_MHRP = 48; + +/// BHA +pub const IPPROTO_BHA = 49; + +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP = 50; + +/// IP6 Auth Header +pub const IPPROTO_AH = 51; + +/// Integ. Net Layer Security +pub const IPPROTO_INLSP = 52; + +/// IP with encryption +pub const IPPROTO_SWIPE = 53; + +/// Next Hop Resolution +pub const IPPROTO_NHRP = 54; + +/// IP Mobility +pub const IPPROTO_MOBILE = 55; + +/// Transport Layer Security +pub const IPPROTO_TLSP = 56; + +/// SKIP +pub const IPPROTO_SKIP = 57; + +/// ICMP6 +pub const IPPROTO_ICMPV6 = 58; + +/// IP6 no next header +pub const IPPROTO_NONE = 59; + +/// IP6 destination option +pub const IPPROTO_DSTOPTS = 60; + +/// any host internal protocol +pub const IPPROTO_AHIP = 61; + +/// CFTP +pub const IPPROTO_CFTP = 62; + +/// "hello" routing protocol +pub const IPPROTO_HELLO = 63; + +/// SATNET/Backroom EXPAK +pub const IPPROTO_SATEXPAK = 64; + +/// Kryptolan +pub const IPPROTO_KRYPTOLAN = 65; + +/// Remote Virtual Disk +pub const IPPROTO_RVD = 66; + +/// Pluribus Packet Core +pub const IPPROTO_IPPC = 67; + +/// Any distributed FS +pub const IPPROTO_ADFS = 68; + +/// Satnet Monitoring +pub const IPPROTO_SATMON = 69; + +/// VISA Protocol +pub const IPPROTO_VISA = 70; + +/// Packet Core Utility +pub const IPPROTO_IPCV = 71; + +/// Comp. Prot. Net. Executive +pub const IPPROTO_CPNX = 72; + +/// Comp. Prot. HeartBeat +pub const IPPROTO_CPHB = 73; + +/// Wang Span Network +pub const IPPROTO_WSN = 74; + +/// Packet Video Protocol +pub const IPPROTO_PVP = 75; + +/// BackRoom SATNET Monitoring +pub const IPPROTO_BRSATMON = 76; + +/// Sun net disk proto (temp.) +pub const IPPROTO_ND = 77; + +/// WIDEBAND Monitoring +pub const IPPROTO_WBMON = 78; + +/// WIDEBAND EXPAK +pub const IPPROTO_WBEXPAK = 79; + +/// ISO cnlp +pub const IPPROTO_EON = 80; + +/// VMTP +pub const IPPROTO_VMTP = 81; + +/// Secure VMTP +pub const IPPROTO_SVMTP = 82; + +/// Banyon VINES +pub const IPPROTO_VINES = 83; + +/// TTP +pub const IPPROTO_TTP = 84; + +/// NSFNET-IGP +pub const IPPROTO_IGP = 85; + +/// dissimilar gateway prot. +pub const IPPROTO_DGP = 86; + +/// TCF +pub const IPPROTO_TCF = 87; + +/// Cisco/GXS IGRP +pub const IPPROTO_IGRP = 88; + +/// OSPFIGP +pub const IPPROTO_OSPFIGP = 89; + +/// Strite RPC protocol +pub const IPPROTO_SRPC = 90; + +/// Locus Address Resoloution +pub const IPPROTO_LARP = 91; + +/// Multicast Transport +pub const IPPROTO_MTP = 92; + +/// AX.25 Frames +pub const IPPROTO_AX25 = 93; + +/// IP encapsulated in IP +pub const IPPROTO_IPEIP = 94; + +/// Mobile Int.ing control +pub const IPPROTO_MICP = 95; + +/// Semaphore Comm. security +pub const IPPROTO_SCCSP = 96; + +/// Ethernet IP encapsulation +pub const IPPROTO_ETHERIP = 97; + +/// encapsulation header +pub const IPPROTO_ENCAP = 98; + +/// any private encr. scheme +pub const IPPROTO_APES = 99; + +/// GMTP +pub const IPPROTO_GMTP = 100; + +/// payload compression (IPComp) +pub const IPPROTO_IPCOMP = 108; + +/// SCTP +pub const IPPROTO_SCTP = 132; + +/// IPv6 Mobility Header +pub const IPPROTO_MH = 135; + +/// UDP-Lite +pub const IPPROTO_UDPLITE = 136; + +/// IP6 Host Identity Protocol +pub const IPPROTO_HIP = 139; + +/// IP6 Shim6 Protocol +pub const IPPROTO_SHIM6 = 140; + +/// Protocol Independent Mcast +pub const IPPROTO_PIM = 103; + +/// CARP +pub const IPPROTO_CARP = 112; + +/// PGM +pub const IPPROTO_PGM = 113; + +/// MPLS-in-IP +pub const IPPROTO_MPLS = 137; + +/// PFSYNC +pub const IPPROTO_PFSYNC = 240; + +/// Reserved +pub const IPPROTO_RESERVED_253 = 253; + +/// Reserved +pub const IPPROTO_RESERVED_254 = 254; + +pub const rlimit_resource = extern enum(c_int) { + CPU = 0, + FSIZE = 1, + DATA = 2, + STACK = 3, + CORE = 4, + RSS = 5, + MEMLOCK = 6, + NPROC = 7, + NOFILE = 8, + SBSIZE = 9, + VMEM = 10, + AS = 10, + NPTS = 11, + SWAP = 12, + KQUEUES = 13, + UMTXP = 14, + + _, +}; + +pub const rlim_t = i64; + +/// No limit +pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; + +pub const RLIM_SAVED_MAX = RLIM_INFINITY; +pub const RLIM_SAVED_CUR = RLIM_INFINITY; + +pub const rlimit = extern struct { + /// Soft limit + cur: rlim_t, + /// Hard limit + max: rlim_t, +}; + +pub const SHUT_RD = 0; +pub const SHUT_WR = 1; +pub const SHUT_RDWR = 2; + +// TODO fill out if needed +pub const directory_which = extern enum(c_int) { + B_USER_SETTINGS_DIRECTORY = 0xbbe, + + _, +}; diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index e86a08e861..8d3d5c49a3 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -533,6 +533,59 @@ pub const SOL_TLS = 282; pub const SOMAXCONN = 128; +pub const IP_TOS = 1; +pub const IP_TTL = 2; +pub const IP_HDRINCL = 3; +pub const IP_OPTIONS = 4; +pub const IP_ROUTER_ALERT = 5; +pub const IP_RECVOPTS = 6; +pub const IP_RETOPTS = 7; +pub const IP_PKTINFO = 8; +pub const IP_PKTOPTIONS = 9; +pub const IP_PMTUDISC = 10; +pub const IP_MTU_DISCOVER = 10; +pub const IP_RECVERR = 11; +pub const IP_RECVTTL = 12; +pub const IP_RECVTOS = 13; +pub const IP_MTU = 14; +pub const IP_FREEBIND = 15; +pub const IP_IPSEC_POLICY = 16; +pub const IP_XFRM_POLICY = 17; +pub const IP_PASSSEC = 18; +pub const IP_TRANSPARENT = 19; +pub const IP_ORIGDSTADDR = 20; +pub const IP_RECVORIGDSTADDR = IP_ORIGDSTADDR; +pub const IP_MINTTL = 21; +pub const IP_NODEFRAG = 22; +pub const IP_CHECKSUM = 23; +pub const IP_BIND_ADDRESS_NO_PORT = 24; +pub const IP_RECVFRAGSIZE = 25; +pub const IP_MULTICAST_IF = 32; +pub const IP_MULTICAST_TTL = 33; +pub const IP_MULTICAST_LOOP = 34; +pub const IP_ADD_MEMBERSHIP = 35; +pub const IP_DROP_MEMBERSHIP = 36; +pub const IP_UNBLOCK_SOURCE = 37; +pub const IP_BLOCK_SOURCE = 38; +pub const IP_ADD_SOURCE_MEMBERSHIP = 39; +pub const IP_DROP_SOURCE_MEMBERSHIP = 40; +pub const IP_MSFILTER = 41; +pub const IP_MULTICAST_ALL = 49; +pub const IP_UNICAST_IF = 50; + +pub const IP_RECVRETOPTS = IP_RETOPTS; + +pub const IP_PMTUDISC_DONT = 0; +pub const IP_PMTUDISC_WANT = 1; +pub const IP_PMTUDISC_DO = 2; +pub const IP_PMTUDISC_PROBE = 3; +pub const IP_PMTUDISC_INTERFACE = 4; +pub const IP_PMTUDISC_OMIT = 5; + +pub const IP_DEFAULT_MULTICAST_TTL = 1; +pub const IP_DEFAULT_MULTICAST_LOOP = 1; +pub const IP_MAX_MEMBERSHIPS = 20; + pub const MSG_OOB = 0x0001; pub const MSG_PEEK = 0x0002; pub const MSG_DONTROUTE = 0x0004; @@ -1284,6 +1337,9 @@ pub const IORING_SETUP_CLAMP = 1 << 4; /// attach to existing wq pub const IORING_SETUP_ATTACH_WQ = 1 << 5; +/// start with ring disabled +pub const IORING_SETUP_R_DISABLED = 1 << 6; + pub const io_sqring_offsets = extern struct { /// offset of ring head head: u32, @@ -1430,6 +1486,11 @@ pub const io_uring_cqe = extern struct { flags: u32, }; +// io_uring_cqe.flags + +/// If set, the upper 16 bits are the buffer ID +pub const IORING_CQE_F_BUFFER = 1 << 0; + pub const IORING_OFF_SQ_RING = 0; pub const IORING_OFF_CQ_RING = 0x8000000; pub const IORING_OFF_SQES = 0x10000000; @@ -1439,7 +1500,7 @@ pub const IORING_ENTER_GETEVENTS = 1 << 0; pub const IORING_ENTER_SQ_WAKEUP = 1 << 1; // io_uring_register opcodes and arguments -pub const IORING_REGISTER = extern enum(u32) { +pub const IORING_REGISTER = extern enum(u8) { REGISTER_BUFFERS, UNREGISTER_BUFFERS, REGISTER_FILES, @@ -1451,11 +1512,13 @@ pub const IORING_REGISTER = extern enum(u32) { REGISTER_PROBE, REGISTER_PERSONALITY, UNREGISTER_PERSONALITY, + REGISTER_RESTRICTIONS, + REGISTER_ENABLE_RINGS, _, }; -pub const io_uring_files_update = struct { +pub const io_uring_files_update = extern struct { offset: u32, resv: u32, fds: u64, @@ -1463,7 +1526,7 @@ pub const io_uring_files_update = struct { pub const IO_URING_OP_SUPPORTED = 1 << 0; -pub const io_uring_probe_op = struct { +pub const io_uring_probe_op = extern struct { op: IORING_OP, resv: u8, @@ -1474,7 +1537,7 @@ pub const io_uring_probe_op = struct { resv2: u32, }; -pub const io_uring_probe = struct { +pub const io_uring_probe = extern struct { /// last opcode supported last_op: IORING_OP, @@ -1487,6 +1550,39 @@ pub const io_uring_probe = struct { // Followed by up to `ops_len` io_uring_probe_op structures }; +pub const io_uring_restriction = extern struct { + opcode: u16, + arg: extern union { + /// IORING_RESTRICTION_REGISTER_OP + register_op: IORING_REGISTER, + + /// IORING_RESTRICTION_SQE_OP + sqe_op: IORING_OP, + + /// IORING_RESTRICTION_SQE_FLAGS_* + sqe_flags: u8, + }, + resv: u8, + resv2: u32[3], +}; + +/// io_uring_restriction->opcode values +pub const IORING_RESTRICTION = extern enum(u8) { + /// Allow an io_uring_register(2) opcode + REGISTER_OP = 0, + + /// Allow an sqe opcode + SQE_OP = 1, + + /// Allow sqe flags + SQE_FLAGS_ALLOWED = 2, + + /// Require sqe flags (these flags must be set on each submission) + SQE_FLAGS_REQUIRED = 3, + + _, +}; + pub const utsname = extern struct { sysname: [64:0]u8, nodename: [64:0]u8, @@ -1837,6 +1933,120 @@ pub const tcflag_t = u32; pub const NCCS = 32; +pub const B0 = 0o0000000; +pub const B50 = 0o0000001; +pub const B75 = 0o0000002; +pub const B110 = 0o0000003; +pub const B134 = 0o0000004; +pub const B150 = 0o0000005; +pub const B200 = 0o0000006; +pub const B300 = 0o0000007; +pub const B600 = 0o0000010; +pub const B1200 = 0o0000011; +pub const B1800 = 0o0000012; +pub const B2400 = 0o0000013; +pub const B4800 = 0o0000014; +pub const B9600 = 0o0000015; +pub const B19200 = 0o0000016; +pub const B38400 = 0o0000017; +pub const BOTHER = 0o0010000; +pub const B57600 = 0o0010001; +pub const B115200 = 0o0010002; +pub const B230400 = 0o0010003; +pub const B460800 = 0o0010004; +pub const B500000 = 0o0010005; +pub const B576000 = 0o0010006; +pub const B921600 = 0o0010007; +pub const B1000000 = 0o0010010; +pub const B1152000 = 0o0010011; +pub const B1500000 = 0o0010012; +pub const B2000000 = 0o0010013; +pub const B2500000 = 0o0010014; +pub const B3000000 = 0o0010015; +pub const B3500000 = 0o0010016; +pub const B4000000 = 0o0010017; + +pub usingnamespace switch (builtin.arch) { + .powerpc, .powerpc64, .powerpc64le => struct { + pub const VINTR = 0; + pub const VQUIT = 1; + pub const VERASE = 2; + pub const VKILL = 3; + pub const VEOF = 4; + pub const VMIN = 5; + pub const VEOL = 6; + pub const VTIME = 7; + pub const VEOL2 = 8; + pub const VSWTC = 9; + pub const VWERASE = 10; + pub const VREPRINT = 11; + pub const VSUSP = 12; + pub const VSTART = 13; + pub const VSTOP = 14; + pub const VLNEXT = 15; + pub const VDISCARD = 16; + }, + .sparc, .sparcv9 => struct { + pub const VINTR = 0; + pub const VQUIT = 1; + pub const VERASE = 2; + pub const VKILL = 3; + pub const VEOF = 4; + pub const VEOL = 5; + pub const VEOL2 = 6; + pub const VSWTC = 7; + pub const VSTART = 8; + pub const VSTOP = 9; + pub const VSUSP = 10; + pub const VDSUSP = 11; + pub const VREPRINT = 12; + pub const VDISCARD = 13; + pub const VWERASE = 14; + pub const VLNEXT = 15; + pub const VMIN = VEOF; + pub const VTIME = VEOL; + }, + .mips, .mipsel, .mips64, .mips64el => struct { + pub const VINTR = 0; + pub const VQUIT = 1; + pub const VERASE = 2; + pub const VKILL = 3; + pub const VMIN = 4; + pub const VTIME = 5; + pub const VEOL2 = 6; + pub const VSWTC = 7; + pub const VSWTCH = 7; + pub const VSTART = 8; + pub const VSTOP = 9; + pub const VSUSP = 10; + pub const VREPRINT = 12; + pub const VDISCARD = 13; + pub const VWERASE = 14; + pub const VLNEXT = 15; + pub const VEOF = 16; + pub const VEOL = 17; + }, + else => struct { + pub const VINTR = 0; + pub const VQUIT = 1; + pub const VERASE = 2; + pub const VKILL = 3; + pub const VEOF = 4; + pub const VTIME = 5; + pub const VMIN = 6; + pub const VSWTC = 7; + pub const VSTART = 8; + pub const VSTOP = 9; + pub const VSUSP = 10; + pub const VEOL = 11; + pub const VREPRINT = 12; + pub const VDISCARD = 13; + pub const VWERASE = 14; + pub const VLNEXT = 15; + pub const VEOL2 = 16; + }, +}; + pub const IGNBRK = 1; pub const BRKINT = 2; pub const IGNPAR = 4; @@ -2012,3 +2222,25 @@ pub const rlimit = extern struct { /// Hard limit max: rlim_t, }; + +pub const MADV_NORMAL = 0; +pub const MADV_RANDOM = 1; +pub const MADV_SEQUENTIAL = 2; +pub const MADV_WILLNEED = 3; +pub const MADV_DONTNEED = 4; +pub const MADV_FREE = 8; +pub const MADV_REMOVE = 9; +pub const MADV_DONTFORK = 10; +pub const MADV_DOFORK = 11; +pub const MADV_MERGEABLE = 12; +pub const MADV_UNMERGEABLE = 13; +pub const MADV_HUGEPAGE = 14; +pub const MADV_NOHUGEPAGE = 15; +pub const MADV_DONTDUMP = 16; +pub const MADV_DODUMP = 17; +pub const MADV_WIPEONFORK = 18; +pub const MADV_KEEPONFORK = 19; +pub const MADV_COLD = 20; +pub const MADV_PAGEOUT = 21; +pub const MADV_HWPOISON = 100; +pub const MADV_SOFT_OFFLINE = 101; diff --git a/lib/std/os/bits/linux/arm-eabi.zig b/lib/std/os/bits/linux/arm-eabi.zig index d89e75ccd6..5673cb952b 100644 --- a/lib/std/os/bits/linux/arm-eabi.zig +++ b/lib/std/os/bits/linux/arm-eabi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -411,6 +411,8 @@ pub const SYS = extern enum(usize) { openat2 = 437, pidfd_getfd = 438, faccessat2 = 439, + process_madvise = 440, + epoll_pwait2 = 441, breakpoint = 0x0f0001, cacheflush = 0x0f0002, diff --git a/lib/std/os/bits/linux/arm64.zig b/lib/std/os/bits/linux/arm64.zig index 22955aa896..a069b6adf1 100644 --- a/lib/std/os/bits/linux/arm64.zig +++ b/lib/std/os/bits/linux/arm64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -312,6 +312,8 @@ pub const SYS = extern enum(usize) { openat2 = 437, pidfd_getfd = 438, faccessat2 = 439, + process_madvise = 440, + epoll_pwait2 = 441, _, }; diff --git a/lib/std/os/bits/linux/errno-generic.zig b/lib/std/os/bits/linux/errno-generic.zig index a99f20a1a8..f55aa3698e 100644 --- a/lib/std/os/bits/linux/errno-generic.zig +++ b/lib/std/os/bits/linux/errno-generic.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/bits/linux/errno-mips.zig b/lib/std/os/bits/linux/errno-mips.zig index 1258863086..2c74fa6f8c 100644 --- a/lib/std/os/bits/linux/errno-mips.zig +++ b/lib/std/os/bits/linux/errno-mips.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/bits/linux/i386.zig b/lib/std/os/bits/linux/i386.zig index 92b21727c1..7ef34eb96b 100644 --- a/lib/std/os/bits/linux/i386.zig +++ b/lib/std/os/bits/linux/i386.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -447,6 +447,8 @@ pub const SYS = extern enum(usize) { openat2 = 437, pidfd_getfd = 438, faccessat2 = 439, + process_madvise = 440, + epoll_pwait2 = 441, _, }; diff --git a/lib/std/os/bits/linux/mips.zig b/lib/std/os/bits/linux/mips.zig index cfd9c7adce..412a1f48be 100644 --- a/lib/std/os/bits/linux/mips.zig +++ b/lib/std/os/bits/linux/mips.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -430,6 +430,7 @@ pub const SYS = extern enum(usize) { pidfd_getfd = Linux + 438, faccessat2 = Linux + 439, process_madvise = Linux + 440, + epoll_pwait2 = Linux + 441, _, }; diff --git a/lib/std/os/bits/linux/netlink.zig b/lib/std/os/bits/linux/netlink.zig index 3e75733b9a..72596cb1ab 100644 --- a/lib/std/os/bits/linux/netlink.zig +++ b/lib/std/os/bits/linux/netlink.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/bits/linux/powerpc64.zig b/lib/std/os/bits/linux/powerpc64.zig index 4313a609e4..e0e9347aa1 100644 --- a/lib/std/os/bits/linux/powerpc64.zig +++ b/lib/std/os/bits/linux/powerpc64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -408,6 +408,8 @@ pub const SYS = extern enum(usize) { openat2 = 437, pidfd_getfd = 438, faccessat2 = 439, + process_madvise = 440, + epoll_pwait2 = 441, _, }; diff --git a/lib/std/os/bits/linux/prctl.zig b/lib/std/os/bits/linux/prctl.zig index 6a601784ef..151acf4e71 100644 --- a/lib/std/os/bits/linux/prctl.zig +++ b/lib/std/os/bits/linux/prctl.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/bits/linux/riscv64.zig b/lib/std/os/bits/linux/riscv64.zig index a61b56db38..0cbdea415c 100644 --- a/lib/std/os/bits/linux/riscv64.zig +++ b/lib/std/os/bits/linux/riscv64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -309,6 +309,8 @@ pub const SYS = extern enum(usize) { openat2 = 437, pidfd_getfd = 438, faccessat2 = 439, + process_madvise = 440, + epoll_pwait2 = 441, _, }; diff --git a/lib/std/os/bits/linux/securebits.zig b/lib/std/os/bits/linux/securebits.zig index 0086a694d9..374f7c9f02 100644 --- a/lib/std/os/bits/linux/securebits.zig +++ b/lib/std/os/bits/linux/securebits.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/bits/linux/sparc64.zig b/lib/std/os/bits/linux/sparc64.zig index d4c65de36d..5644256a95 100644 --- a/lib/std/os/bits/linux/sparc64.zig +++ b/lib/std/os/bits/linux/sparc64.zig @@ -386,6 +386,8 @@ pub const SYS = extern enum(usize) { openat2 = 437, pidfd_getfd = 438, faccessat2 = 439, + process_madvise = 440, + epoll_pwait2 = 441, _, }; diff --git a/lib/std/os/bits/linux/x86_64.zig b/lib/std/os/bits/linux/x86_64.zig index 665c8f6eba..52fee679c5 100644 --- a/lib/std/os/bits/linux/x86_64.zig +++ b/lib/std/os/bits/linux/x86_64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -374,6 +374,8 @@ pub const SYS = extern enum(usize) { openat2 = 437, pidfd_getfd = 438, faccessat2 = 439, + process_madvise = 440, + epoll_pwait2 = 441, _, }; diff --git a/lib/std/os/bits/netbsd.zig b/lib/std/os/bits/netbsd.zig index be25284b73..57ae70ddbf 100644 --- a/lib/std/os/bits/netbsd.zig +++ b/lib/std/os/bits/netbsd.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -22,6 +22,7 @@ pub const socklen_t = u32; pub const time_t = i64; pub const uid_t = u32; pub const lwpid_t = i32; +pub const suseconds_t = c_int; /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. pub const Kevent = extern struct { @@ -190,6 +191,13 @@ pub const timespec = extern struct { tv_nsec: isize, }; +pub const timeval = extern struct { + /// seconds + tv_sec: time_t, + /// microseconds + tv_usec: suseconds_t, +}; + pub const MAXNAMLEN = 511; pub const dirent = extern struct { @@ -788,16 +796,16 @@ pub const _ksiginfo = extern struct { pub const _SIG_WORDS = 4; pub const _SIG_MAXSIG = 128; -pub inline fn _SIG_IDX(sig: usize) usize { +pub fn _SIG_IDX(sig: usize) callconv(.Inline) usize { return sig - 1; } -pub inline fn _SIG_WORD(sig: usize) usize { +pub fn _SIG_WORD(sig: usize) callconv(.Inline) usize { return_SIG_IDX(sig) >> 5; } -pub inline fn _SIG_BIT(sig: usize) usize { +pub fn _SIG_BIT(sig: usize) callconv(.Inline) usize { return 1 << (_SIG_IDX(sig) & 31); } -pub inline fn _SIG_VALID(sig: usize) usize { +pub fn _SIG_VALID(sig: usize) callconv(.Inline) usize { return sig <= _SIG_MAXSIG and sig > 0; } @@ -828,13 +836,15 @@ pub const ucontext_t = extern struct { sigmask: sigset_t, stack: stack_t, mcontext: mcontext_t, - __pad: [switch (builtin.arch) { - .i386 => 4, - .mips, .mipsel, .mips64, .mips64el => 14, - .arm, .armeb, .thumb, .thumbeb => 1, - .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8, - else => 0, - }]u32, + __pad: [ + switch (builtin.arch) { + .i386 => 4, + .mips, .mipsel, .mips64, .mips64el => 14, + .arm, .armeb, .thumb, .thumbeb => 1, + .sparc, .sparcel, .sparcv9 => if (@sizeOf(usize) == 4) 43 else 8, + else => 0, + } + ]u32, }; pub const EPERM = 1; // Operation not permitted diff --git a/lib/std/os/bits/openbsd.zig b/lib/std/os/bits/openbsd.zig index 2aae0cef09..8d1e74ec20 100644 --- a/lib/std/os/bits/openbsd.zig +++ b/lib/std/os/bits/openbsd.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -781,11 +781,17 @@ pub const siginfo_t = extern struct { data: extern union { proc: extern struct { pid: pid_t, - uid: uid_t, - value: sigval, - utime: clock_t, - stime: clock_t, - status: c_int, + pdata: extern union { + kill: extern struct { + uid: uid_t, + value: sigval, + }, + cld: extern struct { + utime: clock_t, + stime: clock_t, + status: c_int, + }, + }, }, fault: extern struct { addr: ?*c_void, @@ -803,6 +809,60 @@ comptime { std.debug.assert(@sizeOf(siginfo_t) == 136); } +pub usingnamespace switch (builtin.arch) { + .x86_64 => struct { + pub const ucontext_t = extern struct { + sc_rdi: c_long, + sc_rsi: c_long, + sc_rdx: c_long, + sc_rcx: c_long, + sc_r8: c_long, + sc_r9: c_long, + sc_r10: c_long, + sc_r11: c_long, + sc_r12: c_long, + sc_r13: c_long, + sc_r14: c_long, + sc_r15: c_long, + sc_rbp: c_long, + sc_rbx: c_long, + sc_rax: c_long, + sc_gs: c_long, + sc_fs: c_long, + sc_es: c_long, + sc_ds: c_long, + sc_trapno: c_long, + sc_err: c_long, + sc_rip: c_long, + sc_cs: c_long, + sc_rflags: c_long, + sc_rsp: c_long, + sc_ss: c_long, + + sc_fpstate: fxsave64, + __sc_unused: c_int, + sc_mask: c_int, + sc_cookie: c_long, + }; + + pub const fxsave64 = packed struct { + fx_fcw: u16, + fx_fsw: u16, + fx_ftw: u8, + fx_unused1: u8, + fx_fop: u16, + fx_rip: u64, + fx_rdp: u64, + fx_mxcsr: u32, + fx_mxcsr_mask: u32, + fx_st: [8][2]u64, + fx_xmm: [16][2]u64, + fx_unused3: [96]u8, + }; + }, + else => struct {}, +}; + pub const sigset_t = c_uint; pub const empty_sigset: sigset_t = 0; @@ -1149,3 +1209,23 @@ pub const rlimit = extern struct { pub const SHUT_RD = 0; pub const SHUT_WR = 1; pub const SHUT_RDWR = 2; + +pub const nfds_t = c_uint; + +pub const pollfd = extern struct { + fd: fd_t, + events: c_short, + revents: c_short, +}; + +pub const POLLIN = 0x0001; +pub const POLLPRI = 0x0002; +pub const POLLOUT = 0x0004; +pub const POLLERR = 0x0008; +pub const POLLHUP = 0x0010; +pub const POLLNVAL = 0x0020; +pub const POLLRDNORM = 0x0040; +pub const POLLNORM = POLLRDNORM; +pub const POLLWRNORM = POLLOUT; +pub const POLLRDBAND = 0x0080; +pub const POLLWRBAND = 0x0100; diff --git a/lib/std/os/bits/wasi.zig b/lib/std/os/bits/wasi.zig index 07275fc229..8b2f5c3351 100644 --- a/lib/std/os/bits/wasi.zig +++ b/lib/std/os/bits/wasi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/bits/windows.zig b/lib/std/os/bits/windows.zig index dda57208f8..28a6a251f8 100644 --- a/lib/std/os/bits/windows.zig +++ b/lib/std/os/bits/windows.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -243,6 +243,7 @@ pub const IPPROTO_UDP = ws2_32.IPPROTO_UDP; pub const IPPROTO_ICMPV6 = ws2_32.IPPROTO_ICMPV6; pub const IPPROTO_RM = ws2_32.IPPROTO_RM; +pub const nfds_t = c_ulong; pub const pollfd = ws2_32.pollfd; pub const POLLRDNORM = ws2_32.POLLRDNORM; diff --git a/lib/std/os/darwin.zig b/lib/std/os/darwin.zig index 1bd983398b..87a9ed12ac 100644 --- a/lib/std/os/darwin.zig +++ b/lib/std/os/darwin.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/dragonfly.zig b/lib/std/os/dragonfly.zig index a713a009ad..572b470239 100644 --- a/lib/std/os/dragonfly.zig +++ b/lib/std/os/dragonfly.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/freebsd.zig b/lib/std/os/freebsd.zig index a713a009ad..572b470239 100644 --- a/lib/std/os/freebsd.zig +++ b/lib/std/os/freebsd.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/io/out_stream.zig b/lib/std/os/haiku.zig similarity index 73% rename from lib/std/io/out_stream.zig rename to lib/std/os/haiku.zig index c937ccf16a..a713a009ad 100644 --- a/lib/std/io/out_stream.zig +++ b/lib/std/os/haiku.zig @@ -3,5 +3,6 @@ // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -/// Deprecated: use `std.io.writer.Writer` -pub const OutStream = @import("./writer.zig").Writer; +const std = @import("../std.zig"); +pub usingnamespace std.c; +pub usingnamespace @import("bits.zig"); diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index f840f6a255..035cdabe63 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -126,7 +126,7 @@ pub fn fork() usize { /// It is advised to avoid this function and use clone instead, because /// the compiler is not aware of how vfork affects control flow and you may /// see different results in optimized builds. -pub inline fn vfork() usize { +pub fn vfork() callconv(.Inline) usize { return @call(.{ .modifier = .always_inline }, syscall0, .{.vfork}); } @@ -634,6 +634,37 @@ pub fn tgkill(tgid: pid_t, tid: pid_t, sig: i32) usize { return syscall2(.tgkill, @bitCast(usize, @as(isize, tgid)), @bitCast(usize, @as(isize, tid)), @bitCast(usize, @as(isize, sig))); } +pub fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: i32) usize { + if (@hasField(SYS, "link")) { + return syscall3( + .link, + @ptrToInt(oldpath), + @ptrToInt(newpath), + @bitCast(usize, @as(isize, flags)), + ); + } else { + return syscall5( + .linkat, + @bitCast(usize, @as(isize, AT_FDCWD)), + @ptrToInt(oldpath), + @bitCast(usize, @as(isize, AT_FDCWD)), + @ptrToInt(newpath), + @bitCast(usize, @as(isize, flags)), + ); + } +} + +pub fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: i32) usize { + return syscall5( + .linkat, + @bitCast(usize, @as(isize, oldfd)), + @ptrToInt(oldpath), + @bitCast(usize, @as(isize, newfd)), + @ptrToInt(newpath), + @bitCast(usize, @as(isize, flags)), + ); +} + pub fn unlink(path: [*:0]const u8) usize { if (@hasField(SYS, "unlink")) { return syscall1(.unlink, @ptrToInt(path)); @@ -745,33 +776,33 @@ pub fn setregid(rgid: gid_t, egid: gid_t) usize { pub fn getuid() uid_t { if (@hasField(SYS, "getuid32")) { - return @as(uid_t, syscall0(.getuid32)); + return @intCast(uid_t, syscall0(.getuid32)); } else { - return @as(uid_t, syscall0(.getuid)); + return @intCast(uid_t, syscall0(.getuid)); } } pub fn getgid() gid_t { if (@hasField(SYS, "getgid32")) { - return @as(gid_t, syscall0(.getgid32)); + return @intCast(gid_t, syscall0(.getgid32)); } else { - return @as(gid_t, syscall0(.getgid)); + return @intCast(gid_t, syscall0(.getgid)); } } pub fn geteuid() uid_t { if (@hasField(SYS, "geteuid32")) { - return @as(uid_t, syscall0(.geteuid32)); + return @intCast(uid_t, syscall0(.geteuid32)); } else { - return @as(uid_t, syscall0(.geteuid)); + return @intCast(uid_t, syscall0(.geteuid)); } } pub fn getegid() gid_t { if (@hasField(SYS, "getegid32")) { - return @as(gid_t, syscall0(.getegid32)); + return @intCast(gid_t, syscall0(.getegid32)); } else { - return @as(gid_t, syscall0(.getegid)); + return @intCast(gid_t, syscall0(.getegid)); } } @@ -1351,7 +1382,11 @@ pub fn prlimit(pid: pid_t, resource: rlimit_resource, new_limit: ?*const rlimit, ); } -test "" { +pub fn madvise(address: [*]u8, len: usize, advice: u32) usize { + return syscall3(.madvise, @ptrToInt(address), len, advice); +} + +test { if (builtin.os.tag == .linux) { _ = @import("linux/test.zig"); } diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig index a72799a26a..bac7048615 100644 --- a/lib/std/os/linux/arm-eabi.zig +++ b/lib/std/os/linux/arm-eabi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/arm64.zig b/lib/std/os/linux/arm64.zig index 6727cbce8e..dd5c3ef3af 100644 --- a/lib/std/os/linux/arm64.zig +++ b/lib/std/os/linux/arm64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig index 44c938feb8..0d7e0a19ed 100644 --- a/lib/std/os/linux/bpf.zig +++ b/lib/std/os/linux/bpf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/bpf/btf.zig b/lib/std/os/linux/bpf/btf.zig index 5338994aff..b28f65945a 100644 --- a/lib/std/os/linux/bpf/btf.zig +++ b/lib/std/os/linux/bpf/btf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/bpf/btf_ext.zig b/lib/std/os/linux/bpf/btf_ext.zig index ce412fdf4e..ca713f1910 100644 --- a/lib/std/os/linux/bpf/btf_ext.zig +++ b/lib/std/os/linux/bpf/btf_ext.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/bpf/helpers.zig b/lib/std/os/linux/bpf/helpers.zig index 9228e1f1fd..c6f0bc0b5e 100644 --- a/lib/std/os/linux/bpf/helpers.zig +++ b/lib/std/os/linux/bpf/helpers.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/bpf/kern.zig b/lib/std/os/linux/bpf/kern.zig index a2e9d36aa1..d1b4347d85 100644 --- a/lib/std/os/linux/bpf/kern.zig +++ b/lib/std/os/linux/bpf/kern.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/i386.zig b/lib/std/os/linux/i386.zig index ed5bc88f0f..c1ac6938fb 100644 --- a/lib/std/os/linux/i386.zig +++ b/lib/std/os/linux/i386.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index 0fdc7651d2..b47d4c7b32 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -28,7 +28,7 @@ pub const IO_Uring = struct { /// call on how many entries the submission and completion queues will ultimately have, /// see https://github.com/torvalds/linux/blob/v5.8/fs/io_uring.c#L8027-L8050. /// Matches the interface of io_uring_queue_init() in liburing. - pub fn init(entries: u12, flags: u32) !IO_Uring { + pub fn init(entries: u13, flags: u32) !IO_Uring { var params = mem.zeroInit(io_uring_params, .{ .flags = flags, .sq_thread_idle = 1000, @@ -39,17 +39,15 @@ pub const IO_Uring = struct { /// A powerful way to setup an io_uring, if you want to tweak io_uring_params such as submission /// queue thread cpu affinity or thread idle timeout (the kernel and our default is 1 second). /// `params` is passed by reference because the kernel needs to modify the parameters. - /// You may only set the `flags`, `sq_thread_cpu` and `sq_thread_idle` parameters. - /// Every other parameter belongs to the kernel and must be zeroed. /// Matches the interface of io_uring_queue_init_params() in liburing. - pub fn init_params(entries: u12, p: *io_uring_params) !IO_Uring { + pub fn init_params(entries: u13, p: *io_uring_params) !IO_Uring { if (entries == 0) return error.EntriesZero; if (!std.math.isPowerOfTwo(entries)) return error.EntriesNotPowerOfTwo; assert(p.sq_entries == 0); - assert(p.cq_entries == 0); + assert(p.cq_entries == 0 or p.flags & linux.IORING_SETUP_CQSIZE != 0); assert(p.features == 0); - assert(p.wq_fd == 0); + assert(p.wq_fd == 0 or p.flags & linux.IORING_SETUP_ATTACH_WQ != 0); assert(p.resv[0] == 0); assert(p.resv[1] == 0); assert(p.resv[2] == 0); @@ -558,6 +556,22 @@ pub const IO_Uring = struct { return sqe; } + /// Queues (but does not submit) an SQE to perform an `fallocate(2)`. + /// Returns a pointer to the SQE. + pub fn fallocate( + self: *IO_Uring, + user_data: u64, + fd: os.fd_t, + mode: i32, + offset: u64, + len: u64, + ) !*io_uring_sqe { + const sqe = try self.get_sqe(); + io_uring_prep_fallocate(sqe, fd, mode, offset, len); + sqe.user_data = user_data; + return sqe; + } + /// Registers an array of file descriptors. /// Every time a file descriptor is put in an SQE and submitted to the kernel, the kernel must /// retrieve a reference to the file, and once I/O has completed the file reference must be @@ -896,6 +910,30 @@ pub fn io_uring_prep_timeout_remove(sqe: *io_uring_sqe, timeout_user_data: u64, }; } +pub fn io_uring_prep_fallocate( + sqe: *io_uring_sqe, + fd: os.fd_t, + mode: i32, + offset: u64, + len: u64, +) void { + sqe.* = .{ + .opcode = .FALLOCATE, + .flags = 0, + .ioprio = 0, + .fd = fd, + .off = offset, + .addr = len, + .len = @intCast(u32, mode), + .rw_flags = 0, + .user_data = 0, + .buf_index = 0, + .personality = 0, + .splice_fd_in = 0, + .__pad2 = [2]u64{ 0, 0 }, + }; +} + test "structs/offsets/entries" { if (builtin.os.tag != .linux) return error.SkipZigTest; @@ -1378,11 +1416,10 @@ test "timeout_remove" { // Timeout remove operations set the fd to -1, which results in EBADF before EINVAL. // We use IORING_FEAT_RW_CUR_POS as a safety check here to make sure we are at least pre-5.6. // We don't want to skip this test for newer kernels. - if ( - cqe_timeout.user_data == 0x99999999 and + if (cqe_timeout.user_data == 0x99999999 and cqe_timeout.res == -linux.EBADF and - (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0 - ) { + (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) + { return error.SkipZigTest; } testing.expectEqual(linux.io_uring_cqe{ @@ -1398,3 +1435,47 @@ test "timeout_remove" { .flags = 0, }, cqe_timeout_remove); } + +test "fallocate" { + if (builtin.os.tag != .linux) return error.SkipZigTest; + + var ring = IO_Uring.init(1, 0) catch |err| switch (err) { + error.SystemOutdated => return error.SkipZigTest, + error.PermissionDenied => return error.SkipZigTest, + else => return err, + }; + defer ring.deinit(); + + const path = "test_io_uring_fallocate"; + const file = try std.fs.cwd().createFile(path, .{ .truncate = true, .mode = 0o666 }); + defer file.close(); + defer std.fs.cwd().deleteFile(path) catch {}; + + testing.expectEqual(@as(u64, 0), (try file.stat()).size); + + const len: u64 = 65536; + const sqe = try ring.fallocate(0xaaaaaaaa, file.handle, 0, 0, len); + testing.expectEqual(linux.IORING_OP.FALLOCATE, sqe.opcode); + testing.expectEqual(file.handle, sqe.fd); + testing.expectEqual(@as(u32, 1), try ring.submit()); + + const cqe = try ring.copy_cqe(); + switch (-cqe.res) { + 0 => {}, + // This kernel's io_uring does not yet implement fallocate(): + linux.EINVAL => return error.SkipZigTest, + // This kernel does not implement fallocate(): + linux.ENOSYS => return error.SkipZigTest, + // The filesystem containing the file referred to by fd does not support this operation; + // or the mode is not supported by the filesystem containing the file referred to by fd: + linux.EOPNOTSUPP => return error.SkipZigTest, + else => |errno| std.debug.panic("unhandled errno: {}", .{errno}), + } + testing.expectEqual(linux.io_uring_cqe{ + .user_data = 0xaaaaaaaa, + .res = 0, + .flags = 0, + }, cqe); + + testing.expectEqual(len, (try file.stat()).size); +} diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig index ad673e06f9..2622628533 100644 --- a/lib/std/os/linux/mips.zig +++ b/lib/std/os/linux/mips.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/powerpc64.zig b/lib/std/os/linux/powerpc64.zig index 7252000f24..567ad2bc1f 100644 --- a/lib/std/os/linux/powerpc64.zig +++ b/lib/std/os/linux/powerpc64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/riscv64.zig b/lib/std/os/linux/riscv64.zig index 034340d0b3..d58e080407 100644 --- a/lib/std/os/linux/riscv64.zig +++ b/lib/std/os/linux/riscv64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/test.zig b/lib/std/os/linux/test.zig index 7b3840288a..039678e405 100644 --- a/lib/std/os/linux/test.zig +++ b/lib/std/os/linux/test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -9,6 +9,7 @@ const linux = std.os.linux; const mem = std.mem; const elf = std.elf; const expect = std.testing.expect; +const expectEqual = std.testing.expectEqual; const fs = std.fs; test "fallocate" { @@ -99,3 +100,11 @@ test "statx" { expect(@bitCast(u64, @as(i64, stat_buf.blksize)) == statx_buf.blksize); expect(@bitCast(u64, @as(i64, stat_buf.blocks)) == statx_buf.blocks); } + +test "user and group ids" { + if (builtin.link_libc) return error.SkipZigTest; + expectEqual(linux.getauxval(elf.AT_UID), linux.getuid()); + expectEqual(linux.getauxval(elf.AT_GID), linux.getgid()); + expectEqual(linux.getauxval(elf.AT_EUID), linux.geteuid()); + expectEqual(linux.getauxval(elf.AT_EGID), linux.getegid()); +} diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig index f6c339bc2c..614f5b4395 100644 --- a/lib/std/os/linux/tls.zig +++ b/lib/std/os/linux/tls.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -300,7 +300,7 @@ fn initTLS() void { }; } -inline fn alignPtrCast(comptime T: type, ptr: [*]u8) *T { +fn alignPtrCast(comptime T: type, ptr: [*]u8) callconv(.Inline) *T { return @ptrCast(*T, @alignCast(@alignOf(*T), ptr)); } @@ -327,32 +327,43 @@ pub fn prepareTLS(area: []u8) usize { if (tls_tp_points_past_tcb) tls_image.data_offset else tls_image.tcb_offset; } -var main_thread_tls_buffer: [256]u8 = undefined; +// The main motivation for the size chosen here is this is how much ends up being +// requested for the thread local variables of the std.crypto.random implementation. +// I'm not sure why it ends up being so much; the struct itself is only 64 bytes. +// I think it has to do with being page aligned and LLVM or LLD is not smart enough +// to lay out the TLS data in a space conserving way. Anyway I think it's fine +// because it's less than 3 pages of memory, and putting it in the ELF like this +// is equivalent to moving the mmap call below into the kernel, avoiding syscall +// overhead. +var main_thread_tls_buffer: [0x2100]u8 align(mem.page_size) = undefined; pub fn initStaticTLS() void { initTLS(); - const alloc_tls_area: []u8 = blk: { - const full_alloc_size = tls_image.alloc_size + tls_image.alloc_align - 1; - + const tls_area = blk: { // Fast path for the common case where the TLS data is really small, - // avoid an allocation and use our local buffer - if (full_alloc_size < main_thread_tls_buffer.len) - break :blk main_thread_tls_buffer[0..]; + // avoid an allocation and use our local buffer. + if (tls_image.alloc_align <= mem.page_size and + tls_image.alloc_size <= main_thread_tls_buffer.len) + { + break :blk main_thread_tls_buffer[0..tls_image.alloc_size]; + } - break :blk os.mmap( + const alloc_tls_area = os.mmap( null, - full_alloc_size, + tls_image.alloc_size + tls_image.alloc_align - 1, os.PROT_READ | os.PROT_WRITE, os.MAP_PRIVATE | os.MAP_ANONYMOUS, -1, 0, ) catch os.abort(); - }; - // Make sure the slice is correctly aligned - const start = @ptrToInt(alloc_tls_area.ptr) & (tls_image.alloc_align - 1); - const tls_area = alloc_tls_area[start .. start + tls_image.alloc_size]; + // Make sure the slice is correctly aligned. + const begin_addr = @ptrToInt(alloc_tls_area.ptr); + const begin_aligned_addr = mem.alignForward(begin_addr, tls_image.alloc_align); + const start = begin_aligned_addr - begin_addr; + break :blk alloc_tls_area[start .. start + tls_image.alloc_size]; + }; const tp_value = prepareTLS(tls_area); setThreadPointer(tp_value); diff --git a/lib/std/os/linux/vdso.zig b/lib/std/os/linux/vdso.zig index eb99c7407b..f2e4f1f5bc 100644 --- a/lib/std/os/linux/vdso.zig +++ b/lib/std/os/linux/vdso.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/linux/x86_64.zig b/lib/std/os/linux/x86_64.zig index 8987e1aab3..b9b3ff47eb 100644 --- a/lib/std/os/linux/x86_64.zig +++ b/lib/std/os/linux/x86_64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/netbsd.zig b/lib/std/os/netbsd.zig index a713a009ad..572b470239 100644 --- a/lib/std/os/netbsd.zig +++ b/lib/std/os/netbsd.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/openbsd.zig b/lib/std/os/openbsd.zig index a713a009ad..572b470239 100644 --- a/lib/std/os/openbsd.zig +++ b/lib/std/os/openbsd.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 8ad172679b..f08d4d58fa 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -189,6 +189,75 @@ fn testReadlink(target_path: []const u8, symlink_path: []const u8) !void { expect(mem.eql(u8, target_path, given)); } +test "link with relative paths" { + if (builtin.os.tag != .linux) return error.SkipZigTest; + var cwd = fs.cwd(); + + cwd.deleteFile("example.txt") catch {}; + cwd.deleteFile("new.txt") catch {}; + + try cwd.writeFile("example.txt", "example"); + try os.link("example.txt", "new.txt", 0); + + const efd = try cwd.openFile("example.txt", .{}); + defer efd.close(); + + const nfd = try cwd.openFile("new.txt", .{}); + defer nfd.close(); + + { + const estat = try os.fstat(efd.handle); + const nstat = try os.fstat(nfd.handle); + + testing.expectEqual(estat.ino, nstat.ino); + testing.expectEqual(@as(usize, 2), nstat.nlink); + } + + try os.unlink("new.txt"); + + { + const estat = try os.fstat(efd.handle); + testing.expectEqual(@as(usize, 1), estat.nlink); + } + + try cwd.deleteFile("example.txt"); +} + +test "linkat with different directories" { + if (builtin.os.tag != .linux) return error.SkipZigTest; + var cwd = fs.cwd(); + var tmp = tmpDir(.{}); + + cwd.deleteFile("example.txt") catch {}; + tmp.dir.deleteFile("new.txt") catch {}; + + try cwd.writeFile("example.txt", "example"); + try os.linkat(cwd.fd, "example.txt", tmp.dir.fd, "new.txt", 0); + + const efd = try cwd.openFile("example.txt", .{}); + defer efd.close(); + + const nfd = try tmp.dir.openFile("new.txt", .{}); + + { + defer nfd.close(); + const estat = try os.fstat(efd.handle); + const nstat = try os.fstat(nfd.handle); + + testing.expectEqual(estat.ino, nstat.ino); + testing.expectEqual(@as(usize, 2), nstat.nlink); + } + + try os.unlinkat(tmp.dir.fd, "new.txt", 0); + + { + const estat = try os.fstat(efd.handle); + testing.expectEqual(@as(usize, 1), estat.nlink); + } + + try cwd.deleteFile("example.txt"); +} + test "fstatat" { // enable when `fstat` and `fstatat` are implemented on Windows if (builtin.os.tag == .windows) return error.SkipZigTest; @@ -475,7 +544,7 @@ test "mmap" { const file = try tmp.dir.createFile(test_out_file, .{}); defer file.close(); - const stream = file.outStream(); + const stream = file.writer(); var i: u32 = 0; while (i < alloc_size / @sizeOf(u32)) : (i += 1) { @@ -499,7 +568,7 @@ test "mmap" { defer os.munmap(data); var mem_stream = io.fixedBufferStream(data); - const stream = mem_stream.inStream(); + const stream = mem_stream.reader(); var i: u32 = 0; while (i < alloc_size / @sizeOf(u32)) : (i += 1) { @@ -523,7 +592,7 @@ test "mmap" { defer os.munmap(data); var mem_stream = io.fixedBufferStream(data); - const stream = mem_stream.inStream(); + const stream = mem_stream.reader(); var i: u32 = alloc_size / 2 / @sizeOf(u32); while (i < alloc_size / @sizeOf(u32)) : (i += 1) { diff --git a/lib/std/os/uefi.zig b/lib/std/os/uefi.zig index ba1544105c..1942165999 100644 --- a/lib/std/os/uefi.zig +++ b/lib/std/os/uefi.zig @@ -1,8 +1,10 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. +const std = @import("../std.zig"); + /// A protocol is an interface identified by a GUID. pub const protocols = @import("uefi/protocols.zig"); @@ -33,10 +35,10 @@ pub const Guid = extern struct { self: @This(), comptime f: []const u8, options: std.fmt.FormatOptions, - out_stream: anytype, - ) Errors!void { + writer: anytype, + ) !void { if (f.len == 0) { - return std.fmt.format(out_stream, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{ + return std.fmt.format(writer, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{ self.time_low, self.time_mid, self.time_high_and_version, @@ -48,6 +50,15 @@ pub const Guid = extern struct { @compileError("Unknown format character: '" ++ f ++ "'"); } } + + pub fn eql(a: std.os.uefi.Guid, b: std.os.uefi.Guid) bool { + return a.time_low == b.time_low and + a.time_mid == b.time_mid and + a.time_high_and_version == b.time_high_and_version and + a.clock_seq_high_and_reserved == b.clock_seq_high_and_reserved and + a.clock_seq_low == b.clock_seq_low and + std.mem.eql(u8, &a.node, &b.node); + } }; /// An EFI Handle represents a collection of related interfaces. diff --git a/lib/std/os/uefi/protocols.zig b/lib/std/os/uefi/protocols.zig index 1519092b84..68dafdcecb 100644 --- a/lib/std/os/uefi/protocols.zig +++ b/lib/std/os/uefi/protocols.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig b/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig index 3ec6aab5b9..8edc11e24d 100644 --- a/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig +++ b/lib/std/os/uefi/protocols/absolute_pointer_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/device_path_protocol.zig b/lib/std/os/uefi/protocols/device_path_protocol.zig index 1a998f0f78..0d1d028f60 100644 --- a/lib/std/os/uefi/protocols/device_path_protocol.zig +++ b/lib/std/os/uefi/protocols/device_path_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/edid_active_protocol.zig b/lib/std/os/uefi/protocols/edid_active_protocol.zig index dc8057b4f8..750ff2833b 100644 --- a/lib/std/os/uefi/protocols/edid_active_protocol.zig +++ b/lib/std/os/uefi/protocols/edid_active_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/edid_discovered_protocol.zig b/lib/std/os/uefi/protocols/edid_discovered_protocol.zig index 1ed2b6277d..fdbe594563 100644 --- a/lib/std/os/uefi/protocols/edid_discovered_protocol.zig +++ b/lib/std/os/uefi/protocols/edid_discovered_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/edid_override_protocol.zig b/lib/std/os/uefi/protocols/edid_override_protocol.zig index 83260f7b88..e451d41f32 100644 --- a/lib/std/os/uefi/protocols/edid_override_protocol.zig +++ b/lib/std/os/uefi/protocols/edid_override_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/file_protocol.zig b/lib/std/os/uefi/protocols/file_protocol.zig index ce34a2d6e5..782ac70810 100644 --- a/lib/std/os/uefi/protocols/file_protocol.zig +++ b/lib/std/os/uefi/protocols/file_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -16,7 +16,7 @@ pub const FileProtocol = extern struct { _read: fn (*const FileProtocol, *usize, [*]u8) callconv(.C) Status, _write: fn (*const FileProtocol, *usize, [*]const u8) callconv(.C) Status, _get_position: fn (*const FileProtocol, *u64) callconv(.C) Status, - _set_position: fn (*const FileProtocol, *const u64) callconv(.C) Status, + _set_position: fn (*const FileProtocol, u64) callconv(.C) Status, _get_info: fn (*const FileProtocol, *align(8) const Guid, *const usize, [*]u8) callconv(.C) Status, _set_info: fn (*const FileProtocol, *align(8) const Guid, usize, [*]const u8) callconv(.C) Status, _flush: fn (*const FileProtocol) callconv(.C) Status, @@ -41,11 +41,19 @@ pub const FileProtocol = extern struct { return self._write(self, buffer_size, buffer); } - pub fn get_info(self: *const FileProtocol, information_type: *align(8) Guid, buffer_size: *usize, buffer: [*]u8) Status { + pub fn getPosition(self: *const FileProtocol, position: *u64) Status { + return self._get_position(self, position); + } + + pub fn setPosition(self: *const FileProtocol, position: u64) Status { + return self._set_position(self, position); + } + + pub fn getInfo(self: *const FileProtocol, information_type: *align(8) Guid, buffer_size: *usize, buffer: [*]u8) Status { return self._get_info(self, information_type, buffer_size, buffer); } - pub fn set_info(self: *const FileProtocol, information_type: *align(8) Guid, buffer_size: usize, buffer: [*]const u8) Status { + pub fn setInfo(self: *const FileProtocol, information_type: *align(8) Guid, buffer_size: usize, buffer: [*]const u8) Status { return self._set_info(self, information_type, buffer_size, buffer); } @@ -73,6 +81,8 @@ pub const FileProtocol = extern struct { pub const efi_file_directory: u64 = 0x0000000000000010; pub const efi_file_archive: u64 = 0x0000000000000020; pub const efi_file_valid_attr: u64 = 0x0000000000000037; + + pub const efi_file_position_end_of_file: u64 = 0xffffffffffffffff; }; pub const FileInfo = extern struct { diff --git a/lib/std/os/uefi/protocols/graphics_output_protocol.zig b/lib/std/os/uefi/protocols/graphics_output_protocol.zig index 3ec1c39ab8..a5e784b597 100644 --- a/lib/std/os/uefi/protocols/graphics_output_protocol.zig +++ b/lib/std/os/uefi/protocols/graphics_output_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/hii.zig b/lib/std/os/uefi/protocols/hii.zig index ed7c40d6ac..9d85f293b3 100644 --- a/lib/std/os/uefi/protocols/hii.zig +++ b/lib/std/os/uefi/protocols/hii.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/hii_database_protocol.zig b/lib/std/os/uefi/protocols/hii_database_protocol.zig index d0b16ff943..33014e1cb7 100644 --- a/lib/std/os/uefi/protocols/hii_database_protocol.zig +++ b/lib/std/os/uefi/protocols/hii_database_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/hii_popup_protocol.zig b/lib/std/os/uefi/protocols/hii_popup_protocol.zig index 1f5c5ce0f4..22bae95449 100644 --- a/lib/std/os/uefi/protocols/hii_popup_protocol.zig +++ b/lib/std/os/uefi/protocols/hii_popup_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/ip6_config_protocol.zig b/lib/std/os/uefi/protocols/ip6_config_protocol.zig index 16002f62a6..8dd0caf31a 100644 --- a/lib/std/os/uefi/protocols/ip6_config_protocol.zig +++ b/lib/std/os/uefi/protocols/ip6_config_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/ip6_protocol.zig b/lib/std/os/uefi/protocols/ip6_protocol.zig index 578a3cfb01..011517ba2a 100644 --- a/lib/std/os/uefi/protocols/ip6_protocol.zig +++ b/lib/std/os/uefi/protocols/ip6_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig b/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig index 59605cc11b..69a410c01c 100644 --- a/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig +++ b/lib/std/os/uefi/protocols/ip6_service_binding_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/loaded_image_protocol.zig b/lib/std/os/uefi/protocols/loaded_image_protocol.zig index 96aa10f08d..a5c5610f9b 100644 --- a/lib/std/os/uefi/protocols/loaded_image_protocol.zig +++ b/lib/std/os/uefi/protocols/loaded_image_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/managed_network_protocol.zig b/lib/std/os/uefi/protocols/managed_network_protocol.zig index 9202c6f139..6652107a1a 100644 --- a/lib/std/os/uefi/protocols/managed_network_protocol.zig +++ b/lib/std/os/uefi/protocols/managed_network_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig b/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig index 0c684336c8..f0b8c5fb15 100644 --- a/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig +++ b/lib/std/os/uefi/protocols/managed_network_service_binding_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/rng_protocol.zig b/lib/std/os/uefi/protocols/rng_protocol.zig index 713b76b371..25f7c936c3 100644 --- a/lib/std/os/uefi/protocols/rng_protocol.zig +++ b/lib/std/os/uefi/protocols/rng_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/shell_parameters_protocol.zig b/lib/std/os/uefi/protocols/shell_parameters_protocol.zig index 7ec46b732c..338d88fc9b 100644 --- a/lib/std/os/uefi/protocols/shell_parameters_protocol.zig +++ b/lib/std/os/uefi/protocols/shell_parameters_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/simple_file_system_protocol.zig b/lib/std/os/uefi/protocols/simple_file_system_protocol.zig index 946c88a89b..68f08ebff8 100644 --- a/lib/std/os/uefi/protocols/simple_file_system_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_file_system_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/simple_network_protocol.zig b/lib/std/os/uefi/protocols/simple_network_protocol.zig index f74f11a857..d29cd68873 100644 --- a/lib/std/os/uefi/protocols/simple_network_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_network_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/simple_pointer_protocol.zig b/lib/std/os/uefi/protocols/simple_pointer_protocol.zig index 5f8ca7569e..b76b5bc512 100644 --- a/lib/std/os/uefi/protocols/simple_pointer_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_pointer_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig b/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig index 096013bfb0..0cc1416641 100644 --- a/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/simple_text_input_protocol.zig b/lib/std/os/uefi/protocols/simple_text_input_protocol.zig index 00fae88472..47e632021b 100644 --- a/lib/std/os/uefi/protocols/simple_text_input_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_text_input_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/simple_text_output_protocol.zig b/lib/std/os/uefi/protocols/simple_text_output_protocol.zig index f9bbc37140..6fb56724c7 100644 --- a/lib/std/os/uefi/protocols/simple_text_output_protocol.zig +++ b/lib/std/os/uefi/protocols/simple_text_output_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/udp6_protocol.zig b/lib/std/os/uefi/protocols/udp6_protocol.zig index 50b7dae7c4..c2e4228998 100644 --- a/lib/std/os/uefi/protocols/udp6_protocol.zig +++ b/lib/std/os/uefi/protocols/udp6_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig b/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig index 4f4e0a2638..620f015722 100644 --- a/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig +++ b/lib/std/os/uefi/protocols/udp6_service_binding_protocol.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/status.zig b/lib/std/os/uefi/status.zig index 3e86962202..ccf50d8515 100644 --- a/lib/std/os/uefi/status.zig +++ b/lib/std/os/uefi/status.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/tables.zig b/lib/std/os/uefi/tables.zig index b796eb6e06..649fe95cd2 100644 --- a/lib/std/os/uefi/tables.zig +++ b/lib/std/os/uefi/tables.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/tables/boot_services.zig b/lib/std/os/uefi/tables/boot_services.zig index 09431cf3f4..b96881fcc2 100644 --- a/lib/std/os/uefi/tables/boot_services.zig +++ b/lib/std/os/uefi/tables/boot_services.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/tables/configuration_table.zig b/lib/std/os/uefi/tables/configuration_table.zig index c7dedad5fb..00c8f2f429 100644 --- a/lib/std/os/uefi/tables/configuration_table.zig +++ b/lib/std/os/uefi/tables/configuration_table.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/tables/runtime_services.zig b/lib/std/os/uefi/tables/runtime_services.zig index a2012168ee..7436ab530c 100644 --- a/lib/std/os/uefi/tables/runtime_services.zig +++ b/lib/std/os/uefi/tables/runtime_services.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/tables/system_table.zig b/lib/std/os/uefi/tables/system_table.zig index 3f0624d2ce..c5b6c5f1e9 100644 --- a/lib/std/os/uefi/tables/system_table.zig +++ b/lib/std/os/uefi/tables/system_table.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/uefi/tables/table_header.zig b/lib/std/os/uefi/tables/table_header.zig index a8343c967a..8af1895cad 100644 --- a/lib/std/os/uefi/tables/table_header.zig +++ b/lib/std/os/uefi/tables/table_header.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/wasi.zig b/lib/std/os/wasi.zig index 899541f3fe..3965ae77a0 100644 --- a/lib/std/os/wasi.zig +++ b/lib/std/os/wasi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index b994720ce9..6f67b65252 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -109,7 +109,12 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN 0, ); switch (rc) { - .SUCCESS => return result, + .SUCCESS => { + if (std.io.is_async and options.io_mode == .evented) { + _ = CreateIoCompletionPort(result, std.event.Loop.instance.?.os_data.io_port, undefined, undefined) catch undefined; + } + return result; + }, .OBJECT_NAME_INVALID => unreachable, .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, @@ -418,8 +423,6 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo }, }, }; - // TODO only call create io completion port once per fd - _ = CreateIoCompletionPort(in_hFile, loop.os_data.io_port, undefined, undefined) catch undefined; loop.beginOneEvent(); suspend { // TODO handle buffer bigger than DWORD can hold @@ -500,8 +503,6 @@ pub fn WriteFile( }, }, }; - // TODO only call create io completion port once per fd - _ = CreateIoCompletionPort(handle, loop.os_data.io_port, undefined, undefined) catch undefined; loop.beginOneEvent(); suspend { const adjusted_len = math.cast(DWORD, bytes.len) catch maxInt(DWORD); @@ -857,6 +858,7 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil .SUCCESS => return CloseHandle(tmp_handle), .OBJECT_NAME_INVALID => unreachable, .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, + .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, .INVALID_PARAMETER => unreachable, .FILE_IS_A_DIRECTORY => return error.IsDir, .NOT_A_DIRECTORY => return error.NotDir, @@ -952,7 +954,56 @@ pub fn SetFilePointerEx_CURRENT_get(handle: HANDLE) SetFilePointerError!u64 { return @bitCast(u64, result); } +pub fn QueryObjectName( + handle: HANDLE, + out_buffer: []u16, +) ![]u16 { + const out_buffer_aligned = mem.alignInSlice(out_buffer, @alignOf(OBJECT_NAME_INFORMATION)) orelse return error.NameTooLong; + + const info = @ptrCast(*OBJECT_NAME_INFORMATION, out_buffer_aligned); + //buffer size is specified in bytes + const out_buffer_len = std.math.cast(ULONG, out_buffer_aligned.len * 2) catch |e| switch (e) { + error.Overflow => std.math.maxInt(ULONG), + }; + //last argument would return the length required for full_buffer, not exposed here + const rc = ntdll.NtQueryObject(handle, .ObjectNameInformation, info, out_buffer_len, null); + switch (rc) { + .SUCCESS => { + // info.Name.Buffer from ObQueryNameString is documented to be null (and MaximumLength == 0) + // if the object was "unnamed", not sure if this can happen for file handles + if (info.Name.MaximumLength == 0) return error.Unexpected; + // resulting string length is specified in bytes + const path_length_unterminated = @divExact(info.Name.Length, 2); + return info.Name.Buffer[0..path_length_unterminated]; + }, + .ACCESS_DENIED => return error.AccessDenied, + .INVALID_HANDLE => return error.InvalidHandle, + // triggered when the buffer is too small for the OBJECT_NAME_INFORMATION object (.INFO_LENGTH_MISMATCH), + // or if the buffer is too small for the file path returned (.BUFFER_OVERFLOW, .BUFFER_TOO_SMALL) + .INFO_LENGTH_MISMATCH, .BUFFER_OVERFLOW, .BUFFER_TOO_SMALL => return error.NameTooLong, + else => |e| return unexpectedStatus(e), + } +} +test "QueryObjectName" { + if (comptime builtin.os.tag != .windows) + return; + + //any file will do; canonicalization works on NTFS junctions and symlinks, hardlinks remain separate paths. + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const handle = tmp.dir.fd; + var out_buffer: [PATH_MAX_WIDE]u16 = undefined; + + var result_path = try QueryObjectName(handle, &out_buffer); + const required_len_in_u16 = result_path.len + @divExact(@ptrToInt(result_path.ptr) - @ptrToInt(&out_buffer), 2) + 1; + //insufficient size + std.testing.expectError(error.NameTooLong, QueryObjectName(handle, out_buffer[0 .. required_len_in_u16 - 1])); + //exactly-sufficient size + _ = try QueryObjectName(handle, out_buffer[0..required_len_in_u16]); +} + pub const GetFinalPathNameByHandleError = error{ + AccessDenied, BadPathName, FileNotFound, NameTooLong, @@ -980,32 +1031,31 @@ pub fn GetFinalPathNameByHandle( fmt: GetFinalPathNameByHandleFormat, out_buffer: []u16, ) GetFinalPathNameByHandleError![]u16 { - // Get normalized path; doesn't include volume name though. - var path_buffer: [@sizeOf(FILE_NAME_INFORMATION) + PATH_MAX_WIDE * 2]u8 align(@alignOf(FILE_NAME_INFORMATION)) = undefined; - try QueryInformationFile(hFile, .FileNormalizedNameInformation, path_buffer[0..]); - - // Get NT volume name. - var volume_buffer: [@sizeOf(FILE_NAME_INFORMATION) + MAX_PATH]u8 align(@alignOf(FILE_NAME_INFORMATION)) = undefined; // MAX_PATH bytes should be enough since it's Windows-defined name - try QueryInformationFile(hFile, .FileVolumeNameInformation, volume_buffer[0..]); - - const file_name = @ptrCast(*const FILE_NAME_INFORMATION, &path_buffer[0]); - const file_name_u16 = @ptrCast([*]const u16, &file_name.FileName[0])[0 .. file_name.FileNameLength / 2]; - - const volume_name = @ptrCast(*const FILE_NAME_INFORMATION, &volume_buffer[0]); + const final_path = QueryObjectName(hFile, out_buffer) catch |err| switch (err) { + // we assume InvalidHandle is close enough to FileNotFound in semantics + // to not further complicate the error set + error.InvalidHandle => return error.FileNotFound, + else => |e| return e, + }; switch (fmt.volume_name) { .Nt => { - // Nothing to do, we simply copy the bytes to the user-provided buffer. - const volume_name_u16 = @ptrCast([*]const u16, &volume_name.FileName[0])[0 .. volume_name.FileNameLength / 2]; - - if (out_buffer.len < volume_name_u16.len + file_name_u16.len) return error.NameTooLong; - - std.mem.copy(u16, out_buffer[0..], volume_name_u16); - std.mem.copy(u16, out_buffer[volume_name_u16.len..], file_name_u16); - - return out_buffer[0 .. volume_name_u16.len + file_name_u16.len]; + // the returned path is already in .Nt format + return final_path; }, .Dos => { + // parse the string to separate volume path from file path + const expected_prefix = std.unicode.utf8ToUtf16LeStringLiteral("\\Device\\"); + + // TODO find out if a path can start with something besides `\Device\`, + // and if we need to handle it differently + // (i.e. how to determine the start and end of the volume name in that case) + if (!mem.eql(u16, expected_prefix, final_path[0..expected_prefix.len])) return error.Unexpected; + + const file_path_begin_index = mem.indexOfPos(u16, final_path, expected_prefix.len, &[_]u16{'\\'}) orelse unreachable; + const volume_name_u16 = final_path[0..file_path_begin_index]; + const file_name_u16 = final_path[file_path_begin_index..]; + // Get DOS volume name. DOS volume names are actually symbolic link objects to the // actual NT volume. For example: // (NT) \Device\HarddiskVolume4 => (DOS) \DosDevices\C: == (DOS) C: @@ -1038,10 +1088,10 @@ pub fn GetFinalPathNameByHandle( var input_struct = @ptrCast(*MOUNTMGR_MOUNT_POINT, &input_buf[0]); input_struct.DeviceNameOffset = @sizeOf(MOUNTMGR_MOUNT_POINT); - input_struct.DeviceNameLength = @intCast(USHORT, volume_name.FileNameLength); - @memcpy(input_buf[@sizeOf(MOUNTMGR_MOUNT_POINT)..], @ptrCast([*]const u8, &volume_name.FileName[0]), volume_name.FileNameLength); + input_struct.DeviceNameLength = @intCast(USHORT, volume_name_u16.len * 2); + @memcpy(input_buf[@sizeOf(MOUNTMGR_MOUNT_POINT)..], @ptrCast([*]const u8, volume_name_u16.ptr), volume_name_u16.len * 2); - DeviceIoControl(mgmt_handle, IOCTL_MOUNTMGR_QUERY_POINTS, input_buf[0..], output_buf[0..]) catch |err| switch (err) { + DeviceIoControl(mgmt_handle, IOCTL_MOUNTMGR_QUERY_POINTS, &input_buf, &output_buf) catch |err| switch (err) { error.AccessDenied => unreachable, else => |e| return e, }; @@ -1061,22 +1111,20 @@ pub fn GetFinalPathNameByHandle( // Look for `\DosDevices\` prefix. We don't really care if there are more than one symlinks // with traditional DOS drive letters, so pick the first one available. - const prefix_u8 = "\\DosDevices\\"; - var prefix_buf_u16: [prefix_u8.len]u16 = undefined; - const prefix_len_u16 = std.unicode.utf8ToUtf16Le(prefix_buf_u16[0..], prefix_u8[0..]) catch unreachable; - const prefix = prefix_buf_u16[0..prefix_len_u16]; + var prefix_buf = std.unicode.utf8ToUtf16LeStringLiteral("\\DosDevices\\"); + const prefix = prefix_buf[0..prefix_buf.len]; - if (std.mem.startsWith(u16, symlink, prefix)) { + if (mem.startsWith(u16, symlink, prefix)) { const drive_letter = symlink[prefix.len..]; if (out_buffer.len < drive_letter.len + file_name_u16.len) return error.NameTooLong; - std.mem.copy(u16, out_buffer[0..], drive_letter); - std.mem.copy(u16, out_buffer[drive_letter.len..], file_name_u16); + mem.copy(u16, out_buffer, drive_letter); + mem.copy(u16, out_buffer[drive_letter.len..], file_name_u16); const total_len = drive_letter.len + file_name_u16.len; // Validate that DOS does not contain any spurious nul bytes. - if (std.mem.indexOfScalar(u16, out_buffer[0..total_len], 0)) |_| { + if (mem.indexOfScalar(u16, out_buffer[0..total_len], 0)) |_| { return error.BadPathName; } @@ -1091,6 +1139,30 @@ pub fn GetFinalPathNameByHandle( } } +test "GetFinalPathNameByHandle" { + if (comptime builtin.os.tag != .windows) + return; + + //any file will do + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const handle = tmp.dir.fd; + var buffer: [PATH_MAX_WIDE]u16 = undefined; + + //check with sufficient size + const nt_path = try GetFinalPathNameByHandle(handle, .{ .volume_name = .Nt }, &buffer); + _ = try GetFinalPathNameByHandle(handle, .{ .volume_name = .Dos }, &buffer); + + const required_len_in_u16 = nt_path.len + @divExact(@ptrToInt(nt_path.ptr) - @ptrToInt(&buffer), 2) + 1; + //check with insufficient size + std.testing.expectError(error.NameTooLong, GetFinalPathNameByHandle(handle, .{ .volume_name = .Nt }, buffer[0 .. required_len_in_u16 - 1])); + std.testing.expectError(error.NameTooLong, GetFinalPathNameByHandle(handle, .{ .volume_name = .Dos }, buffer[0 .. required_len_in_u16 - 1])); + + //check with exactly-sufficient size + _ = try GetFinalPathNameByHandle(handle, .{ .volume_name = .Nt }, buffer[0..required_len_in_u16]); + _ = try GetFinalPathNameByHandle(handle, .{ .volume_name = .Dos }, buffer[0..required_len_in_u16]); +} + pub const QueryInformationFileError = error{Unexpected}; pub fn QueryInformationFile( @@ -1240,8 +1312,8 @@ pub fn recvfrom(s: ws2_32.SOCKET, buf: [*]u8, len: usize, flags: u32, from: ?*ws } } -pub fn poll(fds: [*]ws2_32.pollfd, n: usize, timeout: i32) i32 { - return ws2_32.WSAPoll(fds, @intCast(u32, n), timeout); +pub fn poll(fds: [*]ws2_32.pollfd, n: c_ulong, timeout: i32) i32 { + return ws2_32.WSAPoll(fds, n, timeout); } pub fn WSAIoctl( @@ -1597,7 +1669,7 @@ pub fn wToPrefixedFileW(s: []const u16) !PathSpace { return path_space; } -inline fn MAKELANGID(p: c_ushort, s: c_ushort) LANGID { +fn MAKELANGID(p: c_ushort, s: c_ushort) callconv(.Inline) LANGID { return (s << 10) | p; } @@ -1618,7 +1690,7 @@ pub fn unexpectedError(err: Win32Error) std.os.UnexpectedError { null, ); _ = std.unicode.utf16leToUtf8(&buf_u8, buf_u16[0..len]) catch unreachable; - std.debug.warn("error.Unexpected: GetLastError({}): {}\n", .{ @enumToInt(err), buf_u8[0..len] }); + std.debug.warn("error.Unexpected: GetLastError({}): {s}\n", .{ @enumToInt(err), buf_u8[0..len] }); std.debug.dumpCurrentStackTrace(null); } return error.Unexpected; diff --git a/lib/std/os/windows/advapi32.zig b/lib/std/os/windows/advapi32.zig index 177449a70e..6fa9ae2b45 100644 --- a/lib/std/os/windows/advapi32.zig +++ b/lib/std/os/windows/advapi32.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows/bits.zig b/lib/std/os/windows/bits.zig index f5d520c580..cbeb0b483d 100644 --- a/lib/std/os/windows/bits.zig +++ b/lib/std/os/windows/bits.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -37,6 +37,7 @@ pub const UCHAR = u8; pub const FLOAT = f32; pub const HANDLE = *c_void; pub const HCRYPTPROV = ULONG_PTR; +pub const ATOM = u16; pub const HBRUSH = *opaque {}; pub const HCURSOR = *opaque {}; pub const HICON = *opaque {}; @@ -84,8 +85,8 @@ pub const HLOCAL = HANDLE; pub const LANGID = c_ushort; pub const WPARAM = usize; -pub const LPARAM = ?*c_void; -pub const LRESULT = ?*c_void; +pub const LPARAM = LONG_PTR; +pub const LRESULT = LONG_PTR; pub const va_list = *opaque {}; @@ -770,6 +771,13 @@ pub const FILE_FLAG_SESSION_AWARE = 0x00800000; pub const FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000; pub const FILE_FLAG_WRITE_THROUGH = 0x80000000; +pub const RECT = extern struct { + left: LONG, + top: LONG, + right: LONG, + bottom: LONG, +}; + pub const SMALL_RECT = extern struct { Left: SHORT, Top: SHORT, @@ -777,6 +785,11 @@ pub const SMALL_RECT = extern struct { Bottom: SHORT, }; +pub const POINT = extern struct { + x: LONG, + y: LONG, +}; + pub const COORD = extern struct { X: SHORT, Y: SHORT, @@ -813,7 +826,8 @@ pub const FILE_NOTIFY_INFORMATION = extern struct { NextEntryOffset: DWORD, Action: DWORD, FileNameLength: DWORD, - FileName: [1]WCHAR, + // Flexible array member + // FileName: [1]WCHAR, }; pub const FILE_ACTION_ADDED = 0x00000001; @@ -1301,11 +1315,13 @@ pub const PEB = extern struct { ImageSubSystemMinorVersion: ULONG, // note: there is padding here on 64 bit ActiveProcessAffinityMask: KAFFINITY, - GdiHandleBuffer: [switch (@sizeOf(usize)) { - 4 => 0x22, - 8 => 0x3C, - else => unreachable, - }]ULONG, + GdiHandleBuffer: [ + switch (@sizeOf(usize)) { + 4 => 0x22, + 8 => 0x3C, + else => unreachable, + } + ]ULONG, // Fields appended in 5.0 (Windows 2000): PostProcessInitRoutine: PVOID, @@ -1606,3 +1622,23 @@ pub const IOCTL_MOUNTMGR_QUERY_POINTS: ULONG = 0x6d0008; pub const SD_RECEIVE = 0; pub const SD_SEND = 1; pub const SD_BOTH = 2; + +pub const OBJECT_INFORMATION_CLASS = extern enum { + ObjectBasicInformation = 0, + ObjectNameInformation = 1, + ObjectTypeInformation = 2, + ObjectTypesInformation = 3, + ObjectHandleFlagInformation = 4, + ObjectSessionInformation = 5, + MaxObjectInfoClass, +}; + +pub const OBJECT_NAME_INFORMATION = extern struct { + Name: UNICODE_STRING, +}; +pub const POBJECT_NAME_INFORMATION = *OBJECT_NAME_INFORMATION; + +pub const SRWLOCK = usize; +pub const SRWLOCK_INIT: SRWLOCK = 0; +pub const CONDITION_VARIABLE = usize; +pub const CONDITION_VARIABLE_INIT: CONDITION_VARIABLE = 0; diff --git a/lib/std/os/windows/gdi32.zig b/lib/std/os/windows/gdi32.zig index 35ebfb7789..c91e1d487c 100644 --- a/lib/std/os/windows/gdi32.zig +++ b/lib/std/os/windows/gdi32.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows/kernel32.zig b/lib/std/os/windows/kernel32.zig index 444234876c..734059a08a 100644 --- a/lib/std/os/windows/kernel32.zig +++ b/lib/std/os/windows/kernel32.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -8,7 +8,7 @@ usingnamespace @import("bits.zig"); pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(WINAPI) ?*c_void; pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(WINAPI) c_ulong; -pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) callconv(WINAPI) BOOL; +pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: ?LPOVERLAPPED) callconv(WINAPI) BOOL; pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(WINAPI) BOOL; @@ -115,6 +115,7 @@ pub extern "kernel32" fn GetModuleFileNameW(hModule: ?HMODULE, lpFilename: [*]u1 pub extern "kernel32" fn GetModuleHandleW(lpModuleName: ?[*:0]const WCHAR) callconv(WINAPI) ?HMODULE; pub extern "kernel32" fn GetLastError() callconv(WINAPI) Win32Error; +pub extern "kernel32" fn SetLastError(dwErrCode: Win32Error) callconv(WINAPI) void; pub extern "kernel32" fn GetFileInformationByHandle( hFile: HANDLE, @@ -288,3 +289,16 @@ pub extern "kernel32" fn K32QueryWorkingSet(hProcess: HANDLE, pv: PVOID, cb: DWO pub extern "kernel32" fn K32QueryWorkingSetEx(hProcess: HANDLE, pv: PVOID, cb: DWORD) callconv(WINAPI) BOOL; pub extern "kernel32" fn FlushFileBuffers(hFile: HANDLE) callconv(WINAPI) BOOL; + +pub extern "kernel32" fn WakeAllConditionVariable(c: *CONDITION_VARIABLE) callconv(WINAPI) void; +pub extern "kernel32" fn WakeConditionVariable(c: *CONDITION_VARIABLE) callconv(WINAPI) void; +pub extern "kernel32" fn SleepConditionVariableSRW( + c: *CONDITION_VARIABLE, + s: *SRWLOCK, + t: DWORD, + f: ULONG, +) callconv(WINAPI) BOOL; + +pub extern "kernel32" fn TryAcquireSRWLockExclusive(s: *SRWLOCK) callconv(WINAPI) BOOLEAN; +pub extern "kernel32" fn AcquireSRWLockExclusive(s: *SRWLOCK) callconv(WINAPI) void; +pub extern "kernel32" fn ReleaseSRWLockExclusive(s: *SRWLOCK) callconv(WINAPI) void; diff --git a/lib/std/os/windows/lang.zig b/lib/std/os/windows/lang.zig index 61efa3bdb3..40b363cfae 100644 --- a/lib/std/os/windows/lang.zig +++ b/lib/std/os/windows/lang.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows/ntdll.zig b/lib/std/os/windows/ntdll.zig index fc485f87f2..3f76036762 100644 --- a/lib/std/os/windows/ntdll.zig +++ b/lib/std/os/windows/ntdll.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -113,3 +113,11 @@ pub extern "NtDll" fn NtWaitForKeyedEvent( ) callconv(WINAPI) NTSTATUS; pub extern "NtDll" fn RtlSetCurrentDirectory_U(PathName: *UNICODE_STRING) callconv(WINAPI) NTSTATUS; + +pub extern "NtDll" fn NtQueryObject( + Handle: HANDLE, + ObjectInformationClass: OBJECT_INFORMATION_CLASS, + ObjectInformation: PVOID, + ObjectInformationLength: ULONG, + ReturnLength: ?*ULONG, +) callconv(WINAPI) NTSTATUS; diff --git a/lib/std/os/windows/ntstatus.zig b/lib/std/os/windows/ntstatus.zig index 0e567df510..b86cd1186b 100644 --- a/lib/std/os/windows/ntstatus.zig +++ b/lib/std/os/windows/ntstatus.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows/ole32.zig b/lib/std/os/windows/ole32.zig index 13920dd510..bf1eabd63e 100644 --- a/lib/std/os/windows/ole32.zig +++ b/lib/std/os/windows/ole32.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows/psapi.zig b/lib/std/os/windows/psapi.zig index 0d19117c30..2952df1635 100644 --- a/lib/std/os/windows/psapi.zig +++ b/lib/std/os/windows/psapi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows/shell32.zig b/lib/std/os/windows/shell32.zig index 812cbd6cfc..d184ba1036 100644 --- a/lib/std/os/windows/shell32.zig +++ b/lib/std/os/windows/shell32.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows/sublang.zig b/lib/std/os/windows/sublang.zig index 5249e8ed0a..ecc46dbfc4 100644 --- a/lib/std/os/windows/sublang.zig +++ b/lib/std/os/windows/sublang.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows/user32.zig b/lib/std/os/windows/user32.zig index f4533faaa6..186a1af59f 100644 --- a/lib/std/os/windows/user32.zig +++ b/lib/std/os/windows/user32.zig @@ -1,48 +1,82 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. usingnamespace @import("bits.zig"); +const std = @import("std"); +const builtin = @import("builtin"); +const assert = std.debug.assert; +const windows = @import("../windows.zig"); +const unexpectedError = windows.unexpectedError; +const GetLastError = windows.kernel32.GetLastError; +const SetLastError = windows.kernel32.SetLastError; -// PM -pub const PM_REMOVE = 0x0001; -pub const PM_NOREMOVE = 0x0000; -pub const PM_NOYIELD = 0x0002; +fn selectSymbol(comptime function_static: anytype, function_dynamic: @TypeOf(function_static), comptime os: std.Target.Os.WindowsVersion) @TypeOf(function_static) { + comptime { + const sym_ok = builtin.Target.current.os.isAtLeast(.windows, os); + if (sym_ok == true) return function_static; + if (sym_ok == null) return function_dynamic; + if (sym_ok == false) @compileError("Target OS range does not support function, at least " ++ @tagName(os) ++ " is required"); + } +} + +// === Messages === + +pub const WNDPROC = fn (hwnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM) callconv(WINAPI) LRESULT; + +pub const MSG = extern struct { + hWnd: ?HWND, + message: UINT, + wParam: WPARAM, + lParam: LPARAM, + time: DWORD, + pt: POINT, + lPrivate: DWORD, +}; -// WM pub const WM_NULL = 0x0000; pub const WM_CREATE = 0x0001; pub const WM_DESTROY = 0x0002; +pub const WM_NCDESTROY = WM_DESTROY; pub const WM_MOVE = 0x0003; pub const WM_SIZE = 0x0005; - pub const WM_ACTIVATE = 0x0006; -pub const WM_PAINT = 0x000F; -pub const WM_CLOSE = 0x0010; -pub const WM_QUIT = 0x0012; pub const WM_SETFOCUS = 0x0007; - pub const WM_KILLFOCUS = 0x0008; pub const WM_ENABLE = 0x000A; pub const WM_SETREDRAW = 0x000B; - -pub const WM_SYSCOLORCHANGE = 0x0015; +pub const WM_SETTEXT = 0x000C; +pub const WM_GETTEXT = 0x000D; +pub const WM_GETTEXTLENGTH = 0x000E; +pub const WM_PAINT = 0x000F; +pub const WM_CLOSE = 0x0010; +pub const WM_QUIT = 0x0012; +pub const WM_ERASEBKGND = 0x0014; pub const WM_SHOWWINDOW = 0x0018; - -pub const WM_WINDOWPOSCHANGING = 0x0046; +pub const WM_CTLCOLOR = 0x0019; +pub const WM_NEXTDLGCTL = 0x0028; +pub const WM_DRAWITEM = 0x002B; +pub const WM_MEASUREITEM = 0x002C; +pub const WM_DELETEITEM = 0x002D; +pub const WM_VKEYTOITEM = 0x002E; +pub const WM_CHARTOITEM = 0x002F; +pub const WM_SETFONT = 0x0030; +pub const WM_GETFONT = 0x0031; +pub const WM_COMPAREITEM = 0x0039; pub const WM_WINDOWPOSCHANGED = 0x0047; -pub const WM_POWER = 0x0048; - -pub const WM_CONTEXTMENU = 0x007B; -pub const WM_STYLECHANGING = 0x007C; -pub const WM_STYLECHANGED = 0x007D; -pub const WM_DISPLAYCHANGE = 0x007E; -pub const WM_GETICON = 0x007F; -pub const WM_SETICON = 0x0080; - -pub const WM_INPUT_DEVICE_CHANGE = 0x00fe; -pub const WM_INPUT = 0x00FF; +pub const WM_NOTIFY = 0x004E; +pub const WM_NCCALCSIZE = 0x0083; +pub const WM_NCHITTEST = 0x0084; +pub const WM_NCPAINT = 0x0085; +pub const WM_GETDLGCODE = 0x0087; +pub const WM_NCMOUSEMOVE = 0x00A0; +pub const WM_NCLBUTTONDOWN = 0x00A1; +pub const WM_NCLBUTTONUP = 0x00A2; +pub const WM_NCLBUTTONDBLCLK = 0x00A3; +pub const WM_NCRBUTTONDOWN = 0x00A4; +pub const WM_NCRBUTTONUP = 0x00A5; +pub const WM_NCRBUTTONDBLCLK = 0x00A6; pub const WM_KEYFIRST = 0x0100; pub const WM_KEYDOWN = 0x0100; pub const WM_KEYUP = 0x0101; @@ -54,11 +88,20 @@ pub const WM_SYSCHAR = 0x0106; pub const WM_SYSDEADCHAR = 0x0107; pub const WM_UNICHAR = 0x0109; pub const WM_KEYLAST = 0x0109; - +pub const WM_INITDIALOG = 0x0110; pub const WM_COMMAND = 0x0111; pub const WM_SYSCOMMAND = 0x0112; pub const WM_TIMER = 0x0113; - +pub const WM_HSCROLL = 0x0114; +pub const WM_VSCROLL = 0x0115; +pub const WM_ENTERIDLE = 0x0121; +pub const WM_CTLCOLORMSGBOX = 0x0132; +pub const WM_CTLCOLOREDIT = 0x0133; +pub const WM_CTLCOLORLISTBOX = 0x0134; +pub const WM_CTLCOLORBTN = 0x0135; +pub const WM_CTLCOLORDLG = 0x0136; +pub const WM_CTLCOLORSCROLLBAR = 0x0137; +pub const WM_CTLCOLORSTATIC = 0x0138; pub const WM_MOUSEFIRST = 0x0200; pub const WM_MOUSEMOVE = 0x0200; pub const WM_LBUTTONDOWN = 0x0201; @@ -71,105 +114,561 @@ pub const WM_MBUTTONDOWN = 0x0207; pub const WM_MBUTTONUP = 0x0208; pub const WM_MBUTTONDBLCLK = 0x0209; pub const WM_MOUSEWHEEL = 0x020A; -pub const WM_XBUTTONDOWN = 0x020B; -pub const WM_XBUTTONUP = 0x020C; -pub const WM_XBUTTONDBLCLK = 0x020D; +pub const WM_MOUSELAST = 0x020A; +pub const WM_HOTKEY = 0x0312; +pub const WM_CARET_CREATE = 0x03E0; +pub const WM_CARET_DESTROY = 0x03E1; +pub const WM_CARET_BLINK = 0x03E2; +pub const WM_FDINPUT = 0x03F0; +pub const WM_FDOUTPUT = 0x03F1; +pub const WM_FDEXCEPT = 0x03F2; +pub const WM_USER = 0x0400; -// WA -pub const WA_INACTIVE = 0; -pub const WA_ACTIVE = 0x0006; +pub extern "user32" fn GetMessageA(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) callconv(WINAPI) BOOL; +pub fn getMessageA(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax: u32) !void { + const r = GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); + if (r == 0) return error.Quit; + if (r != -1) return; + switch (GetLastError()) { + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} -// WS -pub const WS_OVERLAPPED = 0x00000000; -pub const WS_CAPTION = 0x00C00000; -pub const WS_SYSMENU = 0x00080000; -pub const WS_THICKFRAME = 0x00040000; -pub const WS_MINIMIZEBOX = 0x00020000; -pub const WS_MAXIMIZEBOX = 0x00010000; +pub extern "user32" fn GetMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT) callconv(WINAPI) BOOL; +pub var pfnGetMessageW: @TypeOf(GetMessageW) = undefined; +pub fn getMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax: u32) !void { + const function = selectSymbol(GetMessageW, pfnGetMessageW, .win2k); -// PFD -pub const PFD_DRAW_TO_WINDOW = 0x00000004; -pub const PFD_SUPPORT_OPENGL = 0x00000020; -pub const PFD_DOUBLEBUFFER = 0x00000001; -pub const PFD_MAIN_PLANE = 0; -pub const PFD_TYPE_RGBA = 0; + const r = function(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); + if (r == 0) return error.Quit; + if (r != -1) return; + switch (GetLastError()) { + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub const PM_NOREMOVE = 0x0000; +pub const PM_REMOVE = 0x0001; +pub const PM_NOYIELD = 0x0002; + +pub extern "user32" fn PeekMessageA(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) callconv(WINAPI) BOOL; +pub fn peekMessageA(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax: u32, wRemoveMsg: u32) !bool { + const r = PeekMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + if (r == 0) return false; + if (r != -1) return true; + switch (GetLastError()) { + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn PeekMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: UINT, wMsgFilterMax: UINT, wRemoveMsg: UINT) callconv(WINAPI) BOOL; +pub var pfnPeekMessageW: @TypeOf(PeekMessageW) = undefined; +pub fn peekMessageW(lpMsg: *MSG, hWnd: ?HWND, wMsgFilterMin: u32, wMsgFilterMax: u32, wRemoveMsg: u32) !bool { + const function = selectSymbol(PeekMessageW, pfnPeekMessageW, .win2k); + + const r = function(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + if (r == 0) return false; + if (r != -1) return true; + switch (GetLastError()) { + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn TranslateMessage(lpMsg: *const MSG) callconv(WINAPI) BOOL; +pub fn translateMessage(lpMsg: *const MSG) bool { + return if (TranslateMessage(lpMsg) == 0) false else true; +} + +pub extern "user32" fn DispatchMessageA(lpMsg: *const MSG) callconv(WINAPI) LRESULT; +pub fn dispatchMessageA(lpMsg: *const MSG) LRESULT { + return DispatchMessageA(lpMsg); +} + +pub extern "user32" fn DispatchMessageW(lpMsg: *const MSG) callconv(WINAPI) LRESULT; +pub var pfnDispatchMessageW: @TypeOf(DispatchMessageW) = undefined; +pub fn dispatchMessageW(lpMsg: *const MSG) LRESULT { + const function = selectSymbol(DispatchMessageW, pfnDispatchMessageW, .win2k); + return function(lpMsg); +} + +pub extern "user32" fn PostQuitMessage(nExitCode: i32) callconv(WINAPI) void; +pub fn postQuitMessage(nExitCode: i32) void { + PostQuitMessage(nExitCode); +} + +pub extern "user32" fn DefWindowProcA(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) callconv(WINAPI) LRESULT; +pub fn defWindowProcA(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) LRESULT { + return DefWindowProcA(hWnd, Msg, wParam, lParam); +} + +pub extern "user32" fn DefWindowProcW(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) callconv(WINAPI) LRESULT; +pub var pfnDefWindowProcW: @TypeOf(DefWindowProcW) = undefined; +pub fn defWindowProcW(hWnd: HWND, Msg: UINT, wParam: WPARAM, lParam: LPARAM) LRESULT { + const function = selectSymbol(DefWindowProcW, pfnDefWindowProcW, .win2k); + return function(hWnd, Msg, wParam, lParam); +} + +// === Windows === -// CS -pub const CS_HREDRAW = 0x0002; pub const CS_VREDRAW = 0x0001; +pub const CS_HREDRAW = 0x0002; +pub const CS_DBLCLKS = 0x0008; pub const CS_OWNDC = 0x0020; - -// SW -pub const SW_HIDE = 0; -pub const SW_SHOW = 5; - -pub const WNDPROC = fn (HWND, UINT, WPARAM, LPARAM) callconv(WINAPI) LRESULT; +pub const CS_CLASSDC = 0x0040; +pub const CS_PARENTDC = 0x0080; +pub const CS_NOCLOSE = 0x0200; +pub const CS_SAVEBITS = 0x0800; +pub const CS_BYTEALIGNCLIENT = 0x1000; +pub const CS_BYTEALIGNWINDOW = 0x2000; +pub const CS_GLOBALCLASS = 0x4000; pub const WNDCLASSEXA = extern struct { cbSize: UINT = @sizeOf(WNDCLASSEXA), style: UINT, lpfnWndProc: WNDPROC, - cbClsExtra: i32, - cbWndExtra: i32, + cbClsExtra: i32 = 0, + cbWndExtra: i32 = 0, hInstance: HINSTANCE, hIcon: ?HICON, hCursor: ?HCURSOR, hbrBackground: ?HBRUSH, - lpszMenuName: ?LPCSTR, - lpszClassName: LPCSTR, + lpszMenuName: ?[*:0]const u8, + lpszClassName: [*:0]const u8, hIconSm: ?HICON, }; -pub const POINT = extern struct { - x: c_long, y: c_long -}; - -pub const MSG = extern struct { - hWnd: ?HWND, - message: UINT, - wParam: WPARAM, - lParam: LPARAM, - time: DWORD, - pt: POINT, - lPrivate: DWORD, -}; - -pub extern "user32" fn CreateWindowExA( - dwExStyle: DWORD, - lpClassName: LPCSTR, - lpWindowName: LPCSTR, - dwStyle: DWORD, - X: i32, - Y: i32, - nWidth: i32, - nHeight: i32, - hWindParent: ?HWND, - hMenu: ?HMENU, +pub const WNDCLASSEXW = extern struct { + cbSize: UINT = @sizeOf(WNDCLASSEXW), + style: UINT, + lpfnWndProc: WNDPROC, + cbClsExtra: i32 = 0, + cbWndExtra: i32 = 0, hInstance: HINSTANCE, - lpParam: ?LPVOID, -) callconv(WINAPI) ?HWND; + hIcon: ?HICON, + hCursor: ?HCURSOR, + hbrBackground: ?HBRUSH, + lpszMenuName: ?[*:0]const u16, + lpszClassName: [*:0]const u16, + hIconSm: ?HICON, +}; + +pub extern "user32" fn RegisterClassExA(*const WNDCLASSEXA) callconv(WINAPI) ATOM; +pub fn registerClassExA(window_class: *const WNDCLASSEXA) !ATOM { + const atom = RegisterClassExA(window_class); + if (atom != 0) return atom; + switch (GetLastError()) { + .CLASS_ALREADY_EXISTS => return error.AlreadyExists, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn RegisterClassExW(*const WNDCLASSEXW) callconv(WINAPI) ATOM; +pub var pfnRegisterClassExW: @TypeOf(RegisterClassExW) = undefined; +pub fn registerClassExW(window_class: *const WNDCLASSEXW) !ATOM { + const function = selectSymbol(RegisterClassExW, pfnRegisterClassExW, .win2k); + const atom = function(window_class); + if (atom != 0) return atom; + switch (GetLastError()) { + .CLASS_ALREADY_EXISTS => return error.AlreadyExists, + .CALL_NOT_IMPLEMENTED => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn UnregisterClassA(lpClassName: [*:0]const u8, hInstance: HINSTANCE) callconv(WINAPI) BOOL; +pub fn unregisterClassA(lpClassName: [*:0]const u8, hInstance: HINSTANCE) !void { + if (UnregisterClassA(lpClassName, hInstance) == 0) { + switch (GetLastError()) { + .CLASS_DOES_NOT_EXIST => return error.ClassDoesNotExist, + else => |err| return windows.unexpectedError(err), + } + } +} + +pub extern "user32" fn UnregisterClassW(lpClassName: [*:0]const u16, hInstance: HINSTANCE) callconv(WINAPI) BOOL; +pub var pfnUnregisterClassW: @TypeOf(UnregisterClassW) = undefined; +pub fn unregisterClassW(lpClassName: [*:0]const u16, hInstance: HINSTANCE) !void { + const function = selectSymbol(UnregisterClassW, pfnUnregisterClassW, .win2k); + if (function(lpClassName, hInstance) == 0) { + switch (GetLastError()) { + .CLASS_DOES_NOT_EXIST => return error.ClassDoesNotExist, + else => |err| return windows.unexpectedError(err), + } + } +} + +pub const WS_OVERLAPPED = 0x00000000; +pub const WS_POPUP = 0x80000000; +pub const WS_CHILD = 0x40000000; +pub const WS_MINIMIZE = 0x20000000; +pub const WS_VISIBLE = 0x10000000; +pub const WS_DISABLED = 0x08000000; +pub const WS_CLIPSIBLINGS = 0x04000000; +pub const WS_CLIPCHILDREN = 0x02000000; +pub const WS_MAXIMIZE = 0x01000000; +pub const WS_CAPTION = WS_BORDER | WS_DLGFRAME; +pub const WS_BORDER = 0x00800000; +pub const WS_DLGFRAME = 0x00400000; +pub const WS_VSCROLL = 0x00200000; +pub const WS_HSCROLL = 0x00100000; +pub const WS_SYSMENU = 0x00080000; +pub const WS_THICKFRAME = 0x00040000; +pub const WS_GROUP = 0x00020000; +pub const WS_TABSTOP = 0x00010000; +pub const WS_MINIMIZEBOX = 0x00020000; +pub const WS_MAXIMIZEBOX = 0x00010000; +pub const WS_TILED = WS_OVERLAPPED; +pub const WS_ICONIC = WS_MINIMIZE; +pub const WS_SIZEBOX = WS_THICKFRAME; +pub const WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW; +pub const WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; +pub const WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU; +pub const WS_CHILDWINDOW = WS_CHILD; + +pub const WS_EX_DLGMODALFRAME = 0x00000001; +pub const WS_EX_NOPARENTNOTIFY = 0x00000004; +pub const WS_EX_TOPMOST = 0x00000008; +pub const WS_EX_ACCEPTFILES = 0x00000010; +pub const WS_EX_TRANSPARENT = 0x00000020; +pub const WS_EX_MDICHILD = 0x00000040; +pub const WS_EX_TOOLWINDOW = 0x00000080; +pub const WS_EX_WINDOWEDGE = 0x00000100; +pub const WS_EX_CLIENTEDGE = 0x00000200; +pub const WS_EX_CONTEXTHELP = 0x00000400; +pub const WS_EX_RIGHT = 0x00001000; +pub const WS_EX_LEFT = 0x00000000; +pub const WS_EX_RTLREADING = 0x00002000; +pub const WS_EX_LTRREADING = 0x00000000; +pub const WS_EX_LEFTSCROLLBAR = 0x00004000; +pub const WS_EX_RIGHTSCROLLBAR = 0x00000000; +pub const WS_EX_CONTROLPARENT = 0x00010000; +pub const WS_EX_STATICEDGE = 0x00020000; +pub const WS_EX_APPWINDOW = 0x00040000; +pub const WS_EX_LAYERED = 0x00080000; +pub const WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE; +pub const WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST; + +pub const CW_USEDEFAULT = @bitCast(i32, @as(u32, 0x80000000)); + +pub extern "user32" fn CreateWindowExA(dwExStyle: DWORD, lpClassName: [*:0]const u8, lpWindowName: [*:0]const u8, dwStyle: DWORD, X: i32, Y: i32, nWidth: i32, nHeight: i32, hWindParent: ?HWND, hMenu: ?HMENU, hInstance: HINSTANCE, lpParam: ?LPVOID) callconv(WINAPI) ?HWND; +pub fn createWindowExA(dwExStyle: u32, lpClassName: [*:0]const u8, lpWindowName: [*:0]const u8, dwStyle: u32, X: i32, Y: i32, nWidth: i32, nHeight: i32, hWindParent: ?HWND, hMenu: ?HMENU, hInstance: HINSTANCE, lpParam: ?*c_void) !HWND { + const window = CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWindParent, hMenu, hInstance, lpParam); + if (window) |win| return win; + + switch (GetLastError()) { + .CLASS_DOES_NOT_EXIST => return error.ClassDoesNotExist, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn CreateWindowExW(dwExStyle: DWORD, lpClassName: [*:0]const u16, lpWindowName: [*:0]const u16, dwStyle: DWORD, X: i32, Y: i32, nWidth: i32, nHeight: i32, hWindParent: ?HWND, hMenu: ?HMENU, hInstance: HINSTANCE, lpParam: ?LPVOID) callconv(WINAPI) ?HWND; +pub var pfnCreateWindowExW: @TypeOf(RegisterClassExW) = undefined; +pub fn createWindowExW(dwExStyle: u32, lpClassName: [*:0]const u16, lpWindowName: [*:0]const u16, dwStyle: u32, X: i32, Y: i32, nWidth: i32, nHeight: i32, hWindParent: ?HWND, hMenu: ?HMENU, hInstance: HINSTANCE, lpParam: ?*c_void) !HWND { + const function = selectSymbol(CreateWindowExW, pfnCreateWindowExW, .win2k); + const window = function(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWindParent, hMenu, hInstance, lpParam); + if (window) |win| return win; + + switch (GetLastError()) { + .CLASS_DOES_NOT_EXIST => return error.ClassDoesNotExist, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn DestroyWindow(hWnd: HWND) callconv(WINAPI) BOOL; +pub fn destroyWindow(hWnd: HWND) !void { + if (DestroyWindow(hWnd) == 0) { + switch (GetLastError()) { + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } + } +} + +pub const SW_HIDE = 0; +pub const SW_SHOWNORMAL = 1; +pub const SW_NORMAL = 1; +pub const SW_SHOWMINIMIZED = 2; +pub const SW_SHOWMAXIMIZED = 3; +pub const SW_MAXIMIZE = 3; +pub const SW_SHOWNOACTIVATE = 4; +pub const SW_SHOW = 5; +pub const SW_MINIMIZE = 6; +pub const SW_SHOWMINNOACTIVE = 7; +pub const SW_SHOWNA = 8; +pub const SW_RESTORE = 9; +pub const SW_SHOWDEFAULT = 10; +pub const SW_FORCEMINIMIZE = 11; +pub const SW_MAX = 11; + +pub extern "user32" fn ShowWindow(hWnd: HWND, nCmdShow: i32) callconv(WINAPI) BOOL; +pub fn showWindow(hWnd: HWND, nCmdShow: i32) bool { + return (ShowWindow(hWnd, nCmdShow) == TRUE); +} + +pub extern "user32" fn UpdateWindow(hWnd: HWND) callconv(WINAPI) BOOL; +pub fn updateWindow(hWnd: HWND) !void { + if (ShowWindow(hWnd, nCmdShow) == 0) { + switch (GetLastError()) { + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } + } +} + +pub extern "user32" fn AdjustWindowRectEx(lpRect: *RECT, dwStyle: DWORD, bMenu: BOOL, dwExStyle: DWORD) callconv(WINAPI) BOOL; +pub fn adjustWindowRectEx(lpRect: *RECT, dwStyle: u32, bMenu: bool, dwExStyle: u32) !void { + assert(dwStyle & WS_OVERLAPPED == 0); + + if (AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle) == 0) { + switch (GetLastError()) { + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } + } +} + +pub const GWL_WNDPROC = -4; +pub const GWL_HINSTANCE = -6; +pub const GWL_HWNDPARENT = -8; +pub const GWL_STYLE = -16; +pub const GWL_EXSTYLE = -20; +pub const GWL_USERDATA = -21; +pub const GWL_ID = -12; + +pub extern "user32" fn GetWindowLongA(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG; +pub fn getWindowLongA(hWnd: HWND, nIndex: i32) !i32 { + const value = GetWindowLongA(hWnd, nIndex); + if (value != 0) return value; + + switch (GetLastError()) { + .SUCCESS => return 0, + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn GetWindowLongW(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG; +pub var pfnGetWindowLongW: @TypeOf(GetWindowLongW) = undefined; +pub fn getWindowLongW(hWnd: HWND, nIndex: i32) !i32 { + const function = selectSymbol(GetWindowLongW, pfnGetWindowLongW, .win2k); + + const value = function(hWnd, nIndex); + if (value != 0) return value; + + switch (GetLastError()) { + .SUCCESS => return 0, + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn GetWindowLongPtrA(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG_PTR; +pub fn getWindowLongPtrA(hWnd: HWND, nIndex: i32) !isize { + // "When compiling for 32-bit Windows, GetWindowLongPtr is defined as a call to the GetWindowLong function." + // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongptrw + if (@sizeOf(LONG_PTR) == 4) return getWindowLongA(hWnd, nIndex); + + const value = GetWindowLongPtrA(hWnd, nIndex); + if (value != 0) return value; + + switch (GetLastError()) { + .SUCCESS => return 0, + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn GetWindowLongPtrW(hWnd: HWND, nIndex: i32) callconv(WINAPI) LONG_PTR; +pub var pfnGetWindowLongPtrW: @TypeOf(GetWindowLongPtrW) = undefined; +pub fn getWindowLongPtrW(hWnd: HWND, nIndex: i32) !isize { + if (@sizeOf(LONG_PTR) == 4) return getWindowLongW(hWnd, nIndex); + const function = selectSymbol(GetWindowLongPtrW, pfnGetWindowLongPtrW, .win2k); + + const value = function(hWnd, nIndex); + if (value != 0) return value; + + switch (GetLastError()) { + .SUCCESS => return 0, + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn SetWindowLongA(hWnd: HWND, nIndex: i32, dwNewLong: LONG) callconv(WINAPI) LONG; +pub fn setWindowLongA(hWnd: HWND, nIndex: i32, dwNewLong: i32) !i32 { + // [...] you should clear the last error information by calling SetLastError with 0 before calling SetWindowLong. + // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlonga + SetLastError(.SUCCESS); + + const value = SetWindowLongA(hWnd, nIndex, dwNewLong); + if (value != 0) return value; + + switch (GetLastError()) { + .SUCCESS => return 0, + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn SetWindowLongW(hWnd: HWND, nIndex: i32, dwNewLong: LONG) callconv(WINAPI) LONG; +pub var pfnSetWindowLongW: @TypeOf(SetWindowLongW) = undefined; +pub fn setWindowLongW(hWnd: HWND, nIndex: i32, dwNewLong: i32) !i32 { + const function = selectSymbol(SetWindowLongW, pfnSetWindowLongW, .win2k); + + SetLastError(.SUCCESS); + const value = function(hWnd, nIndex, dwNewLong); + if (value != 0) return value; + + switch (GetLastError()) { + .SUCCESS => return 0, + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn SetWindowLongPtrA(hWnd: HWND, nIndex: i32, dwNewLong: LONG_PTR) callconv(WINAPI) LONG_PTR; +pub fn setWindowLongPtrA(hWnd: HWND, nIndex: i32, dwNewLong: isize) !isize { + // "When compiling for 32-bit Windows, GetWindowLongPtr is defined as a call to the GetWindowLong function." + // https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongptrw + if (@sizeOf(LONG_PTR) == 4) return setWindowLongA(hWnd, nIndex, dwNewLong); + + SetLastError(.SUCCESS); + const value = SetWindowLongPtrA(hWnd, nIndex, dwNewLong); + if (value != 0) return value; + + switch (GetLastError()) { + .SUCCESS => return 0, + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn SetWindowLongPtrW(hWnd: HWND, nIndex: i32, dwNewLong: LONG_PTR) callconv(WINAPI) LONG_PTR; +pub var pfnSetWindowLongPtrW: @TypeOf(SetWindowLongPtrW) = undefined; +pub fn setWindowLongPtrW(hWnd: HWND, nIndex: i32, dwNewLong: isize) !isize { + if (@sizeOf(LONG_PTR) == 4) return setWindowLongW(hWnd, nIndex, dwNewLong); + const function = selectSymbol(SetWindowLongPtrW, pfnSetWindowLongPtrW, .win2k); + + SetLastError(.SUCCESS); + const value = function(hWnd, nIndex, dwNewLong); + if (value != 0) return value; + + switch (GetLastError()) { + .SUCCESS => return 0, + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} -pub extern "user32" fn RegisterClassExA(*const WNDCLASSEXA) callconv(WINAPI) c_ushort; -pub extern "user32" fn DefWindowProcA(HWND, Msg: UINT, WPARAM, LPARAM) callconv(WINAPI) LRESULT; -pub extern "user32" fn ShowWindow(hWnd: ?HWND, nCmdShow: i32) callconv(WINAPI) bool; -pub extern "user32" fn UpdateWindow(hWnd: ?HWND) callconv(WINAPI) bool; pub extern "user32" fn GetDC(hWnd: ?HWND) callconv(WINAPI) ?HDC; +pub fn getDC(hWnd: ?HWND) !HDC { + const hdc = GetDC(hWnd); + if (hdc) |h| return h; -pub extern "user32" fn PeekMessageA( - lpMsg: ?*MSG, - hWnd: ?HWND, - wMsgFilterMin: UINT, - wMsgFilterMax: UINT, - wRemoveMsg: UINT, -) callconv(WINAPI) bool; + switch (GetLastError()) { + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} -pub extern "user32" fn GetMessageA( - lpMsg: ?*MSG, - hWnd: ?HWND, - wMsgFilterMin: UINT, - wMsgFilterMax: UINT, -) callconv(WINAPI) bool; +pub extern "user32" fn ReleaseDC(hWnd: ?HWND, hDC: HDC) callconv(WINAPI) i32; +pub fn releaseDC(hWnd: ?HWND, hDC: HDC) bool { + return if (ReleaseDC(hWnd, hDC) == 1) true else false; +} -pub extern "user32" fn TranslateMessage(lpMsg: *const MSG) callconv(WINAPI) bool; -pub extern "user32" fn DispatchMessageA(lpMsg: *const MSG) callconv(WINAPI) LRESULT; -pub extern "user32" fn PostQuitMessage(nExitCode: i32) callconv(WINAPI) void; +// === Modal dialogue boxes === + +pub const MB_OK = 0x00000000; +pub const MB_OKCANCEL = 0x00000001; +pub const MB_ABORTRETRYIGNORE = 0x00000002; +pub const MB_YESNOCANCEL = 0x00000003; +pub const MB_YESNO = 0x00000004; +pub const MB_RETRYCANCEL = 0x00000005; +pub const MB_CANCELTRYCONTINUE = 0x00000006; +pub const MB_ICONHAND = 0x00000010; +pub const MB_ICONQUESTION = 0x00000020; +pub const MB_ICONEXCLAMATION = 0x00000030; +pub const MB_ICONASTERISK = 0x00000040; +pub const MB_USERICON = 0x00000080; +pub const MB_ICONWARNING = MB_ICONEXCLAMATION; +pub const MB_ICONERROR = MB_ICONHAND; +pub const MB_ICONINFORMATION = MB_ICONASTERISK; +pub const MB_ICONSTOP = MB_ICONHAND; +pub const MB_DEFBUTTON1 = 0x00000000; +pub const MB_DEFBUTTON2 = 0x00000100; +pub const MB_DEFBUTTON3 = 0x00000200; +pub const MB_DEFBUTTON4 = 0x00000300; +pub const MB_APPLMODAL = 0x00000000; +pub const MB_SYSTEMMODAL = 0x00001000; +pub const MB_TASKMODAL = 0x00002000; +pub const MB_HELP = 0x00004000; +pub const MB_NOFOCUS = 0x00008000; +pub const MB_SETFOREGROUND = 0x00010000; +pub const MB_DEFAULT_DESKTOP_ONLY = 0x00020000; +pub const MB_TOPMOST = 0x00040000; +pub const MB_RIGHT = 0x00080000; +pub const MB_RTLREADING = 0x00100000; +pub const MB_TYPEMASK = 0x0000000F; +pub const MB_ICONMASK = 0x000000F0; +pub const MB_DEFMASK = 0x00000F00; +pub const MB_MODEMASK = 0x00003000; +pub const MB_MISCMASK = 0x0000C000; + +pub const IDOK = 1; +pub const IDCANCEL = 2; +pub const IDABORT = 3; +pub const IDRETRY = 4; +pub const IDIGNORE = 5; +pub const IDYES = 6; +pub const IDNO = 7; +pub const IDCLOSE = 8; +pub const IDHELP = 9; +pub const IDTRYAGAIN = 10; +pub const IDCONTINUE = 11; + +pub extern "user32" fn MessageBoxA(hWnd: ?HWND, lpText: [*:0]const u8, lpCaption: [*:0]const u8, uType: UINT) callconv(WINAPI) i32; +pub fn messageBoxA(hWnd: ?HWND, lpText: [*:0]const u8, lpCaption: [*:0]const u8, uType: u32) !i32 { + const value = MessageBoxA(hWnd, lpText, lpCaption, uType); + if (value != 0) return value; + switch (GetLastError()) { + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} + +pub extern "user32" fn MessageBoxW(hWnd: ?HWND, lpText: [*:0]const u16, lpCaption: ?[*:0]const u16, uType: UINT) callconv(WINAPI) i32; +pub var pfnMessageBoxW: @TypeOf(MessageBoxW) = undefined; +pub fn messageBoxW(hWnd: ?HWND, lpText: [*:0]const u16, lpCaption: [*:0]const u16, uType: u32) !i32 { + const function = selectSymbol(pfnMessageBoxW, MessageBoxW, .win2k); + const value = function(hWnd, lpText, lpCaption, uType); + if (value != 0) return value; + switch (GetLastError()) { + .INVALID_WINDOW_HANDLE => unreachable, + .INVALID_PARAMETER => unreachable, + else => |err| return windows.unexpectedError(err), + } +} diff --git a/lib/std/os/windows/win32error.zig b/lib/std/os/windows/win32error.zig index 2e1f111d92..61bbcac8bb 100644 --- a/lib/std/os/windows/win32error.zig +++ b/lib/std/os/windows/win32error.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/os/windows/ws2_32.zig b/lib/std/os/windows/ws2_32.zig index 7123869d65..1dd2ce738b 100644 --- a/lib/std/os/windows/ws2_32.zig +++ b/lib/std/os/windows/ws2_32.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/packed_int_array.zig b/lib/std/packed_int_array.zig index c3222c483c..c53d6f0505 100644 --- a/lib/std/packed_int_array.zig +++ b/lib/std/packed_int_array.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -203,6 +203,14 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: builtin.Endian, return self; } + ///Initialize all entries of a packed array to the same value + pub fn initAllTo(int: Int) Self { + // TODO: use `var self = @as(Self, undefined);` https://github.com/ziglang/zig/issues/7635 + var self = Self{ .bytes = [_]u8{0} ** total_bytes }; + self.setAll(int); + return self; + } + ///Return the Int stored at index pub fn get(self: Self, index: usize) Int { debug.assert(index < int_count); @@ -215,6 +223,14 @@ pub fn PackedIntArrayEndian(comptime Int: type, comptime endian: builtin.Endian, return Io.set(&self.bytes, index, 0, int); } + ///Set all entries of a packed array to the same value + pub fn setAll(self: *Self, int: Int) void { + var i: usize = 0; + while (i < int_count) : (i += 1) { + self.set(i, int); + } + } + ///Create a PackedIntSlice of the array from given start to given end pub fn slice(self: *Self, start: usize, end: usize) PackedIntSliceEndian(Int, endian) { debug.assert(start < int_count); @@ -365,7 +381,15 @@ test "PackedIntArray init" { const PackedArray = PackedIntArray(u3, 8); var packed_array = PackedArray.init([_]u3{ 0, 1, 2, 3, 4, 5, 6, 7 }); var i = @as(usize, 0); - while (i < packed_array.len()) : (i += 1) testing.expect(packed_array.get(i) == i); + while (i < packed_array.len()) : (i += 1) testing.expectEqual(@intCast(u3, i), packed_array.get(i)); +} + +test "PackedIntArray initAllTo" { + if (we_are_testing_this_with_stage1_which_leaks_comptime_memory) return error.SkipZigTest; + const PackedArray = PackedIntArray(u3, 8); + var packed_array = PackedArray.initAllTo(5); + var i = @as(usize, 0); + while (i < packed_array.len()) : (i += 1) testing.expectEqual(@as(u3, 5), packed_array.get(i)); } test "PackedIntSlice" { diff --git a/lib/std/pdb.zig b/lib/std/pdb.zig index c35ab6f723..6a47cd6e8b 100644 --- a/lib/std/pdb.zig +++ b/lib/std/pdb.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -662,6 +662,7 @@ const MsfStream = struct { fn read(self: *MsfStream, buffer: []u8) !usize { var block_id = @intCast(usize, self.pos / self.block_size); + if (block_id >= self.blocks.len) return 0; // End of Stream var block = self.blocks[block_id]; var offset = self.pos % self.block_size; @@ -680,6 +681,7 @@ const MsfStream = struct { if (offset == self.block_size) { offset = 0; block_id += 1; + if (block_id >= self.blocks.len) break; // End of Stream block = self.blocks[block_id]; try self.in_file.seekTo(block * self.block_size); } @@ -716,8 +718,4 @@ const MsfStream = struct { pub fn reader(self: *MsfStream) std.io.Reader(*MsfStream, Error, read) { return .{ .context = self }; } - /// Deprecated: use `reader` - pub fn inStream(self: *MsfStream) std.io.InStream(*MsfStream, Error, read) { - return .{ .context = self }; - } }; diff --git a/lib/std/priority_queue.zig b/lib/std/priority_queue.zig index 951e07bfb6..f5c01edff5 100644 --- a/lib/std/priority_queue.zig +++ b/lib/std/priority_queue.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/process.zig b/lib/std/process.zig index e12bc28c0c..3ad73db420 100644 --- a/lib/std/process.zig +++ b/lib/std/process.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -13,6 +13,7 @@ const math = std.math; const Allocator = mem.Allocator; const assert = std.debug.assert; const testing = std.testing; +const child_process = @import("child_process.zig"); pub const abort = os.abort; pub const exit = os.exit; @@ -516,7 +517,8 @@ test "args iterator" { const given_suffix = std.fs.path.basename(prog_name); testing.expect(mem.eql(u8, expected_suffix, given_suffix)); - testing.expectEqual(it.next(ga), null); + testing.expect(it.skip()); // Skip over zig_exe_path, passed to the test runner + testing.expect(it.next(ga) == null); testing.expect(!it.skip()); } @@ -594,7 +596,7 @@ fn testWindowsCmdLine(input_cmd_line: [*]const u16, expected_args: []const []con for (expected_args) |expected_arg| { const arg = it.next(std.testing.allocator).? catch unreachable; defer std.testing.allocator.free(arg); - testing.expectEqualSlices(u8, expected_arg, arg); + testing.expectEqualStrings(expected_arg, arg); } testing.expect(it.next(std.testing.allocator) == null); } @@ -607,7 +609,7 @@ pub const UserInfo = struct { /// POSIX function which gets a uid from username. pub fn getUserInfo(name: []const u8) !UserInfo { return switch (builtin.os.tag) { - .linux, .macos, .watchos, .tvos, .ios, .freebsd, .netbsd, .openbsd => posixGetUserInfo(name), + .linux, .macos, .watchos, .tvos, .ios, .freebsd, .netbsd, .openbsd, .haiku => posixGetUserInfo(name), else => @compileError("Unsupported OS"), }; } @@ -775,6 +777,82 @@ pub fn getSelfExeSharedLibPaths(allocator: *Allocator) error{OutOfMemory}![][:0] } return paths.toOwnedSlice(); }, + // revisit if Haiku implements dl_iterat_phdr (https://dev.haiku-os.org/ticket/15743) + .haiku => { + var paths = List.init(allocator); + errdefer { + const slice = paths.toOwnedSlice(); + for (slice) |item| { + allocator.free(item); + } + allocator.free(slice); + } + + var b = "/boot/system/runtime_loader"; + const item = try allocator.dupeZ(u8, mem.spanZ(b)); + errdefer allocator.free(item); + try paths.append(item); + + return paths.toOwnedSlice(); + }, else => @compileError("getSelfExeSharedLibPaths unimplemented for this target"), } } + +/// Tells whether calling the `execv` or `execve` functions will be a compile error. +pub const can_execv = std.builtin.os.tag != .windows; + +pub const ExecvError = std.os.ExecveError || error{OutOfMemory}; + +/// Replaces the current process image with the executed process. +/// This function must allocate memory to add a null terminating bytes on path and each arg. +/// It must also convert to KEY=VALUE\0 format for environment variables, and include null +/// pointers after the args and after the environment variables. +/// `argv[0]` is the executable path. +/// This function also uses the PATH environment variable to get the full path to the executable. +/// Due to the heap-allocation, it is illegal to call this function in a fork() child. +/// For that use case, use the `std.os` functions directly. +pub fn execv(allocator: *mem.Allocator, argv: []const []const u8) ExecvError { + return execve(allocator, argv, null); +} + +/// Replaces the current process image with the executed process. +/// This function must allocate memory to add a null terminating bytes on path and each arg. +/// It must also convert to KEY=VALUE\0 format for environment variables, and include null +/// pointers after the args and after the environment variables. +/// `argv[0]` is the executable path. +/// This function also uses the PATH environment variable to get the full path to the executable. +/// Due to the heap-allocation, it is illegal to call this function in a fork() child. +/// For that use case, use the `std.os` functions directly. +pub fn execve( + allocator: *mem.Allocator, + argv: []const []const u8, + env_map: ?*const std.BufMap, +) ExecvError { + if (!can_execv) @compileError("The target OS does not support execv"); + + var arena_allocator = std.heap.ArenaAllocator.init(allocator); + defer arena_allocator.deinit(); + const arena = &arena_allocator.allocator; + + const argv_buf = try arena.allocSentinel(?[*:0]u8, argv.len, null); + for (argv) |arg, i| argv_buf[i] = (try arena.dupeZ(u8, arg)).ptr; + + const envp = m: { + if (env_map) |m| { + const envp_buf = try child_process.createNullDelimitedEnvMap(arena, m); + break :m envp_buf.ptr; + } else if (std.builtin.link_libc) { + break :m std.c.environ; + } else if (std.builtin.output_mode == .Exe) { + // Then we have Zig start code and this works. + // TODO type-safety for null-termination of `os.environ`. + break :m @ptrCast([*:null]?[*:0]u8, os.environ.ptr); + } else { + // TODO come up with a solution for this. + @compileError("missing std lib enhancement: std.process.execv implementation has no way to collect the environment variables to forward to the child process"); + } + }; + + return os.execvpeZ_expandArg0(.no_expand, argv_buf.ptr[0].?, argv_buf.ptr, envp); +} diff --git a/lib/std/progress.zig b/lib/std/progress.zig deleted file mode 100644 index 82f2801fa1..0000000000 --- a/lib/std/progress.zig +++ /dev/null @@ -1,310 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -const std = @import("std"); -const windows = std.os.windows; -const testing = std.testing; -const assert = std.debug.assert; - -/// This API is non-allocating and non-fallible. The tradeoff is that users of -/// this API must provide the storage for each `Progress.Node`. -/// Initialize the struct directly, overriding these fields as desired: -/// * `refresh_rate_ms` -/// * `initial_delay_ms` -pub const Progress = struct { - /// `null` if the current node (and its children) should - /// not print on update() - terminal: ?std.fs.File = undefined, - - /// Whether the terminal supports ANSI escape codes. - supports_ansi_escape_codes: bool = false, - - root: Node = undefined, - - /// Keeps track of how much time has passed since the beginning. - /// Used to compare with `initial_delay_ms` and `refresh_rate_ms`. - timer: std.time.Timer = undefined, - - /// When the previous refresh was written to the terminal. - /// Used to compare with `refresh_rate_ms`. - prev_refresh_timestamp: u64 = undefined, - - /// This buffer represents the maximum number of bytes written to the terminal - /// with each refresh. - output_buffer: [100]u8 = undefined, - - /// How many nanoseconds between writing updates to the terminal. - refresh_rate_ns: u64 = 50 * std.time.ns_per_ms, - - /// How many nanoseconds to keep the output hidden - initial_delay_ns: u64 = 500 * std.time.ns_per_ms, - - done: bool = true, - - /// Keeps track of how many columns in the terminal have been output, so that - /// we can move the cursor back later. - columns_written: usize = undefined, - - /// Represents one unit of progress. Each node can have children nodes, or - /// one can use integers with `update`. - pub const Node = struct { - context: *Progress, - parent: ?*Node, - completed_items: usize, - name: []const u8, - recently_updated_child: ?*Node = null, - - /// This field may be updated freely. - estimated_total_items: ?usize, - - /// Create a new child progress node. - /// Call `Node.end` when done. - /// TODO solve https://github.com/ziglang/zig/issues/2765 and then change this - /// API to set `self.parent.recently_updated_child` with the return value. - /// Until that is fixed you probably want to call `activate` on the return value. - pub fn start(self: *Node, name: []const u8, estimated_total_items: ?usize) Node { - return Node{ - .context = self.context, - .parent = self, - .completed_items = 0, - .name = name, - .estimated_total_items = estimated_total_items, - }; - } - - /// This is the same as calling `start` and then `end` on the returned `Node`. - pub fn completeOne(self: *Node) void { - if (self.parent) |parent| parent.recently_updated_child = self; - self.completed_items += 1; - self.context.maybeRefresh(); - } - - pub fn end(self: *Node) void { - self.context.maybeRefresh(); - if (self.parent) |parent| { - if (parent.recently_updated_child) |parent_child| { - if (parent_child == self) { - parent.recently_updated_child = null; - } - } - parent.completeOne(); - } else { - self.context.done = true; - self.context.refresh(); - } - } - - /// Tell the parent node that this node is actively being worked on. - pub fn activate(self: *Node) void { - if (self.parent) |parent| parent.recently_updated_child = self; - } - }; - - /// Create a new progress node. - /// Call `Node.end` when done. - /// TODO solve https://github.com/ziglang/zig/issues/2765 and then change this - /// API to return Progress rather than accept it as a parameter. - pub fn start(self: *Progress, name: []const u8, estimated_total_items: ?usize) !*Node { - const stderr = std.io.getStdErr(); - self.terminal = null; - if (stderr.supportsAnsiEscapeCodes()) { - self.terminal = stderr; - self.supports_ansi_escape_codes = true; - } else if (std.builtin.os.tag == .windows and stderr.isTty()) { - self.terminal = stderr; - } - self.root = Node{ - .context = self, - .parent = null, - .completed_items = 0, - .name = name, - .estimated_total_items = estimated_total_items, - }; - self.columns_written = 0; - self.prev_refresh_timestamp = 0; - self.timer = try std.time.Timer.start(); - self.done = false; - return &self.root; - } - - /// Updates the terminal if enough time has passed since last update. - pub fn maybeRefresh(self: *Progress) void { - const now = self.timer.read(); - if (now < self.initial_delay_ns) return; - if (now - self.prev_refresh_timestamp < self.refresh_rate_ns) return; - self.refresh(); - } - - /// Updates the terminal and resets `self.next_refresh_timestamp`. - pub fn refresh(self: *Progress) void { - const file = self.terminal orelse return; - - const prev_columns_written = self.columns_written; - var end: usize = 0; - if (self.columns_written > 0) { - // restore the cursor position by moving the cursor - // `columns_written` cells to the left, then clear the rest of the - // line - if (self.supports_ansi_escape_codes) { - end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len; - end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len; - } else if (std.builtin.os.tag == .windows) winapi: { - var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined; - if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) - unreachable; - - var cursor_pos = windows.COORD{ - .X = info.dwCursorPosition.X - @intCast(windows.SHORT, self.columns_written), - .Y = info.dwCursorPosition.Y, - }; - - if (cursor_pos.X < 0) - cursor_pos.X = 0; - - const fill_chars = @intCast(windows.DWORD, info.dwSize.X - cursor_pos.X); - - var written: windows.DWORD = undefined; - if (windows.kernel32.FillConsoleOutputAttribute( - file.handle, - info.wAttributes, - fill_chars, - cursor_pos, - &written, - ) != windows.TRUE) { - // Stop trying to write to this file. - self.terminal = null; - break :winapi; - } - if (windows.kernel32.FillConsoleOutputCharacterA( - file.handle, - ' ', - fill_chars, - cursor_pos, - &written, - ) != windows.TRUE) unreachable; - - if (windows.kernel32.SetConsoleCursorPosition(file.handle, cursor_pos) != windows.TRUE) - unreachable; - } else unreachable; - - self.columns_written = 0; - } - - if (!self.done) { - var need_ellipse = false; - var maybe_node: ?*Node = &self.root; - while (maybe_node) |node| { - if (need_ellipse) { - self.bufWrite(&end, "... ", .{}); - } - need_ellipse = false; - if (node.name.len != 0 or node.estimated_total_items != null) { - if (node.name.len != 0) { - self.bufWrite(&end, "{}", .{node.name}); - need_ellipse = true; - } - if (node.estimated_total_items) |total| { - if (need_ellipse) self.bufWrite(&end, " ", .{}); - self.bufWrite(&end, "[{}/{}] ", .{ node.completed_items + 1, total }); - need_ellipse = false; - } else if (node.completed_items != 0) { - if (need_ellipse) self.bufWrite(&end, " ", .{}); - self.bufWrite(&end, "[{}] ", .{node.completed_items + 1}); - need_ellipse = false; - } - } - maybe_node = node.recently_updated_child; - } - if (need_ellipse) { - self.bufWrite(&end, "... ", .{}); - } - } - - _ = file.write(self.output_buffer[0..end]) catch |e| { - // Stop trying to write to this file once it errors. - self.terminal = null; - }; - self.prev_refresh_timestamp = self.timer.read(); - } - - pub fn log(self: *Progress, comptime format: []const u8, args: anytype) void { - const file = self.terminal orelse return; - self.refresh(); - file.outStream().print(format, args) catch { - self.terminal = null; - return; - }; - self.columns_written = 0; - } - - fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: anytype) void { - if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| { - const amt = written.len; - end.* += amt; - self.columns_written += amt; - } else |err| switch (err) { - error.NoSpaceLeft => { - self.columns_written += self.output_buffer.len - end.*; - end.* = self.output_buffer.len; - }, - } - const bytes_needed_for_esc_codes_at_end = if (std.builtin.os.tag == .windows) 0 else 11; - const max_end = self.output_buffer.len - bytes_needed_for_esc_codes_at_end; - if (end.* > max_end) { - const suffix = "... "; - self.columns_written = self.columns_written - (end.* - max_end) + suffix.len; - std.mem.copy(u8, self.output_buffer[max_end..], suffix); - end.* = max_end + suffix.len; - } - } -}; - -test "basic functionality" { - var disable = true; - if (disable) { - // This test is disabled because it uses time.sleep() and is therefore slow. It also - // prints bogus progress data to stderr. - return error.SkipZigTest; - } - var progress = Progress{}; - const root_node = try progress.start("", 100); - defer root_node.end(); - - const sub_task_names = [_][]const u8{ - "reticulating splines", - "adjusting shoes", - "climbing towers", - "pouring juice", - }; - var next_sub_task: usize = 0; - - var i: usize = 0; - while (i < 100) : (i += 1) { - var node = root_node.start(sub_task_names[next_sub_task], 5); - node.activate(); - next_sub_task = (next_sub_task + 1) % sub_task_names.len; - - node.completeOne(); - std.time.sleep(5 * std.time.ns_per_ms); - node.completeOne(); - node.completeOne(); - std.time.sleep(5 * std.time.ns_per_ms); - node.completeOne(); - node.completeOne(); - std.time.sleep(5 * std.time.ns_per_ms); - - node.end(); - - std.time.sleep(5 * std.time.ns_per_ms); - } - { - var node = root_node.start("this is a really long name designed to activate the truncation code. let's find out if it works", null); - node.activate(); - std.time.sleep(10 * std.time.ns_per_ms); - progress.refresh(); - std.time.sleep(10 * std.time.ns_per_ms); - node.end(); - } -} diff --git a/lib/std/rand.zig b/lib/std/rand.zig index a201968a5f..d0d400b5b0 100644 --- a/lib/std/rand.zig +++ b/lib/std/rand.zig @@ -1,22 +1,14 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -//! The engines provided here should be initialized from an external source. For now, randomBytes -//! from the crypto package is the most suitable. Be sure to use a CSPRNG when required, otherwise using -//! a normal PRNG will be faster and use substantially less stack space. -//! -//! ``` -//! var buf: [8]u8 = undefined; -//! try std.crypto.randomBytes(buf[0..]); -//! const seed = mem.readIntLittle(u64, buf[0..8]); -//! -//! var r = DefaultPrng.init(seed); -//! -//! const s = r.random.int(u64); -//! ``` +//! The engines provided here should be initialized from an external source. +//! For a thread-local cryptographically secure pseudo random number generator, +//! use `std.crypto.random`. +//! Be sure to use a CSPRNG when required, otherwise using a normal PRNG will +//! be faster and use substantially less stack space. //! //! TODO(tiehuis): Benchmark these against other reference implementations. @@ -36,6 +28,12 @@ pub const DefaultPrng = Xoroshiro128; /// Cryptographically secure random numbers. pub const DefaultCsprng = Gimli; +pub const Isaac64 = @import("rand/Isaac64.zig"); +pub const Gimli = @import("rand/Gimli.zig"); +pub const Pcg = @import("rand/Pcg.zig"); +pub const Xoroshiro128 = @import("rand/Xoroshiro128.zig"); +pub const Sfc64 = @import("rand/Sfc64.zig"); + pub const Random = struct { fillFn: fn (r: *Random, buf: []u8) void, @@ -491,7 +489,7 @@ test "Random Biased" { // // The number of cycles is thus limited to 64-bits regardless of the engine, but this // is still plenty for practical purposes. -const SplitMix64 = struct { +pub const SplitMix64 = struct { s: u64, pub fn init(seed: u64) SplitMix64 { @@ -525,557 +523,6 @@ test "splitmix64 sequence" { } } -// PCG32 - http://www.pcg-random.org/ -// -// PRNG -pub const Pcg = struct { - const default_multiplier = 6364136223846793005; - - random: Random, - - s: u64, - i: u64, - - pub fn init(init_s: u64) Pcg { - var pcg = Pcg{ - .random = Random{ .fillFn = fill }, - .s = undefined, - .i = undefined, - }; - - pcg.seed(init_s); - return pcg; - } - - fn next(self: *Pcg) u32 { - const l = self.s; - self.s = l *% default_multiplier +% (self.i | 1); - - const xor_s = @truncate(u32, ((l >> 18) ^ l) >> 27); - const rot = @intCast(u32, l >> 59); - - return (xor_s >> @intCast(u5, rot)) | (xor_s << @intCast(u5, (0 -% rot) & 31)); - } - - fn seed(self: *Pcg, init_s: u64) void { - // Pcg requires 128-bits of seed. - var gen = SplitMix64.init(init_s); - self.seedTwo(gen.next(), gen.next()); - } - - fn seedTwo(self: *Pcg, init_s: u64, init_i: u64) void { - self.s = 0; - self.i = (init_s << 1) | 1; - self.s = self.s *% default_multiplier +% self.i; - self.s +%= init_i; - self.s = self.s *% default_multiplier +% self.i; - } - - fn fill(r: *Random, buf: []u8) void { - const self = @fieldParentPtr(Pcg, "random", r); - - var i: usize = 0; - const aligned_len = buf.len - (buf.len & 7); - - // Complete 4 byte segments. - while (i < aligned_len) : (i += 4) { - var n = self.next(); - comptime var j: usize = 0; - inline while (j < 4) : (j += 1) { - buf[i + j] = @truncate(u8, n); - n >>= 8; - } - } - - // Remaining. (cuts the stream) - if (i != buf.len) { - var n = self.next(); - while (i < buf.len) : (i += 1) { - buf[i] = @truncate(u8, n); - n >>= 4; - } - } - } -}; - -test "pcg sequence" { - var r = Pcg.init(0); - const s0: u64 = 0x9394bf54ce5d79de; - const s1: u64 = 0x84e9c579ef59bbf7; - r.seedTwo(s0, s1); - - const seq = [_]u32{ - 2881561918, - 3063928540, - 1199791034, - 2487695858, - 1479648952, - 3247963454, - }; - - for (seq) |s| { - expect(s == r.next()); - } -} - -// Xoroshiro128+ - http://xoroshiro.di.unimi.it/ -// -// PRNG -pub const Xoroshiro128 = struct { - random: Random, - - s: [2]u64, - - pub fn init(init_s: u64) Xoroshiro128 { - var x = Xoroshiro128{ - .random = Random{ .fillFn = fill }, - .s = undefined, - }; - - x.seed(init_s); - return x; - } - - fn next(self: *Xoroshiro128) u64 { - const s0 = self.s[0]; - var s1 = self.s[1]; - const r = s0 +% s1; - - s1 ^= s0; - self.s[0] = math.rotl(u64, s0, @as(u8, 55)) ^ s1 ^ (s1 << 14); - self.s[1] = math.rotl(u64, s1, @as(u8, 36)); - - return r; - } - - // Skip 2^64 places ahead in the sequence - fn jump(self: *Xoroshiro128) void { - var s0: u64 = 0; - var s1: u64 = 0; - - const table = [_]u64{ - 0xbeac0467eba5facb, - 0xd86b048b86aa9922, - }; - - inline for (table) |entry| { - var b: usize = 0; - while (b < 64) : (b += 1) { - if ((entry & (@as(u64, 1) << @intCast(u6, b))) != 0) { - s0 ^= self.s[0]; - s1 ^= self.s[1]; - } - _ = self.next(); - } - } - - self.s[0] = s0; - self.s[1] = s1; - } - - pub fn seed(self: *Xoroshiro128, init_s: u64) void { - // Xoroshiro requires 128-bits of seed. - var gen = SplitMix64.init(init_s); - - self.s[0] = gen.next(); - self.s[1] = gen.next(); - } - - fn fill(r: *Random, buf: []u8) void { - const self = @fieldParentPtr(Xoroshiro128, "random", r); - - var i: usize = 0; - const aligned_len = buf.len - (buf.len & 7); - - // Complete 8 byte segments. - while (i < aligned_len) : (i += 8) { - var n = self.next(); - comptime var j: usize = 0; - inline while (j < 8) : (j += 1) { - buf[i + j] = @truncate(u8, n); - n >>= 8; - } - } - - // Remaining. (cuts the stream) - if (i != buf.len) { - var n = self.next(); - while (i < buf.len) : (i += 1) { - buf[i] = @truncate(u8, n); - n >>= 8; - } - } - } -}; - -test "xoroshiro sequence" { - var r = Xoroshiro128.init(0); - r.s[0] = 0xaeecf86f7878dd75; - r.s[1] = 0x01cd153642e72622; - - const seq1 = [_]u64{ - 0xb0ba0da5bb600397, - 0x18a08afde614dccc, - 0xa2635b956a31b929, - 0xabe633c971efa045, - 0x9ac19f9706ca3cac, - 0xf62b426578c1e3fb, - }; - - for (seq1) |s| { - expect(s == r.next()); - } - - r.jump(); - - const seq2 = [_]u64{ - 0x95344a13556d3e22, - 0xb4fb32dafa4d00df, - 0xb2011d9ccdcfe2dd, - 0x05679a9b2119b908, - 0xa860a1da7c9cd8a0, - 0x658a96efe3f86550, - }; - - for (seq2) |s| { - expect(s == r.next()); - } -} - -// Gimli -// -// CSPRNG -pub const Gimli = struct { - random: Random, - state: std.crypto.core.Gimli, - - pub const secret_seed_length = 32; - - /// The seed must be uniform, secret and `secret_seed_length` bytes long. - /// It can be generated using `std.crypto.randomBytes()`. - pub fn init(secret_seed: [secret_seed_length]u8) Gimli { - var initial_state: [std.crypto.core.Gimli.BLOCKBYTES]u8 = undefined; - mem.copy(u8, initial_state[0..secret_seed_length], &secret_seed); - mem.set(u8, initial_state[secret_seed_length..], 0); - var self = Gimli{ - .random = Random{ .fillFn = fill }, - .state = std.crypto.core.Gimli.init(initial_state), - }; - return self; - } - - fn fill(r: *Random, buf: []u8) void { - const self = @fieldParentPtr(Gimli, "random", r); - - if (buf.len != 0) { - self.state.squeeze(buf); - } else { - self.state.permute(); - } - mem.set(u8, self.state.toSlice()[0..std.crypto.core.Gimli.RATE], 0); - } -}; - -// ISAAC64 - http://www.burtleburtle.net/bob/rand/isaacafa.html -// -// Follows the general idea of the implementation from here with a few shortcuts. -// https://doc.rust-lang.org/rand/src/rand/prng/isaac64.rs.html -pub const Isaac64 = struct { - random: Random, - - r: [256]u64, - m: [256]u64, - a: u64, - b: u64, - c: u64, - i: usize, - - pub fn init(init_s: u64) Isaac64 { - var isaac = Isaac64{ - .random = Random{ .fillFn = fill }, - .r = undefined, - .m = undefined, - .a = undefined, - .b = undefined, - .c = undefined, - .i = undefined, - }; - - // seed == 0 => same result as the unseeded reference implementation - isaac.seed(init_s, 1); - return isaac; - } - - fn step(self: *Isaac64, mix: u64, base: usize, comptime m1: usize, comptime m2: usize) void { - const x = self.m[base + m1]; - self.a = mix +% self.m[base + m2]; - - const y = self.a +% self.b +% self.m[@intCast(usize, (x >> 3) % self.m.len)]; - self.m[base + m1] = y; - - self.b = x +% self.m[@intCast(usize, (y >> 11) % self.m.len)]; - self.r[self.r.len - 1 - base - m1] = self.b; - } - - fn refill(self: *Isaac64) void { - const midpoint = self.r.len / 2; - - self.c +%= 1; - self.b +%= self.c; - - { - var i: usize = 0; - while (i < midpoint) : (i += 4) { - self.step(~(self.a ^ (self.a << 21)), i + 0, 0, midpoint); - self.step(self.a ^ (self.a >> 5), i + 1, 0, midpoint); - self.step(self.a ^ (self.a << 12), i + 2, 0, midpoint); - self.step(self.a ^ (self.a >> 33), i + 3, 0, midpoint); - } - } - - { - var i: usize = 0; - while (i < midpoint) : (i += 4) { - self.step(~(self.a ^ (self.a << 21)), i + 0, midpoint, 0); - self.step(self.a ^ (self.a >> 5), i + 1, midpoint, 0); - self.step(self.a ^ (self.a << 12), i + 2, midpoint, 0); - self.step(self.a ^ (self.a >> 33), i + 3, midpoint, 0); - } - } - - self.i = 0; - } - - fn next(self: *Isaac64) u64 { - if (self.i >= self.r.len) { - self.refill(); - } - - const value = self.r[self.i]; - self.i += 1; - return value; - } - - fn seed(self: *Isaac64, init_s: u64, comptime rounds: usize) void { - // We ignore the multi-pass requirement since we don't currently expose full access to - // seeding the self.m array completely. - mem.set(u64, self.m[0..], 0); - self.m[0] = init_s; - - // prescrambled golden ratio constants - var a = [_]u64{ - 0x647c4677a2884b7c, - 0xb9f8b322c73ac862, - 0x8c0ea5053d4712a0, - 0xb29b2e824a595524, - 0x82f053db8355e0ce, - 0x48fe4a0fa5a09315, - 0xae985bf2cbfc89ed, - 0x98f5704f6c44c0ab, - }; - - comptime var i: usize = 0; - inline while (i < rounds) : (i += 1) { - var j: usize = 0; - while (j < self.m.len) : (j += 8) { - comptime var x1: usize = 0; - inline while (x1 < 8) : (x1 += 1) { - a[x1] +%= self.m[j + x1]; - } - - a[0] -%= a[4]; - a[5] ^= a[7] >> 9; - a[7] +%= a[0]; - a[1] -%= a[5]; - a[6] ^= a[0] << 9; - a[0] +%= a[1]; - a[2] -%= a[6]; - a[7] ^= a[1] >> 23; - a[1] +%= a[2]; - a[3] -%= a[7]; - a[0] ^= a[2] << 15; - a[2] +%= a[3]; - a[4] -%= a[0]; - a[1] ^= a[3] >> 14; - a[3] +%= a[4]; - a[5] -%= a[1]; - a[2] ^= a[4] << 20; - a[4] +%= a[5]; - a[6] -%= a[2]; - a[3] ^= a[5] >> 17; - a[5] +%= a[6]; - a[7] -%= a[3]; - a[4] ^= a[6] << 14; - a[6] +%= a[7]; - - comptime var x2: usize = 0; - inline while (x2 < 8) : (x2 += 1) { - self.m[j + x2] = a[x2]; - } - } - } - - mem.set(u64, self.r[0..], 0); - self.a = 0; - self.b = 0; - self.c = 0; - self.i = self.r.len; // trigger refill on first value - } - - fn fill(r: *Random, buf: []u8) void { - const self = @fieldParentPtr(Isaac64, "random", r); - - var i: usize = 0; - const aligned_len = buf.len - (buf.len & 7); - - // Fill complete 64-byte segments - while (i < aligned_len) : (i += 8) { - var n = self.next(); - comptime var j: usize = 0; - inline while (j < 8) : (j += 1) { - buf[i + j] = @truncate(u8, n); - n >>= 8; - } - } - - // Fill trailing, ignoring excess (cut the stream). - if (i != buf.len) { - var n = self.next(); - while (i < buf.len) : (i += 1) { - buf[i] = @truncate(u8, n); - n >>= 8; - } - } - } -}; - -test "isaac64 sequence" { - var r = Isaac64.init(0); - - // from reference implementation - const seq = [_]u64{ - 0xf67dfba498e4937c, - 0x84a5066a9204f380, - 0xfee34bd5f5514dbb, - 0x4d1664739b8f80d6, - 0x8607459ab52a14aa, - 0x0e78bc5a98529e49, - 0xfe5332822ad13777, - 0x556c27525e33d01a, - 0x08643ca615f3149f, - 0xd0771faf3cb04714, - 0x30e86f68a37b008d, - 0x3074ebc0488a3adf, - 0x270645ea7a2790bc, - 0x5601a0a8d3763c6a, - 0x2f83071f53f325dd, - 0xb9090f3d42d2d2ea, - }; - - for (seq) |s| { - expect(s == r.next()); - } -} - -/// Sfc64 pseudo-random number generator from Practically Random. -/// Fastest engine of pracrand and smallest footprint. -/// See http://pracrand.sourceforge.net/ -pub const Sfc64 = struct { - random: Random, - - a: u64 = undefined, - b: u64 = undefined, - c: u64 = undefined, - counter: u64 = undefined, - - const Rotation = 24; - const RightShift = 11; - const LeftShift = 3; - - pub fn init(init_s: u64) Sfc64 { - var x = Sfc64{ - .random = Random{ .fillFn = fill }, - }; - - x.seed(init_s); - return x; - } - - fn next(self: *Sfc64) u64 { - const tmp = self.a +% self.b +% self.counter; - self.counter += 1; - self.a = self.b ^ (self.b >> RightShift); - self.b = self.c +% (self.c << LeftShift); - self.c = math.rotl(u64, self.c, Rotation) +% tmp; - return tmp; - } - - fn seed(self: *Sfc64, init_s: u64) void { - self.a = init_s; - self.b = init_s; - self.c = init_s; - self.counter = 1; - var i: u32 = 0; - while (i < 12) : (i += 1) { - _ = self.next(); - } - } - - fn fill(r: *Random, buf: []u8) void { - const self = @fieldParentPtr(Sfc64, "random", r); - - var i: usize = 0; - const aligned_len = buf.len - (buf.len & 7); - - // Complete 8 byte segments. - while (i < aligned_len) : (i += 8) { - var n = self.next(); - comptime var j: usize = 0; - inline while (j < 8) : (j += 1) { - buf[i + j] = @truncate(u8, n); - n >>= 8; - } - } - - // Remaining. (cuts the stream) - if (i != buf.len) { - var n = self.next(); - while (i < buf.len) : (i += 1) { - buf[i] = @truncate(u8, n); - n >>= 8; - } - } - } -}; - -test "Sfc64 sequence" { - // Unfortunately there does not seem to be an official test sequence. - var r = Sfc64.init(0); - - const seq = [_]u64{ - 0x3acfa029e3cc6041, - 0xf5b6515bf2ee419c, - 0x1259635894a29b61, - 0xb6ae75395f8ebd6, - 0x225622285ce302e2, - 0x520d28611395cb21, - 0xdb909c818901599d, - 0x8ffd195365216f57, - 0xe8c4ad5e258ac04a, - 0x8f8ef2c89fdb63ca, - 0xf9865b01d98d8e2f, - 0x46555871a65d08ba, - 0x66868677c6298fcd, - 0x2ce15a7e6329f57d, - 0xb2f1833ca91ca79, - 0x4b0890ac9bf453ca, - }; - - for (seq) |s| { - expectEqual(s, r.next()); - } -} - // Actual Random helper function tests, pcg engine is assumed correct. test "Random float" { var prng = DefaultPrng.init(0); @@ -1147,7 +594,7 @@ fn testRangeBias(r: *Random, start: i8, end: i8, biased: bool) void { test "CSPRNG" { var secret_seed: [DefaultCsprng.secret_seed_length]u8 = undefined; - try std.crypto.randomBytes(&secret_seed); + std.crypto.random.bytes(&secret_seed); var csprng = DefaultCsprng.init(secret_seed); const a = csprng.random.int(u64); const b = csprng.random.int(u64); @@ -1155,6 +602,6 @@ test "CSPRNG" { expect(a ^ b ^ c != 0); } -test "" { +test { std.testing.refAllDecls(@This()); } diff --git a/lib/std/rand/Gimli.zig b/lib/std/rand/Gimli.zig new file mode 100644 index 0000000000..8356c7afde --- /dev/null +++ b/lib/std/rand/Gimli.zig @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! CSPRNG + +const std = @import("std"); +const Random = std.rand.Random; +const mem = std.mem; +const Gimli = @This(); + +random: Random, +state: std.crypto.core.Gimli, + +pub const secret_seed_length = 32; + +/// The seed must be uniform, secret and `secret_seed_length` bytes long. +pub fn init(secret_seed: [secret_seed_length]u8) Gimli { + var initial_state: [std.crypto.core.Gimli.BLOCKBYTES]u8 = undefined; + mem.copy(u8, initial_state[0..secret_seed_length], &secret_seed); + mem.set(u8, initial_state[secret_seed_length..], 0); + var self = Gimli{ + .random = Random{ .fillFn = fill }, + .state = std.crypto.core.Gimli.init(initial_state), + }; + return self; +} + +fn fill(r: *Random, buf: []u8) void { + const self = @fieldParentPtr(Gimli, "random", r); + + if (buf.len != 0) { + self.state.squeeze(buf); + } else { + self.state.permute(); + } + mem.set(u8, self.state.toSlice()[0..std.crypto.core.Gimli.RATE], 0); +} diff --git a/lib/std/rand/Isaac64.zig b/lib/std/rand/Isaac64.zig new file mode 100644 index 0000000000..e1d4dedf5a --- /dev/null +++ b/lib/std/rand/Isaac64.zig @@ -0,0 +1,210 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! ISAAC64 - http://www.burtleburtle.net/bob/rand/isaacafa.html +//! +//! Follows the general idea of the implementation from here with a few shortcuts. +//! https://doc.rust-lang.org/rand/src/rand/prng/isaac64.rs.html + +const std = @import("std"); +const Random = std.rand.Random; +const mem = std.mem; +const Isaac64 = @This(); + +random: Random, + +r: [256]u64, +m: [256]u64, +a: u64, +b: u64, +c: u64, +i: usize, + +pub fn init(init_s: u64) Isaac64 { + var isaac = Isaac64{ + .random = Random{ .fillFn = fill }, + .r = undefined, + .m = undefined, + .a = undefined, + .b = undefined, + .c = undefined, + .i = undefined, + }; + + // seed == 0 => same result as the unseeded reference implementation + isaac.seed(init_s, 1); + return isaac; +} + +fn step(self: *Isaac64, mix: u64, base: usize, comptime m1: usize, comptime m2: usize) void { + const x = self.m[base + m1]; + self.a = mix +% self.m[base + m2]; + + const y = self.a +% self.b +% self.m[@intCast(usize, (x >> 3) % self.m.len)]; + self.m[base + m1] = y; + + self.b = x +% self.m[@intCast(usize, (y >> 11) % self.m.len)]; + self.r[self.r.len - 1 - base - m1] = self.b; +} + +fn refill(self: *Isaac64) void { + const midpoint = self.r.len / 2; + + self.c +%= 1; + self.b +%= self.c; + + { + var i: usize = 0; + while (i < midpoint) : (i += 4) { + self.step(~(self.a ^ (self.a << 21)), i + 0, 0, midpoint); + self.step(self.a ^ (self.a >> 5), i + 1, 0, midpoint); + self.step(self.a ^ (self.a << 12), i + 2, 0, midpoint); + self.step(self.a ^ (self.a >> 33), i + 3, 0, midpoint); + } + } + + { + var i: usize = 0; + while (i < midpoint) : (i += 4) { + self.step(~(self.a ^ (self.a << 21)), i + 0, midpoint, 0); + self.step(self.a ^ (self.a >> 5), i + 1, midpoint, 0); + self.step(self.a ^ (self.a << 12), i + 2, midpoint, 0); + self.step(self.a ^ (self.a >> 33), i + 3, midpoint, 0); + } + } + + self.i = 0; +} + +fn next(self: *Isaac64) u64 { + if (self.i >= self.r.len) { + self.refill(); + } + + const value = self.r[self.i]; + self.i += 1; + return value; +} + +fn seed(self: *Isaac64, init_s: u64, comptime rounds: usize) void { + // We ignore the multi-pass requirement since we don't currently expose full access to + // seeding the self.m array completely. + mem.set(u64, self.m[0..], 0); + self.m[0] = init_s; + + // prescrambled golden ratio constants + var a = [_]u64{ + 0x647c4677a2884b7c, + 0xb9f8b322c73ac862, + 0x8c0ea5053d4712a0, + 0xb29b2e824a595524, + 0x82f053db8355e0ce, + 0x48fe4a0fa5a09315, + 0xae985bf2cbfc89ed, + 0x98f5704f6c44c0ab, + }; + + comptime var i: usize = 0; + inline while (i < rounds) : (i += 1) { + var j: usize = 0; + while (j < self.m.len) : (j += 8) { + comptime var x1: usize = 0; + inline while (x1 < 8) : (x1 += 1) { + a[x1] +%= self.m[j + x1]; + } + + a[0] -%= a[4]; + a[5] ^= a[7] >> 9; + a[7] +%= a[0]; + a[1] -%= a[5]; + a[6] ^= a[0] << 9; + a[0] +%= a[1]; + a[2] -%= a[6]; + a[7] ^= a[1] >> 23; + a[1] +%= a[2]; + a[3] -%= a[7]; + a[0] ^= a[2] << 15; + a[2] +%= a[3]; + a[4] -%= a[0]; + a[1] ^= a[3] >> 14; + a[3] +%= a[4]; + a[5] -%= a[1]; + a[2] ^= a[4] << 20; + a[4] +%= a[5]; + a[6] -%= a[2]; + a[3] ^= a[5] >> 17; + a[5] +%= a[6]; + a[7] -%= a[3]; + a[4] ^= a[6] << 14; + a[6] +%= a[7]; + + comptime var x2: usize = 0; + inline while (x2 < 8) : (x2 += 1) { + self.m[j + x2] = a[x2]; + } + } + } + + mem.set(u64, self.r[0..], 0); + self.a = 0; + self.b = 0; + self.c = 0; + self.i = self.r.len; // trigger refill on first value +} + +fn fill(r: *Random, buf: []u8) void { + const self = @fieldParentPtr(Isaac64, "random", r); + + var i: usize = 0; + const aligned_len = buf.len - (buf.len & 7); + + // Fill complete 64-byte segments + while (i < aligned_len) : (i += 8) { + var n = self.next(); + comptime var j: usize = 0; + inline while (j < 8) : (j += 1) { + buf[i + j] = @truncate(u8, n); + n >>= 8; + } + } + + // Fill trailing, ignoring excess (cut the stream). + if (i != buf.len) { + var n = self.next(); + while (i < buf.len) : (i += 1) { + buf[i] = @truncate(u8, n); + n >>= 8; + } + } +} + +test "isaac64 sequence" { + var r = Isaac64.init(0); + + // from reference implementation + const seq = [_]u64{ + 0xf67dfba498e4937c, + 0x84a5066a9204f380, + 0xfee34bd5f5514dbb, + 0x4d1664739b8f80d6, + 0x8607459ab52a14aa, + 0x0e78bc5a98529e49, + 0xfe5332822ad13777, + 0x556c27525e33d01a, + 0x08643ca615f3149f, + 0xd0771faf3cb04714, + 0x30e86f68a37b008d, + 0x3074ebc0488a3adf, + 0x270645ea7a2790bc, + 0x5601a0a8d3763c6a, + 0x2f83071f53f325dd, + 0xb9090f3d42d2d2ea, + }; + + for (seq) |s| { + std.testing.expect(s == r.next()); + } +} diff --git a/lib/std/rand/Pcg.zig b/lib/std/rand/Pcg.zig new file mode 100644 index 0000000000..6be17b3bb8 --- /dev/null +++ b/lib/std/rand/Pcg.zig @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! PCG32 - http://www.pcg-random.org/ +//! +//! PRNG + +const std = @import("std"); +const Random = std.rand.Random; +const Pcg = @This(); + +const default_multiplier = 6364136223846793005; + +random: Random, + +s: u64, +i: u64, + +pub fn init(init_s: u64) Pcg { + var pcg = Pcg{ + .random = Random{ .fillFn = fill }, + .s = undefined, + .i = undefined, + }; + + pcg.seed(init_s); + return pcg; +} + +fn next(self: *Pcg) u32 { + const l = self.s; + self.s = l *% default_multiplier +% (self.i | 1); + + const xor_s = @truncate(u32, ((l >> 18) ^ l) >> 27); + const rot = @intCast(u32, l >> 59); + + return (xor_s >> @intCast(u5, rot)) | (xor_s << @intCast(u5, (0 -% rot) & 31)); +} + +fn seed(self: *Pcg, init_s: u64) void { + // Pcg requires 128-bits of seed. + var gen = std.rand.SplitMix64.init(init_s); + self.seedTwo(gen.next(), gen.next()); +} + +fn seedTwo(self: *Pcg, init_s: u64, init_i: u64) void { + self.s = 0; + self.i = (init_s << 1) | 1; + self.s = self.s *% default_multiplier +% self.i; + self.s +%= init_i; + self.s = self.s *% default_multiplier +% self.i; +} + +fn fill(r: *Random, buf: []u8) void { + const self = @fieldParentPtr(Pcg, "random", r); + + var i: usize = 0; + const aligned_len = buf.len - (buf.len & 7); + + // Complete 4 byte segments. + while (i < aligned_len) : (i += 4) { + var n = self.next(); + comptime var j: usize = 0; + inline while (j < 4) : (j += 1) { + buf[i + j] = @truncate(u8, n); + n >>= 8; + } + } + + // Remaining. (cuts the stream) + if (i != buf.len) { + var n = self.next(); + while (i < buf.len) : (i += 1) { + buf[i] = @truncate(u8, n); + n >>= 4; + } + } +} + +test "pcg sequence" { + var r = Pcg.init(0); + const s0: u64 = 0x9394bf54ce5d79de; + const s1: u64 = 0x84e9c579ef59bbf7; + r.seedTwo(s0, s1); + + const seq = [_]u32{ + 2881561918, + 3063928540, + 1199791034, + 2487695858, + 1479648952, + 3247963454, + }; + + for (seq) |s| { + std.testing.expect(s == r.next()); + } +} diff --git a/lib/std/rand/Sfc64.zig b/lib/std/rand/Sfc64.zig new file mode 100644 index 0000000000..3b5f1eda82 --- /dev/null +++ b/lib/std/rand/Sfc64.zig @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! Sfc64 pseudo-random number generator from Practically Random. +//! Fastest engine of pracrand and smallest footprint. +//! See http://pracrand.sourceforge.net/ + +const std = @import("std"); +const Random = std.rand.Random; +const math = std.math; +const Sfc64 = @This(); + +random: Random, + +a: u64 = undefined, +b: u64 = undefined, +c: u64 = undefined, +counter: u64 = undefined, + +const Rotation = 24; +const RightShift = 11; +const LeftShift = 3; + +pub fn init(init_s: u64) Sfc64 { + var x = Sfc64{ + .random = Random{ .fillFn = fill }, + }; + + x.seed(init_s); + return x; +} + +fn next(self: *Sfc64) u64 { + const tmp = self.a +% self.b +% self.counter; + self.counter += 1; + self.a = self.b ^ (self.b >> RightShift); + self.b = self.c +% (self.c << LeftShift); + self.c = math.rotl(u64, self.c, Rotation) +% tmp; + return tmp; +} + +fn seed(self: *Sfc64, init_s: u64) void { + self.a = init_s; + self.b = init_s; + self.c = init_s; + self.counter = 1; + var i: u32 = 0; + while (i < 12) : (i += 1) { + _ = self.next(); + } +} + +fn fill(r: *Random, buf: []u8) void { + const self = @fieldParentPtr(Sfc64, "random", r); + + var i: usize = 0; + const aligned_len = buf.len - (buf.len & 7); + + // Complete 8 byte segments. + while (i < aligned_len) : (i += 8) { + var n = self.next(); + comptime var j: usize = 0; + inline while (j < 8) : (j += 1) { + buf[i + j] = @truncate(u8, n); + n >>= 8; + } + } + + // Remaining. (cuts the stream) + if (i != buf.len) { + var n = self.next(); + while (i < buf.len) : (i += 1) { + buf[i] = @truncate(u8, n); + n >>= 8; + } + } +} + +test "Sfc64 sequence" { + // Unfortunately there does not seem to be an official test sequence. + var r = Sfc64.init(0); + + const seq = [_]u64{ + 0x3acfa029e3cc6041, + 0xf5b6515bf2ee419c, + 0x1259635894a29b61, + 0xb6ae75395f8ebd6, + 0x225622285ce302e2, + 0x520d28611395cb21, + 0xdb909c818901599d, + 0x8ffd195365216f57, + 0xe8c4ad5e258ac04a, + 0x8f8ef2c89fdb63ca, + 0xf9865b01d98d8e2f, + 0x46555871a65d08ba, + 0x66868677c6298fcd, + 0x2ce15a7e6329f57d, + 0xb2f1833ca91ca79, + 0x4b0890ac9bf453ca, + }; + + for (seq) |s| { + std.testing.expectEqual(s, r.next()); + } +} diff --git a/lib/std/rand/Xoroshiro128.zig b/lib/std/rand/Xoroshiro128.zig new file mode 100644 index 0000000000..816bb9f58c --- /dev/null +++ b/lib/std/rand/Xoroshiro128.zig @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. + +//! Xoroshiro128+ - http://xoroshiro.di.unimi.it/ +//! +//! PRNG + +const std = @import("std"); +const Random = std.rand.Random; +const math = std.math; +const Xoroshiro128 = @This(); + +random: Random, + +s: [2]u64, + +pub fn init(init_s: u64) Xoroshiro128 { + var x = Xoroshiro128{ + .random = Random{ .fillFn = fill }, + .s = undefined, + }; + + x.seed(init_s); + return x; +} + +fn next(self: *Xoroshiro128) u64 { + const s0 = self.s[0]; + var s1 = self.s[1]; + const r = s0 +% s1; + + s1 ^= s0; + self.s[0] = math.rotl(u64, s0, @as(u8, 55)) ^ s1 ^ (s1 << 14); + self.s[1] = math.rotl(u64, s1, @as(u8, 36)); + + return r; +} + +// Skip 2^64 places ahead in the sequence +fn jump(self: *Xoroshiro128) void { + var s0: u64 = 0; + var s1: u64 = 0; + + const table = [_]u64{ + 0xbeac0467eba5facb, + 0xd86b048b86aa9922, + }; + + inline for (table) |entry| { + var b: usize = 0; + while (b < 64) : (b += 1) { + if ((entry & (@as(u64, 1) << @intCast(u6, b))) != 0) { + s0 ^= self.s[0]; + s1 ^= self.s[1]; + } + _ = self.next(); + } + } + + self.s[0] = s0; + self.s[1] = s1; +} + +pub fn seed(self: *Xoroshiro128, init_s: u64) void { + // Xoroshiro requires 128-bits of seed. + var gen = std.rand.SplitMix64.init(init_s); + + self.s[0] = gen.next(); + self.s[1] = gen.next(); +} + +fn fill(r: *Random, buf: []u8) void { + const self = @fieldParentPtr(Xoroshiro128, "random", r); + + var i: usize = 0; + const aligned_len = buf.len - (buf.len & 7); + + // Complete 8 byte segments. + while (i < aligned_len) : (i += 8) { + var n = self.next(); + comptime var j: usize = 0; + inline while (j < 8) : (j += 1) { + buf[i + j] = @truncate(u8, n); + n >>= 8; + } + } + + // Remaining. (cuts the stream) + if (i != buf.len) { + var n = self.next(); + while (i < buf.len) : (i += 1) { + buf[i] = @truncate(u8, n); + n >>= 8; + } + } +} + +test "xoroshiro sequence" { + var r = Xoroshiro128.init(0); + r.s[0] = 0xaeecf86f7878dd75; + r.s[1] = 0x01cd153642e72622; + + const seq1 = [_]u64{ + 0xb0ba0da5bb600397, + 0x18a08afde614dccc, + 0xa2635b956a31b929, + 0xabe633c971efa045, + 0x9ac19f9706ca3cac, + 0xf62b426578c1e3fb, + }; + + for (seq1) |s| { + std.testing.expect(s == r.next()); + } + + r.jump(); + + const seq2 = [_]u64{ + 0x95344a13556d3e22, + 0xb4fb32dafa4d00df, + 0xb2011d9ccdcfe2dd, + 0x05679a9b2119b908, + 0xa860a1da7c9cd8a0, + 0x658a96efe3f86550, + }; + + for (seq2) |s| { + std.testing.expect(s == r.next()); + } +} diff --git a/lib/std/rand/ziggurat.zig b/lib/std/rand/ziggurat.zig index da189637bf..fe120943d7 100644 --- a/lib/std/rand/ziggurat.zig +++ b/lib/std/rand/ziggurat.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -131,7 +131,11 @@ fn norm_zero_case(random: *Random, u: f64) f64 { } } -test "ziggurant normal dist sanity" { +const please_windows_dont_oom = std.Target.current.os.tag == .windows; + +test "normal dist sanity" { + if (please_windows_dont_oom) return error.SkipZigTest; + var prng = std.rand.DefaultPrng.init(0); var i: usize = 0; while (i < 1000) : (i += 1) { @@ -158,7 +162,9 @@ fn exp_zero_case(random: *Random, _: f64) f64 { return exp_r - math.ln(random.float(f64)); } -test "ziggurant exp dist sanity" { +test "exp dist sanity" { + if (please_windows_dont_oom) return error.SkipZigTest; + var prng = std.rand.DefaultPrng.init(0); var i: usize = 0; while (i < 1000) : (i += 1) { @@ -166,6 +172,8 @@ test "ziggurant exp dist sanity" { } } -test "ziggurat table gen" { +test "table gen" { + if (please_windows_dont_oom) return error.SkipZigTest; + const table = NormDist; } diff --git a/lib/std/sort.zig b/lib/std/sort.zig index e2e4cc662d..b30fb6ae57 100644 --- a/lib/std/sort.zig +++ b/lib/std/sort.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -1129,7 +1129,7 @@ fn swap( } } -/// Use to generate a comparator function for a given type. e.g. `sort(u8, slice, asc(u8))`. +/// Use to generate a comparator function for a given type. e.g. `sort(u8, slice, {}, comptime asc(u8))`. pub fn asc(comptime T: type) fn (void, T, T) bool { const impl = struct { fn inner(context: void, a: T, b: T) bool { @@ -1140,7 +1140,7 @@ pub fn asc(comptime T: type) fn (void, T, T) bool { return impl.inner; } -/// Use to generate a comparator function for a given type. e.g. `sort(u8, slice, asc(u8))`. +/// Use to generate a comparator function for a given type. e.g. `sort(u8, slice, {}, comptime desc(u8))`. pub fn desc(comptime T: type) fn (void, T, T) bool { const impl = struct { fn inner(context: void, a: T, b: T) bool { diff --git a/lib/std/special/build_runner.zig b/lib/std/special/build_runner.zig index 7d9ac17499..0b7baf0fc1 100644 --- a/lib/std/special/build_runner.zig +++ b/lib/std/special/build_runner.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -57,8 +57,8 @@ pub fn main() !void { var targets = ArrayList([]const u8).init(allocator); - const stderr_stream = io.getStdErr().outStream(); - const stdout_stream = io.getStdOut().outStream(); + const stderr_stream = io.getStdErr().writer(); + const stdout_stream = io.getStdOut().writer(); while (nextArg(args, &arg_idx)) |arg| { if (mem.startsWith(u8, arg, "-D")) { @@ -98,7 +98,7 @@ pub fn main() !void { return usageAndErr(builder, false, stderr_stream); }; builder.color = std.meta.stringToEnum(@TypeOf(builder.color), next_arg) orelse { - warn("expected [auto|on|off] after --color, found '{}'", .{next_arg}); + warn("expected [auto|on|off] after --color, found '{s}'", .{next_arg}); return usageAndErr(builder, false, stderr_stream); }; } else if (mem.eql(u8, arg, "--override-lib-dir")) { @@ -126,7 +126,7 @@ pub fn main() !void { builder.args = argsRest(args, arg_idx); break; } else { - warn("Unrecognized argument: {}\n\n", .{arg}); + warn("Unrecognized argument: {s}\n\n", .{arg}); return usageAndErr(builder, false, stderr_stream); } } else { @@ -168,7 +168,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void } try out_stream.print( - \\Usage: {} build [steps] [options] + \\Usage: {s} build [steps] [options] \\ \\Steps: \\ @@ -177,10 +177,10 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void const allocator = builder.allocator; for (builder.top_level_steps.items) |top_level_step| { const name = if (&top_level_step.step == builder.default_step) - try fmt.allocPrint(allocator, "{} (default)", .{top_level_step.step.name}) + try fmt.allocPrint(allocator, "{s} (default)", .{top_level_step.step.name}) else top_level_step.step.name; - try out_stream.print(" {s:<27} {}\n", .{ name, top_level_step.description }); + try out_stream.print(" {s:<27} {s}\n", .{ name, top_level_step.description }); } try out_stream.writeAll( @@ -200,12 +200,12 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void try out_stream.print(" (none)\n", .{}); } else { for (builder.available_options_list.items) |option| { - const name = try fmt.allocPrint(allocator, " -D{}=[{}]", .{ + const name = try fmt.allocPrint(allocator, " -D{s}=[{s}]", .{ option.name, Builder.typeIdName(option.type_id), }); defer allocator.free(name); - try out_stream.print("{s:<29} {}\n", .{ name, option.description }); + try out_stream.print("{s:<29} {s}\n", .{ name, option.description }); } } diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index 449b70d6b0..51cbafc133 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -172,7 +172,7 @@ test "strncmp" { pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { if (builtin.is_test) { @setCold(true); - std.debug.panic("{}", .{msg}); + std.debug.panic("{s}", .{msg}); } if (builtin.os.tag != .freestanding and builtin.os.tag != .other) { std.os.abort(); @@ -634,6 +634,16 @@ export fn cosf(a: f32) f32 { return math.cos(a); } +export fn sincos(a: f64, r_sin: *f64, r_cos: *f64) void { + r_sin.* = math.sin(a); + r_cos.* = math.cos(a); +} + +export fn sincosf(a: f32, r_sin: *f32, r_cos: *f32) void { + r_sin.* = math.sin(a); + r_cos.* = math.cos(a); +} + export fn exp(a: f64) f64 { return math.exp(a); } diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index 98d292cce9..4f12d21957 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -167,6 +167,10 @@ comptime { @export(@import("compiler_rt/clzsi2.zig").__clzsi2, .{ .name = "__clzsi2", .linkage = linkage }); + if (builtin.link_libc and builtin.os.tag == .openbsd) { + @export(@import("compiler_rt/emutls.zig").__emutls_get_address, .{ .name = "__emutls_get_address", .linkage = linkage }); + } + if ((builtin.arch.isARM() or builtin.arch.isThumb()) and !is_test) { @export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = linkage }); @export(@import("compiler_rt/arm.zig").__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = linkage }); @@ -273,6 +277,25 @@ comptime { @export(@import("compiler_rt/aullrem.zig")._aullrem, .{ .name = "\x01__aullrem", .linkage = strong_linkage }); } + if (builtin.arch.isSPARC()) { + // SPARC systems use a different naming scheme + @export(@import("compiler_rt/sparc.zig")._Qp_add, .{ .name = "_Qp_add", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_div, .{ .name = "_Qp_div", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_mul, .{ .name = "_Qp_mul", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_sub, .{ .name = "_Qp_sub", .linkage = linkage }); + + @export(@import("compiler_rt/sparc.zig")._Qp_cmp, .{ .name = "_Qp_cmp", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_feq, .{ .name = "_Qp_feq", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_fne, .{ .name = "_Qp_fne", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_flt, .{ .name = "_Qp_flt", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_fle, .{ .name = "_Qp_fle", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_fgt, .{ .name = "_Qp_fgt", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_fge, .{ .name = "_Qp_fge", .linkage = linkage }); + + @export(@import("compiler_rt/sparc.zig")._Qp_dtoq, .{ .name = "_Qp_dtoq", .linkage = linkage }); + @export(@import("compiler_rt/sparc.zig")._Qp_qtod, .{ .name = "_Qp_qtod", .linkage = linkage }); + } + if (builtin.os.tag == .windows) { // Default stack-probe functions emitted by LLVM if (is_mingw) { @@ -324,7 +347,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig"); pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn { @setCold(true); if (is_test) { - std.debug.panic("{}", .{msg}); + std.debug.panic("{s}", .{msg}); } else { unreachable; } diff --git a/lib/std/special/compiler_rt/addXf3.zig b/lib/std/special/compiler_rt/addXf3.zig index 27dbd440c2..5a2f3c976c 100644 --- a/lib/std/special/compiler_rt/addXf3.zig +++ b/lib/std/special/compiler_rt/addXf3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/addXf3_test.zig b/lib/std/special/compiler_rt/addXf3_test.zig index 3d75309507..a8f454384c 100644 --- a/lib/std/special/compiler_rt/addXf3_test.zig +++ b/lib/std/special/compiler_rt/addXf3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/arm.zig b/lib/std/special/compiler_rt/arm.zig index 1eecd3ceac..f100f8293c 100644 --- a/lib/std/special/compiler_rt/arm.zig +++ b/lib/std/special/compiler_rt/arm.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -66,10 +66,7 @@ pub fn __aeabi_uidivmod() callconv(.Naked) void { \\ ldr r1, [sp] \\ add sp, #4 \\ pop {pc} - : - : - : "memory" - ); + ::: "memory"); unreachable; } @@ -86,10 +83,7 @@ pub fn __aeabi_uldivmod() callconv(.Naked) void { \\ ldr r3, [sp, #12] \\ add sp, #16 \\ pop {r4, pc} - : - : - : "memory" - ); + ::: "memory"); unreachable; } @@ -104,10 +98,7 @@ pub fn __aeabi_idivmod() callconv(.Naked) void { \\ ldr r1, [sp] \\ add sp, #4 \\ pop {pc} - : - : - : "memory" - ); + ::: "memory"); unreachable; } @@ -124,9 +115,6 @@ pub fn __aeabi_ldivmod() callconv(.Naked) void { \\ ldr r3, [sp, #12] \\ add sp, #16 \\ pop {r4, pc} - : - : - : "memory" - ); + ::: "memory"); unreachable; } diff --git a/lib/std/special/compiler_rt/ashldi3_test.zig b/lib/std/special/compiler_rt/ashldi3_test.zig index 874681a79a..dfc3712e39 100644 --- a/lib/std/special/compiler_rt/ashldi3_test.zig +++ b/lib/std/special/compiler_rt/ashldi3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/ashlti3_test.zig b/lib/std/special/compiler_rt/ashlti3_test.zig index 42cb3a47bb..453fa9e77b 100644 --- a/lib/std/special/compiler_rt/ashlti3_test.zig +++ b/lib/std/special/compiler_rt/ashlti3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/ashrdi3_test.zig b/lib/std/special/compiler_rt/ashrdi3_test.zig index e80b95af9e..77fe286185 100644 --- a/lib/std/special/compiler_rt/ashrdi3_test.zig +++ b/lib/std/special/compiler_rt/ashrdi3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/ashrti3_test.zig b/lib/std/special/compiler_rt/ashrti3_test.zig index 958b8a8a74..5f4e166001 100644 --- a/lib/std/special/compiler_rt/ashrti3_test.zig +++ b/lib/std/special/compiler_rt/ashrti3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/atomics.zig b/lib/std/special/compiler_rt/atomics.zig index cf9854c3c6..cda87236a9 100644 --- a/lib/std/special/compiler_rt/atomics.zig +++ b/lib/std/special/compiler_rt/atomics.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/aulldiv.zig b/lib/std/special/compiler_rt/aulldiv.zig index 321ff288bb..196c218e24 100644 --- a/lib/std/special/compiler_rt/aulldiv.zig +++ b/lib/std/special/compiler_rt/aulldiv.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/aullrem.zig b/lib/std/special/compiler_rt/aullrem.zig index a14eb99be3..7d0eef5921 100644 --- a/lib/std/special/compiler_rt/aullrem.zig +++ b/lib/std/special/compiler_rt/aullrem.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/clear_cache.zig b/lib/std/special/compiler_rt/clear_cache.zig index 4b00721868..568373aabe 100644 --- a/lib/std/special/compiler_rt/clear_cache.zig +++ b/lib/std/special/compiler_rt/clear_cache.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/clzsi2.zig b/lib/std/special/compiler_rt/clzsi2.zig index e4739d47c4..c10786b462 100644 --- a/lib/std/special/compiler_rt/clzsi2.zig +++ b/lib/std/special/compiler_rt/clzsi2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/clzsi2_test.zig b/lib/std/special/compiler_rt/clzsi2_test.zig index 2d9ba3d1b3..2b860afd22 100644 --- a/lib/std/special/compiler_rt/clzsi2_test.zig +++ b/lib/std/special/compiler_rt/clzsi2_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/compareXf2.zig b/lib/std/special/compiler_rt/compareXf2.zig index eba6abb003..c903321669 100644 --- a/lib/std/special/compiler_rt/compareXf2.zig +++ b/lib/std/special/compiler_rt/compareXf2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/comparedf2_test.zig b/lib/std/special/compiler_rt/comparedf2_test.zig index 9d681b8f81..f5e8cfe372 100644 --- a/lib/std/special/compiler_rt/comparedf2_test.zig +++ b/lib/std/special/compiler_rt/comparedf2_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/comparesf2_test.zig b/lib/std/special/compiler_rt/comparesf2_test.zig index da7fe940a0..0a1f5e74f6 100644 --- a/lib/std/special/compiler_rt/comparesf2_test.zig +++ b/lib/std/special/compiler_rt/comparesf2_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/divdf3.zig b/lib/std/special/compiler_rt/divdf3.zig index 31d6ff0993..10a548090a 100644 --- a/lib/std/special/compiler_rt/divdf3.zig +++ b/lib/std/special/compiler_rt/divdf3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/divdf3_test.zig b/lib/std/special/compiler_rt/divdf3_test.zig index 04cac956d2..8bdecc7c6a 100644 --- a/lib/std/special/compiler_rt/divdf3_test.zig +++ b/lib/std/special/compiler_rt/divdf3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/divsf3.zig b/lib/std/special/compiler_rt/divsf3.zig index 779506d85e..3f89f12313 100644 --- a/lib/std/special/compiler_rt/divsf3.zig +++ b/lib/std/special/compiler_rt/divsf3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/divsf3_test.zig b/lib/std/special/compiler_rt/divsf3_test.zig index 30dcba462b..a14e8e9163 100644 --- a/lib/std/special/compiler_rt/divsf3_test.zig +++ b/lib/std/special/compiler_rt/divsf3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/divtf3.zig b/lib/std/special/compiler_rt/divtf3.zig index 152ffa9926..9c18e79dd5 100644 --- a/lib/std/special/compiler_rt/divtf3.zig +++ b/lib/std/special/compiler_rt/divtf3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/divtf3_test.zig b/lib/std/special/compiler_rt/divtf3_test.zig index cf6f2f2eaf..98910e9994 100644 --- a/lib/std/special/compiler_rt/divtf3_test.zig +++ b/lib/std/special/compiler_rt/divtf3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/divti3.zig b/lib/std/special/compiler_rt/divti3.zig index a065111510..03bae3f3f8 100644 --- a/lib/std/special/compiler_rt/divti3.zig +++ b/lib/std/special/compiler_rt/divti3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/divti3_test.zig b/lib/std/special/compiler_rt/divti3_test.zig index 18fab24ed1..a20be340c6 100644 --- a/lib/std/special/compiler_rt/divti3_test.zig +++ b/lib/std/special/compiler_rt/divti3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/emutls.zig b/lib/std/special/compiler_rt/emutls.zig new file mode 100644 index 0000000000..2b0fba5b34 --- /dev/null +++ b/lib/std/special/compiler_rt/emutls.zig @@ -0,0 +1,395 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2018 LLVM Compiler Infrastructure +// Copyright (c) 2020 Sebastien Marie +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. +// __emutls_get_address specific builtin +// +// derived work from LLVM Compiler Infrastructure - release 8.0 (MIT) +// https://github.com/llvm-mirror/compiler-rt/blob/release_80/lib/builtins/emutls.c +// + +const std = @import("std"); + +const abort = std.os.abort; +const assert = std.debug.assert; +const expect = std.testing.expect; + +// defined in C as: +// typedef unsigned int gcc_word __attribute__((mode(word))); +const gcc_word = usize; + +comptime { + assert(std.builtin.link_libc); +} + +/// public entrypoint for generated code using EmulatedTLS +pub fn __emutls_get_address(control: *emutls_control) callconv(.C) *c_void { + return control.getPointer(); +} + +/// Simple allocator interface, to avoid pulling in the while +/// std allocator implementation. +const simple_allocator = struct { + /// Allocate a memory chunk for requested type. Return a pointer on the data. + pub fn alloc(comptime T: type) *T { + return @ptrCast(*T, @alignCast( + @alignOf(T), + advancedAlloc(@alignOf(T), @sizeOf(T)), + )); + } + + /// Allocate a slice of T, with len elements. + pub fn allocSlice(comptime T: type, len: usize) []T { + return @ptrCast([*]T, @alignCast( + @alignOf(T), + advancedAlloc(@alignOf(T), @sizeOf(T) * len), + ))[0 .. len - 1]; + } + + /// Allocate a memory chunk. + pub fn advancedAlloc(alignment: u29, size: usize) [*]u8 { + const minimal_alignment = std.math.max(@alignOf(usize), alignment); + + var aligned_ptr: ?*c_void = undefined; + if (std.c.posix_memalign(&aligned_ptr, minimal_alignment, size) != 0) { + abort(); + } + + return @ptrCast([*]u8, aligned_ptr); + } + + /// Resize a slice. + pub fn reallocSlice(comptime T: type, slice: []T, len: usize) []T { + var c_ptr: *c_void = @ptrCast(*c_void, slice.ptr); + var new_array: [*]T = @ptrCast([*]T, @alignCast( + @alignOf(T), + std.c.realloc(c_ptr, @sizeOf(T) * len) orelse abort(), + )); + return new_array[0..len]; + } + + /// Free a memory chunk allocated with simple_allocator. + pub fn free(ptr: anytype) void { + std.c.free(@ptrCast(*c_void, ptr)); + } +}; + +/// Simple array of ?ObjectPointer with automatic resizing and +/// automatic storage allocation. +const ObjectArray = struct { + const ObjectPointer = *c_void; + + // content of the array + slots: []?ObjectPointer, + + /// create a new ObjectArray with n slots. must call deinit() to deallocate. + pub fn init(n: usize) *ObjectArray { + var array = simple_allocator.alloc(ObjectArray); + errdefer simple_allocator.free(array); + + array.* = ObjectArray{ + .slots = simple_allocator.allocSlice(?ObjectPointer, n), + }; + errdefer simple_allocator.free(array.slots); + + for (array.slots) |*object| { + object.* = null; + } + + return array; + } + + /// deallocate the ObjectArray. + pub fn deinit(self: *ObjectArray) void { + // deallocated used objects in the array + for (self.slots) |*object| { + simple_allocator.free(object.*); + } + simple_allocator.free(self.slots); + simple_allocator.free(self); + } + + /// resize the ObjectArray if needed. + pub fn ensureLength(self: *ObjectArray, new_len: usize) *ObjectArray { + const old_len = self.slots.len; + + if (old_len > new_len) { + return self; + } + + // reallocate + self.slots = simple_allocator.reallocSlice(?ObjectPointer, self.slots, new_len); + + // init newly added slots + for (self.slots[old_len..]) |*object| { + object.* = null; + } + + return self; + } + + /// Retrieve the pointer at request index, using control to initialize it if needed. + pub fn getPointer(self: *ObjectArray, index: usize, control: *emutls_control) ObjectPointer { + if (self.slots[index] == null) { + // initialize the slot + const size = control.size; + const alignment = @truncate(u29, control.alignment); + + var data = simple_allocator.advancedAlloc(alignment, size); + errdefer simple_allocator.free(data); + + if (control.default_value) |value| { + // default value: copy the content to newly allocated object. + @memcpy(data, @ptrCast([*]u8, value), size); + } else { + // no default: return zeroed memory. + @memset(data, 0, size); + } + + self.slots[index] = @ptrCast(*c_void, data); + } + + return self.slots[index].?; + } +}; + +// Global stucture for Thread Storage. +// It provides thread-safety for on-demand storage of Thread Objects. +const current_thread_storage = struct { + var key: std.c.pthread_key_t = undefined; + var init_once = std.once(current_thread_storage.init); + + /// Return a per thread ObjectArray with at least the expected index. + pub fn getArray(index: usize) *ObjectArray { + if (current_thread_storage.getspecific()) |array| { + // we already have a specific. just ensure the array is + // big enough for the wanted index. + return array.ensureLength(index); + } + + // no specific. we need to create a new array. + + // make it to contains at least 16 objects (to avoid too much + // reallocation at startup). + const size = std.math.max(16, index); + + // create a new array and store it. + var array: *ObjectArray = ObjectArray.init(size); + current_thread_storage.setspecific(array); + return array; + } + + /// Return casted thread specific value. + fn getspecific() ?*ObjectArray { + return @ptrCast( + ?*ObjectArray, + @alignCast( + @alignOf(ObjectArray), + std.c.pthread_getspecific(current_thread_storage.key), + ), + ); + } + + /// Set casted thread specific value. + fn setspecific(new: ?*ObjectArray) void { + if (std.c.pthread_setspecific(current_thread_storage.key, @ptrCast(*c_void, new)) != 0) { + abort(); + } + } + + /// Initialize pthread_key_t. + fn init() void { + if (std.c.pthread_key_create(¤t_thread_storage.key, current_thread_storage.deinit) != 0) { + abort(); + } + } + + /// Invoked by pthread specific destructor. the passed argument is the ObjectArray pointer. + fn deinit(arrayPtr: *c_void) callconv(.C) void { + var array = @ptrCast( + *ObjectArray, + @alignCast(@alignOf(ObjectArray), arrayPtr), + ); + array.deinit(); + } +}; + +const emutls_control = extern struct { + // A emutls_control value is a global value across all + // threads. The threads shares the index of TLS variable. The data + // array (containing address of allocated variables) is thread + // specific and stored using pthread_setspecific(). + + // size of the object in bytes + size: gcc_word, + + // alignment of the object in bytes + alignment: gcc_word, + + object: extern union { + // data[index-1] is the object address / 0 = uninit + index: usize, + + // object address, when in single thread env (not used) + address: *c_void, + }, + + // null or non-zero initial value for the object + default_value: ?*c_void, + + // global Mutex used to serialize control.index initialization. + var mutex: std.c.pthread_mutex_t = std.c.PTHREAD_MUTEX_INITIALIZER; + + // global counter for keeping track of requested indexes. + // access should be done with mutex held. + var next_index: usize = 1; + + /// Simple wrapper for global lock. + fn lock() void { + if (std.c.pthread_mutex_lock(&emutls_control.mutex) != 0) { + abort(); + } + } + + /// Simple wrapper for global unlock. + fn unlock() void { + if (std.c.pthread_mutex_unlock(&emutls_control.mutex) != 0) { + abort(); + } + } + + /// Helper to retrieve nad initialize global unique index per emutls variable. + pub fn getIndex(self: *emutls_control) usize { + // Two threads could race against the same emutls_control. + + // Use atomic for reading coherent value lockless. + const index_lockless = @atomicLoad(usize, &self.object.index, .Acquire); + + if (index_lockless != 0) { + // index is already initialized, return it. + return index_lockless; + } + + // index is uninitialized: take global lock to avoid possible race. + emutls_control.lock(); + defer emutls_control.unlock(); + + const index_locked = self.object.index; + if (index_locked != 0) { + // we lost a race, but index is already initialized: nothing particular to do. + return index_locked; + } + + // Store a new index atomically (for having coherent index_lockless reading). + @atomicStore(usize, &self.object.index, emutls_control.next_index, .Release); + + // Increment the next available index + emutls_control.next_index += 1; + + return self.object.index; + } + + /// Simple helper for testing purpose. + pub fn init(comptime T: type, default_value: ?*T) emutls_control { + return emutls_control{ + .size = @sizeOf(T), + .alignment = @alignOf(T), + .object = .{ .index = 0 }, + .default_value = @ptrCast(?*c_void, default_value), + }; + } + + /// Get the pointer on allocated storage for emutls variable. + pub fn getPointer(self: *emutls_control) *c_void { + // ensure current_thread_storage initialization is done + current_thread_storage.init_once.call(); + + const index = self.getIndex(); + var array = current_thread_storage.getArray(index); + + return array.getPointer(index - 1, self); + } + + /// Testing helper for retrieving typed pointer. + pub fn get_typed_pointer(self: *emutls_control, comptime T: type) *T { + assert(self.size == @sizeOf(T)); + assert(self.alignment == @alignOf(T)); + return @ptrCast( + *T, + @alignCast(@alignOf(T), self.getPointer()), + ); + } +}; + +test "simple_allocator" { + var data1: *[64]u8 = simple_allocator.alloc([64]u8); + defer simple_allocator.free(data1); + for (data1) |*c| { + c.* = 0xff; + } + + var data2: [*]u8 = simple_allocator.advancedAlloc(@alignOf(u8), 64); + defer simple_allocator.free(data2); + for (data2[0..63]) |*c| { + c.* = 0xff; + } +} + +test "__emutls_get_address zeroed" { + var ctl = emutls_control.init(usize, null); + expect(ctl.object.index == 0); + + // retrieve a variable from ctl + var x = @ptrCast(*usize, @alignCast(@alignOf(usize), __emutls_get_address(&ctl))); + expect(ctl.object.index != 0); // index has been allocated for this ctl + expect(x.* == 0); // storage has been zeroed + + // modify the storage + x.* = 1234; + + // retrieve a variable from ctl (same ctl) + var y = @ptrCast(*usize, @alignCast(@alignOf(usize), __emutls_get_address(&ctl))); + + expect(y.* == 1234); // same content that x.* + expect(x == y); // same pointer +} + +test "__emutls_get_address with default_value" { + var value: usize = 5678; // default value + var ctl = emutls_control.init(usize, &value); + expect(ctl.object.index == 0); + + var x: *usize = @ptrCast(*usize, @alignCast(@alignOf(usize), __emutls_get_address(&ctl))); + expect(ctl.object.index != 0); + expect(x.* == 5678); // storage initialized with default value + + // modify the storage + x.* = 9012; + + expect(value == 5678); // the default value didn't change + + var y = @ptrCast(*usize, @alignCast(@alignOf(usize), __emutls_get_address(&ctl))); + expect(y.* == 9012); // the modified storage persists +} + +test "test default_value with differents sizes" { + const testType = struct { + fn _testType(comptime T: type, value: T) void { + var def: T = value; + var ctl = emutls_control.init(T, &def); + var x = ctl.get_typed_pointer(T); + expect(x.* == value); + } + }._testType; + + testType(usize, 1234); + testType(u32, 1234); + testType(i16, -12); + testType(f64, -12.0); + testType( + @TypeOf("012345678901234567890123456789"), + "012345678901234567890123456789", + ); +} diff --git a/lib/std/special/compiler_rt/extendXfYf2.zig b/lib/std/special/compiler_rt/extendXfYf2.zig index 53783d2b13..c5b93fa51e 100644 --- a/lib/std/special/compiler_rt/extendXfYf2.zig +++ b/lib/std/special/compiler_rt/extendXfYf2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/extendXfYf2_test.zig b/lib/std/special/compiler_rt/extendXfYf2_test.zig index d82a8baf4c..6a3f69d8e9 100644 --- a/lib/std/special/compiler_rt/extendXfYf2_test.zig +++ b/lib/std/special/compiler_rt/extendXfYf2_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixdfdi.zig b/lib/std/special/compiler_rt/fixdfdi.zig index 28de1ecd23..f827f22a4a 100644 --- a/lib/std/special/compiler_rt/fixdfdi.zig +++ b/lib/std/special/compiler_rt/fixdfdi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixdfdi_test.zig b/lib/std/special/compiler_rt/fixdfdi_test.zig index 83835106cd..f085bdf665 100644 --- a/lib/std/special/compiler_rt/fixdfdi_test.zig +++ b/lib/std/special/compiler_rt/fixdfdi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixdfsi.zig b/lib/std/special/compiler_rt/fixdfsi.zig index 678c75d0c1..2e9fab2297 100644 --- a/lib/std/special/compiler_rt/fixdfsi.zig +++ b/lib/std/special/compiler_rt/fixdfsi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixdfsi_test.zig b/lib/std/special/compiler_rt/fixdfsi_test.zig index 8050a1b9c5..1445149546 100644 --- a/lib/std/special/compiler_rt/fixdfsi_test.zig +++ b/lib/std/special/compiler_rt/fixdfsi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixdfti.zig b/lib/std/special/compiler_rt/fixdfti.zig index 3d9266ae1f..88072de063 100644 --- a/lib/std/special/compiler_rt/fixdfti.zig +++ b/lib/std/special/compiler_rt/fixdfti.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixdfti_test.zig b/lib/std/special/compiler_rt/fixdfti_test.zig index 796855b716..3b5bac4b4e 100644 --- a/lib/std/special/compiler_rt/fixdfti_test.zig +++ b/lib/std/special/compiler_rt/fixdfti_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixint.zig b/lib/std/special/compiler_rt/fixint.zig index 889b599e62..2947154d20 100644 --- a/lib/std/special/compiler_rt/fixint.zig +++ b/lib/std/special/compiler_rt/fixint.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixint_test.zig b/lib/std/special/compiler_rt/fixint_test.zig index 49942e5382..139546c52b 100644 --- a/lib/std/special/compiler_rt/fixint_test.zig +++ b/lib/std/special/compiler_rt/fixint_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixsfdi.zig b/lib/std/special/compiler_rt/fixsfdi.zig index cc5731946d..9563af1a56 100644 --- a/lib/std/special/compiler_rt/fixsfdi.zig +++ b/lib/std/special/compiler_rt/fixsfdi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixsfdi_test.zig b/lib/std/special/compiler_rt/fixsfdi_test.zig index d93c3d4218..7c13d83da5 100644 --- a/lib/std/special/compiler_rt/fixsfdi_test.zig +++ b/lib/std/special/compiler_rt/fixsfdi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixsfsi.zig b/lib/std/special/compiler_rt/fixsfsi.zig index 62334574b0..f1a32d9f77 100644 --- a/lib/std/special/compiler_rt/fixsfsi.zig +++ b/lib/std/special/compiler_rt/fixsfsi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixsfsi_test.zig b/lib/std/special/compiler_rt/fixsfsi_test.zig index 56c28d91ab..07c080470d 100644 --- a/lib/std/special/compiler_rt/fixsfsi_test.zig +++ b/lib/std/special/compiler_rt/fixsfsi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixsfti.zig b/lib/std/special/compiler_rt/fixsfti.zig index 31dea953e8..75c0a2fe1d 100644 --- a/lib/std/special/compiler_rt/fixsfti.zig +++ b/lib/std/special/compiler_rt/fixsfti.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixsfti_test.zig b/lib/std/special/compiler_rt/fixsfti_test.zig index d0bdcc4e75..dbc30c5404 100644 --- a/lib/std/special/compiler_rt/fixsfti_test.zig +++ b/lib/std/special/compiler_rt/fixsfti_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixtfdi.zig b/lib/std/special/compiler_rt/fixtfdi.zig index edf70dbe49..a9e37b777f 100644 --- a/lib/std/special/compiler_rt/fixtfdi.zig +++ b/lib/std/special/compiler_rt/fixtfdi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixtfdi_test.zig b/lib/std/special/compiler_rt/fixtfdi_test.zig index b926f33d50..dfc08f84a3 100644 --- a/lib/std/special/compiler_rt/fixtfdi_test.zig +++ b/lib/std/special/compiler_rt/fixtfdi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixtfsi.zig b/lib/std/special/compiler_rt/fixtfsi.zig index cf614ec8b3..cd92a972c4 100644 --- a/lib/std/special/compiler_rt/fixtfsi.zig +++ b/lib/std/special/compiler_rt/fixtfsi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixtfsi_test.zig b/lib/std/special/compiler_rt/fixtfsi_test.zig index 86207f7dbc..e5605a3936 100644 --- a/lib/std/special/compiler_rt/fixtfsi_test.zig +++ b/lib/std/special/compiler_rt/fixtfsi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixtfti.zig b/lib/std/special/compiler_rt/fixtfti.zig index e796b86d50..cfae7c249b 100644 --- a/lib/std/special/compiler_rt/fixtfti.zig +++ b/lib/std/special/compiler_rt/fixtfti.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixtfti_test.zig b/lib/std/special/compiler_rt/fixtfti_test.zig index 65a64ac431..b01e3af9f9 100644 --- a/lib/std/special/compiler_rt/fixtfti_test.zig +++ b/lib/std/special/compiler_rt/fixtfti_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixuint.zig b/lib/std/special/compiler_rt/fixuint.zig index e10926177f..755e1b8bb2 100644 --- a/lib/std/special/compiler_rt/fixuint.zig +++ b/lib/std/special/compiler_rt/fixuint.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunsdfdi.zig b/lib/std/special/compiler_rt/fixunsdfdi.zig index 19f94c95a8..24a88236e0 100644 --- a/lib/std/special/compiler_rt/fixunsdfdi.zig +++ b/lib/std/special/compiler_rt/fixunsdfdi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunsdfdi_test.zig b/lib/std/special/compiler_rt/fixunsdfdi_test.zig index da6fef3376..b7bbe42fb9 100644 --- a/lib/std/special/compiler_rt/fixunsdfdi_test.zig +++ b/lib/std/special/compiler_rt/fixunsdfdi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunsdfsi.zig b/lib/std/special/compiler_rt/fixunsdfsi.zig index 2f622aff39..416ffc59af 100644 --- a/lib/std/special/compiler_rt/fixunsdfsi.zig +++ b/lib/std/special/compiler_rt/fixunsdfsi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunsdfsi_test.zig b/lib/std/special/compiler_rt/fixunsdfsi_test.zig index ddbb05c705..a083f97f0b 100644 --- a/lib/std/special/compiler_rt/fixunsdfsi_test.zig +++ b/lib/std/special/compiler_rt/fixunsdfsi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunsdfti.zig b/lib/std/special/compiler_rt/fixunsdfti.zig index f11f6b937f..02836a6f75 100644 --- a/lib/std/special/compiler_rt/fixunsdfti.zig +++ b/lib/std/special/compiler_rt/fixunsdfti.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunsdfti_test.zig b/lib/std/special/compiler_rt/fixunsdfti_test.zig index 11ba3bc425..dbfeb0fc4b 100644 --- a/lib/std/special/compiler_rt/fixunsdfti_test.zig +++ b/lib/std/special/compiler_rt/fixunsdfti_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunssfdi.zig b/lib/std/special/compiler_rt/fixunssfdi.zig index 5dd9b27d10..77077b4344 100644 --- a/lib/std/special/compiler_rt/fixunssfdi.zig +++ b/lib/std/special/compiler_rt/fixunssfdi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunssfdi_test.zig b/lib/std/special/compiler_rt/fixunssfdi_test.zig index 018c94ce7c..d5e04292cb 100644 --- a/lib/std/special/compiler_rt/fixunssfdi_test.zig +++ b/lib/std/special/compiler_rt/fixunssfdi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunssfsi.zig b/lib/std/special/compiler_rt/fixunssfsi.zig index ce983cb78a..9c63424629 100644 --- a/lib/std/special/compiler_rt/fixunssfsi.zig +++ b/lib/std/special/compiler_rt/fixunssfsi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunssfsi_test.zig b/lib/std/special/compiler_rt/fixunssfsi_test.zig index 98cac8a1e4..c30c1d6804 100644 --- a/lib/std/special/compiler_rt/fixunssfsi_test.zig +++ b/lib/std/special/compiler_rt/fixunssfsi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunssfti.zig b/lib/std/special/compiler_rt/fixunssfti.zig index bbaeafd6a8..ab5b95ec7f 100644 --- a/lib/std/special/compiler_rt/fixunssfti.zig +++ b/lib/std/special/compiler_rt/fixunssfti.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunssfti_test.zig b/lib/std/special/compiler_rt/fixunssfti_test.zig index b5c79906b7..b148f5a35a 100644 --- a/lib/std/special/compiler_rt/fixunssfti_test.zig +++ b/lib/std/special/compiler_rt/fixunssfti_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunstfdi.zig b/lib/std/special/compiler_rt/fixunstfdi.zig index 3062e5322c..2053b948e0 100644 --- a/lib/std/special/compiler_rt/fixunstfdi.zig +++ b/lib/std/special/compiler_rt/fixunstfdi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunstfdi_test.zig b/lib/std/special/compiler_rt/fixunstfdi_test.zig index 299c509cea..b0297d4a2f 100644 --- a/lib/std/special/compiler_rt/fixunstfdi_test.zig +++ b/lib/std/special/compiler_rt/fixunstfdi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunstfsi.zig b/lib/std/special/compiler_rt/fixunstfsi.zig index 6836e5df36..3c317cd7fe 100644 --- a/lib/std/special/compiler_rt/fixunstfsi.zig +++ b/lib/std/special/compiler_rt/fixunstfsi.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunstfsi_test.zig b/lib/std/special/compiler_rt/fixunstfsi_test.zig index 2e5139e5e2..f1cb9f6de7 100644 --- a/lib/std/special/compiler_rt/fixunstfsi_test.zig +++ b/lib/std/special/compiler_rt/fixunstfsi_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunstfti.zig b/lib/std/special/compiler_rt/fixunstfti.zig index da3319ee5c..b089fedd3f 100644 --- a/lib/std/special/compiler_rt/fixunstfti.zig +++ b/lib/std/special/compiler_rt/fixunstfti.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/fixunstfti_test.zig b/lib/std/special/compiler_rt/fixunstfti_test.zig index 2fbde63e63..fcbf9d3b25 100644 --- a/lib/std/special/compiler_rt/fixunstfti_test.zig +++ b/lib/std/special/compiler_rt/fixunstfti_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatXisf.zig b/lib/std/special/compiler_rt/floatXisf.zig index fcbd02239e..4ce97c98f6 100644 --- a/lib/std/special/compiler_rt/floatXisf.zig +++ b/lib/std/special/compiler_rt/floatXisf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatdidf.zig b/lib/std/special/compiler_rt/floatdidf.zig index 2a1ba4cadd..2e07c91dd5 100644 --- a/lib/std/special/compiler_rt/floatdidf.zig +++ b/lib/std/special/compiler_rt/floatdidf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatdidf_test.zig b/lib/std/special/compiler_rt/floatdidf_test.zig index a2072cc922..41b851a306 100644 --- a/lib/std/special/compiler_rt/floatdidf_test.zig +++ b/lib/std/special/compiler_rt/floatdidf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatdisf_test.zig b/lib/std/special/compiler_rt/floatdisf_test.zig index 6676871035..845dc7b1ae 100644 --- a/lib/std/special/compiler_rt/floatdisf_test.zig +++ b/lib/std/special/compiler_rt/floatdisf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatditf.zig b/lib/std/special/compiler_rt/floatditf.zig index aa945ca5dd..a06f66e71e 100644 --- a/lib/std/special/compiler_rt/floatditf.zig +++ b/lib/std/special/compiler_rt/floatditf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatditf_test.zig b/lib/std/special/compiler_rt/floatditf_test.zig index ff4f10927c..13796efd69 100644 --- a/lib/std/special/compiler_rt/floatditf_test.zig +++ b/lib/std/special/compiler_rt/floatditf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatsiXf.zig b/lib/std/special/compiler_rt/floatsiXf.zig index 5941e0ca57..50fcdd748b 100644 --- a/lib/std/special/compiler_rt/floatsiXf.zig +++ b/lib/std/special/compiler_rt/floatsiXf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floattidf.zig b/lib/std/special/compiler_rt/floattidf.zig index 73d86f7747..2fa5fee400 100644 --- a/lib/std/special/compiler_rt/floattidf.zig +++ b/lib/std/special/compiler_rt/floattidf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floattidf_test.zig b/lib/std/special/compiler_rt/floattidf_test.zig index d299ed8087..ab6311c9ff 100644 --- a/lib/std/special/compiler_rt/floattidf_test.zig +++ b/lib/std/special/compiler_rt/floattidf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floattisf_test.zig b/lib/std/special/compiler_rt/floattisf_test.zig index c92db9e150..2458e4bb76 100644 --- a/lib/std/special/compiler_rt/floattisf_test.zig +++ b/lib/std/special/compiler_rt/floattisf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floattitf.zig b/lib/std/special/compiler_rt/floattitf.zig index 87408ea445..a577b6dc10 100644 --- a/lib/std/special/compiler_rt/floattitf.zig +++ b/lib/std/special/compiler_rt/floattitf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floattitf_test.zig b/lib/std/special/compiler_rt/floattitf_test.zig index c4014a6298..3310875ecc 100644 --- a/lib/std/special/compiler_rt/floattitf_test.zig +++ b/lib/std/special/compiler_rt/floattitf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatundidf.zig b/lib/std/special/compiler_rt/floatundidf.zig index a88ca4a03d..e079dabced 100644 --- a/lib/std/special/compiler_rt/floatundidf.zig +++ b/lib/std/special/compiler_rt/floatundidf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatundidf_test.zig b/lib/std/special/compiler_rt/floatundidf_test.zig index c0651cb359..a0e18c4f5a 100644 --- a/lib/std/special/compiler_rt/floatundidf_test.zig +++ b/lib/std/special/compiler_rt/floatundidf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatundisf.zig b/lib/std/special/compiler_rt/floatundisf.zig index 67cd53b21c..ac7e576316 100644 --- a/lib/std/special/compiler_rt/floatundisf.zig +++ b/lib/std/special/compiler_rt/floatundisf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatunditf.zig b/lib/std/special/compiler_rt/floatunditf.zig index 014a479c5f..59c433b372 100644 --- a/lib/std/special/compiler_rt/floatunditf.zig +++ b/lib/std/special/compiler_rt/floatunditf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatunditf_test.zig b/lib/std/special/compiler_rt/floatunditf_test.zig index 19d1b4a2a3..e734355589 100644 --- a/lib/std/special/compiler_rt/floatunditf_test.zig +++ b/lib/std/special/compiler_rt/floatunditf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatunsidf.zig b/lib/std/special/compiler_rt/floatunsidf.zig index c9a31eff8e..1b700b001d 100644 --- a/lib/std/special/compiler_rt/floatunsidf.zig +++ b/lib/std/special/compiler_rt/floatunsidf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatunsisf.zig b/lib/std/special/compiler_rt/floatunsisf.zig index 17eae51092..1a0ef47b5c 100644 --- a/lib/std/special/compiler_rt/floatunsisf.zig +++ b/lib/std/special/compiler_rt/floatunsisf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatunsitf.zig b/lib/std/special/compiler_rt/floatunsitf.zig index f59446abac..3cdadfc07e 100644 --- a/lib/std/special/compiler_rt/floatunsitf.zig +++ b/lib/std/special/compiler_rt/floatunsitf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatunsitf_test.zig b/lib/std/special/compiler_rt/floatunsitf_test.zig index deb95ca396..7e7b8b69b9 100644 --- a/lib/std/special/compiler_rt/floatunsitf_test.zig +++ b/lib/std/special/compiler_rt/floatunsitf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatuntidf.zig b/lib/std/special/compiler_rt/floatuntidf.zig index adb804d0ec..6e1fe3b117 100644 --- a/lib/std/special/compiler_rt/floatuntidf.zig +++ b/lib/std/special/compiler_rt/floatuntidf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatuntidf_test.zig b/lib/std/special/compiler_rt/floatuntidf_test.zig index cce3893860..427c7a08f2 100644 --- a/lib/std/special/compiler_rt/floatuntidf_test.zig +++ b/lib/std/special/compiler_rt/floatuntidf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatuntisf.zig b/lib/std/special/compiler_rt/floatuntisf.zig index d0c9a76562..dd173945ba 100644 --- a/lib/std/special/compiler_rt/floatuntisf.zig +++ b/lib/std/special/compiler_rt/floatuntisf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatuntisf_test.zig b/lib/std/special/compiler_rt/floatuntisf_test.zig index 42379d8084..78d45dc5e0 100644 --- a/lib/std/special/compiler_rt/floatuntisf_test.zig +++ b/lib/std/special/compiler_rt/floatuntisf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatuntitf.zig b/lib/std/special/compiler_rt/floatuntitf.zig index c87ff50e9a..9759268b93 100644 --- a/lib/std/special/compiler_rt/floatuntitf.zig +++ b/lib/std/special/compiler_rt/floatuntitf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/floatuntitf_test.zig b/lib/std/special/compiler_rt/floatuntitf_test.zig index 62c9b631df..fd57be51e6 100644 --- a/lib/std/special/compiler_rt/floatuntitf_test.zig +++ b/lib/std/special/compiler_rt/floatuntitf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/int.zig b/lib/std/special/compiler_rt/int.zig index 1fb2c263e1..b852139516 100644 --- a/lib/std/special/compiler_rt/int.zig +++ b/lib/std/special/compiler_rt/int.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/lshrdi3_test.zig b/lib/std/special/compiler_rt/lshrdi3_test.zig index de83f0a9c8..5443fd9bce 100644 --- a/lib/std/special/compiler_rt/lshrdi3_test.zig +++ b/lib/std/special/compiler_rt/lshrdi3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/lshrti3_test.zig b/lib/std/special/compiler_rt/lshrti3_test.zig index f831e8b132..bfd812f028 100644 --- a/lib/std/special/compiler_rt/lshrti3_test.zig +++ b/lib/std/special/compiler_rt/lshrti3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/modti3.zig b/lib/std/special/compiler_rt/modti3.zig index 9c3de44395..298a488dc2 100644 --- a/lib/std/special/compiler_rt/modti3.zig +++ b/lib/std/special/compiler_rt/modti3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/modti3_test.zig b/lib/std/special/compiler_rt/modti3_test.zig index cad60c015e..644c9027b7 100644 --- a/lib/std/special/compiler_rt/modti3_test.zig +++ b/lib/std/special/compiler_rt/modti3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/mulXf3.zig b/lib/std/special/compiler_rt/mulXf3.zig index d8dac5b1bc..a4c71529d1 100644 --- a/lib/std/special/compiler_rt/mulXf3.zig +++ b/lib/std/special/compiler_rt/mulXf3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/mulXf3_test.zig b/lib/std/special/compiler_rt/mulXf3_test.zig index c9994b089b..272c96522d 100644 --- a/lib/std/special/compiler_rt/mulXf3_test.zig +++ b/lib/std/special/compiler_rt/mulXf3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/muldi3.zig b/lib/std/special/compiler_rt/muldi3.zig index 2de96ea66c..607ac489fc 100644 --- a/lib/std/special/compiler_rt/muldi3.zig +++ b/lib/std/special/compiler_rt/muldi3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/muldi3_test.zig b/lib/std/special/compiler_rt/muldi3_test.zig index b4962189cd..78023f514b 100644 --- a/lib/std/special/compiler_rt/muldi3_test.zig +++ b/lib/std/special/compiler_rt/muldi3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/mulodi4.zig b/lib/std/special/compiler_rt/mulodi4.zig index fab345fa47..ed90b4d382 100644 --- a/lib/std/special/compiler_rt/mulodi4.zig +++ b/lib/std/special/compiler_rt/mulodi4.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/mulodi4_test.zig b/lib/std/special/compiler_rt/mulodi4_test.zig index a96f7a1996..7d7658e192 100644 --- a/lib/std/special/compiler_rt/mulodi4_test.zig +++ b/lib/std/special/compiler_rt/mulodi4_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/muloti4.zig b/lib/std/special/compiler_rt/muloti4.zig index b1ad82da29..30054ac751 100644 --- a/lib/std/special/compiler_rt/muloti4.zig +++ b/lib/std/special/compiler_rt/muloti4.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/muloti4_test.zig b/lib/std/special/compiler_rt/muloti4_test.zig index 44ab93a069..83722df6a5 100644 --- a/lib/std/special/compiler_rt/muloti4_test.zig +++ b/lib/std/special/compiler_rt/muloti4_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/multi3.zig b/lib/std/special/compiler_rt/multi3.zig index fad73789ac..d417c79ff2 100644 --- a/lib/std/special/compiler_rt/multi3.zig +++ b/lib/std/special/compiler_rt/multi3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/multi3_test.zig b/lib/std/special/compiler_rt/multi3_test.zig index 04b70d0538..674cf1cb9b 100644 --- a/lib/std/special/compiler_rt/multi3_test.zig +++ b/lib/std/special/compiler_rt/multi3_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/negXf2.zig b/lib/std/special/compiler_rt/negXf2.zig index 389b26584d..8c7010cccb 100644 --- a/lib/std/special/compiler_rt/negXf2.zig +++ b/lib/std/special/compiler_rt/negXf2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/popcountdi2.zig b/lib/std/special/compiler_rt/popcountdi2.zig index 5bb49ce402..8495068339 100644 --- a/lib/std/special/compiler_rt/popcountdi2.zig +++ b/lib/std/special/compiler_rt/popcountdi2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/popcountdi2_test.zig b/lib/std/special/compiler_rt/popcountdi2_test.zig index 6ea181bf0e..d0665bf278 100644 --- a/lib/std/special/compiler_rt/popcountdi2_test.zig +++ b/lib/std/special/compiler_rt/popcountdi2_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/shift.zig b/lib/std/special/compiler_rt/shift.zig index 21e52d9db8..46712738ab 100644 --- a/lib/std/special/compiler_rt/shift.zig +++ b/lib/std/special/compiler_rt/shift.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -124,7 +124,7 @@ pub fn __aeabi_llsr(a: i64, b: i32) callconv(.AAPCS) i64 { return __lshrdi3(a, b); } -test "" { +test { _ = @import("ashrdi3_test.zig"); _ = @import("ashrti3_test.zig"); diff --git a/lib/std/special/compiler_rt/sparc.zig b/lib/std/special/compiler_rt/sparc.zig new file mode 100644 index 0000000000..e66bb25886 --- /dev/null +++ b/lib/std/special/compiler_rt/sparc.zig @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2020 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. +// +// SPARC uses a different naming scheme for its support routines so we map it here to the x86 name. + +const std = @import("std"); +const builtin = @import("builtin"); + +// The SPARC Architecture Manual, Version 9: +// A.13 Floating-Point Compare +const FCMP = extern enum(i32) { + Equal = 0, + Less = 1, + Greater = 2, + Unordered = 3, +}; + +// Basic arithmetic + +pub fn _Qp_add(c: *f128, a: *f128, b: *f128) callconv(.C) void { + c.* = @import("addXf3.zig").__addtf3(a.*, b.*); +} + +pub fn _Qp_div(c: *f128, a: *f128, b: *f128) callconv(.C) void { + c.* = @import("divtf3.zig").__divtf3(a.*, b.*); +} + +pub fn _Qp_mul(c: *f128, a: *f128, b: *f128) callconv(.C) void { + c.* = @import("mulXf3.zig").__multf3(a.*, b.*); +} + +pub fn _Qp_sub(c: *f128, a: *f128, b: *f128) callconv(.C) void { + c.* = @import("addXf3.zig").__subtf3(a.*, b.*); +} + +// Comparison + +pub fn _Qp_cmp(a: *f128, b: *f128) callconv(.C) i32 { + return @enumToInt(@import("compareXf2.zig").cmp(f128, FCMP, a.*, b.*)); +} + +pub fn _Qp_feq(a: *f128, b: *f128) callconv(.C) bool { + return _Qp_cmp(a, b) == @enumToInt(FCMP.Equal); +} + +pub fn _Qp_fne(a: *f128, b: *f128) callconv(.C) bool { + return _Qp_cmp(a, b) != @enumToInt(FCMP.Equal); +} + +pub fn _Qp_flt(a: *f128, b: *f128) callconv(.C) bool { + return _Qp_cmp(a, b) == @enumToInt(FCMP.Less); +} + +pub fn _Qp_fle(a: *f128, b: *f128) callconv(.C) bool { + const cmp = _Qp_cmp(a, b); + return cmp == @enumToInt(FCMP.Less) or cmp == @enumToInt(FCMP.Equal); +} + +pub fn _Qp_fgt(a: *f128, b: *f128) callconv(.C) bool { + return _Qp_cmp(a, b) == @enumToInt(FCMP.Greater); +} + +pub fn _Qp_fge(a: *f128, b: *f128) callconv(.C) bool { + const cmp = _Qp_cmp(a, b); + return cmp == @enumToInt(FCMP.Greater) or cmp == @enumToInt(FCMP.Equal); +} + +// Casting + +pub fn _Qp_dtoq(c: *f128, a: f64) callconv(.C) void { + c.* = @import("extendXfYf2.zig").__extenddftf2(a); +} + +pub fn _Qp_qtod(a: *f128) callconv(.C) f64 { + return @import("truncXfYf2.zig").__trunctfdf2(a.*); +} diff --git a/lib/std/special/compiler_rt/stack_probe.zig b/lib/std/special/compiler_rt/stack_probe.zig index 58cce9fb6f..d0dcd70550 100644 --- a/lib/std/special/compiler_rt/stack_probe.zig +++ b/lib/std/special/compiler_rt/stack_probe.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/truncXfYf2.zig b/lib/std/special/compiler_rt/truncXfYf2.zig index a3885d1211..470ac17c2c 100644 --- a/lib/std/special/compiler_rt/truncXfYf2.zig +++ b/lib/std/special/compiler_rt/truncXfYf2.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/truncXfYf2_test.zig b/lib/std/special/compiler_rt/truncXfYf2_test.zig index 048005f86d..6426614b07 100644 --- a/lib/std/special/compiler_rt/truncXfYf2_test.zig +++ b/lib/std/special/compiler_rt/truncXfYf2_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/udivmod.zig b/lib/std/special/compiler_rt/udivmod.zig index aa3ca7ea30..265a365dc8 100644 --- a/lib/std/special/compiler_rt/udivmod.zig +++ b/lib/std/special/compiler_rt/udivmod.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/udivmoddi4_test.zig b/lib/std/special/compiler_rt/udivmoddi4_test.zig index 74a4a828e8..d3f39a0589 100644 --- a/lib/std/special/compiler_rt/udivmoddi4_test.zig +++ b/lib/std/special/compiler_rt/udivmoddi4_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/udivmodti4.zig b/lib/std/special/compiler_rt/udivmodti4.zig index ff33a35680..310f4dce42 100644 --- a/lib/std/special/compiler_rt/udivmodti4.zig +++ b/lib/std/special/compiler_rt/udivmodti4.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/udivmodti4_test.zig b/lib/std/special/compiler_rt/udivmodti4_test.zig index 1852d5c7af..667b27f0aa 100644 --- a/lib/std/special/compiler_rt/udivmodti4_test.zig +++ b/lib/std/special/compiler_rt/udivmodti4_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/udivti3.zig b/lib/std/special/compiler_rt/udivti3.zig index 187b4a1577..8d95624edc 100644 --- a/lib/std/special/compiler_rt/udivti3.zig +++ b/lib/std/special/compiler_rt/udivti3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/compiler_rt/umodti3.zig b/lib/std/special/compiler_rt/umodti3.zig index 3bc5be8ffc..98160039a1 100644 --- a/lib/std/special/compiler_rt/umodti3.zig +++ b/lib/std/special/compiler_rt/umodti3.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/ssp.zig b/lib/std/special/ssp.zig index 255487744d..81db44a534 100644 --- a/lib/std/special/ssp.zig +++ b/lib/std/special/ssp.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/special/test_runner.zig b/lib/std/special/test_runner.zig index 2b2fe78262..f5a93298b5 100644 --- a/lib/std/special/test_runner.zig +++ b/lib/std/special/test_runner.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -11,7 +11,15 @@ pub const io_mode: io.Mode = builtin.test_io_mode; var log_err_count: usize = 0; +var args_buffer: [std.fs.MAX_PATH_BYTES + std.mem.page_size]u8 = undefined; +var args_allocator = std.heap.FixedBufferAllocator.init(&args_buffer); + pub fn main() anyerror!void { + const args = std.process.argsAlloc(&args_allocator.allocator) catch { + @panic("Too many bytes passed over the CLI to the test runner"); + }; + std.testing.zig_exe_path = args[1]; + const test_fn_list = builtin.test_functions; var ok_count: usize = 0; var skip_count: usize = 0; @@ -36,11 +44,11 @@ pub fn main() anyerror!void { } std.testing.log_level = .warn; - var test_node = root_node.start(test_fn.name, null); + var test_node = root_node.start(test_fn.name, 0); test_node.activate(); progress.refresh(); if (progress.terminal == null) { - std.debug.print("{}/{} {}... ", .{ i + 1, test_fn_list.len, test_fn.name }); + std.debug.print("{d}/{d} {s}... ", .{ i + 1, test_fn_list.len, test_fn.name }); } const result = if (test_fn.async_frame_size) |size| switch (io_mode) { .evented => blk: { @@ -54,7 +62,7 @@ pub fn main() anyerror!void { .blocking => { skip_count += 1; test_node.end(); - progress.log("{}...SKIP (async test)\n", .{test_fn.name}); + progress.log("{s}...SKIP (async test)\n", .{test_fn.name}); if (progress.terminal == null) std.debug.print("SKIP (async test)\n", .{}); continue; }, @@ -67,7 +75,7 @@ pub fn main() anyerror!void { error.SkipZigTest => { skip_count += 1; test_node.end(); - progress.log("{}...SKIP\n", .{test_fn.name}); + progress.log("{s}...SKIP\n", .{test_fn.name}); if (progress.terminal == null) std.debug.print("SKIP\n", .{}); }, else => { @@ -78,15 +86,15 @@ pub fn main() anyerror!void { } root_node.end(); if (ok_count == test_fn_list.len) { - std.debug.print("All {} tests passed.\n", .{ok_count}); + std.debug.print("All {d} tests passed.\n", .{ok_count}); } else { - std.debug.print("{} passed; {} skipped.\n", .{ ok_count, skip_count }); + std.debug.print("{d} passed; {d} skipped.\n", .{ ok_count, skip_count }); } if (log_err_count != 0) { - std.debug.print("{} errors were logged.\n", .{log_err_count}); + std.debug.print("{d} errors were logged.\n", .{log_err_count}); } if (leaks != 0) { - std.debug.print("{} tests leaked memory.\n", .{leaks}); + std.debug.print("{d} tests leaked memory.\n", .{leaks}); } if (leaks != 0 or log_err_count != 0) { std.process.exit(1); @@ -103,6 +111,6 @@ pub fn log( log_err_count += 1; } if (@enumToInt(message_level) <= @enumToInt(std.testing.log_level)) { - std.debug.print("[{}] ({}): " ++ format ++ "\n", .{ @tagName(scope), @tagName(message_level) } ++ args); + std.debug.print("[{s}] ({s}): " ++ format ++ "\n", .{ @tagName(scope), @tagName(message_level) } ++ args); } } diff --git a/lib/std/spinlock.zig b/lib/std/spinlock.zig deleted file mode 100644 index d72ac14ecf..0000000000 --- a/lib/std/spinlock.zig +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -const std = @import("std.zig"); -const builtin = @import("builtin"); - -pub const SpinLock = struct { - state: State, - - const State = enum(u8) { - Unlocked, - Locked, - }; - - pub const Held = struct { - spinlock: *SpinLock, - - pub fn release(self: Held) void { - @atomicStore(State, &self.spinlock.state, .Unlocked, .Release); - } - }; - - pub fn init() SpinLock { - return SpinLock{ .state = .Unlocked }; - } - - pub fn deinit(self: *SpinLock) void { - self.* = undefined; - } - - pub fn tryAcquire(self: *SpinLock) ?Held { - return switch (@atomicRmw(State, &self.state, .Xchg, .Locked, .Acquire)) { - .Unlocked => Held{ .spinlock = self }, - .Locked => null, - }; - } - - pub fn acquire(self: *SpinLock) Held { - while (true) { - return self.tryAcquire() orelse { - yield(); - continue; - }; - } - } - - pub fn yield() void { - // On native windows, SwitchToThread is too expensive, - // and yielding for 380-410 iterations was found to be - // a nice sweet spot. Posix systems on the other hand, - // especially linux, perform better by yielding the thread. - switch (builtin.os.tag) { - .windows => loopHint(400), - else => std.os.sched_yield() catch loopHint(1), - } - } - - /// Hint to the cpu that execution is spinning - /// for the given amount of iterations. - pub fn loopHint(iterations: usize) void { - var i = iterations; - while (i != 0) : (i -= 1) { - switch (builtin.arch) { - // these instructions use a memory clobber as they - // flush the pipeline of any speculated reads/writes. - .i386, .x86_64 => asm volatile ("pause" - : - : - : "memory" - ), - .arm, .aarch64 => asm volatile ("yield" - : - : - : "memory" - ), - else => std.os.sched_yield() catch {}, - } - } - } -}; - -test "spinlock" { - var lock = SpinLock.init(); - defer lock.deinit(); - - const held = lock.acquire(); - defer held.release(); -} diff --git a/lib/std/start.zig b/lib/std/start.zig index 7d3a9c45c7..0fb96c768f 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -10,6 +10,7 @@ const std = @import("std.zig"); const builtin = std.builtin; const assert = std.debug.assert; const uefi = std.os.uefi; +const tlcsprng = @import("crypto/tlcsprng.zig"); var argc_argv_ptr: [*]usize = undefined; @@ -261,11 +262,11 @@ const bad_main_ret = "expected return type of main to be 'void', '!void', 'noret // This is marked inline because for some reason LLVM in release mode fails to inline it, // and we want fewer call frames in stack traces. -inline fn initEventLoopAndCallMain() u8 { +fn initEventLoopAndCallMain() callconv(.Inline) u8 { if (std.event.Loop.instance) |loop| { if (!@hasDecl(root, "event_loop")) { loop.init() catch |err| { - std.log.err("{}", .{@errorName(err)}); + std.log.err("{s}", .{@errorName(err)}); if (@errorReturnTrace()) |trace| { std.debug.dumpStackTrace(trace.*); } @@ -290,11 +291,11 @@ inline fn initEventLoopAndCallMain() u8 { // and we want fewer call frames in stack traces. // TODO This function is duplicated from initEventLoopAndCallMain instead of using generics // because it is working around stage1 compiler bugs. -inline fn initEventLoopAndCallWinMain() std.os.windows.INT { +fn initEventLoopAndCallWinMain() callconv(.Inline) std.os.windows.INT { if (std.event.Loop.instance) |loop| { if (!@hasDecl(root, "event_loop")) { loop.init() catch |err| { - std.log.err("{}", .{@errorName(err)}); + std.log.err("{s}", .{@errorName(err)}); if (@errorReturnTrace()) |trace| { std.debug.dumpStackTrace(trace.*); } @@ -342,7 +343,7 @@ pub fn callMain() u8 { }, .ErrorUnion => { const result = root.main() catch |err| { - std.log.err("{}", .{@errorName(err)}); + std.log.err("{s}", .{@errorName(err)}); if (@errorReturnTrace()) |trace| { std.debug.dumpStackTrace(trace.*); } diff --git a/lib/std/start_windows_tls.zig b/lib/std/start_windows_tls.zig index 18c016d206..1ad10126d2 100644 --- a/lib/std/start_windows_tls.zig +++ b/lib/std/start_windows_tls.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/std.zig b/lib/std/std.zig index f6da7afc55..c0d97a9d9c 100644 --- a/lib/std/std.zig +++ b/lib/std/std.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -8,13 +8,11 @@ pub const ArrayHashMapUnmanaged = array_hash_map.ArrayHashMapUnmanaged; pub const ArrayList = @import("array_list.zig").ArrayList; pub const ArrayListAligned = @import("array_list.zig").ArrayListAligned; pub const ArrayListAlignedUnmanaged = @import("array_list.zig").ArrayListAlignedUnmanaged; -pub const ArrayListSentineled = @import("array_list_sentineled.zig").ArrayListSentineled; pub const ArrayListUnmanaged = @import("array_list.zig").ArrayListUnmanaged; pub const AutoArrayHashMap = array_hash_map.AutoArrayHashMap; pub const AutoArrayHashMapUnmanaged = array_hash_map.AutoArrayHashMapUnmanaged; pub const AutoHashMap = hash_map.AutoHashMap; pub const AutoHashMapUnmanaged = hash_map.AutoHashMapUnmanaged; -pub const AutoResetEvent = @import("auto_reset_event.zig").AutoResetEvent; pub const BufMap = @import("buf_map.zig").BufMap; pub const BufSet = @import("buf_set.zig").BufSet; pub const ChildProcess = @import("child_process.zig").ChildProcess; @@ -22,25 +20,22 @@ pub const ComptimeStringMap = @import("comptime_string_map.zig").ComptimeStringM pub const DynLib = @import("dynamic_library.zig").DynLib; pub const HashMap = hash_map.HashMap; pub const HashMapUnmanaged = hash_map.HashMapUnmanaged; -pub const mutex = @import("mutex.zig"); -pub const Mutex = mutex.Mutex; +pub const MultiArrayList = @import("multi_array_list.zig").MultiArrayList; pub const PackedIntArray = @import("packed_int_array.zig").PackedIntArray; pub const PackedIntArrayEndian = @import("packed_int_array.zig").PackedIntArrayEndian; pub const PackedIntSlice = @import("packed_int_array.zig").PackedIntSlice; pub const PackedIntSliceEndian = @import("packed_int_array.zig").PackedIntSliceEndian; pub const PriorityQueue = @import("priority_queue.zig").PriorityQueue; -pub const Progress = @import("progress.zig").Progress; -pub const ResetEvent = @import("reset_event.zig").ResetEvent; +pub const Progress = @import("Progress.zig"); pub const SemanticVersion = @import("SemanticVersion.zig"); pub const SinglyLinkedList = @import("linked_list.zig").SinglyLinkedList; -pub const SpinLock = @import("spinlock.zig").SpinLock; pub const StringHashMap = hash_map.StringHashMap; pub const StringHashMapUnmanaged = hash_map.StringHashMapUnmanaged; pub const StringArrayHashMap = array_hash_map.StringArrayHashMap; pub const StringArrayHashMapUnmanaged = array_hash_map.StringArrayHashMapUnmanaged; pub const TailQueue = @import("linked_list.zig").TailQueue; pub const Target = @import("target.zig").Target; -pub const Thread = @import("thread.zig").Thread; +pub const Thread = @import("Thread.zig"); pub const array_hash_map = @import("array_hash_map.zig"); pub const atomic = @import("atomic.zig"); @@ -83,6 +78,7 @@ pub const testing = @import("testing.zig"); pub const time = @import("time.zig"); pub const unicode = @import("unicode.zig"); pub const valgrind = @import("valgrind.zig"); +pub const wasm = @import("wasm.zig"); pub const zig = @import("zig.zig"); pub const start = @import("start.zig"); @@ -92,6 +88,37 @@ comptime { _ = start; } -test "" { - testing.refAllDecls(@This()); +test { + if (builtin.os.tag == .windows) { + // We only test the Windows-relevant stuff to save memory because the CI + // server is hitting OOM. TODO revert this after stage2 arrives. + _ = ChildProcess; + _ = DynLib; + _ = Progress; + _ = Target; + _ = Thread; + + _ = atomic; + _ = build; + _ = builtin; + _ = debug; + _ = event; + _ = fs; + _ = heap; + _ = io; + _ = log; + _ = macho; + _ = net; + _ = os; + _ = once; + _ = pdb; + _ = process; + _ = testing; + _ = time; + _ = unicode; + _ = zig; + _ = start; + } else { + testing.refAllDecls(@This()); + } } diff --git a/lib/std/target.zig b/lib/std/target.zig index 08fecd7a82..ff7ee5d33c 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -57,6 +57,9 @@ pub const Target = struct { wasi, emscripten, uefi, + opencl, + glsl450, + vulkan, other, pub fn isDarwin(tag: Tag) bool { @@ -95,7 +98,7 @@ pub const Target = struct { win7 = 0x06010000, win8 = 0x06020000, win8_1 = 0x06030000, - win10 = 0x0A000000, + win10 = 0x0A000000, //aka win10_th1 win10_th2 = 0x0A000001, win10_rs1 = 0x0A000002, win10_rs2 = 0x0A000003, @@ -103,11 +106,34 @@ pub const Target = struct { win10_rs4 = 0x0A000005, win10_rs5 = 0x0A000006, win10_19h1 = 0x0A000007, - win10_20h1 = 0x0A000008, + win10_vb = 0x0A000008, //aka win10_19h2 + win10_mn = 0x0A000009, //aka win10_20h1 + win10_fe = 0x0A00000A, //aka win10_20h2 _, /// Latest Windows version that the Zig Standard Library is aware of - pub const latest = WindowsVersion.win10_20h1; + pub const latest = WindowsVersion.win10_fe; + + /// Compared against build numbers reported by the runtime to distinguish win10 versions, + /// where 0x0A000000 + index corresponds to the WindowsVersion u32 value. + pub const known_win10_build_numbers = [_]u32{ + 10240, //win10 aka win10_th1 + 10586, //win10_th2 + 14393, //win10_rs1 + 15063, //win10_rs2 + 16299, //win10_rs3 + 17134, //win10_rs4 + 17763, //win10_rs5 + 18362, //win10_19h1 + 18363, //win10_vb aka win10_19h2 + 19041, //win10_mn aka win10_20h1 + 19042, //win10_fe aka win10_20h2 + }; + + /// Returns whether the first version `self` is newer (greater) than or equal to the second version `ver`. + pub fn isAtLeast(self: WindowsVersion, ver: WindowsVersion) bool { + return @enumToInt(self) >= @enumToInt(ver); + } pub const Range = struct { min: WindowsVersion, @@ -136,14 +162,14 @@ pub const Target = struct { ) !void { if (fmt.len > 0 and fmt[0] == 's') { if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) { - try std.fmt.format(out_stream, ".{}", .{@tagName(self)}); + try std.fmt.format(out_stream, ".{s}", .{@tagName(self)}); } else { // TODO this code path breaks zig triples, but it is used in `builtin` try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, 0x{X:0>8})", .{@enumToInt(self)}); } } else { if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) { - try std.fmt.format(out_stream, "WindowsVersion.{}", .{@tagName(self)}); + try std.fmt.format(out_stream, "WindowsVersion.{s}", .{@tagName(self)}); } else { try std.fmt.format(out_stream, "WindowsVersion(0x{X:0>8})", .{@enumToInt(self)}); } @@ -225,6 +251,9 @@ pub const Target = struct { .wasi, .emscripten, .uefi, + .opencl, // TODO: OpenCL versions + .glsl450, // TODO: GLSL versions + .vulkan, .other, => return .{ .none = {} }, @@ -237,7 +266,7 @@ pub const Target = struct { .macos => return .{ .semver = .{ .min = .{ .major = 10, .minor = 13 }, - .max = .{ .major = 10, .minor = 15, .patch = 7 }, + .max = .{ .major = 11, .minor = 1 }, }, }, .ios => return .{ @@ -337,6 +366,9 @@ pub const Target = struct { }; } + /// On Darwin, we always link libSystem which contains libc. + /// Similarly on FreeBSD and NetBSD we always link system libc + /// since this is the stable syscall interface. pub fn requiresLibC(os: Os) bool { return switch (os.tag) { .freebsd, @@ -347,6 +379,7 @@ pub const Target = struct { .watchos, .dragonfly, .openbsd, + .haiku, => true, .linux, @@ -359,7 +392,6 @@ pub const Target = struct { .lv2, .solaris, .zos, - .haiku, .minix, .rtems, .nacl, @@ -377,6 +409,9 @@ pub const Target = struct { .wasi, .emscripten, .uefi, + .opencl, + .glsl450, + .vulkan, .other, => false, }; @@ -395,6 +430,7 @@ pub const Target = struct { pub const powerpc = @import("target/powerpc.zig"); pub const riscv = @import("target/riscv.zig"); pub const sparc = @import("target/sparc.zig"); + pub const spirv = @import("target/spirv.zig"); pub const systemz = @import("target/systemz.zig"); pub const wasm = @import("target/wasm.zig"); pub const x86 = @import("target/x86.zig"); @@ -433,7 +469,6 @@ pub const Target = struct { .lv2, .solaris, .zos, - .haiku, .minix, .rtems, .nacl, @@ -459,6 +494,7 @@ pub const Target = struct { .kfreebsd, .netbsd, .hurd, + .haiku, => return .gnu, .windows, .uefi, @@ -467,6 +503,10 @@ pub const Target = struct { .wasi, .emscripten, => return .musl, + .opencl, // TODO: SPIR-V ABIs with Linkage capability + .glsl450, + .vulkan, + => return .none, } } @@ -502,6 +542,7 @@ pub const Target = struct { macho, wasm, c, + spirv, hex, raw, }; @@ -719,6 +760,8 @@ pub const Target = struct { // Stage1 currently assumes that architectures above this comment // map one-to-one with the ZigLLVM_ArchType enum. spu_2, + spirv32, + spirv64, pub fn isARM(arch: Arch) bool { return switch (arch) { @@ -833,6 +876,8 @@ pub const Target = struct { .s390x => ._S390, .ve => ._NONE, .spu_2 => ._SPU_2, + .spirv32 => ._NONE, + .spirv64 => ._NONE, }; } @@ -891,6 +936,8 @@ pub const Target = struct { .s390x => .Unknown, .ve => .Unknown, .spu_2 => .Unknown, + .spirv32 => .Unknown, + .spirv64 => .Unknown, }; } @@ -935,6 +982,9 @@ pub const Target = struct { .shave, .ve, .spu_2, + // GPU bitness is opaque. For now, assume little endian. + .spirv32, + .spirv64, => .Little, .arc, @@ -991,6 +1041,7 @@ pub const Target = struct { .wasm32, .renderscript32, .aarch64_32, + .spirv32, => return 32, .aarch64, @@ -1014,6 +1065,7 @@ pub const Target = struct { .sparcv9, .s390x, .ve, + .spirv64, => return 64, } } @@ -1037,6 +1089,7 @@ pub const Target = struct { .i386, .x86_64 => "x86", .nvptx, .nvptx64 => "nvptx", .wasm32, .wasm64 => "wasm", + .spirv32, .spirv64 => "spir-v", else => @tagName(arch), }; } @@ -1180,7 +1233,7 @@ pub const Target = struct { } pub fn linuxTripleSimple(allocator: *mem.Allocator, cpu_arch: Cpu.Arch, os_tag: Os.Tag, abi: Abi) ![]u8 { - return std.fmt.allocPrint(allocator, "{}-{}-{}", .{ @tagName(cpu_arch), @tagName(os_tag), @tagName(abi) }); + return std.fmt.allocPrint(allocator, "{s}-{s}-{s}", .{ @tagName(cpu_arch), @tagName(os_tag), @tagName(abi) }); } pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 { @@ -1327,6 +1380,9 @@ pub const Target = struct { .uefi, .windows, .emscripten, + .opencl, + .glsl450, + .vulkan, .other, => return false, else => return true, @@ -1384,7 +1440,7 @@ pub const Target = struct { if (self.abi == .android) { const suffix = if (self.cpu.arch.ptrBitWidth() == 64) "64" else ""; - return print(&result, "/system/bin/linker{}", .{suffix}); + return print(&result, "/system/bin/linker{s}", .{suffix}); } if (self.abi.isMusl()) { @@ -1398,7 +1454,7 @@ pub const Target = struct { else => |arch| @tagName(arch), }; const arch_suffix = if (is_arm and self.abi.floatAbi() == .hard) "hf" else ""; - return print(&result, "/lib/ld-musl-{}{}.so.1", .{ arch_part, arch_suffix }); + return print(&result, "/lib/ld-musl-{s}{s}.so.1", .{ arch_part, arch_suffix }); } switch (self.os.tag) { @@ -1437,7 +1493,7 @@ pub const Target = struct { }; const is_nan_2008 = mips.featureSetHas(self.cpu.features, .nan2008); const loader = if (is_nan_2008) "ld-linux-mipsn8.so.1" else "ld.so.1"; - return print(&result, "/lib{}/{}", .{ lib_suffix, loader }); + return print(&result, "/lib{s}/{s}", .{ lib_suffix, loader }); }, .powerpc => return copy(&result, "/lib/ld.so.1"), @@ -1462,6 +1518,8 @@ pub const Target = struct { .nvptx64, .spu_2, .avr, + .spirv32, + .spirv64, => return result, // TODO go over each item in this list and either move it to the above list, or @@ -1505,9 +1563,15 @@ pub const Target = struct { .windows, .emscripten, .wasi, + .opencl, + .glsl450, + .vulkan, .other, => return result, + // TODO revisit when multi-arch for Haiku is available + .haiku => return copy(&result, "/system/runtime_loader"), + // TODO go over each item in this list and either move it to the above list, or // implement the standard dynamic linker path code for it. .ananas, @@ -1517,7 +1581,6 @@ pub const Target = struct { .lv2, .solaris, .zos, - .haiku, .minix, .rtems, .nacl, @@ -1558,6 +1621,6 @@ pub const Target = struct { } }; -test "" { +test { std.testing.refAllDecls(Target.Cpu.Arch); } diff --git a/lib/std/target/aarch64.zig b/lib/std/target/aarch64.zig index abf7f09943..b64f04d7ad 100644 --- a/lib/std/target/aarch64.zig +++ b/lib/std/target/aarch64.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/amdgpu.zig b/lib/std/target/amdgpu.zig index 368bd80dc8..135446c7df 100644 --- a/lib/std/target/amdgpu.zig +++ b/lib/std/target/amdgpu.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/arm.zig b/lib/std/target/arm.zig index 7243fc3805..b717120de3 100644 --- a/lib/std/target/arm.zig +++ b/lib/std/target/arm.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/avr.zig b/lib/std/target/avr.zig index 4517fd5abe..9513c1861f 100644 --- a/lib/std/target/avr.zig +++ b/lib/std/target/avr.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/bpf.zig b/lib/std/target/bpf.zig index 5e23c233c8..73287ec6a8 100644 --- a/lib/std/target/bpf.zig +++ b/lib/std/target/bpf.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/hexagon.zig b/lib/std/target/hexagon.zig index 34bbf70bb4..b1f565f52d 100644 --- a/lib/std/target/hexagon.zig +++ b/lib/std/target/hexagon.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/mips.zig b/lib/std/target/mips.zig index ccc207ff0f..59da13ac39 100644 --- a/lib/std/target/mips.zig +++ b/lib/std/target/mips.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/msp430.zig b/lib/std/target/msp430.zig index 38ea358f90..c1005a1d81 100644 --- a/lib/std/target/msp430.zig +++ b/lib/std/target/msp430.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/nvptx.zig b/lib/std/target/nvptx.zig index 9a35edc7e9..b025fbfcf7 100644 --- a/lib/std/target/nvptx.zig +++ b/lib/std/target/nvptx.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/powerpc.zig b/lib/std/target/powerpc.zig index ba59ee5da9..a2040e70b9 100644 --- a/lib/std/target/powerpc.zig +++ b/lib/std/target/powerpc.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -792,7 +792,7 @@ pub const cpu = struct { }; pub const ppc32 = CpuModel{ .name = "ppc32", - .llvm_name = "ppc32", + .llvm_name = "ppc", .features = featureSet(&[_]Feature{ .hard_float, }), diff --git a/lib/std/target/riscv.zig b/lib/std/target/riscv.zig index 3e26f0a094..a791f0105b 100644 --- a/lib/std/target/riscv.zig +++ b/lib/std/target/riscv.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/sparc.zig b/lib/std/target/sparc.zig index 4b6698e8de..a075160d59 100644 --- a/lib/std/target/sparc.zig +++ b/lib/std/target/sparc.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/systemz.zig b/lib/std/target/systemz.zig index 16b1471d55..8a78167e69 100644 --- a/lib/std/target/systemz.zig +++ b/lib/std/target/systemz.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/wasm.zig b/lib/std/target/wasm.zig index 6a2053c613..0a3281c692 100644 --- a/lib/std/target/wasm.zig +++ b/lib/std/target/wasm.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/target/x86.zig b/lib/std/target/x86.zig index d764bc2d21..1a52162969 100644 --- a/lib/std/target/x86.zig +++ b/lib/std/target/x86.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 69df01190d..1d89155a58 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -21,14 +21,18 @@ pub var base_allocator_instance = std.heap.FixedBufferAllocator.init(""); /// TODO https://github.com/ziglang/zig/issues/5738 pub var log_level = std.log.Level.warn; +/// This is available to any test that wants to execute Zig in a child process. +/// It will be the same executable that is running `zig test`. +pub var zig_exe_path: []const u8 = undefined; + /// This function is intended to be used only in tests. It prints diagnostics to stderr /// and then aborts when actual_error_union is not expected_error. pub fn expectError(expected_error: anyerror, actual_error_union: anytype) void { if (actual_error_union) |actual_payload| { - std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload }); + std.debug.panic("expected error.{s}, found {any}", .{ @errorName(expected_error), actual_payload }); } else |actual_error| { if (expected_error != actual_error) { - std.debug.panic("expected error.{}, found error.{}", .{ + std.debug.panic("expected error.{s}, found error.{s}", .{ @errorName(expected_error), @errorName(actual_error), }); @@ -56,7 +60,7 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { .Type => { if (actual != expected) { - std.debug.panic("expected type {}, found type {}", .{ @typeName(expected), @typeName(actual) }); + std.debug.panic("expected type {s}, found type {s}", .{ @typeName(expected), @typeName(actual) }); } }, @@ -84,7 +88,7 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { }, .Slice => { if (actual.ptr != expected.ptr) { - std.debug.panic("expected slice ptr {}, found {}", .{ expected.ptr, actual.ptr }); + std.debug.panic("expected slice ptr {*}, found {*}", .{ expected.ptr, actual.ptr }); } if (actual.len != expected.len) { std.debug.panic("expected slice len {}, found {}", .{ expected.len, actual.len }); @@ -115,10 +119,10 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { @compileError("Unable to compare untagged union values"); } - const TagType = @TagType(@TypeOf(expected)); + const Tag = std.meta.Tag(@TypeOf(expected)); - const expectedTag = @as(TagType, expected); - const actualTag = @as(TagType, actual); + const expectedTag = @as(Tag, expected); + const actualTag = @as(Tag, actual); expectEqual(expectedTag, actualTag); @@ -141,11 +145,11 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { if (actual) |actual_payload| { expectEqual(expected_payload, actual_payload); } else { - std.debug.panic("expected {}, found null", .{expected_payload}); + std.debug.panic("expected {any}, found null", .{expected_payload}); } } else { if (actual) |actual_payload| { - std.debug.panic("expected null, found {}", .{actual_payload}); + std.debug.panic("expected null, found {any}", .{actual_payload}); } } }, @@ -155,11 +159,11 @@ pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { if (actual) |actual_payload| { expectEqual(expected_payload, actual_payload); } else |actual_err| { - std.debug.panic("expected {}, found {}", .{ expected_payload, actual_err }); + std.debug.panic("expected {any}, found {}", .{ expected_payload, actual_err }); } } else |expected_err| { if (actual) |actual_payload| { - std.debug.panic("expected {}, found {}", .{ expected_err, actual_payload }); + std.debug.panic("expected {}, found {any}", .{ expected_err, actual_payload }); } else |actual_err| { expectEqual(expected_err, actual_err); } @@ -180,6 +184,22 @@ test "expectEqual.union(enum)" { expectEqual(a10, a10); } +/// This function is intended to be used only in tests. When the formatted result of the template +/// and its arguments does not equal the expected text, it prints diagnostics to stderr to show how +/// they are not equal, then returns an error. +pub fn expectFmt(expected: []const u8, comptime template: []const u8, args: anytype) !void { + const result = try std.fmt.allocPrint(allocator, template, args); + defer allocator.free(result); + if (std.mem.eql(u8, result, expected)) return; + + print("\n====== expected this output: =========\n", .{}); + print("{s}", .{expected}); + print("\n======== instead found this: =========\n", .{}); + print("{s}", .{result}); + print("\n======================================\n", .{}); + return error.TestFailed; +} + /// This function is intended to be used only in tests. When the actual value is not /// within the margin of the expected value, /// prints diagnostics to stderr to show exactly how they are not equal, then aborts. @@ -254,12 +274,12 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const // If the child type is u8 and no weird bytes, we could print it as strings // Even for the length difference, it would be useful to see the values of the slices probably. if (expected.len != actual.len) { - std.debug.panic("slice lengths differ. expected {}, found {}", .{ expected.len, actual.len }); + std.debug.panic("slice lengths differ. expected {d}, found {d}", .{ expected.len, actual.len }); } var i: usize = 0; while (i < expected.len) : (i += 1) { if (!std.meta.eql(expected[i], actual[i])) { - std.debug.panic("index {} incorrect. expected {}, found {}", .{ i, expected[i], actual[i] }); + std.debug.panic("index {} incorrect. expected {any}, found {any}", .{ i, expected[i], actual[i] }); } } } @@ -303,10 +323,9 @@ fn getCwdOrWasiPreopen() std.fs.Dir { pub fn tmpDir(opts: std.fs.Dir.OpenDirOptions) TmpDir { var random_bytes: [TmpDir.random_bytes_count]u8 = undefined; - std.crypto.randomBytes(&random_bytes) catch - @panic("unable to make tmp dir for testing: unable to get random bytes"); + std.crypto.random.bytes(&random_bytes); var sub_path: [TmpDir.sub_path_len]u8 = undefined; - std.fs.base64_encoder.encode(&sub_path, &random_bytes); + _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes); var cwd = getCwdOrWasiPreopen(); var cache_dir = cwd.makeOpenPath("zig-cache", .{}) catch @@ -357,7 +376,7 @@ pub fn expectEqualStrings(expected: []const u8, actual: []const u8) void { for (expected[0..diff_index]) |value| { if (value == '\n') diff_line_number += 1; } - print("First difference occurs on line {}:\n", .{diff_line_number}); + print("First difference occurs on line {d}:\n", .{diff_line_number}); print("expected:\n", .{}); printIndicatorLine(expected, diff_index); @@ -413,18 +432,18 @@ fn printWithVisibleNewlines(source: []const u8) void { while (std.mem.indexOf(u8, source[i..], "\n")) |nl| : (i += nl + 1) { printLine(source[i .. i + nl]); } - print("{}␃\n", .{source[i..]}); // End of Text symbol (ETX) + print("{s}␃\n", .{source[i..]}); // End of Text symbol (ETX) } fn printLine(line: []const u8) void { if (line.len != 0) switch (line[line.len - 1]) { - ' ', '\t' => print("{}⏎\n", .{line}), // Carriage return symbol, + ' ', '\t' => print("{s}⏎\n", .{line}), // Carriage return symbol, else => {}, }; - print("{}\n", .{line}); + print("{s}\n", .{line}); } -test "" { +test { expectEqualStrings("foo", "foo"); } diff --git a/lib/std/testing/failing_allocator.zig b/lib/std/testing/failing_allocator.zig index 61912e6933..570050762d 100644 --- a/lib/std/testing/failing_allocator.zig +++ b/lib/std/testing/failing_allocator.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/thread.zig b/lib/std/thread.zig deleted file mode 100644 index 83dfd7cb52..0000000000 --- a/lib/std/thread.zig +++ /dev/null @@ -1,496 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors -// This file is part of [zig](https://ziglang.org/), which is MIT licensed. -// The MIT license requires this copyright notice to be included in all copies -// and substantial portions of the software. -const std = @import("std.zig"); -const builtin = std.builtin; -const os = std.os; -const mem = std.mem; -const windows = std.os.windows; -const c = std.c; -const assert = std.debug.assert; - -const bad_startfn_ret = "expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'"; - -pub const Thread = struct { - data: Data, - - pub const use_pthreads = std.Target.current.os.tag != .windows and builtin.link_libc; - - /// Represents a kernel thread handle. - /// May be an integer or a pointer depending on the platform. - /// On Linux and POSIX, this is the same as Id. - pub const Handle = if (use_pthreads) - c.pthread_t - else switch (std.Target.current.os.tag) { - .linux => i32, - .windows => windows.HANDLE, - else => void, - }; - - /// Represents a unique ID per thread. - /// May be an integer or pointer depending on the platform. - /// On Linux and POSIX, this is the same as Handle. - pub const Id = switch (std.Target.current.os.tag) { - .windows => windows.DWORD, - else => Handle, - }; - - pub const Data = if (use_pthreads) - struct { - handle: Thread.Handle, - memory: []u8, - } - else switch (std.Target.current.os.tag) { - .linux => struct { - handle: Thread.Handle, - memory: []align(mem.page_size) u8, - }, - .windows => struct { - handle: Thread.Handle, - alloc_start: *c_void, - heap_handle: windows.HANDLE, - }, - else => struct {}, - }; - - /// Returns the ID of the calling thread. - /// Makes a syscall every time the function is called. - /// On Linux and POSIX, this Id is the same as a Handle. - pub fn getCurrentId() Id { - if (use_pthreads) { - return c.pthread_self(); - } else - return switch (std.Target.current.os.tag) { - .linux => os.linux.gettid(), - .windows => windows.kernel32.GetCurrentThreadId(), - else => @compileError("Unsupported OS"), - }; - } - - /// Returns the handle of this thread. - /// On Linux and POSIX, this is the same as Id. - /// On Linux, it is possible that the thread spawned with `spawn` - /// finishes executing entirely before the clone syscall completes. In this - /// case, this function will return 0 rather than the no-longer-existing thread's - /// pid. - pub fn handle(self: Thread) Handle { - return self.data.handle; - } - - pub fn wait(self: *Thread) void { - if (use_pthreads) { - const err = c.pthread_join(self.data.handle, null); - switch (err) { - 0 => {}, - os.EINVAL => unreachable, - os.ESRCH => unreachable, - os.EDEADLK => unreachable, - else => unreachable, - } - std.heap.c_allocator.free(self.data.memory); - std.heap.c_allocator.destroy(self); - } else switch (std.Target.current.os.tag) { - .linux => { - while (true) { - const pid_value = @atomicLoad(i32, &self.data.handle, .SeqCst); - if (pid_value == 0) break; - const rc = os.linux.futex_wait(&self.data.handle, os.linux.FUTEX_WAIT, pid_value, null); - switch (os.linux.getErrno(rc)) { - 0 => continue, - os.EINTR => continue, - os.EAGAIN => continue, - else => unreachable, - } - } - os.munmap(self.data.memory); - }, - .windows => { - windows.WaitForSingleObjectEx(self.data.handle, windows.INFINITE, false) catch unreachable; - windows.CloseHandle(self.data.handle); - windows.HeapFree(self.data.heap_handle, 0, self.data.alloc_start); - }, - else => @compileError("Unsupported OS"), - } - } - - pub const SpawnError = error{ - /// A system-imposed limit on the number of threads was encountered. - /// There are a number of limits that may trigger this error: - /// * the RLIMIT_NPROC soft resource limit (set via setrlimit(2)), - /// which limits the number of processes and threads for a real - /// user ID, was reached; - /// * the kernel's system-wide limit on the number of processes and - /// threads, /proc/sys/kernel/threads-max, was reached (see - /// proc(5)); - /// * the maximum number of PIDs, /proc/sys/kernel/pid_max, was - /// reached (see proc(5)); or - /// * the PID limit (pids.max) imposed by the cgroup "process num‐ - /// ber" (PIDs) controller was reached. - ThreadQuotaExceeded, - - /// The kernel cannot allocate sufficient memory to allocate a task structure - /// for the child, or to copy those parts of the caller's context that need to - /// be copied. - SystemResources, - - /// Not enough userland memory to spawn the thread. - OutOfMemory, - - /// `mlockall` is enabled, and the memory needed to spawn the thread - /// would exceed the limit. - LockedMemoryLimitExceeded, - - Unexpected, - }; - - /// caller must call wait on the returned thread - /// fn startFn(@TypeOf(context)) T - /// where T is u8, noreturn, void, or !void - /// caller must call wait on the returned thread - pub fn spawn(context: anytype, comptime startFn: anytype) SpawnError!*Thread { - if (builtin.single_threaded) @compileError("cannot spawn thread when building in single-threaded mode"); - // TODO compile-time call graph analysis to determine stack upper bound - // https://github.com/ziglang/zig/issues/157 - const default_stack_size = 16 * 1024 * 1024; - - const Context = @TypeOf(context); - comptime assert(@typeInfo(@TypeOf(startFn)).Fn.args[0].arg_type.? == Context); - - if (std.Target.current.os.tag == .windows) { - const WinThread = struct { - const OuterContext = struct { - thread: Thread, - inner: Context, - }; - fn threadMain(raw_arg: windows.LPVOID) callconv(.C) windows.DWORD { - const arg = if (@sizeOf(Context) == 0) {} else @ptrCast(*Context, @alignCast(@alignOf(Context), raw_arg)).*; - - switch (@typeInfo(@typeInfo(@TypeOf(startFn)).Fn.return_type.?)) { - .NoReturn => { - startFn(arg); - }, - .Void => { - startFn(arg); - return 0; - }, - .Int => |info| { - if (info.bits != 8) { - @compileError(bad_startfn_ret); - } - return startFn(arg); - }, - .ErrorUnion => |info| { - if (info.payload != void) { - @compileError(bad_startfn_ret); - } - startFn(arg) catch |err| { - std.debug.warn("error: {}\n", .{@errorName(err)}); - if (@errorReturnTrace()) |trace| { - std.debug.dumpStackTrace(trace.*); - } - }; - return 0; - }, - else => @compileError(bad_startfn_ret), - } - } - }; - - const heap_handle = windows.kernel32.GetProcessHeap() orelse return error.OutOfMemory; - const byte_count = @alignOf(WinThread.OuterContext) + @sizeOf(WinThread.OuterContext); - const bytes_ptr = windows.kernel32.HeapAlloc(heap_handle, 0, byte_count) orelse return error.OutOfMemory; - errdefer assert(windows.kernel32.HeapFree(heap_handle, 0, bytes_ptr) != 0); - const bytes = @ptrCast([*]u8, bytes_ptr)[0..byte_count]; - const outer_context = std.heap.FixedBufferAllocator.init(bytes).allocator.create(WinThread.OuterContext) catch unreachable; - outer_context.* = WinThread.OuterContext{ - .thread = Thread{ - .data = Thread.Data{ - .heap_handle = heap_handle, - .alloc_start = bytes_ptr, - .handle = undefined, - }, - }, - .inner = context, - }; - - const parameter = if (@sizeOf(Context) == 0) null else @ptrCast(*c_void, &outer_context.inner); - outer_context.thread.data.handle = windows.kernel32.CreateThread(null, default_stack_size, WinThread.threadMain, parameter, 0, null) orelse { - switch (windows.kernel32.GetLastError()) { - else => |err| return windows.unexpectedError(err), - } - }; - return &outer_context.thread; - } - - const MainFuncs = struct { - fn linuxThreadMain(ctx_addr: usize) callconv(.C) u8 { - const arg = if (@sizeOf(Context) == 0) {} else @intToPtr(*const Context, ctx_addr).*; - - switch (@typeInfo(@typeInfo(@TypeOf(startFn)).Fn.return_type.?)) { - .NoReturn => { - startFn(arg); - }, - .Void => { - startFn(arg); - return 0; - }, - .Int => |info| { - if (info.bits != 8) { - @compileError(bad_startfn_ret); - } - return startFn(arg); - }, - .ErrorUnion => |info| { - if (info.payload != void) { - @compileError(bad_startfn_ret); - } - startFn(arg) catch |err| { - std.debug.warn("error: {}\n", .{@errorName(err)}); - if (@errorReturnTrace()) |trace| { - std.debug.dumpStackTrace(trace.*); - } - }; - return 0; - }, - else => @compileError(bad_startfn_ret), - } - } - fn posixThreadMain(ctx: ?*c_void) callconv(.C) ?*c_void { - const arg = if (@sizeOf(Context) == 0) {} else @ptrCast(*Context, @alignCast(@alignOf(Context), ctx)).*; - - switch (@typeInfo(@typeInfo(@TypeOf(startFn)).Fn.return_type.?)) { - .NoReturn => { - startFn(arg); - }, - .Void => { - startFn(arg); - return null; - }, - .Int => |info| { - if (info.bits != 8) { - @compileError(bad_startfn_ret); - } - // pthreads don't support exit status, ignore value - _ = startFn(arg); - return null; - }, - .ErrorUnion => |info| { - if (info.payload != void) { - @compileError(bad_startfn_ret); - } - startFn(arg) catch |err| { - std.debug.warn("error: {}\n", .{@errorName(err)}); - if (@errorReturnTrace()) |trace| { - std.debug.dumpStackTrace(trace.*); - } - }; - return null; - }, - else => @compileError(bad_startfn_ret), - } - } - }; - - if (Thread.use_pthreads) { - var attr: c.pthread_attr_t = undefined; - if (c.pthread_attr_init(&attr) != 0) return error.SystemResources; - defer assert(c.pthread_attr_destroy(&attr) == 0); - - const thread_obj = try std.heap.c_allocator.create(Thread); - errdefer std.heap.c_allocator.destroy(thread_obj); - if (@sizeOf(Context) > 0) { - thread_obj.data.memory = try std.heap.c_allocator.allocAdvanced( - u8, - @alignOf(Context), - @sizeOf(Context), - .at_least, - ); - errdefer std.heap.c_allocator.free(thread_obj.data.memory); - mem.copy(u8, thread_obj.data.memory, mem.asBytes(&context)); - } else { - thread_obj.data.memory = @as([*]u8, undefined)[0..0]; - } - - // Use the same set of parameters used by the libc-less impl. - assert(c.pthread_attr_setstacksize(&attr, default_stack_size) == 0); - assert(c.pthread_attr_setguardsize(&attr, mem.page_size) == 0); - - const err = c.pthread_create( - &thread_obj.data.handle, - &attr, - MainFuncs.posixThreadMain, - thread_obj.data.memory.ptr, - ); - switch (err) { - 0 => return thread_obj, - os.EAGAIN => return error.SystemResources, - os.EPERM => unreachable, - os.EINVAL => unreachable, - else => return os.unexpectedErrno(@intCast(usize, err)), - } - - return thread_obj; - } - - var guard_end_offset: usize = undefined; - var stack_end_offset: usize = undefined; - var thread_start_offset: usize = undefined; - var context_start_offset: usize = undefined; - var tls_start_offset: usize = undefined; - const mmap_len = blk: { - var l: usize = mem.page_size; - // Allocate a guard page right after the end of the stack region - guard_end_offset = l; - // The stack itself, which grows downwards. - l = mem.alignForward(l + default_stack_size, mem.page_size); - stack_end_offset = l; - // Above the stack, so that it can be in the same mmap call, put the Thread object. - l = mem.alignForward(l, @alignOf(Thread)); - thread_start_offset = l; - l += @sizeOf(Thread); - // Next, the Context object. - if (@sizeOf(Context) != 0) { - l = mem.alignForward(l, @alignOf(Context)); - context_start_offset = l; - l += @sizeOf(Context); - } - // Finally, the Thread Local Storage, if any. - l = mem.alignForward(l, os.linux.tls.tls_image.alloc_align); - tls_start_offset = l; - l += os.linux.tls.tls_image.alloc_size; - // Round the size to the page size. - break :blk mem.alignForward(l, mem.page_size); - }; - - const mmap_slice = mem: { - // Map the whole stack with no rw permissions to avoid - // committing the whole region right away - const mmap_slice = os.mmap( - null, - mmap_len, - os.PROT_NONE, - os.MAP_PRIVATE | os.MAP_ANONYMOUS, - -1, - 0, - ) catch |err| switch (err) { - error.MemoryMappingNotSupported => unreachable, - error.AccessDenied => unreachable, - error.PermissionDenied => unreachable, - else => |e| return e, - }; - errdefer os.munmap(mmap_slice); - - // Map everything but the guard page as rw - os.mprotect( - mmap_slice[guard_end_offset..], - os.PROT_READ | os.PROT_WRITE, - ) catch |err| switch (err) { - error.AccessDenied => unreachable, - else => |e| return e, - }; - - break :mem mmap_slice; - }; - - const mmap_addr = @ptrToInt(mmap_slice.ptr); - - const thread_ptr = @alignCast(@alignOf(Thread), @intToPtr(*Thread, mmap_addr + thread_start_offset)); - thread_ptr.data.memory = mmap_slice; - - var arg: usize = undefined; - if (@sizeOf(Context) != 0) { - arg = mmap_addr + context_start_offset; - const context_ptr = @alignCast(@alignOf(Context), @intToPtr(*Context, arg)); - context_ptr.* = context; - } - - if (std.Target.current.os.tag == .linux) { - const flags: u32 = os.CLONE_VM | os.CLONE_FS | os.CLONE_FILES | - os.CLONE_SIGHAND | os.CLONE_THREAD | os.CLONE_SYSVSEM | - os.CLONE_PARENT_SETTID | os.CLONE_CHILD_CLEARTID | - os.CLONE_DETACHED | os.CLONE_SETTLS; - // This structure is only needed when targeting i386 - var user_desc: if (std.Target.current.cpu.arch == .i386) os.linux.user_desc else void = undefined; - - const tls_area = mmap_slice[tls_start_offset..]; - const tp_value = os.linux.tls.prepareTLS(tls_area); - - const newtls = blk: { - if (std.Target.current.cpu.arch == .i386) { - user_desc = os.linux.user_desc{ - .entry_number = os.linux.tls.tls_image.gdt_entry_number, - .base_addr = tp_value, - .limit = 0xfffff, - .seg_32bit = 1, - .contents = 0, // Data - .read_exec_only = 0, - .limit_in_pages = 1, - .seg_not_present = 0, - .useable = 1, - }; - break :blk @ptrToInt(&user_desc); - } else { - break :blk tp_value; - } - }; - - const rc = os.linux.clone( - MainFuncs.linuxThreadMain, - mmap_addr + stack_end_offset, - flags, - arg, - &thread_ptr.data.handle, - newtls, - &thread_ptr.data.handle, - ); - switch (os.errno(rc)) { - 0 => return thread_ptr, - os.EAGAIN => return error.ThreadQuotaExceeded, - os.EINVAL => unreachable, - os.ENOMEM => return error.SystemResources, - os.ENOSPC => unreachable, - os.EPERM => unreachable, - os.EUSERS => unreachable, - else => |err| return os.unexpectedErrno(err), - } - } else { - @compileError("Unsupported OS"); - } - } - - pub const CpuCountError = error{ - PermissionDenied, - SystemResources, - Unexpected, - }; - - pub fn cpuCount() CpuCountError!usize { - if (std.Target.current.os.tag == .linux) { - const cpu_set = try os.sched_getaffinity(0); - return @as(usize, os.CPU_COUNT(cpu_set)); // TODO should not need this usize cast - } - if (std.Target.current.os.tag == .windows) { - return os.windows.peb().NumberOfProcessors; - } - if (std.Target.current.os.tag == .openbsd) { - var count: c_int = undefined; - var count_size: usize = @sizeOf(c_int); - const mib = [_]c_int{ os.CTL_HW, os.HW_NCPUONLINE }; - os.sysctl(&mib, &count, &count_size, null, 0) catch |err| switch (err) { - error.NameTooLong, error.UnknownName => unreachable, - else => |e| return e, - }; - return @intCast(usize, count); - } - var count: c_int = undefined; - var count_len: usize = @sizeOf(c_int); - const name = if (comptime std.Target.current.isDarwin()) "hw.logicalcpu" else "hw.ncpu"; - os.sysctlbynameZ(name, &count, &count_len, null, 0) catch |err| switch (err) { - error.NameTooLong, error.UnknownName => unreachable, - else => |e| return e, - }; - return @intCast(usize, count); - } -}; diff --git a/lib/std/time.zig b/lib/std/time.zig index 2f56e82f45..7435a67e3d 100644 --- a/lib/std/time.zig +++ b/lib/std/time.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/time/epoch.zig b/lib/std/time/epoch.zig index 3a42c85a6d..75bddc71c3 100644 --- a/lib/std/time/epoch.zig +++ b/lib/std/time/epoch.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig index c791e07f78..f9ad6e3eb5 100644 --- a/lib/std/unicode.zig +++ b/lib/std/unicode.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/unicode/throughput_test.zig b/lib/std/unicode/throughput_test.zig index 5474124fd2..8f9f9d9cb7 100644 --- a/lib/std/unicode/throughput_test.zig +++ b/lib/std/unicode/throughput_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -45,7 +45,7 @@ fn benchmarkCodepointCount(buf: []const u8) !ResultCount { } pub fn main() !void { - const stdout = std.io.getStdOut().outStream(); + const stdout = std.io.getStdOut().writer(); const args = try std.process.argsAlloc(std.heap.page_allocator); diff --git a/lib/std/valgrind.zig b/lib/std/valgrind.zig index 5373a2d513..6930652fbc 100644 --- a/lib/std/valgrind.zig +++ b/lib/std/valgrind.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -262,7 +262,7 @@ pub fn monitorCommand(command: [*]u8) bool { pub const memcheck = @import("valgrind/memcheck.zig"); pub const callgrind = @import("valgrind/callgrind.zig"); -test "" { +test { _ = @import("valgrind/memcheck.zig"); _ = @import("valgrind/callgrind.zig"); } diff --git a/lib/std/valgrind/callgrind.zig b/lib/std/valgrind/callgrind.zig index 5e025c4ffe..3962ad3e3a 100644 --- a/lib/std/valgrind/callgrind.zig +++ b/lib/std/valgrind/callgrind.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/valgrind/memcheck.zig b/lib/std/valgrind/memcheck.zig index 449b4c4a46..3226beec53 100644 --- a/lib/std/valgrind/memcheck.zig +++ b/lib/std/valgrind/memcheck.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/wasm.zig b/lib/std/wasm.zig new file mode 100644 index 0000000000..a04378d283 --- /dev/null +++ b/lib/std/wasm.zig @@ -0,0 +1,280 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2021 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. +const testing = @import("std.zig").testing; + +/// Wasm instruction opcodes +/// +/// All instructions are defined as per spec: +/// https://webassembly.github.io/spec/core/appendix/index-instructions.html +pub const Opcode = enum(u8) { + @"unreachable" = 0x00, + nop = 0x01, + block = 0x02, + loop = 0x03, + @"if" = 0x04, + @"else" = 0x05, + end = 0x0B, + br = 0x0C, + br_if = 0x0D, + br_table = 0x0E, + @"return" = 0x0F, + call = 0x10, + call_indirect = 0x11, + drop = 0x1A, + select = 0x1B, + local_get = 0x20, + local_set = 0x21, + local_tee = 0x22, + global_get = 0x23, + global_set = 0x24, + i32_load = 0x28, + i64_load = 0x29, + f32_load = 0x2A, + f64_load = 0x2B, + i32_load8_s = 0x2C, + i32_load8_u = 0x2D, + i32_load16_s = 0x2E, + i32_load16_u = 0x2F, + i64_load8_s = 0x30, + i64_load8_u = 0x31, + i64_load16_s = 0x32, + i64_load16_u = 0x33, + i64_load32_s = 0x34, + i64_load32_u = 0x35, + i32_store = 0x36, + i64_store = 0x37, + f32_store = 0x38, + f64_store = 0x39, + i32_store8 = 0x3A, + i32_store16 = 0x3B, + i64_store8 = 0x3C, + i64_store16 = 0x3D, + i64_store32 = 0x3E, + memory_size = 0x3F, + memory_grow = 0x40, + i32_const = 0x41, + i64_const = 0x42, + f32_const = 0x43, + f64_const = 0x44, + i32_eqz = 0x45, + i32_eq = 0x46, + i32_ne = 0x47, + i32_lt_s = 0x48, + i32_lt_u = 0x49, + i32_gt_s = 0x4A, + i32_gt_u = 0x4B, + i32_le_s = 0x4C, + i32_le_u = 0x4D, + i32_ge_s = 0x4E, + i32_ge_u = 0x4F, + i64_eqz = 0x50, + i64_eq = 0x51, + i64_ne = 0x52, + i64_lt_s = 0x53, + i64_lt_u = 0x54, + i64_gt_s = 0x55, + i64_gt_u = 0x56, + i64_le_s = 0x57, + i64_le_u = 0x58, + i64_ge_s = 0x59, + i64_ge_u = 0x5A, + f32_eq = 0x5B, + f32_ne = 0x5C, + f32_lt = 0x5D, + f32_gt = 0x5E, + f32_le = 0x5F, + f32_ge = 0x60, + f64_eq = 0x61, + f64_ne = 0x62, + f64_lt = 0x63, + f64_gt = 0x64, + f64_le = 0x65, + f64_ge = 0x66, + i32_clz = 0x67, + i32_ctz = 0x68, + i32_popcnt = 0x69, + i32_add = 0x6A, + i32_sub = 0x6B, + i32_mul = 0x6C, + i32_div_s = 0x6D, + i32_div_u = 0x6E, + i32_rem_s = 0x6F, + i32_rem_u = 0x70, + i32_and = 0x71, + i32_or = 0x72, + i32_xor = 0x73, + i32_shl = 0x74, + i32_shr_s = 0x75, + i32_shr_u = 0x76, + i32_rotl = 0x77, + i32_rotr = 0x78, + i64_clz = 0x79, + i64_ctz = 0x7A, + i64_popcnt = 0x7B, + i64_add = 0x7C, + i64_sub = 0x7D, + i64_mul = 0x7E, + i64_div_s = 0x7F, + i64_div_u = 0x80, + i64_rem_s = 0x81, + i64_rem_u = 0x82, + i64_and = 0x83, + i64_or = 0x84, + i64_xor = 0x85, + i64_shl = 0x86, + i64_shr_s = 0x87, + i64_shr_u = 0x88, + i64_rotl = 0x89, + i64_rotr = 0x8A, + f32_abs = 0x8B, + f32_neg = 0x8C, + f32_ceil = 0x8D, + f32_floor = 0x8E, + f32_trunc = 0x8F, + f32_nearest = 0x90, + f32_sqrt = 0x91, + f32_add = 0x92, + f32_sub = 0x93, + f32_mul = 0x94, + f32_div = 0x95, + f32_min = 0x96, + f32_max = 0x97, + f32_copysign = 0x98, + f64_abs = 0x99, + f64_neg = 0x9A, + f64_ceil = 0x9B, + f64_floor = 0x9C, + f64_trunc = 0x9D, + f64_nearest = 0x9E, + f64_sqrt = 0x9F, + f64_add = 0xA0, + f64_sub = 0xA1, + f64_mul = 0xA2, + f64_div = 0xA3, + f64_min = 0xA4, + f64_max = 0xA5, + f64_copysign = 0xA6, + i32_wrap_i64 = 0xA7, + i32_trunc_f32_s = 0xA8, + i32_trunc_f32_u = 0xA9, + i32_trunc_f64_s = 0xB0, + i32_trunc_f64_u = 0xB1, + f32_convert_i32_s = 0xB2, + f32_convert_i32_u = 0xB3, + f32_convert_i64_s = 0xB4, + f32_convert_i64_u = 0xB5, + f32_demote_f64 = 0xB6, + f64_convert_i32_s = 0xB7, + f64_convert_i32_u = 0xB8, + f64_convert_i64_s = 0xB9, + f64_convert_i64_u = 0xBA, + f64_promote_f32 = 0xBB, + i32_reinterpret_f32 = 0xBC, + i64_reinterpret_f64 = 0xBD, + f32_reinterpret_i32 = 0xBE, + i64_reinterpret_i64 = 0xBF, + i32_extend8_s = 0xC0, + i32_extend16_s = 0xC1, + i64_extend8_s = 0xC2, + i64_extend16_s = 0xC3, + i64_extend32_s = 0xC4, + _, +}; + +/// Returns the integer value of an `Opcode`. Used by the Zig compiler +/// to write instructions to the wasm binary file +pub fn opcode(op: Opcode) u8 { + return @enumToInt(op); +} + +test "Wasm - opcodes" { + // Ensure our opcodes values remain intact as certain values are skipped due to them being reserved + const i32_const = opcode(.i32_const); + const end = opcode(.end); + const drop = opcode(.drop); + const local_get = opcode(.local_get); + const i64_extend32_s = opcode(.i64_extend32_s); + + testing.expectEqual(@as(u16, 0x41), i32_const); + testing.expectEqual(@as(u16, 0x0B), end); + testing.expectEqual(@as(u16, 0x1A), drop); + testing.expectEqual(@as(u16, 0x20), local_get); + testing.expectEqual(@as(u16, 0xC4), i64_extend32_s); +} + +/// Enum representing all Wasm value types as per spec: +/// https://webassembly.github.io/spec/core/binary/types.html +pub const Valtype = enum(u8) { + i32 = 0x7F, + i64 = 0x7E, + f32 = 0x7D, + f64 = 0x7C, +}; + +/// Returns the integer value of a `Valtype` +pub fn valtype(value: Valtype) u8 { + return @enumToInt(value); +} + +test "Wasm - valtypes" { + const _i32 = valtype(.i32); + const _i64 = valtype(.i64); + const _f32 = valtype(.f32); + const _f64 = valtype(.f64); + + testing.expectEqual(@as(u8, 0x7F), _i32); + testing.expectEqual(@as(u8, 0x7E), _i64); + testing.expectEqual(@as(u8, 0x7D), _f32); + testing.expectEqual(@as(u8, 0x7C), _f64); +} + +/// Wasm module sections as per spec: +/// https://webassembly.github.io/spec/core/binary/modules.html +pub const Section = enum(u8) { + custom, + type, + import, + function, + table, + memory, + global, + @"export", + start, + element, + code, + data, +}; + +/// Returns the integer value of a given `Section` +pub fn section(val: Section) u8 { + return @enumToInt(val); +} + +/// The kind of the type when importing or exporting to/from the host environment +/// https://webassembly.github.io/spec/core/syntax/modules.html +pub const ExternalKind = enum(u8) { + function, + table, + memory, + global, +}; + +/// Returns the integer value of a given `ExternalKind` +pub fn externalKind(val: ExternalKind) u8 { + return @enumToInt(val); +} + +// types +pub const element_type: u8 = 0x70; +pub const function_type: u8 = 0x60; +pub const result_type: u8 = 0x40; + +/// Represents a block which will not return a value +pub const block_empty: u8 = 0x40; + +// binary constants +pub const magic = [_]u8{ 0x00, 0x61, 0x73, 0x6D }; // \0asm +pub const version = [_]u8{ 0x01, 0x00, 0x00, 0x00 }; // version 1 diff --git a/lib/std/zig.zig b/lib/std/zig.zig index 06a74a9786..197d7c2c59 100644 --- a/lib/std/zig.zig +++ b/lib/std/zig.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -8,9 +8,10 @@ const tokenizer = @import("zig/tokenizer.zig"); pub const Token = tokenizer.Token; pub const Tokenizer = tokenizer.Tokenizer; +pub const fmtId = @import("zig/fmt.zig").fmtId; +pub const fmtEscapes = @import("zig/fmt.zig").fmtEscapes; pub const parse = @import("zig/parse.zig").parse; pub const parseStringLiteral = @import("zig/string_literal.zig").parse; -pub const render = @import("zig/render.zig").render; pub const ast = @import("zig/ast.zig"); pub const system = @import("zig/system.zig"); pub const CrossTarget = @import("zig/cross_target.zig").CrossTarget; @@ -139,6 +140,7 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro .Lib => return std.fmt.allocPrint(allocator, "{s}.wasm", .{root_name}), }, .c => return std.fmt.allocPrint(allocator, "{s}.c", .{root_name}), + .spirv => return std.fmt.allocPrint(allocator, "{s}.spv", .{root_name}), .hex => return std.fmt.allocPrint(allocator, "{s}.ihex", .{root_name}), .raw => return std.fmt.allocPrint(allocator, "{s}.bin", .{root_name}), } @@ -253,6 +255,6 @@ test "parseCharLiteral" { std.testing.expectError(error.InvalidCharacter, parseCharLiteral("'\\u{FFFF}x'", &bad_index)); } -test "" { +test { @import("std").testing.refAllDecls(@This()); } diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig index 3e2f08cd06..46b58e9465 100644 --- a/lib/std/zig/ast.zig +++ b/lib/std/zig/ast.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -9,48 +9,26 @@ const testing = std.testing; const mem = std.mem; const Token = std.zig.Token; -pub const TokenIndex = usize; -pub const NodeIndex = usize; +pub const TokenIndex = u32; +pub const ByteOffset = u32; + +pub const TokenList = std.MultiArrayList(struct { + tag: Token.Tag, + start: ByteOffset, +}); +pub const NodeList = std.MultiArrayList(Node); pub const Tree = struct { /// Reference to externally-owned data. source: []const u8, - token_ids: []const Token.Id, - token_locs: []const Token.Loc, + + tokens: TokenList.Slice, + /// The root AST node is assumed to be index 0. Since there can be no + /// references to the root node, this means 0 is available to indicate null. + nodes: NodeList.Slice, + extra_data: []Node.Index, + errors: []const Error, - root_node: *Node.Root, - - arena: std.heap.ArenaAllocator.State, - gpa: *mem.Allocator, - - /// translate-c uses this to avoid having to emit correct newlines - /// TODO get rid of this hack - generated: bool = false, - - pub fn deinit(self: *Tree) void { - self.gpa.free(self.token_ids); - self.gpa.free(self.token_locs); - self.gpa.free(self.errors); - self.arena.promote(self.gpa).deinit(); - } - - pub fn renderError(self: *Tree, parse_error: *const Error, stream: anytype) !void { - return parse_error.render(self.token_ids, stream); - } - - pub fn tokenSlice(self: *Tree, token_index: TokenIndex) []const u8 { - return self.tokenSliceLoc(self.token_locs[token_index]); - } - - pub fn tokenSliceLoc(self: *Tree, token: Token.Loc) []const u8 { - return self.source[token.start..token.end]; - } - - pub fn getNodeSource(self: *const Tree, node: *const Node) []const u8 { - const first_token = self.token_locs[node.firstToken()]; - const last_token = self.token_locs[node.lastToken()]; - return self.source[first_token.start..last_token.end]; - } pub const Location = struct { line: usize, @@ -59,21 +37,50 @@ pub const Tree = struct { line_end: usize, }; - /// Return the Location of the token relative to the offset specified by `start_index`. - pub fn tokenLocationLoc(self: *Tree, start_index: usize, token: Token.Loc) Location { + pub fn deinit(tree: *Tree, gpa: *mem.Allocator) void { + tree.tokens.deinit(gpa); + tree.nodes.deinit(gpa); + gpa.free(tree.extra_data); + gpa.free(tree.errors); + tree.* = undefined; + } + + pub const RenderError = error{ + /// Ran out of memory allocating call stack frames to complete rendering, or + /// ran out of memory allocating space in the output buffer. + OutOfMemory, + }; + + /// `gpa` is used for allocating the resulting formatted source code, as well as + /// for allocating extra stack memory if needed, because this function utilizes recursion. + /// Note: that's not actually true yet, see https://github.com/ziglang/zig/issues/1006. + /// Caller owns the returned slice of bytes, allocated with `gpa`. + pub fn render(tree: Tree, gpa: *mem.Allocator) RenderError![]u8 { + var buffer = std.ArrayList(u8).init(gpa); + defer buffer.deinit(); + + try tree.renderToArrayList(&buffer); + return buffer.toOwnedSlice(); + } + + pub fn renderToArrayList(tree: Tree, buffer: *std.ArrayList(u8)) RenderError!void { + return @import("./render.zig").renderTree(buffer, tree); + } + + pub fn tokenLocation(self: Tree, start_offset: ByteOffset, token_index: TokenIndex) Location { var loc = Location{ .line = 0, .column = 0, - .line_start = start_index, + .line_start = start_offset, .line_end = self.source.len, }; - if (self.generated) - return loc; - const token_start = token.start; - for (self.source[start_index..]) |c, i| { - if (i + start_index == token_start) { - loc.line_end = i + start_index; - while (loc.line_end < self.source.len and self.source[loc.line_end] != '\n') : (loc.line_end += 1) {} + const token_start = self.tokens.items(.start)[token_index]; + for (self.source[start_offset..]) |c, i| { + if (i + start_offset == token_start) { + loc.line_end = i + start_offset; + while (loc.line_end < self.source.len and self.source[loc.line_end] != '\n') { + loc.line_end += 1; + } return loc; } if (c == '\n') { @@ -87,3196 +94,2878 @@ pub const Tree = struct { return loc; } - pub fn tokenLocation(self: *Tree, start_index: usize, token_index: TokenIndex) Location { - return self.tokenLocationLoc(start_index, self.token_locs[token_index]); - } + pub fn tokenSlice(tree: Tree, token_index: TokenIndex) []const u8 { + const token_starts = tree.tokens.items(.start); + const token_tags = tree.tokens.items(.tag); + const token_tag = token_tags[token_index]; - pub fn tokensOnSameLine(self: *Tree, token1_index: TokenIndex, token2_index: TokenIndex) bool { - return self.tokensOnSameLineLoc(self.token_locs[token1_index], self.token_locs[token2_index]); - } - - pub fn tokensOnSameLineLoc(self: *Tree, token1: Token.Loc, token2: Token.Loc) bool { - return mem.indexOfScalar(u8, self.source[token1.end..token2.start], '\n') == null; - } - - pub fn dump(self: *Tree) void { - self.root_node.base.dump(0); - } - - /// Skips over comments - pub fn prevToken(self: *Tree, token_index: TokenIndex) TokenIndex { - var index = token_index - 1; - while (self.token_ids[index] == Token.Id.LineComment) { - index -= 1; + // Many tokens can be determined entirely by their tag. + if (token_tag.lexeme()) |lexeme| { + return lexeme; } - return index; + + // For some tokens, re-tokenization is needed to find the end. + var tokenizer: std.zig.Tokenizer = .{ + .buffer = tree.source, + .index = token_starts[token_index], + .pending_invalid_token = null, + }; + const token = tokenizer.next(); + assert(token.tag == token_tag); + return tree.source[token.loc.start..token.loc.end]; } - /// Skips over comments - pub fn nextToken(self: *Tree, token_index: TokenIndex) TokenIndex { - var index = token_index + 1; - while (self.token_ids[index] == Token.Id.LineComment) { - index += 1; + pub fn extraData(tree: Tree, index: usize, comptime T: type) T { + const fields = std.meta.fields(T); + var result: T = undefined; + inline for (fields) |field, i| { + comptime assert(field.field_type == Node.Index); + @field(result, field.name) = tree.extra_data[index + i]; } - return index; + return result; + } + + pub fn rootDecls(tree: Tree) []const Node.Index { + // Root is always index 0. + const nodes_data = tree.nodes.items(.data); + return tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs]; + } + + pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void { + const token_tags = tree.tokens.items(.tag); + switch (parse_error.tag) { + .asterisk_after_ptr_deref => { + return stream.writeAll("'.*' cannot be followed by '*'. Are you missing a space?"); + }, + .decl_between_fields => { + return stream.writeAll("declarations are not allowed between container fields"); + }, + .expected_block => { + return stream.print("expected block or field, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_block_or_assignment => { + return stream.print("expected block or assignment, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_block_or_expr => { + return stream.print("expected block or expression, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_block_or_field => { + return stream.print("expected block or field, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_container_members => { + return stream.print("expected test, comptime, var decl, or container field, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_expr => { + return stream.print("expected expression, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_expr_or_assignment => { + return stream.print("expected expression or assignment, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_fn => { + return stream.print("expected function, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_inlinable => { + return stream.print("expected 'while' or 'for', found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_labelable => { + return stream.print("expected 'while', 'for', 'inline', 'suspend', or '{{', found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_param_list => { + return stream.print("expected parameter list, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_prefix_expr => { + return stream.print("expected prefix expression, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_primary_type_expr => { + return stream.print("expected primary type expression, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_pub_item => { + return stream.writeAll("expected function or variable declaration after pub"); + }, + .expected_return_type => { + return stream.print("expected return type expression, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_semi_or_else => { + return stream.print("expected ';' or 'else', found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_semi_or_lbrace => { + return stream.print("expected ';' or '{{', found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_statement => { + return stream.print("expected statement, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_string_literal => { + return stream.print("expected string literal, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_suffix_op => { + return stream.print("expected pointer dereference, optional unwrap, or field access, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_type_expr => { + return stream.print("expected type expression, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_var_decl => { + return stream.print("expected variable declaration, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_var_decl_or_fn => { + return stream.print("expected variable declaration or function, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_loop_payload => { + return stream.print("expected loop payload, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .expected_container => { + return stream.print("expected a struct, enum or union, found '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .extra_align_qualifier => { + return stream.writeAll("extra align qualifier"); + }, + .extra_allowzero_qualifier => { + return stream.writeAll("extra allowzero qualifier"); + }, + .extra_const_qualifier => { + return stream.writeAll("extra const qualifier"); + }, + .extra_volatile_qualifier => { + return stream.writeAll("extra volatile qualifier"); + }, + .invalid_align => { + return stream.writeAll("alignment not allowed on arrays"); + }, + .invalid_and => { + return stream.writeAll("`&&` is invalid; note that `and` is boolean AND"); + }, + .invalid_bit_range => { + return stream.writeAll("bit range not allowed on slices and arrays"); + }, + .invalid_token => { + return stream.print("invalid token '{s}'", .{ + token_tags[parse_error.token].symbol(), + }); + }, + .same_line_doc_comment => { + return stream.writeAll("same line documentation comment"); + }, + .unattached_doc_comment => { + return stream.writeAll("unattached documentation comment"); + }, + + .expected_token => { + const found_tag = token_tags[parse_error.token]; + const expected_symbol = parse_error.extra.expected_tag.symbol(); + switch (found_tag) { + .invalid => return stream.print("expected '{s}', found invalid bytes", .{ + expected_symbol, + }), + else => return stream.print("expected '{s}', found '{s}'", .{ + expected_symbol, found_tag.symbol(), + }), + } + }, + } + } + + pub fn firstToken(tree: Tree, node: Node.Index) TokenIndex { + const tags = tree.nodes.items(.tag); + const datas = tree.nodes.items(.data); + const main_tokens = tree.nodes.items(.main_token); + const token_tags = tree.tokens.items(.tag); + var end_offset: TokenIndex = 0; + var n = node; + while (true) switch (tags[n]) { + .root => return 0, + + .test_decl, + .@"errdefer", + .@"defer", + .bool_not, + .negation, + .bit_not, + .negation_wrap, + .address_of, + .@"try", + .@"await", + .optional_type, + .@"switch", + .switch_comma, + .if_simple, + .@"if", + .@"suspend", + .@"resume", + .@"continue", + .@"break", + .@"return", + .anyframe_type, + .identifier, + .anyframe_literal, + .char_literal, + .integer_literal, + .float_literal, + .false_literal, + .true_literal, + .null_literal, + .undefined_literal, + .unreachable_literal, + .string_literal, + .multiline_string_literal, + .grouped_expression, + .builtin_call_two, + .builtin_call_two_comma, + .builtin_call, + .builtin_call_comma, + .error_set_decl, + .@"anytype", + .@"comptime", + .@"nosuspend", + .asm_simple, + .@"asm", + .array_type, + .array_type_sentinel, + .error_value, + => return main_tokens[n] - end_offset, + + .array_init_dot, + .array_init_dot_comma, + .array_init_dot_two, + .array_init_dot_two_comma, + .struct_init_dot, + .struct_init_dot_comma, + .struct_init_dot_two, + .struct_init_dot_two_comma, + .enum_literal, + => return main_tokens[n] - 1 - end_offset, + + .@"catch", + .field_access, + .unwrap_optional, + .equal_equal, + .bang_equal, + .less_than, + .greater_than, + .less_or_equal, + .greater_or_equal, + .assign_mul, + .assign_div, + .assign_mod, + .assign_add, + .assign_sub, + .assign_bit_shift_left, + .assign_bit_shift_right, + .assign_bit_and, + .assign_bit_xor, + .assign_bit_or, + .assign_mul_wrap, + .assign_add_wrap, + .assign_sub_wrap, + .assign, + .merge_error_sets, + .mul, + .div, + .mod, + .array_mult, + .mul_wrap, + .add, + .sub, + .array_cat, + .add_wrap, + .sub_wrap, + .bit_shift_left, + .bit_shift_right, + .bit_and, + .bit_xor, + .bit_or, + .@"orelse", + .bool_and, + .bool_or, + .slice_open, + .slice, + .slice_sentinel, + .deref, + .array_access, + .array_init_one, + .array_init_one_comma, + .array_init, + .array_init_comma, + .struct_init_one, + .struct_init_one_comma, + .struct_init, + .struct_init_comma, + .call_one, + .call_one_comma, + .call, + .call_comma, + .switch_range, + .error_union, + => n = datas[n].lhs, + + .fn_decl, + .fn_proto_simple, + .fn_proto_multi, + .fn_proto_one, + .fn_proto, + => { + var i = main_tokens[n]; // fn token + while (i > 0) { + i -= 1; + switch (token_tags[i]) { + .keyword_extern, + .keyword_export, + .keyword_pub, + .keyword_threadlocal, + .string_literal, + => continue, + + else => return i + 1 - end_offset, + } + } + return i - end_offset; + }, + + .@"usingnamespace" => { + const main_token = main_tokens[n]; + if (main_token > 0 and token_tags[main_token - 1] == .keyword_pub) { + end_offset += 1; + } + return main_token - end_offset; + }, + + .async_call_one, + .async_call_one_comma, + .async_call, + .async_call_comma, + => { + end_offset += 1; // async token + n = datas[n].lhs; + }, + + .container_field_init, + .container_field_align, + .container_field, + => { + const name_token = main_tokens[n]; + if (name_token > 0 and token_tags[name_token - 1] == .keyword_comptime) { + end_offset += 1; + } + return name_token - end_offset; + }, + + .global_var_decl, + .local_var_decl, + .simple_var_decl, + .aligned_var_decl, + => { + var i = main_tokens[n]; // mut token + while (i > 0) { + i -= 1; + switch (token_tags[i]) { + .keyword_extern, + .keyword_export, + .keyword_comptime, + .keyword_pub, + .keyword_threadlocal, + .string_literal, + => continue, + + else => return i + 1 - end_offset, + } + } + return i - end_offset; + }, + + .block, + .block_semicolon, + .block_two, + .block_two_semicolon, + => { + // Look for a label. + const lbrace = main_tokens[n]; + if (token_tags[lbrace - 1] == .colon) { + end_offset += 2; + } + return lbrace - end_offset; + }, + + .container_decl, + .container_decl_trailing, + .container_decl_two, + .container_decl_two_trailing, + .container_decl_arg, + .container_decl_arg_trailing, + .tagged_union, + .tagged_union_trailing, + .tagged_union_two, + .tagged_union_two_trailing, + .tagged_union_enum_tag, + .tagged_union_enum_tag_trailing, + => { + const main_token = main_tokens[n]; + switch (token_tags[main_token - 1]) { + .keyword_packed, .keyword_extern => end_offset += 1, + else => {}, + } + return main_token - end_offset; + }, + + .ptr_type_aligned, + .ptr_type_sentinel, + .ptr_type, + .ptr_type_bit_range, + => { + const main_token = main_tokens[n]; + return switch (token_tags[main_token]) { + .asterisk, + .asterisk_asterisk, + => switch (token_tags[main_token - 1]) { + .l_bracket => main_token - 1, + else => main_token, + }, + .l_bracket => main_token, + else => unreachable, + } - end_offset; + }, + + .switch_case_one => { + if (datas[n].lhs == 0) { + return main_tokens[n] - 1 - end_offset; // else token + } else { + n = datas[n].lhs; + } + }, + .switch_case => { + const extra = tree.extraData(datas[n].lhs, Node.SubRange); + assert(extra.end - extra.start > 0); + n = tree.extra_data[extra.start]; + }, + + .asm_output, .asm_input => { + assert(token_tags[main_tokens[n] - 1] == .l_bracket); + return main_tokens[n] - 1 - end_offset; + }, + + .while_simple, + .while_cont, + .@"while", + .for_simple, + .@"for", + => { + // Look for a label and inline. + const main_token = main_tokens[n]; + var result = main_token; + if (token_tags[result - 1] == .keyword_inline) { + result -= 1; + } + if (token_tags[result - 1] == .colon) { + result -= 2; + } + return result - end_offset; + }, + }; + } + + pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex { + const tags = tree.nodes.items(.tag); + const datas = tree.nodes.items(.data); + const main_tokens = tree.nodes.items(.main_token); + const token_starts = tree.tokens.items(.start); + const token_tags = tree.tokens.items(.tag); + var n = node; + var end_offset: TokenIndex = 0; + while (true) switch (tags[n]) { + .root => return @intCast(TokenIndex, tree.tokens.len - 1), + + .@"usingnamespace", + .bool_not, + .negation, + .bit_not, + .negation_wrap, + .address_of, + .@"try", + .@"await", + .optional_type, + .@"resume", + .@"nosuspend", + .@"comptime", + => n = datas[n].lhs, + + .test_decl, + .@"errdefer", + .@"defer", + .@"catch", + .equal_equal, + .bang_equal, + .less_than, + .greater_than, + .less_or_equal, + .greater_or_equal, + .assign_mul, + .assign_div, + .assign_mod, + .assign_add, + .assign_sub, + .assign_bit_shift_left, + .assign_bit_shift_right, + .assign_bit_and, + .assign_bit_xor, + .assign_bit_or, + .assign_mul_wrap, + .assign_add_wrap, + .assign_sub_wrap, + .assign, + .merge_error_sets, + .mul, + .div, + .mod, + .array_mult, + .mul_wrap, + .add, + .sub, + .array_cat, + .add_wrap, + .sub_wrap, + .bit_shift_left, + .bit_shift_right, + .bit_and, + .bit_xor, + .bit_or, + .@"orelse", + .bool_and, + .bool_or, + .anyframe_type, + .error_union, + .if_simple, + .while_simple, + .for_simple, + .fn_proto_simple, + .fn_proto_multi, + .ptr_type_aligned, + .ptr_type_sentinel, + .ptr_type, + .ptr_type_bit_range, + .array_type, + .switch_case_one, + .switch_case, + .switch_range, + => n = datas[n].rhs, + + .field_access, + .unwrap_optional, + .grouped_expression, + .multiline_string_literal, + .error_set_decl, + .asm_simple, + .asm_output, + .asm_input, + .error_value, + => return datas[n].rhs + end_offset, + + .@"anytype", + .anyframe_literal, + .char_literal, + .integer_literal, + .float_literal, + .false_literal, + .true_literal, + .null_literal, + .undefined_literal, + .unreachable_literal, + .identifier, + .deref, + .enum_literal, + .string_literal, + => return main_tokens[n] + end_offset, + + .@"return" => if (datas[n].lhs != 0) { + n = datas[n].lhs; + } else { + return main_tokens[n] + end_offset; + }, + + .call, .async_call => { + end_offset += 1; // for the rparen + const params = tree.extraData(datas[n].rhs, Node.SubRange); + if (params.end - params.start == 0) { + return main_tokens[n] + end_offset; + } + n = tree.extra_data[params.end - 1]; // last parameter + }, + .tagged_union_enum_tag => { + const members = tree.extraData(datas[n].rhs, Node.SubRange); + if (members.end - members.start == 0) { + end_offset += 4; // for the rparen + rparen + lbrace + rbrace + n = datas[n].lhs; + } else { + end_offset += 1; // for the rbrace + n = tree.extra_data[members.end - 1]; // last parameter + } + }, + .call_comma, + .async_call_comma, + .tagged_union_enum_tag_trailing, + => { + end_offset += 2; // for the comma/semicolon + rparen/rbrace + const params = tree.extraData(datas[n].rhs, Node.SubRange); + assert(params.end > params.start); + n = tree.extra_data[params.end - 1]; // last parameter + }, + .@"switch" => { + const cases = tree.extraData(datas[n].rhs, Node.SubRange); + if (cases.end - cases.start == 0) { + end_offset += 3; // rparen, lbrace, rbrace + n = datas[n].lhs; // condition expression + } else { + end_offset += 1; // for the rbrace + n = tree.extra_data[cases.end - 1]; // last case + } + }, + .container_decl_arg => { + const members = tree.extraData(datas[n].rhs, Node.SubRange); + if (members.end - members.start == 0) { + end_offset += 1; // for the rparen + n = datas[n].lhs; + } else { + end_offset += 1; // for the rbrace + n = tree.extra_data[members.end - 1]; // last parameter + } + }, + .@"asm" => { + const extra = tree.extraData(datas[n].rhs, Node.Asm); + return extra.rparen + end_offset; + }, + .array_init, + .struct_init, + => { + const elements = tree.extraData(datas[n].rhs, Node.SubRange); + assert(elements.end - elements.start > 0); + end_offset += 1; // for the rbrace + n = tree.extra_data[elements.end - 1]; // last element + }, + .array_init_comma, + .struct_init_comma, + .container_decl_arg_trailing, + .switch_comma, + => { + const members = tree.extraData(datas[n].rhs, Node.SubRange); + assert(members.end - members.start > 0); + end_offset += 2; // for the comma + rbrace + n = tree.extra_data[members.end - 1]; // last parameter + }, + .array_init_dot, + .struct_init_dot, + .block, + .container_decl, + .tagged_union, + .builtin_call, + => { + assert(datas[n].rhs - datas[n].lhs > 0); + end_offset += 1; // for the rbrace + n = tree.extra_data[datas[n].rhs - 1]; // last statement + }, + .array_init_dot_comma, + .struct_init_dot_comma, + .block_semicolon, + .container_decl_trailing, + .tagged_union_trailing, + .builtin_call_comma, + => { + assert(datas[n].rhs - datas[n].lhs > 0); + end_offset += 2; // for the comma/semicolon + rbrace/rparen + n = tree.extra_data[datas[n].rhs - 1]; // last member + }, + .call_one, + .async_call_one, + .array_access, + => { + end_offset += 1; // for the rparen/rbracket + if (datas[n].rhs == 0) { + return main_tokens[n] + end_offset; + } + n = datas[n].rhs; + }, + .array_init_dot_two, + .block_two, + .builtin_call_two, + .struct_init_dot_two, + .container_decl_two, + .tagged_union_two, + => { + if (datas[n].rhs != 0) { + end_offset += 1; // for the rparen/rbrace + n = datas[n].rhs; + } else if (datas[n].lhs != 0) { + end_offset += 1; // for the rparen/rbrace + n = datas[n].lhs; + } else { + switch (tags[n]) { + .array_init_dot_two, + .block_two, + .struct_init_dot_two, + => end_offset += 1, // rbrace + .builtin_call_two => end_offset += 2, // lparen/lbrace + rparen/rbrace + .container_decl_two => { + var i: u32 = 2; // lbrace + rbrace + while (token_tags[main_tokens[n] + i] == .container_doc_comment) i += 1; + end_offset += i; + }, + .tagged_union_two => { + var i: u32 = 5; // (enum) {} + while (token_tags[main_tokens[n] + i] == .container_doc_comment) i += 1; + end_offset += i; + }, + else => unreachable, + } + return main_tokens[n] + end_offset; + } + }, + .array_init_dot_two_comma, + .builtin_call_two_comma, + .block_two_semicolon, + .struct_init_dot_two_comma, + .container_decl_two_trailing, + .tagged_union_two_trailing, + => { + end_offset += 2; // for the comma/semicolon + rbrace/rparen + if (datas[n].rhs != 0) { + n = datas[n].rhs; + } else if (datas[n].lhs != 0) { + n = datas[n].lhs; + } else { + unreachable; + } + }, + .simple_var_decl => { + if (datas[n].rhs != 0) { + n = datas[n].rhs; + } else if (datas[n].lhs != 0) { + n = datas[n].lhs; + } else { + end_offset += 1; // from mut token to name + return main_tokens[n] + end_offset; + } + }, + .aligned_var_decl => { + if (datas[n].rhs != 0) { + n = datas[n].rhs; + } else if (datas[n].lhs != 0) { + end_offset += 1; // for the rparen + n = datas[n].lhs; + } else { + end_offset += 1; // from mut token to name + return main_tokens[n] + end_offset; + } + }, + .global_var_decl => { + if (datas[n].rhs != 0) { + n = datas[n].rhs; + } else { + const extra = tree.extraData(datas[n].lhs, Node.GlobalVarDecl); + if (extra.section_node != 0) { + end_offset += 1; // for the rparen + n = extra.section_node; + } else if (extra.align_node != 0) { + end_offset += 1; // for the rparen + n = extra.align_node; + } else if (extra.type_node != 0) { + n = extra.type_node; + } else { + end_offset += 1; // from mut token to name + return main_tokens[n] + end_offset; + } + } + }, + .local_var_decl => { + if (datas[n].rhs != 0) { + n = datas[n].rhs; + } else { + const extra = tree.extraData(datas[n].lhs, Node.LocalVarDecl); + if (extra.align_node != 0) { + end_offset += 1; // for the rparen + n = extra.align_node; + } else if (extra.type_node != 0) { + n = extra.type_node; + } else { + end_offset += 1; // from mut token to name + return main_tokens[n] + end_offset; + } + } + }, + .container_field_init => { + if (datas[n].rhs != 0) { + n = datas[n].rhs; + } else if (datas[n].lhs != 0) { + n = datas[n].lhs; + } else { + return main_tokens[n] + end_offset; + } + }, + .container_field_align => { + if (datas[n].rhs != 0) { + end_offset += 1; // for the rparen + n = datas[n].rhs; + } else if (datas[n].lhs != 0) { + n = datas[n].lhs; + } else { + return main_tokens[n] + end_offset; + } + }, + .container_field => { + const extra = tree.extraData(datas[n].rhs, Node.ContainerField); + if (extra.value_expr != 0) { + n = extra.value_expr; + } else if (extra.align_expr != 0) { + end_offset += 1; // for the rparen + n = extra.align_expr; + } else if (datas[n].lhs != 0) { + n = datas[n].lhs; + } else { + return main_tokens[n] + end_offset; + } + }, + + .array_init_one, + .struct_init_one, + => { + end_offset += 1; // rbrace + if (datas[n].rhs == 0) { + return main_tokens[n] + end_offset; + } else { + n = datas[n].rhs; + } + }, + .slice_open, + .call_one_comma, + .async_call_one_comma, + .array_init_one_comma, + .struct_init_one_comma, + => { + end_offset += 2; // ellipsis2 + rbracket, or comma + rparen + n = datas[n].rhs; + assert(n != 0); + }, + .slice => { + const extra = tree.extraData(datas[n].rhs, Node.Slice); + assert(extra.end != 0); // should have used SliceOpen + end_offset += 1; // rbracket + n = extra.end; + }, + .slice_sentinel => { + const extra = tree.extraData(datas[n].rhs, Node.SliceSentinel); + assert(extra.sentinel != 0); // should have used Slice + end_offset += 1; // rbracket + n = extra.sentinel; + }, + + .@"continue" => { + if (datas[n].lhs != 0) { + return datas[n].lhs + end_offset; + } else { + return main_tokens[n] + end_offset; + } + }, + .@"break" => { + if (datas[n].rhs != 0) { + n = datas[n].rhs; + } else if (datas[n].lhs != 0) { + return datas[n].lhs + end_offset; + } else { + return main_tokens[n] + end_offset; + } + }, + .fn_decl => { + if (datas[n].rhs != 0) { + n = datas[n].rhs; + } else { + n = datas[n].lhs; + } + }, + .fn_proto_one => { + const extra = tree.extraData(datas[n].lhs, Node.FnProtoOne); + // linksection, callconv, align can appear in any order, so we + // find the last one here. + var max_node: Node.Index = datas[n].rhs; + var max_start = token_starts[main_tokens[max_node]]; + var max_offset: TokenIndex = 0; + if (extra.align_expr != 0) { + const start = token_starts[main_tokens[extra.align_expr]]; + if (start > max_start) { + max_node = extra.align_expr; + max_start = start; + max_offset = 1; // for the rparen + } + } + if (extra.section_expr != 0) { + const start = token_starts[main_tokens[extra.section_expr]]; + if (start > max_start) { + max_node = extra.section_expr; + max_start = start; + max_offset = 1; // for the rparen + } + } + if (extra.callconv_expr != 0) { + const start = token_starts[main_tokens[extra.callconv_expr]]; + if (start > max_start) { + max_node = extra.callconv_expr; + max_start = start; + max_offset = 1; // for the rparen + } + } + n = max_node; + end_offset += max_offset; + }, + .fn_proto => { + const extra = tree.extraData(datas[n].lhs, Node.FnProto); + // linksection, callconv, align can appear in any order, so we + // find the last one here. + var max_node: Node.Index = datas[n].rhs; + var max_start = token_starts[main_tokens[max_node]]; + var max_offset: TokenIndex = 0; + if (extra.align_expr != 0) { + const start = token_starts[main_tokens[extra.align_expr]]; + if (start > max_start) { + max_node = extra.align_expr; + max_start = start; + max_offset = 1; // for the rparen + } + } + if (extra.section_expr != 0) { + const start = token_starts[main_tokens[extra.section_expr]]; + if (start > max_start) { + max_node = extra.section_expr; + max_start = start; + max_offset = 1; // for the rparen + } + } + if (extra.callconv_expr != 0) { + const start = token_starts[main_tokens[extra.callconv_expr]]; + if (start > max_start) { + max_node = extra.callconv_expr; + max_start = start; + max_offset = 1; // for the rparen + } + } + n = max_node; + end_offset += max_offset; + }, + .while_cont => { + const extra = tree.extraData(datas[n].rhs, Node.WhileCont); + assert(extra.then_expr != 0); + n = extra.then_expr; + }, + .@"while" => { + const extra = tree.extraData(datas[n].rhs, Node.While); + assert(extra.else_expr != 0); + n = extra.else_expr; + }, + .@"if", .@"for" => { + const extra = tree.extraData(datas[n].rhs, Node.If); + assert(extra.else_expr != 0); + n = extra.else_expr; + }, + .@"suspend" => { + if (datas[n].lhs != 0) { + n = datas[n].lhs; + } else { + return main_tokens[n] + end_offset; + } + }, + .array_type_sentinel => { + const extra = tree.extraData(datas[n].rhs, Node.ArrayTypeSentinel); + n = extra.elem_type; + }, + }; + } + + pub fn tokensOnSameLine(tree: Tree, token1: TokenIndex, token2: TokenIndex) bool { + const token_starts = tree.tokens.items(.start); + const source = tree.source[token_starts[token1]..token_starts[token2]]; + return mem.indexOfScalar(u8, source, '\n') == null; + } + + pub fn getNodeSource(tree: Tree, node: Node.Index) []const u8 { + const token_starts = tree.tokens.items(.start); + const first_token = tree.firstToken(node); + const last_token = tree.lastToken(node); + const start = token_starts[first_token]; + const end = token_starts[last_token] + tree.tokenSlice(last_token).len; + return tree.source[start..end]; + } + + pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl { + assert(tree.nodes.items(.tag)[node] == .global_var_decl); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.lhs, Node.GlobalVarDecl); + return tree.fullVarDecl(.{ + .type_node = extra.type_node, + .align_node = extra.align_node, + .section_node = extra.section_node, + .init_node = data.rhs, + .mut_token = tree.nodes.items(.main_token)[node], + }); + } + + pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl { + assert(tree.nodes.items(.tag)[node] == .local_var_decl); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.lhs, Node.LocalVarDecl); + return tree.fullVarDecl(.{ + .type_node = extra.type_node, + .align_node = extra.align_node, + .section_node = 0, + .init_node = data.rhs, + .mut_token = tree.nodes.items(.main_token)[node], + }); + } + + pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl { + assert(tree.nodes.items(.tag)[node] == .simple_var_decl); + const data = tree.nodes.items(.data)[node]; + return tree.fullVarDecl(.{ + .type_node = data.lhs, + .align_node = 0, + .section_node = 0, + .init_node = data.rhs, + .mut_token = tree.nodes.items(.main_token)[node], + }); + } + + pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl { + assert(tree.nodes.items(.tag)[node] == .aligned_var_decl); + const data = tree.nodes.items(.data)[node]; + return tree.fullVarDecl(.{ + .type_node = 0, + .align_node = data.lhs, + .section_node = 0, + .init_node = data.rhs, + .mut_token = tree.nodes.items(.main_token)[node], + }); + } + + pub fn ifSimple(tree: Tree, node: Node.Index) full.If { + assert(tree.nodes.items(.tag)[node] == .if_simple); + const data = tree.nodes.items(.data)[node]; + return tree.fullIf(.{ + .cond_expr = data.lhs, + .then_expr = data.rhs, + .else_expr = 0, + .if_token = tree.nodes.items(.main_token)[node], + }); + } + + pub fn ifFull(tree: Tree, node: Node.Index) full.If { + assert(tree.nodes.items(.tag)[node] == .@"if"); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.If); + return tree.fullIf(.{ + .cond_expr = data.lhs, + .then_expr = extra.then_expr, + .else_expr = extra.else_expr, + .if_token = tree.nodes.items(.main_token)[node], + }); + } + + pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField { + assert(tree.nodes.items(.tag)[node] == .container_field); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.ContainerField); + return tree.fullContainerField(.{ + .name_token = tree.nodes.items(.main_token)[node], + .type_expr = data.lhs, + .value_expr = extra.value_expr, + .align_expr = extra.align_expr, + }); + } + + pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField { + assert(tree.nodes.items(.tag)[node] == .container_field_init); + const data = tree.nodes.items(.data)[node]; + return tree.fullContainerField(.{ + .name_token = tree.nodes.items(.main_token)[node], + .type_expr = data.lhs, + .value_expr = data.rhs, + .align_expr = 0, + }); + } + + pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField { + assert(tree.nodes.items(.tag)[node] == .container_field_align); + const data = tree.nodes.items(.data)[node]; + return tree.fullContainerField(.{ + .name_token = tree.nodes.items(.main_token)[node], + .type_expr = data.lhs, + .value_expr = 0, + .align_expr = data.rhs, + }); + } + + pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { + assert(tree.nodes.items(.tag)[node] == .fn_proto_simple); + const data = tree.nodes.items(.data)[node]; + buffer[0] = data.lhs; + const params = if (data.lhs == 0) buffer[0..0] else buffer[0..1]; + return tree.fullFnProto(.{ + .fn_token = tree.nodes.items(.main_token)[node], + .return_type = data.rhs, + .params = params, + .align_expr = 0, + .section_expr = 0, + .callconv_expr = 0, + }); + } + + pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto { + assert(tree.nodes.items(.tag)[node] == .fn_proto_multi); + const data = tree.nodes.items(.data)[node]; + const params_range = tree.extraData(data.lhs, Node.SubRange); + const params = tree.extra_data[params_range.start..params_range.end]; + return tree.fullFnProto(.{ + .fn_token = tree.nodes.items(.main_token)[node], + .return_type = data.rhs, + .params = params, + .align_expr = 0, + .section_expr = 0, + .callconv_expr = 0, + }); + } + + pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { + assert(tree.nodes.items(.tag)[node] == .fn_proto_one); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.lhs, Node.FnProtoOne); + buffer[0] = extra.param; + const params = if (extra.param == 0) buffer[0..0] else buffer[0..1]; + return tree.fullFnProto(.{ + .fn_token = tree.nodes.items(.main_token)[node], + .return_type = data.rhs, + .params = params, + .align_expr = extra.align_expr, + .section_expr = extra.section_expr, + .callconv_expr = extra.callconv_expr, + }); + } + + pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto { + assert(tree.nodes.items(.tag)[node] == .fn_proto); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.lhs, Node.FnProto); + const params = tree.extra_data[extra.params_start..extra.params_end]; + return tree.fullFnProto(.{ + .fn_token = tree.nodes.items(.main_token)[node], + .return_type = data.rhs, + .params = params, + .align_expr = extra.align_expr, + .section_expr = extra.section_expr, + .callconv_expr = extra.callconv_expr, + }); + } + + pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.StructInit { + assert(tree.nodes.items(.tag)[node] == .struct_init_one or + tree.nodes.items(.tag)[node] == .struct_init_one_comma); + const data = tree.nodes.items(.data)[node]; + buffer[0] = data.rhs; + const fields = if (data.rhs == 0) buffer[0..0] else buffer[0..1]; + return tree.fullStructInit(.{ + .lbrace = tree.nodes.items(.main_token)[node], + .fields = fields, + .type_expr = data.lhs, + }); + } + + pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.StructInit { + assert(tree.nodes.items(.tag)[node] == .struct_init_dot_two or + tree.nodes.items(.tag)[node] == .struct_init_dot_two_comma); + const data = tree.nodes.items(.data)[node]; + buffer.* = .{ data.lhs, data.rhs }; + const fields = if (data.rhs != 0) + buffer[0..2] + else if (data.lhs != 0) + buffer[0..1] + else + buffer[0..0]; + return tree.fullStructInit(.{ + .lbrace = tree.nodes.items(.main_token)[node], + .fields = fields, + .type_expr = 0, + }); + } + + pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit { + assert(tree.nodes.items(.tag)[node] == .struct_init_dot or + tree.nodes.items(.tag)[node] == .struct_init_dot_comma); + const data = tree.nodes.items(.data)[node]; + return tree.fullStructInit(.{ + .lbrace = tree.nodes.items(.main_token)[node], + .fields = tree.extra_data[data.lhs..data.rhs], + .type_expr = 0, + }); + } + + pub fn structInit(tree: Tree, node: Node.Index) full.StructInit { + assert(tree.nodes.items(.tag)[node] == .struct_init or + tree.nodes.items(.tag)[node] == .struct_init_comma); + const data = tree.nodes.items(.data)[node]; + const fields_range = tree.extraData(data.rhs, Node.SubRange); + return tree.fullStructInit(.{ + .lbrace = tree.nodes.items(.main_token)[node], + .fields = tree.extra_data[fields_range.start..fields_range.end], + .type_expr = data.lhs, + }); + } + + pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit { + assert(tree.nodes.items(.tag)[node] == .array_init_one or + tree.nodes.items(.tag)[node] == .array_init_one_comma); + const data = tree.nodes.items(.data)[node]; + buffer[0] = data.rhs; + const elements = if (data.rhs == 0) buffer[0..0] else buffer[0..1]; + return .{ + .ast = .{ + .lbrace = tree.nodes.items(.main_token)[node], + .elements = elements, + .type_expr = data.lhs, + }, + }; + } + + pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit { + assert(tree.nodes.items(.tag)[node] == .array_init_dot_two or + tree.nodes.items(.tag)[node] == .array_init_dot_two_comma); + const data = tree.nodes.items(.data)[node]; + buffer.* = .{ data.lhs, data.rhs }; + const elements = if (data.rhs != 0) + buffer[0..2] + else if (data.lhs != 0) + buffer[0..1] + else + buffer[0..0]; + return .{ + .ast = .{ + .lbrace = tree.nodes.items(.main_token)[node], + .elements = elements, + .type_expr = 0, + }, + }; + } + + pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit { + assert(tree.nodes.items(.tag)[node] == .array_init_dot or + tree.nodes.items(.tag)[node] == .array_init_dot_comma); + const data = tree.nodes.items(.data)[node]; + return .{ + .ast = .{ + .lbrace = tree.nodes.items(.main_token)[node], + .elements = tree.extra_data[data.lhs..data.rhs], + .type_expr = 0, + }, + }; + } + + pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit { + assert(tree.nodes.items(.tag)[node] == .array_init or + tree.nodes.items(.tag)[node] == .array_init_comma); + const data = tree.nodes.items(.data)[node]; + const elem_range = tree.extraData(data.rhs, Node.SubRange); + return .{ + .ast = .{ + .lbrace = tree.nodes.items(.main_token)[node], + .elements = tree.extra_data[elem_range.start..elem_range.end], + .type_expr = data.lhs, + }, + }; + } + + pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType { + assert(tree.nodes.items(.tag)[node] == .array_type); + const data = tree.nodes.items(.data)[node]; + return .{ + .ast = .{ + .lbracket = tree.nodes.items(.main_token)[node], + .elem_count = data.lhs, + .sentinel = null, + .elem_type = data.rhs, + }, + }; + } + + pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType { + assert(tree.nodes.items(.tag)[node] == .array_type_sentinel); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.ArrayTypeSentinel); + return .{ + .ast = .{ + .lbracket = tree.nodes.items(.main_token)[node], + .elem_count = data.lhs, + .sentinel = extra.sentinel, + .elem_type = extra.elem_type, + }, + }; + } + + pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType { + assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned); + const data = tree.nodes.items(.data)[node]; + return tree.fullPtrType(.{ + .main_token = tree.nodes.items(.main_token)[node], + .align_node = data.lhs, + .sentinel = 0, + .bit_range_start = 0, + .bit_range_end = 0, + .child_type = data.rhs, + }); + } + + pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType { + assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel); + const data = tree.nodes.items(.data)[node]; + return tree.fullPtrType(.{ + .main_token = tree.nodes.items(.main_token)[node], + .align_node = 0, + .sentinel = data.lhs, + .bit_range_start = 0, + .bit_range_end = 0, + .child_type = data.rhs, + }); + } + + pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType { + assert(tree.nodes.items(.tag)[node] == .ptr_type); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.lhs, Node.PtrType); + return tree.fullPtrType(.{ + .main_token = tree.nodes.items(.main_token)[node], + .align_node = extra.align_node, + .sentinel = extra.sentinel, + .bit_range_start = 0, + .bit_range_end = 0, + .child_type = data.rhs, + }); + } + + pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType { + assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange); + return tree.fullPtrType(.{ + .main_token = tree.nodes.items(.main_token)[node], + .align_node = extra.align_node, + .sentinel = extra.sentinel, + .bit_range_start = extra.bit_range_start, + .bit_range_end = extra.bit_range_end, + .child_type = data.rhs, + }); + } + + pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice { + assert(tree.nodes.items(.tag)[node] == .slice_open); + const data = tree.nodes.items(.data)[node]; + return .{ + .ast = .{ + .sliced = data.lhs, + .lbracket = tree.nodes.items(.main_token)[node], + .start = data.rhs, + .end = 0, + .sentinel = 0, + }, + }; + } + + pub fn slice(tree: Tree, node: Node.Index) full.Slice { + assert(tree.nodes.items(.tag)[node] == .slice); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.Slice); + return .{ + .ast = .{ + .sliced = data.lhs, + .lbracket = tree.nodes.items(.main_token)[node], + .start = extra.start, + .end = extra.end, + .sentinel = 0, + }, + }; + } + + pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice { + assert(tree.nodes.items(.tag)[node] == .slice_sentinel); + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.SliceSentinel); + return .{ + .ast = .{ + .sliced = data.lhs, + .lbracket = tree.nodes.items(.main_token)[node], + .start = extra.start, + .end = extra.end, + .sentinel = extra.sentinel, + }, + }; + } + + pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { + assert(tree.nodes.items(.tag)[node] == .container_decl_two or + tree.nodes.items(.tag)[node] == .container_decl_two_trailing); + const data = tree.nodes.items(.data)[node]; + buffer.* = .{ data.lhs, data.rhs }; + const members = if (data.rhs != 0) + buffer[0..2] + else if (data.lhs != 0) + buffer[0..1] + else + buffer[0..0]; + return tree.fullContainerDecl(.{ + .main_token = tree.nodes.items(.main_token)[node], + .enum_token = null, + .members = members, + .arg = 0, + }); + } + + pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl { + assert(tree.nodes.items(.tag)[node] == .container_decl or + tree.nodes.items(.tag)[node] == .container_decl_trailing); + const data = tree.nodes.items(.data)[node]; + return tree.fullContainerDecl(.{ + .main_token = tree.nodes.items(.main_token)[node], + .enum_token = null, + .members = tree.extra_data[data.lhs..data.rhs], + .arg = 0, + }); + } + + pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl { + assert(tree.nodes.items(.tag)[node] == .container_decl_arg or + tree.nodes.items(.tag)[node] == .container_decl_arg_trailing); + const data = tree.nodes.items(.data)[node]; + const members_range = tree.extraData(data.rhs, Node.SubRange); + return tree.fullContainerDecl(.{ + .main_token = tree.nodes.items(.main_token)[node], + .enum_token = null, + .members = tree.extra_data[members_range.start..members_range.end], + .arg = data.lhs, + }); + } + + pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { + assert(tree.nodes.items(.tag)[node] == .tagged_union_two or + tree.nodes.items(.tag)[node] == .tagged_union_two_trailing); + const data = tree.nodes.items(.data)[node]; + buffer.* = .{ data.lhs, data.rhs }; + const members = if (data.rhs != 0) + buffer[0..2] + else if (data.lhs != 0) + buffer[0..1] + else + buffer[0..0]; + const main_token = tree.nodes.items(.main_token)[node]; + return tree.fullContainerDecl(.{ + .main_token = main_token, + .enum_token = main_token + 2, // union lparen enum + .members = members, + .arg = 0, + }); + } + + pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl { + assert(tree.nodes.items(.tag)[node] == .tagged_union or + tree.nodes.items(.tag)[node] == .tagged_union_trailing); + const data = tree.nodes.items(.data)[node]; + const main_token = tree.nodes.items(.main_token)[node]; + return tree.fullContainerDecl(.{ + .main_token = main_token, + .enum_token = main_token + 2, // union lparen enum + .members = tree.extra_data[data.lhs..data.rhs], + .arg = 0, + }); + } + + pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl { + assert(tree.nodes.items(.tag)[node] == .tagged_union_enum_tag or + tree.nodes.items(.tag)[node] == .tagged_union_enum_tag_trailing); + const data = tree.nodes.items(.data)[node]; + const members_range = tree.extraData(data.rhs, Node.SubRange); + const main_token = tree.nodes.items(.main_token)[node]; + return tree.fullContainerDecl(.{ + .main_token = main_token, + .enum_token = main_token + 2, // union lparen enum + .members = tree.extra_data[members_range.start..members_range.end], + .arg = data.lhs, + }); + } + + pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase { + const data = &tree.nodes.items(.data)[node]; + const values: *[1]Node.Index = &data.lhs; + return tree.fullSwitchCase(.{ + .values = if (data.lhs == 0) values[0..0] else values[0..1], + .arrow_token = tree.nodes.items(.main_token)[node], + .target_expr = data.rhs, + }); + } + + pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase { + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.lhs, Node.SubRange); + return tree.fullSwitchCase(.{ + .values = tree.extra_data[extra.start..extra.end], + .arrow_token = tree.nodes.items(.main_token)[node], + .target_expr = data.rhs, + }); + } + + pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm { + const data = tree.nodes.items(.data)[node]; + return tree.fullAsm(.{ + .asm_token = tree.nodes.items(.main_token)[node], + .template = data.lhs, + .items = &.{}, + .rparen = data.rhs, + }); + } + + pub fn asmFull(tree: Tree, node: Node.Index) full.Asm { + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.Asm); + return tree.fullAsm(.{ + .asm_token = tree.nodes.items(.main_token)[node], + .template = data.lhs, + .items = tree.extra_data[extra.items_start..extra.items_end], + .rparen = extra.rparen, + }); + } + + pub fn whileSimple(tree: Tree, node: Node.Index) full.While { + const data = tree.nodes.items(.data)[node]; + return tree.fullWhile(.{ + .while_token = tree.nodes.items(.main_token)[node], + .cond_expr = data.lhs, + .cont_expr = 0, + .then_expr = data.rhs, + .else_expr = 0, + }); + } + + pub fn whileCont(tree: Tree, node: Node.Index) full.While { + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.WhileCont); + return tree.fullWhile(.{ + .while_token = tree.nodes.items(.main_token)[node], + .cond_expr = data.lhs, + .cont_expr = extra.cont_expr, + .then_expr = extra.then_expr, + .else_expr = 0, + }); + } + + pub fn whileFull(tree: Tree, node: Node.Index) full.While { + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.While); + return tree.fullWhile(.{ + .while_token = tree.nodes.items(.main_token)[node], + .cond_expr = data.lhs, + .cont_expr = extra.cont_expr, + .then_expr = extra.then_expr, + .else_expr = extra.else_expr, + }); + } + + pub fn forSimple(tree: Tree, node: Node.Index) full.While { + const data = tree.nodes.items(.data)[node]; + return tree.fullWhile(.{ + .while_token = tree.nodes.items(.main_token)[node], + .cond_expr = data.lhs, + .cont_expr = 0, + .then_expr = data.rhs, + .else_expr = 0, + }); + } + + pub fn forFull(tree: Tree, node: Node.Index) full.While { + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.If); + return tree.fullWhile(.{ + .while_token = tree.nodes.items(.main_token)[node], + .cond_expr = data.lhs, + .cont_expr = 0, + .then_expr = extra.then_expr, + .else_expr = extra.else_expr, + }); + } + + pub fn callOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.Call { + const data = tree.nodes.items(.data)[node]; + buffer.* = .{data.rhs}; + const params = if (data.rhs != 0) buffer[0..1] else buffer[0..0]; + return tree.fullCall(.{ + .lparen = tree.nodes.items(.main_token)[node], + .fn_expr = data.lhs, + .params = params, + }); + } + + pub fn callFull(tree: Tree, node: Node.Index) full.Call { + const data = tree.nodes.items(.data)[node]; + const extra = tree.extraData(data.rhs, Node.SubRange); + return tree.fullCall(.{ + .lparen = tree.nodes.items(.main_token)[node], + .fn_expr = data.lhs, + .params = tree.extra_data[extra.start..extra.end], + }); + } + + fn fullVarDecl(tree: Tree, info: full.VarDecl.Ast) full.VarDecl { + const token_tags = tree.tokens.items(.tag); + var result: full.VarDecl = .{ + .ast = info, + .visib_token = null, + .extern_export_token = null, + .lib_name = null, + .threadlocal_token = null, + .comptime_token = null, + }; + var i = info.mut_token; + while (i > 0) { + i -= 1; + switch (token_tags[i]) { + .keyword_extern, .keyword_export => result.extern_export_token = i, + .keyword_comptime => result.comptime_token = i, + .keyword_pub => result.visib_token = i, + .keyword_threadlocal => result.threadlocal_token = i, + .string_literal => result.lib_name = i, + else => break, + } + } + return result; + } + + fn fullIf(tree: Tree, info: full.If.Ast) full.If { + const token_tags = tree.tokens.items(.tag); + var result: full.If = .{ + .ast = info, + .payload_token = null, + .error_token = null, + .else_token = undefined, + }; + // if (cond_expr) |x| + // ^ ^ + const payload_pipe = tree.lastToken(info.cond_expr) + 2; + if (token_tags[payload_pipe] == .pipe) { + result.payload_token = payload_pipe + 1; + } + if (info.else_expr != 0) { + // then_expr else |x| + // ^ ^ + result.else_token = tree.lastToken(info.then_expr) + 1; + if (token_tags[result.else_token + 1] == .pipe) { + result.error_token = result.else_token + 2; + } + } + return result; + } + + fn fullContainerField(tree: Tree, info: full.ContainerField.Ast) full.ContainerField { + const token_tags = tree.tokens.items(.tag); + var result: full.ContainerField = .{ + .ast = info, + .comptime_token = null, + }; + // comptime name: type = init, + // ^ + if (info.name_token > 0 and token_tags[info.name_token - 1] == .keyword_comptime) { + result.comptime_token = info.name_token - 1; + } + return result; + } + + fn fullFnProto(tree: Tree, info: full.FnProto.Ast) full.FnProto { + const token_tags = tree.tokens.items(.tag); + var result: full.FnProto = .{ + .ast = info, + .visib_token = null, + .extern_export_token = null, + .lib_name = null, + .name_token = null, + .lparen = undefined, + }; + var i = info.fn_token; + while (i > 0) { + i -= 1; + switch (token_tags[i]) { + .keyword_extern, .keyword_export => result.extern_export_token = i, + .keyword_pub => result.visib_token = i, + .string_literal => result.lib_name = i, + else => break, + } + } + const after_fn_token = info.fn_token + 1; + if (token_tags[after_fn_token] == .identifier) { + result.name_token = after_fn_token; + result.lparen = after_fn_token + 1; + } else { + result.lparen = after_fn_token; + } + assert(token_tags[result.lparen] == .l_paren); + + return result; + } + + fn fullStructInit(tree: Tree, info: full.StructInit.Ast) full.StructInit { + const token_tags = tree.tokens.items(.tag); + var result: full.StructInit = .{ + .ast = info, + }; + return result; + } + + fn fullPtrType(tree: Tree, info: full.PtrType.Ast) full.PtrType { + const token_tags = tree.tokens.items(.tag); + // TODO: looks like stage1 isn't quite smart enough to handle enum + // literals in some places here + const Size = std.builtin.TypeInfo.Pointer.Size; + const size: Size = switch (token_tags[info.main_token]) { + .asterisk, + .asterisk_asterisk, + => switch (token_tags[info.main_token + 1]) { + .r_bracket, .colon => .Many, + .identifier => if (token_tags[info.main_token - 1] == .l_bracket) Size.C else .One, + else => .One, + }, + .l_bracket => Size.Slice, + else => unreachable, + }; + var result: full.PtrType = .{ + .size = size, + .allowzero_token = null, + .const_token = null, + .volatile_token = null, + .ast = info, + }; + // We need to be careful that we don't iterate over any sub-expressions + // here while looking for modifiers as that could result in false + // positives. Therefore, start after a sentinel if there is one and + // skip over any align node and bit range nodes. + var i = if (info.sentinel != 0) tree.lastToken(info.sentinel) + 1 else info.main_token; + const end = tree.firstToken(info.child_type); + while (i < end) : (i += 1) { + switch (token_tags[i]) { + .keyword_allowzero => result.allowzero_token = i, + .keyword_const => result.const_token = i, + .keyword_volatile => result.volatile_token = i, + .keyword_align => { + assert(info.align_node != 0); + if (info.bit_range_end != 0) { + assert(info.bit_range_start != 0); + i = tree.lastToken(info.bit_range_end) + 1; + } else { + i = tree.lastToken(info.align_node) + 1; + } + }, + else => {}, + } + } + return result; + } + + fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Ast) full.ContainerDecl { + const token_tags = tree.tokens.items(.tag); + var result: full.ContainerDecl = .{ + .ast = info, + .layout_token = null, + }; + switch (token_tags[info.main_token - 1]) { + .keyword_extern, .keyword_packed => result.layout_token = info.main_token - 1, + else => {}, + } + return result; + } + + fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Ast) full.SwitchCase { + const token_tags = tree.tokens.items(.tag); + var result: full.SwitchCase = .{ + .ast = info, + .payload_token = null, + }; + if (token_tags[info.arrow_token + 1] == .pipe) { + result.payload_token = info.arrow_token + 2; + } + return result; + } + + fn fullAsm(tree: Tree, info: full.Asm.Ast) full.Asm { + const token_tags = tree.tokens.items(.tag); + const node_tags = tree.nodes.items(.tag); + var result: full.Asm = .{ + .ast = info, + .volatile_token = null, + .inputs = &.{}, + .outputs = &.{}, + .first_clobber = null, + }; + if (token_tags[info.asm_token + 1] == .keyword_volatile) { + result.volatile_token = info.asm_token + 1; + } + const outputs_end: usize = for (info.items) |item, i| { + switch (node_tags[item]) { + .asm_output => continue, + else => break i, + } + } else info.items.len; + + result.outputs = info.items[0..outputs_end]; + result.inputs = info.items[outputs_end..]; + + if (info.items.len == 0) { + // asm ("foo" ::: "a", "b"); + const template_token = tree.lastToken(info.template); + if (token_tags[template_token + 1] == .colon and + token_tags[template_token + 2] == .colon and + token_tags[template_token + 3] == .colon and + token_tags[template_token + 4] == .string_literal) + { + result.first_clobber = template_token + 4; + } + } else if (result.inputs.len != 0) { + // asm ("foo" :: [_] "" (y) : "a", "b"); + const last_input = result.inputs[result.inputs.len - 1]; + const rparen = tree.lastToken(last_input); + if (token_tags[rparen + 1] == .colon and + token_tags[rparen + 2] == .string_literal) + { + result.first_clobber = rparen + 2; + } + } else { + // asm ("foo" : [_] "" (x) :: "a", "b"); + const last_output = result.outputs[result.outputs.len - 1]; + const rparen = tree.lastToken(last_output); + if (token_tags[rparen + 1] == .colon and + token_tags[rparen + 2] == .colon and + token_tags[rparen + 3] == .string_literal) + { + result.first_clobber = rparen + 3; + } + } + + return result; + } + + fn fullWhile(tree: Tree, info: full.While.Ast) full.While { + const token_tags = tree.tokens.items(.tag); + var result: full.While = .{ + .ast = info, + .inline_token = null, + .label_token = null, + .payload_token = null, + .else_token = undefined, + .error_token = null, + }; + var tok_i = info.while_token - 1; + if (token_tags[tok_i] == .keyword_inline) { + result.inline_token = tok_i; + tok_i -= 1; + } + if (token_tags[tok_i] == .colon and + token_tags[tok_i - 1] == .identifier) + { + result.label_token = tok_i - 1; + } + const last_cond_token = tree.lastToken(info.cond_expr); + if (token_tags[last_cond_token + 2] == .pipe) { + result.payload_token = last_cond_token + 3; + } + if (info.else_expr != 0) { + // then_expr else |x| + // ^ ^ + result.else_token = tree.lastToken(info.then_expr) + 1; + if (token_tags[result.else_token + 1] == .pipe) { + result.error_token = result.else_token + 2; + } + } + return result; + } + + fn fullCall(tree: Tree, info: full.Call.Ast) full.Call { + const token_tags = tree.tokens.items(.tag); + var result: full.Call = .{ + .ast = info, + .async_token = null, + }; + const maybe_async_token = tree.firstToken(info.fn_expr) - 1; + if (token_tags[maybe_async_token] == .keyword_async) { + result.async_token = maybe_async_token; + } + return result; } }; -pub const Error = union(enum) { - InvalidToken: InvalidToken, - ExpectedContainerMembers: ExpectedContainerMembers, - ExpectedStringLiteral: ExpectedStringLiteral, - ExpectedIntegerLiteral: ExpectedIntegerLiteral, - ExpectedPubItem: ExpectedPubItem, - ExpectedIdentifier: ExpectedIdentifier, - ExpectedStatement: ExpectedStatement, - ExpectedVarDeclOrFn: ExpectedVarDeclOrFn, - ExpectedVarDecl: ExpectedVarDecl, - ExpectedFn: ExpectedFn, - ExpectedReturnType: ExpectedReturnType, - ExpectedAggregateKw: ExpectedAggregateKw, - UnattachedDocComment: UnattachedDocComment, - ExpectedEqOrSemi: ExpectedEqOrSemi, - ExpectedSemiOrLBrace: ExpectedSemiOrLBrace, - ExpectedSemiOrElse: ExpectedSemiOrElse, - ExpectedLabelOrLBrace: ExpectedLabelOrLBrace, - ExpectedLBrace: ExpectedLBrace, - ExpectedColonOrRParen: ExpectedColonOrRParen, - ExpectedLabelable: ExpectedLabelable, - ExpectedInlinable: ExpectedInlinable, - ExpectedAsmOutputReturnOrType: ExpectedAsmOutputReturnOrType, - ExpectedCall: ExpectedCall, - ExpectedCallOrFnProto: ExpectedCallOrFnProto, - ExpectedSliceOrRBracket: ExpectedSliceOrRBracket, - ExtraAlignQualifier: ExtraAlignQualifier, - ExtraConstQualifier: ExtraConstQualifier, - ExtraVolatileQualifier: ExtraVolatileQualifier, - ExtraAllowZeroQualifier: ExtraAllowZeroQualifier, - ExpectedTypeExpr: ExpectedTypeExpr, - ExpectedPrimaryTypeExpr: ExpectedPrimaryTypeExpr, - ExpectedParamType: ExpectedParamType, - ExpectedExpr: ExpectedExpr, - ExpectedPrimaryExpr: ExpectedPrimaryExpr, - ExpectedToken: ExpectedToken, - ExpectedCommaOrEnd: ExpectedCommaOrEnd, - ExpectedParamList: ExpectedParamList, - ExpectedPayload: ExpectedPayload, - ExpectedBlockOrAssignment: ExpectedBlockOrAssignment, - ExpectedBlockOrExpression: ExpectedBlockOrExpression, - ExpectedExprOrAssignment: ExpectedExprOrAssignment, - ExpectedPrefixExpr: ExpectedPrefixExpr, - ExpectedLoopExpr: ExpectedLoopExpr, - ExpectedDerefOrUnwrap: ExpectedDerefOrUnwrap, - ExpectedSuffixOp: ExpectedSuffixOp, - ExpectedBlockOrField: ExpectedBlockOrField, - DeclBetweenFields: DeclBetweenFields, - InvalidAnd: InvalidAnd, - AsteriskAfterPointerDereference: AsteriskAfterPointerDereference, +/// Fully assembled AST node information. +pub const full = struct { + pub const VarDecl = struct { + visib_token: ?TokenIndex, + extern_export_token: ?TokenIndex, + lib_name: ?TokenIndex, + threadlocal_token: ?TokenIndex, + comptime_token: ?TokenIndex, + ast: Ast, - pub fn render(self: *const Error, tokens: []const Token.Id, stream: anytype) !void { - switch (self.*) { - .InvalidToken => |*x| return x.render(tokens, stream), - .ExpectedContainerMembers => |*x| return x.render(tokens, stream), - .ExpectedStringLiteral => |*x| return x.render(tokens, stream), - .ExpectedIntegerLiteral => |*x| return x.render(tokens, stream), - .ExpectedPubItem => |*x| return x.render(tokens, stream), - .ExpectedIdentifier => |*x| return x.render(tokens, stream), - .ExpectedStatement => |*x| return x.render(tokens, stream), - .ExpectedVarDeclOrFn => |*x| return x.render(tokens, stream), - .ExpectedVarDecl => |*x| return x.render(tokens, stream), - .ExpectedFn => |*x| return x.render(tokens, stream), - .ExpectedReturnType => |*x| return x.render(tokens, stream), - .ExpectedAggregateKw => |*x| return x.render(tokens, stream), - .UnattachedDocComment => |*x| return x.render(tokens, stream), - .ExpectedEqOrSemi => |*x| return x.render(tokens, stream), - .ExpectedSemiOrLBrace => |*x| return x.render(tokens, stream), - .ExpectedSemiOrElse => |*x| return x.render(tokens, stream), - .ExpectedLabelOrLBrace => |*x| return x.render(tokens, stream), - .ExpectedLBrace => |*x| return x.render(tokens, stream), - .ExpectedColonOrRParen => |*x| return x.render(tokens, stream), - .ExpectedLabelable => |*x| return x.render(tokens, stream), - .ExpectedInlinable => |*x| return x.render(tokens, stream), - .ExpectedAsmOutputReturnOrType => |*x| return x.render(tokens, stream), - .ExpectedCall => |*x| return x.render(tokens, stream), - .ExpectedCallOrFnProto => |*x| return x.render(tokens, stream), - .ExpectedSliceOrRBracket => |*x| return x.render(tokens, stream), - .ExtraAlignQualifier => |*x| return x.render(tokens, stream), - .ExtraConstQualifier => |*x| return x.render(tokens, stream), - .ExtraVolatileQualifier => |*x| return x.render(tokens, stream), - .ExtraAllowZeroQualifier => |*x| return x.render(tokens, stream), - .ExpectedTypeExpr => |*x| return x.render(tokens, stream), - .ExpectedPrimaryTypeExpr => |*x| return x.render(tokens, stream), - .ExpectedParamType => |*x| return x.render(tokens, stream), - .ExpectedExpr => |*x| return x.render(tokens, stream), - .ExpectedPrimaryExpr => |*x| return x.render(tokens, stream), - .ExpectedToken => |*x| return x.render(tokens, stream), - .ExpectedCommaOrEnd => |*x| return x.render(tokens, stream), - .ExpectedParamList => |*x| return x.render(tokens, stream), - .ExpectedPayload => |*x| return x.render(tokens, stream), - .ExpectedBlockOrAssignment => |*x| return x.render(tokens, stream), - .ExpectedBlockOrExpression => |*x| return x.render(tokens, stream), - .ExpectedExprOrAssignment => |*x| return x.render(tokens, stream), - .ExpectedPrefixExpr => |*x| return x.render(tokens, stream), - .ExpectedLoopExpr => |*x| return x.render(tokens, stream), - .ExpectedDerefOrUnwrap => |*x| return x.render(tokens, stream), - .ExpectedSuffixOp => |*x| return x.render(tokens, stream), - .ExpectedBlockOrField => |*x| return x.render(tokens, stream), - .DeclBetweenFields => |*x| return x.render(tokens, stream), - .InvalidAnd => |*x| return x.render(tokens, stream), - .AsteriskAfterPointerDereference => |*x| return x.render(tokens, stream), - } - } - - pub fn loc(self: *const Error) TokenIndex { - switch (self.*) { - .InvalidToken => |x| return x.token, - .ExpectedContainerMembers => |x| return x.token, - .ExpectedStringLiteral => |x| return x.token, - .ExpectedIntegerLiteral => |x| return x.token, - .ExpectedPubItem => |x| return x.token, - .ExpectedIdentifier => |x| return x.token, - .ExpectedStatement => |x| return x.token, - .ExpectedVarDeclOrFn => |x| return x.token, - .ExpectedVarDecl => |x| return x.token, - .ExpectedFn => |x| return x.token, - .ExpectedReturnType => |x| return x.token, - .ExpectedAggregateKw => |x| return x.token, - .UnattachedDocComment => |x| return x.token, - .ExpectedEqOrSemi => |x| return x.token, - .ExpectedSemiOrLBrace => |x| return x.token, - .ExpectedSemiOrElse => |x| return x.token, - .ExpectedLabelOrLBrace => |x| return x.token, - .ExpectedLBrace => |x| return x.token, - .ExpectedColonOrRParen => |x| return x.token, - .ExpectedLabelable => |x| return x.token, - .ExpectedInlinable => |x| return x.token, - .ExpectedAsmOutputReturnOrType => |x| return x.token, - .ExpectedCall => |x| return x.node.firstToken(), - .ExpectedCallOrFnProto => |x| return x.node.firstToken(), - .ExpectedSliceOrRBracket => |x| return x.token, - .ExtraAlignQualifier => |x| return x.token, - .ExtraConstQualifier => |x| return x.token, - .ExtraVolatileQualifier => |x| return x.token, - .ExtraAllowZeroQualifier => |x| return x.token, - .ExpectedTypeExpr => |x| return x.token, - .ExpectedPrimaryTypeExpr => |x| return x.token, - .ExpectedParamType => |x| return x.token, - .ExpectedExpr => |x| return x.token, - .ExpectedPrimaryExpr => |x| return x.token, - .ExpectedToken => |x| return x.token, - .ExpectedCommaOrEnd => |x| return x.token, - .ExpectedParamList => |x| return x.token, - .ExpectedPayload => |x| return x.token, - .ExpectedBlockOrAssignment => |x| return x.token, - .ExpectedBlockOrExpression => |x| return x.token, - .ExpectedExprOrAssignment => |x| return x.token, - .ExpectedPrefixExpr => |x| return x.token, - .ExpectedLoopExpr => |x| return x.token, - .ExpectedDerefOrUnwrap => |x| return x.token, - .ExpectedSuffixOp => |x| return x.token, - .ExpectedBlockOrField => |x| return x.token, - .DeclBetweenFields => |x| return x.token, - .InvalidAnd => |x| return x.token, - .AsteriskAfterPointerDereference => |x| return x.token, - } - } - - pub const InvalidToken = SingleTokenError("Invalid token '{}'"); - pub const ExpectedContainerMembers = SingleTokenError("Expected test, comptime, var decl, or container field, found '{}'"); - pub const ExpectedStringLiteral = SingleTokenError("Expected string literal, found '{}'"); - pub const ExpectedIntegerLiteral = SingleTokenError("Expected integer literal, found '{}'"); - pub const ExpectedIdentifier = SingleTokenError("Expected identifier, found '{}'"); - pub const ExpectedStatement = SingleTokenError("Expected statement, found '{}'"); - pub const ExpectedVarDeclOrFn = SingleTokenError("Expected variable declaration or function, found '{}'"); - pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found '{}'"); - pub const ExpectedFn = SingleTokenError("Expected function, found '{}'"); - pub const ExpectedReturnType = SingleTokenError("Expected 'var' or return type expression, found '{}'"); - pub const ExpectedAggregateKw = SingleTokenError("Expected '" ++ Token.Id.Keyword_struct.symbol() ++ "', '" ++ Token.Id.Keyword_union.symbol() ++ "', '" ++ Token.Id.Keyword_enum.symbol() ++ "', or '" ++ Token.Id.Keyword_opaque.symbol() ++ "', found '{}'"); - pub const ExpectedEqOrSemi = SingleTokenError("Expected '=' or ';', found '{}'"); - pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found '{}'"); - pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found '{}'"); - pub const ExpectedLBrace = SingleTokenError("Expected '{{', found '{}'"); - pub const ExpectedLabelOrLBrace = SingleTokenError("Expected label or '{{', found '{}'"); - pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found '{}'"); - pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found '{}'"); - pub const ExpectedInlinable = SingleTokenError("Expected 'while' or 'for', found '{}'"); - pub const ExpectedAsmOutputReturnOrType = SingleTokenError("Expected '->' or '" ++ Token.Id.Identifier.symbol() ++ "', found '{}'"); - pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found '{}'"); - pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found '{}'"); - pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found '{}'"); - pub const ExpectedExpr = SingleTokenError("Expected expression, found '{}'"); - pub const ExpectedPrimaryExpr = SingleTokenError("Expected primary expression, found '{}'"); - pub const ExpectedParamList = SingleTokenError("Expected parameter list, found '{}'"); - pub const ExpectedPayload = SingleTokenError("Expected loop payload, found '{}'"); - pub const ExpectedBlockOrAssignment = SingleTokenError("Expected block or assignment, found '{}'"); - pub const ExpectedBlockOrExpression = SingleTokenError("Expected block or expression, found '{}'"); - pub const ExpectedExprOrAssignment = SingleTokenError("Expected expression or assignment, found '{}'"); - pub const ExpectedPrefixExpr = SingleTokenError("Expected prefix expression, found '{}'"); - pub const ExpectedLoopExpr = SingleTokenError("Expected loop expression, found '{}'"); - pub const ExpectedDerefOrUnwrap = SingleTokenError("Expected pointer dereference or optional unwrap, found '{}'"); - pub const ExpectedSuffixOp = SingleTokenError("Expected pointer dereference, optional unwrap, or field access, found '{}'"); - pub const ExpectedBlockOrField = SingleTokenError("Expected block or field, found '{}'"); - - pub const ExpectedParamType = SimpleError("Expected parameter type"); - pub const ExpectedPubItem = SimpleError("Expected function or variable declaration after pub"); - pub const UnattachedDocComment = SimpleError("Unattached documentation comment"); - pub const ExtraAlignQualifier = SimpleError("Extra align qualifier"); - pub const ExtraConstQualifier = SimpleError("Extra const qualifier"); - pub const ExtraVolatileQualifier = SimpleError("Extra volatile qualifier"); - pub const ExtraAllowZeroQualifier = SimpleError("Extra allowzero qualifier"); - pub const DeclBetweenFields = SimpleError("Declarations are not allowed between container fields"); - pub const InvalidAnd = SimpleError("`&&` is invalid. Note that `and` is boolean AND."); - pub const AsteriskAfterPointerDereference = SimpleError("`.*` can't be followed by `*`. Are you missing a space?"); - - pub const ExpectedCall = struct { - node: *Node, - - pub fn render(self: *const ExpectedCall, tokens: []const Token.Id, stream: anytype) !void { - return stream.print("expected " ++ @tagName(Node.Tag.Call) ++ ", found {}", .{ - @tagName(self.node.tag), - }); - } + pub const Ast = struct { + mut_token: TokenIndex, + type_node: Node.Index, + align_node: Node.Index, + section_node: Node.Index, + init_node: Node.Index, + }; }; - pub const ExpectedCallOrFnProto = struct { - node: *Node, + pub const If = struct { + /// Points to the first token after the `|`. Will either be an identifier or + /// a `*` (with an identifier immediately after it). + payload_token: ?TokenIndex, + /// Points to the identifier after the `|`. + error_token: ?TokenIndex, + /// Populated only if else_expr != 0. + else_token: TokenIndex, + ast: Ast, - pub fn render(self: *const ExpectedCallOrFnProto, tokens: []const Token.Id, stream: anytype) !void { - return stream.print("expected " ++ @tagName(Node.Tag.Call) ++ " or " ++ - @tagName(Node.Tag.FnProto) ++ ", found {}", .{@tagName(self.node.tag)}); - } + pub const Ast = struct { + if_token: TokenIndex, + cond_expr: Node.Index, + then_expr: Node.Index, + else_expr: Node.Index, + }; }; - pub const ExpectedToken = struct { - token: TokenIndex, - expected_id: Token.Id, + pub const While = struct { + ast: Ast, + inline_token: ?TokenIndex, + label_token: ?TokenIndex, + payload_token: ?TokenIndex, + error_token: ?TokenIndex, + /// Populated only if else_expr != 0. + else_token: TokenIndex, - pub fn render(self: *const ExpectedToken, tokens: []const Token.Id, stream: anytype) !void { - const found_token = tokens[self.token]; - switch (found_token) { - .Invalid => { - return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()}); - }, - else => { - const token_name = found_token.symbol(); - return stream.print("expected '{}', found '{}'", .{ self.expected_id.symbol(), token_name }); - }, - } - } + pub const Ast = struct { + while_token: TokenIndex, + cond_expr: Node.Index, + cont_expr: Node.Index, + then_expr: Node.Index, + else_expr: Node.Index, + }; }; - pub const ExpectedCommaOrEnd = struct { - token: TokenIndex, - end_id: Token.Id, + pub const ContainerField = struct { + comptime_token: ?TokenIndex, + ast: Ast, - pub fn render(self: *const ExpectedCommaOrEnd, tokens: []const Token.Id, stream: anytype) !void { - const actual_token = tokens[self.token]; - return stream.print("expected ',' or '{}', found '{}'", .{ - self.end_id.symbol(), - actual_token.symbol(), - }); - } + pub const Ast = struct { + name_token: TokenIndex, + type_expr: Node.Index, + value_expr: Node.Index, + align_expr: Node.Index, + }; }; - fn SingleTokenError(comptime msg: []const u8) type { - return struct { - const ThisError = @This(); + pub const FnProto = struct { + visib_token: ?TokenIndex, + extern_export_token: ?TokenIndex, + lib_name: ?TokenIndex, + name_token: ?TokenIndex, + lparen: TokenIndex, + ast: Ast, - token: TokenIndex, + pub const Ast = struct { + fn_token: TokenIndex, + return_type: Node.Index, + params: []const Node.Index, + align_expr: Node.Index, + section_expr: Node.Index, + callconv_expr: Node.Index, + }; - pub fn render(self: *const ThisError, tokens: []const Token.Id, stream: anytype) !void { - const actual_token = tokens[self.token]; - return stream.print(msg, .{actual_token.symbol()}); + pub const Param = struct { + first_doc_comment: ?TokenIndex, + name_token: ?TokenIndex, + comptime_noalias: ?TokenIndex, + anytype_ellipsis3: ?TokenIndex, + type_expr: Node.Index, + }; + + /// Abstracts over the fact that anytype and ... are not included + /// in the params slice, since they are simple identifiers and + /// not sub-expressions. + pub const Iterator = struct { + tree: *const Tree, + fn_proto: *const FnProto, + param_i: usize, + tok_i: TokenIndex, + tok_flag: bool, + + pub fn next(it: *Iterator) ?Param { + const token_tags = it.tree.tokens.items(.tag); + while (true) { + var first_doc_comment: ?TokenIndex = null; + var comptime_noalias: ?TokenIndex = null; + var name_token: ?TokenIndex = null; + if (!it.tok_flag) { + if (it.param_i >= it.fn_proto.ast.params.len) { + return null; + } + const param_type = it.fn_proto.ast.params[it.param_i]; + var tok_i = it.tree.firstToken(param_type) - 1; + while (true) : (tok_i -= 1) switch (token_tags[tok_i]) { + .colon => continue, + .identifier => name_token = tok_i, + .doc_comment => first_doc_comment = tok_i, + .keyword_comptime, .keyword_noalias => comptime_noalias = tok_i, + else => break, + }; + it.param_i += 1; + it.tok_i = it.tree.lastToken(param_type) + 1; + it.tok_flag = true; + return Param{ + .first_doc_comment = first_doc_comment, + .comptime_noalias = comptime_noalias, + .name_token = name_token, + .anytype_ellipsis3 = null, + .type_expr = param_type, + }; + } + // Look for anytype and ... params afterwards. + if (token_tags[it.tok_i] == .comma) { + it.tok_i += 1; + } else { + return null; + } + if (token_tags[it.tok_i] == .doc_comment) { + first_doc_comment = it.tok_i; + while (token_tags[it.tok_i] == .doc_comment) { + it.tok_i += 1; + } + } + switch (token_tags[it.tok_i]) { + .ellipsis3 => { + it.tok_flag = false; // Next iteration should return null. + return Param{ + .first_doc_comment = first_doc_comment, + .comptime_noalias = null, + .name_token = null, + .anytype_ellipsis3 = it.tok_i, + .type_expr = 0, + }; + }, + .keyword_noalias, .keyword_comptime => { + comptime_noalias = it.tok_i; + it.tok_i += 1; + }, + else => {}, + } + if (token_tags[it.tok_i] == .identifier and + token_tags[it.tok_i + 1] == .colon) + { + name_token = it.tok_i; + it.tok_i += 2; + } + if (token_tags[it.tok_i] == .keyword_anytype) { + it.tok_i += 1; + return Param{ + .first_doc_comment = first_doc_comment, + .comptime_noalias = comptime_noalias, + .name_token = name_token, + .anytype_ellipsis3 = it.tok_i - 1, + .type_expr = 0, + }; + } + it.tok_flag = false; + } } }; - } - fn SimpleError(comptime msg: []const u8) type { - return struct { - const ThisError = @This(); + pub fn iterate(fn_proto: FnProto, tree: Tree) Iterator { + return .{ + .tree = &tree, + .fn_proto = &fn_proto, + .param_i = 0, + .tok_i = undefined, + .tok_flag = false, + }; + } + }; - token: TokenIndex, + pub const StructInit = struct { + ast: Ast, - pub fn render(self: *const ThisError, tokens: []const Token.Id, stream: anytype) !void { - return stream.writeAll(msg); - } + pub const Ast = struct { + lbrace: TokenIndex, + fields: []const Node.Index, + type_expr: Node.Index, }; - } + }; + + pub const ArrayInit = struct { + ast: Ast, + + pub const Ast = struct { + lbrace: TokenIndex, + elements: []const Node.Index, + type_expr: Node.Index, + }; + }; + + pub const ArrayType = struct { + ast: Ast, + + pub const Ast = struct { + lbracket: TokenIndex, + elem_count: Node.Index, + sentinel: ?Node.Index, + elem_type: Node.Index, + }; + }; + + pub const PtrType = struct { + size: std.builtin.TypeInfo.Pointer.Size, + allowzero_token: ?TokenIndex, + const_token: ?TokenIndex, + volatile_token: ?TokenIndex, + ast: Ast, + + pub const Ast = struct { + main_token: TokenIndex, + align_node: Node.Index, + sentinel: Node.Index, + bit_range_start: Node.Index, + bit_range_end: Node.Index, + child_type: Node.Index, + }; + }; + + pub const Slice = struct { + ast: Ast, + + pub const Ast = struct { + sliced: Node.Index, + lbracket: TokenIndex, + start: Node.Index, + end: Node.Index, + sentinel: Node.Index, + }; + }; + + pub const ContainerDecl = struct { + layout_token: ?TokenIndex, + ast: Ast, + + pub const Ast = struct { + main_token: TokenIndex, + /// Populated when main_token is Keyword_union. + enum_token: ?TokenIndex, + members: []const Node.Index, + arg: Node.Index, + }; + }; + + pub const SwitchCase = struct { + /// Points to the first token after the `|`. Will either be an identifier or + /// a `*` (with an identifier immediately after it). + payload_token: ?TokenIndex, + ast: Ast, + + pub const Ast = struct { + /// If empty, this is an else case + values: []const Node.Index, + arrow_token: TokenIndex, + target_expr: Node.Index, + }; + }; + + pub const Asm = struct { + ast: Ast, + volatile_token: ?TokenIndex, + first_clobber: ?TokenIndex, + outputs: []const Node.Index, + inputs: []const Node.Index, + + pub const Ast = struct { + asm_token: TokenIndex, + template: Node.Index, + items: []const Node.Index, + rparen: TokenIndex, + }; + }; + + pub const Call = struct { + ast: Ast, + async_token: ?TokenIndex, + + pub const Ast = struct { + lparen: TokenIndex, + fn_expr: Node.Index, + params: []const Node.Index, + }; + }; +}; + +pub const Error = struct { + tag: Tag, + token: TokenIndex, + extra: union { + none: void, + expected_tag: Token.Tag, + } = .{ .none = {} }, + + pub const Tag = enum { + asterisk_after_ptr_deref, + decl_between_fields, + expected_block, + expected_block_or_assignment, + expected_block_or_expr, + expected_block_or_field, + expected_container_members, + expected_expr, + expected_expr_or_assignment, + expected_fn, + expected_inlinable, + expected_labelable, + expected_param_list, + expected_prefix_expr, + expected_primary_type_expr, + expected_pub_item, + expected_return_type, + expected_semi_or_else, + expected_semi_or_lbrace, + expected_statement, + expected_string_literal, + expected_suffix_op, + expected_type_expr, + expected_var_decl, + expected_var_decl_or_fn, + expected_loop_payload, + expected_container, + extra_align_qualifier, + extra_allowzero_qualifier, + extra_const_qualifier, + extra_volatile_qualifier, + invalid_align, + invalid_and, + invalid_bit_range, + invalid_token, + same_line_doc_comment, + unattached_doc_comment, + + /// `expected_tag` is populated. + expected_token, + }; }; pub const Node = struct { tag: Tag, + main_token: TokenIndex, + data: Data, + pub const Index = u32; + + comptime { + // Goal is to keep this under one byte for efficiency. + assert(@sizeOf(Tag) == 1); + } + + /// Note: The FooComma/FooSemicolon variants exist to ease the implementation of + /// Tree.lastToken() pub const Tag = enum { - // Top level - Root, - Use, - TestDecl, + /// sub_list[lhs...rhs] + root, + /// `usingnamespace lhs;`. rhs unused. main_token is `usingnamespace`. + @"usingnamespace", + /// lhs is test name token (must be string literal), if any. + /// rhs is the body node. + test_decl, + /// lhs is the index into extra_data. + /// rhs is the initialization expression, if any. + /// main_token is `var` or `const`. + global_var_decl, + /// `var a: x align(y) = rhs` + /// lhs is the index into extra_data. + /// main_token is `var` or `const`. + local_var_decl, + /// `var a: lhs = rhs`. lhs and rhs may be unused. + /// Can be local or global. + /// main_token is `var` or `const`. + simple_var_decl, + /// `var a align(lhs) = rhs`. lhs and rhs may be unused. + /// Can be local or global. + /// main_token is `var` or `const`. + aligned_var_decl, + /// lhs is the identifier token payload if any, + /// rhs is the deferred expression. + @"errdefer", + /// lhs is unused. + /// rhs is the deferred expression. + @"defer", + /// lhs catch rhs + /// lhs catch |err| rhs + /// main_token is the `catch` keyword. + /// payload is determined by looking at the next token after the `catch` keyword. + @"catch", + /// `lhs.a`. main_token is the dot. rhs is the identifier token index. + field_access, + /// `lhs.?`. main_token is the dot. rhs is the `?` token index. + unwrap_optional, + /// `lhs == rhs`. main_token is op. + equal_equal, + /// `lhs != rhs`. main_token is op. + bang_equal, + /// `lhs < rhs`. main_token is op. + less_than, + /// `lhs > rhs`. main_token is op. + greater_than, + /// `lhs <= rhs`. main_token is op. + less_or_equal, + /// `lhs >= rhs`. main_token is op. + greater_or_equal, + /// `lhs *= rhs`. main_token is op. + assign_mul, + /// `lhs /= rhs`. main_token is op. + assign_div, + /// `lhs *= rhs`. main_token is op. + assign_mod, + /// `lhs += rhs`. main_token is op. + assign_add, + /// `lhs -= rhs`. main_token is op. + assign_sub, + /// `lhs <<= rhs`. main_token is op. + assign_bit_shift_left, + /// `lhs >>= rhs`. main_token is op. + assign_bit_shift_right, + /// `lhs &= rhs`. main_token is op. + assign_bit_and, + /// `lhs ^= rhs`. main_token is op. + assign_bit_xor, + /// `lhs |= rhs`. main_token is op. + assign_bit_or, + /// `lhs *%= rhs`. main_token is op. + assign_mul_wrap, + /// `lhs +%= rhs`. main_token is op. + assign_add_wrap, + /// `lhs -%= rhs`. main_token is op. + assign_sub_wrap, + /// `lhs = rhs`. main_token is op. + assign, + /// `lhs || rhs`. main_token is the `||`. + merge_error_sets, + /// `lhs * rhs`. main_token is the `*`. + mul, + /// `lhs / rhs`. main_token is the `/`. + div, + /// `lhs % rhs`. main_token is the `%`. + mod, + /// `lhs ** rhs`. main_token is the `**`. + array_mult, + /// `lhs *% rhs`. main_token is the `*%`. + mul_wrap, + /// `lhs + rhs`. main_token is the `+`. + add, + /// `lhs - rhs`. main_token is the `-`. + sub, + /// `lhs ++ rhs`. main_token is the `++`. + array_cat, + /// `lhs +% rhs`. main_token is the `+%`. + add_wrap, + /// `lhs -% rhs`. main_token is the `-%`. + sub_wrap, + /// `lhs << rhs`. main_token is the `<<`. + bit_shift_left, + /// `lhs >> rhs`. main_token is the `>>`. + bit_shift_right, + /// `lhs & rhs`. main_token is the `&`. + bit_and, + /// `lhs ^ rhs`. main_token is the `^`. + bit_xor, + /// `lhs | rhs`. main_token is the `|`. + bit_or, + /// `lhs orelse rhs`. main_token is the `orelse`. + @"orelse", + /// `lhs and rhs`. main_token is the `and`. + bool_and, + /// `lhs or rhs`. main_token is the `or`. + bool_or, + /// `op lhs`. rhs unused. main_token is op. + bool_not, + /// `op lhs`. rhs unused. main_token is op. + negation, + /// `op lhs`. rhs unused. main_token is op. + bit_not, + /// `op lhs`. rhs unused. main_token is op. + negation_wrap, + /// `op lhs`. rhs unused. main_token is op. + address_of, + /// `op lhs`. rhs unused. main_token is op. + @"try", + /// `op lhs`. rhs unused. main_token is op. + @"await", + /// `?lhs`. rhs unused. main_token is the `?`. + optional_type, + /// `[lhs]rhs`. lhs can be omitted to make it a slice. + array_type, + /// `[lhs:a]b`. `array_type_sentinel[rhs]`. + array_type_sentinel, + /// `[*]align(lhs) rhs`. lhs can be omitted. + /// `*align(lhs) rhs`. lhs can be omitted. + /// `[]rhs`. + /// main_token is the asterisk if a pointer or the lbracket if a slice + /// main_token might be a ** token, which is shared with a parent/child + /// pointer type and may require special handling. + ptr_type_aligned, + /// `[*:lhs]rhs`. lhs can be omitted. + /// `*rhs`. + /// `[:lhs]rhs`. + /// main_token is the asterisk if a pointer or the lbracket if a slice + /// main_token might be a ** token, which is shared with a parent/child + /// pointer type and may require special handling. + ptr_type_sentinel, + /// lhs is index into ptr_type. rhs is the element type expression. + /// main_token is the asterisk if a pointer or the lbracket if a slice + /// main_token might be a ** token, which is shared with a parent/child + /// pointer type and may require special handling. + ptr_type, + /// lhs is index into ptr_type_bit_range. rhs is the element type expression. + /// main_token is the asterisk if a pointer or the lbracket if a slice + /// main_token might be a ** token, which is shared with a parent/child + /// pointer type and may require special handling. + ptr_type_bit_range, + /// `lhs[rhs..]` + /// main_token is the lbracket. + slice_open, + /// `lhs[b..c]`. rhs is index into Slice + /// main_token is the lbracket. + slice, + /// `lhs[b..c :d]`. rhs is index into SliceSentinel + /// main_token is the lbracket. + slice_sentinel, + /// `lhs.*`. rhs is unused. + deref, + /// `lhs[rhs]`. + array_access, + /// `lhs{rhs}`. rhs can be omitted. + array_init_one, + /// `lhs{rhs,}`. rhs can *not* be omitted + array_init_one_comma, + /// `.{lhs, rhs}`. lhs and rhs can be omitted. + array_init_dot_two, + /// Same as `array_init_dot_two` except there is known to be a trailing comma + /// before the final rbrace. + array_init_dot_two_comma, + /// `.{a, b}`. `sub_list[lhs..rhs]`. + array_init_dot, + /// Same as `array_init_dot` except there is known to be a trailing comma + /// before the final rbrace. + array_init_dot_comma, + /// `lhs{a, b}`. `sub_range_list[rhs]`. lhs can be omitted which means `.{a, b}`. + array_init, + /// Same as `array_init` except there is known to be a trailing comma + /// before the final rbrace. + array_init_comma, + /// `lhs{.a = rhs}`. rhs can be omitted making it empty. + /// main_token is the lbrace. + struct_init_one, + /// `lhs{.a = rhs,}`. rhs can *not* be omitted. + /// main_token is the lbrace. + struct_init_one_comma, + /// `.{.a = lhs, .b = rhs}`. lhs and rhs can be omitted. + /// main_token is the lbrace. + /// No trailing comma before the rbrace. + struct_init_dot_two, + /// Same as `struct_init_dot_two` except there is known to be a trailing comma + /// before the final rbrace. + struct_init_dot_two_comma, + /// `.{.a = b, .c = d}`. `sub_list[lhs..rhs]`. + /// main_token is the lbrace. + struct_init_dot, + /// Same as `struct_init_dot` except there is known to be a trailing comma + /// before the final rbrace. + struct_init_dot_comma, + /// `lhs{.a = b, .c = d}`. `sub_range_list[rhs]`. + /// lhs can be omitted which means `.{.a = b, .c = d}`. + /// main_token is the lbrace. + struct_init, + /// Same as `struct_init` except there is known to be a trailing comma + /// before the final rbrace. + struct_init_comma, + /// `lhs(rhs)`. rhs can be omitted. + /// main_token is the lparen. + call_one, + /// `lhs(rhs,)`. rhs can be omitted. + /// main_token is the lparen. + call_one_comma, + /// `async lhs(rhs)`. rhs can be omitted. + async_call_one, + /// `async lhs(rhs,)`. + async_call_one_comma, + /// `lhs(a, b, c)`. `SubRange[rhs]`. + /// main_token is the `(`. + call, + /// `lhs(a, b, c,)`. `SubRange[rhs]`. + /// main_token is the `(`. + call_comma, + /// `async lhs(a, b, c)`. `SubRange[rhs]`. + /// main_token is the `(`. + async_call, + /// `async lhs(a, b, c,)`. `SubRange[rhs]`. + /// main_token is the `(`. + async_call_comma, + /// `switch(lhs) {}`. `SubRange[rhs]`. + @"switch", + /// Same as switch except there is known to be a trailing comma + /// before the final rbrace + switch_comma, + /// `lhs => rhs`. If lhs is omitted it means `else`. + /// main_token is the `=>` + switch_case_one, + /// `a, b, c => rhs`. `SubRange[lhs]`. + /// main_token is the `=>` + switch_case, + /// `lhs...rhs`. + switch_range, + /// `while (lhs) rhs`. + /// `while (lhs) |x| rhs`. + while_simple, + /// `while (lhs) : (a) b`. `WhileCont[rhs]`. + /// `while (lhs) : (a) b`. `WhileCont[rhs]`. + while_cont, + /// `while (lhs) : (a) b else c`. `While[rhs]`. + /// `while (lhs) |x| : (a) b else c`. `While[rhs]`. + /// `while (lhs) |x| : (a) b else |y| c`. `While[rhs]`. + @"while", + /// `for (lhs) rhs`. + for_simple, + /// `for (lhs) a else b`. `if_list[rhs]`. + @"for", + /// `if (lhs) rhs`. + /// `if (lhs) |a| rhs`. + if_simple, + /// `if (lhs) a else b`. `If[rhs]`. + /// `if (lhs) |x| a else b`. `If[rhs]`. + /// `if (lhs) |x| a else |y| b`. `If[rhs]`. + @"if", + /// `suspend lhs`. lhs can be omitted. rhs is unused. + @"suspend", + /// `resume lhs`. rhs is unused. + @"resume", + /// `continue`. lhs is token index of label if any. rhs is unused. + @"continue", + /// `break :lhs rhs` + /// both lhs and rhs may be omitted. + @"break", + /// `return lhs`. lhs can be omitted. rhs is unused. + @"return", + /// `fn(a: lhs) rhs`. lhs can be omitted. + /// anytype and ... parameters are omitted from the AST tree. + /// main_token is the `fn` keyword. + /// extern function declarations use this tag. + fn_proto_simple, + /// `fn(a: b, c: d) rhs`. `sub_range_list[lhs]`. + /// anytype and ... parameters are omitted from the AST tree. + /// main_token is the `fn` keyword. + /// extern function declarations use this tag. + fn_proto_multi, + /// `fn(a: b) rhs linksection(e) callconv(f)`. `FnProtoOne[lhs]`. + /// zero or one parameters. + /// anytype and ... parameters are omitted from the AST tree. + /// main_token is the `fn` keyword. + /// extern function declarations use this tag. + fn_proto_one, + /// `fn(a: b, c: d) rhs linksection(e) callconv(f)`. `FnProto[lhs]`. + /// anytype and ... parameters are omitted from the AST tree. + /// main_token is the `fn` keyword. + /// extern function declarations use this tag. + fn_proto, + /// lhs is the fn_proto. + /// rhs is the function body block. + /// Note that extern function declarations use the fn_proto tags rather + /// than this one. + fn_decl, + /// `anyframe->rhs`. main_token is `anyframe`. `lhs` is arrow token index. + anyframe_type, + /// Both lhs and rhs unused. + anyframe_literal, + /// Both lhs and rhs unused. + char_literal, + /// Both lhs and rhs unused. + integer_literal, + /// Both lhs and rhs unused. + float_literal, + /// Both lhs and rhs unused. + false_literal, + /// Both lhs and rhs unused. + true_literal, + /// Both lhs and rhs unused. + null_literal, + /// Both lhs and rhs unused. + undefined_literal, + /// Both lhs and rhs unused. + unreachable_literal, + /// Both lhs and rhs unused. + /// Most identifiers will not have explicit AST nodes, however for expressions + /// which could be one of many different kinds of AST nodes, there will be an + /// identifier AST node for it. + identifier, + /// lhs is the dot token index, rhs unused, main_token is the identifier. + enum_literal, + /// main_token is the string literal token + /// Both lhs and rhs unused. + string_literal, + /// main_token is the first token index (redundant with lhs) + /// lhs is the first token index; rhs is the last token index. + /// Could be a series of multiline_string_literal_line tokens, or a single + /// string_literal token. + multiline_string_literal, + /// `(lhs)`. main_token is the `(`; rhs is the token index of the `)`. + grouped_expression, + /// `@a(lhs, rhs)`. lhs and rhs may be omitted. + /// main_token is the builtin token. + builtin_call_two, + /// Same as builtin_call_two but there is known to be a trailing comma before the rparen. + builtin_call_two_comma, + /// `@a(b, c)`. `sub_list[lhs..rhs]`. + /// main_token is the builtin token. + builtin_call, + /// Same as builtin_call but there is known to be a trailing comma before the rparen. + builtin_call_comma, + /// `error{a, b}`. + /// rhs is the rbrace, lhs is unused. + error_set_decl, + /// `struct {}`, `union {}`, `opaque {}`, `enum {}`. `extra_data[lhs..rhs]`. + /// main_token is `struct`, `union`, `opaque`, `enum` keyword. + container_decl, + /// Same as ContainerDecl but there is known to be a trailing comma + /// or semicolon before the rbrace. + container_decl_trailing, + /// `struct {lhs, rhs}`, `union {lhs, rhs}`, `opaque {lhs, rhs}`, `enum {lhs, rhs}`. + /// lhs or rhs can be omitted. + /// main_token is `struct`, `union`, `opaque`, `enum` keyword. + container_decl_two, + /// Same as ContainerDeclTwo except there is known to be a trailing comma + /// or semicolon before the rbrace. + container_decl_two_trailing, + /// `union(lhs)` / `enum(lhs)`. `SubRange[rhs]`. + container_decl_arg, + /// Same as container_decl_arg but there is known to be a trailing + /// comma or semicolon before the rbrace. + container_decl_arg_trailing, + /// `union(enum) {}`. `sub_list[lhs..rhs]`. + /// Note that tagged unions with explicitly provided enums are represented + /// by `container_decl_arg`. + tagged_union, + /// Same as tagged_union but there is known to be a trailing comma + /// or semicolon before the rbrace. + tagged_union_trailing, + /// `union(enum) {lhs, rhs}`. lhs or rhs may be omitted. + /// Note that tagged unions with explicitly provided enums are represented + /// by `container_decl_arg`. + tagged_union_two, + /// Same as tagged_union_two but there is known to be a trailing comma + /// or semicolon before the rbrace. + tagged_union_two_trailing, + /// `union(enum(lhs)) {}`. `SubRange[rhs]`. + tagged_union_enum_tag, + /// Same as tagged_union_enum_tag but there is known to be a trailing comma + /// or semicolon before the rbrace. + tagged_union_enum_tag_trailing, + /// `a: lhs = rhs,`. lhs and rhs can be omitted. + /// main_token is the field name identifier. + /// lastToken() does not include the possible trailing comma. + container_field_init, + /// `a: lhs align(rhs),`. rhs can be omitted. + /// main_token is the field name identifier. + /// lastToken() does not include the possible trailing comma. + container_field_align, + /// `a: lhs align(c) = d,`. `container_field_list[rhs]`. + /// main_token is the field name identifier. + /// lastToken() does not include the possible trailing comma. + container_field, + /// `anytype`. both lhs and rhs unused. + /// Used by `ContainerField`. + @"anytype", + /// `comptime lhs`. rhs unused. + @"comptime", + /// `nosuspend lhs`. rhs unused. + @"nosuspend", + /// `{lhs rhs}`. rhs or lhs can be omitted. + /// main_token points at the lbrace. + block_two, + /// Same as block_two but there is known to be a semicolon before the rbrace. + block_two_semicolon, + /// `{}`. `sub_list[lhs..rhs]`. + /// main_token points at the lbrace. + block, + /// Same as block but there is known to be a semicolon before the rbrace. + block_semicolon, + /// `asm(lhs)`. rhs is the token index of the rparen. + asm_simple, + /// `asm(lhs, a)`. `Asm[rhs]`. + @"asm", + /// `[a] "b" (c)`. lhs is 0, rhs is token index of the rparen. + /// `[a] "b" (-> lhs)`. rhs is token index of the rparen. + /// main_token is `a`. + asm_output, + /// `[a] "b" (lhs)`. rhs is token index of the rparen. + /// main_token is `a`. + asm_input, + /// `error.a`. lhs is token index of `.`. rhs is token index of `a`. + error_value, + /// `lhs!rhs`. main_token is the `!`. + error_union, - // Statements - VarDecl, - Defer, - - // Infix operators - Catch, - - // SimpleInfixOp - Add, - AddWrap, - ArrayCat, - ArrayMult, - Assign, - AssignBitAnd, - AssignBitOr, - AssignBitShiftLeft, - AssignBitShiftRight, - AssignBitXor, - AssignDiv, - AssignSub, - AssignSubWrap, - AssignMod, - AssignAdd, - AssignAddWrap, - AssignMul, - AssignMulWrap, - BangEqual, - BitAnd, - BitOr, - BitShiftLeft, - BitShiftRight, - BitXor, - BoolAnd, - BoolOr, - Div, - EqualEqual, - ErrorUnion, - GreaterOrEqual, - GreaterThan, - LessOrEqual, - LessThan, - MergeErrorSets, - Mod, - Mul, - MulWrap, - Period, - Range, - Sub, - SubWrap, - OrElse, - - // SimplePrefixOp - AddressOf, - Await, - BitNot, - BoolNot, - OptionalType, - Negation, - NegationWrap, - Resume, - Try, - - ArrayType, - /// ArrayType but has a sentinel node. - ArrayTypeSentinel, - PtrType, - SliceType, - /// `a[b..c]` - Slice, - /// `a.*` - Deref, - /// `a.?` - UnwrapOptional, - /// `a[b]` - ArrayAccess, - /// `T{a, b}` - ArrayInitializer, - /// ArrayInitializer but with `.` instead of a left-hand-side operand. - ArrayInitializerDot, - /// `T{.a = b}` - StructInitializer, - /// StructInitializer but with `.` instead of a left-hand-side operand. - StructInitializerDot, - /// `foo()` - Call, - - // Control flow - Switch, - While, - For, - If, - Suspend, - Continue, - Break, - Return, - - // Type expressions - AnyType, - ErrorType, - FnProto, - AnyFrameType, - - // Primary expressions - IntegerLiteral, - FloatLiteral, - EnumLiteral, - StringLiteral, - MultilineStringLiteral, - CharLiteral, - BoolLiteral, - NullLiteral, - UndefinedLiteral, - Unreachable, - Identifier, - GroupedExpression, - BuiltinCall, - ErrorSetDecl, - ContainerDecl, - Asm, - Comptime, - Nosuspend, - Block, - LabeledBlock, - - // Misc - DocComment, - SwitchCase, // TODO make this not a child of AST Node - SwitchElse, // TODO make this not a child of AST Node - Else, // TODO make this not a child of AST Node - Payload, // TODO make this not a child of AST Node - PointerPayload, // TODO make this not a child of AST Node - PointerIndexPayload, // TODO make this not a child of AST Node - ContainerField, - ErrorTag, // TODO make this not a child of AST Node - FieldInitializer, // TODO make this not a child of AST Node - - pub fn Type(tag: Tag) type { + pub fn isContainerField(tag: Tag) bool { return switch (tag) { - .Root => Root, - .Use => Use, - .TestDecl => TestDecl, - .VarDecl => VarDecl, - .Defer => Defer, - .Catch => Catch, + .container_field_init, + .container_field_align, + .container_field, + => true, - .Add, - .AddWrap, - .ArrayCat, - .ArrayMult, - .Assign, - .AssignBitAnd, - .AssignBitOr, - .AssignBitShiftLeft, - .AssignBitShiftRight, - .AssignBitXor, - .AssignDiv, - .AssignSub, - .AssignSubWrap, - .AssignMod, - .AssignAdd, - .AssignAddWrap, - .AssignMul, - .AssignMulWrap, - .BangEqual, - .BitAnd, - .BitOr, - .BitShiftLeft, - .BitShiftRight, - .BitXor, - .BoolAnd, - .BoolOr, - .Div, - .EqualEqual, - .ErrorUnion, - .GreaterOrEqual, - .GreaterThan, - .LessOrEqual, - .LessThan, - .MergeErrorSets, - .Mod, - .Mul, - .MulWrap, - .Period, - .Range, - .Sub, - .SubWrap, - .OrElse, - => SimpleInfixOp, - - .AddressOf, - .Await, - .BitNot, - .BoolNot, - .OptionalType, - .Negation, - .NegationWrap, - .Resume, - .Try, - => SimplePrefixOp, - - .Identifier, - .BoolLiteral, - .NullLiteral, - .UndefinedLiteral, - .Unreachable, - .AnyType, - .ErrorType, - .IntegerLiteral, - .FloatLiteral, - .StringLiteral, - .CharLiteral, - => OneToken, - - .Continue, - .Break, - .Return, - => ControlFlowExpression, - - .ArrayType => ArrayType, - .ArrayTypeSentinel => ArrayTypeSentinel, - - .PtrType => PtrType, - .SliceType => SliceType, - .Slice => Slice, - .Deref, .UnwrapOptional => SimpleSuffixOp, - .ArrayAccess => ArrayAccess, - - .ArrayInitializer => ArrayInitializer, - .ArrayInitializerDot => ArrayInitializerDot, - - .StructInitializer => StructInitializer, - .StructInitializerDot => StructInitializerDot, - - .Call => Call, - .Switch => Switch, - .While => While, - .For => For, - .If => If, - .Suspend => Suspend, - .FnProto => FnProto, - .AnyFrameType => AnyFrameType, - .EnumLiteral => EnumLiteral, - .MultilineStringLiteral => MultilineStringLiteral, - .GroupedExpression => GroupedExpression, - .BuiltinCall => BuiltinCall, - .ErrorSetDecl => ErrorSetDecl, - .ContainerDecl => ContainerDecl, - .Asm => Asm, - .Comptime => Comptime, - .Nosuspend => Nosuspend, - .Block => Block, - .LabeledBlock => LabeledBlock, - .DocComment => DocComment, - .SwitchCase => SwitchCase, - .SwitchElse => SwitchElse, - .Else => Else, - .Payload => Payload, - .PointerPayload => PointerPayload, - .PointerIndexPayload => PointerIndexPayload, - .ContainerField => ContainerField, - .ErrorTag => ErrorTag, - .FieldInitializer => FieldInitializer, - }; - } - - pub fn isBlock(tag: Tag) bool { - return switch (tag) { - .Block, .LabeledBlock => true, else => false, }; } }; - /// Prefer `castTag` to this. - pub fn cast(base: *Node, comptime T: type) ?*T { - if (std.meta.fieldInfo(T, "base").default_value) |default_base| { - return base.castTag(default_base.tag); - } - inline for (@typeInfo(Tag).Enum.fields) |field| { - const tag = @intToEnum(Tag, field.value); - if (base.tag == tag) { - if (T == tag.Type()) { - return @fieldParentPtr(T, "base", base); - } - return null; - } - } - unreachable; - } - - pub fn castTag(base: *Node, comptime tag: Tag) ?*tag.Type() { - if (base.tag == tag) { - return @fieldParentPtr(tag.Type(), "base", base); - } - return null; - } - - pub fn iterate(base: *Node, index: usize) ?*Node { - inline for (@typeInfo(Tag).Enum.fields) |field| { - const tag = @intToEnum(Tag, field.value); - if (base.tag == tag) { - return @fieldParentPtr(tag.Type(), "base", base).iterate(index); - } - } - unreachable; - } - - pub fn firstToken(base: *const Node) TokenIndex { - inline for (@typeInfo(Tag).Enum.fields) |field| { - const tag = @intToEnum(Tag, field.value); - if (base.tag == tag) { - return @fieldParentPtr(tag.Type(), "base", base).firstToken(); - } - } - unreachable; - } - - pub fn lastToken(base: *const Node) TokenIndex { - inline for (@typeInfo(Tag).Enum.fields) |field| { - const tag = @intToEnum(Tag, field.value); - if (base.tag == tag) { - return @fieldParentPtr(tag.Type(), "base", base).lastToken(); - } - } - unreachable; - } - - pub fn requireSemiColon(base: *const Node) bool { - var n = base; - while (true) { - switch (n.tag) { - .Root, - .ContainerField, - .Block, - .LabeledBlock, - .Payload, - .PointerPayload, - .PointerIndexPayload, - .Switch, - .SwitchCase, - .SwitchElse, - .FieldInitializer, - .DocComment, - .TestDecl, - => return false, - - .While => { - const while_node = @fieldParentPtr(While, "base", n); - if (while_node.@"else") |@"else"| { - n = &@"else".base; - continue; - } - - return !while_node.body.tag.isBlock(); - }, - .For => { - const for_node = @fieldParentPtr(For, "base", n); - if (for_node.@"else") |@"else"| { - n = &@"else".base; - continue; - } - - return !for_node.body.tag.isBlock(); - }, - .If => { - const if_node = @fieldParentPtr(If, "base", n); - if (if_node.@"else") |@"else"| { - n = &@"else".base; - continue; - } - - return !if_node.body.tag.isBlock(); - }, - .Else => { - const else_node = @fieldParentPtr(Else, "base", n); - n = else_node.body; - continue; - }, - .Defer => { - const defer_node = @fieldParentPtr(Defer, "base", n); - return !defer_node.expr.tag.isBlock(); - }, - .Comptime => { - const comptime_node = @fieldParentPtr(Comptime, "base", n); - return !comptime_node.expr.tag.isBlock(); - }, - .Suspend => { - const suspend_node = @fieldParentPtr(Suspend, "base", n); - if (suspend_node.body) |body| { - return !body.tag.isBlock(); - } - - return true; - }, - .Nosuspend => { - const nosuspend_node = @fieldParentPtr(Nosuspend, "base", n); - return !nosuspend_node.expr.tag.isBlock(); - }, - else => return true, - } - } - } - - /// Asserts the node is a Block or LabeledBlock and returns the statements slice. - pub fn blockStatements(base: *Node) []*Node { - if (base.castTag(.Block)) |block| { - return block.statements(); - } else if (base.castTag(.LabeledBlock)) |labeled_block| { - return labeled_block.statements(); - } else { - unreachable; - } - } - - pub fn findFirstWithId(self: *Node, id: Id) ?*Node { - if (self.id == id) return self; - var child_i: usize = 0; - while (self.iterate(child_i)) |child| : (child_i += 1) { - if (child.findFirstWithId(id)) |result| return result; - } - return null; - } - - pub fn dump(self: *Node, indent: usize) void { - { - var i: usize = 0; - while (i < indent) : (i += 1) { - std.debug.warn(" ", .{}); - } - } - std.debug.warn("{}\n", .{@tagName(self.tag)}); - - var child_i: usize = 0; - while (self.iterate(child_i)) |child| : (child_i += 1) { - child.dump(indent + 2); - } - } - - /// The decls data follows this struct in memory as an array of Node pointers. - pub const Root = struct { - base: Node = Node{ .tag = .Root }, - eof_token: TokenIndex, - decls_len: NodeIndex, - - /// After this the caller must initialize the decls list. - pub fn create(allocator: *mem.Allocator, decls_len: NodeIndex, eof_token: TokenIndex) !*Root { - const bytes = try allocator.alignedAlloc(u8, @alignOf(Root), sizeInBytes(decls_len)); - const self = @ptrCast(*Root, bytes.ptr); - self.* = .{ - .eof_token = eof_token, - .decls_len = decls_len, - }; - return self; - } - - pub fn destroy(self: *Decl, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.decls_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const Root, index: usize) ?*Node { - var i = index; - - if (i < self.decls_len) return self.declsConst()[i]; - return null; - } - - pub fn decls(self: *Root) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(Root); - return @ptrCast([*]*Node, decls_start)[0..self.decls_len]; - } - - pub fn declsConst(self: *const Root) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(Root); - return @ptrCast([*]const *Node, decls_start)[0..self.decls_len]; - } - - pub fn firstToken(self: *const Root) TokenIndex { - if (self.decls_len == 0) return self.eof_token; - return self.declsConst()[0].firstToken(); - } - - pub fn lastToken(self: *const Root) TokenIndex { - if (self.decls_len == 0) return self.eof_token; - return self.declsConst()[self.decls_len - 1].lastToken(); - } - - fn sizeInBytes(decls_len: NodeIndex) usize { - return @sizeOf(Root) + @sizeOf(*Node) * @as(usize, decls_len); - } + pub const Data = struct { + lhs: Index, + rhs: Index, }; - /// Trailed in memory by possibly many things, with each optional thing - /// determined by a bit in `trailer_flags`. - pub const VarDecl = struct { - base: Node = Node{ .tag = .VarDecl }, - trailer_flags: TrailerFlags, - mut_token: TokenIndex, - name_token: TokenIndex, - semicolon_token: TokenIndex, - - pub const TrailerFlags = std.meta.TrailerFlags(struct { - doc_comments: *DocComment, - visib_token: TokenIndex, - thread_local_token: TokenIndex, - eq_token: TokenIndex, - comptime_token: TokenIndex, - extern_export_token: TokenIndex, - lib_name: *Node, - type_node: *Node, - align_node: *Node, - section_node: *Node, - init_node: *Node, - }); - - pub fn getDocComments(self: *const VarDecl) ?*DocComment { - return self.getTrailer(.doc_comments); - } - - pub fn setDocComments(self: *VarDecl, value: *DocComment) void { - self.setTrailer(.doc_comments, value); - } - - pub fn getVisibToken(self: *const VarDecl) ?TokenIndex { - return self.getTrailer(.visib_token); - } - - pub fn setVisibToken(self: *VarDecl, value: TokenIndex) void { - self.setTrailer(.visib_token, value); - } - - pub fn getThreadLocalToken(self: *const VarDecl) ?TokenIndex { - return self.getTrailer(.thread_local_token); - } - - pub fn setThreadLocalToken(self: *VarDecl, value: TokenIndex) void { - self.setTrailer(.thread_local_token, value); - } - - pub fn getEqToken(self: *const VarDecl) ?TokenIndex { - return self.getTrailer(.eq_token); - } - - pub fn setEqToken(self: *VarDecl, value: TokenIndex) void { - self.setTrailer(.eq_token, value); - } - - pub fn getComptimeToken(self: *const VarDecl) ?TokenIndex { - return self.getTrailer(.comptime_token); - } - - pub fn setComptimeToken(self: *VarDecl, value: TokenIndex) void { - self.setTrailer(.comptime_token, value); - } - - pub fn getExternExportToken(self: *const VarDecl) ?TokenIndex { - return self.getTrailer(.extern_export_token); - } - - pub fn setExternExportToken(self: *VarDecl, value: TokenIndex) void { - self.setTrailer(.extern_export_token, value); - } - - pub fn getLibName(self: *const VarDecl) ?*Node { - return self.getTrailer(.lib_name); - } - - pub fn setLibName(self: *VarDecl, value: *Node) void { - self.setTrailer(.lib_name, value); - } - - pub fn getTypeNode(self: *const VarDecl) ?*Node { - return self.getTrailer(.type_node); - } - - pub fn setTypeNode(self: *VarDecl, value: *Node) void { - self.setTrailer(.type_node, value); - } - - pub fn getAlignNode(self: *const VarDecl) ?*Node { - return self.getTrailer(.align_node); - } - - pub fn setAlignNode(self: *VarDecl, value: *Node) void { - self.setTrailer(.align_node, value); - } - - pub fn getSectionNode(self: *const VarDecl) ?*Node { - return self.getTrailer(.section_node); - } - - pub fn setSectionNode(self: *VarDecl, value: *Node) void { - self.setTrailer(.section_node, value); - } - - pub fn getInitNode(self: *const VarDecl) ?*Node { - return self.getTrailer(.init_node); - } - - pub fn setInitNode(self: *VarDecl, value: *Node) void { - self.setTrailer(.init_node, value); - } - - pub const RequiredFields = struct { - mut_token: TokenIndex, - name_token: TokenIndex, - semicolon_token: TokenIndex, - }; - - fn getTrailer(self: *const VarDecl, comptime field: TrailerFlags.FieldEnum) ?TrailerFlags.Field(field) { - const trailers_start = @ptrCast([*]const u8, self) + @sizeOf(VarDecl); - return self.trailer_flags.get(trailers_start, field); - } - - fn setTrailer(self: *VarDecl, comptime field: TrailerFlags.FieldEnum, value: TrailerFlags.Field(field)) void { - const trailers_start = @ptrCast([*]u8, self) + @sizeOf(VarDecl); - self.trailer_flags.set(trailers_start, field, value); - } - - pub fn create(allocator: *mem.Allocator, required: RequiredFields, trailers: TrailerFlags.InitStruct) !*VarDecl { - const trailer_flags = TrailerFlags.init(trailers); - const bytes = try allocator.alignedAlloc(u8, @alignOf(VarDecl), sizeInBytes(trailer_flags)); - const var_decl = @ptrCast(*VarDecl, bytes.ptr); - var_decl.* = .{ - .trailer_flags = trailer_flags, - .mut_token = required.mut_token, - .name_token = required.name_token, - .semicolon_token = required.semicolon_token, - }; - const trailers_start = bytes.ptr + @sizeOf(VarDecl); - trailer_flags.setMany(trailers_start, trailers); - return var_decl; - } - - pub fn destroy(self: *VarDecl, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.trailer_flags)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const VarDecl, index: usize) ?*Node { - var i = index; - - if (self.getTypeNode()) |type_node| { - if (i < 1) return type_node; - i -= 1; - } - - if (self.getAlignNode()) |align_node| { - if (i < 1) return align_node; - i -= 1; - } - - if (self.getSectionNode()) |section_node| { - if (i < 1) return section_node; - i -= 1; - } - - if (self.getInitNode()) |init_node| { - if (i < 1) return init_node; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const VarDecl) TokenIndex { - if (self.getVisibToken()) |visib_token| return visib_token; - if (self.getThreadLocalToken()) |thread_local_token| return thread_local_token; - if (self.getComptimeToken()) |comptime_token| return comptime_token; - if (self.getExternExportToken()) |extern_export_token| return extern_export_token; - assert(self.getLibName() == null); - return self.mut_token; - } - - pub fn lastToken(self: *const VarDecl) TokenIndex { - return self.semicolon_token; - } - - fn sizeInBytes(trailer_flags: TrailerFlags) usize { - return @sizeOf(VarDecl) + trailer_flags.sizeInBytes(); - } - }; - - pub const Use = struct { - base: Node = Node{ .tag = .Use }, - doc_comments: ?*DocComment, - visib_token: ?TokenIndex, - use_token: TokenIndex, - expr: *Node, - semicolon_token: TokenIndex, - - pub fn iterate(self: *const Use, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.expr; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const Use) TokenIndex { - if (self.visib_token) |visib_token| return visib_token; - return self.use_token; - } - - pub fn lastToken(self: *const Use) TokenIndex { - return self.semicolon_token; - } - }; - - pub const ErrorSetDecl = struct { - base: Node = Node{ .tag = .ErrorSetDecl }, - error_token: TokenIndex, - rbrace_token: TokenIndex, - decls_len: NodeIndex, - - /// After this the caller must initialize the decls list. - pub fn alloc(allocator: *mem.Allocator, decls_len: NodeIndex) !*ErrorSetDecl { - const bytes = try allocator.alignedAlloc(u8, @alignOf(ErrorSetDecl), sizeInBytes(decls_len)); - return @ptrCast(*ErrorSetDecl, bytes.ptr); - } - - pub fn free(self: *ErrorSetDecl, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.decls_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const ErrorSetDecl, index: usize) ?*Node { - var i = index; - - if (i < self.decls_len) return self.declsConst()[i]; - i -= self.decls_len; - - return null; - } - - pub fn firstToken(self: *const ErrorSetDecl) TokenIndex { - return self.error_token; - } - - pub fn lastToken(self: *const ErrorSetDecl) TokenIndex { - return self.rbrace_token; - } - - pub fn decls(self: *ErrorSetDecl) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(ErrorSetDecl); - return @ptrCast([*]*Node, decls_start)[0..self.decls_len]; - } - - pub fn declsConst(self: *const ErrorSetDecl) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(ErrorSetDecl); - return @ptrCast([*]const *Node, decls_start)[0..self.decls_len]; - } - - fn sizeInBytes(decls_len: NodeIndex) usize { - return @sizeOf(ErrorSetDecl) + @sizeOf(*Node) * @as(usize, decls_len); - } - }; - - /// The fields and decls Node pointers directly follow this struct in memory. - pub const ContainerDecl = struct { - base: Node = Node{ .tag = .ContainerDecl }, - kind_token: TokenIndex, - layout_token: ?TokenIndex, - lbrace_token: TokenIndex, - rbrace_token: TokenIndex, - fields_and_decls_len: NodeIndex, - init_arg_expr: InitArg, - - pub const InitArg = union(enum) { - None, - Enum: ?*Node, - Type: *Node, - }; - - /// After this the caller must initialize the fields_and_decls list. - pub fn alloc(allocator: *mem.Allocator, fields_and_decls_len: NodeIndex) !*ContainerDecl { - const bytes = try allocator.alignedAlloc(u8, @alignOf(ContainerDecl), sizeInBytes(fields_and_decls_len)); - return @ptrCast(*ContainerDecl, bytes.ptr); - } - - pub fn free(self: *ContainerDecl, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.fields_and_decls_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const ContainerDecl, index: usize) ?*Node { - var i = index; - - switch (self.init_arg_expr) { - .Type => |t| { - if (i < 1) return t; - i -= 1; - }, - .None, .Enum => {}, - } - - if (i < self.fields_and_decls_len) return self.fieldsAndDeclsConst()[i]; - i -= self.fields_and_decls_len; - - return null; - } - - pub fn firstToken(self: *const ContainerDecl) TokenIndex { - if (self.layout_token) |layout_token| { - return layout_token; - } - return self.kind_token; - } - - pub fn lastToken(self: *const ContainerDecl) TokenIndex { - return self.rbrace_token; - } - - pub fn fieldsAndDecls(self: *ContainerDecl) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(ContainerDecl); - return @ptrCast([*]*Node, decls_start)[0..self.fields_and_decls_len]; - } - - pub fn fieldsAndDeclsConst(self: *const ContainerDecl) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(ContainerDecl); - return @ptrCast([*]const *Node, decls_start)[0..self.fields_and_decls_len]; - } - - fn sizeInBytes(fields_and_decls_len: NodeIndex) usize { - return @sizeOf(ContainerDecl) + @sizeOf(*Node) * @as(usize, fields_and_decls_len); - } - }; - - pub const ContainerField = struct { - base: Node = Node{ .tag = .ContainerField }, - doc_comments: ?*DocComment, - comptime_token: ?TokenIndex, - name_token: TokenIndex, - type_expr: ?*Node, - value_expr: ?*Node, - align_expr: ?*Node, - - pub fn iterate(self: *const ContainerField, index: usize) ?*Node { - var i = index; - - if (self.type_expr) |type_expr| { - if (i < 1) return type_expr; - i -= 1; - } - - if (self.align_expr) |align_expr| { - if (i < 1) return align_expr; - i -= 1; - } - - if (self.value_expr) |value_expr| { - if (i < 1) return value_expr; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const ContainerField) TokenIndex { - return self.comptime_token orelse self.name_token; - } - - pub fn lastToken(self: *const ContainerField) TokenIndex { - if (self.value_expr) |value_expr| { - return value_expr.lastToken(); - } - if (self.align_expr) |align_expr| { - // The expression refers to what's inside the parenthesis, the - // last token is the closing one - return align_expr.lastToken() + 1; - } - if (self.type_expr) |type_expr| { - return type_expr.lastToken(); - } - - return self.name_token; - } - }; - - pub const ErrorTag = struct { - base: Node = Node{ .tag = .ErrorTag }, - doc_comments: ?*DocComment, - name_token: TokenIndex, - - pub fn iterate(self: *const ErrorTag, index: usize) ?*Node { - var i = index; - - if (self.doc_comments) |comments| { - if (i < 1) return &comments.base; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const ErrorTag) TokenIndex { - return self.name_token; - } - - pub fn lastToken(self: *const ErrorTag) TokenIndex { - return self.name_token; - } - }; - - pub const OneToken = struct { - base: Node, - token: TokenIndex, - - pub fn iterate(self: *const OneToken, index: usize) ?*Node { - return null; - } - - pub fn firstToken(self: *const OneToken) TokenIndex { - return self.token; - } - - pub fn lastToken(self: *const OneToken) TokenIndex { - return self.token; - } - }; - - /// The params are directly after the FnProto in memory. - /// Next, each optional thing determined by a bit in `trailer_flags`. - pub const FnProto = struct { - base: Node = Node{ .tag = .FnProto }, - trailer_flags: TrailerFlags, - fn_token: TokenIndex, - params_len: NodeIndex, - return_type: ReturnType, - - pub const TrailerFlags = std.meta.TrailerFlags(struct { - doc_comments: *DocComment, - body_node: *Node, - lib_name: *Node, // populated if this is an extern declaration - align_expr: *Node, // populated if align(A) is present - section_expr: *Node, // populated if linksection(A) is present - callconv_expr: *Node, // populated if callconv(A) is present - visib_token: TokenIndex, - name_token: TokenIndex, - var_args_token: TokenIndex, - extern_export_inline_token: TokenIndex, - is_extern_prototype: void, // TODO: Remove once extern fn rewriting is - is_async: void, // TODO: remove once async fn rewriting is - }); - - pub const RequiredFields = struct { - fn_token: TokenIndex, - params_len: NodeIndex, - return_type: ReturnType, - }; - - pub const ReturnType = union(enum) { - Explicit: *Node, - InferErrorSet: *Node, - Invalid: TokenIndex, - }; - - pub const ParamDecl = struct { - doc_comments: ?*DocComment, - comptime_token: ?TokenIndex, - noalias_token: ?TokenIndex, - name_token: ?TokenIndex, - param_type: ParamType, - - pub const ParamType = union(enum) { - any_type: *Node, - type_expr: *Node, - }; - - pub fn iterate(self: *const ParamDecl, index: usize) ?*Node { - var i = index; - - if (i < 1) { - switch (self.param_type) { - .any_type, .type_expr => |node| return node, - } - } - i -= 1; - - return null; - } - - pub fn firstToken(self: *const ParamDecl) TokenIndex { - if (self.comptime_token) |comptime_token| return comptime_token; - if (self.noalias_token) |noalias_token| return noalias_token; - if (self.name_token) |name_token| return name_token; - switch (self.param_type) { - .any_type, .type_expr => |node| return node.firstToken(), - } - } - - pub fn lastToken(self: *const ParamDecl) TokenIndex { - switch (self.param_type) { - .any_type, .type_expr => |node| return node.lastToken(), - } - } - }; - - /// For debugging purposes. - pub fn dump(self: *const FnProto) void { - const trailers_start = @alignCast( - @alignOf(ParamDecl), - @ptrCast([*]const u8, self) + @sizeOf(FnProto) + @sizeOf(ParamDecl) * self.params_len, - ); - std.debug.print("{*} flags: {b} name_token: {} {*} params_len: {}\n", .{ - self, - self.trailer_flags.bits, - self.getNameToken(), - self.trailer_flags.ptrConst(trailers_start, .name_token), - self.params_len, - }); - } - - pub fn getDocComments(self: *const FnProto) ?*DocComment { - return self.getTrailer(.doc_comments); - } - - pub fn setDocComments(self: *FnProto, value: *DocComment) void { - self.setTrailer(.doc_comments, value); - } - - pub fn getBodyNode(self: *const FnProto) ?*Node { - return self.getTrailer(.body_node); - } - - pub fn setBodyNode(self: *FnProto, value: *Node) void { - self.setTrailer(.body_node, value); - } - - pub fn getLibName(self: *const FnProto) ?*Node { - return self.getTrailer(.lib_name); - } - - pub fn setLibName(self: *FnProto, value: *Node) void { - self.setTrailer(.lib_name, value); - } - - pub fn getAlignExpr(self: *const FnProto) ?*Node { - return self.getTrailer(.align_expr); - } - - pub fn setAlignExpr(self: *FnProto, value: *Node) void { - self.setTrailer(.align_expr, value); - } - - pub fn getSectionExpr(self: *const FnProto) ?*Node { - return self.getTrailer(.section_expr); - } - - pub fn setSectionExpr(self: *FnProto, value: *Node) void { - self.setTrailer(.section_expr, value); - } - - pub fn getCallconvExpr(self: *const FnProto) ?*Node { - return self.getTrailer(.callconv_expr); - } - - pub fn setCallconvExpr(self: *FnProto, value: *Node) void { - self.setTrailer(.callconv_expr, value); - } - - pub fn getVisibToken(self: *const FnProto) ?TokenIndex { - return self.getTrailer(.visib_token); - } - - pub fn setVisibToken(self: *FnProto, value: TokenIndex) void { - self.setTrailer(.visib_token, value); - } - - pub fn getNameToken(self: *const FnProto) ?TokenIndex { - return self.getTrailer(.name_token); - } - - pub fn setNameToken(self: *FnProto, value: TokenIndex) void { - self.setTrailer(.name_token, value); - } - - pub fn getVarArgsToken(self: *const FnProto) ?TokenIndex { - return self.getTrailer(.var_args_token); - } - - pub fn setVarArgsToken(self: *FnProto, value: TokenIndex) void { - self.setTrailer(.var_args_token, value); - } - - pub fn getExternExportInlineToken(self: *const FnProto) ?TokenIndex { - return self.getTrailer(.extern_export_inline_token); - } - - pub fn setExternExportInlineToken(self: *FnProto, value: TokenIndex) void { - self.setTrailer(.extern_export_inline_token, value); - } - - pub fn getIsExternPrototype(self: *const FnProto) ?void { - return self.getTrailer(.is_extern_prototype); - } - - pub fn setIsExternPrototype(self: *FnProto, value: void) void { - self.setTrailer(.is_extern_prototype, value); - } - - pub fn getIsAsync(self: *const FnProto) ?void { - return self.getTrailer(.is_async); - } - - pub fn setIsAsync(self: *FnProto, value: void) void { - self.setTrailer(.is_async, value); - } - - fn getTrailer(self: *const FnProto, comptime field: TrailerFlags.FieldEnum) ?TrailerFlags.Field(field) { - const trailers_start = @alignCast( - @alignOf(ParamDecl), - @ptrCast([*]const u8, self) + @sizeOf(FnProto) + @sizeOf(ParamDecl) * self.params_len, - ); - return self.trailer_flags.get(trailers_start, field); - } - - fn setTrailer(self: *FnProto, comptime field: TrailerFlags.FieldEnum, value: TrailerFlags.Field(field)) void { - const trailers_start = @alignCast( - @alignOf(ParamDecl), - @ptrCast([*]u8, self) + @sizeOf(FnProto) + @sizeOf(ParamDecl) * self.params_len, - ); - self.trailer_flags.set(trailers_start, field, value); - } - - /// After this the caller must initialize the params list. - pub fn create(allocator: *mem.Allocator, required: RequiredFields, trailers: TrailerFlags.InitStruct) !*FnProto { - const trailer_flags = TrailerFlags.init(trailers); - const bytes = try allocator.alignedAlloc(u8, @alignOf(FnProto), sizeInBytes( - required.params_len, - trailer_flags, - )); - const fn_proto = @ptrCast(*FnProto, bytes.ptr); - fn_proto.* = .{ - .trailer_flags = trailer_flags, - .fn_token = required.fn_token, - .params_len = required.params_len, - .return_type = required.return_type, - }; - const trailers_start = @alignCast( - @alignOf(ParamDecl), - bytes.ptr + @sizeOf(FnProto) + @sizeOf(ParamDecl) * required.params_len, - ); - trailer_flags.setMany(trailers_start, trailers); - return fn_proto; - } - - pub fn destroy(self: *FnProto, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.params_len, self.trailer_flags)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const FnProto, index: usize) ?*Node { - var i = index; - - if (self.getLibName()) |lib_name| { - if (i < 1) return lib_name; - i -= 1; - } - - const params_len: usize = if (self.params_len == 0) - 0 - else switch (self.paramsConst()[self.params_len - 1].param_type) { - .any_type, .type_expr => self.params_len, - }; - if (i < params_len) { - switch (self.paramsConst()[i].param_type) { - .any_type => |n| return n, - .type_expr => |n| return n, - } - } - i -= params_len; - - if (self.getAlignExpr()) |align_expr| { - if (i < 1) return align_expr; - i -= 1; - } - - if (self.getSectionExpr()) |section_expr| { - if (i < 1) return section_expr; - i -= 1; - } - - switch (self.return_type) { - .Explicit, .InferErrorSet => |node| { - if (i < 1) return node; - i -= 1; - }, - .Invalid => {}, - } - - if (self.getBodyNode()) |body_node| { - if (i < 1) return body_node; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const FnProto) TokenIndex { - if (self.getVisibToken()) |visib_token| return visib_token; - if (self.getExternExportInlineToken()) |extern_export_inline_token| return extern_export_inline_token; - assert(self.getLibName() == null); - return self.fn_token; - } - - pub fn lastToken(self: *const FnProto) TokenIndex { - if (self.getBodyNode()) |body_node| return body_node.lastToken(); - switch (self.return_type) { - .Explicit, .InferErrorSet => |node| return node.lastToken(), - .Invalid => |tok| return tok, - } - } - - pub fn params(self: *FnProto) []ParamDecl { - const params_start = @ptrCast([*]u8, self) + @sizeOf(FnProto); - return @ptrCast([*]ParamDecl, params_start)[0..self.params_len]; - } - - pub fn paramsConst(self: *const FnProto) []const ParamDecl { - const params_start = @ptrCast([*]const u8, self) + @sizeOf(FnProto); - return @ptrCast([*]const ParamDecl, params_start)[0..self.params_len]; - } - - fn sizeInBytes(params_len: NodeIndex, trailer_flags: TrailerFlags) usize { - return @sizeOf(FnProto) + @sizeOf(ParamDecl) * @as(usize, params_len) + trailer_flags.sizeInBytes(); - } - }; - - pub const AnyFrameType = struct { - base: Node = Node{ .tag = .AnyFrameType }, - anyframe_token: TokenIndex, - result: ?Result, - - pub const Result = struct { - arrow_token: TokenIndex, - return_type: *Node, - }; - - pub fn iterate(self: *const AnyFrameType, index: usize) ?*Node { - var i = index; - - if (self.result) |result| { - if (i < 1) return result.return_type; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const AnyFrameType) TokenIndex { - return self.anyframe_token; - } - - pub fn lastToken(self: *const AnyFrameType) TokenIndex { - if (self.result) |result| return result.return_type.lastToken(); - return self.anyframe_token; - } - }; - - /// The statements of the block follow Block directly in memory. - pub const Block = struct { - base: Node = Node{ .tag = .Block }, - statements_len: NodeIndex, - lbrace: TokenIndex, - rbrace: TokenIndex, - - /// After this the caller must initialize the statements list. - pub fn alloc(allocator: *mem.Allocator, statements_len: NodeIndex) !*Block { - const bytes = try allocator.alignedAlloc(u8, @alignOf(Block), sizeInBytes(statements_len)); - return @ptrCast(*Block, bytes.ptr); - } - - pub fn free(self: *Block, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.statements_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const Block, index: usize) ?*Node { - var i = index; - - if (i < self.statements_len) return self.statementsConst()[i]; - i -= self.statements_len; - - return null; - } - - pub fn firstToken(self: *const Block) TokenIndex { - return self.lbrace; - } - - pub fn lastToken(self: *const Block) TokenIndex { - return self.rbrace; - } - - pub fn statements(self: *Block) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(Block); - return @ptrCast([*]*Node, decls_start)[0..self.statements_len]; - } - - pub fn statementsConst(self: *const Block) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(Block); - return @ptrCast([*]const *Node, decls_start)[0..self.statements_len]; - } - - fn sizeInBytes(statements_len: NodeIndex) usize { - return @sizeOf(Block) + @sizeOf(*Node) * @as(usize, statements_len); - } - }; - - /// The statements of the block follow LabeledBlock directly in memory. - pub const LabeledBlock = struct { - base: Node = Node{ .tag = .LabeledBlock }, - statements_len: NodeIndex, - lbrace: TokenIndex, - rbrace: TokenIndex, - label: TokenIndex, - - /// After this the caller must initialize the statements list. - pub fn alloc(allocator: *mem.Allocator, statements_len: NodeIndex) !*LabeledBlock { - const bytes = try allocator.alignedAlloc(u8, @alignOf(LabeledBlock), sizeInBytes(statements_len)); - return @ptrCast(*LabeledBlock, bytes.ptr); - } - - pub fn free(self: *LabeledBlock, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.statements_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const LabeledBlock, index: usize) ?*Node { - var i = index; - - if (i < self.statements_len) return self.statementsConst()[i]; - i -= self.statements_len; - - return null; - } - - pub fn firstToken(self: *const LabeledBlock) TokenIndex { - return self.label; - } - - pub fn lastToken(self: *const LabeledBlock) TokenIndex { - return self.rbrace; - } - - pub fn statements(self: *LabeledBlock) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(LabeledBlock); - return @ptrCast([*]*Node, decls_start)[0..self.statements_len]; - } - - pub fn statementsConst(self: *const LabeledBlock) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(LabeledBlock); - return @ptrCast([*]const *Node, decls_start)[0..self.statements_len]; - } - - fn sizeInBytes(statements_len: NodeIndex) usize { - return @sizeOf(LabeledBlock) + @sizeOf(*Node) * @as(usize, statements_len); - } - }; - - pub const Defer = struct { - base: Node = Node{ .tag = .Defer }, - defer_token: TokenIndex, - payload: ?*Node, - expr: *Node, - - pub fn iterate(self: *const Defer, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.expr; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const Defer) TokenIndex { - return self.defer_token; - } - - pub fn lastToken(self: *const Defer) TokenIndex { - return self.expr.lastToken(); - } - }; - - pub const Comptime = struct { - base: Node = Node{ .tag = .Comptime }, - doc_comments: ?*DocComment, - comptime_token: TokenIndex, - expr: *Node, - - pub fn iterate(self: *const Comptime, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.expr; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const Comptime) TokenIndex { - return self.comptime_token; - } - - pub fn lastToken(self: *const Comptime) TokenIndex { - return self.expr.lastToken(); - } - }; - - pub const Nosuspend = struct { - base: Node = Node{ .tag = .Nosuspend }, - nosuspend_token: TokenIndex, - expr: *Node, - - pub fn iterate(self: *const Nosuspend, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.expr; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const Nosuspend) TokenIndex { - return self.nosuspend_token; - } - - pub fn lastToken(self: *const Nosuspend) TokenIndex { - return self.expr.lastToken(); - } - }; - - pub const Payload = struct { - base: Node = Node{ .tag = .Payload }, - lpipe: TokenIndex, - error_symbol: *Node, - rpipe: TokenIndex, - - pub fn iterate(self: *const Payload, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.error_symbol; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const Payload) TokenIndex { - return self.lpipe; - } - - pub fn lastToken(self: *const Payload) TokenIndex { - return self.rpipe; - } - }; - - pub const PointerPayload = struct { - base: Node = Node{ .tag = .PointerPayload }, - lpipe: TokenIndex, - ptr_token: ?TokenIndex, - value_symbol: *Node, - rpipe: TokenIndex, - - pub fn iterate(self: *const PointerPayload, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.value_symbol; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const PointerPayload) TokenIndex { - return self.lpipe; - } - - pub fn lastToken(self: *const PointerPayload) TokenIndex { - return self.rpipe; - } - }; - - pub const PointerIndexPayload = struct { - base: Node = Node{ .tag = .PointerIndexPayload }, - lpipe: TokenIndex, - ptr_token: ?TokenIndex, - value_symbol: *Node, - index_symbol: ?*Node, - rpipe: TokenIndex, - - pub fn iterate(self: *const PointerIndexPayload, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.value_symbol; - i -= 1; - - if (self.index_symbol) |index_symbol| { - if (i < 1) return index_symbol; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const PointerIndexPayload) TokenIndex { - return self.lpipe; - } - - pub fn lastToken(self: *const PointerIndexPayload) TokenIndex { - return self.rpipe; - } - }; - - pub const Else = struct { - base: Node = Node{ .tag = .Else }, - else_token: TokenIndex, - payload: ?*Node, - body: *Node, - - pub fn iterate(self: *const Else, index: usize) ?*Node { - var i = index; - - if (self.payload) |payload| { - if (i < 1) return payload; - i -= 1; - } - - if (i < 1) return self.body; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const Else) TokenIndex { - return self.else_token; - } - - pub fn lastToken(self: *const Else) TokenIndex { - return self.body.lastToken(); - } - }; - - /// The cases node pointers are found in memory after Switch. - /// They must be SwitchCase or SwitchElse nodes. - pub const Switch = struct { - base: Node = Node{ .tag = .Switch }, - switch_token: TokenIndex, - rbrace: TokenIndex, - cases_len: NodeIndex, - expr: *Node, - - /// After this the caller must initialize the fields_and_decls list. - pub fn alloc(allocator: *mem.Allocator, cases_len: NodeIndex) !*Switch { - const bytes = try allocator.alignedAlloc(u8, @alignOf(Switch), sizeInBytes(cases_len)); - return @ptrCast(*Switch, bytes.ptr); - } - - pub fn free(self: *Switch, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.cases_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const Switch, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.expr; - i -= 1; - - if (i < self.cases_len) return self.casesConst()[i]; - i -= self.cases_len; - - return null; - } - - pub fn firstToken(self: *const Switch) TokenIndex { - return self.switch_token; - } - - pub fn lastToken(self: *const Switch) TokenIndex { - return self.rbrace; - } - - pub fn cases(self: *Switch) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(Switch); - return @ptrCast([*]*Node, decls_start)[0..self.cases_len]; - } - - pub fn casesConst(self: *const Switch) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(Switch); - return @ptrCast([*]const *Node, decls_start)[0..self.cases_len]; - } - - fn sizeInBytes(cases_len: NodeIndex) usize { - return @sizeOf(Switch) + @sizeOf(*Node) * @as(usize, cases_len); - } - }; - - /// Items sub-nodes appear in memory directly following SwitchCase. - pub const SwitchCase = struct { - base: Node = Node{ .tag = .SwitchCase }, - arrow_token: TokenIndex, - payload: ?*Node, - expr: *Node, - items_len: NodeIndex, - - /// After this the caller must initialize the fields_and_decls list. - pub fn alloc(allocator: *mem.Allocator, items_len: NodeIndex) !*SwitchCase { - const bytes = try allocator.alignedAlloc(u8, @alignOf(SwitchCase), sizeInBytes(items_len)); - return @ptrCast(*SwitchCase, bytes.ptr); - } - - pub fn free(self: *SwitchCase, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.items_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const SwitchCase, index: usize) ?*Node { - var i = index; - - if (i < self.items_len) return self.itemsConst()[i]; - i -= self.items_len; - - if (self.payload) |payload| { - if (i < 1) return payload; - i -= 1; - } - - if (i < 1) return self.expr; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const SwitchCase) TokenIndex { - return self.itemsConst()[0].firstToken(); - } - - pub fn lastToken(self: *const SwitchCase) TokenIndex { - return self.expr.lastToken(); - } - - pub fn items(self: *SwitchCase) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(SwitchCase); - return @ptrCast([*]*Node, decls_start)[0..self.items_len]; - } - - pub fn itemsConst(self: *const SwitchCase) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(SwitchCase); - return @ptrCast([*]const *Node, decls_start)[0..self.items_len]; - } - - fn sizeInBytes(items_len: NodeIndex) usize { - return @sizeOf(SwitchCase) + @sizeOf(*Node) * @as(usize, items_len); - } - }; - - pub const SwitchElse = struct { - base: Node = Node{ .tag = .SwitchElse }, - token: TokenIndex, - - pub fn iterate(self: *const SwitchElse, index: usize) ?*Node { - return null; - } - - pub fn firstToken(self: *const SwitchElse) TokenIndex { - return self.token; - } - - pub fn lastToken(self: *const SwitchElse) TokenIndex { - return self.token; - } - }; - - pub const While = struct { - base: Node = Node{ .tag = .While }, - label: ?TokenIndex, - inline_token: ?TokenIndex, - while_token: TokenIndex, - condition: *Node, - payload: ?*Node, - continue_expr: ?*Node, - body: *Node, - @"else": ?*Else, - - pub fn iterate(self: *const While, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.condition; - i -= 1; - - if (self.payload) |payload| { - if (i < 1) return payload; - i -= 1; - } - - if (self.continue_expr) |continue_expr| { - if (i < 1) return continue_expr; - i -= 1; - } - - if (i < 1) return self.body; - i -= 1; - - if (self.@"else") |@"else"| { - if (i < 1) return &@"else".base; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const While) TokenIndex { - if (self.label) |label| { - return label; - } - - if (self.inline_token) |inline_token| { - return inline_token; - } - - return self.while_token; - } - - pub fn lastToken(self: *const While) TokenIndex { - if (self.@"else") |@"else"| { - return @"else".body.lastToken(); - } - - return self.body.lastToken(); - } - }; - - pub const For = struct { - base: Node = Node{ .tag = .For }, - label: ?TokenIndex, - inline_token: ?TokenIndex, - for_token: TokenIndex, - array_expr: *Node, - payload: *Node, - body: *Node, - @"else": ?*Else, - - pub fn iterate(self: *const For, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.array_expr; - i -= 1; - - if (i < 1) return self.payload; - i -= 1; - - if (i < 1) return self.body; - i -= 1; - - if (self.@"else") |@"else"| { - if (i < 1) return &@"else".base; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const For) TokenIndex { - if (self.label) |label| { - return label; - } - - if (self.inline_token) |inline_token| { - return inline_token; - } - - return self.for_token; - } - - pub fn lastToken(self: *const For) TokenIndex { - if (self.@"else") |@"else"| { - return @"else".body.lastToken(); - } - - return self.body.lastToken(); - } - }; - - pub const If = struct { - base: Node = Node{ .tag = .If }, - if_token: TokenIndex, - condition: *Node, - payload: ?*Node, - body: *Node, - @"else": ?*Else, - - pub fn iterate(self: *const If, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.condition; - i -= 1; - - if (self.payload) |payload| { - if (i < 1) return payload; - i -= 1; - } - - if (i < 1) return self.body; - i -= 1; - - if (self.@"else") |@"else"| { - if (i < 1) return &@"else".base; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const If) TokenIndex { - return self.if_token; - } - - pub fn lastToken(self: *const If) TokenIndex { - if (self.@"else") |@"else"| { - return @"else".body.lastToken(); - } - - return self.body.lastToken(); - } - }; - - pub const Catch = struct { - base: Node = Node{ .tag = .Catch }, - op_token: TokenIndex, - lhs: *Node, - rhs: *Node, - payload: ?*Node, - - pub fn iterate(self: *const Catch, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.lhs; - i -= 1; - - if (self.payload) |payload| { - if (i < 1) return payload; - i -= 1; - } - - if (i < 1) return self.rhs; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const Catch) TokenIndex { - return self.lhs.firstToken(); - } - - pub fn lastToken(self: *const Catch) TokenIndex { - return self.rhs.lastToken(); - } - }; - - pub const SimpleInfixOp = struct { - base: Node, - op_token: TokenIndex, - lhs: *Node, - rhs: *Node, - - pub fn iterate(self: *const SimpleInfixOp, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.lhs; - i -= 1; - - if (i < 1) return self.rhs; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const SimpleInfixOp) TokenIndex { - return self.lhs.firstToken(); - } - - pub fn lastToken(self: *const SimpleInfixOp) TokenIndex { - return self.rhs.lastToken(); - } - }; - - pub const SimplePrefixOp = struct { - base: Node, - op_token: TokenIndex, - rhs: *Node, - - const Self = @This(); - - pub fn iterate(self: *const Self, index: usize) ?*Node { - if (index == 0) return self.rhs; - return null; - } - - pub fn firstToken(self: *const Self) TokenIndex { - return self.op_token; - } - - pub fn lastToken(self: *const Self) TokenIndex { - return self.rhs.lastToken(); - } - }; - - pub const ArrayType = struct { - base: Node = Node{ .tag = .ArrayType }, - op_token: TokenIndex, - rhs: *Node, - len_expr: *Node, - - pub fn iterate(self: *const ArrayType, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.len_expr; - i -= 1; - - if (i < 1) return self.rhs; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const ArrayType) TokenIndex { - return self.op_token; - } - - pub fn lastToken(self: *const ArrayType) TokenIndex { - return self.rhs.lastToken(); - } + pub const LocalVarDecl = struct { + type_node: Index, + align_node: Index, }; pub const ArrayTypeSentinel = struct { - base: Node = Node{ .tag = .ArrayTypeSentinel }, - op_token: TokenIndex, - rhs: *Node, - len_expr: *Node, - sentinel: *Node, - - pub fn iterate(self: *const ArrayTypeSentinel, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.len_expr; - i -= 1; - - if (i < 1) return self.sentinel; - i -= 1; - - if (i < 1) return self.rhs; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const ArrayTypeSentinel) TokenIndex { - return self.op_token; - } - - pub fn lastToken(self: *const ArrayTypeSentinel) TokenIndex { - return self.rhs.lastToken(); - } + elem_type: Index, + sentinel: Index, }; pub const PtrType = struct { - base: Node = Node{ .tag = .PtrType }, - op_token: TokenIndex, - rhs: *Node, - /// TODO Add a u8 flags field to Node where it would otherwise be padding, and each bit represents - /// one of these possibly-null things. Then we have them directly follow the PtrType in memory. - ptr_info: PtrInfo = .{}, - - pub fn iterate(self: *const PtrType, index: usize) ?*Node { - var i = index; - - if (self.ptr_info.sentinel) |sentinel| { - if (i < 1) return sentinel; - i -= 1; - } - - if (self.ptr_info.align_info) |align_info| { - if (i < 1) return align_info.node; - i -= 1; - } - - if (i < 1) return self.rhs; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const PtrType) TokenIndex { - return self.op_token; - } - - pub fn lastToken(self: *const PtrType) TokenIndex { - return self.rhs.lastToken(); - } + sentinel: Index, + align_node: Index, }; - pub const SliceType = struct { - base: Node = Node{ .tag = .SliceType }, - op_token: TokenIndex, - rhs: *Node, - /// TODO Add a u8 flags field to Node where it would otherwise be padding, and each bit represents - /// one of these possibly-null things. Then we have them directly follow the SliceType in memory. - ptr_info: PtrInfo = .{}, - - pub fn iterate(self: *const SliceType, index: usize) ?*Node { - var i = index; - - if (self.ptr_info.sentinel) |sentinel| { - if (i < 1) return sentinel; - i -= 1; - } - - if (self.ptr_info.align_info) |align_info| { - if (i < 1) return align_info.node; - i -= 1; - } - - if (i < 1) return self.rhs; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const SliceType) TokenIndex { - return self.op_token; - } - - pub fn lastToken(self: *const SliceType) TokenIndex { - return self.rhs.lastToken(); - } + pub const PtrTypeBitRange = struct { + sentinel: Index, + align_node: Index, + bit_range_start: Index, + bit_range_end: Index, }; - pub const FieldInitializer = struct { - base: Node = Node{ .tag = .FieldInitializer }, - period_token: TokenIndex, - name_token: TokenIndex, - expr: *Node, - - pub fn iterate(self: *const FieldInitializer, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.expr; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const FieldInitializer) TokenIndex { - return self.period_token; - } - - pub fn lastToken(self: *const FieldInitializer) TokenIndex { - return self.expr.lastToken(); - } + pub const SubRange = struct { + /// Index into sub_list. + start: Index, + /// Index into sub_list. + end: Index, }; - /// Elements occur directly in memory after ArrayInitializer. - pub const ArrayInitializer = struct { - base: Node = Node{ .tag = .ArrayInitializer }, - rtoken: TokenIndex, - list_len: NodeIndex, - lhs: *Node, - - /// After this the caller must initialize the fields_and_decls list. - pub fn alloc(allocator: *mem.Allocator, list_len: NodeIndex) !*ArrayInitializer { - const bytes = try allocator.alignedAlloc(u8, @alignOf(ArrayInitializer), sizeInBytes(list_len)); - return @ptrCast(*ArrayInitializer, bytes.ptr); - } - - pub fn free(self: *ArrayInitializer, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.list_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const ArrayInitializer, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.lhs; - i -= 1; - - if (i < self.list_len) return self.listConst()[i]; - i -= self.list_len; - - return null; - } - - pub fn firstToken(self: *const ArrayInitializer) TokenIndex { - return self.lhs.firstToken(); - } - - pub fn lastToken(self: *const ArrayInitializer) TokenIndex { - return self.rtoken; - } - - pub fn list(self: *ArrayInitializer) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(ArrayInitializer); - return @ptrCast([*]*Node, decls_start)[0..self.list_len]; - } - - pub fn listConst(self: *const ArrayInitializer) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(ArrayInitializer); - return @ptrCast([*]const *Node, decls_start)[0..self.list_len]; - } - - fn sizeInBytes(list_len: NodeIndex) usize { - return @sizeOf(ArrayInitializer) + @sizeOf(*Node) * @as(usize, list_len); - } + pub const If = struct { + then_expr: Index, + else_expr: Index, }; - /// Elements occur directly in memory after ArrayInitializerDot. - pub const ArrayInitializerDot = struct { - base: Node = Node{ .tag = .ArrayInitializerDot }, - dot: TokenIndex, - rtoken: TokenIndex, - list_len: NodeIndex, - - /// After this the caller must initialize the fields_and_decls list. - pub fn alloc(allocator: *mem.Allocator, list_len: NodeIndex) !*ArrayInitializerDot { - const bytes = try allocator.alignedAlloc(u8, @alignOf(ArrayInitializerDot), sizeInBytes(list_len)); - return @ptrCast(*ArrayInitializerDot, bytes.ptr); - } - - pub fn free(self: *ArrayInitializerDot, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.list_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const ArrayInitializerDot, index: usize) ?*Node { - var i = index; - - if (i < self.list_len) return self.listConst()[i]; - i -= self.list_len; - - return null; - } - - pub fn firstToken(self: *const ArrayInitializerDot) TokenIndex { - return self.dot; - } - - pub fn lastToken(self: *const ArrayInitializerDot) TokenIndex { - return self.rtoken; - } - - pub fn list(self: *ArrayInitializerDot) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(ArrayInitializerDot); - return @ptrCast([*]*Node, decls_start)[0..self.list_len]; - } - - pub fn listConst(self: *const ArrayInitializerDot) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(ArrayInitializerDot); - return @ptrCast([*]const *Node, decls_start)[0..self.list_len]; - } - - fn sizeInBytes(list_len: NodeIndex) usize { - return @sizeOf(ArrayInitializerDot) + @sizeOf(*Node) * @as(usize, list_len); - } + pub const ContainerField = struct { + value_expr: Index, + align_expr: Index, }; - /// Elements occur directly in memory after StructInitializer. - pub const StructInitializer = struct { - base: Node = Node{ .tag = .StructInitializer }, - rtoken: TokenIndex, - list_len: NodeIndex, - lhs: *Node, - - /// After this the caller must initialize the fields_and_decls list. - pub fn alloc(allocator: *mem.Allocator, list_len: NodeIndex) !*StructInitializer { - const bytes = try allocator.alignedAlloc(u8, @alignOf(StructInitializer), sizeInBytes(list_len)); - return @ptrCast(*StructInitializer, bytes.ptr); - } - - pub fn free(self: *StructInitializer, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.list_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const StructInitializer, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.lhs; - i -= 1; - - if (i < self.list_len) return self.listConst()[i]; - i -= self.list_len; - - return null; - } - - pub fn firstToken(self: *const StructInitializer) TokenIndex { - return self.lhs.firstToken(); - } - - pub fn lastToken(self: *const StructInitializer) TokenIndex { - return self.rtoken; - } - - pub fn list(self: *StructInitializer) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(StructInitializer); - return @ptrCast([*]*Node, decls_start)[0..self.list_len]; - } - - pub fn listConst(self: *const StructInitializer) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(StructInitializer); - return @ptrCast([*]const *Node, decls_start)[0..self.list_len]; - } - - fn sizeInBytes(list_len: NodeIndex) usize { - return @sizeOf(StructInitializer) + @sizeOf(*Node) * @as(usize, list_len); - } - }; - - /// Elements occur directly in memory after StructInitializerDot. - pub const StructInitializerDot = struct { - base: Node = Node{ .tag = .StructInitializerDot }, - dot: TokenIndex, - rtoken: TokenIndex, - list_len: NodeIndex, - - /// After this the caller must initialize the fields_and_decls list. - pub fn alloc(allocator: *mem.Allocator, list_len: NodeIndex) !*StructInitializerDot { - const bytes = try allocator.alignedAlloc(u8, @alignOf(StructInitializerDot), sizeInBytes(list_len)); - return @ptrCast(*StructInitializerDot, bytes.ptr); - } - - pub fn free(self: *StructInitializerDot, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.list_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const StructInitializerDot, index: usize) ?*Node { - var i = index; - - if (i < self.list_len) return self.listConst()[i]; - i -= self.list_len; - - return null; - } - - pub fn firstToken(self: *const StructInitializerDot) TokenIndex { - return self.dot; - } - - pub fn lastToken(self: *const StructInitializerDot) TokenIndex { - return self.rtoken; - } - - pub fn list(self: *StructInitializerDot) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(StructInitializerDot); - return @ptrCast([*]*Node, decls_start)[0..self.list_len]; - } - - pub fn listConst(self: *const StructInitializerDot) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(StructInitializerDot); - return @ptrCast([*]const *Node, decls_start)[0..self.list_len]; - } - - fn sizeInBytes(list_len: NodeIndex) usize { - return @sizeOf(StructInitializerDot) + @sizeOf(*Node) * @as(usize, list_len); - } - }; - - /// Parameter nodes directly follow Call in memory. - pub const Call = struct { - base: Node = Node{ .tag = .Call }, - rtoken: TokenIndex, - lhs: *Node, - params_len: NodeIndex, - async_token: ?TokenIndex, - - /// After this the caller must initialize the fields_and_decls list. - pub fn alloc(allocator: *mem.Allocator, params_len: NodeIndex) !*Call { - const bytes = try allocator.alignedAlloc(u8, @alignOf(Call), sizeInBytes(params_len)); - return @ptrCast(*Call, bytes.ptr); - } - - pub fn free(self: *Call, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.params_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const Call, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.lhs; - i -= 1; - - if (i < self.params_len) return self.paramsConst()[i]; - i -= self.params_len; - - return null; - } - - pub fn firstToken(self: *const Call) TokenIndex { - if (self.async_token) |async_token| return async_token; - return self.lhs.firstToken(); - } - - pub fn lastToken(self: *const Call) TokenIndex { - return self.rtoken; - } - - pub fn params(self: *Call) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(Call); - return @ptrCast([*]*Node, decls_start)[0..self.params_len]; - } - - pub fn paramsConst(self: *const Call) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(Call); - return @ptrCast([*]const *Node, decls_start)[0..self.params_len]; - } - - fn sizeInBytes(params_len: NodeIndex) usize { - return @sizeOf(Call) + @sizeOf(*Node) * @as(usize, params_len); - } - }; - - pub const ArrayAccess = struct { - base: Node = Node{ .tag = .ArrayAccess }, - rtoken: TokenIndex, - lhs: *Node, - index_expr: *Node, - - pub fn iterate(self: *const ArrayAccess, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.lhs; - i -= 1; - - if (i < 1) return self.index_expr; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const ArrayAccess) TokenIndex { - return self.lhs.firstToken(); - } - - pub fn lastToken(self: *const ArrayAccess) TokenIndex { - return self.rtoken; - } - }; - - pub const SimpleSuffixOp = struct { - base: Node, - rtoken: TokenIndex, - lhs: *Node, - - pub fn iterate(self: *const SimpleSuffixOp, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.lhs; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const SimpleSuffixOp) TokenIndex { - return self.lhs.firstToken(); - } - - pub fn lastToken(self: *const SimpleSuffixOp) TokenIndex { - return self.rtoken; - } + pub const GlobalVarDecl = struct { + type_node: Index, + align_node: Index, + section_node: Index, }; pub const Slice = struct { - base: Node = Node{ .tag = .Slice }, - rtoken: TokenIndex, - lhs: *Node, - start: *Node, - end: ?*Node, - sentinel: ?*Node, - - pub fn iterate(self: *const Slice, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.lhs; - i -= 1; - - if (i < 1) return self.start; - i -= 1; - - if (self.end) |end| { - if (i < 1) return end; - i -= 1; - } - if (self.sentinel) |sentinel| { - if (i < 1) return sentinel; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const Slice) TokenIndex { - return self.lhs.firstToken(); - } - - pub fn lastToken(self: *const Slice) TokenIndex { - return self.rtoken; - } + start: Index, + end: Index, }; - pub const GroupedExpression = struct { - base: Node = Node{ .tag = .GroupedExpression }, - lparen: TokenIndex, - expr: *Node, - rparen: TokenIndex, - - pub fn iterate(self: *const GroupedExpression, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.expr; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const GroupedExpression) TokenIndex { - return self.lparen; - } - - pub fn lastToken(self: *const GroupedExpression) TokenIndex { - return self.rparen; - } + pub const SliceSentinel = struct { + start: Index, + end: Index, + sentinel: Index, }; - /// Trailed in memory by possibly many things, with each optional thing - /// determined by a bit in `trailer_flags`. - /// Can be: return, break, continue - pub const ControlFlowExpression = struct { - base: Node, - trailer_flags: TrailerFlags, - ltoken: TokenIndex, - - pub const TrailerFlags = std.meta.TrailerFlags(struct { - rhs: *Node, - label: TokenIndex, - }); - - pub const RequiredFields = struct { - tag: Tag, - ltoken: TokenIndex, - }; - - pub fn getRHS(self: *const ControlFlowExpression) ?*Node { - return self.getTrailer(.rhs); - } - - pub fn setRHS(self: *ControlFlowExpression, value: *Node) void { - self.setTrailer(.rhs, value); - } - - pub fn getLabel(self: *const ControlFlowExpression) ?TokenIndex { - return self.getTrailer(.label); - } - - pub fn setLabel(self: *ControlFlowExpression, value: TokenIndex) void { - self.setTrailer(.label, value); - } - - fn getTrailer(self: *const ControlFlowExpression, comptime field: TrailerFlags.FieldEnum) ?TrailerFlags.Field(field) { - const trailers_start = @ptrCast([*]const u8, self) + @sizeOf(ControlFlowExpression); - return self.trailer_flags.get(trailers_start, field); - } - - fn setTrailer(self: *ControlFlowExpression, comptime field: TrailerFlags.FieldEnum, value: TrailerFlags.Field(field)) void { - const trailers_start = @ptrCast([*]u8, self) + @sizeOf(ControlFlowExpression); - self.trailer_flags.set(trailers_start, field, value); - } - - pub fn create(allocator: *mem.Allocator, required: RequiredFields, trailers: TrailerFlags.InitStruct) !*ControlFlowExpression { - const trailer_flags = TrailerFlags.init(trailers); - const bytes = try allocator.alignedAlloc(u8, @alignOf(ControlFlowExpression), sizeInBytes(trailer_flags)); - const ctrl_flow_expr = @ptrCast(*ControlFlowExpression, bytes.ptr); - ctrl_flow_expr.* = .{ - .base = .{ .tag = required.tag }, - .trailer_flags = trailer_flags, - .ltoken = required.ltoken, - }; - const trailers_start = bytes.ptr + @sizeOf(ControlFlowExpression); - trailer_flags.setMany(trailers_start, trailers); - return ctrl_flow_expr; - } - - pub fn destroy(self: *ControlFlowExpression, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.trailer_flags)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const ControlFlowExpression, index: usize) ?*Node { - var i = index; - - if (self.getRHS()) |rhs| { - if (i < 1) return rhs; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const ControlFlowExpression) TokenIndex { - return self.ltoken; - } - - pub fn lastToken(self: *const ControlFlowExpression) TokenIndex { - if (self.getRHS()) |rhs| { - return rhs.lastToken(); - } - - if (self.getLabel()) |label| { - return label; - } - - return self.ltoken; - } - - fn sizeInBytes(trailer_flags: TrailerFlags) usize { - return @sizeOf(ControlFlowExpression) + trailer_flags.sizeInBytes(); - } + pub const While = struct { + cont_expr: Index, + then_expr: Index, + else_expr: Index, }; - pub const Suspend = struct { - base: Node = Node{ .tag = .Suspend }, - suspend_token: TokenIndex, - body: ?*Node, - - pub fn iterate(self: *const Suspend, index: usize) ?*Node { - var i = index; - - if (self.body) |body| { - if (i < 1) return body; - i -= 1; - } - - return null; - } - - pub fn firstToken(self: *const Suspend) TokenIndex { - return self.suspend_token; - } - - pub fn lastToken(self: *const Suspend) TokenIndex { - if (self.body) |body| { - return body.lastToken(); - } - - return self.suspend_token; - } + pub const WhileCont = struct { + cont_expr: Index, + then_expr: Index, }; - pub const EnumLiteral = struct { - base: Node = Node{ .tag = .EnumLiteral }, - dot: TokenIndex, - name: TokenIndex, - - pub fn iterate(self: *const EnumLiteral, index: usize) ?*Node { - return null; - } - - pub fn firstToken(self: *const EnumLiteral) TokenIndex { - return self.dot; - } - - pub fn lastToken(self: *const EnumLiteral) TokenIndex { - return self.name; - } + pub const FnProtoOne = struct { + /// Populated if there is exactly 1 parameter. Otherwise there are 0 parameters. + param: Index, + /// Populated if align(A) is present. + align_expr: Index, + /// Populated if linksection(A) is present. + section_expr: Index, + /// Populated if callconv(A) is present. + callconv_expr: Index, }; - /// Parameters are in memory following BuiltinCall. - pub const BuiltinCall = struct { - base: Node = Node{ .tag = .BuiltinCall }, - params_len: NodeIndex, - builtin_token: TokenIndex, - rparen_token: TokenIndex, - - /// After this the caller must initialize the fields_and_decls list. - pub fn alloc(allocator: *mem.Allocator, params_len: NodeIndex) !*BuiltinCall { - const bytes = try allocator.alignedAlloc(u8, @alignOf(BuiltinCall), sizeInBytes(params_len)); - return @ptrCast(*BuiltinCall, bytes.ptr); - } - - pub fn free(self: *BuiltinCall, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.params_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const BuiltinCall, index: usize) ?*Node { - var i = index; - - if (i < self.params_len) return self.paramsConst()[i]; - i -= self.params_len; - - return null; - } - - pub fn firstToken(self: *const BuiltinCall) TokenIndex { - return self.builtin_token; - } - - pub fn lastToken(self: *const BuiltinCall) TokenIndex { - return self.rparen_token; - } - - pub fn params(self: *BuiltinCall) []*Node { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(BuiltinCall); - return @ptrCast([*]*Node, decls_start)[0..self.params_len]; - } - - pub fn paramsConst(self: *const BuiltinCall) []const *Node { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(BuiltinCall); - return @ptrCast([*]const *Node, decls_start)[0..self.params_len]; - } - - fn sizeInBytes(params_len: NodeIndex) usize { - return @sizeOf(BuiltinCall) + @sizeOf(*Node) * @as(usize, params_len); - } - }; - - /// The string literal tokens appear directly in memory after MultilineStringLiteral. - pub const MultilineStringLiteral = struct { - base: Node = Node{ .tag = .MultilineStringLiteral }, - lines_len: TokenIndex, - - /// After this the caller must initialize the lines list. - pub fn alloc(allocator: *mem.Allocator, lines_len: NodeIndex) !*MultilineStringLiteral { - const bytes = try allocator.alignedAlloc(u8, @alignOf(MultilineStringLiteral), sizeInBytes(lines_len)); - return @ptrCast(*MultilineStringLiteral, bytes.ptr); - } - - pub fn free(self: *MultilineStringLiteral, allocator: *mem.Allocator) void { - const bytes = @ptrCast([*]u8, self)[0..sizeInBytes(self.lines_len)]; - allocator.free(bytes); - } - - pub fn iterate(self: *const MultilineStringLiteral, index: usize) ?*Node { - return null; - } - - pub fn firstToken(self: *const MultilineStringLiteral) TokenIndex { - return self.linesConst()[0]; - } - - pub fn lastToken(self: *const MultilineStringLiteral) TokenIndex { - return self.linesConst()[self.lines_len - 1]; - } - - pub fn lines(self: *MultilineStringLiteral) []TokenIndex { - const decls_start = @ptrCast([*]u8, self) + @sizeOf(MultilineStringLiteral); - return @ptrCast([*]TokenIndex, decls_start)[0..self.lines_len]; - } - - pub fn linesConst(self: *const MultilineStringLiteral) []const TokenIndex { - const decls_start = @ptrCast([*]const u8, self) + @sizeOf(MultilineStringLiteral); - return @ptrCast([*]const TokenIndex, decls_start)[0..self.lines_len]; - } - - fn sizeInBytes(lines_len: NodeIndex) usize { - return @sizeOf(MultilineStringLiteral) + @sizeOf(TokenIndex) * @as(usize, lines_len); - } + pub const FnProto = struct { + params_start: Index, + params_end: Index, + /// Populated if align(A) is present. + align_expr: Index, + /// Populated if linksection(A) is present. + section_expr: Index, + /// Populated if callconv(A) is present. + callconv_expr: Index, }; pub const Asm = struct { - base: Node = Node{ .tag = .Asm }, - asm_token: TokenIndex, + items_start: Index, + items_end: Index, + /// Needed to make lastToken() work. rparen: TokenIndex, - volatile_token: ?TokenIndex, - template: *Node, - outputs: []Output, - inputs: []Input, - /// A clobber node must be a StringLiteral or MultilineStringLiteral. - clobbers: []*Node, - - pub const Output = struct { - lbracket: TokenIndex, - symbolic_name: *Node, - constraint: *Node, - kind: Kind, - rparen: TokenIndex, - - pub const Kind = union(enum) { - Variable: *OneToken, - Return: *Node, - }; - - pub fn iterate(self: *const Output, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.symbolic_name; - i -= 1; - - if (i < 1) return self.constraint; - i -= 1; - - switch (self.kind) { - .Variable => |variable_name| { - if (i < 1) return &variable_name.base; - i -= 1; - }, - .Return => |return_type| { - if (i < 1) return return_type; - i -= 1; - }, - } - - return null; - } - - pub fn firstToken(self: *const Output) TokenIndex { - return self.lbracket; - } - - pub fn lastToken(self: *const Output) TokenIndex { - return self.rparen; - } - }; - - pub const Input = struct { - lbracket: TokenIndex, - symbolic_name: *Node, - constraint: *Node, - expr: *Node, - rparen: TokenIndex, - - pub fn iterate(self: *const Input, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.symbolic_name; - i -= 1; - - if (i < 1) return self.constraint; - i -= 1; - - if (i < 1) return self.expr; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const Input) TokenIndex { - return self.lbracket; - } - - pub fn lastToken(self: *const Input) TokenIndex { - return self.rparen; - } - }; - - pub fn iterate(self: *const Asm, index: usize) ?*Node { - var i = index; - - if (i < self.outputs.len * 3) switch (i % 3) { - 0 => return self.outputs[i / 3].symbolic_name, - 1 => return self.outputs[i / 3].constraint, - 2 => switch (self.outputs[i / 3].kind) { - .Variable => |variable_name| return &variable_name.base, - .Return => |return_type| return return_type, - }, - else => unreachable, - }; - i -= self.outputs.len * 3; - - if (i < self.inputs.len * 3) switch (i % 3) { - 0 => return self.inputs[i / 3].symbolic_name, - 1 => return self.inputs[i / 3].constraint, - 2 => return self.inputs[i / 3].expr, - else => unreachable, - }; - i -= self.inputs.len * 3; - - return null; - } - - pub fn firstToken(self: *const Asm) TokenIndex { - return self.asm_token; - } - - pub fn lastToken(self: *const Asm) TokenIndex { - return self.rparen; - } - }; - - /// TODO remove from the Node base struct - /// TODO actually maybe remove entirely in favor of iterating backward from Node.firstToken() - /// and forwards to find same-line doc comments. - pub const DocComment = struct { - base: Node = Node{ .tag = .DocComment }, - /// Points to the first doc comment token. API users are expected to iterate over the - /// tokens array, looking for more doc comments, ignoring line comments, and stopping - /// at the first other token. - first_line: TokenIndex, - - pub fn iterate(self: *const DocComment, index: usize) ?*Node { - return null; - } - - pub fn firstToken(self: *const DocComment) TokenIndex { - return self.first_line; - } - - /// Returns the first doc comment line. Be careful, this may not be the desired behavior, - /// which would require the tokens array. - pub fn lastToken(self: *const DocComment) TokenIndex { - return self.first_line; - } - }; - - pub const TestDecl = struct { - base: Node = Node{ .tag = .TestDecl }, - doc_comments: ?*DocComment, - test_token: TokenIndex, - name: *Node, - body_node: *Node, - - pub fn iterate(self: *const TestDecl, index: usize) ?*Node { - var i = index; - - if (i < 1) return self.body_node; - i -= 1; - - return null; - } - - pub fn firstToken(self: *const TestDecl) TokenIndex { - return self.test_token; - } - - pub fn lastToken(self: *const TestDecl) TokenIndex { - return self.body_node.lastToken(); - } }; }; - -pub const PtrInfo = struct { - allowzero_token: ?TokenIndex = null, - align_info: ?Align = null, - const_token: ?TokenIndex = null, - volatile_token: ?TokenIndex = null, - sentinel: ?*Node = null, - - pub const Align = struct { - node: *Node, - bit_range: ?BitRange = null, - - pub const BitRange = struct { - start: *Node, - end: *Node, - }; - }; -}; - -test "iterate" { - var root = Node.Root{ - .base = Node{ .tag = Node.Tag.Root }, - .decls_len = 0, - .eof_token = 0, - }; - var base = &root.base; - testing.expect(base.iterate(0) == null); -} diff --git a/lib/std/zig/cross_target.zig b/lib/std/zig/cross_target.zig index 5c68fb3798..8d6f63f5e3 100644 --- a/lib/std/zig/cross_target.zig +++ b/lib/std/zig/cross_target.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -130,6 +130,9 @@ pub const CrossTarget = struct { .wasi, .emscripten, .uefi, + .opencl, + .glsl450, + .vulkan, .other, => { self.os_version_min = .{ .none = {} }; @@ -519,29 +522,29 @@ pub const CrossTarget = struct { var result = std.ArrayList(u8).init(allocator); defer result.deinit(); - try result.outStream().print("{}-{}", .{ arch_name, os_name }); + try result.writer().print("{s}-{s}", .{ arch_name, os_name }); // The zig target syntax does not allow specifying a max os version with no min, so // if either are present, we need the min. if (self.os_version_min != null or self.os_version_max != null) { switch (self.getOsVersionMin()) { .none => {}, - .semver => |v| try result.outStream().print(".{}", .{v}), - .windows => |v| try result.outStream().print("{s}", .{v}), + .semver => |v| try result.writer().print(".{}", .{v}), + .windows => |v| try result.writer().print("{s}", .{v}), } } if (self.os_version_max) |max| { switch (max) { .none => {}, - .semver => |v| try result.outStream().print("...{}", .{v}), - .windows => |v| try result.outStream().print("..{s}", .{v}), + .semver => |v| try result.writer().print("...{}", .{v}), + .windows => |v| try result.writer().print("..{s}", .{v}), } } if (self.glibc_version) |v| { - try result.outStream().print("-{}.{}", .{ @tagName(self.getAbi()), v }); + try result.writer().print("-{s}.{}", .{ @tagName(self.getAbi()), v }); } else if (self.abi) |abi| { - try result.outStream().print("-{}", .{@tagName(abi)}); + try result.writer().print("-{s}", .{@tagName(abi)}); } return result.toOwnedSlice(); @@ -595,7 +598,7 @@ pub const CrossTarget = struct { .Dynamic => "", }; - return std.fmt.allocPrint(allocator, "{}-{}{}", .{ arch, os, static_suffix }); + return std.fmt.allocPrint(allocator, "{s}-{s}{s}", .{ arch, os, static_suffix }); } pub const Executor = union(enum) { @@ -730,6 +733,9 @@ pub const CrossTarget = struct { .wasi, .emscripten, .uefi, + .opencl, + .glsl450, + .vulkan, .other, => return error.InvalidOperatingSystemVersion, @@ -790,7 +796,7 @@ test "CrossTarget.parse" { var buf: [256]u8 = undefined; const triple = std.fmt.bufPrint( buf[0..], - "native-native-{}.2.1.1", + "native-native-{s}.2.1.1", .{@tagName(std.Target.current.abi)}, ) catch unreachable; diff --git a/lib/std/zig/fmt.zig b/lib/std/zig/fmt.zig new file mode 100644 index 0000000000..2ca5279263 --- /dev/null +++ b/lib/std/zig/fmt.zig @@ -0,0 +1,72 @@ +const std = @import("std"); +const mem = std.mem; + +/// Print the string as a Zig identifier escaping it with @"" syntax if needed. +pub fn formatId( + bytes: []const u8, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, +) !void { + if (isValidId(bytes)) { + return writer.writeAll(bytes); + } + try writer.writeAll("@\""); + try formatEscapes(bytes, fmt, options, writer); + try writer.writeByte('"'); +} + +/// Return a Formatter for a Zig identifier +pub fn fmtId(bytes: []const u8) std.fmt.Formatter(formatId) { + return .{ .data = bytes }; +} + +pub fn isValidId(bytes: []const u8) bool { + for (bytes) |c, i| { + switch (c) { + '_', 'a'...'z', 'A'...'Z' => {}, + '0'...'9' => if (i == 0) return false, + else => return false, + } + } + return std.zig.Token.getKeyword(bytes) == null; +} + +pub fn formatEscapes( + bytes: []const u8, + comptime fmt: []const u8, + options: std.fmt.FormatOptions, + writer: anytype, +) !void { + for (bytes) |byte| switch (byte) { + '\n' => try writer.writeAll("\\n"), + '\r' => try writer.writeAll("\\r"), + '\t' => try writer.writeAll("\\t"), + '\\' => try writer.writeAll("\\\\"), + '"' => try writer.writeAll("\\\""), + '\'' => try writer.writeAll("\\'"), + ' ', '!', '#'...'&', '('...'[', ']'...'~' => try writer.writeByte(byte), + // Use hex escapes for rest any unprintable characters. + else => { + try writer.writeAll("\\x"); + try std.fmt.formatInt(byte, 16, false, .{ .width = 2, .fill = '0' }, writer); + }, + }; +} + +/// Return a Formatter for Zig Escapes +pub fn fmtEscapes(bytes: []const u8) std.fmt.Formatter(formatEscapes) { + return .{ .data = bytes }; +} + +test "escape invalid identifiers" { + const expectFmt = std.testing.expectFmt; + try expectFmt("@\"while\"", "{}", .{fmtId("while")}); + try expectFmt("hello", "{}", .{fmtId("hello")}); + try expectFmt("@\"11\\\"23\"", "{}", .{fmtId("11\"23")}); + try expectFmt("@\"11\\x0f23\"", "{}", .{fmtId("11\x0F23")}); + try expectFmt("\\x0f", "{}", .{fmtEscapes("\x0f")}); + try expectFmt( + \\" \\ hi \x07 \x11 \" derp \'" + , "\"{}\"", .{fmtEscapes(" \\ hi \x07 \x11 \" derp '")}); +} diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index 411273b149..7a6404fbb2 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -11,85 +11,181 @@ const Node = ast.Node; const Tree = ast.Tree; const AstError = ast.Error; const TokenIndex = ast.TokenIndex; -const NodeIndex = ast.NodeIndex; const Token = std.zig.Token; pub const Error = error{ParseError} || Allocator.Error; /// Result should be freed with tree.deinit() when there are /// no more references to any of the tokens or nodes. -pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!*Tree { - var token_ids = std.ArrayList(Token.Id).init(gpa); - defer token_ids.deinit(); - var token_locs = std.ArrayList(Token.Loc).init(gpa); - defer token_locs.deinit(); +pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!Tree { + var tokens = ast.TokenList{}; + defer tokens.deinit(gpa); // Empirically, the zig std lib has an 8:1 ratio of source bytes to token count. const estimated_token_count = source.len / 8; - try token_ids.ensureCapacity(estimated_token_count); - try token_locs.ensureCapacity(estimated_token_count); + try tokens.ensureCapacity(gpa, estimated_token_count); var tokenizer = std.zig.Tokenizer.init(source); while (true) { const token = tokenizer.next(); - try token_ids.append(token.id); - try token_locs.append(token.loc); - if (token.id == .Eof) break; + try tokens.append(gpa, .{ + .tag = token.tag, + .start = @intCast(u32, token.loc.start), + }); + if (token.tag == .eof) break; } var parser: Parser = .{ .source = source, - .arena = std.heap.ArenaAllocator.init(gpa), .gpa = gpa, - .token_ids = token_ids.items, - .token_locs = token_locs.items, + .token_tags = tokens.items(.tag), + .token_starts = tokens.items(.start), .errors = .{}, + .nodes = .{}, + .extra_data = .{}, .tok_i = 0, }; defer parser.errors.deinit(gpa); - errdefer parser.arena.deinit(); + defer parser.nodes.deinit(gpa); + defer parser.extra_data.deinit(gpa); - while (token_ids.items[parser.tok_i] == .LineComment) parser.tok_i += 1; + // Empirically, Zig source code has a 2:1 ratio of tokens to AST nodes. + // Make sure at least 1 so we can use appendAssumeCapacity on the root node below. + const estimated_node_count = (tokens.len + 2) / 2; + try parser.nodes.ensureCapacity(gpa, estimated_node_count); - const root_node = try parser.parseRoot(); - - const tree = try parser.arena.allocator.create(Tree); - tree.* = .{ - .gpa = gpa, - .source = source, - .token_ids = token_ids.toOwnedSlice(), - .token_locs = token_locs.toOwnedSlice(), - .errors = parser.errors.toOwnedSlice(gpa), - .root_node = root_node, - .arena = parser.arena.state, + // Root node must be index 0. + // Root <- skip ContainerMembers eof + parser.nodes.appendAssumeCapacity(.{ + .tag = .root, + .main_token = 0, + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }); + const root_members = try parser.parseContainerMembers(); + const root_decls = try root_members.toSpan(&parser); + if (parser.token_tags[parser.tok_i] != .eof) { + try parser.warnExpected(.eof); + } + parser.nodes.items(.data)[0] = .{ + .lhs = root_decls.start, + .rhs = root_decls.end, + }; + + // TODO experiment with compacting the MultiArrayList slices here + return Tree{ + .source = source, + .tokens = tokens.toOwnedSlice(), + .nodes = parser.nodes.toOwnedSlice(), + .extra_data = parser.extra_data.toOwnedSlice(gpa), + .errors = parser.errors.toOwnedSlice(gpa), }; - return tree; } +const null_node: Node.Index = 0; + /// Represents in-progress parsing, will be converted to an ast.Tree after completion. const Parser = struct { - arena: std.heap.ArenaAllocator, gpa: *Allocator, source: []const u8, - token_ids: []const Token.Id, - token_locs: []const Token.Loc, + token_tags: []const Token.Tag, + token_starts: []const ast.ByteOffset, tok_i: TokenIndex, errors: std.ArrayListUnmanaged(AstError), + nodes: ast.NodeList, + extra_data: std.ArrayListUnmanaged(Node.Index), - /// Root <- skip ContainerMembers eof - fn parseRoot(p: *Parser) Allocator.Error!*Node.Root { - const decls = try parseContainerMembers(p, true); - defer p.gpa.free(decls); + const SmallSpan = union(enum) { + zero_or_one: Node.Index, + multi: []Node.Index, - // parseContainerMembers will try to skip as much - // invalid tokens as it can so this can only be the EOF - const eof_token = p.eatToken(.Eof).?; + fn deinit(self: SmallSpan, gpa: *Allocator) void { + switch (self) { + .zero_or_one => {}, + .multi => |list| gpa.free(list), + } + } + }; - const decls_len = @intCast(NodeIndex, decls.len); - const node = try Node.Root.create(&p.arena.allocator, decls_len, eof_token); - std.mem.copy(*Node, node.decls(), decls); + const Members = struct { + len: usize, + lhs: Node.Index, + rhs: Node.Index, + trailing: bool, - return node; + fn toSpan(self: Members, p: *Parser) !Node.SubRange { + if (self.len <= 2) { + const nodes = [2]Node.Index{ self.lhs, self.rhs }; + return p.listToSpan(nodes[0..self.len]); + } else { + return Node.SubRange{ .start = self.lhs, .end = self.rhs }; + } + } + }; + + fn listToSpan(p: *Parser, list: []const Node.Index) !Node.SubRange { + try p.extra_data.appendSlice(p.gpa, list); + return Node.SubRange{ + .start = @intCast(Node.Index, p.extra_data.items.len - list.len), + .end = @intCast(Node.Index, p.extra_data.items.len), + }; + } + + fn addNode(p: *Parser, elem: ast.NodeList.Elem) Allocator.Error!Node.Index { + const result = @intCast(Node.Index, p.nodes.len); + try p.nodes.append(p.gpa, elem); + return result; + } + + fn addExtra(p: *Parser, extra: anytype) Allocator.Error!Node.Index { + const fields = std.meta.fields(@TypeOf(extra)); + try p.extra_data.ensureCapacity(p.gpa, p.extra_data.items.len + fields.len); + const result = @intCast(u32, p.extra_data.items.len); + inline for (fields) |field| { + comptime assert(field.field_type == Node.Index); + p.extra_data.appendAssumeCapacity(@field(extra, field.name)); + } + return result; + } + + fn warn(p: *Parser, tag: ast.Error.Tag) error{OutOfMemory}!void { + @setCold(true); + try p.warnMsg(.{ .tag = tag, .token = p.tok_i }); + } + + fn warnExpected(p: *Parser, expected_token: Token.Tag) error{OutOfMemory}!void { + @setCold(true); + try p.warnMsg(.{ + .tag = .expected_token, + .token = p.tok_i, + .extra = .{ .expected_tag = expected_token }, + }); + } + fn warnMsg(p: *Parser, msg: ast.Error) error{OutOfMemory}!void { + @setCold(true); + try p.errors.append(p.gpa, msg); + } + + fn fail(p: *Parser, tag: ast.Error.Tag) error{ ParseError, OutOfMemory } { + @setCold(true); + return p.failMsg(.{ .tag = tag, .token = p.tok_i }); + } + + fn failExpected(p: *Parser, expected_token: Token.Tag) error{ ParseError, OutOfMemory } { + @setCold(true); + return p.failMsg(.{ + .tag = .expected_token, + .token = p.tok_i, + .extra = .{ .expected_tag = expected_token }, + }); + } + + fn failMsg(p: *Parser, msg: ast.Error) error{ ParseError, OutOfMemory } { + @setCold(true); + try p.warnMsg(msg); + return error.ParseError; } /// ContainerMembers @@ -99,176 +195,226 @@ const Parser = struct { /// / ContainerField COMMA ContainerMembers /// / ContainerField /// / - fn parseContainerMembers(p: *Parser, top_level: bool) ![]*Node { - var list = std.ArrayList(*Node).init(p.gpa); + /// TopLevelComptime <- KEYWORD_comptime BlockExpr + fn parseContainerMembers(p: *Parser) !Members { + var list = std.ArrayList(Node.Index).init(p.gpa); defer list.deinit(); var field_state: union(enum) { - /// no fields have been seen + /// No fields have been seen. none, - /// currently parsing fields + /// Currently parsing fields. seen, - /// saw fields and then a declaration after them. - /// payload is first token of previous declaration. - end: TokenIndex, - /// ther was a declaration between fields, don't report more errors + /// Saw fields and then a declaration after them. + /// Payload is first token of previous declaration. + end: Node.Index, + /// There was a declaration between fields, don't report more errors. err, } = .none; + // Skip container doc comments. + while (p.eatToken(.container_doc_comment)) |_| {} + + var trailing = false; while (true) { - if (try p.parseContainerDocComments()) |node| { - try list.append(node); - continue; - } + const doc_comment = try p.eatDocComments(); - const doc_comments = try p.parseDocComment(); - - if (p.parseTestDecl() catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.ParseError => { - p.findNextContainerMember(); - continue; - }, - }) |node| { - if (field_state == .seen) { - field_state = .{ .end = node.firstToken() }; - } - node.cast(Node.TestDecl).?.doc_comments = doc_comments; - try list.append(node); - continue; - } - - if (p.parseTopLevelComptime() catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.ParseError => { - p.findNextContainerMember(); - continue; - }, - }) |node| { - if (field_state == .seen) { - field_state = .{ .end = node.firstToken() }; - } - node.cast(Node.Comptime).?.doc_comments = doc_comments; - try list.append(node); - continue; - } - - const visib_token = p.eatToken(.Keyword_pub); - - if (p.parseTopLevelDecl(doc_comments, visib_token) catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.ParseError => { - p.findNextContainerMember(); - continue; - }, - }) |node| { - if (field_state == .seen) { - field_state = .{ .end = visib_token orelse node.firstToken() }; - } - try list.append(node); - continue; - } - - if (visib_token != null) { - try p.errors.append(p.gpa, .{ - .ExpectedPubItem = .{ .token = p.tok_i }, - }); - // ignore this pub - continue; - } - - if (p.parseContainerField() catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.ParseError => { - // attempt to recover - p.findNextContainerMember(); - continue; - }, - }) |node| { - switch (field_state) { - .none => field_state = .seen, - .err, .seen => {}, - .end => |tok| { - try p.errors.append(p.gpa, .{ - .DeclBetweenFields = .{ .token = tok }, - }); - // continue parsing, error will be reported later - field_state = .err; - }, - } - - const field = node.cast(Node.ContainerField).?; - field.doc_comments = doc_comments; - try list.append(node); - const comma = p.eatToken(.Comma) orelse { - // try to continue parsing - const index = p.tok_i; - p.findNextContainerMember(); - const next = p.token_ids[p.tok_i]; - switch (next) { - .Eof => { - // no invalid tokens were found - if (index == p.tok_i) break; - - // Invalid tokens, add error and exit - try p.errors.append(p.gpa, .{ - .ExpectedToken = .{ .token = index, .expected_id = .Comma }, - }); - break; - }, - else => { - if (next == .RBrace) { - if (!top_level) break; - _ = p.nextToken(); - } - - // add error and continue - try p.errors.append(p.gpa, .{ - .ExpectedToken = .{ .token = index, .expected_id = .Comma }, - }); - continue; - }, + switch (p.token_tags[p.tok_i]) { + .keyword_test => { + const test_decl_node = try p.expectTestDeclRecoverable(); + if (test_decl_node != 0) { + if (field_state == .seen) { + field_state = .{ .end = test_decl_node }; + } + try list.append(test_decl_node); } - }; - if (try p.parseAppendedDocComment(comma)) |appended_comment| - field.doc_comments = appended_comment; - continue; - } - - // Dangling doc comment - if (doc_comments != null) { - try p.errors.append(p.gpa, .{ - .UnattachedDocComment = .{ .token = doc_comments.?.firstToken() }, - }); - } - - const next = p.token_ids[p.tok_i]; - switch (next) { - .Eof => break, - .Keyword_comptime => { - _ = p.nextToken(); - try p.errors.append(p.gpa, .{ - .ExpectedBlockOrField = .{ .token = p.tok_i }, - }); + trailing = false; + }, + .keyword_comptime => switch (p.token_tags[p.tok_i + 1]) { + .identifier => { + p.tok_i += 1; + const container_field = try p.expectContainerFieldRecoverable(); + if (container_field != 0) { + switch (field_state) { + .none => field_state = .seen, + .err, .seen => {}, + .end => |node| { + try p.warnMsg(.{ + .tag = .decl_between_fields, + .token = p.nodes.items(.main_token)[node], + }); + // Continue parsing; error will be reported later. + field_state = .err; + }, + } + try list.append(container_field); + switch (p.token_tags[p.tok_i]) { + .comma => { + p.tok_i += 1; + trailing = true; + continue; + }, + .r_brace, .eof => { + trailing = false; + break; + }, + else => {}, + } + // There is not allowed to be a decl after a field with no comma. + // Report error but recover parser. + try p.warnExpected(.comma); + p.findNextContainerMember(); + } + }, + .l_brace => { + const comptime_token = p.nextToken(); + const block = p.parseBlock() catch |err| switch (err) { + error.OutOfMemory => return error.OutOfMemory, + error.ParseError => blk: { + p.findNextContainerMember(); + break :blk null_node; + }, + }; + if (block != 0) { + const comptime_node = try p.addNode(.{ + .tag = .@"comptime", + .main_token = comptime_token, + .data = .{ + .lhs = block, + .rhs = undefined, + }, + }); + if (field_state == .seen) { + field_state = .{ .end = comptime_node }; + } + try list.append(comptime_node); + } + trailing = false; + }, + else => { + p.tok_i += 1; + try p.warn(.expected_block_or_field); + }, + }, + .keyword_pub => { + p.tok_i += 1; + const top_level_decl = try p.expectTopLevelDeclRecoverable(); + if (top_level_decl != 0) { + if (field_state == .seen) { + field_state = .{ .end = top_level_decl }; + } + try list.append(top_level_decl); + } + trailing = p.token_tags[p.tok_i - 1] == .semicolon; + }, + .keyword_usingnamespace => { + const node = try p.expectUsingNamespaceRecoverable(); + if (node != 0) { + if (field_state == .seen) { + field_state = .{ .end = node }; + } + try list.append(node); + } + trailing = p.token_tags[p.tok_i - 1] == .semicolon; + }, + .keyword_const, + .keyword_var, + .keyword_threadlocal, + .keyword_export, + .keyword_extern, + .keyword_inline, + .keyword_noinline, + .keyword_fn, + => { + const top_level_decl = try p.expectTopLevelDeclRecoverable(); + if (top_level_decl != 0) { + if (field_state == .seen) { + field_state = .{ .end = top_level_decl }; + } + try list.append(top_level_decl); + } + trailing = p.token_tags[p.tok_i - 1] == .semicolon; + }, + .identifier => { + const container_field = try p.expectContainerFieldRecoverable(); + if (container_field != 0) { + switch (field_state) { + .none => field_state = .seen, + .err, .seen => {}, + .end => |node| { + try p.warnMsg(.{ + .tag = .decl_between_fields, + .token = p.nodes.items(.main_token)[node], + }); + // Continue parsing; error will be reported later. + field_state = .err; + }, + } + try list.append(container_field); + switch (p.token_tags[p.tok_i]) { + .comma => { + p.tok_i += 1; + trailing = true; + continue; + }, + .r_brace, .eof => { + trailing = false; + break; + }, + else => {}, + } + // There is not allowed to be a decl after a field with no comma. + // Report error but recover parser. + try p.warnExpected(.comma); + p.findNextContainerMember(); + } + }, + .eof, .r_brace => { + if (doc_comment) |tok| { + try p.warnMsg(.{ + .tag = .unattached_doc_comment, + .token = tok, + }); + } + break; }, else => { - const index = p.tok_i; - if (next == .RBrace) { - if (!top_level) break; - _ = p.nextToken(); - } - - // this was likely not supposed to end yet, - // try to find the next declaration + try p.warn(.expected_container_members); + // This was likely not supposed to end yet; try to find the next declaration. p.findNextContainerMember(); - try p.errors.append(p.gpa, .{ - .ExpectedContainerMembers = .{ .token = index }, - }); }, } } - return list.toOwnedSlice(); + switch (list.items.len) { + 0 => return Members{ + .len = 0, + .lhs = 0, + .rhs = 0, + .trailing = trailing, + }, + 1 => return Members{ + .len = 1, + .lhs = list.items[0], + .rhs = 0, + .trailing = trailing, + }, + 2 => return Members{ + .len = 2, + .lhs = list.items[0], + .rhs = list.items[1], + .trailing = trailing, + }, + else => { + const span = try p.listToSpan(list.items); + return Members{ + .len = list.items.len, + .lhs = span.start, + .rhs = span.end, + .trailing = trailing, + }; + }, + } } /// Attempts to find next container member by searching for certain tokens @@ -276,47 +422,52 @@ const Parser = struct { var level: u32 = 0; while (true) { const tok = p.nextToken(); - switch (p.token_ids[tok]) { - // any of these can start a new top level declaration - .Keyword_test, - .Keyword_comptime, - .Keyword_pub, - .Keyword_export, - .Keyword_extern, - .Keyword_inline, - .Keyword_noinline, - .Keyword_usingnamespace, - .Keyword_threadlocal, - .Keyword_const, - .Keyword_var, - .Keyword_fn, - .Identifier, + switch (p.token_tags[tok]) { + // Any of these can start a new top level declaration. + .keyword_test, + .keyword_comptime, + .keyword_pub, + .keyword_export, + .keyword_extern, + .keyword_inline, + .keyword_noinline, + .keyword_usingnamespace, + .keyword_threadlocal, + .keyword_const, + .keyword_var, + .keyword_fn, => { if (level == 0) { - p.putBackToken(tok); + p.tok_i -= 1; return; } }, - .Comma, .Semicolon => { + .identifier => { + if (p.token_tags[tok + 1] == .comma and level == 0) { + p.tok_i -= 1; + return; + } + }, + .comma, .semicolon => { // this decl was likely meant to end here if (level == 0) { return; } }, - .LParen, .LBracket, .LBrace => level += 1, - .RParen, .RBracket => { + .l_paren, .l_bracket, .l_brace => level += 1, + .r_paren, .r_bracket => { if (level != 0) level -= 1; }, - .RBrace => { + .r_brace => { if (level == 0) { // end of container, exit - p.putBackToken(tok); + p.tok_i -= 1; return; } level -= 1; }, - .Eof => { - p.putBackToken(tok); + .eof => { + p.tok_i -= 1; return; }, else => {}, @@ -329,22 +480,22 @@ const Parser = struct { var level: u32 = 0; while (true) { const tok = p.nextToken(); - switch (p.token_ids[tok]) { - .LBrace => level += 1, - .RBrace => { + switch (p.token_tags[tok]) { + .l_brace => level += 1, + .r_brace => { if (level == 0) { - p.putBackToken(tok); + p.tok_i -= 1; return; } level -= 1; }, - .Semicolon => { + .semicolon => { if (level == 0) { return; } }, - .Eof => { - p.putBackToken(tok); + .eof => { + p.tok_i -= 1; return; }, else => {}, @@ -352,330 +503,337 @@ const Parser = struct { } } - /// Eat a multiline container doc comment - fn parseContainerDocComments(p: *Parser) !?*Node { - if (p.eatToken(.ContainerDocComment)) |first_line| { - while (p.eatToken(.ContainerDocComment)) |_| {} - const node = try p.arena.allocator.create(Node.DocComment); - node.* = .{ .first_line = first_line }; - return &node.base; - } - return null; + /// TestDecl <- KEYWORD_test STRINGLITERALSINGLE? Block + fn expectTestDecl(p: *Parser) !Node.Index { + const test_token = p.assertToken(.keyword_test); + const name_token = p.eatToken(.string_literal); + const block_node = try p.parseBlock(); + if (block_node == 0) return p.fail(.expected_block); + return p.addNode(.{ + .tag = .test_decl, + .main_token = test_token, + .data = .{ + .lhs = name_token orelse 0, + .rhs = block_node, + }, + }); } - /// TestDecl <- KEYWORD_test STRINGLITERALSINGLE Block - fn parseTestDecl(p: *Parser) !?*Node { - const test_token = p.eatToken(.Keyword_test) orelse return null; - const name_node = try p.expectNode(parseStringLiteralSingle, .{ - .ExpectedStringLiteral = .{ .token = p.tok_i }, - }); - const block_node = (try p.parseBlock(null)) orelse { - try p.errors.append(p.gpa, .{ .ExpectedLBrace = .{ .token = p.tok_i } }); - return error.ParseError; + fn expectTestDeclRecoverable(p: *Parser) error{OutOfMemory}!Node.Index { + return p.expectTestDecl() catch |err| switch (err) { + error.OutOfMemory => return error.OutOfMemory, + error.ParseError => { + p.findNextContainerMember(); + return null_node; + }, }; - - const test_node = try p.arena.allocator.create(Node.TestDecl); - test_node.* = .{ - .doc_comments = null, - .test_token = test_token, - .name = name_node, - .body_node = block_node, - }; - return &test_node.base; - } - - /// TopLevelComptime <- KEYWORD_comptime BlockExpr - fn parseTopLevelComptime(p: *Parser) !?*Node { - const tok = p.eatToken(.Keyword_comptime) orelse return null; - const lbrace = p.eatToken(.LBrace) orelse { - p.putBackToken(tok); - return null; - }; - p.putBackToken(lbrace); - const block_node = try p.expectNode(parseBlockExpr, .{ - .ExpectedLabelOrLBrace = .{ .token = p.tok_i }, - }); - - const comptime_node = try p.arena.allocator.create(Node.Comptime); - comptime_node.* = .{ - .doc_comments = null, - .comptime_token = tok, - .expr = block_node, - }; - return &comptime_node.base; } /// TopLevelDecl /// <- (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE? / (KEYWORD_inline / KEYWORD_noinline))? FnProto (SEMICOLON / Block) /// / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl /// / KEYWORD_usingnamespace Expr SEMICOLON - fn parseTopLevelDecl(p: *Parser, doc_comments: ?*Node.DocComment, visib_token: ?TokenIndex) !?*Node { - var lib_name: ?*Node = null; - const extern_export_inline_token = blk: { - if (p.eatToken(.Keyword_export)) |token| break :blk token; - if (p.eatToken(.Keyword_extern)) |token| { - lib_name = try p.parseStringLiteralSingle(); - break :blk token; - } - if (p.eatToken(.Keyword_inline)) |token| break :blk token; - if (p.eatToken(.Keyword_noinline)) |token| break :blk token; - break :blk null; - }; - - if (try p.parseFnProto(.top_level, .{ - .doc_comments = doc_comments, - .visib_token = visib_token, - .extern_export_inline_token = extern_export_inline_token, - .lib_name = lib_name, - })) |node| { - return node; + fn expectTopLevelDecl(p: *Parser) !Node.Index { + const extern_export_inline_token = p.nextToken(); + var expect_fn: bool = false; + var expect_var_or_fn: bool = false; + switch (p.token_tags[extern_export_inline_token]) { + .keyword_extern => { + _ = p.eatToken(.string_literal); + expect_var_or_fn = true; + }, + .keyword_export => expect_var_or_fn = true, + .keyword_inline, .keyword_noinline => expect_fn = true, + else => p.tok_i -= 1, } - - if (extern_export_inline_token) |token| { - if (p.token_ids[token] == .Keyword_inline or - p.token_ids[token] == .Keyword_noinline) - { - try p.errors.append(p.gpa, .{ - .ExpectedFn = .{ .token = p.tok_i }, - }); - return error.ParseError; - } - } - - const thread_local_token = p.eatToken(.Keyword_threadlocal); - - if (try p.parseVarDecl(.{ - .doc_comments = doc_comments, - .visib_token = visib_token, - .thread_local_token = thread_local_token, - .extern_export_token = extern_export_inline_token, - .lib_name = lib_name, - })) |node| { - return node; - } - - if (thread_local_token != null) { - try p.errors.append(p.gpa, .{ - .ExpectedVarDecl = .{ .token = p.tok_i }, - }); - // ignore this and try again; - return error.ParseError; - } - - if (extern_export_inline_token) |token| { - try p.errors.append(p.gpa, .{ - .ExpectedVarDeclOrFn = .{ .token = p.tok_i }, - }); - // ignore this and try again; - return error.ParseError; - } - - const use_token = p.eatToken(.Keyword_usingnamespace) orelse return null; - const expr = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - const semicolon_token = try p.expectToken(.Semicolon); - - const node = try p.arena.allocator.create(Node.Use); - node.* = .{ - .doc_comments = doc_comments orelse try p.parseAppendedDocComment(semicolon_token), - .visib_token = visib_token, - .use_token = use_token, - .expr = expr, - .semicolon_token = semicolon_token, - }; - - return &node.base; - } - - /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? CallConv? EXCLAMATIONMARK? (Keyword_anytype / TypeExpr) - fn parseFnProto(p: *Parser, level: enum { top_level, as_type }, fields: struct { - doc_comments: ?*Node.DocComment = null, - visib_token: ?TokenIndex = null, - extern_export_inline_token: ?TokenIndex = null, - lib_name: ?*Node = null, - }) !?*Node { - // TODO: Remove once extern/async fn rewriting is - var is_async: ?void = null; - var is_extern_prototype: ?void = null; - const cc_token: ?TokenIndex = blk: { - if (p.eatToken(.Keyword_extern)) |token| { - is_extern_prototype = {}; - break :blk token; - } - if (p.eatToken(.Keyword_async)) |token| { - is_async = {}; - break :blk token; - } - break :blk null; - }; - const fn_token = p.eatToken(.Keyword_fn) orelse { - if (cc_token) |token| - p.putBackToken(token); - return null; - }; - const name_token = p.eatToken(.Identifier); - const lparen = try p.expectToken(.LParen); - const params = try p.parseParamDeclList(); - defer p.gpa.free(params); - const var_args_token = p.eatToken(.Ellipsis3); - const rparen = try p.expectToken(.RParen); - const align_expr = try p.parseByteAlign(); - const section_expr = try p.parseLinkSection(); - const callconv_expr = try p.parseCallconv(); - const exclamation_token = p.eatToken(.Bang); - - const return_type_expr = (try p.parseAnyType()) orelse - try p.expectNodeRecoverable(parseTypeExpr, .{ - // most likely the user forgot to specify the return type. - // Mark return type as invalid and try to continue. - .ExpectedReturnType = .{ .token = p.tok_i }, - }); - - // TODO https://github.com/ziglang/zig/issues/3750 - const R = Node.FnProto.ReturnType; - const return_type = if (return_type_expr == null) - R{ .Invalid = rparen } - else if (exclamation_token != null) - R{ .InferErrorSet = return_type_expr.? } - else - R{ .Explicit = return_type_expr.? }; - - const body_node: ?*Node = switch (level) { - .top_level => blk: { - if (p.eatToken(.Semicolon)) |_| { - break :blk null; - } - const body_block = (try p.parseBlock(null)) orelse { + const fn_proto = try p.parseFnProto(); + if (fn_proto != 0) { + switch (p.token_tags[p.tok_i]) { + .semicolon => { + p.tok_i += 1; + return fn_proto; + }, + .l_brace => { + const body_block = try p.parseBlock(); + assert(body_block != 0); + return p.addNode(.{ + .tag = .fn_decl, + .main_token = p.nodes.items(.main_token)[fn_proto], + .data = .{ + .lhs = fn_proto, + .rhs = body_block, + }, + }); + }, + else => { // Since parseBlock only return error.ParseError on // a missing '}' we can assume this function was // supposed to end here. - try p.errors.append(p.gpa, .{ .ExpectedSemiOrLBrace = .{ .token = p.tok_i } }); - break :blk null; - }; - break :blk body_block; + try p.warn(.expected_semi_or_lbrace); + return null_node; + }, + } + } + if (expect_fn) { + try p.warn(.expected_fn); + return error.ParseError; + } + + const thread_local_token = p.eatToken(.keyword_threadlocal); + const var_decl = try p.parseVarDecl(); + if (var_decl != 0) { + const semicolon_token = try p.expectToken(.semicolon); + return var_decl; + } + if (thread_local_token != null) { + return p.fail(.expected_var_decl); + } + if (expect_var_or_fn) { + return p.fail(.expected_var_decl_or_fn); + } + if (p.token_tags[p.tok_i] != .keyword_usingnamespace) { + return p.fail(.expected_pub_item); + } + return p.expectUsingNamespace(); + } + + fn expectTopLevelDeclRecoverable(p: *Parser) error{OutOfMemory}!Node.Index { + return p.expectTopLevelDecl() catch |err| switch (err) { + error.OutOfMemory => return error.OutOfMemory, + error.ParseError => { + p.findNextContainerMember(); + return null_node; }, - .as_type => null, }; + } - const fn_proto_node = try Node.FnProto.create(&p.arena.allocator, .{ - .params_len = params.len, - .fn_token = fn_token, - .return_type = return_type, - }, .{ - .doc_comments = fields.doc_comments, - .visib_token = fields.visib_token, - .name_token = name_token, - .var_args_token = var_args_token, - .extern_export_inline_token = fields.extern_export_inline_token, - .body_node = body_node, - .lib_name = fields.lib_name, - .align_expr = align_expr, - .section_expr = section_expr, - .callconv_expr = callconv_expr, - .is_extern_prototype = is_extern_prototype, - .is_async = is_async, + fn expectUsingNamespace(p: *Parser) !Node.Index { + const usingnamespace_token = p.assertToken(.keyword_usingnamespace); + const expr = try p.expectExpr(); + const semicolon_token = try p.expectToken(.semicolon); + return p.addNode(.{ + .tag = .@"usingnamespace", + .main_token = usingnamespace_token, + .data = .{ + .lhs = expr, + .rhs = undefined, + }, }); - std.mem.copy(Node.FnProto.ParamDecl, fn_proto_node.params(), params); + } - return &fn_proto_node.base; + fn expectUsingNamespaceRecoverable(p: *Parser) error{OutOfMemory}!Node.Index { + return p.expectUsingNamespace() catch |err| switch (err) { + error.OutOfMemory => return error.OutOfMemory, + error.ParseError => { + p.findNextContainerMember(); + return null_node; + }, + }; + } + + /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? CallConv? EXCLAMATIONMARK? (Keyword_anytype / TypeExpr) + fn parseFnProto(p: *Parser) !Node.Index { + const fn_token = p.eatToken(.keyword_fn) orelse return null_node; + _ = p.eatToken(.identifier); + const params = try p.parseParamDeclList(); + defer params.deinit(p.gpa); + const align_expr = try p.parseByteAlign(); + const section_expr = try p.parseLinkSection(); + const callconv_expr = try p.parseCallconv(); + const bang_token = p.eatToken(.bang); + + const return_type_expr = try p.parseTypeExpr(); + if (return_type_expr == 0) { + // most likely the user forgot to specify the return type. + // Mark return type as invalid and try to continue. + try p.warn(.expected_return_type); + } + + if (align_expr == 0 and section_expr == 0 and callconv_expr == 0) { + switch (params) { + .zero_or_one => |param| return p.addNode(.{ + .tag = .fn_proto_simple, + .main_token = fn_token, + .data = .{ + .lhs = param, + .rhs = return_type_expr, + }, + }), + .multi => |list| { + const span = try p.listToSpan(list); + return p.addNode(.{ + .tag = .fn_proto_multi, + .main_token = fn_token, + .data = .{ + .lhs = try p.addExtra(Node.SubRange{ + .start = span.start, + .end = span.end, + }), + .rhs = return_type_expr, + }, + }); + }, + } + } + switch (params) { + .zero_or_one => |param| return p.addNode(.{ + .tag = .fn_proto_one, + .main_token = fn_token, + .data = .{ + .lhs = try p.addExtra(Node.FnProtoOne{ + .param = param, + .align_expr = align_expr, + .section_expr = section_expr, + .callconv_expr = callconv_expr, + }), + .rhs = return_type_expr, + }, + }), + .multi => |list| { + const span = try p.listToSpan(list); + return p.addNode(.{ + .tag = .fn_proto, + .main_token = fn_token, + .data = .{ + .lhs = try p.addExtra(Node.FnProto{ + .params_start = span.start, + .params_end = span.end, + .align_expr = align_expr, + .section_expr = section_expr, + .callconv_expr = callconv_expr, + }), + .rhs = return_type_expr, + }, + }); + }, + } } /// VarDecl <- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON - fn parseVarDecl(p: *Parser, fields: struct { - doc_comments: ?*Node.DocComment = null, - visib_token: ?TokenIndex = null, - thread_local_token: ?TokenIndex = null, - extern_export_token: ?TokenIndex = null, - lib_name: ?*Node = null, - comptime_token: ?TokenIndex = null, - }) !?*Node { - const mut_token = p.eatToken(.Keyword_const) orelse - p.eatToken(.Keyword_var) orelse - return null; + fn parseVarDecl(p: *Parser) !Node.Index { + const mut_token = p.eatToken(.keyword_const) orelse + p.eatToken(.keyword_var) orelse + return null_node; - const name_token = try p.expectToken(.Identifier); - const type_node = if (p.eatToken(.Colon) != null) - try p.expectNode(parseTypeExpr, .{ - .ExpectedTypeExpr = .{ .token = p.tok_i }, - }) - else - null; + _ = try p.expectToken(.identifier); + const type_node: Node.Index = if (p.eatToken(.colon) == null) 0 else try p.expectTypeExpr(); const align_node = try p.parseByteAlign(); const section_node = try p.parseLinkSection(); - const eq_token = p.eatToken(.Equal); - const init_node = if (eq_token != null) blk: { - break :blk try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, + const init_node: Node.Index = if (p.eatToken(.equal) == null) 0 else try p.expectExpr(); + if (section_node == 0) { + if (align_node == 0) { + return p.addNode(.{ + .tag = .simple_var_decl, + .main_token = mut_token, + .data = .{ + .lhs = type_node, + .rhs = init_node, + }, + }); + } else if (type_node == 0) { + return p.addNode(.{ + .tag = .aligned_var_decl, + .main_token = mut_token, + .data = .{ + .lhs = align_node, + .rhs = init_node, + }, + }); + } else { + return p.addNode(.{ + .tag = .local_var_decl, + .main_token = mut_token, + .data = .{ + .lhs = try p.addExtra(Node.LocalVarDecl{ + .type_node = type_node, + .align_node = align_node, + }), + .rhs = init_node, + }, + }); + } + } else { + return p.addNode(.{ + .tag = .global_var_decl, + .main_token = mut_token, + .data = .{ + .lhs = try p.addExtra(Node.GlobalVarDecl{ + .type_node = type_node, + .align_node = align_node, + .section_node = section_node, + }), + .rhs = init_node, + }, }); - } else null; - const semicolon_token = try p.expectToken(.Semicolon); - - const doc_comments = fields.doc_comments orelse try p.parseAppendedDocComment(semicolon_token); - - const node = try Node.VarDecl.create(&p.arena.allocator, .{ - .mut_token = mut_token, - .name_token = name_token, - .semicolon_token = semicolon_token, - }, .{ - .doc_comments = doc_comments, - .visib_token = fields.visib_token, - .thread_local_token = fields.thread_local_token, - .eq_token = eq_token, - .comptime_token = fields.comptime_token, - .extern_export_token = fields.extern_export_token, - .lib_name = fields.lib_name, - .type_node = type_node, - .align_node = align_node, - .section_node = section_node, - .init_node = init_node, - }); - return &node.base; + } } /// ContainerField <- KEYWORD_comptime? IDENTIFIER (COLON TypeExpr ByteAlign?)? (EQUAL Expr)? - fn parseContainerField(p: *Parser) !?*Node { - const comptime_token = p.eatToken(.Keyword_comptime); - const name_token = p.eatToken(.Identifier) orelse { - if (comptime_token) |t| p.putBackToken(t); - return null; - }; + fn expectContainerField(p: *Parser) !Node.Index { + const comptime_token = p.eatToken(.keyword_comptime); + const name_token = p.assertToken(.identifier); - var align_expr: ?*Node = null; - var type_expr: ?*Node = null; - if (p.eatToken(.Colon)) |_| { - if (p.eatToken(.Keyword_anytype) orelse p.eatToken(.Keyword_var)) |anytype_tok| { - const node = try p.arena.allocator.create(Node.OneToken); - node.* = .{ - .base = .{ .tag = .AnyType }, - .token = anytype_tok, - }; - type_expr = &node.base; - } else { - type_expr = try p.expectNode(parseTypeExpr, .{ - .ExpectedTypeExpr = .{ .token = p.tok_i }, + var align_expr: Node.Index = 0; + var type_expr: Node.Index = 0; + if (p.eatToken(.colon)) |_| { + if (p.eatToken(.keyword_anytype)) |anytype_tok| { + type_expr = try p.addNode(.{ + .tag = .@"anytype", + .main_token = anytype_tok, + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, }); + } else { + type_expr = try p.expectTypeExpr(); align_expr = try p.parseByteAlign(); } } - const value_expr = if (p.eatToken(.Equal)) |_| - try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }) - else - null; + const value_expr: Node.Index = if (p.eatToken(.equal) == null) 0 else try p.expectExpr(); - const node = try p.arena.allocator.create(Node.ContainerField); - node.* = .{ - .doc_comments = null, - .comptime_token = comptime_token, - .name_token = name_token, - .type_expr = type_expr, - .value_expr = value_expr, - .align_expr = align_expr, + if (align_expr == 0) { + return p.addNode(.{ + .tag = .container_field_init, + .main_token = name_token, + .data = .{ + .lhs = type_expr, + .rhs = value_expr, + }, + }); + } else if (value_expr == 0) { + return p.addNode(.{ + .tag = .container_field_align, + .main_token = name_token, + .data = .{ + .lhs = type_expr, + .rhs = align_expr, + }, + }); + } else { + return p.addNode(.{ + .tag = .container_field, + .main_token = name_token, + .data = .{ + .lhs = type_expr, + .rhs = try p.addExtra(Node.ContainerField{ + .value_expr = value_expr, + .align_expr = align_expr, + }), + }, + }); + } + } + + fn expectContainerFieldRecoverable(p: *Parser) error{OutOfMemory}!Node.Index { + return p.expectContainerField() catch |err| switch (err) { + error.OutOfMemory => return error.OutOfMemory, + error.ParseError => { + p.findNextContainerMember(); + return null_node; + }, }; - return &node.base; } /// Statement @@ -689,391 +847,1023 @@ const Parser = struct { /// / LabeledStatement /// / SwitchExpr /// / AssignExpr SEMICOLON - fn parseStatement(p: *Parser) Error!?*Node { - const comptime_token = p.eatToken(.Keyword_comptime); + fn parseStatement(p: *Parser) Error!Node.Index { + const comptime_token = p.eatToken(.keyword_comptime); - if (try p.parseVarDecl(.{ - .comptime_token = comptime_token, - })) |node| { - return node; + const var_decl = try p.parseVarDecl(); + if (var_decl != 0) { + _ = try p.expectTokenRecoverable(.semicolon); + return var_decl; } if (comptime_token) |token| { - const block_expr = try p.expectNode(parseBlockExprStatement, .{ - .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, + return p.addNode(.{ + .tag = .@"comptime", + .main_token = token, + .data = .{ + .lhs = try p.expectBlockExprStatement(), + .rhs = undefined, + }, }); - - const node = try p.arena.allocator.create(Node.Comptime); - node.* = .{ - .doc_comments = null, - .comptime_token = token, - .expr = block_expr, - }; - return &node.base; } - if (p.eatToken(.Keyword_nosuspend)) |nosuspend_token| { - const block_expr = try p.expectNode(parseBlockExprStatement, .{ - .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, - }); - - const node = try p.arena.allocator.create(Node.Nosuspend); - node.* = .{ - .nosuspend_token = nosuspend_token, - .expr = block_expr, - }; - return &node.base; - } - - if (p.eatToken(.Keyword_suspend)) |suspend_token| { - const semicolon = p.eatToken(.Semicolon); - - const body_node = if (semicolon == null) blk: { - break :blk try p.expectNode(parseBlockExprStatement, .{ - .ExpectedBlockOrExpression = .{ .token = p.tok_i }, + switch (p.token_tags[p.tok_i]) { + .keyword_nosuspend => { + return p.addNode(.{ + .tag = .@"nosuspend", + .main_token = p.nextToken(), + .data = .{ + .lhs = try p.expectBlockExprStatement(), + .rhs = undefined, + }, }); - } else null; + }, + .keyword_suspend => { + const token = p.nextToken(); + const block_expr: Node.Index = if (p.eatToken(.semicolon) != null) + 0 + else + try p.expectBlockExprStatement(); + return p.addNode(.{ + .tag = .@"suspend", + .main_token = token, + .data = .{ + .lhs = block_expr, + .rhs = undefined, + }, + }); + }, + .keyword_defer => return p.addNode(.{ + .tag = .@"defer", + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = try p.expectBlockExprStatement(), + }, + }), + .keyword_errdefer => return p.addNode(.{ + .tag = .@"errdefer", + .main_token = p.nextToken(), + .data = .{ + .lhs = try p.parsePayload(), + .rhs = try p.expectBlockExprStatement(), + }, + }), + .keyword_switch => return p.expectSwitchExpr(), + .keyword_if => return p.expectIfStatement(), + else => {}, + } - const node = try p.arena.allocator.create(Node.Suspend); - node.* = .{ - .suspend_token = suspend_token, - .body = body_node, + const labeled_statement = try p.parseLabeledStatement(); + if (labeled_statement != 0) return labeled_statement; + + const assign_expr = try p.parseAssignExpr(); + if (assign_expr != 0) { + _ = try p.expectTokenRecoverable(.semicolon); + return assign_expr; + } + + return null_node; + } + + fn expectStatement(p: *Parser) !Node.Index { + const statement = try p.parseStatement(); + if (statement == 0) { + return p.fail(.expected_statement); + } + return statement; + } + + /// If a parse error occurs, reports an error, but then finds the next statement + /// and returns that one instead. If a parse error occurs but there is no following + /// statement, returns 0. + fn expectStatementRecoverable(p: *Parser) error{OutOfMemory}!Node.Index { + while (true) { + return p.expectStatement() catch |err| switch (err) { + error.OutOfMemory => return error.OutOfMemory, + error.ParseError => { + p.findNextStmt(); // Try to skip to the next statement. + if (p.token_tags[p.tok_i] == .r_brace) return null_node; + continue; + }, }; - return &node.base; } - - const defer_token = p.eatToken(.Keyword_defer) orelse p.eatToken(.Keyword_errdefer); - if (defer_token) |token| { - const payload = if (p.token_ids[token] == .Keyword_errdefer) - try p.parsePayload() - else - null; - const expr_node = try p.expectNode(parseBlockExprStatement, .{ - .ExpectedBlockOrExpression = .{ .token = p.tok_i }, - }); - const node = try p.arena.allocator.create(Node.Defer); - node.* = .{ - .defer_token = token, - .expr = expr_node, - .payload = payload, - }; - return &node.base; - } - - if (try p.parseIfStatement()) |node| return node; - if (try p.parseLabeledStatement()) |node| return node; - if (try p.parseSwitchExpr()) |node| return node; - if (try p.parseAssignExpr()) |node| { - _ = try p.expectTokenRecoverable(.Semicolon); - return node; - } - - return null; } /// IfStatement /// <- IfPrefix BlockExpr ( KEYWORD_else Payload? Statement )? /// / IfPrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement ) - fn parseIfStatement(p: *Parser) !?*Node { - const if_node = (try p.parseIfPrefix()) orelse return null; - const if_prefix = if_node.cast(Node.If).?; + fn expectIfStatement(p: *Parser) !Node.Index { + const if_token = p.assertToken(.keyword_if); + _ = try p.expectToken(.l_paren); + const condition = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + const then_payload = try p.parsePtrPayload(); - const block_expr = (try p.parseBlockExpr()); - const assign_expr = if (block_expr == null) - try p.expectNode(parseAssignExpr, .{ - .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, - }) - else - null; - - const semicolon = if (assign_expr != null) p.eatToken(.Semicolon) else null; - - const else_node = if (semicolon == null) blk: { - const else_token = p.eatToken(.Keyword_else) orelse break :blk null; - const payload = try p.parsePayload(); - const else_body = try p.expectNode(parseStatement, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - - const node = try p.arena.allocator.create(Node.Else); - node.* = .{ - .else_token = else_token, - .payload = payload, - .body = else_body, - }; - - break :blk node; - } else null; - - if (block_expr) |body| { - if_prefix.body = body; - if_prefix.@"else" = else_node; - return if_node; - } - - if (assign_expr) |body| { - if_prefix.body = body; - if (semicolon != null) return if_node; - if (else_node != null) { - if_prefix.@"else" = else_node; - return if_node; + // TODO propose to change the syntax so that semicolons are always required + // inside if statements, even if there is an `else`. + var else_required = false; + const then_expr = blk: { + const block_expr = try p.parseBlockExpr(); + if (block_expr != 0) break :blk block_expr; + const assign_expr = try p.parseAssignExpr(); + if (assign_expr == 0) { + return p.fail(.expected_block_or_assignment); } - try p.errors.append(p.gpa, .{ - .ExpectedSemiOrElse = .{ .token = p.tok_i }, + if (p.eatToken(.semicolon)) |_| { + return p.addNode(.{ + .tag = .if_simple, + .main_token = if_token, + .data = .{ + .lhs = condition, + .rhs = assign_expr, + }, + }); + } + else_required = true; + break :blk assign_expr; + }; + const else_token = p.eatToken(.keyword_else) orelse { + if (else_required) { + try p.warn(.expected_semi_or_else); + } + return p.addNode(.{ + .tag = .if_simple, + .main_token = if_token, + .data = .{ + .lhs = condition, + .rhs = then_expr, + }, }); - } - - return if_node; + }; + const else_payload = try p.parsePayload(); + const else_expr = try p.expectStatement(); + return p.addNode(.{ + .tag = .@"if", + .main_token = if_token, + .data = .{ + .lhs = condition, + .rhs = try p.addExtra(Node.If{ + .then_expr = then_expr, + .else_expr = else_expr, + }), + }, + }); } /// LabeledStatement <- BlockLabel? (Block / LoopStatement) - fn parseLabeledStatement(p: *Parser) !?*Node { - var colon: TokenIndex = undefined; - const label_token = p.parseBlockLabel(&colon); + fn parseLabeledStatement(p: *Parser) !Node.Index { + const label_token = p.parseBlockLabel(); + const block = try p.parseBlock(); + if (block != 0) return block; - if (try p.parseBlock(label_token)) |node| return node; + const loop_stmt = try p.parseLoopStatement(); + if (loop_stmt != 0) return loop_stmt; - if (try p.parseLoopStatement()) |node| { - if (node.cast(Node.For)) |for_node| { - for_node.label = label_token; - } else if (node.cast(Node.While)) |while_node| { - while_node.label = label_token; - } else unreachable; - return node; + if (label_token != 0) { + return p.fail(.expected_labelable); } - if (label_token != null) { - try p.errors.append(p.gpa, .{ - .ExpectedLabelable = .{ .token = p.tok_i }, - }); - return error.ParseError; - } - - return null; + return null_node; } /// LoopStatement <- KEYWORD_inline? (ForStatement / WhileStatement) - fn parseLoopStatement(p: *Parser) !?*Node { - const inline_token = p.eatToken(.Keyword_inline); + fn parseLoopStatement(p: *Parser) !Node.Index { + const inline_token = p.eatToken(.keyword_inline); - if (try p.parseForStatement()) |node| { - node.cast(Node.For).?.inline_token = inline_token; - return node; - } + const for_statement = try p.parseForStatement(); + if (for_statement != 0) return for_statement; - if (try p.parseWhileStatement()) |node| { - node.cast(Node.While).?.inline_token = inline_token; - return node; - } - if (inline_token == null) return null; + const while_statement = try p.parseWhileStatement(); + if (while_statement != 0) return while_statement; + + if (inline_token == null) return null_node; // If we've seen "inline", there should have been a "for" or "while" - try p.errors.append(p.gpa, .{ - .ExpectedInlinable = .{ .token = p.tok_i }, - }); - return error.ParseError; + return p.fail(.expected_inlinable); } + /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload /// ForStatement /// <- ForPrefix BlockExpr ( KEYWORD_else Statement )? /// / ForPrefix AssignExpr ( SEMICOLON / KEYWORD_else Statement ) - fn parseForStatement(p: *Parser) !?*Node { - const node = (try p.parseForPrefix()) orelse return null; - const for_prefix = node.cast(Node.For).?; + fn parseForStatement(p: *Parser) !Node.Index { + const for_token = p.eatToken(.keyword_for) orelse return null_node; + _ = try p.expectToken(.l_paren); + const array_expr = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + const found_payload = try p.parsePtrIndexPayload(); + if (found_payload == 0) try p.warn(.expected_loop_payload); - if (try p.parseBlockExpr()) |block_expr_node| { - for_prefix.body = block_expr_node; - - if (p.eatToken(.Keyword_else)) |else_token| { - const statement_node = try p.expectNode(parseStatement, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - - const else_node = try p.arena.allocator.create(Node.Else); - else_node.* = .{ - .else_token = else_token, - .payload = null, - .body = statement_node, - }; - for_prefix.@"else" = else_node; - - return node; + // TODO propose to change the syntax so that semicolons are always required + // inside while statements, even if there is an `else`. + var else_required = false; + const then_expr = blk: { + const block_expr = try p.parseBlockExpr(); + if (block_expr != 0) break :blk block_expr; + const assign_expr = try p.parseAssignExpr(); + if (assign_expr == 0) { + return p.fail(.expected_block_or_assignment); } - - return node; - } - - for_prefix.body = try p.expectNode(parseAssignExpr, .{ - .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, - }); - - if (p.eatToken(.Semicolon) != null) return node; - - if (p.eatToken(.Keyword_else)) |else_token| { - const statement_node = try p.expectNode(parseStatement, .{ - .ExpectedStatement = .{ .token = p.tok_i }, + if (p.eatToken(.semicolon)) |_| { + return p.addNode(.{ + .tag = .for_simple, + .main_token = for_token, + .data = .{ + .lhs = array_expr, + .rhs = assign_expr, + }, + }); + } + else_required = true; + break :blk assign_expr; + }; + const else_token = p.eatToken(.keyword_else) orelse { + if (else_required) { + try p.warn(.expected_semi_or_else); + } + return p.addNode(.{ + .tag = .for_simple, + .main_token = for_token, + .data = .{ + .lhs = array_expr, + .rhs = then_expr, + }, }); - - const else_node = try p.arena.allocator.create(Node.Else); - else_node.* = .{ - .else_token = else_token, - .payload = null, - .body = statement_node, - }; - for_prefix.@"else" = else_node; - return node; - } - - try p.errors.append(p.gpa, .{ - .ExpectedSemiOrElse = .{ .token = p.tok_i }, + }; + return p.addNode(.{ + .tag = .@"for", + .main_token = for_token, + .data = .{ + .lhs = array_expr, + .rhs = try p.addExtra(Node.If{ + .then_expr = then_expr, + .else_expr = try p.expectStatement(), + }), + }, }); - - return node; } + /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr? /// WhileStatement /// <- WhilePrefix BlockExpr ( KEYWORD_else Payload? Statement )? /// / WhilePrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement ) - fn parseWhileStatement(p: *Parser) !?*Node { - const node = (try p.parseWhilePrefix()) orelse return null; - const while_prefix = node.cast(Node.While).?; + fn parseWhileStatement(p: *Parser) !Node.Index { + const while_token = p.eatToken(.keyword_while) orelse return null_node; + _ = try p.expectToken(.l_paren); + const condition = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + const then_payload = try p.parsePtrPayload(); + const cont_expr = try p.parseWhileContinueExpr(); - if (try p.parseBlockExpr()) |block_expr_node| { - while_prefix.body = block_expr_node; - - if (p.eatToken(.Keyword_else)) |else_token| { - const payload = try p.parsePayload(); - - const statement_node = try p.expectNode(parseStatement, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - - const else_node = try p.arena.allocator.create(Node.Else); - else_node.* = .{ - .else_token = else_token, - .payload = payload, - .body = statement_node, - }; - while_prefix.@"else" = else_node; - - return node; + // TODO propose to change the syntax so that semicolons are always required + // inside while statements, even if there is an `else`. + var else_required = false; + const then_expr = blk: { + const block_expr = try p.parseBlockExpr(); + if (block_expr != 0) break :blk block_expr; + const assign_expr = try p.parseAssignExpr(); + if (assign_expr == 0) { + return p.fail(.expected_block_or_assignment); } - - return node; - } - - while_prefix.body = try p.expectNode(parseAssignExpr, .{ - .ExpectedBlockOrAssignment = .{ .token = p.tok_i }, + if (p.eatToken(.semicolon)) |_| { + if (cont_expr == 0) { + return p.addNode(.{ + .tag = .while_simple, + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = assign_expr, + }, + }); + } else { + return p.addNode(.{ + .tag = .while_cont, + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = try p.addExtra(Node.WhileCont{ + .cont_expr = cont_expr, + .then_expr = assign_expr, + }), + }, + }); + } + } + else_required = true; + break :blk assign_expr; + }; + const else_token = p.eatToken(.keyword_else) orelse { + if (else_required) { + try p.warn(.expected_semi_or_else); + } + if (cont_expr == 0) { + return p.addNode(.{ + .tag = .while_simple, + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = then_expr, + }, + }); + } else { + return p.addNode(.{ + .tag = .while_cont, + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = try p.addExtra(Node.WhileCont{ + .cont_expr = cont_expr, + .then_expr = then_expr, + }), + }, + }); + } + }; + const else_payload = try p.parsePayload(); + const else_expr = try p.expectStatement(); + return p.addNode(.{ + .tag = .@"while", + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = try p.addExtra(Node.While{ + .cont_expr = cont_expr, + .then_expr = then_expr, + .else_expr = else_expr, + }), + }, }); - - if (p.eatToken(.Semicolon) != null) return node; - - if (p.eatToken(.Keyword_else)) |else_token| { - const payload = try p.parsePayload(); - - const statement_node = try p.expectNode(parseStatement, .{ - .ExpectedStatement = .{ .token = p.tok_i }, - }); - - const else_node = try p.arena.allocator.create(Node.Else); - else_node.* = .{ - .else_token = else_token, - .payload = payload, - .body = statement_node, - }; - while_prefix.@"else" = else_node; - return node; - } - - try p.errors.append(p.gpa, .{ - .ExpectedSemiOrElse = .{ .token = p.tok_i }, - }); - - return node; } /// BlockExprStatement /// <- BlockExpr /// / AssignExpr SEMICOLON - fn parseBlockExprStatement(p: *Parser) !?*Node { - if (try p.parseBlockExpr()) |node| return node; - if (try p.parseAssignExpr()) |node| { - _ = try p.expectTokenRecoverable(.Semicolon); - return node; + fn parseBlockExprStatement(p: *Parser) !Node.Index { + const block_expr = try p.parseBlockExpr(); + if (block_expr != 0) { + return block_expr; } - return null; + const assign_expr = try p.parseAssignExpr(); + if (assign_expr != 0) { + _ = try p.expectTokenRecoverable(.semicolon); + return assign_expr; + } + return null_node; + } + + fn expectBlockExprStatement(p: *Parser) !Node.Index { + const node = try p.parseBlockExprStatement(); + if (node == 0) { + return p.fail(.expected_block_or_expr); + } + return node; } /// BlockExpr <- BlockLabel? Block - fn parseBlockExpr(p: *Parser) Error!?*Node { - var colon: TokenIndex = undefined; - const label_token = p.parseBlockLabel(&colon); - const block_node = (try p.parseBlock(label_token)) orelse { - if (label_token) |label| { - p.putBackToken(label + 1); // ":" - p.putBackToken(label); // IDENTIFIER - } - return null; - }; - return block_node; + fn parseBlockExpr(p: *Parser) Error!Node.Index { + switch (p.token_tags[p.tok_i]) { + .identifier => { + if (p.token_tags[p.tok_i + 1] == .colon and + p.token_tags[p.tok_i + 2] == .l_brace) + { + p.tok_i += 2; + return p.parseBlock(); + } else { + return null_node; + } + }, + .l_brace => return p.parseBlock(), + else => return null_node, + } } /// AssignExpr <- Expr (AssignOp Expr)? - fn parseAssignExpr(p: *Parser) !?*Node { - return p.parseBinOpExpr(parseAssignOp, parseExpr, .Once); + /// AssignOp + /// <- ASTERISKEQUAL + /// / SLASHEQUAL + /// / PERCENTEQUAL + /// / PLUSEQUAL + /// / MINUSEQUAL + /// / LARROW2EQUAL + /// / RARROW2EQUAL + /// / AMPERSANDEQUAL + /// / CARETEQUAL + /// / PIPEEQUAL + /// / ASTERISKPERCENTEQUAL + /// / PLUSPERCENTEQUAL + /// / MINUSPERCENTEQUAL + /// / EQUAL + fn parseAssignExpr(p: *Parser) !Node.Index { + const expr = try p.parseExpr(); + if (expr == 0) return null_node; + + const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { + .asterisk_equal => .assign_mul, + .slash_equal => .assign_div, + .percent_equal => .assign_mod, + .plus_equal => .assign_add, + .minus_equal => .assign_sub, + .angle_bracket_angle_bracket_left_equal => .assign_bit_shift_left, + .angle_bracket_angle_bracket_right_equal => .assign_bit_shift_right, + .ampersand_equal => .assign_bit_and, + .caret_equal => .assign_bit_xor, + .pipe_equal => .assign_bit_or, + .asterisk_percent_equal => .assign_mul_wrap, + .plus_percent_equal => .assign_add_wrap, + .minus_percent_equal => .assign_sub_wrap, + .equal => .assign, + else => return expr, + }; + return p.addNode(.{ + .tag = tag, + .main_token = p.nextToken(), + .data = .{ + .lhs = expr, + .rhs = try p.expectExpr(), + }, + }); + } + + fn expectAssignExpr(p: *Parser) !Node.Index { + const expr = try p.parseAssignExpr(); + if (expr == 0) { + return p.fail(.expected_expr_or_assignment); + } + return expr; } /// Expr <- BoolOrExpr - fn parseExpr(p: *Parser) Error!?*Node { - return p.parsePrefixOpExpr(parseTry, parseBoolOrExpr); + fn parseExpr(p: *Parser) Error!Node.Index { + return p.parseBoolOrExpr(); + } + + fn expectExpr(p: *Parser) Error!Node.Index { + const node = try p.parseExpr(); + if (node == 0) { + return p.fail(.expected_expr); + } else { + return node; + } } /// BoolOrExpr <- BoolAndExpr (KEYWORD_or BoolAndExpr)* - fn parseBoolOrExpr(p: *Parser) !?*Node { - return p.parseBinOpExpr( - SimpleBinOpParseFn(.Keyword_or, .BoolOr), - parseBoolAndExpr, - .Infinitely, - ); + fn parseBoolOrExpr(p: *Parser) Error!Node.Index { + var res = try p.parseBoolAndExpr(); + if (res == 0) return null_node; + + while (true) { + switch (p.token_tags[p.tok_i]) { + .keyword_or => { + const or_token = p.nextToken(); + const rhs = try p.parseBoolAndExpr(); + if (rhs == 0) { + return p.fail(.invalid_token); + } + res = try p.addNode(.{ + .tag = .bool_or, + .main_token = or_token, + .data = .{ + .lhs = res, + .rhs = rhs, + }, + }); + }, + else => return res, + } + } } /// BoolAndExpr <- CompareExpr (KEYWORD_and CompareExpr)* - fn parseBoolAndExpr(p: *Parser) !?*Node { - return p.parseBinOpExpr( - SimpleBinOpParseFn(.Keyword_and, .BoolAnd), - parseCompareExpr, - .Infinitely, - ); + fn parseBoolAndExpr(p: *Parser) !Node.Index { + var res = try p.parseCompareExpr(); + if (res == 0) return null_node; + + while (true) { + switch (p.token_tags[p.tok_i]) { + .keyword_and => { + const and_token = p.nextToken(); + const rhs = try p.parseCompareExpr(); + if (rhs == 0) { + return p.fail(.invalid_token); + } + res = try p.addNode(.{ + .tag = .bool_and, + .main_token = and_token, + .data = .{ + .lhs = res, + .rhs = rhs, + }, + }); + }, + .invalid_ampersands => { + try p.warn(.invalid_and); + p.tok_i += 1; + return p.parseCompareExpr(); + }, + else => return res, + } + } } /// CompareExpr <- BitwiseExpr (CompareOp BitwiseExpr)? - fn parseCompareExpr(p: *Parser) !?*Node { - return p.parseBinOpExpr(parseCompareOp, parseBitwiseExpr, .Once); + /// CompareOp + /// <- EQUALEQUAL + /// / EXCLAMATIONMARKEQUAL + /// / LARROW + /// / RARROW + /// / LARROWEQUAL + /// / RARROWEQUAL + fn parseCompareExpr(p: *Parser) !Node.Index { + const expr = try p.parseBitwiseExpr(); + if (expr == 0) return null_node; + + const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { + .equal_equal => .equal_equal, + .bang_equal => .bang_equal, + .angle_bracket_left => .less_than, + .angle_bracket_right => .greater_than, + .angle_bracket_left_equal => .less_or_equal, + .angle_bracket_right_equal => .greater_or_equal, + else => return expr, + }; + return p.addNode(.{ + .tag = tag, + .main_token = p.nextToken(), + .data = .{ + .lhs = expr, + .rhs = try p.expectBitwiseExpr(), + }, + }); } /// BitwiseExpr <- BitShiftExpr (BitwiseOp BitShiftExpr)* - fn parseBitwiseExpr(p: *Parser) !?*Node { - return p.parseBinOpExpr(parseBitwiseOp, parseBitShiftExpr, .Infinitely); + /// BitwiseOp + /// <- AMPERSAND + /// / CARET + /// / PIPE + /// / KEYWORD_orelse + /// / KEYWORD_catch Payload? + fn parseBitwiseExpr(p: *Parser) !Node.Index { + var res = try p.parseBitShiftExpr(); + if (res == 0) return null_node; + + while (true) { + const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { + .ampersand => .bit_and, + .caret => .bit_xor, + .pipe => .bit_or, + .keyword_orelse => .@"orelse", + .keyword_catch => { + const catch_token = p.nextToken(); + _ = try p.parsePayload(); + const rhs = try p.parseBitShiftExpr(); + if (rhs == 0) { + return p.fail(.invalid_token); + } + res = try p.addNode(.{ + .tag = .@"catch", + .main_token = catch_token, + .data = .{ + .lhs = res, + .rhs = rhs, + }, + }); + continue; + }, + else => return res, + }; + res = try p.addNode(.{ + .tag = tag, + .main_token = p.nextToken(), + .data = .{ + .lhs = res, + .rhs = try p.expectBitShiftExpr(), + }, + }); + } + } + + fn expectBitwiseExpr(p: *Parser) Error!Node.Index { + const node = try p.parseBitwiseExpr(); + if (node == 0) { + return p.fail(.invalid_token); + } else { + return node; + } } /// BitShiftExpr <- AdditionExpr (BitShiftOp AdditionExpr)* - fn parseBitShiftExpr(p: *Parser) !?*Node { - return p.parseBinOpExpr(parseBitShiftOp, parseAdditionExpr, .Infinitely); + /// BitShiftOp + /// <- LARROW2 + /// / RARROW2 + fn parseBitShiftExpr(p: *Parser) Error!Node.Index { + var res = try p.parseAdditionExpr(); + if (res == 0) return null_node; + + while (true) { + const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { + .angle_bracket_angle_bracket_left => .bit_shift_left, + .angle_bracket_angle_bracket_right => .bit_shift_right, + else => return res, + }; + res = try p.addNode(.{ + .tag = tag, + .main_token = p.nextToken(), + .data = .{ + .lhs = res, + .rhs = try p.expectAdditionExpr(), + }, + }); + } + } + + fn expectBitShiftExpr(p: *Parser) Error!Node.Index { + const node = try p.parseBitShiftExpr(); + if (node == 0) { + return p.fail(.invalid_token); + } else { + return node; + } } /// AdditionExpr <- MultiplyExpr (AdditionOp MultiplyExpr)* - fn parseAdditionExpr(p: *Parser) !?*Node { - return p.parseBinOpExpr(parseAdditionOp, parseMultiplyExpr, .Infinitely); + /// AdditionOp + /// <- PLUS + /// / MINUS + /// / PLUS2 + /// / PLUSPERCENT + /// / MINUSPERCENT + fn parseAdditionExpr(p: *Parser) Error!Node.Index { + var res = try p.parseMultiplyExpr(); + if (res == 0) return null_node; + + while (true) { + const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { + .plus => .add, + .minus => .sub, + .plus_plus => .array_cat, + .plus_percent => .add_wrap, + .minus_percent => .sub_wrap, + else => return res, + }; + res = try p.addNode(.{ + .tag = tag, + .main_token = p.nextToken(), + .data = .{ + .lhs = res, + .rhs = try p.expectMultiplyExpr(), + }, + }); + } + } + + fn expectAdditionExpr(p: *Parser) Error!Node.Index { + const node = try p.parseAdditionExpr(); + if (node == 0) { + return p.fail(.invalid_token); + } + return node; } /// MultiplyExpr <- PrefixExpr (MultiplyOp PrefixExpr)* - fn parseMultiplyExpr(p: *Parser) !?*Node { - return p.parseBinOpExpr(parseMultiplyOp, parsePrefixExpr, .Infinitely); + /// MultiplyOp + /// <- PIPE2 + /// / ASTERISK + /// / SLASH + /// / PERCENT + /// / ASTERISK2 + /// / ASTERISKPERCENT + fn parseMultiplyExpr(p: *Parser) Error!Node.Index { + var res = try p.parsePrefixExpr(); + if (res == 0) return null_node; + + while (true) { + const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { + .pipe_pipe => .merge_error_sets, + .asterisk => .mul, + .slash => .div, + .percent => .mod, + .asterisk_asterisk => .array_mult, + .asterisk_percent => .mul_wrap, + else => return res, + }; + res = try p.addNode(.{ + .tag = tag, + .main_token = p.nextToken(), + .data = .{ + .lhs = res, + .rhs = try p.expectPrefixExpr(), + }, + }); + } + } + + fn expectMultiplyExpr(p: *Parser) Error!Node.Index { + const node = try p.parseMultiplyExpr(); + if (node == 0) { + return p.fail(.invalid_token); + } + return node; } /// PrefixExpr <- PrefixOp* PrimaryExpr - fn parsePrefixExpr(p: *Parser) !?*Node { - return p.parsePrefixOpExpr(parsePrefixOp, parsePrimaryExpr); + /// PrefixOp + /// <- EXCLAMATIONMARK + /// / MINUS + /// / TILDE + /// / MINUSPERCENT + /// / AMPERSAND + /// / KEYWORD_try + /// / KEYWORD_await + fn parsePrefixExpr(p: *Parser) Error!Node.Index { + const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { + .bang => .bool_not, + .minus => .negation, + .tilde => .bit_not, + .minus_percent => .negation_wrap, + .ampersand => .address_of, + .keyword_try => .@"try", + .keyword_await => .@"await", + else => return p.parsePrimaryExpr(), + }; + return p.addNode(.{ + .tag = tag, + .main_token = p.nextToken(), + .data = .{ + .lhs = try p.expectPrefixExpr(), + .rhs = undefined, + }, + }); + } + + fn expectPrefixExpr(p: *Parser) Error!Node.Index { + const node = try p.parsePrefixExpr(); + if (node == 0) { + return p.fail(.expected_prefix_expr); + } + return node; + } + + /// TypeExpr <- PrefixTypeOp* ErrorUnionExpr + /// PrefixTypeOp + /// <- QUESTIONMARK + /// / KEYWORD_anyframe MINUSRARROW + /// / ArrayTypeStart (ByteAlign / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)* + /// / PtrTypeStart (KEYWORD_align LPAREN Expr (COLON INTEGER COLON INTEGER)? RPAREN / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)* + /// PtrTypeStart + /// <- ASTERISK + /// / ASTERISK2 + /// / LBRACKET ASTERISK (LETTERC / COLON Expr)? RBRACKET + /// ArrayTypeStart <- LBRACKET Expr? (COLON Expr)? RBRACKET + fn parseTypeExpr(p: *Parser) Error!Node.Index { + switch (p.token_tags[p.tok_i]) { + .question_mark => return p.addNode(.{ + .tag = .optional_type, + .main_token = p.nextToken(), + .data = .{ + .lhs = try p.expectTypeExpr(), + .rhs = undefined, + }, + }), + .keyword_anyframe => switch (p.token_tags[p.tok_i + 1]) { + .arrow => return p.addNode(.{ + .tag = .anyframe_type, + .main_token = p.nextToken(), + .data = .{ + .lhs = p.nextToken(), + .rhs = try p.expectTypeExpr(), + }, + }), + else => return p.parseErrorUnionExpr(), + }, + .asterisk => { + const asterisk = p.nextToken(); + const mods = try p.parsePtrModifiers(); + const elem_type = try p.expectTypeExpr(); + if (mods.bit_range_start == 0) { + return p.addNode(.{ + .tag = .ptr_type_aligned, + .main_token = asterisk, + .data = .{ + .lhs = mods.align_node, + .rhs = elem_type, + }, + }); + } else { + return p.addNode(.{ + .tag = .ptr_type_bit_range, + .main_token = asterisk, + .data = .{ + .lhs = try p.addExtra(Node.PtrTypeBitRange{ + .sentinel = 0, + .align_node = mods.align_node, + .bit_range_start = mods.bit_range_start, + .bit_range_end = mods.bit_range_end, + }), + .rhs = elem_type, + }, + }); + } + }, + .asterisk_asterisk => { + const asterisk = p.nextToken(); + const mods = try p.parsePtrModifiers(); + const elem_type = try p.expectTypeExpr(); + const inner: Node.Index = inner: { + if (mods.bit_range_start == 0) { + break :inner try p.addNode(.{ + .tag = .ptr_type_aligned, + .main_token = asterisk, + .data = .{ + .lhs = mods.align_node, + .rhs = elem_type, + }, + }); + } else { + break :inner try p.addNode(.{ + .tag = .ptr_type_bit_range, + .main_token = asterisk, + .data = .{ + .lhs = try p.addExtra(Node.PtrTypeBitRange{ + .sentinel = 0, + .align_node = mods.align_node, + .bit_range_start = mods.bit_range_start, + .bit_range_end = mods.bit_range_end, + }), + .rhs = elem_type, + }, + }); + } + }; + return p.addNode(.{ + .tag = .ptr_type_aligned, + .main_token = asterisk, + .data = .{ + .lhs = 0, + .rhs = inner, + }, + }); + }, + .l_bracket => switch (p.token_tags[p.tok_i + 1]) { + .asterisk => { + const lbracket = p.nextToken(); + const asterisk = p.nextToken(); + var sentinel: Node.Index = 0; + prefix: { + if (p.eatToken(.identifier)) |ident| { + const token_slice = p.source[p.token_starts[ident]..][0..2]; + if (!std.mem.eql(u8, token_slice, "c]")) { + p.tok_i -= 1; + } else { + break :prefix; + } + } + if (p.eatToken(.colon)) |_| { + sentinel = try p.expectExpr(); + } + } + _ = try p.expectToken(.r_bracket); + const mods = try p.parsePtrModifiers(); + const elem_type = try p.expectTypeExpr(); + if (mods.bit_range_start == 0) { + if (sentinel == 0) { + return p.addNode(.{ + .tag = .ptr_type_aligned, + .main_token = asterisk, + .data = .{ + .lhs = mods.align_node, + .rhs = elem_type, + }, + }); + } else if (mods.align_node == 0) { + return p.addNode(.{ + .tag = .ptr_type_sentinel, + .main_token = asterisk, + .data = .{ + .lhs = sentinel, + .rhs = elem_type, + }, + }); + } else { + return p.addNode(.{ + .tag = .ptr_type, + .main_token = asterisk, + .data = .{ + .lhs = try p.addExtra(Node.PtrType{ + .sentinel = sentinel, + .align_node = mods.align_node, + }), + .rhs = elem_type, + }, + }); + } + } else { + return p.addNode(.{ + .tag = .ptr_type_bit_range, + .main_token = asterisk, + .data = .{ + .lhs = try p.addExtra(Node.PtrTypeBitRange{ + .sentinel = sentinel, + .align_node = mods.align_node, + .bit_range_start = mods.bit_range_start, + .bit_range_end = mods.bit_range_end, + }), + .rhs = elem_type, + }, + }); + } + }, + else => { + const lbracket = p.nextToken(); + const len_expr = try p.parseExpr(); + const sentinel: Node.Index = if (p.eatToken(.colon)) |_| + try p.expectExpr() + else + 0; + _ = try p.expectToken(.r_bracket); + const mods = try p.parsePtrModifiers(); + const elem_type = try p.expectTypeExpr(); + if (mods.bit_range_start != 0) { + try p.warnMsg(.{ + .tag = .invalid_bit_range, + .token = p.nodes.items(.main_token)[mods.bit_range_start], + }); + } + if (len_expr == 0) { + if (sentinel == 0) { + return p.addNode(.{ + .tag = .ptr_type_aligned, + .main_token = lbracket, + .data = .{ + .lhs = mods.align_node, + .rhs = elem_type, + }, + }); + } else if (mods.align_node == 0) { + return p.addNode(.{ + .tag = .ptr_type_sentinel, + .main_token = lbracket, + .data = .{ + .lhs = sentinel, + .rhs = elem_type, + }, + }); + } else { + return p.addNode(.{ + .tag = .ptr_type, + .main_token = lbracket, + .data = .{ + .lhs = try p.addExtra(Node.PtrType{ + .sentinel = sentinel, + .align_node = mods.align_node, + }), + .rhs = elem_type, + }, + }); + } + } else { + if (mods.align_node != 0) { + try p.warnMsg(.{ + .tag = .invalid_align, + .token = p.nodes.items(.main_token)[mods.align_node], + }); + } + if (sentinel == 0) { + return p.addNode(.{ + .tag = .array_type, + .main_token = lbracket, + .data = .{ + .lhs = len_expr, + .rhs = elem_type, + }, + }); + } else { + return p.addNode(.{ + .tag = .array_type_sentinel, + .main_token = lbracket, + .data = .{ + .lhs = len_expr, + .rhs = try p.addExtra(.{ + .elem_type = elem_type, + .sentinel = sentinel, + }), + }, + }); + } + } + }, + }, + else => return p.parseErrorUnionExpr(), + } + } + + fn expectTypeExpr(p: *Parser) Error!Node.Index { + const node = try p.parseTypeExpr(); + if (node == 0) { + return p.fail(.expected_type_expr); + } + return node; } /// PrimaryExpr @@ -1088,434 +1878,601 @@ const Parser = struct { /// / BlockLabel? LoopExpr /// / Block /// / CurlySuffixExpr - fn parsePrimaryExpr(p: *Parser) !?*Node { - if (try p.parseAsmExpr()) |node| return node; - if (try p.parseIfExpr()) |node| return node; - - if (p.eatToken(.Keyword_break)) |token| { - const label = try p.parseBreakLabel(); - const expr_node = try p.parseExpr(); - const node = try Node.ControlFlowExpression.create(&p.arena.allocator, .{ - .tag = .Break, - .ltoken = token, - }, .{ - .label = label, - .rhs = expr_node, - }); - return &node.base; + fn parsePrimaryExpr(p: *Parser) !Node.Index { + switch (p.token_tags[p.tok_i]) { + .keyword_asm => return p.expectAsmExpr(), + .keyword_if => return p.parseIfExpr(), + .keyword_break => { + p.tok_i += 1; + return p.addNode(.{ + .tag = .@"break", + .main_token = p.tok_i - 1, + .data = .{ + .lhs = try p.parseBreakLabel(), + .rhs = try p.parseExpr(), + }, + }); + }, + .keyword_continue => { + p.tok_i += 1; + return p.addNode(.{ + .tag = .@"continue", + .main_token = p.tok_i - 1, + .data = .{ + .lhs = try p.parseBreakLabel(), + .rhs = undefined, + }, + }); + }, + .keyword_comptime => { + p.tok_i += 1; + return p.addNode(.{ + .tag = .@"comptime", + .main_token = p.tok_i - 1, + .data = .{ + .lhs = try p.expectExpr(), + .rhs = undefined, + }, + }); + }, + .keyword_nosuspend => { + p.tok_i += 1; + return p.addNode(.{ + .tag = .@"nosuspend", + .main_token = p.tok_i - 1, + .data = .{ + .lhs = try p.expectExpr(), + .rhs = undefined, + }, + }); + }, + .keyword_resume => { + p.tok_i += 1; + return p.addNode(.{ + .tag = .@"resume", + .main_token = p.tok_i - 1, + .data = .{ + .lhs = try p.expectExpr(), + .rhs = undefined, + }, + }); + }, + .keyword_return => { + p.tok_i += 1; + return p.addNode(.{ + .tag = .@"return", + .main_token = p.tok_i - 1, + .data = .{ + .lhs = try p.parseExpr(), + .rhs = undefined, + }, + }); + }, + .identifier => { + if (p.token_tags[p.tok_i + 1] == .colon) { + switch (p.token_tags[p.tok_i + 2]) { + .keyword_inline => { + p.tok_i += 3; + switch (p.token_tags[p.tok_i]) { + .keyword_for => return p.parseForExpr(), + .keyword_while => return p.parseWhileExpr(), + else => return p.fail(.expected_inlinable), + } + }, + .keyword_for => { + p.tok_i += 2; + return p.parseForExpr(); + }, + .keyword_while => { + p.tok_i += 2; + return p.parseWhileExpr(); + }, + .l_brace => { + p.tok_i += 2; + return p.parseBlock(); + }, + else => return p.parseCurlySuffixExpr(), + } + } else { + return p.parseCurlySuffixExpr(); + } + }, + .keyword_inline => { + p.tok_i += 2; + switch (p.token_tags[p.tok_i]) { + .keyword_for => return p.parseForExpr(), + .keyword_while => return p.parseWhileExpr(), + else => return p.fail(.expected_inlinable), + } + }, + .keyword_for => return p.parseForExpr(), + .keyword_while => return p.parseWhileExpr(), + .l_brace => return p.parseBlock(), + else => return p.parseCurlySuffixExpr(), } - - if (p.eatToken(.Keyword_comptime)) |token| { - const expr_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - const node = try p.arena.allocator.create(Node.Comptime); - node.* = .{ - .doc_comments = null, - .comptime_token = token, - .expr = expr_node, - }; - return &node.base; - } - - if (p.eatToken(.Keyword_nosuspend)) |token| { - const expr_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - const node = try p.arena.allocator.create(Node.Nosuspend); - node.* = .{ - .nosuspend_token = token, - .expr = expr_node, - }; - return &node.base; - } - - if (p.eatToken(.Keyword_continue)) |token| { - const label = try p.parseBreakLabel(); - const node = try Node.ControlFlowExpression.create(&p.arena.allocator, .{ - .tag = .Continue, - .ltoken = token, - }, .{ - .label = label, - .rhs = null, - }); - return &node.base; - } - - if (p.eatToken(.Keyword_resume)) |token| { - const expr_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - const node = try p.arena.allocator.create(Node.SimplePrefixOp); - node.* = .{ - .base = .{ .tag = .Resume }, - .op_token = token, - .rhs = expr_node, - }; - return &node.base; - } - - if (p.eatToken(.Keyword_return)) |token| { - const expr_node = try p.parseExpr(); - const node = try Node.ControlFlowExpression.create(&p.arena.allocator, .{ - .tag = .Return, - .ltoken = token, - }, .{ - .rhs = expr_node, - }); - return &node.base; - } - - var colon: TokenIndex = undefined; - const label = p.parseBlockLabel(&colon); - if (try p.parseLoopExpr()) |node| { - if (node.cast(Node.For)) |for_node| { - for_node.label = label; - } else if (node.cast(Node.While)) |while_node| { - while_node.label = label; - } else unreachable; - return node; - } - if (label) |token| { - p.putBackToken(token + 1); // ":" - p.putBackToken(token); // IDENTIFIER - } - - if (try p.parseBlock(null)) |node| return node; - if (try p.parseCurlySuffixExpr()) |node| return node; - - return null; } /// IfExpr <- IfPrefix Expr (KEYWORD_else Payload? Expr)? - fn parseIfExpr(p: *Parser) !?*Node { + fn parseIfExpr(p: *Parser) !Node.Index { return p.parseIf(parseExpr); } /// Block <- LBRACE Statement* RBRACE - fn parseBlock(p: *Parser, label_token: ?TokenIndex) !?*Node { - const lbrace = p.eatToken(.LBrace) orelse return null; + fn parseBlock(p: *Parser) !Node.Index { + const lbrace = p.eatToken(.l_brace) orelse return null_node; - var statements = std.ArrayList(*Node).init(p.gpa); + if (p.eatToken(.r_brace)) |_| { + return p.addNode(.{ + .tag = .block_two, + .main_token = lbrace, + .data = .{ + .lhs = 0, + .rhs = 0, + }, + }); + } + + const stmt_one = try p.expectStatementRecoverable(); + if (p.eatToken(.r_brace)) |_| { + const semicolon = p.token_tags[p.tok_i - 2] == .semicolon; + return p.addNode(.{ + .tag = if (semicolon) .block_two_semicolon else .block_two, + .main_token = lbrace, + .data = .{ + .lhs = stmt_one, + .rhs = 0, + }, + }); + } + const stmt_two = try p.expectStatementRecoverable(); + if (p.eatToken(.r_brace)) |_| { + const semicolon = p.token_tags[p.tok_i - 2] == .semicolon; + return p.addNode(.{ + .tag = if (semicolon) .block_two_semicolon else .block_two, + .main_token = lbrace, + .data = .{ + .lhs = stmt_one, + .rhs = stmt_two, + }, + }); + } + + var statements = std.ArrayList(Node.Index).init(p.gpa); defer statements.deinit(); + try statements.appendSlice(&.{ stmt_one, stmt_two }); + while (true) { - const statement = (p.parseStatement() catch |err| switch (err) { - error.OutOfMemory => return error.OutOfMemory, - error.ParseError => { - // try to skip to the next statement - p.findNextStmt(); - continue; - }, - }) orelse break; + const statement = try p.expectStatementRecoverable(); + if (statement == 0) break; try statements.append(statement); + if (p.token_tags[p.tok_i] == .r_brace) break; } - - const rbrace = try p.expectToken(.RBrace); - - const statements_len = @intCast(NodeIndex, statements.items.len); - - if (label_token) |label| { - const block_node = try Node.LabeledBlock.alloc(&p.arena.allocator, statements_len); - block_node.* = .{ - .label = label, - .lbrace = lbrace, - .statements_len = statements_len, - .rbrace = rbrace, - }; - std.mem.copy(*Node, block_node.statements(), statements.items); - return &block_node.base; - } else { - const block_node = try Node.Block.alloc(&p.arena.allocator, statements_len); - block_node.* = .{ - .lbrace = lbrace, - .statements_len = statements_len, - .rbrace = rbrace, - }; - std.mem.copy(*Node, block_node.statements(), statements.items); - return &block_node.base; - } - } - - /// LoopExpr <- KEYWORD_inline? (ForExpr / WhileExpr) - fn parseLoopExpr(p: *Parser) !?*Node { - const inline_token = p.eatToken(.Keyword_inline); - - if (try p.parseForExpr()) |node| { - node.cast(Node.For).?.inline_token = inline_token; - return node; - } - - if (try p.parseWhileExpr()) |node| { - node.cast(Node.While).?.inline_token = inline_token; - return node; - } - - if (inline_token == null) return null; - - // If we've seen "inline", there should have been a "for" or "while" - try p.errors.append(p.gpa, .{ - .ExpectedInlinable = .{ .token = p.tok_i }, + _ = try p.expectToken(.r_brace); + const semicolon = p.token_tags[p.tok_i - 2] == .semicolon; + const statements_span = try p.listToSpan(statements.items); + return p.addNode(.{ + .tag = if (semicolon) .block_semicolon else .block, + .main_token = lbrace, + .data = .{ + .lhs = statements_span.start, + .rhs = statements_span.end, + }, }); - return error.ParseError; } + /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload /// ForExpr <- ForPrefix Expr (KEYWORD_else Expr)? - fn parseForExpr(p: *Parser) !?*Node { - const node = (try p.parseForPrefix()) orelse return null; - const for_prefix = node.cast(Node.For).?; + fn parseForExpr(p: *Parser) !Node.Index { + const for_token = p.eatToken(.keyword_for) orelse return null_node; + _ = try p.expectToken(.l_paren); + const array_expr = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + const found_payload = try p.parsePtrIndexPayload(); + if (found_payload == 0) try p.warn(.expected_loop_payload); - const body_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - for_prefix.body = body_node; - - if (p.eatToken(.Keyword_else)) |else_token| { - const body = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, + const then_expr = try p.expectExpr(); + const else_token = p.eatToken(.keyword_else) orelse { + return p.addNode(.{ + .tag = .for_simple, + .main_token = for_token, + .data = .{ + .lhs = array_expr, + .rhs = then_expr, + }, }); - - const else_node = try p.arena.allocator.create(Node.Else); - else_node.* = .{ - .else_token = else_token, - .payload = null, - .body = body, - }; - - for_prefix.@"else" = else_node; - } - - return node; + }; + const else_expr = try p.expectExpr(); + return p.addNode(.{ + .tag = .@"for", + .main_token = for_token, + .data = .{ + .lhs = array_expr, + .rhs = try p.addExtra(Node.If{ + .then_expr = then_expr, + .else_expr = else_expr, + }), + }, + }); } + /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr? /// WhileExpr <- WhilePrefix Expr (KEYWORD_else Payload? Expr)? - fn parseWhileExpr(p: *Parser) !?*Node { - const node = (try p.parseWhilePrefix()) orelse return null; - const while_prefix = node.cast(Node.While).?; + fn parseWhileExpr(p: *Parser) !Node.Index { + const while_token = p.eatToken(.keyword_while) orelse return null_node; + _ = try p.expectToken(.l_paren); + const condition = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + const then_payload = try p.parsePtrPayload(); + const cont_expr = try p.parseWhileContinueExpr(); - const body_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, + const then_expr = try p.expectExpr(); + const else_token = p.eatToken(.keyword_else) orelse { + if (cont_expr == 0) { + return p.addNode(.{ + .tag = .while_simple, + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = then_expr, + }, + }); + } else { + return p.addNode(.{ + .tag = .while_cont, + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = try p.addExtra(Node.WhileCont{ + .cont_expr = cont_expr, + .then_expr = then_expr, + }), + }, + }); + } + }; + const else_payload = try p.parsePayload(); + const else_expr = try p.expectExpr(); + return p.addNode(.{ + .tag = .@"while", + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = try p.addExtra(Node.While{ + .cont_expr = cont_expr, + .then_expr = then_expr, + .else_expr = else_expr, + }), + }, }); - while_prefix.body = body_node; - - if (p.eatToken(.Keyword_else)) |else_token| { - const payload = try p.parsePayload(); - const body = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - - const else_node = try p.arena.allocator.create(Node.Else); - else_node.* = .{ - .else_token = else_token, - .payload = payload, - .body = body, - }; - - while_prefix.@"else" = else_node; - } - - return node; } /// CurlySuffixExpr <- TypeExpr InitList? - fn parseCurlySuffixExpr(p: *Parser) !?*Node { - const lhs = (try p.parseTypeExpr()) orelse return null; - const suffix_op = (try p.parseInitList(lhs)) orelse return lhs; - return suffix_op; - } - /// InitList /// <- LBRACE FieldInit (COMMA FieldInit)* COMMA? RBRACE /// / LBRACE Expr (COMMA Expr)* COMMA? RBRACE /// / LBRACE RBRACE - fn parseInitList(p: *Parser, lhs: *Node) !?*Node { - const lbrace = p.eatToken(.LBrace) orelse return null; - var init_list = std.ArrayList(*Node).init(p.gpa); + fn parseCurlySuffixExpr(p: *Parser) !Node.Index { + const lhs = try p.parseTypeExpr(); + if (lhs == 0) return null_node; + const lbrace = p.eatToken(.l_brace) orelse return lhs; + + // If there are 0 or 1 items, we can use ArrayInitOne/StructInitOne; + // otherwise we use the full ArrayInit/StructInit. + + if (p.eatToken(.r_brace)) |_| { + return p.addNode(.{ + .tag = .struct_init_one, + .main_token = lbrace, + .data = .{ + .lhs = lhs, + .rhs = 0, + }, + }); + } + const field_init = try p.parseFieldInit(); + if (field_init != 0) { + const comma_one = p.eatToken(.comma); + if (p.eatToken(.r_brace)) |_| { + return p.addNode(.{ + .tag = if (comma_one != null) .struct_init_one_comma else .struct_init_one, + .main_token = lbrace, + .data = .{ + .lhs = lhs, + .rhs = field_init, + }, + }); + } + + var init_list = std.ArrayList(Node.Index).init(p.gpa); + defer init_list.deinit(); + + try init_list.append(field_init); + + while (true) { + const next = try p.expectFieldInit(); + try init_list.append(next); + + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_brace)) |_| break; + continue; + }, + .r_brace => break, + .colon, .r_paren, .r_bracket => { + p.tok_i -= 1; + return p.failExpected(.r_brace); + }, + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } + const span = try p.listToSpan(init_list.items); + return p.addNode(.{ + .tag = if (p.token_tags[p.tok_i - 2] == .comma) .struct_init_comma else .struct_init, + .main_token = lbrace, + .data = .{ + .lhs = lhs, + .rhs = try p.addExtra(Node.SubRange{ + .start = span.start, + .end = span.end, + }), + }, + }); + } + + const elem_init = try p.expectExpr(); + const comma_one = p.eatToken(.comma); + if (p.eatToken(.r_brace)) |_| { + return p.addNode(.{ + .tag = if (comma_one != null) .array_init_one_comma else .array_init_one, + .main_token = lbrace, + .data = .{ + .lhs = lhs, + .rhs = elem_init, + }, + }); + } + if (comma_one == null) { + try p.warnExpected(.comma); + } + + var init_list = std.ArrayList(Node.Index).init(p.gpa); defer init_list.deinit(); - if (try p.parseFieldInit()) |field_init| { - try init_list.append(field_init); - while (p.eatToken(.Comma)) |_| { - const next = (try p.parseFieldInit()) orelse break; - try init_list.append(next); + try init_list.append(elem_init); + + var trailing_comma = true; + var next = try p.parseExpr(); + while (next != 0) : (next = try p.parseExpr()) { + try init_list.append(next); + if (p.eatToken(.comma) == null) { + trailing_comma = false; + break; } - const node = try Node.StructInitializer.alloc(&p.arena.allocator, init_list.items.len); - node.* = .{ + } + _ = try p.expectToken(.r_brace); + const span = try p.listToSpan(init_list.items); + return p.addNode(.{ + .tag = if (trailing_comma) .array_init_comma else .array_init, + .main_token = lbrace, + .data = .{ .lhs = lhs, - .rtoken = try p.expectToken(.RBrace), - .list_len = init_list.items.len, - }; - std.mem.copy(*Node, node.list(), init_list.items); - return &node.base; - } - - if (try p.parseExpr()) |expr| { - try init_list.append(expr); - while (p.eatToken(.Comma)) |_| { - const next = (try p.parseExpr()) orelse break; - try init_list.append(next); - } - const node = try Node.ArrayInitializer.alloc(&p.arena.allocator, init_list.items.len); - node.* = .{ - .lhs = lhs, - .rtoken = try p.expectToken(.RBrace), - .list_len = init_list.items.len, - }; - std.mem.copy(*Node, node.list(), init_list.items); - return &node.base; - } - - const node = try p.arena.allocator.create(Node.StructInitializer); - node.* = .{ - .lhs = lhs, - .rtoken = try p.expectToken(.RBrace), - .list_len = 0, - }; - return &node.base; - } - - /// InitList - /// <- LBRACE FieldInit (COMMA FieldInit)* COMMA? RBRACE - /// / LBRACE Expr (COMMA Expr)* COMMA? RBRACE - /// / LBRACE RBRACE - fn parseAnonInitList(p: *Parser, dot: TokenIndex) !?*Node { - const lbrace = p.eatToken(.LBrace) orelse return null; - var init_list = std.ArrayList(*Node).init(p.gpa); - defer init_list.deinit(); - - if (try p.parseFieldInit()) |field_init| { - try init_list.append(field_init); - while (p.eatToken(.Comma)) |_| { - const next = (try p.parseFieldInit()) orelse break; - try init_list.append(next); - } - const node = try Node.StructInitializerDot.alloc(&p.arena.allocator, init_list.items.len); - node.* = .{ - .dot = dot, - .rtoken = try p.expectToken(.RBrace), - .list_len = init_list.items.len, - }; - std.mem.copy(*Node, node.list(), init_list.items); - return &node.base; - } - - if (try p.parseExpr()) |expr| { - try init_list.append(expr); - while (p.eatToken(.Comma)) |_| { - const next = (try p.parseExpr()) orelse break; - try init_list.append(next); - } - const node = try Node.ArrayInitializerDot.alloc(&p.arena.allocator, init_list.items.len); - node.* = .{ - .dot = dot, - .rtoken = try p.expectToken(.RBrace), - .list_len = init_list.items.len, - }; - std.mem.copy(*Node, node.list(), init_list.items); - return &node.base; - } - - const node = try p.arena.allocator.create(Node.StructInitializerDot); - node.* = .{ - .dot = dot, - .rtoken = try p.expectToken(.RBrace), - .list_len = 0, - }; - return &node.base; - } - - /// TypeExpr <- PrefixTypeOp* ErrorUnionExpr - fn parseTypeExpr(p: *Parser) Error!?*Node { - return p.parsePrefixOpExpr(parsePrefixTypeOp, parseErrorUnionExpr); + .rhs = try p.addExtra(Node.SubRange{ + .start = span.start, + .end = span.end, + }), + }, + }); } /// ErrorUnionExpr <- SuffixExpr (EXCLAMATIONMARK TypeExpr)? - fn parseErrorUnionExpr(p: *Parser) !?*Node { - const suffix_expr = (try p.parseSuffixExpr()) orelse return null; - - if (try SimpleBinOpParseFn(.Bang, .ErrorUnion)(p)) |node| { - const error_union = node.castTag(.ErrorUnion).?; - const type_expr = try p.expectNode(parseTypeExpr, .{ - .ExpectedTypeExpr = .{ .token = p.tok_i }, - }); - error_union.lhs = suffix_expr; - error_union.rhs = type_expr; - return node; - } - - return suffix_expr; + fn parseErrorUnionExpr(p: *Parser) !Node.Index { + const suffix_expr = try p.parseSuffixExpr(); + if (suffix_expr == 0) return null_node; + const bang = p.eatToken(.bang) orelse return suffix_expr; + return p.addNode(.{ + .tag = .error_union, + .main_token = bang, + .data = .{ + .lhs = suffix_expr, + .rhs = try p.expectTypeExpr(), + }, + }); } /// SuffixExpr /// <- KEYWORD_async PrimaryTypeExpr SuffixOp* FnCallArguments /// / PrimaryTypeExpr (SuffixOp / FnCallArguments)* - fn parseSuffixExpr(p: *Parser) !?*Node { - const maybe_async = p.eatToken(.Keyword_async); - if (maybe_async) |async_token| { - const token_fn = p.eatToken(.Keyword_fn); - if (token_fn != null) { - // TODO: remove this hack when async fn rewriting is - // HACK: If we see the keyword `fn`, then we assume that - // we are parsing an async fn proto, and not a call. - // We therefore put back all tokens consumed by the async - // prefix... - p.putBackToken(token_fn.?); - p.putBackToken(async_token); - return p.parsePrimaryTypeExpr(); - } - var res = try p.expectNode(parsePrimaryTypeExpr, .{ - .ExpectedPrimaryTypeExpr = .{ .token = p.tok_i }, - }); - - while (try p.parseSuffixOp(res)) |node| { - res = node; - } - - const params = (try p.parseFnCallArguments()) orelse { - try p.errors.append(p.gpa, .{ - .ExpectedParamList = .{ .token = p.tok_i }, - }); - // ignore this, continue parsing - return res; - }; - defer p.gpa.free(params.list); - const node = try Node.Call.alloc(&p.arena.allocator, params.list.len); - node.* = .{ - .lhs = res, - .params_len = params.list.len, - .async_token = async_token, - .rtoken = params.rparen, - }; - std.mem.copy(*Node, node.params(), params.list); - return &node.base; - } - if (try p.parsePrimaryTypeExpr()) |expr| { - var res = expr; + /// FnCallArguments <- LPAREN ExprList RPAREN + /// ExprList <- (Expr COMMA)* Expr? + fn parseSuffixExpr(p: *Parser) !Node.Index { + if (p.eatToken(.keyword_async)) |async_token| { + var res = try p.expectPrimaryTypeExpr(); while (true) { - if (try p.parseSuffixOp(res)) |node| { - res = node; - continue; - } - if (try p.parseFnCallArguments()) |params| { - defer p.gpa.free(params.list); - const call = try Node.Call.alloc(&p.arena.allocator, params.list.len); - call.* = .{ - .lhs = res, - .params_len = params.list.len, - .async_token = null, - .rtoken = params.rparen, - }; - std.mem.copy(*Node, call.params(), params.list); - res = &call.base; - continue; - } - break; + const node = try p.parseSuffixOp(res); + if (node == 0) break; + res = node; + } + const lparen = p.nextToken(); + if (p.token_tags[lparen] != .l_paren) { + p.tok_i -= 1; + try p.warn(.expected_param_list); + return res; + } + if (p.eatToken(.r_paren)) |_| { + return p.addNode(.{ + .tag = .async_call_one, + .main_token = lparen, + .data = .{ + .lhs = res, + .rhs = 0, + }, + }); + } + const param_one = try p.expectExpr(); + const comma_one = p.eatToken(.comma); + if (p.eatToken(.r_paren)) |_| { + return p.addNode(.{ + .tag = if (comma_one == null) .async_call_one else .async_call_one_comma, + .main_token = lparen, + .data = .{ + .lhs = res, + .rhs = param_one, + }, + }); + } + if (comma_one == null) { + try p.warnExpected(.comma); } - return res; - } - return null; + var param_list = std.ArrayList(Node.Index).init(p.gpa); + defer param_list.deinit(); + + try param_list.append(param_one); + + while (true) { + const next = try p.expectExpr(); + try param_list.append(next); + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_paren)) |_| { + const span = try p.listToSpan(param_list.items); + return p.addNode(.{ + .tag = .async_call_comma, + .main_token = lparen, + .data = .{ + .lhs = res, + .rhs = try p.addExtra(Node.SubRange{ + .start = span.start, + .end = span.end, + }), + }, + }); + } else { + continue; + } + }, + .r_paren => { + const span = try p.listToSpan(param_list.items); + return p.addNode(.{ + .tag = .async_call, + .main_token = lparen, + .data = .{ + .lhs = res, + .rhs = try p.addExtra(Node.SubRange{ + .start = span.start, + .end = span.end, + }), + }, + }); + }, + .colon, .r_brace, .r_bracket => { + p.tok_i -= 1; + return p.failExpected(.r_paren); + }, + else => { + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } + } + var res = try p.parsePrimaryTypeExpr(); + if (res == 0) return res; + + while (true) { + const suffix_op = try p.parseSuffixOp(res); + if (suffix_op != 0) { + res = suffix_op; + continue; + } + res = res: { + const lparen = p.eatToken(.l_paren) orelse return res; + if (p.eatToken(.r_paren)) |_| { + break :res try p.addNode(.{ + .tag = .call_one, + .main_token = lparen, + .data = .{ + .lhs = res, + .rhs = 0, + }, + }); + } + const param_one = try p.expectExpr(); + const comma_one = p.eatToken(.comma); + if (p.eatToken(.r_paren)) |_| { + break :res try p.addNode(.{ + .tag = if (comma_one == null) .call_one else .call_one_comma, + .main_token = lparen, + .data = .{ + .lhs = res, + .rhs = param_one, + }, + }); + } + if (comma_one == null) { + try p.warnExpected(.comma); + } + + var param_list = std.ArrayList(Node.Index).init(p.gpa); + defer param_list.deinit(); + + try param_list.append(param_one); + + while (true) { + const next = try p.expectExpr(); + try param_list.append(next); + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_paren)) |_| { + const span = try p.listToSpan(param_list.items); + break :res try p.addNode(.{ + .tag = .call_comma, + .main_token = lparen, + .data = .{ + .lhs = res, + .rhs = try p.addExtra(Node.SubRange{ + .start = span.start, + .end = span.end, + }), + }, + }); + } else { + continue; + } + }, + .r_paren => { + const span = try p.listToSpan(param_list.items); + break :res try p.addNode(.{ + .tag = .call, + .main_token = lparen, + .data = .{ + .lhs = res, + .rhs = try p.addExtra(Node.SubRange{ + .start = span.start, + .end = span.end, + }), + }, + }); + }, + .colon, .r_brace, .r_bracket => { + p.tok_i -= 1; + return p.failExpected(.r_paren); + }, + else => { + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } + }; + } } /// PrimaryTypeExpr @@ -1523,6 +2480,7 @@ const Parser = struct { /// / CHAR_LITERAL /// / ContainerDecl /// / DOT IDENTIFIER + /// / DOT InitList /// / ErrorSetDecl /// / FLOAT /// / FnProto @@ -1541,260 +2499,546 @@ const Parser = struct { /// / KEYWORD_unreachable /// / STRINGLITERAL /// / SwitchExpr - fn parsePrimaryTypeExpr(p: *Parser) !?*Node { - if (try p.parseBuiltinCall()) |node| return node; - if (p.eatToken(.CharLiteral)) |token| { - const node = try p.arena.allocator.create(Node.OneToken); - node.* = .{ - .base = .{ .tag = .CharLiteral }, - .token = token, - }; - return &node.base; - } - if (try p.parseContainerDecl()) |node| return node; - if (try p.parseAnonLiteral()) |node| return node; - if (try p.parseErrorSetDecl()) |node| return node; - if (try p.parseFloatLiteral()) |node| return node; - if (try p.parseFnProto(.as_type, .{})) |node| return node; - if (try p.parseGroupedExpr()) |node| return node; - if (try p.parseLabeledTypeExpr()) |node| return node; - if (try p.parseIdentifier()) |node| return node; - if (try p.parseIfTypeExpr()) |node| return node; - if (try p.parseIntegerLiteral()) |node| return node; - if (p.eatToken(.Keyword_comptime)) |token| { - const expr = (try p.parseTypeExpr()) orelse return null; - const node = try p.arena.allocator.create(Node.Comptime); - node.* = .{ - .doc_comments = null, - .comptime_token = token, - .expr = expr, - }; - return &node.base; - } - if (p.eatToken(.Keyword_error)) |token| { - const period = try p.expectTokenRecoverable(.Period); - const identifier = try p.expectNodeRecoverable(parseIdentifier, .{ - .ExpectedIdentifier = .{ .token = p.tok_i }, - }); - const global_error_set = try p.createLiteral(.ErrorType, token); - if (period == null or identifier == null) return global_error_set; - - const node = try p.arena.allocator.create(Node.SimpleInfixOp); - node.* = .{ - .base = Node{ .tag = .Period }, - .op_token = period.?, - .lhs = global_error_set, - .rhs = identifier.?, - }; - return &node.base; - } - if (p.eatToken(.Keyword_false)) |token| return p.createLiteral(.BoolLiteral, token); - if (p.eatToken(.Keyword_null)) |token| return p.createLiteral(.NullLiteral, token); - if (p.eatToken(.Keyword_anyframe)) |token| { - const node = try p.arena.allocator.create(Node.AnyFrameType); - node.* = .{ - .anyframe_token = token, - .result = null, - }; - return &node.base; - } - if (p.eatToken(.Keyword_true)) |token| return p.createLiteral(.BoolLiteral, token); - if (p.eatToken(.Keyword_undefined)) |token| return p.createLiteral(.UndefinedLiteral, token); - if (p.eatToken(.Keyword_unreachable)) |token| return p.createLiteral(.Unreachable, token); - if (try p.parseStringLiteral()) |node| return node; - if (try p.parseSwitchExpr()) |node| return node; - - return null; - } - /// ContainerDecl <- (KEYWORD_extern / KEYWORD_packed)? ContainerDeclAuto - fn parseContainerDecl(p: *Parser) !?*Node { - const layout_token = p.eatToken(.Keyword_extern) orelse - p.eatToken(.Keyword_packed); - - const node = (try p.parseContainerDeclAuto()) orelse { - if (layout_token) |token| - p.putBackToken(token); - return null; - }; - node.cast(Node.ContainerDecl).?.*.layout_token = layout_token; - return node; - } - + /// ContainerDeclAuto <- ContainerDeclType LBRACE ContainerMembers RBRACE + /// InitList + /// <- LBRACE FieldInit (COMMA FieldInit)* COMMA? RBRACE + /// / LBRACE Expr (COMMA Expr)* COMMA? RBRACE + /// / LBRACE RBRACE /// ErrorSetDecl <- KEYWORD_error LBRACE IdentifierList RBRACE - fn parseErrorSetDecl(p: *Parser) !?*Node { - const error_token = p.eatToken(.Keyword_error) orelse return null; - if (p.eatToken(.LBrace) == null) { - // Might parse as `KEYWORD_error DOT IDENTIFIER` later in PrimaryTypeExpr, so don't error - p.putBackToken(error_token); - return null; - } - const decls = try p.parseErrorTagList(); - defer p.gpa.free(decls); - const rbrace = try p.expectToken(.RBrace); - - const node = try Node.ErrorSetDecl.alloc(&p.arena.allocator, decls.len); - node.* = .{ - .error_token = error_token, - .decls_len = decls.len, - .rbrace_token = rbrace, - }; - std.mem.copy(*Node, node.decls(), decls); - return &node.base; - } - /// GroupedExpr <- LPAREN Expr RPAREN - fn parseGroupedExpr(p: *Parser) !?*Node { - const lparen = p.eatToken(.LParen) orelse return null; - const expr = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - const rparen = try p.expectToken(.RParen); - - const node = try p.arena.allocator.create(Node.GroupedExpression); - node.* = .{ - .lparen = lparen, - .expr = expr, - .rparen = rparen, - }; - return &node.base; - } - /// IfTypeExpr <- IfPrefix TypeExpr (KEYWORD_else Payload? TypeExpr)? - fn parseIfTypeExpr(p: *Parser) !?*Node { - return p.parseIf(parseTypeExpr); - } - /// LabeledTypeExpr /// <- BlockLabel Block /// / BlockLabel? LoopTypeExpr - fn parseLabeledTypeExpr(p: *Parser) !?*Node { - var colon: TokenIndex = undefined; - const label = p.parseBlockLabel(&colon); - - if (label) |label_token| { - if (try p.parseBlock(label_token)) |node| return node; - } - - if (try p.parseLoopTypeExpr()) |node| { - switch (node.tag) { - .For => node.cast(Node.For).?.label = label, - .While => node.cast(Node.While).?.label = label, - else => unreachable, - } - return node; - } - - if (label) |token| { - p.putBackToken(colon); - p.putBackToken(token); - } - return null; - } - /// LoopTypeExpr <- KEYWORD_inline? (ForTypeExpr / WhileTypeExpr) - fn parseLoopTypeExpr(p: *Parser) !?*Node { - const inline_token = p.eatToken(.Keyword_inline); + fn parsePrimaryTypeExpr(p: *Parser) !Node.Index { + switch (p.token_tags[p.tok_i]) { + .char_literal => return p.addNode(.{ + .tag = .char_literal, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + .integer_literal => return p.addNode(.{ + .tag = .integer_literal, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + .float_literal => return p.addNode(.{ + .tag = .float_literal, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + .keyword_false => return p.addNode(.{ + .tag = .false_literal, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + .keyword_true => return p.addNode(.{ + .tag = .true_literal, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + .keyword_null => return p.addNode(.{ + .tag = .null_literal, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + .keyword_undefined => return p.addNode(.{ + .tag = .undefined_literal, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + .keyword_unreachable => return p.addNode(.{ + .tag = .unreachable_literal, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + .keyword_anyframe => return p.addNode(.{ + .tag = .anyframe_literal, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + .string_literal => { + const main_token = p.nextToken(); + return p.addNode(.{ + .tag = .string_literal, + .main_token = main_token, + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }); + }, - if (try p.parseForTypeExpr()) |node| { - node.cast(Node.For).?.inline_token = inline_token; - return node; + .builtin => return p.parseBuiltinCall(), + .keyword_fn => return p.parseFnProto(), + .keyword_if => return p.parseIf(parseTypeExpr), + .keyword_switch => return p.expectSwitchExpr(), + + .keyword_extern, + .keyword_packed, + => { + p.tok_i += 1; + return p.parseContainerDeclAuto(); + }, + + .keyword_struct, + .keyword_opaque, + .keyword_enum, + .keyword_union, + => return p.parseContainerDeclAuto(), + + .keyword_comptime => return p.addNode(.{ + .tag = .@"comptime", + .main_token = p.nextToken(), + .data = .{ + .lhs = try p.expectTypeExpr(), + .rhs = undefined, + }, + }), + .multiline_string_literal_line => { + const first_line = p.nextToken(); + while (p.token_tags[p.tok_i] == .multiline_string_literal_line) { + p.tok_i += 1; + } + return p.addNode(.{ + .tag = .multiline_string_literal, + .main_token = first_line, + .data = .{ + .lhs = first_line, + .rhs = p.tok_i - 1, + }, + }); + }, + .identifier => switch (p.token_tags[p.tok_i + 1]) { + .colon => switch (p.token_tags[p.tok_i + 2]) { + .keyword_inline => { + p.tok_i += 3; + switch (p.token_tags[p.tok_i]) { + .keyword_for => return p.parseForTypeExpr(), + .keyword_while => return p.parseWhileTypeExpr(), + else => return p.fail(.expected_inlinable), + } + }, + .keyword_for => { + p.tok_i += 2; + return p.parseForTypeExpr(); + }, + .keyword_while => { + p.tok_i += 2; + return p.parseWhileTypeExpr(); + }, + .l_brace => { + p.tok_i += 2; + return p.parseBlock(); + }, + else => return p.addNode(.{ + .tag = .identifier, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + }, + else => return p.addNode(.{ + .tag = .identifier, + .main_token = p.nextToken(), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }), + }, + .keyword_inline => { + p.tok_i += 1; + switch (p.token_tags[p.tok_i]) { + .keyword_for => return p.parseForTypeExpr(), + .keyword_while => return p.parseWhileTypeExpr(), + else => return p.fail(.expected_inlinable), + } + }, + .keyword_for => return p.parseForTypeExpr(), + .keyword_while => return p.parseWhileTypeExpr(), + .period => switch (p.token_tags[p.tok_i + 1]) { + .identifier => return p.addNode(.{ + .tag = .enum_literal, + .data = .{ + .lhs = p.nextToken(), // dot + .rhs = undefined, + }, + .main_token = p.nextToken(), // identifier + }), + .l_brace => { + const lbrace = p.tok_i + 1; + p.tok_i = lbrace + 1; + + // If there are 0, 1, or 2 items, we can use ArrayInitDotTwo/StructInitDotTwo; + // otherwise we use the full ArrayInitDot/StructInitDot. + + if (p.eatToken(.r_brace)) |_| { + return p.addNode(.{ + .tag = .struct_init_dot_two, + .main_token = lbrace, + .data = .{ + .lhs = 0, + .rhs = 0, + }, + }); + } + const field_init_one = try p.parseFieldInit(); + if (field_init_one != 0) { + const comma_one = p.eatToken(.comma); + if (p.eatToken(.r_brace)) |_| { + return p.addNode(.{ + .tag = if (comma_one != null) .struct_init_dot_two_comma else .struct_init_dot_two, + .main_token = lbrace, + .data = .{ + .lhs = field_init_one, + .rhs = 0, + }, + }); + } + if (comma_one == null) { + try p.warnExpected(.comma); + } + const field_init_two = try p.expectFieldInit(); + const comma_two = p.eatToken(.comma); + if (p.eatToken(.r_brace)) |_| { + return p.addNode(.{ + .tag = if (comma_two != null) .struct_init_dot_two_comma else .struct_init_dot_two, + .main_token = lbrace, + .data = .{ + .lhs = field_init_one, + .rhs = field_init_two, + }, + }); + } + if (comma_two == null) { + try p.warnExpected(.comma); + } + var init_list = std.ArrayList(Node.Index).init(p.gpa); + defer init_list.deinit(); + + try init_list.appendSlice(&.{ field_init_one, field_init_two }); + + while (true) { + const next = try p.expectFieldInit(); + assert(next != 0); + try init_list.append(next); + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_brace)) |_| break; + continue; + }, + .r_brace => break, + .colon, .r_paren, .r_bracket => { + p.tok_i -= 1; + return p.failExpected(.r_brace); + }, + else => { + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } + const span = try p.listToSpan(init_list.items); + const trailing_comma = p.token_tags[p.tok_i - 2] == .comma; + return p.addNode(.{ + .tag = if (trailing_comma) .struct_init_dot_comma else .struct_init_dot, + .main_token = lbrace, + .data = .{ + .lhs = span.start, + .rhs = span.end, + }, + }); + } + + const elem_init_one = try p.expectExpr(); + const comma_one = p.eatToken(.comma); + if (p.eatToken(.r_brace)) |_| { + return p.addNode(.{ + .tag = if (comma_one != null) .array_init_dot_two_comma else .array_init_dot_two, + .main_token = lbrace, + .data = .{ + .lhs = elem_init_one, + .rhs = 0, + }, + }); + } + if (comma_one == null) { + try p.warnExpected(.comma); + } + const elem_init_two = try p.expectExpr(); + const comma_two = p.eatToken(.comma); + if (p.eatToken(.r_brace)) |_| { + return p.addNode(.{ + .tag = if (comma_two != null) .array_init_dot_two_comma else .array_init_dot_two, + .main_token = lbrace, + .data = .{ + .lhs = elem_init_one, + .rhs = elem_init_two, + }, + }); + } + if (comma_two == null) { + try p.warnExpected(.comma); + } + var init_list = std.ArrayList(Node.Index).init(p.gpa); + defer init_list.deinit(); + + try init_list.appendSlice(&.{ elem_init_one, elem_init_two }); + + while (true) { + const next = try p.expectExpr(); + if (next == 0) break; + try init_list.append(next); + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_brace)) |_| break; + continue; + }, + .r_brace => break, + .colon, .r_paren, .r_bracket => { + p.tok_i -= 1; + return p.failExpected(.r_brace); + }, + else => { + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } + const span = try p.listToSpan(init_list.items); + return p.addNode(.{ + .tag = if (p.token_tags[p.tok_i - 2] == .comma) .array_init_dot_comma else .array_init_dot, + .main_token = lbrace, + .data = .{ + .lhs = span.start, + .rhs = span.end, + }, + }); + }, + else => return null_node, + }, + .keyword_error => switch (p.token_tags[p.tok_i + 1]) { + .l_brace => { + const error_token = p.tok_i; + p.tok_i += 2; + + if (p.eatToken(.r_brace)) |rbrace| { + return p.addNode(.{ + .tag = .error_set_decl, + .main_token = error_token, + .data = .{ + .lhs = undefined, + .rhs = rbrace, + }, + }); + } + + while (true) { + const doc_comment = try p.eatDocComments(); + const identifier = try p.expectToken(.identifier); + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_brace)) |_| break; + continue; + }, + .r_brace => break, + .colon, .r_paren, .r_bracket => { + p.tok_i -= 1; + return p.failExpected(.r_brace); + }, + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } + return p.addNode(.{ + .tag = .error_set_decl, + .main_token = error_token, + .data = .{ + .lhs = undefined, + .rhs = p.tok_i - 1, // rbrace + }, + }); + }, + else => { + const main_token = p.nextToken(); + const period = p.eatToken(.period); + if (period == null) try p.warnExpected(.period); + const identifier = p.eatToken(.identifier); + if (identifier == null) try p.warnExpected(.identifier); + return p.addNode(.{ + .tag = .error_value, + .main_token = main_token, + .data = .{ + .lhs = period orelse 0, + .rhs = identifier orelse 0, + }, + }); + }, + }, + .l_paren => return p.addNode(.{ + .tag = .grouped_expression, + .main_token = p.nextToken(), + .data = .{ + .lhs = try p.expectExpr(), + .rhs = try p.expectToken(.r_paren), + }, + }), + else => return null_node, } - - if (try p.parseWhileTypeExpr()) |node| { - node.cast(Node.While).?.inline_token = inline_token; - return node; - } - - if (inline_token == null) return null; - - // If we've seen "inline", there should have been a "for" or "while" - try p.errors.append(p.gpa, .{ - .ExpectedInlinable = .{ .token = p.tok_i }, - }); - return error.ParseError; } + fn expectPrimaryTypeExpr(p: *Parser) !Node.Index { + const node = try p.parsePrimaryTypeExpr(); + if (node == 0) { + return p.fail(.expected_primary_type_expr); + } + return node; + } + + /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload /// ForTypeExpr <- ForPrefix TypeExpr (KEYWORD_else TypeExpr)? - fn parseForTypeExpr(p: *Parser) !?*Node { - const node = (try p.parseForPrefix()) orelse return null; - const for_prefix = node.cast(Node.For).?; + fn parseForTypeExpr(p: *Parser) !Node.Index { + const for_token = p.eatToken(.keyword_for) orelse return null_node; + _ = try p.expectToken(.l_paren); + const array_expr = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + const found_payload = try p.parsePtrIndexPayload(); + if (found_payload == 0) try p.warn(.expected_loop_payload); - const type_expr = try p.expectNode(parseTypeExpr, .{ - .ExpectedTypeExpr = .{ .token = p.tok_i }, - }); - for_prefix.body = type_expr; - - if (p.eatToken(.Keyword_else)) |else_token| { - const else_expr = try p.expectNode(parseTypeExpr, .{ - .ExpectedTypeExpr = .{ .token = p.tok_i }, + const then_expr = try p.expectExpr(); + const else_token = p.eatToken(.keyword_else) orelse { + return p.addNode(.{ + .tag = .for_simple, + .main_token = for_token, + .data = .{ + .lhs = array_expr, + .rhs = then_expr, + }, }); - - const else_node = try p.arena.allocator.create(Node.Else); - else_node.* = .{ - .else_token = else_token, - .payload = null, - .body = else_expr, - }; - - for_prefix.@"else" = else_node; - } - - return node; + }; + const else_expr = try p.expectTypeExpr(); + return p.addNode(.{ + .tag = .@"for", + .main_token = for_token, + .data = .{ + .lhs = array_expr, + .rhs = try p.addExtra(Node.If{ + .then_expr = then_expr, + .else_expr = else_expr, + }), + }, + }); } + /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr? /// WhileTypeExpr <- WhilePrefix TypeExpr (KEYWORD_else Payload? TypeExpr)? - fn parseWhileTypeExpr(p: *Parser) !?*Node { - const node = (try p.parseWhilePrefix()) orelse return null; - const while_prefix = node.cast(Node.While).?; + fn parseWhileTypeExpr(p: *Parser) !Node.Index { + const while_token = p.eatToken(.keyword_while) orelse return null_node; + _ = try p.expectToken(.l_paren); + const condition = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + const then_payload = try p.parsePtrPayload(); + const cont_expr = try p.parseWhileContinueExpr(); - const type_expr = try p.expectNode(parseTypeExpr, .{ - .ExpectedTypeExpr = .{ .token = p.tok_i }, + const then_expr = try p.expectTypeExpr(); + const else_token = p.eatToken(.keyword_else) orelse { + if (cont_expr == 0) { + return p.addNode(.{ + .tag = .while_simple, + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = then_expr, + }, + }); + } else { + return p.addNode(.{ + .tag = .while_cont, + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = try p.addExtra(Node.WhileCont{ + .cont_expr = cont_expr, + .then_expr = then_expr, + }), + }, + }); + } + }; + const else_payload = try p.parsePayload(); + const else_expr = try p.expectTypeExpr(); + return p.addNode(.{ + .tag = .@"while", + .main_token = while_token, + .data = .{ + .lhs = condition, + .rhs = try p.addExtra(Node.While{ + .cont_expr = cont_expr, + .then_expr = then_expr, + .else_expr = else_expr, + }), + }, }); - while_prefix.body = type_expr; - - if (p.eatToken(.Keyword_else)) |else_token| { - const payload = try p.parsePayload(); - - const else_expr = try p.expectNode(parseTypeExpr, .{ - .ExpectedTypeExpr = .{ .token = p.tok_i }, - }); - - const else_node = try p.arena.allocator.create(Node.Else); - else_node.* = .{ - .else_token = else_token, - .payload = null, - .body = else_expr, - }; - - while_prefix.@"else" = else_node; - } - - return node; } /// SwitchExpr <- KEYWORD_switch LPAREN Expr RPAREN LBRACE SwitchProngList RBRACE - fn parseSwitchExpr(p: *Parser) !?*Node { - const switch_token = p.eatToken(.Keyword_switch) orelse return null; - _ = try p.expectToken(.LParen); - const expr_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); - _ = try p.expectToken(.LBrace); + fn expectSwitchExpr(p: *Parser) !Node.Index { + const switch_token = p.assertToken(.keyword_switch); + _ = try p.expectToken(.l_paren); + const expr_node = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + _ = try p.expectToken(.l_brace); const cases = try p.parseSwitchProngList(); - defer p.gpa.free(cases); - const rbrace = try p.expectToken(.RBrace); + const trailing_comma = p.token_tags[p.tok_i - 1] == .comma; + _ = try p.expectToken(.r_brace); - const node = try Node.Switch.alloc(&p.arena.allocator, cases.len); - node.* = .{ - .switch_token = switch_token, - .expr = expr_node, - .cases_len = cases.len, - .rbrace = rbrace, - }; - std.mem.copy(*Node, node.cases(), cases); - return &node.base; + return p.addNode(.{ + .tag = if (trailing_comma) .switch_comma else .@"switch", + .main_token = switch_token, + .data = .{ + .lhs = expr_node, + .rhs = try p.addExtra(Node.SubRange{ + .start = cases.start, + .end = cases.end, + }), + }, + }); } /// AsmExpr <- KEYWORD_asm KEYWORD_volatile? LPAREN Expr AsmOutput? RPAREN @@ -1802,854 +3046,395 @@ const Parser = struct { /// AsmInput <- COLON AsmInputList AsmClobbers? /// AsmClobbers <- COLON StringList /// StringList <- (STRINGLITERAL COMMA)* STRINGLITERAL? - fn parseAsmExpr(p: *Parser) !?*Node { - const asm_token = p.eatToken(.Keyword_asm) orelse return null; - const volatile_token = p.eatToken(.Keyword_volatile); - _ = try p.expectToken(.LParen); - const template = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); + /// AsmOutputList <- (AsmOutputItem COMMA)* AsmOutputItem? + /// AsmInputList <- (AsmInputItem COMMA)* AsmInputItem? + fn expectAsmExpr(p: *Parser) !Node.Index { + const asm_token = p.assertToken(.keyword_asm); + _ = p.eatToken(.keyword_volatile); + _ = try p.expectToken(.l_paren); + const template = try p.expectExpr(); - var arena_outputs: []Node.Asm.Output = &[0]Node.Asm.Output{}; - var arena_inputs: []Node.Asm.Input = &[0]Node.Asm.Input{}; - var arena_clobbers: []*Node = &[0]*Node{}; + if (p.eatToken(.r_paren)) |rparen| { + return p.addNode(.{ + .tag = .asm_simple, + .main_token = asm_token, + .data = .{ + .lhs = template, + .rhs = rparen, + }, + }); + } - if (p.eatToken(.Colon) != null) { - const outputs = try p.parseAsmOutputList(); - defer p.gpa.free(outputs); - arena_outputs = try p.arena.allocator.dupe(Node.Asm.Output, outputs); + _ = try p.expectToken(.colon); - if (p.eatToken(.Colon) != null) { - const inputs = try p.parseAsmInputList(); - defer p.gpa.free(inputs); - arena_inputs = try p.arena.allocator.dupe(Node.Asm.Input, inputs); + var list = std.ArrayList(Node.Index).init(p.gpa); + defer list.deinit(); - if (p.eatToken(.Colon) != null) { - const clobbers = try ListParseFn(*Node, parseStringLiteral)(p); - defer p.gpa.free(clobbers); - arena_clobbers = try p.arena.allocator.dupe(*Node, clobbers); + while (true) { + const output_item = try p.parseAsmOutputItem(); + if (output_item == 0) break; + try list.append(output_item); + switch (p.token_tags[p.tok_i]) { + .comma => p.tok_i += 1, + .colon, .r_paren, .r_brace, .r_bracket => break, // All possible delimiters. + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + try p.warnExpected(.comma); + }, + } + } + if (p.eatToken(.colon)) |_| { + while (true) { + const input_item = try p.parseAsmInputItem(); + if (input_item == 0) break; + try list.append(input_item); + switch (p.token_tags[p.tok_i]) { + .comma => p.tok_i += 1, + .colon, .r_paren, .r_brace, .r_bracket => break, // All possible delimiters. + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + try p.warnExpected(.comma); + }, + } + } + if (p.eatToken(.colon)) |_| { + while (p.eatToken(.string_literal)) |_| { + switch (p.token_tags[p.tok_i]) { + .comma => p.tok_i += 1, + .colon, .r_paren, .r_brace, .r_bracket => break, + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + try p.warnExpected(.comma); + }, + } } } } - - const node = try p.arena.allocator.create(Node.Asm); - node.* = .{ - .asm_token = asm_token, - .volatile_token = volatile_token, - .template = template, - .outputs = arena_outputs, - .inputs = arena_inputs, - .clobbers = arena_clobbers, - .rparen = try p.expectToken(.RParen), - }; - - return &node.base; - } - - /// DOT IDENTIFIER - fn parseAnonLiteral(p: *Parser) !?*Node { - const dot = p.eatToken(.Period) orelse return null; - - // anon enum literal - if (p.eatToken(.Identifier)) |name| { - const node = try p.arena.allocator.create(Node.EnumLiteral); - node.* = .{ - .dot = dot, - .name = name, - }; - return &node.base; - } - - if (try p.parseAnonInitList(dot)) |node| { - return node; - } - - p.putBackToken(dot); - return null; + const rparen = try p.expectToken(.r_paren); + const span = try p.listToSpan(list.items); + return p.addNode(.{ + .tag = .@"asm", + .main_token = asm_token, + .data = .{ + .lhs = template, + .rhs = try p.addExtra(Node.Asm{ + .items_start = span.start, + .items_end = span.end, + .rparen = rparen, + }), + }, + }); } /// AsmOutputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN (MINUSRARROW TypeExpr / IDENTIFIER) RPAREN - fn parseAsmOutputItem(p: *Parser) !?Node.Asm.Output { - const lbracket = p.eatToken(.LBracket) orelse return null; - const name = try p.expectNode(parseIdentifier, .{ - .ExpectedIdentifier = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RBracket); - - const constraint = try p.expectNode(parseStringLiteral, .{ - .ExpectedStringLiteral = .{ .token = p.tok_i }, - }); - - _ = try p.expectToken(.LParen); - const kind: Node.Asm.Output.Kind = blk: { - if (p.eatToken(.Arrow) != null) { - const return_ident = try p.expectNode(parseTypeExpr, .{ - .ExpectedTypeExpr = .{ .token = p.tok_i }, - }); - break :blk .{ .Return = return_ident }; + fn parseAsmOutputItem(p: *Parser) !Node.Index { + _ = p.eatToken(.l_bracket) orelse return null_node; + const identifier = try p.expectToken(.identifier); + _ = try p.expectToken(.r_bracket); + _ = try p.expectToken(.string_literal); + _ = try p.expectToken(.l_paren); + const type_expr: Node.Index = blk: { + if (p.eatToken(.arrow)) |_| { + break :blk try p.expectTypeExpr(); + } else { + _ = try p.expectToken(.identifier); + break :blk null_node; } - const variable = try p.expectNode(parseIdentifier, .{ - .ExpectedIdentifier = .{ .token = p.tok_i }, - }); - break :blk .{ .Variable = variable.castTag(.Identifier).? }; - }; - const rparen = try p.expectToken(.RParen); - - return Node.Asm.Output{ - .lbracket = lbracket, - .symbolic_name = name, - .constraint = constraint, - .kind = kind, - .rparen = rparen, }; + const rparen = try p.expectToken(.r_paren); + return p.addNode(.{ + .tag = .asm_output, + .main_token = identifier, + .data = .{ + .lhs = type_expr, + .rhs = rparen, + }, + }); } /// AsmInputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN Expr RPAREN - fn parseAsmInputItem(p: *Parser) !?Node.Asm.Input { - const lbracket = p.eatToken(.LBracket) orelse return null; - const name = try p.expectNode(parseIdentifier, .{ - .ExpectedIdentifier = .{ .token = p.tok_i }, + fn parseAsmInputItem(p: *Parser) !Node.Index { + _ = p.eatToken(.l_bracket) orelse return null_node; + const identifier = try p.expectToken(.identifier); + _ = try p.expectToken(.r_bracket); + _ = try p.expectToken(.string_literal); + _ = try p.expectToken(.l_paren); + const expr = try p.expectExpr(); + const rparen = try p.expectToken(.r_paren); + return p.addNode(.{ + .tag = .asm_input, + .main_token = identifier, + .data = .{ + .lhs = expr, + .rhs = rparen, + }, }); - _ = try p.expectToken(.RBracket); - - const constraint = try p.expectNode(parseStringLiteral, .{ - .ExpectedStringLiteral = .{ .token = p.tok_i }, - }); - - _ = try p.expectToken(.LParen); - const expr = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - const rparen = try p.expectToken(.RParen); - - return Node.Asm.Input{ - .lbracket = lbracket, - .symbolic_name = name, - .constraint = constraint, - .expr = expr, - .rparen = rparen, - }; } /// BreakLabel <- COLON IDENTIFIER - fn parseBreakLabel(p: *Parser) !?TokenIndex { - _ = p.eatToken(.Colon) orelse return null; - const ident = try p.expectToken(.Identifier); - return ident; + fn parseBreakLabel(p: *Parser) !TokenIndex { + _ = p.eatToken(.colon) orelse return @as(TokenIndex, 0); + return p.expectToken(.identifier); } /// BlockLabel <- IDENTIFIER COLON - fn parseBlockLabel(p: *Parser, colon_token: *TokenIndex) ?TokenIndex { - const identifier = p.eatToken(.Identifier) orelse return null; - if (p.eatToken(.Colon)) |colon| { - colon_token.* = colon; + fn parseBlockLabel(p: *Parser) TokenIndex { + if (p.token_tags[p.tok_i] == .identifier and + p.token_tags[p.tok_i + 1] == .colon) + { + const identifier = p.tok_i; + p.tok_i += 2; return identifier; } - p.putBackToken(identifier); - return null; + return 0; } /// FieldInit <- DOT IDENTIFIER EQUAL Expr - fn parseFieldInit(p: *Parser) !?*Node { - const period_token = p.eatToken(.Period) orelse return null; - const name_token = p.eatToken(.Identifier) orelse { - // Because of anon literals `.{` is also valid. - p.putBackToken(period_token); - return null; - }; - const eq_token = p.eatToken(.Equal) orelse { - // `.Name` may also be an enum literal, which is a later rule. - p.putBackToken(name_token); - p.putBackToken(period_token); - return null; - }; - const expr_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); + fn parseFieldInit(p: *Parser) !Node.Index { + if (p.token_tags[p.tok_i + 0] == .period and + p.token_tags[p.tok_i + 1] == .identifier and + p.token_tags[p.tok_i + 2] == .equal) + { + p.tok_i += 3; + return p.expectExpr(); + } else { + return null_node; + } + } - const node = try p.arena.allocator.create(Node.FieldInitializer); - node.* = .{ - .period_token = period_token, - .name_token = name_token, - .expr = expr_node, - }; - return &node.base; + fn expectFieldInit(p: *Parser) !Node.Index { + _ = try p.expectToken(.period); + _ = try p.expectToken(.identifier); + _ = try p.expectToken(.equal); + return p.expectExpr(); } /// WhileContinueExpr <- COLON LPAREN AssignExpr RPAREN - fn parseWhileContinueExpr(p: *Parser) !?*Node { - _ = p.eatToken(.Colon) orelse return null; - _ = try p.expectToken(.LParen); - const node = try p.expectNode(parseAssignExpr, .{ - .ExpectedExprOrAssignment = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); + fn parseWhileContinueExpr(p: *Parser) !Node.Index { + _ = p.eatToken(.colon) orelse return null_node; + _ = try p.expectToken(.l_paren); + const node = try p.parseAssignExpr(); + if (node == 0) return p.fail(.expected_expr_or_assignment); + _ = try p.expectToken(.r_paren); return node; } /// LinkSection <- KEYWORD_linksection LPAREN Expr RPAREN - fn parseLinkSection(p: *Parser) !?*Node { - _ = p.eatToken(.Keyword_linksection) orelse return null; - _ = try p.expectToken(.LParen); - const expr_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); + fn parseLinkSection(p: *Parser) !Node.Index { + _ = p.eatToken(.keyword_linksection) orelse return null_node; + _ = try p.expectToken(.l_paren); + const expr_node = try p.expectExpr(); + _ = try p.expectToken(.r_paren); return expr_node; } /// CallConv <- KEYWORD_callconv LPAREN Expr RPAREN - fn parseCallconv(p: *Parser) !?*Node { - _ = p.eatToken(.Keyword_callconv) orelse return null; - _ = try p.expectToken(.LParen); - const expr_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); + fn parseCallconv(p: *Parser) !Node.Index { + _ = p.eatToken(.keyword_callconv) orelse return null_node; + _ = try p.expectToken(.l_paren); + const expr_node = try p.expectExpr(); + _ = try p.expectToken(.r_paren); return expr_node; } - /// ParamDecl <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType - fn parseParamDecl(p: *Parser) !?Node.FnProto.ParamDecl { - const doc_comments = try p.parseDocComment(); - const noalias_token = p.eatToken(.Keyword_noalias); - const comptime_token = if (noalias_token == null) p.eatToken(.Keyword_comptime) else null; - const name_token = blk: { - const identifier = p.eatToken(.Identifier) orelse break :blk null; - if (p.eatToken(.Colon) != null) break :blk identifier; - p.putBackToken(identifier); // ParamType may also be an identifier - break :blk null; - }; - const param_type = (try p.parseParamType()) orelse { - // Only return cleanly if no keyword, identifier, or doc comment was found - if (noalias_token == null and - comptime_token == null and - name_token == null and - doc_comments == null) - { - return null; - } - try p.errors.append(p.gpa, .{ - .ExpectedParamType = .{ .token = p.tok_i }, - }); - return error.ParseError; - }; - - return Node.FnProto.ParamDecl{ - .doc_comments = doc_comments, - .comptime_token = comptime_token, - .noalias_token = noalias_token, - .name_token = name_token, - .param_type = param_type, - }; - } - + /// ParamDecl + /// <- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType + /// / DOT3 /// ParamType /// <- Keyword_anytype - /// / DOT3 /// / TypeExpr - fn parseParamType(p: *Parser) !?Node.FnProto.ParamDecl.ParamType { - // TODO cast from tuple to error union is broken - const P = Node.FnProto.ParamDecl.ParamType; - if (try p.parseAnyType()) |node| return P{ .any_type = node }; - if (try p.parseTypeExpr()) |node| return P{ .type_expr = node }; - return null; - } - - /// IfPrefix <- KEYWORD_if LPAREN Expr RPAREN PtrPayload? - fn parseIfPrefix(p: *Parser) !?*Node { - const if_token = p.eatToken(.Keyword_if) orelse return null; - _ = try p.expectToken(.LParen); - const condition = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); - const payload = try p.parsePtrPayload(); - - const node = try p.arena.allocator.create(Node.If); - node.* = .{ - .if_token = if_token, - .condition = condition, - .payload = payload, - .body = undefined, // set by caller - .@"else" = null, - }; - return &node.base; - } - - /// WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr? - fn parseWhilePrefix(p: *Parser) !?*Node { - const while_token = p.eatToken(.Keyword_while) orelse return null; - - _ = try p.expectToken(.LParen); - const condition = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); - - const payload = try p.parsePtrPayload(); - const continue_expr = try p.parseWhileContinueExpr(); - - const node = try p.arena.allocator.create(Node.While); - node.* = .{ - .label = null, - .inline_token = null, - .while_token = while_token, - .condition = condition, - .payload = payload, - .continue_expr = continue_expr, - .body = undefined, // set by caller - .@"else" = null, - }; - return &node.base; - } - - /// ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload - fn parseForPrefix(p: *Parser) !?*Node { - const for_token = p.eatToken(.Keyword_for) orelse return null; - - _ = try p.expectToken(.LParen); - const array_expr = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); - - const payload = try p.expectNode(parsePtrIndexPayload, .{ - .ExpectedPayload = .{ .token = p.tok_i }, - }); - - const node = try p.arena.allocator.create(Node.For); - node.* = .{ - .label = null, - .inline_token = null, - .for_token = for_token, - .array_expr = array_expr, - .payload = payload, - .body = undefined, // set by caller - .@"else" = null, - }; - return &node.base; + /// This function can return null nodes and then still return nodes afterwards, + /// such as in the case of anytype and `...`. Caller must look for rparen to find + /// out when there are no more param decls left. + fn expectParamDecl(p: *Parser) !Node.Index { + _ = try p.eatDocComments(); + switch (p.token_tags[p.tok_i]) { + .keyword_noalias, .keyword_comptime => p.tok_i += 1, + .ellipsis3 => { + p.tok_i += 1; + return null_node; + }, + else => {}, + } + if (p.token_tags[p.tok_i] == .identifier and + p.token_tags[p.tok_i + 1] == .colon) + { + p.tok_i += 2; + } + switch (p.token_tags[p.tok_i]) { + .keyword_anytype => { + p.tok_i += 1; + return null_node; + }, + else => return p.expectTypeExpr(), + } } /// Payload <- PIPE IDENTIFIER PIPE - fn parsePayload(p: *Parser) !?*Node { - const lpipe = p.eatToken(.Pipe) orelse return null; - const identifier = try p.expectNode(parseIdentifier, .{ - .ExpectedIdentifier = .{ .token = p.tok_i }, - }); - const rpipe = try p.expectToken(.Pipe); - - const node = try p.arena.allocator.create(Node.Payload); - node.* = .{ - .lpipe = lpipe, - .error_symbol = identifier, - .rpipe = rpipe, - }; - return &node.base; + fn parsePayload(p: *Parser) !TokenIndex { + _ = p.eatToken(.pipe) orelse return @as(TokenIndex, 0); + const identifier = try p.expectToken(.identifier); + _ = try p.expectToken(.pipe); + return identifier; } /// PtrPayload <- PIPE ASTERISK? IDENTIFIER PIPE - fn parsePtrPayload(p: *Parser) !?*Node { - const lpipe = p.eatToken(.Pipe) orelse return null; - const asterisk = p.eatToken(.Asterisk); - const identifier = try p.expectNode(parseIdentifier, .{ - .ExpectedIdentifier = .{ .token = p.tok_i }, - }); - const rpipe = try p.expectToken(.Pipe); - - const node = try p.arena.allocator.create(Node.PointerPayload); - node.* = .{ - .lpipe = lpipe, - .ptr_token = asterisk, - .value_symbol = identifier, - .rpipe = rpipe, - }; - return &node.base; + fn parsePtrPayload(p: *Parser) !TokenIndex { + _ = p.eatToken(.pipe) orelse return @as(TokenIndex, 0); + _ = p.eatToken(.asterisk); + const identifier = try p.expectToken(.identifier); + _ = try p.expectToken(.pipe); + return identifier; } /// PtrIndexPayload <- PIPE ASTERISK? IDENTIFIER (COMMA IDENTIFIER)? PIPE - fn parsePtrIndexPayload(p: *Parser) !?*Node { - const lpipe = p.eatToken(.Pipe) orelse return null; - const asterisk = p.eatToken(.Asterisk); - const identifier = try p.expectNode(parseIdentifier, .{ - .ExpectedIdentifier = .{ .token = p.tok_i }, - }); - - const index = if (p.eatToken(.Comma) == null) - null - else - try p.expectNode(parseIdentifier, .{ - .ExpectedIdentifier = .{ .token = p.tok_i }, - }); - - const rpipe = try p.expectToken(.Pipe); - - const node = try p.arena.allocator.create(Node.PointerIndexPayload); - node.* = .{ - .lpipe = lpipe, - .ptr_token = asterisk, - .value_symbol = identifier, - .index_symbol = index, - .rpipe = rpipe, - }; - return &node.base; + /// Returns the first identifier token, if any. + fn parsePtrIndexPayload(p: *Parser) !TokenIndex { + _ = p.eatToken(.pipe) orelse return @as(TokenIndex, 0); + _ = p.eatToken(.asterisk); + const identifier = try p.expectToken(.identifier); + if (p.eatToken(.comma) != null) { + _ = try p.expectToken(.identifier); + } + _ = try p.expectToken(.pipe); + return identifier; } /// SwitchProng <- SwitchCase EQUALRARROW PtrPayload? AssignExpr - fn parseSwitchProng(p: *Parser) !?*Node { - const node = (try p.parseSwitchCase()) orelse return null; - const arrow = try p.expectToken(.EqualAngleBracketRight); - const payload = try p.parsePtrPayload(); - const expr = try p.expectNode(parseAssignExpr, .{ - .ExpectedExprOrAssignment = .{ .token = p.tok_i }, - }); - - const switch_case = node.cast(Node.SwitchCase).?; - switch_case.arrow_token = arrow; - switch_case.payload = payload; - switch_case.expr = expr; - - return node; - } - /// SwitchCase /// <- SwitchItem (COMMA SwitchItem)* COMMA? /// / KEYWORD_else - fn parseSwitchCase(p: *Parser) !?*Node { - var list = std.ArrayList(*Node).init(p.gpa); + fn parseSwitchProng(p: *Parser) !Node.Index { + if (p.eatToken(.keyword_else)) |_| { + const arrow_token = try p.expectToken(.equal_angle_bracket_right); + _ = try p.parsePtrPayload(); + return p.addNode(.{ + .tag = .switch_case_one, + .main_token = arrow_token, + .data = .{ + .lhs = 0, + .rhs = try p.expectAssignExpr(), + }, + }); + } + const first_item = try p.parseSwitchItem(); + if (first_item == 0) return null_node; + + if (p.eatToken(.equal_angle_bracket_right)) |arrow_token| { + _ = try p.parsePtrPayload(); + return p.addNode(.{ + .tag = .switch_case_one, + .main_token = arrow_token, + .data = .{ + .lhs = first_item, + .rhs = try p.expectAssignExpr(), + }, + }); + } + + var list = std.ArrayList(Node.Index).init(p.gpa); defer list.deinit(); - if (try p.parseSwitchItem()) |first_item| { - try list.append(first_item); - while (p.eatToken(.Comma) != null) { - const next_item = (try p.parseSwitchItem()) orelse break; - try list.append(next_item); - } - } else if (p.eatToken(.Keyword_else)) |else_token| { - const else_node = try p.arena.allocator.create(Node.SwitchElse); - else_node.* = .{ - .token = else_token, - }; - try list.append(&else_node.base); - } else return null; - - const node = try Node.SwitchCase.alloc(&p.arena.allocator, list.items.len); - node.* = .{ - .items_len = list.items.len, - .arrow_token = undefined, // set by caller - .payload = null, - .expr = undefined, // set by caller - }; - std.mem.copy(*Node, node.items(), list.items); - return &node.base; + try list.append(first_item); + while (p.eatToken(.comma)) |_| { + const next_item = try p.parseSwitchItem(); + if (next_item == 0) break; + try list.append(next_item); + } + const span = try p.listToSpan(list.items); + const arrow_token = try p.expectToken(.equal_angle_bracket_right); + _ = try p.parsePtrPayload(); + return p.addNode(.{ + .tag = .switch_case, + .main_token = arrow_token, + .data = .{ + .lhs = try p.addExtra(Node.SubRange{ + .start = span.start, + .end = span.end, + }), + .rhs = try p.expectAssignExpr(), + }, + }); } /// SwitchItem <- Expr (DOT3 Expr)? - fn parseSwitchItem(p: *Parser) !?*Node { - const expr = (try p.parseExpr()) orelse return null; - if (p.eatToken(.Ellipsis3)) |token| { - const range_end = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); + fn parseSwitchItem(p: *Parser) !Node.Index { + const expr = try p.parseExpr(); + if (expr == 0) return null_node; - const node = try p.arena.allocator.create(Node.SimpleInfixOp); - node.* = .{ - .base = Node{ .tag = .Range }, - .op_token = token, - .lhs = expr, - .rhs = range_end, - }; - return &node.base; + if (p.eatToken(.ellipsis3)) |token| { + return p.addNode(.{ + .tag = .switch_range, + .main_token = token, + .data = .{ + .lhs = expr, + .rhs = try p.expectExpr(), + }, + }); } return expr; } - /// AssignOp - /// <- ASTERISKEQUAL - /// / SLASHEQUAL - /// / PERCENTEQUAL - /// / PLUSEQUAL - /// / MINUSEQUAL - /// / LARROW2EQUAL - /// / RARROW2EQUAL - /// / AMPERSANDEQUAL - /// / CARETEQUAL - /// / PIPEEQUAL - /// / ASTERISKPERCENTEQUAL - /// / PLUSPERCENTEQUAL - /// / MINUSPERCENTEQUAL - /// / EQUAL - fn parseAssignOp(p: *Parser) !?*Node { - const token = p.nextToken(); - const op: Node.Tag = switch (p.token_ids[token]) { - .AsteriskEqual => .AssignMul, - .SlashEqual => .AssignDiv, - .PercentEqual => .AssignMod, - .PlusEqual => .AssignAdd, - .MinusEqual => .AssignSub, - .AngleBracketAngleBracketLeftEqual => .AssignBitShiftLeft, - .AngleBracketAngleBracketRightEqual => .AssignBitShiftRight, - .AmpersandEqual => .AssignBitAnd, - .CaretEqual => .AssignBitXor, - .PipeEqual => .AssignBitOr, - .AsteriskPercentEqual => .AssignMulWrap, - .PlusPercentEqual => .AssignAddWrap, - .MinusPercentEqual => .AssignSubWrap, - .Equal => .Assign, - else => { - p.putBackToken(token); - return null; - }, + const PtrModifiers = struct { + align_node: Node.Index, + bit_range_start: Node.Index, + bit_range_end: Node.Index, + }; + + fn parsePtrModifiers(p: *Parser) !PtrModifiers { + var result: PtrModifiers = .{ + .align_node = 0, + .bit_range_start = 0, + .bit_range_end = 0, }; + var saw_const = false; + var saw_volatile = false; + var saw_allowzero = false; + while (true) { + switch (p.token_tags[p.tok_i]) { + .keyword_align => { + if (result.align_node != 0) { + try p.warn(.extra_align_qualifier); + } + p.tok_i += 1; + _ = try p.expectToken(.l_paren); + result.align_node = try p.expectExpr(); - const node = try p.arena.allocator.create(Node.SimpleInfixOp); - node.* = .{ - .base = .{ .tag = op }, - .op_token = token, - .lhs = undefined, // set by caller - .rhs = undefined, // set by caller - }; - return &node.base; - } + if (p.eatToken(.colon)) |_| { + result.bit_range_start = try p.expectExpr(); + _ = try p.expectToken(.colon); + result.bit_range_end = try p.expectExpr(); + } - /// CompareOp - /// <- EQUALEQUAL - /// / EXCLAMATIONMARKEQUAL - /// / LARROW - /// / RARROW - /// / LARROWEQUAL - /// / RARROWEQUAL - fn parseCompareOp(p: *Parser) !?*Node { - const token = p.nextToken(); - const op: Node.Tag = switch (p.token_ids[token]) { - .EqualEqual => .EqualEqual, - .BangEqual => .BangEqual, - .AngleBracketLeft => .LessThan, - .AngleBracketRight => .GreaterThan, - .AngleBracketLeftEqual => .LessOrEqual, - .AngleBracketRightEqual => .GreaterOrEqual, - else => { - p.putBackToken(token); - return null; - }, - }; - - return p.createInfixOp(token, op); - } - - /// BitwiseOp - /// <- AMPERSAND - /// / CARET - /// / PIPE - /// / KEYWORD_orelse - /// / KEYWORD_catch Payload? - fn parseBitwiseOp(p: *Parser) !?*Node { - const token = p.nextToken(); - const op: Node.Tag = switch (p.token_ids[token]) { - .Ampersand => .BitAnd, - .Caret => .BitXor, - .Pipe => .BitOr, - .Keyword_orelse => .OrElse, - .Keyword_catch => { - const payload = try p.parsePayload(); - const node = try p.arena.allocator.create(Node.Catch); - node.* = .{ - .op_token = token, - .lhs = undefined, // set by caller - .rhs = undefined, // set by caller - .payload = payload, - }; - return &node.base; - }, - else => { - p.putBackToken(token); - return null; - }, - }; - - return p.createInfixOp(token, op); - } - - /// BitShiftOp - /// <- LARROW2 - /// / RARROW2 - fn parseBitShiftOp(p: *Parser) !?*Node { - const token = p.nextToken(); - const op: Node.Tag = switch (p.token_ids[token]) { - .AngleBracketAngleBracketLeft => .BitShiftLeft, - .AngleBracketAngleBracketRight => .BitShiftRight, - else => { - p.putBackToken(token); - return null; - }, - }; - - return p.createInfixOp(token, op); - } - - /// AdditionOp - /// <- PLUS - /// / MINUS - /// / PLUS2 - /// / PLUSPERCENT - /// / MINUSPERCENT - fn parseAdditionOp(p: *Parser) !?*Node { - const token = p.nextToken(); - const op: Node.Tag = switch (p.token_ids[token]) { - .Plus => .Add, - .Minus => .Sub, - .PlusPlus => .ArrayCat, - .PlusPercent => .AddWrap, - .MinusPercent => .SubWrap, - else => { - p.putBackToken(token); - return null; - }, - }; - - return p.createInfixOp(token, op); - } - - /// MultiplyOp - /// <- PIPE2 - /// / ASTERISK - /// / SLASH - /// / PERCENT - /// / ASTERISK2 - /// / ASTERISKPERCENT - fn parseMultiplyOp(p: *Parser) !?*Node { - const token = p.nextToken(); - const op: Node.Tag = switch (p.token_ids[token]) { - .PipePipe => .MergeErrorSets, - .Asterisk => .Mul, - .Slash => .Div, - .Percent => .Mod, - .AsteriskAsterisk => .ArrayMult, - .AsteriskPercent => .MulWrap, - else => { - p.putBackToken(token); - return null; - }, - }; - - return p.createInfixOp(token, op); - } - - /// PrefixOp - /// <- EXCLAMATIONMARK - /// / MINUS - /// / TILDE - /// / MINUSPERCENT - /// / AMPERSAND - /// / KEYWORD_try - /// / KEYWORD_await - fn parsePrefixOp(p: *Parser) !?*Node { - const token = p.nextToken(); - switch (p.token_ids[token]) { - .Bang => return p.allocSimplePrefixOp(.BoolNot, token), - .Minus => return p.allocSimplePrefixOp(.Negation, token), - .Tilde => return p.allocSimplePrefixOp(.BitNot, token), - .MinusPercent => return p.allocSimplePrefixOp(.NegationWrap, token), - .Ampersand => return p.allocSimplePrefixOp(.AddressOf, token), - .Keyword_try => return p.allocSimplePrefixOp(.Try, token), - .Keyword_await => return p.allocSimplePrefixOp(.Await, token), - else => { - p.putBackToken(token); - return null; - }, - } - } - - fn allocSimplePrefixOp(p: *Parser, comptime tag: Node.Tag, token: TokenIndex) !?*Node { - const node = try p.arena.allocator.create(Node.SimplePrefixOp); - node.* = .{ - .base = .{ .tag = tag }, - .op_token = token, - .rhs = undefined, // set by caller - }; - return &node.base; - } - - // TODO: ArrayTypeStart is either an array or a slice, but const/allowzero only work on - // pointers. Consider updating this rule: - // ... - // / ArrayTypeStart - // / SliceTypeStart (ByteAlign / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)* - // / PtrTypeStart ... - - /// PrefixTypeOp - /// <- QUESTIONMARK - /// / KEYWORD_anyframe MINUSRARROW - /// / ArrayTypeStart (ByteAlign / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)* - /// / PtrTypeStart (KEYWORD_align LPAREN Expr (COLON INTEGER COLON INTEGER)? RPAREN / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)* - fn parsePrefixTypeOp(p: *Parser) !?*Node { - if (p.eatToken(.QuestionMark)) |token| { - const node = try p.arena.allocator.create(Node.SimplePrefixOp); - node.* = .{ - .base = .{ .tag = .OptionalType }, - .op_token = token, - .rhs = undefined, // set by caller - }; - return &node.base; - } - - if (p.eatToken(.Keyword_anyframe)) |token| { - const arrow = p.eatToken(.Arrow) orelse { - p.putBackToken(token); - return null; - }; - const node = try p.arena.allocator.create(Node.AnyFrameType); - node.* = .{ - .anyframe_token = token, - .result = .{ - .arrow_token = arrow, - .return_type = undefined, // set by caller + _ = try p.expectToken(.r_paren); }, - }; - return &node.base; - } - - if (try p.parsePtrTypeStart()) |node| { - // If the token encountered was **, there will be two nodes instead of one. - // The attributes should be applied to the rightmost operator. - var ptr_info = if (node.cast(Node.PtrType)) |ptr_type| - if (p.token_ids[ptr_type.op_token] == .AsteriskAsterisk) - &ptr_type.rhs.cast(Node.PtrType).?.ptr_info - else - &ptr_type.ptr_info - else if (node.cast(Node.SliceType)) |slice_type| - &slice_type.ptr_info - else - unreachable; - - while (true) { - if (p.eatToken(.Keyword_align)) |align_token| { - const lparen = try p.expectToken(.LParen); - const expr_node = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - - // Optional bit range - const bit_range = if (p.eatToken(.Colon)) |_| bit_range_value: { - const range_start = try p.expectNode(parseIntegerLiteral, .{ - .ExpectedIntegerLiteral = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.Colon); - const range_end = try p.expectNode(parseIntegerLiteral, .{ - .ExpectedIntegerLiteral = .{ .token = p.tok_i }, - }); - - break :bit_range_value ast.PtrInfo.Align.BitRange{ - .start = range_start, - .end = range_end, - }; - } else null; - _ = try p.expectToken(.RParen); - - if (ptr_info.align_info != null) { - try p.errors.append(p.gpa, .{ - .ExtraAlignQualifier = .{ .token = p.tok_i - 1 }, - }); - continue; + .keyword_const => { + if (saw_const) { + try p.warn(.extra_const_qualifier); } - - ptr_info.align_info = ast.PtrInfo.Align{ - .node = expr_node, - .bit_range = bit_range, - }; - - continue; - } - if (p.eatToken(.Keyword_const)) |const_token| { - if (ptr_info.const_token != null) { - try p.errors.append(p.gpa, .{ - .ExtraConstQualifier = .{ .token = p.tok_i - 1 }, - }); - continue; + p.tok_i += 1; + saw_const = true; + }, + .keyword_volatile => { + if (saw_volatile) { + try p.warn(.extra_volatile_qualifier); } - ptr_info.const_token = const_token; - continue; - } - if (p.eatToken(.Keyword_volatile)) |volatile_token| { - if (ptr_info.volatile_token != null) { - try p.errors.append(p.gpa, .{ - .ExtraVolatileQualifier = .{ .token = p.tok_i - 1 }, - }); - continue; + p.tok_i += 1; + saw_volatile = true; + }, + .keyword_allowzero => { + if (saw_allowzero) { + try p.warn(.extra_allowzero_qualifier); } - ptr_info.volatile_token = volatile_token; - continue; - } - if (p.eatToken(.Keyword_allowzero)) |allowzero_token| { - if (ptr_info.allowzero_token != null) { - try p.errors.append(p.gpa, .{ - .ExtraAllowZeroQualifier = .{ .token = p.tok_i - 1 }, - }); - continue; - } - ptr_info.allowzero_token = allowzero_token; - continue; - } - break; + p.tok_i += 1; + saw_allowzero = true; + }, + else => return result, } - - return node; } - - if (try p.parseArrayTypeStart()) |node| { - if (node.cast(Node.SliceType)) |slice_type| { - // Collect pointer qualifiers in any order, but disallow duplicates - while (true) { - if (try p.parseByteAlign()) |align_expr| { - if (slice_type.ptr_info.align_info != null) { - try p.errors.append(p.gpa, .{ - .ExtraAlignQualifier = .{ .token = p.tok_i - 1 }, - }); - continue; - } - slice_type.ptr_info.align_info = ast.PtrInfo.Align{ - .node = align_expr, - .bit_range = null, - }; - continue; - } - if (p.eatToken(.Keyword_const)) |const_token| { - if (slice_type.ptr_info.const_token != null) { - try p.errors.append(p.gpa, .{ - .ExtraConstQualifier = .{ .token = p.tok_i - 1 }, - }); - continue; - } - slice_type.ptr_info.const_token = const_token; - continue; - } - if (p.eatToken(.Keyword_volatile)) |volatile_token| { - if (slice_type.ptr_info.volatile_token != null) { - try p.errors.append(p.gpa, .{ - .ExtraVolatileQualifier = .{ .token = p.tok_i - 1 }, - }); - continue; - } - slice_type.ptr_info.volatile_token = volatile_token; - continue; - } - if (p.eatToken(.Keyword_allowzero)) |allowzero_token| { - if (slice_type.ptr_info.allowzero_token != null) { - try p.errors.append(p.gpa, .{ - .ExtraAllowZeroQualifier = .{ .token = p.tok_i - 1 }, - }); - continue; - } - slice_type.ptr_info.allowzero_token = allowzero_token; - continue; - } - break; - } - } - return node; - } - - return null; } /// SuffixOp @@ -2657,841 +3442,654 @@ const Parser = struct { /// / DOT IDENTIFIER /// / DOTASTERISK /// / DOTQUESTIONMARK - fn parseSuffixOp(p: *Parser, lhs: *Node) !?*Node { - if (p.eatToken(.LBracket)) |_| { - const index_expr = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); + fn parseSuffixOp(p: *Parser, lhs: Node.Index) !Node.Index { + switch (p.token_tags[p.tok_i]) { + .l_bracket => { + const lbracket = p.nextToken(); + const index_expr = try p.expectExpr(); - if (p.eatToken(.Ellipsis2) != null) { - const end_expr = try p.parseExpr(); - const sentinel: ?*Node = if (p.eatToken(.Colon) != null) - try p.parseExpr() - else - null; - const rtoken = try p.expectToken(.RBracket); - const node = try p.arena.allocator.create(Node.Slice); - node.* = .{ - .lhs = lhs, - .rtoken = rtoken, - .start = index_expr, - .end = end_expr, - .sentinel = sentinel, - }; - return &node.base; - } - - const rtoken = try p.expectToken(.RBracket); - const node = try p.arena.allocator.create(Node.ArrayAccess); - node.* = .{ - .lhs = lhs, - .rtoken = rtoken, - .index_expr = index_expr, - }; - return &node.base; - } - - if (p.eatToken(.PeriodAsterisk)) |period_asterisk| { - const node = try p.arena.allocator.create(Node.SimpleSuffixOp); - node.* = .{ - .base = .{ .tag = .Deref }, - .lhs = lhs, - .rtoken = period_asterisk, - }; - return &node.base; - } - - if (p.eatToken(.Invalid_periodasterisks)) |period_asterisk| { - try p.errors.append(p.gpa, .{ - .AsteriskAfterPointerDereference = .{ .token = period_asterisk }, - }); - const node = try p.arena.allocator.create(Node.SimpleSuffixOp); - node.* = .{ - .base = .{ .tag = .Deref }, - .lhs = lhs, - .rtoken = period_asterisk, - }; - return &node.base; - } - - if (p.eatToken(.Period)) |period| { - if (try p.parseIdentifier()) |identifier| { - const node = try p.arena.allocator.create(Node.SimpleInfixOp); - node.* = .{ - .base = Node{ .tag = .Period }, - .op_token = period, - .lhs = lhs, - .rhs = identifier, - }; - return &node.base; - } - if (p.eatToken(.QuestionMark)) |question_mark| { - const node = try p.arena.allocator.create(Node.SimpleSuffixOp); - node.* = .{ - .base = .{ .tag = .UnwrapOptional }, - .lhs = lhs, - .rtoken = question_mark, - }; - return &node.base; - } - try p.errors.append(p.gpa, .{ - .ExpectedSuffixOp = .{ .token = p.tok_i }, - }); - return null; - } - - return null; - } - - /// FnCallArguments <- LPAREN ExprList RPAREN - /// ExprList <- (Expr COMMA)* Expr? - fn parseFnCallArguments(p: *Parser) !?AnnotatedParamList { - if (p.eatToken(.LParen) == null) return null; - const list = try ListParseFn(*Node, parseExpr)(p); - errdefer p.gpa.free(list); - const rparen = try p.expectToken(.RParen); - return AnnotatedParamList{ .list = list, .rparen = rparen }; - } - - const AnnotatedParamList = struct { - list: []*Node, - rparen: TokenIndex, - }; - - /// ArrayTypeStart <- LBRACKET Expr? (COLON Expr)? RBRACKET - fn parseArrayTypeStart(p: *Parser) !?*Node { - const lbracket = p.eatToken(.LBracket) orelse return null; - const expr = try p.parseExpr(); - const sentinel = if (p.eatToken(.Colon)) |_| - try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }) - else - null; - const rbracket = try p.expectToken(.RBracket); - - if (expr) |len_expr| { - if (sentinel) |s| { - const node = try p.arena.allocator.create(Node.ArrayTypeSentinel); - node.* = .{ - .op_token = lbracket, - .rhs = undefined, // set by caller - .len_expr = len_expr, - .sentinel = s, - }; - return &node.base; - } else { - const node = try p.arena.allocator.create(Node.ArrayType); - node.* = .{ - .op_token = lbracket, - .rhs = undefined, // set by caller - .len_expr = len_expr, - }; - return &node.base; - } - } - - const node = try p.arena.allocator.create(Node.SliceType); - node.* = .{ - .op_token = lbracket, - .rhs = undefined, // set by caller - .ptr_info = .{ .sentinel = sentinel }, - }; - return &node.base; - } - - /// PtrTypeStart - /// <- ASTERISK - /// / ASTERISK2 - /// / LBRACKET ASTERISK (LETTERC / COLON Expr)? RBRACKET - fn parsePtrTypeStart(p: *Parser) !?*Node { - if (p.eatToken(.Asterisk)) |asterisk| { - const sentinel = if (p.eatToken(.Colon)) |_| - try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }) - else - null; - const node = try p.arena.allocator.create(Node.PtrType); - node.* = .{ - .op_token = asterisk, - .rhs = undefined, // set by caller - .ptr_info = .{ .sentinel = sentinel }, - }; - return &node.base; - } - - if (p.eatToken(.AsteriskAsterisk)) |double_asterisk| { - const node = try p.arena.allocator.create(Node.PtrType); - node.* = .{ - .op_token = double_asterisk, - .rhs = undefined, // set by caller - }; - - // Special case for **, which is its own token - const child = try p.arena.allocator.create(Node.PtrType); - child.* = .{ - .op_token = double_asterisk, - .rhs = undefined, // set by caller - }; - node.rhs = &child.base; - - return &node.base; - } - if (p.eatToken(.LBracket)) |lbracket| { - const asterisk = p.eatToken(.Asterisk) orelse { - p.putBackToken(lbracket); - return null; - }; - if (p.eatToken(.Identifier)) |ident| { - const token_loc = p.token_locs[ident]; - const token_slice = p.source[token_loc.start..token_loc.end]; - if (!std.mem.eql(u8, token_slice, "c")) { - p.putBackToken(ident); - } else { - _ = try p.expectToken(.RBracket); - const node = try p.arena.allocator.create(Node.PtrType); - node.* = .{ - .op_token = lbracket, - .rhs = undefined, // set by caller - }; - return &node.base; + if (p.eatToken(.ellipsis2)) |_| { + const end_expr = try p.parseExpr(); + if (end_expr == 0) { + _ = try p.expectToken(.r_bracket); + return p.addNode(.{ + .tag = .slice_open, + .main_token = lbracket, + .data = .{ + .lhs = lhs, + .rhs = index_expr, + }, + }); + } + if (p.eatToken(.colon)) |_| { + const sentinel = try p.parseExpr(); + _ = try p.expectToken(.r_bracket); + return p.addNode(.{ + .tag = .slice_sentinel, + .main_token = lbracket, + .data = .{ + .lhs = lhs, + .rhs = try p.addExtra(Node.SliceSentinel{ + .start = index_expr, + .end = end_expr, + .sentinel = sentinel, + }), + }, + }); + } else { + _ = try p.expectToken(.r_bracket); + return p.addNode(.{ + .tag = .slice, + .main_token = lbracket, + .data = .{ + .lhs = lhs, + .rhs = try p.addExtra(Node.Slice{ + .start = index_expr, + .end = end_expr, + }), + }, + }); + } } - } - const sentinel = if (p.eatToken(.Colon)) |_| - try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }) - else - null; - _ = try p.expectToken(.RBracket); - const node = try p.arena.allocator.create(Node.PtrType); - node.* = .{ - .op_token = lbracket, - .rhs = undefined, // set by caller - .ptr_info = .{ .sentinel = sentinel }, - }; - return &node.base; + _ = try p.expectToken(.r_bracket); + return p.addNode(.{ + .tag = .array_access, + .main_token = lbracket, + .data = .{ + .lhs = lhs, + .rhs = index_expr, + }, + }); + }, + .period_asterisk => return p.addNode(.{ + .tag = .deref, + .main_token = p.nextToken(), + .data = .{ + .lhs = lhs, + .rhs = undefined, + }, + }), + .invalid_periodasterisks => { + try p.warn(.asterisk_after_ptr_deref); + return p.addNode(.{ + .tag = .deref, + .main_token = p.nextToken(), + .data = .{ + .lhs = lhs, + .rhs = undefined, + }, + }); + }, + .period => switch (p.token_tags[p.tok_i + 1]) { + .identifier => return p.addNode(.{ + .tag = .field_access, + .main_token = p.nextToken(), + .data = .{ + .lhs = lhs, + .rhs = p.nextToken(), + }, + }), + .question_mark => return p.addNode(.{ + .tag = .unwrap_optional, + .main_token = p.nextToken(), + .data = .{ + .lhs = lhs, + .rhs = p.nextToken(), + }, + }), + else => { + p.tok_i += 1; + try p.warn(.expected_suffix_op); + return null_node; + }, + }, + else => return null_node, } - return null; } - /// ContainerDeclAuto <- ContainerDeclType LBRACE ContainerMembers RBRACE - fn parseContainerDeclAuto(p: *Parser) !?*Node { - const container_decl_type = (try p.parseContainerDeclType()) orelse return null; - const lbrace = try p.expectToken(.LBrace); - const members = try p.parseContainerMembers(false); - defer p.gpa.free(members); - const rbrace = try p.expectToken(.RBrace); - - const members_len = @intCast(NodeIndex, members.len); - const node = try Node.ContainerDecl.alloc(&p.arena.allocator, members_len); - node.* = .{ - .layout_token = null, - .kind_token = container_decl_type.kind_token, - .init_arg_expr = container_decl_type.init_arg_expr, - .fields_and_decls_len = members_len, - .lbrace_token = lbrace, - .rbrace_token = rbrace, - }; - std.mem.copy(*Node, node.fieldsAndDecls(), members); - return &node.base; - } - - /// Holds temporary data until we are ready to construct the full ContainerDecl AST node. - const ContainerDeclType = struct { - kind_token: TokenIndex, - init_arg_expr: Node.ContainerDecl.InitArg, - }; - + /// Caller must have already verified the first token. /// ContainerDeclType /// <- KEYWORD_struct /// / KEYWORD_enum (LPAREN Expr RPAREN)? /// / KEYWORD_union (LPAREN (KEYWORD_enum (LPAREN Expr RPAREN)? / Expr) RPAREN)? /// / KEYWORD_opaque - fn parseContainerDeclType(p: *Parser) !?ContainerDeclType { - const kind_token = p.nextToken(); - - const init_arg_expr = switch (p.token_ids[kind_token]) { - .Keyword_struct, .Keyword_opaque => Node.ContainerDecl.InitArg{ .None = {} }, - .Keyword_enum => blk: { - if (p.eatToken(.LParen) != null) { - const expr = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); - break :blk Node.ContainerDecl.InitArg{ .Type = expr }; + fn parseContainerDeclAuto(p: *Parser) !Node.Index { + const main_token = p.nextToken(); + const arg_expr = switch (p.token_tags[main_token]) { + .keyword_struct, .keyword_opaque => null_node, + .keyword_enum => blk: { + if (p.eatToken(.l_paren)) |_| { + const expr = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + break :blk expr; + } else { + break :blk null_node; } - break :blk Node.ContainerDecl.InitArg{ .None = {} }; }, - .Keyword_union => blk: { - if (p.eatToken(.LParen) != null) { - if (p.eatToken(.Keyword_enum) != null) { - if (p.eatToken(.LParen) != null) { - const expr = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, + .keyword_union => blk: { + if (p.eatToken(.l_paren)) |_| { + if (p.eatToken(.keyword_enum)) |_| { + if (p.eatToken(.l_paren)) |_| { + const enum_tag_expr = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + _ = try p.expectToken(.r_paren); + + _ = try p.expectToken(.l_brace); + const members = try p.parseContainerMembers(); + const members_span = try members.toSpan(p); + _ = try p.expectToken(.r_brace); + return p.addNode(.{ + .tag = switch (members.trailing) { + true => .tagged_union_enum_tag_trailing, + false => .tagged_union_enum_tag, + }, + .main_token = main_token, + .data = .{ + .lhs = enum_tag_expr, + .rhs = try p.addExtra(members_span), + }, }); - _ = try p.expectToken(.RParen); - _ = try p.expectToken(.RParen); - break :blk Node.ContainerDecl.InitArg{ .Enum = expr }; + } else { + _ = try p.expectToken(.r_paren); + + _ = try p.expectToken(.l_brace); + const members = try p.parseContainerMembers(); + _ = try p.expectToken(.r_brace); + if (members.len <= 2) { + return p.addNode(.{ + .tag = switch (members.trailing) { + true => .tagged_union_two_trailing, + false => .tagged_union_two, + }, + .main_token = main_token, + .data = .{ + .lhs = members.lhs, + .rhs = members.rhs, + }, + }); + } else { + const span = try members.toSpan(p); + return p.addNode(.{ + .tag = switch (members.trailing) { + true => .tagged_union_trailing, + false => .tagged_union, + }, + .main_token = main_token, + .data = .{ + .lhs = span.start, + .rhs = span.end, + }, + }); + } } - _ = try p.expectToken(.RParen); - break :blk Node.ContainerDecl.InitArg{ .Enum = null }; + } else { + const expr = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + break :blk expr; } - const expr = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); - break :blk Node.ContainerDecl.InitArg{ .Type = expr }; + } else { + break :blk null_node; } - break :blk Node.ContainerDecl.InitArg{ .None = {} }; }, else => { - p.putBackToken(kind_token); - return null; + p.tok_i -= 1; + return p.fail(.expected_container); }, }; - - return ContainerDeclType{ - .kind_token = kind_token, - .init_arg_expr = init_arg_expr, - }; + _ = try p.expectToken(.l_brace); + const members = try p.parseContainerMembers(); + _ = try p.expectToken(.r_brace); + if (arg_expr == 0) { + if (members.len <= 2) { + return p.addNode(.{ + .tag = switch (members.trailing) { + true => .container_decl_two_trailing, + false => .container_decl_two, + }, + .main_token = main_token, + .data = .{ + .lhs = members.lhs, + .rhs = members.rhs, + }, + }); + } else { + const span = try members.toSpan(p); + return p.addNode(.{ + .tag = switch (members.trailing) { + true => .container_decl_trailing, + false => .container_decl, + }, + .main_token = main_token, + .data = .{ + .lhs = span.start, + .rhs = span.end, + }, + }); + } + } else { + const span = try members.toSpan(p); + return p.addNode(.{ + .tag = switch (members.trailing) { + true => .container_decl_arg_trailing, + false => .container_decl_arg, + }, + .main_token = main_token, + .data = .{ + .lhs = arg_expr, + .rhs = try p.addExtra(Node.SubRange{ + .start = span.start, + .end = span.end, + }), + }, + }); + } } + /// Holds temporary data until we are ready to construct the full ContainerDecl AST node. /// ByteAlign <- KEYWORD_align LPAREN Expr RPAREN - fn parseByteAlign(p: *Parser) !?*Node { - _ = p.eatToken(.Keyword_align) orelse return null; - _ = try p.expectToken(.LParen); - const expr = try p.expectNode(parseExpr, .{ - .ExpectedExpr = .{ .token = p.tok_i }, - }); - _ = try p.expectToken(.RParen); + fn parseByteAlign(p: *Parser) !Node.Index { + _ = p.eatToken(.keyword_align) orelse return null_node; + _ = try p.expectToken(.l_paren); + const expr = try p.expectExpr(); + _ = try p.expectToken(.r_paren); return expr; } - /// IdentifierList <- (IDENTIFIER COMMA)* IDENTIFIER? - /// Only ErrorSetDecl parses an IdentifierList - fn parseErrorTagList(p: *Parser) ![]*Node { - return ListParseFn(*Node, parseErrorTag)(p); - } - /// SwitchProngList <- (SwitchProng COMMA)* SwitchProng? - fn parseSwitchProngList(p: *Parser) ![]*Node { - return ListParseFn(*Node, parseSwitchProng)(p); - } - - /// AsmOutputList <- (AsmOutputItem COMMA)* AsmOutputItem? - fn parseAsmOutputList(p: *Parser) Error![]Node.Asm.Output { - return ListParseFn(Node.Asm.Output, parseAsmOutputItem)(p); - } - - /// AsmInputList <- (AsmInputItem COMMA)* AsmInputItem? - fn parseAsmInputList(p: *Parser) Error![]Node.Asm.Input { - return ListParseFn(Node.Asm.Input, parseAsmInputItem)(p); + fn parseSwitchProngList(p: *Parser) !Node.SubRange { + return ListParseFn(parseSwitchProng)(p); } /// ParamDeclList <- (ParamDecl COMMA)* ParamDecl? - fn parseParamDeclList(p: *Parser) ![]Node.FnProto.ParamDecl { - return ListParseFn(Node.FnProto.ParamDecl, parseParamDecl)(p); + fn parseParamDeclList(p: *Parser) !SmallSpan { + _ = try p.expectToken(.l_paren); + if (p.eatToken(.r_paren)) |_| { + return SmallSpan{ .zero_or_one = 0 }; + } + const param_one = while (true) { + const param = try p.expectParamDecl(); + if (param != 0) break param; + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_paren)) |_| { + return SmallSpan{ .zero_or_one = 0 }; + } + continue; + }, + .r_paren => return SmallSpan{ .zero_or_one = 0 }, + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } else unreachable; + + const param_two = while (true) { + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_paren)) |_| { + return SmallSpan{ .zero_or_one = param_one }; + } + const param = try p.expectParamDecl(); + if (param != 0) break param; + continue; + }, + .r_paren => return SmallSpan{ .zero_or_one = param_one }, + .colon, .r_brace, .r_bracket => { + p.tok_i -= 1; + return p.failExpected(.r_paren); + }, + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } else unreachable; + + var list = std.ArrayList(Node.Index).init(p.gpa); + defer list.deinit(); + + try list.appendSlice(&.{ param_one, param_two }); + + while (true) { + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.token_tags[p.tok_i] == .r_paren) { + p.tok_i += 1; + return SmallSpan{ .multi = list.toOwnedSlice() }; + } + const param = try p.expectParamDecl(); + if (param != 0) { + try list.append(param); + } + continue; + }, + .r_paren => return SmallSpan{ .multi = list.toOwnedSlice() }, + .colon, .r_brace, .r_bracket => { + p.tok_i -= 1; + return p.failExpected(.r_paren); + }, + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } } - const NodeParseFn = fn (p: *Parser) Error!?*Node; + const NodeParseFn = fn (p: *Parser) Error!Node.Index; - fn ListParseFn(comptime E: type, comptime nodeParseFn: anytype) ParseFn([]E) { + fn ListParseFn(comptime nodeParseFn: anytype) (fn (p: *Parser) Error!Node.SubRange) { return struct { - pub fn parse(p: *Parser) ![]E { - var list = std.ArrayList(E).init(p.gpa); + pub fn parse(p: *Parser) Error!Node.SubRange { + var list = std.ArrayList(Node.Index).init(p.gpa); defer list.deinit(); - while (try nodeParseFn(p)) |item| { + while (true) { + const item = try nodeParseFn(p); + if (item == 0) break; + try list.append(item); - switch (p.token_ids[p.tok_i]) { - .Comma => _ = p.nextToken(), + switch (p.token_tags[p.tok_i]) { + .comma => p.tok_i += 1, // all possible delimiters - .Colon, .RParen, .RBrace, .RBracket => break, + .colon, .r_paren, .r_brace, .r_bracket => break, else => { - // this is likely just a missing comma, - // continue parsing this list and give an error - try p.errors.append(p.gpa, .{ - .ExpectedToken = .{ .token = p.tok_i, .expected_id = .Comma }, - }); + // This is likely just a missing comma; + // give an error but continue parsing this list. + try p.warnExpected(.comma); }, } } - return list.toOwnedSlice(); + return p.listToSpan(list.items); } }.parse; } - fn SimpleBinOpParseFn(comptime token: Token.Id, comptime op: Node.Tag) NodeParseFn { - return struct { - pub fn parse(p: *Parser) Error!?*Node { - const op_token = if (token == .Keyword_and) switch (p.token_ids[p.tok_i]) { - .Keyword_and => p.nextToken(), - .Invalid_ampersands => blk: { - try p.errors.append(p.gpa, .{ - .InvalidAnd = .{ .token = p.tok_i }, - }); - break :blk p.nextToken(); - }, - else => return null, - } else p.eatToken(token) orelse return null; - - const node = try p.arena.allocator.create(Node.SimpleInfixOp); - node.* = .{ - .base = .{ .tag = op }, - .op_token = op_token, - .lhs = undefined, // set by caller - .rhs = undefined, // set by caller - }; - return &node.base; - } - }.parse; - } - - // Helper parsers not included in the grammar - - fn parseBuiltinCall(p: *Parser) !?*Node { - const token = p.eatToken(.Builtin) orelse return null; - const params = (try p.parseFnCallArguments()) orelse { - try p.errors.append(p.gpa, .{ - .ExpectedParamList = .{ .token = p.tok_i }, + /// FnCallArguments <- LPAREN ExprList RPAREN + /// ExprList <- (Expr COMMA)* Expr? + fn parseBuiltinCall(p: *Parser) !Node.Index { + const builtin_token = p.assertToken(.builtin); + if (p.token_tags[p.nextToken()] != .l_paren) { + p.tok_i -= 1; + try p.warn(.expected_param_list); + // Pretend this was an identifier so we can continue parsing. + return p.addNode(.{ + .tag = .identifier, + .main_token = builtin_token, + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, }); - - // lets pretend this was an identifier so we can continue parsing - const node = try p.arena.allocator.create(Node.OneToken); - node.* = .{ - .base = .{ .tag = .Identifier }, - .token = token, - }; - return &node.base; - }; - defer p.gpa.free(params.list); - - const node = try Node.BuiltinCall.alloc(&p.arena.allocator, params.list.len); - node.* = .{ - .builtin_token = token, - .params_len = params.list.len, - .rparen_token = params.rparen, - }; - std.mem.copy(*Node, node.params(), params.list); - return &node.base; - } - - fn parseErrorTag(p: *Parser) !?*Node { - const doc_comments = try p.parseDocComment(); // no need to rewind on failure - const token = p.eatToken(.Identifier) orelse return null; - - const node = try p.arena.allocator.create(Node.ErrorTag); - node.* = .{ - .doc_comments = doc_comments, - .name_token = token, - }; - return &node.base; - } - - fn parseIdentifier(p: *Parser) !?*Node { - const token = p.eatToken(.Identifier) orelse return null; - const node = try p.arena.allocator.create(Node.OneToken); - node.* = .{ - .base = .{ .tag = .Identifier }, - .token = token, - }; - return &node.base; - } - - fn parseAnyType(p: *Parser) !?*Node { - const token = p.eatToken(.Keyword_anytype) orelse - p.eatToken(.Keyword_var) orelse return null; // TODO remove in next release cycle - const node = try p.arena.allocator.create(Node.OneToken); - node.* = .{ - .base = .{ .tag = .AnyType }, - .token = token, - }; - return &node.base; - } - - fn createLiteral(p: *Parser, tag: ast.Node.Tag, token: TokenIndex) !*Node { - const result = try p.arena.allocator.create(Node.OneToken); - result.* = .{ - .base = .{ .tag = tag }, - .token = token, - }; - return &result.base; - } - - fn parseStringLiteralSingle(p: *Parser) !?*Node { - if (p.eatToken(.StringLiteral)) |token| { - const node = try p.arena.allocator.create(Node.OneToken); - node.* = .{ - .base = .{ .tag = .StringLiteral }, - .token = token, - }; - return &node.base; } - return null; + if (p.eatToken(.r_paren)) |_| { + return p.addNode(.{ + .tag = .builtin_call_two, + .main_token = builtin_token, + .data = .{ + .lhs = 0, + .rhs = 0, + }, + }); + } + const param_one = try p.expectExpr(); + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_paren)) |_| { + return p.addNode(.{ + .tag = .builtin_call_two_comma, + .main_token = builtin_token, + .data = .{ + .lhs = param_one, + .rhs = 0, + }, + }); + } + }, + .r_paren => return p.addNode(.{ + .tag = .builtin_call_two, + .main_token = builtin_token, + .data = .{ + .lhs = param_one, + .rhs = 0, + }, + }), + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + const param_two = try p.expectExpr(); + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_paren)) |_| { + return p.addNode(.{ + .tag = .builtin_call_two_comma, + .main_token = builtin_token, + .data = .{ + .lhs = param_one, + .rhs = param_two, + }, + }); + } + }, + .r_paren => return p.addNode(.{ + .tag = .builtin_call_two, + .main_token = builtin_token, + .data = .{ + .lhs = param_one, + .rhs = param_two, + }, + }), + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + + var list = std.ArrayList(Node.Index).init(p.gpa); + defer list.deinit(); + + try list.appendSlice(&.{ param_one, param_two }); + + while (true) { + const param = try p.expectExpr(); + try list.append(param); + switch (p.token_tags[p.nextToken()]) { + .comma => { + if (p.eatToken(.r_paren)) |_| { + const params = try p.listToSpan(list.items); + return p.addNode(.{ + .tag = .builtin_call_comma, + .main_token = builtin_token, + .data = .{ + .lhs = params.start, + .rhs = params.end, + }, + }); + } + continue; + }, + .r_paren => { + const params = try p.listToSpan(list.items); + return p.addNode(.{ + .tag = .builtin_call, + .main_token = builtin_token, + .data = .{ + .lhs = params.start, + .rhs = params.end, + }, + }); + }, + else => { + // This is likely just a missing comma; + // give an error but continue parsing this list. + p.tok_i -= 1; + try p.warnExpected(.comma); + }, + } + } } // string literal or multiline string literal - fn parseStringLiteral(p: *Parser) !?*Node { - if (try p.parseStringLiteralSingle()) |node| return node; - - if (p.eatToken(.MultilineStringLiteralLine)) |first_line| { - const start_tok_i = p.tok_i; - var tok_i = start_tok_i; - var count: usize = 1; // including first_line - while (true) : (tok_i += 1) { - switch (p.token_ids[tok_i]) { - .LineComment => continue, - .MultilineStringLiteralLine => count += 1, - else => break, - } - } - - const node = try Node.MultilineStringLiteral.alloc(&p.arena.allocator, count); - node.* = .{ .lines_len = count }; - const lines = node.lines(); - tok_i = start_tok_i; - lines[0] = first_line; - count = 1; - while (true) : (tok_i += 1) { - switch (p.token_ids[tok_i]) { - .LineComment => continue, - .MultilineStringLiteralLine => { - lines[count] = tok_i; - count += 1; + fn parseStringLiteral(p: *Parser) !Node.Index { + switch (p.token_tags[p.tok_i]) { + .string_literal => { + const main_token = p.nextToken(); + return p.addNode(.{ + .tag = .string_literal, + .main_token = main_token, + .data = .{ + .lhs = undefined, + .rhs = undefined, }, - else => break, + }); + }, + .multiline_string_literal_line => { + const first_line = p.nextToken(); + while (p.token_tags[p.tok_i] == .multiline_string_literal_line) { + p.tok_i += 1; } - } - p.tok_i = tok_i; - return &node.base; + return p.addNode(.{ + .tag = .multiline_string_literal, + .main_token = first_line, + .data = .{ + .lhs = first_line, + .rhs = p.tok_i - 1, + }, + }); + }, + else => return null_node, } - - return null; } - fn parseIntegerLiteral(p: *Parser) !?*Node { - const token = p.eatToken(.IntegerLiteral) orelse return null; - const node = try p.arena.allocator.create(Node.OneToken); - node.* = .{ - .base = .{ .tag = .IntegerLiteral }, - .token = token, - }; - return &node.base; - } - - fn parseFloatLiteral(p: *Parser) !?*Node { - const token = p.eatToken(.FloatLiteral) orelse return null; - const node = try p.arena.allocator.create(Node.OneToken); - node.* = .{ - .base = .{ .tag = .FloatLiteral }, - .token = token, - }; - return &node.base; - } - - fn parseTry(p: *Parser) !?*Node { - const token = p.eatToken(.Keyword_try) orelse return null; - const node = try p.arena.allocator.create(Node.SimplePrefixOp); - node.* = .{ - .base = .{ .tag = .Try }, - .op_token = token, - .rhs = undefined, // set by caller - }; - return &node.base; - } - - /// IfPrefix Body (KEYWORD_else Payload? Body)? - fn parseIf(p: *Parser, bodyParseFn: NodeParseFn) !?*Node { - const node = (try p.parseIfPrefix()) orelse return null; - const if_prefix = node.cast(Node.If).?; - - if_prefix.body = try p.expectNode(bodyParseFn, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - - const else_token = p.eatToken(.Keyword_else) orelse return node; - const payload = try p.parsePayload(); - const else_expr = try p.expectNode(bodyParseFn, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - const else_node = try p.arena.allocator.create(Node.Else); - else_node.* = .{ - .else_token = else_token, - .payload = payload, - .body = else_expr, - }; - if_prefix.@"else" = else_node; - + fn expectStringLiteral(p: *Parser) !Node.Index { + const node = try p.parseStringLiteral(); + if (node == 0) { + return p.fail(.expected_string_literal); + } return node; } - /// Eat a multiline doc comment - fn parseDocComment(p: *Parser) !?*Node.DocComment { - if (p.eatToken(.DocComment)) |first_line| { - while (p.eatToken(.DocComment)) |_| {} - const node = try p.arena.allocator.create(Node.DocComment); - node.* = .{ .first_line = first_line }; - return node; + fn expectIntegerLiteral(p: *Parser) !Node.Index { + return p.addNode(.{ + .tag = .integer_literal, + .main_token = try p.expectToken(.integer_literal), + .data = .{ + .lhs = undefined, + .rhs = undefined, + }, + }); + } + + /// KEYWORD_if LPAREN Expr RPAREN PtrPayload? Body (KEYWORD_else Payload? Body)? + fn parseIf(p: *Parser, bodyParseFn: NodeParseFn) !Node.Index { + const if_token = p.eatToken(.keyword_if) orelse return null_node; + _ = try p.expectToken(.l_paren); + const condition = try p.expectExpr(); + _ = try p.expectToken(.r_paren); + const then_payload = try p.parsePtrPayload(); + + const then_expr = try bodyParseFn(p); + if (then_expr == 0) return p.fail(.invalid_token); + + const else_token = p.eatToken(.keyword_else) orelse return p.addNode(.{ + .tag = .if_simple, + .main_token = if_token, + .data = .{ + .lhs = condition, + .rhs = then_expr, + }, + }); + const else_payload = try p.parsePayload(); + const else_expr = try bodyParseFn(p); + if (else_expr == 0) return p.fail(.invalid_token); + + return p.addNode(.{ + .tag = .@"if", + .main_token = if_token, + .data = .{ + .lhs = condition, + .rhs = try p.addExtra(Node.If{ + .then_expr = then_expr, + .else_expr = else_expr, + }), + }, + }); + } + + /// Skips over doc comment tokens. Returns the first one, if any. + fn eatDocComments(p: *Parser) !?TokenIndex { + if (p.eatToken(.doc_comment)) |tok| { + var first_line = tok; + if (tok > 0 and tokensOnSameLine(p, tok - 1, tok)) { + try p.warnMsg(.{ + .tag = .same_line_doc_comment, + .token = tok, + }); + first_line = p.eatToken(.doc_comment) orelse return null; + } + while (p.eatToken(.doc_comment)) |_| {} + return first_line; } return null; } fn tokensOnSameLine(p: *Parser, token1: TokenIndex, token2: TokenIndex) bool { - return std.mem.indexOfScalar(u8, p.source[p.token_locs[token1].end..p.token_locs[token2].start], '\n') == null; + return std.mem.indexOfScalar(u8, p.source[p.token_starts[token1]..p.token_starts[token2]], '\n') == null; } - /// Eat a single-line doc comment on the same line as another node - fn parseAppendedDocComment(p: *Parser, after_token: TokenIndex) !?*Node.DocComment { - const comment_token = p.eatToken(.DocComment) orelse return null; - if (p.tokensOnSameLine(after_token, comment_token)) { - const node = try p.arena.allocator.create(Node.DocComment); - node.* = .{ .first_line = comment_token }; - return node; - } - p.putBackToken(comment_token); - return null; + fn eatToken(p: *Parser, tag: Token.Tag) ?TokenIndex { + return if (p.token_tags[p.tok_i] == tag) p.nextToken() else null; } - /// Op* Child - fn parsePrefixOpExpr(p: *Parser, comptime opParseFn: NodeParseFn, comptime childParseFn: NodeParseFn) Error!?*Node { - if (try opParseFn(p)) |first_op| { - var rightmost_op = first_op; - while (true) { - switch (rightmost_op.tag) { - .AddressOf, - .Await, - .BitNot, - .BoolNot, - .OptionalType, - .Negation, - .NegationWrap, - .Resume, - .Try, - => { - if (try opParseFn(p)) |rhs| { - rightmost_op.cast(Node.SimplePrefixOp).?.rhs = rhs; - rightmost_op = rhs; - } else break; - }, - .ArrayType => { - if (try opParseFn(p)) |rhs| { - rightmost_op.cast(Node.ArrayType).?.rhs = rhs; - rightmost_op = rhs; - } else break; - }, - .ArrayTypeSentinel => { - if (try opParseFn(p)) |rhs| { - rightmost_op.cast(Node.ArrayTypeSentinel).?.rhs = rhs; - rightmost_op = rhs; - } else break; - }, - .SliceType => { - if (try opParseFn(p)) |rhs| { - rightmost_op.cast(Node.SliceType).?.rhs = rhs; - rightmost_op = rhs; - } else break; - }, - .PtrType => { - var ptr_type = rightmost_op.cast(Node.PtrType).?; - // If the token encountered was **, there will be two nodes - if (p.token_ids[ptr_type.op_token] == .AsteriskAsterisk) { - rightmost_op = ptr_type.rhs; - ptr_type = rightmost_op.cast(Node.PtrType).?; - } - if (try opParseFn(p)) |rhs| { - ptr_type.rhs = rhs; - rightmost_op = rhs; - } else break; - }, - .AnyFrameType => { - const prom = rightmost_op.cast(Node.AnyFrameType).?; - if (try opParseFn(p)) |rhs| { - prom.result.?.return_type = rhs; - rightmost_op = rhs; - } else break; - }, - else => unreachable, - } - } - - // If any prefix op existed, a child node on the RHS is required - switch (rightmost_op.tag) { - .AddressOf, - .Await, - .BitNot, - .BoolNot, - .OptionalType, - .Negation, - .NegationWrap, - .Resume, - .Try, - => { - const prefix_op = rightmost_op.cast(Node.SimplePrefixOp).?; - prefix_op.rhs = try p.expectNode(childParseFn, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - }, - .ArrayType => { - const prefix_op = rightmost_op.cast(Node.ArrayType).?; - prefix_op.rhs = try p.expectNode(childParseFn, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - }, - .ArrayTypeSentinel => { - const prefix_op = rightmost_op.cast(Node.ArrayTypeSentinel).?; - prefix_op.rhs = try p.expectNode(childParseFn, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - }, - .PtrType => { - const prefix_op = rightmost_op.cast(Node.PtrType).?; - prefix_op.rhs = try p.expectNode(childParseFn, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - }, - .SliceType => { - const prefix_op = rightmost_op.cast(Node.SliceType).?; - prefix_op.rhs = try p.expectNode(childParseFn, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - }, - .AnyFrameType => { - const prom = rightmost_op.cast(Node.AnyFrameType).?; - prom.result.?.return_type = try p.expectNode(childParseFn, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - }, - else => unreachable, - } - - return first_op; - } - - // Otherwise, the child node is optional - return childParseFn(p); - } - - /// Child (Op Child)* - /// Child (Op Child)? - fn parseBinOpExpr( - p: *Parser, - opParseFn: NodeParseFn, - childParseFn: NodeParseFn, - chain: enum { - Once, - Infinitely, - }, - ) Error!?*Node { - var res = (try childParseFn(p)) orelse return null; - - while (try opParseFn(p)) |node| { - const right = try p.expectNode(childParseFn, .{ - .InvalidToken = .{ .token = p.tok_i }, - }); - const left = res; - res = node; - - if (node.castTag(.Catch)) |op| { - op.lhs = left; - op.rhs = right; - } else if (node.cast(Node.SimpleInfixOp)) |op| { - op.lhs = left; - op.rhs = right; - } - - switch (chain) { - .Once => break, - .Infinitely => continue, - } - } - - return res; - } - - fn createInfixOp(p: *Parser, op_token: TokenIndex, tag: Node.Tag) !*Node { - const node = try p.arena.allocator.create(Node.SimpleInfixOp); - node.* = .{ - .base = Node{ .tag = tag }, - .op_token = op_token, - .lhs = undefined, // set by caller - .rhs = undefined, // set by caller - }; - return &node.base; - } - - fn eatToken(p: *Parser, id: Token.Id) ?TokenIndex { - return if (p.token_ids[p.tok_i] == id) p.nextToken() else null; - } - - fn expectToken(p: *Parser, id: Token.Id) Error!TokenIndex { - return (try p.expectTokenRecoverable(id)) orelse error.ParseError; - } - - fn expectTokenRecoverable(p: *Parser, id: Token.Id) !?TokenIndex { + fn assertToken(p: *Parser, tag: Token.Tag) TokenIndex { const token = p.nextToken(); - if (p.token_ids[token] != id) { - try p.errors.append(p.gpa, .{ - .ExpectedToken = .{ .token = token, .expected_id = id }, + assert(p.token_tags[token] == tag); + return token; + } + + fn expectToken(p: *Parser, tag: Token.Tag) Error!TokenIndex { + const token = p.nextToken(); + if (p.token_tags[token] != tag) { + p.tok_i -= 1; // Go back so that we can recover properly. + return p.failMsg(.{ + .tag = .expected_token, + .token = token, + .extra = .{ .expected_tag = tag }, }); - // go back so that we can recover properly - p.putBackToken(token); - return null; } return token; } + fn expectTokenRecoverable(p: *Parser, tag: Token.Tag) !?TokenIndex { + if (p.token_tags[p.tok_i] != tag) { + try p.warnExpected(tag); + return null; + } else { + return p.nextToken(); + } + } + fn nextToken(p: *Parser) TokenIndex { const result = p.tok_i; p.tok_i += 1; - assert(p.token_ids[result] != .LineComment); - if (p.tok_i >= p.token_ids.len) return result; - - while (true) { - if (p.token_ids[p.tok_i] != .LineComment) return result; - p.tok_i += 1; - } - } - - fn putBackToken(p: *Parser, putting_back: TokenIndex) void { - while (p.tok_i > 0) { - p.tok_i -= 1; - if (p.token_ids[p.tok_i] == .LineComment) continue; - assert(putting_back == p.tok_i); - return; - } - } - - /// TODO Delete this function. I don't like the inversion of control. - fn expectNode( - p: *Parser, - parseFn: NodeParseFn, - /// if parsing fails - err: AstError, - ) Error!*Node { - return (try p.expectNodeRecoverable(parseFn, err)) orelse return error.ParseError; - } - - /// TODO Delete this function. I don't like the inversion of control. - fn expectNodeRecoverable( - p: *Parser, - parseFn: NodeParseFn, - /// if parsing fails - err: AstError, - ) !?*Node { - return (try parseFn(p)) orelse { - try p.errors.append(p.gpa, err); - return null; - }; + return result; } }; -fn ParseFn(comptime T: type) type { - return fn (p: *Parser) Error!T; -} - -test "std.zig.parser" { +test { _ = @import("parser_test.zig"); } diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 1205dbadab..2b9e3fb03c 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -1,277 +1,36 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. -test "zig fmt: convert var to anytype" { - // TODO remove in next release cycle + +// TODO Remove this after zig 0.9.0 is released. +test "zig fmt: rewrite inline functions as callconv(.Inline)" { try testTransform( - \\pub fn main( - \\ a: var, - \\ bar: var, - \\) void {} + \\inline fn foo() void {} + \\ , - \\pub fn main( - \\ a: anytype, - \\ bar: anytype, - \\) void {} + \\fn foo() callconv(.Inline) void {} \\ ); } -test "zig fmt: noasync to nosuspend" { - // TODO: remove this - try testTransform( - \\pub fn main() void { - \\ noasync call(); - \\} - , - \\pub fn main() void { - \\ nosuspend call(); - \\} +test "zig fmt: simple top level comptime block" { + try testCanonical( + \\// line comment + \\comptime {} \\ ); } -test "recovery: top level" { - try testError( - \\test "" {inline} - \\test "" {inline} - , &[_]Error{ - .ExpectedInlinable, - .ExpectedInlinable, - }); -} - -test "recovery: block statements" { - try testError( - \\test "" { - \\ foo + +; - \\ inline; - \\} - , &[_]Error{ - .InvalidToken, - .ExpectedInlinable, - }); -} - -test "recovery: missing comma" { - try testError( - \\test "" { - \\ switch (foo) { - \\ 2 => {} - \\ 3 => {} - \\ else => { - \\ foo && bar +; - \\ } - \\ } - \\} - , &[_]Error{ - .ExpectedToken, - .ExpectedToken, - .InvalidAnd, - .InvalidToken, - }); -} - -test "recovery: extra qualifier" { - try testError( - \\const a: *const const u8; - \\test "" - , &[_]Error{ - .ExtraConstQualifier, - .ExpectedLBrace, - }); -} - -test "recovery: missing return type" { - try testError( - \\fn foo() { - \\ a && b; - \\} - \\test "" - , &[_]Error{ - .ExpectedReturnType, - .InvalidAnd, - .ExpectedLBrace, - }); -} - -test "recovery: continue after invalid decl" { - try testError( - \\fn foo { - \\ inline; - \\} - \\pub test "" { - \\ async a && b; - \\} - , &[_]Error{ - .ExpectedToken, - .ExpectedPubItem, - .ExpectedParamList, - .InvalidAnd, - }); - try testError( - \\threadlocal test "" { - \\ @a && b; - \\} - , &[_]Error{ - .ExpectedVarDecl, - .ExpectedParamList, - .InvalidAnd, - }); -} - -test "recovery: invalid extern/inline" { - try testError( - \\inline test "" { a && b; } - , &[_]Error{ - .ExpectedFn, - .InvalidAnd, - }); - try testError( - \\extern "" test "" { a && b; } - , &[_]Error{ - .ExpectedVarDeclOrFn, - .InvalidAnd, - }); -} - -test "recovery: missing semicolon" { - try testError( - \\test "" { - \\ comptime a && b - \\ c && d - \\ @foo - \\} - , &[_]Error{ - .InvalidAnd, - .ExpectedToken, - .InvalidAnd, - .ExpectedToken, - .ExpectedParamList, - .ExpectedToken, - }); -} - -test "recovery: invalid container members" { - try testError( - \\usingnamespace; - \\foo+ - \\bar@, - \\while (a == 2) { test "" {}} - \\test "" { - \\ a && b - \\} - , &[_]Error{ - .ExpectedExpr, - .ExpectedToken, - .ExpectedToken, - .ExpectedContainerMembers, - .InvalidAnd, - .ExpectedToken, - }); -} - -test "recovery: invalid parameter" { - try testError( - \\fn main() void { - \\ a(comptime T: type) - \\} - , &[_]Error{ - .ExpectedToken, - }); -} - -test "recovery: extra '}' at top level" { - try testError( - \\}}} - \\test "" { - \\ a && b; - \\} - , &[_]Error{ - .ExpectedContainerMembers, - .ExpectedContainerMembers, - .ExpectedContainerMembers, - .InvalidAnd, - }); -} - -test "recovery: mismatched bracket at top level" { - try testError( - \\const S = struct { - \\ arr: 128]?G - \\}; - , &[_]Error{ - .ExpectedToken, - }); -} - -test "recovery: invalid global error set access" { - try testError( - \\test "" { - \\ error && foo; - \\} - , &[_]Error{ - .ExpectedToken, - .ExpectedIdentifier, - .InvalidAnd, - }); -} - -test "recovery: invalid asterisk after pointer dereference" { - try testError( - \\test "" { - \\ var sequence = "repeat".*** 10; - \\} - , &[_]Error{ - .AsteriskAfterPointerDereference, - }); - try testError( - \\test "" { - \\ var sequence = "repeat".** 10&&a; - \\} - , &[_]Error{ - .AsteriskAfterPointerDereference, - .InvalidAnd, - }); -} - -test "recovery: missing semicolon after if, for, while stmt" { - try testError( - \\test "" { - \\ if (foo) bar - \\ for (foo) |a| bar - \\ while (foo) bar - \\ a && b; - \\} - , &[_]Error{ - .ExpectedSemiOrElse, - .ExpectedSemiOrElse, - .ExpectedSemiOrElse, - .InvalidAnd, - }); -} - -test "recovery: invalid comptime" { - try testError( - \\comptime - , &[_]Error{ - .ExpectedBlockOrField, - }); -} - -test "recovery: missing block after for/while loops" { - try testError( - \\test "" { while (foo) } - , &[_]Error{ - .ExpectedBlockOrAssignment, - }); - try testError( - \\test "" { for (foo) |bar| } - , &[_]Error{ - .ExpectedBlockOrAssignment, - }); +test "zig fmt: two spaced line comments before decl" { + try testCanonical( + \\// line comment + \\ + \\// another + \\comptime {} + \\ + ); } test "zig fmt: respect line breaks after var declarations" { @@ -325,6 +84,35 @@ test "zig fmt: empty file" { ); } +test "zig fmt: file ends in comment" { + try testTransform( + \\ //foobar + , + \\//foobar + \\ + ); +} + +test "zig fmt: file ends in comment after var decl" { + try testTransform( + \\const x = 42; + \\ //foobar + , + \\const x = 42; + \\//foobar + \\ + ); +} + +test "zig fmt: doc comments on test" { + try testCanonical( + \\/// hello + \\/// world + \\test "" {} + \\ + ); +} + test "zig fmt: if statment" { try testCanonical( \\test "" { @@ -357,7 +145,7 @@ test "zig fmt: decl between fields" { \\ b: usize, \\}; , &[_]Error{ - .DeclBetweenFields, + .decl_between_fields, }); } @@ -365,7 +153,7 @@ test "zig fmt: eof after missing comma" { try testError( \\foo() , &[_]Error{ - .ExpectedToken, + .expected_token, }); } @@ -402,7 +190,7 @@ test "zig fmt: nosuspend await" { ); } -test "zig fmt: trailing comma in container declaration" { +test "zig fmt: container declaration, single line" { try testCanonical( \\const X = struct { foo: i32 }; \\const X = struct { foo: i32, bar: i32 }; @@ -411,7 +199,23 @@ test "zig fmt: trailing comma in container declaration" { \\const X = struct { foo: i32 align(4) = 1, bar: i32 align(4) = 2 }; \\ ); +} + +test "zig fmt: container declaration, one item, multi line trailing comma" { try testCanonical( + \\test "" { + \\ comptime { + \\ const X = struct { + \\ x: i32, + \\ }; + \\ } + \\} + \\ + ); +} + +test "zig fmt: container declaration, no trailing comma on separate line" { + try testTransform( \\test "" { \\ comptime { \\ const X = struct { @@ -420,18 +224,101 @@ test "zig fmt: trailing comma in container declaration" { \\ } \\} \\ + , + \\test "" { + \\ comptime { + \\ const X = struct { x: i32 }; + \\ } + \\} + \\ ); +} + +test "zig fmt: container declaration, line break, no trailing comma" { try testTransform( \\const X = struct { \\ foo: i32, bar: i8 }; , + \\const X = struct { foo: i32, bar: i8 }; + \\ + ); +} + +test "zig fmt: container declaration, transform trailing comma" { + try testTransform( \\const X = struct { - \\ foo: i32, bar: i8 + \\ foo: i32, bar: i8, }; + , + \\const X = struct { + \\ foo: i32, + \\ bar: i8, \\}; \\ ); } +test "zig fmt: remove empty lines at start/end of container decl" { + try testTransform( + \\const X = struct { + \\ + \\ foo: i32, + \\ + \\ bar: i8, + \\ + \\}; + \\ + , + \\const X = struct { + \\ foo: i32, + \\ + \\ bar: i8, + \\}; + \\ + ); +} + +test "zig fmt: remove empty lines at start/end of block" { + try testTransform( + \\test { + \\ + \\ if (foo) { + \\ foo(); + \\ } + \\ + \\} + \\ + , + \\test { + \\ if (foo) { + \\ foo(); + \\ } + \\} + \\ + ); +} + +test "zig fmt: allow empty line before commment at start of block" { + try testCanonical( + \\test { + \\ + \\ // foo + \\ const x = 42; + \\} + \\ + ); +} + +test "zig fmt: allow empty line before commment at start of block" { + try testCanonical( + \\test { + \\ + \\ // foo + \\ const x = 42; + \\} + \\ + ); +} + test "zig fmt: trailing comma in fn parameter list" { try testCanonical( \\pub fn f( @@ -480,6 +367,31 @@ test "zig fmt: comptime struct field" { ); } +test "zig fmt: break from block" { + try testCanonical( + \\const a = blk: { + \\ break :blk 42; + \\}; + \\const b = blk: { + \\ break :blk; + \\}; + \\const c = { + \\ break 42; + \\}; + \\const d = { + \\ break; + \\}; + \\ + ); +} + +test "zig fmt: grouped expressions (parentheses)" { + try testCanonical( + \\const r = (x + y) * (a + b); + \\ + ); +} + test "zig fmt: c pointer type" { try testCanonical( \\pub extern fn repro() [*c]const u8; @@ -535,6 +447,19 @@ test "zig fmt: anytype struct field" { ); } +test "zig fmt: array types last token" { + try testCanonical( + \\test { + \\ const x = [40]u32; + \\} + \\ + \\test { + \\ const x = [40:0]u32; + \\} + \\ + ); +} + test "zig fmt: sentinel-terminated array type" { try testCanonical( \\pub fn cStrToPrefixedFileW(s: [*:0]const u8) ![PATH_MAX_WIDE:0]u16 { @@ -553,6 +478,58 @@ test "zig fmt: sentinel-terminated slice type" { ); } +test "zig fmt: pointer-to-one with modifiers" { + try testCanonical( + \\const x: *u32 = undefined; + \\const y: *allowzero align(8) const volatile u32 = undefined; + \\const z: *allowzero align(8:4:2) const volatile u32 = undefined; + \\ + ); +} + +test "zig fmt: pointer-to-many with modifiers" { + try testCanonical( + \\const x: [*]u32 = undefined; + \\const y: [*]allowzero align(8) const volatile u32 = undefined; + \\const z: [*]allowzero align(8:4:2) const volatile u32 = undefined; + \\ + ); +} + +test "zig fmt: sentinel pointer with modifiers" { + try testCanonical( + \\const x: [*:42]u32 = undefined; + \\const y: [*:42]allowzero align(8) const volatile u32 = undefined; + \\const y: [*:42]allowzero align(8:4:2) const volatile u32 = undefined; + \\ + ); +} + +test "zig fmt: c pointer with modifiers" { + try testCanonical( + \\const x: [*c]u32 = undefined; + \\const y: [*c]allowzero align(8) const volatile u32 = undefined; + \\const z: [*c]allowzero align(8:4:2) const volatile u32 = undefined; + \\ + ); +} + +test "zig fmt: slice with modifiers" { + try testCanonical( + \\const x: []u32 = undefined; + \\const y: []allowzero align(8) const volatile u32 = undefined; + \\ + ); +} + +test "zig fmt: sentinel slice with modifiers" { + try testCanonical( + \\const x: [:42]u32 = undefined; + \\const y: [:42]allowzero align(8) const volatile u32 = undefined; + \\ + ); +} + test "zig fmt: anon literal in array" { try testCanonical( \\var arr: [2]Foo = .{ @@ -581,19 +558,328 @@ test "zig fmt: alignment in anonymous literal" { ); } -test "zig fmt: anon struct literal syntax" { +test "zig fmt: anon struct literal 0 element" { try testCanonical( - \\const x = .{ - \\ .a = b, - \\ .c = d, - \\}; + \\test { + \\ const x = .{}; + \\} \\ ); } -test "zig fmt: anon list literal syntax" { +test "zig fmt: anon struct literal 1 element" { try testCanonical( - \\const x = .{ a, b, c }; + \\test { + \\ const x = .{ .a = b }; + \\} + \\ + ); +} + +test "zig fmt: anon struct literal 1 element comma" { + try testCanonical( + \\test { + \\ const x = .{ + \\ .a = b, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: anon struct literal 2 element" { + try testCanonical( + \\test { + \\ const x = .{ .a = b, .c = d }; + \\} + \\ + ); +} + +test "zig fmt: anon struct literal 2 element comma" { + try testCanonical( + \\test { + \\ const x = .{ + \\ .a = b, + \\ .c = d, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: anon struct literal 3 element" { + try testCanonical( + \\test { + \\ const x = .{ .a = b, .c = d, .e = f }; + \\} + \\ + ); +} + +test "zig fmt: anon struct literal 3 element comma" { + try testCanonical( + \\test { + \\ const x = .{ + \\ .a = b, + \\ .c = d, + \\ .e = f, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: struct literal 0 element" { + try testCanonical( + \\test { + \\ const x = X{}; + \\} + \\ + ); +} + +test "zig fmt: struct literal 1 element" { + try testCanonical( + \\test { + \\ const x = X{ .a = b }; + \\} + \\ + ); +} + +test "zig fmt: Unicode code point literal larger than u8" { + try testCanonical( + \\test { + \\ const x = X{ + \\ .a = b, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: struct literal 2 element" { + try testCanonical( + \\test { + \\ const x = X{ .a = b, .c = d }; + \\} + \\ + ); +} + +test "zig fmt: struct literal 2 element comma" { + try testCanonical( + \\test { + \\ const x = X{ + \\ .a = b, + \\ .c = d, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: struct literal 3 element" { + try testCanonical( + \\test { + \\ const x = X{ .a = b, .c = d, .e = f }; + \\} + \\ + ); +} + +test "zig fmt: struct literal 3 element comma" { + try testCanonical( + \\test { + \\ const x = X{ + \\ .a = b, + \\ .c = d, + \\ .e = f, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: anon list literal 1 element" { + try testCanonical( + \\test { + \\ const x = .{a}; + \\} + \\ + ); +} + +test "zig fmt: anon list literal 1 element comma" { + try testCanonical( + \\test { + \\ const x = .{ + \\ a, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: anon list literal 2 element" { + try testCanonical( + \\test { + \\ const x = .{ a, b }; + \\} + \\ + ); +} + +test "zig fmt: anon list literal 2 element comma" { + try testCanonical( + \\test { + \\ const x = .{ + \\ a, + \\ b, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: anon list literal 3 element" { + try testCanonical( + \\test { + \\ const x = .{ a, b, c }; + \\} + \\ + ); +} + +test "zig fmt: anon list literal 3 element comma" { + try testCanonical( + \\test { + \\ const x = .{ + \\ a, + \\ // foo + \\ b, + \\ + \\ c, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: array literal 0 element" { + try testCanonical( + \\test { + \\ const x = [_]u32{}; + \\} + \\ + ); +} + +test "zig fmt: array literal 1 element" { + try testCanonical( + \\test { + \\ const x = [_]u32{a}; + \\} + \\ + ); +} + +test "zig fmt: array literal 1 element comma" { + try testCanonical( + \\test { + \\ const x = [1]u32{ + \\ a, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: array literal 2 element" { + try testCanonical( + \\test { + \\ const x = [_]u32{ a, b }; + \\} + \\ + ); +} + +test "zig fmt: array literal 2 element comma" { + try testCanonical( + \\test { + \\ const x = [2]u32{ + \\ a, + \\ b, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: array literal 3 element" { + try testCanonical( + \\test { + \\ const x = [_]u32{ a, b, c }; + \\} + \\ + ); +} + +test "zig fmt: array literal 3 element comma" { + try testCanonical( + \\test { + \\ const x = [3]u32{ + \\ a, + \\ b, + \\ c, + \\ }; + \\} + \\ + ); +} + +test "zig fmt: sentinel array literal 1 element" { + try testCanonical( + \\test { + \\ const x = [_:9000]u32{a}; + \\} + \\ + ); +} + +test "zig fmt: slices" { + try testCanonical( + \\const a = b[0..]; + \\const c = d[0..1]; + \\const e = f[0..1 :0]; + \\ + ); +} + +test "zig fmt: slices with spaces in bounds" { + try testCanonical( + \\const a = b[0 + 0 ..]; + \\const c = d[0 + 0 .. 1]; + \\const e = f[0 .. 1 + 1 :0]; + \\ + ); +} + +test "zig fmt: block in slice expression" { + try testCanonical( + \\const a = b[{ + \\ _ = x; + \\}..]; + \\const c = d[0..{ + \\ _ = x; + \\ _ = y; + \\}]; + \\const e = f[0..1 :{ + \\ _ = x; + \\ _ = y; + \\ _ = z; + \\}]; \\ ); } @@ -651,6 +937,25 @@ test "zig fmt: tagged union with enum values" { ); } +test "zig fmt: tagged union enum tag last token" { + try testCanonical( + \\test { + \\ const U = union(enum(u32)) {}; + \\} + \\ + \\test { + \\ const U = union(enum(u32)) { foo }; + \\} + \\ + \\test { + \\ const U = union(enum(u32)) { + \\ foo, + \\ }; + \\} + \\ + ); +} + test "zig fmt: allowzero pointer" { try testCanonical( \\const T = [*]allowzero const u8; @@ -729,23 +1034,6 @@ test "zig fmt: linksection" { ); } -test "zig fmt: correctly move doc comments on struct fields" { - try testTransform( - \\pub const section_64 = extern struct { - \\ sectname: [16]u8, /// name of this section - \\ segname: [16]u8, /// segment this section goes in - \\}; - , - \\pub const section_64 = extern struct { - \\ /// name of this section - \\ sectname: [16]u8, - \\ /// segment this section goes in - \\ segname: [16]u8, - \\}; - \\ - ); -} - test "zig fmt: correctly space struct fields with doc comments" { try testTransform( \\pub const S = struct { @@ -934,6 +1222,32 @@ test "zig fmt: doc and line comment following 'zig fmt: on'" { ); } +test "zig fmt: 'zig fmt: (off|on)' works in the middle of code" { + try testTransform( + \\test "" { + \\ const x = 42; + \\ + \\ if (foobar) |y| { + \\ // zig fmt: off + \\ }// zig fmt: on + \\ + \\ const z = 420; + \\} + \\ + , + \\test "" { + \\ const x = 42; + \\ + \\ if (foobar) |y| { + \\ // zig fmt: off + \\ }// zig fmt: on + \\ + \\ const z = 420; + \\} + \\ + ); +} + test "zig fmt: pointer of unknown length" { try testCanonical( \\fn foo(ptr: [*]u8) void {} @@ -975,6 +1289,23 @@ test "zig fmt: 2nd arg multiline string" { \\} \\ ); + try testTransform( + \\comptime { + \\ cases.addAsm("hello world linux x86_64", + \\ \\.text + \\ , "Hello, world!\n",); + \\} + , + \\comptime { + \\ cases.addAsm( + \\ "hello world linux x86_64", + \\ \\.text + \\ , + \\ "Hello, world!\n", + \\ ); + \\} + \\ + ); } test "zig fmt: 2nd arg multiline string many args" { @@ -1104,7 +1435,7 @@ test "zig fmt: if condition has line break but must not wrap" { ); } -test "zig fmt: if condition has line break but must not wrap" { +test "zig fmt: if condition has line break but must not wrap (no fn call comma)" { try testCanonical( \\comptime { \\ if (self.user_input_options.put(name, UserInputOption{ @@ -1137,31 +1468,6 @@ test "zig fmt: function call with multiline argument" { ); } -test "zig fmt: same-line doc comment on variable declaration" { - try testTransform( - \\pub const MAP_ANONYMOUS = 0x1000; /// allocated from memory, swap space - \\pub const MAP_FILE = 0x0000; /// map from file (default) - \\ - \\pub const EMEDIUMTYPE = 124; /// Wrong medium type - \\ - \\// nameserver query return codes - \\pub const ENSROK = 0; /// DNS server returned answer with no data - , - \\/// allocated from memory, swap space - \\pub const MAP_ANONYMOUS = 0x1000; - \\/// map from file (default) - \\pub const MAP_FILE = 0x0000; - \\ - \\/// Wrong medium type - \\pub const EMEDIUMTYPE = 124; - \\ - \\// nameserver query return codes - \\/// DNS server returned answer with no data - \\pub const ENSROK = 0; - \\ - ); -} - test "zig fmt: if-else with comment before else" { try testCanonical( \\comptime { @@ -1190,12 +1496,14 @@ test "zig fmt: if nested" { \\ GE_EQUAL \\ else \\ GE_GREATER + \\ // comment \\ else if (aInt > bInt) \\ GE_LESS \\ else if (aInt == bInt) \\ GE_EQUAL \\ else \\ GE_GREATER; + \\ // comment \\} \\ ); @@ -1275,7 +1583,10 @@ test "zig fmt: struct literal no trailing comma" { \\const a = foo{ .x = 1, .y = 2 }; \\const a = foo{ .x = 1, \\ .y = 2 }; + \\const a = foo{ .x = 1, + \\ .y = 2, }; , + \\const a = foo{ .x = 1, .y = 2 }; \\const a = foo{ .x = 1, .y = 2 }; \\const a = foo{ \\ .x = 1, @@ -1291,17 +1602,26 @@ test "zig fmt: struct literal containing a multiline expression" { \\const a = A{ .x = if (f1()) 10 else 20, }; \\const a = A{ .x = if (f1()) \\ 10 else 20 }; + \\const a = A{ .x = if (f1()) + \\ 10 else 20,}; \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100 }; \\const a = A{ .x = if (f1()) 10 else 20, .y = f2() + 100, }; \\const a = A{ .x = if (f1()) \\ 10 else 20}; + \\const a = A{ .x = if (f1()) + \\ 10 else 20,}; \\const a = A{ .x = switch(g) {0 => "ok", else => "no"} }; + \\const a = A{ .x = switch(g) {0 => "ok", else => "no"}, }; \\ , \\const a = A{ .x = if (f1()) 10 else 20 }; \\const a = A{ \\ .x = if (f1()) 10 else 20, \\}; + \\const a = A{ .x = if (f1()) + \\ 10 + \\else + \\ 20 }; \\const a = A{ \\ .x = if (f1()) \\ 10 @@ -1313,12 +1633,20 @@ test "zig fmt: struct literal containing a multiline expression" { \\ .x = if (f1()) 10 else 20, \\ .y = f2() + 100, \\}; + \\const a = A{ .x = if (f1()) + \\ 10 + \\else + \\ 20 }; \\const a = A{ \\ .x = if (f1()) \\ 10 \\ else \\ 20, \\}; + \\const a = A{ .x = switch (g) { + \\ 0 => "ok", + \\ else => "no", + \\} }; \\const a = A{ \\ .x = switch (g) { \\ 0 => "ok", @@ -1368,19 +1696,19 @@ test "zig fmt: array literal with hint" { \\}; , \\const a = []u8{ - \\ 1, 2, + \\ 1, 2, // \\ 3, 4, \\ 5, 6, \\ 7, \\}; \\const a = []u8{ - \\ 1, 2, + \\ 1, 2, // \\ 3, 4, \\ 5, 6, \\ 7, 8, \\}; \\const a = []u8{ - \\ 1, 2, + \\ 1, 2, // \\ 3, 4, \\ 5, \\ 6, // blah @@ -1388,21 +1716,19 @@ test "zig fmt: array literal with hint" { \\ 8, \\}; \\const a = []u8{ - \\ 1, 2, + \\ 1, 2, // \\ 3, // \\ 4, - \\ 5, 6, + \\ 5, + \\ 6, \\ 7, \\}; \\const a = []u8{ \\ 1, \\ 2, - \\ 3, - \\ 4, - \\ 5, - \\ 6, - \\ 7, - \\ 8, + \\ 3, 4, // + \\ 5, 6, // + \\ 7, 8, // \\}; \\ ); @@ -1508,11 +1834,21 @@ test "zig fmt: empty block with only comment" { ); } -test "zig fmt: no trailing comma on struct decl" { - try testCanonical( +test "zig fmt: trailing commas on struct decl" { + try testTransform( \\const RoundParam = struct { \\ k: usize, s: u32, t: u32 \\}; + \\const RoundParam = struct { + \\ k: usize, s: u32, t: u32, + \\}; + , + \\const RoundParam = struct { k: usize, s: u32, t: u32 }; + \\const RoundParam = struct { + \\ k: usize, + \\ s: u32, + \\ t: u32, + \\}; \\ ); } @@ -1560,11 +1896,7 @@ test "zig fmt: simple asm" { \\ : [a] "x" (-> i32) \\ : [a] "x" (1) \\ ); - \\ asm ("still not real assembly" - \\ : - \\ : - \\ : "a", "b" - \\ ); + \\ asm ("still not real assembly" ::: "a", "b"); \\} \\ ); @@ -1581,7 +1913,7 @@ test "zig fmt: nested struct literal with one item" { test "zig fmt: switch cases trailing comma" { try testTransform( - \\fn switch_cases(x: i32) void { + \\test "switch cases trailing comma"{ \\ switch (x) { \\ 1,2,3 => {}, \\ 4,5, => {}, @@ -1590,7 +1922,7 @@ test "zig fmt: switch cases trailing comma" { \\ } \\} , - \\fn switch_cases(x: i32) void { + \\test "switch cases trailing comma" { \\ switch (x) { \\ 1, 2, 3 => {}, \\ 4, @@ -1657,18 +1989,18 @@ test "zig fmt: line comment after doc comment" { ); } -test "zig fmt: float literal with exponent" { +test "zig fmt: bit field alignment" { try testCanonical( - \\test "bit field alignment" { + \\test { \\ assert(@TypeOf(&blah.b) == *align(1:3:6) const u3); \\} \\ ); } -test "zig fmt: float literal with exponent" { +test "zig fmt: nested switch" { try testCanonical( - \\test "aoeu" { + \\test { \\ switch (state) { \\ TermState.Start => switch (c) { \\ '\x1b' => state = TermState.Escape, @@ -1679,6 +2011,7 @@ test "zig fmt: float literal with exponent" { \\ ); } + test "zig fmt: float literal with exponent" { try testCanonical( \\pub const f64_true_min = 4.94065645841246544177e-324; @@ -2135,7 +2468,7 @@ test "zig fmt: preserve spacing" { test "zig fmt: return types" { try testCanonical( \\pub fn main() !void {} - \\pub fn main() anytype {} + \\pub fn main() FooBar {} \\pub fn main() i32 {} \\ ); @@ -2207,6 +2540,33 @@ test "zig fmt: return" { ); } +test "zig fmt: function attributes" { + try testCanonical( + \\export fn foo() void {} + \\pub export fn foo() void {} + \\extern fn foo() void; + \\pub extern fn foo() void; + \\extern "c" fn foo() void; + \\pub extern "c" fn foo() void; + \\noinline fn foo() void {} + \\pub noinline fn foo() void {} + \\ + ); +} + +test "zig fmt: nested pointers with ** tokens" { + try testCanonical( + \\const x: *u32 = undefined; + \\const x: **u32 = undefined; + \\const x: ***u32 = undefined; + \\const x: ****u32 = undefined; + \\const x: *****u32 = undefined; + \\const x: ******u32 = undefined; + \\const x: *******u32 = undefined; + \\ + ); +} + test "zig fmt: pointer attributes" { try testCanonical( \\extern fn f1(s: *align(*u8) u8) c_int; @@ -2220,11 +2580,11 @@ test "zig fmt: pointer attributes" { test "zig fmt: slice attributes" { try testCanonical( - \\extern fn f1(s: *align(*u8) u8) c_int; - \\extern fn f2(s: **align(1) *const *volatile u8) c_int; - \\extern fn f3(s: *align(1) const *align(1) volatile *const volatile u8) c_int; - \\extern fn f4(s: *align(1) const volatile u8) c_int; - \\extern fn f5(s: [*:0]align(1) const volatile u8) c_int; + \\extern fn f1(s: []align(*u8) u8) c_int; + \\extern fn f2(s: []align(1) []const []volatile u8) c_int; + \\extern fn f3(s: []align(1) const [:0]align(1) volatile []const volatile u8) c_int; + \\extern fn f4(s: []align(1) const volatile u8) c_int; + \\extern fn f5(s: [:0]align(1) const volatile u8) c_int; \\ ); } @@ -2241,7 +2601,7 @@ test "zig fmt: test declaration" { test "zig fmt: infix operators" { try testCanonical( - \\test "infix operators" { + \\test { \\ var i = undefined; \\ i = 2; \\ i *= 2; @@ -2345,7 +2705,7 @@ test "zig fmt: call expression" { test "zig fmt: anytype type" { try testCanonical( - \\fn print(args: anytype) anytype {} + \\fn print(args: anytype) @This() {} \\ ); } @@ -2355,17 +2715,17 @@ test "zig fmt: functions" { \\extern fn puts(s: *const u8) c_int; \\extern "c" fn puts(s: *const u8) c_int; \\export fn puts(s: *const u8) c_int; - \\inline fn puts(s: *const u8) c_int; + \\fn puts(s: *const u8) callconv(.Inline) c_int; \\noinline fn puts(s: *const u8) c_int; \\pub extern fn puts(s: *const u8) c_int; \\pub extern "c" fn puts(s: *const u8) c_int; \\pub export fn puts(s: *const u8) c_int; - \\pub inline fn puts(s: *const u8) c_int; + \\pub fn puts(s: *const u8) callconv(.Inline) c_int; \\pub noinline fn puts(s: *const u8) c_int; \\pub extern fn puts(s: *const u8) align(2 + 2) c_int; \\pub extern "c" fn puts(s: *const u8) align(2 + 2) c_int; \\pub export fn puts(s: *const u8) align(2 + 2) c_int; - \\pub inline fn puts(s: *const u8) align(2 + 2) c_int; + \\pub fn puts(s: *const u8) align(2 + 2) callconv(.Inline) c_int; \\pub noinline fn puts(s: *const u8) align(2 + 2) c_int; \\ ); @@ -2570,7 +2930,11 @@ test "zig fmt: catch" { \\test "catch" { \\ const a: anyerror!u8 = 0; \\ _ = a catch return; + \\ _ = a catch + \\ return; \\ _ = a catch |err| return; + \\ _ = a catch |err| + \\ return; \\} \\ ); @@ -2746,12 +3110,6 @@ test "zig fmt: for" { \\ d => {}, \\ }; \\ - \\ for (a) |b| - \\ switch (b) { - \\ c => {}, - \\ d => {}, - \\ }; - \\ \\ const res = for (a) |v, i| { \\ break v; \\ } else { @@ -2777,7 +3135,8 @@ test "zig fmt: for" { \\test "fix for" { \\ for (a) |x| \\ f(x) - \\ else continue; + \\ else + \\ continue; \\} \\ ); @@ -2948,7 +3307,7 @@ test "zig fmt: nosuspend" { test "zig fmt: Block after if" { try testCanonical( - \\test "Block after if" { + \\test { \\ if (true) { \\ const a = 0; \\ } @@ -2961,7 +3320,7 @@ test "zig fmt: Block after if" { ); } -test "zig fmt: use" { +test "zig fmt: usingnamespace" { try testCanonical( \\usingnamespace @import("std"); \\pub usingnamespace @import("std"); @@ -3025,10 +3384,7 @@ test "zig fmt: inline asm parameter alignment" { \\ asm volatile ( \\ \\ foo \\ \\ bar - \\ : - \\ : - \\ : "", "" - \\ ); + \\ ::: "", ""); \\ asm volatile ( \\ \\ foo \\ \\ bar @@ -3087,16 +3443,12 @@ test "zig fmt: file ends with struct field" { } test "zig fmt: comment after empty comment" { - try testTransform( + try testCanonical( \\const x = true; // \\// \\// \\//a \\ - , - \\const x = true; - \\//a - \\ ); } @@ -3113,7 +3465,8 @@ test "zig fmt: line comment in array" { , \\test "a" { \\ var arr = [_]u32{ - \\ 0, // 1, + \\ 0, + \\ // 1, \\ // 2, \\ }; \\} @@ -3141,7 +3494,8 @@ test "zig fmt: comment after params" { \\ , \\fn a( - \\ b: u32, // c: u32, + \\ b: u32, + \\ // c: u32, \\ // d: u32, \\) void {} \\ @@ -3174,13 +3528,17 @@ test "zig fmt: comment in array initializer/access" { \\ var c = b[ //aa \\ 0 \\ ]; - \\ var d = [_ + \\ var d = [ + \\ _ \\ //aa + \\ : + \\ 0 \\ ]x{ //aa \\ //bb \\ 9, \\ }; - \\ var e = d[0 + \\ var e = d[ + \\ 0 \\ //aa \\ ]; \\} @@ -3199,7 +3557,8 @@ test "zig fmt: comments at several places in struct init" { , \\var bar = Bar{ \\ .x = 10, // test - \\ .y = "test", // test + \\ .y = "test", + \\ // test \\}; \\ ); @@ -3214,7 +3573,7 @@ test "zig fmt: comments at several places in struct init" { ); } -test "zig fmt: top level doc comments" { +test "zig fmt: container doc comments" { try testCanonical( \\//! tld 1 \\//! tld 2 @@ -3235,25 +3594,25 @@ test "zig fmt: top level doc comments" { \\ //! B tld 2 \\ //! B tld 3 \\ - \\ /// b doc + \\ /// B doc \\ b: u32, \\}; \\ \\/// C doc - \\const C = struct { + \\const C = union(enum) { // comment \\ //! C tld 1 \\ //! C tld 2 \\ //! C tld 3 + \\}; \\ - \\ /// c1 doc - \\ c1: u32, + \\/// D doc + \\const D = union(Foo) { + \\ //! D tld 1 + \\ //! D tld 2 + \\ //! D tld 3 \\ - \\ //! C tld 4 - \\ //! C tld 5 - \\ //! C tld 6 - \\ - \\ /// c2 doc - \\ c2: u32, + \\ /// D doc + \\ b: u32, \\}; \\ ); @@ -3275,8 +3634,31 @@ test "zig fmt: extern without container keyword returns error" { \\const container = extern {}; \\ , &[_]Error{ - .ExpectedExpr, - .ExpectedVarDeclOrFn, + .expected_container, + }); +} + +test "zig fmt: same line doc comment returns error" { + try testError( + \\const Foo = struct{ + \\ bar: u32, /// comment + \\ foo: u32, /// comment + \\ /// commment + \\}; + \\ + \\const a = 42; /// comment + \\ + \\extern fn foo() void; /// comment + \\ + \\/// comment + \\ + , &[_]Error{ + .same_line_doc_comment, + .same_line_doc_comment, + .unattached_doc_comment, + .same_line_doc_comment, + .same_line_doc_comment, + .unattached_doc_comment, }); } @@ -3350,26 +3732,6 @@ test "zig fmt: hexadeciaml float literals with underscore separators" { ); } -test "zig fmt: convert async fn into callconv(.Async)" { - try testTransform( - \\async fn foo() void {} - , - \\fn foo() callconv(.Async) void {} - \\ - ); -} - -test "zig fmt: convert extern fn proto into callconv(.C)" { - try testTransform( - \\extern fn foo0() void {} - \\const foo1 = extern fn () void; - , - \\extern fn foo0() void {} - \\const foo1 = fn () callconv(.C) void; - \\ - ); -} - test "zig fmt: C var args" { try testCanonical( \\pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; @@ -3458,6 +3820,54 @@ test "zig fmt: test comments in field access chain" { ); } +test "zig fmt: allow line break before field access" { + try testCanonical( + \\test { + \\ const w = foo.bar().zippy(zag).iguessthisisok(); + \\ + \\ const x = foo + \\ .bar() + \\ . // comment + \\ // comment + \\ swooop().zippy(zag) + \\ .iguessthisisok(); + \\ + \\ const y = view.output.root.server.input_manager.default_seat.wlr_seat.name; + \\ + \\ const z = view.output.root.server + \\ .input_manager // + \\ .default_seat + \\ . // comment + \\ // another comment + \\ wlr_seat.name; + \\} + \\ + ); + try testTransform( + \\test { + \\ const x = foo. + \\ bar() + \\ .zippy(zag).iguessthisisok(); + \\ + \\ const z = view.output.root.server. + \\ input_manager. + \\ default_seat.wlr_seat.name; + \\} + \\ + , + \\test { + \\ const x = foo + \\ .bar() + \\ .zippy(zag).iguessthisisok(); + \\ + \\ const z = view.output.root.server + \\ .input_manager + \\ .default_seat.wlr_seat.name; + \\} + \\ + ); +} + test "zig fmt: Indent comma correctly after multiline string literals in arg list (trailing comma)" { try testCanonical( \\fn foo() void { @@ -3495,8 +3905,7 @@ test "zig fmt: Control flow statement as body of blockless if" { \\ \\ const zoom_node = if (focused_node == layout_first) while (it.next()) |node| { \\ if (!node.view.pending.float and !node.view.pending.fullscreen) break node; - \\ } else null else - \\ focused_node; + \\ } else null else focused_node; \\ \\ const zoom_node = if (focused_node == layout_first) \\ if (it.next()) { @@ -3513,14 +3922,13 @@ test "zig fmt: Control flow statement as body of blockless if" { \\ \\ const zoom_node = if (focused_node == layout_first) switch (nodes) { \\ 0 => 0, - \\ } else - \\ focused_node; + \\ } else focused_node; \\} \\ ); } -test "zig fmt: " { +test "zig fmt: regression test for #5722" { try testCanonical( \\pub fn sendViewTags(self: Self) void { \\ var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32)); @@ -3580,8 +3988,8 @@ test "zig fmt: multiline string literals should play nice with array initializer \\ 0, \\ }}}}}}}}; \\ myFunc(.{ - \\ "aaaaaaa", "bbbbbb", "ccccc", - \\ "dddd", ("eee"), ("fff"), + \\ "aaaaaaa", "bbbbbb", "ccccc", + \\ "dddd", ("eee"), ("fff"), \\ ("gggg"), \\ // Line comment \\ \\Multiline String Literals can be quite long @@ -3610,9 +4018,11 @@ test "zig fmt: multiline string literals should play nice with array initializer \\ ( \\ \\ xxx \\ ), - \\ "xxx", "xxx", + \\ "xxx", + \\ "xxx", \\ }, - \\ .{ "xxxxxxx", "xxx", "xxx", "xxx" }, .{ "xxxxxxx", "xxx", "xxx", "xxx" }, + \\ .{ "xxxxxxx", "xxx", "xxx", "xxx" }, + \\ .{ "xxxxxxx", "xxx", "xxx", "xxx" }, \\ "aaaaaaa", "bbbbbb", "ccccc", // - \\ "dddd", ("eee"), ("fff"), \\ .{ @@ -3620,7 +4030,8 @@ test "zig fmt: multiline string literals should play nice with array initializer \\ ( \\ \\ xxx \\ ), - \\ "xxxxxxxxxxxxxx", "xxx", + \\ "xxxxxxxxxxxxxx", + \\ "xxx", \\ }, \\ .{ \\ ( @@ -3636,10 +4047,10 @@ test "zig fmt: multiline string literals should play nice with array initializer ); } -test "zig fmt: use of comments and Multiline string literals may force the parameters over multiple lines" { +test "zig fmt: use of comments and multiline string literals may force the parameters over multiple lines" { try testCanonical( \\pub fn makeMemUndefined(qzz: []u8) i1 { - \\ cases.add( // fixed bug #2032 + \\ cases.add( // fixed bug foo \\ "compile diagnostic string for top level decl type", \\ \\export fn entry() void { \\ \\ var foo: u32 = @This(){}; @@ -3661,7 +4072,7 @@ test "zig fmt: use of comments and Multiline string literals may force the param \\const rparen = tree.prevToken( \\// the first token for the annotation expressions is the left \\// parenthesis, hence the need for two prevToken - \\ if (fn_proto.getAlignExpr()) |align_expr| + \\if (fn_proto.getAlignExpr()) |align_expr| \\ tree.prevToken(tree.prevToken(align_expr.firstToken())) \\else if (fn_proto.getSectionExpr()) |section_expr| \\ tree.prevToken(tree.prevToken(section_expr.firstToken())) @@ -3714,7 +4125,7 @@ test "zig fmt: function params should align nicely" { \\pub fn foo() void { \\ cases.addRuntimeSafety("slicing operator with sentinel", \\ \\const std = @import("std"); - \\ ++ check_panic_msg ++ + \\ ++ check_panic_msg ++ \\ \\pub fn main() void { \\ \\ var buf = [4]u8{'a','b','c',0}; \\ \\ const slice = buf[0..:0]; @@ -3725,6 +4136,419 @@ test "zig fmt: function params should align nicely" { ); } +test "zig fmt: fn proto end with anytype and comma" { + try testCanonical( + \\pub fn format( + \\ out_stream: anytype, + \\) !void {} + \\ + ); +} + +test "zig fmt: space after top level doc comment" { + try testCanonical( + \\//! top level doc comment + \\ + \\field: i32, + \\ + ); +} + +test "zig fmt: for loop with ptr payload and index" { + try testCanonical( + \\test { + \\ for (self.entries.items) |*item, i| {} + \\ for (self.entries.items) |*item, i| + \\ a = b; + \\ for (self.entries.items) |*item, i| a = b; + \\} + \\ + ); +} + +test "zig fmt: proper indent line comment after multi-line single expr while loop" { + try testCanonical( + \\test { + \\ while (a) : (b) + \\ foo(); + \\ + \\ // bar + \\ baz(); + \\} + \\ + ); +} + +test "zig fmt: function with labeled block as return type" { + try testCanonical( + \\fn foo() t: { + \\ break :t bar; + \\} { + \\ baz(); + \\} + \\ + ); +} + +test "zig fmt: extern function with missing param name" { + try testCanonical( + \\extern fn a( + \\ *b, + \\ c: *d, + \\) e; + \\extern fn f(*g, h: *i) j; + \\ + ); +} + +test "zig fmt: line comment after multiline single expr if statement with multiline string" { + try testCanonical( + \\test { + \\ if (foo) + \\ x = + \\ \\hello + \\ \\hello + \\ \\ + \\ ; + \\ + \\ // bar + \\ baz(); + \\ + \\ if (foo) + \\ x = + \\ \\hello + \\ \\hello + \\ \\ + \\ else + \\ y = + \\ \\hello + \\ \\hello + \\ \\ + \\ ; + \\ + \\ // bar + \\ baz(); + \\} + \\ + ); +} + +test "zig fmt: respect extra newline between fn and pub usingnamespace" { + try testCanonical( + \\fn foo() void { + \\ bar(); + \\} + \\ + \\pub usingnamespace baz; + \\ + ); +} + +test "zig fmt: respect extra newline between switch items" { + try testCanonical( + \\const a = switch (b) { + \\ .c => {}, + \\ + \\ .d, + \\ .e, + \\ => f, + \\}; + \\ + ); +} + +test "zig fmt: insert trailing comma if there are comments between switch values" { + try testTransform( + \\const a = switch (b) { + \\ .c => {}, + \\ + \\ .d, // foobar + \\ .e + \\ => f, + \\ + \\ .g, .h + \\ // comment + \\ => i, + \\}; + \\ + , + \\const a = switch (b) { + \\ .c => {}, + \\ + \\ .d, // foobar + \\ .e, + \\ => f, + \\ + \\ .g, + \\ .h, + \\ // comment + \\ => i, + \\}; + \\ + ); +} + +test "zig fmt: error for invalid bit range" { + try testError( + \\var x: []align(0:0:0)u8 = bar; + , &[_]Error{ + .invalid_bit_range, + }); +} + +test "zig fmt: error for invalid align" { + try testError( + \\var x: [10]align(10)u8 = bar; + , &[_]Error{ + .invalid_align, + }); +} + +test "recovery: top level" { + try testError( + \\test "" {inline} + \\test "" {inline} + , &[_]Error{ + .expected_inlinable, + .expected_inlinable, + }); +} + +test "recovery: block statements" { + try testError( + \\test "" { + \\ foo + +; + \\ inline; + \\} + , &[_]Error{ + .invalid_token, + .expected_inlinable, + }); +} + +test "recovery: missing comma" { + try testError( + \\test "" { + \\ switch (foo) { + \\ 2 => {} + \\ 3 => {} + \\ else => { + \\ foo && bar +; + \\ } + \\ } + \\} + , &[_]Error{ + .expected_token, + .expected_token, + .invalid_and, + .invalid_token, + }); +} + +test "recovery: extra qualifier" { + try testError( + \\const a: *const const u8; + \\test "" + , &[_]Error{ + .extra_const_qualifier, + .expected_block, + }); +} + +test "recovery: missing return type" { + try testError( + \\fn foo() { + \\ a && b; + \\} + \\test "" + , &[_]Error{ + .expected_return_type, + .invalid_and, + .expected_block, + }); +} + +test "recovery: continue after invalid decl" { + try testError( + \\fn foo { + \\ inline; + \\} + \\pub test "" { + \\ async a && b; + \\} + , &[_]Error{ + .expected_token, + .expected_pub_item, + .expected_param_list, + .invalid_and, + }); + try testError( + \\threadlocal test "" { + \\ @a && b; + \\} + , &[_]Error{ + .expected_var_decl, + .expected_param_list, + .invalid_and, + }); +} + +test "recovery: invalid extern/inline" { + try testError( + \\inline test "" { a && b; } + , &[_]Error{ + .expected_fn, + .invalid_and, + }); + try testError( + \\extern "" test "" { a && b; } + , &[_]Error{ + .expected_var_decl_or_fn, + .invalid_and, + }); +} + +test "recovery: missing semicolon" { + try testError( + \\test "" { + \\ comptime a && b + \\ c && d + \\ @foo + \\} + , &[_]Error{ + .invalid_and, + .expected_token, + .invalid_and, + .expected_token, + .expected_param_list, + .expected_token, + }); +} + +test "recovery: invalid container members" { + try testError( + \\usingnamespace; + \\foo+ + \\bar@, + \\while (a == 2) { test "" {}} + \\test "" { + \\ a && b + \\} + , &[_]Error{ + .expected_expr, + .expected_token, + .expected_container_members, + .invalid_and, + .expected_token, + }); +} + +// TODO after https://github.com/ziglang/zig/issues/35 is implemented, +// we should be able to recover from this *at any indentation level*, +// reporting a parse error and yet also parsing all the decls even +// inside structs. +test "recovery: extra '}' at top level" { + try testError( + \\}}} + \\test "" { + \\ a && b; + \\} + , &[_]Error{ + .expected_token, + }); +} + +test "recovery: mismatched bracket at top level" { + try testError( + \\const S = struct { + \\ arr: 128]?G + \\}; + , &[_]Error{ + .expected_token, + }); +} + +test "recovery: invalid global error set access" { + try testError( + \\test "" { + \\ error && foo; + \\} + , &[_]Error{ + .expected_token, + .expected_token, + .invalid_and, + }); +} + +test "recovery: invalid asterisk after pointer dereference" { + try testError( + \\test "" { + \\ var sequence = "repeat".*** 10; + \\} + , &[_]Error{ + .asterisk_after_ptr_deref, + }); + try testError( + \\test "" { + \\ var sequence = "repeat".** 10&&a; + \\} + , &[_]Error{ + .asterisk_after_ptr_deref, + .invalid_and, + }); +} + +test "recovery: missing semicolon after if, for, while stmt" { + try testError( + \\test "" { + \\ if (foo) bar + \\ for (foo) |a| bar + \\ while (foo) bar + \\ a && b; + \\} + , &[_]Error{ + .expected_semi_or_else, + .expected_semi_or_else, + .expected_semi_or_else, + .invalid_and, + }); +} + +test "recovery: invalid comptime" { + try testError( + \\comptime + , &[_]Error{ + .expected_block_or_field, + }); +} + +test "recovery: missing block after for/while loops" { + try testError( + \\test "" { while (foo) } + , &[_]Error{ + .expected_block_or_assignment, + }); + try testError( + \\test "" { for (foo) |bar| } + , &[_]Error{ + .expected_block_or_assignment, + }); +} + +test "recovery: missing for payload" { + try testError( + \\comptime { + \\ const a = for(a) {}; + \\ const a: for(a) {}; + \\ for(a) {} + \\} + , &[_]Error{ + .expected_loop_payload, + .expected_loop_payload, + .expected_loop_payload, + }); +} + const std = @import("std"); const mem = std.mem; const warn = std.debug.warn; @@ -3734,29 +4558,23 @@ const maxInt = std.math.maxInt; var fixed_buffer_mem: [100 * 1024]u8 = undefined; fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *bool) ![]u8 { - const stderr = io.getStdErr().outStream(); + const stderr = io.getStdErr().writer(); - const tree = try std.zig.parse(allocator, source); - defer tree.deinit(); + var tree = try std.zig.parse(allocator, source); + defer tree.deinit(allocator); - for (tree.errors) |*parse_error| { - const token = tree.token_locs[parse_error.loc()]; - const loc = tree.tokenLocation(0, parse_error.loc()); - try stderr.print("(memory buffer):{}:{}: error: ", .{ loc.line + 1, loc.column + 1 }); + for (tree.errors) |parse_error| { + const token_start = tree.tokens.items(.start)[parse_error.token]; + const loc = tree.tokenLocation(0, parse_error.token); + try stderr.print("(memory buffer):{d}:{d}: error: ", .{ loc.line + 1, loc.column + 1 }); try tree.renderError(parse_error, stderr); - try stderr.print("\n{}\n", .{source[loc.line_start..loc.line_end]}); + try stderr.print("\n{s}\n", .{source[loc.line_start..loc.line_end]}); { var i: usize = 0; while (i < loc.column) : (i += 1) { try stderr.writeAll(" "); } - } - { - const caret_count = token.end - token.start; - var i: usize = 0; - while (i < caret_count) : (i += 1) { - try stderr.writeAll("~"); - } + try stderr.writeAll("^"); } try stderr.writeAll("\n"); } @@ -3764,12 +4582,9 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b return error.ParseError; } - var buffer = std.ArrayList(u8).init(allocator); - errdefer buffer.deinit(); - - const outStream = buffer.outStream(); - anything_changed.* = try std.zig.render(allocator, outStream, tree); - return buffer.toOwnedSlice(); + const formatted = try tree.render(allocator); + anything_changed.* = !mem.eql(u8, formatted, source); + return formatted; } fn testTransform(source: []const u8, expected_source: []const u8) !void { const needed_alloc_count = x: { @@ -3800,7 +4615,7 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void { error.OutOfMemory => { if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) { warn( - "\nfail_index: {}/{}\nallocated bytes: {}\nfreed bytes: {}\nallocations: {}\ndeallocations: {}\n", + "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\n", .{ fail_index, needed_alloc_count, @@ -3822,14 +4637,14 @@ fn testCanonical(source: []const u8) !void { return testTransform(source, source); } -const Error = @TagType(std.zig.ast.Error); +const Error = std.zig.ast.Error.Tag; fn testError(source: []const u8, expected_errors: []const Error) !void { - const tree = try std.zig.parse(std.testing.allocator, source); - defer tree.deinit(); + var tree = try std.zig.parse(std.testing.allocator, source); + defer tree.deinit(std.testing.allocator); std.testing.expect(tree.errors.len == expected_errors.len); for (expected_errors) |expected, i| { - std.testing.expect(expected == tree.errors[i]); + std.testing.expectEqual(expected, tree.errors[i].tag); } } diff --git a/lib/std/zig/perf_test.zig b/lib/std/zig/perf_test.zig index 30ae99e57c..b111170902 100644 --- a/lib/std/zig/perf_test.zig +++ b/lib/std/zig/perf_test.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -29,7 +29,7 @@ pub fn main() !void { const mb_per_sec = bytes_per_sec / (1024 * 1024); var stdout_file = std.io.getStdOut(); - const stdout = stdout_file.outStream(); + const stdout = stdout_file.writer(); try stdout.print("{:.3} MiB/s, {} KiB used \n", .{ mb_per_sec, memory_used / 1024 }); } diff --git a/lib/std/zig/render.zig b/lib/std/zig/render.zig index f73979aa6b..e12f7bc733 100644 --- a/lib/std/zig/render.zig +++ b/lib/std/zig/render.zig @@ -1,11 +1,12 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. const std = @import("../std.zig"); const assert = std.debug.assert; const mem = std.mem; +const Allocator = std.mem.Allocator; const meta = std.meta; const ast = std.zig.ast; const Token = std.zig.Token; @@ -13,2654 +14,2557 @@ const Token = std.zig.Token; const indent_delta = 4; const asm_indent_delta = 2; -pub const Error = error{ - /// Ran out of memory allocating call stack frames to complete rendering. - OutOfMemory, -}; +pub const Error = ast.Tree.RenderError; -/// Returns whether anything changed -pub fn render(allocator: *mem.Allocator, stream: anytype, tree: *ast.Tree) (@TypeOf(stream).Error || Error)!bool { - // cannot render an invalid tree - std.debug.assert(tree.errors.len == 0); +const Ais = AutoIndentingStream(std.ArrayList(u8).Writer); - var change_detection_stream = std.io.changeDetectionStream(tree.source, stream); - var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, change_detection_stream.writer()); +pub fn renderTree(buffer: *std.ArrayList(u8), tree: ast.Tree) Error!void { + assert(tree.errors.len == 0); // Cannot render an invalid tree. + var auto_indenting_stream = Ais{ + .indent_delta = indent_delta, + .underlying_writer = buffer.writer(), + }; + const ais = &auto_indenting_stream; - try renderRoot(allocator, &auto_indenting_stream, tree); + // Render all the line comments at the beginning of the file. + const comment_end_loc = tree.tokens.items(.start)[0]; + _ = try renderComments(ais, tree, 0, comment_end_loc); - return change_detection_stream.changeDetected(); -} - -fn renderRoot( - allocator: *mem.Allocator, - ais: anytype, - tree: *ast.Tree, -) (@TypeOf(ais.*).Error || Error)!void { - - // render all the line comments at the beginning of the file - for (tree.token_ids) |token_id, i| { - if (token_id != .LineComment) break; - const token_loc = tree.token_locs[i]; - try ais.writer().print("{}\n", .{mem.trimRight(u8, tree.tokenSliceLoc(token_loc), " ")}); - const next_token = tree.token_locs[i + 1]; - const loc = tree.tokenLocationLoc(token_loc.end, next_token); - if (loc.line >= 2) { - try ais.insertNewline(); - } + if (tree.tokens.items(.tag)[0] == .container_doc_comment) { + try renderContainerDocComments(ais, tree, 0); } - var decl_i: ast.NodeIndex = 0; - const root_decls = tree.root_node.decls(); + try renderMembers(buffer.allocator, ais, tree, tree.rootDecls()); - if (root_decls.len == 0) return; - while (true) { - var decl = root_decls[decl_i]; + if (ais.disabled_offset) |disabled_offset| { + try writeFixingWhitespace(ais.underlying_writer, tree.source[disabled_offset..]); + } +} - // This loop does the following: - // - // - Iterates through line/doc comment tokens that precedes the current - // decl. - // - Figures out the first token index (`copy_start_token_index`) which - // hasn't been copied to the output stream yet. - // - Detects `zig fmt: (off|on)` in the line comment tokens, and - // determines whether the current decl should be reformatted or not. - // - var token_index = decl.firstToken(); - var fmt_active = true; - var found_fmt_directive = false; +/// Render all members in the given slice, keeping empty lines where appropriate +fn renderMembers(gpa: *Allocator, ais: *Ais, tree: ast.Tree, members: []const ast.Node.Index) Error!void { + if (members.len == 0) return; + try renderMember(gpa, ais, tree, members[0], .newline); + for (members[1..]) |member| { + try renderExtraNewline(ais, tree, member); + try renderMember(gpa, ais, tree, member, .newline); + } +} - var copy_start_token_index = token_index; +fn renderMember(gpa: *Allocator, ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) Error!void { + const token_tags = tree.tokens.items(.tag); + const main_tokens = tree.nodes.items(.main_token); + const datas = tree.nodes.items(.data); + try renderDocComments(ais, tree, tree.firstToken(decl)); + switch (tree.nodes.items(.tag)[decl]) { + .fn_decl => { + // Some examples: + // pub extern "foo" fn ... + // export fn ... + const fn_proto = datas[decl].lhs; + const fn_token = main_tokens[fn_proto]; + // Go back to the first token we should render here. + var i = fn_token; + while (i > 0) { + i -= 1; + switch (token_tags[i]) { + .keyword_extern, + .keyword_export, + .keyword_pub, + .string_literal, + .keyword_inline, + .keyword_noinline, + => continue, - while (token_index != 0) { - token_index -= 1; - const token_id = tree.token_ids[token_index]; - switch (token_id) { - .LineComment => {}, - .DocComment => { - copy_start_token_index = token_index; - continue; - }, - else => break, - } - - const token_loc = tree.token_locs[token_index]; - if (mem.eql(u8, mem.trim(u8, tree.tokenSliceLoc(token_loc)[2..], " "), "zig fmt: off")) { - if (!found_fmt_directive) { - fmt_active = false; - found_fmt_directive = true; - } - } else if (mem.eql(u8, mem.trim(u8, tree.tokenSliceLoc(token_loc)[2..], " "), "zig fmt: on")) { - if (!found_fmt_directive) { - fmt_active = true; - found_fmt_directive = true; - } - } - } - - if (!fmt_active) { - // Reformatting is disabled for the current decl and possibly some - // more decls that follow. - // Find the next `decl` for which reformatting is re-enabled. - token_index = decl.firstToken(); - - while (!fmt_active) { - decl_i += 1; - if (decl_i >= root_decls.len) { - // If there's no next reformatted `decl`, just copy the - // remaining input tokens and bail out. - const start = tree.token_locs[copy_start_token_index].start; - try copyFixingWhitespace(ais, tree.source[start..]); - return; - } - decl = root_decls[decl_i]; - var decl_first_token_index = decl.firstToken(); - - while (token_index < decl_first_token_index) : (token_index += 1) { - const token_id = tree.token_ids[token_index]; - switch (token_id) { - .LineComment => {}, - .Eof => unreachable, - else => continue, - } - const token_loc = tree.token_locs[token_index]; - if (mem.eql(u8, mem.trim(u8, tree.tokenSliceLoc(token_loc)[2..], " "), "zig fmt: on")) { - fmt_active = true; - } else if (mem.eql(u8, mem.trim(u8, tree.tokenSliceLoc(token_loc)[2..], " "), "zig fmt: off")) { - fmt_active = false; - } - } - } - - // Found the next `decl` for which reformatting is enabled. Copy - // the input tokens before the `decl` that haven't been copied yet. - var copy_end_token_index = decl.firstToken(); - token_index = copy_end_token_index; - while (token_index != 0) { - token_index -= 1; - const token_id = tree.token_ids[token_index]; - switch (token_id) { - .LineComment => {}, - .DocComment => { - copy_end_token_index = token_index; - continue; + else => { + i += 1; + break; }, - else => break, } } - - const start = tree.token_locs[copy_start_token_index].start; - const end = tree.token_locs[copy_end_token_index].start; - try copyFixingWhitespace(ais, tree.source[start..end]); - } - - try renderTopLevelDecl(allocator, ais, tree, decl); - decl_i += 1; - if (decl_i >= root_decls.len) return; - try renderExtraNewline(tree, ais, root_decls[decl_i]); - } -} - -fn renderExtraNewline(tree: *ast.Tree, ais: anytype, node: *ast.Node) @TypeOf(ais.*).Error!void { - return renderExtraNewlineToken(tree, ais, node.firstToken()); -} - -fn renderExtraNewlineToken( - tree: *ast.Tree, - ais: anytype, - first_token: ast.TokenIndex, -) @TypeOf(ais.*).Error!void { - var prev_token = first_token; - if (prev_token == 0) return; - var newline_threshold: usize = 2; - while (tree.token_ids[prev_token - 1] == .DocComment) { - if (tree.tokenLocation(tree.token_locs[prev_token - 1].end, prev_token).line == 1) { - newline_threshold += 1; - } - prev_token -= 1; - } - const prev_token_end = tree.token_locs[prev_token - 1].end; - const loc = tree.tokenLocation(prev_token_end, first_token); - if (loc.line >= newline_threshold) { - try ais.insertNewline(); - } -} - -fn renderTopLevelDecl(allocator: *mem.Allocator, ais: anytype, tree: *ast.Tree, decl: *ast.Node) (@TypeOf(ais.*).Error || Error)!void { - try renderContainerDecl(allocator, ais, tree, decl, .Newline); -} - -fn renderContainerDecl(allocator: *mem.Allocator, ais: anytype, tree: *ast.Tree, decl: *ast.Node, space: Space) (@TypeOf(ais.*).Error || Error)!void { - switch (decl.tag) { - .FnProto => { - const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl); - - try renderDocComments(tree, ais, fn_proto, fn_proto.getDocComments()); - - if (fn_proto.getBodyNode()) |body_node| { - try renderExpression(allocator, ais, tree, decl, .Space); - try renderExpression(allocator, ais, tree, body_node, space); - } else { - try renderExpression(allocator, ais, tree, decl, .None); - try renderToken(tree, ais, tree.nextToken(decl.lastToken()), space); - } - }, - - .Use => { - const use_decl = @fieldParentPtr(ast.Node.Use, "base", decl); - - if (use_decl.visib_token) |visib_token| { - try renderToken(tree, ais, visib_token, .Space); // pub - } - try renderToken(tree, ais, use_decl.use_token, .Space); // usingnamespace - try renderExpression(allocator, ais, tree, use_decl.expr, .None); - try renderToken(tree, ais, use_decl.semicolon_token, space); // ; - }, - - .VarDecl => { - const var_decl = @fieldParentPtr(ast.Node.VarDecl, "base", decl); - - try renderDocComments(tree, ais, var_decl, var_decl.getDocComments()); - try renderVarDecl(allocator, ais, tree, var_decl); - }, - - .TestDecl => { - const test_decl = @fieldParentPtr(ast.Node.TestDecl, "base", decl); - - try renderDocComments(tree, ais, test_decl, test_decl.doc_comments); - try renderToken(tree, ais, test_decl.test_token, .Space); - try renderExpression(allocator, ais, tree, test_decl.name, .Space); - try renderExpression(allocator, ais, tree, test_decl.body_node, space); - }, - - .ContainerField => { - const field = @fieldParentPtr(ast.Node.ContainerField, "base", decl); - - try renderDocComments(tree, ais, field, field.doc_comments); - if (field.comptime_token) |t| { - try renderToken(tree, ais, t, .Space); // comptime - } - - const src_has_trailing_comma = blk: { - const maybe_comma = tree.nextToken(field.lastToken()); - break :blk tree.token_ids[maybe_comma] == .Comma; - }; - - // The trailing comma is emitted at the end, but if it's not present - // we still have to respect the specified `space` parameter - const last_token_space: Space = if (src_has_trailing_comma) .None else space; - - if (field.type_expr == null and field.value_expr == null) { - try renderToken(tree, ais, field.name_token, last_token_space); // name - } else if (field.type_expr != null and field.value_expr == null) { - try renderToken(tree, ais, field.name_token, .None); // name - try renderToken(tree, ais, tree.nextToken(field.name_token), .Space); // : - - if (field.align_expr) |align_value_expr| { - try renderExpression(allocator, ais, tree, field.type_expr.?, .Space); // type - const lparen_token = tree.prevToken(align_value_expr.firstToken()); - const align_kw = tree.prevToken(lparen_token); - const rparen_token = tree.nextToken(align_value_expr.lastToken()); - try renderToken(tree, ais, align_kw, .None); // align - try renderToken(tree, ais, lparen_token, .None); // ( - try renderExpression(allocator, ais, tree, align_value_expr, .None); // alignment - try renderToken(tree, ais, rparen_token, last_token_space); // ) - } else { - try renderExpression(allocator, ais, tree, field.type_expr.?, last_token_space); // type - } - } else if (field.type_expr == null and field.value_expr != null) { - try renderToken(tree, ais, field.name_token, .Space); // name - try renderToken(tree, ais, tree.nextToken(field.name_token), .Space); // = - try renderExpression(allocator, ais, tree, field.value_expr.?, last_token_space); // value - } else { - try renderToken(tree, ais, field.name_token, .None); // name - try renderToken(tree, ais, tree.nextToken(field.name_token), .Space); // : - - if (field.align_expr) |align_value_expr| { - try renderExpression(allocator, ais, tree, field.type_expr.?, .Space); // type - const lparen_token = tree.prevToken(align_value_expr.firstToken()); - const align_kw = tree.prevToken(lparen_token); - const rparen_token = tree.nextToken(align_value_expr.lastToken()); - try renderToken(tree, ais, align_kw, .None); // align - try renderToken(tree, ais, lparen_token, .None); // ( - try renderExpression(allocator, ais, tree, align_value_expr, .None); // alignment - try renderToken(tree, ais, rparen_token, .Space); // ) - } else { - try renderExpression(allocator, ais, tree, field.type_expr.?, .Space); // type - } - try renderToken(tree, ais, tree.prevToken(field.value_expr.?.firstToken()), .Space); // = - try renderExpression(allocator, ais, tree, field.value_expr.?, last_token_space); // value - } - - if (src_has_trailing_comma) { - const comma = tree.nextToken(field.lastToken()); - try renderToken(tree, ais, comma, space); - } - }, - - .Comptime => { - assert(!decl.requireSemiColon()); - try renderExpression(allocator, ais, tree, decl, space); - }, - - .DocComment => { - const comment = @fieldParentPtr(ast.Node.DocComment, "base", decl); - const kind = tree.token_ids[comment.first_line]; - try renderToken(tree, ais, comment.first_line, .Newline); - var tok_i = comment.first_line + 1; - while (true) : (tok_i += 1) { - const tok_id = tree.token_ids[tok_i]; - if (tok_id == kind) { - try renderToken(tree, ais, tok_i, .Newline); - } else if (tok_id == .LineComment) { + while (i < fn_token) : (i += 1) { + if (token_tags[i] == .keyword_inline) { + // TODO remove this special case when 0.9.0 is released. + // See the commit that introduced this comment for more details. continue; - } else { - break; + } + try renderToken(ais, tree, i, .space); + } + assert(datas[decl].rhs != 0); + try renderExpression(gpa, ais, tree, fn_proto, .space); + return renderExpression(gpa, ais, tree, datas[decl].rhs, space); + }, + .fn_proto_simple, + .fn_proto_multi, + .fn_proto_one, + .fn_proto, + => { + // Extern function prototypes are parsed as these tags. + // Go back to the first token we should render here. + const fn_token = main_tokens[decl]; + var i = fn_token; + while (i > 0) { + i -= 1; + switch (token_tags[i]) { + .keyword_extern, + .keyword_export, + .keyword_pub, + .string_literal, + .keyword_inline, + .keyword_noinline, + => continue, + + else => { + i += 1; + break; + }, } } + while (i < fn_token) : (i += 1) { + try renderToken(ais, tree, i, .space); + } + try renderExpression(gpa, ais, tree, decl, .none); + return renderToken(ais, tree, tree.lastToken(decl) + 1, space); // semicolon }, + + .@"usingnamespace" => { + const main_token = main_tokens[decl]; + const expr = datas[decl].lhs; + if (main_token > 0 and token_tags[main_token - 1] == .keyword_pub) { + try renderToken(ais, tree, main_token - 1, .space); // pub + } + try renderToken(ais, tree, main_token, .space); // usingnamespace + try renderExpression(gpa, ais, tree, expr, .none); + return renderToken(ais, tree, tree.lastToken(expr) + 1, space); // ; + }, + + .global_var_decl => return renderVarDecl(gpa, ais, tree, tree.globalVarDecl(decl)), + .local_var_decl => return renderVarDecl(gpa, ais, tree, tree.localVarDecl(decl)), + .simple_var_decl => return renderVarDecl(gpa, ais, tree, tree.simpleVarDecl(decl)), + .aligned_var_decl => return renderVarDecl(gpa, ais, tree, tree.alignedVarDecl(decl)), + + .test_decl => { + const test_token = main_tokens[decl]; + try renderToken(ais, tree, test_token, .space); + if (token_tags[test_token + 1] == .string_literal) { + try renderToken(ais, tree, test_token + 1, .space); + } + try renderExpression(gpa, ais, tree, datas[decl].rhs, space); + }, + + .container_field_init => return renderContainerField(gpa, ais, tree, tree.containerFieldInit(decl), space), + .container_field_align => return renderContainerField(gpa, ais, tree, tree.containerFieldAlign(decl), space), + .container_field => return renderContainerField(gpa, ais, tree, tree.containerField(decl), space), + .@"comptime" => return renderExpression(gpa, ais, tree, decl, space), + + .root => unreachable, else => unreachable, } } -fn renderExpression( - allocator: *mem.Allocator, - ais: anytype, - tree: *ast.Tree, - base: *ast.Node, - space: Space, -) (@TypeOf(ais.*).Error || Error)!void { - switch (base.tag) { - .Identifier, - .IntegerLiteral, - .FloatLiteral, - .StringLiteral, - .CharLiteral, - .BoolLiteral, - .NullLiteral, - .Unreachable, - .ErrorType, - .UndefinedLiteral, +/// Render all expressions in the slice, keeping empty lines where appropriate +fn renderExpressions(gpa: *Allocator, ais: *Ais, tree: ast.Tree, expressions: []const ast.Node.Index, space: Space) Error!void { + if (expressions.len == 0) return; + try renderExpression(gpa, ais, tree, expressions[0], space); + for (expressions[1..]) |expression| { + try renderExtraNewline(ais, tree, expression); + try renderExpression(gpa, ais, tree, expression, space); + } +} + +fn renderExpression(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Space) Error!void { + const token_tags = tree.tokens.items(.tag); + const main_tokens = tree.nodes.items(.main_token); + const node_tags = tree.nodes.items(.tag); + const datas = tree.nodes.items(.data); + switch (node_tags[node]) { + .identifier, + .integer_literal, + .float_literal, + .char_literal, + .true_literal, + .false_literal, + .null_literal, + .unreachable_literal, + .undefined_literal, + .anyframe_literal, + .string_literal, + => return renderToken(ais, tree, main_tokens[node], space), + + .multiline_string_literal => { + var locked_indents = ais.lockOneShotIndent(); + try ais.maybeInsertNewline(); + + var i = datas[node].lhs; + while (i <= datas[node].rhs) : (i += 1) try renderToken(ais, tree, i, .newline); + + while (locked_indents > 0) : (locked_indents -= 1) ais.popIndent(); + + switch (space) { + .none, .space, .newline, .skip => {}, + .semicolon => if (token_tags[i] == .semicolon) try renderToken(ais, tree, i, .newline), + .comma => if (token_tags[i] == .comma) try renderToken(ais, tree, i, .newline), + .comma_space => if (token_tags[i] == .comma) try renderToken(ais, tree, i, .space), + } + }, + + .error_value => { + try renderToken(ais, tree, main_tokens[node], .none); + try renderToken(ais, tree, main_tokens[node] + 1, .none); + return renderToken(ais, tree, main_tokens[node] + 2, space); + }, + + .@"anytype" => return renderToken(ais, tree, main_tokens[node], space), + + .block_two, + .block_two_semicolon, => { - const casted_node = base.cast(ast.Node.OneToken).?; - return renderToken(tree, ais, casted_node.token, space); - }, - - .AnyType => { - const any_type = base.castTag(.AnyType).?; - if (mem.eql(u8, tree.tokenSlice(any_type.token), "var")) { - // TODO remove in next release cycle - try ais.writer().writeAll("anytype"); - if (space == .Comma) try ais.writer().writeAll(",\n"); - return; - } - return renderToken(tree, ais, any_type.token, space); - }, - - .Block, .LabeledBlock => { - const block: struct { - label: ?ast.TokenIndex, - statements: []*ast.Node, - lbrace: ast.TokenIndex, - rbrace: ast.TokenIndex, - } = b: { - if (base.castTag(.Block)) |block| { - break :b .{ - .label = null, - .statements = block.statements(), - .lbrace = block.lbrace, - .rbrace = block.rbrace, - }; - } else if (base.castTag(.LabeledBlock)) |block| { - break :b .{ - .label = block.label, - .statements = block.statements(), - .lbrace = block.lbrace, - .rbrace = block.rbrace, - }; - } else { - unreachable; - } - }; - - if (block.label) |label| { - try renderToken(tree, ais, label, Space.None); - try renderToken(tree, ais, tree.nextToken(label), Space.Space); - } - - if (block.statements.len == 0) { - ais.pushIndentNextLine(); - defer ais.popIndent(); - try renderToken(tree, ais, block.lbrace, Space.None); + const statements = [2]ast.Node.Index{ datas[node].lhs, datas[node].rhs }; + if (datas[node].lhs == 0) { + return renderBlock(gpa, ais, tree, node, statements[0..0], space); + } else if (datas[node].rhs == 0) { + return renderBlock(gpa, ais, tree, node, statements[0..1], space); } else { - ais.pushIndentNextLine(); - defer ais.popIndent(); - - try renderToken(tree, ais, block.lbrace, Space.Newline); - - for (block.statements) |statement, i| { - try renderStatement(allocator, ais, tree, statement); - - if (i + 1 < block.statements.len) { - try renderExtraNewline(tree, ais, block.statements[i + 1]); - } - } + return renderBlock(gpa, ais, tree, node, statements[0..2], space); } - return renderToken(tree, ais, block.rbrace, space); + }, + .block, + .block_semicolon, + => { + const statements = tree.extra_data[datas[node].lhs..datas[node].rhs]; + return renderBlock(gpa, ais, tree, node, statements, space); }, - .Defer => { - const defer_node = @fieldParentPtr(ast.Node.Defer, "base", base); + .@"errdefer" => { + const defer_token = main_tokens[node]; + const payload_token = datas[node].lhs; + const expr = datas[node].rhs; - try renderToken(tree, ais, defer_node.defer_token, Space.Space); - if (defer_node.payload) |payload| { - try renderExpression(allocator, ais, tree, payload, Space.Space); + try renderToken(ais, tree, defer_token, .space); + if (payload_token != 0) { + try renderToken(ais, tree, payload_token - 1, .none); // | + try renderToken(ais, tree, payload_token, .none); // identifier + try renderToken(ais, tree, payload_token + 1, .space); // | } - return renderExpression(allocator, ais, tree, defer_node.expr, space); + return renderExpression(gpa, ais, tree, expr, space); }, - .Comptime => { - const comptime_node = @fieldParentPtr(ast.Node.Comptime, "base", base); - try renderToken(tree, ais, comptime_node.comptime_token, Space.Space); - return renderExpression(allocator, ais, tree, comptime_node.expr, space); + .@"defer" => { + const defer_token = main_tokens[node]; + const expr = datas[node].rhs; + try renderToken(ais, tree, defer_token, .space); + return renderExpression(gpa, ais, tree, expr, space); }, - .Nosuspend => { - const nosuspend_node = @fieldParentPtr(ast.Node.Nosuspend, "base", base); - if (mem.eql(u8, tree.tokenSlice(nosuspend_node.nosuspend_token), "noasync")) { - // TODO: remove this - try ais.writer().writeAll("nosuspend "); + .@"comptime", .@"nosuspend" => { + const comptime_token = main_tokens[node]; + const block = datas[node].lhs; + try renderToken(ais, tree, comptime_token, .space); + return renderExpression(gpa, ais, tree, block, space); + }, + + .@"suspend" => { + const suspend_token = main_tokens[node]; + const body = datas[node].lhs; + if (body != 0) { + try renderToken(ais, tree, suspend_token, .space); + return renderExpression(gpa, ais, tree, body, space); } else { - try renderToken(tree, ais, nosuspend_node.nosuspend_token, Space.Space); + return renderToken(ais, tree, suspend_token, space); } - return renderExpression(allocator, ais, tree, nosuspend_node.expr, space); }, - .Suspend => { - const suspend_node = @fieldParentPtr(ast.Node.Suspend, "base", base); + .@"catch" => { + const main_token = main_tokens[node]; + const fallback_first = tree.firstToken(datas[node].rhs); - if (suspend_node.body) |body| { - try renderToken(tree, ais, suspend_node.suspend_token, Space.Space); - return renderExpression(allocator, ais, tree, body, space); + const same_line = tree.tokensOnSameLine(main_token, fallback_first); + const after_op_space = if (same_line) Space.space else Space.newline; + + try renderExpression(gpa, ais, tree, datas[node].lhs, .space); // target + + if (token_tags[fallback_first - 1] == .pipe) { + try renderToken(ais, tree, main_token, .space); // catch keyword + try renderToken(ais, tree, main_token + 1, .none); // pipe + try renderToken(ais, tree, main_token + 2, .none); // payload identifier + try renderToken(ais, tree, main_token + 3, after_op_space); // pipe } else { - return renderToken(tree, ais, suspend_node.suspend_token, space); - } - }, - - .Catch => { - const infix_op_node = @fieldParentPtr(ast.Node.Catch, "base", base); - - const op_space = Space.Space; - try renderExpression(allocator, ais, tree, infix_op_node.lhs, op_space); - - const after_op_space = blk: { - const same_line = tree.tokensOnSameLine(infix_op_node.op_token, tree.nextToken(infix_op_node.op_token)); - break :blk if (same_line) op_space else Space.Newline; - }; - - try renderToken(tree, ais, infix_op_node.op_token, after_op_space); - - if (infix_op_node.payload) |payload| { - try renderExpression(allocator, ais, tree, payload, Space.Space); + assert(token_tags[fallback_first - 1] == .keyword_catch); + try renderToken(ais, tree, main_token, after_op_space); // catch keyword } ais.pushIndentOneShot(); - return renderExpression(allocator, ais, tree, infix_op_node.rhs, space); + try renderExpression(gpa, ais, tree, datas[node].rhs, space); // fallback }, - .Add, - .AddWrap, - .ArrayCat, - .ArrayMult, - .Assign, - .AssignBitAnd, - .AssignBitOr, - .AssignBitShiftLeft, - .AssignBitShiftRight, - .AssignBitXor, - .AssignDiv, - .AssignSub, - .AssignSubWrap, - .AssignMod, - .AssignAdd, - .AssignAddWrap, - .AssignMul, - .AssignMulWrap, - .BangEqual, - .BitAnd, - .BitOr, - .BitShiftLeft, - .BitShiftRight, - .BitXor, - .BoolAnd, - .BoolOr, - .Div, - .EqualEqual, - .ErrorUnion, - .GreaterOrEqual, - .GreaterThan, - .LessOrEqual, - .LessThan, - .MergeErrorSets, - .Mod, - .Mul, - .MulWrap, - .Period, - .Range, - .Sub, - .SubWrap, - .OrElse, - => { - const infix_op_node = @fieldParentPtr(ast.Node.SimpleInfixOp, "base", base); - - const op_space = switch (base.tag) { - .Period, .ErrorUnion, .Range => Space.None, - else => Space.Space, - }; - try renderExpression(allocator, ais, tree, infix_op_node.lhs, op_space); - - const after_op_space = blk: { - const loc = tree.tokenLocation(tree.token_locs[infix_op_node.op_token].end, tree.nextToken(infix_op_node.op_token)); - break :blk if (loc.line == 0) op_space else Space.Newline; - }; - - { - ais.pushIndent(); - defer ais.popIndent(); - try renderToken(tree, ais, infix_op_node.op_token, after_op_space); - } - ais.pushIndentOneShot(); - return renderExpression(allocator, ais, tree, infix_op_node.rhs, space); - }, - - .BitNot, - .BoolNot, - .Negation, - .NegationWrap, - .OptionalType, - .AddressOf, - => { - const casted_node = @fieldParentPtr(ast.Node.SimplePrefixOp, "base", base); - try renderToken(tree, ais, casted_node.op_token, Space.None); - return renderExpression(allocator, ais, tree, casted_node.rhs, space); - }, - - .Try, - .Resume, - .Await, - => { - const casted_node = @fieldParentPtr(ast.Node.SimplePrefixOp, "base", base); - try renderToken(tree, ais, casted_node.op_token, Space.Space); - return renderExpression(allocator, ais, tree, casted_node.rhs, space); - }, - - .ArrayType => { - const array_type = @fieldParentPtr(ast.Node.ArrayType, "base", base); - return renderArrayType( - allocator, - ais, - tree, - array_type.op_token, - array_type.rhs, - array_type.len_expr, - null, - space, - ); - }, - .ArrayTypeSentinel => { - const array_type = @fieldParentPtr(ast.Node.ArrayTypeSentinel, "base", base); - return renderArrayType( - allocator, - ais, - tree, - array_type.op_token, - array_type.rhs, - array_type.len_expr, - array_type.sentinel, - space, - ); - }, - - .PtrType => { - const ptr_type = @fieldParentPtr(ast.Node.PtrType, "base", base); - const op_tok_id = tree.token_ids[ptr_type.op_token]; - switch (op_tok_id) { - .Asterisk, .AsteriskAsterisk => try ais.writer().writeByte('*'), - .LBracket => if (tree.token_ids[ptr_type.op_token + 2] == .Identifier) - try ais.writer().writeAll("[*c") - else - try ais.writer().writeAll("[*"), - else => unreachable, - } - if (ptr_type.ptr_info.sentinel) |sentinel| { - const colon_token = tree.prevToken(sentinel.firstToken()); - try renderToken(tree, ais, colon_token, Space.None); // : - const sentinel_space = switch (op_tok_id) { - .LBracket => Space.None, - else => Space.Space, - }; - try renderExpression(allocator, ais, tree, sentinel, sentinel_space); - } - switch (op_tok_id) { - .Asterisk, .AsteriskAsterisk => {}, - .LBracket => try ais.writer().writeByte(']'), - else => unreachable, - } - if (ptr_type.ptr_info.allowzero_token) |allowzero_token| { - try renderToken(tree, ais, allowzero_token, Space.Space); // allowzero - } - if (ptr_type.ptr_info.align_info) |align_info| { - const lparen_token = tree.prevToken(align_info.node.firstToken()); - const align_token = tree.prevToken(lparen_token); - - try renderToken(tree, ais, align_token, Space.None); // align - try renderToken(tree, ais, lparen_token, Space.None); // ( - - try renderExpression(allocator, ais, tree, align_info.node, Space.None); - - if (align_info.bit_range) |bit_range| { - const colon1 = tree.prevToken(bit_range.start.firstToken()); - const colon2 = tree.prevToken(bit_range.end.firstToken()); - - try renderToken(tree, ais, colon1, Space.None); // : - try renderExpression(allocator, ais, tree, bit_range.start, Space.None); - try renderToken(tree, ais, colon2, Space.None); // : - try renderExpression(allocator, ais, tree, bit_range.end, Space.None); - - const rparen_token = tree.nextToken(bit_range.end.lastToken()); - try renderToken(tree, ais, rparen_token, Space.Space); // ) - } else { - const rparen_token = tree.nextToken(align_info.node.lastToken()); - try renderToken(tree, ais, rparen_token, Space.Space); // ) - } - } - if (ptr_type.ptr_info.const_token) |const_token| { - try renderToken(tree, ais, const_token, Space.Space); // const - } - if (ptr_type.ptr_info.volatile_token) |volatile_token| { - try renderToken(tree, ais, volatile_token, Space.Space); // volatile - } - return renderExpression(allocator, ais, tree, ptr_type.rhs, space); - }, - - .SliceType => { - const slice_type = @fieldParentPtr(ast.Node.SliceType, "base", base); - try renderToken(tree, ais, slice_type.op_token, Space.None); // [ - if (slice_type.ptr_info.sentinel) |sentinel| { - const colon_token = tree.prevToken(sentinel.firstToken()); - try renderToken(tree, ais, colon_token, Space.None); // : - try renderExpression(allocator, ais, tree, sentinel, Space.None); - try renderToken(tree, ais, tree.nextToken(sentinel.lastToken()), Space.None); // ] - } else { - try renderToken(tree, ais, tree.nextToken(slice_type.op_token), Space.None); // ] - } - - if (slice_type.ptr_info.allowzero_token) |allowzero_token| { - try renderToken(tree, ais, allowzero_token, Space.Space); // allowzero - } - if (slice_type.ptr_info.align_info) |align_info| { - const lparen_token = tree.prevToken(align_info.node.firstToken()); - const align_token = tree.prevToken(lparen_token); - - try renderToken(tree, ais, align_token, Space.None); // align - try renderToken(tree, ais, lparen_token, Space.None); // ( - - try renderExpression(allocator, ais, tree, align_info.node, Space.None); - - if (align_info.bit_range) |bit_range| { - const colon1 = tree.prevToken(bit_range.start.firstToken()); - const colon2 = tree.prevToken(bit_range.end.firstToken()); - - try renderToken(tree, ais, colon1, Space.None); // : - try renderExpression(allocator, ais, tree, bit_range.start, Space.None); - try renderToken(tree, ais, colon2, Space.None); // : - try renderExpression(allocator, ais, tree, bit_range.end, Space.None); - - const rparen_token = tree.nextToken(bit_range.end.lastToken()); - try renderToken(tree, ais, rparen_token, Space.Space); // ) - } else { - const rparen_token = tree.nextToken(align_info.node.lastToken()); - try renderToken(tree, ais, rparen_token, Space.Space); // ) - } - } - if (slice_type.ptr_info.const_token) |const_token| { - try renderToken(tree, ais, const_token, Space.Space); - } - if (slice_type.ptr_info.volatile_token) |volatile_token| { - try renderToken(tree, ais, volatile_token, Space.Space); - } - return renderExpression(allocator, ais, tree, slice_type.rhs, space); - }, - - .ArrayInitializer, .ArrayInitializerDot => { - var rtoken: ast.TokenIndex = undefined; - var exprs: []*ast.Node = undefined; - const lhs: union(enum) { dot: ast.TokenIndex, node: *ast.Node } = switch (base.tag) { - .ArrayInitializerDot => blk: { - const casted = @fieldParentPtr(ast.Node.ArrayInitializerDot, "base", base); - rtoken = casted.rtoken; - exprs = casted.list(); - break :blk .{ .dot = casted.dot }; - }, - .ArrayInitializer => blk: { - const casted = @fieldParentPtr(ast.Node.ArrayInitializer, "base", base); - rtoken = casted.rtoken; - exprs = casted.list(); - break :blk .{ .node = casted.lhs }; - }, - else => unreachable, - }; - - const lbrace = switch (lhs) { - .dot => |dot| tree.nextToken(dot), - .node => |node| tree.nextToken(node.lastToken()), - }; - - switch (lhs) { - .dot => |dot| try renderToken(tree, ais, dot, Space.None), - .node => |node| try renderExpression(allocator, ais, tree, node, Space.None), - } - - if (exprs.len == 0) { - try renderToken(tree, ais, lbrace, Space.None); - return renderToken(tree, ais, rtoken, space); - } - - if (exprs.len == 1 and exprs[0].tag != .MultilineStringLiteral and tree.token_ids[exprs[0].*.lastToken() + 1] == .RBrace) { - const expr = exprs[0]; - - try renderToken(tree, ais, lbrace, Space.None); - try renderExpression(allocator, ais, tree, expr, Space.None); - return renderToken(tree, ais, rtoken, space); - } - - // scan to find row size - if (rowSize(tree, exprs, rtoken) != null) { - { - ais.pushIndentNextLine(); - defer ais.popIndent(); - try renderToken(tree, ais, lbrace, Space.Newline); - - var expr_index: usize = 0; - while (rowSize(tree, exprs[expr_index..], rtoken)) |row_size| { - const row_exprs = exprs[expr_index..]; - // A place to store the width of each expression and its column's maximum - var widths = try allocator.alloc(usize, row_exprs.len + row_size); - defer allocator.free(widths); - mem.set(usize, widths, 0); - - var expr_newlines = try allocator.alloc(bool, row_exprs.len); - defer allocator.free(expr_newlines); - mem.set(bool, expr_newlines, false); - - var expr_widths = widths[0 .. widths.len - row_size]; - var column_widths = widths[widths.len - row_size ..]; - - // Find next row with trailing comment (if any) to end the current section - var section_end = sec_end: { - var this_line_first_expr: usize = 0; - var this_line_size = rowSize(tree, row_exprs, rtoken); - for (row_exprs) |expr, i| { - // Ignore comment on first line of this section - if (i == 0 or tree.tokensOnSameLine(row_exprs[0].firstToken(), expr.lastToken())) continue; - // Track start of line containing comment - if (!tree.tokensOnSameLine(row_exprs[this_line_first_expr].firstToken(), expr.lastToken())) { - this_line_first_expr = i; - this_line_size = rowSize(tree, row_exprs[this_line_first_expr..], rtoken); - } - - const maybe_comma = expr.lastToken() + 1; - const maybe_comment = expr.lastToken() + 2; - if (maybe_comment < tree.token_ids.len) { - if (tree.token_ids[maybe_comma] == .Comma and - tree.token_ids[maybe_comment] == .LineComment and - tree.tokensOnSameLine(expr.lastToken(), maybe_comment)) - { - var comment_token_loc = tree.token_locs[maybe_comment]; - const comment_is_empty = mem.trimRight(u8, tree.tokenSliceLoc(comment_token_loc), " ").len == 2; - if (!comment_is_empty) { - // Found row ending in comment - break :sec_end i - this_line_size.? + 1; - } - } - } - } - break :sec_end row_exprs.len; - }; - expr_index += section_end; - - const section_exprs = row_exprs[0..section_end]; - - // Null stream for counting the printed length of each expression - var line_find_stream = std.io.findByteOutStream('\n', std.io.null_out_stream); - var counting_stream = std.io.countingOutStream(line_find_stream.writer()); - var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, counting_stream.writer()); - - // Calculate size of columns in current section - var column_counter: usize = 0; - var single_line = true; - for (section_exprs) |expr, i| { - if (i + 1 < section_exprs.len) { - counting_stream.bytes_written = 0; - line_find_stream.byte_found = false; - try renderExpression(allocator, &auto_indenting_stream, tree, expr, Space.None); - const width = @intCast(usize, counting_stream.bytes_written); - expr_widths[i] = width; - expr_newlines[i] = line_find_stream.byte_found; - - if (!line_find_stream.byte_found) { - const column = column_counter % row_size; - column_widths[column] = std.math.max(column_widths[column], width); - - const expr_last_token = expr.*.lastToken() + 1; - const next_expr = section_exprs[i + 1]; - const loc = tree.tokenLocation(tree.token_locs[expr_last_token].start, next_expr.*.firstToken()); - - column_counter += 1; - - if (loc.line != 0) single_line = false; - } else { - single_line = false; - column_counter = 0; - } - } else { - counting_stream.bytes_written = 0; - try renderExpression(allocator, &auto_indenting_stream, tree, expr, Space.None); - const width = @intCast(usize, counting_stream.bytes_written); - expr_widths[i] = width; - expr_newlines[i] = line_find_stream.byte_found; - - if (!line_find_stream.byte_found) { - const column = column_counter % row_size; - column_widths[column] = std.math.max(column_widths[column], width); - } - break; - } - } - - // Render exprs in current section - column_counter = 0; - var last_col_index: usize = row_size - 1; - for (section_exprs) |expr, i| { - if (i + 1 < section_exprs.len) { - const next_expr = section_exprs[i + 1]; - try renderExpression(allocator, ais, tree, expr, Space.None); - - const comma = tree.nextToken(expr.*.lastToken()); - - if (column_counter != last_col_index) { - if (!expr_newlines[i] and !expr_newlines[i + 1]) { - // Neither the current or next expression is multiline - try renderToken(tree, ais, comma, Space.Space); // , - assert(column_widths[column_counter % row_size] >= expr_widths[i]); - const padding = column_widths[column_counter % row_size] - expr_widths[i]; - try ais.writer().writeByteNTimes(' ', padding); - - column_counter += 1; - continue; - } - } - if (single_line and row_size != 1) { - try renderToken(tree, ais, comma, Space.Space); // , - continue; - } - - column_counter = 0; - try renderToken(tree, ais, comma, Space.Newline); // , - try renderExtraNewline(tree, ais, next_expr); - } else { - const maybe_comma = tree.nextToken(expr.*.lastToken()); - if (tree.token_ids[maybe_comma] == .Comma) { - try renderExpression(allocator, ais, tree, expr, Space.None); // , - try renderToken(tree, ais, maybe_comma, Space.Newline); // , - } else { - try renderExpression(allocator, ais, tree, expr, Space.Comma); // , - } - } - } - - if (expr_index == exprs.len) { - break; - } - } - } - - return renderToken(tree, ais, rtoken, space); - } - - // Single line - try renderToken(tree, ais, lbrace, Space.Space); - for (exprs) |expr, i| { - if (i + 1 < exprs.len) { - const next_expr = exprs[i + 1]; - try renderExpression(allocator, ais, tree, expr, Space.None); - const comma = tree.nextToken(expr.*.lastToken()); - try renderToken(tree, ais, comma, Space.Space); // , - } else { - try renderExpression(allocator, ais, tree, expr, Space.Space); - } - } - - return renderToken(tree, ais, rtoken, space); - }, - - .StructInitializer, .StructInitializerDot => { - var rtoken: ast.TokenIndex = undefined; - var field_inits: []*ast.Node = undefined; - const lhs: union(enum) { dot: ast.TokenIndex, node: *ast.Node } = switch (base.tag) { - .StructInitializerDot => blk: { - const casted = @fieldParentPtr(ast.Node.StructInitializerDot, "base", base); - rtoken = casted.rtoken; - field_inits = casted.list(); - break :blk .{ .dot = casted.dot }; - }, - .StructInitializer => blk: { - const casted = @fieldParentPtr(ast.Node.StructInitializer, "base", base); - rtoken = casted.rtoken; - field_inits = casted.list(); - break :blk .{ .node = casted.lhs }; - }, - else => unreachable, - }; - - const lbrace = switch (lhs) { - .dot => |dot| tree.nextToken(dot), - .node => |node| tree.nextToken(node.lastToken()), - }; - - if (field_inits.len == 0) { - switch (lhs) { - .dot => |dot| try renderToken(tree, ais, dot, Space.None), - .node => |node| try renderExpression(allocator, ais, tree, node, Space.None), - } - - { - ais.pushIndentNextLine(); - defer ais.popIndent(); - try renderToken(tree, ais, lbrace, Space.None); - } - - return renderToken(tree, ais, rtoken, space); - } - - const src_has_trailing_comma = blk: { - const maybe_comma = tree.prevToken(rtoken); - break :blk tree.token_ids[maybe_comma] == .Comma; - }; - - const src_same_line = blk: { - const loc = tree.tokenLocation(tree.token_locs[lbrace].end, rtoken); - break :blk loc.line == 0; - }; - - const expr_outputs_one_line = blk: { - // render field expressions until a LF is found - for (field_inits) |field_init| { - var find_stream = std.io.findByteOutStream('\n', std.io.null_out_stream); - var auto_indenting_stream = std.io.autoIndentingStream(indent_delta, find_stream.writer()); - - try renderExpression(allocator, &auto_indenting_stream, tree, field_init, Space.None); - if (find_stream.byte_found) break :blk false; - } - break :blk true; - }; - - if (field_inits.len == 1) blk: { - const field_init = field_inits[0].cast(ast.Node.FieldInitializer).?; - - switch (field_init.expr.tag) { - .StructInitializer, - .StructInitializerDot, - => break :blk, - else => {}, - } - - // if the expression outputs to multiline, make this struct multiline - if (!expr_outputs_one_line or src_has_trailing_comma) { - break :blk; - } - - switch (lhs) { - .dot => |dot| try renderToken(tree, ais, dot, Space.None), - .node => |node| try renderExpression(allocator, ais, tree, node, Space.None), - } - try renderToken(tree, ais, lbrace, Space.Space); - try renderExpression(allocator, ais, tree, &field_init.base, Space.Space); - return renderToken(tree, ais, rtoken, space); - } - - if (!src_has_trailing_comma and src_same_line and expr_outputs_one_line) { - // render all on one line, no trailing comma - switch (lhs) { - .dot => |dot| try renderToken(tree, ais, dot, Space.None), - .node => |node| try renderExpression(allocator, ais, tree, node, Space.None), - } - try renderToken(tree, ais, lbrace, Space.Space); - - for (field_inits) |field_init, i| { - if (i + 1 < field_inits.len) { - try renderExpression(allocator, ais, tree, field_init, Space.None); - - const comma = tree.nextToken(field_init.lastToken()); - try renderToken(tree, ais, comma, Space.Space); - } else { - try renderExpression(allocator, ais, tree, field_init, Space.Space); - } - } - - return renderToken(tree, ais, rtoken, space); - } - - { - switch (lhs) { - .dot => |dot| try renderToken(tree, ais, dot, Space.None), - .node => |node| try renderExpression(allocator, ais, tree, node, Space.None), - } - - ais.pushIndentNextLine(); - defer ais.popIndent(); - - try renderToken(tree, ais, lbrace, Space.Newline); - - for (field_inits) |field_init, i| { - if (i + 1 < field_inits.len) { - const next_field_init = field_inits[i + 1]; - try renderExpression(allocator, ais, tree, field_init, Space.None); - - const comma = tree.nextToken(field_init.lastToken()); - try renderToken(tree, ais, comma, Space.Newline); - - try renderExtraNewline(tree, ais, next_field_init); - } else { - try renderExpression(allocator, ais, tree, field_init, Space.Comma); - } - } - } - - return renderToken(tree, ais, rtoken, space); - }, - - .Call => { - const call = @fieldParentPtr(ast.Node.Call, "base", base); - if (call.async_token) |async_token| { - try renderToken(tree, ais, async_token, Space.Space); - } - - try renderExpression(allocator, ais, tree, call.lhs, Space.None); - - const lparen = tree.nextToken(call.lhs.lastToken()); - - if (call.params_len == 0) { - try renderToken(tree, ais, lparen, Space.None); - return renderToken(tree, ais, call.rtoken, space); - } - - const src_has_trailing_comma = blk: { - const maybe_comma = tree.prevToken(call.rtoken); - break :blk tree.token_ids[maybe_comma] == .Comma; - }; - - if (src_has_trailing_comma) { - { - ais.pushIndent(); - defer ais.popIndent(); - - try renderToken(tree, ais, lparen, Space.Newline); // ( - const params = call.params(); - for (params) |param_node, i| { - if (i + 1 < params.len) { - const next_node = params[i + 1]; - try renderExpression(allocator, ais, tree, param_node, Space.None); - - // Unindent the comma for multiline string literals - const maybe_multiline_string = param_node.firstToken(); - const is_multiline_string = tree.token_ids[maybe_multiline_string] == .MultilineStringLiteralLine; - if (is_multiline_string) ais.popIndent(); - defer if (is_multiline_string) ais.pushIndent(); - - const comma = tree.nextToken(param_node.lastToken()); - try renderToken(tree, ais, comma, Space.Newline); // , - try renderExtraNewline(tree, ais, next_node); - } else { - try renderExpression(allocator, ais, tree, param_node, Space.Comma); - } - } - } - return renderToken(tree, ais, call.rtoken, space); - } - - try renderToken(tree, ais, lparen, Space.None); // ( - - const params = call.params(); - for (params) |param_node, i| { - const maybe_comment = param_node.firstToken() - 1; - const maybe_multiline_string = param_node.firstToken(); - if (tree.token_ids[maybe_multiline_string] == .MultilineStringLiteralLine or tree.token_ids[maybe_comment] == .LineComment) { - ais.pushIndentOneShot(); - } - - try renderExpression(allocator, ais, tree, param_node, Space.None); - - if (i + 1 < params.len) { - const comma = tree.nextToken(param_node.lastToken()); - try renderToken(tree, ais, comma, Space.Space); - } - } - return renderToken(tree, ais, call.rtoken, space); // ) - }, - - .ArrayAccess => { - const suffix_op = base.castTag(.ArrayAccess).?; - - const lbracket = tree.nextToken(suffix_op.lhs.lastToken()); - const rbracket = tree.nextToken(suffix_op.index_expr.lastToken()); - - try renderExpression(allocator, ais, tree, suffix_op.lhs, Space.None); - try renderToken(tree, ais, lbracket, Space.None); // [ - - const starts_with_comment = tree.token_ids[lbracket + 1] == .LineComment; - const ends_with_comment = tree.token_ids[rbracket - 1] == .LineComment; - { - const new_space = if (ends_with_comment) Space.Newline else Space.None; - - ais.pushIndent(); - defer ais.popIndent(); - try renderExpression(allocator, ais, tree, suffix_op.index_expr, new_space); - } - if (starts_with_comment) try ais.maybeInsertNewline(); - return renderToken(tree, ais, rbracket, space); // ] - }, - - .Slice => { - const suffix_op = base.castTag(.Slice).?; - try renderExpression(allocator, ais, tree, suffix_op.lhs, Space.None); - - const lbracket = tree.prevToken(suffix_op.start.firstToken()); - const dotdot = tree.nextToken(suffix_op.start.lastToken()); - - const after_start_space_bool = nodeCausesSliceOpSpace(suffix_op.start) or - (if (suffix_op.end) |end| nodeCausesSliceOpSpace(end) else false); - const after_start_space = if (after_start_space_bool) Space.Space else Space.None; - const after_op_space = if (suffix_op.end != null) after_start_space else Space.None; - - try renderToken(tree, ais, lbracket, Space.None); // [ - try renderExpression(allocator, ais, tree, suffix_op.start, after_start_space); - try renderToken(tree, ais, dotdot, after_op_space); // .. - if (suffix_op.end) |end| { - const after_end_space = if (suffix_op.sentinel != null) Space.Space else Space.None; - try renderExpression(allocator, ais, tree, end, after_end_space); - } - if (suffix_op.sentinel) |sentinel| { - const colon = tree.prevToken(sentinel.firstToken()); - try renderToken(tree, ais, colon, Space.None); // : - try renderExpression(allocator, ais, tree, sentinel, Space.None); - } - return renderToken(tree, ais, suffix_op.rtoken, space); // ] - }, - - .Deref => { - const suffix_op = base.castTag(.Deref).?; - - try renderExpression(allocator, ais, tree, suffix_op.lhs, Space.None); - return renderToken(tree, ais, suffix_op.rtoken, space); // .* - }, - .UnwrapOptional => { - const suffix_op = base.castTag(.UnwrapOptional).?; - - try renderExpression(allocator, ais, tree, suffix_op.lhs, Space.None); - try renderToken(tree, ais, tree.prevToken(suffix_op.rtoken), Space.None); // . - return renderToken(tree, ais, suffix_op.rtoken, space); // ? - }, - - .Break => { - const flow_expr = base.castTag(.Break).?; - const maybe_rhs = flow_expr.getRHS(); - const maybe_label = flow_expr.getLabel(); - - if (maybe_label == null and maybe_rhs == null) { - return renderToken(tree, ais, flow_expr.ltoken, space); // break - } - - try renderToken(tree, ais, flow_expr.ltoken, Space.Space); // break - if (maybe_label) |label| { - const colon = tree.nextToken(flow_expr.ltoken); - try renderToken(tree, ais, colon, Space.None); // : - - if (maybe_rhs == null) { - return renderToken(tree, ais, label, space); // label - } - try renderToken(tree, ais, label, Space.Space); // label - } - return renderExpression(allocator, ais, tree, maybe_rhs.?, space); - }, - - .Continue => { - const flow_expr = base.castTag(.Continue).?; - if (flow_expr.getLabel()) |label| { - try renderToken(tree, ais, flow_expr.ltoken, Space.Space); // continue - const colon = tree.nextToken(flow_expr.ltoken); - try renderToken(tree, ais, colon, Space.None); // : - return renderToken(tree, ais, label, space); // label - } else { - return renderToken(tree, ais, flow_expr.ltoken, space); // continue - } - }, - - .Return => { - const flow_expr = base.castTag(.Return).?; - if (flow_expr.getRHS()) |rhs| { - try renderToken(tree, ais, flow_expr.ltoken, Space.Space); - return renderExpression(allocator, ais, tree, rhs, space); - } else { - return renderToken(tree, ais, flow_expr.ltoken, space); - } - }, - - .Payload => { - const payload = @fieldParentPtr(ast.Node.Payload, "base", base); - - try renderToken(tree, ais, payload.lpipe, Space.None); - try renderExpression(allocator, ais, tree, payload.error_symbol, Space.None); - return renderToken(tree, ais, payload.rpipe, space); - }, - - .PointerPayload => { - const payload = @fieldParentPtr(ast.Node.PointerPayload, "base", base); - - try renderToken(tree, ais, payload.lpipe, Space.None); - if (payload.ptr_token) |ptr_token| { - try renderToken(tree, ais, ptr_token, Space.None); - } - try renderExpression(allocator, ais, tree, payload.value_symbol, Space.None); - return renderToken(tree, ais, payload.rpipe, space); - }, - - .PointerIndexPayload => { - const payload = @fieldParentPtr(ast.Node.PointerIndexPayload, "base", base); - - try renderToken(tree, ais, payload.lpipe, Space.None); - if (payload.ptr_token) |ptr_token| { - try renderToken(tree, ais, ptr_token, Space.None); - } - try renderExpression(allocator, ais, tree, payload.value_symbol, Space.None); - - if (payload.index_symbol) |index_symbol| { - const comma = tree.nextToken(payload.value_symbol.lastToken()); - - try renderToken(tree, ais, comma, Space.Space); - try renderExpression(allocator, ais, tree, index_symbol, Space.None); - } - - return renderToken(tree, ais, payload.rpipe, space); - }, - - .GroupedExpression => { - const grouped_expr = @fieldParentPtr(ast.Node.GroupedExpression, "base", base); - - try renderToken(tree, ais, grouped_expr.lparen, Space.None); - { + .field_access => { + const main_token = main_tokens[node]; + const field_access = datas[node]; + + try renderExpression(gpa, ais, tree, field_access.lhs, .none); + + // Allow a line break between the lhs and the dot if the lhs and rhs + // are on different lines. + const lhs_last_token = tree.lastToken(field_access.lhs); + const same_line = tree.tokensOnSameLine(lhs_last_token, main_token + 1); + if (!same_line) { + if (!hasComment(tree, lhs_last_token, main_token)) try ais.insertNewline(); ais.pushIndentOneShot(); - try renderExpression(allocator, ais, tree, grouped_expr.expr, Space.None); } - return renderToken(tree, ais, grouped_expr.rparen, space); + + try renderToken(ais, tree, main_token, .none); + + // This check ensures that zag() is indented in the following example: + // const x = foo + // .bar() + // . // comment + // zag(); + if (!same_line and hasComment(tree, main_token, main_token + 1)) { + ais.pushIndentOneShot(); + } + + return renderToken(ais, tree, field_access.rhs, space); }, - .FieldInitializer => { - const field_init = @fieldParentPtr(ast.Node.FieldInitializer, "base", base); - - try renderToken(tree, ais, field_init.period_token, Space.None); // . - try renderToken(tree, ais, field_init.name_token, Space.Space); // name - try renderToken(tree, ais, tree.nextToken(field_init.name_token), Space.Space); // = - return renderExpression(allocator, ais, tree, field_init.expr, space); + .error_union, + .switch_range, + => { + const infix = datas[node]; + try renderExpression(gpa, ais, tree, infix.lhs, .none); + try renderToken(ais, tree, main_tokens[node], .none); + return renderExpression(gpa, ais, tree, infix.rhs, space); }, - .ContainerDecl => { - const container_decl = @fieldParentPtr(ast.Node.ContainerDecl, "base", base); - - if (container_decl.layout_token) |layout_token| { - try renderToken(tree, ais, layout_token, Space.Space); + .add, + .add_wrap, + .array_cat, + .array_mult, + .assign, + .assign_bit_and, + .assign_bit_or, + .assign_bit_shift_left, + .assign_bit_shift_right, + .assign_bit_xor, + .assign_div, + .assign_sub, + .assign_sub_wrap, + .assign_mod, + .assign_add, + .assign_add_wrap, + .assign_mul, + .assign_mul_wrap, + .bang_equal, + .bit_and, + .bit_or, + .bit_shift_left, + .bit_shift_right, + .bit_xor, + .bool_and, + .bool_or, + .div, + .equal_equal, + .greater_or_equal, + .greater_than, + .less_or_equal, + .less_than, + .merge_error_sets, + .mod, + .mul, + .mul_wrap, + .sub, + .sub_wrap, + .@"orelse", + => { + const infix = datas[node]; + try renderExpression(gpa, ais, tree, infix.lhs, .space); + const op_token = main_tokens[node]; + if (tree.tokensOnSameLine(op_token, op_token + 1)) { + try renderToken(ais, tree, op_token, .space); + } else { + ais.pushIndent(); + try renderToken(ais, tree, op_token, .newline); + ais.popIndent(); } + ais.pushIndentOneShot(); + return renderExpression(gpa, ais, tree, infix.rhs, space); + }, - switch (container_decl.init_arg_expr) { - .None => { - try renderToken(tree, ais, container_decl.kind_token, Space.Space); // union - }, - .Enum => |enum_tag_type| { - try renderToken(tree, ais, container_decl.kind_token, Space.None); // union + .bit_not, + .bool_not, + .negation, + .negation_wrap, + .optional_type, + .address_of, + => { + try renderToken(ais, tree, main_tokens[node], .none); + return renderExpression(gpa, ais, tree, datas[node].lhs, space); + }, - const lparen = tree.nextToken(container_decl.kind_token); - const enum_token = tree.nextToken(lparen); + .@"try", + .@"resume", + .@"await", + => { + try renderToken(ais, tree, main_tokens[node], .space); + return renderExpression(gpa, ais, tree, datas[node].lhs, space); + }, - try renderToken(tree, ais, lparen, Space.None); // ( - try renderToken(tree, ais, enum_token, Space.None); // enum + .array_type => return renderArrayType(gpa, ais, tree, tree.arrayType(node), space), + .array_type_sentinel => return renderArrayType(gpa, ais, tree, tree.arrayTypeSentinel(node), space), - if (enum_tag_type) |expr| { - try renderToken(tree, ais, tree.nextToken(enum_token), Space.None); // ( - try renderExpression(allocator, ais, tree, expr, Space.None); + .ptr_type_aligned => return renderPtrType(gpa, ais, tree, tree.ptrTypeAligned(node), space), + .ptr_type_sentinel => return renderPtrType(gpa, ais, tree, tree.ptrTypeSentinel(node), space), + .ptr_type => return renderPtrType(gpa, ais, tree, tree.ptrType(node), space), + .ptr_type_bit_range => return renderPtrType(gpa, ais, tree, tree.ptrTypeBitRange(node), space), - const rparen = tree.nextToken(expr.lastToken()); - try renderToken(tree, ais, rparen, Space.None); // ) - try renderToken(tree, ais, tree.nextToken(rparen), Space.Space); // ) - } else { - try renderToken(tree, ais, tree.nextToken(enum_token), Space.Space); // ) - } - }, - .Type => |type_expr| { - try renderToken(tree, ais, container_decl.kind_token, Space.None); // union + .array_init_one, .array_init_one_comma => { + var elements: [1]ast.Node.Index = undefined; + return renderArrayInit(gpa, ais, tree, tree.arrayInitOne(&elements, node), space); + }, + .array_init_dot_two, .array_init_dot_two_comma => { + var elements: [2]ast.Node.Index = undefined; + return renderArrayInit(gpa, ais, tree, tree.arrayInitDotTwo(&elements, node), space); + }, + .array_init_dot, + .array_init_dot_comma, + => return renderArrayInit(gpa, ais, tree, tree.arrayInitDot(node), space), + .array_init, + .array_init_comma, + => return renderArrayInit(gpa, ais, tree, tree.arrayInit(node), space), - const lparen = tree.nextToken(container_decl.kind_token); - const rparen = tree.nextToken(type_expr.lastToken()); + .struct_init_one, .struct_init_one_comma => { + var fields: [1]ast.Node.Index = undefined; + return renderStructInit(gpa, ais, tree, node, tree.structInitOne(&fields, node), space); + }, + .struct_init_dot_two, .struct_init_dot_two_comma => { + var fields: [2]ast.Node.Index = undefined; + return renderStructInit(gpa, ais, tree, node, tree.structInitDotTwo(&fields, node), space); + }, + .struct_init_dot, + .struct_init_dot_comma, + => return renderStructInit(gpa, ais, tree, node, tree.structInitDot(node), space), + .struct_init, + .struct_init_comma, + => return renderStructInit(gpa, ais, tree, node, tree.structInit(node), space), - try renderToken(tree, ais, lparen, Space.None); // ( - try renderExpression(allocator, ais, tree, type_expr, Space.None); - try renderToken(tree, ais, rparen, Space.Space); // ) - }, + .call_one, .call_one_comma, .async_call_one, .async_call_one_comma => { + var params: [1]ast.Node.Index = undefined; + return renderCall(gpa, ais, tree, tree.callOne(¶ms, node), space); + }, + + .call, + .call_comma, + .async_call, + .async_call_comma, + => return renderCall(gpa, ais, tree, tree.callFull(node), space), + + .array_access => { + const suffix = datas[node]; + const lbracket = tree.firstToken(suffix.rhs) - 1; + const rbracket = tree.lastToken(suffix.rhs) + 1; + const one_line = tree.tokensOnSameLine(lbracket, rbracket); + const inner_space = if (one_line) Space.none else Space.newline; + try renderExpression(gpa, ais, tree, suffix.lhs, .none); + ais.pushIndentNextLine(); + try renderToken(ais, tree, lbracket, inner_space); // [ + try renderExpression(gpa, ais, tree, suffix.rhs, inner_space); + ais.popIndent(); + return renderToken(ais, tree, rbracket, space); // ] + }, + + .slice_open => return renderSlice(gpa, ais, tree, tree.sliceOpen(node), space), + .slice => return renderSlice(gpa, ais, tree, tree.slice(node), space), + .slice_sentinel => return renderSlice(gpa, ais, tree, tree.sliceSentinel(node), space), + + .deref => { + try renderExpression(gpa, ais, tree, datas[node].lhs, .none); + return renderToken(ais, tree, main_tokens[node], space); + }, + + .unwrap_optional => { + try renderExpression(gpa, ais, tree, datas[node].lhs, .none); + try renderToken(ais, tree, main_tokens[node], .none); + return renderToken(ais, tree, datas[node].rhs, space); + }, + + .@"break" => { + const main_token = main_tokens[node]; + const label_token = datas[node].lhs; + const target = datas[node].rhs; + if (label_token == 0 and target == 0) { + try renderToken(ais, tree, main_token, space); // break keyword + } else if (label_token == 0 and target != 0) { + try renderToken(ais, tree, main_token, .space); // break keyword + try renderExpression(gpa, ais, tree, target, space); + } else if (label_token != 0 and target == 0) { + try renderToken(ais, tree, main_token, .space); // break keyword + try renderToken(ais, tree, label_token - 1, .none); // colon + try renderToken(ais, tree, label_token, space); // identifier + } else if (label_token != 0 and target != 0) { + try renderToken(ais, tree, main_token, .space); // break keyword + try renderToken(ais, tree, label_token - 1, .none); // colon + try renderToken(ais, tree, label_token, .space); // identifier + try renderExpression(gpa, ais, tree, target, space); } + }, - if (container_decl.fields_and_decls_len == 0) { - { - ais.pushIndentNextLine(); - defer ais.popIndent(); - try renderToken(tree, ais, container_decl.lbrace_token, Space.None); // { - } - return renderToken(tree, ais, container_decl.rbrace_token, space); // } + .@"continue" => { + const main_token = main_tokens[node]; + const label = datas[node].lhs; + if (label != 0) { + try renderToken(ais, tree, main_token, .space); // continue + try renderToken(ais, tree, label - 1, .none); // : + return renderToken(ais, tree, label, space); // label + } else { + return renderToken(ais, tree, main_token, space); // continue } + }, - const src_has_trailing_comma = blk: { - var maybe_comma = tree.prevToken(container_decl.lastToken()); - // Doc comments for a field may also appear after the comma, eg. - // field_name: T, // comment attached to field_name - if (tree.token_ids[maybe_comma] == .DocComment) - maybe_comma = tree.prevToken(maybe_comma); - break :blk tree.token_ids[maybe_comma] == .Comma; - }; + .@"return" => { + if (datas[node].lhs != 0) { + try renderToken(ais, tree, main_tokens[node], .space); + try renderExpression(gpa, ais, tree, datas[node].lhs, space); + } else { + try renderToken(ais, tree, main_tokens[node], space); + } + }, - const fields_and_decls = container_decl.fieldsAndDecls(); + .grouped_expression => { + try renderToken(ais, tree, main_tokens[node], .none); // lparen + ais.pushIndentOneShot(); + try renderExpression(gpa, ais, tree, datas[node].lhs, .none); + return renderToken(ais, tree, datas[node].rhs, space); // rparen + }, - // Check if the first declaration and the { are on the same line - const src_has_newline = !tree.tokensOnSameLine( - container_decl.lbrace_token, - fields_and_decls[0].firstToken(), - ); + .container_decl, + .container_decl_trailing, + => return renderContainerDecl(gpa, ais, tree, node, tree.containerDecl(node), space), - // We can only print all the elements in-line if all the - // declarations inside are fields - const src_has_only_fields = blk: { - for (fields_and_decls) |decl| { - if (decl.tag != .ContainerField) break :blk false; - } - break :blk true; - }; + .container_decl_two, .container_decl_two_trailing => { + var buffer: [2]ast.Node.Index = undefined; + return renderContainerDecl(gpa, ais, tree, node, tree.containerDeclTwo(&buffer, node), space); + }, + .container_decl_arg, + .container_decl_arg_trailing, + => return renderContainerDecl(gpa, ais, tree, node, tree.containerDeclArg(node), space), - if (src_has_trailing_comma or !src_has_only_fields) { - // One declaration per line + .tagged_union, + .tagged_union_trailing, + => return renderContainerDecl(gpa, ais, tree, node, tree.taggedUnion(node), space), + + .tagged_union_two, .tagged_union_two_trailing => { + var buffer: [2]ast.Node.Index = undefined; + return renderContainerDecl(gpa, ais, tree, node, tree.taggedUnionTwo(&buffer, node), space); + }, + .tagged_union_enum_tag, + .tagged_union_enum_tag_trailing, + => return renderContainerDecl(gpa, ais, tree, node, tree.taggedUnionEnumTag(node), space), + + .error_set_decl => { + const error_token = main_tokens[node]; + const lbrace = error_token + 1; + const rbrace = datas[node].rhs; + + try renderToken(ais, tree, error_token, .none); + + if (lbrace + 1 == rbrace) { + // There is nothing between the braces so render condensed: `error{}` + try renderToken(ais, tree, lbrace, .none); + return renderToken(ais, tree, rbrace, space); + } else if (lbrace + 2 == rbrace and token_tags[lbrace + 1] == .identifier) { + // There is exactly one member and no trailing comma or + // comments, so render without surrounding spaces: `error{Foo}` + try renderToken(ais, tree, lbrace, .none); + try renderToken(ais, tree, lbrace + 1, .none); // identifier + return renderToken(ais, tree, rbrace, space); + } else if (token_tags[rbrace - 1] == .comma) { + // There is a trailing comma so render each member on a new line. ais.pushIndentNextLine(); - defer ais.popIndent(); - try renderToken(tree, ais, container_decl.lbrace_token, .Newline); // { - - for (fields_and_decls) |decl, i| { - try renderContainerDecl(allocator, ais, tree, decl, .Newline); - - if (i + 1 < fields_and_decls.len) { - try renderExtraNewline(tree, ais, fields_and_decls[i + 1]); + try renderToken(ais, tree, lbrace, .newline); + var i = lbrace + 1; + while (i < rbrace) : (i += 1) { + if (i > lbrace + 1) try renderExtraNewlineToken(ais, tree, i); + switch (token_tags[i]) { + .doc_comment => try renderToken(ais, tree, i, .newline), + .identifier => try renderToken(ais, tree, i, .comma), + .comma => {}, + else => unreachable, } } - } else if (src_has_newline) { - // All the declarations on the same line, but place the items on - // their own line - try renderToken(tree, ais, container_decl.lbrace_token, .Newline); // { - - ais.pushIndent(); - defer ais.popIndent(); - - for (fields_and_decls) |decl, i| { - const space_after_decl: Space = if (i + 1 >= fields_and_decls.len) .Newline else .Space; - try renderContainerDecl(allocator, ais, tree, decl, space_after_decl); - } + ais.popIndent(); + return renderToken(ais, tree, rbrace, space); } else { - // All the declarations on the same line - try renderToken(tree, ais, container_decl.lbrace_token, .Space); // { - - for (fields_and_decls) |decl| { - try renderContainerDecl(allocator, ais, tree, decl, .Space); - } - } - - return renderToken(tree, ais, container_decl.rbrace_token, space); // } - }, - - .ErrorSetDecl => { - const err_set_decl = @fieldParentPtr(ast.Node.ErrorSetDecl, "base", base); - - const lbrace = tree.nextToken(err_set_decl.error_token); - - if (err_set_decl.decls_len == 0) { - try renderToken(tree, ais, err_set_decl.error_token, Space.None); - try renderToken(tree, ais, lbrace, Space.None); - return renderToken(tree, ais, err_set_decl.rbrace_token, space); - } - - if (err_set_decl.decls_len == 1) blk: { - const node = err_set_decl.decls()[0]; - - // if there are any doc comments or same line comments - // don't try to put it all on one line - if (node.cast(ast.Node.ErrorTag)) |tag| { - if (tag.doc_comments != null) break :blk; - } else { - break :blk; - } - - try renderToken(tree, ais, err_set_decl.error_token, Space.None); // error - try renderToken(tree, ais, lbrace, Space.None); // { - try renderExpression(allocator, ais, tree, node, Space.None); - return renderToken(tree, ais, err_set_decl.rbrace_token, space); // } - } - - try renderToken(tree, ais, err_set_decl.error_token, Space.None); // error - - const src_has_trailing_comma = blk: { - const maybe_comma = tree.prevToken(err_set_decl.rbrace_token); - break :blk tree.token_ids[maybe_comma] == .Comma; - }; - - if (src_has_trailing_comma) { - { - ais.pushIndent(); - defer ais.popIndent(); - - try renderToken(tree, ais, lbrace, Space.Newline); // { - const decls = err_set_decl.decls(); - for (decls) |node, i| { - if (i + 1 < decls.len) { - try renderExpression(allocator, ais, tree, node, Space.None); - try renderToken(tree, ais, tree.nextToken(node.lastToken()), Space.Newline); // , - - try renderExtraNewline(tree, ais, decls[i + 1]); - } else { - try renderExpression(allocator, ais, tree, node, Space.Comma); - } + // There is no trailing comma so render everything on one line. + try renderToken(ais, tree, lbrace, .space); + var i = lbrace + 1; + while (i < rbrace) : (i += 1) { + switch (token_tags[i]) { + .doc_comment => unreachable, // TODO + .identifier => try renderToken(ais, tree, i, .comma_space), + .comma => {}, + else => unreachable, } } + return renderToken(ais, tree, rbrace, space); + } + }, - return renderToken(tree, ais, err_set_decl.rbrace_token, space); // } + .builtin_call_two, .builtin_call_two_comma => { + if (datas[node].lhs == 0) { + return renderBuiltinCall(gpa, ais, tree, main_tokens[node], &.{}, space); + } else if (datas[node].rhs == 0) { + return renderBuiltinCall(gpa, ais, tree, main_tokens[node], &.{datas[node].lhs}, space); } else { - try renderToken(tree, ais, lbrace, Space.Space); // { - - const decls = err_set_decl.decls(); - for (decls) |node, i| { - if (i + 1 < decls.len) { - try renderExpression(allocator, ais, tree, node, Space.None); - - const comma_token = tree.nextToken(node.lastToken()); - assert(tree.token_ids[comma_token] == .Comma); - try renderToken(tree, ais, comma_token, Space.Space); // , - try renderExtraNewline(tree, ais, decls[i + 1]); - } else { - try renderExpression(allocator, ais, tree, node, Space.Space); - } - } - - return renderToken(tree, ais, err_set_decl.rbrace_token, space); // } + return renderBuiltinCall(gpa, ais, tree, main_tokens[node], &.{ datas[node].lhs, datas[node].rhs }, space); } }, - - .ErrorTag => { - const tag = @fieldParentPtr(ast.Node.ErrorTag, "base", base); - - try renderDocComments(tree, ais, tag, tag.doc_comments); - return renderToken(tree, ais, tag.name_token, space); // name + .builtin_call, .builtin_call_comma => { + const params = tree.extra_data[datas[node].lhs..datas[node].rhs]; + return renderBuiltinCall(gpa, ais, tree, main_tokens[node], params, space); }, - .MultilineStringLiteral => { - const multiline_str_literal = @fieldParentPtr(ast.Node.MultilineStringLiteral, "base", base); - - { - const locked_indents = ais.lockOneShotIndent(); - defer { - var i: u8 = 0; - while (i < locked_indents) : (i += 1) ais.popIndent(); - } - try ais.maybeInsertNewline(); - - for (multiline_str_literal.lines()) |t| try renderToken(tree, ais, t, Space.None); - } + .fn_proto_simple => { + var params: [1]ast.Node.Index = undefined; + return renderFnProto(gpa, ais, tree, tree.fnProtoSimple(¶ms, node), space); }, + .fn_proto_multi => return renderFnProto(gpa, ais, tree, tree.fnProtoMulti(node), space), + .fn_proto_one => { + var params: [1]ast.Node.Index = undefined; + return renderFnProto(gpa, ais, tree, tree.fnProtoOne(¶ms, node), space); + }, + .fn_proto => return renderFnProto(gpa, ais, tree, tree.fnProto(node), space), - .BuiltinCall => { - const builtin_call = @fieldParentPtr(ast.Node.BuiltinCall, "base", base); - - // TODO remove after 0.7.0 release - if (mem.eql(u8, tree.tokenSlice(builtin_call.builtin_token), "@OpaqueType")) - return ais.writer().writeAll("opaque {}"); - - // TODO remove after 0.7.0 release - { - const params = builtin_call.paramsConst(); - if (mem.eql(u8, tree.tokenSlice(builtin_call.builtin_token), "@Type") and - params.len == 1) - { - if (params[0].castTag(.EnumLiteral)) |enum_literal| - if (mem.eql(u8, tree.tokenSlice(enum_literal.name), "Opaque")) - return ais.writer().writeAll("opaque {}"); - } - } - - try renderToken(tree, ais, builtin_call.builtin_token, Space.None); // @name - - const src_params_trailing_comma = blk: { - if (builtin_call.params_len == 0) break :blk false; - const last_node = builtin_call.params()[builtin_call.params_len - 1]; - const maybe_comma = tree.nextToken(last_node.lastToken()); - break :blk tree.token_ids[maybe_comma] == .Comma; - }; - - const lparen = tree.nextToken(builtin_call.builtin_token); - - if (!src_params_trailing_comma) { - try renderToken(tree, ais, lparen, Space.None); // ( - - // render all on one line, no trailing comma - const params = builtin_call.params(); - for (params) |param_node, i| { - const maybe_comment = param_node.firstToken() - 1; - if (param_node.*.tag == .MultilineStringLiteral or tree.token_ids[maybe_comment] == .LineComment) { - ais.pushIndentOneShot(); - } - try renderExpression(allocator, ais, tree, param_node, Space.None); - - if (i + 1 < params.len) { - const comma_token = tree.nextToken(param_node.lastToken()); - try renderToken(tree, ais, comma_token, Space.Space); // , - } - } + .anyframe_type => { + const main_token = main_tokens[node]; + if (datas[node].rhs != 0) { + try renderToken(ais, tree, main_token, .none); // anyframe + try renderToken(ais, tree, main_token + 1, .none); // -> + return renderExpression(gpa, ais, tree, datas[node].rhs, space); } else { - // one param per line - ais.pushIndent(); - defer ais.popIndent(); - try renderToken(tree, ais, lparen, Space.Newline); // ( - - for (builtin_call.params()) |param_node| { - try renderExpression(allocator, ais, tree, param_node, Space.Comma); - } + return renderToken(ais, tree, main_token, space); // anyframe } - - return renderToken(tree, ais, builtin_call.rparen_token, space); // ) }, - .FnProto => { - const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", base); + .@"switch", + .switch_comma, + => { + const switch_token = main_tokens[node]; + const condition = datas[node].lhs; + const extra = tree.extraData(datas[node].rhs, ast.Node.SubRange); + const cases = tree.extra_data[extra.start..extra.end]; + const rparen = tree.lastToken(condition) + 1; - if (fn_proto.getVisibToken()) |visib_token_index| { - const visib_token = tree.token_ids[visib_token_index]; - assert(visib_token == .Keyword_pub or visib_token == .Keyword_export); + try renderToken(ais, tree, switch_token, .space); // switch keyword + try renderToken(ais, tree, switch_token + 1, .none); // lparen + try renderExpression(gpa, ais, tree, condition, .none); // condtion expression + try renderToken(ais, tree, rparen, .space); // rparen - try renderToken(tree, ais, visib_token_index, Space.Space); // pub - } - - if (fn_proto.getExternExportInlineToken()) |extern_export_inline_token| { - if (fn_proto.getIsExternPrototype() == null) - try renderToken(tree, ais, extern_export_inline_token, Space.Space); // extern/export/inline - } - - if (fn_proto.getLibName()) |lib_name| { - try renderExpression(allocator, ais, tree, lib_name, Space.Space); - } - - const lparen = if (fn_proto.getNameToken()) |name_token| blk: { - try renderToken(tree, ais, fn_proto.fn_token, Space.Space); // fn - try renderToken(tree, ais, name_token, Space.None); // name - break :blk tree.nextToken(name_token); - } else blk: { - try renderToken(tree, ais, fn_proto.fn_token, Space.Space); // fn - break :blk tree.nextToken(fn_proto.fn_token); - }; - assert(tree.token_ids[lparen] == .LParen); - - const rparen = tree.prevToken( - // the first token for the annotation expressions is the left - // parenthesis, hence the need for two prevToken - if (fn_proto.getAlignExpr()) |align_expr| - tree.prevToken(tree.prevToken(align_expr.firstToken())) - else if (fn_proto.getSectionExpr()) |section_expr| - tree.prevToken(tree.prevToken(section_expr.firstToken())) - else if (fn_proto.getCallconvExpr()) |callconv_expr| - tree.prevToken(tree.prevToken(callconv_expr.firstToken())) - else switch (fn_proto.return_type) { - .Explicit => |node| node.firstToken(), - .InferErrorSet => |node| tree.prevToken(node.firstToken()), - .Invalid => unreachable, - }, - ); - assert(tree.token_ids[rparen] == .RParen); - - const src_params_trailing_comma = blk: { - const maybe_comma = tree.token_ids[rparen - 1]; - break :blk maybe_comma == .Comma or maybe_comma == .LineComment; - }; - - if (!src_params_trailing_comma) { - try renderToken(tree, ais, lparen, Space.None); // ( - - // render all on one line, no trailing comma - for (fn_proto.params()) |param_decl, i| { - try renderParamDecl(allocator, ais, tree, param_decl, Space.None); - - if (i + 1 < fn_proto.params_len or fn_proto.getVarArgsToken() != null) { - const comma = tree.nextToken(param_decl.lastToken()); - try renderToken(tree, ais, comma, Space.Space); // , - } - } - if (fn_proto.getVarArgsToken()) |var_args_token| { - try renderToken(tree, ais, var_args_token, Space.None); - } + ais.pushIndentNextLine(); + if (cases.len == 0) { + try renderToken(ais, tree, rparen + 1, .none); // lbrace } else { - // one param per line - ais.pushIndent(); - defer ais.popIndent(); - try renderToken(tree, ais, lparen, Space.Newline); // ( - - for (fn_proto.params()) |param_decl| { - try renderParamDecl(allocator, ais, tree, param_decl, Space.Comma); - } - if (fn_proto.getVarArgsToken()) |var_args_token| { - try renderToken(tree, ais, var_args_token, Space.Comma); - } - } - - try renderToken(tree, ais, rparen, Space.Space); // ) - - if (fn_proto.getAlignExpr()) |align_expr| { - const align_rparen = tree.nextToken(align_expr.lastToken()); - const align_lparen = tree.prevToken(align_expr.firstToken()); - const align_kw = tree.prevToken(align_lparen); - - try renderToken(tree, ais, align_kw, Space.None); // align - try renderToken(tree, ais, align_lparen, Space.None); // ( - try renderExpression(allocator, ais, tree, align_expr, Space.None); - try renderToken(tree, ais, align_rparen, Space.Space); // ) - } - - if (fn_proto.getSectionExpr()) |section_expr| { - const section_rparen = tree.nextToken(section_expr.lastToken()); - const section_lparen = tree.prevToken(section_expr.firstToken()); - const section_kw = tree.prevToken(section_lparen); - - try renderToken(tree, ais, section_kw, Space.None); // section - try renderToken(tree, ais, section_lparen, Space.None); // ( - try renderExpression(allocator, ais, tree, section_expr, Space.None); - try renderToken(tree, ais, section_rparen, Space.Space); // ) - } - - if (fn_proto.getCallconvExpr()) |callconv_expr| { - const callconv_rparen = tree.nextToken(callconv_expr.lastToken()); - const callconv_lparen = tree.prevToken(callconv_expr.firstToken()); - const callconv_kw = tree.prevToken(callconv_lparen); - - try renderToken(tree, ais, callconv_kw, Space.None); // callconv - try renderToken(tree, ais, callconv_lparen, Space.None); // ( - try renderExpression(allocator, ais, tree, callconv_expr, Space.None); - try renderToken(tree, ais, callconv_rparen, Space.Space); // ) - } else if (fn_proto.getIsExternPrototype() != null) { - try ais.writer().writeAll("callconv(.C) "); - } else if (fn_proto.getIsAsync() != null) { - try ais.writer().writeAll("callconv(.Async) "); - } - - switch (fn_proto.return_type) { - .Explicit => |node| { - return renderExpression(allocator, ais, tree, node, space); - }, - .InferErrorSet => |node| { - try renderToken(tree, ais, tree.prevToken(node.firstToken()), Space.None); // ! - return renderExpression(allocator, ais, tree, node, space); - }, - .Invalid => unreachable, + try renderToken(ais, tree, rparen + 1, .newline); // lbrace + try renderExpressions(gpa, ais, tree, cases, .comma); } + ais.popIndent(); + return renderToken(ais, tree, tree.lastToken(node), space); // rbrace }, - .AnyFrameType => { - const anyframe_type = @fieldParentPtr(ast.Node.AnyFrameType, "base", base); + .switch_case_one => return renderSwitchCase(gpa, ais, tree, tree.switchCaseOne(node), space), + .switch_case => return renderSwitchCase(gpa, ais, tree, tree.switchCase(node), space), - if (anyframe_type.result) |result| { - try renderToken(tree, ais, anyframe_type.anyframe_token, Space.None); // anyframe - try renderToken(tree, ais, result.arrow_token, Space.None); // -> - return renderExpression(allocator, ais, tree, result.return_type, space); - } else { - return renderToken(tree, ais, anyframe_type.anyframe_token, space); // anyframe - } + .while_simple => return renderWhile(gpa, ais, tree, tree.whileSimple(node), space), + .while_cont => return renderWhile(gpa, ais, tree, tree.whileCont(node), space), + .@"while" => return renderWhile(gpa, ais, tree, tree.whileFull(node), space), + .for_simple => return renderWhile(gpa, ais, tree, tree.forSimple(node), space), + .@"for" => return renderWhile(gpa, ais, tree, tree.forFull(node), space), + + .if_simple => return renderIf(gpa, ais, tree, tree.ifSimple(node), space), + .@"if" => return renderIf(gpa, ais, tree, tree.ifFull(node), space), + + .asm_simple => return renderAsm(gpa, ais, tree, tree.asmSimple(node), space), + .@"asm" => return renderAsm(gpa, ais, tree, tree.asmFull(node), space), + + .enum_literal => { + try renderToken(ais, tree, main_tokens[node] - 1, .none); // . + return renderToken(ais, tree, main_tokens[node], space); // name }, - .DocComment => unreachable, // doc comments are attached to nodes - - .Switch => { - const switch_node = @fieldParentPtr(ast.Node.Switch, "base", base); - - try renderToken(tree, ais, switch_node.switch_token, Space.Space); // switch - try renderToken(tree, ais, tree.nextToken(switch_node.switch_token), Space.None); // ( - - const rparen = tree.nextToken(switch_node.expr.lastToken()); - const lbrace = tree.nextToken(rparen); - - if (switch_node.cases_len == 0) { - try renderExpression(allocator, ais, tree, switch_node.expr, Space.None); - try renderToken(tree, ais, rparen, Space.Space); // ) - try renderToken(tree, ais, lbrace, Space.None); // { - return renderToken(tree, ais, switch_node.rbrace, space); // } - } - - try renderExpression(allocator, ais, tree, switch_node.expr, Space.None); - try renderToken(tree, ais, rparen, Space.Space); // ) - - { - ais.pushIndentNextLine(); - defer ais.popIndent(); - try renderToken(tree, ais, lbrace, Space.Newline); // { - - const cases = switch_node.cases(); - for (cases) |node, i| { - try renderExpression(allocator, ais, tree, node, Space.Comma); - - if (i + 1 < cases.len) { - try renderExtraNewline(tree, ais, cases[i + 1]); - } - } - } - - return renderToken(tree, ais, switch_node.rbrace, space); // } - }, - - .SwitchCase => { - const switch_case = @fieldParentPtr(ast.Node.SwitchCase, "base", base); - - assert(switch_case.items_len != 0); - const src_has_trailing_comma = blk: { - const last_node = switch_case.items()[switch_case.items_len - 1]; - const maybe_comma = tree.nextToken(last_node.lastToken()); - break :blk tree.token_ids[maybe_comma] == .Comma; - }; - - if (switch_case.items_len == 1 or !src_has_trailing_comma) { - const items = switch_case.items(); - for (items) |node, i| { - if (i + 1 < items.len) { - try renderExpression(allocator, ais, tree, node, Space.None); - - const comma_token = tree.nextToken(node.lastToken()); - try renderToken(tree, ais, comma_token, Space.Space); // , - try renderExtraNewline(tree, ais, items[i + 1]); - } else { - try renderExpression(allocator, ais, tree, node, Space.Space); - } - } - } else { - const items = switch_case.items(); - for (items) |node, i| { - if (i + 1 < items.len) { - try renderExpression(allocator, ais, tree, node, Space.None); - - const comma_token = tree.nextToken(node.lastToken()); - try renderToken(tree, ais, comma_token, Space.Newline); // , - try renderExtraNewline(tree, ais, items[i + 1]); - } else { - try renderExpression(allocator, ais, tree, node, Space.Comma); - } - } - } - - try renderToken(tree, ais, switch_case.arrow_token, Space.Space); // => - - if (switch_case.payload) |payload| { - try renderExpression(allocator, ais, tree, payload, Space.Space); - } - - return renderExpression(allocator, ais, tree, switch_case.expr, space); - }, - .SwitchElse => { - const switch_else = @fieldParentPtr(ast.Node.SwitchElse, "base", base); - return renderToken(tree, ais, switch_else.token, space); - }, - .Else => { - const else_node = @fieldParentPtr(ast.Node.Else, "base", base); - - const body_is_block = nodeIsBlock(else_node.body); - const same_line = body_is_block or tree.tokensOnSameLine(else_node.else_token, else_node.body.lastToken()); - - const after_else_space = if (same_line or else_node.payload != null) Space.Space else Space.Newline; - try renderToken(tree, ais, else_node.else_token, after_else_space); - - if (else_node.payload) |payload| { - const payload_space = if (same_line) Space.Space else Space.Newline; - try renderExpression(allocator, ais, tree, payload, payload_space); - } - - if (same_line) { - return renderExpression(allocator, ais, tree, else_node.body, space); - } else { - ais.pushIndent(); - defer ais.popIndent(); - return renderExpression(allocator, ais, tree, else_node.body, space); - } - }, - - .While => { - const while_node = @fieldParentPtr(ast.Node.While, "base", base); - - if (while_node.label) |label| { - try renderToken(tree, ais, label, Space.None); // label - try renderToken(tree, ais, tree.nextToken(label), Space.Space); // : - } - - if (while_node.inline_token) |inline_token| { - try renderToken(tree, ais, inline_token, Space.Space); // inline - } - - try renderToken(tree, ais, while_node.while_token, Space.Space); // while - try renderToken(tree, ais, tree.nextToken(while_node.while_token), Space.None); // ( - try renderExpression(allocator, ais, tree, while_node.condition, Space.None); - - const cond_rparen = tree.nextToken(while_node.condition.lastToken()); - - const body_is_block = nodeIsBlock(while_node.body); - - var block_start_space: Space = undefined; - var after_body_space: Space = undefined; - - if (body_is_block) { - block_start_space = Space.BlockStart; - after_body_space = if (while_node.@"else" == null) space else Space.SpaceOrOutdent; - } else if (tree.tokensOnSameLine(cond_rparen, while_node.body.lastToken())) { - block_start_space = Space.Space; - after_body_space = if (while_node.@"else" == null) space else Space.Space; - } else { - block_start_space = Space.Newline; - after_body_space = if (while_node.@"else" == null) space else Space.Newline; - } - - { - const rparen_space = if (while_node.payload != null or while_node.continue_expr != null) Space.Space else block_start_space; - try renderToken(tree, ais, cond_rparen, rparen_space); // ) - } - - if (while_node.payload) |payload| { - const payload_space = if (while_node.continue_expr != null) Space.Space else block_start_space; - try renderExpression(allocator, ais, tree, payload, payload_space); - } - - if (while_node.continue_expr) |continue_expr| { - const rparen = tree.nextToken(continue_expr.lastToken()); - const lparen = tree.prevToken(continue_expr.firstToken()); - const colon = tree.prevToken(lparen); - - try renderToken(tree, ais, colon, Space.Space); // : - try renderToken(tree, ais, lparen, Space.None); // ( - - try renderExpression(allocator, ais, tree, continue_expr, Space.None); - - try renderToken(tree, ais, rparen, block_start_space); // ) - } - - { - if (!body_is_block) ais.pushIndent(); - defer if (!body_is_block) ais.popIndent(); - try renderExpression(allocator, ais, tree, while_node.body, after_body_space); - } - - if (while_node.@"else") |@"else"| { - return renderExpression(allocator, ais, tree, &@"else".base, space); - } - }, - - .For => { - const for_node = @fieldParentPtr(ast.Node.For, "base", base); - - if (for_node.label) |label| { - try renderToken(tree, ais, label, Space.None); // label - try renderToken(tree, ais, tree.nextToken(label), Space.Space); // : - } - - if (for_node.inline_token) |inline_token| { - try renderToken(tree, ais, inline_token, Space.Space); // inline - } - - try renderToken(tree, ais, for_node.for_token, Space.Space); // for - try renderToken(tree, ais, tree.nextToken(for_node.for_token), Space.None); // ( - try renderExpression(allocator, ais, tree, for_node.array_expr, Space.None); - - const rparen = tree.nextToken(for_node.array_expr.lastToken()); - - const body_is_block = for_node.body.tag.isBlock(); - const src_one_line_to_body = !body_is_block and tree.tokensOnSameLine(rparen, for_node.body.firstToken()); - const body_on_same_line = body_is_block or src_one_line_to_body; - - try renderToken(tree, ais, rparen, Space.Space); // ) - - const space_after_payload = if (body_on_same_line) Space.Space else Space.Newline; - try renderExpression(allocator, ais, tree, for_node.payload, space_after_payload); // |x| - - const space_after_body = blk: { - if (for_node.@"else") |@"else"| { - const src_one_line_to_else = tree.tokensOnSameLine(rparen, @"else".firstToken()); - if (body_is_block or src_one_line_to_else) { - break :blk Space.Space; - } else { - break :blk Space.Newline; - } - } else { - break :blk space; - } - }; - - { - if (!body_on_same_line) ais.pushIndent(); - defer if (!body_on_same_line) ais.popIndent(); - try renderExpression(allocator, ais, tree, for_node.body, space_after_body); // { body } - } - - if (for_node.@"else") |@"else"| { - return renderExpression(allocator, ais, tree, &@"else".base, space); // else - } - }, - - .If => { - const if_node = @fieldParentPtr(ast.Node.If, "base", base); - - const lparen = tree.nextToken(if_node.if_token); - const rparen = tree.nextToken(if_node.condition.lastToken()); - - try renderToken(tree, ais, if_node.if_token, Space.Space); // if - try renderToken(tree, ais, lparen, Space.None); // ( - - try renderExpression(allocator, ais, tree, if_node.condition, Space.None); // condition - - const body_is_if_block = if_node.body.tag == .If; - const body_is_block = nodeIsBlock(if_node.body); - - if (body_is_if_block) { - try renderExtraNewline(tree, ais, if_node.body); - } else if (body_is_block) { - const after_rparen_space = if (if_node.payload == null) Space.BlockStart else Space.Space; - try renderToken(tree, ais, rparen, after_rparen_space); // ) - - if (if_node.payload) |payload| { - try renderExpression(allocator, ais, tree, payload, Space.BlockStart); // |x| - } - - if (if_node.@"else") |@"else"| { - try renderExpression(allocator, ais, tree, if_node.body, Space.SpaceOrOutdent); - return renderExpression(allocator, ais, tree, &@"else".base, space); - } else { - return renderExpression(allocator, ais, tree, if_node.body, space); - } - } - - const src_has_newline = !tree.tokensOnSameLine(rparen, if_node.body.lastToken()); - - if (src_has_newline) { - const after_rparen_space = if (if_node.payload == null) Space.Newline else Space.Space; - - { - ais.pushIndent(); - defer ais.popIndent(); - try renderToken(tree, ais, rparen, after_rparen_space); // ) - } - - if (if_node.payload) |payload| { - try renderExpression(allocator, ais, tree, payload, Space.Newline); - } - - if (if_node.@"else") |@"else"| { - const else_is_block = nodeIsBlock(@"else".body); - - { - ais.pushIndent(); - defer ais.popIndent(); - try renderExpression(allocator, ais, tree, if_node.body, Space.Newline); - } - - if (else_is_block) { - try renderToken(tree, ais, @"else".else_token, Space.Space); // else - - if (@"else".payload) |payload| { - try renderExpression(allocator, ais, tree, payload, Space.Space); - } - - return renderExpression(allocator, ais, tree, @"else".body, space); - } else { - const after_else_space = if (@"else".payload == null) Space.Newline else Space.Space; - try renderToken(tree, ais, @"else".else_token, after_else_space); // else - - if (@"else".payload) |payload| { - try renderExpression(allocator, ais, tree, payload, Space.Newline); - } - - ais.pushIndent(); - defer ais.popIndent(); - return renderExpression(allocator, ais, tree, @"else".body, space); - } - } else { - ais.pushIndent(); - defer ais.popIndent(); - return renderExpression(allocator, ais, tree, if_node.body, space); - } - } - - // Single line if statement - - try renderToken(tree, ais, rparen, Space.Space); // ) - - if (if_node.payload) |payload| { - try renderExpression(allocator, ais, tree, payload, Space.Space); - } - - if (if_node.@"else") |@"else"| { - try renderExpression(allocator, ais, tree, if_node.body, Space.Space); - try renderToken(tree, ais, @"else".else_token, Space.Space); - - if (@"else".payload) |payload| { - try renderExpression(allocator, ais, tree, payload, Space.Space); - } - - return renderExpression(allocator, ais, tree, @"else".body, space); - } else { - return renderExpression(allocator, ais, tree, if_node.body, space); - } - }, - - .Asm => { - const asm_node = @fieldParentPtr(ast.Node.Asm, "base", base); - - try renderToken(tree, ais, asm_node.asm_token, Space.Space); // asm - - if (asm_node.volatile_token) |volatile_token| { - try renderToken(tree, ais, volatile_token, Space.Space); // volatile - try renderToken(tree, ais, tree.nextToken(volatile_token), Space.None); // ( - } else { - try renderToken(tree, ais, tree.nextToken(asm_node.asm_token), Space.None); // ( - } - - asmblk: { - ais.pushIndent(); - defer ais.popIndent(); - - if (asm_node.outputs.len == 0 and asm_node.inputs.len == 0 and asm_node.clobbers.len == 0) { - try renderExpression(allocator, ais, tree, asm_node.template, Space.None); - break :asmblk; - } - - try renderExpression(allocator, ais, tree, asm_node.template, Space.Newline); - - ais.setIndentDelta(asm_indent_delta); - defer ais.setIndentDelta(indent_delta); - - const colon1 = tree.nextToken(asm_node.template.lastToken()); - - const colon2 = if (asm_node.outputs.len == 0) blk: { - try renderToken(tree, ais, colon1, Space.Newline); // : - - break :blk tree.nextToken(colon1); - } else blk: { - try renderToken(tree, ais, colon1, Space.Space); // : - - ais.pushIndent(); - defer ais.popIndent(); - - for (asm_node.outputs) |*asm_output, i| { - if (i + 1 < asm_node.outputs.len) { - const next_asm_output = asm_node.outputs[i + 1]; - try renderAsmOutput(allocator, ais, tree, asm_output, Space.None); - - const comma = tree.prevToken(next_asm_output.firstToken()); - try renderToken(tree, ais, comma, Space.Newline); // , - try renderExtraNewlineToken(tree, ais, next_asm_output.firstToken()); - } else if (asm_node.inputs.len == 0 and asm_node.clobbers.len == 0) { - try renderAsmOutput(allocator, ais, tree, asm_output, Space.Newline); - break :asmblk; - } else { - try renderAsmOutput(allocator, ais, tree, asm_output, Space.Newline); - const comma_or_colon = tree.nextToken(asm_output.lastToken()); - break :blk switch (tree.token_ids[comma_or_colon]) { - .Comma => tree.nextToken(comma_or_colon), - else => comma_or_colon, - }; - } - } - unreachable; - }; - - const colon3 = if (asm_node.inputs.len == 0) blk: { - try renderToken(tree, ais, colon2, Space.Newline); // : - break :blk tree.nextToken(colon2); - } else blk: { - try renderToken(tree, ais, colon2, Space.Space); // : - ais.pushIndent(); - defer ais.popIndent(); - for (asm_node.inputs) |*asm_input, i| { - if (i + 1 < asm_node.inputs.len) { - const next_asm_input = &asm_node.inputs[i + 1]; - try renderAsmInput(allocator, ais, tree, asm_input, Space.None); - - const comma = tree.prevToken(next_asm_input.firstToken()); - try renderToken(tree, ais, comma, Space.Newline); // , - try renderExtraNewlineToken(tree, ais, next_asm_input.firstToken()); - } else if (asm_node.clobbers.len == 0) { - try renderAsmInput(allocator, ais, tree, asm_input, Space.Newline); - break :asmblk; - } else { - try renderAsmInput(allocator, ais, tree, asm_input, Space.Newline); - const comma_or_colon = tree.nextToken(asm_input.lastToken()); - break :blk switch (tree.token_ids[comma_or_colon]) { - .Comma => tree.nextToken(comma_or_colon), - else => comma_or_colon, - }; - } - } - unreachable; - }; - - try renderToken(tree, ais, colon3, Space.Space); // : - ais.pushIndent(); - defer ais.popIndent(); - for (asm_node.clobbers) |clobber_node, i| { - if (i + 1 >= asm_node.clobbers.len) { - try renderExpression(allocator, ais, tree, clobber_node, Space.Newline); - break :asmblk; - } else { - try renderExpression(allocator, ais, tree, clobber_node, Space.None); - const comma = tree.nextToken(clobber_node.lastToken()); - try renderToken(tree, ais, comma, Space.Space); // , - } - } - } - - return renderToken(tree, ais, asm_node.rparen, space); - }, - - .EnumLiteral => { - const enum_literal = @fieldParentPtr(ast.Node.EnumLiteral, "base", base); - - try renderToken(tree, ais, enum_literal.dot, Space.None); // . - return renderToken(tree, ais, enum_literal.name, space); // name - }, - - .ContainerField, - .Root, - .VarDecl, - .Use, - .TestDecl, - => unreachable, + .fn_decl => unreachable, + .container_field => unreachable, + .container_field_init => unreachable, + .container_field_align => unreachable, + .root => unreachable, + .global_var_decl => unreachable, + .local_var_decl => unreachable, + .simple_var_decl => unreachable, + .aligned_var_decl => unreachable, + .@"usingnamespace" => unreachable, + .test_decl => unreachable, + .asm_output => unreachable, + .asm_input => unreachable, } } fn renderArrayType( - allocator: *mem.Allocator, - ais: anytype, - tree: *ast.Tree, - lbracket: ast.TokenIndex, - rhs: *ast.Node, - len_expr: *ast.Node, - opt_sentinel: ?*ast.Node, + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + array_type: ast.full.ArrayType, space: Space, -) (@TypeOf(ais.*).Error || Error)!void { - const rbracket = tree.nextToken(if (opt_sentinel) |sentinel| - sentinel.lastToken() - else - len_expr.lastToken()); +) Error!void { + const rbracket = tree.firstToken(array_type.ast.elem_type) - 1; + const one_line = tree.tokensOnSameLine(array_type.ast.lbracket, rbracket); + const inner_space = if (one_line) Space.none else Space.newline; + ais.pushIndentNextLine(); + try renderToken(ais, tree, array_type.ast.lbracket, inner_space); // lbracket + try renderExpression(gpa, ais, tree, array_type.ast.elem_count, inner_space); + if (array_type.ast.sentinel) |sentinel| { + try renderToken(ais, tree, tree.firstToken(sentinel) - 1, inner_space); // colon + try renderExpression(gpa, ais, tree, sentinel, inner_space); + } + ais.popIndent(); + try renderToken(ais, tree, rbracket, .none); // rbracket + return renderExpression(gpa, ais, tree, array_type.ast.elem_type, space); +} - const starts_with_comment = tree.token_ids[lbracket + 1] == .LineComment; - const ends_with_comment = tree.token_ids[rbracket - 1] == .LineComment; - const new_space = if (ends_with_comment) Space.Newline else Space.None; - { - const do_indent = (starts_with_comment or ends_with_comment); - if (do_indent) ais.pushIndent(); - defer if (do_indent) ais.popIndent(); +fn renderPtrType( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + ptr_type: ast.full.PtrType, + space: Space, +) Error!void { + switch (ptr_type.size) { + .One => { + // Since ** tokens exist and the same token is shared by two + // nested pointer types, we check to see if we are the parent + // in such a relationship. If so, skip rendering anything for + // this pointer type and rely on the child to render our asterisk + // as well when it renders the ** token. + if (tree.tokens.items(.tag)[ptr_type.ast.main_token] == .asterisk_asterisk and + ptr_type.ast.main_token == tree.nodes.items(.main_token)[ptr_type.ast.child_type]) + { + return renderExpression(gpa, ais, tree, ptr_type.ast.child_type, space); + } + try renderToken(ais, tree, ptr_type.ast.main_token, .none); // asterisk + }, + .Many => { + if (ptr_type.ast.sentinel == 0) { + try renderToken(ais, tree, ptr_type.ast.main_token - 1, .none); // lbracket + try renderToken(ais, tree, ptr_type.ast.main_token, .none); // asterisk + try renderToken(ais, tree, ptr_type.ast.main_token + 1, .none); // rbracket + } else { + try renderToken(ais, tree, ptr_type.ast.main_token - 1, .none); // lbracket + try renderToken(ais, tree, ptr_type.ast.main_token, .none); // asterisk + try renderToken(ais, tree, ptr_type.ast.main_token + 1, .none); // colon + try renderExpression(gpa, ais, tree, ptr_type.ast.sentinel, .none); + try renderToken(ais, tree, tree.lastToken(ptr_type.ast.sentinel) + 1, .none); // rbracket + } + }, + .C => { + try renderToken(ais, tree, ptr_type.ast.main_token - 1, .none); // lbracket + try renderToken(ais, tree, ptr_type.ast.main_token, .none); // asterisk + try renderToken(ais, tree, ptr_type.ast.main_token + 1, .none); // c + try renderToken(ais, tree, ptr_type.ast.main_token + 2, .none); // rbracket + }, + .Slice => { + if (ptr_type.ast.sentinel == 0) { + try renderToken(ais, tree, ptr_type.ast.main_token, .none); // lbracket + try renderToken(ais, tree, ptr_type.ast.main_token + 1, .none); // rbracket + } else { + try renderToken(ais, tree, ptr_type.ast.main_token, .none); // lbracket + try renderToken(ais, tree, ptr_type.ast.main_token + 1, .none); // colon + try renderExpression(gpa, ais, tree, ptr_type.ast.sentinel, .none); + try renderToken(ais, tree, tree.lastToken(ptr_type.ast.sentinel) + 1, .none); // rbracket + } + }, + } - try renderToken(tree, ais, lbracket, Space.None); // [ - try renderExpression(allocator, ais, tree, len_expr, new_space); + if (ptr_type.allowzero_token) |allowzero_token| { + try renderToken(ais, tree, allowzero_token, .space); + } - if (starts_with_comment) { - try ais.maybeInsertNewline(); - } - if (opt_sentinel) |sentinel| { - const colon_token = tree.prevToken(sentinel.firstToken()); - try renderToken(tree, ais, colon_token, Space.None); // : - try renderExpression(allocator, ais, tree, sentinel, Space.None); - } - if (starts_with_comment) { - try ais.maybeInsertNewline(); + if (ptr_type.ast.align_node != 0) { + const align_first = tree.firstToken(ptr_type.ast.align_node); + try renderToken(ais, tree, align_first - 2, .none); // align + try renderToken(ais, tree, align_first - 1, .none); // lparen + try renderExpression(gpa, ais, tree, ptr_type.ast.align_node, .none); + if (ptr_type.ast.bit_range_start != 0) { + assert(ptr_type.ast.bit_range_end != 0); + try renderToken(ais, tree, tree.firstToken(ptr_type.ast.bit_range_start) - 1, .none); // colon + try renderExpression(gpa, ais, tree, ptr_type.ast.bit_range_start, .none); + try renderToken(ais, tree, tree.firstToken(ptr_type.ast.bit_range_end) - 1, .none); // colon + try renderExpression(gpa, ais, tree, ptr_type.ast.bit_range_end, .none); + try renderToken(ais, tree, tree.lastToken(ptr_type.ast.bit_range_end) + 1, .space); // rparen + } else { + try renderToken(ais, tree, tree.lastToken(ptr_type.ast.align_node) + 1, .space); // rparen } } - try renderToken(tree, ais, rbracket, Space.None); // ] - return renderExpression(allocator, ais, tree, rhs, space); + if (ptr_type.const_token) |const_token| { + try renderToken(ais, tree, const_token, .space); + } + + if (ptr_type.volatile_token) |volatile_token| { + try renderToken(ais, tree, volatile_token, .space); + } + + try renderExpression(gpa, ais, tree, ptr_type.ast.child_type, space); +} + +fn renderSlice( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + slice: ast.full.Slice, + space: Space, +) Error!void { + const node_tags = tree.nodes.items(.tag); + const after_start_space_bool = nodeCausesSliceOpSpace(node_tags[slice.ast.start]) or + if (slice.ast.end != 0) nodeCausesSliceOpSpace(node_tags[slice.ast.end]) else false; + const after_start_space = if (after_start_space_bool) Space.space else Space.none; + const after_dots_space = if (slice.ast.end != 0) after_start_space else Space.none; + + try renderExpression(gpa, ais, tree, slice.ast.sliced, .none); + try renderToken(ais, tree, slice.ast.lbracket, .none); // lbracket + + const start_last = tree.lastToken(slice.ast.start); + try renderExpression(gpa, ais, tree, slice.ast.start, after_start_space); + try renderToken(ais, tree, start_last + 1, after_dots_space); // ellipsis2 ("..") + if (slice.ast.end == 0) { + return renderToken(ais, tree, start_last + 2, space); // rbracket + } + + const end_last = tree.lastToken(slice.ast.end); + const after_end_space = if (slice.ast.sentinel != 0) Space.space else Space.none; + try renderExpression(gpa, ais, tree, slice.ast.end, after_end_space); + if (slice.ast.sentinel == 0) { + return renderToken(ais, tree, end_last + 1, space); // rbracket + } + + try renderToken(ais, tree, end_last + 1, .none); // colon + try renderExpression(gpa, ais, tree, slice.ast.sentinel, .none); + try renderToken(ais, tree, tree.lastToken(slice.ast.sentinel) + 1, space); // rbracket } fn renderAsmOutput( - allocator: *mem.Allocator, - ais: anytype, - tree: *ast.Tree, - asm_output: *const ast.Node.Asm.Output, + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + asm_output: ast.Node.Index, space: Space, -) (@TypeOf(ais.*).Error || Error)!void { - try ais.writer().writeAll("["); - try renderExpression(allocator, ais, tree, asm_output.symbolic_name, Space.None); - try ais.writer().writeAll("] "); - try renderExpression(allocator, ais, tree, asm_output.constraint, Space.None); - try ais.writer().writeAll(" ("); +) Error!void { + const token_tags = tree.tokens.items(.tag); + const node_tags = tree.nodes.items(.tag); + const main_tokens = tree.nodes.items(.main_token); + const datas = tree.nodes.items(.data); + assert(node_tags[asm_output] == .asm_output); + const symbolic_name = main_tokens[asm_output]; - switch (asm_output.kind) { - .Variable => |variable_name| { - try renderExpression(allocator, ais, tree, &variable_name.base, Space.None); - }, - .Return => |return_type| { - try ais.writer().writeAll("-> "); - try renderExpression(allocator, ais, tree, return_type, Space.None); - }, + try renderToken(ais, tree, symbolic_name - 1, .none); // lbracket + try renderToken(ais, tree, symbolic_name, .none); // ident + try renderToken(ais, tree, symbolic_name + 1, .space); // rbracket + try renderToken(ais, tree, symbolic_name + 2, .space); // "constraint" + try renderToken(ais, tree, symbolic_name + 3, .none); // lparen + + if (token_tags[symbolic_name + 4] == .arrow) { + try renderToken(ais, tree, symbolic_name + 4, .space); // -> + try renderExpression(gpa, ais, tree, datas[asm_output].lhs, Space.none); + return renderToken(ais, tree, datas[asm_output].rhs, space); // rparen + } else { + try renderToken(ais, tree, symbolic_name + 4, .none); // ident + return renderToken(ais, tree, symbolic_name + 5, space); // rparen } - - return renderToken(tree, ais, asm_output.lastToken(), space); // ) } fn renderAsmInput( - allocator: *mem.Allocator, - ais: anytype, - tree: *ast.Tree, - asm_input: *const ast.Node.Asm.Input, + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + asm_input: ast.Node.Index, space: Space, -) (@TypeOf(ais.*).Error || Error)!void { - try ais.writer().writeAll("["); - try renderExpression(allocator, ais, tree, asm_input.symbolic_name, Space.None); - try ais.writer().writeAll("] "); - try renderExpression(allocator, ais, tree, asm_input.constraint, Space.None); - try ais.writer().writeAll(" ("); - try renderExpression(allocator, ais, tree, asm_input.expr, Space.None); - return renderToken(tree, ais, asm_input.lastToken(), space); // ) +) Error!void { + const node_tags = tree.nodes.items(.tag); + const main_tokens = tree.nodes.items(.main_token); + const datas = tree.nodes.items(.data); + assert(node_tags[asm_input] == .asm_input); + const symbolic_name = main_tokens[asm_input]; + + try renderToken(ais, tree, symbolic_name - 1, .none); // lbracket + try renderToken(ais, tree, symbolic_name, .none); // ident + try renderToken(ais, tree, symbolic_name + 1, .space); // rbracket + try renderToken(ais, tree, symbolic_name + 2, .space); // "constraint" + try renderToken(ais, tree, symbolic_name + 3, .none); // lparen + try renderExpression(gpa, ais, tree, datas[asm_input].lhs, Space.none); + return renderToken(ais, tree, datas[asm_input].rhs, space); // rparen } -fn renderVarDecl( - allocator: *mem.Allocator, - ais: anytype, - tree: *ast.Tree, - var_decl: *ast.Node.VarDecl, -) (@TypeOf(ais.*).Error || Error)!void { - if (var_decl.getVisibToken()) |visib_token| { - try renderToken(tree, ais, visib_token, Space.Space); // pub +fn renderVarDecl(gpa: *Allocator, ais: *Ais, tree: ast.Tree, var_decl: ast.full.VarDecl) Error!void { + if (var_decl.visib_token) |visib_token| { + try renderToken(ais, tree, visib_token, Space.space); // pub } - if (var_decl.getExternExportToken()) |extern_export_token| { - try renderToken(tree, ais, extern_export_token, Space.Space); // extern + if (var_decl.extern_export_token) |extern_export_token| { + try renderToken(ais, tree, extern_export_token, Space.space); // extern - if (var_decl.getLibName()) |lib_name| { - try renderExpression(allocator, ais, tree, lib_name, Space.Space); // "lib" + if (var_decl.lib_name) |lib_name| { + try renderToken(ais, tree, lib_name, Space.space); // "lib" } } - if (var_decl.getComptimeToken()) |comptime_token| { - try renderToken(tree, ais, comptime_token, Space.Space); // comptime + if (var_decl.threadlocal_token) |thread_local_token| { + try renderToken(ais, tree, thread_local_token, Space.space); // threadlocal } - if (var_decl.getThreadLocalToken()) |thread_local_token| { - try renderToken(tree, ais, thread_local_token, Space.Space); // threadlocal + if (var_decl.comptime_token) |comptime_token| { + try renderToken(ais, tree, comptime_token, Space.space); // comptime } - try renderToken(tree, ais, var_decl.mut_token, Space.Space); // var - const name_space = if (var_decl.getTypeNode() == null and - (var_decl.getAlignNode() != null or - var_decl.getSectionNode() != null or - var_decl.getInitNode() != null)) - Space.Space + try renderToken(ais, tree, var_decl.ast.mut_token, .space); // var + + const name_space = if (var_decl.ast.type_node == 0 and + (var_decl.ast.align_node != 0 or + var_decl.ast.section_node != 0 or + var_decl.ast.init_node != 0)) + Space.space else - Space.None; - try renderToken(tree, ais, var_decl.name_token, name_space); + Space.none; + try renderToken(ais, tree, var_decl.ast.mut_token + 1, name_space); // name - if (var_decl.getTypeNode()) |type_node| { - try renderToken(tree, ais, tree.nextToken(var_decl.name_token), Space.Space); - const s = if (var_decl.getAlignNode() != null or - var_decl.getSectionNode() != null or - var_decl.getInitNode() != null) Space.Space else Space.None; - try renderExpression(allocator, ais, tree, type_node, s); + if (var_decl.ast.type_node != 0) { + try renderToken(ais, tree, var_decl.ast.mut_token + 2, Space.space); // : + if (var_decl.ast.align_node != 0 or var_decl.ast.section_node != 0 or + var_decl.ast.init_node != 0) + { + try renderExpression(gpa, ais, tree, var_decl.ast.type_node, .space); + } else { + try renderExpression(gpa, ais, tree, var_decl.ast.type_node, .none); + const semicolon = tree.lastToken(var_decl.ast.type_node) + 1; + return renderToken(ais, tree, semicolon, Space.newline); // ; + } } - if (var_decl.getAlignNode()) |align_node| { - const lparen = tree.prevToken(align_node.firstToken()); - const align_kw = tree.prevToken(lparen); - const rparen = tree.nextToken(align_node.lastToken()); - try renderToken(tree, ais, align_kw, Space.None); // align - try renderToken(tree, ais, lparen, Space.None); // ( - try renderExpression(allocator, ais, tree, align_node, Space.None); - const s = if (var_decl.getSectionNode() != null or var_decl.getInitNode() != null) Space.Space else Space.None; - try renderToken(tree, ais, rparen, s); // ) + if (var_decl.ast.align_node != 0) { + const lparen = tree.firstToken(var_decl.ast.align_node) - 1; + const align_kw = lparen - 1; + const rparen = tree.lastToken(var_decl.ast.align_node) + 1; + try renderToken(ais, tree, align_kw, Space.none); // align + try renderToken(ais, tree, lparen, Space.none); // ( + try renderExpression(gpa, ais, tree, var_decl.ast.align_node, Space.none); + if (var_decl.ast.section_node != 0 or var_decl.ast.init_node != 0) { + try renderToken(ais, tree, rparen, .space); // ) + } else { + try renderToken(ais, tree, rparen, .none); // ) + return renderToken(ais, tree, rparen + 1, Space.newline); // ; + } } - if (var_decl.getSectionNode()) |section_node| { - const lparen = tree.prevToken(section_node.firstToken()); - const section_kw = tree.prevToken(lparen); - const rparen = tree.nextToken(section_node.lastToken()); - try renderToken(tree, ais, section_kw, Space.None); // linksection - try renderToken(tree, ais, lparen, Space.None); // ( - try renderExpression(allocator, ais, tree, section_node, Space.None); - const s = if (var_decl.getInitNode() != null) Space.Space else Space.None; - try renderToken(tree, ais, rparen, s); // ) + if (var_decl.ast.section_node != 0) { + const lparen = tree.firstToken(var_decl.ast.section_node) - 1; + const section_kw = lparen - 1; + const rparen = tree.lastToken(var_decl.ast.section_node) + 1; + try renderToken(ais, tree, section_kw, Space.none); // linksection + try renderToken(ais, tree, lparen, Space.none); // ( + try renderExpression(gpa, ais, tree, var_decl.ast.section_node, Space.none); + if (var_decl.ast.init_node != 0) { + try renderToken(ais, tree, rparen, .space); // ) + } else { + try renderToken(ais, tree, rparen, .none); // ) + return renderToken(ais, tree, rparen + 1, Space.newline); // ; + } } - if (var_decl.getInitNode()) |init_node| { - const eq_token = var_decl.getEqToken().?; - const eq_space = blk: { - const loc = tree.tokenLocation(tree.token_locs[eq_token].end, tree.nextToken(eq_token)); - break :blk if (loc.line == 0) Space.Space else Space.Newline; + assert(var_decl.ast.init_node != 0); + const eq_token = tree.firstToken(var_decl.ast.init_node) - 1; + const eq_space: Space = if (tree.tokensOnSameLine(eq_token, eq_token + 1)) .space else .newline; + { + ais.pushIndent(); + try renderToken(ais, tree, eq_token, eq_space); // = + ais.popIndent(); + } + ais.pushIndentOneShot(); + try renderExpression(gpa, ais, tree, var_decl.ast.init_node, .semicolon); +} + +fn renderIf(gpa: *Allocator, ais: *Ais, tree: ast.Tree, if_node: ast.full.If, space: Space) Error!void { + return renderWhile(gpa, ais, tree, .{ + .ast = .{ + .while_token = if_node.ast.if_token, + .cond_expr = if_node.ast.cond_expr, + .cont_expr = 0, + .then_expr = if_node.ast.then_expr, + .else_expr = if_node.ast.else_expr, + }, + .inline_token = null, + .label_token = null, + .payload_token = if_node.payload_token, + .else_token = if_node.else_token, + .error_token = if_node.error_token, + }, space); +} + +/// Note that this function is additionally used to render if and for expressions, with +/// respective values set to null. +fn renderWhile(gpa: *Allocator, ais: *Ais, tree: ast.Tree, while_node: ast.full.While, space: Space) Error!void { + const node_tags = tree.nodes.items(.tag); + const token_tags = tree.tokens.items(.tag); + + if (while_node.label_token) |label| { + try renderToken(ais, tree, label, .none); // label + try renderToken(ais, tree, label + 1, .space); // : + } + + if (while_node.inline_token) |inline_token| { + try renderToken(ais, tree, inline_token, .space); // inline + } + + try renderToken(ais, tree, while_node.ast.while_token, .space); // if + try renderToken(ais, tree, while_node.ast.while_token + 1, .none); // lparen + try renderExpression(gpa, ais, tree, while_node.ast.cond_expr, .none); // condition + + const then_tag = node_tags[while_node.ast.then_expr]; + if (nodeIsBlock(then_tag) and !nodeIsIf(then_tag)) { + if (while_node.payload_token) |payload_token| { + try renderToken(ais, tree, payload_token - 2, .space); // rparen + try renderToken(ais, tree, payload_token - 1, .none); // | + const ident = blk: { + if (token_tags[payload_token] == .asterisk) { + try renderToken(ais, tree, payload_token, .none); // * + break :blk payload_token + 1; + } else { + break :blk payload_token; + } + }; + try renderToken(ais, tree, ident, .none); // identifier + const pipe = blk: { + if (token_tags[ident + 1] == .comma) { + try renderToken(ais, tree, ident + 1, .space); // , + try renderToken(ais, tree, ident + 2, .none); // index + break :blk ident + 3; + } else { + break :blk ident + 1; + } + }; + const brace_space = if (while_node.ast.cont_expr == 0 and ais.isLineOverIndented()) + Space.newline + else + Space.space; + try renderToken(ais, tree, pipe, brace_space); // | + } else { + const rparen = tree.lastToken(while_node.ast.cond_expr) + 1; + const brace_space = if (while_node.ast.cont_expr == 0 and ais.isLineOverIndented()) + Space.newline + else + Space.space; + try renderToken(ais, tree, rparen, brace_space); // rparen + } + if (while_node.ast.cont_expr != 0) { + const rparen = tree.lastToken(while_node.ast.cont_expr) + 1; + const lparen = tree.firstToken(while_node.ast.cont_expr) - 1; + try renderToken(ais, tree, lparen - 1, .space); // : + try renderToken(ais, tree, lparen, .none); // lparen + try renderExpression(gpa, ais, tree, while_node.ast.cont_expr, .none); + const brace_space: Space = if (ais.isLineOverIndented()) .newline else .space; + try renderToken(ais, tree, rparen, brace_space); // rparen + } + if (while_node.ast.else_expr != 0) { + try renderExpression(gpa, ais, tree, while_node.ast.then_expr, Space.space); + try renderToken(ais, tree, while_node.else_token, .space); // else + if (while_node.error_token) |error_token| { + try renderToken(ais, tree, error_token - 1, .none); // | + try renderToken(ais, tree, error_token, .none); // identifier + try renderToken(ais, tree, error_token + 1, .space); // | + } + return renderExpression(gpa, ais, tree, while_node.ast.else_expr, space); + } else { + return renderExpression(gpa, ais, tree, while_node.ast.then_expr, space); + } + } + + const rparen = tree.lastToken(while_node.ast.cond_expr) + 1; + const last_then_token = tree.lastToken(while_node.ast.then_expr); + const src_has_newline = !tree.tokensOnSameLine(rparen, last_then_token); + + if (src_has_newline) { + if (while_node.payload_token) |payload_token| { + try renderToken(ais, tree, payload_token - 2, .space); // rparen + try renderToken(ais, tree, payload_token - 1, .none); // | + const ident = blk: { + if (token_tags[payload_token] == .asterisk) { + try renderToken(ais, tree, payload_token, .none); // * + break :blk payload_token + 1; + } else { + break :blk payload_token; + } + }; + try renderToken(ais, tree, ident, .none); // identifier + const pipe = blk: { + if (token_tags[ident + 1] == .comma) { + try renderToken(ais, tree, ident + 1, .space); // , + try renderToken(ais, tree, ident + 2, .none); // index + break :blk ident + 3; + } else { + break :blk ident + 1; + } + }; + const after_space: Space = if (while_node.ast.cont_expr != 0) .space else .newline; + try renderToken(ais, tree, pipe, after_space); // | + } else { + ais.pushIndent(); + const after_space: Space = if (while_node.ast.cont_expr != 0) .space else .newline; + try renderToken(ais, tree, rparen, after_space); // rparen + ais.popIndent(); + } + if (while_node.ast.cont_expr != 0) { + const cont_rparen = tree.lastToken(while_node.ast.cont_expr) + 1; + const cont_lparen = tree.firstToken(while_node.ast.cont_expr) - 1; + try renderToken(ais, tree, cont_lparen - 1, .space); // : + try renderToken(ais, tree, cont_lparen, .none); // lparen + try renderExpression(gpa, ais, tree, while_node.ast.cont_expr, .none); + try renderToken(ais, tree, cont_rparen, .newline); // rparen + } + if (while_node.ast.else_expr != 0) { + ais.pushIndent(); + try renderExpression(gpa, ais, tree, while_node.ast.then_expr, Space.newline); + ais.popIndent(); + const else_is_block = nodeIsBlock(node_tags[while_node.ast.else_expr]); + if (else_is_block) { + try renderToken(ais, tree, while_node.else_token, .space); // else + if (while_node.error_token) |error_token| { + try renderToken(ais, tree, error_token - 1, .none); // | + try renderToken(ais, tree, error_token, .none); // identifier + try renderToken(ais, tree, error_token + 1, .space); // | + } + return renderExpression(gpa, ais, tree, while_node.ast.else_expr, space); + } else { + if (while_node.error_token) |error_token| { + try renderToken(ais, tree, while_node.else_token, .space); // else + try renderToken(ais, tree, error_token - 1, .none); // | + try renderToken(ais, tree, error_token, .none); // identifier + try renderToken(ais, tree, error_token + 1, .space); // | + } else { + try renderToken(ais, tree, while_node.else_token, .newline); // else + } + try renderExpressionIndented(gpa, ais, tree, while_node.ast.else_expr, space); + return; + } + } else { + try renderExpressionIndented(gpa, ais, tree, while_node.ast.then_expr, space); + return; + } + } + + // Render everything on a single line. + + if (while_node.payload_token) |payload_token| { + assert(payload_token - 2 == rparen); + try renderToken(ais, tree, payload_token - 2, .space); // ) + try renderToken(ais, tree, payload_token - 1, .none); // | + const ident = blk: { + if (token_tags[payload_token] == .asterisk) { + try renderToken(ais, tree, payload_token, .none); // * + break :blk payload_token + 1; + } else { + break :blk payload_token; + } + }; + try renderToken(ais, tree, ident, .none); // identifier + const pipe = blk: { + if (token_tags[ident + 1] == .comma) { + try renderToken(ais, tree, ident + 1, .space); // , + try renderToken(ais, tree, ident + 2, .none); // index + break :blk ident + 3; + } else { + break :blk ident + 1; + } + }; + try renderToken(ais, tree, pipe, .space); // | + } else { + try renderToken(ais, tree, rparen, .space); // ) + } + + if (while_node.ast.cont_expr != 0) { + const cont_rparen = tree.lastToken(while_node.ast.cont_expr) + 1; + const cont_lparen = tree.firstToken(while_node.ast.cont_expr) - 1; + try renderToken(ais, tree, cont_lparen - 1, .space); // : + try renderToken(ais, tree, cont_lparen, .none); // lparen + try renderExpression(gpa, ais, tree, while_node.ast.cont_expr, .none); + try renderToken(ais, tree, cont_rparen, .space); // rparen + } + + if (while_node.ast.else_expr != 0) { + try renderExpression(gpa, ais, tree, while_node.ast.then_expr, .space); + try renderToken(ais, tree, while_node.else_token, .space); // else + + if (while_node.error_token) |error_token| { + try renderToken(ais, tree, error_token - 1, .none); // | + try renderToken(ais, tree, error_token, .none); // identifier + try renderToken(ais, tree, error_token + 1, .space); // | + } + + return renderExpression(gpa, ais, tree, while_node.ast.else_expr, space); + } else { + return renderExpression(gpa, ais, tree, while_node.ast.then_expr, space); + } +} + +fn renderContainerField( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + field: ast.full.ContainerField, + space: Space, +) Error!void { + const main_tokens = tree.nodes.items(.main_token); + if (field.comptime_token) |t| { + try renderToken(ais, tree, t, .space); // comptime + } + if (field.ast.type_expr == 0 and field.ast.value_expr == 0) { + return renderTokenComma(ais, tree, field.ast.name_token, space); // name + } + if (field.ast.type_expr != 0 and field.ast.value_expr == 0) { + try renderToken(ais, tree, field.ast.name_token, .none); // name + try renderToken(ais, tree, field.ast.name_token + 1, .space); // : + + if (field.ast.align_expr != 0) { + try renderExpression(gpa, ais, tree, field.ast.type_expr, .space); // type + const align_token = tree.firstToken(field.ast.align_expr) - 2; + try renderToken(ais, tree, align_token, .none); // align + try renderToken(ais, tree, align_token + 1, .none); // ( + try renderExpression(gpa, ais, tree, field.ast.align_expr, .none); // alignment + const rparen = tree.lastToken(field.ast.align_expr) + 1; + return renderTokenComma(ais, tree, rparen, space); // ) + } else { + return renderExpressionComma(gpa, ais, tree, field.ast.type_expr, space); // type + } + } + if (field.ast.type_expr == 0 and field.ast.value_expr != 0) { + try renderToken(ais, tree, field.ast.name_token, .space); // name + try renderToken(ais, tree, field.ast.name_token + 1, .space); // = + return renderExpressionComma(gpa, ais, tree, field.ast.value_expr, space); // value + } + + try renderToken(ais, tree, field.ast.name_token, .none); // name + try renderToken(ais, tree, field.ast.name_token + 1, .space); // : + try renderExpression(gpa, ais, tree, field.ast.type_expr, .space); // type + + if (field.ast.align_expr != 0) { + const lparen_token = tree.firstToken(field.ast.align_expr) - 1; + const align_kw = lparen_token - 1; + const rparen_token = tree.lastToken(field.ast.align_expr) + 1; + try renderToken(ais, tree, align_kw, .none); // align + try renderToken(ais, tree, lparen_token, .none); // ( + try renderExpression(gpa, ais, tree, field.ast.align_expr, .none); // alignment + try renderToken(ais, tree, rparen_token, .space); // ) + } + const eq_token = tree.firstToken(field.ast.value_expr) - 1; + try renderToken(ais, tree, eq_token, .space); // = + return renderExpressionComma(gpa, ais, tree, field.ast.value_expr, space); // value +} + +fn renderBuiltinCall( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + builtin_token: ast.TokenIndex, + params: []const ast.Node.Index, + space: Space, +) Error!void { + const token_tags = tree.tokens.items(.tag); + + try renderToken(ais, tree, builtin_token, .none); // @name + + if (params.len == 0) { + try renderToken(ais, tree, builtin_token + 1, .none); // ( + return renderToken(ais, tree, builtin_token + 2, space); // ) + } + + const last_param = params[params.len - 1]; + const after_last_param_token = tree.lastToken(last_param) + 1; + + if (token_tags[after_last_param_token] != .comma) { + // Render all on one line, no trailing comma. + try renderToken(ais, tree, builtin_token + 1, .none); // ( + + for (params) |param_node, i| { + const first_param_token = tree.firstToken(param_node); + if (token_tags[first_param_token] == .multiline_string_literal_line or + hasSameLineComment(tree, first_param_token - 1)) + { + ais.pushIndentOneShot(); + } + try renderExpression(gpa, ais, tree, param_node, .none); + + if (i + 1 < params.len) { + const comma_token = tree.lastToken(param_node) + 1; + try renderToken(ais, tree, comma_token, .space); // , + } + } + return renderToken(ais, tree, after_last_param_token, space); // ) + } else { + // Render one param per line. + ais.pushIndent(); + try renderToken(ais, tree, builtin_token + 1, Space.newline); // ( + + for (params) |param_node| { + try renderExpression(gpa, ais, tree, param_node, .comma); + } + ais.popIndent(); + + return renderToken(ais, tree, after_last_param_token + 1, space); // ) + } +} + +fn renderFnProto(gpa: *Allocator, ais: *Ais, tree: ast.Tree, fn_proto: ast.full.FnProto, space: Space) Error!void { + const token_tags = tree.tokens.items(.tag); + const token_starts = tree.tokens.items(.start); + + const is_inline = fn_proto.ast.fn_token > 0 and + token_tags[fn_proto.ast.fn_token - 1] == .keyword_inline; + + const after_fn_token = fn_proto.ast.fn_token + 1; + const lparen = if (token_tags[after_fn_token] == .identifier) blk: { + try renderToken(ais, tree, fn_proto.ast.fn_token, .space); // fn + try renderToken(ais, tree, after_fn_token, .none); // name + break :blk after_fn_token + 1; + } else blk: { + try renderToken(ais, tree, fn_proto.ast.fn_token, .space); // fn + break :blk fn_proto.ast.fn_token + 1; + }; + assert(token_tags[lparen] == .l_paren); + + const maybe_bang = tree.firstToken(fn_proto.ast.return_type) - 1; + const rparen = blk: { + // These may appear in any order, so we have to check the token_starts array + // to find out which is first. + var rparen = if (token_tags[maybe_bang] == .bang) maybe_bang - 1 else maybe_bang; + var smallest_start = token_starts[maybe_bang]; + if (fn_proto.ast.align_expr != 0) { + const tok = tree.firstToken(fn_proto.ast.align_expr) - 3; + const start = token_starts[tok]; + if (start < smallest_start) { + rparen = tok; + smallest_start = start; + } + } + if (fn_proto.ast.section_expr != 0) { + const tok = tree.firstToken(fn_proto.ast.section_expr) - 3; + const start = token_starts[tok]; + if (start < smallest_start) { + rparen = tok; + smallest_start = start; + } + } + if (fn_proto.ast.callconv_expr != 0) { + const tok = tree.firstToken(fn_proto.ast.callconv_expr) - 3; + const start = token_starts[tok]; + if (start < smallest_start) { + rparen = tok; + smallest_start = start; + } + } + break :blk rparen; + }; + assert(token_tags[rparen] == .r_paren); + + // The params list is a sparse set that does *not* include anytype or ... parameters. + + const trailing_comma = token_tags[rparen - 1] == .comma; + if (!trailing_comma and !hasComment(tree, lparen, rparen)) { + // Render all on one line, no trailing comma. + try renderToken(ais, tree, lparen, .none); // ( + + var param_i: usize = 0; + var last_param_token = lparen; + while (true) { + last_param_token += 1; + switch (token_tags[last_param_token]) { + .doc_comment => { + try renderToken(ais, tree, last_param_token, .newline); + continue; + }, + .ellipsis3 => { + try renderToken(ais, tree, last_param_token, .none); // ... + break; + }, + .keyword_noalias, .keyword_comptime => { + try renderToken(ais, tree, last_param_token, .space); + last_param_token += 1; + }, + .identifier => {}, + .keyword_anytype => { + try renderToken(ais, tree, last_param_token, .none); // anytype + continue; + }, + .r_paren => break, + .comma => { + try renderToken(ais, tree, last_param_token, .space); // , + continue; + }, + else => {}, // Parameter type without a name. + } + if (token_tags[last_param_token] == .identifier and + token_tags[last_param_token + 1] == .colon) + { + try renderToken(ais, tree, last_param_token, .none); // name + last_param_token += 1; + try renderToken(ais, tree, last_param_token, .space); // : + last_param_token += 1; + } + if (token_tags[last_param_token] == .keyword_anytype) { + try renderToken(ais, tree, last_param_token, .none); // anytype + continue; + } + const param = fn_proto.ast.params[param_i]; + param_i += 1; + try renderExpression(gpa, ais, tree, param, .none); + last_param_token = tree.lastToken(param); + } + } else { + // One param per line. + ais.pushIndent(); + try renderToken(ais, tree, lparen, .newline); // ( + + var param_i: usize = 0; + var last_param_token = lparen; + while (true) { + last_param_token += 1; + switch (token_tags[last_param_token]) { + .doc_comment => { + try renderToken(ais, tree, last_param_token, .newline); + continue; + }, + .ellipsis3 => { + try renderToken(ais, tree, last_param_token, .comma); // ... + break; + }, + .keyword_noalias, .keyword_comptime => { + try renderToken(ais, tree, last_param_token, .space); + last_param_token += 1; + }, + .identifier => {}, + .keyword_anytype => { + try renderToken(ais, tree, last_param_token, .comma); // anytype + if (token_tags[last_param_token + 1] == .comma) + last_param_token += 1; + continue; + }, + .r_paren => break, + else => {}, // Parameter type without a name. + } + if (token_tags[last_param_token] == .identifier and + token_tags[last_param_token + 1] == .colon) + { + try renderToken(ais, tree, last_param_token, .none); // name + last_param_token += 1; + try renderToken(ais, tree, last_param_token, .space); // : + last_param_token += 1; + } + if (token_tags[last_param_token] == .keyword_anytype) { + try renderToken(ais, tree, last_param_token, .comma); // anytype + if (token_tags[last_param_token + 1] == .comma) + last_param_token += 1; + continue; + } + const param = fn_proto.ast.params[param_i]; + param_i += 1; + try renderExpression(gpa, ais, tree, param, .comma); + last_param_token = tree.lastToken(param); + if (token_tags[last_param_token + 1] == .comma) last_param_token += 1; + } + ais.popIndent(); + } + + try renderToken(ais, tree, rparen, .space); // ) + + if (fn_proto.ast.align_expr != 0) { + const align_lparen = tree.firstToken(fn_proto.ast.align_expr) - 1; + const align_rparen = tree.lastToken(fn_proto.ast.align_expr) + 1; + + try renderToken(ais, tree, align_lparen - 1, .none); // align + try renderToken(ais, tree, align_lparen, .none); // ( + try renderExpression(gpa, ais, tree, fn_proto.ast.align_expr, .none); + try renderToken(ais, tree, align_rparen, .space); // ) + } + + if (fn_proto.ast.section_expr != 0) { + const section_lparen = tree.firstToken(fn_proto.ast.section_expr) - 1; + const section_rparen = tree.lastToken(fn_proto.ast.section_expr) + 1; + + try renderToken(ais, tree, section_lparen - 1, .none); // section + try renderToken(ais, tree, section_lparen, .none); // ( + try renderExpression(gpa, ais, tree, fn_proto.ast.section_expr, .none); + try renderToken(ais, tree, section_rparen, .space); // ) + } + + if (fn_proto.ast.callconv_expr != 0) { + const callconv_lparen = tree.firstToken(fn_proto.ast.callconv_expr) - 1; + const callconv_rparen = tree.lastToken(fn_proto.ast.callconv_expr) + 1; + + try renderToken(ais, tree, callconv_lparen - 1, .none); // callconv + try renderToken(ais, tree, callconv_lparen, .none); // ( + try renderExpression(gpa, ais, tree, fn_proto.ast.callconv_expr, .none); + try renderToken(ais, tree, callconv_rparen, .space); // ) + } else if (is_inline) { + try ais.writer().writeAll("callconv(.Inline) "); + } + + if (token_tags[maybe_bang] == .bang) { + try renderToken(ais, tree, maybe_bang, .none); // ! + } + return renderExpression(gpa, ais, tree, fn_proto.ast.return_type, space); +} + +fn renderSwitchCase( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + switch_case: ast.full.SwitchCase, + space: Space, +) Error!void { + const token_tags = tree.tokens.items(.tag); + const trailing_comma = token_tags[switch_case.ast.arrow_token - 1] == .comma; + + // Render everything before the arrow + if (switch_case.ast.values.len == 0) { + try renderToken(ais, tree, switch_case.ast.arrow_token - 1, .space); // else keyword + } else if (switch_case.ast.values.len == 1) { + // render on one line and drop the trailing comma if any + try renderExpression(gpa, ais, tree, switch_case.ast.values[0], .space); + } else if (trailing_comma or + hasComment(tree, tree.firstToken(switch_case.ast.values[0]), switch_case.ast.arrow_token)) + { + // Render each value on a new line + try renderExpressions(gpa, ais, tree, switch_case.ast.values, .comma); + } else { + // Render on one line + for (switch_case.ast.values) |value_expr| { + try renderExpression(gpa, ais, tree, value_expr, .comma_space); + } + } + + // Render the arrow and everything after it + try renderToken(ais, tree, switch_case.ast.arrow_token, .space); + + if (switch_case.payload_token) |payload_token| { + try renderToken(ais, tree, payload_token - 1, .none); // pipe + if (token_tags[payload_token] == .asterisk) { + try renderToken(ais, tree, payload_token, .none); // asterisk + try renderToken(ais, tree, payload_token + 1, .none); // identifier + try renderToken(ais, tree, payload_token + 2, .space); // pipe + } else { + try renderToken(ais, tree, payload_token, .none); // identifier + try renderToken(ais, tree, payload_token + 1, .space); // pipe + } + } + + try renderExpression(gpa, ais, tree, switch_case.ast.target_expr, space); +} + +fn renderBlock( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + block_node: ast.Node.Index, + statements: []const ast.Node.Index, + space: Space, +) Error!void { + const token_tags = tree.tokens.items(.tag); + const node_tags = tree.nodes.items(.tag); + const nodes_data = tree.nodes.items(.data); + const lbrace = tree.nodes.items(.main_token)[block_node]; + + if (token_tags[lbrace - 1] == .colon and + token_tags[lbrace - 2] == .identifier) + { + try renderToken(ais, tree, lbrace - 2, .none); + try renderToken(ais, tree, lbrace - 1, .space); + } + + ais.pushIndentNextLine(); + if (statements.len == 0) { + try renderToken(ais, tree, lbrace, .none); + } else { + try renderToken(ais, tree, lbrace, .newline); + for (statements) |stmt, i| { + if (i != 0) try renderExtraNewline(ais, tree, stmt); + switch (node_tags[stmt]) { + .global_var_decl => try renderVarDecl(gpa, ais, tree, tree.globalVarDecl(stmt)), + .local_var_decl => try renderVarDecl(gpa, ais, tree, tree.localVarDecl(stmt)), + .simple_var_decl => try renderVarDecl(gpa, ais, tree, tree.simpleVarDecl(stmt)), + .aligned_var_decl => try renderVarDecl(gpa, ais, tree, tree.alignedVarDecl(stmt)), + else => try renderExpression(gpa, ais, tree, stmt, .semicolon), + } + } + } + ais.popIndent(); + + try renderToken(ais, tree, tree.lastToken(block_node), space); // rbrace +} + +fn renderStructInit( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + struct_node: ast.Node.Index, + struct_init: ast.full.StructInit, + space: Space, +) Error!void { + const token_tags = tree.tokens.items(.tag); + if (struct_init.ast.type_expr == 0) { + try renderToken(ais, tree, struct_init.ast.lbrace - 1, .none); // . + } else { + try renderExpression(gpa, ais, tree, struct_init.ast.type_expr, .none); // T + } + if (struct_init.ast.fields.len == 0) { + ais.pushIndentNextLine(); + try renderToken(ais, tree, struct_init.ast.lbrace, .none); // lbrace + ais.popIndent(); + return renderToken(ais, tree, struct_init.ast.lbrace + 1, space); // rbrace + } + + const rbrace = tree.lastToken(struct_node); + const trailing_comma = token_tags[rbrace - 1] == .comma; + if (trailing_comma or hasComment(tree, struct_init.ast.lbrace, rbrace)) { + // Render one field init per line. + ais.pushIndentNextLine(); + try renderToken(ais, tree, struct_init.ast.lbrace, .newline); + + try renderToken(ais, tree, struct_init.ast.lbrace + 1, .none); // . + try renderToken(ais, tree, struct_init.ast.lbrace + 2, .space); // name + try renderToken(ais, tree, struct_init.ast.lbrace + 3, .space); // = + try renderExpression(gpa, ais, tree, struct_init.ast.fields[0], .comma); + + for (struct_init.ast.fields[1..]) |field_init| { + const init_token = tree.firstToken(field_init); + try renderExtraNewlineToken(ais, tree, init_token - 3); + try renderToken(ais, tree, init_token - 3, .none); // . + try renderToken(ais, tree, init_token - 2, .space); // name + try renderToken(ais, tree, init_token - 1, .space); // = + try renderExpression(gpa, ais, tree, field_init, .comma); + } + + ais.popIndent(); + } else { + // Render all on one line, no trailing comma. + try renderToken(ais, tree, struct_init.ast.lbrace, .space); + + for (struct_init.ast.fields) |field_init| { + const init_token = tree.firstToken(field_init); + try renderToken(ais, tree, init_token - 3, .none); // . + try renderToken(ais, tree, init_token - 2, .space); // name + try renderToken(ais, tree, init_token - 1, .space); // = + try renderExpression(gpa, ais, tree, field_init, .comma_space); + } + } + + return renderToken(ais, tree, rbrace, space); +} + +// TODO: handle comments between elements +fn renderArrayInit( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + array_init: ast.full.ArrayInit, + space: Space, +) Error!void { + const token_tags = tree.tokens.items(.tag); + const token_starts = tree.tokens.items(.start); + + if (array_init.ast.type_expr == 0) { + try renderToken(ais, tree, array_init.ast.lbrace - 1, .none); // . + } else { + try renderExpression(gpa, ais, tree, array_init.ast.type_expr, .none); // T + } + + if (array_init.ast.elements.len == 0) { + ais.pushIndentNextLine(); + try renderToken(ais, tree, array_init.ast.lbrace, .none); // lbrace + ais.popIndent(); + return renderToken(ais, tree, array_init.ast.lbrace + 1, space); // rbrace + } + + const last_elem = array_init.ast.elements[array_init.ast.elements.len - 1]; + const last_elem_token = tree.lastToken(last_elem); + const trailing_comma = token_tags[last_elem_token + 1] == .comma; + const rbrace = if (trailing_comma) last_elem_token + 2 else last_elem_token + 1; + assert(token_tags[rbrace] == .r_brace); + + if (array_init.ast.elements.len == 1) { + const only_elem = array_init.ast.elements[0]; + const first_token = tree.firstToken(only_elem); + if (token_tags[first_token] != .multiline_string_literal_line and + !anythingBetween(tree, last_elem_token, rbrace)) + { + try renderToken(ais, tree, array_init.ast.lbrace, .none); + try renderExpression(gpa, ais, tree, only_elem, .none); + return renderToken(ais, tree, rbrace, space); + } + } + + const contains_newlines = !tree.tokensOnSameLine(array_init.ast.lbrace, rbrace); + + if (!trailing_comma and !contains_newlines) { + // Render all on one line, no trailing comma. + if (array_init.ast.elements.len == 1) { + // If there is only one element, we don't use spaces + try renderToken(ais, tree, array_init.ast.lbrace, .none); + try renderExpression(gpa, ais, tree, array_init.ast.elements[0], .none); + } else { + try renderToken(ais, tree, array_init.ast.lbrace, .space); + for (array_init.ast.elements) |elem| { + try renderExpression(gpa, ais, tree, elem, .comma_space); + } + } + return renderToken(ais, tree, last_elem_token + 1, space); // rbrace + } + + ais.pushIndentNextLine(); + try renderToken(ais, tree, array_init.ast.lbrace, .newline); + + var expr_index: usize = 0; + while (rowSize(tree, array_init.ast.elements[expr_index..], rbrace)) |row_size| { + const row_exprs = array_init.ast.elements[expr_index..]; + // A place to store the width of each expression and its column's maximum + const widths = try gpa.alloc(usize, row_exprs.len + row_size); + defer gpa.free(widths); + mem.set(usize, widths, 0); + + const expr_newlines = try gpa.alloc(bool, row_exprs.len); + defer gpa.free(expr_newlines); + mem.set(bool, expr_newlines, false); + + const expr_widths = widths[0..row_exprs.len]; + const column_widths = widths[row_exprs.len..]; + + // Find next row with trailing comment (if any) to end the current section. + const section_end = sec_end: { + var this_line_first_expr: usize = 0; + var this_line_size = rowSize(tree, row_exprs, rbrace); + for (row_exprs) |expr, i| { + // Ignore comment on first line of this section. + if (i == 0) continue; + const expr_last_token = tree.lastToken(expr); + if (tree.tokensOnSameLine(tree.firstToken(row_exprs[0]), expr_last_token)) + continue; + // Track start of line containing comment. + if (!tree.tokensOnSameLine(tree.firstToken(row_exprs[this_line_first_expr]), expr_last_token)) { + this_line_first_expr = i; + this_line_size = rowSize(tree, row_exprs[this_line_first_expr..], rbrace); + } + + const maybe_comma = expr_last_token + 1; + if (token_tags[maybe_comma] == .comma) { + if (hasSameLineComment(tree, maybe_comma)) + break :sec_end i - this_line_size.? + 1; + } + } + break :sec_end row_exprs.len; + }; + expr_index += section_end; + + const section_exprs = row_exprs[0..section_end]; + + var sub_expr_buffer = std.ArrayList(u8).init(gpa); + defer sub_expr_buffer.deinit(); + + var auto_indenting_stream = Ais{ + .indent_delta = indent_delta, + .underlying_writer = sub_expr_buffer.writer(), }; - { - ais.pushIndent(); - defer ais.popIndent(); - try renderToken(tree, ais, eq_token, eq_space); // = - } - ais.pushIndentOneShot(); - try renderExpression(allocator, ais, tree, init_node, Space.None); - } + // Calculate size of columns in current section + var column_counter: usize = 0; + var single_line = true; + var contains_newline = false; + for (section_exprs) |expr, i| { + sub_expr_buffer.shrinkRetainingCapacity(0); + if (i + 1 < section_exprs.len) { + try renderExpression(gpa, &auto_indenting_stream, tree, expr, .none); + const width = sub_expr_buffer.items.len; + const this_contains_newline = mem.indexOfScalar(u8, sub_expr_buffer.items, '\n') != null; + contains_newline = contains_newline or this_contains_newline; + expr_widths[i] = width; + expr_newlines[i] = this_contains_newline; - try renderToken(tree, ais, var_decl.semicolon_token, Space.Newline); -} + if (!this_contains_newline) { + const column = column_counter % row_size; + column_widths[column] = std.math.max(column_widths[column], width); -fn renderParamDecl( - allocator: *mem.Allocator, - ais: anytype, - tree: *ast.Tree, - param_decl: ast.Node.FnProto.ParamDecl, - space: Space, -) (@TypeOf(ais.*).Error || Error)!void { - try renderDocComments(tree, ais, param_decl, param_decl.doc_comments); - - if (param_decl.comptime_token) |comptime_token| { - try renderToken(tree, ais, comptime_token, Space.Space); - } - if (param_decl.noalias_token) |noalias_token| { - try renderToken(tree, ais, noalias_token, Space.Space); - } - if (param_decl.name_token) |name_token| { - try renderToken(tree, ais, name_token, Space.None); - try renderToken(tree, ais, tree.nextToken(name_token), Space.Space); // : - } - switch (param_decl.param_type) { - .any_type, .type_expr => |node| try renderExpression(allocator, ais, tree, node, space), - } -} - -fn renderStatement( - allocator: *mem.Allocator, - ais: anytype, - tree: *ast.Tree, - base: *ast.Node, -) (@TypeOf(ais.*).Error || Error)!void { - switch (base.tag) { - .VarDecl => { - const var_decl = @fieldParentPtr(ast.Node.VarDecl, "base", base); - try renderVarDecl(allocator, ais, tree, var_decl); - }, - else => { - if (base.requireSemiColon()) { - try renderExpression(allocator, ais, tree, base, Space.None); - - const semicolon_index = tree.nextToken(base.lastToken()); - assert(tree.token_ids[semicolon_index] == .Semicolon); - try renderToken(tree, ais, semicolon_index, Space.Newline); + const expr_last_token = tree.lastToken(expr) + 1; + const next_expr = section_exprs[i + 1]; + column_counter += 1; + if (!tree.tokensOnSameLine(expr_last_token, tree.firstToken(next_expr))) single_line = false; + } else { + single_line = false; + column_counter = 0; + } } else { - try renderExpression(allocator, ais, tree, base, Space.Newline); + try renderExpression(gpa, &auto_indenting_stream, tree, expr, .none); + const width = sub_expr_buffer.items.len; + contains_newline = contains_newline or mem.indexOfScalar(u8, sub_expr_buffer.items, '\n') != null; + expr_widths[i] = width; + expr_newlines[i] = contains_newline; + + if (!contains_newline) { + const column = column_counter % row_size; + column_widths[column] = std.math.max(column_widths[column], width); + } + break; + } + } + + // Render exprs in current section. + column_counter = 0; + var last_col_index: usize = row_size - 1; + for (section_exprs) |expr, i| { + if (i + 1 < section_exprs.len) { + const next_expr = section_exprs[i + 1]; + try renderExpression(gpa, ais, tree, expr, .none); + + const comma = tree.lastToken(expr) + 1; + + if (column_counter != last_col_index) { + if (!expr_newlines[i] and !expr_newlines[i + 1]) { + // Neither the current or next expression is multiline + try renderToken(ais, tree, comma, .space); // , + assert(column_widths[column_counter % row_size] >= expr_widths[i]); + const padding = column_widths[column_counter % row_size] - expr_widths[i]; + try ais.writer().writeByteNTimes(' ', padding); + + column_counter += 1; + continue; + } + } + if (single_line and row_size != 1) { + try renderToken(ais, tree, comma, .space); // , + continue; + } + + column_counter = 0; + try renderToken(ais, tree, comma, .newline); // , + try renderExtraNewline(ais, tree, next_expr); + } else { + try renderExpression(gpa, ais, tree, expr, .comma); // , + } + } + + if (expr_index == array_init.ast.elements.len) + break; + } + + ais.popIndent(); + return renderToken(ais, tree, rbrace, space); // rbrace +} + +fn renderContainerDecl( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + container_decl_node: ast.Node.Index, + container_decl: ast.full.ContainerDecl, + space: Space, +) Error!void { + const token_tags = tree.tokens.items(.tag); + const node_tags = tree.nodes.items(.tag); + + if (container_decl.layout_token) |layout_token| { + try renderToken(ais, tree, layout_token, .space); + } + + var lbrace: ast.TokenIndex = undefined; + if (container_decl.ast.enum_token) |enum_token| { + try renderToken(ais, tree, container_decl.ast.main_token, .none); // union + try renderToken(ais, tree, enum_token - 1, .none); // lparen + try renderToken(ais, tree, enum_token, .none); // enum + if (container_decl.ast.arg != 0) { + try renderToken(ais, tree, enum_token + 1, .none); // lparen + try renderExpression(gpa, ais, tree, container_decl.ast.arg, .none); + const rparen = tree.lastToken(container_decl.ast.arg) + 1; + try renderToken(ais, tree, rparen, .none); // rparen + try renderToken(ais, tree, rparen + 1, .space); // rparen + lbrace = rparen + 2; + } else { + try renderToken(ais, tree, enum_token + 1, .space); // rparen + lbrace = enum_token + 2; + } + } else if (container_decl.ast.arg != 0) { + try renderToken(ais, tree, container_decl.ast.main_token, .none); // union + try renderToken(ais, tree, container_decl.ast.main_token + 1, .none); // lparen + try renderExpression(gpa, ais, tree, container_decl.ast.arg, .none); + const rparen = tree.lastToken(container_decl.ast.arg) + 1; + try renderToken(ais, tree, rparen, .space); // rparen + lbrace = rparen + 1; + } else { + try renderToken(ais, tree, container_decl.ast.main_token, .space); // union + lbrace = container_decl.ast.main_token + 1; + } + + const rbrace = tree.lastToken(container_decl_node); + if (container_decl.ast.members.len == 0) { + ais.pushIndentNextLine(); + if (token_tags[lbrace + 1] == .container_doc_comment) { + try renderToken(ais, tree, lbrace, .newline); // lbrace + try renderContainerDocComments(ais, tree, lbrace + 1); + } else { + try renderToken(ais, tree, lbrace, .none); // lbrace + } + ais.popIndent(); + return renderToken(ais, tree, rbrace, space); // rbrace + } + + const src_has_trailing_comma = token_tags[rbrace - 1] == .comma; + if (!src_has_trailing_comma) one_line: { + // We can only print all the members in-line if all the members are fields. + for (container_decl.ast.members) |member| { + if (!node_tags[member].isContainerField()) break :one_line; + } + // All the declarations on the same line. + try renderToken(ais, tree, lbrace, .space); // lbrace + for (container_decl.ast.members) |member| { + try renderMember(gpa, ais, tree, member, .space); + } + return renderToken(ais, tree, rbrace, space); // rbrace + } + + // One member per line. + ais.pushIndentNextLine(); + try renderToken(ais, tree, lbrace, .newline); // lbrace + if (token_tags[lbrace + 1] == .container_doc_comment) { + try renderContainerDocComments(ais, tree, lbrace + 1); + } + try renderMembers(gpa, ais, tree, container_decl.ast.members); + ais.popIndent(); + + return renderToken(ais, tree, rbrace, space); // rbrace +} + +fn renderAsm( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + asm_node: ast.full.Asm, + space: Space, +) Error!void { + const token_tags = tree.tokens.items(.tag); + + try renderToken(ais, tree, asm_node.ast.asm_token, .space); // asm + + if (asm_node.volatile_token) |volatile_token| { + try renderToken(ais, tree, volatile_token, .space); // volatile + try renderToken(ais, tree, volatile_token + 1, .none); // lparen + } else { + try renderToken(ais, tree, asm_node.ast.asm_token + 1, .none); // lparen + } + + if (asm_node.ast.items.len == 0) { + ais.pushIndent(); + if (asm_node.first_clobber) |first_clobber| { + // asm ("foo" ::: "a", "b") + // asm ("foo" ::: "a", "b",) + try renderExpression(gpa, ais, tree, asm_node.ast.template, .space); + // Render the three colons. + try renderToken(ais, tree, first_clobber - 3, .none); + try renderToken(ais, tree, first_clobber - 2, .none); + try renderToken(ais, tree, first_clobber - 1, .space); + + var tok_i = first_clobber; + while (true) : (tok_i += 1) { + try renderToken(ais, tree, tok_i, .none); + tok_i += 1; + switch (token_tags[tok_i]) { + .r_paren => { + ais.popIndent(); + return renderToken(ais, tree, tok_i, space); + }, + .comma => { + if (token_tags[tok_i + 1] == .r_paren) { + ais.popIndent(); + return renderToken(ais, tree, tok_i + 1, space); + } else { + try renderToken(ais, tree, tok_i, .space); + } + }, + else => unreachable, + } + } + } else { + // asm ("foo") + try renderExpression(gpa, ais, tree, asm_node.ast.template, .none); + ais.popIndent(); + return renderToken(ais, tree, asm_node.ast.rparen, space); // rparen + } + } + + ais.pushIndent(); + try renderExpression(gpa, ais, tree, asm_node.ast.template, .newline); + ais.setIndentDelta(asm_indent_delta); + const colon1 = tree.lastToken(asm_node.ast.template) + 1; + + const colon2 = if (asm_node.outputs.len == 0) colon2: { + try renderToken(ais, tree, colon1, .newline); // : + break :colon2 colon1 + 1; + } else colon2: { + try renderToken(ais, tree, colon1, .space); // : + + ais.pushIndent(); + for (asm_node.outputs) |asm_output, i| { + if (i + 1 < asm_node.outputs.len) { + const next_asm_output = asm_node.outputs[i + 1]; + try renderAsmOutput(gpa, ais, tree, asm_output, .none); + + const comma = tree.firstToken(next_asm_output) - 1; + try renderToken(ais, tree, comma, .newline); // , + try renderExtraNewlineToken(ais, tree, tree.firstToken(next_asm_output)); + } else if (asm_node.inputs.len == 0 and asm_node.first_clobber == null) { + try renderAsmOutput(gpa, ais, tree, asm_output, .newline); + ais.popIndent(); + ais.setIndentDelta(indent_delta); + ais.popIndent(); + return renderToken(ais, tree, asm_node.ast.rparen, space); // rparen + } else { + try renderAsmOutput(gpa, ais, tree, asm_output, .newline); + const comma_or_colon = tree.lastToken(asm_output) + 1; + ais.popIndent(); + break :colon2 switch (token_tags[comma_or_colon]) { + .comma => comma_or_colon + 1, + else => comma_or_colon, + }; + } + } else unreachable; + }; + + const colon3 = if (asm_node.inputs.len == 0) colon3: { + try renderToken(ais, tree, colon2, .newline); // : + break :colon3 colon2 + 1; + } else colon3: { + try renderToken(ais, tree, colon2, .space); // : + ais.pushIndent(); + for (asm_node.inputs) |asm_input, i| { + if (i + 1 < asm_node.inputs.len) { + const next_asm_input = asm_node.inputs[i + 1]; + try renderAsmInput(gpa, ais, tree, asm_input, .none); + + const first_token = tree.firstToken(next_asm_input); + try renderToken(ais, tree, first_token - 1, .newline); // , + try renderExtraNewlineToken(ais, tree, first_token); + } else if (asm_node.first_clobber == null) { + try renderAsmInput(gpa, ais, tree, asm_input, .newline); + ais.popIndent(); + ais.setIndentDelta(indent_delta); + ais.popIndent(); + return renderToken(ais, tree, asm_node.ast.rparen, space); // rparen + } else { + try renderAsmInput(gpa, ais, tree, asm_input, .newline); + const comma_or_colon = tree.lastToken(asm_input) + 1; + ais.popIndent(); + break :colon3 switch (token_tags[comma_or_colon]) { + .comma => comma_or_colon + 1, + else => comma_or_colon, + }; + } + } + unreachable; + }; + + try renderToken(ais, tree, colon3, .space); // : + const first_clobber = asm_node.first_clobber.?; + var tok_i = first_clobber; + while (true) { + switch (token_tags[tok_i + 1]) { + .r_paren => { + ais.setIndentDelta(indent_delta); + ais.popIndent(); + try renderToken(ais, tree, tok_i, .newline); + return renderToken(ais, tree, tok_i + 1, space); + }, + .comma => { + try renderToken(ais, tree, tok_i, .none); + try renderToken(ais, tree, tok_i + 1, .space); + tok_i += 2; + }, + else => unreachable, + } + } else unreachable; // TODO shouldn't need this on while(true) +} + +fn renderCall( + gpa: *Allocator, + ais: *Ais, + tree: ast.Tree, + call: ast.full.Call, + space: Space, +) Error!void { + const token_tags = tree.tokens.items(.tag); + const main_tokens = tree.nodes.items(.main_token); + + if (call.async_token) |async_token| { + try renderToken(ais, tree, async_token, .space); + } + try renderExpression(gpa, ais, tree, call.ast.fn_expr, .none); + + const lparen = call.ast.lparen; + const params = call.ast.params; + if (params.len == 0) { + ais.pushIndentNextLine(); + try renderToken(ais, tree, lparen, .none); + ais.popIndent(); + return renderToken(ais, tree, lparen + 1, space); // ) + } + + const last_param = params[params.len - 1]; + const after_last_param_tok = tree.lastToken(last_param) + 1; + if (token_tags[after_last_param_tok] == .comma) { + ais.pushIndentNextLine(); + try renderToken(ais, tree, lparen, .newline); // ( + for (params) |param_node, i| { + if (i + 1 < params.len) { + try renderExpression(gpa, ais, tree, param_node, .none); + + // Unindent the comma for multiline string literals. + const is_multiline_string = + token_tags[tree.firstToken(param_node)] == .multiline_string_literal_line; + if (is_multiline_string) ais.popIndent(); + + const comma = tree.lastToken(param_node) + 1; + try renderToken(ais, tree, comma, .newline); // , + + if (is_multiline_string) ais.pushIndent(); + + try renderExtraNewline(ais, tree, params[i + 1]); + } else { + try renderExpression(gpa, ais, tree, param_node, .comma); + } + } + ais.popIndent(); + return renderToken(ais, tree, after_last_param_tok + 1, space); // ) + } + + try renderToken(ais, tree, lparen, .none); // ( + + for (params) |param_node, i| { + const first_param_token = tree.firstToken(param_node); + if (token_tags[first_param_token] == .multiline_string_literal_line or + hasSameLineComment(tree, first_param_token - 1)) + { + ais.pushIndentOneShot(); + } + try renderExpression(gpa, ais, tree, param_node, .none); + + if (i + 1 < params.len) { + const comma = tree.lastToken(param_node) + 1; + const next_multiline_string = + token_tags[tree.firstToken(params[i + 1])] == .multiline_string_literal_line; + const comma_space: Space = if (next_multiline_string) .none else .space; + try renderToken(ais, tree, comma, comma_space); + } + } + + return renderToken(ais, tree, after_last_param_tok, space); // ) +} + +/// Renders the given expression indented, popping the indent before rendering +/// any following line comments +fn renderExpressionIndented(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Space) Error!void { + const token_starts = tree.tokens.items(.start); + const token_tags = tree.tokens.items(.tag); + + ais.pushIndent(); + + var last_token = tree.lastToken(node); + const punctuation = switch (space) { + .none, .space, .newline, .skip => false, + .comma => true, + .comma_space => token_tags[last_token + 1] == .comma, + .semicolon => token_tags[last_token + 1] == .semicolon, + }; + + try renderExpression(gpa, ais, tree, node, if (punctuation) .none else .skip); + + switch (space) { + .none, .space, .newline, .skip => {}, + .comma => { + if (token_tags[last_token + 1] == .comma) { + try renderToken(ais, tree, last_token + 1, .skip); + last_token += 1; + } else { + try ais.writer().writeByte(','); } }, + .comma_space => if (token_tags[last_token + 1] == .comma) { + try renderToken(ais, tree, last_token + 1, .skip); + last_token += 1; + }, + .semicolon => if (token_tags[last_token + 1] == .semicolon) { + try renderToken(ais, tree, last_token + 1, .skip); + last_token += 1; + }, + } + + ais.popIndent(); + + if (space == .skip) return; + + const comment_start = token_starts[last_token] + tokenSliceForRender(tree, last_token).len; + const comment = try renderComments(ais, tree, comment_start, token_starts[last_token + 1]); + + if (!comment) switch (space) { + .none => {}, + .space, + .comma_space, + => try ais.writer().writeByte(' '), + .newline, + .comma, + .semicolon, + => try ais.insertNewline(), + .skip => unreachable, + }; +} + +/// Render an expression, and the comma that follows it, if it is present in the source. +fn renderExpressionComma(gpa: *Allocator, ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Space) Error!void { + const token_tags = tree.tokens.items(.tag); + const maybe_comma = tree.lastToken(node) + 1; + if (token_tags[maybe_comma] == .comma) { + try renderExpression(gpa, ais, tree, node, .none); + return renderToken(ais, tree, maybe_comma, space); + } else { + return renderExpression(gpa, ais, tree, node, space); + } +} + +fn renderTokenComma(ais: *Ais, tree: ast.Tree, token: ast.TokenIndex, space: Space) Error!void { + const token_tags = tree.tokens.items(.tag); + const maybe_comma = token + 1; + if (token_tags[maybe_comma] == .comma) { + try renderToken(ais, tree, token, .none); + return renderToken(ais, tree, maybe_comma, space); + } else { + return renderToken(ais, tree, token, space); } } const Space = enum { - None, - Newline, - Comma, - Space, - SpaceOrOutdent, - NoNewline, - NoComment, - BlockStart, + /// Output the token lexeme only. + none, + /// Output the token lexeme followed by a single space. + space, + /// Output the token lexeme followed by a newline. + newline, + /// If the next token is a comma, render it as well. If not, insert one. + /// In either case, a newline will be inserted afterwards. + comma, + /// Additionally consume the next token if it is a comma. + /// In either case, a space will be inserted afterwards. + comma_space, + /// Additionally consume the next token if it is a semicolon. + /// In either case, a newline will be inserted afterwards. + semicolon, + /// Skip rendering whitespace and comments. If this is used, the caller + /// *must* handle handle whitespace and comments manually. + skip, }; -fn renderTokenOffset( - tree: *ast.Tree, - ais: anytype, - token_index: ast.TokenIndex, - space: Space, - token_skip_bytes: usize, -) (@TypeOf(ais.*).Error || Error)!void { - if (space == Space.BlockStart) { - // If placing the lbrace on the current line would cause an uggly gap then put the lbrace on the next line - const new_space = if (ais.isLineOverIndented()) Space.Newline else Space.Space; - return renderToken(tree, ais, token_index, new_space); +fn renderToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex, space: Space) Error!void { + const token_tags = tree.tokens.items(.tag); + const token_starts = tree.tokens.items(.start); + + const token_start = token_starts[token_index]; + const lexeme = tokenSliceForRender(tree, token_index); + + try ais.writer().writeAll(lexeme); + + if (space == .skip) return; + + if (space == .comma and token_tags[token_index + 1] != .comma) { + try ais.writer().writeByte(','); } - var token_loc = tree.token_locs[token_index]; - try ais.writer().writeAll(mem.trimRight(u8, tree.tokenSliceLoc(token_loc)[token_skip_bytes..], " ")); + const comment = try renderComments(ais, tree, token_start + lexeme.len, token_starts[token_index + 1]); + switch (space) { + .none => {}, + .space => if (!comment) try ais.writer().writeByte(' '), + .newline => if (!comment) try ais.insertNewline(), - if (space == Space.NoComment) - return; - - var next_token_id = tree.token_ids[token_index + 1]; - var next_token_loc = tree.token_locs[token_index + 1]; - - if (space == Space.Comma) switch (next_token_id) { - .Comma => return renderToken(tree, ais, token_index + 1, Space.Newline), - .LineComment => { - try ais.writer().writeAll(", "); - return renderToken(tree, ais, token_index + 1, Space.Newline); + .comma => if (token_tags[token_index + 1] == .comma) { + try renderToken(ais, tree, token_index + 1, .newline); + } else if (!comment) { + try ais.insertNewline(); }, - else => { - if (token_index + 2 < tree.token_ids.len and - tree.token_ids[token_index + 2] == .MultilineStringLiteralLine) - { - try ais.writer().writeAll(","); - return; - } else { - try ais.writer().writeAll(","); - try ais.insertNewline(); - return; - } - }, - }; - // Skip over same line doc comments - var offset: usize = 1; - if (next_token_id == .DocComment) { - const loc = tree.tokenLocationLoc(token_loc.end, next_token_loc); - if (loc.line == 0) { - offset += 1; - next_token_id = tree.token_ids[token_index + offset]; - next_token_loc = tree.token_locs[token_index + offset]; - } - } - - if (next_token_id != .LineComment) { - switch (space) { - Space.None, Space.NoNewline => return, - Space.Newline => { - if (next_token_id == .MultilineStringLiteralLine) { - return; - } else { - try ais.insertNewline(); - return; - } - }, - Space.Space, Space.SpaceOrOutdent => { - if (next_token_id == .MultilineStringLiteralLine) - return; - try ais.writer().writeByte(' '); - return; - }, - Space.NoComment, Space.Comma, Space.BlockStart => unreachable, - } - } - - while (true) { - const comment_is_empty = mem.trimRight(u8, tree.tokenSliceLoc(next_token_loc), " ").len == 2; - if (comment_is_empty) { - switch (space) { - Space.Newline => { - offset += 1; - token_loc = next_token_loc; - next_token_id = tree.token_ids[token_index + offset]; - next_token_loc = tree.token_locs[token_index + offset]; - if (next_token_id != .LineComment) { - try ais.insertNewline(); - return; - } - }, - else => break, - } - } else { - break; - } - } - - var loc = tree.tokenLocationLoc(token_loc.end, next_token_loc); - if (loc.line == 0) { - if (tree.token_ids[token_index] != .MultilineStringLiteralLine) { + .comma_space => if (token_tags[token_index + 1] == .comma) { + try renderToken(ais, tree, token_index + 1, .space); + } else if (!comment) { try ais.writer().writeByte(' '); - } - try ais.writer().writeAll(mem.trimRight(u8, tree.tokenSliceLoc(next_token_loc), " ")); - offset = 2; - token_loc = next_token_loc; - next_token_loc = tree.token_locs[token_index + offset]; - next_token_id = tree.token_ids[token_index + offset]; - if (next_token_id != .LineComment) { - switch (space) { - .None, .Space, .SpaceOrOutdent => { - try ais.insertNewline(); - }, - .Newline => { - if (next_token_id == .MultilineStringLiteralLine) { - return; - } else { - try ais.insertNewline(); - return; - } - }, - .NoNewline => {}, - .NoComment, .Comma, .BlockStart => unreachable, + }, + + .semicolon => if (token_tags[token_index + 1] == .semicolon) { + try renderToken(ais, tree, token_index + 1, .newline); + } else if (!comment) { + try ais.insertNewline(); + }, + + .skip => unreachable, + } +} + +/// Returns true if there exists a comment between the start of token +/// `start_token` and the start of token `end_token`. This is used to determine +/// if e.g. a fn_proto should be wrapped and have a trailing comma inserted +/// even if there is none in the source. +fn hasComment(tree: ast.Tree, start_token: ast.TokenIndex, end_token: ast.TokenIndex) bool { + const token_starts = tree.tokens.items(.start); + + const start = token_starts[start_token]; + const end = token_starts[end_token]; + + return mem.indexOf(u8, tree.source[start..end], "//") != null; +} + +/// Assumes that start is the first byte past the previous token and +/// that end is the last byte before the next token. +fn renderComments(ais: *Ais, tree: ast.Tree, start: usize, end: usize) Error!bool { + var index: usize = start; + while (mem.indexOf(u8, tree.source[index..end], "//")) |offset| { + const comment_start = index + offset; + + // If there is no newline, the comment ends with EOF + const newline_index = mem.indexOfScalar(u8, tree.source[comment_start..end], '\n'); + const newline = if (newline_index) |i| comment_start + i else null; + + const untrimmed_comment = tree.source[comment_start .. newline orelse tree.source.len]; + const trimmed_comment = mem.trimRight(u8, untrimmed_comment, &std.ascii.spaces); + + // Don't leave any whitespace at the start of the file + if (index != 0) { + if (index == start and mem.containsAtLeast(u8, tree.source[index..comment_start], 2, "\n")) { + // Leave up to one empty line before the first comment + try ais.insertNewline(); + try ais.insertNewline(); + } else if (mem.indexOfScalar(u8, tree.source[index..comment_start], '\n') != null) { + // Respect the newline directly before the comment. + // Note: This allows an empty line between comments + try ais.insertNewline(); + } else if (index == start) { + // Otherwise if the first comment is on the same line as + // the token before it, prefix it with a single space. + try ais.writer().writeByte(' '); } - return; } - loc = tree.tokenLocationLoc(token_loc.end, next_token_loc); - } - while (true) { - // translate-c doesn't generate correct newlines - // in generated code (loc.line == 0) so treat that case - // as though there was meant to be a newline between the tokens - var newline_count = if (loc.line <= 1) @as(u8, 1) else @as(u8, 2); - while (newline_count > 0) : (newline_count -= 1) try ais.insertNewline(); - try ais.writer().writeAll(mem.trimRight(u8, tree.tokenSliceLoc(next_token_loc), " ")); + try ais.writer().print("{s}\n", .{trimmed_comment}); + index = 1 + (newline orelse return true); - offset += 1; - token_loc = next_token_loc; - next_token_loc = tree.token_locs[token_index + offset]; - next_token_id = tree.token_ids[token_index + offset]; - if (next_token_id != .LineComment) { - switch (space) { - .Newline => { - if (next_token_id == .MultilineStringLiteralLine) { - return; - } else { - try ais.insertNewline(); - return; - } - }, - .None, .Space, .SpaceOrOutdent => { - try ais.insertNewline(); - }, - .NoNewline => {}, - .NoComment, .Comma, .BlockStart => unreachable, + if (ais.disabled_offset) |disabled_offset| { + if (mem.eql(u8, trimmed_comment, "// zig fmt: on")) { + // write the source for which formatting was disabled directly + // to the underlying writer, fixing up invaild whitespace + try writeFixingWhitespace(ais.underlying_writer, tree.source[disabled_offset..index]); + ais.disabled_offset = null; } - return; + } else if (mem.eql(u8, trimmed_comment, "// zig fmt: off")) { + ais.disabled_offset = index; } - loc = tree.tokenLocationLoc(token_loc.end, next_token_loc); + } + + if (index != start and mem.containsAtLeast(u8, tree.source[index - 1 .. end], 2, "\n")) { + try ais.insertNewline(); + } + + return index != start; +} + +fn renderExtraNewline(ais: *Ais, tree: ast.Tree, node: ast.Node.Index) Error!void { + return renderExtraNewlineToken(ais, tree, tree.firstToken(node)); +} + +/// Check if there is an empty line immediately before the given token. If so, render it. +fn renderExtraNewlineToken(ais: *Ais, tree: ast.Tree, token_index: ast.TokenIndex) Error!void { + const token_starts = tree.tokens.items(.start); + const token_start = token_starts[token_index]; + if (token_start == 0) return; + const prev_token_end = if (token_index == 0) + 0 + else + token_starts[token_index - 1] + tokenSliceForRender(tree, token_index - 1).len; + + // If there is a comment present, it will handle the empty line + if (mem.indexOf(u8, tree.source[prev_token_end..token_start], "//") != null) return; + + // Iterate backwards to the end of the previous token, stopping if a + // non-whitespace character is encountered or two newlines have been found. + var i = token_start - 1; + var newlines: u2 = 0; + while (std.ascii.isSpace(tree.source[i])) : (i -= 1) { + if (tree.source[i] == '\n') newlines += 1; + if (newlines == 2) return ais.insertNewline(); + if (i == prev_token_end) break; } } -fn renderToken( - tree: *ast.Tree, - ais: anytype, - token_index: ast.TokenIndex, - space: Space, -) (@TypeOf(ais.*).Error || Error)!void { - return renderTokenOffset(tree, ais, token_index, space, 0); -} +/// end_token is the token one past the last doc comment token. This function +/// searches backwards from there. +fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error!void { + // Search backwards for the first doc comment. + const token_tags = tree.tokens.items(.tag); + if (end_token == 0) return; + var tok = end_token - 1; + while (token_tags[tok] == .doc_comment) { + if (tok == 0) break; + tok -= 1; + } else { + tok += 1; + } + const first_tok = tok; + if (first_tok == end_token) return; + try renderExtraNewlineToken(ais, tree, first_tok); -fn renderDocComments( - tree: *ast.Tree, - ais: anytype, - node: anytype, - doc_comments: ?*ast.Node.DocComment, -) (@TypeOf(ais.*).Error || Error)!void { - const comment = doc_comments orelse return; - return renderDocCommentsToken(tree, ais, comment, node.firstToken()); -} - -fn renderDocCommentsToken( - tree: *ast.Tree, - ais: anytype, - comment: *ast.Node.DocComment, - first_token: ast.TokenIndex, -) (@TypeOf(ais.*).Error || Error)!void { - var tok_i = comment.first_line; - while (true) : (tok_i += 1) { - switch (tree.token_ids[tok_i]) { - .DocComment, .ContainerDocComment => { - if (comment.first_line < first_token) { - try renderToken(tree, ais, tok_i, Space.Newline); - } else { - try renderToken(tree, ais, tok_i, Space.NoComment); - try ais.insertNewline(); - } - }, - .LineComment => continue, - else => break, - } + while (token_tags[tok] == .doc_comment) : (tok += 1) { + try renderToken(ais, tree, tok, .newline); } } -fn nodeIsBlock(base: *const ast.Node) bool { - return switch (base.tag) { - .Block, - .LabeledBlock, - .If, - .For, - .While, - .Switch, - => true, - else => false, - }; +/// start_token is first container doc comment token. +fn renderContainerDocComments(ais: *Ais, tree: ast.Tree, start_token: ast.TokenIndex) Error!void { + const token_tags = tree.tokens.items(.tag); + var tok = start_token; + while (token_tags[tok] == .container_doc_comment) : (tok += 1) { + try renderToken(ais, tree, tok, .newline); + } + // Render extra newline if there is one between final container doc comment and + // the next token. If the next token is a doc comment, that code path + // will have its own logic to insert a newline. + if (token_tags[tok] != .doc_comment) { + try renderExtraNewlineToken(ais, tree, tok); + } } -fn nodeCausesSliceOpSpace(base: *ast.Node) bool { - return switch (base.tag) { - .Catch, - .Add, - .AddWrap, - .ArrayCat, - .ArrayMult, - .Assign, - .AssignBitAnd, - .AssignBitOr, - .AssignBitShiftLeft, - .AssignBitShiftRight, - .AssignBitXor, - .AssignDiv, - .AssignSub, - .AssignSubWrap, - .AssignMod, - .AssignAdd, - .AssignAddWrap, - .AssignMul, - .AssignMulWrap, - .BangEqual, - .BitAnd, - .BitOr, - .BitShiftLeft, - .BitShiftRight, - .BitXor, - .BoolAnd, - .BoolOr, - .Div, - .EqualEqual, - .ErrorUnion, - .GreaterOrEqual, - .GreaterThan, - .LessOrEqual, - .LessThan, - .MergeErrorSets, - .Mod, - .Mul, - .MulWrap, - .Range, - .Sub, - .SubWrap, - .OrElse, - => true, - - else => false, - }; +fn tokenSliceForRender(tree: ast.Tree, token_index: ast.TokenIndex) []const u8 { + var ret = tree.tokenSlice(token_index); + if (tree.tokens.items(.tag)[token_index] == .multiline_string_literal_line) { + assert(ret[ret.len - 1] == '\n'); + ret.len -= 1; + } + return ret; } -fn copyFixingWhitespace(ais: anytype, slice: []const u8) @TypeOf(ais.*).Error!void { +fn hasSameLineComment(tree: ast.Tree, token_index: ast.TokenIndex) bool { + const token_starts = tree.tokens.items(.start); + const between_source = tree.source[token_starts[token_index]..token_starts[token_index + 1]]; + for (between_source) |byte| switch (byte) { + '\n' => return false, + '/' => return true, + else => continue, + }; + return false; +} + +/// Returns `true` if and only if there are any tokens or line comments between +/// start_token and end_token. +fn anythingBetween(tree: ast.Tree, start_token: ast.TokenIndex, end_token: ast.TokenIndex) bool { + if (start_token + 1 != end_token) return true; + const token_starts = tree.tokens.items(.start); + const between_source = tree.source[token_starts[start_token]..token_starts[start_token + 1]]; + for (between_source) |byte| switch (byte) { + '/' => return true, + else => continue, + }; + return false; +} + +fn writeFixingWhitespace(writer: std.ArrayList(u8).Writer, slice: []const u8) Error!void { for (slice) |byte| switch (byte) { - '\t' => try ais.writer().writeAll(" "), + '\t' => try writer.writeAll(" " ** 4), '\r' => {}, - else => try ais.writer().writeByte(byte), + else => try writer.writeByte(byte), + }; +} + +fn nodeIsBlock(tag: ast.Node.Tag) bool { + return switch (tag) { + .block, + .block_semicolon, + .block_two, + .block_two_semicolon, + .@"if", + .if_simple, + .@"for", + .for_simple, + .@"while", + .while_simple, + .while_cont, + .@"switch", + .switch_comma, + => true, + else => false, + }; +} + +fn nodeIsIf(tag: ast.Node.Tag) bool { + return switch (tag) { + .@"if", .if_simple => true, + else => false, + }; +} + +fn nodeCausesSliceOpSpace(tag: ast.Node.Tag) bool { + return switch (tag) { + .@"catch", + .add, + .add_wrap, + .array_cat, + .array_mult, + .assign, + .assign_bit_and, + .assign_bit_or, + .assign_bit_shift_left, + .assign_bit_shift_right, + .assign_bit_xor, + .assign_div, + .assign_sub, + .assign_sub_wrap, + .assign_mod, + .assign_add, + .assign_add_wrap, + .assign_mul, + .assign_mul_wrap, + .bang_equal, + .bit_and, + .bit_or, + .bit_shift_left, + .bit_shift_right, + .bit_xor, + .bool_and, + .bool_or, + .div, + .equal_equal, + .error_union, + .greater_or_equal, + .greater_than, + .less_or_equal, + .less_than, + .merge_error_sets, + .mod, + .mul, + .mul_wrap, + .sub, + .sub_wrap, + .@"orelse", + => true, + + else => false, }; } // Returns the number of nodes in `expr` that are on the same line as `rtoken`, // or null if they all are on the same line. -fn rowSize(tree: *ast.Tree, exprs: []*ast.Node, rtoken: ast.TokenIndex) ?usize { - const first_token = exprs[0].firstToken(); - const first_loc = tree.tokenLocation(tree.token_locs[first_token].start, rtoken); - if (first_loc.line == 0) { - const maybe_comma = tree.prevToken(rtoken); - if (tree.token_ids[maybe_comma] == .Comma) +fn rowSize(tree: ast.Tree, exprs: []const ast.Node.Index, rtoken: ast.TokenIndex) ?usize { + const token_tags = tree.tokens.items(.tag); + + const first_token = tree.firstToken(exprs[0]); + if (tree.tokensOnSameLine(first_token, rtoken)) { + const maybe_comma = rtoken - 1; + if (token_tags[maybe_comma] == .comma) return 1; return null; // no newlines } @@ -2668,9 +2572,8 @@ fn rowSize(tree: *ast.Tree, exprs: []*ast.Node, rtoken: ast.TokenIndex) ?usize { var count: usize = 1; for (exprs) |expr, i| { if (i + 1 < exprs.len) { - const expr_last_token = expr.lastToken() + 1; - const loc = tree.tokenLocation(tree.token_locs[expr_last_token].start, exprs[i + 1].firstToken()); - if (loc.line != 0) return count; + const expr_last_token = tree.lastToken(expr) + 1; + if (!tree.tokensOnSameLine(expr_last_token, tree.firstToken(exprs[i + 1]))) return count; count += 1; } else { return count; @@ -2678,3 +2581,150 @@ fn rowSize(tree: *ast.Tree, exprs: []*ast.Node, rtoken: ast.TokenIndex) ?usize { } unreachable; } + +/// Automatically inserts indentation of written data by keeping +/// track of the current indentation level +fn AutoIndentingStream(comptime UnderlyingWriter: type) type { + return struct { + const Self = @This(); + pub const Error = UnderlyingWriter.Error; + pub const Writer = std.io.Writer(*Self, Error, write); + + underlying_writer: UnderlyingWriter, + + /// Offset into the source at which formatting has been disabled with + /// a `zig fmt: off` comment. + /// + /// If non-null, the AutoIndentingStream will not write any bytes + /// to the underlying writer. It will however continue to track the + /// indentation level. + disabled_offset: ?usize = null, + + indent_count: usize = 0, + indent_delta: usize, + current_line_empty: bool = true, + /// automatically popped when applied + indent_one_shot_count: usize = 0, + /// the most recently applied indent + applied_indent: usize = 0, + /// not used until the next line + indent_next_line: usize = 0, + + pub fn writer(self: *Self) Writer { + return .{ .context = self }; + } + + pub fn write(self: *Self, bytes: []const u8) Error!usize { + if (bytes.len == 0) + return @as(usize, 0); + + try self.applyIndent(); + return self.writeNoIndent(bytes); + } + + // Change the indent delta without changing the final indentation level + pub fn setIndentDelta(self: *Self, new_indent_delta: usize) void { + if (self.indent_delta == new_indent_delta) { + return; + } else if (self.indent_delta > new_indent_delta) { + assert(self.indent_delta % new_indent_delta == 0); + self.indent_count = self.indent_count * (self.indent_delta / new_indent_delta); + } else { + // assert that the current indentation (in spaces) in a multiple of the new delta + assert((self.indent_count * self.indent_delta) % new_indent_delta == 0); + self.indent_count = self.indent_count / (new_indent_delta / self.indent_delta); + } + self.indent_delta = new_indent_delta; + } + + fn writeNoIndent(self: *Self, bytes: []const u8) Error!usize { + if (bytes.len == 0) + return @as(usize, 0); + + if (self.disabled_offset == null) try self.underlying_writer.writeAll(bytes); + if (bytes[bytes.len - 1] == '\n') + self.resetLine(); + return bytes.len; + } + + pub fn insertNewline(self: *Self) Error!void { + _ = try self.writeNoIndent("\n"); + } + + fn resetLine(self: *Self) void { + self.current_line_empty = true; + self.indent_next_line = 0; + } + + /// Insert a newline unless the current line is blank + pub fn maybeInsertNewline(self: *Self) Error!void { + if (!self.current_line_empty) + try self.insertNewline(); + } + + /// Push default indentation + /// Doesn't actually write any indentation. + /// Just primes the stream to be able to write the correct indentation if it needs to. + pub fn pushIndent(self: *Self) void { + self.indent_count += 1; + } + + /// Push an indent that is automatically popped after being applied + pub fn pushIndentOneShot(self: *Self) void { + self.indent_one_shot_count += 1; + self.pushIndent(); + } + + /// Turns all one-shot indents into regular indents + /// Returns number of indents that must now be manually popped + pub fn lockOneShotIndent(self: *Self) usize { + var locked_count = self.indent_one_shot_count; + self.indent_one_shot_count = 0; + return locked_count; + } + + /// Push an indent that should not take effect until the next line + pub fn pushIndentNextLine(self: *Self) void { + self.indent_next_line += 1; + self.pushIndent(); + } + + pub fn popIndent(self: *Self) void { + assert(self.indent_count != 0); + self.indent_count -= 1; + + if (self.indent_next_line > 0) + self.indent_next_line -= 1; + } + + /// Writes ' ' bytes if the current line is empty + fn applyIndent(self: *Self) Error!void { + const current_indent = self.currentIndent(); + if (self.current_line_empty and current_indent > 0) { + if (self.disabled_offset == null) { + try self.underlying_writer.writeByteNTimes(' ', current_indent); + } + self.applied_indent = current_indent; + } + + self.indent_count -= self.indent_one_shot_count; + self.indent_one_shot_count = 0; + self.current_line_empty = false; + } + + /// Checks to see if the most recent indentation exceeds the currently pushed indents + pub fn isLineOverIndented(self: *Self) bool { + if (self.current_line_empty) return false; + return self.applied_indent > self.currentIndent(); + } + + fn currentIndent(self: *Self) usize { + var indent_current: usize = 0; + if (self.indent_count > 0) { + const indent_count = self.indent_count - self.indent_next_line; + indent_current = indent_count * self.indent_delta; + } + return indent_current; + } + }; +} diff --git a/lib/std/zig/string_literal.zig b/lib/std/zig/string_literal.zig index b92d795eee..78d4e63bfe 100644 --- a/lib/std/zig/string_literal.zig +++ b/lib/std/zig/string_literal.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index af0b000328..2d9f286dd6 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -14,21 +14,24 @@ const process = std.process; const Target = std.Target; const CrossTarget = std.zig.CrossTarget; const macos = @import("system/macos.zig"); - -const is_windows = Target.current.os.tag == .windows; +pub const windows = @import("system/windows.zig"); pub const getSDKPath = macos.getSDKPath; pub const NativePaths = struct { include_dirs: ArrayList([:0]u8), lib_dirs: ArrayList([:0]u8), + framework_dirs: ArrayList([:0]u8), rpaths: ArrayList([:0]u8), warnings: ArrayList([:0]u8), - pub fn detect(allocator: *Allocator) !NativePaths { + pub fn detect(allocator: *Allocator, native_info: NativeTargetInfo) !NativePaths { + const native_target = native_info.target; + var self: NativePaths = .{ .include_dirs = ArrayList([:0]u8).init(allocator), .lib_dirs = ArrayList([:0]u8).init(allocator), + .framework_dirs = ArrayList([:0]u8).init(allocator), .rpaths = ArrayList([:0]u8).init(allocator), .warnings = ArrayList([:0]u8).init(allocator), }; @@ -49,7 +52,7 @@ pub const NativePaths = struct { }; try self.addIncludeDir(include_path); } else { - try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {}", .{word}); + try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {s}", .{word}); break; } } @@ -75,7 +78,7 @@ pub const NativePaths = struct { const lib_path = word[2..]; try self.addLibDir(lib_path); } else { - try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {}", .{word}); + try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word}); break; } } @@ -88,9 +91,22 @@ pub const NativePaths = struct { return self; } - if (!is_windows) { - const triple = try Target.current.linuxTriple(allocator); - const qual = Target.current.cpu.arch.ptrBitWidth(); + if (comptime Target.current.isDarwin()) { + try self.addIncludeDir("/usr/include"); + try self.addIncludeDir("/usr/local/include"); + + try self.addLibDir("/usr/lib"); + try self.addLibDir("/usr/local/lib"); + + try self.addFrameworkDir("/Library/Frameworks"); + try self.addFrameworkDir("/System/Library/Frameworks"); + + return self; + } + + if (native_target.os.tag != .windows) { + const triple = try native_target.linuxTriple(allocator); + const qual = native_target.cpu.arch.ptrBitWidth(); // TODO: $ ld --verbose | grep SEARCH_DIR // the output contains some paths that end with lib64, maybe include them too? @@ -98,22 +114,22 @@ pub const NativePaths = struct { // TODO: some of these are suspect and should only be added on some systems. audit needed. try self.addIncludeDir("/usr/local/include"); - try self.addLibDirFmt("/usr/local/lib{}", .{qual}); + try self.addLibDirFmt("/usr/local/lib{d}", .{qual}); try self.addLibDir("/usr/local/lib"); - try self.addIncludeDirFmt("/usr/include/{}", .{triple}); - try self.addLibDirFmt("/usr/lib/{}", .{triple}); + try self.addIncludeDirFmt("/usr/include/{s}", .{triple}); + try self.addLibDirFmt("/usr/lib/{s}", .{triple}); try self.addIncludeDir("/usr/include"); - try self.addLibDirFmt("/lib{}", .{qual}); + try self.addLibDirFmt("/lib{d}", .{qual}); try self.addLibDir("/lib"); - try self.addLibDirFmt("/usr/lib{}", .{qual}); + try self.addLibDirFmt("/usr/lib{d}", .{qual}); try self.addLibDir("/usr/lib"); // example: on a 64-bit debian-based linux distro, with zlib installed from apt: // zlib.h is in /usr/include (added above) // libz.so.1 is in /lib/x86_64-linux-gnu (added here) - try self.addLibDirFmt("/lib/{}", .{triple}); + try self.addLibDirFmt("/lib/{s}", .{triple}); } return self; @@ -122,6 +138,7 @@ pub const NativePaths = struct { pub fn deinit(self: *NativePaths) void { deinitArray(&self.include_dirs); deinitArray(&self.lib_dirs); + deinitArray(&self.framework_dirs); deinitArray(&self.rpaths); deinitArray(&self.warnings); self.* = undefined; @@ -158,6 +175,16 @@ pub const NativePaths = struct { return self.appendArray(&self.warnings, s); } + pub fn addFrameworkDir(self: *NativePaths, s: []const u8) !void { + return self.appendArray(&self.framework_dirs, s); + } + + pub fn addFrameworkDirFmt(self: *NativePaths, comptime fmt: []const u8, args: anytype) !void { + const item = try std.fmt.allocPrint0(self.framework_dirs.allocator, fmt, args); + errdefer self.framework_dirs.allocator.free(item); + try self.framework_dirs.append(item); + } + pub fn addWarningFmt(self: *NativePaths, comptime fmt: []const u8, args: anytype) !void { const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args); errdefer self.warnings.allocator.free(item); @@ -195,6 +222,7 @@ pub const NativeTargetInfo = struct { ProcessFdQuotaExceeded, SystemFdQuotaExceeded, DeviceBusy, + OSVersionDetectionFail, }; /// Given a `CrossTarget`, which specifies in detail which parts of the target should be detected @@ -223,77 +251,11 @@ pub const NativeTargetInfo = struct { } }, .windows => { - var version_info: std.os.windows.RTL_OSVERSIONINFOW = undefined; - version_info.dwOSVersionInfoSize = @sizeOf(@TypeOf(version_info)); - - switch (std.os.windows.ntdll.RtlGetVersion(&version_info)) { - .SUCCESS => {}, - else => unreachable, - } - - // Starting from the system infos build a NTDDI-like version - // constant whose format is: - // B0 B1 B2 B3 - // `---` `` ``--> Sub-version (Starting from Windows 10 onwards) - // \ `--> Service pack (Always zero in the constants defined) - // `--> OS version (Major & minor) - const os_ver: u16 = - @intCast(u16, version_info.dwMajorVersion & 0xff) << 8 | - @intCast(u16, version_info.dwMinorVersion & 0xff); - const sp_ver: u8 = 0; - const sub_ver: u8 = if (os_ver >= 0x0A00) subver: { - // There's no other way to obtain this info beside - // checking the build number against a known set of - // values - const known_build_numbers = [_]u32{ - 10240, 10586, 14393, 15063, 16299, 17134, 17763, - 18362, 19041, - }; - var last_idx: usize = 0; - for (known_build_numbers) |build, i| { - if (version_info.dwBuildNumber >= build) - last_idx = i; - } - break :subver @truncate(u8, last_idx); - } else 0; - - const version: u32 = @as(u32, os_ver) << 16 | @as(u32, sp_ver) << 8 | sub_ver; - - os.version_range.windows.max = @intToEnum(Target.Os.WindowsVersion, version); - os.version_range.windows.min = @intToEnum(Target.Os.WindowsVersion, version); - }, - .macos => { - var scbuf: [32]u8 = undefined; - var size: usize = undefined; - - // The osproductversion sysctl was introduced first with 10.13.4 High Sierra. - const key_osproductversion = "kern.osproductversion"; // eg. "10.15.4" - size = scbuf.len; - if (std.os.sysctlbynameZ(key_osproductversion, &scbuf, &size, null, 0)) |_| { - const string_version = scbuf[0 .. size - 1]; - if (std.builtin.Version.parse(string_version)) |ver| { - os.version_range.semver.min = ver; - os.version_range.semver.max = ver; - } else |err| switch (err) { - error.Overflow => {}, - error.InvalidCharacter => {}, - error.InvalidVersion => {}, - } - } else |err| switch (err) { - error.UnknownName => { - const key_osversion = "kern.osversion"; // eg. "19E287" - size = scbuf.len; - std.os.sysctlbynameZ(key_osversion, &scbuf, &size, null, 0) catch { - @panic("unable to detect macOS version: " ++ key_osversion); - }; - if (macos.version_from_build(scbuf[0 .. size - 1])) |ver| { - os.version_range.semver.min = ver; - os.version_range.semver.max = ver; - } else |_| {} - }, - else => @panic("unable to detect macOS version: " ++ key_osproductversion), - } + const detected_version = windows.detectRuntimeVersion(); + os.version_range.windows.min = detected_version; + os.version_range.windows.max = detected_version; }, + .macos => try macos.detect(&os), .freebsd => { var osreldate: u32 = undefined; var len: usize = undefined; @@ -936,6 +898,6 @@ pub const NativeTargetInfo = struct { } }; -test "" { +test { _ = @import("system/macos.zig"); } diff --git a/lib/std/zig/system/macos.zig b/lib/std/zig/system/macos.zig index 6895fa3f3a..abe844d2c4 100644 --- a/lib/std/zig/system/macos.zig +++ b/lib/std/zig/system/macos.zig @@ -1,458 +1,408 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. const std = @import("std"); const assert = std.debug.assert; const mem = std.mem; +const testing = std.testing; -pub fn version_from_build(build: []const u8) !std.builtin.Version { - // build format: - // 19E287 (example) - // xxyzzz +/// Detect macOS version. +/// `os` is not modified in case of error. +pub fn detect(os: *std.Target.Os) !void { + // Drop use of osproductversion sysctl because: + // 1. only available 10.13.4 High Sierra and later + // 2. when used from a binary built against < SDK 11.0 it returns 10.16 and masks Big Sur 11.x version // - // major = 10 - // minor = x - 4 = 19 - 4 = 15 - // patch = ascii(y) - 'A' = 'E' - 'A' = 69 - 65 = 4 - // answer: 10.15.4 + // NEW APPROACH, STEP 1, parse file: // - // note: patch is typical but with some older releases (before 10.8) zzz is considered + // /System/Library/CoreServices/SystemVersion.plist + // + // NOTE: Historically `SystemVersion.plist` first appeared circa '2003 + // with the release of Mac OS X 10.3.0 Panther. + // + // and if it contains a `10.16` value where the `16` is `>= 16` then it is non-canonical, + // discarded, and we move on to next step. Otherwise we accept the version. + // + // BACKGROUND: `10.(16+)` is not a proper version and does not have enough fidelity to + // indicate minor/point version of Big Sur and later. It is a context-sensitive result + // issued by the kernel for backwards compatibility purposes. Likely the kernel checks + // if the executable was linked against an SDK older than Big Sur. + // + // STEP 2, parse next file: + // + // /System/Library/CoreServices/.SystemVersionPlatform.plist + // + // NOTE: Historically `SystemVersionPlatform.plist` first appeared circa '2020 + // with the release of macOS 11.0 Big Sur. + // + // Accessing the content via this path circumvents a context-sensitive result and + // yields a canonical Big Sur version. + // + // At this time there is no other known way for a < SDK 11.0 executable to obtain a + // canonical Big Sur version. + // + // This implementation uses a reasonably simplified approach to parse .plist file + // that while it is an xml document, we have good history on the file and its format + // such that I am comfortable with implementing a minimalistic parser. + // Things like string and general escapes are not supported. + const prefixSlash = "/System/Library/CoreServices/"; + const paths = [_][]const u8{ + prefixSlash ++ "SystemVersion.plist", + prefixSlash ++ ".SystemVersionPlatform.plist", + }; + for (paths) |path| { + // approx. 4 times historical file size + var buf: [2048]u8 = undefined; - // never return anything below 10.0.0 - var result = std.builtin.Version{ .major = 10, .minor = 0, .patch = 0 }; - - // parse format-x - var yindex: usize = 0; - { - while (yindex < build.len) : (yindex += 1) { - if (build[yindex] < '0' or build[yindex] > '9') break; + if (std.fs.cwd().readFile(path, &buf)) |bytes| { + if (parseSystemVersion(bytes)) |ver| { + // never return non-canonical `10.(16+)` + if (!(ver.major == 10 and ver.minor >= 16)) { + os.version_range.semver.min = ver; + os.version_range.semver.max = ver; + return; + } + continue; + } else |err| { + return error.OSVersionDetectionFail; + } + } else |err| { + return error.OSVersionDetectionFail; } - if (yindex == 0) return result; - const x = std.fmt.parseUnsigned(u16, build[0..yindex], 10) catch return error.InvalidVersion; - if (x < 4) return result; - result.minor = x - 4; } - - // parse format-y, format-z - { - // expect two more - if (build.len < yindex + 2) return error.InvalidVersion; - const y = build[yindex]; - if (y < 'A') return error.InvalidVersion; - var zend = yindex + 1; - while (zend < build.len) { - if (build[zend] < '0' or build[zend] > '9') break; - zend += 1; - } - if (zend == yindex + 1) return error.InvalidVersion; - const z = std.fmt.parseUnsigned(u16, build[yindex + 1 .. zend], 10) catch return error.InvalidVersion; - - result.patch = switch (result.minor) { - // TODO: compiler complains without explicit @as() coercion - 0 => @as(u32, switch (y) { // Cheetah: 10.0 - 'K' => 0, - 'L' => 1, - 'P' => @as(u32, block: { - if (z < 13) break :block 2; - break :block 3; - }), - 'Q' => 4, - else => return error.InvalidVersion, - }), - 1 => @as(u32, switch (y) { // Puma: 10.1 - 'G' => 0, - 'M' => 1, - 'P' => 2, - 'Q' => @as(u32, block: { - if (z < 125) break :block 3; - break :block 4; - }), - 'S' => 5, - else => return error.InvalidVersion, - }), - 2 => @as(u32, switch (y) { // Jaguar: 10.2 - 'C' => 0, - 'D' => 1, - 'F' => 2, - 'G' => 3, - 'I' => 4, - 'L' => @as(u32, block: { - if (z < 60) break :block 5; - break :block 6; - }), - 'R' => @as(u32, block: { - if (z < 73) break :block 7; - break :block 8; - }), - 'S' => 8, - else => return error.InvalidVersion, - }), - 3 => @as(u32, switch (y) { // Panther: 10.3 - 'B' => 0, - 'C' => 1, - 'D' => 2, - 'F' => 3, - 'H' => 4, - 'M' => 5, - 'R' => 6, - 'S' => 7, - 'U' => 8, - 'W' => 9, - else => return error.InvalidVersion, - }), - 4 => @as(u32, switch (y) { // Tiger: 10.4 - 'A' => 0, - 'B' => 1, - 'C', - 'E', - => 2, - 'F' => 3, - 'G' => @as(u32, block: { - if (z >= 1454) break :block 5; - break :block 4; - }), - 'H' => 5, - 'I' => 6, - 'J', - 'K', - 'N', - => 7, - 'L' => 8, - 'P' => 9, - 'R' => 10, - 'S' => 11, - else => return error.InvalidVersion, - }), - 5 => @as(u32, switch (y) { // Leopard: 10.5 - 'A' => 0, - 'B' => 1, - 'C' => 2, - 'D' => 3, - 'E' => 4, - 'F' => 5, - 'G' => 6, - 'J' => 7, - 'L' => 8, - else => return error.InvalidVersion, - }), - 6 => @as(u32, switch (y) { // Snow Leopard: 10.6 - 'A' => 0, - 'B' => 1, - 'C' => 2, - 'D' => 3, - 'F' => 4, - 'H' => 5, - 'J' => @as(u32, block: { - if (z < 869) break :block 6; - break :block 7; - }), - 'K' => 8, - else => return error.InvalidVersion, - }), - 7 => @as(u32, switch (y) { // Snow Leopard: 10.6 - 'A' => 0, - 'B' => 1, - 'C' => 2, - 'D' => 3, - 'E' => 4, - 'G' => 5, - else => return error.InvalidVersion, - }), - else => y - 'A', - }; - } - return result; + return error.OSVersionDetectionFail; } -test "version_from_build" { - // see https://en.wikipedia.org/wiki/MacOS_version_history#Releases - const known = [_][2][]const u8{ - .{ "4K78", "10.0.0" }, - .{ "4L13", "10.0.1" }, - .{ "4P12", "10.0.2" }, - .{ "4P13", "10.0.3" }, - .{ "4Q12", "10.0.4" }, - - .{ "5G64", "10.1.0" }, - .{ "5M28", "10.1.1" }, - .{ "5P48", "10.1.2" }, - .{ "5Q45", "10.1.3" }, - .{ "5Q125", "10.1.4" }, - .{ "5S60", "10.1.5" }, - - .{ "6C115", "10.2.0" }, - .{ "6C115a", "10.2.0" }, - .{ "6D52", "10.2.1" }, - .{ "6F21", "10.2.2" }, - .{ "6G30", "10.2.3" }, - .{ "6G37", "10.2.3" }, - .{ "6G50", "10.2.3" }, - .{ "6I32", "10.2.4" }, - .{ "6L29", "10.2.5" }, - .{ "6L60", "10.2.6" }, - .{ "6R65", "10.2.7" }, - .{ "6R73", "10.2.8" }, - .{ "6S90", "10.2.8" }, - - .{ "7B85", "10.3.0" }, - .{ "7B86", "10.3.0" }, - .{ "7C107", "10.3.1" }, - .{ "7D24", "10.3.2" }, - .{ "7D28", "10.3.2" }, - .{ "7F44", "10.3.3" }, - .{ "7H63", "10.3.4" }, - .{ "7M34", "10.3.5" }, - .{ "7R28", "10.3.6" }, - .{ "7S215", "10.3.7" }, - .{ "7U16", "10.3.8" }, - .{ "7W98", "10.3.9" }, - - .{ "8A428", "10.4.0" }, - .{ "8A432", "10.4.0" }, - .{ "8B15", "10.4.1" }, - .{ "8B17", "10.4.1" }, - .{ "8C46", "10.4.2" }, - .{ "8C47", "10.4.2" }, - .{ "8E102", "10.4.2" }, - .{ "8E45", "10.4.2" }, - .{ "8E90", "10.4.2" }, - .{ "8F46", "10.4.3" }, - .{ "8G32", "10.4.4" }, - .{ "8G1165", "10.4.4" }, - .{ "8H14", "10.4.5" }, - .{ "8G1454", "10.4.5" }, - .{ "8I127", "10.4.6" }, - .{ "8I1119", "10.4.6" }, - .{ "8J135", "10.4.7" }, - .{ "8J2135a", "10.4.7" }, - .{ "8K1079", "10.4.7" }, - .{ "8N5107", "10.4.7" }, - .{ "8L127", "10.4.8" }, - .{ "8L2127", "10.4.8" }, - .{ "8P135", "10.4.9" }, - .{ "8P2137", "10.4.9" }, - .{ "8R218", "10.4.10" }, - .{ "8R2218", "10.4.10" }, - .{ "8R2232", "10.4.10" }, - .{ "8S165", "10.4.11" }, - .{ "8S2167", "10.4.11" }, - - .{ "9A581", "10.5.0" }, - .{ "9B18", "10.5.1" }, - .{ "9C31", "10.5.2" }, - .{ "9C7010", "10.5.2" }, - .{ "9D34", "10.5.3" }, - .{ "9E17", "10.5.4" }, - .{ "9F33", "10.5.5" }, - .{ "9G55", "10.5.6" }, - .{ "9G66", "10.5.6" }, - .{ "9J61", "10.5.7" }, - .{ "9L30", "10.5.8" }, - - .{ "10A432", "10.6.0" }, - .{ "10A433", "10.6.0" }, - .{ "10B504", "10.6.1" }, - .{ "10C540", "10.6.2" }, - .{ "10D573", "10.6.3" }, - .{ "10D575", "10.6.3" }, - .{ "10D578", "10.6.3" }, - .{ "10F569", "10.6.4" }, - .{ "10H574", "10.6.5" }, - .{ "10J567", "10.6.6" }, - .{ "10J869", "10.6.7" }, - .{ "10J3250", "10.6.7" }, - .{ "10J4138", "10.6.7" }, - .{ "10K540", "10.6.8" }, - .{ "10K549", "10.6.8" }, - - .{ "11A511", "10.7.0" }, - .{ "11A511s", "10.7.0" }, - .{ "11A2061", "10.7.0" }, - .{ "11A2063", "10.7.0" }, - .{ "11B26", "10.7.1" }, - .{ "11B2118", "10.7.1" }, - .{ "11C74", "10.7.2" }, - .{ "11D50", "10.7.3" }, - .{ "11E53", "10.7.4" }, - .{ "11G56", "10.7.5" }, - .{ "11G63", "10.7.5" }, - - .{ "12A269", "10.8.0" }, - .{ "12B19", "10.8.1" }, - .{ "12C54", "10.8.2" }, - .{ "12C60", "10.8.2" }, - .{ "12C2034", "10.8.2" }, - .{ "12C3104", "10.8.2" }, - .{ "12D78", "10.8.3" }, - .{ "12E55", "10.8.4" }, - .{ "12E3067", "10.8.4" }, - .{ "12E4022", "10.8.4" }, - .{ "12F37", "10.8.5" }, - .{ "12F45", "10.8.5" }, - .{ "12F2501", "10.8.5" }, - .{ "12F2518", "10.8.5" }, - .{ "12F2542", "10.8.5" }, - .{ "12F2560", "10.8.5" }, - - .{ "13A603", "10.9.0" }, - .{ "13B42", "10.9.1" }, - .{ "13C64", "10.9.2" }, - .{ "13C1021", "10.9.2" }, - .{ "13D65", "10.9.3" }, - .{ "13E28", "10.9.4" }, - .{ "13F34", "10.9.5" }, - .{ "13F1066", "10.9.5" }, - .{ "13F1077", "10.9.5" }, - .{ "13F1096", "10.9.5" }, - .{ "13F1112", "10.9.5" }, - .{ "13F1134", "10.9.5" }, - .{ "13F1507", "10.9.5" }, - .{ "13F1603", "10.9.5" }, - .{ "13F1712", "10.9.5" }, - .{ "13F1808", "10.9.5" }, - .{ "13F1911", "10.9.5" }, - - .{ "14A389", "10.10.0" }, - .{ "14B25", "10.10.1" }, - .{ "14C109", "10.10.2" }, - .{ "14C1510", "10.10.2" }, - .{ "14C1514", "10.10.2" }, - .{ "14C2043", "10.10.2" }, - .{ "14C2513", "10.10.2" }, - .{ "14D131", "10.10.3" }, - .{ "14D136", "10.10.3" }, - .{ "14E46", "10.10.4" }, - .{ "14F27", "10.10.5" }, - .{ "14F1021", "10.10.5" }, - .{ "14F1505", "10.10.5" }, - .{ "14F1509", "10.10.5" }, - .{ "14F1605", "10.10.5" }, - .{ "14F1713", "10.10.5" }, - .{ "14F1808", "10.10.5" }, - .{ "14F1909", "10.10.5" }, - .{ "14F1912", "10.10.5" }, - .{ "14F2009", "10.10.5" }, - .{ "14F2109", "10.10.5" }, - .{ "14F2315", "10.10.5" }, - .{ "14F2411", "10.10.5" }, - .{ "14F2511", "10.10.5" }, - - .{ "15A284", "10.11.0" }, - .{ "15B42", "10.11.1" }, - .{ "15C50", "10.11.2" }, - .{ "15D21", "10.11.3" }, - .{ "15E65", "10.11.4" }, - .{ "15F34", "10.11.5" }, - .{ "15G31", "10.11.6" }, - .{ "15G1004", "10.11.6" }, - .{ "15G1011", "10.11.6" }, - .{ "15G1108", "10.11.6" }, - .{ "15G1212", "10.11.6" }, - .{ "15G1217", "10.11.6" }, - .{ "15G1421", "10.11.6" }, - .{ "15G1510", "10.11.6" }, - .{ "15G1611", "10.11.6" }, - .{ "15G17023", "10.11.6" }, - .{ "15G18013", "10.11.6" }, - .{ "15G19009", "10.11.6" }, - .{ "15G20015", "10.11.6" }, - .{ "15G21013", "10.11.6" }, - .{ "15G22010", "10.11.6" }, - - .{ "16A323", "10.12.0" }, - .{ "16B2555", "10.12.1" }, - .{ "16B2657", "10.12.1" }, - .{ "16C67", "10.12.2" }, - .{ "16C68", "10.12.2" }, - .{ "16D32", "10.12.3" }, - .{ "16E195", "10.12.4" }, - .{ "16F73", "10.12.5" }, - .{ "16F2073", "10.12.5" }, - .{ "16G29", "10.12.6" }, - .{ "16G1036", "10.12.6" }, - .{ "16G1114", "10.12.6" }, - .{ "16G1212", "10.12.6" }, - .{ "16G1314", "10.12.6" }, - .{ "16G1408", "10.12.6" }, - .{ "16G1510", "10.12.6" }, - .{ "16G1618", "10.12.6" }, - .{ "16G1710", "10.12.6" }, - .{ "16G1815", "10.12.6" }, - .{ "16G1917", "10.12.6" }, - .{ "16G1918", "10.12.6" }, - .{ "16G2016", "10.12.6" }, - .{ "16G2127", "10.12.6" }, - .{ "16G2128", "10.12.6" }, - .{ "16G2136", "10.12.6" }, - - .{ "17A365", "10.13.0" }, - .{ "17A405", "10.13.0" }, - .{ "17B48", "10.13.1" }, - .{ "17B1002", "10.13.1" }, - .{ "17B1003", "10.13.1" }, - .{ "17C88", "10.13.2" }, - .{ "17C89", "10.13.2" }, - .{ "17C205", "10.13.2" }, - .{ "17C2205", "10.13.2" }, - .{ "17D47", "10.13.3" }, - .{ "17D2047", "10.13.3" }, - .{ "17D102", "10.13.3" }, - .{ "17D2102", "10.13.3" }, - .{ "17E199", "10.13.4" }, - .{ "17E202", "10.13.4" }, - .{ "17F77", "10.13.5" }, - .{ "17G65", "10.13.6" }, - .{ "17G2208", "10.13.6" }, - .{ "17G3025", "10.13.6" }, - .{ "17G4015", "10.13.6" }, - .{ "17G5019", "10.13.6" }, - .{ "17G6029", "10.13.6" }, - .{ "17G6030", "10.13.6" }, - .{ "17G7024", "10.13.6" }, - .{ "17G8029", "10.13.6" }, - .{ "17G8030", "10.13.6" }, - .{ "17G8037", "10.13.6" }, - .{ "17G9016", "10.13.6" }, - .{ "17G10021", "10.13.6" }, - .{ "17G11023", "10.13.6" }, - .{ "17G12034", "10.13.6" }, - - .{ "18A391", "10.14.0" }, - .{ "18B75", "10.14.1" }, - .{ "18B2107", "10.14.1" }, - .{ "18B3094", "10.14.1" }, - .{ "18C54", "10.14.2" }, - .{ "18D42", "10.14.3" }, - .{ "18D43", "10.14.3" }, - .{ "18D109", "10.14.3" }, - .{ "18E226", "10.14.4" }, - .{ "18E227", "10.14.4" }, - .{ "18F132", "10.14.5" }, - .{ "18G84", "10.14.6" }, - .{ "18G87", "10.14.6" }, - .{ "18G95", "10.14.6" }, - .{ "18G103", "10.14.6" }, - .{ "18G1012", "10.14.6" }, - .{ "18G2022", "10.14.6" }, - .{ "18G3020", "10.14.6" }, - .{ "18G4032", "10.14.6" }, - - .{ "19A583", "10.15.0" }, - .{ "19A602", "10.15.0" }, - .{ "19A603", "10.15.0" }, - .{ "19B88", "10.15.1" }, - .{ "19C57", "10.15.2" }, - .{ "19D76", "10.15.3" }, - .{ "19E266", "10.15.4" }, - .{ "19E287", "10.15.4" }, - }; - for (known) |pair| { - var buf: [32]u8 = undefined; - const ver = try version_from_build(pair[0]); - const sver = try std.fmt.bufPrint(buf[0..], "{}.{}.{}", .{ ver.major, ver.minor, ver.patch }); - std.testing.expect(std.mem.eql(u8, sver, pair[1])); +fn parseSystemVersion(buf: []const u8) !std.builtin.Version { + var svt = SystemVersionTokenizer{ .bytes = buf }; + try svt.skipUntilTag(.start, "dict"); + while (true) { + try svt.skipUntilTag(.start, "key"); + const content = try svt.expectContent(); + try svt.skipUntilTag(.end, "key"); + if (std.mem.eql(u8, content, "ProductVersion")) break; } + try svt.skipUntilTag(.start, "string"); + const ver = try svt.expectContent(); + try svt.skipUntilTag(.end, "string"); + + return std.builtin.Version.parse(ver); +} + +const SystemVersionTokenizer = struct { + bytes: []const u8, + index: usize = 0, + state: State = .begin, + + fn next(self: *@This()) !?Token { + var mark: usize = self.index; + var tag = Tag{}; + var content: []const u8 = ""; + + while (self.index < self.bytes.len) { + const char = self.bytes[self.index]; + switch (self.state) { + .begin => switch (char) { + '<' => { + self.state = .tag0; + self.index += 1; + tag = Tag{}; + mark = self.index; + }, + '>' => { + return error.BadToken; + }, + else => { + self.state = .content; + content = ""; + mark = self.index; + }, + }, + .tag0 => switch (char) { + '<' => { + return error.BadToken; + }, + '>' => { + self.state = .begin; + self.index += 1; + tag.name = self.bytes[mark..self.index]; + return Token{ .tag = tag }; + }, + '"' => { + self.state = .tag_string; + self.index += 1; + }, + '/' => { + self.state = .tag0_end_or_empty; + self.index += 1; + }, + 'A'...'Z', 'a'...'z' => { + self.state = .tagN; + tag.kind = .start; + self.index += 1; + }, + else => { + self.state = .tagN; + self.index += 1; + }, + }, + .tag0_end_or_empty => switch (char) { + '<' => { + return error.BadToken; + }, + '>' => { + self.state = .begin; + tag.kind = .empty; + tag.name = self.bytes[self.index..self.index]; + self.index += 1; + return Token{ .tag = tag }; + }, + else => { + self.state = .tagN; + tag.kind = .end; + mark = self.index; + self.index += 1; + }, + }, + .tagN => switch (char) { + '<' => { + return error.BadToken; + }, + '>' => { + self.state = .begin; + tag.name = self.bytes[mark..self.index]; + self.index += 1; + return Token{ .tag = tag }; + }, + '"' => { + self.state = .tag_string; + self.index += 1; + }, + '/' => { + self.state = .tagN_end; + tag.kind = .end; + self.index += 1; + }, + else => { + self.index += 1; + }, + }, + .tagN_end => switch (char) { + '>' => { + self.state = .begin; + tag.name = self.bytes[mark..self.index]; + self.index += 1; + return Token{ .tag = tag }; + }, + else => { + return error.BadToken; + }, + }, + .tag_string => switch (char) { + '"' => { + self.state = .tagN; + self.index += 1; + }, + else => { + self.index += 1; + }, + }, + .content => switch (char) { + '<' => { + self.state = .tag0; + content = self.bytes[mark..self.index]; + self.index += 1; + tag = Tag{}; + mark = self.index; + return Token{ .content = content }; + }, + '>' => { + return error.BadToken; + }, + else => { + self.index += 1; + }, + }, + } + } + + return null; + } + + fn expectContent(self: *@This()) ![]const u8 { + if (try self.next()) |tok| { + switch (tok) { + .content => |content| { + return content; + }, + else => {}, + } + } + return error.UnexpectedToken; + } + + fn skipUntilTag(self: *@This(), kind: Tag.Kind, name: []const u8) !void { + while (try self.next()) |tok| { + switch (tok) { + .tag => |tag| { + if (tag.kind == kind and std.mem.eql(u8, tag.name, name)) return; + }, + else => {}, + } + } + return error.TagNotFound; + } + + const State = enum { + begin, + tag0, + tag0_end_or_empty, + tagN, + tagN_end, + tag_string, + content, + }; + + const Token = union(enum) { + tag: Tag, + content: []const u8, + }; + + const Tag = struct { + kind: Kind = .unknown, + name: []const u8 = "", + + const Kind = enum { unknown, start, end, empty }; + }; +}; + +test "detect" { + const cases = .{ + .{ + \\ + \\ + \\ + \\ + \\ ProductBuildVersion + \\ 7B85 + \\ ProductCopyright + \\ Apple Computer, Inc. 1983-2003 + \\ ProductName + \\ Mac OS X + \\ ProductUserVisibleVersion + \\ 10.3 + \\ ProductVersion + \\ 10.3 + \\ + \\ + , + .{ .major = 10, .minor = 3 }, + }, + .{ + \\ + \\ + \\ + \\ + \\ ProductBuildVersion + \\ 7W98 + \\ ProductCopyright + \\ Apple Computer, Inc. 1983-2004 + \\ ProductName + \\ Mac OS X + \\ ProductUserVisibleVersion + \\ 10.3.9 + \\ ProductVersion + \\ 10.3.9 + \\ + \\ + , + .{ .major = 10, .minor = 3, .patch = 9 }, + }, + .{ + \\ + \\ + \\ + \\ + \\ ProductBuildVersion + \\ 19G68 + \\ ProductCopyright + \\ 1983-2020 Apple Inc. + \\ ProductName + \\ Mac OS X + \\ ProductUserVisibleVersion + \\ 10.15.6 + \\ ProductVersion + \\ 10.15.6 + \\ iOSSupportVersion + \\ 13.6 + \\ + \\ + , + .{ .major = 10, .minor = 15, .patch = 6 }, + }, + .{ + \\ + \\ + \\ + \\ + \\ ProductBuildVersion + \\ 20A2408 + \\ ProductCopyright + \\ 1983-2020 Apple Inc. + \\ ProductName + \\ macOS + \\ ProductUserVisibleVersion + \\ 11.0 + \\ ProductVersion + \\ 11.0 + \\ iOSSupportVersion + \\ 14.2 + \\ + \\ + , + .{ .major = 11, .minor = 0 }, + }, + .{ + \\ + \\ + \\ + \\ + \\ ProductBuildVersion + \\ 20C63 + \\ ProductCopyright + \\ 1983-2020 Apple Inc. + \\ ProductName + \\ macOS + \\ ProductUserVisibleVersion + \\ 11.1 + \\ ProductVersion + \\ 11.1 + \\ iOSSupportVersion + \\ 14.3 + \\ + \\ + , + .{ .major = 11, .minor = 1 }, + }, + }; + + inline for (cases) |case| { + const ver0 = try parseSystemVersion(case[0]); + const ver1: std.builtin.Version = case[1]; + try testVersionEquality(ver1, ver0); + } +} + +fn testVersionEquality(expected: std.builtin.Version, got: std.builtin.Version) !void { + var b_expected: [64]u8 = undefined; + const s_expected: []const u8 = try std.fmt.bufPrint(b_expected[0..], "{}", .{expected}); + + var b_got: [64]u8 = undefined; + const s_got: []const u8 = try std.fmt.bufPrint(b_got[0..], "{}", .{got}); + + testing.expectEqualStrings(s_expected, s_got); } /// Detect SDK path on Darwin. @@ -468,7 +418,7 @@ pub fn getSDKPath(allocator: *mem.Allocator) ![]u8 { allocator.free(result.stdout); } if (result.stderr.len != 0) { - std.log.err("unexpected 'xcrun --show-sdk-path' stderr: {}", .{result.stderr}); + std.log.err("unexpected 'xcrun --show-sdk-path' stderr: {s}", .{result.stderr}); } if (result.term.Exited != 0) { return error.ProcessTerminated; diff --git a/lib/std/zig/system/windows.zig b/lib/std/zig/system/windows.zig new file mode 100644 index 0000000000..d32b28f607 --- /dev/null +++ b/lib/std/zig/system/windows.zig @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2015-2020 Zig Contributors +// This file is part of [zig](https://ziglang.org/), which is MIT licensed. +// The MIT license requires this copyright notice to be included in all copies +// and substantial portions of the software. +const std = @import("std"); + +pub const WindowsVersion = std.Target.Os.WindowsVersion; + +/// Returns the highest known WindowsVersion deduced from reported runtime information. +/// Discards information about in-between versions we don't differentiate. +pub fn detectRuntimeVersion() WindowsVersion { + var version_info: std.os.windows.RTL_OSVERSIONINFOW = undefined; + version_info.dwOSVersionInfoSize = @sizeOf(@TypeOf(version_info)); + + switch (std.os.windows.ntdll.RtlGetVersion(&version_info)) { + .SUCCESS => {}, + else => unreachable, + } + + // Starting from the system infos build a NTDDI-like version + // constant whose format is: + // B0 B1 B2 B3 + // `---` `` ``--> Sub-version (Starting from Windows 10 onwards) + // \ `--> Service pack (Always zero in the constants defined) + // `--> OS version (Major & minor) + const os_ver: u16 = @intCast(u16, version_info.dwMajorVersion & 0xff) << 8 | + @intCast(u16, version_info.dwMinorVersion & 0xff); + const sp_ver: u8 = 0; + const sub_ver: u8 = if (os_ver >= 0x0A00) subver: { + // There's no other way to obtain this info beside + // checking the build number against a known set of + // values + var last_idx: usize = 0; + for (WindowsVersion.known_win10_build_numbers) |build, i| { + if (version_info.dwBuildNumber >= build) + last_idx = i; + } + break :subver @truncate(u8, last_idx); + } else 0; + + const version: u32 = @as(u32, os_ver) << 16 | @as(u16, sp_ver) << 8 | sub_ver; + + return @intToEnum(WindowsVersion, version); +} diff --git a/lib/std/zig/system/x86.zig b/lib/std/zig/system/x86.zig index cbede308dc..bda9a17c95 100644 --- a/lib/std/zig/system/x86.zig +++ b/lib/std/zig/system/x86.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -19,11 +19,11 @@ fn setFeature(cpu: *Target.Cpu, feature: Target.x86.Feature, enabled: bool) void if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx); } -inline fn bit(input: u32, offset: u5) bool { +fn bit(input: u32, offset: u5) callconv(.Inline) bool { return (input >> offset) & 1 != 0; } -inline fn hasMask(input: u32, mask: u32) bool { +fn hasMask(input: u32, mask: u32) callconv(.Inline) bool { return (input & mask) == mask; } diff --git a/lib/std/zig/tokenizer.zig b/lib/std/zig/tokenizer.zig index a0e2806e9a..88feabd021 100644 --- a/lib/std/zig/tokenizer.zig +++ b/lib/std/zig/tokenizer.zig @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -// Copyright (c) 2015-2020 Zig Contributors +// Copyright (c) 2015-2021 Zig Contributors // This file is part of [zig](https://ziglang.org/), which is MIT licensed. // The MIT license requires this copyright notice to be included in all copies // and substantial portions of the software. @@ -7,7 +7,7 @@ const std = @import("../std.zig"); const mem = std.mem; pub const Token = struct { - id: Id, + tag: Tag, loc: Loc, pub const Loc = struct { @@ -15,315 +15,315 @@ pub const Token = struct { end: usize, }; - pub const keywords = std.ComptimeStringMap(Id, .{ - .{ "align", .Keyword_align }, - .{ "allowzero", .Keyword_allowzero }, - .{ "and", .Keyword_and }, - .{ "anyframe", .Keyword_anyframe }, - .{ "anytype", .Keyword_anytype }, - .{ "asm", .Keyword_asm }, - .{ "async", .Keyword_async }, - .{ "await", .Keyword_await }, - .{ "break", .Keyword_break }, - .{ "callconv", .Keyword_callconv }, - .{ "catch", .Keyword_catch }, - .{ "comptime", .Keyword_comptime }, - .{ "const", .Keyword_const }, - .{ "continue", .Keyword_continue }, - .{ "defer", .Keyword_defer }, - .{ "else", .Keyword_else }, - .{ "enum", .Keyword_enum }, - .{ "errdefer", .Keyword_errdefer }, - .{ "error", .Keyword_error }, - .{ "export", .Keyword_export }, - .{ "extern", .Keyword_extern }, - .{ "false", .Keyword_false }, - .{ "fn", .Keyword_fn }, - .{ "for", .Keyword_for }, - .{ "if", .Keyword_if }, - .{ "inline", .Keyword_inline }, - .{ "noalias", .Keyword_noalias }, - .{ "noasync", .Keyword_nosuspend }, // TODO: remove this - .{ "noinline", .Keyword_noinline }, - .{ "nosuspend", .Keyword_nosuspend }, - .{ "null", .Keyword_null }, - .{ "opaque", .Keyword_opaque }, - .{ "or", .Keyword_or }, - .{ "orelse", .Keyword_orelse }, - .{ "packed", .Keyword_packed }, - .{ "pub", .Keyword_pub }, - .{ "resume", .Keyword_resume }, - .{ "return", .Keyword_return }, - .{ "linksection", .Keyword_linksection }, - .{ "struct", .Keyword_struct }, - .{ "suspend", .Keyword_suspend }, - .{ "switch", .Keyword_switch }, - .{ "test", .Keyword_test }, - .{ "threadlocal", .Keyword_threadlocal }, - .{ "true", .Keyword_true }, - .{ "try", .Keyword_try }, - .{ "undefined", .Keyword_undefined }, - .{ "union", .Keyword_union }, - .{ "unreachable", .Keyword_unreachable }, - .{ "usingnamespace", .Keyword_usingnamespace }, - .{ "var", .Keyword_var }, - .{ "volatile", .Keyword_volatile }, - .{ "while", .Keyword_while }, + pub const keywords = std.ComptimeStringMap(Tag, .{ + .{ "align", .keyword_align }, + .{ "allowzero", .keyword_allowzero }, + .{ "and", .keyword_and }, + .{ "anyframe", .keyword_anyframe }, + .{ "anytype", .keyword_anytype }, + .{ "asm", .keyword_asm }, + .{ "async", .keyword_async }, + .{ "await", .keyword_await }, + .{ "break", .keyword_break }, + .{ "callconv", .keyword_callconv }, + .{ "catch", .keyword_catch }, + .{ "comptime", .keyword_comptime }, + .{ "const", .keyword_const }, + .{ "continue", .keyword_continue }, + .{ "defer", .keyword_defer }, + .{ "else", .keyword_else }, + .{ "enum", .keyword_enum }, + .{ "errdefer", .keyword_errdefer }, + .{ "error", .keyword_error }, + .{ "export", .keyword_export }, + .{ "extern", .keyword_extern }, + .{ "false", .keyword_false }, + .{ "fn", .keyword_fn }, + .{ "for", .keyword_for }, + .{ "if", .keyword_if }, + .{ "inline", .keyword_inline }, + .{ "noalias", .keyword_noalias }, + .{ "noinline", .keyword_noinline }, + .{ "nosuspend", .keyword_nosuspend }, + .{ "null", .keyword_null }, + .{ "opaque", .keyword_opaque }, + .{ "or", .keyword_or }, + .{ "orelse", .keyword_orelse }, + .{ "packed", .keyword_packed }, + .{ "pub", .keyword_pub }, + .{ "resume", .keyword_resume }, + .{ "return", .keyword_return }, + .{ "linksection", .keyword_linksection }, + .{ "struct", .keyword_struct }, + .{ "suspend", .keyword_suspend }, + .{ "switch", .keyword_switch }, + .{ "test", .keyword_test }, + .{ "threadlocal", .keyword_threadlocal }, + .{ "true", .keyword_true }, + .{ "try", .keyword_try }, + .{ "undefined", .keyword_undefined }, + .{ "union", .keyword_union }, + .{ "unreachable", .keyword_unreachable }, + .{ "usingnamespace", .keyword_usingnamespace }, + .{ "var", .keyword_var }, + .{ "volatile", .keyword_volatile }, + .{ "while", .keyword_while }, }); - pub fn getKeyword(bytes: []const u8) ?Id { + pub fn getKeyword(bytes: []const u8) ?Tag { return keywords.get(bytes); } - pub const Id = enum { - Invalid, - Invalid_ampersands, - Invalid_periodasterisks, - Identifier, - StringLiteral, - MultilineStringLiteralLine, - CharLiteral, - Eof, - Builtin, - Bang, - Pipe, - PipePipe, - PipeEqual, - Equal, - EqualEqual, - EqualAngleBracketRight, - BangEqual, - LParen, - RParen, - Semicolon, - Percent, - PercentEqual, - LBrace, - RBrace, - LBracket, - RBracket, - Period, - PeriodAsterisk, - Ellipsis2, - Ellipsis3, - Caret, - CaretEqual, - Plus, - PlusPlus, - PlusEqual, - PlusPercent, - PlusPercentEqual, - Minus, - MinusEqual, - MinusPercent, - MinusPercentEqual, - Asterisk, - AsteriskEqual, - AsteriskAsterisk, - AsteriskPercent, - AsteriskPercentEqual, - Arrow, - Colon, - Slash, - SlashEqual, - Comma, - Ampersand, - AmpersandEqual, - QuestionMark, - AngleBracketLeft, - AngleBracketLeftEqual, - AngleBracketAngleBracketLeft, - AngleBracketAngleBracketLeftEqual, - AngleBracketRight, - AngleBracketRightEqual, - AngleBracketAngleBracketRight, - AngleBracketAngleBracketRightEqual, - Tilde, - IntegerLiteral, - FloatLiteral, - LineComment, - DocComment, - ContainerDocComment, - ShebangLine, - Keyword_align, - Keyword_allowzero, - Keyword_and, - Keyword_anyframe, - Keyword_anytype, - Keyword_asm, - Keyword_async, - Keyword_await, - Keyword_break, - Keyword_callconv, - Keyword_catch, - Keyword_comptime, - Keyword_const, - Keyword_continue, - Keyword_defer, - Keyword_else, - Keyword_enum, - Keyword_errdefer, - Keyword_error, - Keyword_export, - Keyword_extern, - Keyword_false, - Keyword_fn, - Keyword_for, - Keyword_if, - Keyword_inline, - Keyword_noalias, - Keyword_noinline, - Keyword_nosuspend, - Keyword_null, - Keyword_opaque, - Keyword_or, - Keyword_orelse, - Keyword_packed, - Keyword_pub, - Keyword_resume, - Keyword_return, - Keyword_linksection, - Keyword_struct, - Keyword_suspend, - Keyword_switch, - Keyword_test, - Keyword_threadlocal, - Keyword_true, - Keyword_try, - Keyword_undefined, - Keyword_union, - Keyword_unreachable, - Keyword_usingnamespace, - Keyword_var, - Keyword_volatile, - Keyword_while, + pub const Tag = enum { + invalid, + invalid_ampersands, + invalid_periodasterisks, + identifier, + string_literal, + multiline_string_literal_line, + char_literal, + eof, + builtin, + bang, + pipe, + pipe_pipe, + pipe_equal, + equal, + equal_equal, + equal_angle_bracket_right, + bang_equal, + l_paren, + r_paren, + semicolon, + percent, + percent_equal, + l_brace, + r_brace, + l_bracket, + r_bracket, + period, + period_asterisk, + ellipsis2, + ellipsis3, + caret, + caret_equal, + plus, + plus_plus, + plus_equal, + plus_percent, + plus_percent_equal, + minus, + minus_equal, + minus_percent, + minus_percent_equal, + asterisk, + asterisk_equal, + asterisk_asterisk, + asterisk_percent, + asterisk_percent_equal, + arrow, + colon, + slash, + slash_equal, + comma, + ampersand, + ampersand_equal, + question_mark, + angle_bracket_left, + angle_bracket_left_equal, + angle_bracket_angle_bracket_left, + angle_bracket_angle_bracket_left_equal, + angle_bracket_right, + angle_bracket_right_equal, + angle_bracket_angle_bracket_right, + angle_bracket_angle_bracket_right_equal, + tilde, + integer_literal, + float_literal, + doc_comment, + container_doc_comment, + keyword_align, + keyword_allowzero, + keyword_and, + keyword_anyframe, + keyword_anytype, + keyword_asm, + keyword_async, + keyword_await, + keyword_break, + keyword_callconv, + keyword_catch, + keyword_comptime, + keyword_const, + keyword_continue, + keyword_defer, + keyword_else, + keyword_enum, + keyword_errdefer, + keyword_error, + keyword_export, + keyword_extern, + keyword_false, + keyword_fn, + keyword_for, + keyword_if, + keyword_inline, + keyword_noalias, + keyword_noinline, + keyword_nosuspend, + keyword_null, + keyword_opaque, + keyword_or, + keyword_orelse, + keyword_packed, + keyword_pub, + keyword_resume, + keyword_return, + keyword_linksection, + keyword_struct, + keyword_suspend, + keyword_switch, + keyword_test, + keyword_threadlocal, + keyword_true, + keyword_try, + keyword_undefined, + keyword_union, + keyword_unreachable, + keyword_usingnamespace, + keyword_var, + keyword_volatile, + keyword_while, - pub fn symbol(id: Id) []const u8 { - return switch (id) { - .Invalid => "Invalid", - .Invalid_ampersands => "&&", - .Invalid_periodasterisks => ".**", - .Identifier => "Identifier", - .StringLiteral => "StringLiteral", - .MultilineStringLiteralLine => "MultilineStringLiteralLine", - .CharLiteral => "CharLiteral", - .Eof => "Eof", - .Builtin => "Builtin", - .IntegerLiteral => "IntegerLiteral", - .FloatLiteral => "FloatLiteral", - .LineComment => "LineComment", - .DocComment => "DocComment", - .ContainerDocComment => "ContainerDocComment", - .ShebangLine => "ShebangLine", + pub fn lexeme(tag: Tag) ?[]const u8 { + return switch (tag) { + .invalid, + .identifier, + .string_literal, + .multiline_string_literal_line, + .char_literal, + .eof, + .builtin, + .integer_literal, + .float_literal, + .doc_comment, + .container_doc_comment, + => null, - .Bang => "!", - .Pipe => "|", - .PipePipe => "||", - .PipeEqual => "|=", - .Equal => "=", - .EqualEqual => "==", - .EqualAngleBracketRight => "=>", - .BangEqual => "!=", - .LParen => "(", - .RParen => ")", - .Semicolon => ";", - .Percent => "%", - .PercentEqual => "%=", - .LBrace => "{", - .RBrace => "}", - .LBracket => "[", - .RBracket => "]", - .Period => ".", - .PeriodAsterisk => ".*", - .Ellipsis2 => "..", - .Ellipsis3 => "...", - .Caret => "^", - .CaretEqual => "^=", - .Plus => "+", - .PlusPlus => "++", - .PlusEqual => "+=", - .PlusPercent => "+%", - .PlusPercentEqual => "+%=", - .Minus => "-", - .MinusEqual => "-=", - .MinusPercent => "-%", - .MinusPercentEqual => "-%=", - .Asterisk => "*", - .AsteriskEqual => "*=", - .AsteriskAsterisk => "**", - .AsteriskPercent => "*%", - .AsteriskPercentEqual => "*%=", - .Arrow => "->", - .Colon => ":", - .Slash => "/", - .SlashEqual => "/=", - .Comma => ",", - .Ampersand => "&", - .AmpersandEqual => "&=", - .QuestionMark => "?", - .AngleBracketLeft => "<", - .AngleBracketLeftEqual => "<=", - .AngleBracketAngleBracketLeft => "<<", - .AngleBracketAngleBracketLeftEqual => "<<=", - .AngleBracketRight => ">", - .AngleBracketRightEqual => ">=", - .AngleBracketAngleBracketRight => ">>", - .AngleBracketAngleBracketRightEqual => ">>=", - .Tilde => "~", - .Keyword_align => "align", - .Keyword_allowzero => "allowzero", - .Keyword_and => "and", - .Keyword_anyframe => "anyframe", - .Keyword_anytype => "anytype", - .Keyword_asm => "asm", - .Keyword_async => "async", - .Keyword_await => "await", - .Keyword_break => "break", - .Keyword_callconv => "callconv", - .Keyword_catch => "catch", - .Keyword_comptime => "comptime", - .Keyword_const => "const", - .Keyword_continue => "continue", - .Keyword_defer => "defer", - .Keyword_else => "else", - .Keyword_enum => "enum", - .Keyword_errdefer => "errdefer", - .Keyword_error => "error", - .Keyword_export => "export", - .Keyword_extern => "extern", - .Keyword_false => "false", - .Keyword_fn => "fn", - .Keyword_for => "for", - .Keyword_if => "if", - .Keyword_inline => "inline", - .Keyword_noalias => "noalias", - .Keyword_noinline => "noinline", - .Keyword_nosuspend => "nosuspend", - .Keyword_null => "null", - .Keyword_opaque => "opaque", - .Keyword_or => "or", - .Keyword_orelse => "orelse", - .Keyword_packed => "packed", - .Keyword_pub => "pub", - .Keyword_resume => "resume", - .Keyword_return => "return", - .Keyword_linksection => "linksection", - .Keyword_struct => "struct", - .Keyword_suspend => "suspend", - .Keyword_switch => "switch", - .Keyword_test => "test", - .Keyword_threadlocal => "threadlocal", - .Keyword_true => "true", - .Keyword_try => "try", - .Keyword_undefined => "undefined", - .Keyword_union => "union", - .Keyword_unreachable => "unreachable", - .Keyword_usingnamespace => "usingnamespace", - .Keyword_var => "var", - .Keyword_volatile => "volatile", - .Keyword_while => "while", + .invalid_ampersands => "&&", + .invalid_periodasterisks => ".**", + .bang => "!", + .pipe => "|", + .pipe_pipe => "||", + .pipe_equal => "|=", + .equal => "=", + .equal_equal => "==", + .equal_angle_bracket_right => "=>", + .bang_equal => "!=", + .l_paren => "(", + .r_paren => ")", + .semicolon => ";", + .percent => "%", + .percent_equal => "%=", + .l_brace => "{", + .r_brace => "}", + .l_bracket => "[", + .r_bracket => "]", + .period => ".", + .period_asterisk => ".*", + .ellipsis2 => "..", + .ellipsis3 => "...", + .caret => "^", + .caret_equal => "^=", + .plus => "+", + .plus_plus => "++", + .plus_equal => "+=", + .plus_percent => "+%", + .plus_percent_equal => "+%=", + .minus => "-", + .minus_equal => "-=", + .minus_percent => "-%", + .minus_percent_equal => "-%=", + .asterisk => "*", + .asterisk_equal => "*=", + .asterisk_asterisk => "**", + .asterisk_percent => "*%", + .asterisk_percent_equal => "*%=", + .arrow => "->", + .colon => ":", + .slash => "/", + .slash_equal => "/=", + .comma => ",", + .ampersand => "&", + .ampersand_equal => "&=", + .question_mark => "?", + .angle_bracket_left => "<", + .angle_bracket_left_equal => "<=", + .angle_bracket_angle_bracket_left => "<<", + .angle_bracket_angle_bracket_left_equal => "<<=", + .angle_bracket_right => ">", + .angle_bracket_right_equal => ">=", + .angle_bracket_angle_bracket_right => ">>", + .angle_bracket_angle_bracket_right_equal => ">>=", + .tilde => "~", + .keyword_align => "align", + .keyword_allowzero => "allowzero", + .keyword_and => "and", + .keyword_anyframe => "anyframe", + .keyword_anytype => "anytype", + .keyword_asm => "asm", + .keyword_async => "async", + .keyword_await => "await", + .keyword_break => "break", + .keyword_callconv => "callconv", + .keyword_catch => "catch", + .keyword_comptime => "comptime", + .keyword_const => "const", + .keyword_continue => "continue", + .keyword_defer => "defer", + .keyword_else => "else", + .keyword_enum => "enum", + .keyword_errdefer => "errdefer", + .keyword_error => "error", + .keyword_export => "export", + .keyword_extern => "extern", + .keyword_false => "false", + .keyword_fn => "fn", + .keyword_for => "for", + .keyword_if => "if", + .keyword_inline => "inline", + .keyword_noalias => "noalias", + .keyword_noinline => "noinline", + .keyword_nosuspend => "nosuspend", + .keyword_null => "null", + .keyword_opaque => "opaque", + .keyword_or => "or", + .keyword_orelse => "orelse", + .keyword_packed => "packed", + .keyword_pub => "pub", + .keyword_resume => "resume", + .keyword_return => "return", + .keyword_linksection => "linksection", + .keyword_struct => "struct", + .keyword_suspend => "suspend", + .keyword_switch => "switch", + .keyword_test => "test", + .keyword_threadlocal => "threadlocal", + .keyword_true => "true", + .keyword_try => "try", + .keyword_undefined => "undefined", + .keyword_union => "union", + .keyword_unreachable => "unreachable", + .keyword_usingnamespace => "usingnamespace", + .keyword_var => "var", + .keyword_volatile => "volatile", + .keyword_while => "while", }; } + + pub fn symbol(tag: Tag) []const u8 { + return tag.lexeme() orelse @tagName(tag); + } }; }; @@ -334,7 +334,7 @@ pub const Tokenizer = struct { /// For debugging purposes pub fn dump(self: *Tokenizer, token: *const Token) void { - std.debug.warn("{} \"{}\"\n", .{ @tagName(token.id), self.buffer[token.start..token.end] }); + std.debug.warn("{s} \"{s}\"\n", .{ @tagName(token.tag), self.buffer[token.start..token.end] }); } pub fn init(buffer: []const u8) Tokenizer { @@ -421,7 +421,7 @@ pub const Tokenizer = struct { const start_index = self.index; var state: State = .start; var result = Token{ - .id = .Eof, + .tag = .eof, .loc = .{ .start = self.index, .end = undefined, @@ -438,14 +438,14 @@ pub const Tokenizer = struct { }, '"' => { state = .string_literal; - result.id = .StringLiteral; + result.tag = .string_literal; }, '\'' => { state = .char_literal; }, 'a'...'z', 'A'...'Z', '_' => { state = .identifier; - result.id = .Identifier; + result.tag = .identifier; }, '@' => { state = .saw_at_sign; @@ -460,42 +460,42 @@ pub const Tokenizer = struct { state = .pipe; }, '(' => { - result.id = .LParen; + result.tag = .l_paren; self.index += 1; break; }, ')' => { - result.id = .RParen; + result.tag = .r_paren; self.index += 1; break; }, '[' => { - result.id = .LBracket; + result.tag = .l_bracket; self.index += 1; break; }, ']' => { - result.id = .RBracket; + result.tag = .r_bracket; self.index += 1; break; }, ';' => { - result.id = .Semicolon; + result.tag = .semicolon; self.index += 1; break; }, ',' => { - result.id = .Comma; + result.tag = .comma; self.index += 1; break; }, '?' => { - result.id = .QuestionMark; + result.tag = .question_mark; self.index += 1; break; }, ':' => { - result.id = .Colon; + result.tag = .colon; self.index += 1; break; }, @@ -519,20 +519,20 @@ pub const Tokenizer = struct { }, '\\' => { state = .backslash; - result.id = .MultilineStringLiteralLine; + result.tag = .multiline_string_literal_line; }, '{' => { - result.id = .LBrace; + result.tag = .l_brace; self.index += 1; break; }, '}' => { - result.id = .RBrace; + result.tag = .r_brace; self.index += 1; break; }, '~' => { - result.id = .Tilde; + result.tag = .tilde; self.index += 1; break; }, @@ -550,14 +550,14 @@ pub const Tokenizer = struct { }, '0' => { state = .zero; - result.id = .IntegerLiteral; + result.tag = .integer_literal; }, '1'...'9' => { state = .int_literal_dec; - result.id = .IntegerLiteral; + result.tag = .integer_literal; }, else => { - result.id = .Invalid; + result.tag = .invalid; self.index += 1; break; }, @@ -565,42 +565,42 @@ pub const Tokenizer = struct { .saw_at_sign => switch (c) { '"' => { - result.id = .Identifier; + result.tag = .identifier; state = .string_literal; }, else => { // reinterpret as a builtin self.index -= 1; state = .builtin; - result.id = .Builtin; + result.tag = .builtin; }, }, .ampersand => switch (c) { '&' => { - result.id = .Invalid_ampersands; + result.tag = .invalid_ampersands; self.index += 1; break; }, '=' => { - result.id = .AmpersandEqual; + result.tag = .ampersand_equal; self.index += 1; break; }, else => { - result.id = .Ampersand; + result.tag = .ampersand; break; }, }, .asterisk => switch (c) { '=' => { - result.id = .AsteriskEqual; + result.tag = .asterisk_equal; self.index += 1; break; }, '*' => { - result.id = .AsteriskAsterisk; + result.tag = .asterisk_asterisk; self.index += 1; break; }, @@ -608,43 +608,43 @@ pub const Tokenizer = struct { state = .asterisk_percent; }, else => { - result.id = .Asterisk; + result.tag = .asterisk; break; }, }, .asterisk_percent => switch (c) { '=' => { - result.id = .AsteriskPercentEqual; + result.tag = .asterisk_percent_equal; self.index += 1; break; }, else => { - result.id = .AsteriskPercent; + result.tag = .asterisk_percent; break; }, }, .percent => switch (c) { '=' => { - result.id = .PercentEqual; + result.tag = .percent_equal; self.index += 1; break; }, else => { - result.id = .Percent; + result.tag = .percent; break; }, }, .plus => switch (c) { '=' => { - result.id = .PlusEqual; + result.tag = .plus_equal; self.index += 1; break; }, '+' => { - result.id = .PlusPlus; + result.tag = .plus_plus; self.index += 1; break; }, @@ -652,31 +652,31 @@ pub const Tokenizer = struct { state = .plus_percent; }, else => { - result.id = .Plus; + result.tag = .plus; break; }, }, .plus_percent => switch (c) { '=' => { - result.id = .PlusPercentEqual; + result.tag = .plus_percent_equal; self.index += 1; break; }, else => { - result.id = .PlusPercent; + result.tag = .plus_percent; break; }, }, .caret => switch (c) { '=' => { - result.id = .CaretEqual; + result.tag = .caret_equal; self.index += 1; break; }, else => { - result.id = .Caret; + result.tag = .caret; break; }, }, @@ -684,8 +684,8 @@ pub const Tokenizer = struct { .identifier => switch (c) { 'a'...'z', 'A'...'Z', '_', '0'...'9' => {}, else => { - if (Token.getKeyword(self.buffer[result.loc.start..self.index])) |id| { - result.id = id; + if (Token.getKeyword(self.buffer[result.loc.start..self.index])) |tag| { + result.tag = tag; } break; }, @@ -724,7 +724,7 @@ pub const Tokenizer = struct { state = .char_literal_backslash; }, '\'', 0x80...0xbf, 0xf8...0xff => { - result.id = .Invalid; + result.tag = .invalid; break; }, 0xc0...0xdf => { // 110xxxxx @@ -746,7 +746,7 @@ pub const Tokenizer = struct { .char_literal_backslash => switch (c) { '\n' => { - result.id = .Invalid; + result.tag = .invalid; break; }, 'x' => { @@ -769,7 +769,7 @@ pub const Tokenizer = struct { } }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -780,7 +780,7 @@ pub const Tokenizer = struct { seen_escape_digits = 0; }, else => { - result.id = .Invalid; + result.tag = .invalid; state = .char_literal_unicode_invalid; }, }, @@ -791,14 +791,14 @@ pub const Tokenizer = struct { }, '}' => { if (seen_escape_digits == 0) { - result.id = .Invalid; + result.tag = .invalid; state = .char_literal_unicode_invalid; } else { state = .char_literal_end; } }, else => { - result.id = .Invalid; + result.tag = .invalid; state = .char_literal_unicode_invalid; }, }, @@ -813,12 +813,12 @@ pub const Tokenizer = struct { .char_literal_end => switch (c) { '\'' => { - result.id = .CharLiteral; + result.tag = .char_literal; self.index += 1; break; }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -831,7 +831,7 @@ pub const Tokenizer = struct { } }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -847,58 +847,58 @@ pub const Tokenizer = struct { .bang => switch (c) { '=' => { - result.id = .BangEqual; + result.tag = .bang_equal; self.index += 1; break; }, else => { - result.id = .Bang; + result.tag = .bang; break; }, }, .pipe => switch (c) { '=' => { - result.id = .PipeEqual; + result.tag = .pipe_equal; self.index += 1; break; }, '|' => { - result.id = .PipePipe; + result.tag = .pipe_pipe; self.index += 1; break; }, else => { - result.id = .Pipe; + result.tag = .pipe; break; }, }, .equal => switch (c) { '=' => { - result.id = .EqualEqual; + result.tag = .equal_equal; self.index += 1; break; }, '>' => { - result.id = .EqualAngleBracketRight; + result.tag = .equal_angle_bracket_right; self.index += 1; break; }, else => { - result.id = .Equal; + result.tag = .equal; break; }, }, .minus => switch (c) { '>' => { - result.id = .Arrow; + result.tag = .arrow; self.index += 1; break; }, '=' => { - result.id = .MinusEqual; + result.tag = .minus_equal; self.index += 1; break; }, @@ -906,19 +906,19 @@ pub const Tokenizer = struct { state = .minus_percent; }, else => { - result.id = .Minus; + result.tag = .minus; break; }, }, .minus_percent => switch (c) { '=' => { - result.id = .MinusPercentEqual; + result.tag = .minus_percent_equal; self.index += 1; break; }, else => { - result.id = .MinusPercent; + result.tag = .minus_percent; break; }, }, @@ -928,24 +928,24 @@ pub const Tokenizer = struct { state = .angle_bracket_angle_bracket_left; }, '=' => { - result.id = .AngleBracketLeftEqual; + result.tag = .angle_bracket_left_equal; self.index += 1; break; }, else => { - result.id = .AngleBracketLeft; + result.tag = .angle_bracket_left; break; }, }, .angle_bracket_angle_bracket_left => switch (c) { '=' => { - result.id = .AngleBracketAngleBracketLeftEqual; + result.tag = .angle_bracket_angle_bracket_left_equal; self.index += 1; break; }, else => { - result.id = .AngleBracketAngleBracketLeft; + result.tag = .angle_bracket_angle_bracket_left; break; }, }, @@ -955,24 +955,24 @@ pub const Tokenizer = struct { state = .angle_bracket_angle_bracket_right; }, '=' => { - result.id = .AngleBracketRightEqual; + result.tag = .angle_bracket_right_equal; self.index += 1; break; }, else => { - result.id = .AngleBracketRight; + result.tag = .angle_bracket_right; break; }, }, .angle_bracket_angle_bracket_right => switch (c) { '=' => { - result.id = .AngleBracketAngleBracketRightEqual; + result.tag = .angle_bracket_angle_bracket_right_equal; self.index += 1; break; }, else => { - result.id = .AngleBracketAngleBracketRight; + result.tag = .angle_bracket_angle_bracket_right; break; }, }, @@ -985,30 +985,30 @@ pub const Tokenizer = struct { state = .period_asterisk; }, else => { - result.id = .Period; + result.tag = .period; break; }, }, .period_2 => switch (c) { '.' => { - result.id = .Ellipsis3; + result.tag = .ellipsis3; self.index += 1; break; }, else => { - result.id = .Ellipsis2; + result.tag = .ellipsis2; break; }, }, .period_asterisk => switch (c) { '*' => { - result.id = .Invalid_periodasterisks; + result.tag = .invalid_periodasterisks; break; }, else => { - result.id = .PeriodAsterisk; + result.tag = .period_asterisk; break; }, }, @@ -1016,15 +1016,14 @@ pub const Tokenizer = struct { .slash => switch (c) { '/' => { state = .line_comment_start; - result.id = .LineComment; }, '=' => { - result.id = .SlashEqual; + result.tag = .slash_equal; self.index += 1; break; }, else => { - result.id = .Slash; + result.tag = .slash; break; }, }, @@ -1033,10 +1032,13 @@ pub const Tokenizer = struct { state = .doc_comment_start; }, '!' => { - result.id = .ContainerDocComment; + result.tag = .container_doc_comment; state = .container_doc_comment; }, - '\n' => break, + '\n' => { + state = .start; + result.loc.start = self.index + 1; + }, '\t', '\r' => state = .line_comment, else => { state = .line_comment; @@ -1048,20 +1050,28 @@ pub const Tokenizer = struct { state = .line_comment; }, '\n' => { - result.id = .DocComment; + result.tag = .doc_comment; break; }, '\t', '\r' => { state = .doc_comment; - result.id = .DocComment; + result.tag = .doc_comment; }, else => { state = .doc_comment; - result.id = .DocComment; + result.tag = .doc_comment; self.checkLiteralCharacter(); }, }, - .line_comment, .doc_comment, .container_doc_comment => switch (c) { + .line_comment => switch (c) { + '\n' => { + state = .start; + result.loc.start = self.index + 1; + }, + '\t', '\r' => {}, + else => self.checkLiteralCharacter(), + }, + .doc_comment, .container_doc_comment => switch (c) { '\n' => break, '\t', '\r' => {}, else => self.checkLiteralCharacter(), @@ -1083,7 +1093,7 @@ pub const Tokenizer = struct { }, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, @@ -1093,7 +1103,7 @@ pub const Tokenizer = struct { state = .int_literal_bin; }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -1104,7 +1114,7 @@ pub const Tokenizer = struct { '0'...'1' => {}, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, @@ -1114,7 +1124,7 @@ pub const Tokenizer = struct { state = .int_literal_oct; }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -1125,7 +1135,7 @@ pub const Tokenizer = struct { '0'...'7' => {}, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, @@ -1135,7 +1145,7 @@ pub const Tokenizer = struct { state = .int_literal_dec; }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -1145,16 +1155,16 @@ pub const Tokenizer = struct { }, '.' => { state = .num_dot_dec; - result.id = .FloatLiteral; + result.tag = .float_literal; }, 'e', 'E' => { state = .float_exponent_unsigned; - result.id = .FloatLiteral; + result.tag = .float_literal; }, '0'...'9' => {}, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, @@ -1164,7 +1174,7 @@ pub const Tokenizer = struct { state = .int_literal_hex; }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -1174,23 +1184,23 @@ pub const Tokenizer = struct { }, '.' => { state = .num_dot_hex; - result.id = .FloatLiteral; + result.tag = .float_literal; }, 'p', 'P' => { state = .float_exponent_unsigned; - result.id = .FloatLiteral; + result.tag = .float_literal; }, '0'...'9', 'a'...'f', 'A'...'F' => {}, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, }, .num_dot_dec => switch (c) { '.' => { - result.id = .IntegerLiteral; + result.tag = .integer_literal; self.index -= 1; state = .start; break; @@ -1203,14 +1213,14 @@ pub const Tokenizer = struct { }, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, }, .num_dot_hex => switch (c) { '.' => { - result.id = .IntegerLiteral; + result.tag = .integer_literal; self.index -= 1; state = .start; break; @@ -1219,12 +1229,12 @@ pub const Tokenizer = struct { state = .float_exponent_unsigned; }, '0'...'9', 'a'...'f', 'A'...'F' => { - result.id = .FloatLiteral; + result.tag = .float_literal; state = .float_fraction_hex; }, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, @@ -1234,7 +1244,7 @@ pub const Tokenizer = struct { state = .float_fraction_dec; }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -1248,7 +1258,7 @@ pub const Tokenizer = struct { '0'...'9' => {}, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, @@ -1258,7 +1268,7 @@ pub const Tokenizer = struct { state = .float_fraction_hex; }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -1272,7 +1282,7 @@ pub const Tokenizer = struct { '0'...'9', 'a'...'f', 'A'...'F' => {}, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, @@ -1292,7 +1302,7 @@ pub const Tokenizer = struct { state = .float_exponent_num; }, else => { - result.id = .Invalid; + result.tag = .invalid; break; }, }, @@ -1303,7 +1313,7 @@ pub const Tokenizer = struct { '0'...'9' => {}, else => { if (isIdentifierChar(c)) { - result.id = .Invalid; + result.tag = .invalid; } break; }, @@ -1324,21 +1334,20 @@ pub const Tokenizer = struct { .string_literal, // find this error later .multiline_string_literal_line, .builtin, + .line_comment, + .line_comment_start, => {}, .identifier => { - if (Token.getKeyword(self.buffer[result.loc.start..self.index])) |id| { - result.id = id; + if (Token.getKeyword(self.buffer[result.loc.start..self.index])) |tag| { + result.tag = tag; } }, - .line_comment, .line_comment_start => { - result.id = .LineComment; - }, .doc_comment, .doc_comment_start => { - result.id = .DocComment; + result.tag = .doc_comment; }, .container_doc_comment => { - result.id = .ContainerDocComment; + result.tag = .container_doc_comment; }, .int_literal_dec_no_underscore, @@ -1361,80 +1370,81 @@ pub const Tokenizer = struct { .char_literal_unicode, .string_literal_backslash, => { - result.id = .Invalid; + result.tag = .invalid; }, .equal => { - result.id = .Equal; + result.tag = .equal; }, .bang => { - result.id = .Bang; + result.tag = .bang; }, .minus => { - result.id = .Minus; + result.tag = .minus; }, .slash => { - result.id = .Slash; + result.tag = .slash; }, .zero => { - result.id = .IntegerLiteral; + result.tag = .integer_literal; }, .ampersand => { - result.id = .Ampersand; + result.tag = .ampersand; }, .period => { - result.id = .Period; + result.tag = .period; }, .period_2 => { - result.id = .Ellipsis2; + result.tag = .ellipsis2; }, .period_asterisk => { - result.id = .PeriodAsterisk; + result.tag = .period_asterisk; }, .pipe => { - result.id = .Pipe; + result.tag = .pipe; }, .angle_bracket_angle_bracket_right => { - result.id = .AngleBracketAngleBracketRight; + result.tag = .angle_bracket_angle_bracket_right; }, .angle_bracket_right => { - result.id = .AngleBracketRight; + result.tag = .angle_bracket_right; }, .angle_bracket_angle_bracket_left => { - result.id = .AngleBracketAngleBracketLeft; + result.tag = .angle_bracket_angle_bracket_left; }, .angle_bracket_left => { - result.id = .AngleBracketLeft; + result.tag = .angle_bracket_left; }, .plus_percent => { - result.id = .PlusPercent; + result.tag = .plus_percent; }, .plus => { - result.id = .Plus; + result.tag = .plus; }, .percent => { - result.id = .Percent; + result.tag = .percent; }, .caret => { - result.id = .Caret; + result.tag = .caret; }, .asterisk_percent => { - result.id = .AsteriskPercent; + result.tag = .asterisk_percent; }, .asterisk => { - result.id = .Asterisk; + result.tag = .asterisk; }, .minus_percent => { - result.id = .MinusPercent; + result.tag = .minus_percent; }, } } - if (result.id == .Eof) { + if (result.tag == .eof) { if (self.pending_invalid_token) |token| { self.pending_invalid_token = null; return token; } + result.loc.start = self.index; } result.loc.end = self.index; @@ -1446,7 +1456,7 @@ pub const Tokenizer = struct { const invalid_length = self.getInvalidCharacterLength(); if (invalid_length == 0) return; self.pending_invalid_token = .{ - .id = .Invalid, + .tag = .invalid, .loc = .{ .start = self.index, .end = self.index + invalid_length, @@ -1493,220 +1503,218 @@ pub const Tokenizer = struct { }; test "tokenizer" { - testTokenize("test", &[_]Token.Id{.Keyword_test}); + testTokenize("test", &.{.keyword_test}); +} + +test "line comment followed by top-level comptime" { + testTokenize( + \\// line comment + \\comptime {} + \\ + , &.{ + .keyword_comptime, + .l_brace, + .r_brace, + }); } test "tokenizer - unknown length pointer and then c pointer" { testTokenize( \\[*]u8 \\[*c]u8 - , &[_]Token.Id{ - .LBracket, - .Asterisk, - .RBracket, - .Identifier, - .LBracket, - .Asterisk, - .Identifier, - .RBracket, - .Identifier, + , &.{ + .l_bracket, + .asterisk, + .r_bracket, + .identifier, + .l_bracket, + .asterisk, + .identifier, + .r_bracket, + .identifier, }); } -test "tokenizer - char literal with hex escape" { +test "tokenizer - code point literal with hex escape" { testTokenize( \\'\x1b' - , &[_]Token.Id{.CharLiteral}); + , &.{.char_literal}); testTokenize( \\'\x1' - , &[_]Token.Id{ .Invalid, .Invalid }); + , &.{ .invalid, .invalid }); } -test "tokenizer - char literal with unicode escapes" { +test "tokenizer - code point literal with unicode escapes" { // Valid unicode escapes testTokenize( \\'\u{3}' - , &[_]Token.Id{.CharLiteral}); + , &.{.char_literal}); testTokenize( \\'\u{01}' - , &[_]Token.Id{.CharLiteral}); + , &.{.char_literal}); testTokenize( \\'\u{2a}' - , &[_]Token.Id{.CharLiteral}); + , &.{.char_literal}); testTokenize( \\'\u{3f9}' - , &[_]Token.Id{.CharLiteral}); + , &.{.char_literal}); testTokenize( \\'\u{6E09aBc1523}' - , &[_]Token.Id{.CharLiteral}); + , &.{.char_literal}); testTokenize( \\"\u{440}" - , &[_]Token.Id{.StringLiteral}); + , &.{.string_literal}); // Invalid unicode escapes testTokenize( \\'\u' - , &[_]Token.Id{.Invalid}); + , &.{.invalid}); testTokenize( \\'\u{{' - , &[_]Token.Id{ .Invalid, .Invalid }); + , &.{ .invalid, .invalid }); testTokenize( \\'\u{}' - , &[_]Token.Id{ .Invalid, .Invalid }); + , &.{ .invalid, .invalid }); testTokenize( \\'\u{s}' - , &[_]Token.Id{ .Invalid, .Invalid }); + , &.{ .invalid, .invalid }); testTokenize( \\'\u{2z}' - , &[_]Token.Id{ .Invalid, .Invalid }); + , &.{ .invalid, .invalid }); testTokenize( \\'\u{4a' - , &[_]Token.Id{.Invalid}); + , &.{.invalid}); // Test old-style unicode literals testTokenize( \\'\u0333' - , &[_]Token.Id{ .Invalid, .Invalid }); + , &.{ .invalid, .invalid }); testTokenize( \\'\U0333' - , &[_]Token.Id{ .Invalid, .IntegerLiteral, .Invalid }); + , &.{ .invalid, .integer_literal, .invalid }); } -test "tokenizer - char literal with unicode code point" { +test "tokenizer - code point literal with unicode code point" { testTokenize( \\'💩' - , &[_]Token.Id{.CharLiteral}); + , &.{.char_literal}); } test "tokenizer - float literal e exponent" { - testTokenize("a = 4.94065645841246544177e-324;\n", &[_]Token.Id{ - .Identifier, - .Equal, - .FloatLiteral, - .Semicolon, + testTokenize("a = 4.94065645841246544177e-324;\n", &.{ + .identifier, + .equal, + .float_literal, + .semicolon, }); } test "tokenizer - float literal p exponent" { - testTokenize("a = 0x1.a827999fcef32p+1022;\n", &[_]Token.Id{ - .Identifier, - .Equal, - .FloatLiteral, - .Semicolon, + testTokenize("a = 0x1.a827999fcef32p+1022;\n", &.{ + .identifier, + .equal, + .float_literal, + .semicolon, }); } test "tokenizer - chars" { - testTokenize("'c'", &[_]Token.Id{.CharLiteral}); + testTokenize("'c'", &.{.char_literal}); } test "tokenizer - invalid token characters" { - testTokenize("#", &[_]Token.Id{.Invalid}); - testTokenize("`", &[_]Token.Id{.Invalid}); - testTokenize("'c", &[_]Token.Id{.Invalid}); - testTokenize("'", &[_]Token.Id{.Invalid}); - testTokenize("''", &[_]Token.Id{ .Invalid, .Invalid }); + testTokenize("#", &.{.invalid}); + testTokenize("`", &.{.invalid}); + testTokenize("'c", &.{.invalid}); + testTokenize("'", &.{.invalid}); + testTokenize("''", &.{ .invalid, .invalid }); } test "tokenizer - invalid literal/comment characters" { - testTokenize("\"\x00\"", &[_]Token.Id{ - .StringLiteral, - .Invalid, + testTokenize("\"\x00\"", &.{ + .string_literal, + .invalid, }); - testTokenize("//\x00", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\x00", &.{ + .invalid, }); - testTokenize("//\x1f", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\x1f", &.{ + .invalid, }); - testTokenize("//\x7f", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\x7f", &.{ + .invalid, }); } test "tokenizer - utf8" { - testTokenize("//\xc2\x80", &[_]Token.Id{.LineComment}); - testTokenize("//\xf4\x8f\xbf\xbf", &[_]Token.Id{.LineComment}); + testTokenize("//\xc2\x80", &.{}); + testTokenize("//\xf4\x8f\xbf\xbf", &.{}); } test "tokenizer - invalid utf8" { - testTokenize("//\x80", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\x80", &.{ + .invalid, }); - testTokenize("//\xbf", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xbf", &.{ + .invalid, }); - testTokenize("//\xf8", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xf8", &.{ + .invalid, }); - testTokenize("//\xff", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xff", &.{ + .invalid, }); - testTokenize("//\xc2\xc0", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xc2\xc0", &.{ + .invalid, }); - testTokenize("//\xe0", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xe0", &.{ + .invalid, }); - testTokenize("//\xf0", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xf0", &.{ + .invalid, }); - testTokenize("//\xf0\x90\x80\xc0", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xf0\x90\x80\xc0", &.{ + .invalid, }); } test "tokenizer - illegal unicode codepoints" { // unicode newline characters.U+0085, U+2028, U+2029 - testTokenize("//\xc2\x84", &[_]Token.Id{.LineComment}); - testTokenize("//\xc2\x85", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xc2\x84", &.{}); + testTokenize("//\xc2\x85", &.{ + .invalid, }); - testTokenize("//\xc2\x86", &[_]Token.Id{.LineComment}); - testTokenize("//\xe2\x80\xa7", &[_]Token.Id{.LineComment}); - testTokenize("//\xe2\x80\xa8", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xc2\x86", &.{}); + testTokenize("//\xe2\x80\xa7", &.{}); + testTokenize("//\xe2\x80\xa8", &.{ + .invalid, }); - testTokenize("//\xe2\x80\xa9", &[_]Token.Id{ - .LineComment, - .Invalid, + testTokenize("//\xe2\x80\xa9", &.{ + .invalid, }); - testTokenize("//\xe2\x80\xaa", &[_]Token.Id{.LineComment}); + testTokenize("//\xe2\x80\xaa", &.{}); } test "tokenizer - string identifier and builtin fns" { testTokenize( \\const @"if" = @import("std"); - , &[_]Token.Id{ - .Keyword_const, - .Identifier, - .Equal, - .Builtin, - .LParen, - .StringLiteral, - .RParen, - .Semicolon, + , &.{ + .keyword_const, + .identifier, + .equal, + .builtin, + .l_paren, + .string_literal, + .r_paren, + .semicolon, }); } test "tokenizer - multiline string literal with literal tab" { testTokenize( \\\\foo bar - , &[_]Token.Id{ - .MultilineStringLiteralLine, + , &.{ + .multiline_string_literal_line, }); } @@ -1718,32 +1726,30 @@ test "tokenizer - comments with literal tab" { \\// foo \\/// foo \\/// /foo - , &[_]Token.Id{ - .LineComment, - .ContainerDocComment, - .DocComment, - .LineComment, - .DocComment, - .DocComment, + , &.{ + .container_doc_comment, + .doc_comment, + .doc_comment, + .doc_comment, }); } test "tokenizer - pipe and then invalid" { - testTokenize("||=", &[_]Token.Id{ - .PipePipe, - .Equal, + testTokenize("||=", &.{ + .pipe_pipe, + .equal, }); } test "tokenizer - line comment and doc comment" { - testTokenize("//", &[_]Token.Id{.LineComment}); - testTokenize("// a / b", &[_]Token.Id{.LineComment}); - testTokenize("// /", &[_]Token.Id{.LineComment}); - testTokenize("/// a", &[_]Token.Id{.DocComment}); - testTokenize("///", &[_]Token.Id{.DocComment}); - testTokenize("////", &[_]Token.Id{.LineComment}); - testTokenize("//!", &[_]Token.Id{.ContainerDocComment}); - testTokenize("//!!", &[_]Token.Id{.ContainerDocComment}); + testTokenize("//", &.{}); + testTokenize("// a / b", &.{}); + testTokenize("// /", &.{}); + testTokenize("/// a", &.{.doc_comment}); + testTokenize("///", &.{.doc_comment}); + testTokenize("////", &.{}); + testTokenize("//!", &.{.container_doc_comment}); + testTokenize("//!!", &.{.container_doc_comment}); } test "tokenizer - line comment followed by identifier" { @@ -1751,304 +1757,304 @@ test "tokenizer - line comment followed by identifier" { \\ Unexpected, \\ // another \\ Another, - , &[_]Token.Id{ - .Identifier, - .Comma, - .LineComment, - .Identifier, - .Comma, + , &.{ + .identifier, + .comma, + .identifier, + .comma, }); } test "tokenizer - UTF-8 BOM is recognized and skipped" { - testTokenize("\xEF\xBB\xBFa;\n", &[_]Token.Id{ - .Identifier, - .Semicolon, + testTokenize("\xEF\xBB\xBFa;\n", &.{ + .identifier, + .semicolon, }); } test "correctly parse pointer assignment" { - testTokenize("b.*=3;\n", &[_]Token.Id{ - .Identifier, - .PeriodAsterisk, - .Equal, - .IntegerLiteral, - .Semicolon, + testTokenize("b.*=3;\n", &.{ + .identifier, + .period_asterisk, + .equal, + .integer_literal, + .semicolon, }); } test "correctly parse pointer dereference followed by asterisk" { - testTokenize("\"b\".* ** 10", &[_]Token.Id{ - .StringLiteral, - .PeriodAsterisk, - .AsteriskAsterisk, - .IntegerLiteral, + testTokenize("\"b\".* ** 10", &.{ + .string_literal, + .period_asterisk, + .asterisk_asterisk, + .integer_literal, }); - testTokenize("(\"b\".*)** 10", &[_]Token.Id{ - .LParen, - .StringLiteral, - .PeriodAsterisk, - .RParen, - .AsteriskAsterisk, - .IntegerLiteral, + testTokenize("(\"b\".*)** 10", &.{ + .l_paren, + .string_literal, + .period_asterisk, + .r_paren, + .asterisk_asterisk, + .integer_literal, }); - testTokenize("\"b\".*** 10", &[_]Token.Id{ - .StringLiteral, - .Invalid_periodasterisks, - .AsteriskAsterisk, - .IntegerLiteral, + testTokenize("\"b\".*** 10", &.{ + .string_literal, + .invalid_periodasterisks, + .asterisk_asterisk, + .integer_literal, }); } test "tokenizer - range literals" { - testTokenize("0...9", &[_]Token.Id{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral }); - testTokenize("'0'...'9'", &[_]Token.Id{ .CharLiteral, .Ellipsis3, .CharLiteral }); - testTokenize("0x00...0x09", &[_]Token.Id{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral }); - testTokenize("0b00...0b11", &[_]Token.Id{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral }); - testTokenize("0o00...0o11", &[_]Token.Id{ .IntegerLiteral, .Ellipsis3, .IntegerLiteral }); + testTokenize("0...9", &.{ .integer_literal, .ellipsis3, .integer_literal }); + testTokenize("'0'...'9'", &.{ .char_literal, .ellipsis3, .char_literal }); + testTokenize("0x00...0x09", &.{ .integer_literal, .ellipsis3, .integer_literal }); + testTokenize("0b00...0b11", &.{ .integer_literal, .ellipsis3, .integer_literal }); + testTokenize("0o00...0o11", &.{ .integer_literal, .ellipsis3, .integer_literal }); } test "tokenizer - number literals decimal" { - testTokenize("0", &[_]Token.Id{.IntegerLiteral}); - testTokenize("1", &[_]Token.Id{.IntegerLiteral}); - testTokenize("2", &[_]Token.Id{.IntegerLiteral}); - testTokenize("3", &[_]Token.Id{.IntegerLiteral}); - testTokenize("4", &[_]Token.Id{.IntegerLiteral}); - testTokenize("5", &[_]Token.Id{.IntegerLiteral}); - testTokenize("6", &[_]Token.Id{.IntegerLiteral}); - testTokenize("7", &[_]Token.Id{.IntegerLiteral}); - testTokenize("8", &[_]Token.Id{.IntegerLiteral}); - testTokenize("9", &[_]Token.Id{.IntegerLiteral}); - testTokenize("1..", &[_]Token.Id{ .IntegerLiteral, .Ellipsis2 }); - testTokenize("0a", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("9b", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1z", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1z_1", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("9z3", &[_]Token.Id{ .Invalid, .Identifier }); + testTokenize("0", &.{.integer_literal}); + testTokenize("1", &.{.integer_literal}); + testTokenize("2", &.{.integer_literal}); + testTokenize("3", &.{.integer_literal}); + testTokenize("4", &.{.integer_literal}); + testTokenize("5", &.{.integer_literal}); + testTokenize("6", &.{.integer_literal}); + testTokenize("7", &.{.integer_literal}); + testTokenize("8", &.{.integer_literal}); + testTokenize("9", &.{.integer_literal}); + testTokenize("1..", &.{ .integer_literal, .ellipsis2 }); + testTokenize("0a", &.{ .invalid, .identifier }); + testTokenize("9b", &.{ .invalid, .identifier }); + testTokenize("1z", &.{ .invalid, .identifier }); + testTokenize("1z_1", &.{ .invalid, .identifier }); + testTokenize("9z3", &.{ .invalid, .identifier }); - testTokenize("0_0", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0001", &[_]Token.Id{.IntegerLiteral}); - testTokenize("01234567890", &[_]Token.Id{.IntegerLiteral}); - testTokenize("012_345_6789_0", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0_1_2_3_4_5_6_7_8_9_0", &[_]Token.Id{.IntegerLiteral}); + testTokenize("0_0", &.{.integer_literal}); + testTokenize("0001", &.{.integer_literal}); + testTokenize("01234567890", &.{.integer_literal}); + testTokenize("012_345_6789_0", &.{.integer_literal}); + testTokenize("0_1_2_3_4_5_6_7_8_9_0", &.{.integer_literal}); - testTokenize("00_", &[_]Token.Id{.Invalid}); - testTokenize("0_0_", &[_]Token.Id{.Invalid}); - testTokenize("0__0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0_0f", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0_0_f", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0_0_f_00", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1_,", &[_]Token.Id{ .Invalid, .Comma }); + testTokenize("00_", &.{.invalid}); + testTokenize("0_0_", &.{.invalid}); + testTokenize("0__0", &.{ .invalid, .identifier }); + testTokenize("0_0f", &.{ .invalid, .identifier }); + testTokenize("0_0_f", &.{ .invalid, .identifier }); + testTokenize("0_0_f_00", &.{ .invalid, .identifier }); + testTokenize("1_,", &.{ .invalid, .comma }); - testTokenize("1.", &[_]Token.Id{.FloatLiteral}); - testTokenize("0.0", &[_]Token.Id{.FloatLiteral}); - testTokenize("1.0", &[_]Token.Id{.FloatLiteral}); - testTokenize("10.0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0e0", &[_]Token.Id{.FloatLiteral}); - testTokenize("1e0", &[_]Token.Id{.FloatLiteral}); - testTokenize("1e100", &[_]Token.Id{.FloatLiteral}); - testTokenize("1.e100", &[_]Token.Id{.FloatLiteral}); - testTokenize("1.0e100", &[_]Token.Id{.FloatLiteral}); - testTokenize("1.0e+100", &[_]Token.Id{.FloatLiteral}); - testTokenize("1.0e-100", &[_]Token.Id{.FloatLiteral}); - testTokenize("1_0_0_0.0_0_0_0_0_1e1_0_0_0", &[_]Token.Id{.FloatLiteral}); - testTokenize("1.+", &[_]Token.Id{ .FloatLiteral, .Plus }); + testTokenize("1.", &.{.float_literal}); + testTokenize("0.0", &.{.float_literal}); + testTokenize("1.0", &.{.float_literal}); + testTokenize("10.0", &.{.float_literal}); + testTokenize("0e0", &.{.float_literal}); + testTokenize("1e0", &.{.float_literal}); + testTokenize("1e100", &.{.float_literal}); + testTokenize("1.e100", &.{.float_literal}); + testTokenize("1.0e100", &.{.float_literal}); + testTokenize("1.0e+100", &.{.float_literal}); + testTokenize("1.0e-100", &.{.float_literal}); + testTokenize("1_0_0_0.0_0_0_0_0_1e1_0_0_0", &.{.float_literal}); + testTokenize("1.+", &.{ .float_literal, .plus }); - testTokenize("1e", &[_]Token.Id{.Invalid}); - testTokenize("1.0e1f0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1.0p100", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1.0p-100", &[_]Token.Id{ .Invalid, .Identifier, .Minus, .IntegerLiteral }); - testTokenize("1.0p1f0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1.0_,", &[_]Token.Id{ .Invalid, .Comma }); - testTokenize("1_.0", &[_]Token.Id{ .Invalid, .Period, .IntegerLiteral }); - testTokenize("1._", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1.a", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1.z", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1._0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1._+", &[_]Token.Id{ .Invalid, .Identifier, .Plus }); - testTokenize("1._e", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1.0e", &[_]Token.Id{.Invalid}); - testTokenize("1.0e,", &[_]Token.Id{ .Invalid, .Comma }); - testTokenize("1.0e_", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1.0e+_", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1.0e-_", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("1.0e0_+", &[_]Token.Id{ .Invalid, .Plus }); + testTokenize("1e", &.{.invalid}); + testTokenize("1.0e1f0", &.{ .invalid, .identifier }); + testTokenize("1.0p100", &.{ .invalid, .identifier }); + testTokenize("1.0p-100", &.{ .invalid, .identifier, .minus, .integer_literal }); + testTokenize("1.0p1f0", &.{ .invalid, .identifier }); + testTokenize("1.0_,", &.{ .invalid, .comma }); + testTokenize("1_.0", &.{ .invalid, .period, .integer_literal }); + testTokenize("1._", &.{ .invalid, .identifier }); + testTokenize("1.a", &.{ .invalid, .identifier }); + testTokenize("1.z", &.{ .invalid, .identifier }); + testTokenize("1._0", &.{ .invalid, .identifier }); + testTokenize("1._+", &.{ .invalid, .identifier, .plus }); + testTokenize("1._e", &.{ .invalid, .identifier }); + testTokenize("1.0e", &.{.invalid}); + testTokenize("1.0e,", &.{ .invalid, .comma }); + testTokenize("1.0e_", &.{ .invalid, .identifier }); + testTokenize("1.0e+_", &.{ .invalid, .identifier }); + testTokenize("1.0e-_", &.{ .invalid, .identifier }); + testTokenize("1.0e0_+", &.{ .invalid, .plus }); } test "tokenizer - number literals binary" { - testTokenize("0b0", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0b1", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0b2", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0b3", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0b4", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0b5", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0b6", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0b7", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0b8", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0b9", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0ba", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0bb", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0bc", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0bd", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0be", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0bf", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0bz", &[_]Token.Id{ .Invalid, .Identifier }); + testTokenize("0b0", &.{.integer_literal}); + testTokenize("0b1", &.{.integer_literal}); + testTokenize("0b2", &.{ .invalid, .integer_literal }); + testTokenize("0b3", &.{ .invalid, .integer_literal }); + testTokenize("0b4", &.{ .invalid, .integer_literal }); + testTokenize("0b5", &.{ .invalid, .integer_literal }); + testTokenize("0b6", &.{ .invalid, .integer_literal }); + testTokenize("0b7", &.{ .invalid, .integer_literal }); + testTokenize("0b8", &.{ .invalid, .integer_literal }); + testTokenize("0b9", &.{ .invalid, .integer_literal }); + testTokenize("0ba", &.{ .invalid, .identifier }); + testTokenize("0bb", &.{ .invalid, .identifier }); + testTokenize("0bc", &.{ .invalid, .identifier }); + testTokenize("0bd", &.{ .invalid, .identifier }); + testTokenize("0be", &.{ .invalid, .identifier }); + testTokenize("0bf", &.{ .invalid, .identifier }); + testTokenize("0bz", &.{ .invalid, .identifier }); - testTokenize("0b0000_0000", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0b1111_1111", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0b10_10_10_10", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0b0_1_0_1_0_1_0_1", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0b1.", &[_]Token.Id{ .IntegerLiteral, .Period }); - testTokenize("0b1.0", &[_]Token.Id{ .IntegerLiteral, .Period, .IntegerLiteral }); + testTokenize("0b0000_0000", &.{.integer_literal}); + testTokenize("0b1111_1111", &.{.integer_literal}); + testTokenize("0b10_10_10_10", &.{.integer_literal}); + testTokenize("0b0_1_0_1_0_1_0_1", &.{.integer_literal}); + testTokenize("0b1.", &.{ .integer_literal, .period }); + testTokenize("0b1.0", &.{ .integer_literal, .period, .integer_literal }); - testTokenize("0B0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0b_", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0b_0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0b1_", &[_]Token.Id{.Invalid}); - testTokenize("0b0__1", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0b0_1_", &[_]Token.Id{.Invalid}); - testTokenize("0b1e", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0b1p", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0b1e0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0b1p0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0b1_,", &[_]Token.Id{ .Invalid, .Comma }); + testTokenize("0B0", &.{ .invalid, .identifier }); + testTokenize("0b_", &.{ .invalid, .identifier }); + testTokenize("0b_0", &.{ .invalid, .identifier }); + testTokenize("0b1_", &.{.invalid}); + testTokenize("0b0__1", &.{ .invalid, .identifier }); + testTokenize("0b0_1_", &.{.invalid}); + testTokenize("0b1e", &.{ .invalid, .identifier }); + testTokenize("0b1p", &.{ .invalid, .identifier }); + testTokenize("0b1e0", &.{ .invalid, .identifier }); + testTokenize("0b1p0", &.{ .invalid, .identifier }); + testTokenize("0b1_,", &.{ .invalid, .comma }); } test "tokenizer - number literals octal" { - testTokenize("0o0", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o1", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o2", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o3", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o4", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o5", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o6", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o7", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o8", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0o9", &[_]Token.Id{ .Invalid, .IntegerLiteral }); - testTokenize("0oa", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0ob", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0oc", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0od", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0oe", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0of", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0oz", &[_]Token.Id{ .Invalid, .Identifier }); + testTokenize("0o0", &.{.integer_literal}); + testTokenize("0o1", &.{.integer_literal}); + testTokenize("0o2", &.{.integer_literal}); + testTokenize("0o3", &.{.integer_literal}); + testTokenize("0o4", &.{.integer_literal}); + testTokenize("0o5", &.{.integer_literal}); + testTokenize("0o6", &.{.integer_literal}); + testTokenize("0o7", &.{.integer_literal}); + testTokenize("0o8", &.{ .invalid, .integer_literal }); + testTokenize("0o9", &.{ .invalid, .integer_literal }); + testTokenize("0oa", &.{ .invalid, .identifier }); + testTokenize("0ob", &.{ .invalid, .identifier }); + testTokenize("0oc", &.{ .invalid, .identifier }); + testTokenize("0od", &.{ .invalid, .identifier }); + testTokenize("0oe", &.{ .invalid, .identifier }); + testTokenize("0of", &.{ .invalid, .identifier }); + testTokenize("0oz", &.{ .invalid, .identifier }); - testTokenize("0o01234567", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o0123_4567", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o01_23_45_67", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o0_1_2_3_4_5_6_7", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0o7.", &[_]Token.Id{ .IntegerLiteral, .Period }); - testTokenize("0o7.0", &[_]Token.Id{ .IntegerLiteral, .Period, .IntegerLiteral }); + testTokenize("0o01234567", &.{.integer_literal}); + testTokenize("0o0123_4567", &.{.integer_literal}); + testTokenize("0o01_23_45_67", &.{.integer_literal}); + testTokenize("0o0_1_2_3_4_5_6_7", &.{.integer_literal}); + testTokenize("0o7.", &.{ .integer_literal, .period }); + testTokenize("0o7.0", &.{ .integer_literal, .period, .integer_literal }); - testTokenize("0O0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0o_", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0o_0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0o1_", &[_]Token.Id{.Invalid}); - testTokenize("0o0__1", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0o0_1_", &[_]Token.Id{.Invalid}); - testTokenize("0o1e", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0o1p", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0o1e0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0o1p0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0o_,", &[_]Token.Id{ .Invalid, .Identifier, .Comma }); + testTokenize("0O0", &.{ .invalid, .identifier }); + testTokenize("0o_", &.{ .invalid, .identifier }); + testTokenize("0o_0", &.{ .invalid, .identifier }); + testTokenize("0o1_", &.{.invalid}); + testTokenize("0o0__1", &.{ .invalid, .identifier }); + testTokenize("0o0_1_", &.{.invalid}); + testTokenize("0o1e", &.{ .invalid, .identifier }); + testTokenize("0o1p", &.{ .invalid, .identifier }); + testTokenize("0o1e0", &.{ .invalid, .identifier }); + testTokenize("0o1p0", &.{ .invalid, .identifier }); + testTokenize("0o_,", &.{ .invalid, .identifier, .comma }); } test "tokenizer - number literals hexadeciaml" { - testTokenize("0x0", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x1", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x2", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x3", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x4", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x5", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x6", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x7", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x8", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x9", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xa", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xb", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xc", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xd", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xe", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xf", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xA", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xB", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xC", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xD", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xE", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0xF", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x0z", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0xz", &[_]Token.Id{ .Invalid, .Identifier }); + testTokenize("0x0", &.{.integer_literal}); + testTokenize("0x1", &.{.integer_literal}); + testTokenize("0x2", &.{.integer_literal}); + testTokenize("0x3", &.{.integer_literal}); + testTokenize("0x4", &.{.integer_literal}); + testTokenize("0x5", &.{.integer_literal}); + testTokenize("0x6", &.{.integer_literal}); + testTokenize("0x7", &.{.integer_literal}); + testTokenize("0x8", &.{.integer_literal}); + testTokenize("0x9", &.{.integer_literal}); + testTokenize("0xa", &.{.integer_literal}); + testTokenize("0xb", &.{.integer_literal}); + testTokenize("0xc", &.{.integer_literal}); + testTokenize("0xd", &.{.integer_literal}); + testTokenize("0xe", &.{.integer_literal}); + testTokenize("0xf", &.{.integer_literal}); + testTokenize("0xA", &.{.integer_literal}); + testTokenize("0xB", &.{.integer_literal}); + testTokenize("0xC", &.{.integer_literal}); + testTokenize("0xD", &.{.integer_literal}); + testTokenize("0xE", &.{.integer_literal}); + testTokenize("0xF", &.{.integer_literal}); + testTokenize("0x0z", &.{ .invalid, .identifier }); + testTokenize("0xz", &.{ .invalid, .identifier }); - testTokenize("0x0123456789ABCDEF", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x0123_4567_89AB_CDEF", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x01_23_45_67_89AB_CDE_F", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F", &[_]Token.Id{.IntegerLiteral}); + testTokenize("0x0123456789ABCDEF", &.{.integer_literal}); + testTokenize("0x0123_4567_89AB_CDEF", &.{.integer_literal}); + testTokenize("0x01_23_45_67_89AB_CDE_F", &.{.integer_literal}); + testTokenize("0x0_1_2_3_4_5_6_7_8_9_A_B_C_D_E_F", &.{.integer_literal}); - testTokenize("0X0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x_", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x_1", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x1_", &[_]Token.Id{.Invalid}); - testTokenize("0x0__1", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0_1_", &[_]Token.Id{.Invalid}); - testTokenize("0x_,", &[_]Token.Id{ .Invalid, .Identifier, .Comma }); + testTokenize("0X0", &.{ .invalid, .identifier }); + testTokenize("0x_", &.{ .invalid, .identifier }); + testTokenize("0x_1", &.{ .invalid, .identifier }); + testTokenize("0x1_", &.{.invalid}); + testTokenize("0x0__1", &.{ .invalid, .identifier }); + testTokenize("0x0_1_", &.{.invalid}); + testTokenize("0x_,", &.{ .invalid, .identifier, .comma }); - testTokenize("0x1.", &[_]Token.Id{.FloatLiteral}); - testTokenize("0x1.0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xF.", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xF.0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xF.F", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xF.Fp0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xF.FP0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0x1p0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xfp0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0x1.+0xF.", &[_]Token.Id{ .FloatLiteral, .Plus, .FloatLiteral }); + testTokenize("0x1.", &.{.float_literal}); + testTokenize("0x1.0", &.{.float_literal}); + testTokenize("0xF.", &.{.float_literal}); + testTokenize("0xF.0", &.{.float_literal}); + testTokenize("0xF.F", &.{.float_literal}); + testTokenize("0xF.Fp0", &.{.float_literal}); + testTokenize("0xF.FP0", &.{.float_literal}); + testTokenize("0x1p0", &.{.float_literal}); + testTokenize("0xfp0", &.{.float_literal}); + testTokenize("0x1.+0xF.", &.{ .float_literal, .plus, .float_literal }); - testTokenize("0x0123456.789ABCDEF", &[_]Token.Id{.FloatLiteral}); - testTokenize("0x0_123_456.789_ABC_DEF", &[_]Token.Id{.FloatLiteral}); - testTokenize("0x0_1_2_3_4_5_6.7_8_9_A_B_C_D_E_F", &[_]Token.Id{.FloatLiteral}); - testTokenize("0x0p0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0x0.0p0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xff.ffp10", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xff.ffP10", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xff.p10", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xffp10", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xff_ff.ff_ffp1_0_0_0", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xf_f_f_f.f_f_f_fp+1_000", &[_]Token.Id{.FloatLiteral}); - testTokenize("0xf_f_f_f.f_f_f_fp-1_00_0", &[_]Token.Id{.FloatLiteral}); + testTokenize("0x0123456.789ABCDEF", &.{.float_literal}); + testTokenize("0x0_123_456.789_ABC_DEF", &.{.float_literal}); + testTokenize("0x0_1_2_3_4_5_6.7_8_9_A_B_C_D_E_F", &.{.float_literal}); + testTokenize("0x0p0", &.{.float_literal}); + testTokenize("0x0.0p0", &.{.float_literal}); + testTokenize("0xff.ffp10", &.{.float_literal}); + testTokenize("0xff.ffP10", &.{.float_literal}); + testTokenize("0xff.p10", &.{.float_literal}); + testTokenize("0xffp10", &.{.float_literal}); + testTokenize("0xff_ff.ff_ffp1_0_0_0", &.{.float_literal}); + testTokenize("0xf_f_f_f.f_f_f_fp+1_000", &.{.float_literal}); + testTokenize("0xf_f_f_f.f_f_f_fp-1_00_0", &.{.float_literal}); - testTokenize("0x1e", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x1e0", &[_]Token.Id{.IntegerLiteral}); - testTokenize("0x1p", &[_]Token.Id{.Invalid}); - testTokenize("0xfp0z1", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0xff.ffpff", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0.p", &[_]Token.Id{.Invalid}); - testTokenize("0x0.z", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0._", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0_.0", &[_]Token.Id{ .Invalid, .Period, .IntegerLiteral }); - testTokenize("0x0_.0.0", &[_]Token.Id{ .Invalid, .Period, .FloatLiteral }); - testTokenize("0x0._0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0.0_", &[_]Token.Id{.Invalid}); - testTokenize("0x0_p0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0_.p0", &[_]Token.Id{ .Invalid, .Period, .Identifier }); - testTokenize("0x0._p0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0.0_p0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0._0p0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0.0p_0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0.0p+_0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0.0p-_0", &[_]Token.Id{ .Invalid, .Identifier }); - testTokenize("0x0.0p0_", &[_]Token.Id{ .Invalid, .Eof }); + testTokenize("0x1e", &.{.integer_literal}); + testTokenize("0x1e0", &.{.integer_literal}); + testTokenize("0x1p", &.{.invalid}); + testTokenize("0xfp0z1", &.{ .invalid, .identifier }); + testTokenize("0xff.ffpff", &.{ .invalid, .identifier }); + testTokenize("0x0.p", &.{.invalid}); + testTokenize("0x0.z", &.{ .invalid, .identifier }); + testTokenize("0x0._", &.{ .invalid, .identifier }); + testTokenize("0x0_.0", &.{ .invalid, .period, .integer_literal }); + testTokenize("0x0_.0.0", &.{ .invalid, .period, .float_literal }); + testTokenize("0x0._0", &.{ .invalid, .identifier }); + testTokenize("0x0.0_", &.{.invalid}); + testTokenize("0x0_p0", &.{ .invalid, .identifier }); + testTokenize("0x0_.p0", &.{ .invalid, .period, .identifier }); + testTokenize("0x0._p0", &.{ .invalid, .identifier }); + testTokenize("0x0.0_p0", &.{ .invalid, .identifier }); + testTokenize("0x0._0p0", &.{ .invalid, .identifier }); + testTokenize("0x0.0p_0", &.{ .invalid, .identifier }); + testTokenize("0x0.0p+_0", &.{ .invalid, .identifier }); + testTokenize("0x0.0p-_0", &.{ .invalid, .identifier }); + testTokenize("0x0.0p0_", &.{ .invalid, .eof }); } -fn testTokenize(source: []const u8, expected_tokens: []const Token.Id) void { +fn testTokenize(source: []const u8, expected_tokens: []const Token.Tag) void { var tokenizer = Tokenizer.init(source); for (expected_tokens) |expected_token_id| { const token = tokenizer.next(); - if (token.id != expected_token_id) { - std.debug.panic("expected {}, found {}\n", .{ @tagName(expected_token_id), @tagName(token.id) }); + if (token.tag != expected_token_id) { + std.debug.panic("expected {s}, found {s}\n", .{ @tagName(expected_token_id), @tagName(token.tag) }); } } const last_token = tokenizer.next(); - std.testing.expect(last_token.id == .Eof); + std.testing.expect(last_token.tag == .eof); + std.testing.expect(last_token.loc.start == source.len); } diff --git a/lib/tsan/interception/interception.h b/lib/tsan/interception/interception.h new file mode 100644 index 0000000000..d27a8ccf92 --- /dev/null +++ b/lib/tsan/interception/interception.h @@ -0,0 +1,304 @@ +//===-- interception.h ------------------------------------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// Machinery for providing replacements/wrappers for system functions. +//===----------------------------------------------------------------------===// + +#ifndef INTERCEPTION_H +#define INTERCEPTION_H + +#include "sanitizer_common/sanitizer_internal_defs.h" + +#if !SANITIZER_LINUX && !SANITIZER_FREEBSD && !SANITIZER_MAC && \ + !SANITIZER_NETBSD && !SANITIZER_OPENBSD && !SANITIZER_WINDOWS && \ + !SANITIZER_FUCHSIA && !SANITIZER_RTEMS && !SANITIZER_SOLARIS +# error "Interception doesn't work on this operating system." +#endif + +// These typedefs should be used only in the interceptor definitions to replace +// the standard system types (e.g. SSIZE_T instead of ssize_t) +typedef __sanitizer::uptr SIZE_T; +typedef __sanitizer::sptr SSIZE_T; +typedef __sanitizer::sptr PTRDIFF_T; +typedef __sanitizer::s64 INTMAX_T; +typedef __sanitizer::u64 UINTMAX_T; +typedef __sanitizer::OFF_T OFF_T; +typedef __sanitizer::OFF64_T OFF64_T; + +// How to add an interceptor: +// Suppose you need to wrap/replace system function (generally, from libc): +// int foo(const char *bar, double baz); +// You'll need to: +// 1) define INTERCEPTOR(int, foo, const char *bar, double baz) { ... } in +// your source file. See the notes below for cases when +// INTERCEPTOR_WITH_SUFFIX(...) should be used instead. +// 2) Call "INTERCEPT_FUNCTION(foo)" prior to the first call of "foo". +// INTERCEPT_FUNCTION(foo) evaluates to "true" iff the function was +// intercepted successfully. +// You can access original function by calling REAL(foo)(bar, baz). +// By default, REAL(foo) will be visible only inside your interceptor, and if +// you want to use it in other parts of RTL, you'll need to: +// 3a) add DECLARE_REAL(int, foo, const char*, double) to a +// header file. +// However, if the call "INTERCEPT_FUNCTION(foo)" and definition for +// INTERCEPTOR(..., foo, ...) are in different files, you'll instead need to: +// 3b) add DECLARE_REAL_AND_INTERCEPTOR(int, foo, const char*, double) +// to a header file. + +// Notes: 1. Things may not work properly if macro INTERCEPTOR(...) {...} or +// DECLARE_REAL(...) are located inside namespaces. +// 2. On Mac you can also use: "OVERRIDE_FUNCTION(foo, zoo)" to +// effectively redirect calls from "foo" to "zoo". In this case +// you aren't required to implement +// INTERCEPTOR(int, foo, const char *bar, double baz) {...} +// but instead you'll have to add +// DECLARE_REAL(int, foo, const char *bar, double baz) in your +// source file (to define a pointer to overriden function). +// 3. Some Mac functions have symbol variants discriminated by +// additional suffixes, e.g. _$UNIX2003 (see +// https://developer.apple.com/library/mac/#releasenotes/Darwin/SymbolVariantsRelNotes/index.html +// for more details). To intercept such functions you need to use the +// INTERCEPTOR_WITH_SUFFIX(...) macro. + +// How it works: +// To replace system functions on Linux we just need to declare functions +// with same names in our library and then obtain the real function pointers +// using dlsym(). +// There is one complication. A user may also intercept some of the functions +// we intercept. To resolve this we declare our interceptors with __interceptor_ +// prefix, and then make actual interceptors weak aliases to __interceptor_ +// functions. +// +// This is not so on Mac OS, where the two-level namespace makes +// our replacement functions invisible to other libraries. This may be overcomed +// using the DYLD_FORCE_FLAT_NAMESPACE, but some errors loading the shared +// libraries in Chromium were noticed when doing so. +// Instead we create a dylib containing a __DATA,__interpose section that +// associates library functions with their wrappers. When this dylib is +// preloaded before an executable using DYLD_INSERT_LIBRARIES, it routes all +// the calls to interposed functions done through stubs to the wrapper +// functions. +// As it's decided at compile time which functions are to be intercepted on Mac, +// INTERCEPT_FUNCTION() is effectively a no-op on this system. + +#if SANITIZER_MAC +#include // For __DARWIN_ALIAS_C(). + +// Just a pair of pointers. +struct interpose_substitution { + const __sanitizer::uptr replacement; + const __sanitizer::uptr original; +}; + +// For a function foo() create a global pair of pointers { wrap_foo, foo } in +// the __DATA,__interpose section. +// As a result all the calls to foo() will be routed to wrap_foo() at runtime. +#define INTERPOSER(func_name) __attribute__((used)) \ +const interpose_substitution substitution_##func_name[] \ + __attribute__((section("__DATA, __interpose"))) = { \ + { reinterpret_cast(WRAP(func_name)), \ + reinterpret_cast(func_name) } \ +} + +// For a function foo() and a wrapper function bar() create a global pair +// of pointers { bar, foo } in the __DATA,__interpose section. +// As a result all the calls to foo() will be routed to bar() at runtime. +#define INTERPOSER_2(func_name, wrapper_name) __attribute__((used)) \ +const interpose_substitution substitution_##func_name[] \ + __attribute__((section("__DATA, __interpose"))) = { \ + { reinterpret_cast(wrapper_name), \ + reinterpret_cast(func_name) } \ +} + +# define WRAP(x) wrap_##x +# define WRAPPER_NAME(x) "wrap_"#x +# define INTERCEPTOR_ATTRIBUTE +# define DECLARE_WRAPPER(ret_type, func, ...) + +#elif SANITIZER_WINDOWS +# define WRAP(x) __asan_wrap_##x +# define WRAPPER_NAME(x) "__asan_wrap_"#x +# define INTERCEPTOR_ATTRIBUTE __declspec(dllexport) +# define DECLARE_WRAPPER(ret_type, func, ...) \ + extern "C" ret_type func(__VA_ARGS__); +# define DECLARE_WRAPPER_WINAPI(ret_type, func, ...) \ + extern "C" __declspec(dllimport) ret_type __stdcall func(__VA_ARGS__); +#elif SANITIZER_RTEMS +# define WRAP(x) x +# define WRAPPER_NAME(x) #x +# define INTERCEPTOR_ATTRIBUTE +# define DECLARE_WRAPPER(ret_type, func, ...) +#elif SANITIZER_FREEBSD || SANITIZER_NETBSD +# define WRAP(x) __interceptor_ ## x +# define WRAPPER_NAME(x) "__interceptor_" #x +# define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default"))) +// FreeBSD's dynamic linker (incompliantly) gives non-weak symbols higher +// priority than weak ones so weak aliases won't work for indirect calls +// in position-independent (-fPIC / -fPIE) mode. +# define DECLARE_WRAPPER(ret_type, func, ...) \ + extern "C" ret_type func(__VA_ARGS__) \ + __attribute__((alias("__interceptor_" #func), visibility("default"))); +#elif !SANITIZER_FUCHSIA +# define WRAP(x) __interceptor_ ## x +# define WRAPPER_NAME(x) "__interceptor_" #x +# define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default"))) +# define DECLARE_WRAPPER(ret_type, func, ...) \ + extern "C" ret_type func(__VA_ARGS__) \ + __attribute__((weak, alias("__interceptor_" #func), visibility("default"))); +#endif + +#if SANITIZER_FUCHSIA +// There is no general interception at all on Fuchsia. +// Sanitizer runtimes just define functions directly to preempt them, +// and have bespoke ways to access the underlying libc functions. +# include +# define INTERCEPTOR_ATTRIBUTE __attribute__((visibility("default"))) +# define REAL(x) __unsanitized_##x +# define DECLARE_REAL(ret_type, func, ...) +#elif SANITIZER_RTEMS +# define REAL(x) __real_ ## x +# define DECLARE_REAL(ret_type, func, ...) \ + extern "C" ret_type REAL(func)(__VA_ARGS__); +#elif !SANITIZER_MAC +# define PTR_TO_REAL(x) real_##x +# define REAL(x) __interception::PTR_TO_REAL(x) +# define FUNC_TYPE(x) x##_type + +# define DECLARE_REAL(ret_type, func, ...) \ + typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__); \ + namespace __interception { \ + extern FUNC_TYPE(func) PTR_TO_REAL(func); \ + } +# define ASSIGN_REAL(dst, src) REAL(dst) = REAL(src) +#else // SANITIZER_MAC +# define REAL(x) x +# define DECLARE_REAL(ret_type, func, ...) \ + extern "C" ret_type func(__VA_ARGS__); +# define ASSIGN_REAL(x, y) +#endif // SANITIZER_MAC + +#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS +# define DECLARE_REAL_AND_INTERCEPTOR(ret_type, func, ...) \ + DECLARE_REAL(ret_type, func, __VA_ARGS__) \ + extern "C" ret_type WRAP(func)(__VA_ARGS__); +// Declare an interceptor and its wrapper defined in a different translation +// unit (ex. asm). +# define DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(ret_type, func, ...) \ + extern "C" ret_type WRAP(func)(__VA_ARGS__); \ + extern "C" ret_type func(__VA_ARGS__); +#else +# define DECLARE_REAL_AND_INTERCEPTOR(ret_type, func, ...) +# define DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(ret_type, func, ...) +#endif + +// Generally, you don't need to use DEFINE_REAL by itself, as INTERCEPTOR +// macros does its job. In exceptional cases you may need to call REAL(foo) +// without defining INTERCEPTOR(..., foo, ...). For example, if you override +// foo with an interceptor for other function. +#if !SANITIZER_MAC && !SANITIZER_FUCHSIA && !SANITIZER_RTEMS +# define DEFINE_REAL(ret_type, func, ...) \ + typedef ret_type (*FUNC_TYPE(func))(__VA_ARGS__); \ + namespace __interception { \ + FUNC_TYPE(func) PTR_TO_REAL(func); \ + } +#else +# define DEFINE_REAL(ret_type, func, ...) +#endif + +#if SANITIZER_FUCHSIA + +// We need to define the __interceptor_func name just to get +// sanitizer_common/scripts/gen_dynamic_list.py to export func. +// But we don't need to export __interceptor_func to get that. +#define INTERCEPTOR(ret_type, func, ...) \ + extern "C"[[ gnu::alias(#func), gnu::visibility("hidden") ]] ret_type \ + __interceptor_##func(__VA_ARGS__); \ + extern "C" INTERCEPTOR_ATTRIBUTE ret_type func(__VA_ARGS__) + +#elif !SANITIZER_MAC + +#define INTERCEPTOR(ret_type, func, ...) \ + DEFINE_REAL(ret_type, func, __VA_ARGS__) \ + DECLARE_WRAPPER(ret_type, func, __VA_ARGS__) \ + extern "C" \ + INTERCEPTOR_ATTRIBUTE \ + ret_type WRAP(func)(__VA_ARGS__) + +// We don't need INTERCEPTOR_WITH_SUFFIX on non-Darwin for now. +#define INTERCEPTOR_WITH_SUFFIX(ret_type, func, ...) \ + INTERCEPTOR(ret_type, func, __VA_ARGS__) + +#else // SANITIZER_MAC + +#define INTERCEPTOR_ZZZ(suffix, ret_type, func, ...) \ + extern "C" ret_type func(__VA_ARGS__) suffix; \ + extern "C" ret_type WRAP(func)(__VA_ARGS__); \ + INTERPOSER(func); \ + extern "C" INTERCEPTOR_ATTRIBUTE ret_type WRAP(func)(__VA_ARGS__) + +#define INTERCEPTOR(ret_type, func, ...) \ + INTERCEPTOR_ZZZ(/*no symbol variants*/, ret_type, func, __VA_ARGS__) + +#define INTERCEPTOR_WITH_SUFFIX(ret_type, func, ...) \ + INTERCEPTOR_ZZZ(__DARWIN_ALIAS_C(func), ret_type, func, __VA_ARGS__) + +// Override |overridee| with |overrider|. +#define OVERRIDE_FUNCTION(overridee, overrider) \ + INTERPOSER_2(overridee, WRAP(overrider)) +#endif + +#if SANITIZER_WINDOWS +# define INTERCEPTOR_WINAPI(ret_type, func, ...) \ + typedef ret_type (__stdcall *FUNC_TYPE(func))(__VA_ARGS__); \ + namespace __interception { \ + FUNC_TYPE(func) PTR_TO_REAL(func); \ + } \ + extern "C" \ + INTERCEPTOR_ATTRIBUTE \ + ret_type __stdcall WRAP(func)(__VA_ARGS__) +#endif + +// ISO C++ forbids casting between pointer-to-function and pointer-to-object, +// so we use casting via an integral type __interception::uptr, +// assuming that system is POSIX-compliant. Using other hacks seem +// challenging, as we don't even pass function type to +// INTERCEPT_FUNCTION macro, only its name. +namespace __interception { +#if defined(_WIN64) +typedef unsigned long long uptr; +#else +typedef unsigned long uptr; +#endif // _WIN64 +} // namespace __interception + +#define INCLUDED_FROM_INTERCEPTION_LIB + +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \ + SANITIZER_OPENBSD || SANITIZER_SOLARIS + +# include "interception_linux.h" +# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) +# define INTERCEPT_FUNCTION_VER(func, symver) \ + INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) +#elif SANITIZER_MAC +# include "interception_mac.h" +# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_MAC(func) +# define INTERCEPT_FUNCTION_VER(func, symver) \ + INTERCEPT_FUNCTION_VER_MAC(func, symver) +#elif SANITIZER_WINDOWS +# include "interception_win.h" +# define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_WIN(func) +# define INTERCEPT_FUNCTION_VER(func, symver) \ + INTERCEPT_FUNCTION_VER_WIN(func, symver) +#endif + +#undef INCLUDED_FROM_INTERCEPTION_LIB + +#endif // INTERCEPTION_H diff --git a/lib/tsan/interception/interception_linux.cpp b/lib/tsan/interception/interception_linux.cpp new file mode 100644 index 0000000000..950cd51265 --- /dev/null +++ b/lib/tsan/interception/interception_linux.cpp @@ -0,0 +1,83 @@ +//===-- interception_linux.cpp ----------------------------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// Linux-specific interception methods. +//===----------------------------------------------------------------------===// + +#include "interception.h" + +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \ + SANITIZER_OPENBSD || SANITIZER_SOLARIS + +#include // for dlsym() and dlvsym() + +namespace __interception { + +#if SANITIZER_NETBSD +static int StrCmp(const char *s1, const char *s2) { + while (true) { + if (*s1 != *s2) + return false; + if (*s1 == 0) + return true; + s1++; + s2++; + } +} +#endif + +static void *GetFuncAddr(const char *name, uptr wrapper_addr) { +#if SANITIZER_NETBSD + // FIXME: Find a better way to handle renames + if (StrCmp(name, "sigaction")) + name = "__sigaction14"; +#endif + void *addr = dlsym(RTLD_NEXT, name); + if (!addr) { + // If the lookup using RTLD_NEXT failed, the sanitizer runtime library is + // later in the library search order than the DSO that we are trying to + // intercept, which means that we cannot intercept this function. We still + // want the address of the real definition, though, so look it up using + // RTLD_DEFAULT. + addr = dlsym(RTLD_DEFAULT, name); + + // In case `name' is not loaded, dlsym ends up finding the actual wrapper. + // We don't want to intercept the wrapper and have it point to itself. + if ((uptr)addr == wrapper_addr) + addr = nullptr; + } + return addr; +} + +bool InterceptFunction(const char *name, uptr *ptr_to_real, uptr func, + uptr wrapper) { + void *addr = GetFuncAddr(name, wrapper); + *ptr_to_real = (uptr)addr; + return addr && (func == wrapper); +} + +// Android and Solaris do not have dlvsym +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD +static void *GetFuncAddr(const char *name, const char *ver) { + return dlvsym(RTLD_NEXT, name, ver); +} + +bool InterceptFunction(const char *name, const char *ver, uptr *ptr_to_real, + uptr func, uptr wrapper) { + void *addr = GetFuncAddr(name, ver); + *ptr_to_real = (uptr)addr; + return addr && (func == wrapper); +} +#endif // !SANITIZER_ANDROID + +} // namespace __interception + +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || + // SANITIZER_OPENBSD || SANITIZER_SOLARIS diff --git a/lib/tsan/interception/interception_linux.h b/lib/tsan/interception/interception_linux.h new file mode 100644 index 0000000000..e578da0cf6 --- /dev/null +++ b/lib/tsan/interception/interception_linux.h @@ -0,0 +1,53 @@ +//===-- interception_linux.h ------------------------------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// Linux-specific interception methods. +//===----------------------------------------------------------------------===// + +#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || \ + SANITIZER_OPENBSD || SANITIZER_SOLARIS + +#if !defined(INCLUDED_FROM_INTERCEPTION_LIB) +# error "interception_linux.h should be included from interception library only" +#endif + +#ifndef INTERCEPTION_LINUX_H +#define INTERCEPTION_LINUX_H + +namespace __interception { +bool InterceptFunction(const char *name, uptr *ptr_to_real, uptr func, + uptr wrapper); +bool InterceptFunction(const char *name, const char *ver, uptr *ptr_to_real, + uptr func, uptr wrapper); +} // namespace __interception + +#define INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) \ + ::__interception::InterceptFunction( \ + #func, \ + (::__interception::uptr *) & REAL(func), \ + (::__interception::uptr) & (func), \ + (::__interception::uptr) & WRAP(func)) + +// Android, Solaris and OpenBSD do not have dlvsym +#if !SANITIZER_ANDROID && !SANITIZER_SOLARIS && !SANITIZER_OPENBSD +#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ + ::__interception::InterceptFunction( \ + #func, symver, \ + (::__interception::uptr *) & REAL(func), \ + (::__interception::uptr) & (func), \ + (::__interception::uptr) & WRAP(func)) +#else +#define INTERCEPT_FUNCTION_VER_LINUX_OR_FREEBSD(func, symver) \ + INTERCEPT_FUNCTION_LINUX_OR_FREEBSD(func) +#endif // !SANITIZER_ANDROID && !SANITIZER_SOLARIS + +#endif // INTERCEPTION_LINUX_H +#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD || + // SANITIZER_OPENBSD || SANITIZER_SOLARIS diff --git a/lib/tsan/interception/interception_mac.cpp b/lib/tsan/interception/interception_mac.cpp new file mode 100644 index 0000000000..fb6eadcff5 --- /dev/null +++ b/lib/tsan/interception/interception_mac.cpp @@ -0,0 +1,18 @@ +//===-- interception_mac.cpp ------------------------------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// Mac-specific interception methods. +//===----------------------------------------------------------------------===// + +#include "interception.h" + +#if SANITIZER_MAC + +#endif // SANITIZER_MAC diff --git a/lib/tsan/interception/interception_mac.h b/lib/tsan/interception/interception_mac.h new file mode 100644 index 0000000000..eddedb8959 --- /dev/null +++ b/lib/tsan/interception/interception_mac.h @@ -0,0 +1,27 @@ +//===-- interception_mac.h --------------------------------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// Mac-specific interception methods. +//===----------------------------------------------------------------------===// + +#if SANITIZER_MAC + +#if !defined(INCLUDED_FROM_INTERCEPTION_LIB) +# error "interception_mac.h should be included from interception.h only" +#endif + +#ifndef INTERCEPTION_MAC_H +#define INTERCEPTION_MAC_H + +#define INTERCEPT_FUNCTION_MAC(func) +#define INTERCEPT_FUNCTION_VER_MAC(func, symver) + +#endif // INTERCEPTION_MAC_H +#endif // SANITIZER_MAC diff --git a/lib/tsan/interception/interception_type_test.cpp b/lib/tsan/interception/interception_type_test.cpp new file mode 100644 index 0000000000..a611604a70 --- /dev/null +++ b/lib/tsan/interception/interception_type_test.cpp @@ -0,0 +1,39 @@ +//===-- interception_type_test.cpp ------------------------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// Compile-time tests of the internal type definitions. +//===----------------------------------------------------------------------===// + +#include "interception.h" + +#if SANITIZER_LINUX || SANITIZER_MAC + +#include +#include +#include + +COMPILER_CHECK(sizeof(::SIZE_T) == sizeof(size_t)); +COMPILER_CHECK(sizeof(::SSIZE_T) == sizeof(ssize_t)); +COMPILER_CHECK(sizeof(::PTRDIFF_T) == sizeof(ptrdiff_t)); +COMPILER_CHECK(sizeof(::INTMAX_T) == sizeof(intmax_t)); + +#if !SANITIZER_MAC +COMPILER_CHECK(sizeof(::OFF64_T) == sizeof(off64_t)); +#endif + +// The following are the cases when pread (and friends) is used instead of +// pread64. In those cases we need OFF_T to match off_t. We don't care about the +// rest (they depend on _FILE_OFFSET_BITS setting when building an application). +# if SANITIZER_ANDROID || !defined _FILE_OFFSET_BITS || \ + _FILE_OFFSET_BITS != 64 +COMPILER_CHECK(sizeof(::OFF_T) == sizeof(off_t)); +# endif + +#endif diff --git a/lib/tsan/interception/interception_win.cpp b/lib/tsan/interception/interception_win.cpp new file mode 100644 index 0000000000..1a1c327e61 --- /dev/null +++ b/lib/tsan/interception/interception_win.cpp @@ -0,0 +1,1022 @@ +//===-- interception_linux.cpp ----------------------------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// Windows-specific interception methods. +// +// This file is implementing several hooking techniques to intercept calls +// to functions. The hooks are dynamically installed by modifying the assembly +// code. +// +// The hooking techniques are making assumptions on the way the code is +// generated and are safe under these assumptions. +// +// On 64-bit architecture, there is no direct 64-bit jump instruction. To allow +// arbitrary branching on the whole memory space, the notion of trampoline +// region is used. A trampoline region is a memory space withing 2G boundary +// where it is safe to add custom assembly code to build 64-bit jumps. +// +// Hooking techniques +// ================== +// +// 1) Detour +// +// The Detour hooking technique is assuming the presence of an header with +// padding and an overridable 2-bytes nop instruction (mov edi, edi). The +// nop instruction can safely be replaced by a 2-bytes jump without any need +// to save the instruction. A jump to the target is encoded in the function +// header and the nop instruction is replaced by a short jump to the header. +// +// head: 5 x nop head: jmp +// func: mov edi, edi --> func: jmp short +// [...] real: [...] +// +// This technique is only implemented on 32-bit architecture. +// Most of the time, Windows API are hookable with the detour technique. +// +// 2) Redirect Jump +// +// The redirect jump is applicable when the first instruction is a direct +// jump. The instruction is replaced by jump to the hook. +// +// func: jmp