Subject: re: a couple of low level questions
To: John Steele Scott <toojays@toojays.net>
From: matthew green <mrg@eterna.com.au>
List: port-sparc
Date: 01/06/2003 13:16:41
   
   On Mon, 6 Jan 2003 03:41, der Mouse wrote:
   > > The "SPARC Architecture Manual" proposes that code should call the
   > > ".udiv" routine (for example) which would then know whether to do the
   > > operation in software or hardware.  Does this happen on NetBSD?
   > > Whereabouts in the libc source can I see this?
   >
   > Based on a somewhat out-of-date source tree, see
   > usr/src/lib/libc/arch/sparc/gen/divrem.m4.  Other files in that
   > directory (mul.S, umul.S) handle multiplication.
   
   What I mean is, where can I see the code which detects whether to use the 
   library code (e.g. usr/src/libc/arch/sparc/gen/divrem.m4) or whether do do it 
   in hardware directly (e.g. with a udiv instruction)?


in -current, the dynamic linker does this.  libc has the normal (old)
div/mul/rem instructions, and libsparc_v8.so has the v8 (new) ones.
when a program starts up, ld.so.conf is read and it has this line in it:

	libc.so.12      machdep.cpu_arch        8:libsparc_v8.so.0,libc.so.12


which tells ld.so to look at the sysctl machdep.cpu_arch and if it
returns "8", to use the libsparc_v8.so.0 library before libc.so.12,
which means programs get the right functions on the each machine.


.mrg.