| delorie.com/archives/browse.cgi | search |
On Fri, Jul 1, 2011 at 8:53 PM, DJ Delorie <dj AT delorie DOT com> wrote:
>
>> Old gcc?
>
> Do we really want to support gcc older than 2.95 ?
>
I guess not.
Quick'n'dirty patch below. Tested comqilation using gcc-3.3.6
and 4.4.7. (Can't test anything older than 3.3 at the moment.)
If OK, use it and abuse it.
Index: w_cabs.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libm/math/w_cabs.c,v
retrieving revision 1.3
diff -u -p -r1.3 w_cabs.c
--- w_cabs.c 14 Dec 1999 12:01:34 -0000 1.3
+++ w_cabs.c 1 Jul 2011 18:01:44 -0000
@@ -9,18 +9,8 @@
#include "fdlibm.h"
-struct complex {
- double x;
- double y;
-};
-
-#ifdef __STDC__
-double cabs(struct complex);
-double cabs(struct complex z)
-#else
-double cabs(z)
- struct complex z;
-#endif
+double cabs(double _Complex);
+double cabs(double _Complex z)
{
- return hypot(z.x, z.y);
+ return hypot(__real__ z, __imag__ z);
}
Index: wf_cabs.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libm/math/wf_cabs.c,v
retrieving revision 1.3
diff -u -p -r1.3 wf_cabs.c
--- wf_cabs.c 14 Dec 1999 12:01:34 -0000 1.3
+++ wf_cabs.c 1 Jul 2011 18:01:44 -0000
@@ -9,18 +9,8 @@
#include "fdlibm.h"
-struct complex {
- float x;
- float y;
-};
-
-#ifdef __STDC__
-float cabsf(struct complex);
-float cabsf(struct complex z)
-#else
-float cabsf(z)
- struct complex z;
-#endif
+float cabsf(float _Complex);
+float cabsf(float _Complex z)
{
- return hypotf(z.x, z.y);
+ return hypotf(__real__ z, __imag__ z);
}
--
O.S.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |