From: Matthew Dillon Date: Sat, 25 Apr 2009 00:11:10 +0000 (-0700) Subject: Add a dummy offset to the arrays generated by genassym to avoid ary[0] X-Git-Tag: v2.3.1~60 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/c4b81afc2638e5b2a17902644721fc0594615287?ds=sidebyside 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 --- diff --git a/sys/sys/assym.h b/sys/sys/assym.h index 8a1b7c3175..3d9ecb466e 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_ */