From owner-freebsd-questions@FreeBSD.ORG Tue Feb 10 13:19:43 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E2C4B16A4CE for ; Tue, 10 Feb 2004 13:19:43 -0800 (PST) Received: from falcon.midgard.homeip.net (h201n1fls24o1048.bredband.comhem.se [212.181.162.201]) by mx1.FreeBSD.org (Postfix) with SMTP id BF22243D1F for ; Tue, 10 Feb 2004 13:19:42 -0800 (PST) (envelope-from ertr1013@student.uu.se) Received: (qmail 93345 invoked by uid 1001); 10 Feb 2004 21:19:40 -0000 Date: Tue, 10 Feb 2004 22:19:40 +0100 From: Erik Trulsson To: Bill Moran Message-ID: <20040210211940.GA93312@falcon.midgard.homeip.net> Mail-Followup-To: Bill Moran , FreeBSD-Questions References: <4029329E.1070406@potentialtech.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4029329E.1070406@potentialtech.com> User-Agent: Mutt/1.5.5.1i cc: FreeBSD-Questions Subject: Re: What does __restrict do? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2004 21:19:44 -0000 On Tue, Feb 10, 2004 at 02:35:58PM -0500, Bill Moran wrote: > In various places in the source code, for example, in the code for printf(): > > printf(char const * __restrict fmt, ...) > > I understand everything except __restrict. What does that mean/do? Is it > a FreeBSDism? (I can't find anything about it in any C docs) '__restrict' is a macro that expands to either 'restrict' if the compiler used supports that keyword, or to the empty string otherwise. 'restrict' is a standard C keyword since 1999, and is essentially used to inform the compiler that two pointers don't alias each other and that the compiler is therefore free to perform certain optimizations that otherwise might not be legal. It is just a hint to the compiler, and can always be removed (but not necessarily added) without changing the semantics of a program. Any C book that covers C99 should contain a more complete explanation. -- Erik Trulsson ertr1013@student.uu.se