[comp.lang.c] inlining

chris@mimsy.UUCP (Chris Torek) (07/02/88)

In article <20520@beta.lanl.gov> jlg@beta.lanl.gov (Jim Giles) writes:
>... C doesn't do [inline function expansion (as I've pointed out before).
>The C language definition (such as it is) doesn't allow it.

Not so.  It merely (?!) makes it difficult.  (Tartan Labs `tcc' has done
inlining of static functions whose address is not taken for quite some
time now.  That is not what is desired in this case, of course.)

>The proposed ANSI C will, I am led to believe, address this issue.

It does.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

friedl@vsi.UUCP (Stephen J. Friedl) (07/03/88)

In article <20520@beta.lanl.gov> jlg@beta.lanl.gov (Jim Giles) writes:
>... C doesn't do [inline function expansion (as I've pointed out before).
>The C language definition (such as it is) doesn't allow it.
 
Then in article <12279@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes:
> Not so.  It merely (?!) makes it difficult.

AT&T's 3B2 C compilers have done this since (at least) Issue 3.
There are flags to the optimizer that tell it how much expansion
it can do (time-vs-space tradeoffs), and there are assembler
macros as well.  Warning: inline expansion make disassembly quite
difficult :-).

     Steve

P.S. - anybody wanting info on how to invoke this on the 3B2 can
       send mail to me.

-- 
Steve Friedl     V-Systems, Inc. (714) 545-6442     3B2-kind-of-guy
friedl@vsi.com     {backbones}!vsi.com!friedl    attmail!vsi!friedl

Nancy Reagan on John DeLorean: "Just say snow"

poser@csli.Stanford.EDU (Bill Poser) (10/23/90)

To my knowledge, there is no way to determine at compile time whether
a particular function is actually being in-lined. Is that correct?
The discussion of fast string comparison made me think of this.
Suppose that we have a macro like Henry Spencer's STREQ:

#define STREQ(a,b) (*(a) == *(b) && strcmp((a),(b)) == 0)

Insofar as it is true that most comparisons fail on the first
character, this should speed things up over a simple call to strcmp.
However, that supposes that the call to strcmp is a real function call.
If strcmp is inlined, doing the extra comparison of the first characters
is likely to slow things down. This suggests that it would be nice to
be able to define STREQ differently depending on whether strcmp is
inlined, e.g.:

#if inlined(strcmp)
#define STREQ(a,b) strcmp((a),(b))
#else
#define STREQ(a,b) (*(a) == *(b) && strcmp((a),(b)) == 0)
#endif

						Bill Poser