public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Guidance please: static or extern __inline__
@ 2005-07-28 16:12 Kean Johnston
  2005-07-28 16:37 ` Gabriel Dos Reis
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Kean Johnston @ 2005-07-28 16:12 UTC (permalink / raw)
  To: gcc

Hi everyone,

I've run into a little SNAFU with my porting work. In my
fixincludes changes I changed all forms in the header files
of (using stat as an example):
   static int
   stat(const char *__p, stat_t *__s)
   {
     return _xstat(_STAT_VER, __p, __s);
   }

to:
   extern int stat (const char *__p, stat_t *__s);
   extern __inline__ int
   stat(const char *__p, stat_t *__s)
   {
     return _xstat(_STAT_VER, __p, __s);
   }

 From reading teh docs it seems like 'extern __inline__' was
the way to go for this type of header file trickery. However,
it caused a problem bootstrapping the compiler, becuase the
first stage doesn't have -O, so any calls to stat() actually
go to the library routine called stat(), which is an old,
deprecated stat that can't deal with, say, 32-bit inodes or
uid_t's etc, and various programs like fixincludes then
fail to stat files.

If things are compiled with -O, everything works fine,
becuase _xstat, which is what I really want, is called. If
I change the extern __inline__ to static __inline__, it
works correctly, even without optimization.

However, I *think* I like the semantics of 'extern inline'
better: use the inline version for the most part but if,
for example, you take the address of the function, use the
actual symbol stat(). But I see that most other fixincs
use static inline.

So my question is in two parts I guess:
a) Which is the better thing to use in a header file for
    this type of function mapping? static or extern inline?
b) If its extern inline, is there a way to force the inline
    expansion even when not using -O (and without command
    line options). I wouldn't want users to get nasty
    surprises if they just used 'gcc -o foo foo.c'.

Any advice and guidance greatly appreciated.

Kean

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2005-07-29 22:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-28 16:12 Guidance please: static or extern __inline__ Kean Johnston
2005-07-28 16:37 ` Gabriel Dos Reis
2005-07-28 17:49   ` Kean Johnston
2005-07-28 17:54 ` Daniel Jacobowitz
2005-07-28 18:32   ` Kean Johnston
2005-07-28 18:54     ` Daniel Jacobowitz
2005-07-28 19:05 ` Mike Stump
2005-07-28 19:43   ` Kean Johnston
2005-07-28 20:15     ` Gabriel Dos Reis
2005-07-28 20:33       ` Kean Johnston
2005-07-28 20:54     ` Mike Stump
2005-07-29 20:23       ` Kean Johnston
2005-07-29 21:18         ` Mike Stump
2005-07-29 22:03           ` Kean Johnston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).