Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140623044807.GA6432@brightrain.aerifal.cx>
Date: Mon, 23 Jun 2014 00:48:07 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: max_align_t mess

Sometime we need to decide what to do about max_align_t. The GCC
definition is:

typedef struct {
  long long __max_align_ll __attribute__((__aligned__(__alignof__(long long))));
  long double __max_align_ld __attribute__((__aligned__(__alignof__(long double))));
} max_align_t;

Unfortunately, this definition is relying on bugs in GCC to give the
"right" result (the result they want and that matches the existing
ABIs), and is not reproducible in any portable manner: they're relying
on __alignof__(T) to give the preferred alignment of T rather than the
required alignment of T, and the portable (C11) _Alignof will not give
this result except on old buggy GCC.

One sane way to handle this might be to just put max_align_t in the
arch-specific alltypes.h fragment and use the following definition:

TYPEDEF struct { _Alignas(N) struct { char __align_c[M]; }; } max_align_t;

where N and M are the correct alignment and size for the arch ABI.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.