Compare commits
181 Commits
zig0-0.15.
...
0.10.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b57081f039 | ||
|
|
edd9d73b0d | ||
|
|
0a03d68594 | ||
|
|
c8a7dc22b1 | ||
|
|
537618464a | ||
|
|
b9ea086812 | ||
|
|
b2cf10c5d5 | ||
|
|
01a44e9aa4 | ||
|
|
7d4bc54277 | ||
|
|
8583e88db5 | ||
|
|
da96e7efcc | ||
|
|
6bb82dad43 | ||
|
|
86f4dfe5a8 | ||
|
|
dc18b8174a | ||
|
|
7d538d6e53 | ||
|
|
be6a81d3a7 | ||
|
|
5572a83123 | ||
|
|
b19a29c70f | ||
|
|
55be10486e | ||
|
|
5766c8ebc8 | ||
|
|
4068fafcc6 | ||
|
|
fe6fd0d541 | ||
|
|
433709a788 | ||
|
|
0420ad0292 | ||
|
|
23c09598c7 | ||
|
|
2acdea7dfd | ||
|
|
c841f52fcb | ||
|
|
bcc2fb66f3 | ||
|
|
d6faa4e868 | ||
|
|
f8ea292d09 | ||
|
|
b5222f86ee | ||
|
|
7d0d99aac0 | ||
|
|
cdcb746cc2 | ||
|
|
3e2ddbfdd7 | ||
|
|
6f39ce93ce | ||
|
|
07f6fc3000 | ||
|
|
a4418a8fd6 | ||
|
|
bb957a976d | ||
|
|
f8f65aebe6 | ||
|
|
3bc70ea2dd | ||
|
|
9067daeb94 | ||
|
|
290874a24e | ||
|
|
033dcf7811 | ||
|
|
39c3889df1 | ||
|
|
594158a692 | ||
|
|
af958e95cc | ||
|
|
fd57487e35 | ||
|
|
5fc7424a8d | ||
|
|
ffb27a8bd0 | ||
|
|
be5b1ab7ed | ||
|
|
6e30359894 | ||
|
|
77c583b4c9 | ||
|
|
fb7ca1ad48 | ||
|
|
aa7e65d5ba | ||
|
|
c2ad78922a | ||
|
|
9d214f6f9d | ||
|
|
3b892f4316 | ||
|
|
fa30458e84 | ||
|
|
0313426ce8 | ||
|
|
970b7efec7 | ||
|
|
282c54a9c9 | ||
|
|
1f61a00a41 | ||
|
|
3357425b87 | ||
|
|
5404d06ea9 | ||
|
|
f986cb1f90 | ||
|
|
2f11de4f51 | ||
|
|
e5d76176b9 | ||
|
|
76c729c967 | ||
|
|
82b8689122 | ||
|
|
d824471489 | ||
|
|
fff7f15fb8 | ||
|
|
b75197ef88 | ||
|
|
ddfcf0246e | ||
|
|
c4cac21b72 | ||
|
|
1d34eafe6c | ||
|
|
71355ef0e2 | ||
|
|
a6e7c43136 | ||
|
|
a10417ae00 | ||
|
|
708a936b88 | ||
|
|
dac5189f31 | ||
|
|
b97fb48a6f | ||
|
|
7a70b22cfb | ||
|
|
e6d0edc888 | ||
|
|
26614d9dcc | ||
|
|
8c94b98e9f | ||
|
|
05afb3f358 | ||
|
|
703552e253 | ||
|
|
3adbe0afa3 | ||
|
|
99f2ce5e91 | ||
|
|
89a491a1d5 | ||
|
|
779674aaca | ||
|
|
60242d6210 | ||
|
|
7d812dc1c7 | ||
|
|
6b1f99dd33 | ||
|
|
090eb347a4 | ||
|
|
58d4d083ea | ||
|
|
30e09270fb | ||
|
|
e1da555148 | ||
|
|
9dd1899e43 | ||
|
|
5f23b65901 | ||
|
|
8bbb4a2f81 | ||
|
|
8f2bb38a09 | ||
|
|
d27007cd7e | ||
|
|
2bbaf95ebe | ||
|
|
a3232c6764 | ||
|
|
10a660ebea | ||
|
|
9498c95faf | ||
|
|
06dfa88d3f | ||
|
|
da418ee0af | ||
|
|
58ac0082d2 | ||
|
|
4428e3837c | ||
|
|
1702404adf | ||
|
|
dd175e2928 | ||
|
|
90fedf24fc | ||
|
|
a5bcdfd27e | ||
|
|
c5900224fd | ||
|
|
9f215318b8 | ||
|
|
91b8d9e370 | ||
|
|
6064477928 | ||
|
|
4ed0cd51c0 | ||
|
|
9e50cb294b | ||
|
|
6494cec59c | ||
|
|
35c13c262c | ||
|
|
2d623d7774 | ||
|
|
d6ee8cb063 | ||
|
|
b10386bcf0 | ||
|
|
3591c51fbe | ||
|
|
2623b5cf3a | ||
|
|
390fb9a3ca | ||
|
|
db58a45ab6 | ||
|
|
dc96e47eb3 | ||
|
|
b239a178c5 | ||
| 50fb7a4144 | |||
|
|
013d615077 | ||
|
|
33fe7f2881 | ||
|
|
568a619251 | ||
|
|
b494f6a9dc | ||
|
|
7748d2bb44 | ||
|
|
56195aa73c | ||
|
|
bc33243650 | ||
|
|
48798da29b | ||
|
|
b931889c65 | ||
|
|
52f8de0194 | ||
|
|
84f5843178 | ||
|
|
95ecd521b8 | ||
|
|
11c1ddfc97 | ||
|
|
c1fc15f913 | ||
|
|
a0dd11c479 | ||
|
|
eb21b20949 | ||
|
|
4efb197f90 | ||
|
|
1be11e230a | ||
|
|
6ea3d3e19f | ||
|
|
6a94bcbbc6 | ||
|
|
30d392a87e | ||
|
|
8d488246da | ||
|
|
5f74bec076 | ||
|
|
2593d4d7d6 | ||
|
|
3608b1d036 | ||
|
|
faca0e4220 | ||
|
|
b511231f95 | ||
|
|
8d95b713c5 | ||
|
|
6165de9a61 | ||
|
|
0848d33d78 | ||
|
|
d8970de510 | ||
|
|
72199c26b9 | ||
|
|
ab4b538d91 | ||
|
|
a7b8d011a3 | ||
|
|
ee8af8cffb | ||
|
|
3ee5cf627f | ||
|
|
a0ac10d903 | ||
|
|
5f11e341d8 | ||
|
|
f354ad638a | ||
|
|
99b1eaaac4 | ||
|
|
54bdc0108a | ||
|
|
57caec8585 | ||
|
|
5aa146c2d2 | ||
|
|
5e4000ee69 | ||
|
|
26e7d4c9a3 | ||
|
|
f366f381f5 | ||
|
|
455d583d30 | ||
|
|
08b42705ab |
@@ -1,8 +0,0 @@
|
||||
image: freebsd/latest
|
||||
secrets:
|
||||
- 51bfddf5-86a6-4e01-8576-358c72a4a0a4
|
||||
- be22288f-b1bc-4243-abe3-43d8f0e7079b
|
||||
sources:
|
||||
- https://github.com/ziglang/zig
|
||||
tasks:
|
||||
- build: cd zig && ./ci/srht/freebsd_script
|
||||
47
.github/workflows/ci.yaml
vendored
Normal file
47
.github/workflows/ci.yaml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: ci
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 0.10.x
|
||||
concurrency:
|
||||
# Cancels pending runs when a PR gets updated.
|
||||
group: ${{ github.head_ref || github.run_id }}-${{ github.actor }}
|
||||
cancel-in-progress: true
|
||||
jobs:
|
||||
x86_64-linux-debug:
|
||||
runs-on: [self-hosted, Linux, x86_64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: sh ci/x86_64-linux-debug.sh
|
||||
x86_64-linux-release:
|
||||
runs-on: [self-hosted, Linux, x86_64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: sh ci/x86_64-linux-release.sh
|
||||
aarch64-linux-debug:
|
||||
runs-on: [self-hosted, Linux, aarch64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: sh ci/aarch64-linux-debug.sh
|
||||
aarch64-linux-release:
|
||||
runs-on: [self-hosted, Linux, aarch64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: sh ci/aarch64-linux-release.sh
|
||||
x86_64-macos:
|
||||
runs-on: "macos-11"
|
||||
env:
|
||||
ARCH: "x86_64"
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
run: ci/x86_64-macos.sh
|
||||
@@ -42,7 +42,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||
|
||||
set(ZIG_VERSION_MAJOR 0)
|
||||
set(ZIG_VERSION_MINOR 10)
|
||||
set(ZIG_VERSION_PATCH 0)
|
||||
set(ZIG_VERSION_PATCH 1)
|
||||
set(ZIG_VERSION "" CACHE STRING "Override Zig version string. Default is to find out with git.")
|
||||
|
||||
if("${ZIG_VERSION}" STREQUAL "")
|
||||
@@ -118,7 +118,7 @@ string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_INCLUDE_DIR_ESCAPED "${ZIG_LIBC_
|
||||
option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF)
|
||||
|
||||
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_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
|
||||
set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary")
|
||||
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")
|
||||
@@ -1033,13 +1033,11 @@ set(BUILD_ZIG2_ARGS
|
||||
"-femit-bin=${ZIG2_OBJECT}"
|
||||
-fcompiler-rt
|
||||
${ZIG_SINGLE_THREADED_ARG}
|
||||
-target "${ZIG_TARGET_TRIPLE}"
|
||||
-mcpu "${ZIG_TARGET_MCPU}"
|
||||
-target native
|
||||
-mcpu native
|
||||
-lc
|
||||
--pkg-begin build_options "${ZIG_CONFIG_ZIG_OUT}"
|
||||
--pkg-end
|
||||
--pkg-begin compiler_rt "${CMAKE_SOURCE_DIR}/lib/compiler_rt.zig"
|
||||
--pkg-end
|
||||
)
|
||||
|
||||
if("${ZIG_EXECUTABLE}" STREQUAL "")
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
The MIT License (Expat)
|
||||
|
||||
Copyright (c) 2015-2022, Zig contributors
|
||||
Copyright (c) 2015-2023, Zig contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
83
build.zig
83
build.zig
@@ -10,14 +10,14 @@ const fs = std.fs;
|
||||
const InstallDirectoryOptions = std.build.InstallDirectoryOptions;
|
||||
const assert = std.debug.assert;
|
||||
|
||||
const zig_version = std.builtin.Version{ .major = 0, .minor = 10, .patch = 0 };
|
||||
const zig_version = std.builtin.Version{ .major = 0, .minor = 10, .patch = 1 };
|
||||
const stack_size = 32 * 1024 * 1024;
|
||||
|
||||
pub fn build(b: *Builder) !void {
|
||||
b.setPreferredReleaseMode(.ReleaseFast);
|
||||
const test_step = b.step("test", "Run all the tests");
|
||||
const mode = b.standardReleaseOptions();
|
||||
const target = b.standardTargetOptions(.{});
|
||||
var target = b.standardTargetOptions(.{});
|
||||
const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");
|
||||
const use_zig_libcxx = b.option(bool, "use-zig-libcxx", "If libc++ is needed, use zig's bundled version, don't try to integrate with the system") orelse false;
|
||||
|
||||
@@ -88,6 +88,7 @@ pub fn build(b: *Builder) !void {
|
||||
"Whether LLVM has the experimental target arc enabled",
|
||||
) orelse false;
|
||||
const enable_macos_sdk = b.option(bool, "enable-macos-sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse false;
|
||||
const enable_symlinks_windows = b.option(bool, "enable-symlinks-windows", "Run tests requiring presence of symlinks on Windows") orelse false;
|
||||
const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h");
|
||||
|
||||
if (!skip_install_lib_files) {
|
||||
@@ -141,6 +142,10 @@ pub fn build(b: *Builder) !void {
|
||||
break :blk 4;
|
||||
};
|
||||
|
||||
if (only_c) {
|
||||
target.ofmt = .c;
|
||||
}
|
||||
|
||||
const main_file: ?[]const u8 = mf: {
|
||||
if (!have_stage1) break :mf "src/main.zig";
|
||||
if (use_zig0) break :mf null;
|
||||
@@ -172,10 +177,6 @@ pub fn build(b: *Builder) !void {
|
||||
test_cases.want_lto = false;
|
||||
}
|
||||
|
||||
if (only_c) {
|
||||
exe.ofmt = .c;
|
||||
}
|
||||
|
||||
const exe_options = b.addOptions();
|
||||
exe.addOptions("build_options", exe_options);
|
||||
|
||||
@@ -519,9 +520,10 @@ pub fn build(b: *Builder) !void {
|
||||
b.enable_rosetta,
|
||||
b.enable_wasmtime,
|
||||
b.enable_wine,
|
||||
enable_symlinks_windows,
|
||||
));
|
||||
test_step.dependOn(tests.addCAbiTests(b, skip_non_native));
|
||||
test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests));
|
||||
test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));
|
||||
test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
|
||||
test_step.dependOn(tests.addCliTests(b, test_filter, modes));
|
||||
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, modes));
|
||||
@@ -567,6 +569,10 @@ fn addCmakeCfgOptionsToExe(
|
||||
exe: *std.build.LibExeObjStep,
|
||||
use_zig_libcxx: bool,
|
||||
) !void {
|
||||
if (exe.target.isDarwin()) {
|
||||
// useful for package maintainers
|
||||
exe.headerpad_max_install_names = true;
|
||||
}
|
||||
exe.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
|
||||
cfg.cmake_binary_dir,
|
||||
"zigcpp",
|
||||
@@ -583,32 +589,47 @@ fn addCmakeCfgOptionsToExe(
|
||||
if (use_zig_libcxx) {
|
||||
exe.linkLibCpp();
|
||||
} else {
|
||||
const need_cpp_includes = true;
|
||||
const lib_suffix = switch (cfg.llvm_linkage) {
|
||||
.static => exe.target.staticLibSuffix()[1..],
|
||||
.dynamic => exe.target.dynamicLibSuffix()[1..],
|
||||
};
|
||||
|
||||
// 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 link against gcc libstdc++. If that doesn't work, we fall
|
||||
// back to -lc++ and cross our fingers.
|
||||
addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), "", need_cpp_includes) catch |err| switch (err) {
|
||||
error.RequiredLibraryNotFound => {
|
||||
exe.linkSystemLibrary("c++");
|
||||
},
|
||||
else => |e| return e,
|
||||
};
|
||||
exe.linkSystemLibrary("unwind");
|
||||
} else if (exe.target.isFreeBSD()) {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
exe.linkSystemLibrary("pthread");
|
||||
} else if (exe.target.getOsTag() == .openbsd) {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++abi.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
} else if (exe.target.isDarwin()) {
|
||||
exe.linkSystemLibrary("c++");
|
||||
const need_cpp_includes = true;
|
||||
const static = cfg.llvm_linkage == .static;
|
||||
const lib_suffix = if (static) exe.target.staticLibSuffix()[1..] else exe.target.dynamicLibSuffix()[1..];
|
||||
switch (exe.target.getOsTag()) {
|
||||
.linux => {
|
||||
// First we try to link against gcc libstdc++. If that doesn't work, we fall
|
||||
// back to -lc++ and cross our fingers.
|
||||
addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), "", need_cpp_includes) catch |err| switch (err) {
|
||||
error.RequiredLibraryNotFound => {
|
||||
exe.linkSystemLibrary("c++");
|
||||
},
|
||||
else => |e| return e,
|
||||
};
|
||||
exe.linkSystemLibrary("unwind");
|
||||
},
|
||||
.ios, .macos, .watchos, .tvos => {
|
||||
exe.linkSystemLibrary("c++");
|
||||
},
|
||||
.freebsd => {
|
||||
if (static) {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
} else {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
}
|
||||
},
|
||||
.openbsd => {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++abi.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
},
|
||||
.netbsd, .dragonfly => {
|
||||
if (static) {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
} else {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
}
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
71
ci/aarch64-linux-debug.sh
Normal file
71
ci/aarch64-linux-debug.sh
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Requires cmake ninja-build
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.971+19056cb68"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH"
|
||||
|
||||
# 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="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-debug
|
||||
mkdir build-debug
|
||||
cd build-debug
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
# 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
|
||||
|
||||
ninja install
|
||||
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-debug/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-debug/bin/zig build -Dtarget=arm-linux-musleabihf
|
||||
|
||||
stage3-debug/bin/zig build test docs \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-debug/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
71
ci/aarch64-linux-release.sh
Normal file
71
ci/aarch64-linux-release.sh
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Requires cmake ninja-build
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.971+19056cb68"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$PATH"
|
||||
|
||||
# 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="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-release
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
# 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
|
||||
|
||||
ninja install
|
||||
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-release/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-release
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-release/bin/zig build -Dtarget=arm-linux-musleabihf
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
70
ci/aarch64-macos.sh
Executable file
70
ci/aarch64-macos.sh
Executable file
@@ -0,0 +1,70 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
# Script assumes the presence of the following:
|
||||
# s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
TARGET="$ARCH-macos-none"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.534+b0b1cc356-1"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
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
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
PATH="$HOME/local/bin:$PATH" cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
|
||||
-DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
$HOME/local/bin/ninja install
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-Denable-macos-sdk \
|
||||
-Dstatic-llvm \
|
||||
-Dskip-non-native \
|
||||
--search-prefix "$PREFIX"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
|
||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||
stage3-release/bin/zig build \
|
||||
--prefix stage4-release \
|
||||
-Denable-llvm \
|
||||
-Dno-lib \
|
||||
-Drelease \
|
||||
-Dstrip \
|
||||
-Dtarget=$TARGET \
|
||||
-Duse-zig-libcxx \
|
||||
-Dversion-string="$(stage3-release/bin/zig version)"
|
||||
|
||||
# diff returns an error code if the files differ.
|
||||
echo "If the following command fails, it means nondeterminism has been"
|
||||
echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
|
||||
diff stage3-release/bin/zig stage4-release/bin/zig
|
||||
@@ -1,106 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
brew update && brew install ncurses s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
ARCH="x86_64"
|
||||
TARGET="$ARCH-macos-none"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
JOBS="-j2"
|
||||
|
||||
rm -rf $PREFIX
|
||||
cd $HOME
|
||||
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
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
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON
|
||||
|
||||
# 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
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-Denable-macos-sdk \
|
||||
-Dstatic-llvm \
|
||||
-Dskip-non-native \
|
||||
--search-prefix "$PREFIX"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p "stage3-release/doc/std"
|
||||
stage3-release/bin/zig test "$(pwd)/../lib/std/std.zig" \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-femit-docs="$(pwd)/stage3-release/doc/std" \
|
||||
-fno-emit-bin
|
||||
|
||||
if [ "${BUILD_REASON}" != "PullRequest" ]; then
|
||||
# Remove the unnecessary bin dir in stage3-release/bin/zig
|
||||
mv stage3-release/bin/zig stage3-release/
|
||||
rmdir stage3-release/bin
|
||||
|
||||
# Remove the unnecessary zig dir in stage3-release/lib/zig/std/std.zig
|
||||
mv stage3-release/lib/zig stage3-release/lib2
|
||||
rmdir stage3-release/lib
|
||||
mv stage3-release/lib2 stage3-release/lib
|
||||
|
||||
mv ../LICENSE stage3-release/
|
||||
mv ../zig-cache/langref.html stage3-release/doc
|
||||
|
||||
VERSION=$(stage3-release/zig version)
|
||||
DIRNAME="zig-macos-$ARCH-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv stage3-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=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="macos-$GITBRANCH.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
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/$ARCH-macos-$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
|
||||
set +x
|
||||
echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
|
||||
echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
|
||||
echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
|
||||
echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
|
||||
fi
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# We do not set -x because this would leak the oauth access token.
|
||||
set +x
|
||||
|
||||
set -e
|
||||
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y curl jq
|
||||
|
||||
OAUTH_TOKEN="$(cat "$DOWNLOADSECUREFILE_SECUREFILEPATH")"
|
||||
./ci/srht/on_master_success "$VERSION" "$OAUTH_TOKEN"
|
||||
@@ -1,169 +0,0 @@
|
||||
jobs:
|
||||
- job: BuildMacOS
|
||||
pool:
|
||||
vmImage: 'macOS-11'
|
||||
timeoutInMinutes: 360
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: s3cfg
|
||||
- script: ci/azure/macos_script
|
||||
name: main
|
||||
displayName: 'Build and test'
|
||||
- job: BuildWindows
|
||||
timeoutInMinutes: 360
|
||||
pool:
|
||||
vmImage: 'windows-2019'
|
||||
variables:
|
||||
TARGET: 'x86_64-windows-gnu'
|
||||
ZIG_LLVM_CLANG_LLD_NAME: 'zig+llvm+lld+clang-${{ variables.TARGET }}-0.10.0-dev.4560+828735ac0'
|
||||
ZIG_LLVM_CLANG_LLD_URL: 'https://ziglang.org/deps/${{ variables.ZIG_LLVM_CLANG_LLD_NAME }}.zip'
|
||||
steps:
|
||||
- pwsh: |
|
||||
(New-Object Net.WebClient).DownloadFile("$(ZIG_LLVM_CLANG_LLD_URL)", "${ZIG_LLVM_CLANG_LLD_NAME}.zip")
|
||||
& 'C:\Program Files\7-Zip\7z.exe' x "${ZIG_LLVM_CLANG_LLD_NAME}.zip"
|
||||
name: install
|
||||
displayName: 'Install ZIG/LLVM/CLANG/LLD'
|
||||
|
||||
- pwsh: |
|
||||
Set-Variable -Name ZIGLIBDIR -Value "$(Get-Location)\lib"
|
||||
Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release"
|
||||
Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$(ZIG_LLVM_CLANG_LLD_NAME)"
|
||||
|
||||
function CheckLastExitCode {
|
||||
if (!$?) {
|
||||
exit 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the `zig build` command below which uses `git describe`.
|
||||
git config core.abbrev 9
|
||||
git fetch --tags
|
||||
if ((git rev-parse --is-shallow-repository) -eq "true") {
|
||||
git fetch --unshallow # `git describe` won't work on a shallow repo
|
||||
}
|
||||
|
||||
& "$ZIGPREFIXPATH\bin\zig.exe" build `
|
||||
--prefix "$ZIGINSTALLDIR" `
|
||||
--search-prefix "$ZIGPREFIXPATH" `
|
||||
--zig-lib-dir "$ZIGLIBDIR" `
|
||||
-Denable-stage1 `
|
||||
-Dstatic-llvm `
|
||||
-Drelease `
|
||||
-Dstrip `
|
||||
-Duse-zig-libcxx `
|
||||
-Dtarget=$(TARGET)
|
||||
CheckLastExitCode
|
||||
name: build
|
||||
displayName: 'Build'
|
||||
|
||||
- pwsh: |
|
||||
Set-Variable -Name ZIGLIBDIR -Value "$(Get-Location)\lib"
|
||||
Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release"
|
||||
Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$(ZIG_LLVM_CLANG_LLD_NAME)"
|
||||
|
||||
function CheckLastExitCode {
|
||||
if (!$?) {
|
||||
exit 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
& "$ZIGINSTALLDIR\bin\zig.exe" build test docs `
|
||||
--search-prefix "$ZIGPREFIXPATH" `
|
||||
-Dstatic-llvm `
|
||||
-Dskip-non-native
|
||||
CheckLastExitCode
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir "$ZIGINSTALLDIR\doc\std" -force
|
||||
& "$ZIGINSTALLDIR\bin\zig.exe" test "$ZIGLIBDIR\std\std.zig" `
|
||||
--zig-lib-dir "$ZIGLIBDIR" `
|
||||
-femit-docs="$ZIGINSTALLDIR\doc\std" `
|
||||
-fno-emit-bin
|
||||
|
||||
name: test
|
||||
displayName: 'Test'
|
||||
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
name: aws_credentials
|
||||
secureFile: aws_credentials
|
||||
|
||||
- pwsh: |
|
||||
$Env:AWS_SHARED_CREDENTIALS_FILE = "$Env:DOWNLOADSECUREFILE_SECUREFILEPATH"
|
||||
|
||||
# Workaround Azure networking issue
|
||||
# https://github.com/aws/aws-cli/issues/5749
|
||||
$Env:AWS_EC2_METADATA_DISABLED = "true"
|
||||
$Env:AWS_REGION = "us-west-2"
|
||||
|
||||
mv LICENSE stage3-release/
|
||||
mv zig-cache/langref.html stage3-release/
|
||||
mv stage3-release/bin/zig.exe stage3-release/
|
||||
rmdir stage3-release/bin
|
||||
|
||||
# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
|
||||
mv stage3-release/lib/zig stage3-release/lib2
|
||||
rmdir stage3-release/lib
|
||||
mv stage3-release/lib2 stage3-release/lib
|
||||
|
||||
Set-Variable -Name VERSION -Value $(./stage3-release/zig.exe version)
|
||||
Set-Variable -Name DIRNAME -Value "zig-windows-x86_64-$VERSION"
|
||||
Set-Variable -Name TARBALL -Value "$DIRNAME.zip"
|
||||
mv stage3-release "$DIRNAME"
|
||||
7z a "$TARBALL" "$DIRNAME"
|
||||
|
||||
aws s3 cp `
|
||||
"$TARBALL" `
|
||||
s3://ziglang.org/builds/ `
|
||||
--acl public-read `
|
||||
--cache-control 'public, max-age=31536000, immutable'
|
||||
|
||||
Set-Variable -Name SHASUM -Value (Get-FileHash "$TARBALL" -Algorithm SHA256 | select-object -ExpandProperty Hash).ToLower()
|
||||
Set-Variable -Name BYTESIZE -Value (Get-Item "$TARBALL").length
|
||||
|
||||
Set-Variable -Name JSONFILE -Value "windows-${Env:BUILD_SOURCEBRANCHNAME}.json"
|
||||
echo $null > $JSONFILE
|
||||
echo ('{"tarball": "' + $TARBALL + '",') >> $JSONFILE
|
||||
echo ('"shasum": "' + $SHASUM + '",') >> $JSONFILE
|
||||
echo ('"size": ' + $BYTESIZE + '}' ) >> $JSONFILE
|
||||
|
||||
aws s3 cp `
|
||||
"$JSONFILE" `
|
||||
s3://ziglang.org/builds/ `
|
||||
--acl public-read `
|
||||
--cache-control 'max-age=0, must-revalidate'
|
||||
|
||||
aws s3 cp `
|
||||
"$JSONFILE" `
|
||||
"s3://ziglang.org/builds/x86_64-windows-${VERSION}.json" `
|
||||
--acl public-read
|
||||
|
||||
echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
|
||||
echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
|
||||
echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
|
||||
|
||||
name: upload
|
||||
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
|
||||
displayName: 'Upload'
|
||||
|
||||
- job: OnMasterSuccess
|
||||
dependsOn:
|
||||
- BuildMacOS
|
||||
- BuildWindows
|
||||
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
||||
strategy:
|
||||
maxParallel: 1
|
||||
pool:
|
||||
vmImage: 'ubuntu-20.04'
|
||||
variables:
|
||||
version: $[ dependencies.BuildMacOS.outputs['main.version'] ]
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: oauth_token
|
||||
- script: ci/azure/on_master_success
|
||||
displayName: 'master branch success hook'
|
||||
@@ -1,98 +0,0 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: test-aarch64-linux-musl
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/linux_script_build
|
||||
|
||||
- name: behavior
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/test_linux_behavior
|
||||
|
||||
- name: std_Debug
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/test_linux_std_Debug
|
||||
|
||||
- name: std_ReleaseSafe
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/test_linux_std_ReleaseSafe
|
||||
|
||||
- name: std_ReleaseFast
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/test_linux_std_ReleaseFast
|
||||
|
||||
- name: std_ReleaseSmall
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/test_linux_std_ReleaseSmall
|
||||
|
||||
- name: misc
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/test_linux_misc
|
||||
|
||||
- name: cases
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/test_linux_cases
|
||||
|
||||
- name: standalone
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/test_linux_standalone
|
||||
|
||||
- name: docs
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
commands:
|
||||
- ./ci/drone/test_linux_docs
|
||||
|
||||
- name: finalize
|
||||
depends_on:
|
||||
- build
|
||||
- behavior
|
||||
- std_Debug
|
||||
- std_ReleaseSafe
|
||||
- std_ReleaseFast
|
||||
- std_ReleaseSmall
|
||||
- misc
|
||||
- cases
|
||||
image: ziglang/static-base:llvm15-aarch64-3
|
||||
environment:
|
||||
SRHT_OAUTH_TOKEN:
|
||||
from_secret: SRHT_OAUTH_TOKEN
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: AWS_ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: AWS_SECRET_ACCESS_KEY
|
||||
commands:
|
||||
- ./ci/drone/linux_script_finalize
|
||||
@@ -1,58 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
PREFIX="/deps/local"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
# The `CMAKE_AR` parameter will consider any spaces to
|
||||
# be part of the executable path rather than CLI args, so we have
|
||||
# to create wrapper scripts for `zig ar` and zig ranlib`.
|
||||
cat <<'ENDFILE' >$PREFIX/bin/ar
|
||||
#!/bin/sh
|
||||
/deps/local/bin/zig ar $@
|
||||
ENDFILE
|
||||
|
||||
cat <<'ENDFILE' >$PREFIX/bin/ranlib
|
||||
#!/bin/sh
|
||||
/deps/local/bin/zig ranlib $@
|
||||
ENDFILE
|
||||
|
||||
chmod +x "$PREFIX/bin/ar"
|
||||
chmod +x "$PREFIX/bin/ranlib"
|
||||
|
||||
# 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_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_AR="$PREFIX/bin/ar" \
|
||||
-DCMAKE_RANLIB="$PREFIX/bin/ranlib" \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
# 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
|
||||
samu install
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
if [ -n "$DRONE_PULL_REQUEST" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd build
|
||||
|
||||
# Remove the unnecessary bin dir in $INSTALL_PREFIX/bin/zig
|
||||
mv "$INSTALL_PREFIX/bin/zig" "$INSTALL_PREFIX/"
|
||||
rmdir "$INSTALL_PREFIX/bin"
|
||||
|
||||
# Remove the unnecessary zig dir in $INSTALL_PREFIX/lib/zig/std/std.zig
|
||||
mv "$INSTALL_PREFIX/lib/zig" "$INSTALL_PREFIX/lib2"
|
||||
rmdir "$INSTALL_PREFIX/lib"
|
||||
mv "$INSTALL_PREFIX/lib2" "$INSTALL_PREFIX/lib"
|
||||
|
||||
mv ../LICENSE "$INSTALL_PREFIX/"
|
||||
mv ../zig-cache/langref.html "$INSTALL_PREFIX/doc/"
|
||||
|
||||
GITBRANCH="$DRONE_BRANCH"
|
||||
VERSION="$("$INSTALL_PREFIX/zig" version)"
|
||||
DIRNAME="zig-linux-$ARCH-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv "$INSTALL_PREFIX" "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="tarball.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
||||
|
||||
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
|
||||
if [ "$GITBRANCH" = "master" ]; then
|
||||
# avoid leaking oauth token
|
||||
set +x
|
||||
|
||||
cd "$DRONE_WORKSPACE"
|
||||
./ci/srht/on_master_success "$VERSION" "$SRHT_OAUTH_TOKEN"
|
||||
fi
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
ZIG="$INSTALL_PREFIX/bin/zig"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
$ZIG build test-behavior -Dskip-non-native --zig-lib-dir lib
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
ZIG="$INSTALL_PREFIX/bin/zig"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
# test building self-hosted without LLVM
|
||||
$ZIG build -Dskip-non-native --zig-lib-dir lib
|
||||
$ZIG build test-cases -Dskip-non-native --zig-lib-dir lib
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
ZIG="$INSTALL_PREFIX/bin/zig"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
$ZIG build docs --zig-lib-dir lib
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
ZIG="$INSTALL_PREFIX/bin/zig"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
$ZIG build test-compiler-rt -Dskip-non-native --zig-lib-dir lib
|
||||
$ZIG build test-compare-output -Dskip-non-native --zig-lib-dir lib
|
||||
$ZIG build test-universal-libc -Dskip-non-native --zig-lib-dir lib
|
||||
$ZIG build test-stack-traces -Dskip-non-native --zig-lib-dir lib
|
||||
$ZIG build test-cli -Dskip-non-native --zig-lib-dir lib
|
||||
$ZIG build test-asm-link -Dskip-non-native --zig-lib-dir lib
|
||||
$ZIG build test-translate-c -Dskip-non-native --zig-lib-dir lib
|
||||
$ZIG build test-fmt --zig-lib-dir lib
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
ZIG="$INSTALL_PREFIX/bin/zig"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
$ZIG build test-standalone -Dskip-non-native --zig-lib-dir lib -Dskip-release-safe
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
ZIG="$INSTALL_PREFIX/bin/zig"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
$ZIG build test-std \
|
||||
--zig-lib-dir lib \
|
||||
-Dskip-release-safe \
|
||||
-Dskip-release-fast \
|
||||
-Dskip-release-small \
|
||||
-Dskip-non-native \
|
||||
-Dskip-single-threaded
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p "$INSTALL_PREFIX/doc/std"
|
||||
$ZIG test "$DRONE_WORKSPACE/lib/std/std.zig" \
|
||||
--zig-lib-dir "$DRONE_WORKSPACE/lib" \
|
||||
-femit-docs="$INSTALL_PREFIX/doc/std" \
|
||||
-fno-emit-bin
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
ZIG="$INSTALL_PREFIX/bin/zig"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
$ZIG build test-std \
|
||||
--zig-lib-dir lib \
|
||||
-Dskip-debug \
|
||||
-Dskip-release-safe \
|
||||
-Dskip-release-small \
|
||||
-Dskip-non-native \
|
||||
-Dskip-single-threaded \
|
||||
-Dskip-libc
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
ZIG="$INSTALL_PREFIX/bin/zig"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
$ZIG build test-std \
|
||||
--zig-lib-dir lib \
|
||||
-Dskip-debug \
|
||||
-Dskip-release-fast \
|
||||
-Dskip-release-small \
|
||||
-Dskip-non-native \
|
||||
-Dskip-single-threaded \
|
||||
-Dskip-libc
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
|
||||
ZIG="$INSTALL_PREFIX/bin/zig"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
|
||||
$ZIG build test-std \
|
||||
--zig-lib-dir lib \
|
||||
-Dskip-debug \
|
||||
-Dskip-release-safe \
|
||||
-Dskip-release-fast \
|
||||
-Dskip-non-native \
|
||||
-Dskip-single-threaded \
|
||||
-Dskip-libc
|
||||
@@ -1,114 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
sudo pkg update -fq
|
||||
sudo pkg install -y cmake py39-s3cmd wget curl jq samurai
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
TARGET="x86_64-freebsd-gnu"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
|
||||
cd $HOME
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
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
|
||||
# codes to show progress.
|
||||
export TERM=dumb
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_PREFIX_PATH=$PREFIX \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
# TODO: eliminate this workaround. Without this, zig does not end up passing
|
||||
# -isystem /usr/include when building libc++, resulting in #include <sys/endian.h>
|
||||
# "file not found" errors.
|
||||
echo "include_dir=/usr/include" >>libc.txt
|
||||
echo "sys_include_dir=/usr/include" >>libc.txt
|
||||
echo "crt_dir=/usr/lib" >>libc.txt
|
||||
echo "msvc_lib_dir=" >>libc.txt
|
||||
echo "kernel32_lib_dir=" >>libc.txt
|
||||
echo "gcc_dir=" >>libc.txt
|
||||
ZIG_LIBC_TXT="$(pwd)/libc.txt"
|
||||
|
||||
ZIG_LIBC="$ZIG_LIBC_TXT" samu install
|
||||
|
||||
# Here we skip some tests to save time.
|
||||
stage3/bin/zig build test docs \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-Dstatic-llvm \
|
||||
--search-prefix "$PREFIX" \
|
||||
-Dskip-stage1 \
|
||||
-Dskip-non-native
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p "stage3/doc/std"
|
||||
stage3/bin/zig test "$(pwd)/../lib/std/std.zig" \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-femit-docs="$(pwd)/stage3/doc/std/" \
|
||||
-fno-emit-bin
|
||||
|
||||
if [ -f ~/.s3cfg ]; then
|
||||
# Remove the unnecessary bin dir in stage3/bin/zig
|
||||
mv stage3/bin/zig stage3/
|
||||
rmdir stage3/bin
|
||||
|
||||
# Remove the unnecessary zig dir in stage3/lib/zig/std/std.zig
|
||||
mv stage3/lib/zig stage3/lib2
|
||||
rmdir stage3/lib
|
||||
mv stage3/lib2 stage3/lib
|
||||
|
||||
mv ../LICENSE stage3/
|
||||
mv ../zig-cache/langref.html stage3/doc/
|
||||
|
||||
GITBRANCH=$(basename $GITHUB_REF)
|
||||
VERSION=$(stage3/zig version)
|
||||
DIRNAME="zig-freebsd-x86_64-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv stage3 "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="freebsd-$GITBRANCH.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
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-freebsd-$VERSION.json"
|
||||
|
||||
if [ "$GITBRANCH" = "master" ]; then
|
||||
# avoid leaking oauth token
|
||||
set +x
|
||||
|
||||
OAUTH_TOKEN="$(cat ~/.oauth_token)"
|
||||
cd "$ZIGDIR"
|
||||
./ci/srht/on_master_success "$VERSION" "$OAUTH_TOKEN"
|
||||
fi
|
||||
fi
|
||||
@@ -1,630 +0,0 @@
|
||||
{
|
||||
"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}}"
|
||||
},
|
||||
"aarch64-macos": {
|
||||
"tarball": "https://ziglang.org/builds/{{AARCH64_MACOS_TARBALL}}",
|
||||
"shasum": "{{AARCH64_MACOS_SHASUM}}",
|
||||
"size": "{{AARCH64_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.9.1": {
|
||||
"date": "2022-02-14",
|
||||
"docs": "https://ziglang.org/documentation/0.9.1/",
|
||||
"stdDocs": "https://ziglang.org/documentation/0.9.1/std/",
|
||||
"notes": "https://ziglang.org/download/0.9.1/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-0.9.1.tar.xz",
|
||||
"shasum": "38cf4e84481f5facc766ba72783e7462e08d6d29a5d47e3b75c8ee3142485210",
|
||||
"size": "13940828"
|
||||
},
|
||||
"bootstrap": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-bootstrap-0.9.1.tar.xz",
|
||||
"shasum": "0a8e221c71860d8975c15662b3ed3bd863e81c4fe383455a596e5e0e490d6109",
|
||||
"size": "42488812"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-freebsd-x86_64-0.9.1.tar.xz",
|
||||
"shasum": "4e06009bd3ede34b72757eec1b5b291b30aa0d5046dadd16ecb6b34a02411254",
|
||||
"size": "39028848"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-linux-aarch64-0.9.1.tar.xz",
|
||||
"shasum": "5d99a39cded1870a3fa95d4de4ce68ac2610cca440336cfd252ffdddc2b90e66",
|
||||
"size": "37034860"
|
||||
},
|
||||
"armv7a-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-linux-armv7a-0.9.1.tar.xz",
|
||||
"shasum": "6de64456cb4757a555816611ea697f86fba7681d8da3e1863fa726a417de49be",
|
||||
"size": "37974652"
|
||||
},
|
||||
"i386-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-linux-i386-0.9.1.tar.xz",
|
||||
"shasum": "e776844fecd2e62fc40d94718891057a1dbca1816ff6013369e9a38c874374ca",
|
||||
"size": "44969172"
|
||||
},
|
||||
"riscv64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-linux-riscv64-0.9.1.tar.xz",
|
||||
"shasum": "208dea53662c2c52777bd9e3076115d2126a4f71aed7f2ff3b8fe224dc3881aa",
|
||||
"size": "39390868"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-linux-x86_64-0.9.1.tar.xz",
|
||||
"shasum": "be8da632c1d3273f766b69244d80669fe4f5e27798654681d77c992f17c237d7",
|
||||
"size": "41011464"
|
||||
},
|
||||
"aarch64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-macos-aarch64-0.9.1.tar.xz",
|
||||
"shasum": "8c473082b4f0f819f1da05de2dbd0c1e891dff7d85d2c12b6ee876887d438287",
|
||||
"size": "38995640"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-macos-x86_64-0.9.1.tar.xz",
|
||||
"shasum": "2d94984972d67292b55c1eb1c00de46580e9916575d083003546e9a01166754c",
|
||||
"size": "43713044"
|
||||
},
|
||||
"i386-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-windows-i386-0.9.1.zip",
|
||||
"shasum": "74a640ed459914b96bcc572183a8db687bed0af08c30d2ea2f8eba03ae930f69",
|
||||
"size": "67929868"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-windows-x86_64-0.9.1.zip",
|
||||
"shasum": "443da53387d6ae8ba6bac4b3b90e9fef4ecbe545e1c5fa3a89485c36f5c0e3a2",
|
||||
"size": "65047697"
|
||||
},
|
||||
"aarch64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.9.1/zig-windows-aarch64-0.9.1.zip",
|
||||
"shasum": "621bf95f54dc3ff71466c5faae67479419951d7489e40e87fd26d195825fb842",
|
||||
"size": "61478151"
|
||||
}
|
||||
},
|
||||
"0.9.0": {
|
||||
"date": "2021-12-20",
|
||||
"docs": "https://ziglang.org/documentation/0.9.0/",
|
||||
"stdDocs": "https://ziglang.org/documentation/0.9.0/std/",
|
||||
"notes": "https://ziglang.org/download/0.9.0/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-0.9.0.tar.xz",
|
||||
"shasum": "cd1be83b12f8269cc5965e59877b49fdd8fa638efb6995ac61eb4cea36a2e381",
|
||||
"size": "13928772"
|
||||
},
|
||||
"bootstrap": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-bootstrap-0.9.0.tar.xz",
|
||||
"shasum": "16b0bdf0bc0a5ed1e0950e08481413d806192e06443a512347526647b2baeabc",
|
||||
"size": "42557736"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-freebsd-x86_64-0.9.0.tar.xz",
|
||||
"shasum": "c95afe679b7cc4110dc2ecd3606c83a699718b7a958d6627f74c20886333e194",
|
||||
"size": "41293236"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-linux-aarch64-0.9.0.tar.xz",
|
||||
"shasum": "1524fedfdbade2dbc9bae1ed98ad38fa7f2114c9a3e94da0d652573c75efbc5a",
|
||||
"size": "40008396"
|
||||
},
|
||||
"armv7a-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-linux-armv7a-0.9.0.tar.xz",
|
||||
"shasum": "50225dee6e6448a63ee96383a34d9fe3bba34ae8da1a0c8619bde2cdfc1df87d",
|
||||
"size": "41196876"
|
||||
},
|
||||
"i386-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-linux-i386-0.9.0.tar.xz",
|
||||
"shasum": "b0dcf688349268c883292acdd55eaa3c13d73b9146e4b990fad95b84a2ac528b",
|
||||
"size": "47408656"
|
||||
},
|
||||
"riscv64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-linux-riscv64-0.9.0.tar.xz",
|
||||
"shasum": "85466de07504767ed37f59782672ad41bbdf43d6480fafd07f45543278b07620",
|
||||
"size": "44171420"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-linux-x86_64-0.9.0.tar.xz",
|
||||
"shasum": "5c55344a877d557fb1b28939785474eb7f4f2f327aab55293998f501f7869fa6",
|
||||
"size": "43420796"
|
||||
},
|
||||
"aarch64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-macos-aarch64-0.9.0.tar.xz",
|
||||
"shasum": "3991c70594d61d09fb4b316157a7c1d87b1d4ec159e7a5ecd11169ff74cad832",
|
||||
"size": "39013392"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-macos-x86_64-0.9.0.tar.xz",
|
||||
"shasum": "c5280eeec4d6e5ea5ce5b448dc9a7c4bdd85ecfed4c1b96aa0835e48b36eccf0",
|
||||
"size": "43764596"
|
||||
},
|
||||
"i386-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-windows-i386-0.9.0.zip",
|
||||
"shasum": "bb839434afc75092015cf4c33319d31463c18512bc01dd719aedf5dcbc368466",
|
||||
"size": "67946715"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-windows-x86_64-0.9.0.zip",
|
||||
"shasum": "084ea2646850aaf068234b0f1a92b914ed629be47075e835f8a67d55c21d880e",
|
||||
"size": "65045849"
|
||||
},
|
||||
"aarch64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.9.0/zig-windows-aarch64-0.9.0.zip",
|
||||
"shasum": "f9018725e3fb2e8992b17c67034726971156eb190685018a9ac8c3a9f7a22340",
|
||||
"size": "61461921"
|
||||
}
|
||||
},
|
||||
"0.8.1": {
|
||||
"date": "2021-09-06",
|
||||
"docs": "https://ziglang.org/documentation/0.8.1/",
|
||||
"stdDocs": "https://ziglang.org/documentation/0.8.1/std/",
|
||||
"notes": "https://ziglang.org/download/0.8.1/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-0.8.1.tar.xz",
|
||||
"shasum": "8c428e14a0a89cb7a15a6768424a37442292858cdb695e2eb503fa3c7bf47f1a",
|
||||
"size": "12650228"
|
||||
},
|
||||
"bootstrap": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-bootstrap-0.8.1.tar.xz",
|
||||
"shasum": "fa1239247f830ecd51c42537043f5220e4d1dfefdc54356fa419616a0efb3902",
|
||||
"size": "43613464"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-freebsd-x86_64-0.8.1.tar.xz",
|
||||
"shasum": "fc4f6478bcf3a9fce1b8ef677a91694f476dd35be6d6c9c4f44a8b76eedbe176",
|
||||
"size": "39150924"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-aarch64-0.8.1.tar.xz",
|
||||
"shasum": "2166dc9f2d8df387e8b4122883bb979d739281e1ff3f3d5483fec3a23b957510",
|
||||
"size": "37605932"
|
||||
},
|
||||
"armv7a-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-armv7a-0.8.1.tar.xz",
|
||||
"shasum": "5ba58141805e2519f38cf8e715933cbf059f4f3dade92c71838cce341045de05",
|
||||
"size": "39185876"
|
||||
},
|
||||
"i386-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-i386-0.8.1.tar.xz",
|
||||
"shasum": "2f3e84f30492b5f1c5f97cecc0166f07a8a8d50c5f85dbb3a6ef2a4ee6f915e6",
|
||||
"size": "44782932"
|
||||
},
|
||||
"riscv64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-riscv64-0.8.1.tar.xz",
|
||||
"shasum": "4adfaf147b025917c03367462fe5018aaa9edbc6439ef9cd0da2b074ae960554",
|
||||
"size": "41234480"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-linux-x86_64-0.8.1.tar.xz",
|
||||
"shasum": "6c032fc61b5d77a3f3cf781730fa549f8f059ffdb3b3f6ad1c2994d2b2d87983",
|
||||
"size": "41250060"
|
||||
},
|
||||
"aarch64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-macos-aarch64-0.8.1.tar.xz",
|
||||
"shasum": "5351297e3b8408213514b29c0a938002c5cf9f97eee28c2f32920e1227fd8423",
|
||||
"size": "35340712"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-macos-x86_64-0.8.1.tar.xz",
|
||||
"shasum": "16b0e1defe4c1807f2e128f72863124bffdd906cefb21043c34b673bf85cd57f",
|
||||
"size": "39946200"
|
||||
},
|
||||
"i386-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-windows-i386-0.8.1.zip",
|
||||
"shasum": "099605051eb0452a947c8eab8fbbc7e43833c8376d267e94e41131c289a1c535",
|
||||
"size": "64152358"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.8.1/zig-windows-x86_64-0.8.1.zip",
|
||||
"shasum": "43573db14cd238f7111d6bdf37492d363f11ecd1eba802567a172f277d003926",
|
||||
"size": "61897838"
|
||||
}
|
||||
},
|
||||
"0.8.0": {
|
||||
"date": "2021-06-04",
|
||||
"docs": "https://ziglang.org/documentation/0.8.0/",
|
||||
"stdDocs": "https://ziglang.org/documentation/0.8.0/std/",
|
||||
"notes": "https://ziglang.org/download/0.8.0/release-notes.html",
|
||||
"src": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-0.8.0.tar.xz",
|
||||
"shasum": "03a828d00c06b2e3bb8b7ff706997fd76bf32503b08d759756155b6e8c981e77",
|
||||
"size": "12614896"
|
||||
},
|
||||
"bootstrap": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-bootstrap-0.8.0.tar.xz",
|
||||
"shasum": "10600bc9c01f92e343f40d6ecc0ad05d67d27c3e382bce75524c0639cd8ca178",
|
||||
"size": "43574248"
|
||||
},
|
||||
"x86_64-freebsd": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-freebsd-x86_64-0.8.0.tar.xz",
|
||||
"shasum": "0d3ccc436c8c0f50fd55462f72f8492d98723c7218ffc2a8a1831967d81b4bdc",
|
||||
"size": "39125332"
|
||||
},
|
||||
"aarch64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-aarch64-0.8.0.tar.xz",
|
||||
"shasum": "ee204ca2c2037952cf3f8b10c609373a08a291efa4af7b3c73be0f2b27720470",
|
||||
"size": "37575428"
|
||||
},
|
||||
"armv7a-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-armv7a-0.8.0.tar.xz",
|
||||
"shasum": "d00b8bd97b79f45d6f5da956983bafeaa082e6c2ae8c6e1c6d4faa22fa29b320",
|
||||
"size": "38884212"
|
||||
},
|
||||
"i386-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-i386-0.8.0.tar.xz",
|
||||
"shasum": "96e43ee6ed81c3c63401f456bd1c58ee6d42373a43cb324f5cf4974ca0998865",
|
||||
"size": "42136032"
|
||||
},
|
||||
"riscv64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-riscv64-0.8.0.tar.xz",
|
||||
"shasum": "75997527a78cdab64c40c43d9df39c01c4cdb557bb3992a869838371a204cfea",
|
||||
"size": "40016268"
|
||||
},
|
||||
"x86_64-linux": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-linux-x86_64-0.8.0.tar.xz",
|
||||
"shasum": "502625d3da3ae595c5f44a809a87714320b7a40e6dff4a895b5fa7df3391d01e",
|
||||
"size": "41211184"
|
||||
},
|
||||
"aarch64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-macos-aarch64-0.8.0.tar.xz",
|
||||
"shasum": "b32d13f66d0e1ff740b3326d66a469ee6baddbd7211fa111c066d3bd57683111",
|
||||
"size": "35292180"
|
||||
},
|
||||
"x86_64-macos": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-macos-x86_64-0.8.0.tar.xz",
|
||||
"shasum": "279f9360b5cb23103f0395dc4d3d0d30626e699b1b4be55e98fd985b62bc6fbe",
|
||||
"size": "39969312"
|
||||
},
|
||||
"i386-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-windows-i386-0.8.0.zip",
|
||||
"shasum": "b6ec9aa6cd6f3872fcb30d43ff411802d82008a0c4142ee49e208a09b2c1c5fe",
|
||||
"size": "61507213"
|
||||
},
|
||||
"x86_64-windows": {
|
||||
"tarball": "https://ziglang.org/download/0.8.0/zig-windows-x86_64-0.8.0.zip",
|
||||
"shasum": "8580fbbf3afb72e9b495c7f8aeac752a03475ae0bbcf5d787f3775c7e1f4f807",
|
||||
"size": "61766193"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
sudo pkgin -y update
|
||||
sudo pkgin -y upgrade
|
||||
sudo pkgin -y install cmake samurai curl jq py27-s3cmd wget clang
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-x86_64-netbsd-gnu-0.8.0"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
|
||||
cd $HOME
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
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
|
||||
# codes to show progress.
|
||||
export TERM=dumb
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
export CC="$PREFIX/bin/zigcc"
|
||||
export CXX="$PREFIX/bin/zigcxx"
|
||||
echo "#!/bin/sh
|
||||
env CC=\"clang\" $PREFIX/bin/zig cc \"\$@\"" > $CC
|
||||
echo "#!/bin/sh
|
||||
env CC=\"clang\" $PREFIX/bin/zig c++ \"\$@\"" > $CXX
|
||||
chmod +x $CC
|
||||
chmod +x $CXX
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_PREFIX_PATH=$PREFIX \
|
||||
"-DCMAKE_INSTALL_PREFIX=$(pwd)/release" \
|
||||
-DZIG_STATIC=ON \
|
||||
-DZIG_TARGET_TRIPLE=x86_64-netbsd-none \
|
||||
-GNinja
|
||||
samu install
|
||||
|
||||
unset CC
|
||||
unset CXX
|
||||
|
||||
# TODO ld.lld: error: undefined symbol: main
|
||||
#>>> referenced by crt0-common.c
|
||||
#>>> /usr/lib/crt0.o:(___start)
|
||||
#release/bin/zig test ../test/behavior.zig -fno-stage1 -fLLVM -I ../test
|
||||
|
||||
# Here we skip some tests to save time.
|
||||
release/bin/zig build test -Dskip-stage1 -Dskip-non-native
|
||||
|
||||
if [ -f ~/.s3cfg ]; then
|
||||
mv ../LICENSE release/
|
||||
mv ../zig-cache/langref.html release/
|
||||
mv release/bin/zig release/
|
||||
rmdir release/bin
|
||||
|
||||
GITBRANCH=$(basename $GITHUB_REF)
|
||||
VERSION=$(release/zig version)
|
||||
DIRNAME="zig-netbsd-x86_64-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv release "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="netbsd-$GITBRANCH.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
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-netbsd-$VERSION.json"
|
||||
|
||||
if [ "$GITBRANCH" = "master" ]; then
|
||||
# avoid leaking oauth token
|
||||
set +x
|
||||
|
||||
OAUTH_TOKEN="$(cat ~/.oauth_token)"
|
||||
cd "$ZIGDIR"
|
||||
./ci/srht/on_master_success "$VERSION" "$OAUTH_TOKEN"
|
||||
fi
|
||||
fi
|
||||
@@ -1,50 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script must run on a lot of different platforms.
|
||||
# It assumes that the following things are installed:
|
||||
# * curl
|
||||
# * jq
|
||||
# * cat
|
||||
|
||||
# We do not set -x because this would leak the oauth access token.
|
||||
set +x
|
||||
|
||||
set -e
|
||||
|
||||
VERSION="$1"
|
||||
OAUTH_TOKEN="$2"
|
||||
YML_FILE="tmp.yml"
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "missing VERSION parameter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$OAUTH_TOKEN" ]; then
|
||||
echo "missing OAUTH_TOKEN parameter"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<EOF >"$YML_FILE"
|
||||
image: alpine/latest
|
||||
packages:
|
||||
- py3-pip
|
||||
- curl
|
||||
- jq
|
||||
- xz
|
||||
secrets:
|
||||
- 51bfddf5-86a6-4e01-8576-358c72a4a0a4
|
||||
- 44e2bd57-1d07-42bf-925e-22a36119041d
|
||||
sources:
|
||||
- https://github.com/ziglang/zig
|
||||
tasks:
|
||||
- build: cd zig && ./ci/srht/update_download_page $VERSION
|
||||
EOF
|
||||
|
||||
jq <$YML_FILE -sR '{
|
||||
"manifest": .,
|
||||
}' | curl \
|
||||
-H Authorization:"token $OAUTH_TOKEN" \
|
||||
-H Content-Type:application/json \
|
||||
-X POST \
|
||||
-d @- "https://builds.hut.lavatech.top/api/jobs"
|
||||
@@ -1,99 +0,0 @@
|
||||
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.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")) {
|
||||
const size = try std.fmt.parseInt(u64, trimmed, 10);
|
||||
try writer.print("{:.1}", .{std.fmt.fmtIntSizeDec(size)});
|
||||
} else {
|
||||
try writer.writeAll(trimmed);
|
||||
}
|
||||
} else {
|
||||
std.debug.print("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.print("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);
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
VERSION="$1"
|
||||
SRCDIR="$(pwd)"
|
||||
NATIVE_TARBALL="zig-linux-$(uname -m)-$VERSION.tar.xz"
|
||||
|
||||
# Check for all the builds being completed. It's expected that this script is run several times
|
||||
# before they are all complete.
|
||||
AARCH64_LINUX_JSON_URL="https://ziglang.org/builds/aarch64-linux-$VERSION.json"
|
||||
X86_64_LINUX_JSON_URL="https://ziglang.org/builds/x86_64-linux-$VERSION.json"
|
||||
X86_64_WINDOWS_JSON_URL="https://ziglang.org/builds/x86_64-windows-$VERSION.json"
|
||||
AARCH64_MACOS_JSON_URL="https://ziglang.org/builds/aarch64-macos-$VERSION.json"
|
||||
X86_64_MACOS_JSON_URL="https://ziglang.org/builds/x86_64-macos-$VERSION.json"
|
||||
X86_64_FREEBSD_JSON_URL="https://ziglang.org/builds/x86_64-freebsd-$VERSION.json"
|
||||
#X86_64_NETBSD_JSON_URL="https://ziglang.org/builds/x86_64-netbsd-$VERSION.json"
|
||||
|
||||
# If any of these fail, it's not really this job failing; rather we have detected
|
||||
# that this job will be called again later when other jobs have completed.
|
||||
curl --fail -I "$AARCH64_LINUX_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$X86_64_LINUX_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$X86_64_WINDOWS_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$AARCH64_MACOS_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$X86_64_MACOS_JSON_URL" >/dev/null || exit 0
|
||||
curl --fail -I "$X86_64_FREEBSD_JSON_URL" >/dev/null || exit 0
|
||||
#curl --fail -I "$X86_64_NETBSD_JSON_URL" >/dev/null || exit 0
|
||||
|
||||
# Without --user, this gave me:
|
||||
# ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied
|
||||
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="$(pwd)/$(basename $NATIVE_TARBALL .tar.xz)"
|
||||
ZIG="$ZIGDIR/zig"
|
||||
LANGREF="$ZIGDIR/doc/langref.html"
|
||||
SRCTARBALLDIR="zig-$VERSION"
|
||||
export SRC_TARBALL="$SRCTARBALLDIR.tar.xz"
|
||||
mv "$SRCDIR" "$SRCTARBALLDIR"
|
||||
tar cfJ "$SRC_TARBALL" "$SRCTARBALLDIR"
|
||||
export SRC_SHASUM=$(sha256sum $SRC_TARBALL | cut '-d ' -f1)
|
||||
export SRC_BYTESIZE=$(wc -c < $SRC_TARBALL)
|
||||
|
||||
X86_64_WINDOWS_JSON=$(curl --fail "$X86_64_WINDOWS_JSON_URL" || exit 1)
|
||||
export X86_64_WINDOWS_TARBALL="$(echo "$X86_64_WINDOWS_JSON" | jq .tarball -r)"
|
||||
export X86_64_WINDOWS_BYTESIZE="$(echo "$X86_64_WINDOWS_JSON" | jq .size -r)"
|
||||
export X86_64_WINDOWS_SHASUM="$(echo "$X86_64_WINDOWS_JSON" | jq .shasum -r)"
|
||||
|
||||
AARCH64_MACOS_JSON=$(curl --fail "$AARCH64_MACOS_JSON_URL" || exit 1)
|
||||
export AARCH64_MACOS_TARBALL="$(echo "$AARCH64_MACOS_JSON" | jq .tarball -r)"
|
||||
export AARCH64_MACOS_BYTESIZE="$(echo "$AARCH64_MACOS_JSON" | jq .size -r)"
|
||||
export AARCH64_MACOS_SHASUM="$(echo "$AARCH64_MACOS_JSON" | jq .shasum -r)"
|
||||
|
||||
X86_64_MACOS_JSON=$(curl --fail "$X86_64_MACOS_JSON_URL" || exit 1)
|
||||
export X86_64_MACOS_TARBALL="$(echo "$X86_64_MACOS_JSON" | jq .tarball -r)"
|
||||
export X86_64_MACOS_BYTESIZE="$(echo "$X86_64_MACOS_JSON" | jq .size -r)"
|
||||
export X86_64_MACOS_SHASUM="$(echo "$X86_64_MACOS_JSON" | jq .shasum -r)"
|
||||
|
||||
X86_64_LINUX_JSON=$(curl --fail "$X86_64_LINUX_JSON_URL" || exit 1)
|
||||
export X86_64_LINUX_TARBALL="$(echo "$X86_64_LINUX_JSON" | jq .tarball -r)"
|
||||
export X86_64_LINUX_BYTESIZE="$(echo "$X86_64_LINUX_JSON" | jq .size -r)"
|
||||
export X86_64_LINUX_SHASUM="$(echo "$X86_64_LINUX_JSON" | jq .shasum -r)"
|
||||
|
||||
AARCH64_LINUX_JSON=$(curl --fail "$AARCH64_LINUX_JSON_URL" || exit 1)
|
||||
export AARCH64_LINUX_TARBALL="$(echo "$AARCH64_LINUX_JSON" | jq .tarball -r)"
|
||||
export AARCH64_LINUX_BYTESIZE="$(echo "$AARCH64_LINUX_JSON" | jq .size -r)"
|
||||
export AARCH64_LINUX_SHASUM="$(echo "$AARCH64_LINUX_JSON" | jq .shasum -r)"
|
||||
|
||||
X86_64_FREEBSD_JSON=$(curl --fail "$X86_64_FREEBSD_JSON_URL" || exit 1)
|
||||
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)"
|
||||
|
||||
#X86_64_NETBSD_JSON=$(curl --fail "$X86_64_NETBSD_JSON_URL" || exit 1)
|
||||
#export X86_64_NETBSD_TARBALL="$(echo "$X86_64_NETBSD_JSON" | jq .tarball -r)"
|
||||
#export X86_64_NETBSD_BYTESIZE="$(echo "$X86_64_NETBSD_JSON" | jq .size -r)"
|
||||
#export X86_64_NETBSD_SHASUM="$(echo "$X86_64_NETBSD_JSON" | jq .shasum -r)"
|
||||
|
||||
export MASTER_DATE="$(date +%Y-%m-%d)"
|
||||
export MASTER_VERSION="$VERSION"
|
||||
|
||||
# Create index.json and update the website repo.
|
||||
cd "$SRCTARBALLDIR/ci/srht"
|
||||
"$ZIG" run update-download-page.zig
|
||||
CIDIR="$(pwd)"
|
||||
|
||||
cd "$HOME"
|
||||
|
||||
# Update autodocs and langref directly to S3 in order to prevent the
|
||||
# www.ziglang.org git repo from growing too big.
|
||||
|
||||
# Please do not edit this script to pre-compress the artifacts before they hit
|
||||
# S3. This prevents the website from working on browsers that do not support gzip
|
||||
# encoding. Cloudfront will automatically compress files if they are less than
|
||||
# 9.5 MiB, and the client advertises itself as capable of decompressing.
|
||||
# The data.js file is currently 16 MiB. In order to fix this problem, we need to do
|
||||
# one of the following things:
|
||||
# * Reduce the size of data.js to less than 9.5 MiB.
|
||||
# * Figure out how to adjust the Cloudfront settings to increase the max size for
|
||||
# auto-compressed objects.
|
||||
# * Migrate to fastly.
|
||||
$S3CMD put -P --no-mime-magic \
|
||||
--add-header="Cache-Control: max-age=0, must-revalidate" \
|
||||
"$LANGREF" s3://ziglang.org/documentation/master/index.html
|
||||
|
||||
$S3CMD put -P --no-mime-magic \
|
||||
--add-header="Cache-Control: max-age=0, must-revalidate" \
|
||||
"$ZIGDIR/doc/std/index.html" s3://ziglang.org/documentation/master/std/index.html
|
||||
|
||||
$S3CMD put -P --no-mime-magic \
|
||||
--add-header="Cache-Control: max-age=0, must-revalidate" \
|
||||
"$ZIGDIR/doc/std/main.js" s3://ziglang.org/documentation/master/std/main.js
|
||||
|
||||
$S3CMD put -P --no-mime-magic \
|
||||
--add-header="Cache-Control: max-age=0, must-revalidate" \
|
||||
"$ZIGDIR/doc/std/data.js" s3://ziglang.org/documentation/master/std/data.js
|
||||
|
||||
$S3CMD put -P --no-mime-magic --recursive \
|
||||
--add-header="Cache-Control: max-age=0, must-revalidate" \
|
||||
-m "text/html" \
|
||||
"$ZIGDIR/doc/std/src/" s3://ziglang.org/documentation/master/std/src/
|
||||
|
||||
$S3CMD put -P --no-mime-magic \
|
||||
--add-header="cache-control: public, max-age=31536000, immutable" \
|
||||
"$HOME/$SRC_TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
git clone --depth 1 git@github.com:ziglang/www.ziglang.org.git
|
||||
cd www.ziglang.org
|
||||
WWWDIR="$(pwd)"
|
||||
|
||||
cd "$WWWDIR"
|
||||
cp "$CIDIR/out/index.json" data/releases.json
|
||||
git add data/releases.json
|
||||
git commit -m "CI: update releases"
|
||||
git push origin master
|
||||
72
ci/x86_64-linux-debug.sh
Executable file
72
ci/x86_64-linux-debug.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Requires cmake ninja-build
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.971+19056cb68"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-6.1.0.1/bin:$PATH"
|
||||
|
||||
# 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="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-debug
|
||||
mkdir build-debug
|
||||
cd build-debug
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
# 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
|
||||
|
||||
ninja install
|
||||
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-debug/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-debug/bin/zig build -Dtarget=arm-linux-musleabihf
|
||||
|
||||
stage3-debug/bin/zig build test docs \
|
||||
-fqemu \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-debug/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
73
ci/x86_64-linux-release.sh
Executable file
73
ci/x86_64-linux-release.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Requires cmake ninja-build
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.971+19056cb68"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v2.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-6.1.0.1/bin:$PATH"
|
||||
|
||||
# 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="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-release
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
# 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
|
||||
|
||||
ninja install
|
||||
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-release/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug \
|
||||
--exclude ../build-release
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-release/bin/zig build -Dtarget=arm-linux-musleabihf
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
-fqemu \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe "$ZIG_LOCAL_CACHE_DIR/langref.html"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
62
ci/x86_64-macos.sh
Executable file
62
ci/x86_64-macos.sh
Executable file
@@ -0,0 +1,62 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
# Script assumes the presence of the following:
|
||||
# s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
TARGET="$ARCH-macos-none"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.534+b0b1cc356"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
JOBS="-j3"
|
||||
|
||||
rm -rf $PREFIX
|
||||
cd $HOME
|
||||
|
||||
curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
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
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
|
||||
-DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON
|
||||
|
||||
make $JOBS install
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-Denable-macos-sdk \
|
||||
-Dstatic-llvm \
|
||||
-Dskip-non-native \
|
||||
--search-prefix "$PREFIX"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
stage3-release/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
RELEASE_STAGING="$DRONE_WORKSPACE/_release/staging"
|
||||
TARGET="aarch64-macos-none"
|
||||
MCPU="apple_a14"
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/$TARGET"
|
||||
SEARCH_PREFIX="/deps/$TARGET"
|
||||
|
||||
"$RELEASE_STAGING/bin/zig" build \
|
||||
--prefix "$INSTALL_PREFIX" \
|
||||
--search-prefix "$SEARCH_PREFIX" \
|
||||
-Dstatic-llvm \
|
||||
-Drelease \
|
||||
-Dstrip \
|
||||
-Dtarget="$TARGET" \
|
||||
-Dcpu="$MCPU" \
|
||||
-Denable-stage1
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake commands that follow.
|
||||
# This is in its own script because git does not support this command
|
||||
# being run concurrently with itself.
|
||||
git config core.abbrev 9
|
||||
@@ -1,88 +0,0 @@
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: x86_64-linux
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
workspace:
|
||||
path: /workspace
|
||||
|
||||
steps:
|
||||
- name: configure_git
|
||||
image: ci/debian-amd64:11.1-12
|
||||
commands:
|
||||
- ./ci/zinc/configure_git
|
||||
|
||||
- name: test_stage3_debug
|
||||
depends_on:
|
||||
- configure_git
|
||||
image: ci/debian-amd64:11.1-12
|
||||
commands:
|
||||
- ./ci/zinc/linux_test_stage3_debug
|
||||
|
||||
- name: test_stage3_release
|
||||
depends_on:
|
||||
- configure_git
|
||||
image: ci/debian-amd64:11.1-12
|
||||
commands:
|
||||
- ./ci/zinc/linux_test_stage3_release
|
||||
|
||||
- name: build_aarch64_macos
|
||||
depends_on:
|
||||
- test_stage3_release
|
||||
image: ci/debian-amd64:11.1-12
|
||||
commands:
|
||||
- ./ci/zinc/build_aarch64_macos
|
||||
|
||||
- name: linux_package
|
||||
depends_on:
|
||||
- test_stage3_debug
|
||||
- test_stage3_release
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
image: ci/debian-amd64:11.1-12
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: AWS_ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: AWS_SECRET_ACCESS_KEY
|
||||
commands:
|
||||
- ./ci/zinc/linux_package
|
||||
|
||||
- name: macos_package
|
||||
depends_on:
|
||||
- test_stage3_debug
|
||||
- build_aarch64_macos
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
image: ci/debian-amd64:11.1-12
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: AWS_ACCESS_KEY_ID
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
from_secret: AWS_SECRET_ACCESS_KEY
|
||||
commands:
|
||||
- ./ci/zinc/macos_package
|
||||
|
||||
- name: notify_lavahut
|
||||
depends_on:
|
||||
- macos_package
|
||||
- linux_package
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- push
|
||||
image: ci/debian-amd64:11.1-12
|
||||
environment:
|
||||
SRHT_OAUTH_TOKEN:
|
||||
from_secret: SRHT_OAUTH_TOKEN
|
||||
commands:
|
||||
- ./ci/zinc/notify_lavahut
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
OS="linux"
|
||||
RELEASE_STAGING="$DRONE_WORKSPACE/_release/staging"
|
||||
VERSION=$($RELEASE_STAGING/bin/zig version)
|
||||
BASENAME="zig-$OS-$ARCH-$VERSION"
|
||||
TARBALL="$BASENAME.tar.xz"
|
||||
|
||||
# This runs concurrently with the macos_package script, so it should not make
|
||||
# any changes to the filesystem that will cause problems for the other script.
|
||||
|
||||
cp -r "$RELEASE_STAGING" "$BASENAME"
|
||||
|
||||
# Remove the unnecessary bin dir in $prefix/bin/zig
|
||||
mv $BASENAME/bin/zig $BASENAME/
|
||||
rmdir $BASENAME/bin
|
||||
|
||||
# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
|
||||
mv $BASENAME/lib/zig $BASENAME/lib2
|
||||
rmdir $BASENAME/lib
|
||||
mv $BASENAME/lib2 $BASENAME/lib
|
||||
|
||||
tar cfJ "$TARBALL" "$BASENAME"
|
||||
|
||||
SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
MANIFEST="manifest-$TARGET.json"
|
||||
touch $MANIFEST
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$MANIFEST
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$MANIFEST
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$MANIFEST
|
||||
|
||||
# Publish artifact.
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
# Publish manifest.
|
||||
s3cmd put -P --add-header="cache-control: max-age=0, must-revalidate" "$MANIFEST" "s3://ziglang.org/builds/$ARCH-$OS-$VERSION.json"
|
||||
|
||||
# Explicit exit helps show last command duration.
|
||||
exit
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
DEPS_LOCAL="/deps/local"
|
||||
OLD_ZIG="$DEPS_LOCAL/bin/zig"
|
||||
TARGET="${ARCH}-linux-musl"
|
||||
MCPU="baseline"
|
||||
|
||||
export PATH=$DEPS_LOCAL/bin:$PATH
|
||||
|
||||
echo "building stage3-debug with zig version $($OLD_ZIG version)"
|
||||
|
||||
# Override the cache directories so that we don't clobber with the release
|
||||
# testing script which is running concurrently and in the same directory.
|
||||
# Normally we want processes to cooperate, but in this case we want them isolated.
|
||||
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-cache-local-debug"
|
||||
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-cache-global-debug"
|
||||
|
||||
export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
mkdir build-debug
|
||||
cd build-debug
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/stage3" \
|
||||
-DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DZIG_STATIC=ON \
|
||||
-DZIG_USE_LLVM_CONFIG=OFF \
|
||||
-GNinja
|
||||
|
||||
# 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
|
||||
|
||||
ninja install
|
||||
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug \
|
||||
--exclude ../build-release \
|
||||
--exclude "$ZIG_LOCAL_CACHE_DIR" \
|
||||
--exclude "$ZIG_GLOBAL_CACHE_DIR"
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3/bin/zig build -Dtarget=arm-linux-musleabihf
|
||||
|
||||
stage3/bin/zig build test \
|
||||
-fqemu \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$DEPS_LOCAL" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Explicit exit helps show last command duration.
|
||||
exit
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="$(uname -m)"
|
||||
DEPS_LOCAL="/deps/local"
|
||||
RELEASE_STAGING="$DRONE_WORKSPACE/_release/staging"
|
||||
OLD_ZIG="$DEPS_LOCAL/bin/zig"
|
||||
TARGET="${ARCH}-linux-musl"
|
||||
MCPU="baseline"
|
||||
|
||||
export PATH=$DEPS_LOCAL/bin:$PATH
|
||||
|
||||
echo "building stage3-release with zig version $($OLD_ZIG version)"
|
||||
|
||||
export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="$RELEASE_STAGING" \
|
||||
-DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
# 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
|
||||
|
||||
ninja install
|
||||
|
||||
"$RELEASE_STAGING/bin/zig" build test docs \
|
||||
-fqemu \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$DEPS_LOCAL" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p "$RELEASE_STAGING/doc/std"
|
||||
"$RELEASE_STAGING/bin/zig" test ../lib/std/std.zig \
|
||||
-femit-docs=$RELEASE_STAGING/doc/std \
|
||||
-fno-emit-bin \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
cp ../LICENSE $RELEASE_STAGING/
|
||||
cp ../zig-cache/langref.html $RELEASE_STAGING/doc/
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy --drop-empty-elements no -qe $RELEASE_STAGING/doc/langref.html
|
||||
|
||||
# Explicit exit helps show last command duration.
|
||||
exit
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ARCH="aarch64"
|
||||
OS=macos
|
||||
ZIG_PREFIX="$DRONE_WORKSPACE/_release/staging"
|
||||
VERSION=$($ZIG_PREFIX/bin/zig version)
|
||||
TARGET="$ARCH-$OS-none"
|
||||
INSTALL_PREFIX="$DRONE_WORKSPACE/$TARGET"
|
||||
BASENAME="zig-$OS-$ARCH-$VERSION"
|
||||
TARBALL="$BASENAME.tar.xz"
|
||||
|
||||
# This runs concurrently with the linux_package script, so it should not make
|
||||
# any changes to the filesystem that will cause problems for the other script.
|
||||
|
||||
# Remove the unnecessary bin dir in $prefix/bin/zig
|
||||
mv $INSTALL_PREFIX/bin/zig $INSTALL_PREFIX/
|
||||
rmdir $INSTALL_PREFIX/bin
|
||||
|
||||
# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
|
||||
mv $INSTALL_PREFIX/lib/zig $INSTALL_PREFIX/lib2
|
||||
rmdir $INSTALL_PREFIX/lib
|
||||
mv $INSTALL_PREFIX/lib2 $INSTALL_PREFIX/lib
|
||||
|
||||
cp -r "$ZIG_PREFIX/doc" "$INSTALL_PREFIX/"
|
||||
cp "$ZIG_PREFIX/LICENSE" "$INSTALL_PREFIX/"
|
||||
|
||||
mv "$INSTALL_PREFIX" "$BASENAME"
|
||||
tar cfJ "$TARBALL" "$BASENAME"
|
||||
|
||||
SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
MANIFEST="manifest-$TARGET.json"
|
||||
touch $MANIFEST
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$MANIFEST
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$MANIFEST
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$MANIFEST
|
||||
|
||||
# Publish artifact.
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
# Publish manifest.
|
||||
s3cmd put -P --add-header="cache-control: max-age=0, must-revalidate" "$MANIFEST" "s3://ziglang.org/builds/$ARCH-$OS-$VERSION.json"
|
||||
|
||||
# Explicit exit helps show last command duration.
|
||||
exit
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set +x # Avoid leaking oauth token.
|
||||
set -e
|
||||
|
||||
ZIG_PREFIX="$DRONE_WORKSPACE/_release/staging"
|
||||
VERSION=$($ZIG_PREFIX/bin/zig version)
|
||||
cd $DRONE_WORKSPACE
|
||||
./ci/srht/on_master_success "$VERSION" "$SRHT_OAUTH_TOKEN"
|
||||
@@ -79,7 +79,11 @@ if(ZIG_USE_LLVM_CONFIG)
|
||||
OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}")
|
||||
function(NEED_TARGET TARGET_NAME)
|
||||
|
||||
set(ZIG_LLVM_REQUIRED_TARGETS "AArch64;AMDGPU;ARM;AVR;BPF;Hexagon;Lanai;Mips;MSP430;NVPTX;PowerPC;RISCV;Sparc;SystemZ;VE;WebAssembly;X86;XCore")
|
||||
|
||||
set(ZIG_LLVM_REQUIRED_TARGETS_ENABLED TRUE)
|
||||
foreach(TARGET_NAME IN LISTS ZIG_LLVM_REQUIRED_TARGETS)
|
||||
list (FIND LLVM_TARGETS_BUILT "${TARGET_NAME}" _index)
|
||||
if (${_index} EQUAL -1)
|
||||
# Save the error message, in case this is the last llvm-config we find
|
||||
@@ -87,27 +91,13 @@ if(ZIG_USE_LLVM_CONFIG)
|
||||
|
||||
# Ignore this directory and try the search again
|
||||
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||
continue()
|
||||
set(ZIG_LLVM_REQUIRED_TARGETS_ENABLED FALSE)
|
||||
break()
|
||||
endif()
|
||||
endfunction(NEED_TARGET)
|
||||
NEED_TARGET("AArch64")
|
||||
NEED_TARGET("AMDGPU")
|
||||
NEED_TARGET("ARM")
|
||||
NEED_TARGET("AVR")
|
||||
NEED_TARGET("BPF")
|
||||
NEED_TARGET("Hexagon")
|
||||
NEED_TARGET("Lanai")
|
||||
NEED_TARGET("Mips")
|
||||
NEED_TARGET("MSP430")
|
||||
NEED_TARGET("NVPTX")
|
||||
NEED_TARGET("PowerPC")
|
||||
NEED_TARGET("RISCV")
|
||||
NEED_TARGET("Sparc")
|
||||
NEED_TARGET("SystemZ")
|
||||
NEED_TARGET("VE")
|
||||
NEED_TARGET("WebAssembly")
|
||||
NEED_TARGET("X86")
|
||||
NEED_TARGET("XCore")
|
||||
endforeach()
|
||||
if (NOT ZIG_LLVM_REQUIRED_TARGETS_ENABLED)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# Got it!
|
||||
break()
|
||||
|
||||
@@ -536,7 +536,7 @@ const Timestamp = struct {
|
||||
{#header_close#}
|
||||
{#header_open|Top-Level Doc Comments#}
|
||||
<p>User documentation that doesn't belong to whatever
|
||||
immediately follows it, like container-level documentation, goes
|
||||
immediately follows it, like {#link|container|Containers#}-level documentation, goes
|
||||
in top-level doc comments. A top-level doc comment is one that
|
||||
begins with two slashes and an exclamation point:
|
||||
{#syntax#}//!{#endsyntax#}.</p>
|
||||
@@ -575,32 +575,27 @@ pub fn main() void {
|
||||
var optional_value: ?[]const u8 = null;
|
||||
assert(optional_value == null);
|
||||
|
||||
print("\noptional 1\ntype: {s}\nvalue: {?s}\n", .{
|
||||
@typeName(@TypeOf(optional_value)),
|
||||
optional_value,
|
||||
print("\noptional 1\ntype: {}\nvalue: {?s}\n", .{
|
||||
@TypeOf(optional_value), optional_value,
|
||||
});
|
||||
|
||||
optional_value = "hi";
|
||||
assert(optional_value != null);
|
||||
|
||||
print("\noptional 2\ntype: {s}\nvalue: {?s}\n", .{
|
||||
@typeName(@TypeOf(optional_value)),
|
||||
optional_value,
|
||||
print("\noptional 2\ntype: {}\nvalue: {?s}\n", .{
|
||||
@TypeOf(optional_value), optional_value,
|
||||
});
|
||||
|
||||
// error union
|
||||
var number_or_error: anyerror!i32 = error.ArgNotFound;
|
||||
|
||||
print("\nerror union 1\ntype: {s}\nvalue: {!}\n", .{
|
||||
@typeName(@TypeOf(number_or_error)),
|
||||
number_or_error,
|
||||
});
|
||||
print("\nerror union 1\ntype: {}\nvalue: {!}\n", .{
|
||||
@TypeOf(number_or_error), number_or_error, });
|
||||
|
||||
number_or_error = 1234;
|
||||
|
||||
print("\nerror union 2\ntype: {s}\nvalue: {!}\n", .{
|
||||
@typeName(@TypeOf(number_or_error)),
|
||||
number_or_error,
|
||||
print("\nerror union 2\ntype: {}\nvalue: {!}\n", .{
|
||||
@TypeOf(number_or_error), number_or_error,
|
||||
});
|
||||
}
|
||||
{#code_end#}
|
||||
@@ -859,7 +854,7 @@ const mem = @import("std").mem; // will be used to compare bytes
|
||||
|
||||
pub fn main() void {
|
||||
const bytes = "hello";
|
||||
print("{s}\n", .{@typeName(@TypeOf(bytes))}); // *const [5:0]u8
|
||||
print("{}\n", .{@TypeOf(bytes)}); // *const [5:0]u8
|
||||
print("{d}\n", .{bytes.len}); // 5
|
||||
print("{c}\n", .{bytes[1]}); // 'e'
|
||||
print("{d}\n", .{bytes[5]}); // 0
|
||||
@@ -1085,7 +1080,7 @@ fn addOne(number: i32) i32 {
|
||||
<p>
|
||||
When the <kbd>zig test</kbd> tool is building a test runner, only resolved {#syntax#}test{#endsyntax#}
|
||||
declarations are included in the build. Initially, only the given Zig source file's top-level
|
||||
declarations are resolved. Unless nested containers are referenced from a top-level test declaration,
|
||||
declarations are resolved. Unless nested {#link|containers|Containers#} are referenced from a top-level test declaration,
|
||||
nested container tests will not be resolved.
|
||||
</p>
|
||||
<p>
|
||||
@@ -1333,7 +1328,7 @@ const color: Color = .@"really red";
|
||||
|
||||
{#header_open|Container Level Variables#}
|
||||
<p>
|
||||
Container level variables have static lifetime and are order-independent and lazily analyzed.
|
||||
{#link|Container|Containers#} level variables have static lifetime and are order-independent and lazily analyzed.
|
||||
The initialization value of container level variables is implicitly
|
||||
{#link|comptime#}. If a container level variable is {#syntax#}const{#endsyntax#} then its value is
|
||||
{#syntax#}comptime{#endsyntax#}-known, otherwise it is runtime-known.
|
||||
@@ -1355,7 +1350,7 @@ const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
{#code_end#}
|
||||
<p>
|
||||
Container level variables may be declared inside a {#link|struct#}, {#link|union#}, or {#link|enum#}:
|
||||
Container level variables may be declared inside a {#link|struct#}, {#link|union#}, {#link|enum#}, or {#link|opaque#}:
|
||||
</p>
|
||||
{#code_begin|test|namespaced_container_level_variable#}
|
||||
const std = @import("std");
|
||||
@@ -3282,7 +3277,7 @@ test "default struct initialization fields" {
|
||||
Unlike normal structs, {#syntax#}packed{#endsyntax#} structs have guaranteed in-memory layout:
|
||||
</p>
|
||||
<ul>
|
||||
<li>Fields remain in the order declared.</li>
|
||||
<li>Fields remain in the order declared, least to most significant.</li>
|
||||
<li>There is no padding between fields.</li>
|
||||
<li>Zig supports arbitrary width {#link|Integers#} and although normally, integers with fewer
|
||||
than 8 bits will still use 1 byte of memory, in packed structs, they use
|
||||
@@ -3325,16 +3320,19 @@ fn doTheTest() !void {
|
||||
try expect(@sizeOf(Divided) == 2);
|
||||
var full = Full{ .number = 0x1234 };
|
||||
var divided = @bitCast(Divided, full);
|
||||
try expect(divided.half1 == 0x34);
|
||||
try expect(divided.quarter3 == 0x2);
|
||||
try expect(divided.quarter4 == 0x1);
|
||||
|
||||
var ordered = @bitCast([2]u8, full);
|
||||
switch (native_endian) {
|
||||
.Big => {
|
||||
try expect(divided.half1 == 0x12);
|
||||
try expect(divided.quarter3 == 0x3);
|
||||
try expect(divided.quarter4 == 0x4);
|
||||
try expect(ordered[0] == 0x12);
|
||||
try expect(ordered[1] == 0x34);
|
||||
},
|
||||
.Little => {
|
||||
try expect(divided.half1 == 0x34);
|
||||
try expect(divided.quarter3 == 0x2);
|
||||
try expect(divided.quarter4 == 0x1);
|
||||
try expect(ordered[0] == 0x34);
|
||||
try expect(ordered[1] == 0x12);
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -7031,8 +7029,7 @@ test "fibonacci" {
|
||||
undefined behavior, which is always a compile error if the compiler knows it happened.
|
||||
But what would have happened if we used a signed integer?
|
||||
</p>
|
||||
{#code_begin|test_err|evaluation exceeded 1000 backwards branches#}
|
||||
{#backend_stage1#}
|
||||
{#code_begin|syntax#}
|
||||
const assert = @import("std").debug.assert;
|
||||
|
||||
fn fibonacci(index: i32) i32 {
|
||||
@@ -7047,13 +7044,22 @@ test "fibonacci" {
|
||||
}
|
||||
{#code_end#}
|
||||
<p>
|
||||
The compiler noticed that evaluating this function at compile-time took a long time,
|
||||
and thus emitted a compile error and gave up. If the programmer wants to increase
|
||||
the budget for compile-time computation, they can use a built-in function called
|
||||
{#link|@setEvalBranchQuota#} to change the default number 1000 to something else.
|
||||
The compiler is supposed to notice that evaluating this function at
|
||||
compile-time took more than 1000 branches, and thus emits an error and
|
||||
gives up. If the programmer wants to increase the budget for compile-time
|
||||
computation, they can use a built-in function called
|
||||
{#link|@setEvalBranchQuota#} to change the default number 1000 to
|
||||
something else.
|
||||
</p>
|
||||
<p>
|
||||
What if we fix the base case, but put the wrong value in the {#syntax#}expect{#endsyntax#} line?
|
||||
However, there is a <a href="https://github.com/ziglang/zig/issues/13724">design
|
||||
flaw in the compiler</a> causing it to stack overflow instead of having the proper
|
||||
behavior here. I'm terribly sorry about that. I hope to get this resolved
|
||||
before the next release.
|
||||
</p>
|
||||
<p>
|
||||
What if we fix the base case, but put the wrong value in the
|
||||
{#syntax#}expect{#endsyntax#} line?
|
||||
</p>
|
||||
{#code_begin|test_err|reached unreachable#}
|
||||
const assert = @import("std").debug.assert;
|
||||
@@ -7071,7 +7077,7 @@ test "fibonacci" {
|
||||
{#code_end#}
|
||||
|
||||
<p>
|
||||
At container level (outside of any function), all expressions are implicitly
|
||||
At {#link|container|Containers#} level (outside of any function), all expressions are implicitly
|
||||
{#syntax#}comptime{#endsyntax#} expressions. This means that we can use functions to
|
||||
initialize complex static data. For example:
|
||||
</p>
|
||||
@@ -7543,7 +7549,7 @@ volatile (
|
||||
|
||||
{#header_open|Global Assembly#}
|
||||
<p>
|
||||
When an assembly expression occurs in a container level {#link|comptime#} block, this is
|
||||
When an assembly expression occurs in a {#link|container|Containers#} level {#link|comptime#} block, this is
|
||||
<strong>global assembly</strong>.
|
||||
</p>
|
||||
<p>
|
||||
@@ -8848,7 +8854,7 @@ fn func() void {
|
||||
{#header_open|@hasDecl#}
|
||||
<pre>{#syntax#}@hasDecl(comptime Container: type, comptime name: []const u8) bool{#endsyntax#}</pre>
|
||||
<p>
|
||||
Returns whether or not a {#link|struct#}, {#link|enum#}, or {#link|union#} has a declaration
|
||||
Returns whether or not a {#link|container|Containers#} has a declaration
|
||||
matching {#syntax#}name{#endsyntax#}.
|
||||
</p>
|
||||
{#code_begin|test|hasDecl#}
|
||||
@@ -12441,6 +12447,19 @@ fn readU32Be() u32 {}
|
||||
</div>
|
||||
{#header_close#}
|
||||
|
||||
{#header_open|Appendix#}
|
||||
{#header_open|Containers#}
|
||||
<p>
|
||||
A <em>container</em> in Zig is any syntactical construct that acts as a namespace to hold {#link|variable|Container Level Variables#} and {#link|function|Functions#} declarations.
|
||||
Containers are also type definitions which can be instantiated.
|
||||
{#link|Structs|struct#}, {#link|enums|enum#}, {#link|unions|union#}, {#link|opaques|opaque#}, and even Zig source files themselves are containers.
|
||||
</p>
|
||||
<p>
|
||||
Although containers (except Zig source files) use curly braces to surround their definition, they should not be confused with {#link|blocks|Blocks#} or functions.
|
||||
Containers do not contain statements.
|
||||
</p>
|
||||
{#header_close#}
|
||||
|
||||
{#header_open|Grammar#}
|
||||
{#syntax_block|peg|grammar.y#}Root <- skip container_doc_comment? ContainerMembers eof
|
||||
|
||||
@@ -13006,6 +13025,7 @@ keyword <- KEYWORD_align / KEYWORD_allowzero / KEYWORD_and / KEYWORD_anyframe
|
||||
<li>Together we serve the users.</li>
|
||||
</ul>
|
||||
{#header_close#}
|
||||
{#header_close#}
|
||||
</main></div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -142,6 +142,8 @@ pub fn main() !void {
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
try debug_log_scopes.append(next_arg);
|
||||
} else if (mem.eql(u8, arg, "--debug-compile-errors")) {
|
||||
builder.debug_compile_errors = true;
|
||||
} else if (mem.eql(u8, arg, "--glibc-runtimes")) {
|
||||
builder.glibc_runtimes_dir = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after --glibc-runtimes\n\n", .{});
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const panic = @import("compiler_rt/common.zig").panic;
|
||||
|
||||
comptime {
|
||||
_ = @import("compiler_rt/atomics.zig");
|
||||
|
||||
// macOS has these functions inside libSystem.
|
||||
if (builtin.cpu.arch.isAARCH64() and !builtin.os.tag.isDarwin()) {
|
||||
_ = @import("compiler_rt/aarch64_outline_atomics.zig");
|
||||
}
|
||||
|
||||
_ = @import("compiler_rt/addf3.zig");
|
||||
_ = @import("compiler_rt/addhf3.zig");
|
||||
_ = @import("compiler_rt/addsf3.zig");
|
||||
|
||||
2227
lib/compiler_rt/aarch64_outline_atomics.zig
Normal file
2227
lib/compiler_rt/aarch64_outline_atomics.zig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@ pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.gnu_f16_abi) {
|
||||
@export(__extendhfsf2, .{ .name = "__gnu_h2f_ieee", .linkage = common.linkage });
|
||||
@export(__gnu_h2f_ieee, .{ .name = "__gnu_h2f_ieee", .linkage = common.linkage });
|
||||
} else if (common.want_aeabi) {
|
||||
@export(__aeabi_h2f, .{ .name = "__aeabi_h2f", .linkage = common.linkage });
|
||||
}
|
||||
@@ -16,6 +16,10 @@ pub fn __extendhfsf2(a: common.F16T) callconv(.C) f32 {
|
||||
return extendf(f32, f16, @bitCast(u16, a));
|
||||
}
|
||||
|
||||
fn __gnu_h2f_ieee(a: common.F16T) callconv(.C) f32 {
|
||||
return extendf(f32, f16, @bitCast(u16, a));
|
||||
}
|
||||
|
||||
fn __aeabi_h2f(a: u16) callconv(.AAPCS) f32 {
|
||||
return extendf(f32, f16, @bitCast(u16, a));
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ comptime {
|
||||
if (is_mingw) {
|
||||
@export(_chkstk, .{ .name = "_alloca", .linkage = strong_linkage });
|
||||
@export(___chkstk_ms, .{ .name = "___chkstk_ms", .linkage = strong_linkage });
|
||||
|
||||
if (arch.isAARCH64()) {
|
||||
@export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage });
|
||||
}
|
||||
} else if (!builtin.link_libc) {
|
||||
// This symbols are otherwise exported by MSVCRT.lib
|
||||
@export(_chkstk, .{ .name = "_chkstk", .linkage = strong_linkage });
|
||||
@export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage });
|
||||
}
|
||||
|
||||
if (arch.isAARCH64()) {
|
||||
@export(__chkstk, .{ .name = "__chkstk", .linkage = strong_linkage });
|
||||
}
|
||||
}
|
||||
|
||||
switch (arch) {
|
||||
|
||||
@@ -5,7 +5,7 @@ pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.gnu_f16_abi) {
|
||||
@export(__truncsfhf2, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage });
|
||||
@export(__gnu_f2h_ieee, .{ .name = "__gnu_f2h_ieee", .linkage = common.linkage });
|
||||
} else if (common.want_aeabi) {
|
||||
@export(__aeabi_f2h, .{ .name = "__aeabi_f2h", .linkage = common.linkage });
|
||||
}
|
||||
@@ -16,6 +16,10 @@ pub fn __truncsfhf2(a: f32) callconv(.C) common.F16T {
|
||||
return @bitCast(common.F16T, truncf(f16, f32, a));
|
||||
}
|
||||
|
||||
fn __gnu_f2h_ieee(a: f32) callconv(.C) common.F16T {
|
||||
return @bitCast(common.F16T, truncf(f16, f32, a));
|
||||
}
|
||||
|
||||
fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {
|
||||
return @bitCast(common.F16T, truncf(f16, f32, a));
|
||||
}
|
||||
|
||||
59
lib/libc/glibc/sysdeps/arm/arm-features.h
vendored
Normal file
59
lib/libc/glibc/sysdeps/arm/arm-features.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Macros to test for CPU features on ARM. Generic ARM version.
|
||||
Copyright (C) 2012-2022 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library. If not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _ARM_ARM_FEATURES_H
|
||||
#define _ARM_ARM_FEATURES_H 1
|
||||
|
||||
/* An OS-specific arm-features.h file should define ARM_HAVE_VFP to
|
||||
an appropriate expression for testing at runtime whether the VFP
|
||||
hardware is present. We'll then redefine it to a constant if we
|
||||
know at compile time that we can assume VFP. */
|
||||
|
||||
#ifndef __SOFTFP__
|
||||
/* The compiler is generating VFP instructions, so we're already
|
||||
assuming the hardware exists. */
|
||||
# undef ARM_HAVE_VFP
|
||||
# define ARM_HAVE_VFP 1
|
||||
#endif
|
||||
|
||||
/* An OS-specific arm-features.h file may define ARM_ASSUME_NO_IWMMXT
|
||||
to indicate at compile time that iWMMXt hardware is never present
|
||||
at runtime (or that we never care about its state) and so need not
|
||||
be checked for. */
|
||||
|
||||
/* A more-specific arm-features.h file may define ARM_ALWAYS_BX to indicate
|
||||
that instructions using pc as a destination register must never be used,
|
||||
so a "bx" (or "blx") instruction is always required. */
|
||||
|
||||
/* The log2 of the minimum alignment required for an address that
|
||||
is the target of a computed branch (i.e. a "bx" instruction).
|
||||
A more-specific arm-features.h file may define this to set a more
|
||||
stringent requirement.
|
||||
|
||||
Using this only makes sense for code in ARM mode (where instructions
|
||||
always have a fixed size of four bytes), or for Thumb-mode code that is
|
||||
specifically aligning all the related branch targets to match (since
|
||||
Thumb instructions might be either two or four bytes). */
|
||||
#ifndef ARM_BX_ALIGN_LOG2
|
||||
# define ARM_BX_ALIGN_LOG2 2
|
||||
#endif
|
||||
|
||||
/* An OS-specific arm-features.h file may define ARM_NO_INDEX_REGISTER to
|
||||
indicate that the two-register addressing modes must never be used. */
|
||||
|
||||
#endif /* arm-features.h */
|
||||
86
lib/libc/mingw/stdio/_vscprintf.c
vendored
Normal file
86
lib/libc/mingw/stdio/_vscprintf.c
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* emulation of _vscprintf() via _vsnprintf() */
|
||||
static int __cdecl emu_vscprintf(const char * __restrict__ format, va_list arglist)
|
||||
{
|
||||
char *buffer, *new_buffer;
|
||||
size_t size;
|
||||
int ret;
|
||||
|
||||
/* if format is a null pointer, _vscprintf() returns -1 and sets errno to EINVAL */
|
||||
if (!format) {
|
||||
_set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* size for _vsnprintf() must be non-zero and buffer must have place for terminating null character */
|
||||
size = strlen(format) * 2 + 1;
|
||||
buffer = malloc(size);
|
||||
|
||||
if (!buffer) {
|
||||
_set_errno(ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* if the number of characters to write is greater than size, _vsnprintf() returns -1 */
|
||||
while (size < SIZE_MAX/2 && (ret = _vsnprintf(buffer, size, format, arglist)) < 0) {
|
||||
/* in this case try with larger buffer */
|
||||
size *= 2;
|
||||
new_buffer = realloc(buffer, size);
|
||||
if (!new_buffer)
|
||||
break;
|
||||
buffer = new_buffer;
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
|
||||
if (ret < 0) {
|
||||
_set_errno(ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifndef __LIBMSVCRT_OS__
|
||||
|
||||
int (__cdecl *__MINGW_IMP_SYMBOL(_vscprintf))(const char * __restrict__, va_list) = emu_vscprintf;
|
||||
|
||||
#else
|
||||
|
||||
#include <msvcrt.h>
|
||||
|
||||
static int __cdecl init_vscprintf(const char * __restrict__ format, va_list arglist);
|
||||
|
||||
int (__cdecl *__MINGW_IMP_SYMBOL(_vscprintf))(const char * __restrict__, va_list) = init_vscprintf;
|
||||
|
||||
static int __cdecl init_vscprintf(const char * __restrict__ format, va_list arglist)
|
||||
{
|
||||
HMODULE msvcrt = __mingw_get_msvcrt_handle();
|
||||
int (__cdecl *func)(const char * __restrict__, va_list) = NULL;
|
||||
|
||||
if (msvcrt)
|
||||
func = (int (__cdecl *)(const char * __restrict__, va_list))GetProcAddress(msvcrt, "_vscprintf");
|
||||
|
||||
if (!func)
|
||||
func = emu_vscprintf;
|
||||
|
||||
return (__MINGW_IMP_SYMBOL(_vscprintf) = func)(format, arglist);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int __cdecl _vscprintf(const char * __restrict__ format, va_list arglist)
|
||||
{
|
||||
return __MINGW_IMP_SYMBOL(_vscprintf)(format, arglist);
|
||||
}
|
||||
11
lib/libcxx/include/__config
vendored
11
lib/libcxx/include/__config
vendored
@@ -148,7 +148,7 @@
|
||||
# endif
|
||||
// Feature macros for disabling pre ABI v1 features. All of these options
|
||||
// are deprecated.
|
||||
# if defined(__FreeBSD__)
|
||||
# if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
|
||||
# endif
|
||||
# endif
|
||||
@@ -726,11 +726,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
|
||||
# endif // _LIBCPP_CXX03_LANG
|
||||
|
||||
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \
|
||||
defined(__NetBSD__)
|
||||
defined(__NetBSD__) || defined(__DragonFly__)
|
||||
# define _LIBCPP_LOCALE__L_EXTENSIONS 1
|
||||
# endif
|
||||
|
||||
# ifdef __FreeBSD__
|
||||
# if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
# define _DECLARE_C99_LDBL_MATH 1
|
||||
# endif
|
||||
|
||||
@@ -750,11 +750,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
|
||||
# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
|
||||
# endif
|
||||
|
||||
# if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
# define _LIBCPP_HAS_DEFAULTRUNELOCALE
|
||||
# endif
|
||||
|
||||
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)
|
||||
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) || defined(__DragonFly__)
|
||||
# define _LIBCPP_WCTYPE_IS_MASK
|
||||
# endif
|
||||
|
||||
@@ -901,6 +901,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
# if defined(__FreeBSD__) || \
|
||||
defined(__wasi__) || \
|
||||
defined(__DragonFly__) || \
|
||||
defined(__NetBSD__) || \
|
||||
defined(__OpenBSD__) || \
|
||||
defined(__NuttX__) || \
|
||||
|
||||
6
lib/libcxx/include/__locale
vendored
6
lib/libcxx/include/__locale
vendored
@@ -33,7 +33,7 @@
|
||||
# include <__support/newlib/xlocale.h>
|
||||
#elif defined(__OpenBSD__)
|
||||
# include <__support/openbsd/xlocale.h>
|
||||
#elif (defined(__APPLE__) || defined(__FreeBSD__))
|
||||
#elif (defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__))
|
||||
# include <xlocale.h>
|
||||
#elif defined(__Fuchsia__)
|
||||
# include <__support/fuchsia/xlocale.h>
|
||||
@@ -453,10 +453,10 @@ public:
|
||||
static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
|
||||
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
|
||||
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__DragonFly__)
|
||||
# ifdef __APPLE__
|
||||
typedef __uint32_t mask;
|
||||
# elif defined(__FreeBSD__)
|
||||
# elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
typedef unsigned long mask;
|
||||
# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
|
||||
typedef unsigned short mask;
|
||||
|
||||
2
lib/libcxx/include/locale
vendored
2
lib/libcxx/include/locale
vendored
@@ -239,7 +239,7 @@ _LIBCPP_PUSH_MACROS
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
# define _LIBCPP_GET_C_LOCALE 0
|
||||
#elif defined(__NetBSD__)
|
||||
# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
|
||||
|
||||
2
lib/libcxx/src/locale.cpp
vendored
2
lib/libcxx/src/locale.cpp
vendored
@@ -1190,7 +1190,7 @@ ctype<char>::classic_table() noexcept
|
||||
const ctype<char>::mask*
|
||||
ctype<char>::classic_table() noexcept
|
||||
{
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
return _DefaultRuneLocale.__runetype;
|
||||
#elif defined(__NetBSD__)
|
||||
return _C_ctype_tab_ + 1;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
//! defer m.unlock();
|
||||
//!
|
||||
//! while (!predicate) {
|
||||
//! c.wait(&mutex);
|
||||
//! c.wait(&m);
|
||||
//! }
|
||||
//! }
|
||||
//!
|
||||
@@ -194,42 +194,27 @@ const FutexImpl = struct {
|
||||
const signal_mask = 0xffff << 16;
|
||||
|
||||
fn wait(self: *Impl, mutex: *Mutex, timeout: ?u64) error{Timeout}!void {
|
||||
// Register that we're waiting on the state by incrementing the wait count.
|
||||
// This assumes that there can be at most ((1<<16)-1) or 65,355 threads concurrently waiting on the same Condvar.
|
||||
// If this is hit in practice, then this condvar not working is the least of your concerns.
|
||||
// Observe the epoch, then check the state again to see if we should wake up.
|
||||
// The epoch must be observed before we check the state or we could potentially miss a wake() and deadlock:
|
||||
//
|
||||
// - T1: s = LOAD(&state)
|
||||
// - T2: UPDATE(&s, signal)
|
||||
// - T2: UPDATE(&epoch, 1) + FUTEX_WAKE(&epoch)
|
||||
// - T1: e = LOAD(&epoch) (was reordered after the state load)
|
||||
// - T1: s & signals == 0 -> FUTEX_WAIT(&epoch, e) (missed the state update + the epoch change)
|
||||
//
|
||||
// Acquire barrier to ensure the epoch load happens before the state load.
|
||||
var epoch = self.epoch.load(.Acquire);
|
||||
var state = self.state.fetchAdd(one_waiter, .Monotonic);
|
||||
assert(state & waiter_mask != waiter_mask);
|
||||
state += one_waiter;
|
||||
|
||||
// Temporarily release the mutex in order to block on the condition variable.
|
||||
mutex.unlock();
|
||||
defer mutex.lock();
|
||||
|
||||
var futex_deadline = Futex.Deadline.init(timeout);
|
||||
|
||||
while (true) {
|
||||
// Try to wake up by consuming a signal and decremented the waiter we added previously.
|
||||
// Acquire barrier ensures code before the wake() which added the signal happens before we decrement it and return.
|
||||
while (state & signal_mask != 0) {
|
||||
const new_state = state - one_waiter - one_signal;
|
||||
state = self.state.tryCompareAndSwap(state, new_state, .Acquire, .Monotonic) orelse return;
|
||||
}
|
||||
|
||||
// Observe the epoch, then check the state again to see if we should wake up.
|
||||
// The epoch must be observed before we check the state or we could potentially miss a wake() and deadlock:
|
||||
//
|
||||
// - T1: s = LOAD(&state)
|
||||
// - T2: UPDATE(&s, signal)
|
||||
// - T2: UPDATE(&epoch, 1) + FUTEX_WAKE(&epoch)
|
||||
// - T1: e = LOAD(&epoch) (was reordered after the state load)
|
||||
// - T1: s & signals == 0 -> FUTEX_WAIT(&epoch, e) (missed the state update + the epoch change)
|
||||
//
|
||||
// Acquire barrier to ensure the epoch load happens before the state load.
|
||||
const epoch = self.epoch.load(.Acquire);
|
||||
state = self.state.load(.Monotonic);
|
||||
if (state & signal_mask != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
futex_deadline.wait(&self.epoch, epoch) catch |err| switch (err) {
|
||||
// On timeout, we must decrement the waiter we added above.
|
||||
error.Timeout => {
|
||||
@@ -247,6 +232,16 @@ const FutexImpl = struct {
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
epoch = self.epoch.load(.Acquire);
|
||||
state = self.state.load(.Monotonic);
|
||||
|
||||
// Try to wake up by consuming a signal and decremented the waiter we added previously.
|
||||
// Acquire barrier ensures code before the wake() which added the signal happens before we decrement it and return.
|
||||
while (state & signal_mask != 0) {
|
||||
const new_state = state - one_waiter - one_signal;
|
||||
state = self.state.tryCompareAndSwap(state, new_state, .Acquire, .Monotonic) orelse return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,3 +531,76 @@ test "Condition - broadcasting" {
|
||||
t.join();
|
||||
}
|
||||
}
|
||||
|
||||
test "Condition - broadcasting - wake all threads" {
|
||||
// Tests issue #12877
|
||||
// This test requires spawning threads
|
||||
if (builtin.single_threaded) {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
var num_runs: usize = 1;
|
||||
const num_threads = 10;
|
||||
|
||||
while (num_runs > 0) : (num_runs -= 1) {
|
||||
const BroadcastTest = struct {
|
||||
mutex: Mutex = .{},
|
||||
cond: Condition = .{},
|
||||
completed: Condition = .{},
|
||||
count: usize = 0,
|
||||
thread_id_to_wake: usize = 0,
|
||||
threads: [num_threads]std.Thread = undefined,
|
||||
wakeups: usize = 0,
|
||||
|
||||
fn run(self: *@This(), thread_id: usize) void {
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
|
||||
// The last broadcast thread to start tells the main test thread it's completed.
|
||||
self.count += 1;
|
||||
if (self.count == num_threads) {
|
||||
self.completed.signal();
|
||||
}
|
||||
|
||||
while (self.thread_id_to_wake != thread_id) {
|
||||
self.cond.timedWait(&self.mutex, 1 * std.time.ns_per_s) catch std.debug.panic("thread_id {d} timeout {d}", .{ thread_id, self.thread_id_to_wake });
|
||||
self.wakeups += 1;
|
||||
}
|
||||
if (self.thread_id_to_wake <= num_threads) {
|
||||
// Signal next thread to wake up.
|
||||
self.thread_id_to_wake += 1;
|
||||
self.cond.broadcast();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var broadcast_test = BroadcastTest{};
|
||||
var thread_id: usize = 1;
|
||||
for (broadcast_test.threads) |*t| {
|
||||
t.* = try std.Thread.spawn(.{}, BroadcastTest.run, .{ &broadcast_test, thread_id });
|
||||
thread_id += 1;
|
||||
}
|
||||
|
||||
{
|
||||
broadcast_test.mutex.lock();
|
||||
defer broadcast_test.mutex.unlock();
|
||||
|
||||
// Wait for all the broadcast threads to spawn.
|
||||
// timedWait() to detect any potential deadlocks.
|
||||
while (broadcast_test.count != num_threads) {
|
||||
try broadcast_test.completed.timedWait(
|
||||
&broadcast_test.mutex,
|
||||
1 * std.time.ns_per_s,
|
||||
);
|
||||
}
|
||||
|
||||
// Signal thread 1 to wake up
|
||||
broadcast_test.thread_id_to_wake = 1;
|
||||
broadcast_test.cond.broadcast();
|
||||
}
|
||||
|
||||
for (broadcast_test.threads) |t| {
|
||||
t.join();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,7 +721,7 @@ const PosixImpl = struct {
|
||||
// then cut off the zero bits from the alignment to get the unique address.
|
||||
const addr = @ptrToInt(ptr);
|
||||
assert(addr & (alignment - 1) == 0);
|
||||
return addr >> @ctz(alignment);
|
||||
return addr >> @ctz(@as(usize, alignment));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -116,6 +116,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
|
||||
|
||||
/// Insert `item` at index `n` by moving `list[n .. list.len]` to make room.
|
||||
/// This operation is O(N).
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn insert(self: *Self, n: usize, item: T) Allocator.Error!void {
|
||||
try self.ensureUnusedCapacity(1);
|
||||
self.items.len += 1;
|
||||
@@ -126,6 +127,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
|
||||
|
||||
/// Insert slice `items` at index `i` by moving `list[i .. list.len]` to make room.
|
||||
/// This operation is O(N).
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn insertSlice(self: *Self, i: usize, items: []const T) Allocator.Error!void {
|
||||
try self.ensureUnusedCapacity(items.len);
|
||||
self.items.len += items.len;
|
||||
@@ -163,6 +165,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
|
||||
}
|
||||
|
||||
/// Extend the list by 1 element. Allocates more memory as necessary.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn append(self: *Self, item: T) Allocator.Error!void {
|
||||
const new_item_ptr = try self.addOne();
|
||||
new_item_ptr.* = item;
|
||||
@@ -205,6 +208,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
|
||||
|
||||
/// Append the slice of items to the list. Allocates more
|
||||
/// memory as necessary.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn appendSlice(self: *Self, items: []const T) Allocator.Error!void {
|
||||
try self.ensureUnusedCapacity(items.len);
|
||||
self.appendSliceAssumeCapacity(items);
|
||||
@@ -223,6 +227,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
|
||||
/// Append an unaligned slice of items to the list. Allocates more
|
||||
/// memory as necessary. Only call this function if calling
|
||||
/// `appendSlice` instead would be a compile error.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn appendUnalignedSlice(self: *Self, items: []align(1) const T) Allocator.Error!void {
|
||||
try self.ensureUnusedCapacity(items.len);
|
||||
self.appendUnalignedSliceAssumeCapacity(items);
|
||||
@@ -257,6 +262,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
|
||||
|
||||
/// 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.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
fn appendWrite(self: *Self, m: []const u8) Allocator.Error!usize {
|
||||
try self.appendSlice(m);
|
||||
return m.len;
|
||||
@@ -264,6 +270,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
|
||||
|
||||
/// Append a value to the list `n` times.
|
||||
/// Allocates more memory as necessary.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn appendNTimes(self: *Self, value: T, n: usize) Allocator.Error!void {
|
||||
const old_len = self.items.len;
|
||||
try self.resize(self.items.len + n);
|
||||
@@ -281,6 +288,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
|
||||
|
||||
/// Adjust the list's length to `new_len`.
|
||||
/// Does not initialize added items if any.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn resize(self: *Self, new_len: usize) Allocator.Error!void {
|
||||
try self.ensureTotalCapacity(new_len);
|
||||
self.items.len = new_len;
|
||||
@@ -527,6 +535,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
|
||||
/// Insert `item` at index `n`. Moves `list[n .. list.len]`
|
||||
/// to higher indices to make room.
|
||||
/// This operation is O(N).
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn insert(self: *Self, allocator: Allocator, n: usize, item: T) Allocator.Error!void {
|
||||
try self.ensureUnusedCapacity(allocator, 1);
|
||||
self.items.len += 1;
|
||||
@@ -538,6 +547,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
|
||||
/// Insert slice `items` at index `i`. Moves `list[i .. list.len]` to
|
||||
/// higher indicices make room.
|
||||
/// This operation is O(N).
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn insertSlice(self: *Self, allocator: Allocator, i: usize, items: []const T) Allocator.Error!void {
|
||||
try self.ensureUnusedCapacity(allocator, items.len);
|
||||
self.items.len += items.len;
|
||||
@@ -557,6 +567,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
|
||||
}
|
||||
|
||||
/// Extend the list by 1 element. Allocates more memory as necessary.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn append(self: *Self, allocator: Allocator, item: T) Allocator.Error!void {
|
||||
const new_item_ptr = try self.addOne(allocator);
|
||||
new_item_ptr.* = item;
|
||||
@@ -598,6 +609,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
|
||||
|
||||
/// Append the slice of items to the list. Allocates more
|
||||
/// memory as necessary.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn appendSlice(self: *Self, allocator: Allocator, items: []const T) Allocator.Error!void {
|
||||
try self.ensureUnusedCapacity(allocator, items.len);
|
||||
self.appendSliceAssumeCapacity(items);
|
||||
@@ -616,6 +628,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
|
||||
/// Append the slice of items to the list. Allocates more
|
||||
/// memory as necessary. Only call this function if a call to `appendSlice` instead would
|
||||
/// be a compile error.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn appendUnalignedSlice(self: *Self, allocator: Allocator, items: []align(1) const T) Allocator.Error!void {
|
||||
try self.ensureUnusedCapacity(allocator, items.len);
|
||||
self.appendUnalignedSliceAssumeCapacity(items);
|
||||
@@ -654,6 +667,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
|
||||
|
||||
/// 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.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
fn appendWrite(context: WriterContext, m: []const u8) Allocator.Error!usize {
|
||||
try context.self.appendSlice(context.allocator, m);
|
||||
return m.len;
|
||||
@@ -661,6 +675,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
|
||||
|
||||
/// Append a value to the list `n` times.
|
||||
/// Allocates more memory as necessary.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn appendNTimes(self: *Self, allocator: Allocator, value: T, n: usize) Allocator.Error!void {
|
||||
const old_len = self.items.len;
|
||||
try self.resize(allocator, self.items.len + n);
|
||||
@@ -679,6 +694,7 @@ 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.
|
||||
/// Invalidates pointers if additional memory is needed.
|
||||
pub fn resize(self: *Self, allocator: Allocator, new_len: usize) Allocator.Error!void {
|
||||
try self.ensureTotalCapacity(allocator, new_len);
|
||||
self.items.len = new_len;
|
||||
|
||||
@@ -64,6 +64,8 @@ pub fn Queue(comptime T: type) type {
|
||||
return head;
|
||||
}
|
||||
|
||||
/// Prepends `node` to the front of the queue.
|
||||
/// The lifetime of `node` must be longer than the lifetime of the queue.
|
||||
pub fn unget(self: *Self, node: *Node) void {
|
||||
node.prev = null;
|
||||
|
||||
@@ -72,8 +74,8 @@ pub fn Queue(comptime T: type) type {
|
||||
|
||||
const opt_head = self.head;
|
||||
self.head = node;
|
||||
if (opt_head) |head| {
|
||||
head.next = node;
|
||||
if (opt_head) |old_head| {
|
||||
node.next = old_head;
|
||||
} else {
|
||||
assert(self.tail == null);
|
||||
self.tail = node;
|
||||
@@ -330,11 +332,25 @@ test "std.atomic.Queue single-threaded" {
|
||||
node_3.next = null;
|
||||
try expect(!queue.isEmpty());
|
||||
|
||||
queue.unget(&node_3);
|
||||
try expect(queue.get().?.data == 3);
|
||||
try expect(!queue.isEmpty());
|
||||
|
||||
try expect(queue.get().?.data == 4);
|
||||
try expect(queue.isEmpty());
|
||||
|
||||
try expect(queue.get() == null);
|
||||
try expect(queue.isEmpty());
|
||||
|
||||
// unget an empty queue
|
||||
queue.unget(&node_4);
|
||||
try expect(queue.tail == &node_4);
|
||||
try expect(queue.head == &node_4);
|
||||
|
||||
try expect(queue.get().?.data == 4);
|
||||
|
||||
try expect(queue.get() == null);
|
||||
try expect(queue.isEmpty());
|
||||
}
|
||||
|
||||
test "std.atomic.Queue dump" {
|
||||
|
||||
@@ -72,6 +72,7 @@ pub const Builder = struct {
|
||||
pkg_config_pkg_list: ?(PkgConfigError![]const PkgConfigPkg) = null,
|
||||
args: ?[][]const u8 = null,
|
||||
debug_log_scopes: []const []const u8 = &.{},
|
||||
debug_compile_errors: bool = false,
|
||||
|
||||
/// Experimental. Use system Darling installation to run cross compiled macOS build artifacts.
|
||||
enable_darling: bool = false,
|
||||
@@ -1622,7 +1623,6 @@ pub const LibExeObjStep = struct {
|
||||
use_stage1: ?bool = null,
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
ofmt: ?std.Target.ObjectFormat = null,
|
||||
|
||||
output_path_source: GeneratedFile,
|
||||
output_lib_path_source: GeneratedFile,
|
||||
@@ -2490,7 +2490,7 @@ pub const LibExeObjStep = struct {
|
||||
}
|
||||
}
|
||||
|
||||
if (self.ofmt) |ofmt| {
|
||||
if (self.target.ofmt) |ofmt| {
|
||||
try zig_args.append(try std.fmt.allocPrint(builder.allocator, "-ofmt={s}", .{@tagName(ofmt)}));
|
||||
}
|
||||
|
||||
@@ -2675,6 +2675,10 @@ pub const LibExeObjStep = struct {
|
||||
try zig_args.append(log_scope);
|
||||
}
|
||||
|
||||
if (builder.debug_compile_errors) {
|
||||
try zig_args.append("--debug-compile-errors");
|
||||
}
|
||||
|
||||
if (builder.verbose_cimport) zig_args.append("--verbose-cimport") catch unreachable;
|
||||
if (builder.verbose_air) zig_args.append("--verbose-air") catch unreachable;
|
||||
if (builder.verbose_llvm_ir) zig_args.append("--verbose-llvm-ir") catch unreachable;
|
||||
|
||||
@@ -207,7 +207,7 @@ pub fn runCommand(
|
||||
const cwd = if (maybe_cwd) |cwd| builder.pathFromRoot(cwd) else builder.build_root;
|
||||
|
||||
if (!std.process.can_spawn) {
|
||||
const cmd = try std.mem.join(builder.addInstallDirectory, " ", argv);
|
||||
const cmd = try std.mem.join(builder.allocator, " ", argv);
|
||||
std.debug.print("the following command cannot be executed ({s} does not support spawning a child process):\n{s}", .{ @tagName(builtin.os.tag), cmd });
|
||||
builder.allocator.free(cmd);
|
||||
return ExecError.ExecNotSupported;
|
||||
|
||||
@@ -262,6 +262,7 @@ pub extern "c" fn pthread_key_create(key: *c.pthread_key_t, destructor: ?PThread
|
||||
pub extern "c" fn pthread_key_delete(key: c.pthread_key_t) c.E;
|
||||
pub extern "c" fn pthread_getspecific(key: c.pthread_key_t) ?*anyopaque;
|
||||
pub extern "c" fn pthread_setspecific(key: c.pthread_key_t, value: ?*anyopaque) c_int;
|
||||
pub extern "c" fn pthread_sigmask(how: c_int, set: *const c.sigset_t, oldset: *c.sigset_t) c_int;
|
||||
pub extern "c" fn sem_init(sem: *c.sem_t, pshared: c_int, value: c_uint) c_int;
|
||||
pub extern "c" fn sem_destroy(sem: *c.sem_t) c_int;
|
||||
pub extern "c" fn sem_open(name: [*:0]const u8, flag: c_int, mode: c.mode_t, value: c_uint) *c.sem_t;
|
||||
@@ -365,6 +366,7 @@ pub extern "c" fn pthread_rwlock_trywrlock(rwl: *c.pthread_rwlock_t) callconv(.C
|
||||
pub extern "c" fn pthread_rwlock_unlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
|
||||
|
||||
pub const pthread_t = *opaque {};
|
||||
pub const pthread_key_t = *opaque {};
|
||||
pub const FILE = opaque {};
|
||||
|
||||
pub extern "c" fn dlopen(path: [*:0]const u8, mode: c_int) ?*anyopaque;
|
||||
|
||||
@@ -918,7 +918,7 @@ pub const siginfo_t = extern struct {
|
||||
|
||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
|
||||
pub const Sigaction = extern struct {
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) callconv(.C) void);
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) align(1) callconv(.C) void);
|
||||
pub const sigaction_fn = std.meta.FnPtr(fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void);
|
||||
|
||||
handler: extern union {
|
||||
|
||||
@@ -12,6 +12,7 @@ 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 extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
|
||||
|
||||
pub const dl_iterate_phdr_callback = std.meta.FnPtr(fn (info: *dl_phdr_info, size: usize, data: ?*anyopaque) callconv(.C) c_int);
|
||||
pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*anyopaque) c_int;
|
||||
@@ -419,6 +420,7 @@ pub const F = struct {
|
||||
pub const DUP2FD = 10;
|
||||
pub const DUPFD_CLOEXEC = 17;
|
||||
pub const DUP2FD_CLOEXEC = 18;
|
||||
pub const GETPATH = 19;
|
||||
};
|
||||
|
||||
pub const FD_CLOEXEC = 1;
|
||||
@@ -681,7 +683,7 @@ pub const empty_sigset = sigset_t{ .__bits = [_]c_uint{0} ** _SIG_WORDS };
|
||||
pub const sig_atomic_t = c_int;
|
||||
|
||||
pub const Sigaction = extern struct {
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) callconv(.C) void);
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) align(1) callconv(.C) void);
|
||||
pub const sigaction_fn = std.meta.FnPtr(fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void);
|
||||
|
||||
/// signal handler
|
||||
|
||||
@@ -15,12 +15,15 @@ pub extern "c" fn pthread_getthreadid_np() c_int;
|
||||
pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void;
|
||||
pub extern "c" fn pthread_get_name_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) void;
|
||||
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 posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int;
|
||||
pub extern "c" fn malloc_usable_size(?*const anyopaque) usize;
|
||||
|
||||
pub extern "c" fn getpid() pid_t;
|
||||
|
||||
pub extern "c" fn kinfo_getfile(pid: pid_t, cntp: *c_int) ?[*]kinfo_file;
|
||||
|
||||
pub const sf_hdtr = extern struct {
|
||||
headers: [*]const iovec_const,
|
||||
hdr_cnt: c_int,
|
||||
@@ -1197,7 +1200,7 @@ const NSIG = 32;
|
||||
|
||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||
pub const Sigaction = extern struct {
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) callconv(.C) void);
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) align(1) callconv(.C) void);
|
||||
pub const sigaction_fn = std.meta.FnPtr(fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void);
|
||||
|
||||
/// signal handler
|
||||
|
||||
@@ -742,7 +742,7 @@ const NSIG = 32;
|
||||
|
||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||
pub const Sigaction = extern struct {
|
||||
pub const handler_fn = std.meta.FnPtr(fn (i32) callconv(.C) void);
|
||||
pub const handler_fn = std.meta.FnPtr(fn (i32) align(1) callconv(.C) void);
|
||||
|
||||
/// signal handler
|
||||
__sigaction_u: extern union {
|
||||
|
||||
@@ -537,6 +537,7 @@ pub const KERN = struct {
|
||||
};
|
||||
|
||||
pub const PATH_MAX = 1024;
|
||||
pub const NAME_MAX = 255;
|
||||
pub const IOV_MAX = KERN.IOV_MAX;
|
||||
|
||||
pub const STDIN_FILENO = 0;
|
||||
@@ -689,13 +690,17 @@ pub const F = struct {
|
||||
pub const SETFD = 2;
|
||||
pub const GETFL = 3;
|
||||
pub const SETFL = 4;
|
||||
|
||||
pub const GETOWN = 5;
|
||||
pub const SETOWN = 6;
|
||||
|
||||
pub const GETLK = 7;
|
||||
pub const SETLK = 8;
|
||||
pub const SETLKW = 9;
|
||||
pub const CLOSEM = 10;
|
||||
pub const MAXFD = 11;
|
||||
pub const DUPFD_CLOEXEC = 12;
|
||||
pub const GETNOSIGPIPE = 13;
|
||||
pub const SETNOSIGPIPE = 14;
|
||||
pub const GETPATH = 15;
|
||||
|
||||
pub const RDLCK = 1;
|
||||
pub const WRLCK = 3;
|
||||
@@ -971,7 +976,7 @@ pub const SIG = struct {
|
||||
|
||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||
pub const Sigaction = extern struct {
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) callconv(.C) void);
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) align(1) callconv(.C) void);
|
||||
pub const sigaction_fn = std.meta.FnPtr(fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void);
|
||||
|
||||
/// signal handler
|
||||
|
||||
@@ -417,6 +417,7 @@ pub const AI = struct {
|
||||
};
|
||||
|
||||
pub const PATH_MAX = 1024;
|
||||
pub const NAME_MAX = 255;
|
||||
pub const IOV_MAX = 1024;
|
||||
|
||||
pub const STDIN_FILENO = 0;
|
||||
@@ -1026,7 +1027,7 @@ pub const SIG = struct {
|
||||
|
||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||
pub const Sigaction = extern struct {
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) callconv(.C) void);
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) align(1) callconv(.C) void);
|
||||
pub const sigaction_fn = std.meta.FnPtr(fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void);
|
||||
|
||||
/// signal handler
|
||||
|
||||
@@ -952,7 +952,7 @@ pub const SIG = struct {
|
||||
|
||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||
pub const Sigaction = extern struct {
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) callconv(.C) void);
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) align(1) callconv(.C) void);
|
||||
pub const sigaction_fn = std.meta.FnPtr(fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void);
|
||||
|
||||
/// signal options
|
||||
|
||||
@@ -15,6 +15,8 @@ const FEXTRA = 1 << 2;
|
||||
const FNAME = 1 << 3;
|
||||
const FCOMMENT = 1 << 4;
|
||||
|
||||
const max_string_len = 1024;
|
||||
|
||||
pub fn GzipStream(comptime ReaderType: type) type {
|
||||
return struct {
|
||||
const Self = @This();
|
||||
@@ -31,9 +33,11 @@ pub fn GzipStream(comptime ReaderType: type) type {
|
||||
read_amt: usize,
|
||||
|
||||
info: struct {
|
||||
extra: ?[]const u8,
|
||||
filename: ?[]const u8,
|
||||
comment: ?[]const u8,
|
||||
modification_time: u32,
|
||||
operating_system: u8,
|
||||
},
|
||||
|
||||
fn init(allocator: mem.Allocator, source: ReaderType) !Self {
|
||||
@@ -57,33 +61,27 @@ pub fn GzipStream(comptime ReaderType: type) type {
|
||||
// Operating system where the compression took place
|
||||
const OS = header[9];
|
||||
_ = XFL;
|
||||
_ = OS;
|
||||
|
||||
if (FLG & FEXTRA != 0) {
|
||||
// Skip the extra data, we could read and expose it to the user
|
||||
// if somebody needs it.
|
||||
const extra = if (FLG & FEXTRA != 0) blk: {
|
||||
const len = try source.readIntLittle(u16);
|
||||
try source.skipBytes(len, .{});
|
||||
}
|
||||
const tmp_buf = try allocator.alloc(u8, len);
|
||||
errdefer allocator.free(tmp_buf);
|
||||
|
||||
var filename: ?[]const u8 = null;
|
||||
if (FLG & FNAME != 0) {
|
||||
filename = try source.readUntilDelimiterAlloc(
|
||||
allocator,
|
||||
0,
|
||||
std.math.maxInt(usize),
|
||||
);
|
||||
}
|
||||
try source.readNoEof(tmp_buf);
|
||||
break :blk tmp_buf;
|
||||
} else null;
|
||||
errdefer if (extra) |p| allocator.free(p);
|
||||
|
||||
const filename = if (FLG & FNAME != 0)
|
||||
try source.readUntilDelimiterAlloc(allocator, 0, max_string_len)
|
||||
else
|
||||
null;
|
||||
errdefer if (filename) |p| allocator.free(p);
|
||||
|
||||
var comment: ?[]const u8 = null;
|
||||
if (FLG & FCOMMENT != 0) {
|
||||
comment = try source.readUntilDelimiterAlloc(
|
||||
allocator,
|
||||
0,
|
||||
std.math.maxInt(usize),
|
||||
);
|
||||
}
|
||||
const comment = if (FLG & FCOMMENT != 0)
|
||||
try source.readUntilDelimiterAlloc(allocator, 0, max_string_len)
|
||||
else
|
||||
null;
|
||||
errdefer if (comment) |p| allocator.free(p);
|
||||
|
||||
if (FLG & FHCRC != 0) {
|
||||
@@ -100,7 +98,9 @@ pub fn GzipStream(comptime ReaderType: type) type {
|
||||
.info = .{
|
||||
.filename = filename,
|
||||
.comment = comment,
|
||||
.extra = extra,
|
||||
.modification_time = MTIME,
|
||||
.operating_system = OS,
|
||||
},
|
||||
.read_amt = 0,
|
||||
};
|
||||
@@ -108,6 +108,8 @@ pub fn GzipStream(comptime ReaderType: type) type {
|
||||
|
||||
pub fn deinit(self: *Self) void {
|
||||
self.inflater.deinit();
|
||||
if (self.info.extra) |extra|
|
||||
self.allocator.free(extra);
|
||||
if (self.info.filename) |filename|
|
||||
self.allocator.free(filename);
|
||||
if (self.info.comment) |comment|
|
||||
|
||||
@@ -147,6 +147,8 @@ pub const stream = struct {
|
||||
};
|
||||
|
||||
pub const salsa = struct {
|
||||
pub const Salsa = @import("crypto/salsa20.zig").Salsa;
|
||||
pub const XSalsa = @import("crypto/salsa20.zig").XSalsa;
|
||||
pub const Salsa20 = @import("crypto/salsa20.zig").Salsa20;
|
||||
pub const XSalsa20 = @import("crypto/salsa20.zig").XSalsa20;
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const builtin = @import("builtin");
|
||||
const std = @import("std");
|
||||
const crypto = std.crypto;
|
||||
const debug = std.debug;
|
||||
@@ -268,18 +269,21 @@ pub const Ed25519 = struct {
|
||||
}
|
||||
|
||||
/// Create a KeyPair from a secret key.
|
||||
pub fn fromSecretKey(secret_key: SecretKey) IdentityElementError!KeyPair {
|
||||
const pk_p = try Curve.fromBytes(secret_key.publicKeyBytes());
|
||||
|
||||
/// Note that with EdDSA, storing the seed, and recovering the key pair
|
||||
/// from it is recommended over storing the entire secret key.
|
||||
/// The seed of an exiting key pair can be obtained with
|
||||
/// `key_pair.secret_key.seed()`.
|
||||
pub fn fromSecretKey(secret_key: SecretKey) (NonCanonicalError || EncodingError || IdentityElementError)!KeyPair {
|
||||
// It is critical for EdDSA to use the correct public key.
|
||||
// In order to enforce this, a SecretKey implicitly includes a copy of the public key.
|
||||
// In Debug mode, we can still afford checking that the public key is correct for extra safety.
|
||||
if (std.builtin.mode == .Debug) {
|
||||
const recomputed_kp = try create(secret_key[0..seed_length].*);
|
||||
debug.assert(recomputed_kp.public_key.p.toBytes() == pk_p.toBytes());
|
||||
if (builtin.mode == .Debug) {
|
||||
const pk_p = try Curve.fromBytes(secret_key.publicKeyBytes());
|
||||
const recomputed_kp = try create(secret_key.seed());
|
||||
debug.assert(mem.eql(u8, &recomputed_kp.public_key.toBytes(), &pk_p.toBytes()));
|
||||
}
|
||||
return KeyPair{
|
||||
.public_key = PublicKey{ .p = pk_p },
|
||||
.public_key = try PublicKey.fromBytes(secret_key.publicKeyBytes()),
|
||||
.secret_key = secret_key,
|
||||
};
|
||||
}
|
||||
@@ -314,6 +318,7 @@ pub const Ed25519 = struct {
|
||||
h.update(&scalar_and_prefix.prefix);
|
||||
var noise2: [noise_length]u8 = undefined;
|
||||
crypto.random.bytes(&noise2);
|
||||
h.update(&noise2);
|
||||
if (noise) |*z| {
|
||||
h.update(z);
|
||||
}
|
||||
@@ -674,3 +679,10 @@ test "ed25519 signatures with streaming" {
|
||||
verifier.update("age");
|
||||
try verifier.verify();
|
||||
}
|
||||
|
||||
test "ed25519 key pair from secret key" {
|
||||
const kp = try Ed25519.KeyPair.create(null);
|
||||
const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key);
|
||||
try std.testing.expectEqualSlices(u8, &kp.secret_key.toBytes(), &kp2.secret_key.toBytes());
|
||||
try std.testing.expectEqualSlices(u8, &kp.public_key.toBytes(), &kp2.public_key.toBytes());
|
||||
}
|
||||
|
||||
@@ -101,8 +101,8 @@ pub const Block = struct {
|
||||
&cpu.sandybridge, &cpu.ivybridge => 8,
|
||||
&cpu.haswell, &cpu.broadwell => 7,
|
||||
&cpu.cannonlake, &cpu.skylake, &cpu.skylake_avx512 => 4,
|
||||
&cpu.icelake_client, &cpu.icelake_server => 6,
|
||||
&cpu.znver1, &cpu.znver2 => 8,
|
||||
&cpu.icelake_client, &cpu.icelake_server, &cpu.tigerlake, &cpu.rocketlake, &cpu.alderlake => 6,
|
||||
&cpu.znver1, &cpu.znver2, &cpu.znver3 => 8,
|
||||
else => 8,
|
||||
};
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ pub const Block = struct {
|
||||
/// Perform operations on multiple blocks in parallel.
|
||||
pub const parallel = struct {
|
||||
/// The recommended number of AES encryption/decryption to perform in parallel for the chosen implementation.
|
||||
pub const optimal_parallel_blocks = 8;
|
||||
pub const optimal_parallel_blocks = 6;
|
||||
|
||||
/// 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 {
|
||||
|
||||
@@ -374,22 +374,18 @@ pub const State = struct {
|
||||
|
||||
const Halves = struct { l: u32, r: u32 };
|
||||
|
||||
fn feistelF(state: State, x: u32) u32 {
|
||||
var r = state.sboxes[0][@truncate(u8, x >> 24)];
|
||||
r +%= state.sboxes[1][@truncate(u8, x >> 16)];
|
||||
r ^= state.sboxes[2][@truncate(u8, x >> 8)];
|
||||
r +%= state.sboxes[3][@truncate(u8, x)];
|
||||
return r;
|
||||
fn halfRound(state: *const State, i: u32, j: u32, n: usize) u32 {
|
||||
var r = state.sboxes[0][@truncate(u8, j >> 24)];
|
||||
r +%= state.sboxes[1][@truncate(u8, j >> 16)];
|
||||
r ^= state.sboxes[2][@truncate(u8, j >> 8)];
|
||||
r +%= state.sboxes[3][@truncate(u8, j)];
|
||||
return i ^ r ^ state.subkeys[n];
|
||||
}
|
||||
|
||||
fn halfRound(state: State, i: u32, j: u32, n: usize) u32 {
|
||||
return i ^ state.feistelF(j) ^ state.subkeys[n];
|
||||
}
|
||||
|
||||
fn encipher(state: State, halves: *Halves) void {
|
||||
fn encipher(state: *const State, halves: *Halves) void {
|
||||
halves.l ^= state.subkeys[0];
|
||||
var i: usize = 1;
|
||||
while (i < 16) : (i += 2) {
|
||||
comptime var i = 1;
|
||||
inline while (i < 16) : (i += 2) {
|
||||
halves.r = state.halfRound(halves.r, halves.l, i);
|
||||
halves.l = state.halfRound(halves.l, halves.r, i + 1);
|
||||
}
|
||||
@@ -397,7 +393,7 @@ pub const State = struct {
|
||||
halves.* = halves_last;
|
||||
}
|
||||
|
||||
fn encrypt(state: State, data: []u32) void {
|
||||
fn encrypt(state: *const State, data: []u32) void {
|
||||
debug.assert(data.len % 2 == 0);
|
||||
var i: usize = 0;
|
||||
while (i < data.len) : (i += 2) {
|
||||
|
||||
@@ -200,7 +200,10 @@ const CompressGeneric = struct {
|
||||
}
|
||||
};
|
||||
|
||||
const compress = if (builtin.cpu.arch == .x86_64) CompressVectorized.compress else CompressGeneric.compress;
|
||||
const compress = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c)
|
||||
CompressVectorized.compress
|
||||
else
|
||||
CompressGeneric.compress;
|
||||
|
||||
fn first8Words(words: [16]u32) [8]u32 {
|
||||
return @ptrCast(*const [8]u32, &words).*;
|
||||
|
||||
@@ -152,7 +152,7 @@ pub const State = struct {
|
||||
self.endianSwap();
|
||||
}
|
||||
|
||||
pub const permute = if (builtin.cpu.arch == .x86_64) impl: {
|
||||
pub const permute = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c) impl: {
|
||||
break :impl permute_vectorized;
|
||||
} else if (builtin.mode == .ReleaseSmall) impl: {
|
||||
break :impl permute_small;
|
||||
|
||||
@@ -14,297 +14,293 @@ const AuthenticationError = crypto.errors.AuthenticationError;
|
||||
const IdentityElementError = crypto.errors.IdentityElementError;
|
||||
const WeakPublicKeyError = crypto.errors.WeakPublicKeyError;
|
||||
|
||||
const Salsa20VecImpl = struct {
|
||||
const Lane = @Vector(4, u32);
|
||||
const Half = @Vector(2, u32);
|
||||
const BlockVec = [4]Lane;
|
||||
/// The Salsa cipher with 20 rounds.
|
||||
pub const Salsa20 = Salsa(20);
|
||||
|
||||
fn initContext(key: [8]u32, d: [4]u32) BlockVec {
|
||||
const c = "expand 32-byte k";
|
||||
const constant_le = comptime [4]u32{
|
||||
mem.readIntLittle(u32, c[0..4]),
|
||||
mem.readIntLittle(u32, c[4..8]),
|
||||
mem.readIntLittle(u32, c[8..12]),
|
||||
mem.readIntLittle(u32, c[12..16]),
|
||||
};
|
||||
return BlockVec{
|
||||
Lane{ key[0], key[1], key[2], key[3] },
|
||||
Lane{ key[4], key[5], key[6], key[7] },
|
||||
Lane{ constant_le[0], constant_le[1], constant_le[2], constant_le[3] },
|
||||
Lane{ d[0], d[1], d[2], d[3] },
|
||||
};
|
||||
}
|
||||
/// The XSalsa cipher with 20 rounds.
|
||||
pub const XSalsa20 = XSalsa(20);
|
||||
|
||||
inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) 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] };
|
||||
const k0k1 = Half{ input[0][0], input[0][1] };
|
||||
const k2k3 = Half{ input[0][2], input[0][3] };
|
||||
const k4k5 = Half{ input[1][0], input[1][1] };
|
||||
const k6k7 = Half{ input[1][2], input[1][3] };
|
||||
const n0k0 = Half{ n3n0[1], k0k1[0] };
|
||||
const k0n0 = Half{ n0k0[1], n0k0[0] };
|
||||
const k4k5k0n0 = Lane{ k4k5[0], k4k5[1], k0n0[0], k0n0[1] };
|
||||
const k1k6 = Half{ k0k1[1], k6k7[0] };
|
||||
const k6k1 = Half{ k1k6[1], k1k6[0] };
|
||||
const n1n2k6k1 = Lane{ n1n2[0], n1n2[1], k6k1[0], k6k1[1] };
|
||||
const k7n3 = Half{ k6k7[1], n3n0[0] };
|
||||
const n3k7 = Half{ k7n3[1], k7n3[0] };
|
||||
const k2k3n3k7 = Lane{ k2k3[0], k2k3[1], n3k7[0], n3k7[1] };
|
||||
fn SalsaVecImpl(comptime rounds: comptime_int) type {
|
||||
return struct {
|
||||
const Lane = @Vector(4, u32);
|
||||
const Half = @Vector(2, u32);
|
||||
const BlockVec = [4]Lane;
|
||||
|
||||
var diag0 = input[2];
|
||||
var diag1 = @shuffle(u32, k4k5k0n0, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
var diag2 = @shuffle(u32, n1n2k6k1, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
var diag3 = @shuffle(u32, k2k3n3k7, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
|
||||
const start0 = diag0;
|
||||
const start1 = diag1;
|
||||
const start2 = diag2;
|
||||
const start3 = diag3;
|
||||
|
||||
var i: usize = 0;
|
||||
while (i < 20) : (i += 2) {
|
||||
var a0 = diag1 +% diag0;
|
||||
diag3 ^= math.rotl(Lane, a0, 7);
|
||||
var a1 = diag0 +% diag3;
|
||||
diag2 ^= math.rotl(Lane, a1, 9);
|
||||
var a2 = diag3 +% diag2;
|
||||
diag1 ^= math.rotl(Lane, a2, 13);
|
||||
var a3 = diag2 +% diag1;
|
||||
diag0 ^= math.rotl(Lane, a3, 18);
|
||||
|
||||
var diag3_shift = @shuffle(u32, diag3, undefined, [_]i32{ 3, 0, 1, 2 });
|
||||
var diag2_shift = @shuffle(u32, diag2, undefined, [_]i32{ 2, 3, 0, 1 });
|
||||
var diag1_shift = @shuffle(u32, diag1, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
diag3 = diag3_shift;
|
||||
diag2 = diag2_shift;
|
||||
diag1 = diag1_shift;
|
||||
|
||||
a0 = diag3 +% diag0;
|
||||
diag1 ^= math.rotl(Lane, a0, 7);
|
||||
a1 = diag0 +% diag1;
|
||||
diag2 ^= math.rotl(Lane, a1, 9);
|
||||
a2 = diag1 +% diag2;
|
||||
diag3 ^= math.rotl(Lane, a2, 13);
|
||||
a3 = diag2 +% diag3;
|
||||
diag0 ^= math.rotl(Lane, a3, 18);
|
||||
|
||||
diag1_shift = @shuffle(u32, diag1, undefined, [_]i32{ 3, 0, 1, 2 });
|
||||
diag2_shift = @shuffle(u32, diag2, undefined, [_]i32{ 2, 3, 0, 1 });
|
||||
diag3_shift = @shuffle(u32, diag3, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
diag1 = diag1_shift;
|
||||
diag2 = diag2_shift;
|
||||
diag3 = diag3_shift;
|
||||
fn initContext(key: [8]u32, d: [4]u32) BlockVec {
|
||||
const c = "expand 32-byte k";
|
||||
const constant_le = comptime [4]u32{
|
||||
mem.readIntLittle(u32, c[0..4]),
|
||||
mem.readIntLittle(u32, c[4..8]),
|
||||
mem.readIntLittle(u32, c[8..12]),
|
||||
mem.readIntLittle(u32, c[12..16]),
|
||||
};
|
||||
return BlockVec{
|
||||
Lane{ key[0], key[1], key[2], key[3] },
|
||||
Lane{ key[4], key[5], key[6], key[7] },
|
||||
Lane{ constant_le[0], constant_le[1], constant_le[2], constant_le[3] },
|
||||
Lane{ d[0], d[1], d[2], d[3] },
|
||||
};
|
||||
}
|
||||
|
||||
if (feedback) {
|
||||
diag0 +%= start0;
|
||||
diag1 +%= start1;
|
||||
diag2 +%= start2;
|
||||
diag3 +%= start3;
|
||||
}
|
||||
inline fn salsaCore(x: *BlockVec, input: BlockVec, comptime feedback: bool) 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] };
|
||||
const k0k1 = Half{ input[0][0], input[0][1] };
|
||||
const k2k3 = Half{ input[0][2], input[0][3] };
|
||||
const k4k5 = Half{ input[1][0], input[1][1] };
|
||||
const k6k7 = Half{ input[1][2], input[1][3] };
|
||||
const n0k0 = Half{ n3n0[1], k0k1[0] };
|
||||
const k0n0 = Half{ n0k0[1], n0k0[0] };
|
||||
const k4k5k0n0 = Lane{ k4k5[0], k4k5[1], k0n0[0], k0n0[1] };
|
||||
const k1k6 = Half{ k0k1[1], k6k7[0] };
|
||||
const k6k1 = Half{ k1k6[1], k1k6[0] };
|
||||
const n1n2k6k1 = Lane{ n1n2[0], n1n2[1], k6k1[0], k6k1[1] };
|
||||
const k7n3 = Half{ k6k7[1], n3n0[0] };
|
||||
const n3k7 = Half{ k7n3[1], k7n3[0] };
|
||||
const k2k3n3k7 = Lane{ k2k3[0], k2k3[1], n3k7[0], n3k7[1] };
|
||||
|
||||
const x0x1x10x11 = Lane{ diag0[0], diag1[1], diag0[2], diag1[3] };
|
||||
const x12x13x6x7 = Lane{ diag1[0], diag2[1], diag1[2], diag2[3] };
|
||||
const x8x9x2x3 = Lane{ diag2[0], diag3[1], diag2[2], diag3[3] };
|
||||
const x4x5x14x15 = Lane{ diag3[0], diag0[1], diag3[2], diag0[3] };
|
||||
var diag0 = input[2];
|
||||
var diag1 = @shuffle(u32, k4k5k0n0, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
var diag2 = @shuffle(u32, n1n2k6k1, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
var diag3 = @shuffle(u32, k2k3n3k7, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
|
||||
x[0] = Lane{ x0x1x10x11[0], x0x1x10x11[1], x8x9x2x3[2], x8x9x2x3[3] };
|
||||
x[1] = Lane{ x4x5x14x15[0], x4x5x14x15[1], x12x13x6x7[2], x12x13x6x7[3] };
|
||||
x[2] = Lane{ x8x9x2x3[0], x8x9x2x3[1], x0x1x10x11[2], x0x1x10x11[3] };
|
||||
x[3] = Lane{ x12x13x6x7[0], x12x13x6x7[1], x4x5x14x15[2], x4x5x14x15[3] };
|
||||
}
|
||||
const start0 = diag0;
|
||||
const start1 = diag1;
|
||||
const start2 = diag2;
|
||||
const start3 = diag3;
|
||||
|
||||
fn hashToBytes(out: *[64]u8, x: BlockVec) void {
|
||||
var i: usize = 0;
|
||||
while (i < 4) : (i += 1) {
|
||||
mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]);
|
||||
mem.writeIntLittle(u32, out[16 * i + 4 ..][0..4], x[i][1]);
|
||||
mem.writeIntLittle(u32, out[16 * i + 8 ..][0..4], x[i][2]);
|
||||
mem.writeIntLittle(u32, out[16 * i + 12 ..][0..4], x[i][3]);
|
||||
}
|
||||
}
|
||||
var i: usize = 0;
|
||||
while (i < rounds) : (i += 2) {
|
||||
diag3 ^= math.rotl(Lane, diag1 +% diag0, 7);
|
||||
diag2 ^= math.rotl(Lane, diag0 +% diag3, 9);
|
||||
diag1 ^= math.rotl(Lane, diag3 +% diag2, 13);
|
||||
diag0 ^= math.rotl(Lane, diag2 +% diag1, 18);
|
||||
|
||||
fn salsa20Xor(out: []u8, in: []const u8, key: [8]u32, d: [4]u32) void {
|
||||
var ctx = initContext(key, d);
|
||||
var x: BlockVec = undefined;
|
||||
var buf: [64]u8 = undefined;
|
||||
var i: usize = 0;
|
||||
while (i + 64 <= in.len) : (i += 64) {
|
||||
salsa20Core(x[0..], ctx, true);
|
||||
hashToBytes(buf[0..], x);
|
||||
var xout = out[i..];
|
||||
const xin = in[i..];
|
||||
var j: usize = 0;
|
||||
while (j < 64) : (j += 1) {
|
||||
xout[j] = xin[j];
|
||||
diag3 = @shuffle(u32, diag3, undefined, [_]i32{ 3, 0, 1, 2 });
|
||||
diag2 = @shuffle(u32, diag2, undefined, [_]i32{ 2, 3, 0, 1 });
|
||||
diag1 = @shuffle(u32, diag1, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
|
||||
diag1 ^= math.rotl(Lane, diag3 +% diag0, 7);
|
||||
diag2 ^= math.rotl(Lane, diag0 +% diag1, 9);
|
||||
diag3 ^= math.rotl(Lane, diag1 +% diag2, 13);
|
||||
diag0 ^= math.rotl(Lane, diag2 +% diag3, 18);
|
||||
|
||||
diag1 = @shuffle(u32, diag1, undefined, [_]i32{ 3, 0, 1, 2 });
|
||||
diag2 = @shuffle(u32, diag2, undefined, [_]i32{ 2, 3, 0, 1 });
|
||||
diag3 = @shuffle(u32, diag3, undefined, [_]i32{ 1, 2, 3, 0 });
|
||||
}
|
||||
j = 0;
|
||||
while (j < 64) : (j += 1) {
|
||||
xout[j] ^= buf[j];
|
||||
|
||||
if (feedback) {
|
||||
diag0 +%= start0;
|
||||
diag1 +%= start1;
|
||||
diag2 +%= start2;
|
||||
diag3 +%= start3;
|
||||
}
|
||||
ctx[3][2] +%= 1;
|
||||
if (ctx[3][2] == 0) {
|
||||
ctx[3][3] += 1;
|
||||
|
||||
const x0x1x10x11 = Lane{ diag0[0], diag1[1], diag0[2], diag1[3] };
|
||||
const x12x13x6x7 = Lane{ diag1[0], diag2[1], diag1[2], diag2[3] };
|
||||
const x8x9x2x3 = Lane{ diag2[0], diag3[1], diag2[2], diag3[3] };
|
||||
const x4x5x14x15 = Lane{ diag3[0], diag0[1], diag3[2], diag0[3] };
|
||||
|
||||
x[0] = Lane{ x0x1x10x11[0], x0x1x10x11[1], x8x9x2x3[2], x8x9x2x3[3] };
|
||||
x[1] = Lane{ x4x5x14x15[0], x4x5x14x15[1], x12x13x6x7[2], x12x13x6x7[3] };
|
||||
x[2] = Lane{ x8x9x2x3[0], x8x9x2x3[1], x0x1x10x11[2], x0x1x10x11[3] };
|
||||
x[3] = Lane{ x12x13x6x7[0], x12x13x6x7[1], x4x5x14x15[2], x4x5x14x15[3] };
|
||||
}
|
||||
|
||||
fn hashToBytes(out: *[64]u8, x: BlockVec) void {
|
||||
var i: usize = 0;
|
||||
while (i < 4) : (i += 1) {
|
||||
mem.writeIntLittle(u32, out[16 * i + 0 ..][0..4], x[i][0]);
|
||||
mem.writeIntLittle(u32, out[16 * i + 4 ..][0..4], x[i][1]);
|
||||
mem.writeIntLittle(u32, out[16 * i + 8 ..][0..4], x[i][2]);
|
||||
mem.writeIntLittle(u32, out[16 * i + 12 ..][0..4], x[i][3]);
|
||||
}
|
||||
}
|
||||
if (i < in.len) {
|
||||
salsa20Core(x[0..], ctx, true);
|
||||
hashToBytes(buf[0..], x);
|
||||
|
||||
var xout = out[i..];
|
||||
const xin = in[i..];
|
||||
var j: usize = 0;
|
||||
while (j < in.len % 64) : (j += 1) {
|
||||
xout[j] = xin[j] ^ buf[j];
|
||||
fn salsaXor(out: []u8, in: []const u8, key: [8]u32, d: [4]u32) void {
|
||||
var ctx = initContext(key, d);
|
||||
var x: BlockVec = undefined;
|
||||
var buf: [64]u8 = undefined;
|
||||
var i: usize = 0;
|
||||
while (i + 64 <= in.len) : (i += 64) {
|
||||
salsaCore(x[0..], ctx, true);
|
||||
hashToBytes(buf[0..], x);
|
||||
var xout = out[i..];
|
||||
const xin = in[i..];
|
||||
var j: usize = 0;
|
||||
while (j < 64) : (j += 1) {
|
||||
xout[j] = xin[j];
|
||||
}
|
||||
j = 0;
|
||||
while (j < 64) : (j += 1) {
|
||||
xout[j] ^= buf[j];
|
||||
}
|
||||
ctx[3][2] +%= 1;
|
||||
if (ctx[3][2] == 0) {
|
||||
ctx[3][3] += 1;
|
||||
}
|
||||
}
|
||||
if (i < in.len) {
|
||||
salsaCore(x[0..], ctx, true);
|
||||
hashToBytes(buf[0..], x);
|
||||
|
||||
var xout = out[i..];
|
||||
const xin = in[i..];
|
||||
var j: usize = 0;
|
||||
while (j < in.len % 64) : (j += 1) {
|
||||
xout[j] = xin[j] ^ buf[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn hsalsa20(input: [16]u8, key: [32]u8) [32]u8 {
|
||||
var c: [4]u32 = undefined;
|
||||
for (c) |_, i| {
|
||||
c[i] = mem.readIntLittle(u32, input[4 * i ..][0..4]);
|
||||
fn hsalsa(input: [16]u8, key: [32]u8) [32]u8 {
|
||||
var c: [4]u32 = undefined;
|
||||
for (c) |_, i| {
|
||||
c[i] = mem.readIntLittle(u32, input[4 * i ..][0..4]);
|
||||
}
|
||||
const ctx = initContext(keyToWords(key), c);
|
||||
var x: BlockVec = undefined;
|
||||
salsaCore(x[0..], ctx, false);
|
||||
var out: [32]u8 = undefined;
|
||||
mem.writeIntLittle(u32, out[0..4], x[0][0]);
|
||||
mem.writeIntLittle(u32, out[4..8], x[1][1]);
|
||||
mem.writeIntLittle(u32, out[8..12], x[2][2]);
|
||||
mem.writeIntLittle(u32, out[12..16], x[3][3]);
|
||||
mem.writeIntLittle(u32, out[16..20], x[1][2]);
|
||||
mem.writeIntLittle(u32, out[20..24], x[1][3]);
|
||||
mem.writeIntLittle(u32, out[24..28], x[2][0]);
|
||||
mem.writeIntLittle(u32, out[28..32], x[2][1]);
|
||||
return out;
|
||||
}
|
||||
const ctx = initContext(keyToWords(key), c);
|
||||
var x: BlockVec = undefined;
|
||||
salsa20Core(x[0..], ctx, false);
|
||||
var out: [32]u8 = undefined;
|
||||
mem.writeIntLittle(u32, out[0..4], x[0][0]);
|
||||
mem.writeIntLittle(u32, out[4..8], x[1][1]);
|
||||
mem.writeIntLittle(u32, out[8..12], x[2][2]);
|
||||
mem.writeIntLittle(u32, out[12..16], x[3][3]);
|
||||
mem.writeIntLittle(u32, out[16..20], x[1][2]);
|
||||
mem.writeIntLittle(u32, out[20..24], x[1][3]);
|
||||
mem.writeIntLittle(u32, out[24..28], x[2][0]);
|
||||
mem.writeIntLittle(u32, out[28..32], x[2][1]);
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
const Salsa20NonVecImpl = struct {
|
||||
const BlockVec = [16]u32;
|
||||
|
||||
fn initContext(key: [8]u32, d: [4]u32) BlockVec {
|
||||
const c = "expand 32-byte k";
|
||||
const constant_le = comptime [4]u32{
|
||||
mem.readIntLittle(u32, c[0..4]),
|
||||
mem.readIntLittle(u32, c[4..8]),
|
||||
mem.readIntLittle(u32, c[8..12]),
|
||||
mem.readIntLittle(u32, c[12..16]),
|
||||
};
|
||||
return BlockVec{
|
||||
constant_le[0], key[0], key[1], key[2],
|
||||
key[3], constant_le[1], d[0], d[1],
|
||||
d[2], d[3], constant_le[2], key[4],
|
||||
key[5], key[6], key[7], constant_le[3],
|
||||
};
|
||||
}
|
||||
|
||||
const QuarterRound = struct {
|
||||
a: usize,
|
||||
b: usize,
|
||||
c: usize,
|
||||
d: u6,
|
||||
};
|
||||
}
|
||||
|
||||
inline fn Rp(a: usize, b: usize, c: usize, d: u6) QuarterRound {
|
||||
return QuarterRound{
|
||||
.a = a,
|
||||
.b = b,
|
||||
.c = c,
|
||||
.d = d,
|
||||
fn SalsaNonVecImpl(comptime rounds: comptime_int) type {
|
||||
return struct {
|
||||
const BlockVec = [16]u32;
|
||||
|
||||
fn initContext(key: [8]u32, d: [4]u32) BlockVec {
|
||||
const c = "expand 32-byte k";
|
||||
const constant_le = comptime [4]u32{
|
||||
mem.readIntLittle(u32, c[0..4]),
|
||||
mem.readIntLittle(u32, c[4..8]),
|
||||
mem.readIntLittle(u32, c[8..12]),
|
||||
mem.readIntLittle(u32, c[12..16]),
|
||||
};
|
||||
return BlockVec{
|
||||
constant_le[0], key[0], key[1], key[2],
|
||||
key[3], constant_le[1], d[0], d[1],
|
||||
d[2], d[3], constant_le[2], key[4],
|
||||
key[5], key[6], key[7], constant_le[3],
|
||||
};
|
||||
}
|
||||
|
||||
const QuarterRound = struct {
|
||||
a: usize,
|
||||
b: usize,
|
||||
c: usize,
|
||||
d: u6,
|
||||
};
|
||||
}
|
||||
|
||||
inline fn salsa20Core(x: *BlockVec, input: BlockVec, comptime feedback: bool) 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),
|
||||
Rp(14, 10, 6, 7), Rp(2, 14, 10, 9), Rp(6, 2, 14, 13), Rp(10, 6, 2, 18),
|
||||
Rp(3, 15, 11, 7), Rp(7, 3, 15, 9), Rp(11, 7, 3, 13), Rp(15, 11, 7, 18),
|
||||
Rp(1, 0, 3, 7), Rp(2, 1, 0, 9), Rp(3, 2, 1, 13), Rp(0, 3, 2, 18),
|
||||
Rp(6, 5, 4, 7), Rp(7, 6, 5, 9), Rp(4, 7, 6, 13), Rp(5, 4, 7, 18),
|
||||
Rp(11, 10, 9, 7), Rp(8, 11, 10, 9), Rp(9, 8, 11, 13), Rp(10, 9, 8, 18),
|
||||
Rp(12, 15, 14, 7), Rp(13, 12, 15, 9), Rp(14, 13, 12, 13), Rp(15, 14, 13, 18),
|
||||
};
|
||||
x.* = input;
|
||||
var j: usize = 0;
|
||||
while (j < 20) : (j += 2) {
|
||||
inline for (arx_steps) |r| {
|
||||
x[r.a] ^= math.rotl(u32, x[r.b] +% x[r.c], r.d);
|
||||
}
|
||||
inline fn Rp(a: usize, b: usize, c: usize, d: u6) QuarterRound {
|
||||
return QuarterRound{
|
||||
.a = a,
|
||||
.b = b,
|
||||
.c = c,
|
||||
.d = d,
|
||||
};
|
||||
}
|
||||
if (feedback) {
|
||||
j = 0;
|
||||
while (j < 16) : (j += 1) {
|
||||
x[j] +%= input[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn hashToBytes(out: *[64]u8, x: BlockVec) void {
|
||||
for (x) |w, i| {
|
||||
mem.writeIntLittle(u32, out[i * 4 ..][0..4], w);
|
||||
}
|
||||
}
|
||||
|
||||
fn salsa20Xor(out: []u8, in: []const u8, key: [8]u32, d: [4]u32) void {
|
||||
var ctx = initContext(key, d);
|
||||
var x: BlockVec = undefined;
|
||||
var buf: [64]u8 = undefined;
|
||||
var i: usize = 0;
|
||||
while (i + 64 <= in.len) : (i += 64) {
|
||||
salsa20Core(x[0..], ctx, true);
|
||||
hashToBytes(buf[0..], x);
|
||||
var xout = out[i..];
|
||||
const xin = in[i..];
|
||||
inline fn salsaCore(x: *BlockVec, input: BlockVec, comptime feedback: bool) 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),
|
||||
Rp(14, 10, 6, 7), Rp(2, 14, 10, 9), Rp(6, 2, 14, 13), Rp(10, 6, 2, 18),
|
||||
Rp(3, 15, 11, 7), Rp(7, 3, 15, 9), Rp(11, 7, 3, 13), Rp(15, 11, 7, 18),
|
||||
Rp(1, 0, 3, 7), Rp(2, 1, 0, 9), Rp(3, 2, 1, 13), Rp(0, 3, 2, 18),
|
||||
Rp(6, 5, 4, 7), Rp(7, 6, 5, 9), Rp(4, 7, 6, 13), Rp(5, 4, 7, 18),
|
||||
Rp(11, 10, 9, 7), Rp(8, 11, 10, 9), Rp(9, 8, 11, 13), Rp(10, 9, 8, 18),
|
||||
Rp(12, 15, 14, 7), Rp(13, 12, 15, 9), Rp(14, 13, 12, 13), Rp(15, 14, 13, 18),
|
||||
};
|
||||
x.* = input;
|
||||
var j: usize = 0;
|
||||
while (j < 64) : (j += 1) {
|
||||
xout[j] = xin[j];
|
||||
while (j < rounds) : (j += 2) {
|
||||
inline for (arx_steps) |r| {
|
||||
x[r.a] ^= math.rotl(u32, x[r.b] +% x[r.c], r.d);
|
||||
}
|
||||
}
|
||||
j = 0;
|
||||
while (j < 64) : (j += 1) {
|
||||
xout[j] ^= buf[j];
|
||||
}
|
||||
ctx[9] += @boolToInt(@addWithOverflow(u32, ctx[8], 1, &ctx[8]));
|
||||
}
|
||||
if (i < in.len) {
|
||||
salsa20Core(x[0..], ctx, true);
|
||||
hashToBytes(buf[0..], x);
|
||||
|
||||
var xout = out[i..];
|
||||
const xin = in[i..];
|
||||
var j: usize = 0;
|
||||
while (j < in.len % 64) : (j += 1) {
|
||||
xout[j] = xin[j] ^ buf[j];
|
||||
if (feedback) {
|
||||
j = 0;
|
||||
while (j < 16) : (j += 1) {
|
||||
x[j] +%= input[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn hsalsa20(input: [16]u8, key: [32]u8) [32]u8 {
|
||||
var c: [4]u32 = undefined;
|
||||
for (c) |_, i| {
|
||||
c[i] = mem.readIntLittle(u32, input[4 * i ..][0..4]);
|
||||
fn hashToBytes(out: *[64]u8, x: BlockVec) void {
|
||||
for (x) |w, i| {
|
||||
mem.writeIntLittle(u32, out[i * 4 ..][0..4], w);
|
||||
}
|
||||
}
|
||||
const ctx = initContext(keyToWords(key), c);
|
||||
var x: BlockVec = undefined;
|
||||
salsa20Core(x[0..], ctx, false);
|
||||
var out: [32]u8 = undefined;
|
||||
mem.writeIntLittle(u32, out[0..4], x[0]);
|
||||
mem.writeIntLittle(u32, out[4..8], x[5]);
|
||||
mem.writeIntLittle(u32, out[8..12], x[10]);
|
||||
mem.writeIntLittle(u32, out[12..16], x[15]);
|
||||
mem.writeIntLittle(u32, out[16..20], x[6]);
|
||||
mem.writeIntLittle(u32, out[20..24], x[7]);
|
||||
mem.writeIntLittle(u32, out[24..28], x[8]);
|
||||
mem.writeIntLittle(u32, out[28..32], x[9]);
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
const Salsa20Impl = if (builtin.cpu.arch == .x86_64) Salsa20VecImpl else Salsa20NonVecImpl;
|
||||
fn salsaXor(out: []u8, in: []const u8, key: [8]u32, d: [4]u32) void {
|
||||
var ctx = initContext(key, d);
|
||||
var x: BlockVec = undefined;
|
||||
var buf: [64]u8 = undefined;
|
||||
var i: usize = 0;
|
||||
while (i + 64 <= in.len) : (i += 64) {
|
||||
salsaCore(x[0..], ctx, true);
|
||||
hashToBytes(buf[0..], x);
|
||||
var xout = out[i..];
|
||||
const xin = in[i..];
|
||||
var j: usize = 0;
|
||||
while (j < 64) : (j += 1) {
|
||||
xout[j] = xin[j];
|
||||
}
|
||||
j = 0;
|
||||
while (j < 64) : (j += 1) {
|
||||
xout[j] ^= buf[j];
|
||||
}
|
||||
ctx[9] += @boolToInt(@addWithOverflow(u32, ctx[8], 1, &ctx[8]));
|
||||
}
|
||||
if (i < in.len) {
|
||||
salsaCore(x[0..], ctx, true);
|
||||
hashToBytes(buf[0..], x);
|
||||
|
||||
var xout = out[i..];
|
||||
const xin = in[i..];
|
||||
var j: usize = 0;
|
||||
while (j < in.len % 64) : (j += 1) {
|
||||
xout[j] = xin[j] ^ buf[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn hsalsa(input: [16]u8, key: [32]u8) [32]u8 {
|
||||
var c: [4]u32 = undefined;
|
||||
for (c) |_, i| {
|
||||
c[i] = mem.readIntLittle(u32, input[4 * i ..][0..4]);
|
||||
}
|
||||
const ctx = initContext(keyToWords(key), c);
|
||||
var x: BlockVec = undefined;
|
||||
salsaCore(x[0..], ctx, false);
|
||||
var out: [32]u8 = undefined;
|
||||
mem.writeIntLittle(u32, out[0..4], x[0]);
|
||||
mem.writeIntLittle(u32, out[4..8], x[5]);
|
||||
mem.writeIntLittle(u32, out[8..12], x[10]);
|
||||
mem.writeIntLittle(u32, out[12..16], x[15]);
|
||||
mem.writeIntLittle(u32, out[16..20], x[6]);
|
||||
mem.writeIntLittle(u32, out[20..24], x[7]);
|
||||
mem.writeIntLittle(u32, out[24..28], x[8]);
|
||||
mem.writeIntLittle(u32, out[28..32], x[9]);
|
||||
return out;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const SalsaImpl = if (builtin.cpu.arch == .x86_64) SalsaVecImpl else SalsaNonVecImpl;
|
||||
|
||||
fn keyToWords(key: [32]u8) [8]u32 {
|
||||
var k: [8]u32 = undefined;
|
||||
@@ -315,52 +311,56 @@ fn keyToWords(key: [32]u8) [8]u32 {
|
||||
return k;
|
||||
}
|
||||
|
||||
fn extend(key: [32]u8, nonce: [24]u8) struct { key: [32]u8, nonce: [8]u8 } {
|
||||
fn extend(comptime rounds: comptime_int, key: [32]u8, nonce: [24]u8) struct { key: [32]u8, nonce: [8]u8 } {
|
||||
return .{
|
||||
.key = Salsa20Impl.hsalsa20(nonce[0..16].*, key),
|
||||
.key = SalsaImpl(rounds).hsalsa(nonce[0..16].*, key),
|
||||
.nonce = nonce[16..24].*,
|
||||
};
|
||||
}
|
||||
|
||||
/// The Salsa20 stream cipher.
|
||||
pub const Salsa20 = struct {
|
||||
/// Nonce length in bytes.
|
||||
pub const nonce_length = 8;
|
||||
/// Key length in bytes.
|
||||
pub const key_length = 32;
|
||||
/// The Salsa stream cipher.
|
||||
pub fn Salsa(comptime rounds: comptime_int) type {
|
||||
return struct {
|
||||
/// Nonce length in bytes.
|
||||
pub const nonce_length = 8;
|
||||
/// Key length in bytes.
|
||||
pub const key_length = 32;
|
||||
|
||||
/// Add the output of the Salsa20 stream cipher to `in` and stores the result into `out`.
|
||||
/// WARNING: This function doesn't provide authenticated encryption.
|
||||
/// Using the AEAD or one of the `box` versions is usually preferred.
|
||||
pub fn xor(out: []u8, in: []const u8, counter: u64, key: [key_length]u8, nonce: [nonce_length]u8) void {
|
||||
debug.assert(in.len == out.len);
|
||||
/// Add the output of the Salsa stream cipher to `in` and stores the result into `out`.
|
||||
/// WARNING: This function doesn't provide authenticated encryption.
|
||||
/// Using the AEAD or one of the `box` versions is usually preferred.
|
||||
pub fn xor(out: []u8, in: []const u8, counter: u64, key: [key_length]u8, nonce: [nonce_length]u8) void {
|
||||
debug.assert(in.len == out.len);
|
||||
|
||||
var d: [4]u32 = undefined;
|
||||
d[0] = mem.readIntLittle(u32, nonce[0..4]);
|
||||
d[1] = mem.readIntLittle(u32, nonce[4..8]);
|
||||
d[2] = @truncate(u32, counter);
|
||||
d[3] = @truncate(u32, counter >> 32);
|
||||
Salsa20Impl.salsa20Xor(out, in, keyToWords(key), d);
|
||||
}
|
||||
};
|
||||
var d: [4]u32 = undefined;
|
||||
d[0] = mem.readIntLittle(u32, nonce[0..4]);
|
||||
d[1] = mem.readIntLittle(u32, nonce[4..8]);
|
||||
d[2] = @truncate(u32, counter);
|
||||
d[3] = @truncate(u32, counter >> 32);
|
||||
SalsaImpl(rounds).salsaXor(out, in, keyToWords(key), d);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// The XSalsa20 stream cipher.
|
||||
pub const XSalsa20 = struct {
|
||||
/// Nonce length in bytes.
|
||||
pub const nonce_length = 24;
|
||||
/// Key length in bytes.
|
||||
pub const key_length = 32;
|
||||
/// The XSalsa stream cipher.
|
||||
pub fn XSalsa(comptime rounds: comptime_int) type {
|
||||
return struct {
|
||||
/// Nonce length in bytes.
|
||||
pub const nonce_length = 24;
|
||||
/// Key length in bytes.
|
||||
pub const key_length = 32;
|
||||
|
||||
/// Add the output of the XSalsa20 stream cipher to `in` and stores the result into `out`.
|
||||
/// WARNING: This function doesn't provide authenticated encryption.
|
||||
/// Using the AEAD or one of the `box` versions is usually preferred.
|
||||
pub fn xor(out: []u8, in: []const u8, counter: u64, key: [key_length]u8, nonce: [nonce_length]u8) void {
|
||||
const extended = extend(key, nonce);
|
||||
Salsa20.xor(out, in, counter, extended.key, extended.nonce);
|
||||
}
|
||||
};
|
||||
/// Add the output of the XSalsa stream cipher to `in` and stores the result into `out`.
|
||||
/// WARNING: This function doesn't provide authenticated encryption.
|
||||
/// Using the AEAD or one of the `box` versions is usually preferred.
|
||||
pub fn xor(out: []u8, in: []const u8, counter: u64, key: [key_length]u8, nonce: [nonce_length]u8) void {
|
||||
const extended = extend(rounds, key, nonce);
|
||||
Salsa(rounds).xor(out, in, counter, extended.key, extended.nonce);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// The XSalsa20 stream cipher, combined with the Poly1305 MAC
|
||||
/// The XSalsa stream cipher, combined with the Poly1305 MAC
|
||||
pub const XSalsa20Poly1305 = struct {
|
||||
/// Authentication tag length in bytes.
|
||||
pub const tag_length = Poly1305.mac_length;
|
||||
@@ -369,6 +369,8 @@ pub const XSalsa20Poly1305 = struct {
|
||||
/// Key length in bytes.
|
||||
pub const key_length = XSalsa20.key_length;
|
||||
|
||||
const rounds = 20;
|
||||
|
||||
/// c: ciphertext: output buffer should be of size m.len
|
||||
/// tag: authentication tag: output MAC
|
||||
/// m: message
|
||||
@@ -377,7 +379,7 @@ pub const XSalsa20Poly1305 = struct {
|
||||
/// k: private key
|
||||
pub fn encrypt(c: []u8, tag: *[tag_length]u8, m: []const u8, ad: []const u8, npub: [nonce_length]u8, k: [key_length]u8) void {
|
||||
debug.assert(c.len == m.len);
|
||||
const extended = extend(k, npub);
|
||||
const extended = extend(rounds, k, npub);
|
||||
var block0 = [_]u8{0} ** 64;
|
||||
const mlen0 = math.min(32, m.len);
|
||||
mem.copy(u8, block0[32..][0..mlen0], m[0..mlen0]);
|
||||
@@ -398,7 +400,7 @@ pub const XSalsa20Poly1305 = struct {
|
||||
/// k: private key
|
||||
pub fn decrypt(m: []u8, c: []const u8, tag: [tag_length]u8, ad: []const u8, npub: [nonce_length]u8, k: [key_length]u8) AuthenticationError!void {
|
||||
debug.assert(c.len == m.len);
|
||||
const extended = extend(k, npub);
|
||||
const extended = extend(rounds, k, npub);
|
||||
var block0 = [_]u8{0} ** 64;
|
||||
const mlen0 = math.min(32, c.len);
|
||||
mem.copy(u8, block0[32..][0..mlen0], c[0..mlen0]);
|
||||
@@ -482,7 +484,7 @@ pub const Box = struct {
|
||||
pub fn createSharedSecret(public_key: [public_length]u8, secret_key: [secret_length]u8) (IdentityElementError || WeakPublicKeyError)![shared_length]u8 {
|
||||
const p = try X25519.scalarmult(secret_key, public_key);
|
||||
const zero = [_]u8{0} ** 16;
|
||||
return Salsa20Impl.hsalsa20(zero, p);
|
||||
return SalsaImpl(20).hsalsa(zero, p);
|
||||
}
|
||||
|
||||
/// Encrypt and authenticate a message using a recipient's public key `public_key` and a sender's `secret_key`.
|
||||
|
||||
@@ -1110,7 +1110,12 @@ fn readMachODebugInfo(allocator: mem.Allocator, macho_file: File) !ModuleDebugIn
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
assert(state == .oso_close);
|
||||
|
||||
switch (state) {
|
||||
.init => return error.MissingDebugInfo,
|
||||
.oso_close => {},
|
||||
else => return error.InvalidDebugInfo,
|
||||
}
|
||||
|
||||
const symbols = allocator.shrink(symbols_buf, symbol_index);
|
||||
|
||||
@@ -2024,9 +2029,14 @@ pub fn dumpStackPointerAddr(prefix: []const u8) void {
|
||||
std.debug.print("{} sp = 0x{x}\n", .{ prefix, sp });
|
||||
}
|
||||
|
||||
test "#4353: std.debug should manage resources correctly" {
|
||||
test "manage resources correctly" {
|
||||
if (builtin.os.tag == .wasi) return error.SkipZigTest;
|
||||
|
||||
if (builtin.os.tag == .windows and builtin.cpu.arch == .x86_64) {
|
||||
// https://github.com/ziglang/zig/issues/13963
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
|
||||
const writer = std.io.null_writer;
|
||||
var di = try openSelfDebugInfo(testing.allocator);
|
||||
defer di.deinit();
|
||||
|
||||
@@ -169,7 +169,8 @@ fn errolSlow(val: f64, buffer: []u8) FloatDecimal {
|
||||
|
||||
// digit generation
|
||||
var buf_index: usize = 0;
|
||||
while (true) {
|
||||
const bound = buffer.len - 1;
|
||||
while (buf_index < bound) {
|
||||
var hdig = @floatToInt(u8, @floor(high.val));
|
||||
if ((high.val == @intToFloat(f64, hdig)) and (high.off < 0)) hdig -= 1;
|
||||
|
||||
|
||||
@@ -34,7 +34,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, .haiku, .solaris => os.PATH_MAX,
|
||||
.linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .haiku, .solaris => 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.
|
||||
@@ -54,10 +54,10 @@ pub const MAX_PATH_BYTES = switch (builtin.os.tag) {
|
||||
/// (depending on the platform) this assumption may not hold for every configuration.
|
||||
/// The byte count does not include a null sentinel byte.
|
||||
pub const MAX_NAME_BYTES = switch (builtin.os.tag) {
|
||||
.linux, .macos, .ios, .freebsd, .dragonfly => os.NAME_MAX,
|
||||
.linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly => os.NAME_MAX,
|
||||
// Haiku's NAME_MAX includes the null terminator, so subtract one.
|
||||
.haiku => os.NAME_MAX - 1,
|
||||
.netbsd, .openbsd, .solaris => os.MAXNAMLEN,
|
||||
.solaris => os.system.MAXNAMLEN,
|
||||
// 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.
|
||||
@@ -809,7 +809,9 @@ pub const IterableDir = struct {
|
||||
// and we avoid the code complexity here.
|
||||
const w = os.wasi;
|
||||
start_over: while (true) {
|
||||
if (self.index >= self.end_index) {
|
||||
// According to the WASI spec, the last entry might be truncated,
|
||||
// so we need to check if the left buffer contains the whole dirent.
|
||||
if (self.end_index - self.index < @sizeOf(w.dirent_t)) {
|
||||
var bufused: usize = undefined;
|
||||
switch (w.fd_readdir(self.dir.fd, &self.buf, self.buf.len, self.cookie, &bufused)) {
|
||||
.SUCCESS => {},
|
||||
@@ -828,6 +830,11 @@ pub const IterableDir = struct {
|
||||
const entry = @ptrCast(*align(1) w.dirent_t, &self.buf[self.index]);
|
||||
const entry_size = @sizeOf(w.dirent_t);
|
||||
const name_index = self.index + entry_size;
|
||||
if (name_index + entry.d_namlen > self.end_index) {
|
||||
// This case, the name is truncated, so we need to call readdir to store the entire name.
|
||||
self.end_index = self.index; // Force fd_readdir in the next loop.
|
||||
continue :start_over;
|
||||
}
|
||||
const name = mem.span(self.buf[name_index .. name_index + entry.d_namlen]);
|
||||
|
||||
const next_index = name_index + entry.d_namlen;
|
||||
@@ -1815,6 +1822,9 @@ pub const Dir = struct {
|
||||
.OBJECT_NAME_NOT_FOUND => return error.FileNotFound,
|
||||
.OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
|
||||
.NOT_A_DIRECTORY => return error.NotDir,
|
||||
// This can happen if the directory has 'List folder contents' permission set to 'Deny'
|
||||
// and the directory is trying to be opened for iteration.
|
||||
.ACCESS_DENIED => return error.AccessDenied,
|
||||
.INVALID_PARAMETER => unreachable,
|
||||
else => return w.unexpectedStatus(rc),
|
||||
}
|
||||
|
||||
@@ -186,6 +186,43 @@ test "Dir.Iterator" {
|
||||
try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory }));
|
||||
}
|
||||
|
||||
test "Dir.Iterator many entries" {
|
||||
if (builtin.os.tag == .wasi and !builtin.link_libc) try os.initPreopensWasi(std.heap.page_allocator, "/");
|
||||
|
||||
var tmp_dir = tmpIterableDir(.{});
|
||||
defer tmp_dir.cleanup();
|
||||
|
||||
const num = 1024;
|
||||
var i: usize = 0;
|
||||
var buf: [4]u8 = undefined; // Enough to store "1024".
|
||||
while (i < num) : (i += 1) {
|
||||
const name = try std.fmt.bufPrint(&buf, "{}", .{i});
|
||||
const file = try tmp_dir.iterable_dir.dir.createFile(name, .{});
|
||||
file.close();
|
||||
}
|
||||
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
var entries = std.ArrayList(IterableDir.Entry).init(allocator);
|
||||
|
||||
// Create iterator.
|
||||
var iter = tmp_dir.iterable_dir.iterate();
|
||||
while (try iter.next()) |entry| {
|
||||
// We cannot just store `entry` as on Windows, we're re-using the name buffer
|
||||
// which means we'll actually share the `name` pointer between entries!
|
||||
const name = try allocator.dupe(u8, entry.name);
|
||||
try entries.append(.{ .name = name, .kind = entry.kind });
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < num) : (i += 1) {
|
||||
const name = try std.fmt.bufPrint(&buf, "{}", .{i});
|
||||
try testing.expect(contains(&entries, .{ .name = name, .kind = .File }));
|
||||
}
|
||||
}
|
||||
|
||||
test "Dir.Iterator twice" {
|
||||
var tmp_dir = tmpIterableDir(.{});
|
||||
defer tmp_dir.cleanup();
|
||||
@@ -414,8 +451,8 @@ test "file operations on directories" {
|
||||
try testing.expectError(error.IsDir, tmp_dir.dir.createFile(test_dir_name, .{}));
|
||||
try testing.expectError(error.IsDir, tmp_dir.dir.deleteFile(test_dir_name));
|
||||
switch (builtin.os.tag) {
|
||||
// NetBSD does not error when reading a directory.
|
||||
.netbsd => {},
|
||||
// no error when reading a directory.
|
||||
.dragonfly, .netbsd => {},
|
||||
// Currently, WASI will return error.Unexpected (via ENOTCAPABLE) when attempting fd_read on a directory handle.
|
||||
// TODO: Re-enable on WASI once https://github.com/bytecodealliance/wasmtime/issues/1935 is resolved.
|
||||
.wasi => {},
|
||||
|
||||
@@ -746,7 +746,7 @@ pub const FixedBufferAllocator = struct {
|
||||
}
|
||||
|
||||
/// Provides a lock free thread safe `Allocator` interface to the underlying `FixedBufferAllocator`
|
||||
/// *WARNING* using this at the same time as the interface returned by `getAllocator` is not thread safe
|
||||
/// *WARNING* using this at the same time as the interface returned by `allocator` is not thread safe
|
||||
pub fn threadSafeAllocator(self: *FixedBufferAllocator) Allocator {
|
||||
return Allocator.init(
|
||||
self,
|
||||
@@ -855,6 +855,9 @@ pub const FixedBufferAllocator = struct {
|
||||
|
||||
pub const ThreadSafeFixedBufferAllocator = @compileError("ThreadSafeFixedBufferAllocator has been replaced with `threadSafeAllocator` on FixedBufferAllocator");
|
||||
|
||||
/// Returns a `StackFallbackAllocator` allocating using either a
|
||||
/// `FixedBufferAllocator` on an array of size `size` and falling back to
|
||||
/// `fallback_allocator` if that fails.
|
||||
pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackFallbackAllocator(size) {
|
||||
return StackFallbackAllocator(size){
|
||||
.buffer = undefined,
|
||||
@@ -863,6 +866,10 @@ pub fn stackFallback(comptime size: usize, fallback_allocator: Allocator) StackF
|
||||
};
|
||||
}
|
||||
|
||||
/// An allocator that attempts to allocate using a
|
||||
/// `FixedBufferAllocator` using an array of size `size`. If the
|
||||
/// allocation fails, it will fall back to using
|
||||
/// `fallback_allocator`. Easily created with `stackFallback`.
|
||||
pub fn StackFallbackAllocator(comptime size: usize) type {
|
||||
return struct {
|
||||
const Self = @This();
|
||||
@@ -998,6 +1005,9 @@ test "PageAllocator" {
|
||||
|
||||
test "HeapAllocator" {
|
||||
if (builtin.os.tag == .windows) {
|
||||
// https://github.com/ziglang/zig/issues/13702
|
||||
if (builtin.cpu.arch == .aarch64) return error.SkipZigTest;
|
||||
|
||||
var heap_allocator = HeapAllocator.init();
|
||||
defer heap_allocator.deinit();
|
||||
const allocator = heap_allocator.allocator();
|
||||
|
||||
@@ -1912,3 +1912,90 @@ pub const LoadCommandIterator = struct {
|
||||
return cmd;
|
||||
}
|
||||
};
|
||||
|
||||
pub const compact_unwind_encoding_t = u32;
|
||||
|
||||
// Relocatable object files: __LD,__compact_unwind
|
||||
|
||||
pub const compact_unwind_entry = extern struct {
|
||||
rangeStart: u64,
|
||||
rangeLength: u32,
|
||||
compactUnwindEncoding: u32,
|
||||
personalityFunction: u64,
|
||||
lsda: u64,
|
||||
};
|
||||
|
||||
// Final linked images: __TEXT,__unwind_info
|
||||
// The __TEXT,__unwind_info section is laid out for an efficient two level lookup.
|
||||
// The header of the section contains a coarse index that maps function address
|
||||
// to the page (4096 byte block) containing the unwind info for that function.
|
||||
|
||||
pub const UNWIND_SECTION_VERSION = 1;
|
||||
pub const UNWIND_SECOND_LEVEL_REGULAR = 2;
|
||||
pub const UNWIND_SECOND_LEVEL_COMPRESSED = 3;
|
||||
|
||||
pub const unwind_info_section_header = extern struct {
|
||||
/// UNWIND_SECTION_VERSION
|
||||
version: u32 = UNWIND_SECTION_VERSION,
|
||||
commonEncodingsArraySectionOffset: u32,
|
||||
commonEncodingsArrayCount: u32,
|
||||
personalityArraySectionOffset: u32,
|
||||
personalityArrayCount: u32,
|
||||
indexSectionOffset: u32,
|
||||
indexCount: u32,
|
||||
// compact_unwind_encoding_t[]
|
||||
// uint32_t personalities[]
|
||||
// unwind_info_section_header_index_entry[]
|
||||
// unwind_info_section_header_lsda_index_entry[]
|
||||
};
|
||||
|
||||
pub const unwind_info_section_header_index_entry = extern struct {
|
||||
functionOffset: u32,
|
||||
|
||||
/// section offset to start of regular or compress page
|
||||
secondLevelPagesSectionOffset: u32,
|
||||
|
||||
/// section offset to start of lsda_index array for this range
|
||||
lsdaIndexArraySectionOffset: u32,
|
||||
};
|
||||
|
||||
pub const unwind_info_section_header_lsda_index_entry = extern struct {
|
||||
functionOffset: u32,
|
||||
lsdaOffset: u32,
|
||||
};
|
||||
|
||||
// There are two kinds of second level index pages: regular and compressed.
|
||||
// A compressed page can hold up to 1021 entries, but it cannot be used if
|
||||
// too many different encoding types are used. The regular page holds 511
|
||||
// entries.
|
||||
|
||||
pub const unwind_info_regular_second_level_entry = extern struct {
|
||||
functionOffset: u32,
|
||||
encoding: compact_unwind_encoding_t,
|
||||
};
|
||||
|
||||
pub const unwind_info_regular_second_level_page_header = extern struct {
|
||||
/// UNWIND_SECOND_LEVEL_REGULAR
|
||||
kind: u32 = UNWIND_SECOND_LEVEL_REGULAR,
|
||||
|
||||
entryPageOffset: u16,
|
||||
entryCount: u16,
|
||||
// entry array
|
||||
};
|
||||
|
||||
pub const unwind_info_compressed_second_level_page_header = extern struct {
|
||||
/// UNWIND_SECOND_LEVEL_COMPRESSED
|
||||
kind: u32 = UNWIND_SECOND_LEVEL_COMPRESSED,
|
||||
|
||||
entryPageOffset: u16,
|
||||
entryCount: u16,
|
||||
encodingsPageOffset: u16,
|
||||
encodingsCount: u16,
|
||||
// 32bit entry array
|
||||
// encodings array
|
||||
};
|
||||
|
||||
pub const UnwindInfoCompressedEntry = packed struct(u32) {
|
||||
funcOffset: u24,
|
||||
encodingIndex: u8,
|
||||
};
|
||||
|
||||
@@ -238,12 +238,14 @@ pub const Mutable = struct {
|
||||
self.limbs[0] = w_value;
|
||||
} else {
|
||||
var i: usize = 0;
|
||||
while (w_value != 0) : (i += 1) {
|
||||
while (true) : (i += 1) {
|
||||
self.limbs[i] = @truncate(Limb, w_value);
|
||||
|
||||
// TODO: shift == 64 at compile-time fails. Fails on u128 limbs.
|
||||
w_value >>= limb_bits / 2;
|
||||
w_value >>= limb_bits / 2;
|
||||
|
||||
if (w_value == 0) break;
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -256,11 +258,13 @@ pub const Mutable = struct {
|
||||
const mask = (1 << limb_bits) - 1;
|
||||
|
||||
comptime var i = 0;
|
||||
inline while (w_value != 0) : (i += 1) {
|
||||
inline while (true) : (i += 1) {
|
||||
self.limbs[i] = w_value & mask;
|
||||
|
||||
w_value >>= limb_bits / 2;
|
||||
w_value >>= limb_bits / 2;
|
||||
|
||||
if (w_value == 0) break;
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1172,15 +1176,26 @@ pub const Mutable = struct {
|
||||
/// `a.limbs.len - (shift / (@sizeOf(Limb) * 8))`.
|
||||
pub fn shiftRight(r: *Mutable, a: Const, shift: usize) void {
|
||||
if (a.limbs.len <= shift / limb_bits) {
|
||||
r.len = 1;
|
||||
r.positive = true;
|
||||
r.limbs[0] = 0;
|
||||
// Shifting negative numbers converges to -1 instead of 0
|
||||
if (a.positive) {
|
||||
r.len = 1;
|
||||
r.positive = true;
|
||||
r.limbs[0] = 0;
|
||||
} else {
|
||||
r.len = 1;
|
||||
r.positive = false;
|
||||
r.limbs[0] = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
llshr(r.limbs[0..], a.limbs[0..a.limbs.len], shift);
|
||||
r.normalize(a.limbs.len - (shift / limb_bits));
|
||||
r.positive = a.positive;
|
||||
// Shifting negative numbers converges to -1 instead of 0
|
||||
if (!r.positive and r.len == 1 and r.limbs[0] == 0) {
|
||||
r.limbs[0] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// r = ~a under 2s complement wrapping semantics.
|
||||
@@ -2896,8 +2911,15 @@ pub const Managed = struct {
|
||||
/// r and a may alias.
|
||||
pub fn shiftRight(r: *Managed, a: *const Managed, shift: usize) !void {
|
||||
if (a.len() <= shift / limb_bits) {
|
||||
r.metadata = 1;
|
||||
r.limbs[0] = 0;
|
||||
// Shifting negative numbers converges to -1 instead of 0
|
||||
if (a.isPositive()) {
|
||||
r.metadata = 1;
|
||||
r.limbs[0] = 0;
|
||||
} else {
|
||||
r.metadata = 1;
|
||||
r.setSign(false);
|
||||
r.limbs[0] = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,14 @@ test "big.int set negative minimum" {
|
||||
try testing.expect((try a.to(i64)) == minInt(i64));
|
||||
}
|
||||
|
||||
test "big.int set double-width maximum then zero" {
|
||||
var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb));
|
||||
defer a.deinit();
|
||||
try a.set(@as(DoubleLimb, 0));
|
||||
|
||||
try testing.expectEqual(@as(DoubleLimb, 0), try a.to(DoubleLimb));
|
||||
}
|
||||
|
||||
test "big.int to target too small error" {
|
||||
var a = try Managed.initSet(testing.allocator, 0xffffffff);
|
||||
defer a.deinit();
|
||||
@@ -508,8 +516,8 @@ test "big.int add multi-single" {
|
||||
}
|
||||
|
||||
test "big.int add multi-multi" {
|
||||
const op1 = 0xefefefef7f7f7f7f;
|
||||
const op2 = 0xfefefefe9f9f9f9f;
|
||||
var op1: u128 = 0xefefefef7f7f7f7f;
|
||||
var op2: u128 = 0xfefefefe9f9f9f9f;
|
||||
var a = try Managed.initSet(testing.allocator, op1);
|
||||
defer a.deinit();
|
||||
var b = try Managed.initSet(testing.allocator, op2);
|
||||
@@ -822,8 +830,8 @@ test "big.int sub multi-single" {
|
||||
}
|
||||
|
||||
test "big.int sub multi-multi" {
|
||||
const op1 = 0xefefefefefefefefefefefef;
|
||||
const op2 = 0xabababababababababababab;
|
||||
var op1: u128 = 0xefefefefefefefefefefefef;
|
||||
var op2: u128 = 0xabababababababababababab;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, op1);
|
||||
defer a.deinit();
|
||||
@@ -906,8 +914,8 @@ test "big.int mul multi-single" {
|
||||
}
|
||||
|
||||
test "big.int mul multi-multi" {
|
||||
const op1 = 0x998888efefefefefefefef;
|
||||
const op2 = 0x333000abababababababab;
|
||||
var op1: u256 = 0x998888efefefefefefefef;
|
||||
var op2: u256 = 0x333000abababababababab;
|
||||
var a = try Managed.initSet(testing.allocator, op1);
|
||||
defer a.deinit();
|
||||
var b = try Managed.initSet(testing.allocator, op2);
|
||||
@@ -1025,8 +1033,8 @@ test "big.int mulWrap single-single signed" {
|
||||
}
|
||||
|
||||
test "big.int mulWrap multi-multi unsigned" {
|
||||
const op1 = 0x998888efefefefefefefef;
|
||||
const op2 = 0x333000abababababababab;
|
||||
var op1: u256 = 0x998888efefefefefefefef;
|
||||
var op2: u256 = 0x333000abababababababab;
|
||||
var a = try Managed.initSet(testing.allocator, op1);
|
||||
defer a.deinit();
|
||||
var b = try Managed.initSet(testing.allocator, op2);
|
||||
@@ -1036,7 +1044,7 @@ test "big.int mulWrap multi-multi unsigned" {
|
||||
defer c.deinit();
|
||||
try c.mulWrap(&a, &b, .unsigned, 65);
|
||||
|
||||
try testing.expect((try c.to(u128)) == (op1 * op2) & ((1 << 65) - 1));
|
||||
try testing.expect((try c.to(u256)) == (op1 * op2) & ((1 << 65) - 1));
|
||||
}
|
||||
|
||||
test "big.int mulWrap multi-multi signed" {
|
||||
@@ -1142,8 +1150,8 @@ test "big.int div single-single with rem" {
|
||||
}
|
||||
|
||||
test "big.int div multi-single no rem" {
|
||||
const op1 = 0xffffeeeeddddcccc;
|
||||
const op2 = 34;
|
||||
var op1: u128 = 0xffffeeeeddddcccc;
|
||||
var op2: u128 = 34;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, op1);
|
||||
defer a.deinit();
|
||||
@@ -1161,8 +1169,8 @@ test "big.int div multi-single no rem" {
|
||||
}
|
||||
|
||||
test "big.int div multi-single with rem" {
|
||||
const op1 = 0xffffeeeeddddcccf;
|
||||
const op2 = 34;
|
||||
var op1: u128 = 0xffffeeeeddddcccf;
|
||||
var op2: u128 = 34;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, op1);
|
||||
defer a.deinit();
|
||||
@@ -1180,8 +1188,8 @@ test "big.int div multi-single with rem" {
|
||||
}
|
||||
|
||||
test "big.int div multi>2-single" {
|
||||
const op1 = 0xfefefefefefefefefefefefefefefefe;
|
||||
const op2 = 0xefab8;
|
||||
var op1: u128 = 0xfefefefefefefefefefefefefefefefe;
|
||||
var op2: u128 = 0xefab8;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, op1);
|
||||
defer a.deinit();
|
||||
@@ -1973,22 +1981,22 @@ test "big.int shift-right negative" {
|
||||
var arg = try Managed.initSet(testing.allocator, -20);
|
||||
defer arg.deinit();
|
||||
try a.shiftRight(&arg, 2);
|
||||
try testing.expect((try a.to(i32)) == -20 >> 2);
|
||||
try testing.expect((try a.to(i32)) == -5); // -20 >> 2 == -5
|
||||
|
||||
var arg2 = try Managed.initSet(testing.allocator, -5);
|
||||
defer arg2.deinit();
|
||||
try a.shiftRight(&arg2, 10);
|
||||
try testing.expect((try a.to(i32)) == -5 >> 10);
|
||||
try testing.expect((try a.to(i32)) == -1); // -5 >> 10 == -1
|
||||
}
|
||||
|
||||
test "big.int shift-left negative" {
|
||||
test "big.int shift-right negative" {
|
||||
var a = try Managed.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
var arg = try Managed.initSet(testing.allocator, -10);
|
||||
defer arg.deinit();
|
||||
try a.shiftRight(&arg, 1232);
|
||||
try testing.expect((try a.to(i32)) == -10 >> 1232);
|
||||
try testing.expect((try a.to(i32)) == -1); // -10 >> 1232 == -1
|
||||
}
|
||||
|
||||
test "big.int sat shift-left simple unsigned" {
|
||||
@@ -2056,34 +2064,35 @@ test "big.int sat shift-left signed simple positive" {
|
||||
}
|
||||
|
||||
test "big.int sat shift-left signed multi positive" {
|
||||
const x = 1;
|
||||
var x: SignedDoubleLimb = 1;
|
||||
const shift = @bitSizeOf(SignedDoubleLimb) - 1;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, x);
|
||||
defer a.deinit();
|
||||
try a.shiftLeftSat(&a, shift, .signed, @bitSizeOf(SignedDoubleLimb));
|
||||
|
||||
try testing.expect((try a.to(SignedDoubleLimb)) == @as(SignedDoubleLimb, x) <<| shift);
|
||||
try testing.expect((try a.to(SignedDoubleLimb)) == x <<| shift);
|
||||
}
|
||||
|
||||
test "big.int sat shift-left signed multi negative" {
|
||||
const x = -1;
|
||||
var x: SignedDoubleLimb = -1;
|
||||
const shift = @bitSizeOf(SignedDoubleLimb) - 1;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, x);
|
||||
defer a.deinit();
|
||||
try a.shiftLeftSat(&a, shift, .signed, @bitSizeOf(SignedDoubleLimb));
|
||||
|
||||
try testing.expect((try a.to(SignedDoubleLimb)) == @as(SignedDoubleLimb, x) <<| shift);
|
||||
try testing.expect((try a.to(SignedDoubleLimb)) == x <<| shift);
|
||||
}
|
||||
|
||||
test "big.int bitNotWrap unsigned simple" {
|
||||
var a = try Managed.initSet(testing.allocator, 123);
|
||||
var x: u10 = 123;
|
||||
var a = try Managed.initSet(testing.allocator, x);
|
||||
defer a.deinit();
|
||||
|
||||
try a.bitNotWrap(&a, .unsigned, 10);
|
||||
|
||||
try testing.expect((try a.to(u10)) == ~@as(u10, 123));
|
||||
try testing.expect((try a.to(u10)) == ~x);
|
||||
}
|
||||
|
||||
test "big.int bitNotWrap unsigned multi" {
|
||||
@@ -2096,12 +2105,13 @@ test "big.int bitNotWrap unsigned multi" {
|
||||
}
|
||||
|
||||
test "big.int bitNotWrap signed simple" {
|
||||
var x: i11 = -456;
|
||||
var a = try Managed.initSet(testing.allocator, -456);
|
||||
defer a.deinit();
|
||||
|
||||
try a.bitNotWrap(&a, .signed, 11);
|
||||
|
||||
try testing.expect((try a.to(i11)) == ~@as(i11, -456));
|
||||
try testing.expect((try a.to(i11)) == ~x);
|
||||
}
|
||||
|
||||
test "big.int bitNotWrap signed multi" {
|
||||
@@ -2224,14 +2234,16 @@ test "big.int bitwise xor simple" {
|
||||
}
|
||||
|
||||
test "big.int bitwise xor multi-limb" {
|
||||
var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1);
|
||||
var x: DoubleLimb = maxInt(Limb) + 1;
|
||||
var y: DoubleLimb = maxInt(Limb);
|
||||
var a = try Managed.initSet(testing.allocator, x);
|
||||
defer a.deinit();
|
||||
var b = try Managed.initSet(testing.allocator, maxInt(Limb));
|
||||
var b = try Managed.initSet(testing.allocator, y);
|
||||
defer b.deinit();
|
||||
|
||||
try a.bitXor(&a, &b);
|
||||
|
||||
try testing.expect((try a.to(DoubleLimb)) == (maxInt(Limb) + 1) ^ maxInt(Limb));
|
||||
try testing.expect((try a.to(DoubleLimb)) == x ^ y);
|
||||
}
|
||||
|
||||
test "big.int bitwise xor single negative simple" {
|
||||
@@ -2319,7 +2331,6 @@ test "big.int bitwise or multi-limb" {
|
||||
|
||||
try a.bitOr(&a, &b);
|
||||
|
||||
// TODO: big.int.cpp or is wrong on multi-limb.
|
||||
try testing.expect((try a.to(DoubleLimb)) == (maxInt(Limb) + 1) + maxInt(Limb));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const std = @import("../std.zig");
|
||||
const builtin = @import("builtin");
|
||||
const math = std.math;
|
||||
const expect = std.testing.expect;
|
||||
|
||||
@@ -42,6 +43,9 @@ pub fn log2(x: anytype) @TypeOf(x) {
|
||||
}
|
||||
|
||||
test "log2" {
|
||||
// https://github.com/ziglang/zig/issues/13703
|
||||
if (builtin.cpu.arch == .aarch64 and builtin.os.tag == .windows) return error.SkipZigTest;
|
||||
|
||||
try expect(log2(@as(f32, 0.2)) == @log2(0.2));
|
||||
try expect(log2(@as(f64, 0.2)) == @log2(0.2));
|
||||
comptime {
|
||||
|
||||
@@ -285,7 +285,14 @@ pub fn zeroes(comptime T: type) T {
|
||||
.Pointer => |ptr_info| {
|
||||
switch (ptr_info.size) {
|
||||
.Slice => {
|
||||
return &[_]ptr_info.child{};
|
||||
if (ptr_info.sentinel) |sentinel| {
|
||||
if (ptr_info.child == u8 and @ptrCast(*const u8, sentinel).* == 0) {
|
||||
return ""; // A special case for the most common use-case: null-terminated strings.
|
||||
}
|
||||
@compileError("Can't set a sentinel slice to zero. This would require allocating memory.");
|
||||
} else {
|
||||
return &[_]ptr_info.child{};
|
||||
}
|
||||
},
|
||||
.C => {
|
||||
return null;
|
||||
@@ -373,6 +380,7 @@ test "zeroes" {
|
||||
optional: ?*u8,
|
||||
c_pointer: [*c]u8,
|
||||
slice: []u8,
|
||||
nullTerminatedString: [:0]const u8,
|
||||
},
|
||||
|
||||
array: [2]u32,
|
||||
@@ -403,6 +411,7 @@ test "zeroes" {
|
||||
try testing.expectEqual(@as(?*u8, null), b.pointers.optional);
|
||||
try testing.expectEqual(@as([*c]u8, null), b.pointers.c_pointer);
|
||||
try testing.expectEqual(@as([]u8, &[_]u8{}), b.pointers.slice);
|
||||
try testing.expectEqual(@as([:0]const u8, ""), b.pointers.nullTerminatedString);
|
||||
for (b.array) |e| {
|
||||
try testing.expectEqual(@as(u32, 0), e);
|
||||
}
|
||||
@@ -2891,6 +2900,7 @@ test "rotate" {
|
||||
/// Replace needle with replacement as many times as possible, writing to an output buffer which is assumed to be of
|
||||
/// appropriate size. Use replacementSize to calculate an appropriate buffer size.
|
||||
/// The needle must not be empty.
|
||||
/// Returns the number of replacements made.
|
||||
pub fn replace(comptime T: type, input: []const T, needle: []const T, replacement: []const T, output: []T) usize {
|
||||
// Empty needle will loop until output buffer overflows.
|
||||
assert(needle.len > 0);
|
||||
|
||||
@@ -167,7 +167,7 @@ pub inline fn rawFree(self: Allocator, buf: []u8, buf_align: u29, ret_addr: usiz
|
||||
/// Returns a pointer to undefined memory.
|
||||
/// Call `destroy` with the result to free the memory.
|
||||
pub fn create(self: Allocator, comptime T: type) Error!*T {
|
||||
if (@sizeOf(T) == 0) return @as(*T, undefined);
|
||||
if (@sizeOf(T) == 0) return @intToPtr(*T, std.math.maxInt(usize));
|
||||
const slice = try self.allocAdvancedWithRetAddr(T, null, 1, .exact, @returnAddress());
|
||||
return &slice[0];
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ test "std.meta.isTag for Tagged Unions" {
|
||||
try testing.expect(!isTag(flt, "int"));
|
||||
}
|
||||
|
||||
/// Returns the variant of an enum type, `T`, which is named `str`, or `null` if no such variant exists.
|
||||
pub fn stringToEnum(comptime T: type, str: []const u8) ?T {
|
||||
// Using ComptimeStringMap here is more performant, but it will start to take too
|
||||
// long to compile if the enum is large enough, due to the current limits of comptime
|
||||
@@ -192,6 +193,7 @@ test "std.meta.alignment" {
|
||||
try testing.expect(alignment(fn () align(128) void) == 128);
|
||||
}
|
||||
|
||||
/// Given a parameterized type (array, vector, pointer, optional), returns the "child type".
|
||||
pub fn Child(comptime T: type) type {
|
||||
return switch (@typeInfo(T)) {
|
||||
.Array => |info| info.child,
|
||||
@@ -210,7 +212,7 @@ test "std.meta.Child" {
|
||||
try testing.expect(Child(Vector(2, u8)) == u8);
|
||||
}
|
||||
|
||||
/// Given a "memory span" type, returns the "element type".
|
||||
/// Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type".
|
||||
pub fn Elem(comptime T: type) type {
|
||||
switch (@typeInfo(T)) {
|
||||
.Array => |info| return info.child,
|
||||
@@ -302,7 +304,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
|
||||
.Array = .{
|
||||
.len = array_info.len,
|
||||
.child = array_info.child,
|
||||
.sentinel = &sentinel_val,
|
||||
.sentinel = @ptrCast(?*const anyopaque, &sentinel_val),
|
||||
},
|
||||
}),
|
||||
.is_allowzero = info.is_allowzero,
|
||||
@@ -320,7 +322,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
|
||||
.address_space = info.address_space,
|
||||
.child = info.child,
|
||||
.is_allowzero = info.is_allowzero,
|
||||
.sentinel = &sentinel_val,
|
||||
.sentinel = @ptrCast(?*const anyopaque, &sentinel_val),
|
||||
},
|
||||
}),
|
||||
else => {},
|
||||
@@ -338,7 +340,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
|
||||
.address_space = ptr_info.address_space,
|
||||
.child = ptr_info.child,
|
||||
.is_allowzero = ptr_info.is_allowzero,
|
||||
.sentinel = &sentinel_val,
|
||||
.sentinel = @ptrCast(?*const anyopaque, &sentinel_val),
|
||||
},
|
||||
}),
|
||||
},
|
||||
@@ -505,7 +507,6 @@ test "std.meta.declarationInfo" {
|
||||
try testing.expect(!info.is_pub);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fields(comptime T: type) switch (@typeInfo(T)) {
|
||||
.Struct => []const Type.StructField,
|
||||
.Union => []const Type.UnionField,
|
||||
@@ -652,6 +653,7 @@ test "std.meta.tags" {
|
||||
try testing.expectEqual(E2.A, e2_tags[0]);
|
||||
}
|
||||
|
||||
/// Returns an enum with a variant named after each field of `T`.
|
||||
pub fn FieldEnum(comptime T: type) type {
|
||||
const field_infos = fields(T);
|
||||
|
||||
|
||||
@@ -436,9 +436,15 @@ pub fn MultiArrayList(comptime S: type) type {
|
||||
}
|
||||
|
||||
fn capacityInBytes(capacity: usize) usize {
|
||||
const sizes_vector: @Vector(sizes.bytes.len, usize) = sizes.bytes;
|
||||
const capacity_vector = @splat(sizes.bytes.len, capacity);
|
||||
return @reduce(.Add, capacity_vector * sizes_vector);
|
||||
if (builtin.zig_backend == .stage2_c) {
|
||||
var bytes: usize = 0;
|
||||
for (sizes.bytes) |size| bytes += size * capacity;
|
||||
return bytes;
|
||||
} else {
|
||||
const sizes_vector: @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 {
|
||||
|
||||
@@ -869,21 +869,21 @@ fn linuxLookupName(
|
||||
} else {
|
||||
try linuxLookupNameFromHosts(addrs, canon, name, family, port);
|
||||
if (addrs.items.len == 0) {
|
||||
try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port);
|
||||
}
|
||||
if (addrs.items.len == 0) {
|
||||
// RFC 6761 Section 6.3
|
||||
// RFC 6761 Section 6.3.3
|
||||
// Name resolution APIs and libraries SHOULD recognize localhost
|
||||
// names as special and SHOULD always return the IP loopback address
|
||||
// for address queries and negative responses for all other query
|
||||
// types.
|
||||
|
||||
// Check for equal to "localhost" or ends in ".localhost"
|
||||
if (mem.endsWith(u8, name, "localhost") and (name.len == "localhost".len or name[name.len - "localhost".len] == '.')) {
|
||||
// Check for equal to "localhost(.)" or ends in ".localhost(.)"
|
||||
const localhost = if (name[name.len - 1] == '.') "localhost." else "localhost";
|
||||
if (mem.endsWith(u8, name, localhost) and (name.len == localhost.len or name[name.len - localhost.len] == '.')) {
|
||||
try addrs.append(LookupAddr{ .addr = .{ .in = Ip4Address.parse("127.0.0.1", port) catch unreachable } });
|
||||
try addrs.append(LookupAddr{ .addr = .{ .in6 = Ip6Address.parse("::1", port) catch unreachable } });
|
||||
return;
|
||||
}
|
||||
|
||||
try linuxLookupNameFromDnsSearch(addrs, canon, name, family, port);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -660,6 +660,7 @@ pub const ReadError = error{
|
||||
/// The limit on Darwin is `0x7fffffff`, trying to read more than that returns EINVAL.
|
||||
/// The corresponding POSIX limit is `math.maxInt(isize)`.
|
||||
pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
|
||||
if (buf.len == 0) return 0;
|
||||
if (builtin.os.tag == .windows) {
|
||||
return windows.ReadFile(fd, buf, null, std.io.default_mode);
|
||||
}
|
||||
@@ -787,6 +788,7 @@ pub const PReadError = ReadError || error{Unseekable};
|
||||
/// 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 (buf.len == 0) return 0;
|
||||
if (builtin.os.tag == .windows) {
|
||||
return windows.ReadFile(fd, buf, offset, std.io.default_mode);
|
||||
}
|
||||
@@ -1045,6 +1047,7 @@ pub const WriteError = error{
|
||||
/// The limit on Darwin is `0x7fffffff`, trying to read more than that returns EINVAL.
|
||||
/// The corresponding POSIX limit is `math.maxInt(isize)`.
|
||||
pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
|
||||
if (bytes.len == 0) return 0;
|
||||
if (builtin.os.tag == .windows) {
|
||||
return windows.WriteFile(fd, bytes, null, std.io.default_mode);
|
||||
}
|
||||
@@ -1197,6 +1200,7 @@ pub const PWriteError = WriteError || error{Unseekable};
|
||||
/// The limit on Darwin is `0x7fffffff`, trying to write more than that returns EINVAL.
|
||||
/// The corresponding POSIX limit is `math.maxInt(isize)`.
|
||||
pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
|
||||
if (bytes.len == 0) return 0;
|
||||
if (builtin.os.tag == .windows) {
|
||||
return windows.WriteFile(fd, bytes, offset, std.io.default_mode);
|
||||
}
|
||||
@@ -2814,6 +2818,8 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: u32) MakeDirErr
|
||||
.NOSPC => return error.NoSpaceLeft,
|
||||
.NOTDIR => return error.NotDir,
|
||||
.ROFS => return error.ReadOnlyFileSystem,
|
||||
// dragonfly: when dir_fd is unlinked from filesystem
|
||||
.NOTCONN => return error.FileNotFound,
|
||||
else => |err| return unexpectedErrno(err),
|
||||
}
|
||||
}
|
||||
@@ -3286,7 +3292,7 @@ pub fn isatty(handle: fd_t) bool {
|
||||
if (builtin.os.tag == .wasi) {
|
||||
var statbuf: fdstat_t = undefined;
|
||||
const err = system.fd_fdstat_get(handle, &statbuf);
|
||||
if (err != 0) {
|
||||
if (err != .SUCCESS) {
|
||||
// errno = err;
|
||||
return false;
|
||||
}
|
||||
@@ -5250,6 +5256,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
|
||||
switch (errno(system.fcntl(fd, F.GETPATH, out_buffer))) {
|
||||
.SUCCESS => {},
|
||||
.BADF => return error.FileNotFound,
|
||||
.NOSPC => return error.NameTooLong,
|
||||
// TODO man pages for fcntl on macOS don't really tell you what
|
||||
// errno values to expect when command is F.GETPATH...
|
||||
else => |err| return unexpectedErrno(err),
|
||||
@@ -5282,19 +5289,85 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
|
||||
return target;
|
||||
},
|
||||
.freebsd => {
|
||||
comptime if (builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0 }) == .lt)
|
||||
@compileError("querying for canonical path of a handle is unsupported on FreeBSD 12 and below");
|
||||
|
||||
var kfile: system.kinfo_file = undefined;
|
||||
kfile.structsize = system.KINFO_FILE_SIZE;
|
||||
switch (errno(system.fcntl(fd, system.F.KINFO, @ptrToInt(&kfile)))) {
|
||||
if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0 }) == .gt) {
|
||||
var kfile: system.kinfo_file = undefined;
|
||||
kfile.structsize = system.KINFO_FILE_SIZE;
|
||||
switch (errno(system.fcntl(fd, system.F.KINFO, @ptrToInt(&kfile)))) {
|
||||
.SUCCESS => {},
|
||||
.BADF => return error.FileNotFound,
|
||||
else => |err| return unexpectedErrno(err),
|
||||
}
|
||||
const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse MAX_PATH_BYTES;
|
||||
if (len == 0) return error.NameTooLong;
|
||||
mem.copy(u8, out_buffer, kfile.path[0..len]);
|
||||
return out_buffer[0..len];
|
||||
} else {
|
||||
// This fallback implementation reimplements libutil's `kinfo_getfile()`.
|
||||
// The motivation is to avoid linking -lutil when building zig or general
|
||||
// user executables.
|
||||
var mib = [4]c_int{ CTL.KERN, KERN.PROC, KERN.PROC_FILEDESC, system.getpid() };
|
||||
var len: usize = undefined;
|
||||
sysctl(&mib, null, &len, null, 0) catch |err| switch (err) {
|
||||
error.PermissionDenied => unreachable,
|
||||
error.SystemResources => return error.SystemResources,
|
||||
error.NameTooLong => unreachable,
|
||||
error.UnknownName => unreachable,
|
||||
else => return error.Unexpected,
|
||||
};
|
||||
len = len * 4 / 3;
|
||||
const buf = std.heap.c_allocator.alloc(u8, len) catch return error.SystemResources;
|
||||
defer std.heap.c_allocator.free(buf);
|
||||
len = buf.len;
|
||||
sysctl(&mib, &buf[0], &len, null, 0) catch |err| switch (err) {
|
||||
error.PermissionDenied => unreachable,
|
||||
error.SystemResources => return error.SystemResources,
|
||||
error.NameTooLong => unreachable,
|
||||
error.UnknownName => unreachable,
|
||||
else => return error.Unexpected,
|
||||
};
|
||||
var i: usize = 0;
|
||||
while (i < len) {
|
||||
const kf: *align(1) system.kinfo_file = @ptrCast(*align(1) system.kinfo_file, &buf[i]);
|
||||
if (kf.fd == fd) {
|
||||
len = mem.indexOfScalar(u8, &kf.path, 0) orelse MAX_PATH_BYTES;
|
||||
if (len == 0) return error.NameTooLong;
|
||||
mem.copy(u8, out_buffer, kf.path[0..len]);
|
||||
return out_buffer[0..len];
|
||||
}
|
||||
i += @intCast(usize, kf.structsize);
|
||||
}
|
||||
return error.InvalidHandle;
|
||||
}
|
||||
},
|
||||
.dragonfly => {
|
||||
if (comptime builtin.os.version_range.semver.max.order(.{ .major = 6, .minor = 0 }) == .lt) {
|
||||
@compileError("querying for canonical path of a handle is unsupported on this host");
|
||||
}
|
||||
@memset(out_buffer, 0, MAX_PATH_BYTES);
|
||||
switch (errno(system.fcntl(fd, F.GETPATH, out_buffer))) {
|
||||
.SUCCESS => {},
|
||||
.BADF => return error.FileNotFound,
|
||||
.RANGE => return error.NameTooLong,
|
||||
else => |err| return unexpectedErrno(err),
|
||||
}
|
||||
|
||||
const len = mem.indexOfScalar(u8, &kfile.path, 0) orelse MAX_PATH_BYTES;
|
||||
mem.copy(u8, out_buffer, kfile.path[0..len]);
|
||||
const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;
|
||||
return out_buffer[0..len];
|
||||
},
|
||||
.netbsd => {
|
||||
if (comptime builtin.os.version_range.semver.max.order(.{ .major = 10, .minor = 0 }) == .lt) {
|
||||
@compileError("querying for canonical path of a handle is unsupported on this host");
|
||||
}
|
||||
@memset(out_buffer, 0, MAX_PATH_BYTES);
|
||||
switch (errno(system.fcntl(fd, F.GETPATH, out_buffer))) {
|
||||
.SUCCESS => {},
|
||||
.ACCES => return error.AccessDenied,
|
||||
.BADF => return error.FileNotFound,
|
||||
.NOENT => return error.FileNotFound,
|
||||
.NOMEM => return error.SystemResources,
|
||||
.RANGE => return error.NameTooLong,
|
||||
else => |err| return unexpectedErrno(err),
|
||||
}
|
||||
const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;
|
||||
return out_buffer[0..len];
|
||||
},
|
||||
else => @compileError("querying for canonical path of a handle is unsupported on this host"),
|
||||
@@ -6667,6 +6740,8 @@ pub fn memfd_createZ(name: [*:0]const u8, flags: u32) MemFdCreateError!fd_t {
|
||||
}
|
||||
},
|
||||
.freebsd => {
|
||||
if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0 }) == .lt)
|
||||
@compileError("memfd_create is unavailable on FreeBSD < 13.0");
|
||||
const rc = system.memfd_create(name, flags);
|
||||
switch (errno(rc)) {
|
||||
.SUCCESS => return rc,
|
||||
|
||||
@@ -1523,6 +1523,21 @@ pub fn timerfd_settime(fd: i32, flags: u32, new_value: *const itimerspec, old_va
|
||||
return syscall4(.timerfd_settime, @bitCast(usize, @as(isize, fd)), flags, @ptrToInt(new_value), @ptrToInt(old_value));
|
||||
}
|
||||
|
||||
// Flags for the 'setitimer' system call
|
||||
pub const ITIMER = enum(i32) {
|
||||
REAL = 0,
|
||||
VIRTUAL = 1,
|
||||
PROF = 2,
|
||||
};
|
||||
|
||||
pub fn getitimer(which: i32, curr_value: *itimerspec) usize {
|
||||
return syscall2(.getitimer, @bitCast(usize, @as(isize, which)), @ptrToInt(curr_value));
|
||||
}
|
||||
|
||||
pub fn setitimer(which: i32, new_value: *const itimerspec, old_value: ?*itimerspec) usize {
|
||||
return syscall3(.setitimer, @bitCast(usize, @as(isize, which)), @ptrToInt(new_value), @ptrToInt(old_value));
|
||||
}
|
||||
|
||||
pub fn unshare(flags: usize) usize {
|
||||
return syscall1(.unshare, flags);
|
||||
}
|
||||
@@ -2823,46 +2838,46 @@ pub const DT = struct {
|
||||
|
||||
pub const T = struct {
|
||||
pub const CGETS = if (is_mips) 0x540D else 0x5401;
|
||||
pub const CSETS = 0x5402;
|
||||
pub const CSETSW = 0x5403;
|
||||
pub const CSETSF = 0x5404;
|
||||
pub const CGETA = 0x5405;
|
||||
pub const CSETA = 0x5406;
|
||||
pub const CSETAW = 0x5407;
|
||||
pub const CSETAF = 0x5408;
|
||||
pub const CSBRK = 0x5409;
|
||||
pub const CXONC = 0x540A;
|
||||
pub const CFLSH = 0x540B;
|
||||
pub const IOCEXCL = 0x540C;
|
||||
pub const IOCNXCL = 0x540D;
|
||||
pub const IOCSCTTY = 0x540E;
|
||||
pub const IOCGPGRP = 0x540F;
|
||||
pub const IOCSPGRP = 0x5410;
|
||||
pub const CSETS = if (is_mips) 0x540e else 0x5402;
|
||||
pub const CSETSW = if (is_mips) 0x540f else 0x5403;
|
||||
pub const CSETSF = if (is_mips) 0x5410 else 0x5404;
|
||||
pub const CGETA = if (is_mips) 0x5401 else 0x5405;
|
||||
pub const CSETA = if (is_mips) 0x5402 else 0x5406;
|
||||
pub const CSETAW = if (is_mips) 0x5403 else 0x5407;
|
||||
pub const CSETAF = if (is_mips) 0x5404 else 0x5408;
|
||||
pub const CSBRK = if (is_mips) 0x5405 else 0x5409;
|
||||
pub const CXONC = if (is_mips) 0x5406 else 0x540A;
|
||||
pub const CFLSH = if (is_mips) 0x5407 else 0x540B;
|
||||
pub const IOCEXCL = if (is_mips) 0x740d else 0x540C;
|
||||
pub const IOCNXCL = if (is_mips) 0x740e else 0x540D;
|
||||
pub const IOCSCTTY = if (is_mips) 0x7472 else 0x540E;
|
||||
pub const IOCGPGRP = if (is_mips) 0x5472 else 0x540F;
|
||||
pub const IOCSPGRP = if (is_mips) 0x741d else 0x5410;
|
||||
pub const IOCOUTQ = if (is_mips) 0x7472 else 0x5411;
|
||||
pub const IOCSTI = 0x5412;
|
||||
pub const IOCSTI = if (is_mips) 0x5472 else 0x5412;
|
||||
pub const IOCGWINSZ = if (is_mips or is_ppc64) 0x40087468 else 0x5413;
|
||||
pub const IOCSWINSZ = if (is_mips or is_ppc64) 0x80087467 else 0x5414;
|
||||
pub const IOCMGET = 0x5415;
|
||||
pub const IOCMBIS = 0x5416;
|
||||
pub const IOCMBIC = 0x5417;
|
||||
pub const IOCMSET = 0x5418;
|
||||
pub const IOCGSOFTCAR = 0x5419;
|
||||
pub const IOCSSOFTCAR = 0x541A;
|
||||
pub const IOCMGET = if (is_mips) 0x741d else 0x5415;
|
||||
pub const IOCMBIS = if (is_mips) 0x741b else 0x5416;
|
||||
pub const IOCMBIC = if (is_mips) 0x741c else 0x5417;
|
||||
pub const IOCMSET = if (is_mips) 0x741a else 0x5418;
|
||||
pub const IOCGSOFTCAR = if (is_mips) 0x5481 else 0x5419;
|
||||
pub const IOCSSOFTCAR = if (is_mips) 0x5482 else 0x541A;
|
||||
pub const FIONREAD = if (is_mips) 0x467F else 0x541B;
|
||||
pub const IOCINQ = FIONREAD;
|
||||
pub const IOCLINUX = 0x541C;
|
||||
pub const IOCCONS = 0x541D;
|
||||
pub const IOCGSERIAL = 0x541E;
|
||||
pub const IOCSSERIAL = 0x541F;
|
||||
pub const IOCPKT = 0x5420;
|
||||
pub const FIONBIO = 0x5421;
|
||||
pub const IOCNOTTY = 0x5422;
|
||||
pub const IOCSETD = 0x5423;
|
||||
pub const IOCGETD = 0x5424;
|
||||
pub const CSBRKP = 0x5425;
|
||||
pub const IOCLINUX = if (is_mips) 0x5483 else 0x541C;
|
||||
pub const IOCCONS = if (is_mips) IOCTL.IOW('t', 120, c_int) else 0x541D;
|
||||
pub const IOCGSERIAL = if (is_mips) 0x5484 else 0x541E;
|
||||
pub const IOCSSERIAL = if (is_mips) 0x5485 else 0x541F;
|
||||
pub const IOCPKT = if (is_mips) 0x5470 else 0x5420;
|
||||
pub const FIONBIO = if (is_mips) 0x667e else 0x5421;
|
||||
pub const IOCNOTTY = if (is_mips) 0x5471 else 0x5422;
|
||||
pub const IOCSETD = if (is_mips) 0x7401 else 0x5423;
|
||||
pub const IOCGETD = if (is_mips) 0x7400 else 0x5424;
|
||||
pub const CSBRKP = if (is_mips) 0x5486 else 0x5425;
|
||||
pub const IOCSBRK = 0x5427;
|
||||
pub const IOCCBRK = 0x5428;
|
||||
pub const IOCGSID = 0x5429;
|
||||
pub const IOCGSID = if (is_mips) 0x7416 else 0x5429;
|
||||
pub const IOCGRS485 = 0x542E;
|
||||
pub const IOCSRS485 = 0x542F;
|
||||
pub const IOCGPTN = IOCTL.IOR('T', 0x30, c_uint);
|
||||
@@ -3130,7 +3145,7 @@ pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).Array.l
|
||||
pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
|
||||
|
||||
const k_sigaction_funcs = struct {
|
||||
const handler = ?std.meta.FnPtr(fn (c_int) callconv(.C) void);
|
||||
const handler = ?std.meta.FnPtr(fn (c_int) align(1) callconv(.C) void);
|
||||
const restorer = std.meta.FnPtr(fn () callconv(.C) void);
|
||||
};
|
||||
|
||||
@@ -3157,7 +3172,7 @@ pub const k_sigaction = switch (native_arch) {
|
||||
|
||||
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
||||
pub const Sigaction = extern struct {
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) callconv(.C) void);
|
||||
pub const handler_fn = std.meta.FnPtr(fn (c_int) align(1) callconv(.C) void);
|
||||
pub const sigaction_fn = std.meta.FnPtr(fn (c_int, *const siginfo_t, ?*const anyopaque) callconv(.C) void);
|
||||
|
||||
handler: extern union {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const std = @import("../../../std.zig");
|
||||
|
||||
const magic = 0xeb9f;
|
||||
const version = 1;
|
||||
pub const magic = 0xeb9f;
|
||||
pub const version = 1;
|
||||
|
||||
pub const ext = @import("btf_ext.zig");
|
||||
|
||||
/// All offsets are in bytes relative to the end of this header
|
||||
pub const Header = packed struct {
|
||||
pub const Header = extern struct {
|
||||
magic: u16,
|
||||
version: u8,
|
||||
flags: u8,
|
||||
@@ -34,15 +34,15 @@ pub const max_name_offset = 0xffffff;
|
||||
/// Max number of struct/union/enum member of func args
|
||||
pub const max_vlen = 0xffff;
|
||||
|
||||
pub const Type = packed struct {
|
||||
pub const Type = extern struct {
|
||||
name_off: u32,
|
||||
info: packed struct {
|
||||
info: packed struct(u32) {
|
||||
/// number of struct's members
|
||||
vlen: u16,
|
||||
|
||||
unused_1: u8,
|
||||
kind: Kind,
|
||||
unused_2: u3,
|
||||
unused_2: u2,
|
||||
|
||||
/// used by Struct, Union, and Fwd
|
||||
kind_flag: bool,
|
||||
@@ -53,31 +53,35 @@ pub const Type = packed struct {
|
||||
///
|
||||
/// type is used by Ptr, Typedef, Volatile, Const, Restrict, Func,
|
||||
/// FuncProto, and Var. It is a type_id referring to another type
|
||||
size_type: union { size: u32, typ: u32 },
|
||||
size_type: extern union { size: u32, typ: u32 },
|
||||
};
|
||||
|
||||
/// For some kinds, Type is immediately followed by extra data
|
||||
pub const Kind = enum(u4) {
|
||||
pub const Kind = enum(u5) {
|
||||
unknown,
|
||||
int,
|
||||
ptr,
|
||||
array,
|
||||
structure,
|
||||
kind_union,
|
||||
enumeration,
|
||||
@"struct",
|
||||
@"union",
|
||||
@"enum",
|
||||
fwd,
|
||||
typedef,
|
||||
kind_volatile,
|
||||
constant,
|
||||
@"volatile",
|
||||
@"const",
|
||||
restrict,
|
||||
func,
|
||||
funcProto,
|
||||
variable,
|
||||
dataSec,
|
||||
func_proto,
|
||||
@"var",
|
||||
datasec,
|
||||
float,
|
||||
decl_tag,
|
||||
type_tag,
|
||||
enum64,
|
||||
};
|
||||
|
||||
/// Int kind is followed by this struct
|
||||
pub const IntInfo = packed struct {
|
||||
/// int kind is followed by this struct
|
||||
pub const IntInfo = packed struct(u32) {
|
||||
bits: u8,
|
||||
unused: u8,
|
||||
offset: u8,
|
||||
@@ -92,36 +96,43 @@ test "IntInfo is 32 bits" {
|
||||
try std.testing.expectEqual(@bitSizeOf(IntInfo), 32);
|
||||
}
|
||||
|
||||
/// Enum kind is followed by this struct
|
||||
pub const Enum = packed struct {
|
||||
/// enum kind is followed by this struct
|
||||
pub const Enum = extern struct {
|
||||
name_off: u32,
|
||||
val: i32,
|
||||
};
|
||||
|
||||
/// Array kind is followd by this struct
|
||||
pub const Array = packed struct {
|
||||
/// enum64 kind is followed by this struct
|
||||
pub const Enum64 = extern struct {
|
||||
name_off: u32,
|
||||
val_lo32: i32,
|
||||
val_hi32: i32,
|
||||
};
|
||||
|
||||
/// array kind is followd by this struct
|
||||
pub const Array = extern struct {
|
||||
typ: u32,
|
||||
index_type: u32,
|
||||
nelems: u32,
|
||||
};
|
||||
|
||||
/// Struct and Union kinds are followed by multiple Member structs. The exact
|
||||
/// struct and union kinds are followed by multiple Member structs. The exact
|
||||
/// number is stored in vlen
|
||||
pub const Member = packed struct {
|
||||
pub const Member = extern struct {
|
||||
name_off: u32,
|
||||
typ: u32,
|
||||
|
||||
/// if the kind_flag is set, offset contains both member bitfield size and
|
||||
/// bit offset, the bitfield size is set for bitfield members. If the type
|
||||
/// info kind_flag is not set, the offset contains only bit offset
|
||||
offset: packed struct {
|
||||
offset: packed struct(u32) {
|
||||
bit: u24,
|
||||
bitfield_size: u8,
|
||||
},
|
||||
};
|
||||
|
||||
/// FuncProto is followed by multiple Params, the exact number is stored in vlen
|
||||
pub const Param = packed struct {
|
||||
/// func_proto is followed by multiple Params, the exact number is stored in vlen
|
||||
pub const Param = extern struct {
|
||||
name_off: u32,
|
||||
typ: u32,
|
||||
};
|
||||
@@ -138,16 +149,26 @@ pub const FuncLinkage = enum {
|
||||
external,
|
||||
};
|
||||
|
||||
/// Var kind is followd by a single Var struct to describe additional
|
||||
/// var kind is followd by a single Var struct to describe additional
|
||||
/// information related to the variable such as its linkage
|
||||
pub const Var = packed struct {
|
||||
pub const Var = extern struct {
|
||||
linkage: u32,
|
||||
};
|
||||
|
||||
/// Datasec kind is followed by multible VarSecInfo to describe all Var kind
|
||||
/// datasec kind is followed by multible VarSecInfo to describe all Var kind
|
||||
/// types it contains along with it's in-section offset as well as size.
|
||||
pub const VarSecInfo = packed struct {
|
||||
pub const VarSecInfo = extern struct {
|
||||
typ: u32,
|
||||
offset: u32,
|
||||
size: u32,
|
||||
};
|
||||
|
||||
// decl_tag kind is followed by a single DeclTag struct to describe
|
||||
// additional information related to the tag applied location.
|
||||
// If component_idx == -1, the tag is applied to a struct, union,
|
||||
// variable or function. Otherwise, it is applied to a struct/union
|
||||
// member or a func argument, and component_idx indicates which member
|
||||
// or argument (0 ... vlen-1).
|
||||
pub const DeclTag = extern struct {
|
||||
component_idx: u32,
|
||||
};
|
||||
|
||||
@@ -496,7 +496,14 @@ test "argsAlloc" {
|
||||
|
||||
test "memfd_create" {
|
||||
// memfd_create is only supported by linux and freebsd.
|
||||
if (native_os != .linux and native_os != .freebsd) return error.SkipZigTest;
|
||||
switch (native_os) {
|
||||
.linux => {},
|
||||
.freebsd => {
|
||||
if (comptime builtin.os.version_range.semver.max.order(.{ .major = 13, .minor = 0 }) == .lt)
|
||||
return error.SkipZigTest;
|
||||
},
|
||||
else => return error.SkipZigTest,
|
||||
}
|
||||
|
||||
const fd = std.os.memfd_create("test", 0) catch |err| switch (err) {
|
||||
// Related: https://github.com/ziglang/zig/issues/4019
|
||||
@@ -739,8 +746,6 @@ test "shutdown socket" {
|
||||
os.closeSocket(sock);
|
||||
}
|
||||
|
||||
var signal_test_failed = true;
|
||||
|
||||
test "sigaction" {
|
||||
if (native_os == .wasi or native_os == .windows)
|
||||
return error.SkipZigTest;
|
||||
@@ -750,17 +755,19 @@ test "sigaction" {
|
||||
return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
var handler_called_count: u32 = 0;
|
||||
|
||||
fn handler(sig: i32, info: *const os.siginfo_t, ctx_ptr: ?*const anyopaque) callconv(.C) void {
|
||||
_ = ctx_ptr;
|
||||
// Check that we received the correct signal.
|
||||
switch (native_os) {
|
||||
.netbsd => {
|
||||
if (sig == os.SIG.USR1 and sig == info.info.signo)
|
||||
signal_test_failed = false;
|
||||
handler_called_count += 1;
|
||||
},
|
||||
else => {
|
||||
if (sig == os.SIG.USR1 and sig == info.signo)
|
||||
signal_test_failed = false;
|
||||
handler_called_count += 1;
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -774,18 +781,41 @@ test "sigaction" {
|
||||
.flags = os.SA.SIGINFO | os.SA.RESETHAND,
|
||||
};
|
||||
var old_sa: os.Sigaction = undefined;
|
||||
|
||||
// Install the new signal handler.
|
||||
try os.sigaction(os.SIG.USR1, &sa, null);
|
||||
|
||||
// Check that we can read it back correctly.
|
||||
try os.sigaction(os.SIG.USR1, null, &old_sa);
|
||||
try testing.expectEqual(actual_handler, old_sa.handler.sigaction.?);
|
||||
try testing.expect((old_sa.flags & os.SA.SIGINFO) != 0);
|
||||
|
||||
// Invoke the handler.
|
||||
try os.raise(os.SIG.USR1);
|
||||
try testing.expect(signal_test_failed == false);
|
||||
// Check if the handler has been correctly reset to SIG_DFL
|
||||
try testing.expect(S.handler_called_count == 1);
|
||||
|
||||
// Check if passing RESETHAND correctly reset the handler to SIG_DFL
|
||||
try os.sigaction(os.SIG.USR1, null, &old_sa);
|
||||
try testing.expectEqual(os.SIG.DFL, old_sa.handler.handler);
|
||||
|
||||
// Reinstall the signal w/o RESETHAND and re-raise
|
||||
sa.flags = os.SA.SIGINFO;
|
||||
try os.sigaction(os.SIG.USR1, &sa, null);
|
||||
try os.raise(os.SIG.USR1);
|
||||
try testing.expect(S.handler_called_count == 2);
|
||||
|
||||
// Now set the signal to ignored
|
||||
sa.handler = .{ .handler = os.SIG.IGN };
|
||||
sa.flags = 0;
|
||||
try os.sigaction(os.SIG.USR1, &sa, null);
|
||||
|
||||
// Re-raise to ensure handler is actually ignored
|
||||
try os.raise(os.SIG.USR1);
|
||||
try testing.expect(S.handler_called_count == 2);
|
||||
|
||||
// Ensure that ignored state is returned when querying
|
||||
try os.sigaction(os.SIG.USR1, null, &old_sa);
|
||||
try testing.expectEqual(os.SIG.IGN, old_sa.handler.handler.?);
|
||||
}
|
||||
|
||||
test "dup & dup2" {
|
||||
@@ -1011,14 +1041,122 @@ test "timerfd" {
|
||||
var tfd = try os.timerfd_create(linux.CLOCK.MONOTONIC, linux.TFD.CLOEXEC);
|
||||
defer os.close(tfd);
|
||||
|
||||
// Fire event 10_000_000ns = 10ms after the os.timerfd_settime call.
|
||||
var sit: linux.itimerspec = .{ .it_interval = .{ .tv_sec = 0, .tv_nsec = 0 }, .it_value = .{ .tv_sec = 0, .tv_nsec = 10 * (1000 * 1000) } };
|
||||
try os.timerfd_settime(tfd, 0, &sit, null);
|
||||
|
||||
var fds: [1]os.pollfd = .{.{ .fd = tfd, .events = os.linux.POLL.IN, .revents = 0 }};
|
||||
try expectEqual(try os.poll(&fds, -1), 1);
|
||||
var git = try os.timerfd_gettime(tfd);
|
||||
try expectEqual(git, .{ .it_interval = .{ .tv_sec = 0, .tv_nsec = 0 }, .it_value = .{ .tv_sec = 0, .tv_nsec = 0 } });
|
||||
try expectEqual(@as(usize, 1), try os.poll(&fds, -1)); // -1 => infinite waiting
|
||||
|
||||
try os.timerfd_settime(tfd, 0, &sit, null);
|
||||
try expectEqual(try os.poll(&fds, 5), 0);
|
||||
var git = try os.timerfd_gettime(tfd);
|
||||
var expect_disarmed_timer: linux.itimerspec = .{ .it_interval = .{ .tv_sec = 0, .tv_nsec = 0 }, .it_value = .{ .tv_sec = 0, .tv_nsec = 0 } };
|
||||
try expectEqual(expect_disarmed_timer, git);
|
||||
}
|
||||
|
||||
test "isatty" {
|
||||
var tmp = tmpDir(.{});
|
||||
defer tmp.cleanup();
|
||||
|
||||
var file = try tmp.dir.createFile("foo", .{});
|
||||
try expectEqual(os.isatty(file.handle), false);
|
||||
}
|
||||
|
||||
test "read with empty buffer" {
|
||||
if (native_os == .wasi) return error.SkipZigTest;
|
||||
|
||||
var tmp = tmpDir(.{});
|
||||
defer tmp.cleanup();
|
||||
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
// Get base abs path
|
||||
const base_path = blk: {
|
||||
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
|
||||
break :blk try fs.realpathAlloc(allocator, relative_path);
|
||||
};
|
||||
|
||||
var file_path: []u8 = try fs.path.join(allocator, &[_][]const u8{ base_path, "some_file" });
|
||||
var file = try fs.cwd().createFile(file_path, .{ .read = true });
|
||||
defer file.close();
|
||||
|
||||
var bytes = try allocator.alloc(u8, 0);
|
||||
|
||||
_ = try os.read(file.handle, bytes);
|
||||
}
|
||||
|
||||
test "pread with empty buffer" {
|
||||
if (native_os == .wasi) return error.SkipZigTest;
|
||||
|
||||
var tmp = tmpDir(.{});
|
||||
defer tmp.cleanup();
|
||||
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
// Get base abs path
|
||||
const base_path = blk: {
|
||||
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
|
||||
break :blk try fs.realpathAlloc(allocator, relative_path);
|
||||
};
|
||||
|
||||
var file_path: []u8 = try fs.path.join(allocator, &[_][]const u8{ base_path, "some_file" });
|
||||
var file = try fs.cwd().createFile(file_path, .{ .read = true });
|
||||
defer file.close();
|
||||
|
||||
var bytes = try allocator.alloc(u8, 0);
|
||||
|
||||
_ = try os.pread(file.handle, bytes, 0);
|
||||
}
|
||||
|
||||
test "write with empty buffer" {
|
||||
if (native_os == .wasi) return error.SkipZigTest;
|
||||
|
||||
var tmp = tmpDir(.{});
|
||||
defer tmp.cleanup();
|
||||
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
// Get base abs path
|
||||
const base_path = blk: {
|
||||
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
|
||||
break :blk try fs.realpathAlloc(allocator, relative_path);
|
||||
};
|
||||
|
||||
var file_path: []u8 = try fs.path.join(allocator, &[_][]const u8{ base_path, "some_file" });
|
||||
var file = try fs.cwd().createFile(file_path, .{});
|
||||
defer file.close();
|
||||
|
||||
var bytes = try allocator.alloc(u8, 0);
|
||||
|
||||
_ = try os.write(file.handle, bytes);
|
||||
}
|
||||
|
||||
test "pwrite with empty buffer" {
|
||||
if (native_os == .wasi) return error.SkipZigTest;
|
||||
|
||||
var tmp = tmpDir(.{});
|
||||
defer tmp.cleanup();
|
||||
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
const allocator = arena.allocator();
|
||||
|
||||
// Get base abs path
|
||||
const base_path = blk: {
|
||||
const relative_path = try fs.path.join(allocator, &[_][]const u8{ "zig-cache", "tmp", tmp.sub_path[0..] });
|
||||
break :blk try fs.realpathAlloc(allocator, relative_path);
|
||||
};
|
||||
|
||||
var file_path: []u8 = try fs.path.join(allocator, &[_][]const u8{ base_path, "some_file" });
|
||||
var file = try fs.cwd().createFile(file_path, .{});
|
||||
defer file.close();
|
||||
|
||||
var bytes = try allocator.alloc(u8, 0);
|
||||
|
||||
_ = try os.pwrite(file.handle, bytes, 0);
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN
|
||||
.OBJECT_NAME_COLLISION => return error.PathAlreadyExists,
|
||||
.FILE_IS_A_DIRECTORY => return error.IsDir,
|
||||
.NOT_A_DIRECTORY => return error.NotDir,
|
||||
.USER_MAPPED_FILE => return error.AccessDenied,
|
||||
.INVALID_HANDLE => unreachable,
|
||||
else => return unexpectedStatus(rc),
|
||||
}
|
||||
@@ -801,7 +802,7 @@ pub fn ReadLink(dir: ?HANDLE, sub_path_w: []const u16, out_buffer: []u8) ReadLin
|
||||
}
|
||||
defer CloseHandle(result_handle);
|
||||
|
||||
var reparse_buf: [MAXIMUM_REPARSE_DATA_BUFFER_SIZE]u8 = undefined;
|
||||
var reparse_buf: [MAXIMUM_REPARSE_DATA_BUFFER_SIZE]u8 align(@alignOf(REPARSE_DATA_BUFFER)) = undefined;
|
||||
_ = DeviceIoControl(result_handle, FSCTL_GET_REPARSE_POINT, null, reparse_buf[0..]) catch |err| switch (err) {
|
||||
error.AccessDenied => unreachable,
|
||||
else => |e| return e,
|
||||
@@ -1567,6 +1568,7 @@ pub const CreateProcessError = error{
|
||||
FileNotFound,
|
||||
AccessDenied,
|
||||
InvalidName,
|
||||
NameTooLong,
|
||||
Unexpected,
|
||||
};
|
||||
|
||||
@@ -1600,6 +1602,7 @@ pub fn CreateProcessW(
|
||||
.ACCESS_DENIED => return error.AccessDenied,
|
||||
.INVALID_PARAMETER => unreachable,
|
||||
.INVALID_NAME => return error.InvalidName,
|
||||
.FILENAME_EXCED_RANGE => return error.NameTooLong,
|
||||
else => |err| return unexpectedError(err),
|
||||
}
|
||||
}
|
||||
@@ -2086,6 +2089,7 @@ pub const LPWSTR = [*:0]WCHAR;
|
||||
pub const LPCWSTR = [*:0]const WCHAR;
|
||||
pub const PVOID = *anyopaque;
|
||||
pub const PWSTR = [*:0]WCHAR;
|
||||
pub const PCWSTR = [*:0]const WCHAR;
|
||||
pub const SIZE_T = usize;
|
||||
pub const UINT = c_uint;
|
||||
pub const ULONG_PTR = usize;
|
||||
@@ -2101,6 +2105,7 @@ pub const USHORT = u16;
|
||||
pub const SHORT = i16;
|
||||
pub const ULONG = u32;
|
||||
pub const LONG = i32;
|
||||
pub const ULONG64 = u64;
|
||||
pub const ULONGLONG = u64;
|
||||
pub const LONGLONG = i64;
|
||||
pub const HLOCAL = HANDLE;
|
||||
@@ -2501,6 +2506,7 @@ pub const STANDARD_RIGHTS_READ = READ_CONTROL;
|
||||
pub const STANDARD_RIGHTS_WRITE = READ_CONTROL;
|
||||
pub const STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
|
||||
pub const STANDARD_RIGHTS_REQUIRED = DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER;
|
||||
pub const MAXIMUM_ALLOWED = 0x02000000;
|
||||
|
||||
// disposition for NtCreateFile
|
||||
pub const FILE_SUPERSEDE = 0;
|
||||
@@ -2869,9 +2875,143 @@ pub const PROV_RSA_FULL = 1;
|
||||
|
||||
pub const REGSAM = ACCESS_MASK;
|
||||
pub const ACCESS_MASK = DWORD;
|
||||
pub const HKEY = *opaque {};
|
||||
pub const LSTATUS = LONG;
|
||||
|
||||
pub const HKEY = *opaque {};
|
||||
|
||||
pub const HKEY_LOCAL_MACHINE: HKEY = @intToPtr(HKEY, 0x80000002);
|
||||
|
||||
/// Combines the STANDARD_RIGHTS_REQUIRED, KEY_QUERY_VALUE, KEY_SET_VALUE, KEY_CREATE_SUB_KEY,
|
||||
/// KEY_ENUMERATE_SUB_KEYS, KEY_NOTIFY, and KEY_CREATE_LINK access rights.
|
||||
pub const KEY_ALL_ACCESS = 0xF003F;
|
||||
/// Reserved for system use.
|
||||
pub const KEY_CREATE_LINK = 0x0020;
|
||||
/// Required to create a subkey of a registry key.
|
||||
pub const KEY_CREATE_SUB_KEY = 0x0004;
|
||||
/// Required to enumerate the subkeys of a registry key.
|
||||
pub const KEY_ENUMERATE_SUB_KEYS = 0x0008;
|
||||
/// Equivalent to KEY_READ.
|
||||
pub const KEY_EXECUTE = 0x20019;
|
||||
/// Required to request change notifications for a registry key or for subkeys of a registry key.
|
||||
pub const KEY_NOTIFY = 0x0010;
|
||||
/// Required to query the values of a registry key.
|
||||
pub const KEY_QUERY_VALUE = 0x0001;
|
||||
/// Combines the STANDARD_RIGHTS_READ, KEY_QUERY_VALUE, KEY_ENUMERATE_SUB_KEYS, and KEY_NOTIFY values.
|
||||
pub const KEY_READ = 0x20019;
|
||||
/// Required to create, delete, or set a registry value.
|
||||
pub const KEY_SET_VALUE = 0x0002;
|
||||
/// Indicates that an application on 64-bit Windows should operate on the 32-bit registry view.
|
||||
/// This flag is ignored by 32-bit Windows.
|
||||
pub const KEY_WOW64_32KEY = 0x0200;
|
||||
/// Indicates that an application on 64-bit Windows should operate on the 64-bit registry view.
|
||||
/// This flag is ignored by 32-bit Windows.
|
||||
pub const KEY_WOW64_64KEY = 0x0100;
|
||||
/// Combines the STANDARD_RIGHTS_WRITE, KEY_SET_VALUE, and KEY_CREATE_SUB_KEY access rights.
|
||||
pub const KEY_WRITE = 0x20006;
|
||||
|
||||
/// Open symbolic link.
|
||||
pub const REG_OPTION_OPEN_LINK: DWORD = 0x8;
|
||||
|
||||
pub const RTL_QUERY_REGISTRY_TABLE = extern struct {
|
||||
QueryRoutine: RTL_QUERY_REGISTRY_ROUTINE,
|
||||
Flags: ULONG,
|
||||
Name: ?PWSTR,
|
||||
EntryContext: ?*anyopaque,
|
||||
DefaultType: ULONG,
|
||||
DefaultData: ?*anyopaque,
|
||||
DefaultLength: ULONG,
|
||||
};
|
||||
|
||||
pub const RTL_QUERY_REGISTRY_ROUTINE = ?std.meta.FnPtr(fn (
|
||||
PWSTR,
|
||||
ULONG,
|
||||
?*anyopaque,
|
||||
ULONG,
|
||||
?*anyopaque,
|
||||
?*anyopaque,
|
||||
) callconv(WINAPI) NTSTATUS);
|
||||
|
||||
/// Path is a full path
|
||||
pub const RTL_REGISTRY_ABSOLUTE = 0;
|
||||
/// \Registry\Machine\System\CurrentControlSet\Services
|
||||
pub const RTL_REGISTRY_SERVICES = 1;
|
||||
/// \Registry\Machine\System\CurrentControlSet\Control
|
||||
pub const RTL_REGISTRY_CONTROL = 2;
|
||||
/// \Registry\Machine\Software\Microsoft\Windows NT\CurrentVersion
|
||||
pub const RTL_REGISTRY_WINDOWS_NT = 3;
|
||||
/// \Registry\Machine\Hardware\DeviceMap
|
||||
pub const RTL_REGISTRY_DEVICEMAP = 4;
|
||||
/// \Registry\User\CurrentUser
|
||||
pub const RTL_REGISTRY_USER = 5;
|
||||
pub const RTL_REGISTRY_MAXIMUM = 6;
|
||||
|
||||
/// Low order bits are registry handle
|
||||
pub const RTL_REGISTRY_HANDLE = 0x40000000;
|
||||
/// Indicates the key node is optional
|
||||
pub const RTL_REGISTRY_OPTIONAL = 0x80000000;
|
||||
|
||||
/// Name is a subkey and remainder of table or until next subkey are value
|
||||
/// names for that subkey to look at.
|
||||
pub const RTL_QUERY_REGISTRY_SUBKEY = 0x00000001;
|
||||
|
||||
/// Reset current key to original key for this and all following table entries.
|
||||
pub const RTL_QUERY_REGISTRY_TOPKEY = 0x00000002;
|
||||
|
||||
/// Fail if no match found for this table entry.
|
||||
pub const RTL_QUERY_REGISTRY_REQUIRED = 0x00000004;
|
||||
|
||||
/// Used to mark a table entry that has no value name, just wants a call out, not
|
||||
/// an enumeration of all values.
|
||||
pub const RTL_QUERY_REGISTRY_NOVALUE = 0x00000008;
|
||||
|
||||
/// Used to suppress the expansion of REG_MULTI_SZ into multiple callouts or
|
||||
/// to prevent the expansion of environment variable values in REG_EXPAND_SZ.
|
||||
pub const RTL_QUERY_REGISTRY_NOEXPAND = 0x00000010;
|
||||
|
||||
/// QueryRoutine field ignored. EntryContext field points to location to store value.
|
||||
/// For null terminated strings, EntryContext points to UNICODE_STRING structure that
|
||||
/// that describes maximum size of buffer. If .Buffer field is NULL then a buffer is
|
||||
/// allocated.
|
||||
pub const RTL_QUERY_REGISTRY_DIRECT = 0x00000020;
|
||||
|
||||
/// Used to delete value keys after they are queried.
|
||||
pub const RTL_QUERY_REGISTRY_DELETE = 0x00000040;
|
||||
|
||||
/// Use this flag with the RTL_QUERY_REGISTRY_DIRECT flag to verify that the REG_XXX type
|
||||
/// of the stored registry value matches the type expected by the caller.
|
||||
/// If the types do not match, the call fails.
|
||||
pub const RTL_QUERY_REGISTRY_TYPECHECK = 0x00000100;
|
||||
|
||||
pub const REG = struct {
|
||||
/// No value type
|
||||
pub const NONE: ULONG = 0;
|
||||
/// Unicode nul terminated string
|
||||
pub const SZ: ULONG = 1;
|
||||
/// Unicode nul terminated string (with environment variable references)
|
||||
pub const EXPAND_SZ: ULONG = 2;
|
||||
/// Free form binary
|
||||
pub const BINARY: ULONG = 3;
|
||||
/// 32-bit number
|
||||
pub const DWORD: ULONG = 4;
|
||||
/// 32-bit number (same as REG_DWORD)
|
||||
pub const DWORD_LITTLE_ENDIAN: ULONG = 4;
|
||||
/// 32-bit number
|
||||
pub const DWORD_BIG_ENDIAN: ULONG = 5;
|
||||
/// Symbolic Link (unicode)
|
||||
pub const LINK: ULONG = 6;
|
||||
/// Multiple Unicode strings
|
||||
pub const MULTI_SZ: ULONG = 7;
|
||||
/// Resource list in the resource map
|
||||
pub const RESOURCE_LIST: ULONG = 8;
|
||||
/// Resource list in the hardware description
|
||||
pub const FULL_RESOURCE_DESCRIPTOR: ULONG = 9;
|
||||
pub const RESOURCE_REQUIREMENTS_LIST: ULONG = 10;
|
||||
/// 64-bit number
|
||||
pub const QWORD: ULONG = 11;
|
||||
/// 64-bit number (same as REG_QWORD)
|
||||
pub const QWORD_LITTLE_ENDIAN: ULONG = 11;
|
||||
};
|
||||
|
||||
pub const FILE_NOTIFY_INFORMATION = extern struct {
|
||||
NextEntryOffset: DWORD,
|
||||
Action: DWORD,
|
||||
@@ -3712,3 +3852,305 @@ pub const CTRL_LOGOFF_EVENT: DWORD = 5;
|
||||
pub const CTRL_SHUTDOWN_EVENT: DWORD = 6;
|
||||
|
||||
pub const HANDLER_ROUTINE = std.meta.FnPtr(fn (dwCtrlType: DWORD) callconv(WINAPI) BOOL);
|
||||
|
||||
/// Processor feature enumeration.
|
||||
pub const PF = enum(DWORD) {
|
||||
/// On a Pentium, a floating-point precision error can occur in rare circumstances.
|
||||
FLOATING_POINT_PRECISION_ERRATA = 0,
|
||||
|
||||
/// Floating-point operations are emulated using software emulator.
|
||||
/// This function returns a nonzero value if floating-point operations are emulated; otherwise, it returns zero.
|
||||
FLOATING_POINT_EMULATED = 1,
|
||||
|
||||
/// The atomic compare and exchange operation (cmpxchg) is available.
|
||||
COMPARE_EXCHANGE_DOUBLE = 2,
|
||||
|
||||
/// The MMX instruction set is available.
|
||||
MMX_INSTRUCTIONS_AVAILABLE = 3,
|
||||
|
||||
PPC_MOVEMEM_64BIT_OK = 4,
|
||||
ALPHA_BYTE_INSTRUCTIONS = 5,
|
||||
|
||||
/// The SSE instruction set is available.
|
||||
XMMI_INSTRUCTIONS_AVAILABLE = 6,
|
||||
|
||||
/// The 3D-Now instruction is available.
|
||||
@"3DNOW_INSTRUCTIONS_AVAILABLE" = 7,
|
||||
|
||||
/// The RDTSC instruction is available.
|
||||
RDTSC_INSTRUCTION_AVAILABLE = 8,
|
||||
|
||||
/// The processor is PAE-enabled.
|
||||
PAE_ENABLED = 9,
|
||||
|
||||
/// The SSE2 instruction set is available.
|
||||
XMMI64_INSTRUCTIONS_AVAILABLE = 10,
|
||||
|
||||
SSE_DAZ_MODE_AVAILABLE = 11,
|
||||
|
||||
/// Data execution prevention is enabled.
|
||||
NX_ENABLED = 12,
|
||||
|
||||
/// The SSE3 instruction set is available.
|
||||
SSE3_INSTRUCTIONS_AVAILABLE = 13,
|
||||
|
||||
/// The atomic compare and exchange 128-bit operation (cmpxchg16b) is available.
|
||||
COMPARE_EXCHANGE128 = 14,
|
||||
|
||||
/// The atomic compare 64 and exchange 128-bit operation (cmp8xchg16) is available.
|
||||
COMPARE64_EXCHANGE128 = 15,
|
||||
|
||||
/// The processor channels are enabled.
|
||||
CHANNELS_ENABLED = 16,
|
||||
|
||||
/// The processor implements the XSAVI and XRSTOR instructions.
|
||||
XSAVE_ENABLED = 17,
|
||||
|
||||
/// The VFP/Neon: 32 x 64bit register bank is present.
|
||||
/// This flag has the same meaning as PF_ARM_VFP_EXTENDED_REGISTERS.
|
||||
ARM_VFP_32_REGISTERS_AVAILABLE = 18,
|
||||
|
||||
/// This ARM processor implements the ARM v8 NEON instruction set.
|
||||
ARM_NEON_INSTRUCTIONS_AVAILABLE = 19,
|
||||
|
||||
/// Second Level Address Translation is supported by the hardware.
|
||||
SECOND_LEVEL_ADDRESS_TRANSLATION = 20,
|
||||
|
||||
/// Virtualization is enabled in the firmware and made available by the operating system.
|
||||
VIRT_FIRMWARE_ENABLED = 21,
|
||||
|
||||
/// RDFSBASE, RDGSBASE, WRFSBASE, and WRGSBASE instructions are available.
|
||||
RDWRFSGBASE_AVAILABLE = 22,
|
||||
|
||||
/// _fastfail() is available.
|
||||
FASTFAIL_AVAILABLE = 23,
|
||||
|
||||
/// The divide instruction_available.
|
||||
ARM_DIVIDE_INSTRUCTION_AVAILABLE = 24,
|
||||
|
||||
/// The 64-bit load/store atomic instructions are available.
|
||||
ARM_64BIT_LOADSTORE_ATOMIC = 25,
|
||||
|
||||
/// The external cache is available.
|
||||
ARM_EXTERNAL_CACHE_AVAILABLE = 26,
|
||||
|
||||
/// The floating-point multiply-accumulate instruction is available.
|
||||
ARM_FMAC_INSTRUCTIONS_AVAILABLE = 27,
|
||||
|
||||
RDRAND_INSTRUCTION_AVAILABLE = 28,
|
||||
|
||||
/// This ARM processor implements the ARM v8 instructions set.
|
||||
ARM_V8_INSTRUCTIONS_AVAILABLE = 29,
|
||||
|
||||
/// This ARM processor implements the ARM v8 extra cryptographic instructions (i.e., AES, SHA1 and SHA2).
|
||||
ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE = 30,
|
||||
|
||||
/// This ARM processor implements the ARM v8 extra CRC32 instructions.
|
||||
ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE = 31,
|
||||
|
||||
RDTSCP_INSTRUCTION_AVAILABLE = 32,
|
||||
RDPID_INSTRUCTION_AVAILABLE = 33,
|
||||
|
||||
/// This ARM processor implements the ARM v8.1 atomic instructions (e.g., CAS, SWP).
|
||||
ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE = 34,
|
||||
|
||||
MONITORX_INSTRUCTION_AVAILABLE = 35,
|
||||
|
||||
/// The SSSE3 instruction set is available.
|
||||
SSSE3_INSTRUCTIONS_AVAILABLE = 36,
|
||||
|
||||
/// The SSE4_1 instruction set is available.
|
||||
SSE4_1_INSTRUCTIONS_AVAILABLE = 37,
|
||||
|
||||
/// The SSE4_2 instruction set is available.
|
||||
SSE4_2_INSTRUCTIONS_AVAILABLE = 38,
|
||||
|
||||
/// The AVX instruction set is available.
|
||||
AVX_INSTRUCTIONS_AVAILABLE = 39,
|
||||
|
||||
/// The AVX2 instruction set is available.
|
||||
AVX2_INSTRUCTIONS_AVAILABLE = 40,
|
||||
|
||||
/// The AVX512F instruction set is available.
|
||||
AVX512F_INSTRUCTIONS_AVAILABLE = 41,
|
||||
|
||||
ERMS_AVAILABLE = 42,
|
||||
|
||||
/// This ARM processor implements the ARM v8.2 Dot Product (DP) instructions.
|
||||
ARM_V82_DP_INSTRUCTIONS_AVAILABLE = 43,
|
||||
|
||||
/// This ARM processor implements the ARM v8.3 JavaScript conversion (JSCVT) instructions.
|
||||
ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE = 44,
|
||||
};
|
||||
|
||||
pub const MAX_WOW64_SHARED_ENTRIES = 16;
|
||||
pub const PROCESSOR_FEATURE_MAX = 64;
|
||||
pub const MAXIMUM_XSTATE_FEATURES = 64;
|
||||
|
||||
pub const KSYSTEM_TIME = extern struct {
|
||||
LowPart: ULONG,
|
||||
High1Time: LONG,
|
||||
High2Time: LONG,
|
||||
};
|
||||
|
||||
pub const NT_PRODUCT_TYPE = enum(INT) {
|
||||
NtProductWinNt = 1,
|
||||
NtProductLanManNt,
|
||||
NtProductServer,
|
||||
};
|
||||
|
||||
pub const ALTERNATIVE_ARCHITECTURE_TYPE = enum(INT) {
|
||||
StandardDesign,
|
||||
NEC98x86,
|
||||
EndAlternatives,
|
||||
};
|
||||
|
||||
pub const XSTATE_FEATURE = extern struct {
|
||||
Offset: ULONG,
|
||||
Size: ULONG,
|
||||
};
|
||||
|
||||
pub const XSTATE_CONFIGURATION = extern struct {
|
||||
EnabledFeatures: ULONG64,
|
||||
Size: ULONG,
|
||||
OptimizedSave: ULONG,
|
||||
Features: [MAXIMUM_XSTATE_FEATURES]XSTATE_FEATURE,
|
||||
};
|
||||
|
||||
/// Shared Kernel User Data
|
||||
pub const KUSER_SHARED_DATA = extern struct {
|
||||
TickCountLowDeprecated: ULONG,
|
||||
TickCountMultiplier: ULONG,
|
||||
InterruptTime: KSYSTEM_TIME,
|
||||
SystemTime: KSYSTEM_TIME,
|
||||
TimeZoneBias: KSYSTEM_TIME,
|
||||
ImageNumberLow: USHORT,
|
||||
ImageNumberHigh: USHORT,
|
||||
NtSystemRoot: [260]WCHAR,
|
||||
MaxStackTraceDepth: ULONG,
|
||||
CryptoExponent: ULONG,
|
||||
TimeZoneId: ULONG,
|
||||
LargePageMinimum: ULONG,
|
||||
AitSamplingValue: ULONG,
|
||||
AppCompatFlag: ULONG,
|
||||
RNGSeedVersion: ULONGLONG,
|
||||
GlobalValidationRunlevel: ULONG,
|
||||
TimeZoneBiasStamp: LONG,
|
||||
NtBuildNumber: ULONG,
|
||||
NtProductType: NT_PRODUCT_TYPE,
|
||||
ProductTypeIsValid: BOOLEAN,
|
||||
Reserved0: [1]BOOLEAN,
|
||||
NativeProcessorArchitecture: USHORT,
|
||||
NtMajorVersion: ULONG,
|
||||
NtMinorVersion: ULONG,
|
||||
ProcessorFeatures: [PROCESSOR_FEATURE_MAX]BOOLEAN,
|
||||
Reserved1: ULONG,
|
||||
Reserved3: ULONG,
|
||||
TimeSlip: ULONG,
|
||||
AlternativeArchitecture: ALTERNATIVE_ARCHITECTURE_TYPE,
|
||||
BootId: ULONG,
|
||||
SystemExpirationDate: LARGE_INTEGER,
|
||||
SuiteMaskY: ULONG,
|
||||
KdDebuggerEnabled: BOOLEAN,
|
||||
DummyUnion1: extern union {
|
||||
MitigationPolicies: UCHAR,
|
||||
Alt: packed struct {
|
||||
NXSupportPolicy: u2,
|
||||
SEHValidationPolicy: u2,
|
||||
CurDirDevicesSkippedForDlls: u2,
|
||||
Reserved: u2,
|
||||
},
|
||||
},
|
||||
CyclesPerYield: USHORT,
|
||||
ActiveConsoleId: ULONG,
|
||||
DismountCount: ULONG,
|
||||
ComPlusPackage: ULONG,
|
||||
LastSystemRITEventTickCount: ULONG,
|
||||
NumberOfPhysicalPages: ULONG,
|
||||
SafeBootMode: BOOLEAN,
|
||||
DummyUnion2: extern union {
|
||||
VirtualizationFlags: UCHAR,
|
||||
Alt: packed struct {
|
||||
ArchStartedInEl2: u1,
|
||||
QcSlIsSupported: u1,
|
||||
SpareBits: u6,
|
||||
},
|
||||
},
|
||||
Reserved12: [2]UCHAR,
|
||||
DummyUnion3: extern union {
|
||||
SharedDataFlags: ULONG,
|
||||
Alt: packed struct {
|
||||
DbgErrorPortPresent: u1,
|
||||
DbgElevationEnabled: u1,
|
||||
DbgVirtEnabled: u1,
|
||||
DbgInstallerDetectEnabled: u1,
|
||||
DbgLkgEnabled: u1,
|
||||
DbgDynProcessorEnabled: u1,
|
||||
DbgConsoleBrokerEnabled: u1,
|
||||
DbgSecureBootEnabled: u1,
|
||||
DbgMultiSessionSku: u1,
|
||||
DbgMultiUsersInSessionSku: u1,
|
||||
DbgStateSeparationEnabled: u1,
|
||||
SpareBits: u21,
|
||||
},
|
||||
},
|
||||
DataFlagsPad: [1]ULONG,
|
||||
TestRetInstruction: ULONGLONG,
|
||||
QpcFrequency: LONGLONG,
|
||||
SystemCall: ULONG,
|
||||
Reserved2: ULONG,
|
||||
SystemCallPad: [2]ULONGLONG,
|
||||
DummyUnion4: extern union {
|
||||
TickCount: KSYSTEM_TIME,
|
||||
TickCountQuad: ULONG64,
|
||||
Alt: extern struct {
|
||||
ReservedTickCountOverlay: [3]ULONG,
|
||||
TickCountPad: [1]ULONG,
|
||||
},
|
||||
},
|
||||
Cookie: ULONG,
|
||||
CookiePad: [1]ULONG,
|
||||
ConsoleSessionForegroundProcessId: LONGLONG,
|
||||
TimeUpdateLock: ULONGLONG,
|
||||
BaselineSystemTimeQpc: ULONGLONG,
|
||||
BaselineInterruptTimeQpc: ULONGLONG,
|
||||
QpcSystemTimeIncrement: ULONGLONG,
|
||||
QpcInterruptTimeIncrement: ULONGLONG,
|
||||
QpcSystemTimeIncrementShift: UCHAR,
|
||||
QpcInterruptTimeIncrementShift: UCHAR,
|
||||
UnparkedProcessorCount: USHORT,
|
||||
EnclaveFeatureMask: [4]ULONG,
|
||||
TelemetryCoverageRound: ULONG,
|
||||
UserModeGlobalLogger: [16]USHORT,
|
||||
ImageFileExecutionOptions: ULONG,
|
||||
LangGenerationCount: ULONG,
|
||||
Reserved4: ULONGLONG,
|
||||
InterruptTimeBias: ULONGLONG,
|
||||
QpcBias: ULONGLONG,
|
||||
ActiveProcessorCount: ULONG,
|
||||
ActiveGroupCount: UCHAR,
|
||||
Reserved9: UCHAR,
|
||||
DummyUnion5: extern union {
|
||||
QpcData: USHORT,
|
||||
Alt: extern struct {
|
||||
QpcBypassEnabled: UCHAR,
|
||||
QpcShift: UCHAR,
|
||||
},
|
||||
},
|
||||
TimeZoneBiasEffectiveStart: LARGE_INTEGER,
|
||||
TimeZoneBiasEffectiveEnd: LARGE_INTEGER,
|
||||
XState: XSTATE_CONFIGURATION,
|
||||
FeatureConfigurationChangeStamp: KSYSTEM_TIME,
|
||||
Spare: ULONG,
|
||||
UserPointerAuthMask: ULONG64,
|
||||
};
|
||||
|
||||
/// Read-only user-mode address for the shared data.
|
||||
/// https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm
|
||||
/// https://msrc-blog.microsoft.com/2022/04/05/randomizing-the-kuser_shared_data-structure-on-windows/
|
||||
pub const SharedUserData: *const KUSER_SHARED_DATA = @intToPtr(*const KUSER_SHARED_DATA, 0x7FFE0000);
|
||||
|
||||
pub fn IsProcessorFeaturePresent(feature: PF) bool {
|
||||
if (@enumToInt(feature) >= PROCESSOR_FEATURE_MAX) return false;
|
||||
return SharedUserData.ProcessorFeatures[@enumToInt(feature)] == 1;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ const DWORD = windows.DWORD;
|
||||
const FILE_INFO_BY_HANDLE_CLASS = windows.FILE_INFO_BY_HANDLE_CLASS;
|
||||
const HANDLE = windows.HANDLE;
|
||||
const HMODULE = windows.HMODULE;
|
||||
const HKEY = windows.HKEY;
|
||||
const HRESULT = windows.HRESULT;
|
||||
const LARGE_INTEGER = windows.LARGE_INTEGER;
|
||||
const LPCWSTR = windows.LPCWSTR;
|
||||
@@ -57,6 +58,8 @@ const UCHAR = windows.UCHAR;
|
||||
const FARPROC = windows.FARPROC;
|
||||
const INIT_ONCE_FN = windows.INIT_ONCE_FN;
|
||||
const PMEMORY_BASIC_INFORMATION = windows.PMEMORY_BASIC_INFORMATION;
|
||||
const REGSAM = windows.REGSAM;
|
||||
const LSTATUS = windows.LSTATUS;
|
||||
|
||||
pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(WINAPI) ?*anyopaque;
|
||||
pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(WINAPI) c_ulong;
|
||||
@@ -231,6 +234,7 @@ pub extern "kernel32" fn GetQueuedCompletionStatusEx(
|
||||
|
||||
pub extern "kernel32" fn GetSystemInfo(lpSystemInfo: *SYSTEM_INFO) callconv(WINAPI) void;
|
||||
pub extern "kernel32" fn GetSystemTimeAsFileTime(*FILETIME) callconv(WINAPI) void;
|
||||
pub extern "kernel32" fn IsProcessorFeaturePresent(ProcessorFeature: DWORD) BOOL;
|
||||
|
||||
pub extern "kernel32" fn HeapCreate(flOptions: DWORD, dwInitialSize: SIZE_T, dwMaximumSize: SIZE_T) callconv(WINAPI) ?HANDLE;
|
||||
pub extern "kernel32" fn HeapDestroy(hHeap: HANDLE) callconv(WINAPI) BOOL;
|
||||
@@ -411,3 +415,11 @@ pub extern "kernel32" fn SleepConditionVariableSRW(
|
||||
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;
|
||||
|
||||
pub extern "kernel32" fn RegOpenKeyExW(
|
||||
hkey: HKEY,
|
||||
lpSubKey: LPCWSTR,
|
||||
ulOptions: DWORD,
|
||||
samDesired: REGSAM,
|
||||
phkResult: *HKEY,
|
||||
) callconv(WINAPI) LSTATUS;
|
||||
|
||||
@@ -22,6 +22,8 @@ const RTL_OSVERSIONINFOW = windows.RTL_OSVERSIONINFOW;
|
||||
const FILE_BASIC_INFORMATION = windows.FILE_BASIC_INFORMATION;
|
||||
const SIZE_T = windows.SIZE_T;
|
||||
const CURDIR = windows.CURDIR;
|
||||
const PCWSTR = windows.PCWSTR;
|
||||
const RTL_QUERY_REGISTRY_TABLE = windows.RTL_QUERY_REGISTRY_TABLE;
|
||||
|
||||
pub const THREADINFOCLASS = enum(c_int) {
|
||||
ThreadBasicInformation,
|
||||
@@ -253,3 +255,17 @@ pub extern "ntdll" fn NtUnlockFile(
|
||||
Length: *const LARGE_INTEGER,
|
||||
Key: ?*ULONG,
|
||||
) callconv(WINAPI) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn NtOpenKey(
|
||||
KeyHandle: *HANDLE,
|
||||
DesiredAccess: ACCESS_MASK,
|
||||
ObjectAttributes: OBJECT_ATTRIBUTES,
|
||||
) callconv(WINAPI) NTSTATUS;
|
||||
|
||||
pub extern "ntdll" fn RtlQueryRegistryValues(
|
||||
RelativeTo: ULONG,
|
||||
Path: PCWSTR,
|
||||
QueryTable: [*]RTL_QUERY_REGISTRY_TABLE,
|
||||
Context: ?*anyopaque,
|
||||
Environment: ?*anyopaque,
|
||||
) callconv(WINAPI) NTSTATUS;
|
||||
|
||||
@@ -972,9 +972,9 @@ fn blockCountFromSize(size: u32, block_size: u32) u32 {
|
||||
}
|
||||
|
||||
// https://llvm.org/docs/PDB/MsfFile.html#the-superblock
|
||||
const SuperBlock = extern struct {
|
||||
pub const SuperBlock = extern struct {
|
||||
/// The LLVM docs list a space between C / C++ but empirically this is not the case.
|
||||
const file_magic = "Microsoft C/C++ MSF 7.00\r\n\x1a\x44\x53\x00\x00\x00";
|
||||
pub const file_magic = "Microsoft C/C++ MSF 7.00\r\n\x1a\x44\x53\x00\x00\x00";
|
||||
|
||||
FileMagic: [file_magic.len]u8,
|
||||
|
||||
|
||||
@@ -390,8 +390,10 @@ pub fn PriorityDequeue(comptime T: type, comptime Context: type, comptime compar
|
||||
|
||||
pub fn update(self: *Self, elem: T, new_elem: T) !void {
|
||||
const old_index = blk: {
|
||||
for (self.items) |item, idx| {
|
||||
if (compareFn(self.context, item, elem).compare(.eq)) break :blk idx;
|
||||
var idx: usize = 0;
|
||||
while (idx < self.len) : (idx += 1) {
|
||||
const item = self.items[idx];
|
||||
if (compareFn(self.context, item, elem) == .eq) break :blk idx;
|
||||
}
|
||||
return error.ElementNotFound;
|
||||
};
|
||||
@@ -778,6 +780,15 @@ test "std.PriorityDequeue: update same max queue" {
|
||||
try expectEqual(@as(u32, 1), queue.removeMax());
|
||||
}
|
||||
|
||||
test "std.PriorityDequeue: update after remove" {
|
||||
var queue = PDQ.init(testing.allocator, {});
|
||||
defer queue.deinit();
|
||||
|
||||
try queue.add(1);
|
||||
try expectEqual(@as(u32, 1), queue.removeMin());
|
||||
try expectError(error.ElementNotFound, queue.update(1, 1));
|
||||
}
|
||||
|
||||
test "std.PriorityDequeue: iterator" {
|
||||
var queue = PDQ.init(testing.allocator, {});
|
||||
var map = std.AutoHashMap(u32, void).init(testing.allocator);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user