Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120824023425.GV27715@brightrain.aerifal.cx>
Date: Thu, 23 Aug 2012 22:34:25 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: compatability: bits/syscall.h requires C99

On Thu, Aug 23, 2012 at 10:07:49PM -0400, Rich Felker wrote:
> > OTOH, s/inline/__inline/g is probably better/more universal, since
> > __inline is supported on some alternate compilers.
> 
> No, that reduces musl's public interface from portable C99 to
> compiler-specific crap.

OK, after discussion on IRC, the 2 options under consideration are:

#if __STDC_VERSION__ < 199901L && defined(__GNUC__)
#define inline __inline
#define restrict __restrict
#elif __STDC_VERSION__ < 199901L
#define inline
#define restrict
#endif

and

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

added near the top of headers that need to use inline and/or restrict.

The former version has the benefit that the "inline" and "restrict"
keywords can be used as-is later in the header, without any __
uglification. The latter version has the benefit that it's fewer lines
of spam, does not explicitly refer to "GNU C", and that it does not
break the gratuitously-C99-incompatible C89 programs like

int main(int inline, char **restrict) { }

I'm not sure if this last issue really matters; certainly there are
plenty unfixable ways C89 programs can fail on a C99 implementation,
like:

assert(strtod("0x1",0)==0);

I'm kind of leaning towards the latter but I'd like to hear some
opinions before a final change is made. Whichever way we decide, I
think it'll make it possible to go and retrofit "restrict" everwhere
it belongs in the headers, which will in turn lead to better code in
some parts of musl.

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.