Thu Jul 28 20:53:21 2011 UTC ()
Add scalbn{,f,l} for VAX.


(matt)
diff -r1.112 -r1.113 src/lib/libm/Makefile
diff -r0 -r1.1 src/lib/libm/arch/vax/n_scalbn.S

cvs diff -r1.112 -r1.113 src/lib/libm/Makefile (expand / switch to context diff)
--- src/lib/libm/Makefile 2011/07/26 16:10:16 1.112
+++ src/lib/libm/Makefile 2011/07/28 20:53:20 1.113
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.112 2011/07/26 16:10:16 joerg Exp $
+#  $NetBSD: Makefile,v 1.113 2011/07/28 20:53:20 matt Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -100,12 +100,13 @@
 .endif
 # end of m68k
 .elif (${MACHINE_ARCH} == "vax")
-#.PATH:	${.CURDIR}/arch/vax
+.PATH:	${.CURDIR}/arch/vax
 
 #NOIEEE_ARCH= n_infnan.S n_argred.S n_sqrt.S
 #ARCH_SRCS = n_atan2.S n_cabs.S n_cbrt.S n_support.S n_sincos.S n_tan.S
 # XXX - ripped out due to lack of the insn polyd in the Mariah chip,
 # and emulation code isn't written yet.
+ARCHS_SRCS = n_scalbn.S
 WARNS?=4
 .endif
 

File Added: src/lib/libm/arch/vax/n_scalbn.S
/*-
 * Copyright (c) 2011 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Matt Thomas of 3am Software Foundry.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include <machine/asm.h>
#include <sys/errno.h>

RCSID("$NetBSD: n_scalbn.S,v 1.1 2011/07/28 20:53:20 matt Exp $")

ENTRY(scalbnf, 0)
	cvtfd	4(%ap), %r0
	movl	8(%ap), %r2
	jr	1f

ALTENTRY(scalbnl)
ENTRY(scalbn, 0)
	movd	4(%ap), %r0
	movl	12(%ap), %r2

	/*
	 * First see if the result will be within bounds
	 */
1:	cmpl	%r2,$(256+55)
	jgeq	overflow
	cmpl	%r2,$-(256+55)
	jleq	underflow

	extzv	$7, $9, %r0, %r3	/* extract exponent */
	jneq	5f			/* 0 * N is still 0 */
	cmpw	%r3, $-256		/* is this a NAN? */
	jgtr	2f			/*    nope */
	ret

2:	movzbl	%r3, %r3		/* clear sign bit */
	addl2	%r2, %r3		/* add to exponent */
	jleq	underflow		/*   <= 0? */

3:	jbs	$8, %r3, overflow	/* did exponent overflow? */
	insv	$7, $8, %r3, %r0	/* replace exponent */
	ret

underflow:
	clrq	%r0			/* return 0.0 */
	jr	copysign		/* or mabye -0.0 */
overflow:
	pushl	$ERANGE			/* overflow */
	calls	$1, _C_LABEL(infnan)	/* possibly signal */
copysign:
	jbc	$15, 4(%ap), 5f		/* if clear, don't set sign-bit */
	bisw2	$0x8000, %r0		/* preserve sign-bit */
5:
	ret