diff options
author | Flavio Cruz <flaviocruz@gmail.com> | 2023-05-05 00:43:36 -0400 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-05-06 21:39:47 +0200 |
commit | 42fbc5f9afb66043d4493297a84842cbeef870b7 (patch) | |
tree | a86af5b68efd99f02df017516ebeb441b0dbe7d5 /eth-multiplexer | |
parent | eca65ec789d6e48536a1a9867647d95746364a3d (diff) | |
download | hurd-42fbc5f9afb66043d4493297a84842cbeef870b7.tar.gz hurd-42fbc5f9afb66043d4493297a84842cbeef870b7.tar.bz2 hurd-42fbc5f9afb66043d4493297a84842cbeef870b7.zip |
Update eth-multiplexer/vdev.c to be more portable
* Perform the correct alignment for x86_64.
* Use designated initializers.
Message-Id: <ZFSJeDp9rWoNK4lL@jupiter.tail36e24.ts.net>
Diffstat (limited to 'eth-multiplexer')
-rw-r--r-- | eth-multiplexer/vdev.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/eth-multiplexer/vdev.c b/eth-multiplexer/vdev.c index 548af9d2..f441803d 100644 --- a/eth-multiplexer/vdev.c +++ b/eth-multiplexer/vdev.c @@ -46,25 +46,29 @@ static int dev_num; * TODO every device structure should has its own lock to protect itself. */ static pthread_mutex_t dev_list_lock = PTHREAD_MUTEX_INITIALIZER; -mach_msg_type_t header_type = +/* Should match MiG's desired_complex_alignof */ +#define MSG_ALIGNMENT __alignof__(uintptr_t) + +static const mach_msg_type_t header_type = { - MACH_MSG_TYPE_BYTE, - 8, - NET_HDW_HDR_MAX, - TRUE, - FALSE, - FALSE, - 0 + .msgt_name = MACH_MSG_TYPE_BYTE, + .msgt_size = 8, + .msgt_number = NET_HDW_HDR_MAX, + .msgt_inline = TRUE, + .msgt_longform = FALSE, + .msgt_deallocate = FALSE, + .msgt_unused = 0 }; -mach_msg_type_t packet_type = +static const mach_msg_type_t packet_type = { - MACH_MSG_TYPE_BYTE, /* name */ - 8, /* size */ - 0, /* number */ - TRUE, /* inline */ - FALSE, /* longform */ - FALSE /* deallocate */ + .msgt_name = MACH_MSG_TYPE_BYTE, + .msgt_size = 8, + .msgt_number = 0, + .msgt_inline = TRUE, + .msgt_longform = FALSE, + .msgt_deallocate = FALSE, + .msgt_unused = 0 }; int @@ -208,8 +212,9 @@ broadcast_pack (char *data, int datalen, struct vether_device *from_vdev) pack_size = datalen - sizeof (struct ethhdr); /* remember message sizes must be rounded up */ - msg.msg_hdr.msgh_size = (((mach_msg_size_t) (sizeof(struct net_rcv_msg) - - NET_RCV_MAX + pack_size)) + 3) & ~3; + msg.msg_hdr.msgh_size = sizeof (struct net_rcv_msg) - NET_RCV_MAX + pack_size; + msg.msg_hdr.msgh_size = (mach_msg_size_t) ((msg.msg_hdr.msgh_size + + MSG_ALIGNMENT - 1) & ~(MSG_ALIGNMENT - 1)); header = (struct ethhdr *) msg.header; packet = (struct packet_header *) msg.packet; |