Skip to content

Commit

Permalink
Library Forwarding/GL: Assume void* always points to compatible data
Browse files Browse the repository at this point in the history
  • Loading branch information
neobrain committed Jun 10, 2024
1 parent 476f175 commit cf08857
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 0 additions & 5 deletions ThunkLibs/Generator/analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,6 @@ void AnalysisAction::ParseInterface(clang::ASTContext& context) {
continue;
}

if (param_type->isVoidPointerType()) {
// TODO: Drop workaround for currently unannotated APIs
data.param_annotations[param_idx].assume_compatible = true;
}

auto check_struct_type = [&](const clang::Type* type) {
if (type->isIncompleteType()) {
throw report_error(type->getAsTagDecl()->getBeginLoc(), "Unannotated pointer with incomplete struct type; consider using "
Expand Down
2 changes: 1 addition & 1 deletion ThunkLibs/Generator/gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void GenerateThunkLibsAction::EmitLayoutWrappers(clang::ASTContext& context, std
auto struct_name = get_type_name(context, type);

// Opaque types don't need layout definitions
if (type_repack_info.assumed_compatible && type_repack_info.pointers_only) {
if (type_repack_info.assumed_compatible && type_repack_info.pointers_only && struct_name != "void") {
if (guest_abi.pointer_size != 4) {
fmt::print(file, "template<> inline constexpr bool has_compatible_data_layout<{}*> = true;\n", struct_name);
}
Expand Down
5 changes: 5 additions & 0 deletions ThunkLibs/libGL/libGL_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ struct fex_gen_config<SetGuestXDisplayString> : fexgen::custom_guest_entrypoint,
template<typename>
struct fex_gen_type {};

// Assume void* always points to data with consistent layout.
// It's used in too many functions to annotate them all.
template<>
struct fex_gen_type<void> : fexgen::opaque_type {};

template<>
struct fex_gen_type<std::remove_pointer_t<GLXContext>> : fexgen::opaque_type {};
template<>
Expand Down

0 comments on commit cf08857

Please sign in to comment.