head	1.3;
access;
symbols
	pkgsrc-2024Q4:1.2.0.68
	pkgsrc-2024Q4-base:1.2
	pkgsrc-2024Q3:1.2.0.66
	pkgsrc-2024Q3-base:1.2
	pkgsrc-2024Q2:1.2.0.64
	pkgsrc-2024Q2-base:1.2
	pkgsrc-2024Q1:1.2.0.62
	pkgsrc-2024Q1-base:1.2
	pkgsrc-2023Q4:1.2.0.60
	pkgsrc-2023Q4-base:1.2
	pkgsrc-2023Q3:1.2.0.58
	pkgsrc-2023Q3-base:1.2
	pkgsrc-2023Q2:1.2.0.56
	pkgsrc-2023Q2-base:1.2
	pkgsrc-2023Q1:1.2.0.54
	pkgsrc-2023Q1-base:1.2
	pkgsrc-2022Q4:1.2.0.52
	pkgsrc-2022Q4-base:1.2
	pkgsrc-2022Q3:1.2.0.50
	pkgsrc-2022Q3-base:1.2
	pkgsrc-2022Q2:1.2.0.48
	pkgsrc-2022Q2-base:1.2
	pkgsrc-2022Q1:1.2.0.46
	pkgsrc-2022Q1-base:1.2
	pkgsrc-2021Q4:1.2.0.44
	pkgsrc-2021Q4-base:1.2
	pkgsrc-2021Q3:1.2.0.42
	pkgsrc-2021Q3-base:1.2
	pkgsrc-2021Q2:1.2.0.40
	pkgsrc-2021Q2-base:1.2
	pkgsrc-2021Q1:1.2.0.38
	pkgsrc-2021Q1-base:1.2
	pkgsrc-2020Q4:1.2.0.36
	pkgsrc-2020Q4-base:1.2
	pkgsrc-2020Q3:1.2.0.34
	pkgsrc-2020Q3-base:1.2
	pkgsrc-2020Q2:1.2.0.30
	pkgsrc-2020Q2-base:1.2
	pkgsrc-2020Q1:1.2.0.10
	pkgsrc-2020Q1-base:1.2
	pkgsrc-2019Q4:1.2.0.32
	pkgsrc-2019Q4-base:1.2
	pkgsrc-2019Q3:1.2.0.28
	pkgsrc-2019Q3-base:1.2
	pkgsrc-2019Q2:1.2.0.26
	pkgsrc-2019Q2-base:1.2
	pkgsrc-2019Q1:1.2.0.24
	pkgsrc-2019Q1-base:1.2
	pkgsrc-2018Q4:1.2.0.22
	pkgsrc-2018Q4-base:1.2
	pkgsrc-2018Q3:1.2.0.20
	pkgsrc-2018Q3-base:1.2
	pkgsrc-2018Q2:1.2.0.18
	pkgsrc-2018Q2-base:1.2
	pkgsrc-2018Q1:1.2.0.16
	pkgsrc-2018Q1-base:1.2
	pkgsrc-2017Q4:1.2.0.14
	pkgsrc-2017Q4-base:1.2
	pkgsrc-2017Q3:1.2.0.12
	pkgsrc-2017Q3-base:1.2
	pkgsrc-2017Q2:1.2.0.8
	pkgsrc-2017Q2-base:1.2
	pkgsrc-2017Q1:1.2.0.6
	pkgsrc-2017Q1-base:1.2
	pkgsrc-2016Q4:1.2.0.4
	pkgsrc-2016Q4-base:1.2
	pkgsrc-2016Q3:1.2.0.2
	pkgsrc-2016Q3-base:1.2;
locks; strict;
comment	@# @;


1.3
date	2025.03.24.06.39.21;	author wiz;	state dead;
branches;
next	1.2;
commitid	3G76OJWDjFd8QhOF;

1.2
date	2016.07.03.18.33.36;	author dholland;	state Exp;
branches;
next	1.1;
commitid	6x7CqftIBqRzcUcz;

1.1
date	2016.07.03.17.50.31;	author dholland;	state Exp;
branches;
next	;
commitid	50Ob5ArDfMiqXTcz;


desc
@@


1.3
log
@smlnj11072: remove

Use lang/smlnj instead

Ok dholland@@
@
text
@$NetBSD: patch-ae,v 1.2 2016/07/03 18:33:36 dholland Exp $

Support for NetBSD.

--- src/runtime/mach-dep/SPARC.prim.asm.orig	Fri Jun 15 15:05:19 2001
+++ src/runtime/mach-dep/SPARC.prim.asm
@@@@ -307,7 +307,7 @@@@ pending_sigs:	/* there are pending signa
 	mov	ALLOCPTR,LIMITPTR	    /* (delay slot) */
 
 
-#if defined(OPSYS_SUNOS) || defined(OPSYS_NEXTSTEP)
+#if defined(OPSYS_SUNOS) || defined(OPSYS_NEXTSTEP) || defined(OPSYS_NETBSD)
 /* ZeroLimitPtr:
  *
  * Zero the heap limit pointer so that a trap will be generated on the next limit
@@@@ -622,13 +622,62 @@@@ _ml_mul:
 	mov	%g1,%l1			  /* save %g1 which may get trashed */
 	mov	%g2,%l2
 	mov	%g3,%l3
+#ifdef OPSYS_NETBSD
+			/* NetBSDs .mul trashes these */
+	mov     %i4,%l4
+	mov     %i5,%l5
+	mov	%i0,%l6
+	mov	%i1,%l7
+#endif
 	mov	%i2,%o0
 	call	.mul
 	mov	%i3,%o1			  /* (delay slot) */
 	mov	%l1,%g1			  /* restore %g1 */
 	mov	%l2,%g2
 	mov	%l3,%g3
+#ifdef OPSYS_NETBSD
+	mov     %l4,%i4
+	mov	%l5,%i5
+	mov	%l6,%i0
+	mov	%l7,%i1
+			/* the code below is a hack:
+			 * NetBSDs .mul does a 32x32->64 bit signed multiply
+			 * The SML code assumes that the multiply
+			 * overflowed (over 32bit) if the Z flag is
+			 * clear on return from .mul 
+			 * NetBSDs .mul doesn't do that, so we have to check
+			 * for overflow. This is done in the following way:
+			 * - If the upper 32 bits are clear:
+	 		 *    + if bit 31 is set => overflow
+		         *    + if bit 31 is clear => OK
+			 * - If the upper 32 bits are != -1 => overflow
+			 * - If the upper 32 bits are == -1:
+			 *    + If bit 31 is clear => overflow
+			 *    + If bit 31 is set   => OK
+			 *
+		   	 * I should be shot for this code ...
+			 */
+	cmp %o1,0
+	bnz 4f
+	nop
+	/* is bit 31 of %o0 set ? */
+	addcc %o0,%o0,%o1
+	bcc 2f
+	nop
+5:      restore %o0,0,%o2                 /* result in %o2 (delay slot) */
+        t       ST_INT_OVERFLOW         /* generate overflow trap */
+
+	
+4:	cmp %o1,-1			/* upper 32 bits == -1 ? */
+	bnz 5
+	nop
+	addcc %o0,%o0,%o1		/* bit 31 clear ? */
+	bcc 2f
+	nop
+#else
 	bnz	1f			  /* if z is clear, then overflow */
+#endif
+2:
 	restore %o0,0,%o2		  /* result in %o2 (delay slot) */
 	retl
 	nop
@@@@ -642,7 +691,15 @@@@ _ml_mul:
  * locals of the new window, since .div is a leaf routine.
  */
 _ml_div:
-	save	%sp,-SA(WINDOWSIZE),%sp
+#ifdef OPSYS_NETBSD
+		/* hack time again: NetBSDs .div trashes too many registers
+		 * we have to store them in the stack frame, so make room
+		 * for six registers (o0-o5) 
+		 */
+	save	%sp,-SA(WINDOWSIZE+24),%sp
+#else
+        save    %sp,-SA(WINDOWSIZE+24),%sp
+#endif
 	addcc	%i3,%g0,%o1		/* %o1 is divisor (and check for zero) */
 	bz	1f
 				    /* save %g1, %g2 and %g3 (using new window) */
@@@@ -650,9 +707,30 @@@@ _ml_div:
 	mov	%g1,%l1			/* (delay slot) */
 	mov	%g2,%l2
 	mov	%g3,%l3
+#ifdef OPSYS_NETBSD
+	/* save g6,g7,o0-o5, they get trashed. 
+	   Note that %o0-%o5 are now %i0-%i5, since we did a 'save'
+	   Since %g6 is the global AllocPtr for SML, this 
+	   is rather bad :-)
+	 */  
+	mov %g6,%l4
+	mov %g7,%l5
+	std	%i0,[%fp-16]
+	std	%i2,[%fp-24]
+	std	%i4,[%fp-32]
+#endif
+
 	call	.div
 	mov	%i2,%o0			/* (delay slot) */
 				    /* restore %g1, %g2 and %g3 */
+#ifdef OPSYS_NETBSD
+	mov %l4,%g6
+	mov %l5,%g7
+	ldd	[%fp-32],%i4
+	ldd	[%fp-24],%i2
+	ldd	[%fp-16],%i0
+#endif
+
 	mov	%l3,%g3
 	mov	%l2,%g2
 	mov	%l1,%g1
@@@@ -679,11 +757,24 @@@@ _ml_umul:
 	mov	%g2,%l2
 	mov	%g3,%l3
 	mov	%i2,%o0
+#ifdef OPSYS_NETBSD
+		/* Save what might be trashed by NetBSDs .umul */
+	mov	%i4,%l4
+	mov	%i5,%l5
+	mov	%i0,%l6
+	mov 	%i1,%l7
+#endif
 	call	.umul
 	mov	%i3,%o1			  /* (delay slot) */
 	mov	%l1,%g1			  /* restore %g1 */
 	mov	%l2,%g2
 	mov	%l3,%g3
+#ifdef OPSYS_NETBSD
+	mov	%l4,%i4
+	mov	%l5,%i5
+	mov	%l6,%i0
+	mov	%l7,%i1
+#endif
 	ret
 	restore %o0,0,%o2		  /* result in %o2 (delay slot) */
 
@@@@ -694,7 +785,12 @@@@ _ml_umul:
  * locals of the new window, since .div is a leaf routine.
  */
 _ml_udiv:
-	save	%sp,-SA(WINDOWSIZE),%sp
+#ifdef OPSYS_NETBSD
+		/* see comment for _ml__div_ */
+	save	%sp,-SA(WINDOWSIZE+24),%sp
+#else
+        save    %sp,-SA(WINDOWSIZE+24),%sp 
+#endif
 	addcc	%i3,%g0,%o1		/* %o1 is divisor (and check for zero) */
 	bz	1f
 				    /* save %g1, %g2 and %g3 (using new window) */
@@@@ -702,9 +798,23 @@@@ _ml_udiv:
 	mov	%g1,%l1			/* (delay slot) */
 	mov	%g2,%l2
 	mov	%g3,%l3
+#ifdef OPSYS_NETBSD
+	mov	%g6,%l4
+	mov 	%g7,%l5
+        std     %i0,[%fp-16]
+        std     %i2,[%fp-24]
+        std     %i4,[%fp-32]
+#endif
 	call	.udiv
 	mov	%i2,%o0			/* (delay slot) */
 				    /* restore %g1, %g2 and %g3 */
+#ifdef OPSYS_NETBSD
+	mov 	%l4,%g6
+	mov 	%l5,%g7
+        ldd     [%fp-32],%i4
+        ldd     [%fp-24],%i2
+        ldd     [%fp-16],%i0
+#endif
 	mov	%l3,%g3
 	mov	%l2,%g2
 	mov	%l1,%g1
@


1.2
log
@Sync patch comments from main smlnj package.
@
text
@d1 1
a1 1
$NetBSD: patch-ae,v 1.1 2016/07/03 17:50:31 dholland Exp $
@


1.1
log
@Add a copy of smlnj from before the last update (so, 110.72) because
this version builds and runs on NetBSD/i386. (Yes, the update was
years back. This is what happens with packages that don't build on
amd64...)
@
text
@d1 3
a3 1
$NetBSD: patch-ae,v 1.1.1.1 2003/03/21 22:20:56 wiz Exp $
@

