From owner-freebsd-current@FreeBSD.ORG Sun Jun 13 12:07:28 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8B37F1065670 for ; Sun, 13 Jun 2010 12:07:28 +0000 (UTC) (envelope-from ticso@cicely7.cicely.de) Received: from raven.bwct.de (raven.bwct.de [85.159.14.73]) by mx1.freebsd.org (Postfix) with ESMTP id E90728FC21 for ; Sun, 13 Jun 2010 12:07:27 +0000 (UTC) Received: from mail.cicely.de ([10.1.1.37]) by raven.bwct.de (8.13.4/8.13.4) with ESMTP id o5DC7QqN001024 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 13 Jun 2010 14:07:26 +0200 (CEST) (envelope-from ticso@cicely7.cicely.de) Received: from cicely7.cicely.de (cicely7.cicely.de [10.1.1.9]) by mail.cicely.de (8.14.3/8.14.3) with ESMTP id o5DC7NDp050702 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 13 Jun 2010 14:07:23 +0200 (CEST) (envelope-from ticso@cicely7.cicely.de) Received: from cicely7.cicely.de (localhost [127.0.0.1]) by cicely7.cicely.de (8.14.2/8.14.2) with ESMTP id o5DC7NgJ001826; Sun, 13 Jun 2010 14:07:23 +0200 (CEST) (envelope-from ticso@cicely7.cicely.de) Received: (from ticso@localhost) by cicely7.cicely.de (8.14.2/8.14.2/Submit) id o5DC7N1Z001825; Sun, 13 Jun 2010 14:07:23 +0200 (CEST) (envelope-from ticso) Date: Sun, 13 Jun 2010 14:07:22 +0200 From: Bernd Walter To: Matthias Andree Message-ID: <20100613120722.GZ87112@cicely7.cicely.de> References: <20100611162118.GR39829@acme.spoerlein.net> <867hm5tl6u.fsf@ds4.des.no> <20100612153526.GA3632@acme.spoerlein.net> <20100612163208.GS87112@cicely7.cicely.de> <864oh86tnl.fsf@ds4.des.no> <20100612225216.GT87112@cicely7.cicely.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD cicely7.cicely.de 7.0-STABLE i386 User-Agent: Mutt/1.5.11 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED=-1, BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 autolearn=ham version=3.3.0 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on spamd.cicely.de Cc: "freebsd-current@freebsd.org" Subject: Re: Cleanup for cryptographic algorithms vs. compiler optimizations X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: ticso@cicely.de List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jun 2010 12:07:28 -0000 On Sun, Jun 13, 2010 at 12:44:03PM +0200, Matthias Andree wrote: > Am 13.06.2010, 00:52 Uhr, schrieb Bernd Walter: > > >>In more general terms, the compiler is allowed to make any changes it > >>likes to the program as long as the end result behaves exactly like it > >>would if it hadn't been changed. This is called the "as if" rule. For > >>instance, if you call printf() or fprintf() with a format string that > >>does not contain any conversion specifiers, gcc will call gets() or > >>fgets() instead. > > > >Amazing - this is one of the things which can get nasty if you try some > >kind of microtuning. > >Recently I had to implement my own atoi on a controller because using the > >library one magically had blown my RAM usage by 1k on a controller with > >just 8k RAM. > > There are certain compiler flags to affect that. For GCC, -Os is one > (which doesn't necessarily work in FreeBSD though, on some versions the > compiler would go into unterminated loop, leak memory and ultimately fail > with OOM), flags to tell the compiler that the implementation is > freestanding, and attributes to select builtins and the likes. I know -Os - the problem was more complicated and at linker stage. It was because atoi sucked more hardly related library parts in, of which one had 1k static RAM requirement. Quite surprising outcome from using atoi. But this isn't related to FreeBSD at all, since it happened with newlibc. -- B.Walter http://www.bwct.de Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.