From owner-freebsd-performance@FreeBSD.ORG Thu Jun 26 14:04:36 2003 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9AD0437B401 for ; Thu, 26 Jun 2003 14:04:36 -0700 (PDT) Received: from stoneport.math.uic.edu (stoneport.math.uic.edu [131.193.178.160]) by mx1.FreeBSD.org (Postfix) with SMTP id F1CCE43FF2 for ; Thu, 26 Jun 2003 14:04:35 -0700 (PDT) (envelope-from djb-dsn-1056661507.36261@cr.yp.to) Received: (qmail 36262 invoked by uid 1017); 26 Jun 2003 21:05:07 -0000 Date: 26 Jun 2003 21:05:07 -0000 Message-ID: <20030626210507.36261.qmail@cr.yp.to> Automatic-Legal-Notices: See http://cr.yp.to/mailcopyright.html. From: "D. J. Bernstein" To: freebsd-performance@freebsd.org References: <20030626034138.88365.qmail@cr.yp.to> <3EFA9CA3.E616B54C@mindspring.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: Re: The dangers of replacing malloc() X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jun 2003 21:04:36 -0000 Terry proposed that I obtain the desired sequence of sbrk() calls by writing my own version of malloc(). I explained how this can destroy data; it isn't portable. Terry now makes the rather strange claim that POSIX guarantees the portability of the resulting programs---even though POSIX doesn't specify sbrk() or various other functions that I use. Terry Lambert writes: > Memeory allocation in the C library is *defined by standards*, > all of which require the ability to replace memory allocation and > freeing functions with equivalents, *as a unit*. You obviously aren't claiming that POSIX requires _all_ system functions to use a replacement malloc()/realloc()/free() library for allocation. That would prohibit sbrk() itself, for example. Are you trying to say that POSIX requires all _POSIX functions_ to do their memory allocation via malloc()/realloc()/free()? This has no relevance to anything I said. We aren't talking about programs that restrict themselves to the POSIX functions. > > Suppose the OS distributor decides that valloc() or xyzalloc() should do > > its own thing, rather than calling malloc(). > Then that OS distributor's OS no longer complies with standards. I already showed you code demonstrating that the Linux valloc() works this way. If, as you claim, there's a ``standard'' prohibiting the Linux behavior, then that ``standard'' is not useful for people who care about real-world portability. Anyway, I see no evidence supporting your claim. > If you are in non-compliance with the Intel Application Binary Interface > specification, you should expect to *minimally* be required to relink, > recompile, or have to modify your program source code, each time the > OS major version number changes If you link statically, upgrades can break your _source code_? Wow. I never realized that the -static option had such power. Will it also cause hair to grow on your palms? ---D. J. Bernstein, Associate Professor, Department of Mathematics, Statistics, and Computer Science, University of Illinois at Chicago