Skip to content

Commit

Permalink
Merge pull request #17 from MacroModel/trcrsired-master
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
MacroModel authored Nov 9, 2024
2 parents 1064292 + e1fe2b4 commit 01ccdd5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
8 changes: 6 additions & 2 deletions include/fast_io_hosted/platforms/nt.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ inline constexpr nt_open_mode calculate_nt_open_mode(open_mode_perms ompm) noexc
}
else if ((value & open_mode::out) != open_mode::none)
{
mode.DesiredAccess |= 0x120116; // FILE_GENERIC_WRITE
mode.DesiredAccess |= 0x120196; // FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES
generic_write = true;
}
if (((value & open_mode::in) != open_mode::none) || ((value & open_mode::app) != open_mode::none))
Expand Down Expand Up @@ -504,8 +504,12 @@ inline ::std::byte *nt_read_pread_some_bytes_common_impl(void *__restrict handle
::fast_io::win32::nt::io_status_block block;
auto const status{::fast_io::win32::nt::nt_read_file<family == ::fast_io::nt_family::zw>(handle, nullptr, nullptr, nullptr, __builtin_addressof(block), first,
::fast_io::details::read_write_bytes_compute<::std::uint_least32_t>(first, last), pbyteoffset, nullptr)};
if (status)
if (status) [[unlikely]]
{
if (status == 0xC0000011) [[likely]]
{
return first;
}
throw_nt_error(status);
}
return first + block.Information;
Expand Down
4 changes: 2 additions & 2 deletions include/fast_io_hosted/platforms/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,10 @@ inline ::std::byte *read_or_pread_some_bytes_common_impl(void *__restrict handle
::std::uint_least32_t number_of_bytes{};
if (!::fast_io::win32::ReadFile(handle, first,
::fast_io::details::read_write_bytes_compute<::std::uint_least32_t>(first, last),
__builtin_addressof(number_of_bytes), lpoverlapped))
__builtin_addressof(number_of_bytes), lpoverlapped)) [[unlikely]]
{
auto err(::fast_io::win32::GetLastError());
if (err == 109)
if (err == 109) [[likely]]
{
return first;
}
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_hosted/process/nt.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ inline void detach(nt_family_process_observer<family> &ppob) noexcept

struct nt_wait_status
{
::std::uint_least32_t exit_code{};
::std::uint_least32_t wait_loc{}; // exit code
};

template <nt_family family, bool throw_eh = true>
Expand Down
2 changes: 1 addition & 1 deletion include/fast_io_hosted/process/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ inline void detach(win32_family_process_observer<family> &ppob) noexcept

struct win32_wait_status
{
::std::uint_least32_t exit_code{};
::std::uint_least32_t wait_loc{}; // exit code
};

template <win32_family family, bool throw_eh = true>
Expand Down
2 changes: 2 additions & 0 deletions tests/0035.process/.test_prop.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
["process.cc"]
interactive = true
4 changes: 3 additions & 1 deletion tests/0035.process/process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ int main(int argc, char** argv)
{
return -1;
}
::fast_io::io::perr("Usage: <exe>\n");
::fast_io::io::perr("Usage: ", ::fast_io::mnp::os_c_str(*argv), " <exe>\n");
}
::fast_io::native_process p{::fast_io::mnp::os_c_str(argv[1]), {}, {}, {}};
auto ec{wait(p)};
::fast_io::io::perrln(::fast_io::mnp::os_c_str(*argv), "Exit code: ", static_cast<int>(ec.wait_loc));
}

0 comments on commit 01ccdd5

Please sign in to comment.