Skip to content
Merged
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
17 changes: 16 additions & 1 deletion include/fast_io_hosted/file_loaders/nt_file_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ inline auto nt_load_file_options_impl(nt_mmap_options const &options, Args &&...

template <::fast_io::nt_family family>
requires(family == ::fast_io::nt_family::nt || family == ::fast_io::nt_family::zw)
class nt_family_file_loader
class nt_family_file_loader FAST_IO_TRIVIALLY_RELOCATABLE_IF_ELIGIBLE
{
public:
using value_type = char;
Expand Down Expand Up @@ -455,4 +455,19 @@ inline constexpr basic_io_scatter_t<char> print_alias_define(::fast_io::io_alias
using nt_file_loader = nt_family_file_loader<::fast_io::nt_family::nt>;
using zw_file_loader = nt_family_file_loader<::fast_io::nt_family::zw>;

namespace freestanding
{
template <::fast_io::nt_family family>
struct is_trivially_copyable_or_relocatable<nt_family_file_loader<family>>
{
inline static constexpr bool value = true;
};

template <::fast_io::nt_family family>
struct is_zero_default_constructible<nt_family_file_loader<family>>
{
inline static constexpr bool value = true;
};
} // namespace freestanding

} // namespace fast_io
11 changes: 10 additions & 1 deletion include/fast_io_hosted/file_loaders/posix_file_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ inline auto posix_load_file_options_impl(::fast_io::posix_mmap_options const &op

} // namespace details

class posix_file_loader
class posix_file_loader FAST_IO_TRIVIALLY_RELOCATABLE_IF_ELIGIBLE
{
public:
using value_type = char;
Expand Down Expand Up @@ -396,4 +396,13 @@ inline constexpr basic_io_scatter_t<char> print_alias_define(io_alias_t, posix_f
return {load.data(), load.size()};
}

namespace freestanding
{
template <>
struct is_trivially_copyable_or_relocatable<posix_file_loader>
{
inline static constexpr bool value = true;
};

} // namespace freestanding
} // namespace fast_io
17 changes: 16 additions & 1 deletion include/fast_io_hosted/file_loaders/win32_file_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ inline void win32_unload_address(void const *address) noexcept
} // namespace win32::details

template <win32_family family>
class win32_family_file_loader
class win32_family_file_loader FAST_IO_TRIVIALLY_RELOCATABLE_IF_ELIGIBLE
{
public:
using value_type = char;
Expand Down Expand Up @@ -440,4 +440,19 @@ using win32_file_loader_9xa = win32_family_file_loader<win32_family::ansi_9x>;
using win32_file_loader_ntw = win32_family_file_loader<win32_family::wide_nt>;
using win32_file_loader = win32_family_file_loader<win32_family::native>;

namespace freestanding
{
template <::fast_io::win32_family family>
struct is_trivially_copyable_or_relocatable<win32_family_file_loader<family>>
{
inline static constexpr bool value = true;
};

template <::fast_io::win32_family family>
struct is_zero_default_constructible<win32_family_file_loader<family>>
{
inline static constexpr bool value = true;
};
} // namespace freestanding

} // namespace fast_io
9 changes: 5 additions & 4 deletions include/fast_io_hosted/filesystem/posix_at.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,13 @@ inline void posix_utimensat_impl(int dirfd, char const *path, unix_timestamp_opt
struct timespec *tsptr{ts};
system_call_throw_error(
#if defined(__linux__)
#if defined(__NR_utimensat64)
system_call<__NR_utimensat64, int>
#else
#if defined(__NR_utimensat_time64)
system_call<__NR_utimensat_time64, int>
#elif defined(__NR_utimensat)
system_call<__NR_utimensat, int>
#else
::fast_io::posix::libc_utimensat
#endif

#else
::fast_io::posix::libc_utimensat
#endif
Expand Down
5 changes: 5 additions & 0 deletions include/fast_io_hosted/platforms/nt/nt_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,4 +1364,9 @@ enum class virtual_memory_information_class
VmCfgCallTargetInformation
};

struct file_allocation_information
{
::std::int_least64_t AllocationSize;
};

} // namespace fast_io::win32::nt
31 changes: 28 additions & 3 deletions include/fast_io_hosted/platforms/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ inline void check_win32_9xa_dir_is_valid(win32_9xa_dir_handle const &h)
::fast_io::win32::win32_find_dataa wfda{};
tlc_win32_9xa_dir_handle_path_str temp_find_path{concat_tlc_win32_9xa_dir_handle_path_str(h.path, u8"\\*")};
auto find_struct{::fast_io::win32::FindFirstFileA(reinterpret_cast<char const *>(temp_find_path.c_str()), __builtin_addressof(wfda))};
if (find_struct == reinterpret_cast<void *>(static_cast<::std::ptrdiff_t>(-1)))
if (find_struct == reinterpret_cast<void *>(static_cast<::std::ptrdiff_t>(-1))) [[unlikely]]
{
throw_win32_error(0x5);
}
Expand All @@ -969,14 +969,39 @@ inline void check_win32_9xa_dir_is_valid(win32_9xa_dir_handle const &h)
}
}

inline bool get_win32_9xa_dir_validity(win32_9xa_dir_handle const &h)
{
::fast_io::win32::win32_find_dataa wfda{};
tlc_win32_9xa_dir_handle_path_str temp_find_path{concat_tlc_win32_9xa_dir_handle_path_str(h.path, u8"\\*")};
auto find_struct{::fast_io::win32::FindFirstFileA(reinterpret_cast<char const *>(temp_find_path.c_str()), __builtin_addressof(wfda))};
if (find_struct == reinterpret_cast<void *>(static_cast<::std::ptrdiff_t>(-1))) [[unlikely]]
{
return false;
}
else
{
::fast_io::win32::FindClose(find_struct);
return true;
}
}

template <bool throw_eh = false>
inline void close_win32_9xa_dir_handle(win32_9xa_dir_handle &h) noexcept(!throw_eh)
{
if constexpr (throw_eh)
{
check_win32_9xa_dir_is_valid(h);
// Make sure to successfully close even if an exception is thrown.
bool const is_win32_9xa_dir_validid{get_win32_9xa_dir_validity(h)};
h.path.clear();
if (!is_win32_9xa_dir_validid) [[unlikely]]
{
throw_win32_error(0x5);
}
}
else
{
h.path.clear();
}
h.path.clear();
}

inline win32_9xa_dir_handle win32_9xa_dir_dup_impl(win32_9xa_dir_handle const &h)
Expand Down
Loading