mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: printf issues
Date: Fri, 4 Apr 2014 16:15:16 +0200	[thread overview]
Message-ID: <20140404141515.GD3034@port70.net> (raw)
In-Reply-To: <CANv4PNn7=o6bNb5YzhiH39gTfiNFfj8G2P2FxH7XcYF3gx9VxA@mail.gmail.com>

* Morten Welinder <mwelinder@gmail.com> [2014-04-04 09:32:18 -0400]:
> Unrelatedly, from function fmt_fp:
> 
> #define CONCAT2(x,y) x ## y
> #define CONCAT(x,y) CONCAT2(x,y)
> [...]
>             long double round = CONCAT(0x1p,LDBL_MANT_DIG);
> 
> That code is cute as a Hello Kitty door knocker, but really?  Let's hope nobody
> gets the urge to define LDBL_MANT_DIG as 0100 or (80-16) or some such.

before you can mock libc code you need to educate yourself

LDBL_MANT_DIG is an identifier (macro definition) that is
defined by the libc itself (in arch/$ARCH/bits/float.h),
not by the application, nor by the compiler

the libc can internally rely on a different contract about
the identifiers it defines, than application code that has
to rely on the external contracts specified by ISO C

so outside the implementation you shouldn't use such a code
because there is no guarantee how LDBL_MANT_DIG is defined,
but internally the libc knows how it defined its symbols and
thus the code is perfectly reasonable

(this distinction between public interface contracts and
implementation internal interface contracts is often
misunderstood: so don't copy-paste code between libc and
application code without thinking and don't try to reason
about APIs/ABIs used inside the libc based on the public
specification of those APIs/ABIs)


  parent reply	other threads:[~2014-04-04 14:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-04 13:32 Morten Welinder
2014-04-04 14:12 ` Rich Felker
2014-04-04 14:15 ` Szabolcs Nagy [this message]
2014-04-04 14:35   ` Morten Welinder
2014-04-04 14:56     ` Szabolcs Nagy
2014-04-04 15:07     ` Rich Felker
2014-04-04 17:42       ` Morten Welinder
2014-04-04 18:54         ` Szabolcs Nagy
2014-04-04 20:01           ` Morten Welinder
2014-04-04 20:22             ` Morten Welinder
2014-04-04 21:08               ` Rich Felker
2014-04-04 22:50                 ` Morten Welinder
2014-04-05  0:01                   ` Morten Welinder
2014-04-05  1:41                     ` Rich Felker
2014-04-07  7:29                     ` Rich Felker
2014-04-07 13:40                       ` Morten Welinder
2014-04-07 14:13                         ` Morten Welinder
2014-04-07 15:36                           ` Szabolcs Nagy
2014-04-07 18:04                             ` Rich Felker
2014-04-04 20:54             ` Szabolcs Nagy
2014-04-04 21:02             ` Rich Felker
2014-04-05  2:08               ` Morten Welinder
2014-04-05  2:50                 ` Rich Felker
2014-04-06 23:07                   ` Szabolcs Nagy
2014-04-04 21:00           ` Rich Felker
2014-04-04 21:10             ` Szabolcs Nagy
2014-04-04 20:58         ` Rich Felker

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=20140404141515.GD3034@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).