diff --git a/include/fast_io_core_impl/freestanding/algorithm.h b/include/fast_io_core_impl/freestanding/algorithm.h index 98dcd4642..560a3c60c 100644 --- a/include/fast_io_core_impl/freestanding/algorithm.h +++ b/include/fast_io_core_impl/freestanding/algorithm.h @@ -768,10 +768,10 @@ inline constexpr ForwardIt uninitialized_fill(ForwardIt first, ForwardIt last, T } template <::std::input_iterator ForwardIt, typename T> -inline constexpr void uninitialized_fill_n(ForwardIt first, ::std::size_t n, T const &x) noexcept( +inline constexpr ForwardIt 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, ::std::next(first, n), x); + return ::fast_io::freestanding::uninitialized_fill(first, ::std::next(first, n), x); } template <::std::forward_iterator ForwardIt> diff --git a/include/fast_io_hosted/file_loaders/posix_file_loader.h b/include/fast_io_hosted/file_loaders/posix_file_loader.h index 1527ef409..fc8834e76 100644 --- a/include/fast_io_hosted/file_loaders/posix_file_loader.h +++ b/include/fast_io_hosted/file_loaders/posix_file_loader.h @@ -34,7 +34,7 @@ inline void posix_unload_address(void *address, [[maybe_unused]] ::std::size_t f { if (address != (void *)-1) [[likely]] { - sys_munmap(address, file_size); + sys_munmap_nothrow(address, file_size); } } diff --git a/include/fast_io_hosted/platforms/posix_mapping.h b/include/fast_io_hosted/platforms/posix_mapping.h index b2a6eb375..97f005ee3 100644 --- a/include/fast_io_hosted/platforms/posix_mapping.h +++ b/include/fast_io_hosted/platforms/posix_mapping.h @@ -69,7 +69,7 @@ inline int sys_mprotect(void *start, ::std::size_t len, int prot) return result; } -inline int sys_munmap(void *addr, ::std::size_t len) +inline int sys_munmap_nothrow(void *addr, ::std::size_t len) { return #if defined(__linux__) && defined(__NR_munmap) @@ -79,9 +79,9 @@ inline int sys_munmap(void *addr, ::std::size_t len) #endif } -inline void sys_munmap_throw_error(void *addr, ::std::size_t len) +inline void sys_munmap(void *addr, ::std::size_t len) { - system_call_throw_error(sys_munmap(addr, len)); + system_call_throw_error(sys_munmap_nothrow(addr, len)); } } // namespace details @@ -195,7 +195,7 @@ class posix_memory_map_file } if (this->address_begin != reinterpret_cast<::std::byte *>(MAP_FAILED)) [[likely]] { - details::sys_munmap(this->address_begin, static_cast<::std::size_t>(address_end - address_begin)); + details::sys_munmap_nothrow(this->address_begin, static_cast<::std::size_t>(address_end - address_begin)); } this->address_begin = other.address_begin; this->address_end = other.address_end; @@ -291,20 +291,20 @@ class posix_memory_map_file { return address_begin[pos]; } - inline void close() + inline constexpr void close() { if (this->address_begin != MAP_FAILED) [[likely]] { - auto ret{details::sys_munmap(this->address_begin, static_cast<::std::size_t>(address_end - address_begin))}; + auto ret{details::sys_munmap_nothrow(this->address_begin, static_cast<::std::size_t>(address_end - address_begin))}; this->address_end = this->address_begin = reinterpret_cast<::std::byte *>(MAP_FAILED); system_call_throw_error(ret); } } - inline ~posix_memory_map_file() + inline constexpr ~posix_memory_map_file() { if (this->address_begin != MAP_FAILED) [[likely]] { - details::sys_munmap(this->address_begin, static_cast<::std::size_t>(address_end - address_begin)); + details::sys_munmap_nothrow(this->address_begin, static_cast<::std::size_t>(address_end - address_begin)); } } }; diff --git a/include/fast_io_hosted/platforms/win32/apis.h b/include/fast_io_hosted/platforms/win32/apis.h index 9dbb96d44..b72785e27 100644 --- a/include/fast_io_hosted/platforms/win32/apis.h +++ b/include/fast_io_hosted/platforms/win32/apis.h @@ -170,5 +170,8 @@ FAST_IO_DLLIMPORT int FAST_IO_WINSTDCALL PrefetchVirtualMemory(void *, ::std::si FAST_IO_DLLIMPORT int FAST_IO_WINSTDCALL SetConsoleTextAttribute(void *, ::std::int_least32_t) noexcept FAST_IO_WINSTDCALL_RENAME(SetConsoleTextAttribute, 8); FAST_IO_DLLIMPORT ::std::uint_least32_t FAST_IO_WINSTDCALL GetCurrentThreadId() noexcept FAST_IO_WINSTDCALL_RENAME(GetCurrentThreadId, 0); FAST_IO_DLLIMPORT void FAST_IO_WINSTDCALL Sleep(::std::uint_least32_t) noexcept FAST_IO_WINSTDCALL_RENAME(Sleep, 4); - +FAST_IO_DLLIMPORT char16_t *FAST_IO_WINSTDCALL GetEnvironmentStringsW() noexcept FAST_IO_WINSTDCALL_RENAME(GetEnvironmentStringsW, 0); +FAST_IO_DLLIMPORT char *FAST_IO_WINSTDCALL GetEnvironmentStringsA() noexcept FAST_IO_WINSTDCALL_RENAME(GetEnvironmentStringsA, 0); +FAST_IO_DLLIMPORT int FAST_IO_WINSTDCALL FreeEnvironmentStringsW(char16_t*) noexcept FAST_IO_WINSTDCALL_RENAME(FreeEnvironmentStringsW, 4); +FAST_IO_DLLIMPORT int FAST_IO_WINSTDCALL FreeEnvironmentStringsA(char*) noexcept FAST_IO_WINSTDCALL_RENAME(FreeEnvironmentStringsA, 4); } // namespace fast_io::win32 diff --git a/include/fast_io_hosted/threads/thread/c_malloc_guard.h b/include/fast_io_hosted/threads/thread/c_malloc_guard.h index f86f53a64..bd17f6466 100644 --- a/include/fast_io_hosted/threads/thread/c_malloc_guard.h +++ b/include/fast_io_hosted/threads/thread/c_malloc_guard.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once namespace fast_io::details { diff --git a/include/fast_io_hosted/threads/thread/impl.h b/include/fast_io_hosted/threads/thread/impl.h index 61944f32d..b7d97f585 100644 --- a/include/fast_io_hosted/threads/thread/impl.h +++ b/include/fast_io_hosted/threads/thread/impl.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #if (defined(_WIN32) && !defined(__WINE__)) && !defined(__CYGWIN__) #ifdef _WIN32_WINDOWS diff --git a/include/fast_io_hosted/threads/thread/nt.h b/include/fast_io_hosted/threads/thread/nt.h index 42892bfcd..923b21f79 100644 --- a/include/fast_io_hosted/threads/thread/nt.h +++ b/include/fast_io_hosted/threads/thread/nt.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include diff --git a/include/fast_io_hosted/threads/thread/posix.h b/include/fast_io_hosted/threads/thread/posix.h index 6f70f09be..73b4b8665 100644 --- a/include/fast_io_hosted/threads/thread/posix.h +++ b/include/fast_io_hosted/threads/thread/posix.h @@ -1 +1 @@ -#pragma once +#pragma once diff --git a/include/fast_io_hosted/threads/thread/win32.h b/include/fast_io_hosted/threads/thread/win32.h index ee3ce2830..17bf17f70 100644 --- a/include/fast_io_hosted/threads/thread/win32.h +++ b/include/fast_io_hosted/threads/thread/win32.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include #include