From 5309904f7767d1c3e543bca85bd826f5174d3544 Mon Sep 17 00:00:00 2001 From: michaelh Date: Sat, 2 Mar 2002 05:44:18 +0000 Subject: [PATCH] Added git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1969 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- support/regression/tests/bug-524691.c | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 support/regression/tests/bug-524691.c diff --git a/support/regression/tests/bug-524691.c b/support/regression/tests/bug-524691.c new file mode 100644 index 00000000..542cedcf --- /dev/null +++ b/support/regression/tests/bug-524691.c @@ -0,0 +1,39 @@ +/* Division by powers of two. + */ +#include + +typedef unsigned int UINT; + +typedef struct _HeapEntryState +{ + void *pBase; + UINT uFlags; +} HeapEntryState; + +static HeapEntryState *_getHeapEntryState(void *p, HeapEntryState *pStates, UINT nStateEntries) +{ + int uLeft = -1, uRight = nStateEntries, uMiddle; + + while (uRight - uLeft > 1) + { + int iDiff; + + uMiddle = (uLeft + uRight)/2; + iDiff = pStates[uMiddle].pBase - p; + + if (iDiff > 0) + { + uRight = uMiddle; + } + else if (iDiff < 0) + { + uLeft = uMiddle; + } + else + { + return pStates + uMiddle; + } + } + + return NULL; +} -- 2.30.2