help-bison
[Top][All Lists]
Advanced

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

Re: fixed size stack


From: Claudio Eterno
Subject: Re: fixed size stack
Date: Thu, 19 Jul 2012 09:26:23 +0200

Hi, probably(but I'll be sure in next days) one possible solution is:
#define YYINITDEPTH 100
#define YYMAXDEPTH  0
#define YYSTACK_ALLOC(size) 0

in the code generated:
----------------------------------------------------------------
# ifndef YYSTACK_RELOCATE
      goto yyexhaustedlab;
# else
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;

      {
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
 goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss);
YYSTACK_RELOCATE (yyvs);

#  undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
 YYSTACK_FREE (yyss1);
      }
# endif
----------------------------------------------------------------
the row 'if (YYMAXDEPTH <= yystacksize)' will generate always a
negative sentence. So the code after the 'if' will be removed by
optimizer..
Claudio

2012/7/18 Luca <address@hidden>
>
> As a compiler and firmware writer, I think this is a very interesting issue.
>
> First, take into account to use the bison macro YYMALLOC and YYFREE (see 
> bison output c file).
> Then I can suggest to use a tiny and efficient memory manager like this one:
> http://eli.thegreenplace.net/2008/10/17/memmgr-a-fixed-pool-memory-allocator/
> I used it on a uC with 96 KB of RAM, without bison but with a RTOS running 
> many task: a TCP-IP task to manage a webserver, a SPI task, many tasks for 
> UART and also with two proprietary interpreters. Moreover, the library allows 
> a printout of allocation statistics that will help to understand how the 
> memory is used.
>
> Luca
>
>
>
> On 17/07/2012 10:00, Claudio Eterno wrote:
>>
>> Hi folks,
>> I'm writing here due to some configuration problems on bison.
>> My question: I would like to use bison for an embedded application (based
>> on a uC with only 16kb of ram a 256 kb of flash). Due to the limited
>> resources reasons and also I know exactly the maximum size of
>> the necessary stack, I don't want to occupy the memory with me unuseful
>> library functions (like malloc for example). Anyway, is this possible to
>> remove the alloc/malloc/realloc functions during compilation?
>> Thank you,
>> Claudio
>>
>



--
Claudio Eterno
via colle dell'Assietta 17
10036 Settimo Torinese (TO)
Linux user n. 499785 registered on linuxcounter.net



reply via email to

[Prev in Thread] Current Thread [Next in Thread]