Simon Josefsson <[email protected]> writes:

> Did you consider using gnulib's align*/stdalign* modules?

No, I wasn't aware of that. (I did use the somewhat related thing
AX_CREATE_STDINT_H, but figured it was no longer needed and deleted that
usage a few years ago).

Does the gnulib module define align* in terms of gcc attributes, or does
it define them as no-ops when they are missing?

I see a few complications:

* Whatever workarounds need to go into installed header files (since
  alignedness is part of the ABI), and it needs to work in the same way
  with any reasonable compiler the user may have. With
  AX_CREATE_STDINT_H, nettle used to create and install a header
  <nettle/nettle-stdint.h>, so adding a <nettle/nettle-align.h> would be
  similar.

* If at configure time, it is decided that alignas doesn't work and it
  is disabled, that is an ABI break. That's not a show stopper, but
  needs to be clearly documented (a bit similar to --enable-mini-gmp),
  and should not be automatic. Disabling alignas will also make the ABI
  incompatible with a few of the assembly files, which would then need
  to be disabled too.

* If one attempts workarounds like

    #define alignas(t) __attribute__((__aligned__(t)))

  then location of alignas on declarations likely gets more brittle. I'm
  still a bit confused as to the requirements, but to me it appears that
  in order to support C++ (a requirement for nettle headers), alignas
  has to be placed early, like

    alignas(uint64_t) char foo[17];

  while an __attribute__ is usually placed late,

    char foo[17] __attribute__(...);

  Unless one-location-to-rule-them-all is found, one may need hacks like

    ALIGNAS_BEFORE(uint64_t) char foo[17] ALIGNAS_AFTER(uint64_t);

  with macros defined differently depending on __cplusplus. Doable, but
  not pretty.

Is gnulib addressing some or all of these issues?

So what I'm trying to figure out is, what's a good
portability/complexity tradeoff. At the moment, I'm leaning towards
requiring stdalign.h, and users stuck with compilers that don't support
that would then need to patch out usage.

(Side note: AX_CREATE_STDINT_H used to work pretty well, I can only
 recall one issue. I may remember details wrong, but on Solaris N,
 stdint.h was missing, and nettle-stdint.h had to define all the
 standard types. But the definition of some of the types, like
 uint_fast32_t, was incompatible with the stdint.h that appeared in
 Solaris (N+1), causing errors for some users).

Regards,
/Niels

-- 
Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.
_______________________________________________
nettle-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to