Skip to content
Merged

Patch 4 #1193

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/fast_io_core_impl/allocation/adapters.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<T *>(newres.ptr), newres.count / sizeof(T)};
}
}
Expand Down
8 changes: 6 additions & 2 deletions include/fast_io_core_impl/char_category/char_category.h
Original file line number Diff line number Diff line change
Expand Up @@ -1859,7 +1859,9 @@ inline constexpr bool is_c_halfwidth(char_type ch) noexcept
using unsigned_char_type = ::std::make_unsigned_t<char_type>;
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<unsigned_char_type>(ch - halfwidth_exclaimation_mark_val) < num;
}
else if constexpr (!::std::same_as<char_type, char32_t> && sizeof(char_type) == sizeof(char32_t))
{
Expand Down Expand Up @@ -1891,7 +1893,9 @@ inline constexpr bool is_c_fullwidth(char_type ch) noexcept
using unsigned_char_type = ::std::make_unsigned_t<char_type>;
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<unsigned_char_type>(ch - fullwidth_exclaimation_mark_val) < num;
}
else if constexpr (!::std::same_as<char_type, char32_t> && sizeof(char_type) == sizeof(char32_t))
{
Expand Down
8 changes: 4 additions & 4 deletions include/fast_io_core_impl/freestanding/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,13 @@ inline constexpr ForwardIt lower_bound(ForwardIt first, ForwardIt last, T const
{
ForwardIt it;
typename ::std::iterator_traits<ForwardIt>::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))
{
Expand Down Expand Up @@ -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<typename ::std::iterator_traits<ForwardIt>::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>
Expand Down Expand Up @@ -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<typename ::std::iterator_traits<ForwardIt>::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>
Expand Down
3 changes: 2 additions & 1 deletion include/fast_io_core_impl/freestanding/bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ inline constexpr ::std::byte *nonoverlapped_bytes_copy(::std::byte const *first,
}

template <typename T>
requires(::std::is_trivially_copyable_v<T>) // 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
{
Expand Down Expand Up @@ -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<T>)
inline constexpr ::std::byte *type_punning_to_bytes_n(T const &__restrict first, ::std::byte *__restrict dest) noexcept
{
if constexpr (n != 0)
Expand Down
8 changes: 4 additions & 4 deletions include/fast_io_core_impl/integers/crypto_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ inline constexpr hash_compress_t<digest_format::upper, ctx> 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<T>)};
}
}

Expand All @@ -296,7 +296,7 @@ inline constexpr hash_compress_t<digest_format::raw_bytes, ctx> 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<T>)};
}
}

Expand Down Expand Up @@ -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<T>(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
{
Expand Down Expand Up @@ -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<T>(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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#error "We do not recommend using this header file for the time being."

namespace fast_io
{

Expand Down
9 changes: 7 additions & 2 deletions include/fast_io_hosted/filesystem/dos_at.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 <posix_api_12 dsp, typename... Args>
Expand Down Expand Up @@ -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);
}
Expand Down
17 changes: 11 additions & 6 deletions include/fast_io_hosted/filesystem/nt_at.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,9 @@ struct nt_create_nothrow_callback
};

template <bool zw>
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

Expand Down Expand Up @@ -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<perms>(436)})};

::fast_io::basic_nt_family_file<(zw ? nt_family::zw : nt_family::nt), char8_t> new_file(
Expand All @@ -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
}

Expand Down Expand Up @@ -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<family == nt_family::zw, dsp>(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...);
});
}

Expand All @@ -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<family == nt_family::zw, dsp>(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...);
});
});
}
Expand All @@ -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<family == nt_family::zw, dsp>(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...);
});
});
}
Expand Down
10 changes: 8 additions & 2 deletions include/fast_io_hosted/filesystem/win32_9xa_at.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<char8_t> 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(
Expand All @@ -321,6 +323,10 @@ inline void win32_9xa_symlinkat_impl(char8_t const *oldpath_c_str, ::std::size_t
::fast_io::operations::print_freestanding<false>(u8obv, u8"!<symlink>", 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,
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_hosted/platforms/win32/msvc_linker_32.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_hosted/platforms/win32/msvc_linker_64.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading