Skip to content

[RISC-V] FP structs larger than 16 bytes in interops #107386

Open
@tomeksowi

Description

@tomeksowi

.NET currently supports passing/returning structs according to hardware floating-point calling convention up to 16 bytes for reasons stated in #107286 (comment)

Native ABI does not limit size of FP structs so this won't work:

struct Empty {}
struct S { double; Empty; long; }

[DllImport("SomeLib")]
public static extern void func(S s);

.NET will pass S according to integer calling convention (by implicit reference) and the native side will expect it in two registers, fa0 and a0.

Such structs are acheivable via empty structs, which are undefined in C, which ABI .NET interops follow. However, it would be nice to throw an exception if FP structs > 16 bytes appear in interops. (Things like struct { _Alignas(16) double; long; } are legal in C and .NET users may use empty structs to match the layout.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions