ReactOS  0.4.15-dev-2776-g4130f0b
merr.c
Go to the documentation of this file.
1 
7 #include <internal.h>
8 #include <math.h>
9 #include <stdio.h>
10 
11 typedef int (__cdecl *fUserMathErr)(struct _exception *);
13 
14 void __mingw_raise_matherr (int typ, const char *name, double a1, double a2,
15  double rslt)
16 {
17  struct _exception ex;
18  if (!stUserMathErr)
19  return;
20  ex.type = typ;
21  ex.name = (char*)name;
22  ex.arg1 = a1;
23  ex.arg2 = a2;
24  ex.retval = rslt;
25  (*stUserMathErr)(&ex);
26 }
27 
28 #undef __setusermatherr
29 
30 void __mingw_setusermatherr (int (__cdecl *f)(struct _exception *))
31 {
32  stUserMathErr = f;
34 }
35 
36 int __CRTDECL
37 _matherr (struct _exception *pexcept)
38 {
39  const char * type;
40 
41  switch(pexcept->type)
42  {
43  case _DOMAIN:
44  type = "Argument domain error (DOMAIN)";
45  break;
46 
47  case _SING:
48  type = "Argument singularity (SIGN)";
49  break;
50 
51  case _OVERFLOW:
52  type = "Overflow range error (OVERFLOW)";
53  break;
54 
55  case _PLOSS:
56  type = "Partial loss of significance (PLOSS)";
57  break;
58 
59  case _TLOSS:
60  type = "Total loss of significance (TLOSS)";
61  break;
62 
63  case _UNDERFLOW:
64  type = "The result is too small to be represented (UNDERFLOW)";
65  break;
66 
67  default:
68  type = "Unknown error";
69  break;
70  }
71 
72  __mingw_fprintf (stderr, "_matherr(): %s in %s(%g, %g) (retval=%g)\n",
73  type, pexcept->name, pexcept->arg1, pexcept->arg2, pexcept->retval);
74  return 0;
75 }
76 
#define _DOMAIN
Definition: math.h:39
Definition: comerr.c:44
double arg2
Definition: math.h:24
#define _PLOSS
Definition: math.h:44
#define __cdecl
Definition: accygwin.h:79
void CDECL __setusermatherr(MSVCRT_matherr_func func)
Definition: matherr.c:45
char * name
Definition: math.h:22
void __mingw_raise_matherr(int typ, const char *name, double a1, double a2, double rslt)
Definition: merr.c:14
int type
Definition: math.h:21
void __mingw_setusermatherr(int(__cdecl *f)(struct _exception *))
Definition: merr.c:30
int __CRTDECL _matherr(struct _exception *pexcept)
Definition: merr.c:37
#define _SING
Definition: math.h:40
static fUserMathErr stUserMathErr
Definition: merr.c:12
GLfloat f
Definition: glext.h:7540
static const struct update_accum a2
Definition: msg.c:586
double retval
Definition: math.h:25
#define _TLOSS
Definition: math.h:43
#define _UNDERFLOW
Definition: math.h:42
#define __CRTDECL
Definition: crtdefs.h:159
#define f
Definition: ke_i.h:83
int(__cdecl * fUserMathErr)(struct _exception *)
Definition: merr.c:11
double arg1
Definition: math.h:23
Definition: name.c:38
FILE * stderr
static const struct update_accum a1
Definition: msg.c:578
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define _OVERFLOW
Definition: math.h:41
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31