Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Sep 2002 21:08:42 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        "David E. O'Brien" <obrien@FreeBSD.org>
Cc:        cvs-committers@FreeBSD.org, <cvs-all@FreeBSD.org>
Subject:   Re: cvs commit: src/contrib/gcc/config freebsd-spec.h
Message-ID:  <20020913203222.U9654-100000@gamplex.bde.org>
In-Reply-To: <200209121605.g8CG5vVT091346@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 12 Sep 2002, David E. O'Brien wrote:

> obrien      2002/09/12 09:05:57 PDT
>
>   Modified files:
>     contrib/gcc/config   freebsd-spec.h
>   Log:
>   Try to detect support for the `long long' type so that ANSI-C[89] clean
>   code will know not to try to use `long long'.
>   Unfortunately the GCC spec parser will not allow us to properly detect the
>   "iso9899:1990" and "iso9899:199409" forms of the acceptable -std= arguments,
>   because of the ':' in the -std argument.  :-(  I have left them in the spec
>   as a place holder in hopes someone knows a way to make the detection of
>   them work.
>
>   Desired by:     wollman

Not wanted by:	bde.

Whether reasonably non-archaic versions of gcc support the long long
mistake is very easy to determine using existing macros.  There are 3
cases:
(1) long long supported because the compiler is a non-archaic version of
    gcc without any standards restrictions:
	_GNUC_ >= 2 && !defined(__STRICT_ANSI__)
(2) long long not supported because the compiler is gcc restricted to c89:
	defined(__GNUC__) && defined(__STRICT_ANSI__) && \
	    __STDC_VERSION__ < 199901
(3) long long supported because the compiler is gcc-3 or any other compiler
    that supports c99:
	    __STDC_VERSION__ >= 199901

Determining whether compilers other than non-archaic versions of gcc
and tools like lint support long long is not so easy.  I think we
should use the simple binary condition _STDC_VERSION__ >= 199901.

The code for this is much simpler than its description:

%%%
Index: cdefs.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/cdefs.h,v
retrieving revision 1.59
diff -u -2 -r1.59 cdefs.h
--- cdefs.h	15 Jul 2002 16:44:07 -0000	1.59
+++ cdefs.h	13 Sep 2002 11:01:06 -0000
@@ -134,6 +134,5 @@
 #endif

-/* XXX: should use `#if __STDC_VERSION__ >= 199901'. */
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
+#if __GNUC__ >= 2 && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
 #define	__LONG_LONG_SUPPORTED
 #endif
%%%

Using the new feature in the specs would not affect this in any way unless
it were used (then it would add a redundant condition).  An ifdef like the
above is still needed to handle compilers other than hacked versions of gcc,
including all old and unhacked gcc ports.

Other C99 features like __func and restrict require slightly different
and maybe messier ifdefs.  I think we should use the simple c99 condition
for these and not provide special support for them with old versions of
gcc like we do now.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020913203222.U9654-100000>