From d34455adf2b02379a6724c08abc57f038a6649c7 Mon Sep 17 00:00:00 2001 From: Trevor Berrange Sanchez Date: Wed, 5 Jun 2024 21:04:33 +0200 Subject: [PATCH] Guarantee the layout of some struct types by making them `extern struct`s. --- src/accountsdb/accounts_file.zig | 4 ++-- src/core/pubkey.zig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/accountsdb/accounts_file.zig b/src/accountsdb/accounts_file.zig index 239d70cc2..bb5bde54c 100644 --- a/src/accountsdb/accounts_file.zig +++ b/src/accountsdb/accounts_file.zig @@ -45,14 +45,14 @@ pub const AccountInFile = struct { len: usize = 0, /// info about the account stored - pub const StorageInfo = struct { + pub const StorageInfo = extern struct { write_version_obsolete: u64, data_len: u64, pubkey: Pubkey, }; /// on-chain account info about the account - pub const AccountInfo = struct { + pub const AccountInfo = extern struct { lamports: u64, rent_epoch: Epoch, owner: Pubkey, diff --git a/src/core/pubkey.zig b/src/core/pubkey.zig index 1df17963d..7c9310cc3 100644 --- a/src/core/pubkey.zig +++ b/src/core/pubkey.zig @@ -4,7 +4,7 @@ const Ed25519 = std.crypto.sign.Ed25519; const encoder = base58.Encoder.init(.{}); const decoder = base58.Decoder.init(.{}); -pub const Pubkey = struct { +pub const Pubkey = extern struct { data: [32]u8, const Self = @This();