return False;
}
-static Word cmp_Names ( Name n1, Name n2 )
+static Int cmp_Names ( Name n1, Name n2 )
{
UInt i = 0;
while (1) {
}
/* Compare XCoffSyms by their start address. */
-static Word cmp_XCoffSym_by_start ( void* v1, void* v2 )
+static Int cmp_XCoffSym_by_start ( void* v1, void* v2 )
{
XCoffSym* s1 = (XCoffSym*)v1;
XCoffSym* s2 = (XCoffSym*)v2;
/* Compare XCoffSyms by a slightly weaker ordering, returning zero
(equivalence) for any overlap, and -1 or 1 otherwise. */
-static Word cmp_XCoffSym_by_overlap ( void* v1, void* v2 )
+static Int cmp_XCoffSym_by_overlap ( void* v1, void* v2 )
{
XCoffSym* s1 = (XCoffSym*)v1;
XCoffSym* s2 = (XCoffSym*)v2;
/* Compare XCoffSyms by their start address, and for equal addresses,
use the name as a secondary sort key. */
-static Word cmp_XCoffSym_by_start_then_name ( void* v1, void* v2 )
+static Int cmp_XCoffSym_by_start_then_name ( void* v1, void* v2 )
{
XCoffSym* s1 = (XCoffSym*)v1;
XCoffSym* s2 = (XCoffSym*)v2;
struct _XArray {
void* (*alloc) ( SizeT ); /* alloc fn (nofail) */
void (*free) ( void* ); /* free fn */
- Word (*cmpFn) ( void*, void* ); /* cmp fn (may be NULL) */
+ Int (*cmpFn) ( void*, void* ); /* cmp fn (may be NULL) */
Word elemSzB; /* element size in bytes */
void* arr; /* pointer to elements */
Word usedsizeE; /* # used elements in arr */
xa->free(xa);
}
-void VG_(setCmpFnXA) ( XArray* xao, Word (*compar)(void*,void*) )
+void VG_(setCmpFnXA) ( XArray* xao, Int (*compar)(void*,void*) )
{
struct _XArray* xa = (struct _XArray*)xao;
vg_assert(xa);
return xa->usedsizeE-1;
}
-// Generic shell sort. Like stdlib.h's qsort().
-static void ssort( void* base, Word nmemb, Word size,
- Word (*compar)(void*, void*) )
-{
- Int incs[14] = { 1, 4, 13, 40, 121, 364, 1093, 3280,
- 9841, 29524, 88573, 265720,
- 797161, 2391484 };
- Int lo = 0;
- Int hi = nmemb-1;
- Int i, j, h, bigN, hp;
-
- bigN = hi - lo + 1; if (bigN < 2) return;
- hp = 0; while (hp < 14 && incs[hp] < bigN) hp++; hp--;
-
- #define SORT \
- for ( ; hp >= 0; hp--) { \
- h = incs[hp]; \
- for (i = lo + h; i <= hi; i++) { \
- ASSIGN(v,0, a,i); \
- j = i; \
- while (COMPAR(a,(j-h), v,0) > 0) { \
- ASSIGN(a,j, a,(j-h)); \
- j = j - h; \
- if (j <= (lo + h - 1)) break; \
- } \
- ASSIGN(a,j, v,0); \
- } \
- }
-
- // General case
- {
- char* a = base;
- char v[size]; // will be at least 'size' bytes
-
- #define ASSIGN(dst, dsti, src, srci) \
- VG_(memcpy)( &dst[size*(dsti)], &src[size*(srci)], size );
-
- #define COMPAR(dst, dsti, src, srci) \
- compar( &dst[size*(dsti)], &src[size*(srci)] )
-
- SORT;
-
- #undef ASSIGN
- #undef COMPAR
- }
- #undef SORT
-}
-
void VG_(sortXA) ( XArray* xao )
{
struct _XArray* xa = (struct _XArray*)xao;
vg_assert(xa);
vg_assert(xa->cmpFn);
- ssort( xa->arr, xa->usedsizeE, xa->elemSzB, xa->cmpFn );
+ VG_(ssort)( xa->arr, xa->usedsizeE, xa->elemSzB, xa->cmpFn );
xa->sorted = True;
}
/* Set the comparison function for this XArray. This clears an
internal 'array is sorted' flag, which means you must call sortXA
before making further queries with lookupXA. */
-extern void VG_(setCmpFnXA) ( XArray*, Word (*compar)(void*,void*) );
+extern void VG_(setCmpFnXA) ( XArray*, Int (*compar)(void*,void*) );
/* Add an element to an XArray. Element is copied into the XArray.
Index at which it was added is returned. Note this will be