From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcda7,71c35a0e73c110d5 X-Google-Attributes: gidfcda7,public X-Google-Thread: 10872d,71c35a0e73c110d5 X-Google-Attributes: gid10872d,public X-Google-Thread: 1164f8,71c35a0e73c110d5 X-Google-Attributes: gid1164f8,public X-Google-Thread: fa528,71c35a0e73c110d5 X-Google-Attributes: gidfa528,public X-Google-Thread: 11035d,71c35a0e73c110d5 X-Google-Attributes: gid11035d,public X-Google-Thread: 115614,71c35a0e73c110d5 X-Google-Attributes: gid115614,public X-Google-ArrivalTime: 2003-08-08 16:12:04 PST Path: archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!newsfeed.online.be!newsfeed.vmunix.org!newspeer1-gui.server.ntli.net!ntli.net!newsfep2-win.server.ntli.net.POSTED!53ab2750!not-for-mail Message-ID: <3F342E36.C633A7AC@ntlworld.com> From: "Dr. David Kirkby" X-Mailer: Mozilla 4.8 [en] (X11; U; SunOS 5.9 sun4u) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.sys.hp.hpux,comp.unix.tru64,comp.sys.dec,comp.unix.solaris,comp.sys.sgi.admin,comp.unix.aix Subject: Re: Free UNIX for non-commerical use. References: <3F233C74.4F4C3BAB@ntlworld.com> <3F23A0AC.4BF58D49@hotmail.com> <3F247C24.8FAA50A6@hotmail.com> <3F2B7E75.AE80EACE@hotmail.com> <3F330255.B90F491B@ntlworld.com> <3F336F45.400A411A@ntlworld.com> <3F3400B7.C644FA19@ntlworld.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit Date: Sat, 09 Aug 2003 00:11:50 +0100 NNTP-Posting-Host: 62.255.96.204 X-Complaints-To: abuse@ntlworld.com X-Trace: newsfep2-win.server.ntli.net 1060384316 62.255.96.204 (Sat, 09 Aug 2003 00:11:56 BST) NNTP-Posting-Date: Sat, 09 Aug 2003 00:11:56 BST Organization: ntlworld News Service Xref: archiver1.google.com comp.sys.hp.hpux:30232 comp.unix.tru64:10583 comp.sys.dec:16648 comp.unix.solaris:165334 comp.sys.sgi.admin:18978 comp.unix.aix:54560 Tony 'Nicoya' Mantler wrote: > : Em, but a lot of packages for which the source is available, are not > : distributed by Debian. > > I rarely find myself in want of a package that isn't distributed in Debian. > They're very good about including everything and the kitchen sink. I was not aware of that. Have they got my finite difference package for computing the properties of transmission lines? http://atlc.sourceforge.net/ It is in NetBSD http://wuarchive.wustl.edu/mirrors/NetBSD/NetBSD-current/pkgsrc/cad/atlc/README.html (a very old version) and someone has produced a binary for a Sony Playstation 2. I've never heard from a user running it on a Sony Playstation 2, but apparently it has been built. I did have a problem on Debian SPARC http://www.mail-archive.com/autoconf@gnu.org/msg08981.html but by testing that problem was found and resolved. > : > 2) The programmer who wrote the SMART tools woke up one > : > morning and said "I want to get SMART data on my linux box", > : > not "I want to get SMART data on any unix box". > : > : Exactly. That is what I see is wrong with a lot of Linux development. > > That's why it's 'linux development', not 'unix development'. ;) Yes, that is a shame. > : Sure it is easier, if you consider making it publicly available, it > : would be helpful if you do put a bit of effort in at the beginning > : thinking about portability. > > No doubt it would be nice, but it's not always practical > to write something portably on the first version. No, but having thought about portability issues, you can then make it a lot easier for others, with little work for yourself, by thinking about portability issues and then doing your best to remove them. > : autoconf does help a lot. You still need to think about it. The other > : day I changed one of my variables from type 'long long' to 'double' > : when I realised that I could achieve exactly the same result using a > : more portable data type. > > I hope you're not substituting a floating point type for an integer type. Yes I am substituting a floating point type for an integer type! In this instance I think that is a good idea, as it avoids the use of a 'long long' on 32-bit systems, which would otherwise be needed. I could write my own 64-bit integer multiplication routine (or even link with one that exists), but I feel the use of a double in this instance was okay. I might be wrong, but at least I have given it some thought, which is more than seems to happen with many people who only develop only on Linux. I needed to find the ram in the system in Mb on Solaris (other methods are used on other systems), so only Solaris is considered. Any Solaris system will have ram which is an integer multiple of a Mb. I first determine the number of pages of ram: sysconf(_SC_PHYS_PAGES); /* returns pages as a long */ and put that in a double. Next I determine the size of the pages in bytes sysconf(_SC_PAGESIZE); /* returns page size as a long */ These are multiplied together, which will overflow a long if the machine has more than 2 Gb of ram. Next it gets divided by the number of bytes per Mb, and cast to the nearest long. Ignoring the error checks, the code looks something like this: #define BYTES_PER_MB 1048576 double ram; long memory_in_mb; ram=(double) sysconf(_SC_PAGESIZE); /* size of page in bytes */ ram*= (double) sysconf(_SC_PHYS_PAGES); /* ram now in bytes */ ram=ram/BYTES_PER_MB; /* convert to Mb, as a double */ memory_in_mb=(long) (ram + 0.5); /* cast to nearest long. */ before adding 0.5 and casting to a long, the number of Mb is likely to be non-exact due to rounding errors. But the error should never be as much as 0.5. Even on a system with 1 Tb of RAM, the precision only needs to be about 6 significant digits for this to be a valid assumption. I eventually cast to a long again, rounding to the nearest integer value. I think that is acceptable. It works okay on a Solaris box with 4 Gb of RAM, as it does on several others with smaller amounts of ram. The same principle has been tested on several other non-Solaris machines, all of which result in the exact right number. You might not like the above code. But it works, and is more portable than trying to use 'long long'. So I have: a) Realised using 'long long' is not portable. b) Thought about ways around the problem. c) Determined for any practical system it should work. d) Tested my solution and verified it works on several Solaris machines, which is all this needs to work on. e) Tested the same principle (but slightly different code) on several other non-Solaris machines and verified it is okay. Whether or not the above code is good or bad is to a certain extent immaterial. I have at least thought about the issue and tried to keep it portable. That is something that a lot of people who only develop on Linux and gcc seem to ignore. Hence I feel introducing people to other compilers, and systems is good for computing as a whole. -- Dr. David Kirkby, Senior Research Fellow, Department of Medical Physics, University College London, 11-20 Capper St, London, WC1E 6JA. Tel: 020 7679 6408 Fax: 020 7679 6269 Internal telephone: ext 46408 e-mail davek@medphys.ucl.ac.uk