1997-04-17 17:10:04 +02:00
|
|
|
/* Raise given exceptions.
|
|
|
|
Copyright (C) 1997 Free Software Foundation, Inc.
|
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
|
|
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
#include <fenv.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
void
|
|
|
|
feraiseexcept (int excepts)
|
|
|
|
{
|
|
|
|
/* Raise exceptions represented by EXCEPTS. But we must raise only one
|
|
|
|
signal at a time. It is important that if the overflow/underflow
|
|
|
|
exception and the divide by zero exception are given at the same
|
|
|
|
time, the overflow/underflow exception follows the divide by zero
|
|
|
|
exception. */
|
|
|
|
|
|
|
|
/* First: invalid exception. */
|
|
|
|
if (excepts & FE_INVALID)
|
|
|
|
{
|
|
|
|
/* One example of a invalid operation is 0 * Infinity. */
|
Update.
1997-06-04 20:57 Ulrich Drepper <drepper@cygnus.com>
* manual/string.texi: Add comments to discourage use of index and
rindex.
(strtok, strsep): Apply function on copy of the strings in example.
(l64a): Add example.
* posix/unistd.h: Correct value for _POSIX_VERSION.
* sunrpc/Makefile (defines): Remove definition.
* sysdeps/ieee754/nan.h: Correct typo.
1997-06-04 10:50 Fila Kolodny <fila@ibi.com>
* posix/unistd.h: Add definition of __fchdir corresponding to fchdir.
* login/utmp_daemon.c: Correct location of utmpd.h.
1997-06-03 19:16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Makerules: Rename $(common-objpfx)distinfo-$(subdir) to
$(objpfx)distinfo.
* rpm/Makefile (distinfo): Adapted.
1997-06-03 18:32 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* rpm/Makefile (install-slib): Collect shared libraries here
instead of in install-lib, including libc.
(instvars): Add slib.
1997-06-03 18:23 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* login/Makefile (libutil-routines): Add updwtmp.
1997-06-03 16:16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* monetary.h: New file, needed for localedata/tst-fmon.c.
1997-06-02 20:31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* math/libm-test.c (cpow_test): Add epsilon for long double in
test for 2^10.
(identities): Add epsilon for float in second identity test.
* sysdeps/m68k/huge_val.h: Change GCC's HUGE_VAL{,F,L} to use
DI and SI mode integers instead of bytes. Fix value of HUGE_VALL.
* sysdeps/m68k/nan.h: New file.
* sysdeps/m68k/fpu/__math.h (isgreater, isgreaterequal, isless,
islessequal, islessgreater, isunordered): Fix assembler syntax.
* sysdeps/m68k/fpu/fraiseexcpt.c: Do it right so that gcc doesn't
optimize out the operations.
* sysdeps/libm-ieee754/s_nan.c: Use NaN macro instead of static
constant.
* sysdeps/libm-ieee754/s_nanf.c: Likewise.
* sysdeps/libm-ieee754/s_nanl.c: Likewise.
* math/carg.c [NO_LONG_DOUBLE]: Add alias for long double
function.
* sysdeps/libm-ieee754/s_erf.c: Likewise.
* sysdeps/libm-ieee754/s_fdim.c: Likewise.
* sysdeps/libm-ieee754/s_fmax.c: Likewise.
* sysdeps/libm-ieee754/s_fmin.c: Likewise.
* sysdeps/libm-ieee754/s_log2.c: Likewise.
* sysdeps/libm-ieee754/s_nan.c: Likewise.
* sysdeps/libm-ieee754/s_remquo.c: Likewise.
1997-06-04 21:05:38 +02:00
|
|
|
double d = HUGE_VAL;
|
|
|
|
__asm__ __volatile__ ("fmul%.s %#0r0,%0; fnop" : "=f" (d) : "0" (d));
|
1997-04-17 17:10:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Next: division by zero. */
|
|
|
|
if (excepts & FE_DIVBYZERO)
|
|
|
|
{
|
|
|
|
double d = 1.0;
|
|
|
|
__asm__ __volatile__ ("fdiv%.s %#0r0,%0; fnop" : "=f" (d) : "0" (d));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Next: overflow. */
|
|
|
|
if (excepts & FE_OVERFLOW)
|
|
|
|
{
|
Update.
1997-06-04 20:57 Ulrich Drepper <drepper@cygnus.com>
* manual/string.texi: Add comments to discourage use of index and
rindex.
(strtok, strsep): Apply function on copy of the strings in example.
(l64a): Add example.
* posix/unistd.h: Correct value for _POSIX_VERSION.
* sunrpc/Makefile (defines): Remove definition.
* sysdeps/ieee754/nan.h: Correct typo.
1997-06-04 10:50 Fila Kolodny <fila@ibi.com>
* posix/unistd.h: Add definition of __fchdir corresponding to fchdir.
* login/utmp_daemon.c: Correct location of utmpd.h.
1997-06-03 19:16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Makerules: Rename $(common-objpfx)distinfo-$(subdir) to
$(objpfx)distinfo.
* rpm/Makefile (distinfo): Adapted.
1997-06-03 18:32 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* rpm/Makefile (install-slib): Collect shared libraries here
instead of in install-lib, including libc.
(instvars): Add slib.
1997-06-03 18:23 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* login/Makefile (libutil-routines): Add updwtmp.
1997-06-03 16:16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* monetary.h: New file, needed for localedata/tst-fmon.c.
1997-06-02 20:31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* math/libm-test.c (cpow_test): Add epsilon for long double in
test for 2^10.
(identities): Add epsilon for float in second identity test.
* sysdeps/m68k/huge_val.h: Change GCC's HUGE_VAL{,F,L} to use
DI and SI mode integers instead of bytes. Fix value of HUGE_VALL.
* sysdeps/m68k/nan.h: New file.
* sysdeps/m68k/fpu/__math.h (isgreater, isgreaterequal, isless,
islessequal, islessgreater, isunordered): Fix assembler syntax.
* sysdeps/m68k/fpu/fraiseexcpt.c: Do it right so that gcc doesn't
optimize out the operations.
* sysdeps/libm-ieee754/s_nan.c: Use NaN macro instead of static
constant.
* sysdeps/libm-ieee754/s_nanf.c: Likewise.
* sysdeps/libm-ieee754/s_nanl.c: Likewise.
* math/carg.c [NO_LONG_DOUBLE]: Add alias for long double
function.
* sysdeps/libm-ieee754/s_erf.c: Likewise.
* sysdeps/libm-ieee754/s_fdim.c: Likewise.
* sysdeps/libm-ieee754/s_fmax.c: Likewise.
* sysdeps/libm-ieee754/s_fmin.c: Likewise.
* sysdeps/libm-ieee754/s_log2.c: Likewise.
* sysdeps/libm-ieee754/s_nan.c: Likewise.
* sysdeps/libm-ieee754/s_remquo.c: Likewise.
1997-06-04 21:05:38 +02:00
|
|
|
long double d = LDBL_MAX;
|
|
|
|
__asm__ __volatile__ ("fmul%.x %0,%0; fnop" : "=f" (d) : "0" (d));
|
1997-04-17 17:10:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Next: underflow. */
|
|
|
|
if (excepts & FE_UNDERFLOW)
|
|
|
|
{
|
Update.
1997-06-04 20:57 Ulrich Drepper <drepper@cygnus.com>
* manual/string.texi: Add comments to discourage use of index and
rindex.
(strtok, strsep): Apply function on copy of the strings in example.
(l64a): Add example.
* posix/unistd.h: Correct value for _POSIX_VERSION.
* sunrpc/Makefile (defines): Remove definition.
* sysdeps/ieee754/nan.h: Correct typo.
1997-06-04 10:50 Fila Kolodny <fila@ibi.com>
* posix/unistd.h: Add definition of __fchdir corresponding to fchdir.
* login/utmp_daemon.c: Correct location of utmpd.h.
1997-06-03 19:16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Makerules: Rename $(common-objpfx)distinfo-$(subdir) to
$(objpfx)distinfo.
* rpm/Makefile (distinfo): Adapted.
1997-06-03 18:32 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* rpm/Makefile (install-slib): Collect shared libraries here
instead of in install-lib, including libc.
(instvars): Add slib.
1997-06-03 18:23 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* login/Makefile (libutil-routines): Add updwtmp.
1997-06-03 16:16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* monetary.h: New file, needed for localedata/tst-fmon.c.
1997-06-02 20:31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* math/libm-test.c (cpow_test): Add epsilon for long double in
test for 2^10.
(identities): Add epsilon for float in second identity test.
* sysdeps/m68k/huge_val.h: Change GCC's HUGE_VAL{,F,L} to use
DI and SI mode integers instead of bytes. Fix value of HUGE_VALL.
* sysdeps/m68k/nan.h: New file.
* sysdeps/m68k/fpu/__math.h (isgreater, isgreaterequal, isless,
islessequal, islessgreater, isunordered): Fix assembler syntax.
* sysdeps/m68k/fpu/fraiseexcpt.c: Do it right so that gcc doesn't
optimize out the operations.
* sysdeps/libm-ieee754/s_nan.c: Use NaN macro instead of static
constant.
* sysdeps/libm-ieee754/s_nanf.c: Likewise.
* sysdeps/libm-ieee754/s_nanl.c: Likewise.
* math/carg.c [NO_LONG_DOUBLE]: Add alias for long double
function.
* sysdeps/libm-ieee754/s_erf.c: Likewise.
* sysdeps/libm-ieee754/s_fdim.c: Likewise.
* sysdeps/libm-ieee754/s_fmax.c: Likewise.
* sysdeps/libm-ieee754/s_fmin.c: Likewise.
* sysdeps/libm-ieee754/s_log2.c: Likewise.
* sysdeps/libm-ieee754/s_nan.c: Likewise.
* sysdeps/libm-ieee754/s_remquo.c: Likewise.
1997-06-04 21:05:38 +02:00
|
|
|
long double d = LDBL_MIN;
|
|
|
|
__asm__ __volatile__ ("fdiv%.s %#0r16,%0; fnop" : "=f" (d) : "0" (d));
|
1997-04-17 17:10:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Last: inexact. */
|
|
|
|
if (excepts & FE_INEXACT)
|
|
|
|
{
|
Update.
1997-06-04 20:57 Ulrich Drepper <drepper@cygnus.com>
* manual/string.texi: Add comments to discourage use of index and
rindex.
(strtok, strsep): Apply function on copy of the strings in example.
(l64a): Add example.
* posix/unistd.h: Correct value for _POSIX_VERSION.
* sunrpc/Makefile (defines): Remove definition.
* sysdeps/ieee754/nan.h: Correct typo.
1997-06-04 10:50 Fila Kolodny <fila@ibi.com>
* posix/unistd.h: Add definition of __fchdir corresponding to fchdir.
* login/utmp_daemon.c: Correct location of utmpd.h.
1997-06-03 19:16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* Makerules: Rename $(common-objpfx)distinfo-$(subdir) to
$(objpfx)distinfo.
* rpm/Makefile (distinfo): Adapted.
1997-06-03 18:32 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* rpm/Makefile (install-slib): Collect shared libraries here
instead of in install-lib, including libc.
(instvars): Add slib.
1997-06-03 18:23 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* login/Makefile (libutil-routines): Add updwtmp.
1997-06-03 16:16 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* monetary.h: New file, needed for localedata/tst-fmon.c.
1997-06-02 20:31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* math/libm-test.c (cpow_test): Add epsilon for long double in
test for 2^10.
(identities): Add epsilon for float in second identity test.
* sysdeps/m68k/huge_val.h: Change GCC's HUGE_VAL{,F,L} to use
DI and SI mode integers instead of bytes. Fix value of HUGE_VALL.
* sysdeps/m68k/nan.h: New file.
* sysdeps/m68k/fpu/__math.h (isgreater, isgreaterequal, isless,
islessequal, islessgreater, isunordered): Fix assembler syntax.
* sysdeps/m68k/fpu/fraiseexcpt.c: Do it right so that gcc doesn't
optimize out the operations.
* sysdeps/libm-ieee754/s_nan.c: Use NaN macro instead of static
constant.
* sysdeps/libm-ieee754/s_nanf.c: Likewise.
* sysdeps/libm-ieee754/s_nanl.c: Likewise.
* math/carg.c [NO_LONG_DOUBLE]: Add alias for long double
function.
* sysdeps/libm-ieee754/s_erf.c: Likewise.
* sysdeps/libm-ieee754/s_fdim.c: Likewise.
* sysdeps/libm-ieee754/s_fmax.c: Likewise.
* sysdeps/libm-ieee754/s_fmin.c: Likewise.
* sysdeps/libm-ieee754/s_log2.c: Likewise.
* sysdeps/libm-ieee754/s_nan.c: Likewise.
* sysdeps/libm-ieee754/s_remquo.c: Likewise.
1997-06-04 21:05:38 +02:00
|
|
|
long double d = 1.0;
|
|
|
|
__asm__ __volatile__ ("fdiv%.s %#0r3,%0; fnop" : "=f" (d) : "0" (d));
|
1997-04-17 17:10:04 +02:00
|
|
|
}
|
|
|
|
}
|