🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2267

Re: Bad Style Contest - We Have a Winner!

#2267
From: Konrad Schwarz
Date: Wed, 13 Mar 1996 12:40
39 lines
2400 bytes
Thad Smith writes:
|> Konrad Schwarz wrote:
|> >In article <4hqed0$1lc@solutions.solon.com>, kanze@gabi-soft.fr (J. Kanze) writes:
|> >|>     [Concerning alloca...]
|> >I: As far as I know, implementing alloca via the stack is trivial on
|> >I: any general-purpose CPU, but I am interested in hearing of counter examples.
|> >|> 
|> >|> So what do you do on machines that don't have a stack?
|> >
|> >General-purpose CPU's have stacks, at least in my book.  How do you
|> >implement C on machines that don't have a stack?
|> 
|> I am currently using such a beast for embedded firmware development on
|> an Intel 8051, which has a very small stack.  Allocation of auto
|> variables is done in two ways:
|> 
|> 1.  A software stack in external memory is allocated for functions
|> that are explicitly reentrant.  This is the exception because of the
|> overhead required to manage and use the software stack.
|> 
|> 2.  Fixed memory areas are allocated for non-reentrant functions.  The
|> loader generates the calling tree and figures out what functions are
|> never active concurrently.  Those functions can be allocated the same
|> area in memory.
|> 
|> Because the default is non-reentrant and a declaration is required for
|> reentrant functions, it isn't fully conforming.  Also, the linker
|> needs some additional information when function pointers are used to
|> know who calls whom.  In general, it seems to be a good adaptation of
|> C to the limited resources of the target processor.

[getting back to my point:]

Thus, a declaration for functions using alloca would not be out of line.
You could then either implement alloca on your comparatively slow
software stack, or using the even slower malloc/free (assuming you
have that---if not, the whole point is moot).

Konrad Schwarz
Technical Details
Message-ID: <4i6fo1$p1q@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4fjmdt$og4@solutions.solon.com> <4g27nn$qaj@solutions.solon.com> <4h2thl$1io@solutions.solon.com> <4hgc5l$99s@solutions.solon.com> <4i168k$g2@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz)
Newsgroups: comp.lang.c.moderated
Subject: Re: Bad Style Contest - We Have a Winner!
Date: 13 Mar 1996 06:40:33 -0600
Organization: TU Wien
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4i6fo1$p1q@solutions.solon.com>
References: <4fjmdt$og4@solutions.solon.com> <4g27nn$qaj@solutions.solon.com>  <4h2thl$1io@solutions.solon.com> <4hgc5l$99s@solutions.solon.com> <4i168k$g2@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com