Skip to content

Commit 9a15b9a

Browse files
MacroModelpuji4810
andauthored
Patch 4 (#1193)
* Update print_freestanding_cxx26.h * Update print_freestanding_cxx20.h * rm djgpp symlink * Update dos_at.h * Update dos_at.h * Update dos_at.h * fix (#1192) - Fix function name in allocation adapters - Correct find_last return value for bidirectional iterators - Use proper iterator operations for forward iterators - Fix template parameters and length calculations in crypto hash * fix include * Update dos_at.h * Update nt_at.h * Update win32_9xa_at.h --------- Co-authored-by: 噗叽 <[email protected]>
1 parent 261d77f commit 9a15b9a

File tree

8 files changed

+31
-15
lines changed

8 files changed

+31
-15
lines changed

include/fast_io_core_impl/integers/crypto_hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ inline constexpr hash_compress_t<digest_format::raw_bytes, ctx> hash_compress_ra
296296
else
297297
{
298298
return {reinterpret_cast<::std::byte const *>(::std::ranges::data(t)),
299-
static_cast<::std::size_t>(::std::ranges::size(t)) * sizeof(T)};
299+
static_cast<::std::size_t>(::std::ranges::size(t)) * sizeof(::std::ranges::range_value_t<T>)};
300300
}
301301
}
302302

include/fast_io_hosted/filesystem/dos_at.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ extern int my_dos_rename(char const *oldname, char const *newname) noexcept __as
1717
// Because of limitations of MS-DOS, this function doesn't really link two files together.
1818
// However, it simulates a real link by copying the file at exists to new.
1919
extern int my_dos_link(char const *exists, char const *newname) noexcept __asm__("_link");
20+
// The symlink of djgpp only generates a 510-byte file and does not exist as a soft link, so it
21+
// will be disabled later.
2022
extern int my_dos_symlink(char const *exists, char const *newname) noexcept __asm__("_symlink");
2123
extern int my_dos_chmod(char const *path, mode_t mode) noexcept __asm__("_chmod");
2224
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
136138
}
137139
}
138140

139-
inline void dos_symlinkat_impl(char const *oldpath, int newdirfd, char const *newpath)
141+
inline void dos_symlinkat_impl([[maybe_unused]] char const *oldpath, [[maybe_unused]] int newdirfd, [[maybe_unused]] char const *newpath)
140142
{
143+
#if defined(FAST_IO_USE_DJGPP_SYMLINK)
141144
::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()));
145+
#else
146+
throw_posix_error(ENOSYS);
147+
#endif
142148
}
143149

144150
template <posix_api_12 dsp, typename... Args>
@@ -203,7 +209,6 @@ inline
203209
[[fallthrough]];
204210
case utime_flags::omit:
205211
throw_posix_error(EINVAL);
206-
::fast_io::unreachable();
207212
default:
208213
return ::fast_io::details::unix_timestamp_to_time_t(opt.timestamp);
209214
}

include/fast_io_hosted/filesystem/nt_at.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,9 @@ struct nt_create_nothrow_callback
434434
};
435435

436436
template <bool zw>
437-
inline void nt_symlinkat_impl(char16_t const *oldpath_c_str, ::std::size_t oldpath_size,
438-
void *newdirhd, char16_t const *newpath_c_str, ::std::size_t newpath_size, bool kernel)
437+
inline void nt_symlinkat_impl([[maybe_unused]] char16_t const *oldpath_c_str, [[maybe_unused]] ::std::size_t oldpath_size,
438+
[[maybe_unused]] void *newdirhd, [[maybe_unused]] char16_t const *newpath_c_str,
439+
[[maybe_unused]] ::std::size_t newpath_size, [[maybe_unused]] bool kernel)
439440
{
440441
#if !defined(_WIN32_WINNT) || _WIN32_WINNT > 0x0600
441442

@@ -634,6 +635,7 @@ inline void nt_symlinkat_impl(char16_t const *oldpath_c_str, ::std::size_t oldpa
634635
throw_nt_error(status);
635636
}
636637
#else
638+
#if defined(FAST_IO_USE_DJGPP_SYMLINK)
637639
constexpr nt_open_mode symbol_mode{::fast_io::win32::nt::details::calculate_nt_open_mode({::fast_io::open_mode::out, static_cast<perms>(436)})};
638640

639641
::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
647649
u8"\nThis is just a text to force symlink file to be 510 bytes long. Do not delete it nor spaces following it.");
648650

649651
::fast_io::operations::write_all(new_file, buffer, buffer + 510);
652+
#else
653+
throw_nt_error(0xC0000002);
654+
#endif
650655
#endif
651656
}
652657

@@ -824,7 +829,7 @@ inline auto nt_deal_with1x(void *dir_handle, path_type const &path, Args... args
824829
{
825830
return nt_api_common(
826831
path, [&](char16_t const *path_c_str, ::std::size_t path_size) {
827-
return nt1x_api_dispatcher<family == nt_family::zw, dsp>(dir_handle, path_c_str, path_size, args...);
832+
return nt1x_api_dispatcher < family == nt_family::zw, dsp > (dir_handle, path_c_str, path_size, args...);
828833
});
829834
}
830835

@@ -837,7 +842,7 @@ inline auto nt_deal_with12(old_path_type const &oldpath, void *newdirfd, new_pat
837842
[&](char16_t const *oldpath_c_str, ::std::size_t oldpath_size) {
838843
return nt_api_common(
839844
newpath, [&](char16_t const *newpath_c_str, ::std::size_t newpath_size) {
840-
return nt12_api_dispatcher<family == nt_family::zw, dsp>(oldpath_c_str, oldpath_size, newdirfd, newpath_c_str, newpath_size, args...);
845+
return nt12_api_dispatcher < family == nt_family::zw, dsp > (oldpath_c_str, oldpath_size, newdirfd, newpath_c_str, newpath_size, args...);
841846
});
842847
});
843848
}
@@ -849,8 +854,8 @@ inline auto nt_deal_with22(void *olddirhd, oldpath_type const &oldpath, void *ne
849854
[&](char16_t const *oldpath_c_str, ::std::size_t oldpath_size) {
850855
return nt_api_common(newpath,
851856
[&](char16_t const *newpath_c_str, ::std::size_t newpath_size) {
852-
return nt22_api_dispatcher<family == nt_family::zw, dsp>(olddirhd, oldpath_c_str, oldpath_size, newdirhd,
853-
newpath_c_str, newpath_size, args...);
857+
return nt22_api_dispatcher < family == nt_family::zw, dsp > (olddirhd, oldpath_c_str, oldpath_size, newdirhd,
858+
newpath_c_str, newpath_size, args...);
854859
});
855860
});
856861
}

include/fast_io_hosted/filesystem/win32_9xa_at.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,11 @@ inline void win32_9xa_utimensat_impl(::fast_io::win32_9xa_dir_handle const &dirh
305305
}
306306
}
307307

308-
inline void win32_9xa_symlinkat_impl(char8_t const *oldpath_c_str, ::std::size_t oldpath_size,
309-
::fast_io::win32_9xa_dir_handle const &newdirhd, char8_t const *newpath_c_str, ::std::size_t newpath_size)
308+
inline void win32_9xa_symlinkat_impl([[maybe_unused]] char8_t const *oldpath_c_str, [[maybe_unused]] ::std::size_t oldpath_size,
309+
[[maybe_unused]] ::fast_io::win32_9xa_dir_handle const &newdirhd,
310+
[[maybe_unused]] char8_t const *newpath_c_str, [[maybe_unused]] ::std::size_t newpath_size)
310311
{
312+
#if defined(FAST_IO_USE_DJGPP_SYMLINK)
311313
::fast_io::containers::basic_cstring_view<char8_t> path{::fast_io::containers::null_terminated, oldpath_c_str, oldpath_size};
312314

313315
::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
321323
::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.");
322324

323325
::fast_io::operations::write_all(f, buffer, buffer + 510);
326+
327+
#else
328+
throw_win32_error(0x1);
329+
#endif
324330
}
325331

326332
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,

include/fast_io_hosted/platforms/win32/msvc_linker_32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22
// This file have been generated by example/0039.win32mangling, therefore, do NOT edit this file directely!
33
// clang-format off
44
// WIN32

include/fast_io_hosted/platforms/win32/msvc_linker_32_i686.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22
// This file have been generated by example/0039.win32mangling, therefore, do NOT edit this file directely!
33
// clang-format off
44
// WIN32

include/fast_io_hosted/platforms/win32/msvc_linker_64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22
// This file have been generated by example/0039.win32mangling, therefore, do NOT edit this file directely!
33
// clang-format off
44
// WIN32

include/fast_io_hosted/platforms/win32/msvc_linker_arm64ec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22
// This file have been generated by example/0039.win32mangling, therefore, do NOT edit this file directely!
33
// clang-format off
44
// WIN32

0 commit comments

Comments
 (0)