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
28 changes: 22 additions & 6 deletions include/fast_io_freestanding_impl/io_buffer/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,30 @@ inline constexpr char_type const *write_some_overflow_impl(optstmtype optstm,
}

template <::std::integral char_type, typename optstmtype>
inline constexpr void write_all_nullptr_case(basic_io_buffer_pointers<char_type> &__restrict pointers,
inline constexpr void write_all_nullptr_case(optstmtype optstm, basic_io_buffer_pointers<char_type> &__restrict pointers,
char_type const *first, char_type const *last)
{
basic_io_scatter_t<char_type> const scatters[2]{
{(pointers.buffer_begin ? pointers.buffer_begin : first),
static_cast<::std::size_t>(pointers.buffer_curr - pointers.buffer_begin)},
{first, static_cast<::std::size_t>(last - first)}};
::fast_io::operations::decay::scatter_write_all_decay(pointers, scatters, 2);
if constexpr (::fast_io::operations::decay::defines::has_any_of_write_bytes_operations<optstmtype>)
{
io_scatter_t const scatters[2]{
{reinterpret_cast<::std::byte const *>(pointers.buffer_begin ? pointers.buffer_begin : first),
static_cast<::std::size_t>(pointers.buffer_begin
? (reinterpret_cast<::std::byte const *>(pointers.buffer_curr) -
reinterpret_cast<::std::byte const *>(pointers.buffer_begin))
: 0u)},
{reinterpret_cast<::std::byte const *>(first),
static_cast<::std::size_t>(reinterpret_cast<::std::byte const *>(last) -
reinterpret_cast<::std::byte const *>(first))}};
::fast_io::operations::decay::scatter_write_all_bytes_decay(optstm, scatters, 2);
}
else
{
basic_io_scatter_t<char_type> const scatters[2]{
{(pointers.buffer_begin ? pointers.buffer_begin : first),
static_cast<::std::size_t>(pointers.buffer_begin ? (pointers.buffer_curr - pointers.buffer_begin) : 0u)},
{first, static_cast<::std::size_t>(last - first)}};
::fast_io::operations::decay::scatter_write_all_decay(optstm, scatters, 2);
}
pointers.buffer_curr = pointers.buffer_begin;
}

Expand Down
15 changes: 13 additions & 2 deletions include/fast_io_hosted/platforms/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -1415,14 +1415,25 @@ class basic_posix_family_pipe
int a2[2]{-1, -1};
#if (defined(_WIN32) && !defined(__WINE__) && !defined(__BIONIC__)) && !defined(__CYGWIN__)
if (noexcept_call(::_pipe, a2, 131072u, _O_BINARY) == -1)
throw_posix_error();
#elif defined(__linux__)
if (noexcept_call(::pipe2, a2, O_CLOEXEC) == -1)
throw_posix_error();
#elif (defined(__MSDOS__) || defined(__DJGPP__)) || defined(__NEWLIB__)
if (noexcept_call(::pipe, a2) == -1)
throw_posix_error();
#else
if (noexcept_call(::pipe, a2) == -1 || ::fast_io::details::sys_fcntl(a2[0], F_SETFD, FD_CLOEXEC) == -1 || ::fast_io::details::sys_fcntl(a2[1], F_SETFD, FD_CLOEXEC) == -1)
{
if (noexcept_call(::pipe, a2) == -1)
throw_posix_error();
::fast_io::posix_file_factory fd0(a2[0]);
::fast_io::posix_file_factory fd1(a2[1]);
::fast_io::details::sys_fcntl(fd0.fd, F_SETFD, FD_CLOEXEC);
::fast_io::details::sys_fcntl(fd1.fd, F_SETFD, FD_CLOEXEC);
fd0.fd = -1;
fd1.fd = -1;
}
#endif
throw_posix_error();
pipes->fd = *a2;
pipes[1].fd = a2[1];
#endif
Expand Down
Loading