diff --git a/include/fast_io_core_impl/allocation/adapters.h b/include/fast_io_core_impl/allocation/adapters.h index 8a80c26f6..e43ebb92f 100644 --- a/include/fast_io_core_impl/allocation/adapters.h +++ b/include/fast_io_core_impl/allocation/adapters.h @@ -1253,7 +1253,7 @@ class typed_generic_allocator_adapter } else { - auto newres{alloc::allocate_zero_aligned_at_least(alignof(T), n * sizeof(T))}; + auto newres{alloc::allocate_aligned_zero_at_least(alignof(T), n * sizeof(T))}; return {reinterpret_cast(newres.ptr), newres.count / sizeof(T)}; } } diff --git a/include/fast_io_core_impl/char_category/char_category.h b/include/fast_io_core_impl/char_category/char_category.h index 205ec1e9c..f525a4470 100644 --- a/include/fast_io_core_impl/char_category/char_category.h +++ b/include/fast_io_core_impl/char_category/char_category.h @@ -1859,7 +1859,9 @@ inline constexpr bool is_c_halfwidth(char_type ch) noexcept using unsigned_char_type = ::std::make_unsigned_t; if constexpr (sizeof(char_type) < sizeof(char32_t)) { - return ch; + constexpr unsigned_char_type halfwidth_exclaimation_mark_val{u8'!'}; + constexpr unsigned_char_type num{94}; + return static_cast(ch - halfwidth_exclaimation_mark_val) < num; } else if constexpr (!::std::same_as && sizeof(char_type) == sizeof(char32_t)) { @@ -1891,7 +1893,9 @@ inline constexpr bool is_c_fullwidth(char_type ch) noexcept using unsigned_char_type = ::std::make_unsigned_t; if constexpr (sizeof(char_type) < sizeof(char32_t)) { - return ch; + constexpr unsigned_char_type fullwidth_exclaimation_mark_val{0xFF01}; + constexpr unsigned_char_type num{94}; + return static_cast(ch - fullwidth_exclaimation_mark_val) < num; } else if constexpr (!::std::same_as && sizeof(char_type) == sizeof(char32_t)) { diff --git a/include/fast_io_core_impl/freestanding/algorithm.h b/include/fast_io_core_impl/freestanding/algorithm.h index f0ed0b983..98dcd4642 100644 --- a/include/fast_io_core_impl/freestanding/algorithm.h +++ b/include/fast_io_core_impl/freestanding/algorithm.h @@ -532,13 +532,13 @@ inline constexpr ForwardIt lower_bound(ForwardIt first, ForwardIt last, T const { ForwardIt it; typename ::std::iterator_traits::difference_type count, step; - count = last - first; + count = ::std::distance(first, last); while (count > 0) { it = first; step = count / 2; - it += step; + ::std::advance(it, step); if (comp(*it, value)) { @@ -735,7 +735,7 @@ template <::std::input_iterator ForwardIt> inline constexpr void uninitialized_default_construct_n(ForwardIt first, ::std::size_t n) noexcept( ::std::is_nothrow_default_constructible_v::value_type>) { - ::fast_io::freestanding::uninitialized_default_construct(first, first + n); + ::fast_io::freestanding::uninitialized_default_construct(first, ::std::next(first, n)); } template <::std::input_iterator ForwardIt, typename T> @@ -771,7 +771,7 @@ template <::std::input_iterator ForwardIt, typename T> inline constexpr void uninitialized_fill_n(ForwardIt first, ::std::size_t n, T const &x) noexcept( ::std::is_nothrow_copy_constructible_v::value_type>) { - ::fast_io::freestanding::uninitialized_fill(first, first + n, x); + ::fast_io::freestanding::uninitialized_fill(first, ::std::next(first, n), x); } template <::std::forward_iterator ForwardIt> diff --git a/include/fast_io_core_impl/freestanding/bytes.h b/include/fast_io_core_impl/freestanding/bytes.h index 0596e8fac..afa0cebcd 100644 --- a/include/fast_io_core_impl/freestanding/bytes.h +++ b/include/fast_io_core_impl/freestanding/bytes.h @@ -137,6 +137,7 @@ inline constexpr ::std::byte *nonoverlapped_bytes_copy(::std::byte const *first, } template + requires(::std::is_trivially_copyable_v) // make sure the type is trivially copyable for safely using memcpy inline constexpr ::std::byte const *type_punning_from_bytes(::std::byte const *__restrict first, T &__restrict t) noexcept { @@ -164,7 +165,7 @@ inline constexpr ::std::byte const *type_punning_from_bytes(::std::byte const *_ } template <::std::size_t n, typename T> - requires(n <= sizeof(T)) + requires(n <= sizeof(T) && ::std::is_trivially_copyable_v) inline constexpr ::std::byte *type_punning_to_bytes_n(T const &__restrict first, ::std::byte *__restrict dest) noexcept { if constexpr (n != 0) diff --git a/include/fast_io_core_impl/integers/crypto_hash.h b/include/fast_io_core_impl/integers/crypto_hash.h index 5f2a74c14..71c1c0e63 100644 --- a/include/fast_io_core_impl/integers/crypto_hash.h +++ b/include/fast_io_core_impl/integers/crypto_hash.h @@ -281,7 +281,7 @@ inline constexpr hash_compress_t hash_compress_upper( else { return {reinterpret_cast<::std::byte const *>(::std::ranges::data(t)), - static_cast<::std::size_t>(::std::ranges::size(t)) * sizeof(T)}; + static_cast<::std::size_t>(::std::ranges::size(t)) * sizeof(::std::ranges::range_value_t)}; } } @@ -296,7 +296,7 @@ inline constexpr hash_compress_t hash_compress_ra else { return {reinterpret_cast<::std::byte const *>(::std::ranges::data(t)), - static_cast<::std::size_t>(::std::ranges::size(t)) * sizeof(T)}; + static_cast<::std::size_t>(::std::ranges::size(t)) * sizeof(::std::ranges::range_value_t)}; } } @@ -478,7 +478,7 @@ inline constexpr char_type *prv_srv_hash_compress_df_impl(char_type *iter, ::std ::std::byte buffer[digest_size]; auto ret{cal_hash_internal_impl(base, len, buffer)}; return ::fast_io::details::copy_to_hash_df_commom_impl < d == - ::fast_io::manipulators::digest_format::upper > (buffer, iter, static_cast<::std::size_t>(ret - buffer)); + ::fast_io::manipulators::digest_format::upper > (iter, buffer, static_cast<::std::size_t>(ret - buffer)); } else { @@ -512,7 +512,7 @@ inline constexpr char_type *prv_srv_hash_compress_df_impl(char_type *iter, ::std ::std::byte buffer[digest_size]; cal_hash_internal(base, len, buffer); return ::fast_io::details::copy_to_hash_df_commom_impl < d == - ::fast_io::manipulators::digest_format::upper > (buffer, iter, digest_size); + ::fast_io::manipulators::digest_format::upper > (iter, buffer, digest_size); } else { diff --git a/include/fast_io_core_impl/operations/printimpl/print_freestanding_cxx20.h b/include/fast_io_core_impl/operations/printimpl/print_freestanding_cxx20.h index 20df211ad..27eb12af9 100644 --- a/include/fast_io_core_impl/operations/printimpl/print_freestanding_cxx20.h +++ b/include/fast_io_core_impl/operations/printimpl/print_freestanding_cxx20.h @@ -141,7 +141,7 @@ inline constexpr scatter_rsv_result find_continuous_scatters_reserve_n() { if constexpr (sizeof...(Args) == 0) { - return {1, 0, ::fast_io::details::intrinsics::add_or_overflow_die_chain(static_cast<::std::size_t>(0), static_cast<::std::size_t>(1))}; + return {1, 0, 1}; } else { diff --git a/include/fast_io_core_impl/operations/printimpl/print_freestanding_cxx26.h b/include/fast_io_core_impl/operations/printimpl/print_freestanding_cxx26.h index 92633ef6e..e41db93f4 100644 --- a/include/fast_io_core_impl/operations/printimpl/print_freestanding_cxx26.h +++ b/include/fast_io_core_impl/operations/printimpl/print_freestanding_cxx26.h @@ -1,5 +1,7 @@ #pragma once +#error "We do not recommend using this header file for the time being." + namespace fast_io { diff --git a/include/fast_io_hosted/filesystem/dos_at.h b/include/fast_io_hosted/filesystem/dos_at.h index e6ffd1bf2..a63ce23ba 100644 --- a/include/fast_io_hosted/filesystem/dos_at.h +++ b/include/fast_io_hosted/filesystem/dos_at.h @@ -17,6 +17,8 @@ extern int my_dos_rename(char const *oldname, char const *newname) noexcept __as // Because of limitations of MS-DOS, this function doesn't really link two files together. // However, it simulates a real link by copying the file at exists to new. extern int my_dos_link(char const *exists, char const *newname) noexcept __asm__("_link"); +// The symlink of djgpp only generates a 510-byte file and does not exist as a soft link, so it +// will be disabled later. extern int my_dos_symlink(char const *exists, char const *newname) noexcept __asm__("_symlink"); extern int my_dos_chmod(char const *path, mode_t mode) noexcept __asm__("_chmod"); extern int my_dos_utime(char const *file, utimbuf const *time) noexcept __asm__("_utime"); @@ -136,9 +138,13 @@ inline auto dos22_api_dispatcher(int olddirfd, char const *oldpath, int newdirfd } } -inline void dos_symlinkat_impl(char const *oldpath, int newdirfd, char const *newpath) +inline void dos_symlinkat_impl([[maybe_unused]] char const *oldpath, [[maybe_unused]] int newdirfd, [[maybe_unused]] char const *newpath) { +#if defined(FAST_IO_USE_DJGPP_SYMLINK) ::fast_io::system_call_throw_error(::fast_io::posix::my_dos_symlink(oldpath, ::fast_io::details::my_dos_concat_tlc_path(newdirfd, newpath).c_str())); +#else + throw_posix_error(ENOSYS); +#endif } template @@ -203,7 +209,6 @@ inline [[fallthrough]]; case utime_flags::omit: throw_posix_error(EINVAL); - ::fast_io::unreachable(); default: return ::fast_io::details::unix_timestamp_to_time_t(opt.timestamp); } diff --git a/include/fast_io_hosted/filesystem/nt_at.h b/include/fast_io_hosted/filesystem/nt_at.h index 409e9ce66..75ca4f4fb 100644 --- a/include/fast_io_hosted/filesystem/nt_at.h +++ b/include/fast_io_hosted/filesystem/nt_at.h @@ -434,8 +434,9 @@ struct nt_create_nothrow_callback }; template -inline void nt_symlinkat_impl(char16_t const *oldpath_c_str, ::std::size_t oldpath_size, - void *newdirhd, char16_t const *newpath_c_str, ::std::size_t newpath_size, bool kernel) +inline void nt_symlinkat_impl([[maybe_unused]] char16_t const *oldpath_c_str, [[maybe_unused]] ::std::size_t oldpath_size, + [[maybe_unused]] void *newdirhd, [[maybe_unused]] char16_t const *newpath_c_str, + [[maybe_unused]] ::std::size_t newpath_size, [[maybe_unused]] bool kernel) { #if !defined(_WIN32_WINNT) || _WIN32_WINNT > 0x0600 @@ -634,6 +635,7 @@ inline void nt_symlinkat_impl(char16_t const *oldpath_c_str, ::std::size_t oldpa throw_nt_error(status); } #else +#if defined(FAST_IO_USE_DJGPP_SYMLINK) constexpr nt_open_mode symbol_mode{::fast_io::win32::nt::details::calculate_nt_open_mode({::fast_io::open_mode::out, static_cast(436)})}; ::fast_io::basic_nt_family_file<(zw ? nt_family::zw : nt_family::nt), char8_t> new_file( @@ -647,6 +649,9 @@ inline void nt_symlinkat_impl(char16_t const *oldpath_c_str, ::std::size_t oldpa u8"\nThis is just a text to force symlink file to be 510 bytes long. Do not delete it nor spaces following it."); ::fast_io::operations::write_all(new_file, buffer, buffer + 510); +#else + throw_nt_error(0xC0000002); +#endif #endif } @@ -824,7 +829,7 @@ inline auto nt_deal_with1x(void *dir_handle, path_type const &path, Args... args { return nt_api_common( path, [&](char16_t const *path_c_str, ::std::size_t path_size) { - return nt1x_api_dispatcher(dir_handle, path_c_str, path_size, args...); + return nt1x_api_dispatcher < family == nt_family::zw, dsp > (dir_handle, path_c_str, path_size, args...); }); } @@ -837,7 +842,7 @@ inline auto nt_deal_with12(old_path_type const &oldpath, void *newdirfd, new_pat [&](char16_t const *oldpath_c_str, ::std::size_t oldpath_size) { return nt_api_common( newpath, [&](char16_t const *newpath_c_str, ::std::size_t newpath_size) { - return nt12_api_dispatcher(oldpath_c_str, oldpath_size, newdirfd, newpath_c_str, newpath_size, args...); + return nt12_api_dispatcher < family == nt_family::zw, dsp > (oldpath_c_str, oldpath_size, newdirfd, newpath_c_str, newpath_size, args...); }); }); } @@ -849,8 +854,8 @@ inline auto nt_deal_with22(void *olddirhd, oldpath_type const &oldpath, void *ne [&](char16_t const *oldpath_c_str, ::std::size_t oldpath_size) { return nt_api_common(newpath, [&](char16_t const *newpath_c_str, ::std::size_t newpath_size) { - return nt22_api_dispatcher(olddirhd, oldpath_c_str, oldpath_size, newdirhd, - newpath_c_str, newpath_size, args...); + return nt22_api_dispatcher < family == nt_family::zw, dsp > (olddirhd, oldpath_c_str, oldpath_size, newdirhd, + newpath_c_str, newpath_size, args...); }); }); } diff --git a/include/fast_io_hosted/filesystem/win32_9xa_at.h b/include/fast_io_hosted/filesystem/win32_9xa_at.h index 074f66fdc..6146cc229 100644 --- a/include/fast_io_hosted/filesystem/win32_9xa_at.h +++ b/include/fast_io_hosted/filesystem/win32_9xa_at.h @@ -305,9 +305,11 @@ inline void win32_9xa_utimensat_impl(::fast_io::win32_9xa_dir_handle const &dirh } } -inline void win32_9xa_symlinkat_impl(char8_t const *oldpath_c_str, ::std::size_t oldpath_size, - ::fast_io::win32_9xa_dir_handle const &newdirhd, char8_t const *newpath_c_str, ::std::size_t newpath_size) +inline void win32_9xa_symlinkat_impl([[maybe_unused]] char8_t const *oldpath_c_str, [[maybe_unused]] ::std::size_t oldpath_size, + [[maybe_unused]] ::fast_io::win32_9xa_dir_handle const &newdirhd, + [[maybe_unused]] char8_t const *newpath_c_str, [[maybe_unused]] ::std::size_t newpath_size) { +#if defined(FAST_IO_USE_DJGPP_SYMLINK) ::fast_io::containers::basic_cstring_view path{::fast_io::containers::null_terminated, oldpath_c_str, oldpath_size}; ::fast_io::u8win32_file_9xa f{::fast_io::win32::details::basic_win32_9xa_create_file_at_fs_dirent_impl( @@ -321,6 +323,10 @@ inline void win32_9xa_symlinkat_impl(char8_t const *oldpath_c_str, ::std::size_t ::fast_io::operations::print_freestanding(u8obv, u8"!", path, u8"\nThis is just a text to force symlink file to be 510 bytes long. Do not delete it nor spaces following it."); ::fast_io::operations::write_all(f, buffer, buffer + 510); + +#else + throw_win32_error(0x1); +#endif } inline void win32_9xa_linkat_impl(::fast_io::win32_9xa_dir_handle const &olddirhd, char8_t const *oldpath_c_str, ::std::size_t oldpath_size, diff --git a/include/fast_io_hosted/platforms/win32/msvc_linker_32.h b/include/fast_io_hosted/platforms/win32/msvc_linker_32.h index 0279ddbbf..a0e312070 100644 --- a/include/fast_io_hosted/platforms/win32/msvc_linker_32.h +++ b/include/fast_io_hosted/platforms/win32/msvc_linker_32.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // This file have been generated by example/0039.win32mangling, therefore, do NOT edit this file directely! // clang-format off // WIN32 diff --git a/include/fast_io_hosted/platforms/win32/msvc_linker_32_i686.h b/include/fast_io_hosted/platforms/win32/msvc_linker_32_i686.h index e7a26e1b4..a8493d1ba 100644 --- a/include/fast_io_hosted/platforms/win32/msvc_linker_32_i686.h +++ b/include/fast_io_hosted/platforms/win32/msvc_linker_32_i686.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // This file have been generated by example/0039.win32mangling, therefore, do NOT edit this file directely! // clang-format off // WIN32 diff --git a/include/fast_io_hosted/platforms/win32/msvc_linker_64.h b/include/fast_io_hosted/platforms/win32/msvc_linker_64.h index 39a9af191..184427533 100644 --- a/include/fast_io_hosted/platforms/win32/msvc_linker_64.h +++ b/include/fast_io_hosted/platforms/win32/msvc_linker_64.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // This file have been generated by example/0039.win32mangling, therefore, do NOT edit this file directely! // clang-format off // WIN32 diff --git a/include/fast_io_hosted/platforms/win32/msvc_linker_arm64ec.h b/include/fast_io_hosted/platforms/win32/msvc_linker_arm64ec.h index 2cb5c6159..262482bb7 100644 --- a/include/fast_io_hosted/platforms/win32/msvc_linker_arm64ec.h +++ b/include/fast_io_hosted/platforms/win32/msvc_linker_arm64ec.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once // This file have been generated by example/0039.win32mangling, therefore, do NOT edit this file directely! // clang-format off // WIN32