15673Smckusick /* Copyright (c) 1982 Regents of the University of California */ 25673Smckusick 3*10230Smckusick static char sccsid[] = "@(#)EXCEPT.c 1.3 01/10/83"; 45673Smckusick 55673Smckusick #include <signal.h> 65673Smckusick 75673Smckusick /* 85673Smckusick * catch runtime arithmetic errors 95673Smckusick */ 105673Smckusick EXCEPT(signum, type) 115673Smckusick int signum, type; 125673Smckusick { 135673Smckusick signal(SIGFPE, EXCEPT); 14*10230Smckusick #ifndef vax 155673Smckusick ERROR("Overflow, underflow, or division by zero in arithmetic operation\n"); 165716Smckusic return; 17*10230Smckusick #endif notvax 18*10230Smckusick #ifdef vax 195716Smckusic /* 205716Smckusic * The values for this switch statement come from page 12-5 of 215716Smckusic * Volume 1 of the 1978 VAX 11/780 Architecture Handbook 225716Smckusic */ 235673Smckusick switch (type) { 245673Smckusick case 1: 255673Smckusick ERROR("Integer overflow\n"); 265716Smckusic return; 275673Smckusick case 2: 285673Smckusick ERROR("Integer division by zero\n"); 295716Smckusic return; 305673Smckusick case 3: 315673Smckusick ERROR("Real overflow\n"); 325716Smckusic return; 335673Smckusick case 4: 345673Smckusick ERROR("Real division by zero\n"); 355716Smckusic return; 365673Smckusick case 5: 375673Smckusick ERROR("Real underflow\n"); 385716Smckusic return; 395673Smckusick default: 405673Smckusick ERROR("Panic: Computational error in interpreter\n"); 415716Smckusic return; 425673Smckusick } 43*10230Smckusick #endif vax 445673Smckusick } 45