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

Re: [MiNT] gcc 4.2.2 compile error



MiKRO a wrote :
OK, after some look into mintlib & freemint sources I've got it.

Great job !
There is probably something wrong in your FreeMiNT configuration.

In order to understand what happens, I wrote a tiny program called 'prstack' which displays the some values related to the stack.

I built it using my cross-tools on Cygwin. I recompiled the latest MiNTLib version from CVS, with all pending patches not already committed (especially the one which force _stksize in the .data segment - my version, not Alan's)

I tested it with Steem Engine (TOS 1.62 with 4MB of RAM) and with ARAnyM. Note that in the MINT.CNF of ARAnyM, I have TPA_INITIALMEM=4096, but it doesn't seem to do anything...

Results with TOS, default stack size:
  basepage = 0x0001dc42
minimal sp = 0x00037006  end of the .bss segment
current sp = 0x0003cfb2  24492 bytes free
maximal sp = 0x0003d01e  end of the Mshrinked TPA
   TPA end = 0x003f8000  value from the basepage
  _stksize = 0x00006000  24576 bytes
 _heapbase = 0x00000000

Results with ARAnyM, default stack size:
  basepage = 0x02312000
minimal sp = 0x0232b3c4  end of the .bss segment
current sp = 0x023313d8  24596 bytes free
maximal sp = 0x02331444  end of the Mshrinked TPA
   TPA end = 0x0272c000  value from the basepage
  _stksize = 0x00006000  24576 bytes
 _heapbase = 0x00000000

Results with TOS, stack set to 3M:
  basepage = 0x0001dc56
minimal sp = 0x0003701a  end of the .bss segment
current sp = 0x00336fc6  3145644 bytes free
maximal sp = 0x00337032  end of the Mshrinked TPA
   TPA end = 0x003f8000  value from the basepage
  _stksize = 0x00300000  3145728 bytes
 _heapbase = 0x00000000

Results with ARAnyM, stack set to 3M:
  basepage = 0x02312000
minimal sp = 0x0232b3c4  end of the .bss segment
current sp = 0x0262b3d8  3145748 bytes free
maximal sp = 0x0262b444  end of the Mshrinked TPA
   TPA end = 0x0272c000  value from the basepage
  _stksize = 0x00300000  3145728 bytes
 _heapbase = 0x00000000

As you see, all the values are exactly what could be expected.
There is absolutely no problem.

MiKRO: try to compile prstack.c, and look at the results with the different configurations. There must be something wrong somewhere.

Good luck.

--
Vincent Rivière
/* prstack.c
 * By Vincent Riviere, 2007
 * Display the current stack values
 */

#include <stdio.h>
#include <mint/basepage.h>

extern long _stksize;
extern void *_heapbase;
extern unsigned long _PgmSize;

int main(int argc, char* argv[])
{
    unsigned long cursp;
    unsigned long minsp;
    unsigned long maxsp;

    /* Get current stack address. */
    asm ("move.l %%sp,%0"
	:"=g"(cursp)	/* outputs */
    );

    /* The minimum stack address is the end of the .bss segment. */
    minsp = (unsigned long)(_base->p_bbase + _base->p_blen);

    /* The maximum stack address is the end of the shrinked TPA. */
    maxsp = (unsigned long)_base + _PgmSize;

    printf ("  basepage = 0x%08lx\n", (unsigned long)_base);
    printf ("minimal sp = 0x%08lx  end of the .bss segment\n", minsp);
    printf ("current sp = 0x%08lx  %ld bytes free\n", cursp, (long)(cursp - minsp));
    printf ("maximal sp = 0x%08lx  end of the Mshrinked TPA\n", maxsp);
    printf ("   TPA end = 0x%08lx  value from the basepage\n", (unsigned long)_base->p_hitpa);
    printf ("  _stksize = 0x%08lx  %ld bytes\n", (unsigned long)_stksize, _stksize);
    printf (" _heapbase = 0x%08lx\n", (unsigned long)_heapbase);

    return 0;
}