Skip to content
16 changes: 8 additions & 8 deletions include/fast_io_core_impl/allocation/adapters.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class generic_allocator_adapter
{
return allocator_type::allocate(n);
}
else if constexpr (::fast_io::details::has_allocate_aligned_at_least_impl<alloc>)
else if constexpr (::fast_io::details::has_allocate_at_least_impl<alloc>)
{
return allocator_type::allocate_at_least(n).ptr;
}
Expand All @@ -141,7 +141,7 @@ class generic_allocator_adapter
{
return allocator_type::allocate_zero(n);
}
else if constexpr (::fast_io::details::has_allocate_aligned_at_least_impl<alloc>)
else if constexpr (::fast_io::details::has_allocate_zero_at_least_impl<alloc>)
{
return allocator_type::allocate_zero_at_least(n).ptr;
}
Expand Down Expand Up @@ -1211,7 +1211,7 @@ class typed_generic_allocator_adapter
}
else
{
return static_cast<T *>(alloc::allocate_aligned(n * sizeof(T), alignof(T)));
return static_cast<T *>(alloc::allocate_aligned(alignof(T), n * sizeof(T)));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the order to match the function signature like

static inline void *allocate_aligned(::std::size_t alignment, ::std::size_t n) noexcept

}
}

Expand Down Expand Up @@ -1248,7 +1248,7 @@ class typed_generic_allocator_adapter
}
else
{
auto newres{alloc::allocate_aligned_at_least(n * sizeof(T), alignof(T))};
auto newres{alloc::allocate_aligned_at_least(alignof(T), n * sizeof(T))};
return {reinterpret_cast<T *>(newres.ptr), newres.count / sizeof(T)};
}
}
Expand All @@ -1274,7 +1274,7 @@ class typed_generic_allocator_adapter
}
else
{
return static_cast<T *>(alloc::allocate_zero_aligned(n * sizeof(T), alignof(T)));
return static_cast<T *>(alloc::allocate_zero_aligned(alignof(T), n * sizeof(T)));
}
}

Expand Down Expand Up @@ -1311,7 +1311,7 @@ class typed_generic_allocator_adapter
}
else
{
auto newres{alloc::allocate_zero_aligned_at_least(n * sizeof(T), alignof(T))};
auto newres{alloc::allocate_zero_aligned_at_least(alignof(T), n * sizeof(T))};
return {reinterpret_cast<T *>(newres.ptr), newres.count / sizeof(T)};
}
}
Expand Down Expand Up @@ -1339,7 +1339,7 @@ class typed_generic_allocator_adapter
}
else
{
return static_cast<T *>(alloc::reallocate_aligned(ptr, n * sizeof(T), alignof(T)));
return static_cast<T *>(alloc::reallocate_aligned(ptr, alignof(T), n * sizeof(T)));
}
}

Expand All @@ -1365,7 +1365,7 @@ class typed_generic_allocator_adapter
}
else
{
auto newres{alloc::reallocate_aligned_zero_at_least(ptr, n * sizeof(T), alignof(T))};
auto newres{alloc::reallocate_aligned_zero_at_least(ptr, alignof(T), n * sizeof(T))};
return {reinterpret_cast<T *>(newres.ptr), newres.count / sizeof(T)};
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_core_impl/allocation/custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace fast_io
class custom_global_allocator;

#if defined(FAST_IO_DISABLE_CUSTOM_THREAD_LOCAL_ALLOCATOR)
using custom_thread_local_allocator = custom_global_allocator
using custom_thread_local_allocator = custom_global_allocator;
#else
class custom_thread_local_allocator;
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_core_impl/concat/concat_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ inline constexpr T basic_general_concat_decay_impl_precise(T& str,Arg arg)
++precise_size_with_line;
constexpr std::size_t local_cap{strlike_sso_size(io_strlike_type<ch_type,T>)};
if(local_cap<precise_size_with_line)
strlike_reserve(io_strlike_type<ch_type,T>,str,local_cap);
strlike_reserve(io_strlike_type<ch_type,T>,str,precise_size_with_line);
auto first{strlike_begin(io_strlike_type<ch_type,T>,str)};
print_reserve_precise_define(io_reserve_type<ch_type,Arg>,first,precise_size,arg);
auto ptr{first+precise_size};
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_core_impl/concepts/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct basic_message_hdr
int flags; /* Flags (unused) */
inline operator basic_message_hdr<void>() const noexcept requires(!std::same_as<T,void>)
{
return {name,namelen*sizeof(T),iov,iovlen*sizeof(T),control,controllen,flags};
return {name,namelen,iov,iovlen,control,controllen,flags};
}
};

Expand Down
4 changes: 2 additions & 2 deletions include/fast_io_core_impl/dynamic_io_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ inline constexpr void dynamic_io_buffer_write_impl_unhappy(dynamic_io_buffer<::s
template<std::integral ch_type>
inline constexpr void oreserve(dynamic_io_buffer<ch_type>& ob,std::size_t new_capacity) noexcept
{
if(static_cast<std::size_t>(ob.buffer_end-ob.buffer_begin)<=new_capacity)
if(static_cast<std::size_t>(ob.buffer_end-ob.buffer_begin)>=new_capacity) // return if enough space
return;
details::dynamic_io_buffer_oreallocate_impl(ob,new_capacity);
}
Expand Down Expand Up @@ -159,7 +159,7 @@ inline constexpr void write(dynamic_io_buffer<ch_type>& ob,Iter first,Iter last)
details::dynamic_io_buffer_write_impl_unhappy(ob,first,diff);
return;
}
ob.buffer_curr=details::non_overlapped_copy(first,last,ob.buffer_begin);
ob.buffer_curr=details::non_overlapped_copy(first,last,ob.buffer_curr); // copy to buffer_curr, not buffer_begin
}
}

Expand Down
9 changes: 6 additions & 3 deletions include/fast_io_core_impl/freestanding/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ inline constexpr output_iter copy(input_iter first, input_iter last, output_iter
{
*result = static_cast<::std::byte>(*first);
}
else
{
*result = *first;
}
++first;
++result;
}
Expand Down Expand Up @@ -403,8 +407,7 @@ inline constexpr output_iter my_copy(input_iter first, input_iter second, output
::std::is_trivially_copyable_v<output_value_type> &&
(::std::same_as<input_value_type, output_value_type> ||
(::std::integral<input_value_type> && ::std::integral<output_value_type> &&
sizeof(::std::is_trivially_copyable_v<input_value_type>) ==
sizeof(::std::is_trivially_copyable_v<output_value_type>))))
sizeof(input_value_type) == sizeof(output_value_type))))
{
my_copy_n(first, static_cast<::std::size_t>(second - first), result);
return result + (second - first);
Expand Down Expand Up @@ -486,7 +489,7 @@ inline constexpr bool my_compare_iter_n(input_iter first, ::std::size_t n, outpu
(::std::integral<input_value_type> && ::std::integral<output_value_type> &&
sizeof(input_value_type) == sizeof(output_value_type))))
{
return my_memcmp(::std::to_address(first), ::std::to_address(outier), n) == 0;
return my_memcmp(::std::to_address(first), ::std::to_address(outier), sizeof(input_value_type) * n) == 0;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_core_impl/freestanding/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace fast_io::freestanding
{

template <typename T, ::std::size_t N>
requires(sizeof(N) != 0)
requires(N != 0)
struct array
{
using value_type = T;
Expand Down
6 changes: 3 additions & 3 deletions include/fast_io_core_impl/integers/crypto_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ inline constexpr hash_compress_t<digest_format::upper,ctx> hash_compress_upper(T
}
else
{
return {reinterpret_cast<std::byte const*>(::std::ranges::data(t)),static_cast<std::size_t>(::std::ranges::size(t))*sizeof(T)};
return {reinterpret_cast<std::byte const*>(::std::ranges::data(t)),static_cast<std::size_t>(::std::ranges::size(t))*sizeof(::std::ranges::range_value_t<T>)};
}
}

Expand All @@ -317,7 +317,7 @@ inline constexpr hash_compress_t<digest_format::raw_bytes,ctx> hash_compress_raw
}
else
{
return {reinterpret_cast<std::byte const*>(::std::ranges::data(t)),static_cast<std::size_t>(::std::ranges::size(t))*sizeof(T)};
return {reinterpret_cast<std::byte const*>(::std::ranges::data(t)),static_cast<std::size_t>(::std::ranges::size(t))*sizeof(::std::ranges::range_value_t<T>)};
}
}

Expand Down Expand Up @@ -511,7 +511,7 @@ inline constexpr char_type* prv_srv_hash_compress_df_impl(char_type* iter,std::b
{
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));
return ::fast_io::details::copy_to_hash_df_commom_impl<d==::fast_io::manipulators::digest_format::upper>(iter,buffer,static_cast<std::size_t>(ret-buffer));
}
else
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_core_impl/simd/gcc_clang.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ struct simd_vector
}
inline constexpr simd_vector<T,N>& operator>>=(simd_vector<T,N> const& other) noexcept
{
value<<=other.value;
value>>=other.value;
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_hosted/filesystem/nt.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ struct basic_nt_family_recursive_directory_generator
constexpr basic_nt_family_recursive_directory_generator(basic_nt_family_recursive_directory_generator&& __restrict other) noexcept:root_handle(other.root_handle),entry(other.entry)
{
other.root_handle=nullptr;
entry=nullptr;
other.entry=nullptr;
}
constexpr basic_nt_family_recursive_directory_generator& operator=(basic_nt_family_recursive_directory_generator&& __restrict other) noexcept
{
Expand Down
4 changes: 4 additions & 0 deletions include/fast_io_hosted/filesystem/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class posix_directory_file:public posix_directory_io_observer
throw_posix_error();
pioh.release();
}
posix_directory_file(posix_directory_file const& other)
{
this->dirp = details::sys_dup_dir(other.dirp);
}
posix_directory_file& operator=(posix_directory_file const& other)
{
auto newdir{details::sys_dup_dir(other.dirp)};
Expand Down
6 changes: 3 additions & 3 deletions include/fast_io_hosted/filesystem/posix_at.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ inline void posix_fchownat_impl(int dirfd, char const* pathname, uintmax_t owner
if constexpr(sizeof(uintmax_t)>sizeof(gid_t))
{
constexpr std::uintmax_t mx{std::numeric_limits<gid_t>::max()};
if(static_cast<std::uintmax_t>(owner)>mx)
if(static_cast<std::uintmax_t>(group)>mx)
throw_posix_error(EOVERFLOW);
}
system_call_throw_error(
Expand Down Expand Up @@ -344,13 +344,13 @@ template<posix_api_12 dsp,::fast_io::constructible_to_os_c_str old_path_type,::f
inline auto posix_deal_with12(
old_path_type const& oldpath,
int newdirfd,
old_path_type const& newpath)
new_path_type const& newpath)
{
return fast_io::posix_api_common(oldpath,[&](char const* oldpath_c_str)
{
return fast_io::posix_api_common(newpath,[&](char const* newpath_c_str)
{
return posix1x_api_dispatcher<dsp>(oldpath_c_str,newdirfd,newpath_c_str);
return posix12_api_dispatcher<dsp>(oldpath_c_str,newdirfd,newpath_c_str);
});
});
}
Expand Down
Loading