Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
PythonIniOS/Python-iOS/libPython/Modules/fpetestmodule.c at master · SuPair/PythonIniOS · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
SuPair
/
PythonIniOS
Public
forked from
koalahl/PythonIniOS
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
PythonIniOS
/
Python-iOS
/
libPython
/
Modules
/
fpetestmodule.c
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
186 lines (161 loc) · 5.53 KB
master
Breadcrumbs
PythonIniOS
/
Python-iOS
/
libPython
/
Modules
/
fpetestmodule.c
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
186 lines (161 loc) · 5.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
---------------------------------------------------------------------
/ Copyright (c) 1996. \
| The Regents of the University of California. |
| All rights reserved. |
| |
| Permission to use, copy, modify, and distribute this software for |
| any purpose without fee is hereby granted, provided that this en- |
| tire notice is included in all copies of any software which is or |
| includes a copy or modification of this software and in all |
| copies of the supporting documentation for such software. |
| |
| This work was produced at the University of California, Lawrence |
| Livermore National Laboratory under contract no. W-7405-ENG-48 |
| between the U.S. Department of Energy and The Regents of the |
| University of California for the operation of UC LLNL. |
| |
| DISCLAIMER |
| |
| This software was prepared as an account of work sponsored by an |
| agency of the United States Government. Neither the United States |
| Government nor the University of California nor any of their em- |
| ployees, makes any warranty, express or implied, or assumes any |
| liability or responsibility for the accuracy, completeness, or |
| usefulness of any information, apparatus, product, or process |
| disclosed, or represents that its use would not infringe |
| privately-owned rights. Reference herein to any specific commer- |
| cial products, process, or service by trade name, trademark, |
| manufacturer, or otherwise, does not necessarily constitute or |
| imply its endorsement, recommendation, or favoring by the United |
| States Government or the University of California. The views and |
| opinions of authors expressed herein do not necessarily state or |
| reflect those of the United States Government or the University |
| of California, and shall not be used for advertising or product |
\ endorsement purposes. /
---------------------------------------------------------------------
*/
/*
Floating point exception test module.
*/
#include
"Python.h"
static
PyObject
*
fpe_error
;
PyMODINIT_FUNC
initfpetest
(
void
);
static
PyObject
*
test
(
PyObject
*
self
,
PyObject
*
args
);
static
double
db0
(
double
);
static
double
overflow
(
double
);
static
double
nest1
(
int
,
double
);
static
double
nest2
(
int
,
double
);
static
double
nest3
(
double
);
static
void
printerr
(
double
);
static
PyMethodDef
fpetest_methods
[]
=
{
{
"test"
, (
PyCFunction
)
test
,
METH_VARARGS
},
{
0
,
0
}
};
static
PyObject
*
test
(
PyObject
*
self
,
PyObject
*
args
)
{
double
r
;
fprintf
(
stderr
,
"overflow"
);
r
=
overflow
(
1.e160
);
printerr
(
r
);
fprintf
(
stderr
,
"\ndiv by 0"
);
r
=
db0
(
0.0
);
printerr
(
r
);
fprintf
(
stderr
,
"\nnested outer"
);
r
=
nest1
(
0
,
0.0
);
printerr
(
r
);
fprintf
(
stderr
,
"\nnested inner"
);
r
=
nest1
(
1
,
1.0
);
printerr
(
r
);
fprintf
(
stderr
,
"\ntrailing outer"
);
r
=
nest1
(
2
,
2.0
);
printerr
(
r
);
fprintf
(
stderr
,
"\nnested prior"
);
r
=
nest2
(
0
,
0.0
);
printerr
(
r
);
fprintf
(
stderr
,
"\nnested interior"
);
r
=
nest2
(
1
,
1.0
);
printerr
(
r
);
fprintf
(
stderr
,
"\nnested trailing"
);
r
=
nest2
(
2
,
2.0
);
printerr
(
r
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
void
printerr
(
double
r
)
{
if
(
r
==
3.1416
){
fprintf
(
stderr
,
"\tPASS\n"
);
PyErr_Print
();
}
else
{
fprintf
(
stderr
,
"\tFAIL\n"
);
}
PyErr_Clear
();
}
static
double
nest1
(
int
i
,
double
x
)
{
double
a
=
1.0
;
PyFPE_START_PROTECT
(
"Division by zero, outer zone"
,
return
3.1416
)
if
(
i
==
0
){
a
=
1.
/
x
;
}
else
if
(
i
==
1
){
/* This (following) message is never seen. */
PyFPE_START_PROTECT
(
"Division by zero, inner zone"
,
return
3.1416
)
a
=
1.
/(
1.
-
x
);
PyFPE_END_PROTECT
(
a
)
}
else
if
(
i
==
2
){
a
=
1.
/(
2.
-
x
);
}
PyFPE_END_PROTECT
(
a
)
return
a
;
}
static
double
nest2
(
int
i
,
double
x
)
{
double
a
=
1.0
;
PyFPE_START_PROTECT
(
"Division by zero, prior error"
,
return
3.1416
)
if
(
i
==
0
){
a
=
1.
/
x
;
}
else
if
(
i
==
1
){
a
=
nest3
(
x
);
}
else
if
(
i
==
2
){
a
=
1.
/(
2.
-
x
);
}
PyFPE_END_PROTECT
(
a
)
return
a
;
}
static
double
nest3
(
double
x
)
{
double
result
;
/* This (following) message is never seen. */
PyFPE_START_PROTECT
(
"Division by zero, nest3 error"
,
return
3.1416
)
result
=
1.
/(
1.
-
x
);
PyFPE_END_PROTECT
(
result
)
return
result
;
}
static
double
db0
(
double
x
)
{
double
a
;
PyFPE_START_PROTECT
(
"Division by zero"
,
return
3.1416
)
a
=
1.
/
x
;
PyFPE_END_PROTECT
(
a
)
return
a
;
}
static
double
overflow
(
double
b
)
{
double
a
;
PyFPE_START_PROTECT
(
"Overflow"
,
return
3.1416
)
a
=
b
*
b
;
PyFPE_END_PROTECT
(
a
)
return
a
;
}
PyMODINIT_FUNC
initfpetest
(
void
)
{
PyObject
*
m
,
*
d
;
m
=
Py_InitModule
(
"fpetest"
,
fpetest_methods
);
if
(
m
==
NULL
)
return
;
d
=
PyModule_GetDict
(
m
);
fpe_error
=
PyErr_NewException
(
"fpetest.error"
,
NULL
,
NULL
);
if
(
fpe_error
!=
NULL
)
PyDict_SetItemString
(
d
,
"error"
,
fpe_error
);
}
You can’t perform that action at this time.