🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c++
Article #77

Re: further C++ fix opportunities

#77
From: Bob Mabee, Software
Date: Fri, 07 Mar 1986 10:48
22 lines
1921 bytes
In article <34200001@orstcs.UUCP> nathan@orstcs.UUCP (nathan) writes:
>The problem of returning structures from functions has always
>been one of where to put the structure.  It could easily go on
>stack, except that the calling routine would have to allocate
>space for it; but then if the routine was misdeclared, local
>variables of the caller could get trashed.  (In C, this was
>something to worry about.)  Steve Johnson, author of "pcc",
>"resolved" this by reserving a static structure for the
>routine, and returning a pointer to it.
>	Nathan C. Myers
>	{hplabs!hp-pcd | tektronix}!orstcs!nathan OR  nathan@oregon-state

You don't need to put the structure on the stack to get reentrancy.
Think of this return value as like a number in a register, just too
large to fit in the one or two registers normally allowed for return
values.  All you need is a virtual register: an agreed-upon place in
memory (static) which all interrupt paths are bound to save and restore
just like the real registers.  Most linkers have the ability to allocate
such a data object with the maximum size of any reference.  If the linker
will not provide the size of that object, however, you may need to create
a convention such as putting the size of the current value in another
known variable.
Technical Details
Message-ID: <687@frog.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!cybvax0!frog!rfm
References: <34200001@orstcs.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site frog.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!cybvax0!frog!rfm
From: rfm@frog.UUCP (Bob Mabee, Software)
Newsgroups: net.lang.c++
Subject: Re: further C++ fix opportunities
Message-ID: <687@frog.UUCP>
Date: Fri, 7-Mar-86 05:48:35 EST
Article-I.D.: frog.687
Posted: Fri Mar  7 05:48:35 1986
Date-Received: Sun, 9-Mar-86 09:28:51 EST
References: <34200001@orstcs.UUCP>
Reply-To: rfm@frog.UUCP (PUT YOUR NAME HERE)
Organization: Superfrog Heaven [ CRDS, Framingham MA ]
Lines: 21