Library Forwarding/wayland: Add functions required by zink + Super Meat Boy on 32-bit

This commit is contained in:
Tony Wasserka committed 2024-02-21 11:44:55 +01:00
1 parent 67941f04eb
commit 6f00611892
3 files changed
+72 -3

No files matched your search

+37
View File
@@ -265,6 +265,38 @@ extern "C" void wl_proxy_marshal(wl_proxy *proxy, uint32_t opcode, ...) {
wl_proxy_marshal_array(proxy, opcode, args);
}
extern "C" wl_proxy *wl_proxy_marshal_constructor(wl_proxy *proxy, uint32_t opcode,
const wl_interface *interface, ...) {
wl_argument args[WL_CLOSURE_MAX_ARGS];
va_list ap;
va_start(ap, interface);
// This is equivalent to reading ((wl_proxy_private*)proxy)->interface->methods[opcode].signature on 64-bit.
// On 32-bit, the data layout differs between host and guest however, so we let the host extract the data.
char signature[64];
fex_wl_get_method_signature(proxy, opcode, signature);
wl_argument_from_va_list(signature, args, WL_CLOSURE_MAX_ARGS, ap);
va_end(ap);
return wl_proxy_marshal_array_constructor(proxy, opcode, args, interface);
}
extern "C" wl_proxy *wl_proxy_marshal_constructor_versioned(wl_proxy *proxy, uint32_t opcode,
const wl_interface *interface, uint32_t version, ...) {
wl_argument args[WL_CLOSURE_MAX_ARGS];
va_list ap;
va_start(ap, version);
// This is equivalent to reading ((wl_proxy_private*)proxy)->interface->methods[opcode].signature on 64-bit.
// On 32-bit, the data layout differs between host and guest however, so we let the host extract the data.
char signature[64];
fex_wl_get_method_signature(proxy, opcode, signature);
wl_argument_from_va_list(signature, args, WL_CLOSURE_MAX_ARGS, ap);
va_end(ap);
return wl_proxy_marshal_array_constructor_versioned(proxy, opcode, args, interface, version);
}
extern "C" wl_proxy *wl_proxy_marshal_flags(wl_proxy *proxy, uint32_t opcode,
const wl_interface *interface,
uint32_t version,
@@ -289,6 +321,11 @@ extern "C" wl_proxy *wl_proxy_marshal_flags(wl_proxy *proxy, uint32_t opcode,
#endif
}
extern "C" void wl_log_set_handler_client(wl_log_func_t handler) {
// Ignore
}
void OnInit() {
fex_wl_exchange_interface_pointer(const_cast<wl_interface*>(&wl_output_interface), "wl_output");
fex_wl_exchange_interface_pointer(const_cast<wl_interface*>(&wl_shm_pool_interface), "wl_shm_pool");
+25 -3
View File
@@ -199,6 +199,7 @@ fex_wl_proxy_marshal_array(
wl_proxy *proxy, uint32_t opcode,
guest_layout<wl_argument*> args,
guest_layout<const wl_interface*> guest_interface,
bool constructor, // Call the _constructor variant of the native wayland function
std::optional<uint32_t> version,
std::optional<uint32_t> flags) {
auto interface = lookup_wl_interface(guest_interface);
@@ -208,9 +209,9 @@ fex_wl_proxy_marshal_array(
auto host_args = fex_wl_remap_argument_list(args, get_proxy_interface(proxy)->methods[opcode]);
if (false) {
} else if (!version && !flags) {
} else if (!constructor && !version && !flags) {
return nullptr;
} else if (version && flags) {
} else if (!constructor && version && flags) {
// wl_proxy_marshal_array_flags is only available starting from Wayland 1.19.91
#if WAYLAND_VERSION_MAJOR * 10000 + WAYLAND_VERSION_MINOR * 100 + WAYLAND_VERSION_MICRO >= 11991
return fexldr_ptr_libwayland_client_wl_proxy_marshal_array_flags(proxy, opcode, interface, version.value(), flags.value(), host_args.data());
@@ -218,19 +219,40 @@ fex_wl_proxy_marshal_array(
fprintf(stderr, "Host Wayland version is too old to support FEX thunking\n");
__builtin_trap();
#endif
} else if (constructor && version && !flags) {
return fexldr_ptr_libwayland_client_wl_proxy_marshal_array_constructor_versioned(proxy, opcode, host_args.data(), interface, version.value());
} else if (constructor && version && !flags) {
return fexldr_ptr_libwayland_client_wl_proxy_marshal_array_constructor(proxy, opcode, host_args.data(), interface);
} else {
fprintf(stderr, "Invalid configuration\n");
__builtin_trap();
}
}
extern "C" wl_proxy*
fexfn_impl_libwayland_client_wl_proxy_marshal_array_constructor_versioned(
wl_proxy *proxy, uint32_t opcode,
guest_layout<wl_argument*> args,
guest_layout<const wl_interface*> interface,
uint32_t version) {
return fex_wl_proxy_marshal_array(proxy, opcode, args, interface, true, version, std::nullopt);
}
extern "C" wl_proxy*
fexfn_impl_libwayland_client_wl_proxy_marshal_array_constructor(
wl_proxy *proxy, uint32_t opcode,
guest_layout<wl_argument*> args,
guest_layout<const wl_interface*> interface) {
return fex_wl_proxy_marshal_array(proxy, opcode, args, interface, true, std::nullopt, std::nullopt);
}
extern "C" wl_proxy*
fexfn_impl_libwayland_client_wl_proxy_marshal_array_flags(
wl_proxy *proxy, uint32_t opcode,
guest_layout<const wl_interface*> interface,
uint32_t version, uint32_t flags,
guest_layout<wl_argument*> args) {
return fex_wl_proxy_marshal_array(proxy, opcode, args, interface, version, flags);
return fex_wl_proxy_marshal_array(proxy, opcode, args, interface, false, version, flags);
}
// Variant of CallbackUnpack::CallGuestPtr that relocates a wl_array parameter
@@ -44,11 +44,13 @@ template<> struct fex_gen_config<wl_display_dispatch> {};
template<> struct fex_gen_config<wl_display_dispatch_pending> {};
template<> struct fex_gen_config<wl_display_dispatch_queue> {};
template<> struct fex_gen_config<wl_display_dispatch_queue_pending> {};
template<> struct fex_gen_config<wl_display_get_error> {};
template<> struct fex_gen_config<wl_display_prepare_read> {};
template<> struct fex_gen_config<wl_display_prepare_read_queue> {};
template<> struct fex_gen_config<wl_display_read_events> {};
template<> struct fex_gen_config<wl_display_roundtrip> {};
template<> struct fex_gen_config<wl_display_roundtrip_queue> {};
template<> struct fex_gen_config<wl_display_connect_to_fd> {};
template<> struct fex_gen_config<wl_display_get_fd> {};
template<> struct fex_gen_config<wl_event_queue_destroy> {};
@@ -61,6 +63,8 @@ template<> struct fex_gen_param<wl_proxy_add_listener, 2, void*> : fexgen::assum
template<> struct fex_gen_config<wl_proxy_create> : fexgen::custom_host_impl {};
template<> struct fex_gen_param<wl_proxy_create, 1, const wl_interface*> : fexgen::ptr_passthrough {};
template<> struct fex_gen_config<wl_proxy_create_wrapper> {};
template<> struct fex_gen_config<wl_proxy_get_class> {};
template<> struct fex_gen_config<wl_proxy_get_id> {};
template<> struct fex_gen_config<wl_proxy_get_listener> {};
template<> struct fex_gen_config<wl_proxy_get_tag> {};
template<> struct fex_gen_config<wl_proxy_get_user_data> {};
@@ -73,6 +77,12 @@ template<> struct fex_gen_config<wl_proxy_wrapper_destroy> {};
template<> struct fex_gen_config<wl_proxy_marshal_array> : fexgen::custom_host_impl {};
template<> struct fex_gen_param<wl_proxy_marshal_array, 2, wl_argument*> : fexgen::ptr_passthrough {};
template<> struct fex_gen_config<wl_proxy_marshal_array_constructor> : fexgen::custom_host_impl {};
template<> struct fex_gen_param<wl_proxy_marshal_array_constructor, 2, wl_argument*> : fexgen::ptr_passthrough {};
template<> struct fex_gen_param<wl_proxy_marshal_array_constructor, 3, const wl_interface*> : fexgen::ptr_passthrough {};
template<> struct fex_gen_config<wl_proxy_marshal_array_constructor_versioned> : fexgen::custom_host_impl {};
template<> struct fex_gen_param<wl_proxy_marshal_array_constructor_versioned, 2, wl_argument*> : fexgen::ptr_passthrough {};
template<> struct fex_gen_param<wl_proxy_marshal_array_constructor_versioned, 3, const wl_interface*> : fexgen::ptr_passthrough {};
// wl_proxy_marshal_array_flags is only available starting from Wayland 1.19.91
#if WAYLAND_VERSION_MAJOR * 10000 + WAYLAND_VERSION_MINOR * 100 + WAYLAND_VERSION_MICRO >= 11991
template<> struct fex_gen_config<wl_proxy_marshal_array_flags> : fexgen::custom_host_impl {};