Skip to content

Commit

Permalink
merge and update
Browse files Browse the repository at this point in the history
  • Loading branch information
MacroModel committed Nov 29, 2024
2 parents c3692da + 8d3d95f commit b81f6c1
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 82 deletions.

This file was deleted.

14 changes: 0 additions & 14 deletions include/fast_io_hosted/platforms/wine/linux_syscall_table/impl.h

This file was deleted.

This file was deleted.

21 changes: 14 additions & 7 deletions include/fast_io_hosted/platforms/wine/wine.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ enum class wine_family : ::std::uint_least32_t
native = unspecified_host
};

using wine_host_fd_t = ::std::common_type_t<::std::intptr_t, ::std::int_least32_t>;
using wine_host_fd_t = ::std::common_type_t<::std::size_t, ::std::uint_least32_t>;

template <wine_family family, ::std::integral ch_type>
class basic_wine_family_io_observer
{
public:
using char_type = ch_type;
using native_handle_type = ::fast_io::wine_host_fd_t;
native_handle_type host_fd{-1};
native_handle_type host_fd{}; // host_fd has +1 offset on unix-like systems, the same value as nt handle on windows
inline constexpr native_handle_type native_handle() const noexcept
{
return host_fd;
}
inline explicit constexpr operator bool() const noexcept
{
return host_fd != -1;
return host_fd;
}
inline constexpr native_handle_type release() noexcept
{
auto temp{host_fd};
host_fd = -1;
host_fd = 0;
return temp;
}
};
Expand All @@ -42,16 +42,16 @@ struct
wine_family_file_factory
{
using native_handle_type = ::fast_io::wine_host_fd_t;
native_handle_type host_fd{-1};
native_handle_type host_fd{};
inline explicit constexpr wine_family_file_factory(native_handle_type v) noexcept
: host_fd(v) {};
inline wine_family_file_factory(wine_family_file_factory const &) = delete;
inline wine_family_file_factory &operator=(wine_family_file_factory const &) = delete;
inline ~wine_family_file_factory()
{
if (host_fd != -1) [[likely]]
if (host_fd) [[likely]]
{
::fast_io::details::wine::wine_close<family>(host_fd);
::__wine_unix_ret_close(host_fd);
}
}
};
Expand All @@ -75,6 +75,13 @@ class basic_wine_family_file : public basic_wine_family_io_observer<family, ch_t
inline constexpr basic_wine_family_file(decltype(nullptr)) noexcept = delete;
inline constexpr basic_wine_family_file(basic_wine_family_file<family, ch_type>) noexcept = delete;
inline constexpr basic_wine_family_file &operator=(basic_wine_family_file<family, ch_type>) noexcept = delete;
inline ~basic_wine_family_file()
{
if (host_fd) [[likely]]
{
::__wine_unix_ret_close(host_fd);
}
}
};

} // namespace fast_io
34 changes: 23 additions & 11 deletions src/__wine_unix/include/__wine_unix/__wine_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,27 @@ extern "C"
#define __WINE_UNIX_NOEXCEPT
#endif
#if INTPTR_MAX < INT_LEAST32_MAX
typedef int_least32_t __wine_host_fd_t;
typedef uint_least32_t __wine_host_fd_t;
typedef uint_least32_t __wine_errno_t;
#else
typedef ptrdiff_t __wine_host_fd_t;
typedef size_t __wine_host_fd_t;
typedef size_t __wine_errno_t;
#endif
#if INTPTR_MAX < INT_LEAST64_MAX
typedef int_least64_t __wine_off_t;
#else
typedef ptrdiff_t __wine_off_t;
#endif

typedef __wine_host_fd_t __wine_host_errno_t;
typedef __wine_host_fd_t __wine_host_flags_t;
typedef __wine_host_fd_t __wine_host_mode_t;

typedef struct
{
void *iov_base;
void const *iov_base;
size_t iov_len;
} __wine_unix_iovec_t;

__WINE_UNIX_DLLEXPORT __wine_errno_t __WINE_UNIX_DEFAULTCALL __wine_unix_host_errno_to_wine_errno(__wine_host_errno_t) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_host_errno_t __WINE_UNIX_DEFAULTCALL __wine_unix_wine_errno_to_host_errno(__wine_errno_t) __WINE_UNIX_NOEXCEPT;

typedef struct
{
__wine_errno_t errcode;
Expand All @@ -53,16 +54,27 @@ typedef size_t __wine_errno_t;
} __wine_unix_result_ret_readwritev;

__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_readwritev __WINE_UNIX_DEFAULTCALL __wine_unix_ret_writev(__wine_host_fd_t, __wine_unix_iovec_t const *, size_t) __WINE_UNIX_NOEXCEPT;

__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_readwritev __WINE_UNIX_DEFAULTCALL __wine_unix_ret_readv(__wine_host_fd_t, __wine_unix_iovec_t *, size_t) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_readwritev __WINE_UNIX_DEFAULTCALL __wine_unix_ret_readv(__wine_host_fd_t, __wine_unix_iovec_t const *, size_t) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_readwritev __WINE_UNIX_DEFAULTCALL __wine_unix_ret_pwritev(__wine_host_fd_t, __wine_unix_iovec_t const *, size_t, __wine_off_t) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_readwritev __WINE_UNIX_DEFAULTCALL __wine_unix_ret_preadv(__wine_host_fd_t, __wine_unix_iovec_t const *, size_t, __wine_off_t) __WINE_UNIX_NOEXCEPT;

typedef struct
{
__wine_errno_t errcode;
__wine_host_fd_t host_fd;
} __wine_unix_result_ret_openat;
} __wine_unix_result_ret_host_fd;

typedef struct
{
__wine_errno_t errcode;
ptrdiff_t handle;
} __wine_unix_result_ret_nt_handle;

__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_openat __WINE_UNIX_DEFAULTCALL __wine_unix_ret_openat(__wine_host_fd_t, void const *, size_t, __wine_host_flags_t, __wine_host_mode_t) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_errno_t __WINE_UNIX_DEFAULTCALL __wine_unix_ret_host_fd_to_unix_fd(__wine_host_fd_t host_fd, void *punixfd, size_t unixfdsizeof) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_host_fd __WINE_UNIX_DEFAULTCALL __wine_unix_ret_unix_fd_to_host_fd(void const *punixfd, size_t unixfdsizeof) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_nt_handle __WINE_UNIX_DEFAULTCALL __wine_unix_ret_host_fd_to_nt_handle(__wine_host_fd_t host_fd) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_host_fd __WINE_UNIX_DEFAULTCALL __wine_unix_ret_nt_handle_to_host_fd(ptrdiff_t handle) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_unix_result_ret_host_fd __WINE_UNIX_DEFAULTCALL __wine_unix_ret_openat(__wine_host_fd_t, void const *, size_t, __wine_host_flags_t, __wine_host_mode_t) __WINE_UNIX_NOEXCEPT;
__WINE_UNIX_DLLEXPORT __wine_errno_t __WINE_UNIX_DEFAULTCALL __wine_unix_ret_close(__wine_host_fd_t) __WINE_UNIX_NOEXCEPT;

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit b81f6c1

Please sign in to comment.