NetBSD Problem Report #3879

Received: (qmail 1630 invoked from network); 17 Jul 1997 17:31:20 -0000
Message-Id: <199707171731.CAA01096@cs-yuugao.cs.sist.ac.jp>
Date: Fri, 18 Jul 1997 02:31:18 +0900
From: Hiroshi HORIMOTO <horimoto@cs-aoi.cs.sist.ac.jp>
Sender: horimoto@cs-yuugao.cs.sist.ac.jp
To: gnats-bugs@gnats.netbsd.org
Subject: Contribution: atoi(3) for m68k.
X-Send-Pr-Version: 3.95

>Number:         3879
>Category:       port-m68k
>Synopsis:       Contribution: atoi(3) for m68k.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    is
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 17 10:35:04 +0000 1997
>Closed-Date:    Sun Oct 27 20:21:40 +0000 2002
>Last-Modified:  Sun Oct 27 20:21:40 +0000 2002
>Originator:     Hiroshi Horimoto
>Release:        07/17/97
>Organization:
Shizuoka Institute of Science and Technology, Japan.
>Environment:
	atoi(3) in libc.a for all m68k-based machines.

System: NetBSD silpheed.faf.mil 1.2G NetBSD 1.2G (SILPHEED) #25: Thu Jul 17 04:53:18 JST 1997 root@silpheed.faf.mil:/usr/src/sys/arch/x68k/compile/SILPHEED x68k


>Description:
	I wrote assembler version of atoi(3) (and atol(3)) for m68k.
	I contribute it. Please use it if you like.
>How-To-Repeat:
>Fix:
	This is src/lib/libc/arch/m68k/stdlib/atoi.S.
	BTW, the codes of abs(3) and labs(3) are identical.
	Why don't you integrate them into one file `abs.S' ?
BEGIN -- cut here
#include <machine/asm.h>

#define ERANGE	34

#ifndef _REENTRANT
	.extern	_errno
#else
	.extern	___errno
#endif

ENTRY(atoi)
ENTRY(atol)
	movl	d2,sp@-
	movl	sp@(8),a0
Lskipsp:
	movq	#-9,d1
	addb	a0@+,d1
	cmpb	#23,d1		| space ?
	jeq	Lskipsp
	cmpb	#5,d1		| or something like ?
	jcs	Lskipsp
	movq	#0,d0		| accumulator
	movl	#214748364,a1	| limits (2147483640+7)
	movq	#7,d2
	cmpb	#34,d1		| plus ?
	jeq	Lgetnum
	cmpb	#36,d1		| minus ?
	jeq	Lnegative
	subqw	#1,a0		| re-fetch this char.
	jra	Lgetnum

Lnegative:
	movq	#-8,d2		| limit (-(2147483640+8))
	negb	d2		| d2 = 0xffffff08
	jra	Lgetnum

Lchkoverflow:
	cmpl	a1,d0
	jcs	Lsafe
	jhi	Loverflow
	cmpb	d2,d1
	jhi	Loverflow	| jcc ?
Lsafe:
	addl	d0,d0		| d0 = d0 * 10 + d1
	addl	d0,d1
	addl	d0,d0
	addl	d0,d0
	addl	d1,d0
Lgetnum:
	movq	#48,d1
	negb	d1
	addb	a0@+,d1
	cmpb	#10,d1
	jcs	Lchkoverflow
	tstl	d2
	jpl	0f
	negl	d0
0:
	movl	sp@+,d2
	rts

Loverflow:
#ifndef _REENTRANT
	movq	#ERANGE,d0
	movl	d0,_errno
#else
	jbsr	___errno	| d2 is not modified.
	movl	d0,a0
	movq	#ERANGE,d0
	movl	d0,a0@
#endif
	movl	#0x7fffffff,d0
	tstl	d2
	jpl	1f
	addql	#1,d0
1:
	movl	sp@+,d2
	rts
END -- cut here
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->jtc 
Responsible-Changed-By: mycroft 
Responsible-Changed-When: Thu Oct 9 22:39:30 PDT 1997 
Responsible-Changed-Why:  
jtc is our 68k optimization guru.   
Responsible-Changed-From-To: jtc->port-m68k-maintainer 
Responsible-Changed-By: fair 
Responsible-Changed-When: Wed Mar 17 14:15:53 PST 1999 
Responsible-Changed-Why:  
JTC has timed out, and these really should be looked at; speeding 
up the large numbers of m68k ports we have would be a win. 
State-Changed-From-To: open->analyzed 
State-Changed-By: is 
State-Changed-When: Tue Nov 28 07:52:43 PST 2000 
State-Changed-Why:  
- merging abs and labs would make of of them go away if an application defines 
its own other-one-of-them. Have to check with some standards wizard wether 
this is acceptable. 
- the provided atoi() code does not use isspace(), but a fixed charset version 
of it. I think this is bad. 


Responsible-Changed-From-To: port-m68k-maintainer->is 
Responsible-Changed-By: is 
Responsible-Changed-When: Tue Nov 28 07:52:43 PST 2000 
Responsible-Changed-Why:  
Looking at this. 
State-Changed-From-To: analyzed->closed 
State-Changed-By: chs 
State-Changed-When: Sun Oct 27 12:20:00 PST 2002 
State-Changed-Why:  
I doubt anyone is going write the assembler for an I18N-safe isspace(). 
if no one has felt motivated to do that for the past 5 years, 
it's unlikely to happen ever. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.