From owner-freebsd-hackers Wed Nov 6 16:23:47 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2AC1B37B404 for ; Wed, 6 Nov 2002 16:23:42 -0800 (PST) Received: from albatross.prod.itd.earthlink.net (albatross.mail.pas.earthlink.net [207.217.120.120]) by mx1.FreeBSD.org (Postfix) with ESMTP id 395A843E42 for ; Wed, 6 Nov 2002 16:23:30 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0019.cvx22-bradley.dialup.earthlink.net ([209.179.198.19] helo=mindspring.com) by albatross.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 189aS5-0003tC-00; Wed, 06 Nov 2002 16:23:17 -0800 Message-ID: <3DC9B202.A94F8C1F@mindspring.com> Date: Wed, 06 Nov 2002 16:21:22 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Marc Olzheim Cc: hackers@FreeBSD.ORG Subject: Re: /usr/src/ed/bin/re.c:99 References: <20021106164653.GA95733@stack.nl> <3DC9811E.35657731@mindspring.com> <20021106213000.GA42483@stack.nl> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Marc Olzheim wrote: > > In any case, your fears are unfounded, for the most part, since > > the FAQ entry you are referencing is not analogous to the construct > > you are trying to apply it to, anyway, and the FAQ fails to deal > > with many of these portability issues, too, since it assumes that > > the compiler is to spec.. > > If not in this FAQ, where else are things like this documented ? There > are also porgrammers who _do_ want to do it the portable/right way, but > if the documentation is nowhere to be found... > > Any pointers ? > > Thanks for the info, It's generally not well documented, except in the minds of people who have had to deal with porting software to many platforms, over time. Really, you are unlikely to need these skills, since unless you are working for a software vendor that has to run on what your customers have available, you won't encounter most of the issues (not really a problem, since no one writes for more than one OS these days). At one point in time, I wrote a small book called "C for Race Car Drivers" (it was a good title at the time), that tried to teach you how to code for speed (things like using "for(;;)" instead of "while(1)" to avoid the extra compare inside the loop, etc.), and for speed of porting to different UNIX platforms (do not use structure assignments, do not use unions, do not use bit fields, do not assume the sign of "char", where to use the "register" keyword, etc.). Optimizing compilers killed most of the utility of the book, which was mostly about "how to write C source code so that the compilers on these 40 platforms won't make a mistake, and so that the assembly code that's emitted is fast". If you are really interested in boundary conditions, ou would do well to get access to some rather different compilers, and compile up a lot of software, and see what doesn't compile, as well as what breaks outright. I don't know of any tools that will, for example, take the reference implementation for SLPv2, as written by Sun, and complain "sockaddr_in used without bzero/memset", or take the ACAP source code and complain "use of '::' construct without guard spaces will not compile in GCC prior to version 2.9.5", or "Space between 'while' and '(' will not compile on Wizard C on CTOS and BTOS platforms", or "Declaration of stack variable 'foo' in statement block not at top of function may scribble on registers in SAS (Lattice) C compiler", or the OpenSSL engine code and complain "Use of array index instead of pointer for descriptor entry references costs 48 out of 232 instructions in the common case, please recode", etc., if that's what you're asking. If you are just starting out, it's worthwhile to learn assembly language, and spend some time figuring out what assembly language will be emitted for certain types of source code: if a high level language user knows what their code is going to do, they will be able to write much better code. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message