v01i042: Patch #1 to Calctool

Charles Mcgrew mcgrew at dartagnan.rutgers.edu
Thu Jul 13 06:07:58 AEST 1989


Submitted-by: chuck at trantor.harris-atd.com (Chuck Musciano)
Posting-number: Volume 1, Issue 41
Archive-name: calctool/patch01

     This patch fixes code which causes the C compiler on 386i machines
to go into an infinite loop.  Apparently, the 386i compiler cannot handle
casting (double *) to (unsigned int) in some cases.  

     If there are any problems with this patch, please let me know, since I
do not have access to a 386i for testing purposes.

Chuck Musciano				ARPA  : chuck at trantor.harris-atd.com
Harris Corporation 			Usenet: ...!uunet!x102a!trantor!chuck
PO Box 37, MS 3A/1912			AT&T  : (407) 727-6131
Melbourne, FL 32902			FAX   : (407) 727-{5118,5227,4004}

Oh yeah, laugh now!  But when the millions start pouring in, I'll be the one
at Burger King, sucking down Whoppers at my own private table! --Al Bundy

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  patch
# Wrapped by chuck at melmac on Tue Jul 11 11:17:07 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'patch' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patch'\"
else
echo shar: Extracting \"'patch'\" \(7011 characters\)
sed "s/^X//" >'patch' <<'END_OF_FILE'
X*** ops.c.orig	Tue Jul 11 10:56:04 1989
X--- ops.c	Tue Jul 11 11:07:49 1989
X***************
X*** 36,53 ****
X  
X  #define		low_order(b, x)		((((unsigned) 0xffffffff) >> (32 - (b))) & (x))
X  
X  PRIVATE	pop_op()
X  
X  {	int	i, temp;
X  
X  	if (curr_mode != SCIENTIFIC && o_stack[o_top - 1]) {
X! 	   v_stack[v_top] = (double) low_order(curr_width[index_of(curr_base)], (unsigned int) v_stack[v_top]);
X! 	   v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], (unsigned int) v_stack[v_top - 1]);
X  	   }
X  	switch (o_stack[--o_top]) {
X  	   case ADD_OP    : v_stack[v_top - 1] += v_stack[v_top];
X  	       		    break;
X! 	   case AND_OP    : temp = ((unsigned int) v_stack[v_top - 1]) & ((unsigned int) v_stack[v_top]);
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X  	   case DIV_OP    : v_stack[v_top - 1] /= v_stack[v_top];
X--- 36,62 ----
X  
X  #define		low_order(b, x)		((((unsigned) 0xffffffff) >> (32 - (b))) & (x))
X  
X+ /************************************************************************/
X+ /*	In the following code, the apparently extraneous assignments	*/
X+ /* to vt1 and vt2 are used to circumvent a bug in the 386i C compiler	*/
X+ /* which hangs when trying to compile code which casts a (double *) to	*/
X+ /* (unsigned int).  Sigh...						*/
X+ /************************************************************************/
X+ 
X+ PRIVATE	double	vt1, vt2;
X+ 
X  PRIVATE	pop_op()
X  
X  {	int	i, temp;
X  
X  	if (curr_mode != SCIENTIFIC && o_stack[o_top - 1]) {
X! 	   v_stack[v_top] = (double) low_order(curr_width[index_of(curr_base)], (unsigned int) (vt1 = v_stack[v_top]));
X! 	   v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], (unsigned int) (vt2 = v_stack[v_top - 1]));
X  	   }
X  	switch (o_stack[--o_top]) {
X  	   case ADD_OP    : v_stack[v_top - 1] += v_stack[v_top];
X  	       		    break;
X! 	   case AND_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) & ((unsigned int) (vt2 = v_stack[v_top]));
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X  	   case DIV_OP    : v_stack[v_top - 1] /= v_stack[v_top];
X***************
X*** 54,86 ****
X  	       		    break;
X  	   case LPAREN_OP : return;
X  	   		    break;
X! 	   case LSL_OP    : temp = ((unsigned int) v_stack[v_top - 1]) << ((unsigned int) v_stack[v_top]);
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X  	   case MUL_OP    : v_stack[v_top - 1] *= v_stack[v_top];
X  	       		    break;
X! 	   case OR_OP     : temp = ((unsigned int) v_stack[v_top - 1]) | ((unsigned int) v_stack[v_top]);
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X! 	   case ROL_OP    : for (i = (unsigned int) v_stack[v_top], temp = (unsigned int) v_stack[v_top - 1]; i; i--)
X  	   		       temp = (temp << 1) + ((((unsigned) temp) >> (curr_width[index_of(curr_base)] - 1)) & 1);
X  	   		    v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], temp);
X  	       		    break;
X  	   case ROOT_OP   : v_stack[v_top - 1] = pow(v_stack[v_top - 1], 1.0 / v_stack[v_top]);
X  	       		    break;
X! 	   case ROR_OP    : for (i = (unsigned int) v_stack[v_top], temp = (unsigned int) v_stack[v_top - 1]; i; i--)
X  	   		       temp = (((unsigned) temp) >> 1) + ((temp & 1) << (curr_width[index_of(curr_base)] - 1));
X  	   		    v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], temp);
X  	       		    break;
X! 	   case RSA_OP    : temp = ((unsigned int) v_stack[v_top - 1]) >> ((unsigned int) v_stack[v_top]);
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X! 	   case RSL_OP    : temp = ((unsigned int) ((unsigned int) v_stack[v_top - 1])) >> ((unsigned int) v_stack[v_top]);
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X  	   case SUB_OP    : v_stack[v_top - 1] -= v_stack[v_top];
X  	       		    break;
X! 	   case XOR_OP    : temp = ((unsigned int) v_stack[v_top - 1]) ^ ((unsigned int) v_stack[v_top]);
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X  	   case Y2X_OP    : v_stack[v_top - 1] = pow(v_stack[v_top - 1], v_stack[v_top]);
X--- 63,95 ----
X  	       		    break;
X  	   case LPAREN_OP : return;
X  	   		    break;
X! 	   case LSL_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) << ((unsigned int) (vt2 = v_stack[v_top]));
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X  	   case MUL_OP    : v_stack[v_top - 1] *= v_stack[v_top];
X  	       		    break;
X! 	   case OR_OP     : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) | ((unsigned int) (vt2 = v_stack[v_top]));
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X! 	   case ROL_OP    : for (i = (unsigned int) (vt1 = v_stack[v_top]), temp = (unsigned int) (vt2 = v_stack[v_top - 1]); i; i--)
X  	   		       temp = (temp << 1) + ((((unsigned) temp) >> (curr_width[index_of(curr_base)] - 1)) & 1);
X  	   		    v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], temp);
X  	       		    break;
X  	   case ROOT_OP   : v_stack[v_top - 1] = pow(v_stack[v_top - 1], 1.0 / v_stack[v_top]);
X  	       		    break;
X! 	   case ROR_OP    : for (i = (unsigned int) (vt1 = v_stack[v_top]), temp = (unsigned int) (vt2 = v_stack[v_top - 1]); i; i--)
X  	   		       temp = (((unsigned) temp) >> 1) + ((temp & 1) << (curr_width[index_of(curr_base)] - 1));
X  	   		    v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], temp);
X  	       		    break;
X! 	   case RSA_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) >> ((unsigned int) (vt2 = v_stack[v_top]));
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X! 	   case RSL_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) >> ((unsigned int) (vt2 = v_stack[v_top]));
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X  	   case SUB_OP    : v_stack[v_top - 1] -= v_stack[v_top];
X  	       		    break;
X! 	   case XOR_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) ^ ((unsigned int) (vt2 = v_stack[v_top]));
X  	       		    v_stack[v_top - 1] = (double) temp;
X  	       		    break;
X  	   case Y2X_OP    : v_stack[v_top - 1] = pow(v_stack[v_top - 1], v_stack[v_top]);
X***************
X*** 199,205 ****
X  	      		    break;
X  	   case LOG_OP    : v_stack[v_top] = log10(v_stack[v_top]);
X  	      		    break;
X! 	   case NOT_OP    : v_stack[v_top] = (double) low_order(curr_width[index_of(curr_base)], (~ (unsigned int) v_stack[v_top]));
X  	      		    break;
X  	   case OVER_OP   : v_stack[v_top] = 1.0 / v_stack[v_top];
X  	      		    break;
X--- 208,214 ----
X  	      		    break;
X  	   case LOG_OP    : v_stack[v_top] = log10(v_stack[v_top]);
X  	      		    break;
X! 	   case NOT_OP    : v_stack[v_top] = (double) low_order(curr_width[index_of(curr_base)], (~ (unsigned int) (vt1 = v_stack[v_top])));
X  	      		    break;
X  	   case OVER_OP   : v_stack[v_top] = 1.0 / v_stack[v_top];
X  	      		    break;
END_OF_FILE
if test 7011 -ne `wc -c <'patch'`; then
    echo shar: \"'patch'\" unpacked with wrong size!
fi
# end of 'patch'
fi
echo shar: End of shell archive.
exit 0

Chuck Musciano				ARPA  : chuck at trantor.harris-atd.com
Harris Corporation 			Usenet: ...!uunet!x102a!trantor!chuck
PO Box 37, MS 3A/1912			AT&T  : (407) 727-6131
Melbourne, FL 32902			FAX   : (407) 727-{5118,5227,4004}

Oh yeah, laugh now!  But when the millions start pouring in, I'll be the one
at Burger King, sucking down Whoppers at my own private table! --Al Bundy



More information about the Comp.sources.sun mailing list