From owner-freebsd-arch@FreeBSD.ORG Sat Jun 14 15:45:27 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ECCE737B401 for ; Sat, 14 Jun 2003 15:45:26 -0700 (PDT) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4C38E43FAF for ; Sat, 14 Jun 2003 15:45:26 -0700 (PDT) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 7461A5310; Sun, 15 Jun 2003 00:45:24 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Alexander Leidinger References: <20030614183544.051c7a57.Alexander@Leidinger.net> From: Dag-Erling Smorgrav Date: Sun, 15 Jun 2003 00:45:23 +0200 In-Reply-To: <20030614183544.051c7a57.Alexander@Leidinger.net> (Alexander Leidinger's message of "Sat, 14 Jun 2003 18:35:44 +0200") Message-ID: User-Agent: Gnus/5.1001 (Gnus v5.10.1) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii cc: freebsd-arch@freebsd.org Subject: Re: unbreaking alloca X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Jun 2003 22:45:27 -0000 Alexander Leidinger writes: > Please also add a comment about the actual pitfalls (alloca function not > possible to implement on AMD64, ... in libc and broken on IA32). How's this? @@ -222,7 +222,23 @@ extern void (*_malloc_message)(const char *, const char *, const char *, const char *); -void *alloca(size_t); /* built-in for gcc */ +/* + * The alloca() function can't be implemented in C, and on some + * platforms it can't be implemented at all as a callable function. + * The GNU C compiler provides a built-in alloca() which we can use; + * in all other cases, provide a prototype, mainly to pacify various + * incarnations of lint. On platforms where alloca() is not in libc, + * programs which use it will fail to link when compiled with non-GNU + * compilers. + */ +#ifdef __GNUC__ +#ifndef alloca +#define alloca(sz) __builtin_alloca(sz) +#endif +#else +void *alloca(size_t); +#endif + __uint32_t arc4random(void); void arc4random_addrandom(unsigned char *dat, int datlen); DES -- Dag-Erling Smorgrav - des@ofug.org