Compare commits
99 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12828c09d6 | ||
|
|
c72f584218 | ||
|
|
3617615e2d | ||
|
|
b3a4074358 | ||
|
|
46f93807aa | ||
|
|
5356151172 | ||
|
|
f7e08ea780 | ||
|
|
a1d532752f | ||
|
|
2588451967 | ||
|
|
551971b5c3 | ||
|
|
5d08e2b5d8 | ||
|
|
d38bd443ef | ||
|
|
c9ab6baf06 | ||
|
|
a45c0c5033 | ||
|
|
7b9612a922 | ||
|
|
1cddcf4484 | ||
|
|
b8a77f3d59 | ||
|
|
d4e22e3eb6 | ||
|
|
d99f55b7cf | ||
|
|
2561b1eb67 | ||
|
|
c1e444b07c | ||
|
|
84154b10a2 | ||
|
|
ba47e09373 | ||
|
|
1063bf696e | ||
|
|
3b8c4f07a4 | ||
|
|
3dcbd489eb | ||
|
|
5582d20f04 | ||
|
|
13aedf09d6 | ||
|
|
cd078c518f | ||
|
|
ceebcfa317 | ||
|
|
b26ab39836 | ||
|
|
eac9bfaa01 | ||
|
|
8a83143316 | ||
|
|
3ef9bd5879 | ||
|
|
f385522ab0 | ||
|
|
de028d5130 | ||
|
|
390a4ded98 | ||
|
|
b0be0c77d8 | ||
|
|
440da6bfad | ||
|
|
b7fe0db9d2 | ||
|
|
d59fc1ac04 | ||
|
|
9349c9c4b1 | ||
|
|
6caa77ea52 | ||
|
|
caddd7eb18 | ||
|
|
2b6727c98f | ||
|
|
5ef70b8b87 | ||
|
|
e75dfbcb3f | ||
|
|
16228e87d6 | ||
|
|
3e4f3a1924 | ||
|
|
939408289c | ||
|
|
d0575310dc | ||
|
|
b72d55ea5f | ||
|
|
c7dd3cc535 | ||
|
|
96b77e030f | ||
|
|
cf6e2d318a | ||
|
|
1fe0142d1f | ||
|
|
76102ea41f | ||
|
|
74ca811a66 | ||
|
|
721ec8fa53 | ||
|
|
dc392f49f8 | ||
|
|
71ec89383b | ||
|
|
4adbdcb587 | ||
|
|
162b92c93e | ||
|
|
8be29674a9 | ||
|
|
52ead255a2 | ||
|
|
6f180131a5 | ||
|
|
4453f6a5ce | ||
|
|
7f6e7e3e5d | ||
|
|
5c9eb94a2b | ||
|
|
9c1e7de6c6 | ||
|
|
54229fec33 | ||
|
|
264969a8c3 | ||
|
|
e3a74697f0 | ||
|
|
a913311f3c | ||
|
|
ec4c60c481 | ||
|
|
29386f0d30 | ||
|
|
80e1797faf | ||
|
|
f677c24740 | ||
|
|
6afdc3cc79 | ||
|
|
c230258d9b | ||
|
|
2d0dff6498 | ||
|
|
060cb0f277 | ||
|
|
05380a11a4 | ||
|
|
4a3ac16711 | ||
|
|
51076f4e1d | ||
|
|
503b85a1b0 | ||
|
|
0c25ff81a3 | ||
|
|
39c80942e7 | ||
|
|
bfc85211bb | ||
|
|
7ca86936ca | ||
|
|
5c765b2ec4 | ||
|
|
a745a17aa9 | ||
|
|
2681e1ffe0 | ||
|
|
27f6db66e3 | ||
|
|
6d6ba1e998 | ||
|
|
c8ee445c86 | ||
|
|
072c3202c3 | ||
|
|
07852a4bc8 | ||
|
|
ae1871a028 |
8
.builds/freebsd.yml
Normal file
8
.builds/freebsd.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
image: freebsd/latest
|
||||
secrets:
|
||||
- 51bfddf5-86a6-4e01-8576-358c72a4a0a4
|
||||
- 5cfede76-914e-4071-893e-e5e2e6ae3cea
|
||||
sources:
|
||||
- https://github.com/ziglang/zig
|
||||
tasks:
|
||||
- build: cd zig && ./ci/srht/freebsd_script
|
||||
4
.github/CODEOWNERS
vendored
4
.github/CODEOWNERS
vendored
@@ -1,4 +0,0 @@
|
||||
# Autodoc
|
||||
/src/Autodoc.zig @kristoff-it
|
||||
/src/autodoc/* @kristoff-it
|
||||
/lib/docs/* @kristoff-it
|
||||
12
.github/ISSUE_TEMPLATE/autodoc-issue.md
vendored
12
.github/ISSUE_TEMPLATE/autodoc-issue.md
vendored
@@ -1,12 +0,0 @@
|
||||
---
|
||||
name: Autodoc Issue
|
||||
about: Issues with automatically generated docs, including stdlib docs.
|
||||
title: 'Autodoc: {your issue}'
|
||||
labels: autodoc
|
||||
assignees: kristoff-it
|
||||
|
||||
---
|
||||
|
||||
Autodoc is still work in progress and as such many bugs and missing features are already known.
|
||||
|
||||
# Please report only <ins>regressions</ins>, i.e. things that worked in a previous build of new Autodoc (orange banner) that now don't work any more.
|
||||
33
.github/ISSUE_TEMPLATE/bug.yml
vendored
33
.github/ISSUE_TEMPLATE/bug.yml
vendored
@@ -1,33 +0,0 @@
|
||||
name: Bug Report
|
||||
description: File a bug report
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
A bug is when something works differently than it is expected to.
|
||||
## Remember to search before filing a new report
|
||||
Please search for this bug in the issue tracker, and use a bug report title that
|
||||
would have made your bug report turn up in the search results for your search query.
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Zig Version
|
||||
description: "The output of `zig version`"
|
||||
placeholder: "0.10.0-dev.4583+875e98a57"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: repro
|
||||
attributes:
|
||||
label: Steps to Reproduce and Observed Behavior
|
||||
description: What exactly can someone else do, in order to observe the problem that you observed? Include the output and all error messages.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: What did you expect to happen instead?
|
||||
validations:
|
||||
required: true
|
||||
7
.github/ISSUE_TEMPLATE/config.yml
vendored
7
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,7 +0,0 @@
|
||||
contact_links:
|
||||
- name: Language Proposal
|
||||
about: Propose to improve the Zig language
|
||||
url: https://github.com/ziglang/zig/wiki/Language-Proposals
|
||||
- name: Question
|
||||
about: Please use one of the community spaces for questions or general discussions.
|
||||
url: https://github.com/ziglang/zig/wiki/Community
|
||||
47
.github/workflows/ci.yaml
vendored
47
.github/workflows/ci.yaml
vendored
@@ -1,47 +0,0 @@
|
||||
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
|
||||
600
CMakeLists.txt
600
CMakeLists.txt
@@ -12,26 +12,10 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_PREFIX)
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage3" CACHE STRING
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE STRING
|
||||
"Directory to install zig to" FORCE)
|
||||
endif()
|
||||
|
||||
# CMake recognizes the CMAKE_PREFIX_PATH environment variable for some things,
|
||||
# and also the CMAKE_PREFIX_PATH cache variable for other things. However, it
|
||||
# does not relate these two things, i.e. if the environment variable is set,
|
||||
# CMake does not populate the cache variable in a corresponding manner. Some
|
||||
# package systems, such as Homebrew, set the environment variable but not the
|
||||
# cache variable. Furthermore, the environment variable follows the system path
|
||||
# separator, such as ':' on POSIX and ';' on Windows, but the cache variable
|
||||
# follows CMake's array behavior, i.e. always ';' for a separator.
|
||||
list(APPEND ZIG_CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}")
|
||||
if(WIN32)
|
||||
list(APPEND ZIG_CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
|
||||
else()
|
||||
string(REGEX REPLACE ":" ";" ZIG_CMAKE_PREFIX_PATH_STRING "$ENV{CMAKE_PREFIX_PATH}")
|
||||
list(APPEND ZIG_CMAKE_PREFIX_PATH "${ZIG_CMAKE_PREFIX_PATH_STRING}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/c_flag_overrides.cmake)
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
|
||||
@@ -41,13 +25,13 @@ project(zig C CXX)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
|
||||
|
||||
set(ZIG_VERSION_MAJOR 0)
|
||||
set(ZIG_VERSION_MINOR 10)
|
||||
set(ZIG_VERSION_MINOR 8)
|
||||
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 "")
|
||||
set(ZIG_VERSION "${ZIG_VERSION_MAJOR}.${ZIG_VERSION_MINOR}.${ZIG_VERSION_PATCH}")
|
||||
find_program(GIT_EXE NAMES git NAMES_PER_DIR)
|
||||
find_program(GIT_EXE NAMES git)
|
||||
if(GIT_EXE)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXE} -C ${CMAKE_SOURCE_DIR} describe --match *.*.* --tags
|
||||
@@ -79,22 +63,12 @@ if("${ZIG_VERSION}" STREQUAL "")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Configuring zig version ${ZIG_VERSION}")
|
||||
|
||||
set(ZIG_NO_LIB off CACHE BOOL
|
||||
"Disable copying lib/ files to install prefix during the build phase")
|
||||
|
||||
set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Deprecated. Use ZIG_NO_LIB")
|
||||
if(ZIG_SKIP_INSTALL_LIB_FILES)
|
||||
message(WARNING "ZIG_SKIP_INSTALL_LIB_FILES is deprecated. Use ZIG_NO_LIB instead.")
|
||||
set(ZIG_NO_LIB ON)
|
||||
endif()
|
||||
message("Configuring zig version ${ZIG_VERSION}")
|
||||
|
||||
set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
|
||||
set(ZIG_SHARED_LLVM off CACHE BOOL "Prefer linking against shared LLVM libraries")
|
||||
set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
|
||||
set(ZIG_STATIC_ZLIB off CACHE BOOL "Prefer linking against static zlib")
|
||||
set(ZIG_STATIC_ZSTD off CACHE BOOL "Prefer linking against static zstd")
|
||||
set(ZIG_PREFER_CLANG_CPP_DYLIB off CACHE BOOL "Try to link against -lclang-cpp")
|
||||
set(ZIG_USE_CCACHE off CACHE BOOL "Use ccache if available")
|
||||
|
||||
if(CCACHE_PROGRAM AND ZIG_USE_CCACHE)
|
||||
@@ -104,11 +78,6 @@ endif()
|
||||
if(ZIG_STATIC)
|
||||
set(ZIG_STATIC_LLVM ON)
|
||||
set(ZIG_STATIC_ZLIB ON)
|
||||
set(ZIG_STATIC_ZSTD ON)
|
||||
endif()
|
||||
|
||||
if (ZIG_SHARED_LLVM AND ZIG_STATIC_LLVM)
|
||||
message(SEND_ERROR "-DZIG_SHARED_LLVM and -DZIG_STATIC_LLVM cannot both be enabled simultaneously")
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_LIB_DIR_ESCAPED "${ZIG_LIBC_LIB_DIR}")
|
||||
@@ -118,16 +87,11 @@ 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 "native" CACHE STRING "-mcpu parameter to output binaries for")
|
||||
set(ZIG_TARGET_MCPU "baseline" CACHE STRING "-mcpu parameter to output binaries for")
|
||||
set(ZIG_EXECUTABLE "" CACHE STRING "(when cross compiling) path to already-built zig binary")
|
||||
set(ZIG_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")
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(ZIG_ENABLE_LOGGING ON CACHE BOOL "enable logging")
|
||||
else()
|
||||
set(ZIG_ENABLE_LOGGING OFF CACHE BOOL "enable logging")
|
||||
endif()
|
||||
set(ZIG_ENABLE_LOGGING off CACHE BOOL "enable logging")
|
||||
|
||||
if("${ZIG_TARGET_TRIPLE}" STREQUAL "native")
|
||||
set(ZIG_USE_LLVM_CONFIG ON CACHE BOOL "use llvm-config to find LLVM libraries")
|
||||
@@ -135,28 +99,19 @@ else()
|
||||
set(ZIG_USE_LLVM_CONFIG OFF CACHE BOOL "use llvm-config to find LLVM libraries")
|
||||
endif()
|
||||
|
||||
find_package(llvm 15)
|
||||
find_package(clang 15)
|
||||
find_package(lld 15)
|
||||
find_package(llvm)
|
||||
find_package(clang)
|
||||
find_package(lld)
|
||||
|
||||
if(ZIG_STATIC_ZLIB)
|
||||
list(REMOVE_ITEM LLVM_LIBRARIES "-lz")
|
||||
find_library(ZLIB NAMES libz.a libzlibstatic.a z zlib libz NAMES_PER_DIR)
|
||||
find_library(ZLIB NAMES libz.a libzlibstatic.a z zlib libz)
|
||||
list(APPEND LLVM_LIBRARIES "${ZLIB}")
|
||||
endif()
|
||||
|
||||
if(ZIG_STATIC_ZSTD)
|
||||
list(REMOVE_ITEM LLVM_LIBRARIES "-lzstd")
|
||||
find_library(ZSTD NAMES libzstd.a libzstdstatic.a zstd NAMES_PER_DIR)
|
||||
list(APPEND LLVM_LIBRARIES "${ZSTD}")
|
||||
endif()
|
||||
|
||||
if(APPLE AND ZIG_STATIC)
|
||||
list(REMOVE_ITEM LLVM_LIBRARIES "-lcurses")
|
||||
find_library(CURSES NAMES libcurses.a libncurses.a NAMES_PER_DIR
|
||||
PATHS
|
||||
/usr/local/opt/ncurses/lib
|
||||
/opt/homebrew/opt/ncurses/lib)
|
||||
find_library(CURSES NAMES libcurses.a curses libcurses libncurses.a ncurses libncurses)
|
||||
list(APPEND LLVM_LIBRARIES "${CURSES}")
|
||||
endif()
|
||||
|
||||
@@ -179,19 +134,15 @@ include_directories(${CLANG_INCLUDE_DIRS})
|
||||
# No patches have been applied to SoftFloat-3e
|
||||
set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/f128M_isSignalingNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/extF80M_isSignalingNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF16UI.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF32UI.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_commonNaNToF64UI.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f128MToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_extF80MToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f16UIToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f32UIToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_f64UIToCommonNaN.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_propagateNaNF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_propagateNaNExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/s_propagateNaNF16UI.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/8086/softfloat_raiseFlags.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_add.c"
|
||||
@@ -211,7 +162,6 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_f64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i32_r_minMag.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_i64.c"
|
||||
@@ -220,20 +170,6 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui32_r_minMag.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_to_ui64_r_minMag.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_add.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_div.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_eq.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_le.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_lt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_mul.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_rem.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_roundToInt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_sqrt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_sub.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_to_f16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_to_f32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_to_f64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/extF80M_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_add.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_div.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_eq.c"
|
||||
@@ -244,12 +180,9 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_roundToInt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_sqrt.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_sub.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_to_f64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f32_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f32_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f64_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f64_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f64_to_f16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/i32_to_f128M.c"
|
||||
@@ -257,7 +190,6 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addCarryM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addComplCarryM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_addMagsF32.c"
|
||||
@@ -268,14 +200,12 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_approxRecip_1Ks.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compare128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compare96M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_compareNonnormExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_countLeadingZeros8.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_eq128.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_invalidF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_invalidExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_isNaNF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_le128.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_lt128.c"
|
||||
@@ -286,9 +216,7 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_mulAddF64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_negXM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normExtF80SigM.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackMToF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackMToExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_normRoundPackToF64.c"
|
||||
@@ -299,7 +227,6 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_remStepMBy32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundMToI64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundMToUI64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackMToExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackMToF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF16.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_roundPackToF32.c"
|
||||
@@ -328,25 +255,16 @@ set(EMBEDDED_SOFTFLOAT_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF32.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_subMagsF64.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_tryPropagateNaNF128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/s_tryPropagateNaNExtF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f16_mulAdd.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/f128M_mulAdd.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/softfloat_state.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui32_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui64_to_f128M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui32_to_extF80M.c"
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e/source/ui64_to_extF80M.c"
|
||||
)
|
||||
add_library(embedded_softfloat STATIC ${EMBEDDED_SOFTFLOAT_SOURCES})
|
||||
if(MSVC)
|
||||
set(SOFTFLOAT_CFLAGS "/w")
|
||||
|
||||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(SOFTFLOAT_CFLAGS "${SOFTFLOAT_CFLAGS} /O2")
|
||||
endif()
|
||||
|
||||
set_target_properties(embedded_softfloat PROPERTIES
|
||||
COMPILE_FLAGS ${SOFTFLOAT_CFLAGS}
|
||||
COMPILE_FLAGS "/w /O2"
|
||||
)
|
||||
else()
|
||||
set_target_properties(embedded_softfloat PROPERTIES
|
||||
@@ -372,7 +290,7 @@ set(ZIG_CONFIG_H_OUT "${CMAKE_BINARY_DIR}/config.h")
|
||||
set(ZIG_CONFIG_ZIG_OUT "${CMAKE_BINARY_DIR}/config.zig")
|
||||
|
||||
# This is our shim which will be replaced by stage1.zig.
|
||||
set(ZIG1_SOURCES
|
||||
set(ZIG0_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/zig0.cpp"
|
||||
)
|
||||
|
||||
@@ -383,6 +301,7 @@ set(STAGE1_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/bigint.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/buffer.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/codegen.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/dump_analysis.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/errmsg.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/error.cpp"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1/heap.cpp"
|
||||
@@ -412,9 +331,9 @@ set(ZIG_CPP_SOURCES
|
||||
# https://github.com/ziglang/zig/issues/6363
|
||||
"${CMAKE_SOURCE_DIR}/src/windows_sdk.cpp"
|
||||
)
|
||||
# Needed because we use cmake, not the zig build system, to build zig2.o.
|
||||
# Needed because we use cmake, not the zig build system, to build zig1.o.
|
||||
# This list is generated by building zig and then clearing the zig-cache directory,
|
||||
# then manually running the build-obj command (see BUILD_ZIG2_ARGS), and then looking
|
||||
# then manually running the build-obj command (see BUILD_ZIG1_ARGS), and then looking
|
||||
# in the zig-cache directory for the compiler-generated list of zig file dependencies.
|
||||
set(ZIG_STAGE2_SOURCES
|
||||
"${ZIG_CONFIG_ZIG_OUT}"
|
||||
@@ -439,12 +358,7 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/crypto/siphash.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/debug.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/dwarf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/dwarf/AT.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/dwarf/ATE.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/dwarf/FORM.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/dwarf/LANG.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/dwarf/OP.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/dwarf/TAG.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/dwarf_bits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/elf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/event.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/event/batch.zig"
|
||||
@@ -486,8 +400,9 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/big.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/big/int.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/float.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/floor.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/frexp.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/inf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/isinf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/isnan.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/math/ln.zig"
|
||||
@@ -504,15 +419,18 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/meta/trait.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/multi_array_list.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/darwin.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/errno/generic.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/bits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/errno-generic.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/netlink.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/prctl.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/securebits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/bits/linux/x86_64.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/posix_spawn.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/windows.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/bits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/win32error.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/Progress.zig"
|
||||
@@ -520,180 +438,68 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/process.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/rand.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/sort.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/absv.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/absvdi2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/absvsi2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/absvti2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/adddf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/addf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/addo.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/addsf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/addtf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/addxf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/arm.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/atomics.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/aulldiv.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/aullrem.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/bswap.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/ceil.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/clear_cache.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmp.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmpdf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmpsf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmptf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/cmpxf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/common.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/comparef.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/cos.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/count0bits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/divdf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/divsf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/divtf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/divti3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/divxf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/emutls.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/exp.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/exp2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extenddftf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extenddfxf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendhfsf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendhftf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendhfxf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendsfdf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendsftf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendsfxf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/extendxftf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fabs.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixdfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixdfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixdfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixhfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixhfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixhfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixsfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixsfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixsfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixtfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixtfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixtfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsdfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsdfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsdfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunshfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunshfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunshfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunssfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunssfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunssfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunstfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunstfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunstfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsxfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsxfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixunsxfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_to_int.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdihf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatditf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdixf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsihf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsitf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatsixf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattihf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattitf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floattixf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatundidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatundihf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatundisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunditf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatundixf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsihf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsitf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatunsixf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntihf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntitf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatuntixf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floor.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fma.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fmax.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fmin.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fmod.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/gedf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/gesf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/getf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/gexf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_to_float.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log10.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/modti3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/muldf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/muldi3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/mulf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/mulo.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/mulsf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/multf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/multi3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/mulxf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/negXi2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/negv.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/os_version_check.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/parity.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/popcount.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/rem_pio2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/rem_pio2_large.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/rem_pio2f.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/round.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/shift.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/sin.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/sincos.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/sqrt.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/stack_probe.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/subo.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/subsf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/subdf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/subtf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/subxf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/negsf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/negdf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/negtf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/negxf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/tan.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/trig.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunc.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncdfhf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncdfsf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncsfhf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunctfdf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunctfhf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunctfsf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/trunctfxf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncxfdf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncxfhf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/truncxfsf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/udivmod.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/udivmodti4.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/udivti3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/umodti3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/unorddf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/unordsf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/unordtf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/addXf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/atomics.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/clear_cache.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/clzsi2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/compareXf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/divdf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/divsf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/divtf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/divti3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/extendXfYf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixdfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixdfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixdfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixint.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixsfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixsfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixsfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixtfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixtfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixtfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixuint.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunsdfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunsdfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunsdfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunssfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunssfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunssfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunstfdi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunstfsi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/fixunstfti.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatXisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatdidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatditf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatsiXf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floattidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floattitf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatundidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatundisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatunditf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatunsidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatunsisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatunsitf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatuntidf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatuntisf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/floatuntitf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/int.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/modti3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/mulXf3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/muldi3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/mulodi4.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/muloti4.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/multi3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/negXf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/popcountdi2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/shift.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/stack_probe.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/truncXfYf2.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/udivmod.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/udivmodti4.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/udivti3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt/umodti3.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/start.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/std.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target.zig"
|
||||
@@ -709,79 +515,50 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/powerpc.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/riscv.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/sparc.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/s390x.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/systemz.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/wasm.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/target/x86.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/Thread.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/Thread/Futex.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/Thread/AutoResetEvent.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/Thread/Mutex.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/Thread/ResetEvent.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/Thread/StaticResetEvent.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/time.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/treap.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/unicode.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/Ast.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/CrossTarget.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/c_builtins.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/ast.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/cross_target.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/parse.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/render.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/string_literal.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/system.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/system/NativePaths.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/system/NativeTargetInfo.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/system/x86.zig"
|
||||
"${CMAKE_SOURCE_DIR}/lib/std/zig/tokenizer.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Air.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/AstGen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Cache.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Compilation.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/DepTokenizer.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Liveness.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Module.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Package.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/RangeSet.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Sema.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/ThreadPool.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/TypedValue.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/WaitGroup.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Zir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/aarch64/CodeGen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/aarch64/Emit.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/aarch64/Mir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/aarch64/bits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/aarch64/abi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/arm/CodeGen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/arm/Emit.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/arm/Mir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/arm/bits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/arm/abi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/riscv64/CodeGen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/riscv64/Emit.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/riscv64/Mir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/riscv64/bits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/riscv64/abi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/sparc64/CodeGen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/sparc64/Emit.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/sparc64/Mir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/sparc64/bits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/sparc64/abi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/wasm/CodeGen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/wasm/Emit.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/wasm/Mir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/x86_64/CodeGen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/x86_64/Emit.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/x86_64/Mir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/x86_64/bits.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/arch/x86_64/abi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/AstGen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/clang.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/clang_options.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/clang_options_data.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/codegen.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/codegen/aarch64.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/codegen/arm.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/codegen/c.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/codegen/llvm.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/codegen/llvm/bindings.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/codegen/riscv64.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/codegen/wasm.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/codegen/x86_64.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/glibc.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/introspect.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/air.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/libc_installation.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/libcxx.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/libtsan.zig"
|
||||
@@ -789,42 +566,30 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/link.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/C.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Coff.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Coff/Atom.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Coff/Object.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Coff/lld.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Elf.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Archive.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Atom.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/CodeSignature.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/DebugSymbols.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/DwarfInfo.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Dylib.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Object.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Symbol.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Trie.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/ZldAtom.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/Zld.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/bind.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/dead_strip.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/thunks.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/zld.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Plan9.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Plan9/aout.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/commands.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/reloc.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/reloc/aarch64.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/MachO/reloc/x86_64.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/Wasm.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/C/zig.h"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/msdos-stub.bin"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/strtab.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/tapi.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/tapi/Tokenizer.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/tapi/parse.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/tapi/parse/test.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/link/tapi/yaml.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/liveness.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/main.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/mingw.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/musl.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/print_air.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/print_env.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/print_targets.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/print_zir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/register_manager.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/stage1.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/target.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/tracy.zig"
|
||||
@@ -834,6 +599,8 @@ set(ZIG_STAGE2_SOURCES
|
||||
"${CMAKE_SOURCE_DIR}/src/value.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/wasi_libc.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/windows_sdk.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Zir.zig"
|
||||
"${CMAKE_SOURCE_DIR}/src/Sema.zig"
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
@@ -911,9 +678,7 @@ else()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(OPTIMIZED_C_FLAGS "/O2")
|
||||
endif()
|
||||
set(OPTIMIZED_C_FLAGS "/O2")
|
||||
else(MSVC)
|
||||
set(OPTIMIZED_C_FLAGS "-std=c99 -O3")
|
||||
endif(MSVC)
|
||||
@@ -963,9 +728,6 @@ add_library(opt_c_util STATIC ${OPTIMIZED_C_SOURCES})
|
||||
set_target_properties(opt_c_util PROPERTIES
|
||||
COMPILE_FLAGS "${OPTIMIZED_C_FLAGS}"
|
||||
)
|
||||
target_include_directories(opt_c_util PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}/deps/SoftFloat-3e-prebuilt"
|
||||
)
|
||||
|
||||
add_library(zigstage1 STATIC ${STAGE1_SOURCES})
|
||||
set_target_properties(zigstage1 PROPERTIES
|
||||
@@ -990,116 +752,110 @@ if(MSVC OR MINGW)
|
||||
endif()
|
||||
|
||||
if("${ZIG_EXECUTABLE}" STREQUAL "")
|
||||
add_executable(zig1 ${ZIG1_SOURCES})
|
||||
set_target_properties(zig1 PROPERTIES
|
||||
add_executable(zig0 ${ZIG0_SOURCES})
|
||||
set_target_properties(zig0 PROPERTIES
|
||||
COMPILE_FLAGS ${EXE_CFLAGS}
|
||||
LINK_FLAGS ${EXE_LDFLAGS}
|
||||
)
|
||||
target_link_libraries(zig1 zigstage1)
|
||||
target_link_libraries(zig0 zigstage1)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(ZIG2_OBJECT "${CMAKE_BINARY_DIR}/zig2.obj")
|
||||
set(ZIG1_OBJECT "${CMAKE_BINARY_DIR}/zig1.obj")
|
||||
else()
|
||||
set(ZIG2_OBJECT "${CMAKE_BINARY_DIR}/zig2.o")
|
||||
set(ZIG1_OBJECT "${CMAKE_BINARY_DIR}/zig1.o")
|
||||
endif()
|
||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
set(ZIG_RELEASE_ARG "")
|
||||
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
||||
set(ZIG_RELEASE_ARG -Drelease)
|
||||
set(ZIG1_RELEASE_ARG "")
|
||||
else()
|
||||
set(ZIG_RELEASE_ARG -Drelease -Dstrip)
|
||||
endif()
|
||||
if(ZIG_NO_LIB)
|
||||
set(ZIG_NO_LIB_ARG "-Dno-lib")
|
||||
else()
|
||||
set(ZIG_NO_LIB_ARG "")
|
||||
set(ZIG1_RELEASE_ARG -OReleaseFast --strip)
|
||||
endif()
|
||||
if(ZIG_SINGLE_THREADED)
|
||||
set(ZIG_SINGLE_THREADED_ARG "-fsingle-threaded")
|
||||
set(ZIG1_SINGLE_THREADED_ARG "--single-threaded")
|
||||
else()
|
||||
set(ZIG_SINGLE_THREADED_ARG "")
|
||||
endif()
|
||||
if(ZIG_STATIC)
|
||||
set(ZIG_STATIC_ARG "-Duse-zig-libcxx")
|
||||
else()
|
||||
set(ZIG_STATIC_ARG "")
|
||||
set(ZIG1_SINGLE_THREADED_ARG "")
|
||||
endif()
|
||||
|
||||
set(BUILD_ZIG2_ARGS
|
||||
set(BUILD_ZIG1_ARGS
|
||||
"src/stage1.zig"
|
||||
--name zig2
|
||||
--zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
|
||||
"-femit-bin=${ZIG2_OBJECT}"
|
||||
-fcompiler-rt
|
||||
${ZIG_SINGLE_THREADED_ARG}
|
||||
-target native
|
||||
-mcpu native
|
||||
-target "${ZIG_TARGET_TRIPLE}"
|
||||
"-mcpu=${ZIG_TARGET_MCPU}"
|
||||
--name zig1
|
||||
--override-lib-dir "${CMAKE_SOURCE_DIR}/lib"
|
||||
"-femit-bin=${ZIG1_OBJECT}"
|
||||
"${ZIG1_RELEASE_ARG}"
|
||||
"${ZIG1_SINGLE_THREADED_ARG}"
|
||||
-lc
|
||||
--pkg-begin build_options "${ZIG_CONFIG_ZIG_OUT}"
|
||||
--pkg-end
|
||||
--pkg-begin compiler_rt "${CMAKE_SOURCE_DIR}/lib/std/special/compiler_rt.zig"
|
||||
--pkg-end
|
||||
)
|
||||
|
||||
if("${ZIG_EXECUTABLE}" STREQUAL "")
|
||||
add_custom_command(
|
||||
OUTPUT "${ZIG2_OBJECT}"
|
||||
COMMAND zig1 ${BUILD_ZIG2_ARGS}
|
||||
DEPENDS zig1 "${ZIG_STAGE2_SOURCES}"
|
||||
COMMENT STATUS "Building stage2 object ${ZIG2_OBJECT}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT "${ZIG1_OBJECT}"
|
||||
COMMAND zig0 ${BUILD_ZIG1_ARGS}
|
||||
DEPENDS zig0 "${ZIG_STAGE2_SOURCES}"
|
||||
COMMENT STATUS "Building self-hosted component ${ZIG1_OBJECT}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
set(ZIG_EXECUTABLE "${zig_BINARY_DIR}/zig")
|
||||
if (WIN32)
|
||||
set(ZIG_EXECUTABLE "${CMAKE_BINARY_DIR}/zig2.exe")
|
||||
else()
|
||||
set(ZIG_EXECUTABLE "${CMAKE_BINARY_DIR}/zig2")
|
||||
set(ZIG_EXECUTABLE "${ZIG_EXECUTABLE}.exe")
|
||||
endif()
|
||||
else()
|
||||
add_custom_command(
|
||||
OUTPUT "${ZIG2_OBJECT}"
|
||||
COMMAND "${ZIG_EXECUTABLE}" "build-obj" ${BUILD_ZIG2_ARGS}
|
||||
DEPENDS ${ZIG_STAGE2_SOURCES}
|
||||
COMMENT STATUS "Building stage2 component ${ZIG2_OBJECT}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT "${ZIG1_OBJECT}"
|
||||
COMMAND "${ZIG_EXECUTABLE}" "build-obj" ${BUILD_ZIG1_ARGS}
|
||||
DEPENDS ${ZIG_STAGE2_SOURCES}
|
||||
COMMENT STATUS "Building self-hosted component ${ZIG1_OBJECT}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# cmake won't let us configure an executable without C sources.
|
||||
add_executable(zig2 "${CMAKE_SOURCE_DIR}/src/stage1/empty.cpp" "${ZIG2_OBJECT}")
|
||||
add_executable(zig "${CMAKE_SOURCE_DIR}/src/stage1/empty.cpp" "${ZIG1_OBJECT}")
|
||||
|
||||
set_target_properties(zig2 PROPERTIES
|
||||
set_target_properties(zig PROPERTIES
|
||||
COMPILE_FLAGS ${EXE_CFLAGS}
|
||||
LINK_FLAGS ${EXE_LDFLAGS}
|
||||
)
|
||||
target_link_libraries(zig2 zigstage1)
|
||||
target_link_libraries(zig zigstage1)
|
||||
if(MSVC)
|
||||
target_link_libraries(zig2 ntdll.lib)
|
||||
target_link_libraries(zig ntdll.lib)
|
||||
elseif(MINGW)
|
||||
target_link_libraries(zig2 ntdll)
|
||||
target_link_libraries(zig ntdll)
|
||||
endif()
|
||||
|
||||
set(ZIG_BUILD_ARGS
|
||||
--zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
|
||||
"-Dconfig_h=${ZIG_CONFIG_H_OUT}"
|
||||
"-Denable-llvm"
|
||||
"-Denable-stage1"
|
||||
${ZIG_RELEASE_ARG}
|
||||
${ZIG_STATIC_ARG}
|
||||
${ZIG_NO_LIB_ARG}
|
||||
${ZIG_SINGLE_THREADED_ARG}
|
||||
"-Dtarget=${ZIG_TARGET_TRIPLE}"
|
||||
"-Dcpu=${ZIG_TARGET_MCPU}"
|
||||
"-Dversion-string=${ZIG_VERSION}"
|
||||
)
|
||||
install(TARGETS zig DESTINATION bin)
|
||||
|
||||
add_custom_target(stage3 ALL
|
||||
COMMAND zig2 build compile ${ZIG_BUILD_ARGS}
|
||||
DEPENDS zig2
|
||||
COMMENT STATUS "Building stage3"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL
|
||||
"Disable copying lib/ files to install prefix during the build phase")
|
||||
|
||||
install(CODE "set(ZIG_EXECUTABLE \"${ZIG_EXECUTABLE}\")")
|
||||
install(CODE "set(ZIG_BUILD_ARGS \"${ZIG_BUILD_ARGS}\")")
|
||||
install(CODE "set(CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")")
|
||||
install(CODE "set(CMAKE_SOURCE_DIR \"${CMAKE_SOURCE_DIR}\")")
|
||||
install(SCRIPT "${CMAKE_SOURCE_DIR}/cmake/install.cmake")
|
||||
if(NOT ZIG_SKIP_INSTALL_LIB_FILES)
|
||||
set(ZIG_INSTALL_ARGS "build"
|
||||
--override-lib-dir "${CMAKE_SOURCE_DIR}/lib"
|
||||
"-Dlib-files-only"
|
||||
--prefix "${CMAKE_INSTALL_PREFIX}"
|
||||
"-Dconfig_h=${ZIG_CONFIG_H_OUT}"
|
||||
install
|
||||
)
|
||||
|
||||
# CODE has no effect with Visual Studio build system generator, therefore
|
||||
# when using Visual Studio build system generator we resort to running
|
||||
# `zig build install` during the build phase.
|
||||
if(MSVC)
|
||||
add_custom_target(zig_install_lib_files ALL
|
||||
COMMAND zig ${ZIG_INSTALL_ARGS}
|
||||
DEPENDS zig
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
else()
|
||||
get_target_property(zig_BINARY_DIR zig BINARY_DIR)
|
||||
install(CODE "set(zig_EXE \"${ZIG_EXECUTABLE}\")")
|
||||
install(CODE "set(ZIG_INSTALL_ARGS \"${ZIG_INSTALL_ARGS}\")")
|
||||
install(CODE "set(CMAKE_SOURCE_DIR \"${CMAKE_SOURCE_DIR}\")")
|
||||
install(SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.cmake)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
One of the best ways you can contribute to Zig is to start using it for a
|
||||
personal project. Here are some great examples:
|
||||
|
||||
* [Oxid](https://github.com/dbandstra/oxid) - arcade style game
|
||||
* [TM35-Metronome](https://github.com/TM35-Metronome) - tools for modifying and randomizing Pokémon games
|
||||
* [River](https://github.com/ifreund/river/) - a dynamic tiling wayland compositor
|
||||
|
||||
@@ -68,7 +69,7 @@ test and debug from a git working tree.
|
||||
- `make` is typically sufficient to build zig during development iterations.
|
||||
- `make install` performs a build __and__ install.
|
||||
- `msbuild -p:Configuration=Release INSTALL.vcxproj` on Windows performs a
|
||||
build and install. To avoid install, pass cmake option `-DZIG_NO_LIB=ON`.
|
||||
build and install. To avoid install, pass cmake option `-DZIG_SKIP_INSTALL_LIB_FILES=ON`.
|
||||
|
||||
To test changes, do the following from the build directory:
|
||||
|
||||
@@ -104,17 +105,9 @@ When making changes to the compiler source code, the most helpful test step to
|
||||
run is `test-behavior`. When editing documentation it is `docs`. You can find
|
||||
this information and more in the `--help` menu.
|
||||
|
||||
#### Testing Changes to std lib
|
||||
|
||||
To quickly test a change to a file in the standard library, you can run zig test and specify a custom lib directory with the follow command-line argument.
|
||||
|
||||
```bash
|
||||
./build/zig test lib/std/fmt.zig --zig-lib-dir lib --main-pkg-path lib/std
|
||||
```
|
||||
|
||||
#### Testing Non-Native Architectures with QEMU
|
||||
|
||||
The Linux CI server additionally has qemu installed and sets `-fqemu`.
|
||||
The Linux CI server additionally has qemu installed and sets `-Denable-qemu`.
|
||||
This provides test coverage for, e.g. aarch64 even on x86_64 machines. It's
|
||||
recommended for Linux users to install qemu and enable this testing option
|
||||
when editing the standard library or anything related to a non-native
|
||||
@@ -123,7 +116,7 @@ architecture.
|
||||
##### glibc
|
||||
|
||||
Testing foreign architectures with dynamically linked glibc is one step trickier.
|
||||
This requires enabling `--glibc-runtimes /path/to/glibc/multi/install/glibcs`.
|
||||
This requires enabling `-Denable-foreign-glibc=/path/to/glibc/multi/install/glibcs`.
|
||||
This path is obtained by building glibc for multiple architectures. This
|
||||
process for me took an entire day to complete and takes up 65 GiB on my hard
|
||||
drive. The CI server does not provide this test coverage. Instructions for
|
||||
@@ -135,7 +128,7 @@ It's understood that most contributors will not have these tests enabled.
|
||||
|
||||
#### Testing Windows from a Linux Machine with Wine
|
||||
|
||||
When developing on Linux, another option is available to you: `-fwine`.
|
||||
When developing on Linux, another option is available to you: `-Denable-wine`.
|
||||
This will enable running behavior tests and std lib tests with Wine. It's
|
||||
recommended for Linux users to install Wine and enable this testing option
|
||||
when editing the standard library or anything Windows-related.
|
||||
@@ -143,7 +136,7 @@ when editing the standard library or anything Windows-related.
|
||||
#### Testing WebAssembly using wasmtime
|
||||
|
||||
If you have [wasmtime](https://wasmtime.dev/) installed, take advantage of the
|
||||
`-fwasmtime` flag which will enable running WASI behavior tests and std
|
||||
`-Denable-wasmtime` flag which will enable running WASI behavior tests and std
|
||||
lib tests. It's recommended for all users to install wasmtime and enable this
|
||||
testing option when editing the standard library and especially anything
|
||||
WebAssembly-related.
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
The MIT License (Expat)
|
||||
|
||||
Copyright (c) 2015-2023, Zig contributors
|
||||
Copyright (c) 2015-2021, 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||

|
||||

|
||||
|
||||
A general-purpose programming language and toolchain for maintaining
|
||||
**robust**, **optimal**, and **reusable** software.
|
||||
@@ -9,8 +9,8 @@ A general-purpose programming language and toolchain for maintaining
|
||||
* [Download & Documentation](https://ziglang.org/download)
|
||||
* [Chapter 0 - Getting Started | ZigLearn.org](https://ziglearn.org/)
|
||||
* [Community](https://github.com/ziglang/zig/wiki/Community)
|
||||
* [Contributing](https://github.com/ziglang/zig/blob/master/.github/CONTRIBUTING.md)
|
||||
* [Code of Conduct](https://github.com/ziglang/zig/blob/master/.github/CODE_OF_CONDUCT.md)
|
||||
* [Contributing](https://github.com/ziglang/zig/blob/master/CONTRIBUTING.md)
|
||||
* [Code of Conduct](https://github.com/ziglang/zig/blob/master/CODE_OF_CONDUCT.md)
|
||||
* [Frequently Asked Questions](https://github.com/ziglang/zig/wiki/FAQ)
|
||||
* [Community Projects](https://github.com/ziglang/zig/wiki/Community-Projects)
|
||||
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,70 +0,0 @@
|
||||
#!/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
|
||||
125
ci/azure/linux_script
Executable file
125
ci/azure/linux_script
Executable file
@@ -0,0 +1,125 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
sudo apt-get update -q
|
||||
sudo apt-get install -y cmake s3cmd tidy
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.1-dev.94+535615117"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
MCPU="baseline"
|
||||
JOBS="-j$(nproc)"
|
||||
|
||||
rm -rf $PREFIX
|
||||
cd $HOME
|
||||
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
QEMUBASE="qemu-linux-x86_64-5.2.0.1"
|
||||
wget -nv "https://ziglang.org/deps/$QEMUBASE.tar.xz"
|
||||
tar xf "$QEMUBASE.tar.xz"
|
||||
export PATH="$(pwd)/$QEMUBASE/bin:$PATH"
|
||||
|
||||
# Bump to v0.23 once this issue is resolved:
|
||||
# https://github.com/ziglang/zig/issues/8742
|
||||
WASMTIME="wasmtime-v0.22.1-x86_64-linux"
|
||||
wget -nv "https://github.com/bytecodealliance/wasmtime/releases/download/v0.22.1/$WASMTIME.tar.xz"
|
||||
tar xf "$WASMTIME.tar.xz"
|
||||
export PATH="$(pwd)/$WASMTIME:$PATH"
|
||||
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON
|
||||
|
||||
# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
|
||||
# so that installation and testing do not get affected by them.
|
||||
unset CC
|
||||
unset CXX
|
||||
|
||||
make $JOBS install
|
||||
|
||||
# Here we rebuild zig but this time using the Zig binary we just now produced to
|
||||
# build zig1.o rather than relying on the one built with stage0. See
|
||||
# https://github.com/ziglang/zig/issues/6830 for more details.
|
||||
cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig"
|
||||
make $JOBS install
|
||||
|
||||
for step in test-toolchain test-std docs; do
|
||||
release/bin/zig build $step -Denable-qemu -Denable-wasmtime
|
||||
done
|
||||
|
||||
# Look for HTML errors.
|
||||
tidy -qe ../zig-cache/langref.html
|
||||
|
||||
if [ "${BUILD_REASON}" != "PullRequest" ]; then
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p release/docs/std
|
||||
release/bin/zig test ../lib/std/std.zig \
|
||||
--override-lib-dir ../lib \
|
||||
-femit-docs=release/docs/std \
|
||||
-fno-emit-bin
|
||||
|
||||
mv ../LICENSE release/
|
||||
mv ../zig-cache/langref.html release/docs/
|
||||
|
||||
# Remove the unnecessary bin dir in $prefix/bin/zig
|
||||
mv release/bin/zig release/
|
||||
rmdir release/bin
|
||||
|
||||
# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
|
||||
mv release/lib/zig release/lib2
|
||||
rmdir release/lib
|
||||
mv release/lib2 release/lib
|
||||
|
||||
VERSION=$(release/zig version)
|
||||
DIRNAME="zig-linux-$ARCH-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv release "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="linux-$GITBRANCH.json"
|
||||
touch $JSONFILE
|
||||
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-linux-$VERSION.json"
|
||||
|
||||
# `set -x` causes these variables to be mangled.
|
||||
# See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
|
||||
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
|
||||
131
ci/azure/macos_arm64_script
Executable file
131
ci/azure/macos_arm64_script
Executable file
@@ -0,0 +1,131 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
brew update && brew install s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
|
||||
HOST_ARCH="x86_64"
|
||||
HOST_TARGET="$HOST_ARCH-macos-gnu"
|
||||
HOST_MCPU="baseline"
|
||||
HOST_CACHE_BASENAME="zig+llvm+lld+clang-$HOST_TARGET-0.8.0-dev.2703+c12704a33"
|
||||
HOST_PREFIX="$HOME/$HOST_CACHE_BASENAME"
|
||||
|
||||
ARCH="aarch64"
|
||||
TARGET="$ARCH-macos-gnu"
|
||||
MCPU="apple_a14"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.0-dev.2703+c12704a33"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
|
||||
JOBS="-j2"
|
||||
|
||||
rm -rf $HOST_PREFIX $PREFIX
|
||||
cd $HOME
|
||||
|
||||
wget -nv "https://ziglang.org/deps/$HOST_CACHE_BASENAME.tar.xz"
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$HOST_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
|
||||
|
||||
# Build host zig compiler in debug so that we can get the
|
||||
# current version when packaging
|
||||
|
||||
ZIG="$HOST_PREFIX/bin/zig"
|
||||
|
||||
export CC="$ZIG cc -target $HOST_TARGET -mcpu=$HOST_MCPU"
|
||||
export CXX="$ZIG c++ -target $HOST_TARGET -mcpu=$HOST_MCPU"
|
||||
|
||||
mkdir build.host
|
||||
cd build.host
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
|
||||
-DCMAKE_PREFIX_PATH="$HOST_PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DZIG_TARGET_TRIPLE="$HOST_TARGET" \
|
||||
-DZIG_TARGET_MCPU="$HOST_MCPU" \
|
||||
-DZIG_STATIC=ON
|
||||
|
||||
unset CC
|
||||
unset CXX
|
||||
|
||||
make $JOBS install
|
||||
|
||||
# Build zig compiler cross-compiled for arm64
|
||||
cd $ZIGDIR
|
||||
|
||||
ZIG="$ZIGDIR/build.host/release/bin/zig"
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_EXECUTABLE="$ZIG" \
|
||||
-DZIG_STATIC=ON
|
||||
|
||||
unset CC
|
||||
unset CXX
|
||||
|
||||
make $JOBS install
|
||||
|
||||
if [ "${BUILD_REASON}" != "PullRequest" ]; then
|
||||
mv ../LICENSE release/
|
||||
|
||||
# We do not run test suite but still need langref.
|
||||
mkdir -p release/docs
|
||||
$ZIG run ../doc/docgen.zig -- $ZIG ../doc/langref.html.in release/docs/langref.html
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p release/docs/std
|
||||
$ZIG test ../lib/std/std.zig \
|
||||
--override-lib-dir ../lib \
|
||||
-femit-docs=release/docs/std \
|
||||
-fno-emit-bin
|
||||
|
||||
mv release/bin/zig release/
|
||||
rmdir release/bin
|
||||
|
||||
VERSION=$(../build.host/release/bin/zig version)
|
||||
DIRNAME="zig-macos-$ARCH-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv release "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(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"
|
||||
fi
|
||||
94
ci/azure/macos_script
Executable file
94
ci/azure/macos_script
Executable file
@@ -0,0 +1,94 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
brew update && brew install s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
ARCH="x86_64"
|
||||
TARGET="$ARCH-macos-gnu"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.8.1-dev.94+535615117"
|
||||
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="$(pwd)/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
|
||||
|
||||
# Here we rebuild zig but this time using the Zig binary we just now produced to
|
||||
# build zig1.o rather than relying on the one built with stage0. See
|
||||
# https://github.com/ziglang/zig/issues/6830 for more details.
|
||||
cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig"
|
||||
make $JOBS install
|
||||
|
||||
for step in test-toolchain test-std docs; do
|
||||
release/bin/zig build $step
|
||||
done
|
||||
|
||||
if [ "${BUILD_REASON}" != "PullRequest" ]; then
|
||||
mv ../LICENSE release/
|
||||
mv ../zig-cache/langref.html release/
|
||||
mv release/bin/zig release/
|
||||
rmdir release/bin
|
||||
|
||||
VERSION=$(release/zig version)
|
||||
DIRNAME="zig-macos-$ARCH-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv release "$DIRNAME"
|
||||
tar cfJ "$TARBALL" "$DIRNAME"
|
||||
|
||||
mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
||||
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(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"
|
||||
fi
|
||||
12
ci/azure/on_master_success
Executable file
12
ci/azure/on_master_success
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/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"
|
||||
78
ci/azure/pipelines.yml
Normal file
78
ci/azure/pipelines.yml
Normal file
@@ -0,0 +1,78 @@
|
||||
jobs:
|
||||
- job: BuildMacOS
|
||||
pool:
|
||||
vmImage: 'macOS-10.15'
|
||||
timeoutInMinutes: 360
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: s3cfg
|
||||
- script: ci/azure/macos_script
|
||||
name: main
|
||||
displayName: 'Build and test'
|
||||
- job: BuildMacOS_arm64
|
||||
pool:
|
||||
vmImage: 'macOS-10.15'
|
||||
timeoutInMinutes: 180
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: s3cfg
|
||||
- script: ci/azure/macos_arm64_script
|
||||
name: main
|
||||
displayName: 'Build'
|
||||
- job: BuildLinux
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
timeoutInMinutes: 360
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: s3cfg
|
||||
- script: ci/azure/linux_script
|
||||
name: main
|
||||
displayName: 'Build and test'
|
||||
- job: BuildWindows
|
||||
pool:
|
||||
vmImage: 'windows-2019'
|
||||
timeoutInMinutes: 360
|
||||
steps:
|
||||
- powershell: |
|
||||
(New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2021-06-04/msys2-base-x86_64-20210604.sfx.exe", "sfx.exe")
|
||||
.\sfx.exe -y -o\
|
||||
del sfx.exe
|
||||
displayName: Download/Extract/Install MSYS2
|
||||
- script: |
|
||||
@REM install updated filesystem package first without dependency checking
|
||||
@REM because of: https://github.com/msys2/MSYS2-packages/issues/2021
|
||||
%CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Sydd filesystem"
|
||||
displayName: Workaround filesystem dash MSYS2 dependency issue
|
||||
- script: |
|
||||
%CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu"
|
||||
%CD:~0,2%\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu"
|
||||
displayName: Update MSYS2
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: s3cfg
|
||||
- script: ci/azure/windows_msvc_script.bat
|
||||
name: main
|
||||
displayName: 'Build and test'
|
||||
- job: OnMasterSuccess
|
||||
dependsOn:
|
||||
- BuildMacOS
|
||||
- BuildMacOS_arm64
|
||||
- BuildLinux
|
||||
- BuildWindows
|
||||
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
|
||||
strategy:
|
||||
maxParallel: 1
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
variables:
|
||||
version: $[ dependencies.BuildLinux.outputs['main.version'] ]
|
||||
steps:
|
||||
- task: DownloadSecureFile@1
|
||||
inputs:
|
||||
secureFile: oauth_token
|
||||
- script: ci/azure/on_master_success
|
||||
displayName: 'master branch success hook'
|
||||
11
ci/azure/windows_msvc_install
Normal file
11
ci/azure/windows_msvc_install
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
pacman -Suy --needed --noconfirm
|
||||
pacman -S --needed --noconfirm wget p7zip python3-pip tar xz
|
||||
|
||||
pip install s3cmd
|
||||
wget -nv "https://ziglang.org/deps/llvm%2bclang%2blld-12.0.1-rc1-x86_64-windows-msvc-release-mt.tar.xz"
|
||||
tar xf llvm+clang+lld-12.0.1-rc1-x86_64-windows-msvc-release-mt.tar.xz
|
||||
35
ci/azure/windows_msvc_script.bat
Normal file
35
ci/azure/windows_msvc_script.bat
Normal file
@@ -0,0 +1,35 @@
|
||||
@echo on
|
||||
SET "SRCROOT=%cd%"
|
||||
SET "PREVPATH=%PATH%"
|
||||
SET "PREVMSYSEM=%MSYSTEM%"
|
||||
|
||||
set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
|
||||
SET "MSYSTEM=MINGW64"
|
||||
bash -lc "cd ${SRCROOT} && ci/azure/windows_msvc_install" || exit /b
|
||||
SET "PATH=%PREVPATH%"
|
||||
SET "MSYSTEM=%PREVMSYSTEM%"
|
||||
|
||||
SET "ZIGBUILDDIR=%SRCROOT%\build"
|
||||
SET "ZIGINSTALLDIR=%ZIGBUILDDIR%\dist"
|
||||
SET "ZIGPREFIXPATH=%SRCROOT%\llvm+clang+lld-12.0.1-rc1-x86_64-windows-msvc-release-mt"
|
||||
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
|
||||
|
||||
REM Make the `zig version` number consistent.
|
||||
REM This will affect the cmake command below.
|
||||
git.exe config core.abbrev 9
|
||||
git.exe fetch --unshallow
|
||||
git.exe fetch --tags
|
||||
|
||||
mkdir %ZIGBUILDDIR%
|
||||
cd %ZIGBUILDDIR%
|
||||
cmake.exe .. -Thost=x64 -G"Visual Studio 16 2019" -A x64 "-DCMAKE_INSTALL_PREFIX=%ZIGINSTALLDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release -DZIG_OMIT_STAGE2=ON || exit /b
|
||||
msbuild /maxcpucount /p:Configuration=Release INSTALL.vcxproj || exit /b
|
||||
|
||||
"%ZIGINSTALLDIR%\bin\zig.exe" build test-toolchain -Dskip-non-native -Dskip-stage2-tests || exit /b
|
||||
"%ZIGINSTALLDIR%\bin\zig.exe" build test-std -Dskip-non-native || exit /b
|
||||
"%ZIGINSTALLDIR%\bin\zig.exe" build docs || exit /b
|
||||
|
||||
set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
|
||||
SET "MSYSTEM=MINGW64"
|
||||
bash -lc "cd ${SRCROOT} && ci/azure/windows_upload" || exit /b
|
||||
41
ci/azure/windows_upload
Executable file
41
ci/azure/windows_upload
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
if [ "${BUILD_REASON}" != "PullRequest" ]; then
|
||||
cd "$ZIGBUILDDIR"
|
||||
|
||||
mv ../LICENSE dist/
|
||||
mv ../zig-cache/langref.html dist/
|
||||
mv dist/bin/zig.exe dist/
|
||||
rmdir dist/bin
|
||||
|
||||
VERSION=$(dist/zig.exe version)
|
||||
DIRNAME="zig-windows-x86_64-$VERSION"
|
||||
TARBALL="$DIRNAME.zip"
|
||||
mv dist "$DIRNAME"
|
||||
7z a "$TARBALL" "$DIRNAME"
|
||||
|
||||
# mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
|
||||
s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
|
||||
BYTESIZE=$(wc -c < $TARBALL)
|
||||
|
||||
JSONFILE="windows-$GITBRANCH.json"
|
||||
touch $JSONFILE
|
||||
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
|
||||
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
|
||||
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
|
||||
|
||||
s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
|
||||
s3cmd -c "$DOWNLOADSECUREFILE_SECUREFILEPATH" put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-windows-$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"
|
||||
fi
|
||||
50
ci/drone/drone.yml
Normal file
50
ci/drone/drone.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: test-aarch64-linux-musl
|
||||
|
||||
platform:
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: ziglang/static-base:llvm12-aarch64-5
|
||||
commands:
|
||||
- ./ci/drone/linux_script_build
|
||||
|
||||
- name: test-1
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm12-aarch64-5
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 1
|
||||
|
||||
- name: test-2
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm12-aarch64-5
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 2
|
||||
|
||||
- name: test-3
|
||||
depends_on:
|
||||
- build
|
||||
image: ziglang/static-base:llvm12-aarch64-5
|
||||
commands:
|
||||
- ./ci/drone/linux_script_test 3
|
||||
|
||||
- name: finalize
|
||||
depends_on:
|
||||
- build
|
||||
- test-1
|
||||
- test-2
|
||||
- test-3
|
||||
image: ziglang/static-base:llvm12-aarch64-5
|
||||
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
|
||||
22
ci/drone/linux_script_base
Executable file
22
ci/drone/linux_script_base
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
# https://docs.drone.io/pipeline/docker/syntax/workspace/
|
||||
#
|
||||
# Drone automatically creates a temporary volume, known as your workspace,
|
||||
# where it clones your repository. The workspace is the current working
|
||||
# directory for each step in your pipeline.
|
||||
#
|
||||
# Because the workspace is a volume, filesystem changes are persisted between
|
||||
# pipeline steps. In other words, individual steps can communicate and share
|
||||
# state using the filesystem.
|
||||
#
|
||||
# Workspace volumes are ephemeral. They are created when the pipeline starts
|
||||
# and destroyed after the pipeline completes.
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
TRIPLEARCH="$(uname -m)"
|
||||
DISTDIR="$DRONE_WORKSPACE/dist"
|
||||
|
||||
export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
|
||||
59
ci/drone/linux_script_build
Executable file
59
ci/drone/linux_script_build
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./ci/drone/linux_script_base
|
||||
|
||||
PREFIX="/deps/local"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
TARGET="$TRIPLEARCH-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_INSTALL_PREFIX="$DISTDIR" \
|
||||
-DCMAKE_PREFIX_PATH="$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
|
||||
|
||||
# Here we rebuild Zig but this time using the Zig binary we just now produced to
|
||||
# build zig1.o rather than relying on the one built with stage0. See
|
||||
# https://github.com/ziglang/zig/issues/6830 for more details.
|
||||
cmake .. -DZIG_EXECUTABLE="$DISTDIR/bin/zig"
|
||||
samu install
|
||||
46
ci/drone/linux_script_finalize
Executable file
46
ci/drone/linux_script_finalize
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./ci/drone/linux_script_base
|
||||
|
||||
if [ -n "$DRONE_PULL_REQUEST" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
apk update
|
||||
apk add py3-pip perl-utils jq curl
|
||||
pip3 install s3cmd
|
||||
|
||||
cd build
|
||||
|
||||
mv ../LICENSE "$DISTDIR/"
|
||||
# docs are disabled due to: https://github.com/ziglang/zig/issues/8597
|
||||
#mv ../zig-cache/langref.html "$DISTDIR/"
|
||||
mv "$DISTDIR/bin/zig" "$DISTDIR/"
|
||||
rmdir "$DISTDIR/bin"
|
||||
|
||||
GITBRANCH="$DRONE_BRANCH"
|
||||
VERSION="$("$DISTDIR/zig" version)"
|
||||
DIRNAME="zig-linux-$TRIPLEARCH-$VERSION"
|
||||
TARBALL="$DIRNAME.tar.xz"
|
||||
mv "$DISTDIR" "$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/$TRIPLEARCH-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
|
||||
46
ci/drone/linux_script_test
Executable file
46
ci/drone/linux_script_test
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
. ./ci/drone/linux_script_base
|
||||
|
||||
# only release-fast builds of test suite due to: https://github.com/ziglang/zig/issues/8597
|
||||
#
|
||||
# Some test suite components will be missing because they do not support
|
||||
# forcing -OReleaseFast
|
||||
#
|
||||
# see `zig build --help` for the full list of test-* components
|
||||
case "$1" in
|
||||
1)
|
||||
steps="\
|
||||
test-stage2 \
|
||||
test-fmt \
|
||||
test-behavior"
|
||||
;;
|
||||
2)
|
||||
steps="test-std"
|
||||
;;
|
||||
3)
|
||||
steps="\
|
||||
test-compiler-rt \
|
||||
test-minilibc \
|
||||
test-compare-output \
|
||||
test-translate-c \
|
||||
test-run-translated-c"
|
||||
;;
|
||||
'')
|
||||
echo "error: expecting test group argument"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
echo "error: unknown test group: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# only release-fast builds of test suite due to: https://github.com/ziglang/zig/issues/8597
|
||||
./build/zig build \
|
||||
-Drelease \
|
||||
-Dskip-debug \
|
||||
-Dskip-release-small \
|
||||
-Dskip-release-safe \
|
||||
-Dskip-non-native \
|
||||
$steps
|
||||
79
ci/srht/freebsd_script
Executable file
79
ci/srht/freebsd_script
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
sudo pkg update -fq
|
||||
sudo pkg install -y cmake py38-s3cmd wget curl jq samurai
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-x86_64-freebsd-gnu-0.8.0-dev.2703+c12704a33"
|
||||
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 \
|
||||
"-DCMAKE_INSTALL_PREFIX=$(pwd)/release" \
|
||||
-DZIG_STATIC=ON \
|
||||
-DZIG_TARGET_TRIPLE=x86_64-freebsd-gnu \
|
||||
-GNinja
|
||||
samu install
|
||||
|
||||
# Here we skip some tests to save time.
|
||||
release/bin/zig build test -Dskip-compile-errors -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-freebsd-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="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
|
||||
737
ci/srht/index.html
Normal file
737
ci/srht/index.html
Normal file
@@ -0,0 +1,737 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Releases ⚡ The Zig Programming Language</title>
|
||||
<link rel="icon" href="/favicon.png">
|
||||
<style>
|
||||
body{
|
||||
font-family: system-ui, -apple-system, Roboto, "Segoe UI", sans-serif;
|
||||
line-height: 1.45;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
p {
|
||||
margin: 0.8em 0;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4 {
|
||||
margin: 0.5em 0 0.5em;
|
||||
line-height: 1.2;
|
||||
font-weight: bold;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
h1 a, h2 a, h3 a, h4 a {
|
||||
text-decoration: none;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
a.hdr {
|
||||
visibility: hidden;
|
||||
}
|
||||
h1:hover > a.hdr, h2:hover > a.hdr, h3:hover > a.hdr, h4:hover > a.hdr, h5:hover > a.hdr {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
h1 { font-size: 2.0em; }
|
||||
|
||||
h2 { font-size: 1.5em; }
|
||||
|
||||
h3 { font-size: 1.25em; }
|
||||
|
||||
h4 { font-size: 1.0em; }
|
||||
|
||||
a {
|
||||
color: #2A6286;
|
||||
}
|
||||
|
||||
a:not(:hover) {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
th, td {
|
||||
padding: 0.6em;
|
||||
text-align: left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
td {
|
||||
font-size: 0.96em;
|
||||
}
|
||||
|
||||
th {
|
||||
border-bottom: 2px solid #f2f3f3;
|
||||
}
|
||||
|
||||
tr:nth-child(even) {
|
||||
background: #f2f3f3;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
max-width: 1000px;
|
||||
}
|
||||
|
||||
#navbar {
|
||||
background-color: #737475;
|
||||
padding: 5px 0;
|
||||
border-top: 4px solid #f7a41d;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
#navbar .navbar-item, #navbar .navbar-item:visited {
|
||||
color: white;
|
||||
padding-right: 5px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.code {
|
||||
font-family: monospace;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
#header-image {
|
||||
background-image: url(https://ziglang.org/img/zig-logo-dark.svg);
|
||||
background-repeat: no-repeat;
|
||||
width: 340px;
|
||||
height: 90px;
|
||||
display: block;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body{
|
||||
background-color:#111;
|
||||
color: #bbb;
|
||||
}
|
||||
a {
|
||||
color: #88f;
|
||||
}
|
||||
table, th, td {
|
||||
border-color: grey;
|
||||
}
|
||||
tr:nth-child(even) {
|
||||
background: #1e1e1e;
|
||||
}
|
||||
h1 a, h2 a, h3 a, h4 a, h5 a {
|
||||
color: #aaa;
|
||||
}
|
||||
#header-image {
|
||||
background-image: url(https://ziglang.org/img/zig-logo-light.svg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<a href="/"><span id="header-image"></span></a>
|
||||
</div>
|
||||
<nav id="navbar">
|
||||
<div class="container">
|
||||
<a href="/download/" class="navbar-item">Download & Documentation</a>
|
||||
<a href="https://github.com/ziglang/zig" class="navbar-item">Source Code</a>
|
||||
<a href="/news/" class="navbar-item">News</a>
|
||||
<a href="https://github.com/ziglang/zig/wiki/Community" class="navbar-item">Join a Community</a>
|
||||
<a href="/zsf/" class="navbar-item">
|
||||
<svg style="color: #ea4aaa; vertical-align: middle;fill: currentColor; margin-right: 5px" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M9 2c-.97 0-1.69.42-2.2 1-.51.58-.78.92-.8 1-.02-.08-.28-.42-.8-1-.52-.58-1.17-1-2.2-1-1.632.086-2.954 1.333-3 3 0 .52.09 1.52.67 2.67C1.25 8.82 3.01 10.61 6 13c2.98-2.39 4.77-4.17 5.34-5.33C11.91 6.51 12 5.5 12 5c-.047-1.69-1.342-2.913-3-3z"></path></svg>Sponsor the Zig Software Foundation</a>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container">
|
||||
<h1>Releases</h1>
|
||||
<p>You can also
|
||||
<a href="https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager">install Zig from a package manager</a>.
|
||||
</p>
|
||||
<p>
|
||||
There is a <a href="index.json">JSON version of this page</a>.
|
||||
</p>
|
||||
|
||||
<h2 id="release-master">master</h2>
|
||||
<ul>
|
||||
<li>{{MASTER_DATE}}</li>
|
||||
<li><a href="/documentation/master/">Language Reference</a></li>
|
||||
<li><a href="/documentation/master/std/">Standard Library Documentation</a> (experimental)</li>
|
||||
</ul>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Filename</th>
|
||||
<th>Kind</th>
|
||||
<th>Size</th>
|
||||
<th>Sha256</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/builds/{{SRC_TARBALL}}">{{SRC_TARBALL}}</a></td>
|
||||
<td>Source</td>
|
||||
<td>{{SRC_BYTESIZE}}</td>
|
||||
<td class="code">{{SRC_SHASUM}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/builds/{{X86_64_LINUX_TARBALL}}">{{X86_64_LINUX_TARBALL}}</a></td>
|
||||
<td>Binary</td>
|
||||
<td>{{X86_64_LINUX_BYTESIZE}}</td>
|
||||
<td class="code">{{X86_64_LINUX_SHASUM}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/builds/{{AARCH64_LINUX_TARBALL}}">{{AARCH64_LINUX_TARBALL}}</a></td>
|
||||
<td>Binary</td>
|
||||
<td>{{AARCH64_LINUX_BYTESIZE}}</td>
|
||||
<td class="code">{{AARCH64_LINUX_SHASUM}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/builds/{{X86_64_WINDOWS_TARBALL}}">{{X86_64_WINDOWS_TARBALL}}</a></td>
|
||||
<td>Binary</td>
|
||||
<td>{{X86_64_WINDOWS_BYTESIZE}}</td>
|
||||
<td class="code">{{X86_64_WINDOWS_SHASUM}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/builds/{{X86_64_MACOS_TARBALL}}">{{X86_64_MACOS_TARBALL}}</a></td>
|
||||
<td>Binary</td>
|
||||
<td>{{X86_64_MACOS_BYTESIZE}}</td>
|
||||
<td class="code">{{X86_64_MACOS_SHASUM}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/builds/{{AARCH64_MACOS_TARBALL}}">{{AARCH64_MACOS_TARBALL}}</a></td>
|
||||
<td>Binary</td>
|
||||
<td>{{AARCH64_MACOS_BYTESIZE}}</td>
|
||||
<td class="code">{{AARCH64_MACOS_SHASUM}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/builds/{{X86_64_FREEBSD_TARBALL}}">{{X86_64_FREEBSD_TARBALL}}</a></td>
|
||||
<td>Binary</td>
|
||||
<td>{{X86_64_FREEBSD_BYTESIZE}}</td>
|
||||
<td class="code">{{X86_64_FREEBSD_SHASUM}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="release-0.7.1">0.7.1</h2>
|
||||
<ul>
|
||||
<li>2020-12-13</li>
|
||||
<li><a href="0.7.1/release-notes.html">Release Notes</a></li>
|
||||
<li><a href="/documentation/0.7.1/">Language Reference</a></li>
|
||||
<li><a href="/documentation/0.7.1/std">Standard Library Documentation</a> (experimental)</li>
|
||||
</ul>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Filename</th>
|
||||
<th>Kind</th>
|
||||
<th>Size</th>
|
||||
<th>Sha256</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-0.7.1.tar.xz">zig-0.7.1.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>11MiB</td>
|
||||
<td class="code">2db3b944ab368d955b48743d9f7c963b8f96de1a441ba5a35e197237cc6dae44</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-bootstrap-0.7.1.tar.xz">zig-bootstrap-0.7.1.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>39MiB</td>
|
||||
<td class="code">040f27c1fae4b0cac0a2782aecdb691f6a2f8e89db6a6ed35024c31c304fd9b2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-freebsd-x86_64-0.7.1.tar.xz">zig-freebsd-x86_64-0.7.1.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>38MiB</td>
|
||||
<td class="code">e73c1dca35791a3183fdd5ecde0443ebbe180942efceafe651886034fb8def09</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-linux-aarch64-0.7.1.tar.xz">zig-linux-aarch64-0.7.1.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>33MiB</td>
|
||||
<td class="code">48ec90eba407e4587ddef7eecef25fec7e13587eb98e3b83c5f2f5fff2a5cbe7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-linux-armv7a-0.7.1.tar.xz">zig-linux-armv7a-0.7.1.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>35MiB</td>
|
||||
<td class="code">5a0662e07b4c4968665e1f97558f8591f6facec45d2e0ff5715e661743107ceb</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-linux-i386-0.7.1.tar.xz">zig-linux-i386-0.7.1.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>38MiB</td>
|
||||
<td class="code">4882e052e5f83690bd0334bb4fc1702b5403cb3a3d2aa63fd7d6043d8afecba3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-linux-riscv64-0.7.1.tar.xz">zig-linux-riscv64-0.7.1.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>36MiB</td>
|
||||
<td class="code">187294bfd35983348c3fe042901b42e67e7e36ab7f77a5f969d21c0051f4d21f</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-linux-x86_64-0.7.1.tar.xz">zig-linux-x86_64-0.7.1.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>37MiB</td>
|
||||
<td class="code">18c7b9b200600f8bcde1cd8d7f1f578cbc3676241ce36d771937ce19a8159b8d</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-macos-x86_64-0.7.1.tar.xz">zig-macos-x86_64-0.7.1.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>35MiB</td>
|
||||
<td class="code">845cb17562978af0cf67e3993f4e33330525eaf01ead9386df9105111e3bc519</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-windows-i386-0.7.1.zip">zig-windows-i386-0.7.1.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>52MiB</td>
|
||||
<td class="code">a1b9a7421e13153e07fd2e2c93ff29aad64d83105b8fcdafa633dbe689caf1c0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.1/zig-windows-x86_64-0.7.1.zip">zig-windows-x86_64-0.7.1.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>53MiB</td>
|
||||
<td class="code">4818a8a65b4672bc52c0ae7f14d014e0eb8caf10f12c0745176820384cea296a</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="release-0.7.0">0.7.0</h2>
|
||||
<ul>
|
||||
<li>2020-11-08</li>
|
||||
<li><a href="0.7.0/release-notes.html">Release Notes</a></li>
|
||||
<li><a href="/documentation/0.7.0/">Language Reference</a></li>
|
||||
<li><a href="/documentation/0.7.0/std">Standard Library Documentation</a> (experimental)</li>
|
||||
</ul>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Filename</th>
|
||||
<th>Kind</th>
|
||||
<th>Size</th>
|
||||
<th>Sha256</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-0.7.0.tar.xz">zig-0.7.0.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>11MiB</td>
|
||||
<td class="code">0efd2cf6c3b05723db80e9cf193bc55150bba84ca41f855a90f53fc756445f83</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-bootstrap-0.7.0.tar.xz">zig-bootstrap-0.7.0.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>39MiB</td>
|
||||
<td class="code">f073beaf5c53c8c57c0d374cbfcb332ef92ad703173edba0d9e0f2ed28401b72</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-freebsd-x86_64-0.7.0.tar.xz">zig-freebsd-x86_64-0.7.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>34MiB</td>
|
||||
<td class="code">a0c926272ee4ae720034b4a6a1dc98399d76156dd84182554740f0ca8a41fc99</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-linux-aarch64-0.7.0.tar.xz">zig-linux-aarch64-0.7.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>32MiB</td>
|
||||
<td class="code">f89933bac87d44be82325754ff88423020c81c7032a6fc41cfeb81e982eeab9b</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-linux-armv7a-0.7.0.tar.xz">zig-linux-armv7a-0.7.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>34MiB</td>
|
||||
<td class="code">011c267e25a96ee160505a560c441daa045359a9d50e13ab1bada9d75c95db2d</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-linux-i386-0.7.0.tar.xz">zig-linux-i386-0.7.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>37MiB</td>
|
||||
<td class="code">4bb2072cd363bcb1cbeb4872ff5cbc1f683b02d0cc1f90c46e3ea7422ce53222</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-linux-riscv64-0.7.0.tar.xz">zig-linux-riscv64-0.7.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>36MiB</td>
|
||||
<td class="code">40dff81faa6f232ac40abbf88b9371f3cc932b6e09c423b94387c9ea580cb7be</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-linux-x86_64-0.7.0.tar.xz">zig-linux-x86_64-0.7.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>36MiB</td>
|
||||
<td class="code">e619b1c6094c095b932767f527aee2507f847ea981513ff8a08aab0fd730e0ac</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-macos-aarch64-0.7.0.tar.xz">zig-macos-aarch64-0.7.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>33MiB</td>
|
||||
<td class="code">338238035734db74ea4f30e500a4893bf741d38305c10952d5e39fa05bdb057d</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-macos-x86_64-0.7.0.tar.xz">zig-macos-x86_64-0.7.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>35MiB</td>
|
||||
<td class="code">94063f9a311cbbf7a2e0a12295e09437182cf950f18cb0eb30ea9893f3677f24</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-windows-i386-0.7.0.zip">zig-windows-i386-0.7.0.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>51MiB</td>
|
||||
<td class="code">b1e520aacbfbd645ff3521b3eb4d44166d9a0288b8725e4b001f8b50a425eb2e</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.7.0/zig-windows-x86_64-0.7.0.zip">zig-windows-x86_64-0.7.0.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>52MiB</td>
|
||||
<td class="code">965f56c0a36f9cda2125e3a348bc654f7f155e2804c3667d231775ec228f8553</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="release-0.6.0">0.6.0</h2>
|
||||
<ul>
|
||||
<li>2020-04-13</li>
|
||||
<li><a href="0.6.0/release-notes.html">Release Notes</a></li>
|
||||
<li><a href="/documentation/0.6.0">Language Reference</a></li>
|
||||
<li><a href="/documentation/0.6.0/std">Standard Library Documentation</a> (experimental)</li>
|
||||
</ul>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Filename</th>
|
||||
<th>Kind</th>
|
||||
<th>Size</th>
|
||||
<th>Sha256</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-0.6.0.tar.xz">zig-0.6.0.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>9.9MiB</td>
|
||||
<td class="code">5d167dc19354282dd35dd17b38e99e1763713b9be8a4ba9e9e69284e059e7204</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-bootstrap-0.6.0.tar.xz">zig-bootstrap-0.6.0.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>36.7MiB</td>
|
||||
<td class="code">5e0e4dc878b3dd0c1852a442b174f0732e8c07869a8fcd226b71a93b89b381ab</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-freebsd-x86_64-0.6.0.tar.xz">zig-freebsd-x86_64-0.6.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>36MiB</td>
|
||||
<td class="code">190ff79c1eb56805a315d7c7a51082e32f62926250c0702b36760c225e1634a3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-linux-aarch64-0.6.0.tar.xz">zig-linux-aarch64-0.6.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>36MiB</td>
|
||||
<td class="code">e7520efd42cfa02be48c2e430d08fe1f3cbb999d21d9f0d3ffd0febb976b2f41</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-linux-armv6kz-0.6.0.tar.xz">zig-linux-armv6kz-0.6.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>38MiB</td>
|
||||
<td class="code">36b6493b3fed43eb1f0000e765798ad31a6bb7d7fd3f553ac1c3761dbc919b82</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-linux-armv7a-0.6.0.tar.xz">zig-linux-armv7a-0.6.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>38MiB</td>
|
||||
<td class="code">946969abe357def95ca9cbbfcebfcf2d90cf967bcd3f48ee87662e32d91d8f35</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-linux-i386-0.6.0.tar.xz">zig-linux-i386-0.6.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>43MiB</td>
|
||||
<td class="code">a97a2f9ae21575743cdd763c1917d49400d83fc562ef64582b18bade43eb24ce</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-linux-riscv64-0.6.0.tar.xz">zig-linux-riscv64-0.6.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>41MiB</td>
|
||||
<td class="code">68ddee43f7503c8ae5f26a921f3602c34719a02ed2241f528c0b8b888cc14b38</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-linux-x86_64-0.6.0.tar.xz">zig-linux-x86_64-0.6.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>43MiB</td>
|
||||
<td class="code">08fd3c757963630645441c2772362e9c2294020c44f14fce1b89f45de0dc1253</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-macos-x86_64-0.6.0.tar.xz">zig-macos-x86_64-0.6.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>41MiB</td>
|
||||
<td class="code">17270360e87ddc49f737e760047b2fac49f1570a824a306119b1194ac4093895</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-windows-i386-0.6.0.zip">zig-windows-i386-0.6.0.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>58MiB</td>
|
||||
<td class="code">3b0a02618743e92175990dc6d1a787bb95ff62c4cda016f1c14c7786f575f8ca</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.6.0/zig-windows-x86_64-0.6.0.zip">zig-windows-x86_64-0.6.0.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>47MiB</td>
|
||||
<td class="code">c3b897832523e1026e10b2d8d55d7f895185c0a27a63681f3a23219c3f1c38f4</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="release-0.5.0">0.5.0</h2>
|
||||
<ul>
|
||||
<li>2019-09-30</li>
|
||||
<li><a href="0.5.0/release-notes.html">Release Notes</a></li>
|
||||
<li><a href="/documentation/0.5.0">Documentation</a></li>
|
||||
</ul>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Filename</th>
|
||||
<th>Kind</th>
|
||||
<th>Size</th>
|
||||
<th>Sha256</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.5.0/zig-0.5.0.tar.xz">zig-0.5.0.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>10.4MiB</td>
|
||||
<td class="code">55ae16960f152bcb9cf98b4f8570902d0e559a141abf927f0d3555b7cc838a31</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.5.0/zig-linux-x86_64-0.5.0.tar.xz">zig-linux-x86_64-0.5.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>39.0MiB</td>
|
||||
<td class="code">43e8f8a8b8556edd373ddf9c1ef3ca6cf852d4d09fe07d5736d12fefedd2b4f7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.5.0/zig-windows-x86_64-0.5.0.zip">zig-windows-x86_64-0.5.0.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>42.8MiB</td>
|
||||
<td class="code">58141323db8d84a5af62746be5f9140bc161ee760ef33dc91a887bf9ac021976</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.5.0/zig-macos-x86_64-0.5.0.tar.xz">zig-macos-x86_64-0.5.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>36.1MiB</td>
|
||||
<td class="code">28702cc05745c7c0bd450487d5f4091bf0a1ad279b35eb9a640ce3e3a15b300d</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.5.0/zig-freebsd-x86_64-0.5.0.tar.xz">zig-freebsd-x86_64-0.5.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>32.1MiB</td>
|
||||
<td class="code">9e1f4d36c3d584c0aa01f20eb4cd0a0eef3eee5af23e483b8414de55feab6ab6</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="release-0.4.0">0.4.0</h2>
|
||||
<ul>
|
||||
<li>2019-04-08</li>
|
||||
<li><a href="0.4.0/release-notes.html">Release Notes</a></li>
|
||||
<li><a href="/documentation/0.4.0">Documentation</a></li>
|
||||
</ul>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Filename</th>
|
||||
<th>Kind</th>
|
||||
<th>Size</th>
|
||||
<th>Sha256</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.4.0/zig-0.4.0.tar.xz">zig-0.4.0.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>5.1MiB</td>
|
||||
<td class="code">fec1f3f6b359a3d942e0a7f9157b3b30cde83927627a0e1ea95c54de3c526cfc</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.4.0/zig-linux-x86_64-0.4.0.tar.xz">zig-linux-x86_64-0.4.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>31.4MiB</td>
|
||||
<td class="code">fb1954e2fb556a01f8079a08130e88f70084e08978ff853bb2b1986d8c39d84e</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.4.0/zig-windows-x86_64-0.4.0.zip">zig-windows-x86_64-0.4.0.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>34.1MiB</td>
|
||||
<td class="code">fbc3dd205e064c263063f69f600bedb18e3d0aa2efa747a63ef6cafb6d73f127</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.4.0/zig-macos-x86_64-0.4.0.tar.xz">zig-macos-x86_64-0.4.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>29.4MiB</td>
|
||||
<td class="code">67c932982484d017c5111e54af9f33f15e8e05c6bc5346a55e04052159c964a8</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.4.0/zig-freebsd-x86_64-0.4.0.tar.xz">zig-freebsd-x86_64-0.4.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>26.0MiB</td>
|
||||
<td class="code">3d557c91ac36d8262eb1733bb5f261c95944f9b635e43386e3d00a3272818c30</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="release-0.3.0">0.3.0</h2>
|
||||
<ul>
|
||||
<li>2018-09-28</li>
|
||||
<li><a href="0.3.0/release-notes.html">Release Notes</a></li>
|
||||
<li><a href="/documentation/0.3.0">Documentation</a></li>
|
||||
</ul>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Filename</th>
|
||||
<th>Kind</th>
|
||||
<th>Size</th>
|
||||
<th>Sha256</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.3.0/zig-0.3.0.tar.xz">zig-0.3.0.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>2.2MiB</td>
|
||||
<td class="code">d70af604f3a8622f3393d93abb3e056bf60351e32d121e6fa4fe03d8d41e1f5a</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.3.0/zig-linux-x86_64-0.3.0.tar.xz">zig-linux-x86_64-0.3.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>24.0MiB</td>
|
||||
<td class="code">b378d0aae30cb54f28494e7bc4efbc9bfb6326f47bfb302e8b5287af777b2f3c</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.3.0/zig-windows-x86_64-0.3.0.zip">zig-windows-x86_64-0.3.0.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>21.5MiB</td>
|
||||
<td class="code">bb568c03950958f8bb3472139c3ab5ed74547c8c694ab50f404c202faf51baf4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.3.0/zig-macos-x86_64-0.3.0.tar.xz">zig-macos-x86_64-0.3.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>22.6MiB</td>
|
||||
<td class="code">19dec1f1943ab7be26823376d466f7e456143deb34e17502778a949034dc2e7e</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="release-0.2.0">0.2.0</h2>
|
||||
<ul>
|
||||
<li>2018-03-15</li>
|
||||
<li><a href="0.2.0/release-notes.html">Release Notes</a></li>
|
||||
<li><a href="/documentation/0.2.0">Documentation</a></li>
|
||||
</ul>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Filename</th>
|
||||
<th>Kind</th>
|
||||
<th>Size</th>
|
||||
<th>Sha256</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.2.0/zig-0.2.0.tar.xz">zig-0.2.0.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>1.9MiB</td>
|
||||
<td class="code">29c9beb172737f4d5019b88ceae829ae8bc6512fb4386cfbf895ae2b42aa6965</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.2.0/zig-linux-x86_64-0.2.0.tar.xz">zig-linux-x86_64-0.2.0.tar.xz</a></td>
|
||||
<td>Binary</td>
|
||||
<td>23.5MiB</td>
|
||||
<td class="code">209c6fb745d42474c0a73d6f291c7ae3a38b6a1b6b641eea285a7f840cc1a890</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.2.0/zig-win64-0.2.0.zip">zig-win64-0.2.0.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>20.6MiB</td>
|
||||
<td class="code">4f8a2979941a1f081ec8e545cca0b72608c0db1c5a3fd377a94db40649dcd3d4</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2 id="release-0.1.1">0.1.1</h2>
|
||||
<ul>
|
||||
<li>2017-10-17</li>
|
||||
<li><a href="0.1.1/release-notes.html">Release Notes</a></li>
|
||||
<li><a href="/documentation/0.1.1">Documentation</a></li>
|
||||
</ul>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="40%">
|
||||
<col width="10%">
|
||||
<col width="10%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Filename</th>
|
||||
<th>Kind</th>
|
||||
<th>Size</th>
|
||||
<th>Sha256</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.1.1/zig-0.1.1.tar.xz">zig-0.1.1.tar.xz</a></td>
|
||||
<td>Source</td>
|
||||
<td>1.62MiB</td>
|
||||
<td class="code">ffca0cfb263485287e19cc997b08701fcd5f24b700345bcdc3dd8074f5a104e0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="https://ziglang.org/download/0.1.1/zig-win64-0.1.1.zip">zig-win64-0.1.1.zip</a></td>
|
||||
<td>Binary</td>
|
||||
<td>19.3MiB</td>
|
||||
<td class="code">6fc88bef531af7e567fe30bf60da1487b86833cbee84c7a2f3e317030aa5b660</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
356
ci/srht/index.json
Normal file
356
ci/srht/index.json
Normal file
@@ -0,0 +1,356 @@
|
||||
{
|
||||
"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.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"
|
||||
}
|
||||
}
|
||||
}
|
||||
40
ci/srht/on_master_success
Executable file
40
ci/srht/on_master_success
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/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"
|
||||
|
||||
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"
|
||||
104
ci/srht/update-download-page.zig
Normal file
104
ci/srht/update-download-page.zig
Normal file
@@ -0,0 +1,104 @@
|
||||
const std = @import("std");
|
||||
const path = std.fs.path;
|
||||
const mem = std.mem;
|
||||
|
||||
pub fn main() !void {
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
const allocator = &arena.allocator;
|
||||
|
||||
const out_dir = "out";
|
||||
try std.fs.cwd().makePath(out_dir);
|
||||
{
|
||||
const out_file = out_dir ++ path.sep_str ++ "index.html";
|
||||
const in_file = "index.html";
|
||||
try render(allocator, in_file, out_file, .html);
|
||||
}
|
||||
{
|
||||
const out_file = out_dir ++ path.sep_str ++ "index.json";
|
||||
const in_file = "index.json";
|
||||
try render(allocator, in_file, out_file, .plain);
|
||||
}
|
||||
}
|
||||
|
||||
fn render(
|
||||
allocator: *mem.Allocator,
|
||||
in_file: []const u8,
|
||||
out_file: []const u8,
|
||||
fmt: enum {
|
||||
html,
|
||||
plain,
|
||||
},
|
||||
) !void {
|
||||
const in_contents = try std.fs.cwd().readFileAlloc(allocator, in_file, 1 * 1024 * 1024);
|
||||
|
||||
var vars = try std.process.getEnvMap(allocator);
|
||||
|
||||
var buffer = std.ArrayList(u8).init(allocator);
|
||||
defer buffer.deinit();
|
||||
|
||||
const State = enum {
|
||||
Start,
|
||||
OpenBrace,
|
||||
VarName,
|
||||
EndBrace,
|
||||
};
|
||||
const writer = buffer.writer();
|
||||
var state = State.Start;
|
||||
var var_name_start: usize = undefined;
|
||||
var line: usize = 1;
|
||||
for (in_contents) |byte, index| {
|
||||
switch (state) {
|
||||
State.Start => switch (byte) {
|
||||
'{' => {
|
||||
state = State.OpenBrace;
|
||||
},
|
||||
else => try writer.writeByte(byte),
|
||||
},
|
||||
State.OpenBrace => switch (byte) {
|
||||
'{' => {
|
||||
state = State.VarName;
|
||||
var_name_start = index + 1;
|
||||
},
|
||||
else => {
|
||||
try writer.writeByte('{');
|
||||
try writer.writeByte(byte);
|
||||
state = State.Start;
|
||||
},
|
||||
},
|
||||
State.VarName => switch (byte) {
|
||||
'}' => {
|
||||
const var_name = in_contents[var_name_start..index];
|
||||
if (vars.get(var_name)) |value| {
|
||||
const trimmed = mem.trim(u8, value, " \r\n");
|
||||
if (fmt == .html and mem.endsWith(u8, var_name, "BYTESIZE")) {
|
||||
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.warn("line {d}: missing variable: {s}\n", .{ line, var_name });
|
||||
try writer.writeAll("(missing)");
|
||||
}
|
||||
state = State.EndBrace;
|
||||
},
|
||||
else => {},
|
||||
},
|
||||
State.EndBrace => switch (byte) {
|
||||
'}' => {
|
||||
state = State.Start;
|
||||
},
|
||||
else => {
|
||||
std.debug.warn("line {d}: invalid byte: '0x{x}'", .{ line, byte });
|
||||
std.process.exit(1);
|
||||
},
|
||||
},
|
||||
}
|
||||
if (byte == '\n') {
|
||||
line += 1;
|
||||
}
|
||||
}
|
||||
try std.fs.cwd().writeFile(out_file, buffer.items);
|
||||
}
|
||||
112
ci/srht/update_download_page
Executable file
112
ci/srht/update_download_page
Executable file
@@ -0,0 +1,112 @@
|
||||
#!/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"
|
||||
|
||||
# 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
|
||||
|
||||
# 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/docs/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)"
|
||||
|
||||
export MASTER_DATE="$(date +%Y-%m-%d)"
|
||||
export MASTER_VERSION="$VERSION"
|
||||
|
||||
cd "$SRCTARBALLDIR/ci/srht"
|
||||
"$ZIG" run update-download-page.zig
|
||||
CIDIR="$(pwd)"
|
||||
|
||||
# Create index.json and index.html and update the website repo.
|
||||
cd "$HOME"
|
||||
git clone git@github.com:ziglang/www.ziglang.org.git
|
||||
cd www.ziglang.org
|
||||
WWWDIR="$(pwd)"
|
||||
|
||||
$S3CMD put -P --no-mime-magic --add-header="cache-control: public, max-age=31536000, immutable" "$HOME/$SRC_TARBALL" s3://ziglang.org/builds/
|
||||
|
||||
cd "$WWWDIR"
|
||||
cp "$CIDIR/out/index.json" data/releases.json
|
||||
mkdir -p content/documentation/master/std
|
||||
cp "$LANGREF" content/documentation/master/index.html
|
||||
cp "$ZIGDIR/docs/std/index.html" content/documentation/master/std/index.html
|
||||
cp "$ZIGDIR/docs/std/data.js" content/documentation/master/std/data.js
|
||||
cp "$ZIGDIR/docs/std/main.js" content/documentation/master/std/main.js
|
||||
git add data/releases.json
|
||||
git add content/
|
||||
git commit -m "CI: update releases and docs"
|
||||
git push origin master
|
||||
@@ -1,72 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/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
|
||||
@@ -8,33 +8,45 @@
|
||||
# CLANG_LIBDIRS
|
||||
|
||||
find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h
|
||||
HINTS ${LLVM_INCLUDE_DIRS}
|
||||
# Only look for Clang next to LLVM or in { CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH, CMAKE_FRAMEWORK_PATH }
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
PATHS
|
||||
/usr/lib/llvm/12/include
|
||||
/usr/lib/llvm-12/include
|
||||
/usr/lib/llvm-12.0/include
|
||||
/usr/local/llvm120/include
|
||||
/usr/local/llvm12/include
|
||||
/mingw64/include
|
||||
)
|
||||
|
||||
if(${LLVM_LINK_MODE} STREQUAL "shared")
|
||||
if(ZIG_PREFER_CLANG_CPP_DYLIB)
|
||||
find_library(CLANG_LIBRARIES
|
||||
NAMES
|
||||
libclang-cpp.so.15
|
||||
clang-cpp-15.0
|
||||
clang-cpp150
|
||||
clang-cpp-12.0
|
||||
clang-cpp120
|
||||
clang-cpp
|
||||
NAMES_PER_DIR
|
||||
HINTS "${LLVM_LIBDIRS}"
|
||||
# Only look for Clang next to LLVM or in { CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH, CMAKE_FRAMEWORK_PATH }
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
PATHS
|
||||
${CLANG_LIBDIRS}
|
||||
/usr/lib/llvm/12/lib
|
||||
/usr/lib/llvm/12/lib64
|
||||
/usr/lib/llvm-12/lib
|
||||
/usr/local/llvm120/lib
|
||||
/usr/local/llvm12/lib
|
||||
)
|
||||
else()
|
||||
endif()
|
||||
|
||||
if(NOT CLANG_LIBRARIES)
|
||||
macro(FIND_AND_ADD_CLANG_LIB _libname_)
|
||||
string(TOUPPER ${_libname_} _prettylibname_)
|
||||
find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_} NAMES_PER_DIR
|
||||
HINTS "${LLVM_LIBDIRS}"
|
||||
# Only look for Clang next to LLVM or in { CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH, CMAKE_FRAMEWORK_PATH }
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
NO_CMAKE_SYSTEM_PATH
|
||||
find_library(CLANG_${_prettylibname_}_LIB NAMES ${_libname_}
|
||||
PATHS
|
||||
${CLANG_LIBDIRS}
|
||||
/usr/lib/llvm/12/lib
|
||||
/usr/lib/llvm-12/lib
|
||||
/usr/lib/llvm-12.0/lib
|
||||
/usr/local/llvm120/lib
|
||||
/usr/local/llvm12/lib
|
||||
/mingw64/lib
|
||||
/c/msys64/mingw64/lib
|
||||
c:\\msys64\\mingw64\\lib
|
||||
)
|
||||
if(CLANG_${_prettylibname_}_LIB)
|
||||
set(CLANG_LIBRARIES ${CLANG_LIBRARIES} ${CLANG_${_prettylibname_}_LIB})
|
||||
@@ -64,8 +76,6 @@ else()
|
||||
FIND_AND_ADD_CLANG_LIB(clangCrossTU)
|
||||
FIND_AND_ADD_CLANG_LIB(clangIndex)
|
||||
FIND_AND_ADD_CLANG_LIB(clangToolingCore)
|
||||
FIND_AND_ADD_CLANG_LIB(clangExtractAPI)
|
||||
FIND_AND_ADD_CLANG_LIB(clangSupport)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
@@ -7,51 +7,46 @@
|
||||
# LLD_LIBRARIES
|
||||
|
||||
find_path(LLD_INCLUDE_DIRS NAMES lld/Common/Driver.h
|
||||
HINTS ${LLVM_INCLUDE_DIRS}
|
||||
PATHS
|
||||
/usr/lib/llvm-15/include
|
||||
/usr/local/llvm150/include
|
||||
/usr/local/llvm15/include
|
||||
/usr/local/opt/llvm@15/include
|
||||
/opt/homebrew/opt/llvm@15/include
|
||||
/usr/lib/llvm-12/include
|
||||
/usr/local/llvm120/include
|
||||
/usr/local/llvm12/include
|
||||
/mingw64/include)
|
||||
|
||||
find_library(LLD_LIBRARY NAMES lld-15.0 lld150 lld NAMES_PER_DIR
|
||||
HINTS ${LLVM_LIBDIRS}
|
||||
find_library(LLD_LIBRARY NAMES lld-12.0 lld120 lld
|
||||
PATHS
|
||||
/usr/lib/llvm-15/lib
|
||||
/usr/local/llvm150/lib
|
||||
/usr/local/llvm15/lib
|
||||
/usr/local/opt/llvm@15/lib
|
||||
/opt/homebrew/opt/llvm@15/lib
|
||||
/usr/lib/llvm-12/lib
|
||||
/usr/local/llvm120/lib
|
||||
/usr/local/llvm12/lib
|
||||
)
|
||||
if(EXISTS ${LLD_LIBRARY})
|
||||
set(LLD_LIBRARIES ${LLD_LIBRARY})
|
||||
else()
|
||||
macro(FIND_AND_ADD_LLD_LIB _libname_)
|
||||
string(TOUPPER ${_libname_} _prettylibname_)
|
||||
find_library(LLD_${_prettylibname_}_LIB NAMES ${_libname_} NAMES_PER_DIR
|
||||
HINTS ${LLVM_LIBDIRS}
|
||||
find_library(LLD_${_prettylibname_}_LIB NAMES ${_libname_}
|
||||
PATHS
|
||||
${LLD_LIBDIRS}
|
||||
/usr/lib/llvm-15/lib
|
||||
/usr/local/llvm150/lib
|
||||
/usr/local/llvm15/lib
|
||||
/usr/local/opt/llvm@15/lib
|
||||
/opt/homebrew/opt/llvm@15/lib
|
||||
/usr/lib/llvm-12/lib
|
||||
/usr/local/llvm120/lib
|
||||
/usr/local/llvm12/lib
|
||||
/mingw64/lib
|
||||
/c/msys64/mingw64/lib
|
||||
c:/msys64/mingw64/lib)
|
||||
if(LLD_${_prettylibname_}_LIB)
|
||||
set(LLD_LIBRARIES ${LLD_LIBRARIES} ${LLD_${_prettylibname_}_LIB})
|
||||
if(LLD_${_prettylibname_}_LIB)
|
||||
set(LLD_LIBRARIES ${LLD_LIBRARIES} ${LLD_${_prettylibname_}_LIB})
|
||||
endif()
|
||||
endmacro(FIND_AND_ADD_LLD_LIB)
|
||||
|
||||
FIND_AND_ADD_LLD_LIB(lldDriver)
|
||||
FIND_AND_ADD_LLD_LIB(lldMinGW)
|
||||
FIND_AND_ADD_LLD_LIB(lldELF)
|
||||
FIND_AND_ADD_LLD_LIB(lldCOFF)
|
||||
FIND_AND_ADD_LLD_LIB(lldWasm)
|
||||
FIND_AND_ADD_LLD_LIB(lldMachO)
|
||||
FIND_AND_ADD_LLD_LIB(lldWasm)
|
||||
FIND_AND_ADD_LLD_LIB(lldReaderWriter)
|
||||
FIND_AND_ADD_LLD_LIB(lldCore)
|
||||
FIND_AND_ADD_LLD_LIB(lldYAML)
|
||||
FIND_AND_ADD_LLD_LIB(lldCommon)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -6,139 +6,150 @@
|
||||
# LLVM_INCLUDE_DIRS
|
||||
# LLVM_LIBRARIES
|
||||
# LLVM_LIBDIRS
|
||||
# LLVM_LINK_MODE
|
||||
|
||||
find_path(LLVM_INCLUDE_DIRS NAMES llvm/IR/IRBuilder.h
|
||||
PATHS
|
||||
/usr/lib/llvm/12/include
|
||||
/usr/lib/llvm-12/include
|
||||
/usr/lib/llvm-12.0/include
|
||||
/usr/local/llvm12/include
|
||||
/usr/local/llvm120/include
|
||||
/mingw64/include
|
||||
)
|
||||
|
||||
if(ZIG_USE_LLVM_CONFIG)
|
||||
set(LLVM_CONFIG_ERROR_MESSAGES "")
|
||||
while(1)
|
||||
unset(LLVM_CONFIG_EXE CACHE)
|
||||
find_program(LLVM_CONFIG_EXE
|
||||
NAMES llvm-config-15 llvm-config-15.0 llvm-config150 llvm-config15 llvm-config NAMES_PER_DIR
|
||||
PATHS
|
||||
"/mingw64/bin"
|
||||
"/c/msys64/mingw64/bin"
|
||||
"c:/msys64/mingw64/bin"
|
||||
"C:/Libraries/llvm-15.0.0/bin")
|
||||
if(ZIG_PREFER_CLANG_CPP_DYLIB)
|
||||
find_library(LLVM_LIBRARIES
|
||||
NAMES
|
||||
LLVM-12.0
|
||||
LLVM-12
|
||||
LLVM-120
|
||||
LLVM
|
||||
PATHS
|
||||
${LLVM_LIBDIRS}
|
||||
/usr/lib/llvm/12/lib
|
||||
/usr/lib/llvm/12/lib64
|
||||
/usr/lib/llvm-12/lib
|
||||
/usr/local/llvm12/lib
|
||||
/usr/local/llvm120/lib
|
||||
)
|
||||
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
if (NOT LLVM_CONFIG_ERROR_MESSAGES STREQUAL "")
|
||||
list(JOIN LLVM_CONFIG_ERROR_MESSAGES "\n" LLVM_CONFIG_ERROR_MESSAGE)
|
||||
message(FATAL_ERROR ${LLVM_CONFIG_ERROR_MESSAGE})
|
||||
else()
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
endif()
|
||||
find_program(LLVM_CONFIG_EXE
|
||||
NAMES llvm-config-12 llvm-config-12.0 llvm-config120 llvm-config12 llvm-config
|
||||
PATHS
|
||||
"/mingw64/bin"
|
||||
"/c/msys64/mingw64/bin"
|
||||
"c:/msys64/mingw64/bin"
|
||||
"C:/Libraries/llvm-12.0.0/bin")
|
||||
|
||||
# Check that this LLVM is the right version
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --version
|
||||
OUTPUT_VARIABLE LLVM_CONFIG_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
|
||||
get_filename_component(LLVM_CONFIG_DIR "${LLVM_CONFIG_EXE}" DIRECTORY)
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 15 OR "${LLVM_CONFIG_VERSION}" VERSION_EQUAL 16 OR "${LLVM_CONFIG_VERSION}" VERSION_GREATER 16)
|
||||
# Save the error message, in case this is the last llvm-config we find
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "expected LLVM 15.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
|
||||
# Ignore this directory and try the search again
|
||||
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||
continue()
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --version
|
||||
OUTPUT_VARIABLE LLVM_CONFIG_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Check that this LLVM supports linking as a shared/static library, if requested
|
||||
if (ZIG_SHARED_LLVM OR ZIG_STATIC_LLVM)
|
||||
if (ZIG_SHARED_LLVM)
|
||||
set(STATIC_OR_SHARED_LINK "--link-shared")
|
||||
elseif (ZIG_STATIC_LLVM)
|
||||
set(STATIC_OR_SHARED_LINK "--link-static")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 12)
|
||||
message(FATAL_ERROR "expected LLVM 12.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_EQUAL 13)
|
||||
message(FATAL_ERROR "expected LLVM 12.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_GREATER 13)
|
||||
message(FATAL_ERROR "expected LLVM 12.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
elseif(ZIG_USE_LLVM_CONFIG)
|
||||
find_program(LLVM_CONFIG_EXE
|
||||
NAMES llvm-config-12 llvm-config-12.0 llvm-config120 llvm-config12 llvm-config
|
||||
PATHS
|
||||
"/mingw64/bin"
|
||||
"/c/msys64/mingw64/bin"
|
||||
"c:/msys64/mingw64/bin"
|
||||
"C:/Libraries/llvm-12.0.0/bin")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libs ${STATIC_OR_SHARED_LINK}
|
||||
OUTPUT_QUIET
|
||||
ERROR_VARIABLE LLVM_CONFIG_ERROR
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
|
||||
if (LLVM_CONFIG_ERROR)
|
||||
# Save the error message, in case this is the last llvm-config we find
|
||||
if (ZIG_SHARED_LLVM)
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 15.x found at ${LLVM_CONFIG_EXE} does not support linking as a shared library")
|
||||
else()
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 15.x found at ${LLVM_CONFIG_EXE} does not support linking as a static library")
|
||||
endif()
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
message(FATAL_ERROR "unable to find llvm-config")
|
||||
endif()
|
||||
|
||||
# Ignore this directory and try the search again
|
||||
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||
continue()
|
||||
endif()
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --version
|
||||
OUTPUT_VARIABLE LLVM_CONFIG_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --targets-built
|
||||
OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}")
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 12)
|
||||
message(FATAL_ERROR "expected LLVM 12.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_EQUAL 13)
|
||||
message(FATAL_ERROR "expected LLVM 12.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_GREATER 13)
|
||||
message(FATAL_ERROR "expected LLVM 12.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
endif()
|
||||
|
||||
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)
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --targets-built
|
||||
OUTPUT_VARIABLE LLVM_TARGETS_BUILT_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_TARGETS_BUILT "${LLVM_TARGETS_BUILT_SPACES}")
|
||||
function(NEED_TARGET TARGET_NAME)
|
||||
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
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM (according to ${LLVM_CONFIG_EXE}) is missing target ${TARGET_NAME}. Zig requires LLVM to be built with all default targets enabled.")
|
||||
|
||||
# Ignore this directory and try the search again
|
||||
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||
set(ZIG_LLVM_REQUIRED_TARGETS_ENABLED FALSE)
|
||||
break()
|
||||
message(FATAL_ERROR "LLVM (according to ${LLVM_CONFIG_EXE}) is missing target ${TARGET_NAME}. Zig requires LLVM to be built with all default targets enabled.")
|
||||
endif()
|
||||
endforeach()
|
||||
if (NOT ZIG_LLVM_REQUIRED_TARGETS_ENABLED)
|
||||
continue()
|
||||
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("WebAssembly")
|
||||
NEED_TARGET("X86")
|
||||
NEED_TARGET("XCore")
|
||||
|
||||
# Got it!
|
||||
break()
|
||||
endwhile()
|
||||
|
||||
if(ZIG_SHARED_LLVM OR ZIG_STATIC_LLVM)
|
||||
if(ZIG_STATIC_LLVM)
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libfiles ${STATIC_OR_SHARED_LINK}
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libfiles --link-static
|
||||
OUTPUT_VARIABLE LLVM_LIBRARIES_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libdir ${STATIC_OR_SHARED_LINK}
|
||||
OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBDIRS "${LLVM_LIBDIRS_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --system-libs ${STATIC_OR_SHARED_LINK}
|
||||
COMMAND ${LLVM_CONFIG_EXE} --system-libs --link-static
|
||||
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_SYSTEM_LIBS "${LLVM_SYSTEM_LIBS_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --shared-mode ${STATIC_OR_SHARED_LINK}
|
||||
OUTPUT_VARIABLE LLVM_LINK_MODE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else()
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libdir --link-static
|
||||
OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBDIRS "${LLVM_LIBDIRS_SPACES}")
|
||||
endif()
|
||||
if(NOT LLVM_LIBRARIES)
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libs
|
||||
OUTPUT_VARIABLE LLVM_LIBRARIES_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBRARIES "${LLVM_LIBRARIES_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libdir
|
||||
OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_LIBDIRS "${LLVM_LIBDIRS_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --system-libs
|
||||
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_SPACES
|
||||
@@ -146,32 +157,17 @@ if(ZIG_USE_LLVM_CONFIG)
|
||||
string(REPLACE " " ";" LLVM_SYSTEM_LIBS "${LLVM_SYSTEM_LIBS_SPACES}")
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --shared-mode
|
||||
OUTPUT_VARIABLE LLVM_LINK_MODE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
if (${LLVM_LINK_MODE} STREQUAL "shared")
|
||||
# We always ask for the system libs corresponding to static linking,
|
||||
# since on some distros LLD is only available as a static library
|
||||
# and we need these libraries to link it successfully
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --system-libs --link-static
|
||||
OUTPUT_VARIABLE LLVM_STATIC_SYSTEM_LIBS_SPACES
|
||||
ERROR_QUIET # Some installations have no static libs, we just ignore the failure
|
||||
COMMAND ${LLVM_CONFIG_EXE} --libdir
|
||||
OUTPUT_VARIABLE LLVM_LIBDIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_STATIC_SYSTEM_LIBS "${LLVM_STATIC_SYSTEM_LIBS_SPACES}")
|
||||
|
||||
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS} ${LLVM_STATIC_SYSTEM_LIBS})
|
||||
else()
|
||||
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS})
|
||||
string(REPLACE " " ";" LLVM_LIBDIRS "${LLVM_LIBDIRS_SPACES}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG_EXE} --includedir
|
||||
OUTPUT_VARIABLE LLVM_INCLUDE_DIRS_SPACES
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_INCLUDE_DIRS "${LLVM_INCLUDE_DIRS_SPACES}")
|
||||
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_SYSTEM_LIBS})
|
||||
|
||||
if(NOT LLVM_LIBRARIES)
|
||||
find_library(LLVM_LIBRARIES NAMES LLVM LLVM-12 LLVM-12.0)
|
||||
endif()
|
||||
|
||||
link_directories("${CMAKE_PREFIX_PATH}/lib")
|
||||
link_directories("${LLVM_LIBDIRS}")
|
||||
@@ -181,18 +177,24 @@ else()
|
||||
|
||||
macro(FIND_AND_ADD_LLVM_LIB _libname_)
|
||||
string(TOUPPER ${_libname_} _prettylibname_)
|
||||
find_library(LLVM_${_prettylibname_}_LIB
|
||||
NAMES ${_libname_} NAMES_PER_DIR)
|
||||
find_library(LLVM_${_prettylibname_}_LIB NAMES ${_libname_}
|
||||
PATHS
|
||||
${LLVM_LIBDIRS}
|
||||
/usr/lib/llvm/12/lib
|
||||
/usr/lib/llvm-12/lib
|
||||
/usr/lib/llvm-12.0/lib
|
||||
/usr/local/llvm120/lib
|
||||
/usr/local/llvm12/lib
|
||||
/mingw64/lib
|
||||
/c/msys64/mingw64/lib
|
||||
c:\\msys64\\mingw64\\lib)
|
||||
set(LLVM_LIBRARIES ${LLVM_LIBRARIES} ${LLVM_${_prettylibname_}_LIB})
|
||||
endmacro(FIND_AND_ADD_LLVM_LIB)
|
||||
|
||||
set(LLVM_LINK_MODE "static")
|
||||
|
||||
# This list can be re-generated with `llvm-config --libfiles` and then
|
||||
# reformatting using your favorite text editor. Note we do not execute
|
||||
# `llvm-config` here because we are cross compiling.
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWindowsManifest)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWindowsDriver)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXRay)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMLibDriver)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDlltoolDriver)
|
||||
@@ -202,7 +204,6 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXCoreCodeGen)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXCoreDesc)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXCoreInfo)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMX86TargetMCA)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMX86Disassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMX86AsmParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMX86CodeGen)
|
||||
@@ -212,13 +213,7 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWebAssemblyAsmParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWebAssemblyCodeGen)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWebAssemblyDesc)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWebAssemblyUtils)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWebAssemblyInfo)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVEDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVEAsmParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVECodeGen)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVEDesc)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVEInfo)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSystemZDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSystemZAsmParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSystemZCodeGen)
|
||||
@@ -278,7 +273,6 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMARMDesc)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMARMUtils)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMARMInfo)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAMDGPUTargetMCA)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAMDGPUDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAMDGPUAsmParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAMDGPUCodeGen)
|
||||
@@ -294,16 +288,16 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMCJIT)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMJITLink)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcTargetProcess)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcShared)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMInterpreter)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMExecutionEngine)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMRuntimeDyld)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcTargetProcess)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcShared)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDWP)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoGSYM)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOption)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMObjectYAML)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMObjCopy)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMCA)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMCDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMLTO)
|
||||
@@ -311,6 +305,7 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCFGuard)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCoroutines)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMObjCARCOpts)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMHelloNew)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMipo)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMVectorize)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMLinker)
|
||||
@@ -322,6 +317,7 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMGlobalISel)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMIRParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAsmPrinter)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoDWARF)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSelectionDAG)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCodeGen)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMIRReader)
|
||||
@@ -337,26 +333,19 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMBitWriter)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAnalysis)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMProfileData)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSymbolize)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoPDB)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoMSF)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoDWARF)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMObject)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMTextAPI)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMCParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMC)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoCodeView)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDebugInfoMSF)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMBitReader)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMFuzzerCLI)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCore)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMRemarks)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMBitstreamReader)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMBinaryFormat)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSupport)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDemangle)
|
||||
|
||||
get_filename_component(LLVM_LIBDIRS "${LLVM_LLVMCORE_LIB}" DIRECTORY)
|
||||
find_path(LLVM_INCLUDE_DIRS NAMES llvm/IR/IRBuilder.h)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
set(ZIG_INSTALL_ARGS build ${ZIG_BUILD_ARGS} --prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
execute_process(
|
||||
COMMAND "${ZIG_EXECUTABLE}" ${ZIG_INSTALL_ARGS}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE _result)
|
||||
message("-- Installing: ${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
if(NOT EXISTS ${zig_EXE})
|
||||
message("::")
|
||||
message(":: ERROR: Executable not found")
|
||||
message(":: (execute_process)")
|
||||
message("::")
|
||||
message(":: executable: ${zig_EXE}")
|
||||
message("::")
|
||||
message(FATAL_ERROR)
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${zig_EXE} ${ZIG_INSTALL_ARGS}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
RESULT_VARIABLE _result
|
||||
)
|
||||
if(_result)
|
||||
message("::")
|
||||
message(":: ERROR: ${_result}")
|
||||
message(":: (execute_process)")
|
||||
|
||||
list(JOIN ZIG_INSTALL_ARGS " " s_INSTALL_LIBSTAGE2_ARGS)
|
||||
string(REPLACE ";" " " s_INSTALL_LIBSTAGE2_ARGS "${ZIG_INSTALL_ARGS}")
|
||||
message("::")
|
||||
message(":: argv: ${ZIG_EXECUTABLE} ${s_INSTALL_LIBSTAGE2_ARGS}")
|
||||
message(":: argv: ${zig_EXE} ${s_INSTALL_LIBSTAGE2_ARGS}")
|
||||
|
||||
set(_args ${ZIG_EXECUTABLE} ${ZIG_INSTALL_ARGS})
|
||||
set(_args ${zig_EXE} ${ZIG_INSTALL_ARGS})
|
||||
list(LENGTH _args _len)
|
||||
math(EXPR _len "${_len} - 1")
|
||||
message("::")
|
||||
|
||||
30
deps/SoftFloat-3e-prebuilt/platform.h
vendored
30
deps/SoftFloat-3e-prebuilt/platform.h
vendored
@@ -3,10 +3,6 @@
|
||||
|
||||
#if defined(__BIG_ENDIAN__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(_BIG_ENDIAN) && (_BIG_ENDIAN == 1)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__ARMEB__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__THUMBEB__)
|
||||
@@ -19,12 +15,20 @@
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__MIPSEB__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(_BIG_ENDIAN)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__sparc)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__sparc__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(_POWER)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__powerpc__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__ppc__)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__hpux)
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__hppa)
|
||||
@@ -33,13 +37,7 @@
|
||||
#define BIGENDIAN 1
|
||||
#elif defined(__s390__)
|
||||
#define BIGENDIAN 1
|
||||
#endif
|
||||
|
||||
#if defined(__LITTLE_ENDIAN__)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(_LITTLE_ENDIAN) && (_LITTLE_ENDIAN == 1)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||
#elif defined(__LITTLE_ENDIAN__)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__ARMEL__)
|
||||
#define LITTLEENDIAN 1
|
||||
@@ -53,6 +51,10 @@
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__MIPSEL__)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(_LITTLE_ENDIAN)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__i386__)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__alpha__)
|
||||
@@ -81,11 +83,7 @@
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(__bfin__)
|
||||
#define LITTLEENDIAN 1
|
||||
#endif
|
||||
|
||||
#if defined(LITTLEENDIAN) && defined(BIGENDIAN)
|
||||
#error unable to detect endianness
|
||||
#elif !defined(LITTLEENDIAN) && !defined(BIGENDIAN)
|
||||
#else
|
||||
#error unable to detect endianness
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef primitiveTypes_h
|
||||
#define primitiveTypes_h 1
|
||||
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef SOFTFLOAT_FAST_INT64
|
||||
|
||||
@@ -37,7 +37,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef softfloat_types_h
|
||||
#define softfloat_types_h 1
|
||||
|
||||
#include "platform.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
||||
724
doc/docgen.zig
724
doc/docgen.zig
File diff suppressed because it is too large
Load Diff
4227
doc/langref.html.in
4227
doc/langref.html.in
File diff suppressed because it is too large
Load Diff
@@ -1,354 +0,0 @@
|
||||
const root = @import("@build");
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const io = std.io;
|
||||
const fmt = std.fmt;
|
||||
const Builder = std.build.Builder;
|
||||
const mem = std.mem;
|
||||
const process = std.process;
|
||||
const ArrayList = std.ArrayList;
|
||||
const File = std.fs.File;
|
||||
|
||||
pub fn main() !void {
|
||||
// Here we use an ArenaAllocator backed by a DirectAllocator because a build is a short-lived,
|
||||
// one shot program. We don't need to waste time freeing memory and finding places to squish
|
||||
// bytes into. So we free everything all at once at the very end.
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
const allocator = arena.allocator();
|
||||
var args = try process.argsAlloc(allocator);
|
||||
defer process.argsFree(allocator, args);
|
||||
|
||||
// skip my own exe name
|
||||
var arg_idx: usize = 1;
|
||||
|
||||
const zig_exe = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected path to zig compiler\n", .{});
|
||||
return error.InvalidArgs;
|
||||
};
|
||||
const build_root = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected build root directory path\n", .{});
|
||||
return error.InvalidArgs;
|
||||
};
|
||||
const cache_root = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected cache root directory path\n", .{});
|
||||
return error.InvalidArgs;
|
||||
};
|
||||
const global_cache_root = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected global cache root directory path\n", .{});
|
||||
return error.InvalidArgs;
|
||||
};
|
||||
|
||||
const builder = try Builder.create(
|
||||
allocator,
|
||||
zig_exe,
|
||||
build_root,
|
||||
cache_root,
|
||||
global_cache_root,
|
||||
);
|
||||
defer builder.destroy();
|
||||
|
||||
var targets = ArrayList([]const u8).init(allocator);
|
||||
var debug_log_scopes = ArrayList([]const u8).init(allocator);
|
||||
|
||||
const stderr_stream = io.getStdErr().writer();
|
||||
const stdout_stream = io.getStdOut().writer();
|
||||
|
||||
var install_prefix: ?[]const u8 = null;
|
||||
var dir_list = Builder.DirList{};
|
||||
|
||||
// before arg parsing, check for the NO_COLOR environment variable
|
||||
// if it exists, default the color setting to .off
|
||||
// explicit --color arguments will still override this setting.
|
||||
builder.color = if (std.process.hasEnvVarConstant("NO_COLOR")) .off else .auto;
|
||||
|
||||
while (nextArg(args, &arg_idx)) |arg| {
|
||||
if (mem.startsWith(u8, arg, "-D")) {
|
||||
const option_contents = arg[2..];
|
||||
if (option_contents.len == 0) {
|
||||
std.debug.print("Expected option name after '-D'\n\n", .{});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
}
|
||||
if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| {
|
||||
const option_name = option_contents[0..name_end];
|
||||
const option_value = option_contents[name_end + 1 ..];
|
||||
if (try builder.addUserInputOption(option_name, option_value))
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
} else {
|
||||
if (try builder.addUserInputFlag(option_contents))
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
}
|
||||
} else if (mem.startsWith(u8, arg, "-")) {
|
||||
if (mem.eql(u8, arg, "--verbose")) {
|
||||
builder.verbose = true;
|
||||
} else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
|
||||
return usage(builder, false, stdout_stream);
|
||||
} else if (mem.eql(u8, arg, "-p") or mem.eql(u8, arg, "--prefix")) {
|
||||
install_prefix = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after {s}\n\n", .{arg});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--prefix-lib-dir")) {
|
||||
dir_list.lib_dir = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after {s}\n\n", .{arg});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--prefix-exe-dir")) {
|
||||
dir_list.exe_dir = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after {s}\n\n", .{arg});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--prefix-include-dir")) {
|
||||
dir_list.include_dir = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after {s}\n\n", .{arg});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--sysroot")) {
|
||||
const sysroot = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after --sysroot\n\n", .{});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
builder.sysroot = sysroot;
|
||||
} else if (mem.eql(u8, arg, "--search-prefix")) {
|
||||
const search_prefix = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after --search-prefix\n\n", .{});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
builder.addSearchPrefix(search_prefix);
|
||||
} else if (mem.eql(u8, arg, "--libc")) {
|
||||
const libc_file = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after --libc\n\n", .{});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
builder.libc_file = libc_file;
|
||||
} else if (mem.eql(u8, arg, "--color")) {
|
||||
const next_arg = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("expected [auto|on|off] after --color", .{});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
builder.color = std.meta.stringToEnum(@TypeOf(builder.color), next_arg) orelse {
|
||||
std.debug.print("expected [auto|on|off] after --color, found '{s}'", .{next_arg});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--zig-lib-dir")) {
|
||||
builder.override_lib_dir = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after --zig-lib-dir\n\n", .{});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--debug-log")) {
|
||||
const next_arg = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after {s}\n\n", .{arg});
|
||||
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", .{});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--verbose-link")) {
|
||||
builder.verbose_link = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-air")) {
|
||||
builder.verbose_air = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {
|
||||
builder.verbose_llvm_ir = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-cimport")) {
|
||||
builder.verbose_cimport = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-cc")) {
|
||||
builder.verbose_cc = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) {
|
||||
builder.verbose_llvm_cpu_features = true;
|
||||
} else if (mem.eql(u8, arg, "--prominent-compile-errors")) {
|
||||
builder.prominent_compile_errors = true;
|
||||
} else if (mem.eql(u8, arg, "-fwine")) {
|
||||
builder.enable_wine = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-wine")) {
|
||||
builder.enable_wine = false;
|
||||
} else if (mem.eql(u8, arg, "-fqemu")) {
|
||||
builder.enable_qemu = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-qemu")) {
|
||||
builder.enable_qemu = false;
|
||||
} else if (mem.eql(u8, arg, "-fwasmtime")) {
|
||||
builder.enable_wasmtime = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-wasmtime")) {
|
||||
builder.enable_wasmtime = false;
|
||||
} else if (mem.eql(u8, arg, "-frosetta")) {
|
||||
builder.enable_rosetta = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-rosetta")) {
|
||||
builder.enable_rosetta = false;
|
||||
} else if (mem.eql(u8, arg, "-fdarling")) {
|
||||
builder.enable_darling = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-darling")) {
|
||||
builder.enable_darling = false;
|
||||
} else if (mem.eql(u8, arg, "-fstage1")) {
|
||||
builder.use_stage1 = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-stage1")) {
|
||||
builder.use_stage1 = false;
|
||||
} else if (mem.eql(u8, arg, "-freference-trace")) {
|
||||
builder.reference_trace = 256;
|
||||
} else if (mem.startsWith(u8, arg, "-freference-trace=")) {
|
||||
const num = arg["-freference-trace=".len..];
|
||||
builder.reference_trace = std.fmt.parseUnsigned(u32, num, 10) catch |err| {
|
||||
std.debug.print("unable to parse reference_trace count '{s}': {s}", .{ num, @errorName(err) });
|
||||
process.exit(1);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "-fno-reference-trace")) {
|
||||
builder.reference_trace = null;
|
||||
} else if (mem.eql(u8, arg, "--")) {
|
||||
builder.args = argsRest(args, arg_idx);
|
||||
break;
|
||||
} else {
|
||||
std.debug.print("Unrecognized argument: {s}\n\n", .{arg});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
}
|
||||
} else {
|
||||
try targets.append(arg);
|
||||
}
|
||||
}
|
||||
|
||||
builder.debug_log_scopes = debug_log_scopes.items;
|
||||
builder.resolveInstallPrefix(install_prefix, dir_list);
|
||||
try runBuild(builder);
|
||||
|
||||
if (builder.validateUserInputDidItFail())
|
||||
return usageAndErr(builder, true, stderr_stream);
|
||||
|
||||
builder.make(targets.items) catch |err| {
|
||||
switch (err) {
|
||||
error.InvalidStepName => {
|
||||
return usageAndErr(builder, true, stderr_stream);
|
||||
},
|
||||
error.UncleanExit => process.exit(1),
|
||||
else => return err,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn runBuild(builder: *Builder) anyerror!void {
|
||||
switch (@typeInfo(@typeInfo(@TypeOf(root.build)).Fn.return_type.?)) {
|
||||
.Void => root.build(builder),
|
||||
.ErrorUnion => try root.build(builder),
|
||||
else => @compileError("expected return type of build to be 'void' or '!void'"),
|
||||
}
|
||||
}
|
||||
|
||||
fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void {
|
||||
// run the build script to collect the options
|
||||
if (!already_ran_build) {
|
||||
builder.resolveInstallPrefix(null, .{});
|
||||
try runBuild(builder);
|
||||
}
|
||||
|
||||
try out_stream.print(
|
||||
\\Usage: {s} build [steps] [options]
|
||||
\\
|
||||
\\Steps:
|
||||
\\
|
||||
, .{builder.zig_exe});
|
||||
|
||||
const allocator = builder.allocator;
|
||||
for (builder.top_level_steps.items) |top_level_step| {
|
||||
const name = if (&top_level_step.step == builder.default_step)
|
||||
try fmt.allocPrint(allocator, "{s} (default)", .{top_level_step.step.name})
|
||||
else
|
||||
top_level_step.step.name;
|
||||
try out_stream.print(" {s:<28} {s}\n", .{ name, top_level_step.description });
|
||||
}
|
||||
|
||||
try out_stream.writeAll(
|
||||
\\
|
||||
\\General Options:
|
||||
\\ -p, --prefix [path] Override default install prefix
|
||||
\\ --prefix-lib-dir [path] Override default library directory path
|
||||
\\ --prefix-exe-dir [path] Override default executable directory path
|
||||
\\ --prefix-include-dir [path] Override default include directory path
|
||||
\\
|
||||
\\ --sysroot [path] Set the system root directory (usually /)
|
||||
\\ --search-prefix [path] Add a path to look for binaries, libraries, headers
|
||||
\\ --libc [file] Provide a file which specifies libc paths
|
||||
\\
|
||||
\\ -fdarling, -fno-darling Integration with system-installed Darling to
|
||||
\\ execute macOS programs on Linux hosts
|
||||
\\ (default: no)
|
||||
\\ -fqemu, -fno-qemu Integration with system-installed QEMU to execute
|
||||
\\ foreign-architecture programs on Linux hosts
|
||||
\\ (default: no)
|
||||
\\ --glibc-runtimes [path] Enhances QEMU integration by providing glibc built
|
||||
\\ for multiple foreign architectures, allowing
|
||||
\\ execution of non-native programs that link with glibc.
|
||||
\\ -frosetta, -fno-rosetta Rely on Rosetta to execute x86_64 programs on
|
||||
\\ ARM64 macOS hosts. (default: no)
|
||||
\\ -fwasmtime, -fno-wasmtime Integration with system-installed wasmtime to
|
||||
\\ execute WASI binaries. (default: no)
|
||||
\\ -fwine, -fno-wine Integration with system-installed Wine to execute
|
||||
\\ Windows programs on Linux hosts. (default: no)
|
||||
\\
|
||||
\\ -h, --help Print this help and exit
|
||||
\\ --verbose Print commands before executing them
|
||||
\\ --color [auto|off|on] Enable or disable colored error messages
|
||||
\\ --prominent-compile-errors Output compile errors formatted for a human to read
|
||||
\\
|
||||
\\Project-Specific Options:
|
||||
\\
|
||||
);
|
||||
|
||||
if (builder.available_options_list.items.len == 0) {
|
||||
try out_stream.print(" (none)\n", .{});
|
||||
} else {
|
||||
for (builder.available_options_list.items) |option| {
|
||||
const name = try fmt.allocPrint(allocator, " -D{s}=[{s}]", .{
|
||||
option.name,
|
||||
@tagName(option.type_id),
|
||||
});
|
||||
defer allocator.free(name);
|
||||
try out_stream.print("{s:<30} {s}\n", .{ name, option.description });
|
||||
if (option.enum_options) |enum_options| {
|
||||
const padding = " " ** 33;
|
||||
try out_stream.writeAll(padding ++ "Supported Values:\n");
|
||||
for (enum_options) |enum_option| {
|
||||
try out_stream.print(padding ++ " {s}\n", .{enum_option});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try out_stream.writeAll(
|
||||
\\
|
||||
\\Advanced Options:
|
||||
\\ -fstage1 Force using bootstrap compiler as the codegen backend
|
||||
\\ -fno-stage1 Prevent using bootstrap compiler as the codegen backend
|
||||
\\ -freference-trace[=num] How many lines of reference trace should be shown per compile error
|
||||
\\ -fno-reference-trace Disable reference trace
|
||||
\\ --build-file [file] Override path to build.zig
|
||||
\\ --cache-dir [path] Override path to local Zig cache directory
|
||||
\\ --global-cache-dir [path] Override path to global Zig cache directory
|
||||
\\ --zig-lib-dir [arg] Override path to Zig lib directory
|
||||
\\ --debug-log [scope] Enable debugging the compiler
|
||||
\\ --verbose-link Enable compiler debug output for linking
|
||||
\\ --verbose-air Enable compiler debug output for Zig AIR
|
||||
\\ --verbose-llvm-ir Enable compiler debug output for LLVM IR
|
||||
\\ --verbose-cimport Enable compiler debug output for C imports
|
||||
\\ --verbose-cc Enable compiler debug output for C compilation
|
||||
\\ --verbose-llvm-cpu-features Enable compiler debug output for LLVM CPU features
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
fn usageAndErr(builder: *Builder, already_ran_build: bool, out_stream: anytype) void {
|
||||
usage(builder, already_ran_build, out_stream) catch {};
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
fn nextArg(args: [][]const u8, idx: *usize) ?[]const u8 {
|
||||
if (idx.* >= args.len) return null;
|
||||
defer idx.* += 1;
|
||||
return args[idx.*];
|
||||
}
|
||||
|
||||
fn argsRest(args: [][]const u8, idx: usize) ?[][]const u8 {
|
||||
if (idx >= args.len) return null;
|
||||
return args[idx..];
|
||||
}
|
||||
555
lib/c.zig
555
lib/c.zig
@@ -1,555 +0,0 @@
|
||||
//! This is Zig's multi-target implementation of libc.
|
||||
//! When builtin.link_libc is true, we need to export all the functions and
|
||||
//! provide an entire C API.
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const math = std.math;
|
||||
const isNan = std.math.isNan;
|
||||
const maxInt = std.math.maxInt;
|
||||
const native_os = builtin.os.tag;
|
||||
const native_arch = builtin.cpu.arch;
|
||||
const native_abi = builtin.abi;
|
||||
|
||||
const is_wasm = switch (native_arch) {
|
||||
.wasm32, .wasm64 => true,
|
||||
else => false,
|
||||
};
|
||||
const is_msvc = switch (native_abi) {
|
||||
.msvc => true,
|
||||
else => false,
|
||||
};
|
||||
const is_freestanding = switch (native_os) {
|
||||
.freestanding => true,
|
||||
else => false,
|
||||
};
|
||||
|
||||
comptime {
|
||||
if (is_freestanding and is_wasm and builtin.link_libc) {
|
||||
@export(wasm_start, .{ .name = "_start", .linkage = .Strong });
|
||||
}
|
||||
|
||||
if (native_os == .linux) {
|
||||
@export(clone, .{ .name = "clone" });
|
||||
}
|
||||
|
||||
if (builtin.link_libc) {
|
||||
@export(strcmp, .{ .name = "strcmp", .linkage = .Strong });
|
||||
@export(strncmp, .{ .name = "strncmp", .linkage = .Strong });
|
||||
@export(strerror, .{ .name = "strerror", .linkage = .Strong });
|
||||
@export(strlen, .{ .name = "strlen", .linkage = .Strong });
|
||||
@export(strcpy, .{ .name = "strcpy", .linkage = .Strong });
|
||||
@export(strncpy, .{ .name = "strncpy", .linkage = .Strong });
|
||||
@export(strcat, .{ .name = "strcat", .linkage = .Strong });
|
||||
@export(strncat, .{ .name = "strncat", .linkage = .Strong });
|
||||
} else if (is_msvc) {
|
||||
@export(_fltused, .{ .name = "_fltused", .linkage = .Strong });
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid dragging in the runtime safety mechanisms into this .o file,
|
||||
// unless we're trying to test this file.
|
||||
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
|
||||
@setCold(true);
|
||||
_ = error_return_trace;
|
||||
if (builtin.is_test) {
|
||||
std.debug.panic("{s}", .{msg});
|
||||
}
|
||||
switch (native_os) {
|
||||
.freestanding, .other, .amdhsa, .amdpal => while (true) {},
|
||||
else => std.os.abort(),
|
||||
}
|
||||
}
|
||||
|
||||
extern fn main(argc: c_int, argv: [*:null]?[*:0]u8) c_int;
|
||||
fn wasm_start() callconv(.C) void {
|
||||
_ = main(0, undefined);
|
||||
}
|
||||
|
||||
var _fltused: c_int = 1;
|
||||
|
||||
fn strcpy(dest: [*:0]u8, src: [*:0]const u8) callconv(.C) [*:0]u8 {
|
||||
var i: usize = 0;
|
||||
while (src[i] != 0) : (i += 1) {
|
||||
dest[i] = src[i];
|
||||
}
|
||||
dest[i] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
test "strcpy" {
|
||||
var s1: [9:0]u8 = undefined;
|
||||
|
||||
s1[0] = 0;
|
||||
_ = strcpy(&s1, "foobarbaz");
|
||||
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.sliceTo(&s1, 0));
|
||||
}
|
||||
|
||||
fn strncpy(dest: [*:0]u8, src: [*:0]const u8, n: usize) callconv(.C) [*:0]u8 {
|
||||
var i: usize = 0;
|
||||
while (i < n and src[i] != 0) : (i += 1) {
|
||||
dest[i] = src[i];
|
||||
}
|
||||
while (i < n) : (i += 1) {
|
||||
dest[i] = 0;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
test "strncpy" {
|
||||
var s1: [9:0]u8 = undefined;
|
||||
|
||||
s1[0] = 0;
|
||||
_ = strncpy(&s1, "foobarbaz", @sizeOf(@TypeOf(s1)));
|
||||
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.sliceTo(&s1, 0));
|
||||
}
|
||||
|
||||
fn strcat(dest: [*:0]u8, src: [*:0]const u8) callconv(.C) [*:0]u8 {
|
||||
var dest_end: usize = 0;
|
||||
while (dest[dest_end] != 0) : (dest_end += 1) {}
|
||||
|
||||
var i: usize = 0;
|
||||
while (src[i] != 0) : (i += 1) {
|
||||
dest[dest_end + i] = src[i];
|
||||
}
|
||||
dest[dest_end + i] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
test "strcat" {
|
||||
var s1: [9:0]u8 = undefined;
|
||||
|
||||
s1[0] = 0;
|
||||
_ = strcat(&s1, "foo");
|
||||
_ = strcat(&s1, "bar");
|
||||
_ = strcat(&s1, "baz");
|
||||
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.sliceTo(&s1, 0));
|
||||
}
|
||||
|
||||
fn strncat(dest: [*:0]u8, src: [*:0]const u8, avail: usize) callconv(.C) [*:0]u8 {
|
||||
var dest_end: usize = 0;
|
||||
while (dest[dest_end] != 0) : (dest_end += 1) {}
|
||||
|
||||
var i: usize = 0;
|
||||
while (i < avail and src[i] != 0) : (i += 1) {
|
||||
dest[dest_end + i] = src[i];
|
||||
}
|
||||
dest[dest_end + i] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
test "strncat" {
|
||||
var s1: [9:0]u8 = undefined;
|
||||
|
||||
s1[0] = 0;
|
||||
_ = strncat(&s1, "foo1111", 3);
|
||||
_ = strncat(&s1, "bar1111", 3);
|
||||
_ = strncat(&s1, "baz1111", 3);
|
||||
try std.testing.expectEqualSlices(u8, "foobarbaz", std.mem.sliceTo(&s1, 0));
|
||||
}
|
||||
|
||||
fn strcmp(s1: [*:0]const u8, s2: [*:0]const u8) callconv(.C) c_int {
|
||||
return std.cstr.cmp(s1, s2);
|
||||
}
|
||||
|
||||
fn strlen(s: [*:0]const u8) callconv(.C) usize {
|
||||
return std.mem.len(s);
|
||||
}
|
||||
|
||||
fn strncmp(_l: [*:0]const u8, _r: [*:0]const u8, _n: usize) callconv(.C) c_int {
|
||||
if (_n == 0) return 0;
|
||||
var l = _l;
|
||||
var r = _r;
|
||||
var n = _n - 1;
|
||||
while (l[0] != 0 and r[0] != 0 and n != 0 and l[0] == r[0]) {
|
||||
l += 1;
|
||||
r += 1;
|
||||
n -= 1;
|
||||
}
|
||||
return @as(c_int, l[0]) - @as(c_int, r[0]);
|
||||
}
|
||||
|
||||
fn strerror(errnum: c_int) callconv(.C) [*:0]const u8 {
|
||||
_ = errnum;
|
||||
return "TODO strerror implementation";
|
||||
}
|
||||
|
||||
test "strncmp" {
|
||||
try std.testing.expect(strncmp("a", "b", 1) < 0);
|
||||
try std.testing.expect(strncmp("a", "c", 1) < 0);
|
||||
try std.testing.expect(strncmp("b", "a", 1) > 0);
|
||||
try std.testing.expect(strncmp("\xff", "\x02", 1) > 0);
|
||||
}
|
||||
|
||||
// TODO we should be able to put this directly in std/linux/x86_64.zig but
|
||||
// it causes a segfault in release mode. this is a workaround of calling it
|
||||
// across .o file boundaries. fix comptime @ptrCast of nakedcc functions.
|
||||
fn clone() callconv(.Naked) void {
|
||||
switch (native_arch) {
|
||||
.i386 => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// +8, +12, +16, +20, +24, +28, +32
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// eax, ebx, ecx, edx, esi, edi
|
||||
asm volatile (
|
||||
\\ push %%ebp
|
||||
\\ mov %%esp,%%ebp
|
||||
\\ push %%ebx
|
||||
\\ push %%esi
|
||||
\\ push %%edi
|
||||
\\ // Setup the arguments
|
||||
\\ mov 16(%%ebp),%%ebx
|
||||
\\ mov 12(%%ebp),%%ecx
|
||||
\\ and $-16,%%ecx
|
||||
\\ sub $20,%%ecx
|
||||
\\ mov 20(%%ebp),%%eax
|
||||
\\ mov %%eax,4(%%ecx)
|
||||
\\ mov 8(%%ebp),%%eax
|
||||
\\ mov %%eax,0(%%ecx)
|
||||
\\ mov 24(%%ebp),%%edx
|
||||
\\ mov 28(%%ebp),%%esi
|
||||
\\ mov 32(%%ebp),%%edi
|
||||
\\ mov $120,%%eax
|
||||
\\ int $128
|
||||
\\ test %%eax,%%eax
|
||||
\\ jnz 1f
|
||||
\\ pop %%eax
|
||||
\\ xor %%ebp,%%ebp
|
||||
\\ call *%%eax
|
||||
\\ mov %%eax,%%ebx
|
||||
\\ xor %%eax,%%eax
|
||||
\\ inc %%eax
|
||||
\\ int $128
|
||||
\\ hlt
|
||||
\\1:
|
||||
\\ pop %%edi
|
||||
\\ pop %%esi
|
||||
\\ pop %%ebx
|
||||
\\ pop %%ebp
|
||||
\\ ret
|
||||
);
|
||||
},
|
||||
.x86_64 => {
|
||||
asm volatile (
|
||||
\\ xor %%eax,%%eax
|
||||
\\ mov $56,%%al // SYS_clone
|
||||
\\ mov %%rdi,%%r11
|
||||
\\ mov %%rdx,%%rdi
|
||||
\\ mov %%r8,%%rdx
|
||||
\\ mov %%r9,%%r8
|
||||
\\ mov 8(%%rsp),%%r10
|
||||
\\ mov %%r11,%%r9
|
||||
\\ and $-16,%%rsi
|
||||
\\ sub $8,%%rsi
|
||||
\\ mov %%rcx,(%%rsi)
|
||||
\\ syscall
|
||||
\\ test %%eax,%%eax
|
||||
\\ jnz 1f
|
||||
\\ xor %%ebp,%%ebp
|
||||
\\ pop %%rdi
|
||||
\\ call *%%r9
|
||||
\\ mov %%eax,%%edi
|
||||
\\ xor %%eax,%%eax
|
||||
\\ mov $60,%%al // SYS_exit
|
||||
\\ syscall
|
||||
\\ hlt
|
||||
\\1: ret
|
||||
\\
|
||||
);
|
||||
},
|
||||
.aarch64 => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// x0, x1, w2, x3, x4, x5, x6
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// x8, x0, x1, x2, x3, x4
|
||||
asm volatile (
|
||||
\\ // align stack and save func,arg
|
||||
\\ and x1,x1,#-16
|
||||
\\ stp x0,x3,[x1,#-16]!
|
||||
\\
|
||||
\\ // syscall
|
||||
\\ uxtw x0,w2
|
||||
\\ mov x2,x4
|
||||
\\ mov x3,x5
|
||||
\\ mov x4,x6
|
||||
\\ mov x8,#220 // SYS_clone
|
||||
\\ svc #0
|
||||
\\
|
||||
\\ cbz x0,1f
|
||||
\\ // parent
|
||||
\\ ret
|
||||
\\ // child
|
||||
\\1: ldp x1,x0,[sp],#16
|
||||
\\ blr x1
|
||||
\\ mov x8,#93 // SYS_exit
|
||||
\\ svc #0
|
||||
);
|
||||
},
|
||||
.arm, .thumb => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// r0, r1, r2, r3, +0, +4, +8
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// r7 r0, r1, r2, r3, r4
|
||||
asm volatile (
|
||||
\\ stmfd sp!,{r4,r5,r6,r7}
|
||||
\\ mov r7,#120
|
||||
\\ mov r6,r3
|
||||
\\ mov r5,r0
|
||||
\\ mov r0,r2
|
||||
\\ and r1,r1,#-16
|
||||
\\ ldr r2,[sp,#16]
|
||||
\\ ldr r3,[sp,#20]
|
||||
\\ ldr r4,[sp,#24]
|
||||
\\ svc 0
|
||||
\\ tst r0,r0
|
||||
\\ beq 1f
|
||||
\\ ldmfd sp!,{r4,r5,r6,r7}
|
||||
\\ bx lr
|
||||
\\
|
||||
\\1: mov r0,r6
|
||||
\\ bl 3f
|
||||
\\2: mov r7,#1
|
||||
\\ svc 0
|
||||
\\ b 2b
|
||||
\\3: bx r5
|
||||
);
|
||||
},
|
||||
.riscv64 => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// a0, a1, a2, a3, a4, a5, a6
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// a7 a0, a1, a2, a3, a4
|
||||
asm volatile (
|
||||
\\ # Save func and arg to stack
|
||||
\\ addi a1, a1, -16
|
||||
\\ sd a0, 0(a1)
|
||||
\\ sd a3, 8(a1)
|
||||
\\
|
||||
\\ # Call SYS_clone
|
||||
\\ mv a0, a2
|
||||
\\ mv a2, a4
|
||||
\\ mv a3, a5
|
||||
\\ mv a4, a6
|
||||
\\ li a7, 220 # SYS_clone
|
||||
\\ ecall
|
||||
\\
|
||||
\\ beqz a0, 1f
|
||||
\\ # Parent
|
||||
\\ ret
|
||||
\\
|
||||
\\ # Child
|
||||
\\1: ld a1, 0(sp)
|
||||
\\ ld a0, 8(sp)
|
||||
\\ jalr a1
|
||||
\\
|
||||
\\ # Exit
|
||||
\\ li a7, 93 # SYS_exit
|
||||
\\ ecall
|
||||
);
|
||||
},
|
||||
.mips, .mipsel => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// 3, 4, 5, 6, 7, 8, 9
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// 2 4, 5, 6, 7, 8
|
||||
asm volatile (
|
||||
\\ # Save function pointer and argument pointer on new thread stack
|
||||
\\ and $5, $5, -8
|
||||
\\ subu $5, $5, 16
|
||||
\\ sw $4, 0($5)
|
||||
\\ sw $7, 4($5)
|
||||
\\ # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
|
||||
\\ move $4, $6
|
||||
\\ lw $6, 16($sp)
|
||||
\\ lw $7, 20($sp)
|
||||
\\ lw $9, 24($sp)
|
||||
\\ subu $sp, $sp, 16
|
||||
\\ sw $9, 16($sp)
|
||||
\\ li $2, 4120
|
||||
\\ syscall
|
||||
\\ beq $7, $0, 1f
|
||||
\\ nop
|
||||
\\ addu $sp, $sp, 16
|
||||
\\ jr $ra
|
||||
\\ subu $2, $0, $2
|
||||
\\1:
|
||||
\\ beq $2, $0, 1f
|
||||
\\ nop
|
||||
\\ addu $sp, $sp, 16
|
||||
\\ jr $ra
|
||||
\\ nop
|
||||
\\1:
|
||||
\\ lw $25, 0($sp)
|
||||
\\ lw $4, 4($sp)
|
||||
\\ jalr $25
|
||||
\\ nop
|
||||
\\ move $4, $2
|
||||
\\ li $2, 4001
|
||||
\\ syscall
|
||||
);
|
||||
},
|
||||
.powerpc => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// 3, 4, 5, 6, 7, 8, 9
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// 0 3, 4, 5, 6, 7
|
||||
asm volatile (
|
||||
\\# store non-volatile regs r30, r31 on stack in order to put our
|
||||
\\# start func and its arg there
|
||||
\\stwu 30, -16(1)
|
||||
\\stw 31, 4(1)
|
||||
\\
|
||||
\\# save r3 (func) into r30, and r6(arg) into r31
|
||||
\\mr 30, 3
|
||||
\\mr 31, 6
|
||||
\\
|
||||
\\# create initial stack frame for new thread
|
||||
\\clrrwi 4, 4, 4
|
||||
\\li 0, 0
|
||||
\\stwu 0, -16(4)
|
||||
\\
|
||||
\\#move c into first arg
|
||||
\\mr 3, 5
|
||||
\\#mr 4, 4
|
||||
\\mr 5, 7
|
||||
\\mr 6, 8
|
||||
\\mr 7, 9
|
||||
\\
|
||||
\\# move syscall number into r0
|
||||
\\li 0, 120
|
||||
\\
|
||||
\\sc
|
||||
\\
|
||||
\\# check for syscall error
|
||||
\\bns+ 1f # jump to label 1 if no summary overflow.
|
||||
\\#else
|
||||
\\neg 3, 3 #negate the result (errno)
|
||||
\\1:
|
||||
\\# compare sc result with 0
|
||||
\\cmpwi cr7, 3, 0
|
||||
\\
|
||||
\\# if not 0, jump to end
|
||||
\\bne cr7, 2f
|
||||
\\
|
||||
\\#else: we're the child
|
||||
\\#call funcptr: move arg (d) into r3
|
||||
\\mr 3, 31
|
||||
\\#move r30 (funcptr) into CTR reg
|
||||
\\mtctr 30
|
||||
\\# call CTR reg
|
||||
\\bctrl
|
||||
\\# mov SYS_exit into r0 (the exit param is already in r3)
|
||||
\\li 0, 1
|
||||
\\sc
|
||||
\\
|
||||
\\2:
|
||||
\\
|
||||
\\# restore stack
|
||||
\\lwz 30, 0(1)
|
||||
\\lwz 31, 4(1)
|
||||
\\addi 1, 1, 16
|
||||
\\
|
||||
\\blr
|
||||
);
|
||||
},
|
||||
.powerpc64, .powerpc64le => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// 3, 4, 5, 6, 7, 8, 9
|
||||
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// 0 3, 4, 5, 6, 7
|
||||
asm volatile (
|
||||
\\ # create initial stack frame for new thread
|
||||
\\ clrrdi 4, 4, 4
|
||||
\\ li 0, 0
|
||||
\\ stdu 0,-32(4)
|
||||
\\
|
||||
\\ # save fn and arg to child stack
|
||||
\\ std 3, 8(4)
|
||||
\\ std 6, 16(4)
|
||||
\\
|
||||
\\ # shuffle args into correct registers and call SYS_clone
|
||||
\\ mr 3, 5
|
||||
\\ #mr 4, 4
|
||||
\\ mr 5, 7
|
||||
\\ mr 6, 8
|
||||
\\ mr 7, 9
|
||||
\\ li 0, 120 # SYS_clone = 120
|
||||
\\ sc
|
||||
\\
|
||||
\\ # if error, negate return (errno)
|
||||
\\ bns+ 1f
|
||||
\\ neg 3, 3
|
||||
\\
|
||||
\\1:
|
||||
\\ # if we're the parent, return
|
||||
\\ cmpwi cr7, 3, 0
|
||||
\\ bnelr cr7
|
||||
\\
|
||||
\\ # we're the child. call fn(arg)
|
||||
\\ ld 3, 16(1)
|
||||
\\ ld 12, 8(1)
|
||||
\\ mtctr 12
|
||||
\\ bctrl
|
||||
\\
|
||||
\\ # call SYS_exit. exit code is already in r3 from fn return value
|
||||
\\ li 0, 1 # SYS_exit = 1
|
||||
\\ sc
|
||||
);
|
||||
},
|
||||
.sparc64 => {
|
||||
// __clone(func, stack, flags, arg, ptid, tls, ctid)
|
||||
// i0, i1, i2, i3, i4, i5, sp
|
||||
// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
|
||||
// g1 o0, o1, o2, o3, o4
|
||||
asm volatile (
|
||||
\\ save %%sp, -192, %%sp
|
||||
\\ # Save the func pointer and the arg pointer
|
||||
\\ mov %%i0, %%g2
|
||||
\\ mov %%i3, %%g3
|
||||
\\ # Shuffle the arguments
|
||||
\\ mov 217, %%g1
|
||||
\\ mov %%i2, %%o0
|
||||
\\ # Add some extra space for the initial frame
|
||||
\\ sub %%i1, 176 + 2047, %%o1
|
||||
\\ mov %%i4, %%o2
|
||||
\\ mov %%i5, %%o3
|
||||
\\ ldx [%%fp + 0x8af], %%o4
|
||||
\\ t 0x6d
|
||||
\\ bcs,pn %%xcc, 2f
|
||||
\\ nop
|
||||
\\ # The child pid is returned in o0 while o1 tells if this
|
||||
\\ # process is # the child (=1) or the parent (=0).
|
||||
\\ brnz %%o1, 1f
|
||||
\\ nop
|
||||
\\ # Parent process, return the child pid
|
||||
\\ mov %%o0, %%i0
|
||||
\\ ret
|
||||
\\ restore
|
||||
\\1:
|
||||
\\ # Child process, call func(arg)
|
||||
\\ mov %%g0, %%fp
|
||||
\\ call %%g2
|
||||
\\ mov %%g3, %%o0
|
||||
\\ # Exit
|
||||
\\ mov 1, %%g1
|
||||
\\ t 0x6d
|
||||
\\2:
|
||||
\\ # The syscall failed
|
||||
\\ sub %%g0, %%o0, %%i0
|
||||
\\ ret
|
||||
\\ restore
|
||||
);
|
||||
},
|
||||
else => @compileError("Implement clone() for this arch."),
|
||||
}
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
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");
|
||||
_ = @import("compiler_rt/adddf3.zig");
|
||||
_ = @import("compiler_rt/addtf3.zig");
|
||||
_ = @import("compiler_rt/addxf3.zig");
|
||||
|
||||
_ = @import("compiler_rt/subhf3.zig");
|
||||
_ = @import("compiler_rt/subsf3.zig");
|
||||
_ = @import("compiler_rt/subdf3.zig");
|
||||
_ = @import("compiler_rt/subtf3.zig");
|
||||
_ = @import("compiler_rt/subxf3.zig");
|
||||
|
||||
_ = @import("compiler_rt/mulf3.zig");
|
||||
_ = @import("compiler_rt/mulhf3.zig");
|
||||
_ = @import("compiler_rt/mulsf3.zig");
|
||||
_ = @import("compiler_rt/muldf3.zig");
|
||||
_ = @import("compiler_rt/multf3.zig");
|
||||
_ = @import("compiler_rt/mulxf3.zig");
|
||||
|
||||
_ = @import("compiler_rt/mulc3.zig");
|
||||
_ = @import("compiler_rt/mulhc3.zig");
|
||||
_ = @import("compiler_rt/mulsc3.zig");
|
||||
_ = @import("compiler_rt/muldc3.zig");
|
||||
_ = @import("compiler_rt/mulxc3.zig");
|
||||
_ = @import("compiler_rt/multc3.zig");
|
||||
|
||||
_ = @import("compiler_rt/divc3.zig");
|
||||
_ = @import("compiler_rt/divhc3.zig");
|
||||
_ = @import("compiler_rt/divsc3.zig");
|
||||
_ = @import("compiler_rt/divdc3.zig");
|
||||
_ = @import("compiler_rt/divxc3.zig");
|
||||
_ = @import("compiler_rt/divtc3.zig");
|
||||
|
||||
_ = @import("compiler_rt/neghf2.zig");
|
||||
_ = @import("compiler_rt/negsf2.zig");
|
||||
_ = @import("compiler_rt/negdf2.zig");
|
||||
_ = @import("compiler_rt/negtf2.zig");
|
||||
_ = @import("compiler_rt/negxf2.zig");
|
||||
|
||||
_ = @import("compiler_rt/comparef.zig");
|
||||
_ = @import("compiler_rt/cmphf2.zig");
|
||||
_ = @import("compiler_rt/cmpsf2.zig");
|
||||
_ = @import("compiler_rt/cmpdf2.zig");
|
||||
_ = @import("compiler_rt/cmptf2.zig");
|
||||
_ = @import("compiler_rt/cmpxf2.zig");
|
||||
_ = @import("compiler_rt/gehf2.zig");
|
||||
_ = @import("compiler_rt/gesf2.zig");
|
||||
_ = @import("compiler_rt/gedf2.zig");
|
||||
_ = @import("compiler_rt/gexf2.zig");
|
||||
_ = @import("compiler_rt/getf2.zig");
|
||||
_ = @import("compiler_rt/unordhf2.zig");
|
||||
_ = @import("compiler_rt/unordsf2.zig");
|
||||
_ = @import("compiler_rt/unorddf2.zig");
|
||||
_ = @import("compiler_rt/unordxf2.zig");
|
||||
_ = @import("compiler_rt/unordtf2.zig");
|
||||
|
||||
_ = @import("compiler_rt/extendf.zig");
|
||||
_ = @import("compiler_rt/extendhfsf2.zig");
|
||||
_ = @import("compiler_rt/extendhfdf2.zig");
|
||||
_ = @import("compiler_rt/extendhftf2.zig");
|
||||
_ = @import("compiler_rt/extendhfxf2.zig");
|
||||
_ = @import("compiler_rt/extendsfdf2.zig");
|
||||
_ = @import("compiler_rt/extendsftf2.zig");
|
||||
_ = @import("compiler_rt/extendsfxf2.zig");
|
||||
_ = @import("compiler_rt/extenddftf2.zig");
|
||||
_ = @import("compiler_rt/extenddfxf2.zig");
|
||||
_ = @import("compiler_rt/extendxftf2.zig");
|
||||
|
||||
_ = @import("compiler_rt/truncf.zig");
|
||||
_ = @import("compiler_rt/truncsfhf2.zig");
|
||||
_ = @import("compiler_rt/truncdfhf2.zig");
|
||||
_ = @import("compiler_rt/truncdfsf2.zig");
|
||||
_ = @import("compiler_rt/truncxfhf2.zig");
|
||||
_ = @import("compiler_rt/truncxfsf2.zig");
|
||||
_ = @import("compiler_rt/truncxfdf2.zig");
|
||||
_ = @import("compiler_rt/trunctfhf2.zig");
|
||||
_ = @import("compiler_rt/trunctfsf2.zig");
|
||||
_ = @import("compiler_rt/trunctfdf2.zig");
|
||||
_ = @import("compiler_rt/trunctfxf2.zig");
|
||||
|
||||
_ = @import("compiler_rt/divhf3.zig");
|
||||
_ = @import("compiler_rt/divsf3.zig");
|
||||
_ = @import("compiler_rt/divdf3.zig");
|
||||
_ = @import("compiler_rt/divxf3.zig");
|
||||
_ = @import("compiler_rt/divtf3.zig");
|
||||
_ = @import("compiler_rt/sin.zig");
|
||||
_ = @import("compiler_rt/cos.zig");
|
||||
_ = @import("compiler_rt/sincos.zig");
|
||||
_ = @import("compiler_rt/ceil.zig");
|
||||
_ = @import("compiler_rt/exp.zig");
|
||||
_ = @import("compiler_rt/exp2.zig");
|
||||
_ = @import("compiler_rt/fabs.zig");
|
||||
_ = @import("compiler_rt/floor.zig");
|
||||
_ = @import("compiler_rt/fma.zig");
|
||||
_ = @import("compiler_rt/fmax.zig");
|
||||
_ = @import("compiler_rt/fmin.zig");
|
||||
_ = @import("compiler_rt/fmod.zig");
|
||||
_ = @import("compiler_rt/log.zig");
|
||||
_ = @import("compiler_rt/log10.zig");
|
||||
_ = @import("compiler_rt/log2.zig");
|
||||
_ = @import("compiler_rt/round.zig");
|
||||
_ = @import("compiler_rt/sqrt.zig");
|
||||
_ = @import("compiler_rt/tan.zig");
|
||||
_ = @import("compiler_rt/trunc.zig");
|
||||
_ = @import("compiler_rt/stack_probe.zig");
|
||||
_ = @import("compiler_rt/divti3.zig");
|
||||
_ = @import("compiler_rt/modti3.zig");
|
||||
_ = @import("compiler_rt/multi3.zig");
|
||||
_ = @import("compiler_rt/udivti3.zig");
|
||||
_ = @import("compiler_rt/udivmodti4.zig");
|
||||
_ = @import("compiler_rt/umodti3.zig");
|
||||
|
||||
_ = @import("compiler_rt/int_to_float.zig");
|
||||
_ = @import("compiler_rt/floatsihf.zig");
|
||||
_ = @import("compiler_rt/floatsisf.zig");
|
||||
_ = @import("compiler_rt/floatsidf.zig");
|
||||
_ = @import("compiler_rt/floatsitf.zig");
|
||||
_ = @import("compiler_rt/floatsixf.zig");
|
||||
_ = @import("compiler_rt/floatdihf.zig");
|
||||
_ = @import("compiler_rt/floatdisf.zig");
|
||||
_ = @import("compiler_rt/floatdidf.zig");
|
||||
_ = @import("compiler_rt/floatditf.zig");
|
||||
_ = @import("compiler_rt/floatdixf.zig");
|
||||
_ = @import("compiler_rt/floattihf.zig");
|
||||
_ = @import("compiler_rt/floattisf.zig");
|
||||
_ = @import("compiler_rt/floattidf.zig");
|
||||
_ = @import("compiler_rt/floattitf.zig");
|
||||
_ = @import("compiler_rt/floattixf.zig");
|
||||
_ = @import("compiler_rt/floatundihf.zig");
|
||||
_ = @import("compiler_rt/floatundisf.zig");
|
||||
_ = @import("compiler_rt/floatundidf.zig");
|
||||
_ = @import("compiler_rt/floatunditf.zig");
|
||||
_ = @import("compiler_rt/floatundixf.zig");
|
||||
_ = @import("compiler_rt/floatunsihf.zig");
|
||||
_ = @import("compiler_rt/floatunsisf.zig");
|
||||
_ = @import("compiler_rt/floatunsidf.zig");
|
||||
_ = @import("compiler_rt/floatunsitf.zig");
|
||||
_ = @import("compiler_rt/floatunsixf.zig");
|
||||
_ = @import("compiler_rt/floatuntihf.zig");
|
||||
_ = @import("compiler_rt/floatuntisf.zig");
|
||||
_ = @import("compiler_rt/floatuntidf.zig");
|
||||
_ = @import("compiler_rt/floatuntitf.zig");
|
||||
_ = @import("compiler_rt/floatuntixf.zig");
|
||||
|
||||
_ = @import("compiler_rt/float_to_int.zig");
|
||||
_ = @import("compiler_rt/fixhfsi.zig");
|
||||
_ = @import("compiler_rt/fixhfdi.zig");
|
||||
_ = @import("compiler_rt/fixhfti.zig");
|
||||
_ = @import("compiler_rt/fixsfsi.zig");
|
||||
_ = @import("compiler_rt/fixsfdi.zig");
|
||||
_ = @import("compiler_rt/fixsfti.zig");
|
||||
_ = @import("compiler_rt/fixdfsi.zig");
|
||||
_ = @import("compiler_rt/fixdfdi.zig");
|
||||
_ = @import("compiler_rt/fixdfti.zig");
|
||||
_ = @import("compiler_rt/fixtfsi.zig");
|
||||
_ = @import("compiler_rt/fixtfdi.zig");
|
||||
_ = @import("compiler_rt/fixtfti.zig");
|
||||
_ = @import("compiler_rt/fixxfsi.zig");
|
||||
_ = @import("compiler_rt/fixxfdi.zig");
|
||||
_ = @import("compiler_rt/fixxfti.zig");
|
||||
_ = @import("compiler_rt/fixunshfsi.zig");
|
||||
_ = @import("compiler_rt/fixunshfdi.zig");
|
||||
_ = @import("compiler_rt/fixunshfti.zig");
|
||||
_ = @import("compiler_rt/fixunssfsi.zig");
|
||||
_ = @import("compiler_rt/fixunssfdi.zig");
|
||||
_ = @import("compiler_rt/fixunssfti.zig");
|
||||
_ = @import("compiler_rt/fixunsdfsi.zig");
|
||||
_ = @import("compiler_rt/fixunsdfdi.zig");
|
||||
_ = @import("compiler_rt/fixunsdfti.zig");
|
||||
_ = @import("compiler_rt/fixunstfsi.zig");
|
||||
_ = @import("compiler_rt/fixunstfdi.zig");
|
||||
_ = @import("compiler_rt/fixunstfti.zig");
|
||||
_ = @import("compiler_rt/fixunsxfsi.zig");
|
||||
_ = @import("compiler_rt/fixunsxfdi.zig");
|
||||
_ = @import("compiler_rt/fixunsxfti.zig");
|
||||
|
||||
_ = @import("compiler_rt/count0bits.zig");
|
||||
_ = @import("compiler_rt/parity.zig");
|
||||
_ = @import("compiler_rt/popcount.zig");
|
||||
_ = @import("compiler_rt/bswap.zig");
|
||||
_ = @import("compiler_rt/int.zig");
|
||||
_ = @import("compiler_rt/shift.zig");
|
||||
|
||||
_ = @import("compiler_rt/negXi2.zig");
|
||||
|
||||
_ = @import("compiler_rt/muldi3.zig");
|
||||
|
||||
_ = @import("compiler_rt/absv.zig");
|
||||
_ = @import("compiler_rt/absvsi2.zig");
|
||||
_ = @import("compiler_rt/absvdi2.zig");
|
||||
_ = @import("compiler_rt/absvti2.zig");
|
||||
|
||||
_ = @import("compiler_rt/negv.zig");
|
||||
_ = @import("compiler_rt/addo.zig");
|
||||
_ = @import("compiler_rt/subo.zig");
|
||||
_ = @import("compiler_rt/mulo.zig");
|
||||
_ = @import("compiler_rt/cmp.zig");
|
||||
|
||||
_ = @import("compiler_rt/os_version_check.zig");
|
||||
_ = @import("compiler_rt/emutls.zig");
|
||||
_ = @import("compiler_rt/arm.zig");
|
||||
_ = @import("compiler_rt/aulldiv.zig");
|
||||
_ = @import("compiler_rt/aullrem.zig");
|
||||
_ = @import("compiler_rt/clear_cache.zig");
|
||||
|
||||
_ = @import("compiler_rt/memcpy.zig");
|
||||
_ = @import("compiler_rt/memset.zig");
|
||||
_ = @import("compiler_rt/memmove.zig");
|
||||
_ = @import("compiler_rt/memcmp.zig");
|
||||
_ = @import("compiler_rt/bcmp.zig");
|
||||
}
|
||||
@@ -1,508 +0,0 @@
|
||||
If hardware lacks basic or specialized functionality, compiler-rt adds such functionality
|
||||
for basic arithmetic(s).
|
||||
One such example is 64-bit integer multiplication on 32-bit x86.
|
||||
|
||||
Goals:
|
||||
1. zig as linker for object files produced by other compilers
|
||||
=> `function compatibility` to compiler-rt and libgcc for same-named functions
|
||||
* compatibility conflict between compiler-rt and libgcc: prefer compiler-rt
|
||||
2. `symbol-level compatibility` low-priority compared to emitted calls by llvm
|
||||
* symbol-level compatibility: libgcc even lower priority
|
||||
3. add zig-specific language runtime features, see #7265
|
||||
* example: arbitrary bit width integer arithmetic
|
||||
* lower to call those functions for e.g. multiplying two i12345 numbers together
|
||||
* proper naming + documention for standardizing (allow languages to follow our exmaple)
|
||||
|
||||
Current status (tracking libgcc documentation):
|
||||
- Integer library routines => almost implemented
|
||||
- Soft float library routines => finished
|
||||
- Decimal float library routines => unimplemented (~120 functions)
|
||||
- Fixed-point fractional library routines => unimplemented (~300 functions)
|
||||
- Exception handling routines => unclear, if supported (~32+x undocumented functions)
|
||||
- Miscellaneous routines => unclear, if supported (cache control and stack function)
|
||||
- No zig-specific language runtime features in compiler-rt yet
|
||||
|
||||
This library is automatically built as-needed for the compilation target and
|
||||
then statically linked and therefore is a transparent dependency for the
|
||||
programmer.
|
||||
For details see `../compiler_rt.zig`.
|
||||
|
||||
The routines in this folder are listed below.
|
||||
Routines are annotated as `type source routine // description`, with `routine`
|
||||
being the name used in aforementioned `compiler_rt.zig`.
|
||||
`dev` means deviating from compiler_rt, `port` ported, `source` is the
|
||||
information source for the implementation, `none` means unimplemented.
|
||||
Some examples for the naming convention are:
|
||||
- dev source name_routine, name_routine2 various implementations for performance, simplicity etc
|
||||
- port llvm compiler-rt library routines from [LLVM](http://compiler-rt.llvm.org/)
|
||||
* LLVM emits library calls to compiler-rt, if the hardware lacks functionality
|
||||
- port musl libc routines from [musl](https://musl.libc.org/)
|
||||
If the library or information source is uncommon, use the entry `other` for `source`.
|
||||
Please do not break the search by inserting entries in another format than `impl space source`.
|
||||
|
||||
Bugs should be solved by trying to duplicate the bug upstream, if possible.
|
||||
* If the bug exists upstream, get it fixed upstream and port the fix downstream to Zig.
|
||||
* If the bug only exists in Zig, use the corresponding C code and debug
|
||||
both implementations side by side to figure out what is wrong.
|
||||
|
||||
## Integer library routines
|
||||
|
||||
#### Integer Bit operations
|
||||
|
||||
- dev HackersDelight __clzsi2 // count leading zeros
|
||||
- dev HackersDelight __clzdi2 // count leading zeros
|
||||
- dev HackersDelight __clzti2 // count leading zeros
|
||||
- dev HackersDelight __ctzsi2 // count trailing zeros
|
||||
- dev HackersDelight __ctzdi2 // count trailing zeros
|
||||
- dev HackersDelight __ctzti2 // count trailing zeros
|
||||
- dev __ctzsi2 __ffssi2 // find least significant 1 bit
|
||||
- dev __ctzsi2 __ffsdi2 // find least significant 1 bit
|
||||
- dev __ctzsi2 __ffsti2 // find least significant 1 bit
|
||||
- dev BitTwiddlingHacks __paritysi2 // bit parity
|
||||
- dev BitTwiddlingHacks __paritydi2 // bit parity
|
||||
- dev BitTwiddlingHacks __parityti2 // bit parity
|
||||
- dev TAOCP __popcountsi2 // bit population
|
||||
- dev TAOCP __popcountdi2 // bit population
|
||||
- dev TAOCP __popcountti2 // bit population
|
||||
- dev other __bswapsi2 // a byteswapped
|
||||
- dev other __bswapdi2 // a byteswapped
|
||||
- dev other __bswapti2 // a byteswapped
|
||||
|
||||
#### Integer Comparison
|
||||
|
||||
- port llvm __cmpsi2 // a,b: i32, (a<b)-> 0, (a==b) -> 1, (a>b) -> 2
|
||||
- port llvm __cmpdi2 // a,b: i64
|
||||
- port llvm __cmpti2 // a,b: i128
|
||||
- port llvm __ucmpsi2 // a,b: u32, (a<b)-> 0, (a==b) -> 1, (a>b) -> 2
|
||||
- port llvm __ucmpdi2 // a,b: u64
|
||||
- port llvm __ucmpti2 // a,b: u128
|
||||
|
||||
#### Integer Arithmetic
|
||||
|
||||
- none none __ashlsi3 // a,b: i32, a << b unused in llvm, TODO (e.g. used by rl78)
|
||||
- port llvm __ashldi3 // a,b: u64
|
||||
- port llvm __ashlti3 // a,b: u128
|
||||
- none none __ashrsi3 // a,b: i32, a >> b arithmetic (sign fill) TODO (e.g. used by rl78)
|
||||
- port llvm __ashrdi3 // ..
|
||||
- port llvm __ashrti3 //
|
||||
- none none __lshrsi3 // a,b: i32, a >> b logical (zero fill) TODO (e.g. used by rl78)
|
||||
- port llvm __lshrdi3 //
|
||||
- port llvm __lshrti3 //
|
||||
- port llvm __negdi2 // a: i32, -a, symbol-level compatibility with libgcc
|
||||
- port llvm __negti2 // unnecessary: unused in backends
|
||||
- port llvm __mulsi3 // a,b: i32, a * b
|
||||
- port llvm __muldi3 //
|
||||
- port llvm __multi3 //
|
||||
- port llvm __divsi3 // a,b: i32, a / b
|
||||
- port llvm __divdi3 //
|
||||
- port llvm __divti3 //
|
||||
- port llvm __udivsi3 // a,b: u32, a / b
|
||||
- port llvm __udivdi3 //
|
||||
- port llvm __udivti3 //
|
||||
- port llvm __modsi3 // a,b: i32, a % b
|
||||
- port llvm __moddi3 //
|
||||
- port llvm __modti3 //
|
||||
- port llvm __umodsi3 // a,b: u32, a % b
|
||||
- port llvm __umoddi3 //
|
||||
- port llvm __umodti3 //
|
||||
- port llvm __udivmoddi4 // a,b: u32, a / b, rem.* = a % b unsigned
|
||||
- port llvm __udivmodti4 //
|
||||
- port llvm __udivmodsi4 //
|
||||
- port llvm __divmodsi4 // a,b: i32, a / b, rem.* = a % b signed, ARM
|
||||
- port llvm __divmoddi4 //
|
||||
|
||||
#### Integer Arithmetic with trapping overflow
|
||||
|
||||
- dev BitTwiddlingHacks __absvsi2 // abs(a)
|
||||
- dev BitTwiddlingHacks __absvdi2 // abs(a)
|
||||
- dev BitTwiddlingHacks __absvti2 // abs(a)
|
||||
- port llvm __negvsi2 // -a symbol-level compatibility: libgcc
|
||||
- port llvm __negvdi2 // -a unnecessary: unused in backends
|
||||
- port llvm __negvti2 // -a
|
||||
- TODO upstreaming __addvsi3..__mulvti3 after testing panics works
|
||||
- dev HackersDelight __addvsi3 // a + b
|
||||
- dev HackersDelight __addvdi3 //
|
||||
- dev HackersDelight __addvti3 //
|
||||
- dev HackersDelight __subvsi3 // a - b
|
||||
- dev HackersDelight __subvdi3 //
|
||||
- dev HackersDelight __subvti3 //
|
||||
- dev HackersDelight __mulvsi3 // a * b
|
||||
- dev HackersDelight __mulvdi3 //
|
||||
- dev HackersDelight __mulvti3 //
|
||||
|
||||
#### Integer Arithmetic which returns if overflow (would be faster without pointer)
|
||||
|
||||
- dev HackersDelight __addosi4 // a + b, overflow->ov.*=1 else 0
|
||||
- dev HackersDelight __addodi4 // (completeness + performance, llvm does not use them)
|
||||
- dev HackersDelight __addoti4 //
|
||||
- dev HackersDelight __subosi4 // a - b, overflow->ov.*=1 else 0
|
||||
- dev HackersDelight __subodi4 // (completeness + performance, llvm does not use them)
|
||||
- dev HackersDelight __suboti4 //
|
||||
- dev HackersDelight __mulosi4 // a * b, overflow->ov.*=1 else 0
|
||||
- dev HackersDelight __mulodi4 // (required by llvm)
|
||||
- dev HackersDelight __muloti4 //
|
||||
|
||||
## Float library routines
|
||||
|
||||
TODO: review source of implementation
|
||||
|
||||
#### Float Conversion
|
||||
|
||||
- dev other __extendsfdf2 // a: f32 -> f64, TODO: missing tests
|
||||
- dev other __extendsftf2 // a: f32 -> f128
|
||||
- dev llvm __extendsfxf2 // a: f32 -> f80, TODO: missing tests
|
||||
- dev other __extenddftf2 // a: f64 -> f128
|
||||
- dev llvm __extenddfxf2 // a: f64 -> f80
|
||||
- dev other __truncdfsf2 // a: f64 -> f32, rounding towards zero
|
||||
- dev other __trunctfdf2 // a: f128-> f64
|
||||
- dev other __trunctfsf2 // a: f128-> f32
|
||||
- dev llvm __truncxfsf2 // a: f80 -> f32, TODO: missing tests
|
||||
- dev llvm __truncxfdf2 // a: f80 -> f64, TODO: missing tests
|
||||
|
||||
- dev unclear __fixsfsi // a: f32 -> i32, rounding towards zero
|
||||
- dev unclear __fixdfsi // a: f64 -> i32
|
||||
- dev unclear __fixtfsi // a: f128-> i32
|
||||
- dev unclear __fixxfsi // a: f80 -> i32, TODO: missing tests
|
||||
- dev unclear __fixsfdi // a: f32 -> i64, rounding towards zero
|
||||
- dev unclear __fixdfdi // ..
|
||||
- dev unclear __fixtfdi //
|
||||
- dev unclear __fixxfdi // TODO: missing tests
|
||||
- dev unclear __fixsfti // a: f32 -> i128, rounding towards zero
|
||||
- dev unclear __fixdfti // ..
|
||||
- dev unclear __fixtfdi //
|
||||
- dev unclear __fixxfti // TODO: missing tests
|
||||
|
||||
- dev unclear __fixunssfsi // a: f32 -> u32, rounding towards zero. negative values become 0.
|
||||
- dev unclear __fixunsdfsi // ..
|
||||
- dev unclear __fixunstfsi //
|
||||
- dev unclear __fixunsxfsi // TODO: missing tests
|
||||
- dev unclear __fixunssfdi // a: f32 -> u64, rounding towards zero. negative values become 0.
|
||||
- dev unclear __fixunsdfdi //
|
||||
- dev unclear __fixunstfdi //
|
||||
- dev unclear __fixunsxfdi // TODO: missing tests
|
||||
- dev unclear __fixunssfti // a: f32 -> u128, rounding towards zero. negative values become 0.
|
||||
- dev unclear __fixunsdfti //
|
||||
- dev unclear __fixunstfdi //
|
||||
- dev unclear __fixunsxfti // TODO: some more tests needed for base coverage
|
||||
|
||||
- dev unclear __floatsisf // a: i32 -> f32
|
||||
- dev unclear __floatsidf // a: i32 -> f64, TODO: missing tests
|
||||
- dev unclear __floatsitf // ..
|
||||
- dev unclear __floatsixf // TODO: missing tests
|
||||
- dev unclear __floatdisf // a: i64 -> f32
|
||||
- dev unclear __floatdidf //
|
||||
- dev unclear __floatditf //
|
||||
- dev unclear __floatdixf // TODO: missing tests
|
||||
- dev unclear __floattisf // a: i128-> f32
|
||||
- dev unclear __floattidf //
|
||||
- dev unclear __floattitf //
|
||||
- dev unclear __floattixf // TODO: missing tests
|
||||
|
||||
- dev unclear __floatunsisf // a: u32 -> f32
|
||||
- dev unclear __floatunsidf // TODO: missing tests
|
||||
- dev unclear __floatunsitf //
|
||||
- dev unclear __floatunsixf // TODO: missing tests
|
||||
- dev unclear __floatundisf // a: u64 -> f32
|
||||
- dev unclear __floatundidf //
|
||||
- dev unclear __floatunditf //
|
||||
- dev unclear __floatundixf // TODO: missing tests
|
||||
- dev unclear __floatuntisf // a: u128-> f32
|
||||
- dev unclear __floatuntidf //
|
||||
- dev unclear __floatuntitf //
|
||||
- dev unclear __floatuntixf // TODO: missing tests
|
||||
|
||||
#### Float Comparison
|
||||
|
||||
- dev other __cmpsf2 // a,b:f32, (a<b)->-1,(a==b)->0,(a>b)->1,Nan->1
|
||||
- dev other __cmpdf2 // exported from __lesf2, __ledf2, __letf2 (below)
|
||||
- dev other __cmptf2 // But: if NaN is a possibility, use another routine.
|
||||
- dev other __unordsf2 // a,b:f32, (a==+-NaN or b==+-NaN) -> !=0, else -> 0
|
||||
- dev other __unorddf2 // __only reliable for (input!=NaN)__
|
||||
- dev other __unordtf2 // TODO: missing tests
|
||||
- dev other __eqsf2 // (a!=NaN) and (b!=Nan) and (a==b) -> output=0
|
||||
- dev other __eqdf2 //
|
||||
- dev other __eqtf2 //
|
||||
- dev other __nesf2 // (a==NaN) or (b==Nan) or (a!=b) -> output!=0
|
||||
- dev other __nedf2 //
|
||||
- dev other __netf2 // __eqtf2 and __netf2 have same return value -> tested with __eqsf2
|
||||
- dev other __gesf2 // (a!=Nan) and (b!=Nan) and (a>=b) -> output>=0
|
||||
- dev other __gedf2 //
|
||||
- dev other __getf2 // TODO: missing tests
|
||||
- dev other __ltsf2 // (a!=Nan) and (b!=Nan) and (a<b) -> output<0
|
||||
- dev other __ltdf2 //
|
||||
- dev other __lttf2 // TODO: missing tests
|
||||
- dev other __lesf2 // (a!=Nan) and (b!=Nan) and (a<=b) -> output<=0
|
||||
- dev other __ledf2 //
|
||||
- dev other __letf2 // TODO: missing tests
|
||||
- dev other __gtsf2 // (a!=Nan) and (b!=Nan) and (a>b) -> output>0
|
||||
- dev other __gtdf2 //
|
||||
- dev other __gttf2 // TODO: missing tests
|
||||
|
||||
#### Float Arithmetic
|
||||
|
||||
- dev unclear __addsf3 // a + b f32, TODO: missing tests
|
||||
- dev unclear __adddf3 // a + b f64, TODO: missing tests
|
||||
- dev unclear __addtf3 // a + b f128
|
||||
- dev unclear __addxf3 // a + b f80
|
||||
- dev unclear __aeabi_fadd // a + b f64 ARM: AAPCS
|
||||
- dev unclear __aeabi_dadd // a + b f64 ARM: AAPCS
|
||||
- dev unclear __subsf3 // a - b, TODO: missing tests
|
||||
- dev unclear __subdf3 // a - b, TODO: missing tests
|
||||
- dev unclear __subtf3 // a - b
|
||||
- dev unclear __subxf3 // a - b f80, TODO: missing tests
|
||||
- dev unclear __aeabi_fsub // a - b f64 ARM: AAPCS
|
||||
- dev unclear __aeabi_dsub // a - b f64 ARM: AAPCS
|
||||
- dev unclear __mulsf3 // a * b, TODO: missing tests
|
||||
- dev unclear __muldf3 // a * b, TODO: missing tests
|
||||
- dev unclear __multf3 // a * b
|
||||
- dev unclear __mulxf3 // a * b
|
||||
- dev unclear __divsf3 // a / b, TODO: review tests
|
||||
- dev unclear __divdf3 // a / b, TODO: review tests
|
||||
- dev unclear __divtf3 // a / b
|
||||
- dev unclear __divxf3 // a / b
|
||||
- dev unclear __negsf2 // -a symbol-level compatibility: libgcc uses this for the rl78
|
||||
- dev unclear __negdf2 // -a unnecessary: can be lowered directly to a xor
|
||||
- dev unclear __negtf2 // -a, TODO: missing tests
|
||||
- dev unclear __negxf2 // -a, TODO: missing tests
|
||||
|
||||
#### Floating point raised to integer power
|
||||
- dev unclear __powisf2 // a ^ b, TODO
|
||||
- dev unclear __powidf2 //
|
||||
- dev unclear __powitf2 //
|
||||
- dev unclear __powixf2 //
|
||||
- dev unclear __mulsc3 // (a+ib) * (c+id)
|
||||
- dev unclear __muldc3 //
|
||||
- dev unclear __multc3 //
|
||||
- dev unclear __mulxc3 //
|
||||
- dev unclear __divsc3 // (a+ib) * / (c+id)
|
||||
- dev unclear __divdc3 //
|
||||
- dev unclear __divtc3 //
|
||||
- dev unclear __divxc3 //
|
||||
|
||||
## Decimal float library routines
|
||||
|
||||
BID means Binary Integer Decimal encoding, DPD means Densely Packed Decimal encoding.
|
||||
BID should be only chosen for binary data, DPD for decimal data (ASCII, Unicode etc).
|
||||
If possible, use BCD instead of DPD to represent numbers not accurately representable
|
||||
in binary like the number 0.2.
|
||||
|
||||
All routines are TODO.
|
||||
|
||||
#### Decimal float Conversion
|
||||
|
||||
- __dpd_extendsddd2 // dec32->dec64
|
||||
- __bid_extendsddd2 // dec32->dec64
|
||||
- __dpd_extendsdtd2 // dec32->dec128
|
||||
- __bid_extendsdtd2 // dec32->dec128
|
||||
- __dpd_extendddtd2 // dec64->dec128
|
||||
- __bid_extendddtd2 // dec64->dec128
|
||||
- __dpd_truncddsd2 // dec64->dec32
|
||||
- __bid_truncddsd2 // dec64->dec32
|
||||
- __dpd_trunctdsd2 // dec128->dec32
|
||||
- __bid_trunctdsd2 // dec128->dec32
|
||||
- __dpd_trunctddd2 // dec128->dec64
|
||||
- __bid_trunctddd2 // dec128->dec64
|
||||
|
||||
- __dpd_extendsfdd // float->dec64
|
||||
- __bid_extendsfdd // float->dec64
|
||||
- __dpd_extendsftd // float->dec128
|
||||
- __bid_extendsftd // float->dec128
|
||||
- __dpd_extenddftd // double->dec128
|
||||
- __bid_extenddftd // double->dec128
|
||||
- __dpd_extendxftd // long double->dec128
|
||||
- __bid_extendxftd // long double->dec128
|
||||
- __dpd_truncdfsd // double->dec32
|
||||
- __bid_truncdfsd // double->dec32
|
||||
- __dpd_truncxfsd // long double->dec32
|
||||
- __bid_truncxfsd // long double->dec32
|
||||
- __dpd_trunctfsd // long double->dec32
|
||||
- __bid_trunctfsd // long double->dec32
|
||||
- __dpd_truncxfdd // long double->dec64
|
||||
- __bid_truncxfdd // long double->dec64
|
||||
- __dpd_trunctfdd // long double->dec64
|
||||
- __bid_trunctfdd // long double->dec64
|
||||
|
||||
- __dpd_truncddsf // dec64->float
|
||||
- __bid_truncddsf // dec64->float
|
||||
- __dpd_trunctdsf // dec128->float
|
||||
- __bid_trunctdsf // dec128->float
|
||||
- __dpd_extendsddf // dec32->double
|
||||
- __bid_extendsddf // dec32->double
|
||||
- __dpd_trunctddf // dec128->double
|
||||
- __bid_trunctddf // dec128->double
|
||||
- __dpd_extendsdxf // dec32->long double
|
||||
- __bid_extendsdxf // dec32->long double
|
||||
- __dpd_extendddxf // dec64->long double
|
||||
- __bid_extendddxf // dec64->long double
|
||||
- __dpd_trunctdxf // dec128->long double
|
||||
- __bid_trunctdxf // dec128->long double
|
||||
- __dpd_extendsdtf // dec32->long double
|
||||
- __bid_extendsdtf // dec32->long double
|
||||
- __dpd_extendddtf // dec64->long double
|
||||
- __bid_extendddtf // dec64->long double
|
||||
|
||||
Same size conversion:
|
||||
- __dpd_extendsfsd // float->dec32
|
||||
- __bid_extendsfsd // float->dec32
|
||||
- __dpd_extenddfdd // double->dec64
|
||||
- __bid_extenddfdd // double->dec64
|
||||
- __dpd_extendtftd //long double->dec128
|
||||
- __bid_extendtftd //long double->dec128
|
||||
- __dpd_truncsdsf // dec32->float
|
||||
- __bid_truncsdsf // dec32->float
|
||||
- __dpd_truncdddf // dec64->float
|
||||
- __bid_truncdddf // dec64->float
|
||||
- __dpd_trunctdtf // dec128->long double
|
||||
- __bid_trunctdtf // dec128->long double
|
||||
|
||||
- __dpd_fixsdsi // dec32->int
|
||||
- __bid_fixsdsi // dec32->int
|
||||
- __dpd_fixddsi // dec64->int
|
||||
- __bid_fixddsi // dec64->int
|
||||
- __dpd_fixtdsi // dec128->int
|
||||
- __bid_fixtdsi // dec128->int
|
||||
|
||||
- __dpd_fixsddi // dec32->long
|
||||
- __bid_fixsddi // dec32->long
|
||||
- __dpd_fixdddi // dec64->long
|
||||
- __bid_fixdddi // dec64->long
|
||||
- __dpd_fixtddi // dec128->long
|
||||
- __bid_fixtddi // dec128->long
|
||||
|
||||
- __dpd_fixunssdsi // dec32->unsigned int, All negative values become zero.
|
||||
- __bid_fixunssdsi // dec32->unsigned int
|
||||
- __dpd_fixunsddsi // dec64->unsigned int
|
||||
- __bid_fixunsddsi // dec64->unsigned int
|
||||
- __dpd_fixunstdsi // dec128->unsigned int
|
||||
- __bid_fixunstdsi // dec128->unsigned int
|
||||
|
||||
- __dpd_fixunssddi // dec32->unsigned long, All negative values become zero.
|
||||
- __bid_fixunssddi // dec32->unsigned long
|
||||
- __dpd_fixunsdddi // dec64->unsigned long
|
||||
- __bid_fixunsdddi // dec64->unsigned long
|
||||
- __dpd_fixunstddi // dec128->unsigned long
|
||||
- __bid_fixunstddi // dec128->unsigned long
|
||||
|
||||
- __dpd_floatsisd // int->dec32
|
||||
- __bid_floatsisd // int->dec32
|
||||
- __dpd_floatsidd // int->dec64
|
||||
- __bid_floatsidd // int->dec64
|
||||
- __dpd_floatsitd // int->dec128
|
||||
- __bid_floatsitd // int->dec128
|
||||
|
||||
- __dpd_floatdisd // long->dec32
|
||||
- __bid_floatdisd // long->dec32
|
||||
- __dpd_floatdidd // long->dec64
|
||||
- __bid_floatdidd // long->dec64
|
||||
- __dpd_floatditd // long->dec128
|
||||
- __bid_floatditd // long->dec128
|
||||
|
||||
- __dpd_floatunssisd // unsigned int->dec32
|
||||
- __bid_floatunssisd // unsigned int->dec32
|
||||
- __dpd_floatunssidd // unsigned int->dec64
|
||||
- __bid_floatunssidd // unsigned int->dec64
|
||||
- __dpd_floatunssitd // unsigned int->dec128
|
||||
- __bid_floatunssitd // unsigned int->dec128
|
||||
|
||||
- __dpd_floatunsdisd // unsigned long->dec32
|
||||
- __bid_floatunsdisd // unsigned long->dec32
|
||||
- __dpd_floatunsdidd // unsigned long->dec64
|
||||
- __bid_floatunsdidd // unsigned long->dec64
|
||||
- __dpd_floatunsditd // unsigned long->dec128
|
||||
- __bid_floatunsditd // unsigned long->dec128
|
||||
|
||||
#### Decimal float Comparison
|
||||
|
||||
All decimal float comparison routines return c_int.
|
||||
|
||||
- __dpd_unordsd2 // a,b: dec32, a +-NaN or a +-NaN -> 1(nonzero), else -> 0
|
||||
- __bid_unordsd2 // a,b: dec32
|
||||
- __dpd_unorddd2 // a,b: dec64
|
||||
- __bid_unorddd2 // a,b: dec64
|
||||
- __dpd_unordtd2 // a,b: dec128
|
||||
- __bid_unordtd2 // a,b: dec128
|
||||
|
||||
- __dpd_eqsd2 // a,b: dec32, a!=+-NaN and b!=+-Nan and a==b -> 0, else -> 1(nonzero)
|
||||
- __bid_eqsd2 // a,b: dec32
|
||||
- __dpd_eqdd2 // a,b: dec64
|
||||
- __bid_eqdd2 // a,b: dec64
|
||||
- __dpd_eqtd2 // a,b: dec128
|
||||
- __bid_eqtd2 // a,b: dec128
|
||||
|
||||
- __dpd_nesd2 // a,b: dec32, a==+-NaN or b==+-NaN or a!=b -> 1(nonzero), else -> 0
|
||||
- __bid_nesd2 // a,b: dec32
|
||||
- __dpd_nedd2 // a,b: dec64
|
||||
- __bid_nedd2 // a,b: dec64
|
||||
- __dpd_netd2 // a,b: dec128
|
||||
- __bid_netd2 // a,b: dec128
|
||||
|
||||
- __dpd_gesd2 // a,b: dec32, a!=+-NaN and b!=+-NaN and a>=b -> >=0, else -> <0
|
||||
- __bid_gesd2 // a,b: dec32
|
||||
- __dpd_gedd2 // a,b: dec64
|
||||
- __bid_gedd2 // a,b: dec64
|
||||
- __dpd_getd2 // a,b: dec128
|
||||
- __bid_getd2 // a,b: dec128
|
||||
|
||||
- __dpd_ltsd2 // a,b: dec32, a!=+-NaN and b!=+-NaN and a<b -> <0, else -> >=0
|
||||
- __bid_ltsd2 // a,b: dec32
|
||||
- __dpd_ltdd2 // a,b: dec64
|
||||
- __bid_ltdd2 // a,b: dec64
|
||||
- __dpd_lttd2 // a,b: dec128
|
||||
- __bid_lttd2 // a,b: dec128
|
||||
|
||||
- __dpd_lesd2 // a,b: dec32, a!=+-NaN and b!=+-NaN and a<=b -> <=0, else -> >=0
|
||||
- __bid_lesd2 // a,b: dec32
|
||||
- __dpd_ledd2 // a,b: dec64
|
||||
- __bid_ledd2 // a,b: dec64
|
||||
- __dpd_letd2 // a,b: dec128
|
||||
- __bid_letd2 // a,b: dec128
|
||||
|
||||
- __dpd_gtsd2 // a,b: dec32, a!=+-NaN and b!=+-NaN and a>b -> >0, else -> <=0
|
||||
- __bid_gtsd2 // a,b: dec32
|
||||
- __dpd_gtdd2 // a,b: dec64
|
||||
- __bid_gtdd2 // a,b: dec64
|
||||
- __dpd_gttd2 // a,b: dec128
|
||||
- __bid_gttd2 // a,b: dec128
|
||||
|
||||
#### Decimal float Arithmetic
|
||||
|
||||
These numbers include options with routines for +-0 and +-Nan.
|
||||
|
||||
- __dpd_addsd3 // a,b: dec32 -> dec32, a + b
|
||||
- __bid_addsd3 // a,b: dec32 -> dec32
|
||||
- __dpd_adddd3 // a,b: dec64 -> dec64
|
||||
- __bid_adddd3 // a,b: dec64 -> dec64
|
||||
- __dpd_addtd3 // a,b: dec128-> dec128
|
||||
- __bid_addtd3 // a,b: dec128-> dec128
|
||||
- __dpd_subsd3 // a,b: dec32, a - b
|
||||
- __bid_subsd3 // a,b: dec32 -> dec32
|
||||
- __dpd_subdd3 // a,b: dec64 ..
|
||||
- __bid_subdd3 // a,b: dec64
|
||||
- __dpd_subtd3 // a,b: dec128
|
||||
- __bid_subtd3 // a,b: dec128
|
||||
- __dpd_mulsd3 // a,b: dec32, a * b
|
||||
- __bid_mulsd3 // a,b: dec32 -> dec32
|
||||
- __dpd_muldd3 // a,b: dec64 ..
|
||||
- __bid_muldd3 // a,b: dec64
|
||||
- __dpd_multd3 // a,b: dec128
|
||||
- __bid_multd3 // a,b: dec128
|
||||
- __dpd_divsd3 // a,b: dec32, a / b
|
||||
- __bid_divsd3 // a,b: dec32 -> dec32
|
||||
- __dpd_divdd3 // a,b: dec64 ..
|
||||
- __bid_divdd3 // a,b: dec64
|
||||
- __dpd_divtd3 // a,b: dec128
|
||||
- __bid_divtd3 // a,b: dec128
|
||||
- __dpd_negsd2 // a,b: dec32, -a
|
||||
- __bid_negsd2 // a,b: dec32 -> dec32
|
||||
- __dpd_negdd2 // a,b: dec64 ..
|
||||
- __bid_negdd2 // a,b: dec64
|
||||
- __dpd_negtd2 // a,b: dec128
|
||||
- __bid_negtd2 // a,b: dec128
|
||||
|
||||
## Fixed-point fractional library routines
|
||||
|
||||
TODO
|
||||
|
||||
Too unclear for work items:
|
||||
- Miscellaneous routines => unclear, if supported (cache control and stack functions)
|
||||
- Zig-specific language runtime features, for example "Arbitrary length integer library routines"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
/// absv - absolute oVerflow
|
||||
/// * @panic if value can not be represented
|
||||
pub inline fn absv(comptime ST: type, a: ST) ST {
|
||||
const UT = switch (ST) {
|
||||
i32 => u32,
|
||||
i64 => u64,
|
||||
i128 => u128,
|
||||
else => unreachable,
|
||||
};
|
||||
// taken from Bit Twiddling Hacks
|
||||
// compute the integer absolute value (abs) without branching
|
||||
var x: ST = a;
|
||||
const N: UT = @bitSizeOf(ST);
|
||||
const sign: ST = a >> N - 1;
|
||||
x +%= sign;
|
||||
x ^= sign;
|
||||
if (x < 0)
|
||||
@panic("compiler_rt absv: overflow");
|
||||
return x;
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("absvsi2_test.zig");
|
||||
_ = @import("absvdi2_test.zig");
|
||||
_ = @import("absvti2_test.zig");
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const absv = @import("./absv.zig").absv;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__absvdi2, .{ .name = "__absvdi2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __absvdi2(a: i64) callconv(.C) i64 {
|
||||
return absv(i64, a);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
const testing = @import("std").testing;
|
||||
|
||||
const __absvdi2 = @import("absvdi2.zig").__absvdi2;
|
||||
|
||||
fn test__absvdi2(a: i64, expected: i64) !void {
|
||||
var result = __absvdi2(a);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "absvdi2" {
|
||||
// -2^63 <= i64 <= 2^63-1
|
||||
// 2^63 = 9223372036854775808
|
||||
// 2^63-1 = 9223372036854775807
|
||||
// TODO write panic handler for testing panics
|
||||
//try test__absvdi2(-9223372036854775808, -5); // tested with return -5; and panic
|
||||
try test__absvdi2(-9223372036854775807, 9223372036854775807);
|
||||
try test__absvdi2(-9223372036854775806, 9223372036854775806);
|
||||
try test__absvdi2(-9223372036854775805, 9223372036854775805);
|
||||
try test__absvdi2(-9223372036854775804, 9223372036854775804);
|
||||
try test__absvdi2(-42, 42);
|
||||
try test__absvdi2(-7, 7);
|
||||
try test__absvdi2(-1, 1);
|
||||
try test__absvdi2(0, 0);
|
||||
try test__absvdi2(1, 1);
|
||||
try test__absvdi2(7, 7);
|
||||
try test__absvdi2(42, 42);
|
||||
try test__absvdi2(9223372036854775804, 9223372036854775804);
|
||||
try test__absvdi2(9223372036854775805, 9223372036854775805);
|
||||
try test__absvdi2(9223372036854775806, 9223372036854775806);
|
||||
try test__absvdi2(9223372036854775807, 9223372036854775807);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const absv = @import("./absv.zig").absv;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__absvsi2, .{ .name = "__absvsi2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __absvsi2(a: i32) callconv(.C) i32 {
|
||||
return absv(i32, a);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
const testing = @import("std").testing;
|
||||
|
||||
const __absvsi2 = @import("absvsi2.zig").__absvsi2;
|
||||
|
||||
fn test__absvsi2(a: i32, expected: i32) !void {
|
||||
var result = __absvsi2(a);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "absvsi2" {
|
||||
// -2^31 <= i32 <= 2^31-1
|
||||
// 2^31 = 2147483648
|
||||
// 2^31-1 = 2147483647
|
||||
// TODO write panic handler for testing panics
|
||||
//try test__absvsi2(-2147483648, -5); // tested with return -5; and panic
|
||||
try test__absvsi2(-2147483647, 2147483647);
|
||||
try test__absvsi2(-2147483646, 2147483646);
|
||||
try test__absvsi2(-2147483645, 2147483645);
|
||||
try test__absvsi2(-2147483644, 2147483644);
|
||||
try test__absvsi2(-42, 42);
|
||||
try test__absvsi2(-7, 7);
|
||||
try test__absvsi2(-1, 1);
|
||||
try test__absvsi2(0, 0);
|
||||
try test__absvsi2(1, 1);
|
||||
try test__absvsi2(7, 7);
|
||||
try test__absvsi2(42, 42);
|
||||
try test__absvsi2(2147483644, 2147483644);
|
||||
try test__absvsi2(2147483645, 2147483645);
|
||||
try test__absvsi2(2147483646, 2147483646);
|
||||
try test__absvsi2(2147483647, 2147483647);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const absv = @import("./absv.zig").absv;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__absvti2, .{ .name = "__absvti2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __absvti2(a: i128) callconv(.C) i128 {
|
||||
return absv(i128, a);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
const testing = @import("std").testing;
|
||||
|
||||
const __absvti2 = @import("absvti2.zig").__absvti2;
|
||||
|
||||
fn test__absvti2(a: i128, expected: i128) !void {
|
||||
var result = __absvti2(a);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "absvti2" {
|
||||
// -2^127 <= i128 <= 2^127-1
|
||||
// 2^127 = 170141183460469231731687303715884105728
|
||||
// 2^127+1 = 170141183460469231731687303715884105727
|
||||
// TODO write panic handler for testing panics
|
||||
//try test__absvti2(-170141183460469231731687303715884105728, -5); // tested with return -5; and panic
|
||||
try test__absvti2(-170141183460469231731687303715884105727, 170141183460469231731687303715884105727);
|
||||
try test__absvti2(-170141183460469231731687303715884105726, 170141183460469231731687303715884105726);
|
||||
try test__absvti2(-170141183460469231731687303715884105725, 170141183460469231731687303715884105725);
|
||||
try test__absvti2(-170141183460469231731687303715884105724, 170141183460469231731687303715884105724);
|
||||
try test__absvti2(-42, 42);
|
||||
try test__absvti2(-7, 7);
|
||||
try test__absvti2(-1, 1);
|
||||
try test__absvti2(0, 0);
|
||||
try test__absvti2(1, 1);
|
||||
try test__absvti2(7, 7);
|
||||
try test__absvti2(42, 42);
|
||||
try test__absvti2(170141183460469231731687303715884105724, 170141183460469231731687303715884105724);
|
||||
try test__absvti2(170141183460469231731687303715884105725, 170141183460469231731687303715884105725);
|
||||
try test__absvti2(170141183460469231731687303715884105726, 170141183460469231731687303715884105726);
|
||||
try test__absvti2(170141183460469231731687303715884105727, 170141183460469231731687303715884105727);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_aeabi) {
|
||||
@export(__aeabi_dadd, .{ .name = "__aeabi_dadd", .linkage = common.linkage });
|
||||
} else {
|
||||
@export(__adddf3, .{ .name = "__adddf3", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
fn __adddf3(a: f64, b: f64) callconv(.C) f64 {
|
||||
return addf3(f64, a, b);
|
||||
}
|
||||
|
||||
fn __aeabi_dadd(a: f64, b: f64) callconv(.AAPCS) f64 {
|
||||
return addf3(f64, a, b);
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
const std = @import("std");
|
||||
const math = std.math;
|
||||
const common = @import("./common.zig");
|
||||
const normalize = common.normalize;
|
||||
|
||||
/// Ported from:
|
||||
///
|
||||
/// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc
|
||||
pub inline fn addf3(comptime T: type, a: T, b: T) T {
|
||||
const bits = @typeInfo(T).Float.bits;
|
||||
const Z = std.meta.Int(.unsigned, bits);
|
||||
const S = std.meta.Int(.unsigned, bits - @clz(@as(Z, bits) - 1));
|
||||
|
||||
const typeWidth = bits;
|
||||
const significandBits = math.floatMantissaBits(T);
|
||||
const fractionalBits = math.floatFractionalBits(T);
|
||||
const exponentBits = math.floatExponentBits(T);
|
||||
|
||||
const signBit = (@as(Z, 1) << (significandBits + exponentBits));
|
||||
const maxExponent = ((1 << exponentBits) - 1);
|
||||
|
||||
const integerBit = (@as(Z, 1) << fractionalBits);
|
||||
const quietBit = integerBit >> 1;
|
||||
const significandMask = (@as(Z, 1) << significandBits) - 1;
|
||||
|
||||
const absMask = signBit - 1;
|
||||
const qnanRep = @bitCast(Z, math.nan(T)) | quietBit;
|
||||
|
||||
var aRep = @bitCast(Z, a);
|
||||
var bRep = @bitCast(Z, b);
|
||||
const aAbs = aRep & absMask;
|
||||
const bAbs = bRep & absMask;
|
||||
|
||||
const infRep = @bitCast(Z, math.inf(T));
|
||||
|
||||
// Detect if a or b is zero, infinity, or NaN.
|
||||
if (aAbs -% @as(Z, 1) >= infRep - @as(Z, 1) or
|
||||
bAbs -% @as(Z, 1) >= infRep - @as(Z, 1))
|
||||
{
|
||||
// NaN + anything = qNaN
|
||||
if (aAbs > infRep) return @bitCast(T, @bitCast(Z, a) | quietBit);
|
||||
// anything + NaN = qNaN
|
||||
if (bAbs > infRep) return @bitCast(T, @bitCast(Z, b) | quietBit);
|
||||
|
||||
if (aAbs == infRep) {
|
||||
// +/-infinity + -/+infinity = qNaN
|
||||
if ((@bitCast(Z, a) ^ @bitCast(Z, b)) == signBit) {
|
||||
return @bitCast(T, qnanRep);
|
||||
}
|
||||
// +/-infinity + anything remaining = +/- infinity
|
||||
else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
// anything remaining + +/-infinity = +/-infinity
|
||||
if (bAbs == infRep) return b;
|
||||
|
||||
// zero + anything = anything
|
||||
if (aAbs == 0) {
|
||||
// but we need to get the sign right for zero + zero
|
||||
if (bAbs == 0) {
|
||||
return @bitCast(T, @bitCast(Z, a) & @bitCast(Z, b));
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
// anything + zero = anything
|
||||
if (bAbs == 0) return a;
|
||||
}
|
||||
|
||||
// Swap a and b if necessary so that a has the larger absolute value.
|
||||
if (bAbs > aAbs) {
|
||||
const temp = aRep;
|
||||
aRep = bRep;
|
||||
bRep = temp;
|
||||
}
|
||||
|
||||
// Extract the exponent and significand from the (possibly swapped) a and b.
|
||||
var aExponent = @intCast(i32, (aRep >> significandBits) & maxExponent);
|
||||
var bExponent = @intCast(i32, (bRep >> significandBits) & maxExponent);
|
||||
var aSignificand = aRep & significandMask;
|
||||
var bSignificand = bRep & significandMask;
|
||||
|
||||
// Normalize any denormals, and adjust the exponent accordingly.
|
||||
if (aExponent == 0) aExponent = normalize(T, &aSignificand);
|
||||
if (bExponent == 0) bExponent = normalize(T, &bSignificand);
|
||||
|
||||
// The sign of the result is the sign of the larger operand, a. If they
|
||||
// have opposite signs, we are performing a subtraction; otherwise addition.
|
||||
const resultSign = aRep & signBit;
|
||||
const subtraction = (aRep ^ bRep) & signBit != 0;
|
||||
|
||||
// Shift the significands to give us round, guard and sticky, and or in the
|
||||
// implicit significand bit. (If we fell through from the denormal path it
|
||||
// was already set by normalize( ), but setting it twice won't hurt
|
||||
// anything.)
|
||||
aSignificand = (aSignificand | integerBit) << 3;
|
||||
bSignificand = (bSignificand | integerBit) << 3;
|
||||
|
||||
// Shift the significand of b by the difference in exponents, with a sticky
|
||||
// bottom bit to get rounding correct.
|
||||
const @"align" = @intCast(u32, aExponent - bExponent);
|
||||
if (@"align" != 0) {
|
||||
if (@"align" < typeWidth) {
|
||||
const sticky = if (bSignificand << @intCast(S, typeWidth - @"align") != 0) @as(Z, 1) else 0;
|
||||
bSignificand = (bSignificand >> @truncate(S, @"align")) | sticky;
|
||||
} else {
|
||||
bSignificand = 1; // sticky; b is known to be non-zero.
|
||||
}
|
||||
}
|
||||
if (subtraction) {
|
||||
aSignificand -= bSignificand;
|
||||
// If a == -b, return +zero.
|
||||
if (aSignificand == 0) return @bitCast(T, @as(Z, 0));
|
||||
|
||||
// If partial cancellation occured, we need to left-shift the result
|
||||
// and adjust the exponent:
|
||||
if (aSignificand < integerBit << 3) {
|
||||
const shift = @intCast(i32, @clz(aSignificand)) - @intCast(i32, @clz(integerBit << 3));
|
||||
aSignificand <<= @intCast(S, shift);
|
||||
aExponent -= shift;
|
||||
}
|
||||
} else { // addition
|
||||
aSignificand += bSignificand;
|
||||
|
||||
// If the addition carried up, we need to right-shift the result and
|
||||
// adjust the exponent:
|
||||
if (aSignificand & (integerBit << 4) != 0) {
|
||||
const sticky = aSignificand & 1;
|
||||
aSignificand = aSignificand >> 1 | sticky;
|
||||
aExponent += 1;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have overflowed the type, return +/- infinity:
|
||||
if (aExponent >= maxExponent) return @bitCast(T, infRep | resultSign);
|
||||
|
||||
if (aExponent <= 0) {
|
||||
// Result is denormal; the exponent and round/sticky bits are zero.
|
||||
// All we need to do is shift the significand and apply the correct sign.
|
||||
aSignificand >>= @intCast(S, 4 - aExponent);
|
||||
return @bitCast(T, resultSign | aSignificand);
|
||||
}
|
||||
|
||||
// Low three bits are round, guard, and sticky.
|
||||
const roundGuardSticky = aSignificand & 0x7;
|
||||
|
||||
// Shift the significand into place, and mask off the integer bit, if it's implicit.
|
||||
var result = (aSignificand >> 3) & significandMask;
|
||||
|
||||
// Insert the exponent and sign.
|
||||
result |= @intCast(Z, aExponent) << significandBits;
|
||||
result |= resultSign;
|
||||
|
||||
// Final rounding. The result may overflow to infinity, but that is the
|
||||
// correct result in that case.
|
||||
if (roundGuardSticky > 0x4) result += 1;
|
||||
if (roundGuardSticky == 0x4) result += result & 1;
|
||||
|
||||
// Restore any explicit integer bit, if it was rounded off
|
||||
if (significandBits != fractionalBits) {
|
||||
if ((result >> significandBits) != 0) result |= integerBit;
|
||||
}
|
||||
|
||||
return @bitCast(T, result);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("addf3_test.zig");
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
// Ported from:
|
||||
//
|
||||
// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/test/builtins/Unit/addtf3_test.c
|
||||
// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/test/builtins/Unit/subtf3_test.c
|
||||
|
||||
const std = @import("std");
|
||||
const math = std.math;
|
||||
const qnan128 = @bitCast(f128, @as(u128, 0x7fff800000000000) << 64);
|
||||
|
||||
const __addtf3 = @import("addtf3.zig").__addtf3;
|
||||
const __addxf3 = @import("addxf3.zig").__addxf3;
|
||||
const __subtf3 = @import("subtf3.zig").__subtf3;
|
||||
|
||||
fn test__addtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) !void {
|
||||
const x = __addtf3(a, b);
|
||||
|
||||
const rep = @bitCast(u128, x);
|
||||
const hi = @intCast(u64, rep >> 64);
|
||||
const lo = @truncate(u64, rep);
|
||||
|
||||
if (hi == expected_hi and lo == expected_lo) {
|
||||
return;
|
||||
}
|
||||
// test other possible NaN representation (signal NaN)
|
||||
else if (expected_hi == 0x7fff800000000000 and expected_lo == 0x0) {
|
||||
if ((hi & 0x7fff000000000000) == 0x7fff000000000000 and
|
||||
((hi & 0xffffffffffff) > 0 or lo > 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return error.TestFailed;
|
||||
}
|
||||
|
||||
test "addtf3" {
|
||||
try test__addtf3(qnan128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
|
||||
|
||||
// NaN + any = NaN
|
||||
try test__addtf3(@bitCast(f128, (@as(u128, 0x7fff000000000000) << 64) | @as(u128, 0x800030000000)), 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
|
||||
|
||||
// inf + inf = inf
|
||||
try test__addtf3(math.inf(f128), math.inf(f128), 0x7fff000000000000, 0x0);
|
||||
|
||||
// inf + any = inf
|
||||
try test__addtf3(math.inf(f128), 0x1.2335653452436234723489432abcdefp+5, 0x7fff000000000000, 0x0);
|
||||
|
||||
// any + any
|
||||
try test__addtf3(0x1.23456734245345543849abcdefp+5, 0x1.edcba52449872455634654321fp-1, 0x40042afc95c8b579, 0x61e58dd6c51eb77c);
|
||||
try test__addtf3(0x1.edcba52449872455634654321fp-1, 0x1.23456734245345543849abcdefp+5, 0x40042afc95c8b579, 0x61e58dd6c51eb77c);
|
||||
}
|
||||
|
||||
fn test__subtf3(a: f128, b: f128, expected_hi: u64, expected_lo: u64) !void {
|
||||
const x = __subtf3(a, b);
|
||||
|
||||
const rep = @bitCast(u128, x);
|
||||
const hi = @intCast(u64, rep >> 64);
|
||||
const lo = @truncate(u64, rep);
|
||||
|
||||
if (hi == expected_hi and lo == expected_lo) {
|
||||
return;
|
||||
}
|
||||
// test other possible NaN representation (signal NaN)
|
||||
else if (expected_hi == 0x7fff800000000000 and expected_lo == 0x0) {
|
||||
if ((hi & 0x7fff000000000000) == 0x7fff000000000000 and
|
||||
((hi & 0xffffffffffff) > 0 or lo > 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return error.TestFailed;
|
||||
}
|
||||
|
||||
test "subtf3" {
|
||||
// qNaN - any = qNaN
|
||||
try test__subtf3(qnan128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
|
||||
|
||||
// NaN + any = NaN
|
||||
try test__subtf3(@bitCast(f128, (@as(u128, 0x7fff000000000000) << 64) | @as(u128, 0x800030000000)), 0x1.23456789abcdefp+5, 0x7fff800000000000, 0x0);
|
||||
|
||||
// inf - any = inf
|
||||
try test__subtf3(math.inf(f128), 0x1.23456789abcdefp+5, 0x7fff000000000000, 0x0);
|
||||
|
||||
// any + any
|
||||
try test__subtf3(0x1.234567829a3bcdef5678ade36734p+5, 0x1.ee9d7c52354a6936ab8d7654321fp-1, 0x40041b8af1915166, 0xa44a7bca780a166c);
|
||||
try test__subtf3(0x1.ee9d7c52354a6936ab8d7654321fp-1, 0x1.234567829a3bcdef5678ade36734p+5, 0xc0041b8af1915166, 0xa44a7bca780a166c);
|
||||
}
|
||||
|
||||
const qnan80 = @bitCast(f80, @bitCast(u80, math.nan(f80)) | (1 << (math.floatFractionalBits(f80) - 1)));
|
||||
|
||||
fn test__addxf3(a: f80, b: f80, expected: u80) !void {
|
||||
const x = __addxf3(a, b);
|
||||
const rep = @bitCast(u80, x);
|
||||
|
||||
if (rep == expected)
|
||||
return;
|
||||
|
||||
if (math.isNan(@bitCast(f80, expected)) and math.isNan(x))
|
||||
return; // We don't currently test NaN payload propagation
|
||||
|
||||
return error.TestFailed;
|
||||
}
|
||||
|
||||
test "addxf3" {
|
||||
// NaN + any = NaN
|
||||
try test__addxf3(qnan80, 0x1.23456789abcdefp+5, @bitCast(u80, qnan80));
|
||||
try test__addxf3(@bitCast(f80, @as(u80, 0x7fff_8000_8000_3000_0000)), 0x1.23456789abcdefp+5, @bitCast(u80, qnan80));
|
||||
|
||||
// any + NaN = NaN
|
||||
try test__addxf3(0x1.23456789abcdefp+5, qnan80, @bitCast(u80, qnan80));
|
||||
try test__addxf3(0x1.23456789abcdefp+5, @bitCast(f80, @as(u80, 0x7fff_8000_8000_3000_0000)), @bitCast(u80, qnan80));
|
||||
|
||||
// NaN + inf = NaN
|
||||
try test__addxf3(qnan80, math.inf(f80), @bitCast(u80, qnan80));
|
||||
|
||||
// inf + NaN = NaN
|
||||
try test__addxf3(math.inf(f80), qnan80, @bitCast(u80, qnan80));
|
||||
|
||||
// inf + inf = inf
|
||||
try test__addxf3(math.inf(f80), math.inf(f80), @bitCast(u80, math.inf(f80)));
|
||||
|
||||
// inf + -inf = NaN
|
||||
try test__addxf3(math.inf(f80), -math.inf(f80), @bitCast(u80, qnan80));
|
||||
|
||||
// -inf + inf = NaN
|
||||
try test__addxf3(-math.inf(f80), math.inf(f80), @bitCast(u80, qnan80));
|
||||
|
||||
// inf + any = inf
|
||||
try test__addxf3(math.inf(f80), 0x1.2335653452436234723489432abcdefp+5, @bitCast(u80, math.inf(f80)));
|
||||
|
||||
// any + inf = inf
|
||||
try test__addxf3(0x1.2335653452436234723489432abcdefp+5, math.inf(f80), @bitCast(u80, math.inf(f80)));
|
||||
|
||||
// any + any
|
||||
try test__addxf3(0x1.23456789abcdp+5, 0x1.dcba987654321p+5, 0x4005_BFFFFFFFFFFFC400);
|
||||
try test__addxf3(0x1.23456734245345543849abcdefp+5, 0x1.edcba52449872455634654321fp-1, 0x4004_957E_4AE4_5ABC_B0F3);
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x1.0p-63, 0x3FFF_FFFFFFFFFFFFFFFF); // exact
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffep+0, 0x0.0p0, 0x3FFF_FFFFFFFFFFFFFFFF); // exact
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x1.4p-63, 0x3FFF_FFFFFFFFFFFFFFFF); // round down
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x1.8p-63, 0x4000_8000000000000000); // round up to even
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x1.cp-63, 0x4000_8000000000000000); // round up
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x2.0p-63, 0x4000_8000000000000000); // exact
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x2.1p-63, 0x4000_8000000000000000); // round down
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x3.0p-63, 0x4000_8000000000000000); // round down to even
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x3.1p-63, 0x4000_8000000000000001); // round up
|
||||
try test__addxf3(0x1.ffff_ffff_ffff_fffcp+0, 0x4.0p-63, 0x4000_8000000000000001); // exact
|
||||
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x1.0p-63, 0x3FFF_8800000000000000); // exact
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x1.7p-63, 0x3FFF_8800000000000000); // round down
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x1.8p-63, 0x3FFF_8800000000000000); // round down to even
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x1.9p-63, 0x3FFF_8800000000000001); // round up
|
||||
try test__addxf3(0x1.0fff_ffff_ffff_fffep+0, 0x2.0p-63, 0x3FFF_8800000000000001); // exact
|
||||
try test__addxf3(0x0.ffff_ffff_ffff_fffcp-16382, 0x0.0000_0000_0000_0002p-16382, 0x0000_7FFFFFFFFFFFFFFF); // exact
|
||||
try test__addxf3(0x0.1fff_ffff_ffff_fffcp-16382, 0x0.0000_0000_0000_0002p-16382, 0x0000_0FFFFFFFFFFFFFFF); // exact
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__addhf3, .{ .name = "__addhf3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
fn __addhf3(a: f16, b: f16) callconv(.C) f16 {
|
||||
return addf3(f16, a, b);
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
|
||||
pub const panic = @import("common.zig").panic;
|
||||
|
||||
comptime {
|
||||
@export(__addosi4, .{ .name = "__addosi4", .linkage = linkage });
|
||||
@export(__addodi4, .{ .name = "__addodi4", .linkage = linkage });
|
||||
@export(__addoti4, .{ .name = "__addoti4", .linkage = linkage });
|
||||
}
|
||||
|
||||
// addo - add overflow
|
||||
// * return a+%b.
|
||||
// * return if a+b overflows => 1 else => 0
|
||||
// - addoXi4_generic as default
|
||||
|
||||
inline fn addoXi4_generic(comptime ST: type, a: ST, b: ST, overflow: *c_int) ST {
|
||||
@setRuntimeSafety(builtin.is_test);
|
||||
overflow.* = 0;
|
||||
var sum: ST = a +% b;
|
||||
// Hackers Delight: section Overflow Detection, subsection Signed Add/Subtract
|
||||
// Let sum = a +% b == a + b + carry == wraparound addition.
|
||||
// Overflow in a+b+carry occurs, iff a and b have opposite signs
|
||||
// and the sign of a+b+carry is the same as a (or equivalently b).
|
||||
// Slower routine: res = ~(a ^ b) & ((sum ^ a)
|
||||
// Faster routine: res = (sum ^ a) & (sum ^ b)
|
||||
// Overflow occured, iff (res < 0)
|
||||
if (((sum ^ a) & (sum ^ b)) < 0)
|
||||
overflow.* = 1;
|
||||
return sum;
|
||||
}
|
||||
|
||||
pub fn __addosi4(a: i32, b: i32, overflow: *c_int) callconv(.C) i32 {
|
||||
return addoXi4_generic(i32, a, b, overflow);
|
||||
}
|
||||
pub fn __addodi4(a: i64, b: i64, overflow: *c_int) callconv(.C) i64 {
|
||||
return addoXi4_generic(i64, a, b, overflow);
|
||||
}
|
||||
pub fn __addoti4(a: i128, b: i128, overflow: *c_int) callconv(.C) i128 {
|
||||
return addoXi4_generic(i128, a, b, overflow);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("addosi4_test.zig");
|
||||
_ = @import("addodi4_test.zig");
|
||||
_ = @import("addoti4_test.zig");
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
const addv = @import("addo.zig");
|
||||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const math = std.math;
|
||||
|
||||
fn test__addodi4(a: i64, b: i64) !void {
|
||||
var result_ov: c_int = undefined;
|
||||
var expected_ov: c_int = undefined;
|
||||
var result = addv.__addodi4(a, b, &result_ov);
|
||||
var expected: i64 = simple_addodi4(a, b, &expected_ov);
|
||||
try testing.expectEqual(expected, result);
|
||||
try testing.expectEqual(expected_ov, result_ov);
|
||||
}
|
||||
|
||||
fn simple_addodi4(a: i64, b: i64, overflow: *c_int) i64 {
|
||||
overflow.* = 0;
|
||||
const min: i64 = math.minInt(i64);
|
||||
const max: i64 = math.maxInt(i64);
|
||||
if (((a > 0) and (b > max - a)) or
|
||||
((a < 0) and (b < min - a)))
|
||||
overflow.* = 1;
|
||||
return a +% b;
|
||||
}
|
||||
|
||||
test "addodi4" {
|
||||
const min: i64 = math.minInt(i64);
|
||||
const max: i64 = math.maxInt(i64);
|
||||
var i: i64 = 1;
|
||||
while (i < max) : (i *|= 2) {
|
||||
try test__addodi4(i, i);
|
||||
try test__addodi4(-i, -i);
|
||||
try test__addodi4(i, -i);
|
||||
try test__addodi4(-i, i);
|
||||
}
|
||||
|
||||
// edge cases
|
||||
// 0 + 0 = 0
|
||||
// MIN + MIN overflow
|
||||
// MAX + MAX overflow
|
||||
// 0 + MIN MIN
|
||||
// 0 + MAX MAX
|
||||
// MIN + 0 MIN
|
||||
// MAX + 0 MAX
|
||||
// MIN + MAX -1
|
||||
// MAX + MIN -1
|
||||
try test__addodi4(0, 0);
|
||||
try test__addodi4(min, min);
|
||||
try test__addodi4(max, max);
|
||||
try test__addodi4(0, min);
|
||||
try test__addodi4(0, max);
|
||||
try test__addodi4(min, 0);
|
||||
try test__addodi4(max, 0);
|
||||
try test__addodi4(min, max);
|
||||
try test__addodi4(max, min);
|
||||
|
||||
// derived edge cases
|
||||
// MIN+1 + MIN overflow
|
||||
// MAX-1 + MAX overflow
|
||||
// 1 + MIN = MIN+1
|
||||
// -1 + MIN overflow
|
||||
// -1 + MAX = MAX-1
|
||||
// +1 + MAX overflow
|
||||
// MIN + 1 = MIN+1
|
||||
// MIN + -1 overflow
|
||||
// MAX + 1 overflow
|
||||
// MAX + -1 = MAX-1
|
||||
try test__addodi4(min + 1, min);
|
||||
try test__addodi4(max - 1, max);
|
||||
try test__addodi4(1, min);
|
||||
try test__addodi4(-1, min);
|
||||
try test__addodi4(-1, max);
|
||||
try test__addodi4(1, max);
|
||||
try test__addodi4(min, 1);
|
||||
try test__addodi4(min, -1);
|
||||
try test__addodi4(max, -1);
|
||||
try test__addodi4(max, 1);
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
const addv = @import("addo.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__addosi4(a: i32, b: i32) !void {
|
||||
var result_ov: c_int = undefined;
|
||||
var expected_ov: c_int = undefined;
|
||||
var result = addv.__addosi4(a, b, &result_ov);
|
||||
var expected: i32 = simple_addosi4(a, b, &expected_ov);
|
||||
try testing.expectEqual(expected, result);
|
||||
try testing.expectEqual(expected_ov, result_ov);
|
||||
}
|
||||
|
||||
fn simple_addosi4(a: i32, b: i32, overflow: *c_int) i32 {
|
||||
overflow.* = 0;
|
||||
const min: i32 = -2147483648;
|
||||
const max: i32 = 2147483647;
|
||||
if (((a > 0) and (b > max - a)) or
|
||||
((a < 0) and (b < min - a)))
|
||||
overflow.* = 1;
|
||||
return a +% b;
|
||||
}
|
||||
|
||||
test "addosi4" {
|
||||
// -2^31 <= i32 <= 2^31-1
|
||||
// 2^31 = 2147483648
|
||||
// 2^31-1 = 2147483647
|
||||
const min: i32 = -2147483648;
|
||||
const max: i32 = 2147483647;
|
||||
var i: i32 = 1;
|
||||
while (i < max) : (i *|= 2) {
|
||||
try test__addosi4(i, i);
|
||||
try test__addosi4(-i, -i);
|
||||
try test__addosi4(i, -i);
|
||||
try test__addosi4(-i, i);
|
||||
}
|
||||
|
||||
// edge cases
|
||||
// 0 + 0 = 0
|
||||
// MIN + MIN overflow
|
||||
// MAX + MAX overflow
|
||||
// 0 + MIN MIN
|
||||
// 0 + MAX MAX
|
||||
// MIN + 0 MIN
|
||||
// MAX + 0 MAX
|
||||
// MIN + MAX -1
|
||||
// MAX + MIN -1
|
||||
try test__addosi4(0, 0);
|
||||
try test__addosi4(min, min);
|
||||
try test__addosi4(max, max);
|
||||
try test__addosi4(0, min);
|
||||
try test__addosi4(0, max);
|
||||
try test__addosi4(min, 0);
|
||||
try test__addosi4(max, 0);
|
||||
try test__addosi4(min, max);
|
||||
try test__addosi4(max, min);
|
||||
|
||||
// derived edge cases
|
||||
// MIN+1 + MIN overflow
|
||||
// MAX-1 + MAX overflow
|
||||
// 1 + MIN = MIN+1
|
||||
// -1 + MIN overflow
|
||||
// -1 + MAX = MAX-1
|
||||
// +1 + MAX overflow
|
||||
// MIN + 1 = MIN+1
|
||||
// MIN + -1 overflow
|
||||
// MAX + 1 overflow
|
||||
// MAX + -1 = MAX-1
|
||||
try test__addosi4(min + 1, min);
|
||||
try test__addosi4(max - 1, max);
|
||||
try test__addosi4(1, min);
|
||||
try test__addosi4(-1, min);
|
||||
try test__addosi4(-1, max);
|
||||
try test__addosi4(1, max);
|
||||
try test__addosi4(min, 1);
|
||||
try test__addosi4(min, -1);
|
||||
try test__addosi4(max, -1);
|
||||
try test__addosi4(max, 1);
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
const addv = @import("addo.zig");
|
||||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const math = std.math;
|
||||
|
||||
fn test__addoti4(a: i128, b: i128) !void {
|
||||
var result_ov: c_int = undefined;
|
||||
var expected_ov: c_int = undefined;
|
||||
var result = addv.__addoti4(a, b, &result_ov);
|
||||
var expected: i128 = simple_addoti4(a, b, &expected_ov);
|
||||
try testing.expectEqual(expected, result);
|
||||
try testing.expectEqual(expected_ov, result_ov);
|
||||
}
|
||||
|
||||
fn simple_addoti4(a: i128, b: i128, overflow: *c_int) i128 {
|
||||
overflow.* = 0;
|
||||
const min: i128 = math.minInt(i128);
|
||||
const max: i128 = math.maxInt(i128);
|
||||
if (((a > 0) and (b > max - a)) or
|
||||
((a < 0) and (b < min - a)))
|
||||
overflow.* = 1;
|
||||
return a +% b;
|
||||
}
|
||||
|
||||
test "addoti4" {
|
||||
const min: i128 = math.minInt(i128);
|
||||
const max: i128 = math.maxInt(i128);
|
||||
var i: i128 = 1;
|
||||
while (i < max) : (i *|= 2) {
|
||||
try test__addoti4(i, i);
|
||||
try test__addoti4(-i, -i);
|
||||
try test__addoti4(i, -i);
|
||||
try test__addoti4(-i, i);
|
||||
}
|
||||
|
||||
// edge cases
|
||||
// 0 + 0 = 0
|
||||
// MIN + MIN overflow
|
||||
// MAX + MAX overflow
|
||||
// 0 + MIN MIN
|
||||
// 0 + MAX MAX
|
||||
// MIN + 0 MIN
|
||||
// MAX + 0 MAX
|
||||
// MIN + MAX -1
|
||||
// MAX + MIN -1
|
||||
try test__addoti4(0, 0);
|
||||
try test__addoti4(min, min);
|
||||
try test__addoti4(max, max);
|
||||
try test__addoti4(0, min);
|
||||
try test__addoti4(0, max);
|
||||
try test__addoti4(min, 0);
|
||||
try test__addoti4(max, 0);
|
||||
try test__addoti4(min, max);
|
||||
try test__addoti4(max, min);
|
||||
|
||||
// derived edge cases
|
||||
// MIN+1 + MIN overflow
|
||||
// MAX-1 + MAX overflow
|
||||
// 1 + MIN = MIN+1
|
||||
// -1 + MIN overflow
|
||||
// -1 + MAX = MAX-1
|
||||
// +1 + MAX overflow
|
||||
// MIN + 1 = MIN+1
|
||||
// MIN + -1 overflow
|
||||
// MAX + 1 overflow
|
||||
// MAX + -1 = MAX-1
|
||||
try test__addoti4(min + 1, min);
|
||||
try test__addoti4(max - 1, max);
|
||||
try test__addoti4(1, min);
|
||||
try test__addoti4(-1, min);
|
||||
try test__addoti4(-1, max);
|
||||
try test__addoti4(1, max);
|
||||
try test__addoti4(min, 1);
|
||||
try test__addoti4(min, -1);
|
||||
try test__addoti4(max, -1);
|
||||
try test__addoti4(max, 1);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_aeabi) {
|
||||
@export(__aeabi_fadd, .{ .name = "__aeabi_fadd", .linkage = common.linkage });
|
||||
} else {
|
||||
@export(__addsf3, .{ .name = "__addsf3", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
fn __addsf3(a: f32, b: f32) callconv(.C) f32 {
|
||||
return addf3(f32, a, b);
|
||||
}
|
||||
|
||||
fn __aeabi_fadd(a: f32, b: f32) callconv(.AAPCS) f32 {
|
||||
return addf3(f32, a, b);
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_ppc_abi) {
|
||||
@export(__addtf3, .{ .name = "__addkf3", .linkage = common.linkage });
|
||||
} else if (common.want_sparc_abi) {
|
||||
@export(_Qp_add, .{ .name = "_Qp_add", .linkage = common.linkage });
|
||||
}
|
||||
@export(__addtf3, .{ .name = "__addtf3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __addtf3(a: f128, b: f128) callconv(.C) f128 {
|
||||
return addf3(f128, a, b);
|
||||
}
|
||||
|
||||
fn _Qp_add(c: *f128, a: *f128, b: *f128) callconv(.C) void {
|
||||
c.* = addf3(f128, a.*, b.*);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const addf3 = @import("./addf3.zig").addf3;
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__addxf3, .{ .name = "__addxf3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __addxf3(a: f80, b: f80) callconv(.C) f80 {
|
||||
return addf3(f80, a, b);
|
||||
}
|
||||
@@ -1,188 +0,0 @@
|
||||
// ARM specific builtins
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const arch = builtin.cpu.arch;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (!builtin.is_test) {
|
||||
if (arch.isARM() or arch.isThumb()) {
|
||||
@export(__aeabi_unwind_cpp_pr0, .{ .name = "__aeabi_unwind_cpp_pr0", .linkage = common.linkage });
|
||||
@export(__aeabi_unwind_cpp_pr1, .{ .name = "__aeabi_unwind_cpp_pr1", .linkage = common.linkage });
|
||||
@export(__aeabi_unwind_cpp_pr2, .{ .name = "__aeabi_unwind_cpp_pr2", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_ldivmod, .{ .name = "__aeabi_ldivmod", .linkage = common.linkage });
|
||||
@export(__aeabi_uldivmod, .{ .name = "__aeabi_uldivmod", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_idivmod, .{ .name = "__aeabi_idivmod", .linkage = common.linkage });
|
||||
@export(__aeabi_uidivmod, .{ .name = "__aeabi_uidivmod", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_memcpy, .{ .name = "__aeabi_memcpy", .linkage = common.linkage });
|
||||
@export(__aeabi_memcpy4, .{ .name = "__aeabi_memcpy4", .linkage = common.linkage });
|
||||
@export(__aeabi_memcpy8, .{ .name = "__aeabi_memcpy8", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_memmove, .{ .name = "__aeabi_memmove", .linkage = common.linkage });
|
||||
@export(__aeabi_memmove4, .{ .name = "__aeabi_memmove4", .linkage = common.linkage });
|
||||
@export(__aeabi_memmove8, .{ .name = "__aeabi_memmove8", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_memset, .{ .name = "__aeabi_memset", .linkage = common.linkage });
|
||||
@export(__aeabi_memset4, .{ .name = "__aeabi_memset4", .linkage = common.linkage });
|
||||
@export(__aeabi_memset8, .{ .name = "__aeabi_memset8", .linkage = common.linkage });
|
||||
|
||||
@export(__aeabi_memclr, .{ .name = "__aeabi_memclr", .linkage = common.linkage });
|
||||
@export(__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage });
|
||||
@export(__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage });
|
||||
|
||||
if (builtin.os.tag == .linux) {
|
||||
@export(__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const __divmodsi4 = @import("int.zig").__divmodsi4;
|
||||
const __udivmodsi4 = @import("int.zig").__udivmodsi4;
|
||||
const __divmoddi4 = @import("int.zig").__divmoddi4;
|
||||
const __udivmoddi4 = @import("int.zig").__udivmoddi4;
|
||||
|
||||
extern fn memset(dest: ?[*]u8, c: u8, n: usize) ?[*]u8;
|
||||
extern fn memcpy(noalias dest: ?[*]u8, noalias src: ?[*]const u8, n: usize) ?[*]u8;
|
||||
extern fn memmove(dest: ?[*]u8, src: ?[*]const u8, n: usize) ?[*]u8;
|
||||
|
||||
pub fn __aeabi_memcpy(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memcpy(dest, src, n);
|
||||
}
|
||||
pub fn __aeabi_memcpy4(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memcpy(dest, src, n);
|
||||
}
|
||||
pub fn __aeabi_memcpy8(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
pub fn __aeabi_memmove(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memmove(dest, src, n);
|
||||
}
|
||||
pub fn __aeabi_memmove4(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memmove(dest, src, n);
|
||||
}
|
||||
pub fn __aeabi_memmove8(dest: [*]u8, src: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memmove(dest, src, n);
|
||||
}
|
||||
|
||||
pub fn __aeabi_memset(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
// This is dentical to the standard `memset` definition but with the last
|
||||
// two arguments swapped
|
||||
_ = memset(dest, c, n);
|
||||
}
|
||||
pub fn __aeabi_memset4(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, c, n);
|
||||
}
|
||||
pub fn __aeabi_memset8(dest: [*]u8, n: usize, c: u8) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, c, n);
|
||||
}
|
||||
|
||||
pub fn __aeabi_memclr(dest: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, 0, n);
|
||||
}
|
||||
pub fn __aeabi_memclr4(dest: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, 0, n);
|
||||
}
|
||||
pub fn __aeabi_memclr8(dest: [*]u8, n: usize) callconv(.AAPCS) void {
|
||||
@setRuntimeSafety(false);
|
||||
_ = memset(dest, 0, n);
|
||||
}
|
||||
|
||||
// Dummy functions to avoid errors during the linking phase
|
||||
pub fn __aeabi_unwind_cpp_pr0() callconv(.AAPCS) void {}
|
||||
pub fn __aeabi_unwind_cpp_pr1() callconv(.AAPCS) void {}
|
||||
pub fn __aeabi_unwind_cpp_pr2() callconv(.AAPCS) void {}
|
||||
|
||||
// This function can only clobber r0 according to the ABI
|
||||
pub fn __aeabi_read_tp() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
asm volatile (
|
||||
\\ mrc p15, 0, r0, c13, c0, 3
|
||||
\\ bx lr
|
||||
);
|
||||
unreachable;
|
||||
}
|
||||
|
||||
// The following functions are wrapped in an asm block to ensure the required
|
||||
// calling convention is always respected
|
||||
|
||||
pub fn __aeabi_uidivmod() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
// Divide r0 by r1; the quotient goes in r0, the remainder in r1
|
||||
asm volatile (
|
||||
\\ push {lr}
|
||||
\\ sub sp, #4
|
||||
\\ mov r2, sp
|
||||
\\ bl __udivmodsi4
|
||||
\\ ldr r1, [sp]
|
||||
\\ add sp, #4
|
||||
\\ pop {pc}
|
||||
::: "memory");
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub fn __aeabi_uldivmod() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
// Divide r1:r0 by r3:r2; the quotient goes in r1:r0, the remainder in r3:r2
|
||||
asm volatile (
|
||||
\\ push {r4, lr}
|
||||
\\ sub sp, #16
|
||||
\\ add r4, sp, #8
|
||||
\\ str r4, [sp]
|
||||
\\ bl __udivmoddi4
|
||||
\\ ldr r2, [sp, #8]
|
||||
\\ ldr r3, [sp, #12]
|
||||
\\ add sp, #16
|
||||
\\ pop {r4, pc}
|
||||
::: "memory");
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub fn __aeabi_idivmod() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
// Divide r0 by r1; the quotient goes in r0, the remainder in r1
|
||||
asm volatile (
|
||||
\\ push {lr}
|
||||
\\ sub sp, #4
|
||||
\\ mov r2, sp
|
||||
\\ bl __divmodsi4
|
||||
\\ ldr r1, [sp]
|
||||
\\ add sp, #4
|
||||
\\ pop {pc}
|
||||
::: "memory");
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub fn __aeabi_ldivmod() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
// Divide r1:r0 by r3:r2; the quotient goes in r1:r0, the remainder in r3:r2
|
||||
asm volatile (
|
||||
\\ push {r4, lr}
|
||||
\\ sub sp, #16
|
||||
\\ add r4, sp, #8
|
||||
\\ str r4, [sp]
|
||||
\\ bl __divmoddi4
|
||||
\\ ldr r2, [sp, #8]
|
||||
\\ ldr r3, [sp, #12]
|
||||
\\ add sp, #16
|
||||
\\ pop {r4, pc}
|
||||
::: "memory");
|
||||
unreachable;
|
||||
}
|
||||
@@ -1,512 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const cpu = builtin.cpu;
|
||||
const arch = cpu.arch;
|
||||
const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
|
||||
pub const panic = @import("common.zig").panic;
|
||||
|
||||
// This parameter is true iff the target architecture supports the bare minimum
|
||||
// to implement the atomic load/store intrinsics.
|
||||
// Some architectures support atomic load/stores but no CAS, but we ignore this
|
||||
// detail to keep the export logic clean and because we need some kind of CAS to
|
||||
// implement the spinlocks.
|
||||
const supports_atomic_ops = switch (arch) {
|
||||
.msp430, .avr, .bpfel, .bpfeb => false,
|
||||
.arm, .armeb, .thumb, .thumbeb =>
|
||||
// The ARM v6m ISA has no ldrex/strex and so it's impossible to do CAS
|
||||
// operations (unless we're targeting Linux, the kernel provides a way to
|
||||
// perform CAS operations).
|
||||
// XXX: The Linux code path is not implemented yet.
|
||||
!std.Target.arm.featureSetHas(builtin.cpu.features, .has_v6m),
|
||||
else => true,
|
||||
};
|
||||
|
||||
// The size (in bytes) of the biggest object that the architecture can
|
||||
// load/store atomically.
|
||||
// Objects bigger than this threshold require the use of a lock.
|
||||
const largest_atomic_size = switch (arch) {
|
||||
// On SPARC systems that lacks CAS and/or swap instructions, the only
|
||||
// available atomic operation is a test-and-set (`ldstub`), so we force
|
||||
// every atomic memory access to go through the lock.
|
||||
.sparc, .sparcel => if (cpu.features.featureSetHas(.hasleoncasa)) @sizeOf(usize) else 0,
|
||||
|
||||
// XXX: On x86/x86_64 we could check the presence of cmpxchg8b/cmpxchg16b
|
||||
// and set this parameter accordingly.
|
||||
else => @sizeOf(usize),
|
||||
};
|
||||
|
||||
// The size (in bytes) of the smallest atomic object that the architecture can
|
||||
// perform fetch/exchange atomically. Note, this does not encompass load and store.
|
||||
// Objects smaller than this threshold are implemented in terms of compare-exchange
|
||||
// of a larger value.
|
||||
const smallest_atomic_fetch_exch_size = switch (arch) {
|
||||
// On AMDGPU, there are no instructions for atomic operations other than load and store
|
||||
// (as of LLVM 15), and so these need to be implemented in terms of atomic CAS.
|
||||
.amdgcn => @sizeOf(u32),
|
||||
else => @sizeOf(u8),
|
||||
};
|
||||
|
||||
const cache_line_size = 64;
|
||||
|
||||
const SpinlockTable = struct {
|
||||
// Allocate ~4096 bytes of memory for the spinlock table
|
||||
const max_spinlocks = 64;
|
||||
|
||||
const Spinlock = struct {
|
||||
// SPARC ldstub instruction will write a 255 into the memory location.
|
||||
// We'll use that as a sign that the lock is currently held.
|
||||
// See also: Section B.7 in SPARCv8 spec & A.29 in SPARCv9 spec.
|
||||
const sparc_lock: type = enum(u8) { Unlocked = 0, Locked = 255 };
|
||||
const other_lock: type = enum(usize) { Unlocked = 0, Locked };
|
||||
|
||||
// Prevent false sharing by providing enough padding between two
|
||||
// consecutive spinlock elements
|
||||
v: if (arch.isSPARC()) sparc_lock else other_lock align(cache_line_size) = .Unlocked,
|
||||
|
||||
fn acquire(self: *@This()) void {
|
||||
while (true) {
|
||||
const flag = if (comptime arch.isSPARC()) flag: {
|
||||
break :flag asm volatile ("ldstub [%[addr]], %[flag]"
|
||||
: [flag] "=r" (-> @TypeOf(self.v)),
|
||||
: [addr] "r" (&self.v),
|
||||
: "memory"
|
||||
);
|
||||
} else flag: {
|
||||
break :flag @atomicRmw(@TypeOf(self.v), &self.v, .Xchg, .Locked, .Acquire);
|
||||
};
|
||||
|
||||
switch (flag) {
|
||||
.Unlocked => break,
|
||||
.Locked => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
fn release(self: *@This()) void {
|
||||
if (comptime arch.isSPARC()) {
|
||||
_ = asm volatile ("clrb [%[addr]]"
|
||||
:
|
||||
: [addr] "r" (&self.v),
|
||||
: "memory"
|
||||
);
|
||||
} else {
|
||||
@atomicStore(@TypeOf(self.v), &self.v, .Unlocked, .Release);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
list: [max_spinlocks]Spinlock = [_]Spinlock{.{}} ** max_spinlocks,
|
||||
|
||||
// The spinlock table behaves as a really simple hash table, mapping
|
||||
// addresses to spinlocks. The mapping is not unique but that's only a
|
||||
// performance problem as the lock will be contended by more than a pair of
|
||||
// threads.
|
||||
fn get(self: *@This(), address: usize) *Spinlock {
|
||||
var sl = &self.list[(address >> 3) % max_spinlocks];
|
||||
sl.acquire();
|
||||
return sl;
|
||||
}
|
||||
};
|
||||
|
||||
var spinlocks: SpinlockTable = SpinlockTable{};
|
||||
|
||||
// The following builtins do not respect the specified memory model and instead
|
||||
// uses seq_cst, the strongest one, for simplicity sake.
|
||||
|
||||
// Generic version of GCC atomic builtin functions.
|
||||
// Those work on any object no matter the pointer alignment nor its size.
|
||||
|
||||
fn __atomic_load(size: u32, src: [*]u8, dest: [*]u8, model: i32) callconv(.C) void {
|
||||
_ = model;
|
||||
var sl = spinlocks.get(@ptrToInt(src));
|
||||
defer sl.release();
|
||||
@memcpy(dest, src, size);
|
||||
}
|
||||
|
||||
fn __atomic_store(size: u32, dest: [*]u8, src: [*]u8, model: i32) callconv(.C) void {
|
||||
_ = model;
|
||||
var sl = spinlocks.get(@ptrToInt(dest));
|
||||
defer sl.release();
|
||||
@memcpy(dest, src, size);
|
||||
}
|
||||
|
||||
fn __atomic_exchange(size: u32, ptr: [*]u8, val: [*]u8, old: [*]u8, model: i32) callconv(.C) void {
|
||||
_ = model;
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
@memcpy(old, ptr, size);
|
||||
@memcpy(ptr, val, size);
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange(
|
||||
size: u32,
|
||||
ptr: [*]u8,
|
||||
expected: [*]u8,
|
||||
desired: [*]u8,
|
||||
success: i32,
|
||||
failure: i32,
|
||||
) callconv(.C) i32 {
|
||||
_ = success;
|
||||
_ = failure;
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
for (ptr[0..size]) |b, i| {
|
||||
if (expected[i] != b) break;
|
||||
} else {
|
||||
// The two objects, ptr and expected, are equal
|
||||
@memcpy(ptr, desired, size);
|
||||
return 1;
|
||||
}
|
||||
@memcpy(expected, ptr, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Specialized versions of the GCC atomic builtin functions.
|
||||
// LLVM emits those iff the object size is known and the pointers are correctly
|
||||
// aligned.
|
||||
inline fn atomic_load_N(comptime T: type, src: *T, model: i32) T {
|
||||
_ = model;
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(src));
|
||||
defer sl.release();
|
||||
return src.*;
|
||||
} else {
|
||||
return @atomicLoad(T, src, .SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
fn __atomic_load_1(src: *u8, model: i32) callconv(.C) u8 {
|
||||
return atomic_load_N(u8, src, model);
|
||||
}
|
||||
|
||||
fn __atomic_load_2(src: *u16, model: i32) callconv(.C) u16 {
|
||||
return atomic_load_N(u16, src, model);
|
||||
}
|
||||
|
||||
fn __atomic_load_4(src: *u32, model: i32) callconv(.C) u32 {
|
||||
return atomic_load_N(u32, src, model);
|
||||
}
|
||||
|
||||
fn __atomic_load_8(src: *u64, model: i32) callconv(.C) u64 {
|
||||
return atomic_load_N(u64, src, model);
|
||||
}
|
||||
|
||||
inline fn atomic_store_N(comptime T: type, dst: *T, value: T, model: i32) void {
|
||||
_ = model;
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(dst));
|
||||
defer sl.release();
|
||||
dst.* = value;
|
||||
} else {
|
||||
@atomicStore(T, dst, value, .SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
fn __atomic_store_1(dst: *u8, value: u8, model: i32) callconv(.C) void {
|
||||
return atomic_store_N(u8, dst, value, model);
|
||||
}
|
||||
|
||||
fn __atomic_store_2(dst: *u16, value: u16, model: i32) callconv(.C) void {
|
||||
return atomic_store_N(u16, dst, value, model);
|
||||
}
|
||||
|
||||
fn __atomic_store_4(dst: *u32, value: u32, model: i32) callconv(.C) void {
|
||||
return atomic_store_N(u32, dst, value, model);
|
||||
}
|
||||
|
||||
fn __atomic_store_8(dst: *u64, value: u64, model: i32) callconv(.C) void {
|
||||
return atomic_store_N(u64, dst, value, model);
|
||||
}
|
||||
|
||||
fn wideUpdate(comptime T: type, ptr: *T, val: T, update: anytype) T {
|
||||
const WideAtomic = std.meta.Int(.unsigned, smallest_atomic_fetch_exch_size * 8);
|
||||
|
||||
const addr = @ptrToInt(ptr);
|
||||
const wide_addr = addr & ~(@as(T, smallest_atomic_fetch_exch_size) - 1);
|
||||
const wide_ptr = @alignCast(smallest_atomic_fetch_exch_size, @intToPtr(*WideAtomic, wide_addr));
|
||||
|
||||
const inner_offset = addr & (@as(T, smallest_atomic_fetch_exch_size) - 1);
|
||||
const inner_shift = @intCast(std.math.Log2Int(T), inner_offset * 8);
|
||||
|
||||
const mask = @as(WideAtomic, std.math.maxInt(T)) << inner_shift;
|
||||
|
||||
var wide_old = @atomicLoad(WideAtomic, wide_ptr, .SeqCst);
|
||||
while (true) {
|
||||
const old = @truncate(T, (wide_old & mask) >> inner_shift);
|
||||
const new = update(val, old);
|
||||
const wide_new = wide_old & ~mask | (@as(WideAtomic, new) << inner_shift);
|
||||
if (@cmpxchgWeak(WideAtomic, wide_ptr, wide_old, wide_new, .SeqCst, .SeqCst)) |new_wide_old| {
|
||||
wide_old = new_wide_old;
|
||||
} else {
|
||||
return old;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fn atomic_exchange_N(comptime T: type, ptr: *T, val: T, model: i32) T {
|
||||
_ = model;
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
const value = ptr.*;
|
||||
ptr.* = val;
|
||||
return value;
|
||||
} else if (@sizeOf(T) < smallest_atomic_fetch_exch_size) {
|
||||
// Machine does not support this type, but it does support a larger type.
|
||||
const Updater = struct {
|
||||
fn update(new: T, old: T) T {
|
||||
_ = old;
|
||||
return new;
|
||||
}
|
||||
};
|
||||
return wideUpdate(T, ptr, val, Updater.update);
|
||||
} else {
|
||||
return @atomicRmw(T, ptr, .Xchg, val, .SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
fn __atomic_exchange_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return atomic_exchange_N(u8, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_exchange_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return atomic_exchange_N(u16, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_exchange_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return atomic_exchange_N(u32, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_exchange_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return atomic_exchange_N(u64, ptr, val, model);
|
||||
}
|
||||
|
||||
inline fn atomic_compare_exchange_N(
|
||||
comptime T: type,
|
||||
ptr: *T,
|
||||
expected: *T,
|
||||
desired: T,
|
||||
success: i32,
|
||||
failure: i32,
|
||||
) i32 {
|
||||
_ = success;
|
||||
_ = failure;
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
const value = ptr.*;
|
||||
if (value == expected.*) {
|
||||
ptr.* = desired;
|
||||
return 1;
|
||||
}
|
||||
expected.* = value;
|
||||
return 0;
|
||||
} else {
|
||||
if (@cmpxchgStrong(T, ptr, expected.*, desired, .SeqCst, .SeqCst)) |old_value| {
|
||||
expected.* = old_value;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange_1(ptr: *u8, expected: *u8, desired: u8, success: i32, failure: i32) callconv(.C) i32 {
|
||||
return atomic_compare_exchange_N(u8, ptr, expected, desired, success, failure);
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange_2(ptr: *u16, expected: *u16, desired: u16, success: i32, failure: i32) callconv(.C) i32 {
|
||||
return atomic_compare_exchange_N(u16, ptr, expected, desired, success, failure);
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange_4(ptr: *u32, expected: *u32, desired: u32, success: i32, failure: i32) callconv(.C) i32 {
|
||||
return atomic_compare_exchange_N(u32, ptr, expected, desired, success, failure);
|
||||
}
|
||||
|
||||
fn __atomic_compare_exchange_8(ptr: *u64, expected: *u64, desired: u64, success: i32, failure: i32) callconv(.C) i32 {
|
||||
return atomic_compare_exchange_N(u64, ptr, expected, desired, success, failure);
|
||||
}
|
||||
|
||||
inline fn fetch_op_N(comptime T: type, comptime op: std.builtin.AtomicRmwOp, ptr: *T, val: T, model: i32) T {
|
||||
_ = model;
|
||||
const Updater = struct {
|
||||
fn update(new: T, old: T) T {
|
||||
return switch (op) {
|
||||
.Add => old +% new,
|
||||
.Sub => old -% new,
|
||||
.And => old & new,
|
||||
.Nand => ~(old & new),
|
||||
.Or => old | new,
|
||||
.Xor => old ^ new,
|
||||
else => @compileError("unsupported atomic op"),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
if (@sizeOf(T) > largest_atomic_size) {
|
||||
var sl = spinlocks.get(@ptrToInt(ptr));
|
||||
defer sl.release();
|
||||
|
||||
const value = ptr.*;
|
||||
ptr.* = Updater.update(val, value);
|
||||
return value;
|
||||
} else if (@sizeOf(T) < smallest_atomic_fetch_exch_size) {
|
||||
// Machine does not support this type, but it does support a larger type.
|
||||
return wideUpdate(T, ptr, val, Updater.update);
|
||||
}
|
||||
|
||||
return @atomicRmw(T, ptr, op, val, .SeqCst);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_add_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Add, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_add_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Add, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_add_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Add, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_add_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Add, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_sub_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Sub, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_sub_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Sub, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_sub_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Sub, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_sub_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Sub, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_and_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .And, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_and_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .And, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_and_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .And, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_and_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .And, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_or_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Or, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_or_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Or, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_or_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Or, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_or_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Or, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_xor_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Xor, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_xor_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Xor, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_xor_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Xor, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_xor_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Xor, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_nand_1(ptr: *u8, val: u8, model: i32) callconv(.C) u8 {
|
||||
return fetch_op_N(u8, .Nand, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_nand_2(ptr: *u16, val: u16, model: i32) callconv(.C) u16 {
|
||||
return fetch_op_N(u16, .Nand, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_nand_4(ptr: *u32, val: u32, model: i32) callconv(.C) u32 {
|
||||
return fetch_op_N(u32, .Nand, ptr, val, model);
|
||||
}
|
||||
|
||||
fn __atomic_fetch_nand_8(ptr: *u64, val: u64, model: i32) callconv(.C) u64 {
|
||||
return fetch_op_N(u64, .Nand, ptr, val, model);
|
||||
}
|
||||
|
||||
comptime {
|
||||
if (supports_atomic_ops) {
|
||||
@export(__atomic_load, .{ .name = "__atomic_load", .linkage = linkage });
|
||||
@export(__atomic_store, .{ .name = "__atomic_store", .linkage = linkage });
|
||||
@export(__atomic_exchange, .{ .name = "__atomic_exchange", .linkage = linkage });
|
||||
@export(__atomic_compare_exchange, .{ .name = "__atomic_compare_exchange", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_add_1, .{ .name = "__atomic_fetch_add_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_add_2, .{ .name = "__atomic_fetch_add_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_add_4, .{ .name = "__atomic_fetch_add_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_add_8, .{ .name = "__atomic_fetch_add_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_sub_1, .{ .name = "__atomic_fetch_sub_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_sub_2, .{ .name = "__atomic_fetch_sub_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_sub_4, .{ .name = "__atomic_fetch_sub_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_sub_8, .{ .name = "__atomic_fetch_sub_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_and_1, .{ .name = "__atomic_fetch_and_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_and_2, .{ .name = "__atomic_fetch_and_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_and_4, .{ .name = "__atomic_fetch_and_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_and_8, .{ .name = "__atomic_fetch_and_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_or_1, .{ .name = "__atomic_fetch_or_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_or_2, .{ .name = "__atomic_fetch_or_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_or_4, .{ .name = "__atomic_fetch_or_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_or_8, .{ .name = "__atomic_fetch_or_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_xor_1, .{ .name = "__atomic_fetch_xor_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_xor_2, .{ .name = "__atomic_fetch_xor_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_xor_4, .{ .name = "__atomic_fetch_xor_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_xor_8, .{ .name = "__atomic_fetch_xor_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_fetch_nand_1, .{ .name = "__atomic_fetch_nand_1", .linkage = linkage });
|
||||
@export(__atomic_fetch_nand_2, .{ .name = "__atomic_fetch_nand_2", .linkage = linkage });
|
||||
@export(__atomic_fetch_nand_4, .{ .name = "__atomic_fetch_nand_4", .linkage = linkage });
|
||||
@export(__atomic_fetch_nand_8, .{ .name = "__atomic_fetch_nand_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_load_1, .{ .name = "__atomic_load_1", .linkage = linkage });
|
||||
@export(__atomic_load_2, .{ .name = "__atomic_load_2", .linkage = linkage });
|
||||
@export(__atomic_load_4, .{ .name = "__atomic_load_4", .linkage = linkage });
|
||||
@export(__atomic_load_8, .{ .name = "__atomic_load_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_store_1, .{ .name = "__atomic_store_1", .linkage = linkage });
|
||||
@export(__atomic_store_2, .{ .name = "__atomic_store_2", .linkage = linkage });
|
||||
@export(__atomic_store_4, .{ .name = "__atomic_store_4", .linkage = linkage });
|
||||
@export(__atomic_store_8, .{ .name = "__atomic_store_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_exchange_1, .{ .name = "__atomic_exchange_1", .linkage = linkage });
|
||||
@export(__atomic_exchange_2, .{ .name = "__atomic_exchange_2", .linkage = linkage });
|
||||
@export(__atomic_exchange_4, .{ .name = "__atomic_exchange_4", .linkage = linkage });
|
||||
@export(__atomic_exchange_8, .{ .name = "__atomic_exchange_8", .linkage = linkage });
|
||||
|
||||
@export(__atomic_compare_exchange_1, .{ .name = "__atomic_compare_exchange_1", .linkage = linkage });
|
||||
@export(__atomic_compare_exchange_2, .{ .name = "__atomic_compare_exchange_2", .linkage = linkage });
|
||||
@export(__atomic_compare_exchange_4, .{ .name = "__atomic_compare_exchange_4", .linkage = linkage });
|
||||
@export(__atomic_compare_exchange_8, .{ .name = "__atomic_compare_exchange_8", .linkage = linkage });
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
const std = @import("std");
|
||||
const common = @import("./common.zig");
|
||||
|
||||
comptime {
|
||||
@export(bcmp, .{ .name = "bcmp", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn bcmp(vl: [*]allowzero const u8, vr: [*]allowzero const u8, n: usize) callconv(.C) c_int {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
var index: usize = 0;
|
||||
while (index != n) : (index += 1) {
|
||||
if (vl[index] != vr[index]) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
test "bcmp" {
|
||||
const base_arr = &[_]u8{ 1, 1, 1 };
|
||||
const arr1 = &[_]u8{ 1, 1, 1 };
|
||||
const arr2 = &[_]u8{ 1, 0, 1 };
|
||||
const arr3 = &[_]u8{ 1, 2, 1 };
|
||||
|
||||
try std.testing.expect(bcmp(base_arr[0..], arr1[0..], base_arr.len) == 0);
|
||||
try std.testing.expect(bcmp(base_arr[0..], arr2[0..], base_arr.len) != 0);
|
||||
try std.testing.expect(bcmp(base_arr[0..], arr3[0..], base_arr.len) != 0);
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__bswapsi2, .{ .name = "__bswapsi2", .linkage = common.linkage });
|
||||
@export(__bswapdi2, .{ .name = "__bswapdi2", .linkage = common.linkage });
|
||||
@export(__bswapti2, .{ .name = "__bswapti2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
// bswap - byteswap
|
||||
// - bswapXi2 for unoptimized big and little endian
|
||||
// ie for u32
|
||||
// DE AD BE EF <- little|big endian
|
||||
// FE BE AD DE <- big|little endian
|
||||
// ff 00 00 00 >> 3*8 (leftmost byte)
|
||||
// 00 ff 00 00 >> 1*8 (2nd left byte)
|
||||
// 00 00 ff 00 << 1*8 (2n right byte)
|
||||
// 00 00 00 ff << 3*8 (rightmost byte)
|
||||
|
||||
inline fn bswapXi2(comptime T: type, a: T) T {
|
||||
switch (@bitSizeOf(T)) {
|
||||
32 => {
|
||||
// zig fmt: off
|
||||
return (((a & 0xff000000) >> 24)
|
||||
| ((a & 0x00ff0000) >> 8 )
|
||||
| ((a & 0x0000ff00) << 8 )
|
||||
| ((a & 0x000000ff) << 24));
|
||||
// zig fmt: on
|
||||
},
|
||||
64 => {
|
||||
// zig fmt: off
|
||||
return (((a & 0xff00000000000000) >> 56)
|
||||
| ((a & 0x00ff000000000000) >> 40 )
|
||||
| ((a & 0x0000ff0000000000) >> 24 )
|
||||
| ((a & 0x000000ff00000000) >> 8 )
|
||||
| ((a & 0x00000000ff000000) << 8 )
|
||||
| ((a & 0x0000000000ff0000) << 24 )
|
||||
| ((a & 0x000000000000ff00) << 40 )
|
||||
| ((a & 0x00000000000000ff) << 56));
|
||||
// zig fmt: on
|
||||
},
|
||||
128 => {
|
||||
// zig fmt: off
|
||||
return (((a & 0xff000000000000000000000000000000) >> 120)
|
||||
| ((a & 0x00ff0000000000000000000000000000) >> 104)
|
||||
| ((a & 0x0000ff00000000000000000000000000) >> 88 )
|
||||
| ((a & 0x000000ff000000000000000000000000) >> 72 )
|
||||
| ((a & 0x00000000ff0000000000000000000000) >> 56 )
|
||||
| ((a & 0x0000000000ff00000000000000000000) >> 40 )
|
||||
| ((a & 0x000000000000ff000000000000000000) >> 24 )
|
||||
| ((a & 0x00000000000000ff0000000000000000) >> 8 )
|
||||
| ((a & 0x0000000000000000ff00000000000000) << 8 )
|
||||
| ((a & 0x000000000000000000ff000000000000) << 24 )
|
||||
| ((a & 0x00000000000000000000ff0000000000) << 40 )
|
||||
| ((a & 0x0000000000000000000000ff00000000) << 56 )
|
||||
| ((a & 0x000000000000000000000000ff000000) << 72 )
|
||||
| ((a & 0x00000000000000000000000000ff0000) << 88 )
|
||||
| ((a & 0x0000000000000000000000000000ff00) << 104)
|
||||
| ((a & 0x000000000000000000000000000000ff) << 120));
|
||||
// zig fmt: on
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn __bswapsi2(a: u32) callconv(.C) u32 {
|
||||
return bswapXi2(u32, a);
|
||||
}
|
||||
|
||||
pub fn __bswapdi2(a: u64) callconv(.C) u64 {
|
||||
return bswapXi2(u64, a);
|
||||
}
|
||||
|
||||
pub fn __bswapti2(a: u128) callconv(.C) u128 {
|
||||
return bswapXi2(u128, a);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("bswapsi2_test.zig");
|
||||
_ = @import("bswapdi2_test.zig");
|
||||
_ = @import("bswapti2_test.zig");
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
const bswap = @import("bswap.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__bswapdi2(a: u64, expected: u64) !void {
|
||||
var result = bswap.__bswapdi2(a);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "bswapdi2" {
|
||||
try test__bswapdi2(0x0123456789abcdef, 0xefcdab8967452301); // 0..f
|
||||
try test__bswapdi2(0xefcdab8967452301, 0x0123456789abcdef);
|
||||
try test__bswapdi2(0x89abcdef01234567, 0x67452301efcdab89); // 8..f0..7
|
||||
try test__bswapdi2(0x67452301efcdab89, 0x89abcdef01234567);
|
||||
try test__bswapdi2(0xdeadbeefdeadbeef, 0xefbeaddeefbeadde); // deadbeefdeadbeef
|
||||
try test__bswapdi2(0xefbeaddeefbeadde, 0xdeadbeefdeadbeef);
|
||||
try test__bswapdi2(0xdeadfacedeadface, 0xcefaaddecefaadde); // deadfacedeadface
|
||||
try test__bswapdi2(0xcefaaddecefaadde, 0xdeadfacedeadface);
|
||||
try test__bswapdi2(0xaaaaaaaaaaaaaaaa, 0xaaaaaaaaaaaaaaaa); // uninitialized memory
|
||||
try test__bswapdi2(0x0000000000000000, 0x0000000000000000); // 0s
|
||||
try test__bswapdi2(0xffffffffffffffff, 0xffffffffffffffff); // fs
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
const bswap = @import("bswap.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__bswapsi2(a: u32, expected: u32) !void {
|
||||
var result = bswap.__bswapsi2(a);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "bswapsi2" {
|
||||
try test__bswapsi2(0x01234567, 0x67452301); // 0..7
|
||||
try test__bswapsi2(0x67452301, 0x01234567);
|
||||
try test__bswapsi2(0x89abcdef, 0xefcdab89); // 8..f
|
||||
try test__bswapsi2(0xefcdab89, 0x89abcdef);
|
||||
try test__bswapsi2(0xdeadbeef, 0xefbeadde); // deadbeef
|
||||
try test__bswapsi2(0xefbeadde, 0xdeadbeef);
|
||||
try test__bswapsi2(0xdeadface, 0xcefaadde); // deadface
|
||||
try test__bswapsi2(0xcefaadde, 0xdeadface);
|
||||
try test__bswapsi2(0xaaaaaaaa, 0xaaaaaaaa); // uninitialized memory
|
||||
try test__bswapsi2(0x00000000, 0x00000000); // 0s
|
||||
try test__bswapsi2(0xffffffff, 0xffffffff); // fs
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
const bswap = @import("bswap.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__bswapti2(a: u128, expected: u128) !void {
|
||||
var result = bswap.__bswapti2(a);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "bswapti2" {
|
||||
try test__bswapti2(0x0123456789abcdef0123456789abcdef, 0xefcdab8967452301efcdab8967452301); // 0..f
|
||||
try test__bswapti2(0xefcdab8967452301efcdab8967452301, 0x0123456789abcdef0123456789abcdef);
|
||||
try test__bswapti2(0x89abcdef0123456789abcdef01234567, 0x67452301efcdab8967452301efcdab89); // 8..f0..7
|
||||
try test__bswapti2(0x67452301efcdab8967452301efcdab89, 0x89abcdef0123456789abcdef01234567);
|
||||
try test__bswapti2(0xdeadbeefdeadbeefdeadbeefdeadbeef, 0xefbeaddeefbeaddeefbeaddeefbeadde); // deadbeefdeadbeef
|
||||
try test__bswapti2(0xefbeaddeefbeaddeefbeaddeefbeadde, 0xdeadbeefdeadbeefdeadbeefdeadbeef);
|
||||
try test__bswapti2(0xdeadfacedeadfacedeadfacedeadface, 0xcefaaddecefaaddecefaaddecefaadde); // deadfacedeadface
|
||||
try test__bswapti2(0xcefaaddecefaaddecefaaddecefaadde, 0xdeadfacedeadfacedeadfacedeadface);
|
||||
try test__bswapti2(0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); // uninitialized memory
|
||||
try test__bswapti2(0x00000000000000000000000000000000, 0x00000000000000000000000000000000); // 0s
|
||||
try test__bswapti2(0xffffffffffffffffffffffffffffffff, 0xffffffffffffffffffffffffffffffff); // fs
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
//! Ported from musl, which is MIT licensed.
|
||||
//! https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
|
||||
//!
|
||||
//! https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c
|
||||
//! https://git.musl-libc.org/cgit/musl/tree/src/math/ceil.c
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const arch = builtin.cpu.arch;
|
||||
const math = std.math;
|
||||
const expect = std.testing.expect;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__ceilh, .{ .name = "__ceilh", .linkage = common.linkage });
|
||||
@export(ceilf, .{ .name = "ceilf", .linkage = common.linkage });
|
||||
@export(ceil, .{ .name = "ceil", .linkage = common.linkage });
|
||||
@export(__ceilx, .{ .name = "__ceilx", .linkage = common.linkage });
|
||||
if (common.want_ppc_abi) {
|
||||
@export(ceilq, .{ .name = "ceilf128", .linkage = common.linkage });
|
||||
}
|
||||
@export(ceilq, .{ .name = "ceilq", .linkage = common.linkage });
|
||||
@export(ceill, .{ .name = "ceill", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __ceilh(x: f16) callconv(.C) f16 {
|
||||
// TODO: more efficient implementation
|
||||
return @floatCast(f16, ceilf(x));
|
||||
}
|
||||
|
||||
pub fn ceilf(x: f32) callconv(.C) f32 {
|
||||
var u = @bitCast(u32, x);
|
||||
var e = @intCast(i32, (u >> 23) & 0xFF) - 0x7F;
|
||||
var m: u32 = undefined;
|
||||
|
||||
// TODO: Shouldn't need this explicit check.
|
||||
if (x == 0.0) {
|
||||
return x;
|
||||
}
|
||||
|
||||
if (e >= 23) {
|
||||
return x;
|
||||
} else if (e >= 0) {
|
||||
m = @as(u32, 0x007FFFFF) >> @intCast(u5, e);
|
||||
if (u & m == 0) {
|
||||
return x;
|
||||
}
|
||||
math.doNotOptimizeAway(x + 0x1.0p120);
|
||||
if (u >> 31 == 0) {
|
||||
u += m;
|
||||
}
|
||||
u &= ~m;
|
||||
return @bitCast(f32, u);
|
||||
} else {
|
||||
math.doNotOptimizeAway(x + 0x1.0p120);
|
||||
if (u >> 31 != 0) {
|
||||
return -0.0;
|
||||
} else {
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ceil(x: f64) callconv(.C) f64 {
|
||||
const f64_toint = 1.0 / math.floatEps(f64);
|
||||
|
||||
const u = @bitCast(u64, x);
|
||||
const e = (u >> 52) & 0x7FF;
|
||||
var y: f64 = undefined;
|
||||
|
||||
if (e >= 0x3FF + 52 or x == 0) {
|
||||
return x;
|
||||
}
|
||||
|
||||
if (u >> 63 != 0) {
|
||||
y = x - f64_toint + f64_toint - x;
|
||||
} else {
|
||||
y = x + f64_toint - f64_toint - x;
|
||||
}
|
||||
|
||||
if (e <= 0x3FF - 1) {
|
||||
math.doNotOptimizeAway(y);
|
||||
if (u >> 63 != 0) {
|
||||
return -0.0;
|
||||
} else {
|
||||
return 1.0;
|
||||
}
|
||||
} else if (y < 0) {
|
||||
return x + y + 1;
|
||||
} else {
|
||||
return x + y;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn __ceilx(x: f80) callconv(.C) f80 {
|
||||
// TODO: more efficient implementation
|
||||
return @floatCast(f80, ceilq(x));
|
||||
}
|
||||
|
||||
pub fn ceilq(x: f128) callconv(.C) f128 {
|
||||
const f128_toint = 1.0 / math.floatEps(f128);
|
||||
|
||||
const u = @bitCast(u128, x);
|
||||
const e = (u >> 112) & 0x7FFF;
|
||||
var y: f128 = undefined;
|
||||
|
||||
if (e >= 0x3FFF + 112 or x == 0) return x;
|
||||
|
||||
if (u >> 127 != 0) {
|
||||
y = x - f128_toint + f128_toint - x;
|
||||
} else {
|
||||
y = x + f128_toint - f128_toint - x;
|
||||
}
|
||||
|
||||
if (e <= 0x3FFF - 1) {
|
||||
math.doNotOptimizeAway(y);
|
||||
if (u >> 127 != 0) {
|
||||
return -0.0;
|
||||
} else {
|
||||
return 1.0;
|
||||
}
|
||||
} else if (y < 0) {
|
||||
return x + y + 1;
|
||||
} else {
|
||||
return x + y;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble {
|
||||
switch (@typeInfo(c_longdouble).Float.bits) {
|
||||
16 => return __ceilh(x),
|
||||
32 => return ceilf(x),
|
||||
64 => return ceil(x),
|
||||
80 => return __ceilx(x),
|
||||
128 => return ceilq(x),
|
||||
else => @compileError("unreachable"),
|
||||
}
|
||||
}
|
||||
|
||||
test "ceil32" {
|
||||
try expect(ceilf(1.3) == 2.0);
|
||||
try expect(ceilf(-1.3) == -1.0);
|
||||
try expect(ceilf(0.2) == 1.0);
|
||||
}
|
||||
|
||||
test "ceil64" {
|
||||
try expect(ceil(1.3) == 2.0);
|
||||
try expect(ceil(-1.3) == -1.0);
|
||||
try expect(ceil(0.2) == 1.0);
|
||||
}
|
||||
|
||||
test "ceil128" {
|
||||
try expect(ceilq(1.3) == 2.0);
|
||||
try expect(ceilq(-1.3) == -1.0);
|
||||
try expect(ceilq(0.2) == 1.0);
|
||||
}
|
||||
|
||||
test "ceil32.special" {
|
||||
try expect(ceilf(0.0) == 0.0);
|
||||
try expect(ceilf(-0.0) == -0.0);
|
||||
try expect(math.isPositiveInf(ceilf(math.inf(f32))));
|
||||
try expect(math.isNegativeInf(ceilf(-math.inf(f32))));
|
||||
try expect(math.isNan(ceilf(math.nan(f32))));
|
||||
}
|
||||
|
||||
test "ceil64.special" {
|
||||
try expect(ceil(0.0) == 0.0);
|
||||
try expect(ceil(-0.0) == -0.0);
|
||||
try expect(math.isPositiveInf(ceil(math.inf(f64))));
|
||||
try expect(math.isNegativeInf(ceil(-math.inf(f64))));
|
||||
try expect(math.isNan(ceil(math.nan(f64))));
|
||||
}
|
||||
|
||||
test "ceil128.special" {
|
||||
try expect(ceilq(0.0) == 0.0);
|
||||
try expect(ceilq(-0.0) == -0.0);
|
||||
try expect(math.isPositiveInf(ceilq(math.inf(f128))));
|
||||
try expect(math.isNegativeInf(ceilq(-math.inf(f128))));
|
||||
try expect(math.isNan(ceilq(math.nan(f128))));
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
const clz = @import("count0bits.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__clzdi2(a: u64, expected: i64) !void {
|
||||
var x = @bitCast(i64, a);
|
||||
var result = clz.__clzdi2(x);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "clzdi2" {
|
||||
try test__clzdi2(0x00800000_00000000, 8);
|
||||
try test__clzdi2(0x01000000_00000000, 7);
|
||||
try test__clzdi2(0x02000000_00000000, 6);
|
||||
try test__clzdi2(0x03000000_00000000, 6);
|
||||
try test__clzdi2(0x04000000_00000000, 5);
|
||||
try test__clzdi2(0x05000000_00000000, 5);
|
||||
try test__clzdi2(0x06000000_00000000, 5);
|
||||
try test__clzdi2(0x07000000_00000000, 5);
|
||||
try test__clzdi2(0x08000000_00000000, 4);
|
||||
try test__clzdi2(0x09000000_00000000, 4);
|
||||
try test__clzdi2(0x0A000000_00000000, 4);
|
||||
try test__clzdi2(0x0B000000_00000000, 4);
|
||||
try test__clzdi2(0x0C000000_00000000, 4);
|
||||
try test__clzdi2(0x0D000000_00000000, 4);
|
||||
try test__clzdi2(0x0E000000_00000000, 4);
|
||||
try test__clzdi2(0x0F000000_00000000, 4);
|
||||
try test__clzdi2(0x10000000_00000000, 3);
|
||||
try test__clzdi2(0x11000000_00000000, 3);
|
||||
try test__clzdi2(0x12000000_00000000, 3);
|
||||
try test__clzdi2(0x13000000_00000000, 3);
|
||||
try test__clzdi2(0x14000000_00000000, 3);
|
||||
try test__clzdi2(0x15000000_00000000, 3);
|
||||
try test__clzdi2(0x16000000_00000000, 3);
|
||||
try test__clzdi2(0x17000000_00000000, 3);
|
||||
try test__clzdi2(0x18000000_00000000, 3);
|
||||
try test__clzdi2(0x19000000_00000000, 3);
|
||||
try test__clzdi2(0x1A000000_00000000, 3);
|
||||
try test__clzdi2(0x1B000000_00000000, 3);
|
||||
try test__clzdi2(0x1C000000_00000000, 3);
|
||||
try test__clzdi2(0x1D000000_00000000, 3);
|
||||
try test__clzdi2(0x1E000000_00000000, 3);
|
||||
try test__clzdi2(0x1F000000_00000000, 3);
|
||||
try test__clzdi2(0x20000000_00000000, 2);
|
||||
try test__clzdi2(0x21000000_00000000, 2);
|
||||
try test__clzdi2(0x22000000_00000000, 2);
|
||||
try test__clzdi2(0x23000000_00000000, 2);
|
||||
try test__clzdi2(0x24000000_00000000, 2);
|
||||
try test__clzdi2(0x25000000_00000000, 2);
|
||||
try test__clzdi2(0x26000000_00000000, 2);
|
||||
try test__clzdi2(0x27000000_00000000, 2);
|
||||
try test__clzdi2(0x28000000_00000000, 2);
|
||||
try test__clzdi2(0x29000000_00000000, 2);
|
||||
try test__clzdi2(0x2A000000_00000000, 2);
|
||||
try test__clzdi2(0x2B000000_00000000, 2);
|
||||
try test__clzdi2(0x2C000000_00000000, 2);
|
||||
try test__clzdi2(0x2D000000_00000000, 2);
|
||||
try test__clzdi2(0x2E000000_00000000, 2);
|
||||
try test__clzdi2(0x2F000000_00000000, 2);
|
||||
try test__clzdi2(0x30000000_00000000, 2);
|
||||
try test__clzdi2(0x31000000_00000000, 2);
|
||||
try test__clzdi2(0x32000000_00000000, 2);
|
||||
try test__clzdi2(0x33000000_00000000, 2);
|
||||
try test__clzdi2(0x34000000_00000000, 2);
|
||||
try test__clzdi2(0x35000000_00000000, 2);
|
||||
try test__clzdi2(0x36000000_00000000, 2);
|
||||
try test__clzdi2(0x37000000_00000000, 2);
|
||||
try test__clzdi2(0x38000000_00000000, 2);
|
||||
try test__clzdi2(0x39000000_00000000, 2);
|
||||
try test__clzdi2(0x3A000000_00000000, 2);
|
||||
try test__clzdi2(0x3B000000_00000000, 2);
|
||||
try test__clzdi2(0x3C000000_00000000, 2);
|
||||
try test__clzdi2(0x3D000000_00000000, 2);
|
||||
try test__clzdi2(0x3E000000_00000000, 2);
|
||||
try test__clzdi2(0x3F000000_00000000, 2);
|
||||
try test__clzdi2(0x40000000_00000000, 1);
|
||||
try test__clzdi2(0x41000000_00000000, 1);
|
||||
try test__clzdi2(0x42000000_00000000, 1);
|
||||
try test__clzdi2(0x43000000_00000000, 1);
|
||||
try test__clzdi2(0x44000000_00000000, 1);
|
||||
try test__clzdi2(0x45000000_00000000, 1);
|
||||
try test__clzdi2(0x46000000_00000000, 1);
|
||||
try test__clzdi2(0x47000000_00000000, 1);
|
||||
try test__clzdi2(0x48000000_00000000, 1);
|
||||
try test__clzdi2(0x49000000_00000000, 1);
|
||||
try test__clzdi2(0x4A000000_00000000, 1);
|
||||
try test__clzdi2(0x4B000000_00000000, 1);
|
||||
try test__clzdi2(0x4C000000_00000000, 1);
|
||||
try test__clzdi2(0x4D000000_00000000, 1);
|
||||
try test__clzdi2(0x4E000000_00000000, 1);
|
||||
try test__clzdi2(0x4F000000_00000000, 1);
|
||||
try test__clzdi2(0x50000000_00000000, 1);
|
||||
try test__clzdi2(0x51000000_00000000, 1);
|
||||
try test__clzdi2(0x52000000_00000000, 1);
|
||||
try test__clzdi2(0x53000000_00000000, 1);
|
||||
try test__clzdi2(0x54000000_00000000, 1);
|
||||
try test__clzdi2(0x55000000_00000000, 1);
|
||||
try test__clzdi2(0x56000000_00000000, 1);
|
||||
try test__clzdi2(0x57000000_00000000, 1);
|
||||
try test__clzdi2(0x58000000_00000000, 1);
|
||||
try test__clzdi2(0x59000000_00000000, 1);
|
||||
try test__clzdi2(0x5A000000_00000000, 1);
|
||||
try test__clzdi2(0x5B000000_00000000, 1);
|
||||
try test__clzdi2(0x5C000000_00000000, 1);
|
||||
try test__clzdi2(0x5D000000_00000000, 1);
|
||||
try test__clzdi2(0x5E000000_00000000, 1);
|
||||
try test__clzdi2(0x5F000000_00000000, 1);
|
||||
try test__clzdi2(0x60000000_00000000, 1);
|
||||
try test__clzdi2(0x61000000_00000000, 1);
|
||||
try test__clzdi2(0x62000000_00000000, 1);
|
||||
try test__clzdi2(0x63000000_00000000, 1);
|
||||
try test__clzdi2(0x64000000_00000000, 1);
|
||||
try test__clzdi2(0x65000000_00000000, 1);
|
||||
try test__clzdi2(0x66000000_00000000, 1);
|
||||
try test__clzdi2(0x67000000_00000000, 1);
|
||||
try test__clzdi2(0x68000000_00000000, 1);
|
||||
try test__clzdi2(0x69000000_00000000, 1);
|
||||
try test__clzdi2(0x6A000000_00000000, 1);
|
||||
try test__clzdi2(0x6B000000_00000000, 1);
|
||||
try test__clzdi2(0x6C000000_00000000, 1);
|
||||
try test__clzdi2(0x6D000000_00000000, 1);
|
||||
try test__clzdi2(0x6E000000_00000000, 1);
|
||||
try test__clzdi2(0x6F000000_00000000, 1);
|
||||
try test__clzdi2(0x70000000_00000000, 1);
|
||||
try test__clzdi2(0x71000000_00000000, 1);
|
||||
try test__clzdi2(0x72000000_00000000, 1);
|
||||
try test__clzdi2(0x73000000_00000000, 1);
|
||||
try test__clzdi2(0x74000000_00000000, 1);
|
||||
try test__clzdi2(0x75000000_00000000, 1);
|
||||
try test__clzdi2(0x76000000_00000000, 1);
|
||||
try test__clzdi2(0x77000000_00000000, 1);
|
||||
try test__clzdi2(0x78000000_00000000, 1);
|
||||
try test__clzdi2(0x79000000_00000000, 1);
|
||||
try test__clzdi2(0x7A000000_00000000, 1);
|
||||
try test__clzdi2(0x7B000000_00000000, 1);
|
||||
try test__clzdi2(0x7C000000_00000000, 1);
|
||||
try test__clzdi2(0x7D000000_00000000, 1);
|
||||
try test__clzdi2(0x7E000000_00000000, 1);
|
||||
try test__clzdi2(0x7F000000_00000000, 1);
|
||||
try test__clzdi2(0x80000000_00000000, 0);
|
||||
try test__clzdi2(0x81000000_00000000, 0);
|
||||
try test__clzdi2(0x82000000_00000000, 0);
|
||||
try test__clzdi2(0x83000000_00000000, 0);
|
||||
try test__clzdi2(0x84000000_00000000, 0);
|
||||
try test__clzdi2(0x85000000_00000000, 0);
|
||||
try test__clzdi2(0x86000000_00000000, 0);
|
||||
try test__clzdi2(0x87000000_00000000, 0);
|
||||
try test__clzdi2(0x88000000_00000000, 0);
|
||||
try test__clzdi2(0x89000000_00000000, 0);
|
||||
try test__clzdi2(0x8A000000_00000000, 0);
|
||||
try test__clzdi2(0x8B000000_00000000, 0);
|
||||
try test__clzdi2(0x8C000000_00000000, 0);
|
||||
try test__clzdi2(0x8D000000_00000000, 0);
|
||||
try test__clzdi2(0x8E000000_00000000, 0);
|
||||
try test__clzdi2(0x8F000000_00000000, 0);
|
||||
try test__clzdi2(0x90000000_00000000, 0);
|
||||
try test__clzdi2(0x91000000_00000000, 0);
|
||||
try test__clzdi2(0x92000000_00000000, 0);
|
||||
try test__clzdi2(0x93000000_00000000, 0);
|
||||
try test__clzdi2(0x94000000_00000000, 0);
|
||||
try test__clzdi2(0x95000000_00000000, 0);
|
||||
try test__clzdi2(0x96000000_00000000, 0);
|
||||
try test__clzdi2(0x97000000_00000000, 0);
|
||||
try test__clzdi2(0x98000000_00000000, 0);
|
||||
try test__clzdi2(0x99000000_00000000, 0);
|
||||
try test__clzdi2(0x9A000000_00000000, 0);
|
||||
try test__clzdi2(0x9B000000_00000000, 0);
|
||||
try test__clzdi2(0x9C000000_00000000, 0);
|
||||
try test__clzdi2(0x9D000000_00000000, 0);
|
||||
try test__clzdi2(0x9E000000_00000000, 0);
|
||||
try test__clzdi2(0x9F000000_00000000, 0);
|
||||
try test__clzdi2(0xA0000000_00000000, 0);
|
||||
try test__clzdi2(0xA1000000_00000000, 0);
|
||||
try test__clzdi2(0xA2000000_00000000, 0);
|
||||
try test__clzdi2(0xA3000000_00000000, 0);
|
||||
try test__clzdi2(0xA4000000_00000000, 0);
|
||||
try test__clzdi2(0xA5000000_00000000, 0);
|
||||
try test__clzdi2(0xA6000000_00000000, 0);
|
||||
try test__clzdi2(0xA7000000_00000000, 0);
|
||||
try test__clzdi2(0xA8000000_00000000, 0);
|
||||
try test__clzdi2(0xA9000000_00000000, 0);
|
||||
try test__clzdi2(0xAA000000_00000000, 0);
|
||||
try test__clzdi2(0xAB000000_00000000, 0);
|
||||
try test__clzdi2(0xAC000000_00000000, 0);
|
||||
try test__clzdi2(0xAD000000_00000000, 0);
|
||||
try test__clzdi2(0xAE000000_00000000, 0);
|
||||
try test__clzdi2(0xAF000000_00000000, 0);
|
||||
try test__clzdi2(0xB0000000_00000000, 0);
|
||||
try test__clzdi2(0xB1000000_00000000, 0);
|
||||
try test__clzdi2(0xB2000000_00000000, 0);
|
||||
try test__clzdi2(0xB3000000_00000000, 0);
|
||||
try test__clzdi2(0xB4000000_00000000, 0);
|
||||
try test__clzdi2(0xB5000000_00000000, 0);
|
||||
try test__clzdi2(0xB6000000_00000000, 0);
|
||||
try test__clzdi2(0xB7000000_00000000, 0);
|
||||
try test__clzdi2(0xB8000000_00000000, 0);
|
||||
try test__clzdi2(0xB9000000_00000000, 0);
|
||||
try test__clzdi2(0xBA000000_00000000, 0);
|
||||
try test__clzdi2(0xBB000000_00000000, 0);
|
||||
try test__clzdi2(0xBC000000_00000000, 0);
|
||||
try test__clzdi2(0xBD000000_00000000, 0);
|
||||
try test__clzdi2(0xBE000000_00000000, 0);
|
||||
try test__clzdi2(0xBF000000_00000000, 0);
|
||||
try test__clzdi2(0xC0000000_00000000, 0);
|
||||
try test__clzdi2(0xC1000000_00000000, 0);
|
||||
try test__clzdi2(0xC2000000_00000000, 0);
|
||||
try test__clzdi2(0xC3000000_00000000, 0);
|
||||
try test__clzdi2(0xC4000000_00000000, 0);
|
||||
try test__clzdi2(0xC5000000_00000000, 0);
|
||||
try test__clzdi2(0xC6000000_00000000, 0);
|
||||
try test__clzdi2(0xC7000000_00000000, 0);
|
||||
try test__clzdi2(0xC8000000_00000000, 0);
|
||||
try test__clzdi2(0xC9000000_00000000, 0);
|
||||
try test__clzdi2(0xCA000000_00000000, 0);
|
||||
try test__clzdi2(0xCB000000_00000000, 0);
|
||||
try test__clzdi2(0xCC000000_00000000, 0);
|
||||
try test__clzdi2(0xCD000000_00000000, 0);
|
||||
try test__clzdi2(0xCE000000_00000000, 0);
|
||||
try test__clzdi2(0xCF000000_00000000, 0);
|
||||
try test__clzdi2(0xD0000000_00000000, 0);
|
||||
try test__clzdi2(0xD1000000_00000000, 0);
|
||||
try test__clzdi2(0xD2000000_00000000, 0);
|
||||
try test__clzdi2(0xD3000000_00000000, 0);
|
||||
try test__clzdi2(0xD4000000_00000000, 0);
|
||||
try test__clzdi2(0xD5000000_00000000, 0);
|
||||
try test__clzdi2(0xD6000000_00000000, 0);
|
||||
try test__clzdi2(0xD7000000_00000000, 0);
|
||||
try test__clzdi2(0xD8000000_00000000, 0);
|
||||
try test__clzdi2(0xD9000000_00000000, 0);
|
||||
try test__clzdi2(0xDA000000_00000000, 0);
|
||||
try test__clzdi2(0xDB000000_00000000, 0);
|
||||
try test__clzdi2(0xDC000000_00000000, 0);
|
||||
try test__clzdi2(0xDD000000_00000000, 0);
|
||||
try test__clzdi2(0xDE000000_00000000, 0);
|
||||
try test__clzdi2(0xDF000000_00000000, 0);
|
||||
try test__clzdi2(0xE0000000_00000000, 0);
|
||||
try test__clzdi2(0xE1000000_00000000, 0);
|
||||
try test__clzdi2(0xE2000000_00000000, 0);
|
||||
try test__clzdi2(0xE3000000_00000000, 0);
|
||||
try test__clzdi2(0xE4000000_00000000, 0);
|
||||
try test__clzdi2(0xE5000000_00000000, 0);
|
||||
try test__clzdi2(0xE6000000_00000000, 0);
|
||||
try test__clzdi2(0xE7000000_00000000, 0);
|
||||
try test__clzdi2(0xE8000000_00000000, 0);
|
||||
try test__clzdi2(0xE9000000_00000000, 0);
|
||||
try test__clzdi2(0xEA000000_00000000, 0);
|
||||
try test__clzdi2(0xEB000000_00000000, 0);
|
||||
try test__clzdi2(0xEC000000_00000000, 0);
|
||||
try test__clzdi2(0xED000000_00000000, 0);
|
||||
try test__clzdi2(0xEE000000_00000000, 0);
|
||||
try test__clzdi2(0xEF000000_00000000, 0);
|
||||
try test__clzdi2(0xF0000000_00000000, 0);
|
||||
try test__clzdi2(0xF1000000_00000000, 0);
|
||||
try test__clzdi2(0xF2000000_00000000, 0);
|
||||
try test__clzdi2(0xF3000000_00000000, 0);
|
||||
try test__clzdi2(0xF4000000_00000000, 0);
|
||||
try test__clzdi2(0xF5000000_00000000, 0);
|
||||
try test__clzdi2(0xF6000000_00000000, 0);
|
||||
try test__clzdi2(0xF7000000_00000000, 0);
|
||||
try test__clzdi2(0xF8000000_00000000, 0);
|
||||
try test__clzdi2(0xF9000000_00000000, 0);
|
||||
try test__clzdi2(0xFA000000_00000000, 0);
|
||||
try test__clzdi2(0xFB000000_00000000, 0);
|
||||
try test__clzdi2(0xFC000000_00000000, 0);
|
||||
try test__clzdi2(0xFD000000_00000000, 0);
|
||||
try test__clzdi2(0xFE000000_00000000, 0);
|
||||
try test__clzdi2(0xFF000000_00000000, 0);
|
||||
|
||||
try test__clzdi2(0x00000000_00000000, 64);
|
||||
try test__clzdi2(0x00000000_00000001, 63);
|
||||
try test__clzdi2(0x00000000_00000002, 62);
|
||||
try test__clzdi2(0x00000000_00000004, 61);
|
||||
try test__clzdi2(0x00000000_00000008, 60);
|
||||
try test__clzdi2(0x00000000_00000010, 59);
|
||||
try test__clzdi2(0x00000000_00000020, 58);
|
||||
try test__clzdi2(0x00000000_00000040, 57);
|
||||
try test__clzdi2(0x00000000_00000080, 56);
|
||||
try test__clzdi2(0x00000000_00000100, 55);
|
||||
try test__clzdi2(0x00000000_00000200, 54);
|
||||
try test__clzdi2(0x00000000_00000400, 53);
|
||||
try test__clzdi2(0x00000000_00000800, 52);
|
||||
try test__clzdi2(0x00000000_00001000, 51);
|
||||
try test__clzdi2(0x00000000_00002000, 50);
|
||||
try test__clzdi2(0x00000000_00004000, 49);
|
||||
try test__clzdi2(0x00000000_00008000, 48);
|
||||
try test__clzdi2(0x00000000_00010000, 47);
|
||||
try test__clzdi2(0x00000000_00020000, 46);
|
||||
try test__clzdi2(0x00000000_00040000, 45);
|
||||
try test__clzdi2(0x00000000_00080000, 44);
|
||||
try test__clzdi2(0x00000000_00100000, 43);
|
||||
try test__clzdi2(0x00000000_00200000, 42);
|
||||
try test__clzdi2(0x00000000_00400000, 41);
|
||||
try test__clzdi2(0x00000000_00800000, 40);
|
||||
try test__clzdi2(0x00000000_01000000, 39);
|
||||
try test__clzdi2(0x00000000_02000000, 38);
|
||||
try test__clzdi2(0x00000000_04000000, 37);
|
||||
try test__clzdi2(0x00000000_08000000, 36);
|
||||
try test__clzdi2(0x00000000_10000000, 35);
|
||||
try test__clzdi2(0x00000000_20000000, 34);
|
||||
try test__clzdi2(0x00000000_40000000, 33);
|
||||
try test__clzdi2(0x00000000_80000000, 32);
|
||||
|
||||
try test__clzdi2(0x00000001_00000000, 31);
|
||||
try test__clzdi2(0x00000002_00000000, 30);
|
||||
try test__clzdi2(0x00000004_00000000, 29);
|
||||
try test__clzdi2(0x00000008_00000000, 28);
|
||||
try test__clzdi2(0x00000010_00000000, 27);
|
||||
try test__clzdi2(0x00000020_00000000, 26);
|
||||
try test__clzdi2(0x00000040_00000000, 25);
|
||||
try test__clzdi2(0x00000080_00000000, 24);
|
||||
try test__clzdi2(0x00000100_00000000, 23);
|
||||
try test__clzdi2(0x00000200_00000000, 22);
|
||||
try test__clzdi2(0x00000400_00000000, 21);
|
||||
try test__clzdi2(0x00000800_00000000, 20);
|
||||
try test__clzdi2(0x00001000_00000000, 19);
|
||||
try test__clzdi2(0x00002000_00000000, 18);
|
||||
try test__clzdi2(0x00004000_00000000, 17);
|
||||
try test__clzdi2(0x00008000_00000000, 16);
|
||||
try test__clzdi2(0x00010000_00000000, 15);
|
||||
try test__clzdi2(0x00020000_00000000, 14);
|
||||
try test__clzdi2(0x00040000_00000000, 13);
|
||||
try test__clzdi2(0x00080000_00000000, 12);
|
||||
try test__clzdi2(0x00100000_00000000, 11);
|
||||
try test__clzdi2(0x00200000_00000000, 10);
|
||||
try test__clzdi2(0x00400000_00000000, 9);
|
||||
}
|
||||
@@ -1,391 +0,0 @@
|
||||
const clz = @import("count0bits.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__clzti2(a: u128, expected: i64) !void {
|
||||
var x = @bitCast(i128, a);
|
||||
var result = clz.__clzti2(x);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "clzti2" {
|
||||
try test__clzti2(0x00800000_00000000_00000000_00000000, 8);
|
||||
try test__clzti2(0x01000000_00000000_00000000_00000000, 7);
|
||||
try test__clzti2(0x02000000_00000000_00000000_00000000, 6);
|
||||
try test__clzti2(0x03000000_00000000_00000000_00000000, 6);
|
||||
try test__clzti2(0x04000000_00000000_00000000_00000000, 5);
|
||||
try test__clzti2(0x05000000_00000000_00000000_00000000, 5);
|
||||
try test__clzti2(0x06000000_00000000_00000000_00000000, 5);
|
||||
try test__clzti2(0x07000000_00000000_00000000_00000000, 5);
|
||||
try test__clzti2(0x08000000_00000000_00000000_00000000, 4);
|
||||
try test__clzti2(0x09000000_00000000_00000000_00000000, 4);
|
||||
try test__clzti2(0x0A000000_00000000_00000000_00000000, 4);
|
||||
try test__clzti2(0x0B000000_00000000_00000000_00000000, 4);
|
||||
try test__clzti2(0x0C000000_00000000_00000000_00000000, 4);
|
||||
try test__clzti2(0x0D000000_00000000_00000000_00000000, 4);
|
||||
try test__clzti2(0x0E000000_00000000_00000000_00000000, 4);
|
||||
try test__clzti2(0x0F000000_00000000_00000000_00000000, 4);
|
||||
try test__clzti2(0x10000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x11000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x12000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x13000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x14000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x15000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x16000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x17000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x18000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x19000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x1A000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x1B000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x1C000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x1D000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x1E000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x1F000000_00000000_00000000_00000000, 3);
|
||||
try test__clzti2(0x20000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x21000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x22000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x23000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x24000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x25000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x26000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x27000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x28000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x29000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x2A000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x2B000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x2C000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x2D000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x2E000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x2F000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x30000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x31000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x32000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x33000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x34000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x35000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x36000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x37000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x38000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x39000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x3A000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x3B000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x3C000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x3D000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x3E000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x3F000000_00000000_00000000_00000000, 2);
|
||||
try test__clzti2(0x40000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x41000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x42000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x43000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x44000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x45000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x46000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x47000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x48000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x49000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x4A000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x4B000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x4C000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x4D000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x4E000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x4F000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x50000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x51000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x52000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x53000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x54000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x55000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x56000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x57000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x58000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x59000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x5A000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x5B000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x5C000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x5D000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x5E000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x5F000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x60000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x61000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x62000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x63000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x64000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x65000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x66000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x67000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x68000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x69000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x6A000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x6B000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x6C000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x6D000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x6E000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x6F000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x70000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x71000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x72000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x73000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x74000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x75000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x76000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x77000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x78000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x79000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x7A000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x7B000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x7C000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x7D000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x7E000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x7F000000_00000000_00000000_00000000, 1);
|
||||
try test__clzti2(0x80000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x81000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x82000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x83000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x84000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x85000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x86000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x87000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x88000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x89000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x8A000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x8B000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x8C000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x8D000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x8E000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x8F000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x90000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x91000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x92000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x93000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x94000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x95000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x96000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x97000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x98000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x99000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x9A000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x9B000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x9C000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x9D000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x9E000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0x9F000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA0000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA1000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA2000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA3000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA4000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA5000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA6000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA7000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA8000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xA9000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xAA000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xAB000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xAC000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xAD000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xAE000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xAF000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB0000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB1000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB2000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB3000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB4000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB5000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB6000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB7000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB8000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xB9000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xBA000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xBB000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xBC000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xBD000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xBE000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xBF000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC0000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC1000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC2000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC3000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC4000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC5000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC6000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC7000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC8000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xC9000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xCA000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xCB000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xCC000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xCD000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xCE000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xCF000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD0000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD1000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD2000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD3000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD4000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD5000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD6000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD7000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD8000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xD9000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xDA000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xDB000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xDC000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xDD000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xDE000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xDF000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE0000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE1000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE2000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE3000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE4000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE5000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE6000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE7000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE8000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xE9000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xEA000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xEB000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xEC000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xED000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xEE000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xEF000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF0000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF1000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF2000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF3000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF4000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF5000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF6000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF7000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF8000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xF9000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xFA000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xFB000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xFC000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xFD000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xFE000000_00000000_00000000_00000000, 0);
|
||||
try test__clzti2(0xFF000000_00000000_00000000_00000000, 0);
|
||||
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000000, 128);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000001, 127);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000002, 126);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000004, 125);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000008, 124);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000010, 123);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000020, 122);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000040, 121);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000080, 120);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000100, 119);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000200, 118);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000400, 117);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00000800, 116);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00001000, 115);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00002000, 114);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00004000, 113);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00008000, 112);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00010000, 111);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00020000, 110);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00040000, 109);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00080000, 108);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00100000, 107);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00200000, 106);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00400000, 105);
|
||||
try test__clzti2(0x00000000_00000000_00000000_00800000, 104);
|
||||
try test__clzti2(0x00000000_00000000_00000000_01000000, 103);
|
||||
try test__clzti2(0x00000000_00000000_00000000_02000000, 102);
|
||||
try test__clzti2(0x00000000_00000000_00000000_04000000, 101);
|
||||
try test__clzti2(0x00000000_00000000_00000000_08000000, 100);
|
||||
try test__clzti2(0x00000000_00000000_00000000_10000000, 99);
|
||||
try test__clzti2(0x00000000_00000000_00000000_20000000, 98);
|
||||
try test__clzti2(0x00000000_00000000_00000000_40000000, 97);
|
||||
try test__clzti2(0x00000000_00000000_00000000_80000000, 96);
|
||||
|
||||
try test__clzti2(0x00000000_00000000_00000001_00000000, 95);
|
||||
try test__clzti2(0x00000000_00000000_00000002_00000000, 94);
|
||||
try test__clzti2(0x00000000_00000000_00000004_00000000, 93);
|
||||
try test__clzti2(0x00000000_00000000_00000008_00000000, 92);
|
||||
try test__clzti2(0x00000000_00000000_00000010_00000000, 91);
|
||||
try test__clzti2(0x00000000_00000000_00000020_00000000, 90);
|
||||
try test__clzti2(0x00000000_00000000_00000040_00000000, 89);
|
||||
try test__clzti2(0x00000000_00000000_00000080_00000000, 88);
|
||||
try test__clzti2(0x00000000_00000000_00000100_00000000, 87);
|
||||
try test__clzti2(0x00000000_00000000_00000200_00000000, 86);
|
||||
try test__clzti2(0x00000000_00000000_00000400_00000000, 85);
|
||||
try test__clzti2(0x00000000_00000000_00000800_00000000, 84);
|
||||
try test__clzti2(0x00000000_00000000_00001000_00000000, 83);
|
||||
try test__clzti2(0x00000000_00000000_00002000_00000000, 82);
|
||||
try test__clzti2(0x00000000_00000000_00004000_00000000, 81);
|
||||
try test__clzti2(0x00000000_00000000_00008000_00000000, 80);
|
||||
try test__clzti2(0x00000000_00000000_00010000_00000000, 79);
|
||||
try test__clzti2(0x00000000_00000000_00020000_00000000, 78);
|
||||
try test__clzti2(0x00000000_00000000_00040000_00000000, 77);
|
||||
try test__clzti2(0x00000000_00000000_00080000_00000000, 76);
|
||||
try test__clzti2(0x00000000_00000000_00100000_00000000, 75);
|
||||
try test__clzti2(0x00000000_00000000_00200000_00000000, 74);
|
||||
try test__clzti2(0x00000000_00000000_00400000_00000000, 73);
|
||||
try test__clzti2(0x00000000_00000000_00800000_00000000, 72);
|
||||
try test__clzti2(0x00000000_00000000_01000000_00000000, 71);
|
||||
try test__clzti2(0x00000000_00000000_02000000_00000000, 70);
|
||||
try test__clzti2(0x00000000_00000000_04000000_00000000, 69);
|
||||
try test__clzti2(0x00000000_00000000_08000000_00000000, 68);
|
||||
try test__clzti2(0x00000000_00000000_10000000_00000000, 67);
|
||||
try test__clzti2(0x00000000_00000000_20000000_00000000, 66);
|
||||
try test__clzti2(0x00000000_00000000_40000000_00000000, 65);
|
||||
try test__clzti2(0x00000000_00000000_80000000_00000000, 64);
|
||||
|
||||
try test__clzti2(0x00000000_00000001_00000000_00000000, 63);
|
||||
try test__clzti2(0x00000000_00000002_00000000_00000000, 62);
|
||||
try test__clzti2(0x00000000_00000004_00000000_00000000, 61);
|
||||
try test__clzti2(0x00000000_00000008_00000000_00000000, 60);
|
||||
try test__clzti2(0x00000000_00000010_00000000_00000000, 59);
|
||||
try test__clzti2(0x00000000_00000020_00000000_00000000, 58);
|
||||
try test__clzti2(0x00000000_00000040_00000000_00000000, 57);
|
||||
try test__clzti2(0x00000000_00000080_00000000_00000000, 56);
|
||||
try test__clzti2(0x00000000_00000100_00000000_00000000, 55);
|
||||
try test__clzti2(0x00000000_00000200_00000000_00000000, 54);
|
||||
try test__clzti2(0x00000000_00000400_00000000_00000000, 53);
|
||||
try test__clzti2(0x00000000_00000800_00000000_00000000, 52);
|
||||
try test__clzti2(0x00000000_00001000_00000000_00000000, 51);
|
||||
try test__clzti2(0x00000000_00002000_00000000_00000000, 50);
|
||||
try test__clzti2(0x00000000_00004000_00000000_00000000, 49);
|
||||
try test__clzti2(0x00000000_00008000_00000000_00000000, 48);
|
||||
try test__clzti2(0x00000000_00010000_00000000_00000000, 47);
|
||||
try test__clzti2(0x00000000_00020000_00000000_00000000, 46);
|
||||
try test__clzti2(0x00000000_00040000_00000000_00000000, 45);
|
||||
try test__clzti2(0x00000000_00080000_00000000_00000000, 44);
|
||||
try test__clzti2(0x00000000_00100000_00000000_00000000, 43);
|
||||
try test__clzti2(0x00000000_00200000_00000000_00000000, 42);
|
||||
try test__clzti2(0x00000000_00400000_00000000_00000000, 41);
|
||||
try test__clzti2(0x00000000_00800000_00000000_00000000, 40);
|
||||
try test__clzti2(0x00000000_01000000_00000000_00000000, 39);
|
||||
try test__clzti2(0x00000000_02000000_00000000_00000000, 38);
|
||||
try test__clzti2(0x00000000_04000000_00000000_00000000, 37);
|
||||
try test__clzti2(0x00000000_08000000_00000000_00000000, 36);
|
||||
try test__clzti2(0x00000000_10000000_00000000_00000000, 35);
|
||||
try test__clzti2(0x00000000_20000000_00000000_00000000, 34);
|
||||
try test__clzti2(0x00000000_40000000_00000000_00000000, 33);
|
||||
try test__clzti2(0x00000000_80000000_00000000_00000000, 32);
|
||||
|
||||
try test__clzti2(0x00000001_00000000_00000000_00000000, 31);
|
||||
try test__clzti2(0x00000002_00000000_00000000_00000000, 30);
|
||||
try test__clzti2(0x00000004_00000000_00000000_00000000, 29);
|
||||
try test__clzti2(0x00000008_00000000_00000000_00000000, 28);
|
||||
try test__clzti2(0x00000010_00000000_00000000_00000000, 27);
|
||||
try test__clzti2(0x00000020_00000000_00000000_00000000, 26);
|
||||
try test__clzti2(0x00000040_00000000_00000000_00000000, 25);
|
||||
try test__clzti2(0x00000080_00000000_00000000_00000000, 24);
|
||||
try test__clzti2(0x00000100_00000000_00000000_00000000, 23);
|
||||
try test__clzti2(0x00000200_00000000_00000000_00000000, 22);
|
||||
try test__clzti2(0x00000400_00000000_00000000_00000000, 21);
|
||||
try test__clzti2(0x00000800_00000000_00000000_00000000, 20);
|
||||
try test__clzti2(0x00001000_00000000_00000000_00000000, 19);
|
||||
try test__clzti2(0x00002000_00000000_00000000_00000000, 18);
|
||||
try test__clzti2(0x00004000_00000000_00000000_00000000, 17);
|
||||
try test__clzti2(0x00008000_00000000_00000000_00000000, 16);
|
||||
try test__clzti2(0x00010000_00000000_00000000_00000000, 15);
|
||||
try test__clzti2(0x00020000_00000000_00000000_00000000, 14);
|
||||
try test__clzti2(0x00040000_00000000_00000000_00000000, 13);
|
||||
try test__clzti2(0x00080000_00000000_00000000_00000000, 12);
|
||||
try test__clzti2(0x00100000_00000000_00000000_00000000, 11);
|
||||
try test__clzti2(0x00200000_00000000_00000000_00000000, 10);
|
||||
try test__clzti2(0x00400000_00000000_00000000_00000000, 9);
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__cmpsi2, .{ .name = "__cmpsi2", .linkage = common.linkage });
|
||||
@export(__cmpdi2, .{ .name = "__cmpdi2", .linkage = common.linkage });
|
||||
@export(__cmpti2, .{ .name = "__cmpti2", .linkage = common.linkage });
|
||||
@export(__ucmpsi2, .{ .name = "__ucmpsi2", .linkage = common.linkage });
|
||||
@export(__ucmpdi2, .{ .name = "__ucmpdi2", .linkage = common.linkage });
|
||||
@export(__ucmpti2, .{ .name = "__ucmpti2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
// cmp - signed compare
|
||||
// - cmpXi2_generic for unoptimized little and big endian
|
||||
|
||||
// ucmp - unsigned compare
|
||||
// - ucmpXi2_generic for unoptimized little and big endian
|
||||
|
||||
// a < b => 0
|
||||
// a == b => 1
|
||||
// a > b => 2
|
||||
|
||||
inline fn XcmpXi2(comptime T: type, a: T, b: T) i32 {
|
||||
var cmp1: i32 = 0;
|
||||
var cmp2: i32 = 0;
|
||||
if (a > b)
|
||||
cmp1 = 1;
|
||||
if (a < b)
|
||||
cmp2 = 1;
|
||||
return cmp1 - cmp2 + 1;
|
||||
}
|
||||
|
||||
pub fn __cmpsi2(a: i32, b: i32) callconv(.C) i32 {
|
||||
return XcmpXi2(i32, a, b);
|
||||
}
|
||||
|
||||
pub fn __cmpdi2(a: i64, b: i64) callconv(.C) i32 {
|
||||
return XcmpXi2(i64, a, b);
|
||||
}
|
||||
|
||||
pub fn __cmpti2(a: i128, b: i128) callconv(.C) i32 {
|
||||
return XcmpXi2(i128, a, b);
|
||||
}
|
||||
|
||||
pub fn __ucmpsi2(a: u32, b: u32) callconv(.C) i32 {
|
||||
return XcmpXi2(u32, a, b);
|
||||
}
|
||||
|
||||
pub fn __ucmpdi2(a: u64, b: u64) callconv(.C) i32 {
|
||||
return XcmpXi2(u64, a, b);
|
||||
}
|
||||
|
||||
pub fn __ucmpti2(a: u128, b: u128) callconv(.C) i32 {
|
||||
return XcmpXi2(u128, a, b);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("cmpsi2_test.zig");
|
||||
_ = @import("cmpdi2_test.zig");
|
||||
_ = @import("cmpti2_test.zig");
|
||||
|
||||
_ = @import("ucmpsi2_test.zig");
|
||||
_ = @import("ucmpdi2_test.zig");
|
||||
_ = @import("ucmpti2_test.zig");
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_aeabi) {
|
||||
@export(__aeabi_dcmpeq, .{ .name = "__aeabi_dcmpeq", .linkage = common.linkage });
|
||||
@export(__aeabi_dcmplt, .{ .name = "__aeabi_dcmplt", .linkage = common.linkage });
|
||||
@export(__aeabi_dcmple, .{ .name = "__aeabi_dcmple", .linkage = common.linkage });
|
||||
} else {
|
||||
@export(__eqdf2, .{ .name = "__eqdf2", .linkage = common.linkage });
|
||||
@export(__nedf2, .{ .name = "__nedf2", .linkage = common.linkage });
|
||||
@export(__ledf2, .{ .name = "__ledf2", .linkage = common.linkage });
|
||||
@export(__cmpdf2, .{ .name = "__cmpdf2", .linkage = common.linkage });
|
||||
@export(__ltdf2, .{ .name = "__ltdf2", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__ledf2`, `__eqdf2`, `__nedf2`, `__cmpdf2`,
|
||||
/// and `__ltdf2`.
|
||||
fn __cmpdf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f64, comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
pub fn __ledf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return __cmpdf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqdf2 and __nedf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __eqdf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return __cmpdf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqdf2 and __nedf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __nedf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return __cmpdf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
pub fn __ltdf2(a: f64, b: f64) callconv(.C) i32 {
|
||||
return __cmpdf2(a, b);
|
||||
}
|
||||
|
||||
fn __aeabi_dcmpeq(a: f64, b: f64) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Equal);
|
||||
}
|
||||
|
||||
fn __aeabi_dcmplt(a: f64, b: f64) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) == .Less);
|
||||
}
|
||||
|
||||
fn __aeabi_dcmple(a: f64, b: f64) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f64, comparef.LE, a, b) != .Greater);
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
const cmp = @import("cmp.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__cmpdi2(a: i64, b: i64, expected: i64) !void {
|
||||
var result = cmp.__cmpdi2(a, b);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "cmpdi2" {
|
||||
// minInt == -9223372036854775808
|
||||
// maxInt == 9223372036854775807
|
||||
// minInt/2 == -4611686018427387904
|
||||
// maxInt/2 == 4611686018427387903
|
||||
// 1. equality minInt, minInt+1, minInt/2, 0, maxInt/2, maxInt-1, maxInt
|
||||
try test__cmpdi2(-9223372036854775808, -9223372036854775808, 1);
|
||||
try test__cmpdi2(-9223372036854775807, -9223372036854775807, 1);
|
||||
try test__cmpdi2(-4611686018427387904, -4611686018427387904, 1);
|
||||
try test__cmpdi2(-1, -1, 1);
|
||||
try test__cmpdi2(0, 0, 1);
|
||||
try test__cmpdi2(1, 1, 1);
|
||||
try test__cmpdi2(4611686018427387903, 4611686018427387903, 1);
|
||||
try test__cmpdi2(9223372036854775806, 9223372036854775806, 1);
|
||||
try test__cmpdi2(9223372036854775807, 9223372036854775807, 1);
|
||||
// 2. cmp minInt, { minInt + 1, minInt/2, -1, 0, 1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpdi2(-9223372036854775808, -9223372036854775807, 0);
|
||||
try test__cmpdi2(-9223372036854775808, -4611686018427387904, 0);
|
||||
try test__cmpdi2(-9223372036854775808, -1, 0);
|
||||
try test__cmpdi2(-9223372036854775808, 0, 0);
|
||||
try test__cmpdi2(-9223372036854775808, 1, 0);
|
||||
try test__cmpdi2(-9223372036854775808, 4611686018427387903, 0);
|
||||
try test__cmpdi2(-9223372036854775808, 9223372036854775806, 0);
|
||||
try test__cmpdi2(-9223372036854775808, 9223372036854775807, 0);
|
||||
// 3. cmp minInt+1, {minInt, minInt/2, -1,0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpdi2(-9223372036854775807, -9223372036854775808, 2);
|
||||
try test__cmpdi2(-9223372036854775807, -4611686018427387904, 0);
|
||||
try test__cmpdi2(-9223372036854775807, -1, 0);
|
||||
try test__cmpdi2(-9223372036854775807, 0, 0);
|
||||
try test__cmpdi2(-9223372036854775807, 1, 0);
|
||||
try test__cmpdi2(-9223372036854775807, 4611686018427387903, 0);
|
||||
try test__cmpdi2(-9223372036854775807, 9223372036854775806, 0);
|
||||
try test__cmpdi2(-9223372036854775807, 9223372036854775807, 0);
|
||||
// 4. cmp minInt/2, {minInt, minInt + 1, -1,0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpdi2(-4611686018427387904, -9223372036854775808, 2);
|
||||
try test__cmpdi2(-4611686018427387904, -9223372036854775807, 2);
|
||||
try test__cmpdi2(-4611686018427387904, -1, 0);
|
||||
try test__cmpdi2(-4611686018427387904, 0, 0);
|
||||
try test__cmpdi2(-4611686018427387904, 1, 0);
|
||||
try test__cmpdi2(-4611686018427387904, 4611686018427387903, 0);
|
||||
try test__cmpdi2(-4611686018427387904, 9223372036854775806, 0);
|
||||
try test__cmpdi2(-4611686018427387904, 9223372036854775807, 0);
|
||||
// 5. cmp -1, {minInt, minInt + 1, minInt/2, 0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpdi2(-1, -9223372036854775808, 2);
|
||||
try test__cmpdi2(-1, -9223372036854775807, 2);
|
||||
try test__cmpdi2(-1, -4611686018427387904, 2);
|
||||
try test__cmpdi2(-1, 0, 0);
|
||||
try test__cmpdi2(-1, 1, 0);
|
||||
try test__cmpdi2(-1, 4611686018427387903, 0);
|
||||
try test__cmpdi2(-1, 9223372036854775806, 0);
|
||||
try test__cmpdi2(-1, 9223372036854775807, 0);
|
||||
// 6. cmp 0, {minInt, minInt + 1, minInt/2, -1, 1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpdi2(0, -9223372036854775808, 2);
|
||||
try test__cmpdi2(0, -9223372036854775807, 2);
|
||||
try test__cmpdi2(0, -4611686018427387904, 2);
|
||||
try test__cmpdi2(0, -1, 2);
|
||||
try test__cmpdi2(0, 1, 0);
|
||||
try test__cmpdi2(0, 4611686018427387903, 0);
|
||||
try test__cmpdi2(0, 9223372036854775806, 0);
|
||||
try test__cmpdi2(0, 9223372036854775807, 0);
|
||||
// 7. cmp 1, {minInt, minInt + 1, minInt/2, -1,0, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpdi2(1, -9223372036854775808, 2);
|
||||
try test__cmpdi2(1, -9223372036854775807, 2);
|
||||
try test__cmpdi2(1, -4611686018427387904, 2);
|
||||
try test__cmpdi2(1, -1, 2);
|
||||
try test__cmpdi2(1, 0, 2);
|
||||
try test__cmpdi2(1, 4611686018427387903, 0);
|
||||
try test__cmpdi2(1, 9223372036854775806, 0);
|
||||
try test__cmpdi2(1, 9223372036854775807, 0);
|
||||
// 8. cmp maxInt/2, {minInt, minInt + 1, minInt/2, -1,0,1, maxInt-1, maxInt}
|
||||
try test__cmpdi2(4611686018427387903, -9223372036854775808, 2);
|
||||
try test__cmpdi2(4611686018427387903, -9223372036854775807, 2);
|
||||
try test__cmpdi2(4611686018427387903, -4611686018427387904, 2);
|
||||
try test__cmpdi2(4611686018427387903, -1, 2);
|
||||
try test__cmpdi2(4611686018427387903, 0, 2);
|
||||
try test__cmpdi2(4611686018427387903, 1, 2);
|
||||
try test__cmpdi2(4611686018427387903, 9223372036854775806, 0);
|
||||
try test__cmpdi2(4611686018427387903, 9223372036854775807, 0);
|
||||
// 9. cmp maxInt-1, {minInt, minInt + 1, minInt/2, -1,0,1, maxInt/2, maxInt}
|
||||
try test__cmpdi2(9223372036854775806, -9223372036854775808, 2);
|
||||
try test__cmpdi2(9223372036854775806, -9223372036854775807, 2);
|
||||
try test__cmpdi2(9223372036854775806, -4611686018427387904, 2);
|
||||
try test__cmpdi2(9223372036854775806, -1, 2);
|
||||
try test__cmpdi2(9223372036854775806, 0, 2);
|
||||
try test__cmpdi2(9223372036854775806, 1, 2);
|
||||
try test__cmpdi2(9223372036854775806, 4611686018427387903, 2);
|
||||
try test__cmpdi2(9223372036854775806, 9223372036854775807, 0);
|
||||
// 10.cmp maxInt, {minInt, minInt + 1, minInt/2, -1,0,1, maxInt/2, maxInt-1, }
|
||||
try test__cmpdi2(9223372036854775807, -9223372036854775808, 2);
|
||||
try test__cmpdi2(9223372036854775807, -9223372036854775807, 2);
|
||||
try test__cmpdi2(9223372036854775807, -4611686018427387904, 2);
|
||||
try test__cmpdi2(9223372036854775807, -1, 2);
|
||||
try test__cmpdi2(9223372036854775807, 0, 2);
|
||||
try test__cmpdi2(9223372036854775807, 1, 2);
|
||||
try test__cmpdi2(9223372036854775807, 4611686018427387903, 2);
|
||||
try test__cmpdi2(9223372036854775807, 9223372036854775806, 2);
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__eqhf2, .{ .name = "__eqhf2", .linkage = common.linkage });
|
||||
@export(__nehf2, .{ .name = "__nehf2", .linkage = common.linkage });
|
||||
@export(__lehf2, .{ .name = "__lehf2", .linkage = common.linkage });
|
||||
@export(__cmphf2, .{ .name = "__cmphf2", .linkage = common.linkage });
|
||||
@export(__lthf2, .{ .name = "__lthf2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__lehf2`, `__eqhf2`, `__nehf2`, `__cmphf2`,
|
||||
/// and `__lthf2`.
|
||||
fn __cmphf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f16, comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
pub fn __lehf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return __cmphf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __eqhf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return __cmphf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqhf2 and __nehf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __nehf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return __cmphf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
pub fn __lthf2(a: f16, b: f16) callconv(.C) i32 {
|
||||
return __cmphf2(a, b);
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_aeabi) {
|
||||
@export(__aeabi_fcmpeq, .{ .name = "__aeabi_fcmpeq", .linkage = common.linkage });
|
||||
@export(__aeabi_fcmplt, .{ .name = "__aeabi_fcmplt", .linkage = common.linkage });
|
||||
@export(__aeabi_fcmple, .{ .name = "__aeabi_fcmple", .linkage = common.linkage });
|
||||
} else {
|
||||
@export(__eqsf2, .{ .name = "__eqsf2", .linkage = common.linkage });
|
||||
@export(__nesf2, .{ .name = "__nesf2", .linkage = common.linkage });
|
||||
@export(__lesf2, .{ .name = "__lesf2", .linkage = common.linkage });
|
||||
@export(__cmpsf2, .{ .name = "__cmpsf2", .linkage = common.linkage });
|
||||
@export(__ltsf2, .{ .name = "__ltsf2", .linkage = common.linkage });
|
||||
}
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__lesf2`, `__eqsf2`, `__nesf2`, `__cmpsf2`,
|
||||
/// and `__ltsf2`.
|
||||
fn __cmpsf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f32, comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
pub fn __lesf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return __cmpsf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __eqsf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return __cmpsf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqsf2 and __nesf2 are defined
|
||||
/// to have the same return value.
|
||||
pub fn __nesf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return __cmpsf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
pub fn __ltsf2(a: f32, b: f32) callconv(.C) i32 {
|
||||
return __cmpsf2(a, b);
|
||||
}
|
||||
|
||||
fn __aeabi_fcmpeq(a: f32, b: f32) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Equal);
|
||||
}
|
||||
|
||||
fn __aeabi_fcmplt(a: f32, b: f32) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) == .Less);
|
||||
}
|
||||
|
||||
fn __aeabi_fcmple(a: f32, b: f32) callconv(.AAPCS) i32 {
|
||||
return @boolToInt(comparef.cmpf2(f32, comparef.LE, a, b) != .Greater);
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
const cmp = @import("cmp.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__cmpsi2(a: i32, b: i32, expected: i32) !void {
|
||||
var result = cmp.__cmpsi2(a, b);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "cmpsi2" {
|
||||
// minInt == -2147483648
|
||||
// maxInt == 2147483647
|
||||
// minInt/2 == -1073741824
|
||||
// maxInt/2 == 1073741823
|
||||
// 1. equality minInt, minInt+1, minInt/2, -1, 0, 1, maxInt/2, maxInt-1, maxInt
|
||||
try test__cmpsi2(-2147483648, -2147483648, 1);
|
||||
try test__cmpsi2(-2147483647, -2147483647, 1);
|
||||
try test__cmpsi2(-1073741824, -1073741824, 1);
|
||||
try test__cmpsi2(-1, -1, 1);
|
||||
try test__cmpsi2(0, 0, 1);
|
||||
try test__cmpsi2(1, 1, 1);
|
||||
try test__cmpsi2(1073741823, 1073741823, 1);
|
||||
try test__cmpsi2(2147483646, 2147483646, 1);
|
||||
try test__cmpsi2(2147483647, 2147483647, 1);
|
||||
// 2. cmp minInt, { minInt + 1, minInt/2, -1,0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpsi2(-2147483648, -2147483647, 0);
|
||||
try test__cmpsi2(-2147483648, -1073741824, 0);
|
||||
try test__cmpsi2(-2147483648, -1, 0);
|
||||
try test__cmpsi2(-2147483648, 0, 0);
|
||||
try test__cmpsi2(-2147483648, 1, 0);
|
||||
try test__cmpsi2(-2147483648, 1073741823, 0);
|
||||
try test__cmpsi2(-2147483648, 2147483646, 0);
|
||||
try test__cmpsi2(-2147483648, 2147483647, 0);
|
||||
// 3. cmp minInt+1, {minInt, minInt/2, -1,0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpsi2(-2147483647, -2147483648, 2);
|
||||
try test__cmpsi2(-2147483647, -1073741824, 0);
|
||||
try test__cmpsi2(-2147483647, -1, 0);
|
||||
try test__cmpsi2(-2147483647, 0, 0);
|
||||
try test__cmpsi2(-2147483647, 1, 0);
|
||||
try test__cmpsi2(-2147483647, 1073741823, 0);
|
||||
try test__cmpsi2(-2147483647, 2147483646, 0);
|
||||
try test__cmpsi2(-2147483647, 2147483647, 0);
|
||||
// 4. cmp minInt/2, {minInt, minInt + 1, -1,0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpsi2(-1073741824, -2147483648, 2);
|
||||
try test__cmpsi2(-1073741824, -2147483647, 2);
|
||||
try test__cmpsi2(-1073741824, -1, 0);
|
||||
try test__cmpsi2(-1073741824, 0, 0);
|
||||
try test__cmpsi2(-1073741824, 1, 0);
|
||||
try test__cmpsi2(-1073741824, 1073741823, 0);
|
||||
try test__cmpsi2(-1073741824, 2147483646, 0);
|
||||
try test__cmpsi2(-1073741824, 2147483647, 0);
|
||||
// 5. cmp -1, {minInt, minInt + 1, minInt/2, 0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpsi2(-1, -2147483648, 2);
|
||||
try test__cmpsi2(-1, -2147483647, 2);
|
||||
try test__cmpsi2(-1, -1073741824, 2);
|
||||
try test__cmpsi2(-1, 0, 0);
|
||||
try test__cmpsi2(-1, 1, 0);
|
||||
try test__cmpsi2(-1, 1073741823, 0);
|
||||
try test__cmpsi2(-1, 2147483646, 0);
|
||||
try test__cmpsi2(-1, 2147483647, 0);
|
||||
// 6. cmp 0, {minInt, minInt + 1, minInt/2, -1, 1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpsi2(0, -2147483648, 2);
|
||||
try test__cmpsi2(0, -2147483647, 2);
|
||||
try test__cmpsi2(0, -1073741824, 2);
|
||||
try test__cmpsi2(0, -1, 2);
|
||||
try test__cmpsi2(0, 1, 0);
|
||||
try test__cmpsi2(0, 1073741823, 0);
|
||||
try test__cmpsi2(0, 2147483646, 0);
|
||||
try test__cmpsi2(0, 2147483647, 0);
|
||||
// 7. cmp 1, {minInt, minInt + 1, minInt/2, -1,0, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpsi2(1, -2147483648, 2);
|
||||
try test__cmpsi2(1, -2147483647, 2);
|
||||
try test__cmpsi2(1, -1073741824, 2);
|
||||
try test__cmpsi2(1, -1, 2);
|
||||
try test__cmpsi2(1, 0, 2);
|
||||
try test__cmpsi2(1, 1073741823, 0);
|
||||
try test__cmpsi2(1, 2147483646, 0);
|
||||
try test__cmpsi2(1, 2147483647, 0);
|
||||
// 8. cmp maxInt/2, {minInt, minInt + 1, minInt/2, -1, 0, 1, maxInt-1, maxInt}
|
||||
try test__cmpsi2(1073741823, -2147483648, 2);
|
||||
try test__cmpsi2(1073741823, -2147483647, 2);
|
||||
try test__cmpsi2(1073741823, -1073741824, 2);
|
||||
try test__cmpsi2(1073741823, -1, 2);
|
||||
try test__cmpsi2(1073741823, 0, 2);
|
||||
try test__cmpsi2(1073741823, 1, 2);
|
||||
try test__cmpsi2(1073741823, 2147483646, 0);
|
||||
try test__cmpsi2(1073741823, 2147483647, 0);
|
||||
// 9. cmp maxInt-1, {minInt, minInt + 1, minInt/2, -1, 0, 1, maxInt/2, maxInt}
|
||||
try test__cmpsi2(2147483646, -2147483648, 2);
|
||||
try test__cmpsi2(2147483646, -2147483647, 2);
|
||||
try test__cmpsi2(2147483646, -1073741824, 2);
|
||||
try test__cmpsi2(2147483646, -1, 2);
|
||||
try test__cmpsi2(2147483646, 0, 2);
|
||||
try test__cmpsi2(2147483646, 1, 2);
|
||||
try test__cmpsi2(2147483646, 1073741823, 2);
|
||||
try test__cmpsi2(2147483646, 2147483647, 0);
|
||||
// 10.cmp maxInt, {minInt, minInt + 1, minInt/2, -1, 0, 1, maxInt/2, maxInt-1, }
|
||||
try test__cmpsi2(2147483647, -2147483648, 2);
|
||||
try test__cmpsi2(2147483647, -2147483647, 2);
|
||||
try test__cmpsi2(2147483647, -1073741824, 2);
|
||||
try test__cmpsi2(2147483647, -1, 2);
|
||||
try test__cmpsi2(2147483647, 0, 2);
|
||||
try test__cmpsi2(2147483647, 1, 2);
|
||||
try test__cmpsi2(2147483647, 1073741823, 2);
|
||||
try test__cmpsi2(2147483647, 2147483646, 2);
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
if (common.want_ppc_abi) {
|
||||
@export(__eqtf2, .{ .name = "__eqkf2", .linkage = common.linkage });
|
||||
@export(__netf2, .{ .name = "__nekf2", .linkage = common.linkage });
|
||||
@export(__lttf2, .{ .name = "__ltkf2", .linkage = common.linkage });
|
||||
@export(__letf2, .{ .name = "__lekf2", .linkage = common.linkage });
|
||||
} else if (common.want_sparc_abi) {
|
||||
@export(_Qp_cmp, .{ .name = "_Qp_cmp", .linkage = common.linkage });
|
||||
@export(_Qp_feq, .{ .name = "_Qp_feq", .linkage = common.linkage });
|
||||
@export(_Qp_fne, .{ .name = "_Qp_fne", .linkage = common.linkage });
|
||||
@export(_Qp_flt, .{ .name = "_Qp_flt", .linkage = common.linkage });
|
||||
@export(_Qp_fle, .{ .name = "_Qp_fle", .linkage = common.linkage });
|
||||
@export(_Qp_fgt, .{ .name = "_Qp_fgt", .linkage = common.linkage });
|
||||
@export(_Qp_fge, .{ .name = "_Qp_fge", .linkage = common.linkage });
|
||||
}
|
||||
@export(__eqtf2, .{ .name = "__eqtf2", .linkage = common.linkage });
|
||||
@export(__netf2, .{ .name = "__netf2", .linkage = common.linkage });
|
||||
@export(__letf2, .{ .name = "__letf2", .linkage = common.linkage });
|
||||
@export(__cmptf2, .{ .name = "__cmptf2", .linkage = common.linkage });
|
||||
@export(__lttf2, .{ .name = "__lttf2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__letf2`, `__eqtf2`, `__netf2`, `__cmptf2`,
|
||||
/// and `__lttf2`.
|
||||
fn __cmptf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f128, comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
fn __letf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return __cmptf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqtf2 and __netf2 are defined
|
||||
/// to have the same return value.
|
||||
fn __eqtf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return __cmptf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqtf2 and __netf2 are defined
|
||||
/// to have the same return value.
|
||||
fn __netf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return __cmptf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
fn __lttf2(a: f128, b: f128) callconv(.C) i32 {
|
||||
return __cmptf2(a, b);
|
||||
}
|
||||
|
||||
const SparcFCMP = enum(i32) {
|
||||
Equal = 0,
|
||||
Less = 1,
|
||||
Greater = 2,
|
||||
Unordered = 3,
|
||||
};
|
||||
|
||||
fn _Qp_cmp(a: *const f128, b: *const f128) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmpf2(f128, SparcFCMP, a.*, b.*));
|
||||
}
|
||||
|
||||
fn _Qp_feq(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Equal;
|
||||
}
|
||||
|
||||
fn _Qp_fne(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) != .Equal;
|
||||
}
|
||||
|
||||
fn _Qp_flt(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Less;
|
||||
}
|
||||
|
||||
fn _Qp_fgt(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return @intToEnum(SparcFCMP, _Qp_cmp(a, b)) == .Greater;
|
||||
}
|
||||
|
||||
fn _Qp_fge(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
|
||||
.Equal, .Greater => true,
|
||||
.Less, .Unordered => false,
|
||||
};
|
||||
}
|
||||
|
||||
fn _Qp_fle(a: *const f128, b: *const f128) callconv(.C) bool {
|
||||
return switch (@intToEnum(SparcFCMP, _Qp_cmp(a, b))) {
|
||||
.Equal, .Less => true,
|
||||
.Greater, .Unordered => false,
|
||||
};
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
const cmp = @import("cmp.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__cmpti2(a: i128, b: i128, expected: i128) !void {
|
||||
var result = cmp.__cmpti2(a, b);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "cmpti2" {
|
||||
// minInt == -170141183460469231731687303715884105728
|
||||
// maxInt == 170141183460469231731687303715884105727
|
||||
// minInt/2 == -85070591730234615865843651857942052864
|
||||
// maxInt/2 == 85070591730234615865843651857942052863
|
||||
// 1. equality minInt, minInt+1, minInt/2, 0, maxInt/2, maxInt-1, maxInt
|
||||
try test__cmpti2(-170141183460469231731687303715884105728, -170141183460469231731687303715884105728, 1);
|
||||
try test__cmpti2(-170141183460469231731687303715884105727, -170141183460469231731687303715884105727, 1);
|
||||
try test__cmpti2(-85070591730234615865843651857942052864, -85070591730234615865843651857942052864, 1);
|
||||
try test__cmpti2(-1, -1, 1);
|
||||
try test__cmpti2(0, 0, 1);
|
||||
try test__cmpti2(1, 1, 1);
|
||||
try test__cmpti2(85070591730234615865843651857942052863, 85070591730234615865843651857942052863, 1);
|
||||
try test__cmpti2(170141183460469231731687303715884105726, 170141183460469231731687303715884105726, 1);
|
||||
try test__cmpti2(170141183460469231731687303715884105727, 170141183460469231731687303715884105727, 1);
|
||||
// 2. cmp minInt, { minInt + 1, minInt/2, -1,0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpti2(-170141183460469231731687303715884105728, -170141183460469231731687303715884105727, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105728, -85070591730234615865843651857942052864, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105728, -1, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105728, 0, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105728, 1, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105728, 85070591730234615865843651857942052863, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105728, 170141183460469231731687303715884105726, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105728, 170141183460469231731687303715884105727, 0);
|
||||
// 3. cmp minInt+1, {minInt, minInt/2, -1,0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpti2(-170141183460469231731687303715884105727, -170141183460469231731687303715884105728, 2);
|
||||
try test__cmpti2(-170141183460469231731687303715884105727, -85070591730234615865843651857942052864, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105727, -1, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105727, 0, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105727, 1, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105727, 85070591730234615865843651857942052863, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105727, 170141183460469231731687303715884105726, 0);
|
||||
try test__cmpti2(-170141183460469231731687303715884105727, 170141183460469231731687303715884105727, 0);
|
||||
// 4. cmp minInt/2, {minInt, minInt + 1, -1,0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpti2(-85070591730234615865843651857942052864, -170141183460469231731687303715884105728, 2);
|
||||
try test__cmpti2(-85070591730234615865843651857942052864, -170141183460469231731687303715884105727, 2);
|
||||
try test__cmpti2(-85070591730234615865843651857942052864, -1, 0);
|
||||
try test__cmpti2(-85070591730234615865843651857942052864, 0, 0);
|
||||
try test__cmpti2(-85070591730234615865843651857942052864, 1, 0);
|
||||
try test__cmpti2(-85070591730234615865843651857942052864, 85070591730234615865843651857942052863, 0);
|
||||
try test__cmpti2(-85070591730234615865843651857942052864, 170141183460469231731687303715884105726, 0);
|
||||
try test__cmpti2(-85070591730234615865843651857942052864, 170141183460469231731687303715884105727, 0);
|
||||
// 5. cmp -1, {minInt, minInt + 1, minInt/2, 0,1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpti2(-1, -170141183460469231731687303715884105728, 2);
|
||||
try test__cmpti2(-1, -170141183460469231731687303715884105727, 2);
|
||||
try test__cmpti2(-1, -85070591730234615865843651857942052864, 2);
|
||||
try test__cmpti2(-1, 0, 0);
|
||||
try test__cmpti2(-1, 1, 0);
|
||||
try test__cmpti2(-1, 85070591730234615865843651857942052863, 0);
|
||||
try test__cmpti2(-1, 170141183460469231731687303715884105726, 0);
|
||||
try test__cmpti2(-1, 170141183460469231731687303715884105727, 0);
|
||||
// 6. cmp 0, {minInt, minInt + 1, minInt/2, -1, 1, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpti2(0, -170141183460469231731687303715884105728, 2);
|
||||
try test__cmpti2(0, -170141183460469231731687303715884105727, 2);
|
||||
try test__cmpti2(0, -85070591730234615865843651857942052864, 2);
|
||||
try test__cmpti2(0, -1, 2);
|
||||
try test__cmpti2(0, 1, 0);
|
||||
try test__cmpti2(0, 85070591730234615865843651857942052863, 0);
|
||||
try test__cmpti2(0, 170141183460469231731687303715884105726, 0);
|
||||
try test__cmpti2(0, 170141183460469231731687303715884105727, 0);
|
||||
// 7. cmp 1, {minInt, minInt + 1, minInt/2, -1,0, maxInt/2, maxInt-1, maxInt}
|
||||
try test__cmpti2(1, -170141183460469231731687303715884105728, 2);
|
||||
try test__cmpti2(1, -170141183460469231731687303715884105727, 2);
|
||||
try test__cmpti2(1, -85070591730234615865843651857942052864, 2);
|
||||
try test__cmpti2(1, -1, 2);
|
||||
try test__cmpti2(1, 0, 2);
|
||||
try test__cmpti2(1, 85070591730234615865843651857942052863, 0);
|
||||
try test__cmpti2(1, 170141183460469231731687303715884105726, 0);
|
||||
try test__cmpti2(1, 170141183460469231731687303715884105727, 0);
|
||||
// 8. cmp maxInt/2, {minInt, minInt + 1, minInt/2, -1,0,1, maxInt-1, maxInt}
|
||||
try test__cmpti2(85070591730234615865843651857942052863, -170141183460469231731687303715884105728, 2);
|
||||
try test__cmpti2(85070591730234615865843651857942052863, -170141183460469231731687303715884105727, 2);
|
||||
try test__cmpti2(85070591730234615865843651857942052863, -85070591730234615865843651857942052864, 2);
|
||||
try test__cmpti2(85070591730234615865843651857942052863, -1, 2);
|
||||
try test__cmpti2(85070591730234615865843651857942052863, 0, 2);
|
||||
try test__cmpti2(85070591730234615865843651857942052863, 1, 2);
|
||||
try test__cmpti2(85070591730234615865843651857942052863, 170141183460469231731687303715884105726, 0);
|
||||
try test__cmpti2(85070591730234615865843651857942052863, 170141183460469231731687303715884105727, 0);
|
||||
// 9. cmp maxInt-1, {minInt, minInt + 1, minInt/2, -1,0,1, maxInt/2, maxInt}
|
||||
try test__cmpti2(170141183460469231731687303715884105726, -170141183460469231731687303715884105728, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105726, -170141183460469231731687303715884105727, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105726, -85070591730234615865843651857942052864, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105726, -1, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105726, 0, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105726, 1, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105726, 85070591730234615865843651857942052863, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105726, 170141183460469231731687303715884105727, 0);
|
||||
// 10.cmp maxInt, {minInt, minInt + 1, minInt/2, -1,0,1, maxInt/2, maxInt-1, }
|
||||
try test__cmpti2(170141183460469231731687303715884105727, -170141183460469231731687303715884105728, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105727, -170141183460469231731687303715884105727, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105727, -85070591730234615865843651857942052864, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105727, -1, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105727, 0, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105727, 1, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105727, 85070591730234615865843651857942052863, 2);
|
||||
try test__cmpti2(170141183460469231731687303715884105727, 170141183460469231731687303715884105726, 2);
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
///! The quoted behavior definitions are from
|
||||
///! https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gccint/Soft-float-library-routines.html#Soft-float-library-routines
|
||||
const common = @import("./common.zig");
|
||||
const comparef = @import("./comparef.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__eqxf2, .{ .name = "__eqxf2", .linkage = common.linkage });
|
||||
@export(__nexf2, .{ .name = "__nexf2", .linkage = common.linkage });
|
||||
@export(__lexf2, .{ .name = "__lexf2", .linkage = common.linkage });
|
||||
@export(__cmpxf2, .{ .name = "__cmpxf2", .linkage = common.linkage });
|
||||
@export(__ltxf2, .{ .name = "__ltxf2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
/// "These functions calculate a <=> b. That is, if a is less than b, they return -1;
|
||||
/// if a is greater than b, they return 1; and if a and b are equal they return 0.
|
||||
/// If either argument is NaN they return 1..."
|
||||
///
|
||||
/// Note that this matches the definition of `__lexf2`, `__eqxf2`, `__nexf2`, `__cmpxf2`,
|
||||
/// and `__ltxf2`.
|
||||
fn __cmpxf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return @enumToInt(comparef.cmp_f80(comparef.LE, a, b));
|
||||
}
|
||||
|
||||
/// "These functions return a value less than or equal to zero if neither argument is NaN,
|
||||
/// and a is less than or equal to b."
|
||||
fn __lexf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return __cmpxf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return zero if neither argument is NaN, and a and b are equal."
|
||||
/// Note that due to some kind of historical accident, __eqxf2 and __nexf2 are defined
|
||||
/// to have the same return value.
|
||||
fn __eqxf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return __cmpxf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a nonzero value if either argument is NaN, or if a and b are unequal."
|
||||
/// Note that due to some kind of historical accident, __eqxf2 and __nexf2 are defined
|
||||
/// to have the same return value.
|
||||
fn __nexf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return __cmpxf2(a, b);
|
||||
}
|
||||
|
||||
/// "These functions return a value less than zero if neither argument is NaN, and a
|
||||
/// is strictly less than b."
|
||||
fn __ltxf2(a: f80, b: f80) callconv(.C) i32 {
|
||||
return __cmpxf2(a, b);
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak;
|
||||
pub const want_aeabi = switch (builtin.abi) {
|
||||
.eabi,
|
||||
.eabihf,
|
||||
.musleabi,
|
||||
.musleabihf,
|
||||
.gnueabi,
|
||||
.gnueabihf,
|
||||
.android,
|
||||
=> switch (builtin.cpu.arch) {
|
||||
.arm, .armeb, .thumb, .thumbeb => true,
|
||||
else => false,
|
||||
},
|
||||
else => false,
|
||||
};
|
||||
pub const want_ppc_abi = builtin.cpu.arch.isPPC() or builtin.cpu.arch.isPPC64();
|
||||
|
||||
// Libcalls that involve u128 on Windows x86-64 are expected by LLVM to use the
|
||||
// calling convention of @Vector(2, u64), rather than what's standard.
|
||||
pub const want_windows_v2u64_abi = builtin.os.tag == .windows and builtin.cpu.arch == .x86_64;
|
||||
|
||||
/// This governs whether to use these symbol names for f16/f32 conversions
|
||||
/// rather than the standard names:
|
||||
/// * __gnu_f2h_ieee
|
||||
/// * __gnu_h2f_ieee
|
||||
/// Known correct configurations:
|
||||
/// x86_64-freestanding-none => true
|
||||
/// x86_64-linux-none => true
|
||||
/// x86_64-linux-gnu => true
|
||||
/// x86_64-linux-musl => true
|
||||
/// x86_64-linux-eabi => true
|
||||
/// arm-linux-musleabihf => true
|
||||
/// arm-linux-gnueabihf => true
|
||||
/// arm-linux-eabihf => false
|
||||
/// wasm32-wasi-musl => false
|
||||
/// wasm32-freestanding-none => false
|
||||
/// x86_64-windows-gnu => true
|
||||
/// x86_64-windows-msvc => true
|
||||
/// any-macos-any => false
|
||||
pub const gnu_f16_abi = switch (builtin.cpu.arch) {
|
||||
.wasm32,
|
||||
.wasm64,
|
||||
.riscv64,
|
||||
.riscv32,
|
||||
.x86_64,
|
||||
=> false,
|
||||
|
||||
.i386 => true,
|
||||
|
||||
.arm, .armeb, .thumb, .thumbeb => switch (builtin.abi) {
|
||||
.eabi, .eabihf => false,
|
||||
else => true,
|
||||
},
|
||||
|
||||
else => !builtin.os.tag.isDarwin(),
|
||||
};
|
||||
|
||||
pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
|
||||
|
||||
// Avoid dragging in the runtime safety mechanisms into this .o file,
|
||||
// unless we're trying to test compiler-rt.
|
||||
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
|
||||
_ = error_return_trace;
|
||||
if (builtin.is_test) {
|
||||
@setCold(true);
|
||||
std.debug.panic("{s}", .{msg});
|
||||
} else {
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
/// AArch64 is the only ABI (at the moment) to support f16 arguments without the
|
||||
/// need for extending them to wider fp types.
|
||||
/// TODO remove this; do this type selection in the language rather than
|
||||
/// here in compiler-rt.
|
||||
pub const F16T = switch (builtin.cpu.arch) {
|
||||
.aarch64, .aarch64_be, .aarch64_32 => f16,
|
||||
.riscv64 => if (builtin.zig_backend == .stage1) u16 else f16,
|
||||
.i386, .x86_64 => f16,
|
||||
else => u16,
|
||||
};
|
||||
|
||||
pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
|
||||
switch (Z) {
|
||||
u16 => {
|
||||
// 16x16 --> 32 bit multiply
|
||||
const product = @as(u32, a) * @as(u32, b);
|
||||
hi.* = @intCast(u16, product >> 16);
|
||||
lo.* = @truncate(u16, product);
|
||||
},
|
||||
u32 => {
|
||||
// 32x32 --> 64 bit multiply
|
||||
const product = @as(u64, a) * @as(u64, b);
|
||||
hi.* = @truncate(u32, product >> 32);
|
||||
lo.* = @truncate(u32, product);
|
||||
},
|
||||
u64 => {
|
||||
const S = struct {
|
||||
fn loWord(x: u64) u64 {
|
||||
return @truncate(u32, x);
|
||||
}
|
||||
fn hiWord(x: u64) u64 {
|
||||
return @truncate(u32, x >> 32);
|
||||
}
|
||||
};
|
||||
// 64x64 -> 128 wide multiply for platforms that don't have such an operation;
|
||||
// many 64-bit platforms have this operation, but they tend to have hardware
|
||||
// floating-point, so we don't bother with a special case for them here.
|
||||
// Each of the component 32x32 -> 64 products
|
||||
const plolo: u64 = S.loWord(a) * S.loWord(b);
|
||||
const plohi: u64 = S.loWord(a) * S.hiWord(b);
|
||||
const philo: u64 = S.hiWord(a) * S.loWord(b);
|
||||
const phihi: u64 = S.hiWord(a) * S.hiWord(b);
|
||||
// Sum terms that contribute to lo in a way that allows us to get the carry
|
||||
const r0: u64 = S.loWord(plolo);
|
||||
const r1: u64 = S.hiWord(plolo) +% S.loWord(plohi) +% S.loWord(philo);
|
||||
lo.* = r0 +% (r1 << 32);
|
||||
// Sum terms contributing to hi with the carry from lo
|
||||
hi.* = S.hiWord(plohi) +% S.hiWord(philo) +% S.hiWord(r1) +% phihi;
|
||||
},
|
||||
u128 => {
|
||||
const Word_LoMask = @as(u64, 0x00000000ffffffff);
|
||||
const Word_HiMask = @as(u64, 0xffffffff00000000);
|
||||
const Word_FullMask = @as(u64, 0xffffffffffffffff);
|
||||
const S = struct {
|
||||
fn Word_1(x: u128) u64 {
|
||||
return @truncate(u32, x >> 96);
|
||||
}
|
||||
fn Word_2(x: u128) u64 {
|
||||
return @truncate(u32, x >> 64);
|
||||
}
|
||||
fn Word_3(x: u128) u64 {
|
||||
return @truncate(u32, x >> 32);
|
||||
}
|
||||
fn Word_4(x: u128) u64 {
|
||||
return @truncate(u32, x);
|
||||
}
|
||||
};
|
||||
// 128x128 -> 256 wide multiply for platforms that don't have such an operation;
|
||||
// many 64-bit platforms have this operation, but they tend to have hardware
|
||||
// floating-point, so we don't bother with a special case for them here.
|
||||
|
||||
const product11: u64 = S.Word_1(a) * S.Word_1(b);
|
||||
const product12: u64 = S.Word_1(a) * S.Word_2(b);
|
||||
const product13: u64 = S.Word_1(a) * S.Word_3(b);
|
||||
const product14: u64 = S.Word_1(a) * S.Word_4(b);
|
||||
const product21: u64 = S.Word_2(a) * S.Word_1(b);
|
||||
const product22: u64 = S.Word_2(a) * S.Word_2(b);
|
||||
const product23: u64 = S.Word_2(a) * S.Word_3(b);
|
||||
const product24: u64 = S.Word_2(a) * S.Word_4(b);
|
||||
const product31: u64 = S.Word_3(a) * S.Word_1(b);
|
||||
const product32: u64 = S.Word_3(a) * S.Word_2(b);
|
||||
const product33: u64 = S.Word_3(a) * S.Word_3(b);
|
||||
const product34: u64 = S.Word_3(a) * S.Word_4(b);
|
||||
const product41: u64 = S.Word_4(a) * S.Word_1(b);
|
||||
const product42: u64 = S.Word_4(a) * S.Word_2(b);
|
||||
const product43: u64 = S.Word_4(a) * S.Word_3(b);
|
||||
const product44: u64 = S.Word_4(a) * S.Word_4(b);
|
||||
|
||||
const sum0: u128 = @as(u128, product44);
|
||||
const sum1: u128 = @as(u128, product34) +%
|
||||
@as(u128, product43);
|
||||
const sum2: u128 = @as(u128, product24) +%
|
||||
@as(u128, product33) +%
|
||||
@as(u128, product42);
|
||||
const sum3: u128 = @as(u128, product14) +%
|
||||
@as(u128, product23) +%
|
||||
@as(u128, product32) +%
|
||||
@as(u128, product41);
|
||||
const sum4: u128 = @as(u128, product13) +%
|
||||
@as(u128, product22) +%
|
||||
@as(u128, product31);
|
||||
const sum5: u128 = @as(u128, product12) +%
|
||||
@as(u128, product21);
|
||||
const sum6: u128 = @as(u128, product11);
|
||||
|
||||
const r0: u128 = (sum0 & Word_FullMask) +%
|
||||
((sum1 & Word_LoMask) << 32);
|
||||
const r1: u128 = (sum0 >> 64) +%
|
||||
((sum1 >> 32) & Word_FullMask) +%
|
||||
(sum2 & Word_FullMask) +%
|
||||
((sum3 << 32) & Word_HiMask);
|
||||
|
||||
lo.* = r0 +% (r1 << 64);
|
||||
hi.* = (r1 >> 64) +%
|
||||
(sum1 >> 96) +%
|
||||
(sum2 >> 64) +%
|
||||
(sum3 >> 32) +%
|
||||
sum4 +%
|
||||
(sum5 << 32) +%
|
||||
(sum6 << 64);
|
||||
},
|
||||
else => @compileError("unsupported"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
|
||||
const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
|
||||
const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T);
|
||||
|
||||
const shift = @clz(significand.*) - @clz(integerBit);
|
||||
significand.* <<= @intCast(std.math.Log2Int(Z), shift);
|
||||
return @as(i32, 1) - shift;
|
||||
}
|
||||
|
||||
pub inline fn fneg(a: anytype) @TypeOf(a) {
|
||||
const F = @TypeOf(a);
|
||||
const bits = @typeInfo(F).Float.bits;
|
||||
const U = @Type(.{ .Int = .{
|
||||
.signedness = .unsigned,
|
||||
.bits = bits,
|
||||
} });
|
||||
const sign_bit_mask = @as(U, 1) << (bits - 1);
|
||||
const negated = @bitCast(U, a) ^ sign_bit_mask;
|
||||
return @bitCast(F, negated);
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
// Ported from:
|
||||
//
|
||||
// https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/test/builtins/Unit/comparedf2_test.c
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
|
||||
const __eqdf2 = @import("./cmpdf2.zig").__eqdf2;
|
||||
const __ledf2 = @import("./cmpdf2.zig").__ledf2;
|
||||
const __ltdf2 = @import("./cmpdf2.zig").__ltdf2;
|
||||
const __nedf2 = @import("./cmpdf2.zig").__nedf2;
|
||||
|
||||
const __gedf2 = @import("./gedf2.zig").__gedf2;
|
||||
const __gtdf2 = @import("./gedf2.zig").__gtdf2;
|
||||
|
||||
const __unorddf2 = @import("./unorddf2.zig").__unorddf2;
|
||||
|
||||
const TestVector = struct {
|
||||
a: f64,
|
||||
b: f64,
|
||||
eqReference: c_int,
|
||||
geReference: c_int,
|
||||
gtReference: c_int,
|
||||
leReference: c_int,
|
||||
ltReference: c_int,
|
||||
neReference: c_int,
|
||||
unReference: c_int,
|
||||
};
|
||||
|
||||
fn test__cmpdf2(vector: TestVector) bool {
|
||||
if (__eqdf2(vector.a, vector.b) != vector.eqReference) {
|
||||
return false;
|
||||
}
|
||||
if (__gedf2(vector.a, vector.b) != vector.geReference) {
|
||||
return false;
|
||||
}
|
||||
if (__gtdf2(vector.a, vector.b) != vector.gtReference) {
|
||||
return false;
|
||||
}
|
||||
if (__ledf2(vector.a, vector.b) != vector.leReference) {
|
||||
return false;
|
||||
}
|
||||
if (__ltdf2(vector.a, vector.b) != vector.ltReference) {
|
||||
return false;
|
||||
}
|
||||
if (__nedf2(vector.a, vector.b) != vector.neReference) {
|
||||
return false;
|
||||
}
|
||||
if (__unorddf2(vector.a, vector.b) != vector.unReference) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const arguments = [_]f64{
|
||||
std.math.nan(f64),
|
||||
-std.math.inf(f64),
|
||||
-0x1.fffffffffffffp1023,
|
||||
-0x1.0000000000001p0 - 0x1.0000000000000p0,
|
||||
-0x1.fffffffffffffp-1,
|
||||
-0x1.0000000000000p-1022,
|
||||
-0x0.fffffffffffffp-1022,
|
||||
-0x0.0000000000001p-1022,
|
||||
-0.0,
|
||||
0.0,
|
||||
0x0.0000000000001p-1022,
|
||||
0x0.fffffffffffffp-1022,
|
||||
0x1.0000000000000p-1022,
|
||||
0x1.fffffffffffffp-1,
|
||||
0x1.0000000000000p0,
|
||||
0x1.0000000000001p0,
|
||||
0x1.fffffffffffffp1023,
|
||||
std.math.inf(f64),
|
||||
};
|
||||
|
||||
fn generateVector(comptime a: f64, comptime b: f64) TestVector {
|
||||
const leResult = if (a < b) -1 else if (a == b) 0 else 1;
|
||||
const geResult = if (a > b) 1 else if (a == b) 0 else -1;
|
||||
const unResult = if (a != a or b != b) 1 else 0;
|
||||
return TestVector{
|
||||
.a = a,
|
||||
.b = b,
|
||||
.eqReference = leResult,
|
||||
.geReference = geResult,
|
||||
.gtReference = geResult,
|
||||
.leReference = leResult,
|
||||
.ltReference = leResult,
|
||||
.neReference = leResult,
|
||||
.unReference = unResult,
|
||||
};
|
||||
}
|
||||
|
||||
const test_vectors = init: {
|
||||
@setEvalBranchQuota(10000);
|
||||
var vectors: [arguments.len * arguments.len]TestVector = undefined;
|
||||
for (arguments[0..]) |arg_i, i| {
|
||||
for (arguments[0..]) |arg_j, j| {
|
||||
vectors[(i * arguments.len) + j] = generateVector(arg_i, arg_j);
|
||||
}
|
||||
}
|
||||
break :init vectors;
|
||||
};
|
||||
|
||||
test "compare f64" {
|
||||
for (test_vectors) |vector| {
|
||||
try std.testing.expect(test__cmpdf2(vector));
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub const LE = enum(i32) {
|
||||
Less = -1,
|
||||
Equal = 0,
|
||||
Greater = 1,
|
||||
|
||||
const Unordered: LE = .Greater;
|
||||
};
|
||||
|
||||
pub const GE = enum(i32) {
|
||||
Less = -1,
|
||||
Equal = 0,
|
||||
Greater = 1,
|
||||
|
||||
const Unordered: GE = .Less;
|
||||
};
|
||||
|
||||
pub inline fn cmpf2(comptime T: type, comptime RT: type, a: T, b: T) RT {
|
||||
const bits = @typeInfo(T).Float.bits;
|
||||
const srep_t = std.meta.Int(.signed, bits);
|
||||
const rep_t = std.meta.Int(.unsigned, bits);
|
||||
|
||||
const significandBits = std.math.floatMantissaBits(T);
|
||||
const exponentBits = std.math.floatExponentBits(T);
|
||||
const signBit = (@as(rep_t, 1) << (significandBits + exponentBits));
|
||||
const absMask = signBit - 1;
|
||||
const infT = comptime std.math.inf(T);
|
||||
const infRep = @bitCast(rep_t, infT);
|
||||
|
||||
const aInt = @bitCast(srep_t, a);
|
||||
const bInt = @bitCast(srep_t, b);
|
||||
const aAbs = @bitCast(rep_t, aInt) & absMask;
|
||||
const bAbs = @bitCast(rep_t, bInt) & absMask;
|
||||
|
||||
// If either a or b is NaN, they are unordered.
|
||||
if (aAbs > infRep or bAbs > infRep) return RT.Unordered;
|
||||
|
||||
// If a and b are both zeros, they are equal.
|
||||
if ((aAbs | bAbs) == 0) return .Equal;
|
||||
|
||||
// If at least one of a and b is positive, we get the same result comparing
|
||||
// a and b as signed integers as we would with a floating-point compare.
|
||||
if ((aInt & bInt) >= 0) {
|
||||
if (aInt < bInt) {
|
||||
return .Less;
|
||||
} else if (aInt == bInt) {
|
||||
return .Equal;
|
||||
} else return .Greater;
|
||||
} else {
|
||||
// Otherwise, both are negative, so we need to flip the sense of the
|
||||
// comparison to get the correct result. (This assumes a twos- or ones-
|
||||
// complement integer representation; if integers are represented in a
|
||||
// sign-magnitude representation, then this flip is incorrect).
|
||||
if (aInt > bInt) {
|
||||
return .Less;
|
||||
} else if (aInt == bInt) {
|
||||
return .Equal;
|
||||
} else return .Greater;
|
||||
}
|
||||
}
|
||||
|
||||
pub inline fn cmp_f80(comptime RT: type, a: f80, b: f80) RT {
|
||||
const a_rep = std.math.break_f80(a);
|
||||
const b_rep = std.math.break_f80(b);
|
||||
const sig_bits = std.math.floatMantissaBits(f80);
|
||||
const int_bit = 0x8000000000000000;
|
||||
const sign_bit = 0x8000;
|
||||
const special_exp = 0x7FFF;
|
||||
|
||||
// If either a or b is NaN, they are unordered.
|
||||
if ((a_rep.exp & special_exp == special_exp and a_rep.fraction ^ int_bit != 0) or
|
||||
(b_rep.exp & special_exp == special_exp and b_rep.fraction ^ int_bit != 0))
|
||||
return RT.Unordered;
|
||||
|
||||
// If a and b are both zeros, they are equal.
|
||||
if ((a_rep.fraction | b_rep.fraction) | ((a_rep.exp | b_rep.exp) & special_exp) == 0)
|
||||
return .Equal;
|
||||
|
||||
if (@boolToInt(a_rep.exp == b_rep.exp) & @boolToInt(a_rep.fraction == b_rep.fraction) != 0) {
|
||||
return .Equal;
|
||||
} else if (a_rep.exp & sign_bit != b_rep.exp & sign_bit) {
|
||||
// signs are different
|
||||
if (@bitCast(i16, a_rep.exp) < @bitCast(i16, b_rep.exp)) {
|
||||
return .Less;
|
||||
} else {
|
||||
return .Greater;
|
||||
}
|
||||
} else {
|
||||
const a_fraction = a_rep.fraction | (@as(u80, a_rep.exp) << sig_bits);
|
||||
const b_fraction = b_rep.fraction | (@as(u80, b_rep.exp) << sig_bits);
|
||||
if (a_fraction < b_fraction) {
|
||||
return .Less;
|
||||
} else {
|
||||
return .Greater;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 {
|
||||
const rep_t = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
|
||||
|
||||
const significandBits = std.math.floatMantissaBits(T);
|
||||
const exponentBits = std.math.floatExponentBits(T);
|
||||
const signBit = (@as(rep_t, 1) << (significandBits + exponentBits));
|
||||
const absMask = signBit - 1;
|
||||
const infRep = @bitCast(rep_t, std.math.inf(T));
|
||||
|
||||
const aAbs: rep_t = @bitCast(rep_t, a) & absMask;
|
||||
const bAbs: rep_t = @bitCast(rep_t, b) & absMask;
|
||||
|
||||
return @boolToInt(aAbs > infRep or bAbs > infRep);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("comparesf2_test.zig");
|
||||
_ = @import("comparedf2_test.zig");
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
// Ported from:
|
||||
//
|
||||
// https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/test/builtins/Unit/comparesf2_test.c
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
|
||||
const __eqsf2 = @import("./cmpsf2.zig").__eqsf2;
|
||||
const __lesf2 = @import("./cmpsf2.zig").__lesf2;
|
||||
const __ltsf2 = @import("./cmpsf2.zig").__ltsf2;
|
||||
const __nesf2 = @import("./cmpsf2.zig").__nesf2;
|
||||
|
||||
const __gesf2 = @import("./gesf2.zig").__gesf2;
|
||||
const __gtsf2 = @import("./gesf2.zig").__gtsf2;
|
||||
|
||||
const __unordsf2 = @import("./unordsf2.zig").__unordsf2;
|
||||
|
||||
const TestVector = struct {
|
||||
a: f32,
|
||||
b: f32,
|
||||
eqReference: c_int,
|
||||
geReference: c_int,
|
||||
gtReference: c_int,
|
||||
leReference: c_int,
|
||||
ltReference: c_int,
|
||||
neReference: c_int,
|
||||
unReference: c_int,
|
||||
};
|
||||
|
||||
fn test__cmpsf2(vector: TestVector) bool {
|
||||
if (__eqsf2(vector.a, vector.b) != vector.eqReference) {
|
||||
return false;
|
||||
}
|
||||
if (__gesf2(vector.a, vector.b) != vector.geReference) {
|
||||
return false;
|
||||
}
|
||||
if (__gtsf2(vector.a, vector.b) != vector.gtReference) {
|
||||
return false;
|
||||
}
|
||||
if (__lesf2(vector.a, vector.b) != vector.leReference) {
|
||||
return false;
|
||||
}
|
||||
if (__ltsf2(vector.a, vector.b) != vector.ltReference) {
|
||||
return false;
|
||||
}
|
||||
if (__nesf2(vector.a, vector.b) != vector.neReference) {
|
||||
return false;
|
||||
}
|
||||
if (__unordsf2(vector.a, vector.b) != vector.unReference) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const arguments = [_]f32{
|
||||
std.math.nan(f32),
|
||||
-std.math.inf(f32),
|
||||
-0x1.fffffep127,
|
||||
-0x1.000002p0 - 0x1.000000p0,
|
||||
-0x1.fffffep-1,
|
||||
-0x1.000000p-126,
|
||||
-0x0.fffffep-126,
|
||||
-0x0.000002p-126,
|
||||
-0.0,
|
||||
0.0,
|
||||
0x0.000002p-126,
|
||||
0x0.fffffep-126,
|
||||
0x1.000000p-126,
|
||||
0x1.fffffep-1,
|
||||
0x1.000000p0,
|
||||
0x1.000002p0,
|
||||
0x1.fffffep127,
|
||||
std.math.inf(f32),
|
||||
};
|
||||
|
||||
fn generateVector(comptime a: f32, comptime b: f32) TestVector {
|
||||
const leResult = if (a < b) -1 else if (a == b) 0 else 1;
|
||||
const geResult = if (a > b) 1 else if (a == b) 0 else -1;
|
||||
const unResult = if (a != a or b != b) 1 else 0;
|
||||
return TestVector{
|
||||
.a = a,
|
||||
.b = b,
|
||||
.eqReference = leResult,
|
||||
.geReference = geResult,
|
||||
.gtReference = geResult,
|
||||
.leReference = leResult,
|
||||
.ltReference = leResult,
|
||||
.neReference = leResult,
|
||||
.unReference = unResult,
|
||||
};
|
||||
}
|
||||
|
||||
const test_vectors = init: {
|
||||
@setEvalBranchQuota(10000);
|
||||
var vectors: [arguments.len * arguments.len]TestVector = undefined;
|
||||
for (arguments[0..]) |arg_i, i| {
|
||||
for (arguments[0..]) |arg_j, j| {
|
||||
vectors[(i * arguments.len) + j] = generateVector(arg_i, arg_j);
|
||||
}
|
||||
}
|
||||
break :init vectors;
|
||||
};
|
||||
|
||||
test "compare f32" {
|
||||
for (test_vectors) |vector| {
|
||||
try std.testing.expect(test__cmpsf2(vector));
|
||||
}
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const arch = builtin.cpu.arch;
|
||||
const math = std.math;
|
||||
const expect = std.testing.expect;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
const trig = @import("trig.zig");
|
||||
const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
|
||||
const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
|
||||
|
||||
comptime {
|
||||
@export(__cosh, .{ .name = "__cosh", .linkage = common.linkage });
|
||||
@export(cosf, .{ .name = "cosf", .linkage = common.linkage });
|
||||
@export(cos, .{ .name = "cos", .linkage = common.linkage });
|
||||
@export(__cosx, .{ .name = "__cosx", .linkage = common.linkage });
|
||||
if (common.want_ppc_abi) {
|
||||
@export(cosq, .{ .name = "cosf128", .linkage = common.linkage });
|
||||
}
|
||||
@export(cosq, .{ .name = "cosq", .linkage = common.linkage });
|
||||
@export(cosl, .{ .name = "cosl", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __cosh(a: f16) callconv(.C) f16 {
|
||||
// TODO: more efficient implementation
|
||||
return @floatCast(f16, cosf(a));
|
||||
}
|
||||
|
||||
pub fn cosf(x: f32) callconv(.C) f32 {
|
||||
// Small multiples of pi/2 rounded to double precision.
|
||||
const c1pio2: f64 = 1.0 * math.pi / 2.0; // 0x3FF921FB, 0x54442D18
|
||||
const c2pio2: f64 = 2.0 * math.pi / 2.0; // 0x400921FB, 0x54442D18
|
||||
const c3pio2: f64 = 3.0 * math.pi / 2.0; // 0x4012D97C, 0x7F3321D2
|
||||
const c4pio2: f64 = 4.0 * math.pi / 2.0; // 0x401921FB, 0x54442D18
|
||||
|
||||
var ix = @bitCast(u32, x);
|
||||
const sign = ix >> 31 != 0;
|
||||
ix &= 0x7fffffff;
|
||||
|
||||
if (ix <= 0x3f490fda) { // |x| ~<= pi/4
|
||||
if (ix < 0x39800000) { // |x| < 2**-12
|
||||
// raise inexact if x != 0
|
||||
math.doNotOptimizeAway(x + 0x1p120);
|
||||
return 1.0;
|
||||
}
|
||||
return trig.__cosdf(x);
|
||||
}
|
||||
if (ix <= 0x407b53d1) { // |x| ~<= 5*pi/4
|
||||
if (ix > 0x4016cbe3) { // |x| ~> 3*pi/4
|
||||
return -trig.__cosdf(if (sign) x + c2pio2 else x - c2pio2);
|
||||
} else {
|
||||
if (sign) {
|
||||
return trig.__sindf(x + c1pio2);
|
||||
} else {
|
||||
return trig.__sindf(c1pio2 - x);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ix <= 0x40e231d5) { // |x| ~<= 9*pi/4
|
||||
if (ix > 0x40afeddf) { // |x| ~> 7*pi/4
|
||||
return trig.__cosdf(if (sign) x + c4pio2 else x - c4pio2);
|
||||
} else {
|
||||
if (sign) {
|
||||
return trig.__sindf(-x - c3pio2);
|
||||
} else {
|
||||
return trig.__sindf(x - c3pio2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cos(Inf or NaN) is NaN
|
||||
if (ix >= 0x7f800000) {
|
||||
return x - x;
|
||||
}
|
||||
|
||||
var y: f64 = undefined;
|
||||
const n = rem_pio2f(x, &y);
|
||||
return switch (n & 3) {
|
||||
0 => trig.__cosdf(y),
|
||||
1 => trig.__sindf(-y),
|
||||
2 => -trig.__cosdf(y),
|
||||
else => trig.__sindf(y),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn cos(x: f64) callconv(.C) f64 {
|
||||
var ix = @bitCast(u64, x) >> 32;
|
||||
ix &= 0x7fffffff;
|
||||
|
||||
// |x| ~< pi/4
|
||||
if (ix <= 0x3fe921fb) {
|
||||
if (ix < 0x3e46a09e) { // |x| < 2**-27 * sqrt(2)
|
||||
// raise inexact if x!=0
|
||||
math.doNotOptimizeAway(x + 0x1p120);
|
||||
return 1.0;
|
||||
}
|
||||
return trig.__cos(x, 0);
|
||||
}
|
||||
|
||||
// cos(Inf or NaN) is NaN
|
||||
if (ix >= 0x7ff00000) {
|
||||
return x - x;
|
||||
}
|
||||
|
||||
var y: [2]f64 = undefined;
|
||||
const n = rem_pio2(x, &y);
|
||||
return switch (n & 3) {
|
||||
0 => trig.__cos(y[0], y[1]),
|
||||
1 => -trig.__sin(y[0], y[1], 1),
|
||||
2 => -trig.__cos(y[0], y[1]),
|
||||
else => trig.__sin(y[0], y[1], 1),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn __cosx(a: f80) callconv(.C) f80 {
|
||||
// TODO: more efficient implementation
|
||||
return @floatCast(f80, cosq(a));
|
||||
}
|
||||
|
||||
pub fn cosq(a: f128) callconv(.C) f128 {
|
||||
// TODO: more correct implementation
|
||||
return cos(@floatCast(f64, a));
|
||||
}
|
||||
|
||||
pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble {
|
||||
switch (@typeInfo(c_longdouble).Float.bits) {
|
||||
16 => return __cosh(x),
|
||||
32 => return cosf(x),
|
||||
64 => return cos(x),
|
||||
80 => return __cosx(x),
|
||||
128 => return cosq(x),
|
||||
else => @compileError("unreachable"),
|
||||
}
|
||||
}
|
||||
|
||||
test "cos32" {
|
||||
const epsilon = 0.00001;
|
||||
|
||||
try expect(math.approxEqAbs(f32, cosf(0.0), 1.0, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(0.2), 0.980067, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(0.8923), 0.627623, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(1.5), 0.070737, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(-1.5), 0.070737, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(37.45), 0.969132, epsilon));
|
||||
try expect(math.approxEqAbs(f32, cosf(89.123), 0.400798, epsilon));
|
||||
}
|
||||
|
||||
test "cos64" {
|
||||
const epsilon = 0.000001;
|
||||
|
||||
try expect(math.approxEqAbs(f64, cos(0.0), 1.0, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(0.2), 0.980067, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(0.8923), 0.627623, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(1.5), 0.070737, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(-1.5), 0.070737, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(37.45), 0.969132, epsilon));
|
||||
try expect(math.approxEqAbs(f64, cos(89.123), 0.40080, epsilon));
|
||||
}
|
||||
|
||||
test "cos32.special" {
|
||||
try expect(math.isNan(cosf(math.inf(f32))));
|
||||
try expect(math.isNan(cosf(-math.inf(f32))));
|
||||
try expect(math.isNan(cosf(math.nan(f32))));
|
||||
}
|
||||
|
||||
test "cos64.special" {
|
||||
try expect(math.isNan(cos(math.inf(f64))));
|
||||
try expect(math.isNan(cos(-math.inf(f64))));
|
||||
try expect(math.isNan(cos(math.nan(f64))));
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const is_test = builtin.is_test;
|
||||
const common = @import("common.zig");
|
||||
|
||||
pub const panic = common.panic;
|
||||
|
||||
comptime {
|
||||
@export(__clzsi2, .{ .name = "__clzsi2", .linkage = common.linkage });
|
||||
@export(__clzdi2, .{ .name = "__clzdi2", .linkage = common.linkage });
|
||||
@export(__clzti2, .{ .name = "__clzti2", .linkage = common.linkage });
|
||||
@export(__ctzsi2, .{ .name = "__ctzsi2", .linkage = common.linkage });
|
||||
@export(__ctzdi2, .{ .name = "__ctzdi2", .linkage = common.linkage });
|
||||
@export(__ctzti2, .{ .name = "__ctzti2", .linkage = common.linkage });
|
||||
@export(__ffssi2, .{ .name = "__ffssi2", .linkage = common.linkage });
|
||||
@export(__ffsdi2, .{ .name = "__ffsdi2", .linkage = common.linkage });
|
||||
@export(__ffsti2, .{ .name = "__ffsti2", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
// clz - count leading zeroes
|
||||
// - clzXi2 for unoptimized little and big endian
|
||||
// - __clzsi2_thumb1: assume a != 0
|
||||
// - __clzsi2_arm32: assume a != 0
|
||||
|
||||
// ctz - count trailing zeroes
|
||||
// - ctzXi2 for unoptimized little and big endian
|
||||
|
||||
// ffs - find first set
|
||||
// * ffs = (a == 0) => 0, (a != 0) => ctz + 1
|
||||
// * dont pay for `if (x == 0) return shift;` inside ctz
|
||||
// - ffsXi2 for unoptimized little and big endian
|
||||
|
||||
inline fn clzXi2(comptime T: type, a: T) i32 {
|
||||
var x = switch (@bitSizeOf(T)) {
|
||||
32 => @bitCast(u32, a),
|
||||
64 => @bitCast(u64, a),
|
||||
128 => @bitCast(u128, a),
|
||||
else => unreachable,
|
||||
};
|
||||
var n: T = @bitSizeOf(T);
|
||||
// Count first bit set using binary search, from Hacker's Delight
|
||||
var y: @TypeOf(x) = 0;
|
||||
comptime var shift: u8 = @bitSizeOf(T);
|
||||
inline while (shift > 0) {
|
||||
shift = shift >> 1;
|
||||
y = x >> shift;
|
||||
if (y != 0) {
|
||||
n = n - shift;
|
||||
x = y;
|
||||
}
|
||||
}
|
||||
return @intCast(i32, n - @bitCast(T, x));
|
||||
}
|
||||
|
||||
fn __clzsi2_thumb1() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
// Similar to the generic version with the last two rounds replaced by a LUT
|
||||
asm volatile (
|
||||
\\ movs r1, #32
|
||||
\\ lsrs r2, r0, #16
|
||||
\\ beq 1f
|
||||
\\ subs r1, #16
|
||||
\\ movs r0, r2
|
||||
\\ 1:
|
||||
\\ lsrs r2, r0, #8
|
||||
\\ beq 1f
|
||||
\\ subs r1, #8
|
||||
\\ movs r0, r2
|
||||
\\ 1:
|
||||
\\ lsrs r2, r0, #4
|
||||
\\ beq 1f
|
||||
\\ subs r1, #4
|
||||
\\ movs r0, r2
|
||||
\\ 1:
|
||||
\\ ldr r3, =LUT
|
||||
\\ ldrb r0, [r3, r0]
|
||||
\\ subs r0, r1, r0
|
||||
\\ bx lr
|
||||
\\ .p2align 2
|
||||
\\ // Number of bits set in the 0-15 range
|
||||
\\ LUT:
|
||||
\\ .byte 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4
|
||||
);
|
||||
|
||||
unreachable;
|
||||
}
|
||||
|
||||
fn __clzsi2_arm32() callconv(.Naked) void {
|
||||
@setRuntimeSafety(false);
|
||||
|
||||
asm volatile (
|
||||
\\ // Assumption: n != 0
|
||||
\\ // r0: n
|
||||
\\ // r1: count of leading zeros in n + 1
|
||||
\\ // r2: scratch register for shifted r0
|
||||
\\ mov r1, #1
|
||||
\\
|
||||
\\ // Basic block:
|
||||
\\ // if ((r0 >> SHIFT) == 0)
|
||||
\\ // r1 += SHIFT;
|
||||
\\ // else
|
||||
\\ // r0 >>= SHIFT;
|
||||
\\ // for descending powers of two as SHIFT.
|
||||
\\ lsrs r2, r0, #16
|
||||
\\ movne r0, r2
|
||||
\\ addeq r1, #16
|
||||
\\
|
||||
\\ lsrs r2, r0, #8
|
||||
\\ movne r0, r2
|
||||
\\ addeq r1, #8
|
||||
\\
|
||||
\\ lsrs r2, r0, #4
|
||||
\\ movne r0, r2
|
||||
\\ addeq r1, #4
|
||||
\\
|
||||
\\ lsrs r2, r0, #2
|
||||
\\ movne r0, r2
|
||||
\\ addeq r1, #2
|
||||
\\
|
||||
\\ // The basic block invariants at this point are (r0 >> 2) == 0 and
|
||||
\\ // r0 != 0. This means 1 <= r0 <= 3 and 0 <= (r0 >> 1) <= 1.
|
||||
\\ //
|
||||
\\ // r0 | (r0 >> 1) == 0 | (r0 >> 1) == 1 | -(r0 >> 1) | 1 - (r0 >> 1)f
|
||||
\\ // ---+----------------+----------------+------------+--------------
|
||||
\\ // 1 | 1 | 0 | 0 | 1
|
||||
\\ // 2 | 0 | 1 | -1 | 0
|
||||
\\ // 3 | 0 | 1 | -1 | 0
|
||||
\\ //
|
||||
\\ // The r1's initial value of 1 compensates for the 1 here.
|
||||
\\ sub r0, r1, r0, lsr #1
|
||||
\\ bx lr
|
||||
);
|
||||
|
||||
unreachable;
|
||||
}
|
||||
|
||||
fn clzsi2_generic(a: i32) callconv(.C) i32 {
|
||||
return clzXi2(i32, a);
|
||||
}
|
||||
|
||||
pub const __clzsi2 = switch (builtin.cpu.arch) {
|
||||
.arm, .armeb, .thumb, .thumbeb => impl: {
|
||||
const use_thumb1 =
|
||||
(builtin.cpu.arch.isThumb() or
|
||||
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
|
||||
!std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);
|
||||
|
||||
if (use_thumb1) {
|
||||
break :impl __clzsi2_thumb1;
|
||||
}
|
||||
// From here on we're either targeting Thumb2 or ARM.
|
||||
else if (!builtin.cpu.arch.isThumb()) {
|
||||
break :impl __clzsi2_arm32;
|
||||
}
|
||||
// Use the generic implementation otherwise.
|
||||
else break :impl clzsi2_generic;
|
||||
},
|
||||
else => clzsi2_generic,
|
||||
};
|
||||
|
||||
pub fn __clzdi2(a: i64) callconv(.C) i32 {
|
||||
return clzXi2(i64, a);
|
||||
}
|
||||
|
||||
pub fn __clzti2(a: i128) callconv(.C) i32 {
|
||||
return clzXi2(i128, a);
|
||||
}
|
||||
|
||||
inline fn ctzXi2(comptime T: type, a: T) i32 {
|
||||
var x = switch (@bitSizeOf(T)) {
|
||||
32 => @bitCast(u32, a),
|
||||
64 => @bitCast(u64, a),
|
||||
128 => @bitCast(u128, a),
|
||||
else => unreachable,
|
||||
};
|
||||
var n: T = 1;
|
||||
// Number of trailing zeroes as binary search, from Hacker's Delight
|
||||
var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));
|
||||
comptime var shift = @bitSizeOf(T);
|
||||
if (x == 0) return shift;
|
||||
inline while (shift > 1) {
|
||||
shift = shift >> 1;
|
||||
mask = mask >> shift;
|
||||
if ((x & mask) == 0) {
|
||||
n = n + shift;
|
||||
x = x >> shift;
|
||||
}
|
||||
}
|
||||
return @intCast(i32, n - @bitCast(T, (x & 1)));
|
||||
}
|
||||
|
||||
pub fn __ctzsi2(a: i32) callconv(.C) i32 {
|
||||
return ctzXi2(i32, a);
|
||||
}
|
||||
|
||||
pub fn __ctzdi2(a: i64) callconv(.C) i32 {
|
||||
return ctzXi2(i64, a);
|
||||
}
|
||||
|
||||
pub fn __ctzti2(a: i128) callconv(.C) i32 {
|
||||
return ctzXi2(i128, a);
|
||||
}
|
||||
|
||||
inline fn ffsXi2(comptime T: type, a: T) i32 {
|
||||
var x = switch (@bitSizeOf(T)) {
|
||||
32 => @bitCast(u32, a),
|
||||
64 => @bitCast(u64, a),
|
||||
128 => @bitCast(u128, a),
|
||||
else => unreachable,
|
||||
};
|
||||
var n: T = 1;
|
||||
// adapted from Number of trailing zeroes (see ctzXi2)
|
||||
var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));
|
||||
comptime var shift = @bitSizeOf(T);
|
||||
// In contrast to ctz return 0
|
||||
if (x == 0) return 0;
|
||||
inline while (shift > 1) {
|
||||
shift = shift >> 1;
|
||||
mask = mask >> shift;
|
||||
if ((x & mask) == 0) {
|
||||
n = n + shift;
|
||||
x = x >> shift;
|
||||
}
|
||||
}
|
||||
// return ctz + 1
|
||||
return @intCast(i32, n - @bitCast(T, (x & 1))) + @as(i32, 1);
|
||||
}
|
||||
|
||||
pub fn __ffssi2(a: i32) callconv(.C) i32 {
|
||||
return ffsXi2(i32, a);
|
||||
}
|
||||
|
||||
pub fn __ffsdi2(a: i64) callconv(.C) i32 {
|
||||
return ffsXi2(i64, a);
|
||||
}
|
||||
|
||||
pub fn __ffsti2(a: i128) callconv(.C) i32 {
|
||||
return ffsXi2(i128, a);
|
||||
}
|
||||
|
||||
test {
|
||||
_ = @import("clzsi2_test.zig");
|
||||
_ = @import("clzdi2_test.zig");
|
||||
_ = @import("clzti2_test.zig");
|
||||
|
||||
_ = @import("ctzsi2_test.zig");
|
||||
_ = @import("ctzdi2_test.zig");
|
||||
_ = @import("ctzti2_test.zig");
|
||||
|
||||
_ = @import("ffssi2_test.zig");
|
||||
_ = @import("ffsdi2_test.zig");
|
||||
_ = @import("ffsti2_test.zig");
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
const ctz = @import("count0bits.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__ctzdi2(a: u64, expected: i32) !void {
|
||||
var x = @bitCast(i64, a);
|
||||
var result = ctz.__ctzdi2(x);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "ctzdi2" {
|
||||
try test__ctzdi2(0x00000000_00000001, 0);
|
||||
try test__ctzdi2(0x00000000_00000002, 1);
|
||||
try test__ctzdi2(0x00000000_00000003, 0);
|
||||
try test__ctzdi2(0x00000000_00000004, 2);
|
||||
try test__ctzdi2(0x00000000_00000005, 0);
|
||||
try test__ctzdi2(0x00000000_00000006, 1);
|
||||
try test__ctzdi2(0x00000000_00000007, 0);
|
||||
try test__ctzdi2(0x00000000_00000008, 3);
|
||||
try test__ctzdi2(0x00000000_00000009, 0);
|
||||
try test__ctzdi2(0x00000000_0000000A, 1);
|
||||
try test__ctzdi2(0x00000000_0000000B, 0);
|
||||
try test__ctzdi2(0x00000000_0000000C, 2);
|
||||
try test__ctzdi2(0x00000000_0000000D, 0);
|
||||
try test__ctzdi2(0x00000000_0000000E, 1);
|
||||
try test__ctzdi2(0x00000000_0000000F, 0);
|
||||
try test__ctzdi2(0x00000000_00000010, 4);
|
||||
try test__ctzdi2(0x00000000_00000011, 0);
|
||||
try test__ctzdi2(0x00000000_00000012, 1);
|
||||
try test__ctzdi2(0x00000000_00000013, 0);
|
||||
try test__ctzdi2(0x00000000_00000014, 2);
|
||||
try test__ctzdi2(0x00000000_00000015, 0);
|
||||
try test__ctzdi2(0x00000000_00000016, 1);
|
||||
try test__ctzdi2(0x00000000_00000017, 0);
|
||||
try test__ctzdi2(0x00000000_00000018, 3);
|
||||
try test__ctzdi2(0x00000000_00000019, 0);
|
||||
try test__ctzdi2(0x00000000_0000001A, 1);
|
||||
try test__ctzdi2(0x00000000_0000001B, 0);
|
||||
try test__ctzdi2(0x00000000_0000001C, 2);
|
||||
try test__ctzdi2(0x00000000_0000001D, 0);
|
||||
try test__ctzdi2(0x00000000_0000001E, 1);
|
||||
try test__ctzdi2(0x00000000_0000001F, 0);
|
||||
try test__ctzdi2(0x00000000_00000020, 5);
|
||||
try test__ctzdi2(0x00000000_00000021, 0);
|
||||
try test__ctzdi2(0x00000000_00000022, 1);
|
||||
try test__ctzdi2(0x00000000_00000023, 0);
|
||||
try test__ctzdi2(0x00000000_00000024, 2);
|
||||
try test__ctzdi2(0x00000000_00000025, 0);
|
||||
try test__ctzdi2(0x00000000_00000026, 1);
|
||||
try test__ctzdi2(0x00000000_00000027, 0);
|
||||
try test__ctzdi2(0x00000000_00000028, 3);
|
||||
try test__ctzdi2(0x00000000_00000029, 0);
|
||||
try test__ctzdi2(0x00000000_0000002A, 1);
|
||||
try test__ctzdi2(0x00000000_0000002B, 0);
|
||||
try test__ctzdi2(0x00000000_0000002C, 2);
|
||||
try test__ctzdi2(0x00000000_0000002D, 0);
|
||||
try test__ctzdi2(0x00000000_0000002E, 1);
|
||||
try test__ctzdi2(0x00000000_0000002F, 0);
|
||||
try test__ctzdi2(0x00000000_00000030, 4);
|
||||
try test__ctzdi2(0x00000000_00000031, 0);
|
||||
try test__ctzdi2(0x00000000_00000032, 1);
|
||||
try test__ctzdi2(0x00000000_00000033, 0);
|
||||
try test__ctzdi2(0x00000000_00000034, 2);
|
||||
try test__ctzdi2(0x00000000_00000035, 0);
|
||||
try test__ctzdi2(0x00000000_00000036, 1);
|
||||
try test__ctzdi2(0x00000000_00000037, 0);
|
||||
try test__ctzdi2(0x00000000_00000038, 3);
|
||||
try test__ctzdi2(0x00000000_00000039, 0);
|
||||
try test__ctzdi2(0x00000000_0000003A, 1);
|
||||
try test__ctzdi2(0x00000000_0000003B, 0);
|
||||
try test__ctzdi2(0x00000000_0000003C, 2);
|
||||
try test__ctzdi2(0x00000000_0000003D, 0);
|
||||
try test__ctzdi2(0x00000000_0000003E, 1);
|
||||
try test__ctzdi2(0x00000000_0000003F, 0);
|
||||
try test__ctzdi2(0x00000000_00000040, 6);
|
||||
try test__ctzdi2(0x00000000_00000041, 0);
|
||||
try test__ctzdi2(0x00000000_00000042, 1);
|
||||
try test__ctzdi2(0x00000000_00000043, 0);
|
||||
try test__ctzdi2(0x00000000_00000044, 2);
|
||||
try test__ctzdi2(0x00000000_00000045, 0);
|
||||
try test__ctzdi2(0x00000000_00000046, 1);
|
||||
try test__ctzdi2(0x00000000_00000047, 0);
|
||||
try test__ctzdi2(0x00000000_00000048, 3);
|
||||
try test__ctzdi2(0x00000000_00000049, 0);
|
||||
try test__ctzdi2(0x00000000_0000004A, 1);
|
||||
try test__ctzdi2(0x00000000_0000004B, 0);
|
||||
try test__ctzdi2(0x00000000_0000004C, 2);
|
||||
try test__ctzdi2(0x00000000_0000004D, 0);
|
||||
try test__ctzdi2(0x00000000_0000004E, 1);
|
||||
try test__ctzdi2(0x00000000_0000004F, 0);
|
||||
try test__ctzdi2(0x00000000_00000050, 4);
|
||||
try test__ctzdi2(0x00000000_00000051, 0);
|
||||
try test__ctzdi2(0x00000000_00000052, 1);
|
||||
try test__ctzdi2(0x00000000_00000053, 0);
|
||||
try test__ctzdi2(0x00000000_00000054, 2);
|
||||
try test__ctzdi2(0x00000000_00000055, 0);
|
||||
try test__ctzdi2(0x00000000_00000056, 1);
|
||||
try test__ctzdi2(0x00000000_00000057, 0);
|
||||
try test__ctzdi2(0x00000000_00000058, 3);
|
||||
try test__ctzdi2(0x00000000_00000059, 0);
|
||||
try test__ctzdi2(0x00000000_0000005A, 1);
|
||||
try test__ctzdi2(0x00000000_0000005B, 0);
|
||||
try test__ctzdi2(0x00000000_0000005C, 2);
|
||||
try test__ctzdi2(0x00000000_0000005D, 0);
|
||||
try test__ctzdi2(0x00000000_0000005E, 1);
|
||||
try test__ctzdi2(0x00000000_0000005F, 0);
|
||||
try test__ctzdi2(0x00000000_00000060, 5);
|
||||
try test__ctzdi2(0x00000000_00000061, 0);
|
||||
try test__ctzdi2(0x00000000_00000062, 1);
|
||||
try test__ctzdi2(0x00000000_00000063, 0);
|
||||
try test__ctzdi2(0x00000000_00000064, 2);
|
||||
try test__ctzdi2(0x00000000_00000065, 0);
|
||||
try test__ctzdi2(0x00000000_00000066, 1);
|
||||
try test__ctzdi2(0x00000000_00000067, 0);
|
||||
try test__ctzdi2(0x00000000_00000068, 3);
|
||||
try test__ctzdi2(0x00000000_00000069, 0);
|
||||
try test__ctzdi2(0x00000000_0000006A, 1);
|
||||
try test__ctzdi2(0x00000000_0000006B, 0);
|
||||
try test__ctzdi2(0x00000000_0000006C, 2);
|
||||
try test__ctzdi2(0x00000000_0000006D, 0);
|
||||
try test__ctzdi2(0x00000000_0000006E, 1);
|
||||
try test__ctzdi2(0x00000000_0000006F, 0);
|
||||
try test__ctzdi2(0x00000000_00000070, 4);
|
||||
try test__ctzdi2(0x00000000_00000071, 0);
|
||||
try test__ctzdi2(0x00000000_00000072, 1);
|
||||
try test__ctzdi2(0x00000000_00000073, 0);
|
||||
try test__ctzdi2(0x00000000_00000074, 2);
|
||||
try test__ctzdi2(0x00000000_00000075, 0);
|
||||
try test__ctzdi2(0x00000000_00000076, 1);
|
||||
try test__ctzdi2(0x00000000_00000077, 0);
|
||||
try test__ctzdi2(0x00000000_00000078, 3);
|
||||
try test__ctzdi2(0x00000000_00000079, 0);
|
||||
try test__ctzdi2(0x00000000_0000007A, 1);
|
||||
try test__ctzdi2(0x00000000_0000007B, 0);
|
||||
try test__ctzdi2(0x00000000_0000007C, 2);
|
||||
try test__ctzdi2(0x00000000_0000007D, 0);
|
||||
try test__ctzdi2(0x00000000_0000007E, 1);
|
||||
try test__ctzdi2(0x00000000_0000007F, 0);
|
||||
try test__ctzdi2(0x00000000_00000080, 7);
|
||||
try test__ctzdi2(0x00000000_00000081, 0);
|
||||
try test__ctzdi2(0x00000000_00000082, 1);
|
||||
try test__ctzdi2(0x00000000_00000083, 0);
|
||||
try test__ctzdi2(0x00000000_00000084, 2);
|
||||
try test__ctzdi2(0x00000000_00000085, 0);
|
||||
try test__ctzdi2(0x00000000_00000086, 1);
|
||||
try test__ctzdi2(0x00000000_00000087, 0);
|
||||
try test__ctzdi2(0x00000000_00000088, 3);
|
||||
try test__ctzdi2(0x00000000_00000089, 0);
|
||||
try test__ctzdi2(0x00000000_0000008A, 1);
|
||||
try test__ctzdi2(0x00000000_0000008B, 0);
|
||||
try test__ctzdi2(0x00000000_0000008C, 2);
|
||||
try test__ctzdi2(0x00000000_0000008D, 0);
|
||||
try test__ctzdi2(0x00000000_0000008E, 1);
|
||||
try test__ctzdi2(0x00000000_0000008F, 0);
|
||||
try test__ctzdi2(0x00000000_00000090, 4);
|
||||
try test__ctzdi2(0x00000000_00000091, 0);
|
||||
try test__ctzdi2(0x00000000_00000092, 1);
|
||||
try test__ctzdi2(0x00000000_00000093, 0);
|
||||
try test__ctzdi2(0x00000000_00000094, 2);
|
||||
try test__ctzdi2(0x00000000_00000095, 0);
|
||||
try test__ctzdi2(0x00000000_00000096, 1);
|
||||
try test__ctzdi2(0x00000000_00000097, 0);
|
||||
try test__ctzdi2(0x00000000_00000098, 3);
|
||||
try test__ctzdi2(0x00000000_00000099, 0);
|
||||
try test__ctzdi2(0x00000000_0000009A, 1);
|
||||
try test__ctzdi2(0x00000000_0000009B, 0);
|
||||
try test__ctzdi2(0x00000000_0000009C, 2);
|
||||
try test__ctzdi2(0x00000000_0000009D, 0);
|
||||
try test__ctzdi2(0x00000000_0000009E, 1);
|
||||
try test__ctzdi2(0x00000000_0000009F, 0);
|
||||
try test__ctzdi2(0x00000000_000000A0, 5);
|
||||
try test__ctzdi2(0x00000000_000000A1, 0);
|
||||
try test__ctzdi2(0x00000000_000000A2, 1);
|
||||
try test__ctzdi2(0x00000000_000000A3, 0);
|
||||
try test__ctzdi2(0x00000000_000000A4, 2);
|
||||
try test__ctzdi2(0x00000000_000000A5, 0);
|
||||
try test__ctzdi2(0x00000000_000000A6, 1);
|
||||
try test__ctzdi2(0x00000000_000000A7, 0);
|
||||
try test__ctzdi2(0x00000000_000000A8, 3);
|
||||
try test__ctzdi2(0x00000000_000000A9, 0);
|
||||
try test__ctzdi2(0x00000000_000000AA, 1);
|
||||
try test__ctzdi2(0x00000000_000000AB, 0);
|
||||
try test__ctzdi2(0x00000000_000000AC, 2);
|
||||
try test__ctzdi2(0x00000000_000000AD, 0);
|
||||
try test__ctzdi2(0x00000000_000000AE, 1);
|
||||
try test__ctzdi2(0x00000000_000000AF, 0);
|
||||
try test__ctzdi2(0x00000000_000000B0, 4);
|
||||
try test__ctzdi2(0x00000000_000000B1, 0);
|
||||
try test__ctzdi2(0x00000000_000000B2, 1);
|
||||
try test__ctzdi2(0x00000000_000000B3, 0);
|
||||
try test__ctzdi2(0x00000000_000000B4, 2);
|
||||
try test__ctzdi2(0x00000000_000000B5, 0);
|
||||
try test__ctzdi2(0x00000000_000000B6, 1);
|
||||
try test__ctzdi2(0x00000000_000000B7, 0);
|
||||
try test__ctzdi2(0x00000000_000000B8, 3);
|
||||
try test__ctzdi2(0x00000000_000000B9, 0);
|
||||
try test__ctzdi2(0x00000000_000000BA, 1);
|
||||
try test__ctzdi2(0x00000000_000000BB, 0);
|
||||
try test__ctzdi2(0x00000000_000000BC, 2);
|
||||
try test__ctzdi2(0x00000000_000000BD, 0);
|
||||
try test__ctzdi2(0x00000000_000000BE, 1);
|
||||
try test__ctzdi2(0x00000000_000000BF, 0);
|
||||
try test__ctzdi2(0x00000000_000000C0, 6);
|
||||
try test__ctzdi2(0x00000000_000000C1, 0);
|
||||
try test__ctzdi2(0x00000000_000000C2, 1);
|
||||
try test__ctzdi2(0x00000000_000000C3, 0);
|
||||
try test__ctzdi2(0x00000000_000000C4, 2);
|
||||
try test__ctzdi2(0x00000000_000000C5, 0);
|
||||
try test__ctzdi2(0x00000000_000000C6, 1);
|
||||
try test__ctzdi2(0x00000000_000000C7, 0);
|
||||
try test__ctzdi2(0x00000000_000000C8, 3);
|
||||
try test__ctzdi2(0x00000000_000000C9, 0);
|
||||
try test__ctzdi2(0x00000000_000000CA, 1);
|
||||
try test__ctzdi2(0x00000000_000000CB, 0);
|
||||
try test__ctzdi2(0x00000000_000000CC, 2);
|
||||
try test__ctzdi2(0x00000000_000000CD, 0);
|
||||
try test__ctzdi2(0x00000000_000000CE, 1);
|
||||
try test__ctzdi2(0x00000000_000000CF, 0);
|
||||
try test__ctzdi2(0x00000000_000000D0, 4);
|
||||
try test__ctzdi2(0x00000000_000000D1, 0);
|
||||
try test__ctzdi2(0x00000000_000000D2, 1);
|
||||
try test__ctzdi2(0x00000000_000000D3, 0);
|
||||
try test__ctzdi2(0x00000000_000000D4, 2);
|
||||
try test__ctzdi2(0x00000000_000000D5, 0);
|
||||
try test__ctzdi2(0x00000000_000000D6, 1);
|
||||
try test__ctzdi2(0x00000000_000000D7, 0);
|
||||
try test__ctzdi2(0x00000000_000000D8, 3);
|
||||
try test__ctzdi2(0x00000000_000000D9, 0);
|
||||
try test__ctzdi2(0x00000000_000000DA, 1);
|
||||
try test__ctzdi2(0x00000000_000000DB, 0);
|
||||
try test__ctzdi2(0x00000000_000000DC, 2);
|
||||
try test__ctzdi2(0x00000000_000000DD, 0);
|
||||
try test__ctzdi2(0x00000000_000000DE, 1);
|
||||
try test__ctzdi2(0x00000000_000000DF, 0);
|
||||
try test__ctzdi2(0x00000000_000000E0, 5);
|
||||
try test__ctzdi2(0x00000000_000000E1, 0);
|
||||
try test__ctzdi2(0x00000000_000000E2, 1);
|
||||
try test__ctzdi2(0x00000000_000000E3, 0);
|
||||
try test__ctzdi2(0x00000000_000000E4, 2);
|
||||
try test__ctzdi2(0x00000000_000000E5, 0);
|
||||
try test__ctzdi2(0x00000000_000000E6, 1);
|
||||
try test__ctzdi2(0x00000000_000000E7, 0);
|
||||
try test__ctzdi2(0x00000000_000000E8, 3);
|
||||
try test__ctzdi2(0x00000000_000000E9, 0);
|
||||
try test__ctzdi2(0x00000000_000000EA, 1);
|
||||
try test__ctzdi2(0x00000000_000000EB, 0);
|
||||
try test__ctzdi2(0x00000000_000000EC, 2);
|
||||
try test__ctzdi2(0x00000000_000000ED, 0);
|
||||
try test__ctzdi2(0x00000000_000000EE, 1);
|
||||
try test__ctzdi2(0x00000000_000000EF, 0);
|
||||
try test__ctzdi2(0x00000000_000000F0, 4);
|
||||
try test__ctzdi2(0x00000000_000000F1, 0);
|
||||
try test__ctzdi2(0x00000000_000000F2, 1);
|
||||
try test__ctzdi2(0x00000000_000000F3, 0);
|
||||
try test__ctzdi2(0x00000000_000000F4, 2);
|
||||
try test__ctzdi2(0x00000000_000000F5, 0);
|
||||
try test__ctzdi2(0x00000000_000000F6, 1);
|
||||
try test__ctzdi2(0x00000000_000000F7, 0);
|
||||
try test__ctzdi2(0x00000000_000000F8, 3);
|
||||
try test__ctzdi2(0x00000000_000000F9, 0);
|
||||
try test__ctzdi2(0x00000000_000000FA, 1);
|
||||
try test__ctzdi2(0x00000000_000000FB, 0);
|
||||
try test__ctzdi2(0x00000000_000000FC, 2);
|
||||
try test__ctzdi2(0x00000000_000000FD, 0);
|
||||
try test__ctzdi2(0x00000000_000000FE, 1);
|
||||
try test__ctzdi2(0x00000000_000000FF, 0);
|
||||
|
||||
try test__ctzdi2(0x00000000_00000000, 64);
|
||||
try test__ctzdi2(0x80000000_00000000, 63);
|
||||
try test__ctzdi2(0x40000000_00000000, 62);
|
||||
try test__ctzdi2(0x20000000_00000000, 61);
|
||||
try test__ctzdi2(0x10000000_00000000, 60);
|
||||
try test__ctzdi2(0x08000000_00000000, 59);
|
||||
try test__ctzdi2(0x04000000_00000000, 58);
|
||||
try test__ctzdi2(0x02000000_00000000, 57);
|
||||
try test__ctzdi2(0x01000000_00000000, 56);
|
||||
try test__ctzdi2(0x00800000_00000000, 55);
|
||||
try test__ctzdi2(0x00400000_00000000, 54);
|
||||
try test__ctzdi2(0x00200000_00000000, 53);
|
||||
try test__ctzdi2(0x00100000_00000000, 52);
|
||||
try test__ctzdi2(0x00080000_00000000, 51);
|
||||
try test__ctzdi2(0x00040000_00000000, 50);
|
||||
try test__ctzdi2(0x00020000_00000000, 49);
|
||||
try test__ctzdi2(0x00010000_00000000, 48);
|
||||
try test__ctzdi2(0x00008000_00000000, 47);
|
||||
try test__ctzdi2(0x00004000_00000000, 46);
|
||||
try test__ctzdi2(0x00002000_00000000, 45);
|
||||
try test__ctzdi2(0x00001000_00000000, 44);
|
||||
try test__ctzdi2(0x00000800_00000000, 43);
|
||||
try test__ctzdi2(0x00000400_00000000, 42);
|
||||
try test__ctzdi2(0x00000200_00000000, 41);
|
||||
try test__ctzdi2(0x00000100_00000000, 40);
|
||||
try test__ctzdi2(0x00000080_00000000, 39);
|
||||
try test__ctzdi2(0x00000040_00000000, 38);
|
||||
try test__ctzdi2(0x00000020_00000000, 37);
|
||||
try test__ctzdi2(0x00000010_00000000, 36);
|
||||
try test__ctzdi2(0x00000008_00000000, 35);
|
||||
try test__ctzdi2(0x00000004_00000000, 34);
|
||||
try test__ctzdi2(0x00000002_00000000, 33);
|
||||
try test__ctzdi2(0x00000001_00000000, 32);
|
||||
|
||||
try test__ctzdi2(0x00000000_80000000, 31);
|
||||
try test__ctzdi2(0x00000000_40000000, 30);
|
||||
try test__ctzdi2(0x00000000_20000000, 29);
|
||||
try test__ctzdi2(0x00000000_10000000, 28);
|
||||
try test__ctzdi2(0x00000000_08000000, 27);
|
||||
try test__ctzdi2(0x00000000_04000000, 26);
|
||||
try test__ctzdi2(0x00000000_02000000, 25);
|
||||
try test__ctzdi2(0x00000000_01000000, 24);
|
||||
try test__ctzdi2(0x00000000_00800000, 23);
|
||||
try test__ctzdi2(0x00000000_00400000, 22);
|
||||
try test__ctzdi2(0x00000000_00200000, 21);
|
||||
try test__ctzdi2(0x00000000_00100000, 20);
|
||||
try test__ctzdi2(0x00000000_00080000, 19);
|
||||
try test__ctzdi2(0x00000000_00040000, 18);
|
||||
try test__ctzdi2(0x00000000_00020000, 17);
|
||||
try test__ctzdi2(0x00000000_00010000, 16);
|
||||
try test__ctzdi2(0x00000000_00008000, 15);
|
||||
try test__ctzdi2(0x00000000_00004000, 14);
|
||||
try test__ctzdi2(0x00000000_00002000, 13);
|
||||
try test__ctzdi2(0x00000000_00001000, 12);
|
||||
try test__ctzdi2(0x00000000_00000800, 11);
|
||||
try test__ctzdi2(0x00000000_00000400, 10);
|
||||
try test__ctzdi2(0x00000000_00000200, 9);
|
||||
try test__ctzdi2(0x00000000_00000100, 8);
|
||||
}
|
||||
@@ -1,292 +0,0 @@
|
||||
const ctz = @import("count0bits.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__ctzsi2(a: u32, expected: i32) !void {
|
||||
var x = @bitCast(i32, a);
|
||||
var result = ctz.__ctzsi2(x);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "ctzsi2" {
|
||||
try test__ctzsi2(0x00000001, 0);
|
||||
try test__ctzsi2(0x00000002, 1);
|
||||
try test__ctzsi2(0x00000003, 0);
|
||||
try test__ctzsi2(0x00000004, 2);
|
||||
try test__ctzsi2(0x00000005, 0);
|
||||
try test__ctzsi2(0x00000006, 1);
|
||||
try test__ctzsi2(0x00000007, 0);
|
||||
try test__ctzsi2(0x00000008, 3);
|
||||
try test__ctzsi2(0x00000009, 0);
|
||||
try test__ctzsi2(0x0000000A, 1);
|
||||
try test__ctzsi2(0x0000000B, 0);
|
||||
try test__ctzsi2(0x0000000C, 2);
|
||||
try test__ctzsi2(0x0000000D, 0);
|
||||
try test__ctzsi2(0x0000000E, 1);
|
||||
try test__ctzsi2(0x0000000F, 0);
|
||||
try test__ctzsi2(0x00000010, 4);
|
||||
try test__ctzsi2(0x00000011, 0);
|
||||
try test__ctzsi2(0x00000012, 1);
|
||||
try test__ctzsi2(0x00000013, 0);
|
||||
try test__ctzsi2(0x00000014, 2);
|
||||
try test__ctzsi2(0x00000015, 0);
|
||||
try test__ctzsi2(0x00000016, 1);
|
||||
try test__ctzsi2(0x00000017, 0);
|
||||
try test__ctzsi2(0x00000018, 3);
|
||||
try test__ctzsi2(0x00000019, 0);
|
||||
try test__ctzsi2(0x0000001A, 1);
|
||||
try test__ctzsi2(0x0000001B, 0);
|
||||
try test__ctzsi2(0x0000001C, 2);
|
||||
try test__ctzsi2(0x0000001D, 0);
|
||||
try test__ctzsi2(0x0000001E, 1);
|
||||
try test__ctzsi2(0x0000001F, 0);
|
||||
try test__ctzsi2(0x00000020, 5);
|
||||
try test__ctzsi2(0x00000021, 0);
|
||||
try test__ctzsi2(0x00000022, 1);
|
||||
try test__ctzsi2(0x00000023, 0);
|
||||
try test__ctzsi2(0x00000024, 2);
|
||||
try test__ctzsi2(0x00000025, 0);
|
||||
try test__ctzsi2(0x00000026, 1);
|
||||
try test__ctzsi2(0x00000027, 0);
|
||||
try test__ctzsi2(0x00000028, 3);
|
||||
try test__ctzsi2(0x00000029, 0);
|
||||
try test__ctzsi2(0x0000002A, 1);
|
||||
try test__ctzsi2(0x0000002B, 0);
|
||||
try test__ctzsi2(0x0000002C, 2);
|
||||
try test__ctzsi2(0x0000002D, 0);
|
||||
try test__ctzsi2(0x0000002E, 1);
|
||||
try test__ctzsi2(0x0000002F, 0);
|
||||
try test__ctzsi2(0x00000030, 4);
|
||||
try test__ctzsi2(0x00000031, 0);
|
||||
try test__ctzsi2(0x00000032, 1);
|
||||
try test__ctzsi2(0x00000033, 0);
|
||||
try test__ctzsi2(0x00000034, 2);
|
||||
try test__ctzsi2(0x00000035, 0);
|
||||
try test__ctzsi2(0x00000036, 1);
|
||||
try test__ctzsi2(0x00000037, 0);
|
||||
try test__ctzsi2(0x00000038, 3);
|
||||
try test__ctzsi2(0x00000039, 0);
|
||||
try test__ctzsi2(0x0000003A, 1);
|
||||
try test__ctzsi2(0x0000003B, 0);
|
||||
try test__ctzsi2(0x0000003C, 2);
|
||||
try test__ctzsi2(0x0000003D, 0);
|
||||
try test__ctzsi2(0x0000003E, 1);
|
||||
try test__ctzsi2(0x0000003F, 0);
|
||||
try test__ctzsi2(0x00000040, 6);
|
||||
try test__ctzsi2(0x00000041, 0);
|
||||
try test__ctzsi2(0x00000042, 1);
|
||||
try test__ctzsi2(0x00000043, 0);
|
||||
try test__ctzsi2(0x00000044, 2);
|
||||
try test__ctzsi2(0x00000045, 0);
|
||||
try test__ctzsi2(0x00000046, 1);
|
||||
try test__ctzsi2(0x00000047, 0);
|
||||
try test__ctzsi2(0x00000048, 3);
|
||||
try test__ctzsi2(0x00000049, 0);
|
||||
try test__ctzsi2(0x0000004A, 1);
|
||||
try test__ctzsi2(0x0000004B, 0);
|
||||
try test__ctzsi2(0x0000004C, 2);
|
||||
try test__ctzsi2(0x0000004D, 0);
|
||||
try test__ctzsi2(0x0000004E, 1);
|
||||
try test__ctzsi2(0x0000004F, 0);
|
||||
try test__ctzsi2(0x00000050, 4);
|
||||
try test__ctzsi2(0x00000051, 0);
|
||||
try test__ctzsi2(0x00000052, 1);
|
||||
try test__ctzsi2(0x00000053, 0);
|
||||
try test__ctzsi2(0x00000054, 2);
|
||||
try test__ctzsi2(0x00000055, 0);
|
||||
try test__ctzsi2(0x00000056, 1);
|
||||
try test__ctzsi2(0x00000057, 0);
|
||||
try test__ctzsi2(0x00000058, 3);
|
||||
try test__ctzsi2(0x00000059, 0);
|
||||
try test__ctzsi2(0x0000005A, 1);
|
||||
try test__ctzsi2(0x0000005B, 0);
|
||||
try test__ctzsi2(0x0000005C, 2);
|
||||
try test__ctzsi2(0x0000005D, 0);
|
||||
try test__ctzsi2(0x0000005E, 1);
|
||||
try test__ctzsi2(0x0000005F, 0);
|
||||
try test__ctzsi2(0x00000060, 5);
|
||||
try test__ctzsi2(0x00000061, 0);
|
||||
try test__ctzsi2(0x00000062, 1);
|
||||
try test__ctzsi2(0x00000063, 0);
|
||||
try test__ctzsi2(0x00000064, 2);
|
||||
try test__ctzsi2(0x00000065, 0);
|
||||
try test__ctzsi2(0x00000066, 1);
|
||||
try test__ctzsi2(0x00000067, 0);
|
||||
try test__ctzsi2(0x00000068, 3);
|
||||
try test__ctzsi2(0x00000069, 0);
|
||||
try test__ctzsi2(0x0000006A, 1);
|
||||
try test__ctzsi2(0x0000006B, 0);
|
||||
try test__ctzsi2(0x0000006C, 2);
|
||||
try test__ctzsi2(0x0000006D, 0);
|
||||
try test__ctzsi2(0x0000006E, 1);
|
||||
try test__ctzsi2(0x0000006F, 0);
|
||||
try test__ctzsi2(0x00000070, 4);
|
||||
try test__ctzsi2(0x00000071, 0);
|
||||
try test__ctzsi2(0x00000072, 1);
|
||||
try test__ctzsi2(0x00000073, 0);
|
||||
try test__ctzsi2(0x00000074, 2);
|
||||
try test__ctzsi2(0x00000075, 0);
|
||||
try test__ctzsi2(0x00000076, 1);
|
||||
try test__ctzsi2(0x00000077, 0);
|
||||
try test__ctzsi2(0x00000078, 3);
|
||||
try test__ctzsi2(0x00000079, 0);
|
||||
try test__ctzsi2(0x0000007A, 1);
|
||||
try test__ctzsi2(0x0000007B, 0);
|
||||
try test__ctzsi2(0x0000007C, 2);
|
||||
try test__ctzsi2(0x0000007D, 0);
|
||||
try test__ctzsi2(0x0000007E, 1);
|
||||
try test__ctzsi2(0x0000007F, 0);
|
||||
try test__ctzsi2(0x00000080, 7);
|
||||
try test__ctzsi2(0x00000081, 0);
|
||||
try test__ctzsi2(0x00000082, 1);
|
||||
try test__ctzsi2(0x00000083, 0);
|
||||
try test__ctzsi2(0x00000084, 2);
|
||||
try test__ctzsi2(0x00000085, 0);
|
||||
try test__ctzsi2(0x00000086, 1);
|
||||
try test__ctzsi2(0x00000087, 0);
|
||||
try test__ctzsi2(0x00000088, 3);
|
||||
try test__ctzsi2(0x00000089, 0);
|
||||
try test__ctzsi2(0x0000008A, 1);
|
||||
try test__ctzsi2(0x0000008B, 0);
|
||||
try test__ctzsi2(0x0000008C, 2);
|
||||
try test__ctzsi2(0x0000008D, 0);
|
||||
try test__ctzsi2(0x0000008E, 1);
|
||||
try test__ctzsi2(0x0000008F, 0);
|
||||
try test__ctzsi2(0x00000090, 4);
|
||||
try test__ctzsi2(0x00000091, 0);
|
||||
try test__ctzsi2(0x00000092, 1);
|
||||
try test__ctzsi2(0x00000093, 0);
|
||||
try test__ctzsi2(0x00000094, 2);
|
||||
try test__ctzsi2(0x00000095, 0);
|
||||
try test__ctzsi2(0x00000096, 1);
|
||||
try test__ctzsi2(0x00000097, 0);
|
||||
try test__ctzsi2(0x00000098, 3);
|
||||
try test__ctzsi2(0x00000099, 0);
|
||||
try test__ctzsi2(0x0000009A, 1);
|
||||
try test__ctzsi2(0x0000009B, 0);
|
||||
try test__ctzsi2(0x0000009C, 2);
|
||||
try test__ctzsi2(0x0000009D, 0);
|
||||
try test__ctzsi2(0x0000009E, 1);
|
||||
try test__ctzsi2(0x0000009F, 0);
|
||||
try test__ctzsi2(0x000000A0, 5);
|
||||
try test__ctzsi2(0x000000A1, 0);
|
||||
try test__ctzsi2(0x000000A2, 1);
|
||||
try test__ctzsi2(0x000000A3, 0);
|
||||
try test__ctzsi2(0x000000A4, 2);
|
||||
try test__ctzsi2(0x000000A5, 0);
|
||||
try test__ctzsi2(0x000000A6, 1);
|
||||
try test__ctzsi2(0x000000A7, 0);
|
||||
try test__ctzsi2(0x000000A8, 3);
|
||||
try test__ctzsi2(0x000000A9, 0);
|
||||
try test__ctzsi2(0x000000AA, 1);
|
||||
try test__ctzsi2(0x000000AB, 0);
|
||||
try test__ctzsi2(0x000000AC, 2);
|
||||
try test__ctzsi2(0x000000AD, 0);
|
||||
try test__ctzsi2(0x000000AE, 1);
|
||||
try test__ctzsi2(0x000000AF, 0);
|
||||
try test__ctzsi2(0x000000B0, 4);
|
||||
try test__ctzsi2(0x000000B1, 0);
|
||||
try test__ctzsi2(0x000000B2, 1);
|
||||
try test__ctzsi2(0x000000B3, 0);
|
||||
try test__ctzsi2(0x000000B4, 2);
|
||||
try test__ctzsi2(0x000000B5, 0);
|
||||
try test__ctzsi2(0x000000B6, 1);
|
||||
try test__ctzsi2(0x000000B7, 0);
|
||||
try test__ctzsi2(0x000000B8, 3);
|
||||
try test__ctzsi2(0x000000B9, 0);
|
||||
try test__ctzsi2(0x000000BA, 1);
|
||||
try test__ctzsi2(0x000000BB, 0);
|
||||
try test__ctzsi2(0x000000BC, 2);
|
||||
try test__ctzsi2(0x000000BD, 0);
|
||||
try test__ctzsi2(0x000000BE, 1);
|
||||
try test__ctzsi2(0x000000BF, 0);
|
||||
try test__ctzsi2(0x000000C0, 6);
|
||||
try test__ctzsi2(0x000000C1, 0);
|
||||
try test__ctzsi2(0x000000C2, 1);
|
||||
try test__ctzsi2(0x000000C3, 0);
|
||||
try test__ctzsi2(0x000000C4, 2);
|
||||
try test__ctzsi2(0x000000C5, 0);
|
||||
try test__ctzsi2(0x000000C6, 1);
|
||||
try test__ctzsi2(0x000000C7, 0);
|
||||
try test__ctzsi2(0x000000C8, 3);
|
||||
try test__ctzsi2(0x000000C9, 0);
|
||||
try test__ctzsi2(0x000000CA, 1);
|
||||
try test__ctzsi2(0x000000CB, 0);
|
||||
try test__ctzsi2(0x000000CC, 2);
|
||||
try test__ctzsi2(0x000000CD, 0);
|
||||
try test__ctzsi2(0x000000CE, 1);
|
||||
try test__ctzsi2(0x000000CF, 0);
|
||||
try test__ctzsi2(0x000000D0, 4);
|
||||
try test__ctzsi2(0x000000D1, 0);
|
||||
try test__ctzsi2(0x000000D2, 1);
|
||||
try test__ctzsi2(0x000000D3, 0);
|
||||
try test__ctzsi2(0x000000D4, 2);
|
||||
try test__ctzsi2(0x000000D5, 0);
|
||||
try test__ctzsi2(0x000000D6, 1);
|
||||
try test__ctzsi2(0x000000D7, 0);
|
||||
try test__ctzsi2(0x000000D8, 3);
|
||||
try test__ctzsi2(0x000000D9, 0);
|
||||
try test__ctzsi2(0x000000DA, 1);
|
||||
try test__ctzsi2(0x000000DB, 0);
|
||||
try test__ctzsi2(0x000000DC, 2);
|
||||
try test__ctzsi2(0x000000DD, 0);
|
||||
try test__ctzsi2(0x000000DE, 1);
|
||||
try test__ctzsi2(0x000000DF, 0);
|
||||
try test__ctzsi2(0x000000E0, 5);
|
||||
try test__ctzsi2(0x000000E1, 0);
|
||||
try test__ctzsi2(0x000000E2, 1);
|
||||
try test__ctzsi2(0x000000E3, 0);
|
||||
try test__ctzsi2(0x000000E4, 2);
|
||||
try test__ctzsi2(0x000000E5, 0);
|
||||
try test__ctzsi2(0x000000E6, 1);
|
||||
try test__ctzsi2(0x000000E7, 0);
|
||||
try test__ctzsi2(0x000000E8, 3);
|
||||
try test__ctzsi2(0x000000E9, 0);
|
||||
try test__ctzsi2(0x000000EA, 1);
|
||||
try test__ctzsi2(0x000000EB, 0);
|
||||
try test__ctzsi2(0x000000EC, 2);
|
||||
try test__ctzsi2(0x000000ED, 0);
|
||||
try test__ctzsi2(0x000000EE, 1);
|
||||
try test__ctzsi2(0x000000EF, 0);
|
||||
try test__ctzsi2(0x000000F0, 4);
|
||||
try test__ctzsi2(0x000000F1, 0);
|
||||
try test__ctzsi2(0x000000F2, 1);
|
||||
try test__ctzsi2(0x000000F3, 0);
|
||||
try test__ctzsi2(0x000000F4, 2);
|
||||
try test__ctzsi2(0x000000F5, 0);
|
||||
try test__ctzsi2(0x000000F6, 1);
|
||||
try test__ctzsi2(0x000000F7, 0);
|
||||
try test__ctzsi2(0x000000F8, 3);
|
||||
try test__ctzsi2(0x000000F9, 0);
|
||||
try test__ctzsi2(0x000000FA, 1);
|
||||
try test__ctzsi2(0x000000FB, 0);
|
||||
try test__ctzsi2(0x000000FC, 2);
|
||||
try test__ctzsi2(0x000000FD, 0);
|
||||
try test__ctzsi2(0x000000FE, 1);
|
||||
try test__ctzsi2(0x000000FF, 0);
|
||||
|
||||
try test__ctzsi2(0x00000000, 32);
|
||||
try test__ctzsi2(0x80000000, 31);
|
||||
try test__ctzsi2(0x40000000, 30);
|
||||
try test__ctzsi2(0x20000000, 29);
|
||||
try test__ctzsi2(0x10000000, 28);
|
||||
try test__ctzsi2(0x08000000, 27);
|
||||
try test__ctzsi2(0x04000000, 26);
|
||||
try test__ctzsi2(0x02000000, 25);
|
||||
try test__ctzsi2(0x01000000, 24);
|
||||
try test__ctzsi2(0x00800000, 23);
|
||||
try test__ctzsi2(0x00400000, 22);
|
||||
try test__ctzsi2(0x00200000, 21);
|
||||
try test__ctzsi2(0x00100000, 20);
|
||||
try test__ctzsi2(0x00080000, 19);
|
||||
try test__ctzsi2(0x00040000, 18);
|
||||
try test__ctzsi2(0x00020000, 17);
|
||||
try test__ctzsi2(0x00010000, 16);
|
||||
try test__ctzsi2(0x00008000, 15);
|
||||
try test__ctzsi2(0x00004000, 14);
|
||||
try test__ctzsi2(0x00002000, 13);
|
||||
try test__ctzsi2(0x00001000, 12);
|
||||
try test__ctzsi2(0x00000800, 11);
|
||||
try test__ctzsi2(0x00000400, 10);
|
||||
try test__ctzsi2(0x00000200, 9);
|
||||
try test__ctzsi2(0x00000100, 8);
|
||||
}
|
||||
@@ -1,391 +0,0 @@
|
||||
const ctz = @import("count0bits.zig");
|
||||
const testing = @import("std").testing;
|
||||
|
||||
fn test__ctzti2(a: u128, expected: i32) !void {
|
||||
var x = @bitCast(i128, a);
|
||||
var result = ctz.__ctzti2(x);
|
||||
try testing.expectEqual(expected, result);
|
||||
}
|
||||
|
||||
test "ctzti2" {
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000001, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000002, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000003, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000004, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000005, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000006, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000007, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000008, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000009, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000000A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000000B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000000C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000000D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000000E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000000F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000010, 4);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000011, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000012, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000013, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000014, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000015, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000016, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000017, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000018, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000019, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000001A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000001B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000001C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000001D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000001E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000001F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000020, 5);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000021, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000022, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000023, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000024, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000025, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000026, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000027, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000028, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000029, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000002A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000002B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000002C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000002D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000002E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000002F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000030, 4);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000031, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000032, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000033, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000034, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000035, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000036, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000037, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000038, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000039, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000003A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000003B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000003C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000003D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000003E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000003F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000040, 6);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000041, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000042, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000043, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000044, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000045, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000046, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000047, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000048, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000049, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000004A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000004B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000004C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000004D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000004E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000004F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000050, 4);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000051, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000052, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000053, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000054, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000055, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000056, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000057, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000058, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000059, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000005A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000005B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000005C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000005D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000005E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000005F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000060, 5);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000061, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000062, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000063, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000064, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000065, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000066, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000067, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000068, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000069, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000006A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000006B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000006C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000006D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000006E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000006F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000070, 4);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000071, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000072, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000073, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000074, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000075, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000076, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000077, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000078, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000079, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000007A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000007B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000007C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000007D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000007E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000007F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000080, 7);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000081, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000082, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000083, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000084, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000085, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000086, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000087, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000088, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000089, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000008A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000008B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000008C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000008D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000008E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000008F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000090, 4);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000091, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000092, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000093, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000094, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000095, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000096, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000097, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000098, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000099, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000009A, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000009B, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000009C, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000009D, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000009E, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_0000009F, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A0, 5);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A1, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A2, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A3, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A4, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A5, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A6, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A7, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A8, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000A9, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000AA, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000AB, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000AC, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000AD, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000AE, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000AF, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B0, 4);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B1, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B2, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B3, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B4, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B5, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B6, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B7, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B8, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000B9, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000BA, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000BB, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000BC, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000BD, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000BE, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000BF, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C0, 6);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C1, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C2, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C3, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C4, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C5, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C6, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C7, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C8, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000C9, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000CA, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000CB, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000CC, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000CD, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000CE, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000CF, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D0, 4);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D1, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D2, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D3, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D4, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D5, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D6, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D7, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D8, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000D9, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000DA, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000DB, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000DC, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000DD, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000DE, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000DF, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E0, 5);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E1, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E2, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E3, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E4, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E5, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E6, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E7, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E8, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000E9, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000EA, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000EB, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000EC, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000ED, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000EE, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000EF, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F0, 4);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F1, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F2, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F3, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F4, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F5, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F6, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F7, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F8, 3);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000F9, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000FA, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000FB, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000FC, 2);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000FD, 0);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000FE, 1);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_000000FF, 0);
|
||||
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000000, 128);
|
||||
try test__ctzti2(0x80000000_00000000_00000000_00000000, 127);
|
||||
try test__ctzti2(0x40000000_00000000_00000000_00000000, 126);
|
||||
try test__ctzti2(0x20000000_00000000_00000000_00000000, 125);
|
||||
try test__ctzti2(0x10000000_00000000_00000000_00000000, 124);
|
||||
try test__ctzti2(0x08000000_00000000_00000000_00000000, 123);
|
||||
try test__ctzti2(0x04000000_00000000_00000000_00000000, 122);
|
||||
try test__ctzti2(0x02000000_00000000_00000000_00000000, 121);
|
||||
try test__ctzti2(0x01000000_00000000_00000000_00000000, 120);
|
||||
try test__ctzti2(0x00800000_00000000_00000000_00000000, 119);
|
||||
try test__ctzti2(0x00400000_00000000_00000000_00000000, 118);
|
||||
try test__ctzti2(0x00200000_00000000_00000000_00000000, 117);
|
||||
try test__ctzti2(0x00100000_00000000_00000000_00000000, 116);
|
||||
try test__ctzti2(0x00080000_00000000_00000000_00000000, 115);
|
||||
try test__ctzti2(0x00040000_00000000_00000000_00000000, 114);
|
||||
try test__ctzti2(0x00020000_00000000_00000000_00000000, 113);
|
||||
try test__ctzti2(0x00010000_00000000_00000000_00000000, 112);
|
||||
try test__ctzti2(0x00008000_00000000_00000000_00000000, 111);
|
||||
try test__ctzti2(0x00004000_00000000_00000000_00000000, 110);
|
||||
try test__ctzti2(0x00002000_00000000_00000000_00000000, 109);
|
||||
try test__ctzti2(0x00001000_00000000_00000000_00000000, 108);
|
||||
try test__ctzti2(0x00000800_00000000_00000000_00000000, 107);
|
||||
try test__ctzti2(0x00000400_00000000_00000000_00000000, 106);
|
||||
try test__ctzti2(0x00000200_00000000_00000000_00000000, 105);
|
||||
try test__ctzti2(0x00000100_00000000_00000000_00000000, 104);
|
||||
try test__ctzti2(0x00000080_00000000_00000000_00000000, 103);
|
||||
try test__ctzti2(0x00000040_00000000_00000000_00000000, 102);
|
||||
try test__ctzti2(0x00000020_00000000_00000000_00000000, 101);
|
||||
try test__ctzti2(0x00000010_00000000_00000000_00000000, 100);
|
||||
try test__ctzti2(0x00000008_00000000_00000000_00000000, 99);
|
||||
try test__ctzti2(0x00000004_00000000_00000000_00000000, 98);
|
||||
try test__ctzti2(0x00000002_00000000_00000000_00000000, 97);
|
||||
try test__ctzti2(0x00000001_00000000_00000000_00000000, 96);
|
||||
|
||||
try test__ctzti2(0x00000000_80000000_00000000_00000000, 95);
|
||||
try test__ctzti2(0x00000000_40000000_00000000_00000000, 94);
|
||||
try test__ctzti2(0x00000000_20000000_00000000_00000000, 93);
|
||||
try test__ctzti2(0x00000000_10000000_00000000_00000000, 92);
|
||||
try test__ctzti2(0x00000000_08000000_00000000_00000000, 91);
|
||||
try test__ctzti2(0x00000000_04000000_00000000_00000000, 90);
|
||||
try test__ctzti2(0x00000000_02000000_00000000_00000000, 89);
|
||||
try test__ctzti2(0x00000000_01000000_00000000_00000000, 88);
|
||||
try test__ctzti2(0x00000000_00800000_00000000_00000000, 87);
|
||||
try test__ctzti2(0x00000000_00400000_00000000_00000000, 86);
|
||||
try test__ctzti2(0x00000000_00200000_00000000_00000000, 85);
|
||||
try test__ctzti2(0x00000000_00100000_00000000_00000000, 84);
|
||||
try test__ctzti2(0x00000000_00080000_00000000_00000000, 83);
|
||||
try test__ctzti2(0x00000000_00040000_00000000_00000000, 82);
|
||||
try test__ctzti2(0x00000000_00020000_00000000_00000000, 81);
|
||||
try test__ctzti2(0x00000000_00010000_00000000_00000000, 80);
|
||||
try test__ctzti2(0x00000000_00008000_00000000_00000000, 79);
|
||||
try test__ctzti2(0x00000000_00004000_00000000_00000000, 78);
|
||||
try test__ctzti2(0x00000000_00002000_00000000_00000000, 77);
|
||||
try test__ctzti2(0x00000000_00001000_00000000_00000000, 76);
|
||||
try test__ctzti2(0x00000000_00000800_00000000_00000000, 75);
|
||||
try test__ctzti2(0x00000000_00000400_00000000_00000000, 74);
|
||||
try test__ctzti2(0x00000000_00000200_00000000_00000000, 73);
|
||||
try test__ctzti2(0x00000000_00000100_00000000_00000000, 72);
|
||||
try test__ctzti2(0x00000000_00000080_00000000_00000000, 71);
|
||||
try test__ctzti2(0x00000000_00000040_00000000_00000000, 70);
|
||||
try test__ctzti2(0x00000000_00000020_00000000_00000000, 69);
|
||||
try test__ctzti2(0x00000000_00000010_00000000_00000000, 68);
|
||||
try test__ctzti2(0x00000000_00000008_00000000_00000000, 67);
|
||||
try test__ctzti2(0x00000000_00000004_00000000_00000000, 66);
|
||||
try test__ctzti2(0x00000000_00000002_00000000_00000000, 65);
|
||||
try test__ctzti2(0x00000000_00000001_00000000_00000000, 64);
|
||||
|
||||
try test__ctzti2(0x00000000_00000000_80000000_00000000, 63);
|
||||
try test__ctzti2(0x00000000_00000000_40000000_00000000, 62);
|
||||
try test__ctzti2(0x00000000_00000000_20000000_00000000, 61);
|
||||
try test__ctzti2(0x00000000_00000000_10000000_00000000, 60);
|
||||
try test__ctzti2(0x00000000_00000000_08000000_00000000, 59);
|
||||
try test__ctzti2(0x00000000_00000000_04000000_00000000, 58);
|
||||
try test__ctzti2(0x00000000_00000000_02000000_00000000, 57);
|
||||
try test__ctzti2(0x00000000_00000000_01000000_00000000, 56);
|
||||
try test__ctzti2(0x00000000_00000000_00800000_00000000, 55);
|
||||
try test__ctzti2(0x00000000_00000000_00400000_00000000, 54);
|
||||
try test__ctzti2(0x00000000_00000000_00200000_00000000, 53);
|
||||
try test__ctzti2(0x00000000_00000000_00100000_00000000, 52);
|
||||
try test__ctzti2(0x00000000_00000000_00080000_00000000, 51);
|
||||
try test__ctzti2(0x00000000_00000000_00040000_00000000, 50);
|
||||
try test__ctzti2(0x00000000_00000000_00020000_00000000, 49);
|
||||
try test__ctzti2(0x00000000_00000000_00010000_00000000, 48);
|
||||
try test__ctzti2(0x00000000_00000000_00008000_00000000, 47);
|
||||
try test__ctzti2(0x00000000_00000000_00004000_00000000, 46);
|
||||
try test__ctzti2(0x00000000_00000000_00002000_00000000, 45);
|
||||
try test__ctzti2(0x00000000_00000000_00001000_00000000, 44);
|
||||
try test__ctzti2(0x00000000_00000000_00000800_00000000, 43);
|
||||
try test__ctzti2(0x00000000_00000000_00000400_00000000, 42);
|
||||
try test__ctzti2(0x00000000_00000000_00000200_00000000, 41);
|
||||
try test__ctzti2(0x00000000_00000000_00000100_00000000, 40);
|
||||
try test__ctzti2(0x00000000_00000000_00000080_00000000, 39);
|
||||
try test__ctzti2(0x00000000_00000000_00000040_00000000, 38);
|
||||
try test__ctzti2(0x00000000_00000000_00000020_00000000, 37);
|
||||
try test__ctzti2(0x00000000_00000000_00000010_00000000, 36);
|
||||
try test__ctzti2(0x00000000_00000000_00000008_00000000, 35);
|
||||
try test__ctzti2(0x00000000_00000000_00000004_00000000, 34);
|
||||
try test__ctzti2(0x00000000_00000000_00000002_00000000, 33);
|
||||
try test__ctzti2(0x00000000_00000000_00000001_00000000, 32);
|
||||
|
||||
try test__ctzti2(0x00000000_00000000_00000000_80000000, 31);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_40000000, 30);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_20000000, 29);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_10000000, 28);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_08000000, 27);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_04000000, 26);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_02000000, 25);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_01000000, 24);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00800000, 23);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00400000, 22);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00200000, 21);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00100000, 20);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00080000, 19);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00040000, 18);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00020000, 17);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00010000, 16);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00008000, 15);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00004000, 14);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00002000, 13);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00001000, 12);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000800, 11);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000400, 10);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000200, 9);
|
||||
try test__ctzti2(0x00000000_00000000_00000000_00000100, 8);
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
const std = @import("std");
|
||||
const isNan = std.math.isNan;
|
||||
const isInf = std.math.isInf;
|
||||
const scalbn = std.math.scalbn;
|
||||
const ilogb = std.math.ilogb;
|
||||
const max = std.math.max;
|
||||
const fabs = std.math.fabs;
|
||||
const maxInt = std.math.maxInt;
|
||||
const minInt = std.math.minInt;
|
||||
const isFinite = std.math.isFinite;
|
||||
const copysign = std.math.copysign;
|
||||
const Complex = @import("mulc3.zig").Complex;
|
||||
|
||||
/// Implementation based on Annex G of C17 Standard (N2176)
|
||||
pub inline fn divc3(comptime T: type, a: T, b: T, c_in: T, d_in: T) Complex(T) {
|
||||
var c = c_in;
|
||||
var d = d_in;
|
||||
|
||||
// logbw used to prevent under/over-flow
|
||||
const logbw = ilogb(max(fabs(c), fabs(d)));
|
||||
const logbw_finite = logbw != maxInt(i32) and logbw != minInt(i32);
|
||||
const ilogbw = if (logbw_finite) b: {
|
||||
c = scalbn(c, -logbw);
|
||||
d = scalbn(d, -logbw);
|
||||
break :b logbw;
|
||||
} else 0;
|
||||
const denom = c * c + d * d;
|
||||
const result = Complex(T){
|
||||
.real = scalbn((a * c + b * d) / denom, -ilogbw),
|
||||
.imag = scalbn((b * c - a * d) / denom, -ilogbw),
|
||||
};
|
||||
|
||||
// Recover infinities and zeros that computed as NaN+iNaN;
|
||||
// the only cases are non-zero/zero, infinite/finite, and finite/infinite, ...
|
||||
if (isNan(result.real) and isNan(result.imag)) {
|
||||
const zero: T = 0.0;
|
||||
const one: T = 1.0;
|
||||
|
||||
if ((denom == 0.0) and (!isNan(a) or !isNan(b))) {
|
||||
return .{
|
||||
.real = copysign(std.math.inf(T), c) * a,
|
||||
.imag = copysign(std.math.inf(T), c) * b,
|
||||
};
|
||||
} else if ((isInf(a) or isInf(b)) and isFinite(c) and isFinite(d)) {
|
||||
const boxed_a = copysign(if (isInf(a)) one else zero, a);
|
||||
const boxed_b = copysign(if (isInf(b)) one else zero, b);
|
||||
return .{
|
||||
.real = std.math.inf(T) * (boxed_a * c - boxed_b * d),
|
||||
.imag = std.math.inf(T) * (boxed_b * c - boxed_a * d),
|
||||
};
|
||||
} else if (logbw == maxInt(i32) and isFinite(a) and isFinite(b)) {
|
||||
const boxed_c = copysign(if (isInf(c)) one else zero, c);
|
||||
const boxed_d = copysign(if (isInf(d)) one else zero, d);
|
||||
return .{
|
||||
.real = 0.0 * (a * boxed_c + b * boxed_d),
|
||||
.imag = 0.0 * (b * boxed_c - a * boxed_d),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
const std = @import("std");
|
||||
const math = std.math;
|
||||
const expect = std.testing.expect;
|
||||
|
||||
const Complex = @import("./mulc3.zig").Complex;
|
||||
const __divhc3 = @import("./divhc3.zig").__divhc3;
|
||||
const __divsc3 = @import("./divsc3.zig").__divsc3;
|
||||
const __divdc3 = @import("./divdc3.zig").__divdc3;
|
||||
const __divxc3 = @import("./divxc3.zig").__divxc3;
|
||||
const __divtc3 = @import("./divtc3.zig").__divtc3;
|
||||
|
||||
test {
|
||||
try testDiv(f16, __divhc3);
|
||||
try testDiv(f32, __divsc3);
|
||||
try testDiv(f64, __divdc3);
|
||||
try testDiv(f80, __divxc3);
|
||||
try testDiv(f128, __divtc3);
|
||||
}
|
||||
|
||||
fn testDiv(comptime T: type, comptime f: fn (T, T, T, T) callconv(.C) Complex(T)) !void {
|
||||
{
|
||||
var a: T = 1.0;
|
||||
var b: T = 0.0;
|
||||
var c: T = -1.0;
|
||||
var d: T = 0.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == -1.0);
|
||||
try expect(result.imag == 0.0);
|
||||
}
|
||||
{
|
||||
var a: T = 1.0;
|
||||
var b: T = 0.0;
|
||||
var c: T = -4.0;
|
||||
var d: T = 0.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == -0.25);
|
||||
try expect(result.imag == 0.0);
|
||||
}
|
||||
{
|
||||
// if the first operand is an infinity and the second operand is a finite number, then the
|
||||
// result of the / operator is an infinity;
|
||||
var a: T = -math.inf(T);
|
||||
var b: T = 0.0;
|
||||
var c: T = -4.0;
|
||||
var d: T = 1.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == math.inf(T));
|
||||
try expect(result.imag == math.inf(T));
|
||||
}
|
||||
{
|
||||
// if the first operand is a finite number and the second operand is an infinity, then the
|
||||
// result of the / operator is a zero;
|
||||
var a: T = 17.2;
|
||||
var b: T = 0.0;
|
||||
var c: T = -math.inf(T);
|
||||
var d: T = 0.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == -0.0);
|
||||
try expect(result.imag == 0.0);
|
||||
}
|
||||
{
|
||||
// if the first operand is a nonzero finite number or an infinity and the second operand is
|
||||
// a zero, then the result of the / operator is an infinity
|
||||
var a: T = 1.1;
|
||||
var b: T = 0.1;
|
||||
var c: T = 0.0;
|
||||
var d: T = 0.0;
|
||||
|
||||
const result = f(a, b, c, d);
|
||||
try expect(result.real == math.inf(T));
|
||||
try expect(result.imag == math.inf(T));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
const common = @import("./common.zig");
|
||||
const divc3 = @import("./divc3.zig");
|
||||
const Complex = @import("./mulc3.zig").Complex;
|
||||
|
||||
comptime {
|
||||
@export(__divdc3, .{ .name = "__divdc3", .linkage = common.linkage });
|
||||
}
|
||||
|
||||
pub fn __divdc3(a: f64, b: f64, c: f64, d: f64) callconv(.C) Complex(f64) {
|
||||
return divc3.divc3(f64, a, b, c, d);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user