Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.9 KiB

  1. /***
  2. *matherr.c - floating point exception handling
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *
  8. *Revision History:
  9. * 8-24-91 GDP written
  10. * 08-03-94 GJF Revised to support user-supplied version of _matherr
  11. * in clients of msvcrt*.dll.
  12. * 05-13-99 PML Remove Win32s
  13. *
  14. *******************************************************************************/
  15. #include <math.h>
  16. #include <stddef.h>
  17. int _matherr_flag = 9876;
  18. #if defined(CRTDLL) && !defined(_NTSDK)
  19. /*
  20. * Pointer to user-supplied _matherr routine if one has been supplied.
  21. */
  22. int (__cdecl * pusermatherr)(struct _exception *) = NULL;
  23. /***
  24. *void __setusermatherr ( int (__cdecl *pf)(struct exception *) )
  25. *
  26. *Purpose:
  27. * Copy pointer to user-supplied matherr routine into pusermatherr
  28. *
  29. *Entry:
  30. * pf - pointer to an implementation of _matherr supplied by the user
  31. *Exit:
  32. *
  33. *Exceptions:
  34. *******************************************************************************/
  35. _CRTIMP void __setusermatherr( int (__cdecl *pf)(struct _exception *) )
  36. {
  37. pusermatherr = pf;
  38. _matherr_flag = 0;
  39. }
  40. #endif
  41. /***
  42. *int _matherr(struct _exception *except) - handle math errors
  43. *
  44. *Purpose:
  45. * Permits the user customize fp error handling by redefining this function.
  46. *
  47. * The default matherr does nothing and returns 0
  48. *
  49. *Entry:
  50. *
  51. *Exit:
  52. *
  53. *Exceptions:
  54. *******************************************************************************/
  55. int _matherr(struct _exception *pexcept)
  56. {
  57. #if defined(CRTDLL) && !defined(_NTSDK)
  58. /*
  59. * If user has supplied a _matherr implementation, pass control to
  60. * it and let it handle the error.
  61. */
  62. if ( pusermatherr != NULL )
  63. return pusermatherr(pexcept);
  64. #endif
  65. return 0;
  66. }