14154Sdlw /* 2*22989Skre * Copyright (c) 1980 Regents of the University of California. 3*22989Skre * All rights reserved. The Berkeley software License Agreement 4*22989Skre * specifies the terms and conditions for redistribution. 5*22989Skre * 6*22989Skre * @(#)traper_.c 5.1 06/07/85 7*22989Skre */ 84154Sdlw * Full of Magic! DON'T CHANGE ANYTHING !! 94154Sdlw * 104154Sdlw * To use from f77: 114154Sdlw * integer oldmsk, traper 124154Sdlw * oldmsk = traper (mask) 134154Sdlw * where: 144154Sdlw * mask = 1 to trap integer overflow 154154Sdlw * mask = 2 to trap floating underflow 164154Sdlw * mask = 3 to trap both 174154Sdlw * These 2 bits will be set into the PSW. 184154Sdlw * The old state will be returned. 194154Sdlw */ 204154Sdlw 214154Sdlw long traper_(msk) 224154Sdlw long *msk; 234154Sdlw { 244154Sdlw int old = 0; 254154Sdlw #if vax 264154Sdlw #define IOV_MASK 0140 274154Sdlw int **s = &msk; 284154Sdlw int psw; 294154Sdlw 304154Sdlw s -= 5; 314154Sdlw psw = (int)*s; 324154Sdlw old = (psw & IOV_MASK) >> 5; 334154Sdlw psw = (psw & ~IOV_MASK) | ((*msk << 5) & IOV_MASK); 344154Sdlw *s = (int *)psw; 354154Sdlw #endif vax 364154Sdlw return((long)old); 374154Sdlw } 38