From: sdcc-builder Date: Tue, 9 Sep 2003 09:58:17 +0000 (+0000) Subject: added workaround for packing bug in gcc 21.95.2 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=2a963d700e99cf48ae3550100eece963de43c5c4;p=fw%2Fsdcc added workaround for packing bug in gcc 21.95.2 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2883 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/support/regression/tests/libmullong.c b/support/regression/tests/libmullong.c index 71959813..61ead68b 100644 --- a/support/regression/tests/libmullong.c +++ b/support/regression/tests/libmullong.c @@ -13,54 +13,79 @@ # define near # define long int # include "../../../../../device/lib/_mullong.c" +# define mullong(a,b) mullong_wrapper(a,b) # else -# define _mullong(a,b) (a*b) +# define mullong(a,b) (a*b) # endif #else # if defined(type_c) # define _SDCC_NO_ASM_LIB_FUNCS 1 # endif # include "../../../../../device/lib/_mullong.c" +# define mullong _mullong +#endif + +/* gcc 2.95.2 on usf-cf-x86-linux-1 (debian 2.2) has a bug with + * packing structs + */ +#if defined(PORT_HOST) && defined(type_c) && !defined(WORDS_BIGENDIAN) +struct +{ + char c1; + short i; + char c2; +} pack_test; + +long +mullong_wrapper (long a, long b) +{ + if (sizeof(pack_test) == 4) + /* length of struct ok: use SDCC library */ + return _mullong (a, b); + else + /* buggy gcc: use generic multiplication */ + return a * b; +} #endif void testlibmullong(void) { - ASSERT(_mullong ( 0, 0) == 0); - ASSERT(_mullong ( 0x100, 0x100) == 0x10000); - ASSERT(_mullong (0x01020304, 3) == 0x0306090c); - ASSERT(_mullong ( 3, 0x01020304) == 0x0306090c); - ASSERT(_mullong (0x000000ff, 2) == 0x000001fe); - ASSERT(_mullong ( 2, 0x000000ff) == 0x000001fe); - ASSERT(_mullong (0x00007fff, 4) == 0x0001fffc); - ASSERT(_mullong ( 4, 0x00007fff) == 0x0001fffc); - ASSERT(_mullong (0x003fffff, 8) == 0x01fffff8); - ASSERT(_mullong ( 8, 0x003fffff) == 0x01fffff8); + ASSERT(mullong ( 0, 0) == 0); + ASSERT(mullong ( 0x100, 0x100) == 0x10000); + ASSERT(mullong (0x01020304, 3) == 0x0306090c); + ASSERT(mullong ( 3, 0x01020304) == 0x0306090c); + ASSERT(mullong (0x000000ff, 2) == 0x000001fe); + ASSERT(mullong ( 2, 0x000000ff) == 0x000001fe); + ASSERT(mullong (0x00007fff, 4) == 0x0001fffc); + ASSERT(mullong ( 4, 0x00007fff) == 0x0001fffc); + ASSERT(mullong (0x003fffff, 8) == 0x01fffff8); + ASSERT(mullong ( 8, 0x003fffff) == 0x01fffff8); - ASSERT(_mullong ( 0x33, 0x34) == 0x00000a5c); - ASSERT(_mullong ( 0x34, 0x33) == 0x00000a5c); - ASSERT(_mullong ( 0x3334, 0x3536) == 0x0aa490f8); - ASSERT(_mullong ( 0x3536, 0x3334) == 0x0aa490f8); - ASSERT(_mullong ( 0x333435, 0x363738) == 0x0e98ce98); - ASSERT(_mullong ( 0x363738, 0x333435) == 0x0e98ce98); - ASSERT(_mullong (0x33343536, 0x3738393a) == 0x777d143c); - ASSERT(_mullong (0x3738393a, 0x33343536) == 0x777d143c); + ASSERT(mullong ( 0x33, 0x34) == 0x00000a5c); + ASSERT(mullong ( 0x34, 0x33) == 0x00000a5c); + ASSERT(mullong ( 0x3334, 0x3536) == 0x0aa490f8); + ASSERT(mullong ( 0x3536, 0x3334) == 0x0aa490f8); + ASSERT(mullong ( 0x333435, 0x363738) == 0x0e98ce98); + ASSERT(mullong ( 0x363738, 0x333435) == 0x0e98ce98); + ASSERT(mullong (0x33343536, 0x3738393a) == 0x777d143c); + ASSERT(mullong (0x3738393a, 0x33343536) == 0x777d143c); - ASSERT(_mullong ( 0xff, 0xfe) == 0x0000fd02); - ASSERT(_mullong ( 0xfe, 0xff) == 0x0000fd02); - ASSERT(_mullong ( 0xfffe, 0xfdfc) == 0xfdfa0408); - ASSERT(_mullong ( 0xfdfc, 0xfffe) == 0xfdfa0408); - ASSERT(_mullong ( 0xfffefd, 0xfcfbfa) == 0xfa0d1212); - ASSERT(_mullong ( 0xfcfbfa, 0xfffefd) == 0xfa0d1212); - ASSERT(_mullong (0xfffefdfc, 0xfbfaf9f8) == 0x20282820); - ASSERT(_mullong (0xfbfaf9f8, 0xfffefdfc) == 0x20282820); + ASSERT(mullong ( 0xff, 0xfe) == 0x0000fd02); + ASSERT(mullong ( 0xfe, 0xff) == 0x0000fd02); + ASSERT(mullong ( 0xfffe, 0xfdfc) == 0xfdfa0408); + ASSERT(mullong ( 0xfdfc, 0xfffe) == 0xfdfa0408); + ASSERT(mullong ( 0xfffefd, 0xfcfbfa) == 0xfa0d1212); + ASSERT(mullong ( 0xfcfbfa, 0xfffefd) == 0xfa0d1212); + ASSERT(mullong (0xfffefdfc, 0xfbfaf9f8) == 0x20282820); + ASSERT(mullong (0xfbfaf9f8, 0xfffefdfc) == 0x20282820); - ASSERT(_mullong (0xff000000, 0xff000000) == 0); - ASSERT(_mullong (0xffff0000, 0xffff0000) == 0); - ASSERT(_mullong (0xfffffe00, 0xfffffd00) == 0x00060000); - ASSERT(_mullong (0xfffffd00, 0xfffffe00) == 0x00060000); - ASSERT(_mullong (0xfffffefd, 0xfffffcfb) == 0x00030e0f); - ASSERT(_mullong (0xfffffcfb, 0xfffffefd) == 0x00030e0f); + ASSERT(mullong (0xff000000, 0xff000000) == 0); + ASSERT(mullong (0xffff0000, 0xffff0000) == 0); + ASSERT(mullong (0xfffffe00, 0xfffffd00) == 0x00060000); + ASSERT(mullong (0xfffffd00, 0xfffffe00) == 0x00060000); + ASSERT(mullong (0xfffffefd, 0xfffffcfb) == 0x00030e0f); + ASSERT(mullong (0xfffffcfb, 0xfffffefd) == 0x00030e0f); - ASSERT(_mullong (0xffffffff, 0xffffffff) == 1); + ASSERT(mullong (0xffffffff, 0xffffffff) == 1); }