summaryrefslogtreecommitdiffstats
path: root/lib/msun
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2001-06-13 15:16:30 +0000
committerru <ru@FreeBSD.org>2001-06-13 15:16:30 +0000
commit0d5bbb03497fb236d7d90377834431974b0614da (patch)
tree37b7552d4bd478688101be23177232d72f8186b9 /lib/msun
parent086630c576392797f494de067ba6ca5608875b1a (diff)
downloadFreeBSD-src-0d5bbb03497fb236d7d90377834431974b0614da.zip
FreeBSD-src-0d5bbb03497fb236d7d90377834431974b0614da.tar.gz
Added skeleton <complex.h> (aligned with the POSIX.1-200x), mostly
to fix the "-nostdinc WARNS=X" breakage caused by broken prototypes for cabs() and cabsl() in <math.h>. Reimplemented cabs() and cabsl() using new complex numbers types and moved prototypes from <math.h> to <complex.h>.
Diffstat (limited to 'lib/msun')
-rw-r--r--lib/msun/src/math.h2
-rw-r--r--lib/msun/src/w_cabs.c19
-rw-r--r--lib/msun/src/w_cabsf.c18
3 files changed, 20 insertions, 19 deletions
diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h
index e26e39f..e5a5e16 100644
--- a/lib/msun/src/math.h
+++ b/lib/msun/src/math.h
@@ -174,7 +174,6 @@ extern double scalbn __P((double, int));
/*
* BSD math library entry points
*/
-extern double cabs();
extern double drem __P((double, double));
extern double expm1 __P((double));
extern double log1p __P((double));
@@ -257,7 +256,6 @@ extern float scalbnf __P((float, int));
/*
* float versions of BSD math library entry points
*/
-extern float cabsf ();
extern float dremf __P((float, float));
extern float expm1f __P((float));
extern float log1pf __P((float));
diff --git a/lib/msun/src/w_cabs.c b/lib/msun/src/w_cabs.c
index b140515..a33a41f 100644
--- a/lib/msun/src/w_cabs.c
+++ b/lib/msun/src/w_cabs.c
@@ -5,23 +5,24 @@
* Placed into the Public Domain, 1994.
*/
-#include <math.h>
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
-struct complex {
- double x;
- double y;
-};
+#include <complex.h>
+#include <math.h>
double
cabs(z)
- struct complex z;
+ double complex z;
{
- return hypot(z.x, z.y);
+ return hypot(creal(z), cimag(z));
}
double
z_abs(z)
- struct complex *z;
+ double complex *z;
{
- return hypot(z->x, z->y);
+ return hypot(creal(*z), cimag(*z));
}
diff --git a/lib/msun/src/w_cabsf.c b/lib/msun/src/w_cabsf.c
index 6336d6d..e7bfe22 100644
--- a/lib/msun/src/w_cabsf.c
+++ b/lib/msun/src/w_cabsf.c
@@ -5,17 +5,19 @@
* Placed into the Public Domain, 1994.
*/
-#include "math.h"
-#include "math_private.h"
+#ifndef lint
+static const char rcsid[] =
+ "$FreeBSD$";
+#endif /* not lint */
-struct complex {
- float x;
- float y;
-};
+#include <complex.h>
+#include <math.h>
+#include "math_private.h"
float
cabsf(z)
- struct complex z;
+ float complex z;
{
- return hypotf(z.x, z.y);
+
+ return hypotf(crealf(z), cimagf(z));
}
OpenPOWER on IntegriCloud