From owner-freebsd-arch Mon Jul 9 5:11:55 2001 Delivered-To: freebsd-arch@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 733DC37B405 for ; Mon, 9 Jul 2001 05:11:52 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id WAA16973; Mon, 9 Jul 2001 22:11:46 +1000 Date: Mon, 9 Jul 2001 22:09:41 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Dag-Erling Smorgrav Cc: arch@FreeBSD.ORG Subject: Re: -fno-builtin In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 9 Jul 2001, Dag-Erling Smorgrav wrote: > Bruce Evans writes: > > Unfortunately, the inline function version doesn't work right, at least > > on i386's: __builtin_strlen("foo") gives code that loads the constant > > result 3, but the inline strlen("foo") gives code that scans the string. > > What about a macro? > > #define strlen(s) __builtin_strlen(s) > > Would this work? I think it would work right except in broken code which "knows" that strlen isn't a macro, e.g.: size_t (*p)(const char *s) = strlen; and in non-broken code that avoids the macro, e.g.: size_t foo = (strlen)("123"); It only loses the optimization (if any) of using the builtin for non-broken code. This is only practical because there aren't many builtins for standard functions. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message