logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0007-Use-C23-syntax-for-packed-attribute-and-alignment.patch (2218B)


  1. From dcc5033eb17003d078525e146e2a4fec29f71f84 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Wed, 1 Apr 2026 21:37:21 -0700
  4. Subject: [PATCH] Use C23 syntax for packed attribute and alignment
  5. ---
  6. include/linux-private/linux/gen_stats.h | 4 ++--
  7. include/linux-private/linux/if_ether.h | 4 ++--
  8. include/linux-private/linux/socket.h | 3 ++-
  9. 3 files changed, 6 insertions(+), 5 deletions(-)
  10. diff --git a/include/linux-private/linux/gen_stats.h b/include/linux-private/linux/gen_stats.h
  11. index 24a861c0..f2e3d45e 100644
  12. --- a/include/linux-private/linux/gen_stats.h
  13. +++ b/include/linux-private/linux/gen_stats.h
  14. @@ -25,10 +25,10 @@ struct gnet_stats_basic {
  15. __u64 bytes;
  16. __u32 packets;
  17. };
  18. -struct gnet_stats_basic_packed {
  19. +struct [[gnu::packed]] gnet_stats_basic_packed {
  20. __u64 bytes;
  21. __u32 packets;
  22. -} __attribute__ ((packed));
  23. +};
  24. /**
  25. * struct gnet_stats_rate_est - rate estimator
  26. diff --git a/include/linux-private/linux/if_ether.h b/include/linux-private/linux/if_ether.h
  27. index 8c36f63e..8887d042 100644
  28. --- a/include/linux-private/linux/if_ether.h
  29. +++ b/include/linux-private/linux/if_ether.h
  30. @@ -158,11 +158,11 @@
  31. #endif
  32. #if __UAPI_DEF_ETHHDR
  33. -struct ethhdr {
  34. +struct [[gnu::packed]] ethhdr {
  35. unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
  36. unsigned char h_source[ETH_ALEN]; /* source ether addr */
  37. __be16 h_proto; /* packet type ID field */
  38. -} __attribute__((packed));
  39. +};
  40. #endif
  41. diff --git a/include/linux-private/linux/socket.h b/include/linux-private/linux/socket.h
  42. index 268b9482..93a7b713 100644
  43. --- a/include/linux-private/linux/socket.h
  44. +++ b/include/linux-private/linux/socket.h
  45. @@ -12,11 +12,12 @@
  46. typedef unsigned short __kernel_sa_family_t;
  47. struct __kernel_sockaddr_storage {
  48. + _Alignas(_K_SS_ALIGNSIZE) /* force desired alignment */
  49. __kernel_sa_family_t ss_family; /* address family */
  50. /* Following field(s) are implementation specific */
  51. char __data[_K_SS_MAXSIZE - sizeof(unsigned short)];
  52. /* space to achieve desired size, */
  53. /* _SS_MAXSIZE value minus size of ss_family */
  54. -} __attribute__ ((aligned(_K_SS_ALIGNSIZE))); /* force desired alignment */
  55. +};
  56. #endif /* _LINUX_SOCKET_H */
  57. --
  58. 2.49.0