From c4b81afc2638e5b2a17902644721fc0594615287 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 24 Apr 2009 17:11:10 -0700 Subject: [PATCH] Add a dummy offset to the arrays generated by genassym to avoid ary[0] The dummy offset avoids the generation of dummy arrays of size zero. This whole code path is a hack, but after a lot of messing around Alex and I determined that it was easier to hack it then to try to redo the code due to complications introduced by cross-compiled environments. Submitted-by: Alex Hornung --- sys/sys/assym.h | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sys/sys/assym.h b/sys/sys/assym.h index 8a1b7c3..3d9ecb4 100644 --- a/sys/sys/assym.h +++ b/sys/sys/assym.h @@ -36,13 +36,17 @@ #error "This file should not be included by userland programs." #endif -#define ASSYM_ABS(value) ((value) < 0 ? -((value) + 1) + 1ULL : (value)) +/* Add an ASSYM_BIAS to all arrays to avoid zero-size, which can be + mishandled in some compilers */ +#define ASSYM_BIAS 0x00100000 -#define ASSYM(name, value) \ -char name ## sign[(value) < 0 ? 1 : 0]; \ -char name ## w0[ASSYM_ABS(value) & 0xFFFFU]; \ -char name ## w1[(ASSYM_ABS(value) & 0xFFFF0000UL) >> 16]; \ -char name ## w2[(ASSYM_ABS(value) & 0xFFFF00000000ULL) >> 32]; \ -char name ## w3[(ASSYM_ABS(value) & 0xFFFF000000000000ULL) >> 48] +#define ASSYM_ABS(value) ((value) < 0 ? -((value) + 1) + 1ULL : (value)) + +#define ASSYM(name, value) \ +char name ## sign[((value) < 0 ? 1 : 0) + ASSYM_BIAS]; \ +char name ## w0[(ASSYM_ABS(value) & 0xFFFFU) + ASSYM_BIAS]; \ +char name ## w1[((ASSYM_ABS(value) & 0xFFFF0000UL) >> 16) + ASSYM_BIAS]; \ +char name ## w2[((ASSYM_ABS(value) & 0xFFFF00000000ULL) >> 32) + ASSYM_BIAS]; \ +char name ## w3[((ASSYM_ABS(value) & 0xFFFF000000000000ULL) >> 48) + ASSYM_BIAS] #endif /* !_SYS_ASSYM_H_ */ -- 1.7.7.2