15673Smckusick /* Copyright (c) 1982 Regents of the University of California */ 25673Smckusick 3*5716Smckusic static char sccsid[] = "@(#)EXCEPT.c 1.2 02/08/82"; 45673Smckusick 55673Smckusick #include <signal.h> 65673Smckusick #include "whoami.h" 75673Smckusick 85673Smckusick /* 95673Smckusick * catch runtime arithmetic errors 105673Smckusick */ 115673Smckusick EXCEPT(signum, type) 125673Smckusick int signum, type; 135673Smckusick { 145673Smckusick signal(SIGFPE, EXCEPT); 155673Smckusick #ifndef VAX 165673Smckusick ERROR("Overflow, underflow, or division by zero in arithmetic operation\n"); 17*5716Smckusic return; 185673Smckusick #else 19*5716Smckusic /* 20*5716Smckusic * The values for this switch statement come from page 12-5 of 21*5716Smckusic * Volume 1 of the 1978 VAX 11/780 Architecture Handbook 22*5716Smckusic */ 235673Smckusick switch (type) { 245673Smckusick case 1: 255673Smckusick ERROR("Integer overflow\n"); 26*5716Smckusic return; 275673Smckusick case 2: 285673Smckusick ERROR("Integer division by zero\n"); 29*5716Smckusic return; 305673Smckusick case 3: 315673Smckusick ERROR("Real overflow\n"); 32*5716Smckusic return; 335673Smckusick case 4: 345673Smckusick ERROR("Real division by zero\n"); 35*5716Smckusic return; 365673Smckusick case 5: 375673Smckusick ERROR("Real underflow\n"); 38*5716Smckusic return; 395673Smckusick default: 405673Smckusick ERROR("Panic: Computational error in interpreter\n"); 41*5716Smckusic return; 425673Smckusick } 435673Smckusick #endif 445673Smckusick } 45