1 /*- 2 * Copyright (c) 1982, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)EXCEPT.c 8.1 (Berkeley) 06/06/93"; 10 #endif /* not lint */ 11 12 #include <signal.h> 13 14 /* 15 * catch runtime arithmetic errors 16 */ 17 EXCEPT(signum, type) 18 int signum, type; 19 { 20 signal(SIGFPE, EXCEPT); 21 #ifndef vax 22 ERROR("Overflow, underflow, or division by zero in arithmetic operation\n"); 23 return; 24 #endif notvax 25 #ifdef vax 26 /* 27 * The values for this switch statement come from page 12-5 of 28 * Volume 1 of the 1978 VAX 11/780 Architecture Handbook 29 */ 30 switch (type) { 31 case FPE_INTOVF_TRAP: 32 ERROR("Integer overflow\n"); 33 return; 34 case FPE_INTDIV_TRAP: 35 ERROR("Integer division by zero\n"); 36 return; 37 case FPE_FLTOVF_TRAP: 38 case FPE_FLTOVF_FAULT: 39 ERROR("Real overflow\n"); 40 return; 41 case FPE_FLTDIV_TRAP: 42 case FPE_FLTDIV_FAULT: 43 ERROR("Real division by zero\n"); 44 return; 45 case FPE_FLTUND_TRAP: 46 case FPE_FLTUND_FAULT: 47 ERROR("Real underflow\n"); 48 return; 49 case FPE_DECOVF_TRAP: 50 case FPE_SUBRNG_TRAP: 51 default: 52 ERROR("Undefined arithmetic exception type (%d)\n", type); 53 return; 54 } 55 #endif vax 56 } 57