Mercurial > cpython-lru_cache-weakref
annotate Modules/fpetestmodule.c @ 16798:258dcafe2d0b legacy-trunk
Gustavo Niemeyer <niemeyer@conectiva.com>:
Fixed recno support (keys are integers rather than strings).
Work around DB bug that cause stdin to be closed by rnopen() when the
DB file needed to exist but did not (no longer segfaults).
This closes SF tracker patch #403445.
Also wrapped some long lines and added whitespace around operators -- FLD.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 27 Feb 2001 18:56:46 +0000 |
| parents | 179fb63b1554 |
| children | 40631ae74b17 |
| rev | line source |
|---|---|
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 /* |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 --------------------------------------------------------------------- |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 / Copyright (c) 1996. \ |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 | The Regents of the University of California. | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 | All rights reserved. | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 | | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 | Permission to use, copy, modify, and distribute this software for | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 | any purpose without fee is hereby granted, provided that this en- | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 | tire notice is included in all copies of any software which is or | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 | includes a copy or modification of this software and in all | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 | copies of the supporting documentation for such software. | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 | | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 | This work was produced at the University of California, Lawrence | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 | Livermore National Laboratory under contract no. W-7405-ENG-48 | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 | between the U.S. Department of Energy and The Regents of the | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 | University of California for the operation of UC LLNL. | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 | | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 | DISCLAIMER | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 | | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 | This software was prepared as an account of work sponsored by an | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 | agency of the United States Government. Neither the United States | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 | Government nor the University of California nor any of their em- | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 | ployees, makes any warranty, express or implied, or assumes any | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 | liability or responsibility for the accuracy, completeness, or | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 | usefulness of any information, apparatus, product, or process | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 | disclosed, or represents that its use would not infringe | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 | privately-owned rights. Reference herein to any specific commer- | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 | cial products, process, or service by trade name, trademark, | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 | manufacturer, or otherwise, does not necessarily constitute or | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 | imply its endorsement, recommendation, or favoring by the United | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 | States Government or the University of California. The views and | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 | opinions of authors expressed herein do not necessarily state or | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 | reflect those of the United States Government or the University | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 | of California, and shall not be used for advertising or product | |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 \ endorsement purposes. / |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 --------------------------------------------------------------------- |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 */ |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 /* |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 Floating point exception test module. |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 */ |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 #include "Python.h" |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 static PyObject *fpe_error; |
|
9620
179fb63b1554
Needed to add DL_EXPORT to (redundant?) extern decl of module init function.
Guido van Rossum <guido@python.org>
parents:
9588
diff
changeset
|
47 DL_EXPORT(void) initfpetest(void); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 static PyObject *test(PyObject *self,PyObject *args); |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
49 static double db0(double); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
50 static double overflow(double); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
51 static double nest1(int, double); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
52 static double nest2(int, double); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 static double nest3(double); |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
54 static void printerr(double); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 static PyMethodDef fpetest_methods[] = { |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 {"test", (PyCFunction) test, 1}, |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 {0,0} |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 }; |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 static PyObject *test(PyObject *self,PyObject *args) |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 { |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
63 double r; |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
65 fprintf(stderr,"overflow"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
66 r = overflow(1.e160); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
67 printerr(r); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
69 fprintf(stderr,"\ndiv by 0"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
70 r = db0(0.0); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
71 printerr(r); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
73 fprintf(stderr,"\nnested outer"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
74 r = nest1(0, 0.0); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
75 printerr(r); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
77 fprintf(stderr,"\nnested inner"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
78 r = nest1(1, 1.0); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
79 printerr(r); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
81 fprintf(stderr,"\ntrailing outer"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
82 r = nest1(2, 2.0); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
83 printerr(r); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
85 fprintf(stderr,"\nnested prior"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
86 r = nest2(0, 0.0); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
87 printerr(r); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
89 fprintf(stderr,"\nnested interior"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
90 r = nest2(1, 1.0); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
91 printerr(r); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
93 fprintf(stderr,"\nnested trailing"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
94 r = nest2(2, 2.0); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
95 printerr(r); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 Py_INCREF (Py_None); |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 return Py_None; |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 } |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
101 static void printerr(double r) |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
102 { |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
103 if(r == 3.1416){ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
104 fprintf(stderr,"\tPASS\n"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
105 PyErr_Print(); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
106 }else{ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
107 fprintf(stderr,"\tFAIL\n"); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
108 } |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
109 PyErr_Clear(); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
110 } |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
111 |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
112 static double nest1(int i, double x) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 { |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 double a = 1.0; |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
115 |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
116 PyFPE_START_PROTECT("Division by zero, outer zone", return 3.1416) |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
117 if(i == 0){ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
118 a = 1./x; |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
119 }else if(i == 1){ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
120 /* This (following) message is never seen. */ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
121 PyFPE_START_PROTECT("Division by zero, inner zone", return 3.1416) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 a = 1./(1. - x); |
|
5197
74c12704a0bd
New form of PyFPE_END_PROTECT macro.
Guido van Rossum <guido@python.org>
parents:
5147
diff
changeset
|
123 PyFPE_END_PROTECT(a) |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
124 }else if(i == 2){ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
125 a = 1./(2. - x); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
126 } |
|
5197
74c12704a0bd
New form of PyFPE_END_PROTECT macro.
Guido van Rossum <guido@python.org>
parents:
5147
diff
changeset
|
127 PyFPE_END_PROTECT(a) |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
128 |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
129 return a; |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 } |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
132 static double nest2(int i, double x) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 { |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 double a = 1.0; |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
135 PyFPE_START_PROTECT("Division by zero, prior error", return 3.1416) |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
136 if(i == 0){ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
137 a = 1./x; |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
138 }else if(i == 1){ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
139 a = nest3(x); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
140 }else if(i == 2){ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
141 a = 1./(2. - x); |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
142 } |
|
5197
74c12704a0bd
New form of PyFPE_END_PROTECT macro.
Guido van Rossum <guido@python.org>
parents:
5147
diff
changeset
|
143 PyFPE_END_PROTECT(a) |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
144 return a; |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 } |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 static double nest3(double x) |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 { |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 double result; |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
150 /* This (following) message is never seen. */ |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
151 PyFPE_START_PROTECT("Division by zero, nest3 error", return 3.1416) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 result = 1./(1. - x); |
|
5197
74c12704a0bd
New form of PyFPE_END_PROTECT macro.
Guido van Rossum <guido@python.org>
parents:
5147
diff
changeset
|
153 PyFPE_END_PROTECT(result) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
154 return result; |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 } |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
157 static double db0(double x) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 { |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
159 double a; |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
160 PyFPE_START_PROTECT("Division by zero", return 3.1416) |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
161 a = 1./x; |
|
5197
74c12704a0bd
New form of PyFPE_END_PROTECT macro.
Guido van Rossum <guido@python.org>
parents:
5147
diff
changeset
|
162 PyFPE_END_PROTECT(a) |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
163 return a; |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 } |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
166 static double overflow(double b) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 { |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
168 double a; |
|
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
169 PyFPE_START_PROTECT("Overflow", return 3.1416) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 a = b*b; |
|
5197
74c12704a0bd
New form of PyFPE_END_PROTECT macro.
Guido van Rossum <guido@python.org>
parents:
5147
diff
changeset
|
171 PyFPE_END_PROTECT(a) |
|
5147
b227b9af5f53
Lee's next version. Careful: this now dumps core for me on SGI IRIX 5.3.
Guido van Rossum <guido@python.org>
parents:
5120
diff
changeset
|
172 return a; |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 } |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 |
|
9588
38023a425e48
Add DL_EXPORT() to all modules that could possibly be used
Guido van Rossum <guido@python.org>
parents:
6367
diff
changeset
|
175 DL_EXPORT(void) initfpetest(void) |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 { |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 PyObject *m, *d; |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 m = Py_InitModule("fpetest", fpetest_methods); |
|
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 d = PyModule_GetDict(m); |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
5197
diff
changeset
|
181 fpe_error = PyErr_NewException("fpetest.error", NULL, NULL); |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
5197
diff
changeset
|
182 if (fpe_error != NULL) |
|
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
5197
diff
changeset
|
183 PyDict_SetItemString(d, "error", fpe_error); |
|
5120
a48f3678f9e1
Changes for Lee Busby's SIGFPE patch set.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 } |
