[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[opendx-dev] qsort.c again. Basic type redefinitions and stack overflow???





Greg and others,

Qsort.c in src/exec/libdx seems to be giving problems:

My compilers complain about basic type redefinition errors of
QUICSORT_LOCAL. On Windows MVSC gives errors,
on Linux KAI and Fujitsu compilers complain with errors... only GCC, seems
to ignore it with warnings only.

you have:

static void QUICSORT_LOCAL(TYPE *base,TYPE *max);

static void
QUICKSORT(TYPE *base, int n)
{
    register TYPE *i;
    register TYPE *j;
    register TYPE *hi;
    register TYPE *lo;
    TYPE swaptmp;
    TYPE *min;
    TYPE *max;
----<snip>----

   max = base + n;
    if (n >= THRESHOLD)
    {
	QUICKSORT_LOCAL(base, max);
	hi = base + THRESHOLD;
    }
    else
    {
	hi = max;
-------------------------------------------
Then redefined the QUICKSORT_LOCAL with different type in:

/*
 * perform quicksort partitioning
 */

static void
QUICKSORT_LOCAL(TYPE *base, TYPE *max)
{
    register TYPE *i;
    register TYPE *j;
    register TYPE *t;
    TYPE *mid;
    TYPE *tmp;
    TYPE swaptmp;
    int         lo, hi;
--------<snip>----------

	{
	    if (lo >= THRESHOLD)
		QUICKSORT_LOCAL(base, j);
	    base = i;
	    lo = hi;
	}
	else /* hi > lo */
	{
	    if (hi >= THRESHOLD)
		QUICKSORT_LOCAL(i, max);
	    max = j;
	}


Also: I am getting stack overflow on opening very large *.net files.  On
Windows MSVC
and on Linux KAI and Fujitsu Debugs points to following lines in qsort.c

    /*
     * sort using insertion sort
     */
    for (min = base; (hi = ++min) < max;)
    {
	while (hi--, GT(hi, min))
	     continue ;

	if (++hi != min)
	{
	    swaptmp = *min;
	    for (i = j = min; --j >= hi; i = j)
		*i = *j;
	    *i = swaptmp;
	}
    }

Any suggestions from any one?

Suhaib