mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: making math.h c89 compatible
Date: Mon, 23 Jul 2012 00:25:21 +0200	[thread overview]
Message-ID: <20120722222521.GH14463@port70.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 117 bytes --]

__FLOAT_BITS macro uses compound literal
i think this is the only case where
standard c header is not c89 compatible

[-- Attachment #2: math.h.diff --]
[-- Type: text/x-diff, Size: 1110 bytes --]

diff --git a/include/math.h b/include/math.h
index d732648..ffde3da 100644
--- a/include/math.h
+++ b/include/math.h
@@ -44,8 +44,13 @@ int __fpclassifyl(long double);
 union __float_repr { float __f; __uint32_t __i; };
 union __double_repr { double __f; __uint64_t __i; };
 
+#if __STDC_VERSION__ >= 199901L
 #define __FLOAT_BITS(f) (((union __float_repr){ (float)(f) }).__i)
 #define __DOUBLE_BITS(f) (((union __double_repr){ (double)(f) }).__i)
+#else
+static __uint32_t __FLOAT_BITS(float __f) { union __float_repr __u = {__f}; return __u.__i; }
+static __uint64_t __DOUBLE_BITS(double __f) { union __double_repr __u = {__f}; return __u.__i; }
+#endif
 
 #define fpclassify(x) ( \
 	sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
@@ -199,8 +204,8 @@ float       fmodf(float, float);
 long double fmodl(long double, long double);
 
 double      frexp(double, int *);
-float       frexpf(float value, int *);
-long double frexpl(long double value, int *);
+float       frexpf(float, int *);
+long double frexpl(long double, int *);
 
 double      hypot(double, double);
 float       hypotf(float, float);

                 reply	other threads:[~2012-07-22 22:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120722222521.GH14463@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).