public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: James Hanley <jhanley@dgtlrift.com>
Cc: libc-alpha@sourceware.org
Subject: Re: in6_addr struct union with uint64_t
Date: Fri, 26 Jan 2024 20:38:06 +0100	[thread overview]
Message-ID: <87a5or28dd.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CAF++6APe8VxPaSwuToFeAfugvXOY=pb19Td-e4r4_1O4b1Ja5Q@mail.gmail.com> (James Hanley's message of "Fri, 26 Jan 2024 09:57:57 -0500")

* James Hanley:

> #if !__USE_KERNEL_IPV6_DEFS
> /* IPv6 address */
> struct in6_addr
>   {
>     union
>       {
>         uint8_t __u6_addr8[16];
>         uint16_t __u6_addr16[8];
>         uint32_t __u6_addr32[4];
>         uint64_t __u6_addr64[2]; // new
>         unsigned __int128 __u6_addr128; // new
>       } __in6_u;
> #define s6_addr                 __in6_u.__u6_addr8
> #ifdef __USE_MISC
> # define s6_addr16              __in6_u.__u6_addr16
> # define s6_addr32              __in6_u.__u6_addr32
> # define s6_addr64              __in6_u.__u6_addr64
> # define s6_addr128             __in6_u.__u6_addr128
> #endif
>   };
> #endif /* !__USE_KERNEL_IPV6_DEFS */ 
>
> First, is this useful, and is there a standard that prohibits defining
> additional union members?

It changes alignment from 4 bytes to 16 bytes on some architectures,
which is an ABI-breaking change.  For example, if a member of type
struct in6_addr is embedded in a struct, it may require additional
padding in front of it as a result of this change.

Compilers should be able to use wider instructions if beneficial.

Thanks,
Florian


  reply	other threads:[~2024-01-26 19:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26 14:57 James Hanley
2024-01-26 19:38 ` Florian Weimer [this message]
2024-01-29 18:02   ` James Hanley
2024-01-29 19:08     ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a5or28dd.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=jhanley@dgtlrift.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).