Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ucdavis!iris!lim From: lim@iris.ucdavis.edu (Lloyd Lim) Newsgroups: comp.sys.mac.programmer Subject: Re: C/LSC question Message-ID: <5834@ucdavis.ucdavis.edu> Date: 6 Nov 89 00:02:36 GMT References: <113@fornax.UUCP> Sender: uucp@ucdavis.ucdavis.edu Reply-To: lim@iris.ucdavis.edu (Lloyd Lim) Distribution: na Organization: U.C. Davis - Department of Electrical Engineering and Computer Science Lines: 48 In article <113@fornax.UUCP> mcdonald@fornax.UUCP (Ken Mcdonald) writes: >I'm writing a program in C which requires lots of calls to a small number >of very small functions. Because of the number of calls made to them, >these functions need to be as fast as possible; because of their size, >it would be quite worthwhile to have the code for these functions >inserted by the compiler directly wherever said function is called, >rather than having the compiler generate all the necessary stack >manipulations and JSRs involved in a "real" function call. Is there >any way to have C do this? Is there any way to have Lightspeed C (okay, >okay, THINK C, but I liked the old name better) do this? If not, is >there any good way to fake it? How about any bad way? Please don't >say I have to use the built in assembler, I'd prefer to avoid going down >to that level. I know you don't want to but as a reminder for those that don't mind assembly you can define a assembly language routine as inline. My only other suggestion would be to code it as a macro. Just put the same statements into a macro with a backslash at the end of each line and parentheses around each occurence of a macro argument. I've coded some of the more basic QuickDraw routines this way for slight speed increases. If you need local storage you can just put your statements in a block and declare some variables. Make sure you don't do anything funny in the macro calls which would be have side effects (e.g. SWAP(++a, ++b)). Here's a very simple example that I just made up and which seems to run through THINK's syntax checker ok. #define SWAP(x, y) \ { \ short temp; \ \ temp = (x); \ (x) = (y); \ (y) = temp; \ } void main(void); void main() { short a, b; SWAP(a, b); } +++ Lloyd Lim Internet: lim@iris.ucdavis.edu (128.120.57.20) Compuserve: 72647,660 US Mail: 146 Lysle Leach Hall, U.C. Davis, Davis, CA 95616