Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120823121824.GK27715@brightrain.aerifal.cx>
Date: Thu, 23 Aug 2012 08:18:24 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] Problem is static inline

On Wed, Aug 22, 2012 at 11:11:38PM -0700, idunham@...abit.com wrote:
> > I've been trying to get musl compatability patches for libuv merged
> > upstream, and I have it building, but there's one sticking point:
> > Upstream insists on using --std=c89 (I guess for portability to other
> > platforms).
> > This makes GCC choke on "long" in <bits/syscall.h>.
> I tried fixing it, and ended up finding that the issue was the "static
> inline" in the header.
> 
> For future reference:
> sed -e 's/static inline/#if __STDC_VERSION__ >=
> 199901L\ninline\n#endif\nstatic/g' -i <filename>
> is what I used.

I really dislike this type of fix because it potentially generates
much worse code on compilers where c89 is the default but not strictly
enforced (e.g. gnu89 is the default). (While inline is usually ignored
for inlining purposes, lots of gcc versions seem to avoid eliminating
dead static functions from the .o file unless they're also marked
inline.)

Is there an easy way to detect gcc's obnoxious strict c89 mode?

By the way, I also wonder if it wouldn't be easier to do:

#if [strict c89 mode]
#define inline
#endif

or

#if [strict c89 mode]
#define inline __inline
#endif

in headers that will use it, rather than repeating the #if over and
over for each use.

We're going to need something like this for adding restrict at a later
time, anyway...

Perhaps (but I also find this really ugly...) it would be better to
do it the other way around: use __inline in the headers, and do

#if __STDC_VERSION__ >= 199901L
#define __inline inline
#endif

This would support any C99 compiler that does not need __inline for
its own purposes separate from inline, as well as any compiler in
legacy mode that has __inline as an extension.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.