diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-01-26 00:40:51 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-01-26 00:42:44 +0100 |
commit | cf7db48c261ee9c896c813a38ff8c59da5b8fe07 (patch) | |
tree | 41d827be5db5f3322d745215fe38a9c395a52fa3 | |
parent | 79aaec3d7d12bc1a0483f19eadeda325a2d65920 (diff) |
Fix line endings
64 files changed, 6490 insertions, 6412 deletions
@@ -1,44 +1,44 @@ -startup --windows_enable_symlinks
-build:windows --enable_runfiles=true
-
-build --build_python_zip=false
-
-build:windows --extra_execution_platforms=//:x64_windows-clang-cl
-# @Todo(bazel) We should be able to use @local_config_cc...
-build:windows --extra_toolchains=@@rules_cc++cc_configure_extension+local_config_cc//:cc-toolchain-x64_windows-clang-cl
-
-build:linux --repo_env=CC=clang
-
-build:windows --cxxopt=-Xclang=-std=c++20
-build:linux --cxxopt=-std=c++20
-
-build --cxxopt=-Wall
-build --cxxopt=-Wno-c++98-compat
-build --cxxopt=-Wno-c++98-compat-pedantic
-build --cxxopt=-Wno-pre-c++17-compat
-build --cxxopt=-Wno-c++20-compat
-build --cxxopt=-Wno-unused-macros
-build --cxxopt=-Wno-documentation-unknown-command
-build --cxxopt=-Wno-extra-semi-stmt
-build --cxxopt=-Wno-extra-semi
-build --cxxopt=-Wno-global-constructors
-build --cxxopt=-Wno-unsafe-buffer-usage
-build --cxxopt=-Wno-covered-switch-default
-
-build:windows_san --config=windows
-build:windows_san --copt=-fno-sanitize-ignorelist
-build:windows_san --copt=-fsanitize=address
-build:windows_san --copt=-fsanitize=undefined
-build:windows_san --copt=-fno-sanitize-recover=all
-build:windows_san --linkopt=clang_rt.asan-x86_64.lib
-build:windows_san --copt=/MT
-
-build:linux_san --config=linux
-build:linux_san --copt=-fsanitize=address
-build:linux_san --linkopt=-fsanitize=address
-build:linux_san --copt=-fsanitize=undefined
-build:linux_san --copt=-fno-sanitize-recover=all
-build:linux_san --linkopt=-fsanitize=undefined
-build:linux_san --linkopt=-fsanitize-link-c++-runtime
-
-test --test_output=errors
+startup --windows_enable_symlinks +build:windows --enable_runfiles=true + +build --build_python_zip=false + +build:windows --extra_execution_platforms=//:x64_windows-clang-cl +# @Todo(bazel) We should be able to use @local_config_cc... +build:windows --extra_toolchains=@@rules_cc++cc_configure_extension+local_config_cc//:cc-toolchain-x64_windows-clang-cl + +build:linux --repo_env=CC=clang + +build:windows --cxxopt=-Xclang=-std=c++20 +build:linux --cxxopt=-std=c++20 + +build --cxxopt=-Wall +build --cxxopt=-Wno-c++98-compat +build --cxxopt=-Wno-c++98-compat-pedantic +build --cxxopt=-Wno-pre-c++17-compat +build --cxxopt=-Wno-c++20-compat +build --cxxopt=-Wno-unused-macros +build --cxxopt=-Wno-documentation-unknown-command +build --cxxopt=-Wno-extra-semi-stmt +build --cxxopt=-Wno-extra-semi +build --cxxopt=-Wno-global-constructors +build --cxxopt=-Wno-unsafe-buffer-usage +build --cxxopt=-Wno-covered-switch-default + +build:windows_san --config=windows +build:windows_san --copt=-fno-sanitize-ignorelist +build:windows_san --copt=-fsanitize=address +build:windows_san --copt=-fsanitize=undefined +build:windows_san --copt=-fno-sanitize-recover=all +build:windows_san --linkopt=clang_rt.asan-x86_64.lib +build:windows_san --copt=/MT + +build:linux_san --config=linux +build:linux_san --copt=-fsanitize=address +build:linux_san --linkopt=-fsanitize=address +build:linux_san --copt=-fsanitize=undefined +build:linux_san --copt=-fno-sanitize-recover=all +build:linux_san --linkopt=-fsanitize=undefined +build:linux_san --linkopt=-fsanitize-link-c++-runtime + +test --test_output=errors diff --git a/.clang-tidy b/.clang-tidy index d7337bd..d988d1b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,34 +1,34 @@ -Checks:
- - "hicpp-*"
- - "cppcoreguidelines-*"
- - "misc-*"
- - "clang-analyzer-*"
- - "-misc-include-cleaner"
- - "performance-*"
- - "readability-*"
- - "-*-named-parameter"
- - "-*-avoid-do-while"
- - "-*-magic-numbers"
- - "-*-identifier-length"
- - "-*-union-access"
- - "-*-vararg"
- - "-*-macro-usage"
- - "-*-non-private-member-variables-in-classes"
- - "-*-avoid-non-const-global-variables"
- - "-*-missing-std-forward"
- - "-*-owning-memory"
- - "-*-no-malloc"
- - "-*-avoid-c-arrays"
- - "-*-use-anonymous-namespace"
- - "-*-reinterpret-cast"
- - "-*-noexcept-swap"
- - "-*-noexcept-move"
- - "-*-noexcept-move-constructor"
- - "-*-noexcept-move-operations"
- - "-*-bounds-array-to-pointer-decay"
- - "-*-no-array-decay"
- - "-*-signed-bitwise"
- - "-readability-use-anyofallof"
- - "-readability-function-cognitive-complexity"
- - "-readability-math-missing-parentheses"
- - "-*-rvalue-reference-param-not-moved"
+Checks: + - "hicpp-*" + - "cppcoreguidelines-*" + - "misc-*" + - "clang-analyzer-*" + - "-misc-include-cleaner" + - "performance-*" + - "readability-*" + - "-*-named-parameter" + - "-*-avoid-do-while" + - "-*-magic-numbers" + - "-*-identifier-length" + - "-*-union-access" + - "-*-vararg" + - "-*-macro-usage" + - "-*-non-private-member-variables-in-classes" + - "-*-avoid-non-const-global-variables" + - "-*-missing-std-forward" + - "-*-owning-memory" + - "-*-no-malloc" + - "-*-avoid-c-arrays" + - "-*-use-anonymous-namespace" + - "-*-reinterpret-cast" + - "-*-noexcept-swap" + - "-*-noexcept-move" + - "-*-noexcept-move-constructor" + - "-*-noexcept-move-operations" + - "-*-bounds-array-to-pointer-decay" + - "-*-no-array-decay" + - "-*-signed-bitwise" + - "-readability-use-anyofallof" + - "-readability-function-cognitive-complexity" + - "-readability-math-missing-parentheses" + - "-*-rvalue-reference-param-not-moved" @@ -1,2 +1,4 @@ -bazel-*/
-compile_commands.json
+bazel-*/ +compile_commands.json +.cache/ +external/ diff --git a/BUILD.bazel b/BUILD.bazel index d861b66..c5a2f79 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,18 +1,18 @@ -load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")
-
-refresh_compile_commands(
- name = "refresh_clangd",
- targets = "//...",
-)
-
-platform(
- name = "x64_windows-clang-cl",
- constraint_values = [
- "@platforms//cpu:x86_64",
- "@platforms//os:windows",
- # @Todo(bazel) Bit weird to use a private thing.
- # We used to use @bazel_tools//tools/cpp:clang-cl but it's deprecated
- # in favor of... this?...
- "@rules_cc//cc/private/toolchain:clang-cl",
- ],
-)
+load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands") + +refresh_compile_commands( + name = "refresh_clangd", + targets = "//...", +) + +platform( + name = "x64_windows-clang-cl", + constraint_values = [ + "@platforms//cpu:x86_64", + "@platforms//os:windows", + # @Todo(bazel) Bit weird to use a private thing. + # We used to use @bazel_tools//tools/cpp:clang-cl but it's deprecated + # in favor of... this?... + "@rules_cc//cc/private/toolchain:clang-cl", + ], +) diff --git a/MODULE.bazel b/MODULE.bazel index a10bf6f..197d3cc 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,15 +1,15 @@ -module(name = "asl")
-
-bazel_dep(name = "platforms", version = "0.0.10")
-bazel_dep(name = "rules_cc", version = "0.0.17")
-
-bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
-git_override(
- module_name = "hedron_compile_commands",
- remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
- commit = "4f28899228fb3ad0126897876f147ca15026151e",
-)
-
-bazel_dep(name = "rules_python", version = "1.1.0", dev_dependency = True)
-python = use_extension("@rules_python//python/extensions:python.bzl", "python")
-python.toolchain(python_version = "3.13", is_default = True)
+module(name = "asl") + +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "rules_cc", version = "0.0.17") + +bazel_dep(name = "hedron_compile_commands", dev_dependency = True) +git_override( + module_name = "hedron_compile_commands", + remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git", + commit = "4f28899228fb3ad0126897876f147ca15026151e", +) + +bazel_dep(name = "rules_python", version = "1.1.0", dev_dependency = True) +python = use_extension("@rules_python//python/extensions:python.bzl", "python") +python.toolchain(python_version = "3.13", is_default = True) diff --git a/asl/BUILD.bazel b/asl/BUILD.bazel index 2d82f4b..2cc4af5 100644 --- a/asl/BUILD.bazel +++ b/asl/BUILD.bazel @@ -1,78 +1,78 @@ -cc_library(
- name = "asl",
- hdrs = [
- "allocator.hpp",
- "annotations.hpp",
- "assert.hpp",
- "atomic.hpp",
- "box.hpp",
- "buffer.hpp",
- "config.hpp",
- "float.hpp",
- "format.hpp",
- "functional.hpp",
- "hash.hpp",
- "hash_map.hpp",
- "hash_set.hpp",
- "integers.hpp",
- "io.hpp",
- "layout.hpp",
- "maybe_uninit.hpp",
- "memory.hpp",
- "meta.hpp",
- "option.hpp",
- "print.hpp",
- "span.hpp",
- "status.hpp",
- "status_or.hpp",
- "string.hpp",
- "string_builder.hpp",
- "string_view.hpp",
- "utility.hpp",
- ],
- srcs = [
- "allocator.cpp",
- "assert.cpp",
- "format.cpp",
- "format_float.cpp",
- "hash_cityhash.cpp",
- "print.cpp",
- "status.cpp",
- ],
- deps = [
- "//vendor/dragonbox",
- ],
- visibility = ["//visibility:public"],
-)
-
-[cc_test(
- name = "%s_tests" % name,
- srcs = [
- "tests/%s_tests.cpp" % name,
- "tests/test_types.hpp",
- ],
- deps = [
- ":asl",
- "//asl/testing",
- ],
-) for name in [
- "box",
- "buffer",
- "float",
- "format",
- "functional",
- "hash",
- "hash_map",
- "hash_set",
- "integers",
- "maybe_uninit",
- "meta",
- "option",
- "span",
- "status",
- "status_or",
- "string",
- "string_builder",
- "string_view",
- "utility",
-]]
+cc_library( + name = "asl", + hdrs = [ + "allocator.hpp", + "annotations.hpp", + "assert.hpp", + "atomic.hpp", + "box.hpp", + "buffer.hpp", + "config.hpp", + "float.hpp", + "format.hpp", + "functional.hpp", + "hash.hpp", + "hash_map.hpp", + "hash_set.hpp", + "integers.hpp", + "io.hpp", + "layout.hpp", + "maybe_uninit.hpp", + "memory.hpp", + "meta.hpp", + "option.hpp", + "print.hpp", + "span.hpp", + "status.hpp", + "status_or.hpp", + "string.hpp", + "string_builder.hpp", + "string_view.hpp", + "utility.hpp", + ], + srcs = [ + "allocator.cpp", + "assert.cpp", + "format.cpp", + "format_float.cpp", + "hash_cityhash.cpp", + "print.cpp", + "status.cpp", + ], + deps = [ + "//vendor/dragonbox", + ], + visibility = ["//visibility:public"], +) + +[cc_test( + name = "%s_tests" % name, + srcs = [ + "tests/%s_tests.cpp" % name, + "tests/test_types.hpp", + ], + deps = [ + ":asl", + "//asl/testing", + ], +) for name in [ + "box", + "buffer", + "float", + "format", + "functional", + "hash", + "hash_map", + "hash_set", + "integers", + "maybe_uninit", + "meta", + "option", + "span", + "status", + "status_or", + "string", + "string_builder", + "string_view", + "utility", +]] diff --git a/asl/allocator.cpp b/asl/allocator.cpp index 5dbdce0..59bff76 100644 --- a/asl/allocator.cpp +++ b/asl/allocator.cpp @@ -1,56 +1,56 @@ -#include "asl/allocator.hpp"
-#include "asl/assert.hpp"
-#include "asl/utility.hpp"
-#include "asl/memory.hpp"
-#include "asl/print.hpp"
-
-#include <cstdlib>
-
-// @Todo zalloc
-// @Todo Cookies
-// @Todo Debug values
-
-void* asl::GlobalHeap::alloc(const layout& layout)
-{
-#if ASL_OS_WINDOWS
- void* ptr = ::_aligned_malloc(
- static_cast<size_t>(layout.size),
- static_cast<size_t>(layout.align));
-#elif ASL_OS_LINUX
- void* ptr = ::aligned_alloc(
- static_cast<size_t>(layout.align),
- static_cast<size_t>(layout.size));
-#endif
- ASL_ASSERT(ptr != nullptr); // @Todo panic
- return ptr;
-}
-
-void* asl::GlobalHeap::realloc(void* old_ptr, [[maybe_unused]] const layout& old_layout, const layout& new_layout)
-{
-#if ASL_OS_WINDOWS
- return ::_aligned_realloc(old_ptr,
- static_cast<size_t>(new_layout.size),
- static_cast<size_t>(new_layout.align));
-#elif ASL_OS_LINUX
- if (new_layout.align <= old_layout.align)
- {
- void* new_ptr = ::realloc(old_ptr, static_cast<size_t>(new_layout.size));
- ASL_ASSERT(new_ptr != nullptr); // @Todo panic
- return new_ptr;
- }
-
- void* new_ptr = alloc(new_layout);
- asl::memcpy(new_ptr, old_ptr, asl::min(old_layout.size, new_layout.size));
- dealloc(old_ptr, old_layout);
- return new_ptr;
-#endif
-}
-
-void asl::GlobalHeap::dealloc(void* ptr, const layout&)
-{
-#if ASL_OS_WINDOWS
- ::_aligned_free(ptr);
-#elif ASL_OS_LINUX
- ::free(ptr);
-#endif
-}
+#include "asl/allocator.hpp" +#include "asl/assert.hpp" +#include "asl/utility.hpp" +#include "asl/memory.hpp" +#include "asl/print.hpp" + +#include <cstdlib> + +// @Todo zalloc +// @Todo Cookies +// @Todo Debug values + +void* asl::GlobalHeap::alloc(const layout& layout) +{ +#if ASL_OS_WINDOWS + void* ptr = ::_aligned_malloc( + static_cast<size_t>(layout.size), + static_cast<size_t>(layout.align)); +#elif ASL_OS_LINUX + void* ptr = ::aligned_alloc( + static_cast<size_t>(layout.align), + static_cast<size_t>(layout.size)); +#endif + ASL_ASSERT(ptr != nullptr); // @Todo panic + return ptr; +} + +void* asl::GlobalHeap::realloc(void* old_ptr, [[maybe_unused]] const layout& old_layout, const layout& new_layout) +{ +#if ASL_OS_WINDOWS + return ::_aligned_realloc(old_ptr, + static_cast<size_t>(new_layout.size), + static_cast<size_t>(new_layout.align)); +#elif ASL_OS_LINUX + if (new_layout.align <= old_layout.align) + { + void* new_ptr = ::realloc(old_ptr, static_cast<size_t>(new_layout.size)); + ASL_ASSERT(new_ptr != nullptr); // @Todo panic + return new_ptr; + } + + void* new_ptr = alloc(new_layout); + asl::memcpy(new_ptr, old_ptr, asl::min(old_layout.size, new_layout.size)); + dealloc(old_ptr, old_layout); + return new_ptr; +#endif +} + +void asl::GlobalHeap::dealloc(void* ptr, const layout&) +{ +#if ASL_OS_WINDOWS + ::_aligned_free(ptr); +#elif ASL_OS_LINUX + ::free(ptr); +#endif +} diff --git a/asl/allocator.hpp b/asl/allocator.hpp index 265378b..90793dd 100644 --- a/asl/allocator.hpp +++ b/asl/allocator.hpp @@ -1,58 +1,58 @@ -#pragma once
-
-#include "asl/layout.hpp"
-#include "asl/meta.hpp"
-#include "asl/memory.hpp"
-
-namespace asl
-{
-
-template<typename T>
-concept allocator = moveable<T> && equality_comparable<T> &&
- requires(T& alloc, layout layout, void* ptr)
- {
- { alloc.alloc(layout) } -> same_as<void*>;
- { alloc.realloc(ptr, layout, layout) } -> same_as<void*>;
- alloc.dealloc(ptr, layout);
- };
-
-class GlobalHeap
-{
-public:
- static void* alloc(const layout&);
- static void* realloc(void* ptr, const layout& old, const layout& new_layout);
- static void dealloc(void* ptr, const layout&);
-
- constexpr bool operator==(const GlobalHeap&) const { return true; }
-};
-static_assert(allocator<GlobalHeap>);
-
-using DefaultAllocator = GlobalHeap;
-
-template<typename T>
-T* alloc_new(allocator auto& a, auto&&... args)
-{
- void* ptr = a.alloc(layout::of<T>());
- return construct_at<T>(ptr, ASL_FWD(args)...);
-}
-
-template<typename T>
-void alloc_delete(allocator auto& a, T* ptr)
-{
- destroy(ptr);
- a.dealloc(ptr, layout::of<T>());
-}
-
-template<typename T>
-constexpr T* alloc_new_default(auto&&... args)
-{
- return alloc_new<T>(DefaultAllocator{}, ASL_FWD(args)...);
-}
-
-template<typename T>
-void alloc_delete_default(T* ptr)
-{
- alloc_delete(DefaultAllocator{}, ptr);
-}
-
-} // namespace asl
+#pragma once + +#include "asl/layout.hpp" +#include "asl/meta.hpp" +#include "asl/memory.hpp" + +namespace asl +{ + +template<typename T> +concept allocator = moveable<T> && equality_comparable<T> && + requires(T& alloc, layout layout, void* ptr) + { + { alloc.alloc(layout) } -> same_as<void*>; + { alloc.realloc(ptr, layout, layout) } -> same_as<void*>; + alloc.dealloc(ptr, layout); + }; + +class GlobalHeap +{ +public: + static void* alloc(const layout&); + static void* realloc(void* ptr, const layout& old, const layout& new_layout); + static void dealloc(void* ptr, const layout&); + + constexpr bool operator==(const GlobalHeap&) const { return true; } +}; +static_assert(allocator<GlobalHeap>); + +using DefaultAllocator = GlobalHeap; + +template<typename T> +T* alloc_new(allocator auto& a, auto&&... args) +{ + void* ptr = a.alloc(layout::of<T>()); + return construct_at<T>(ptr, ASL_FWD(args)...); +} + +template<typename T> +void alloc_delete(allocator auto& a, T* ptr) +{ + destroy(ptr); + a.dealloc(ptr, layout::of<T>()); +} + +template<typename T> +constexpr T* alloc_new_default(auto&&... args) +{ + return alloc_new<T>(DefaultAllocator{}, ASL_FWD(args)...); +} + +template<typename T> +void alloc_delete_default(T* ptr) +{ + alloc_delete(DefaultAllocator{}, ptr); +} + +} // namespace asl diff --git a/asl/annotations.hpp b/asl/annotations.hpp index fc65378..6ea3a84 100644 --- a/asl/annotations.hpp +++ b/asl/annotations.hpp @@ -1,9 +1,9 @@ -#pragma once
-
-#include "asl/config.hpp"
-
-#if ASL_COMPILER_CLANG_CL
- #define ASL_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
-#elif ASL_COMPILER_CLANG
- #define ASL_NO_UNIQUE_ADDRESS [[no_unique_address]]
|