[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Bob Friesenhahn
Subject: RE: AC_CHECK_ALIGNOF maximum ??
Date: Thu, 20 Jun 2013 10:31:41 -0500 (CDT)
User-agent: Alpine 2.01 (GSO 1266 2009-07-14)

On Thu, 20 Jun 2013, 'Chris Hall' wrote:
Of course gcc gives __BIGGEST_ALIGNMENT__ for this.  And I guess
other compilers do something similar...

...but I cannot help feeling that autoconf should cover this, but
if it does, I have failed to find where :-(

How would Autoconf portably test for this

I have no idea.  Correct me if I am wrong: but I thought Autoconf was
there to save humble journeymen like me from having to know that sort
of thing ?

Autoconf figures things out by running the compiler and linker in a portable way. It does not usually want to run the compiled test program because that does not work for cross-compilation. There needs to be a way to discover the desired alignment by compiling code.

and for what purpose would you use this information for?

Specifically... I want to allocate lumps of memory with some red tape
in front to be followed by the "body" of the allocation.  That body
needs to be aligned, as if by malloc, to the maximum alignment.

For completeness, given the sizeof() the body I wish to align to
sizeof() % maximum alignment.

With C11 I could use the alignof() spell to do something more precise.
And I guess I could Autoconf my way to discovering if __alignof__() or
equivalent whizzy-ness is available.

You know and I know that 16 is probably an excellent guess that will
be true for the foreseeable... but that's hardly satisfactory !

I am not so sure. Are you talking about the alignment of a large type like 'double', 'long double', a 128-bit integer on PowerPC, the alignment required by SSE2 instructions, or the alignment required by some AVX instructions (see

Compile-time estimation of biggest alignment seems risky to me if it
is used for any serious purpose.  If all of the software in the
running application was not compiled with the same flags, then the
compiled-in value may be wrong.

AFAICS any disagreement about any alignment is a recipe for tears
(before, after and during bedtime).  Why should the maximum alignment
be any different ?

Depending on what you mean by 'maximum alignment', the answer could be different depending on compiler options and the target instruction set.

Autoconf usually creates a configuration header file which is used by all of the code in the project. If some parts of an application are built with different flags, they might still work in the application but object code may require different maximum alignment.

Bob Friesenhahn
GraphicsMagick Maintainer,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]