www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/04/24/01:13:08

Date: Mon, 24 Apr 2000 08:44:59 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Martin Str|mberg <ams AT ludd DOT luth DOT se>
cc: DJGPP-WORKERS <djgpp-workers AT delorie DOT com>
Subject: Re: restrict
In-Reply-To: <200004232143.XAA24489@father.ludd.luth.se>
Message-ID: <Pine.SUN.3.91.1000424084439.12476I-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 23 Apr 2000, Martin Str|mberg wrote:

> According the the gcc manual restrict is only available if
> "-flang-isoc9x" option is given to gcc. And that seems to be a
> documentation bug, you need to use "-std=iso9899:199x according to
> <http://gcc.gnu.org/ml/gcc-bugs/1999-11n/msg00793.html>.

Yes, this is a known bug.

> So I sueggest we use __restrict__ instead of restrict which seems to
> be recognised always (I guess, from the documentation).

What docs says __restrict__ is always recognised?  And what does
``always'' mean here?

> So how far back was __restrict__ supported?

The following example (from the C99 standard) doesn't compile with GCC
2.7.2.1:

    void foo (int n, int * __restrict__ p, int * __restrict__ q)
    {
      while (n-- > 0)
	*p++ = *q++;
    }

The #ifdef magic below (lifted from the GCC bug-reporting list) seems
to imply that __restrict__ is only supported in GCC 2.91 and later.

> Or can we demand that users of DJGPP v. 2.04 use gcc 2.95.2?

I would like to avoid requiring specific versions of GCC, unless we
absolutely must.

> Or do you know/suggest a different approach (some magic #define
> somewhere, perhaps)?

I suggest the following:

    #if __STDC_VERSION__ >= 199901
    #elif __GNUC__ >= 2 && __GNUC_MINOR__ >= 91
    #define restrict __restrict__
    #else
    #define restrict
    #endif

In a recent discussion, this seems to have got a semi-formal blessing
of at least one GCC maintainer.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019