diff --git a/lib/libc/arch/alpha/gen/divrem.m4 b/lib/libc/arch/alpha/gen/divrem.m4 index d8e17ee12cac..6fc90fdc9fde 100644 --- a/lib/libc/arch/alpha/gen/divrem.m4 +++ b/lib/libc/arch/alpha/gen/divrem.m4 @@ -1,4 +1,4 @@ -/* $NetBSD: divrem.m4,v 1.1 1995/02/10 17:50:20 cgd Exp $ */ +/* $NetBSD: divrem.m4,v 1.2 1995/02/25 03:09:32 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -84,7 +84,15 @@ LnegB: /* B is definitely negative, no matter how we got here. */ subq zero, B, B Ldoit: -') +', ` +ifelse(WORDSIZE, `32', ` + /* + * Clear the top 32 bits of each operand, as the compiler may + * have sign extended them, if the 31st bit was set. + */ + zap A, 0xf0, A + zap B, 0xf0, B +')' ) /* kill the special cases. */ beq B, Ldotrap /* division by zero! XXX */ @@ -164,6 +172,9 @@ ifelse(S, `true', Ldotrap: CONST(-2, a0) /* This is the signal to SIGFPE! */ call_pal PAL_gentrap +ifelse(OP, `div', +`', ` mov zero, A /* so that zero will be returned */ +') br zero, Lret_result END(NAME)