x86emul: correct DECLARE_ALIGNED()

Stop creating an excessively large array on the stack, by properly
taking into account the array element size when establishing its
element count (and of course also when calculating the pointer to
be actually used to access the memory).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
Jan Beulich committed 2017-03-17 09:33:45 +01:00
1 parent 182602911c
commit da091ea2f1
1 file changed
+4 -4
+4 -4
View File
@@ -553,10 +553,10 @@ typedef union {
* the compiler for automatic variables. Use this helper to instantiate a
* suitably aligned variable, producing a pointer to access it.
*/
#define DECLARE_ALIGNED(type, var) \
long __##var[sizeof(type) + __alignof(type) - __alignof(long)]; \
type *const var##p = \
(void *)((long)(__##var + __alignof(type) - __alignof(long)) \
#define DECLARE_ALIGNED(type, var) \
long __##var[(sizeof(type) + __alignof(type)) / __alignof(long) - 1]; \
type *const var##p = \
(void *)(((long)__##var + __alignof(type) - __alignof(__##var)) \
& -__alignof(type))
#ifdef __GCC_ASM_FLAG_OUTPUTS__
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.