Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!oberon!poisson.usc.edu!mlinar From: mlinar@poisson.usc.edu (Mitch Mlinar) Newsgroups: comp.lang.c Subject: Re: Another portable code question Message-ID: <3127@oberon.USC.EDU> Date: Tue, 30-Jun-87 14:56:05 EDT Article-I.D.: oberon.3127 Posted: Tue Jun 30 14:56:05 1987 Date-Received: Thu, 2-Jul-87 01:28:39 EDT References: <16673@cca.CCA.COM> <1763@ttrdc.UUCP> <16769@cca.CCA.COM> <1019@killer.UUCP> <225@sugar.UUCP> <4761@columbia.UUCP> Sender: nobody@oberon.USC.EDU Reply-To: mlinar@poisson.usc.edu.UUCP (Mitch Mlinar) Organization: University of Southern California, Los Angeles Lines: 40 In article <4761@columbia.UUCP> francus@cheshire.columbia.edu.UUCP (Yoseff Francus) writes: >In article <225@sugar.UUCP> peter@sugar.UUCP (Peter DaSilva) writes: >>> There it is in a nutshell, you really don't need the * unless the function >>> is declared int (**func)();, then you have pointer to pointer to a function >>> returning an integer. >> > >True ususally you want to pass the address of a strucuture. But what if >you change the values of the structure in the function, and DON'T want >to know about the changes after returning from the function???? > >Yoseff > Maybe I am not too familiar with the BIG frame architectures, but I am somewhat familiar with items of the Sun/uVaxII genre on down. The issue actually boils down to efficiency of structures and the simple fact is: Operations on static variables are ALWAYS faster than operations on auto variables. Now, this could just be a weakness in the uP instruction set or in the C compilers themselves, but I have yet to see the reverse. If you insist upon doing big structs as "auto" (stack) variables, then there is probably not much difference in speed - both passing a structure on the stack and copying to a local "auto" are slow. However, using stack operations on these machines is MUCH slower than passing a pointer and copying to a local static area. Secondly, MANY C compilers still do not support pushing anything other than simple arguments on the stack. Pushing whole structures is NOT portable in my book. As it turns out, almost ALL efficient C compilers handle static memory allocation much better than stack, too. So, you are not saving any REAL memory, although swap decreases. (Use of static is REQUIRED in our Sun 3.0 compilers here at USC, ANY auto variable over 16k-bytes in size gets lunched on the second recursive entry. It took me 2 weeks and head bashing with the also buggie dbxtool to figure this one out. By breaking things up to <16k-bytes and using static, the code zooms!) -Mitch