tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Patch for graphics/lcms2 (alignment issues on sparc)
On Sat, Oct 31, 2026 at 09:05:04PM -0400, Greg Troxel wrote:
> > Maybe this should be alignof(max_align_t) instead? I expect this
> > affects more than just sparc32.
>
> In this case, we really need to know the alignment for doubles, as I
> understand it. Having some other type with even biggger alignment would
> cause max_align_t to be bigger, and that would be wasteful.
>
> Anyone with a retro arch that needs more then 4 for doubles, please
> speak up.
You can do something like
union foo {
int y;
double x;
char *z;
};
that specifically includes exactly the types needed, and ask for its
alignment.
In the absence of alignof, it's probably sufficient to also do
struct bar {
unsigned char a;
union foo b;
};
and take offsetof(struct bar, b). There's no guarantee that compilers
won't insert extra padding in structs, but reasonable ones don't.
--
David A. Holland
dholland%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index