Date: Mon, 9 Jul 2001 22:09:41 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Dag-Erling Smorgrav <des@ofug.org> Cc: arch@FreeBSD.ORG Subject: Re: -fno-builtin Message-ID: <Pine.BSF.4.21.0107092158160.87629-100000@besplex.bde.org> In-Reply-To: <xzpr8vqtjwh.fsf@flood.ping.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
On 9 Jul 2001, Dag-Erling Smorgrav wrote: > Bruce Evans <bde@zeta.org.au> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0107092158160.87629-100000>