Skip to content

Commit

Permalink
Merge pull request #1062 from MacroModel/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
trcrsired authored Feb 1, 2025
2 parents f27ef57 + d528c15 commit 9bad4fd
Show file tree
Hide file tree
Showing 20 changed files with 220 additions and 24 deletions.
4 changes: 2 additions & 2 deletions include/fast_io_core_impl/enums/mmap_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ enum class mmap_flags : ::std::uint_least32_t
map_hugetlb = 0x100000, /* create a huge page mapping */
map_fixed_noreplace = 0x200000, /* MAP_FIXED which doesn't unmap underlying mapping */
map_uninitialized = 0x4000000, /* For anonymous mmap, memory could be uninitialized */
map_huge_2mb = 21u << 26,
map_huge_1gb = 30u << 26,
map_huge_2mb = static_cast<::std::uint_least32_t>(21u) << 26,
map_huge_1gb = static_cast<::std::uint_least32_t>(30u) << 26,
};

inline constexpr mmap_flags operator&(mmap_flags x, mmap_flags y) noexcept
Expand Down
2 changes: 2 additions & 0 deletions include/fast_io_driver/unix.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include "unix_driver/syscall.h"
67 changes: 67 additions & 0 deletions include/fast_io_driver/unix_driver/syscall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once

namespace fast_io
{
/*
system calls
01;0000001 /exit
01;0000002 /fork
01;0000003 /read
01;0000004 /write
01;0000005 /open
01;0000006 /close
01;0000007 /wait
01;0000010 /creat
01;0000011 /link
01;0000012 /unlink
01;0000013 /exec
01;0000014 /chdir
01;0000015 /time
01;0000016 /makdir
01;0000017 /chmod
01;0000020 /chown
01;0000021 /break
01;0000022 /stat
01;0000023 /seek
01;0000024 /tell
01;0000025 /mount
01;0000026 /umount
01;0000027 /setuid
01;0000030 /getuid
01;0000031 /stime
01;0000034 /fstat
01;0000036 /mdate
01;0000037 /stty
01;0000040 /gtty
01;0000042 /nice
01;0000060 /signal
*/
namespace unix
{
inline void exit(int status) noexcept
{
__asm__ __volatile__(
"mov %0, r2\n\t"
"sys 1\n\t"
:
: "r"(status)
: "memory", "cc");
}

inline int write(int fd, char const *buf, int len) noexcept
{
int ret;
__asm__ __volatile__(
"mov %1, r2\n\t"
"mov %2, r3\n\t"
"mov %3, r4\n\t"
"sys 4\n\t"
"mov r0, %0\n\t"
: "=r"(ret)
: "r"(fd), "r"(buf), "r"(len)
: "memory", "cc");
return ret;
}
} // namespace unix
} // namespace fast_io
2 changes: 1 addition & 1 deletion include/fast_io_dsal/impl/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,7 @@ inline constexpr bool operator==(char_type const (&buffer)[n], ::fast_io::contai
return ::std::equal(buffer, buffer + nm1, a.cbegin(), a.cend());
}

#if defined(__cpp_lib_three_way_comparison)
#if __cpp_lib_three_way_comparison >= 201907L

template <::std::integral chtype, typename allocator1, typename allocator2>
inline constexpr auto operator<=>(::fast_io::containers::basic_string<chtype, allocator1> const &lhs, ::fast_io::containers::basic_string<chtype, allocator2> const &rhs) noexcept
Expand Down
4 changes: 1 addition & 3 deletions include/fast_io_hosted/platforms/nt.h
Original file line number Diff line number Diff line change
Expand Up @@ -708,15 +708,13 @@ inline constexpr bool operator==(basic_nt_family_io_observer<family, ch_type> a,
return a.handle == b.handle;
}

#if __cpp_lib_three_way_comparison >= 201907L

#if __cpp_impl_three_way_comparison >= 201907L
template <nt_family family, ::std::integral ch_type>
inline constexpr auto operator<=>(basic_nt_family_io_observer<family, ch_type> a,
basic_nt_family_io_observer<family, ch_type> b) noexcept
{
return a.handle <=> b.handle;
}

#endif

template <nt_family family, ::std::integral ch_type>
Expand Down
4 changes: 1 addition & 3 deletions include/fast_io_hosted/platforms/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,14 +500,12 @@ inline constexpr bool operator==(basic_posix_family_io_observer<family, ch_type>
return a.fd == b.fd;
}

#if __cpp_lib_three_way_comparison >= 201907L

#if __cpp_impl_three_way_comparison >= 201907L
template <::fast_io::posix_family family, ::std::integral ch_type>
inline constexpr auto operator<=>(basic_posix_family_io_observer<family, ch_type> a, basic_posix_family_io_observer<family, ch_type> b) noexcept
{
return a.fd <=> b.fd;
}

#endif

template <::fast_io::posix_family family, ::std::integral ch_type>
Expand Down
8 changes: 2 additions & 6 deletions include/fast_io_hosted/platforms/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,15 +606,13 @@ inline constexpr bool operator==(basic_win32_family_io_observer<family, ch_type>
return a.handle == b.handle;
}

#if __cpp_lib_three_way_comparison >= 201907L

#if __cpp_impl_three_way_comparison >= 201907L
template <win32_family family, ::std::integral ch_type>
inline constexpr auto operator<=>(basic_win32_family_io_observer<family, ch_type> a,
basic_win32_family_io_observer<family, ch_type> b) noexcept
{
return a.handle <=> b.handle;
}

#endif

template <win32_family family, ::std::integral ch_type>
Expand Down Expand Up @@ -1292,14 +1290,12 @@ inline constexpr bool operator==(win32_9xa_dir_io_observer const &a,
return a.handle.path == b.handle.path;
}

#if __cpp_lib_three_way_comparison >= 201907L

#if __cpp_impl_three_way_comparison >= 201907L
inline constexpr auto operator<=>(win32_9xa_dir_io_observer const &a,
win32_9xa_dir_io_observer const &b) noexcept
{
return a.handle.path <=> b.handle.path;
}

#endif

class win32_9xa_dir_file : public win32_9xa_dir_io_observer
Expand Down
4 changes: 3 additions & 1 deletion include/fast_io_hosted/process/ipc/basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace fast_io
{
enum class ipc_mode : ::std::uint_fast8_t
enum class ipc_mode
{
sender,
receiver
};


} // namespace fast_io
28 changes: 28 additions & 0 deletions include/fast_io_hosted/process/ipc/native.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
#pragma once

#if !defined(__MSDOS__) && !defined(__NEWLIB__) && !defined(__wasi__) && !defined(_PICOLIBC__)
#include "basic.h"

#include "posix/named_pipe.h"
#include "posix/eventfd.h"
#if (defined(_WIN32) && !defined(__WINE__)) || defined(__CYGWIN__)
#include "win32/named_pipe_win32.h"
#include "win32/rpc_nt.h"
#include "win32/alpc_nt.h"
#endif

namespace fast_io
{
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WINE__)
#if !defined(_WIN32_WINDOWS) && (!defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x600)
// alpc
#elif !defined(_WIN32_WINDOWS)
// rpc
#else
// named pipe
template <::std::integral char_type>
using basic_native_ipc_observer = ::fast_io::basic_named_pipe_ipc_observer<char_type>;
#endif
#else
// posix to do
#endif
}
#endif
5 changes: 5 additions & 0 deletions include/fast_io_hosted/process/ipc/posix/named_pipe.h
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
#pragma once

namespace fast_io
{

}
1 change: 0 additions & 1 deletion include/fast_io_hosted/process/ipc/win32/named_pipe.h

This file was deleted.

91 changes: 91 additions & 0 deletions include/fast_io_hosted/process/ipc/win32/named_pipe_win32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#pragma once

namespace fast_io
{
template <win32_family family, ::std::integral ch_type>
class basic_win32_family_named_pipe_ipc_observer
{
public:
using native_handle_type = void *;
using char_type = ch_type;
using input_char_type = char_type;
using output_char_type = char_type;
native_handle_type handle{};
inline constexpr native_handle_type native_handle() const noexcept
{
return handle;
}
inline explicit operator bool() const noexcept
{
return handle != nullptr && handle != reinterpret_cast<void *>(static_cast<::std::ptrdiff_t>(-1));
}
inline constexpr native_handle_type release() noexcept
{
auto temp{handle};
handle = nullptr;
return temp;
}
};

template <win32_family family, ::std::integral ch_type>
inline constexpr bool operator==(basic_win32_family_named_pipe_ipc_observer<family, ch_type> a,
basic_win32_family_named_pipe_ipc_observer<family, ch_type> b) noexcept
{
return a.handle == b.handle;
}

#if __cpp_impl_three_way_comparison >= 201907L
template <win32_family family, ::std::integral ch_type>
inline constexpr auto operator<=>(basic_win32_family_named_pipe_ipc_observer<family, ch_type> a,
basic_win32_family_named_pipe_ipc_observer<family, ch_type> b) noexcept
{
return a.handle <=> b.handle;
}
#endif

template <win32_family family, ::std::integral ch_type>
class basic_win32_family_named_pipe_ipc : public basic_win32_family_named_pipe_ipc_observer<family, ch_type>
{
public:
using typename basic_win32_family_named_pipe_ipc_observer<family, ch_type>::char_type;
using typename basic_win32_family_named_pipe_ipc_observer<family, ch_type>::input_char_type;
using typename basic_win32_family_named_pipe_ipc_observer<family, ch_type>::output_char_type;
using typename basic_win32_family_named_pipe_ipc_observer<family, ch_type>::native_handle_type;
using basic_win32_family_named_pipe_ipc_observer<family, ch_type>::native_handle;

inline explicit constexpr basic_win32_family_named_pipe_ipc() noexcept = default;

inline constexpr basic_win32_family_named_pipe_ipc(basic_win32_family_named_pipe_ipc_observer<family, ch_type>) noexcept = delete;
inline constexpr basic_win32_family_named_pipe_ipc &operator=(basic_win32_family_named_pipe_ipc_observer<family, ch_type>) noexcept = delete;

};


template <::std::integral ch_type>
using basic_win32_named_pipe_ipc_observer = basic_win32_family_named_pipe_ipc_observer<win32_family::native, ch_type>;
template <::std::integral ch_type>
using basic_win32_named_pipe_ipc_observer_ntw = basic_win32_family_named_pipe_ipc_observer<win32_family::wide_nt, ch_type>;
template <::std::integral ch_type>
using basic_win32_named_pipe_ipc_observer_9xa = basic_win32_family_named_pipe_ipc_observer<win32_family::ansi_9x, ch_type>;

using win32_named_pipe_ipc_observer = basic_win32_named_pipe_ipc_observer<char>;
using win32_named_pipe_ipc_observer_ntw = basic_win32_named_pipe_ipc_observer_ntw<char>;
using win32_named_pipe_ipc_observer_9xa = basic_win32_named_pipe_ipc_observer_9xa<char>;

using wwin32_named_pipe_ipc_observer = basic_win32_named_pipe_ipc_observer<wchar_t>;
using wwin32_named_pipe_ipc_observer_ntw = basic_win32_named_pipe_ipc_observer_ntw<wchar_t>;
using wwin32_named_pipe_ipc_observer_9xa = basic_win32_named_pipe_ipc_observer_9xa<wchar_t>;

using u8win32_named_pipe_ipc_observer = basic_win32_named_pipe_ipc_observer<char8_t>;
using u8win32_named_pipe_ipc_observer_ntw = basic_win32_named_pipe_ipc_observer_ntw<char8_t>;
using u8win32_named_pipe_ipc_observer_9xa = basic_win32_named_pipe_ipc_observer_9xa<char8_t>;

using u16win32_named_pipe_ipc_observer = basic_win32_named_pipe_ipc_observer<char16_t>;
using u16win32_named_pipe_ipc_observer_ntw = basic_win32_named_pipe_ipc_observer_ntw<char16_t>;
using u16win32_named_pipe_ipc_observer_9xa = basic_win32_named_pipe_ipc_observer_9xa<char16_t>;

using u32win32_named_pipe_ipc_observer = basic_win32_named_pipe_ipc_observer<char32_t>;
using u32win32_named_pipe_ipc_observer_ntw = basic_win32_named_pipe_ipc_observer_ntw<char32_t>;
using u32win32_named_pipe_ipc_observer_9xa = basic_win32_named_pipe_ipc_observer_9xa<char32_t>;
} // namespace fast_io

1 change: 0 additions & 1 deletion include/fast_io_hosted/process/ipc/win32/rpc.h

This file was deleted.

4 changes: 2 additions & 2 deletions include/fast_io_hosted/process/process/nt.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,8 @@ inline nt_user_process_information nt_6x_process_create_impl(void *__restrict fh
void *hProcess{};
void *hThread{};
check_nt_status(::fast_io::win32::nt::nt_create_user_process<zw>(
&hProcess, &hThread, 0x2000000, 0x2000000, nullptr, nullptr,
512, 0x00, rtl_temp, &CreateInfo, &AttributeList));
__builtin_addressof(hProcess), __builtin_addressof(hThread), 0x2000000, 0x2000000, nullptr, nullptr,
512, 0x00, rtl_temp, __builtin_addressof(CreateInfo), __builtin_addressof(AttributeList)));

return {hProcess, hThread};
}
Expand Down
1 change: 1 addition & 0 deletions include/fast_io_hosted/process/shared_memory/impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#pragma once
3 changes: 1 addition & 2 deletions include/fast_io_legacy_impl/c/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,15 +855,14 @@ inline ::fast_io::intfpos_t io_stream_seek_bytes_define(basic_c_family_io_observ
return details::my_c_io_seek_impl<family>(cfhd.fp, offset, s);
}

#if __cpp_lib_three_way_comparison >= 201907L

template <c_family family, ::std::integral ch_type>
inline constexpr bool operator==(basic_c_family_io_observer<family, ch_type> a,
basic_c_family_io_observer<family, ch_type> b) noexcept
{
return a.fp == b.fp;
}

#if __cpp_impl_three_way_comparison >= 201907L
template <c_family family, ::std::integral ch_type>
inline constexpr auto operator<=>(basic_c_family_io_observer<family, ch_type> a,
basic_c_family_io_observer<family, ch_type> b) noexcept
Expand Down
3 changes: 1 addition & 2 deletions include/fast_io_legacy_impl/filebuf/streambuf_io_observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,13 @@ inline constexpr bool operator==(basic_general_streambuf_io_observer<T> a,
return a.fb == b.fb;
}

#if __cpp_lib_three_way_comparison >= 201907L
#if __cpp_impl_three_way_comparison >= 201907L
template <typename T>
inline constexpr auto operator<=>(basic_general_streambuf_io_observer<T> a,
basic_general_streambuf_io_observer<T> b) noexcept
{
return a.fb <=> b.fb;
}

#endif

template <::std::integral CharT, typename Traits = ::std::char_traits<CharT>>
Expand Down
12 changes: 12 additions & 0 deletions support.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
- xtensa-esp32
- All other architectures should work, they just aren't tested due to time not being infinite.

## Other Architectures Support (unverified)
- pdp11
- Blackfin
- Convex
- E2K
- Itanium 64
- M68K
- HP/PA
- System/370
- System/390
- RS/6000

## Platform Support
- Windows 10/12
- Windows Server 2019
Expand Down

0 comments on commit 9bad4fd

Please sign in to comment.