1170754Sdelphij/* $NetBSD: matherr.c,v 1.1.1.1 2016/01/13 18:41:48 christos Exp $ */ 2170754Sdelphij 3170754Sdelphij/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc. 4170754Sdelphij Written by James Clark (jjc@jclark.com) 5170754Sdelphij 6170754SdelphijThis file is part of groff. 7170754Sdelphij 8170754Sdelphijgroff is free software; you can redistribute it and/or modify it under 9170754Sdelphijthe terms of the GNU General Public License as published by the Free 10170754SdelphijSoftware Foundation; either version 2, or (at your option) any later 11170754Sdelphijversion. 12170754Sdelphij 13170754Sdelphijgroff is distributed in the hope that it will be useful, but WITHOUT ANY 14170754SdelphijWARRANTY; without even the implied warranty of MERCHANTABILITY or 15170754SdelphijFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16170754Sdelphijfor more details. 17170754Sdelphij 18170754SdelphijYou should have received a copy of the GNU General Public License along 19170754Sdelphijwith groff; see the file COPYING. If not, write to the Free Software 20170754SdelphijFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 21170754Sdelphij 22170754Sdelphij#ifdef HAVE_CONFIG_H 23170754Sdelphij#include <config.h> 24170754Sdelphij#endif 25170754Sdelphij 26170754Sdelphij#include <math.h> 27170754Sdelphij#include <errno.h> 28170754Sdelphij 29170754Sdelphij#ifdef HAVE_STRUCT_EXCEPTION 30170754Sdelphij#ifdef TLOSS 31170754Sdelphij 32170754Sdelphijint matherr(exc) 33struct exception *exc; 34{ 35 switch (exc->type) { 36 case SING: 37 case DOMAIN: 38 errno = EDOM; 39 break; 40 case OVERFLOW: 41 case UNDERFLOW: 42 case TLOSS: 43 case PLOSS: 44 errno = ERANGE; 45 break; 46 } 47 return 1; 48} 49 50#endif /* TLOSS */ 51#endif /* HAVE_STRUCT_EXCEPTION */ 52