Skip to content

Commit 2eba8eb

Browse files
committed
17602 atan2(0.0, -0.0) sets errno unexpectedly
Reviewed by: ixi meow <illumos@iximeow.net> Reviewed by: Dan Cross <cross@oxidecomputer.com> Reviewed by: Marcel Telka <marcel@telka.sk> Approved by: Dan McDonald <danmcd@edgecast.io>
1 parent 5882dd1 commit 2eba8eb

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎usr/src/lib/libm/common/C/_SVID_error.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121
/*
2222
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23+
* Copyright 2025 OmniOS Community Edition (OmniOSce) Association.
2324
*/
2425
/*
2526
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
@@ -120,7 +121,8 @@ static const union {
120121
#define Inf HUGE_VAL
121122

122123
double
123-
_SVID_libm_err(double x, double y, int type) {
124+
_SVID_libm_err(double x, double y, int type)
125+
{
124126
struct exception exc;
125127
double t, w, ieee_retval = 0;
126128
enum version lib_version = _lib_version;
@@ -172,11 +174,11 @@ _SVID_libm_err(double x, double y, int type) {
172174
exc.type = DOMAIN;
173175
exc.name = "atan2";
174176
ieee_retval = copysign(1.0, x) == 1.0 ? y :
175-
copysign(PI_RZ + DBL_MIN, y);
177+
copysign(PI_RZ + DBL_MIN, y);
176178
exc.retval = 0.0;
177179
if (lib_version == strict_ansi) {
178180
errno = EDOM;
179-
} else if (!matherr(&exc)) {
181+
} else if (lib_version != libm_ieee && !matherr(&exc)) {
180182
if (lib_version == c_issue_4) {
181183
(void) write(2, "atan2: DOMAIN error\n", 20);
182184
}
@@ -515,9 +517,9 @@ _SVID_libm_err(double x, double y, int type) {
515517
/* INDENT OFF */
516518
/*
517519
* determine if y is an odd int when x = -0
518-
* yisint = 0 ... y is not an integer
519-
* yisint = 1 ... y is an odd int
520-
* yisint = 2 ... y is an even int
520+
* yisint = 0 ... y is not an integer
521+
* yisint = 1 ... y is an odd int
522+
* yisint = 2 ... y is an even int
521523
*/
522524
/* INDENT ON */
523525
hx = __HI(x);
@@ -856,7 +858,7 @@ _SVID_libm_err(double x, double y, int type) {
856858
if (lib_version == strict_ansi) {
857859
exc.retval = 1.0;
858860
} else if (!matherr(&exc)) {
859-
if ((lib_version == c_issue_4) || (lib_version == ansi_1))
861+
if (lib_version == c_issue_4 || lib_version == ansi_1)
860862
errno = EDOM;
861863
}
862864
break;
@@ -948,7 +950,8 @@ _SVID_libm_err(double x, double y, int type) {
948950
}
949951

950952
static double
951-
setexception(int n, double x) {
953+
setexception(int n, double x)
954+
{
952955
/*
953956
* n =
954957
* 0 division by zero

0 commit comments

Comments
 (0)