standard libraries

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jacob navia

    #31
    Re: standard libraries

    Mark McIntyre wrote:
    On Wed, 04 Oct 2006 22:19:49 +0200, in comp.lang.c , jacob navia
    <jacob@jacob.re mcomp.frwrote:
    >
    >
    >>those who know me have no need of my name wrote:
    >>
    >>>"real"!?!? ! as someone that produces a c implementation you surprise me.
    >>>ms' long double is just as real as gcc's. t
    >>
    >>Can't you read?
    >
    >
    Can't you read?
    >
    the PP was responding to the part you snipped, in which you said that
    MS's long doubles were not real long doubles. Since this is false, he
    felt you need called on it.
    >
    Yeah...

    Making long doubles the same as doubles means that there is no
    higher precision floating point. Technically you are right,
    we can have float == double == long double... but excuse me
    there is then only floats and other "types" are just synonyms.

    According to the words of the standard the above is legal, but
    according to my point of view that is just playing with
    words.

    Comment

    • Richard Heathfield

      #32
      Re: standard libraries

      jacob navia said:
      those who know me have no need of my name wrote:
      >>
      >"real"!?!?! as someone that produces a c implementation you surprise me.
      >ms' long double is just as real as gcc's. that they are different is not
      >significant except to people writing programs based solely on
      >assumptions. differences between implementations is why <limits.hand
      ><math.hprovi de most of the macros they provide, so that people can
      >write programs that will work sensibly.
      >>
      >
      Can't you read?
      You might want to limit the number of experts you're fighting with at a
      time, or your fingers will get awfully tired.

      The problem is that the gcc compiler used by mingw assumes gcc's
      long doubles with 80 bits, and CRTDLL.DLL, the run time library
      assumes microsoft "long doubles" with 64 bits!!
      Oh look. If, for a change, you are correct (and I have no reason to doubt it
      here), it appears that some idiot changed the rules by changing a DLL, and
      broke working software as a result. That sounds very familiar. DLLs? Just
      say no.

      --
      Richard Heathfield
      "Usenet is a strange place" - dmr 29/7/1999

      email: rjh at above domain (but drop the www, obviously)

      Comment

      • CBFalconer

        #33
        Re: standard libraries

        Richard Heathfield wrote:
        jacob navia said:
        >
        .... snip ...
        >>
        >The problem is that the gcc compiler used by mingw assumes gcc's
        >long doubles with 80 bits, and CRTDLL.DLL, the run time library
        >assumes microsoft "long doubles" with 64 bits!!
        >
        Oh look. If, for a change, you are correct (and I have no reason
        to doubt it here), it appears that some idiot changed the rules by
        changing a DLL, and broke working software as a result. That
        sounds very familiar. DLLs? Just say no.
        No need to go that far. As an implementor, Jacob can easily catch
        all printf calls in his own run-time library via a suitable #define
        of printf, examine them for long double access, and pass them on
        lacking such. Otherwise it may be possible to substitute for the
        appropriate routine in the CRTDLL printf interpreter, or to provide
        a complete printf replacement. I leave the hairy details to Jacob.

        --
        Some informative links:
        <news:news.anno unce.newusers
        <http://www.geocities.c om/nnqweb/>
        <http://www.catb.org/~esr/faqs/smart-questions.html>
        <http://www.caliburn.nl/topposting.html >
        <http://www.netmeister. org/news/learn2quote.htm l>
        <http://cfaj.freeshell. org/google/>


        Comment

        • Keith Thompson

          #34
          Re: standard libraries

          CBFalconer <cbfalconer@yah oo.comwrites:
          [...]
          No need to go that far. As an implementor, Jacob can easily catch
          all printf calls in his own run-time library via a suitable #define
          of printf, examine them for long double access, and pass them on
          lacking such. Otherwise it may be possible to substitute for the
          appropriate routine in the CRTDLL printf interpreter, or to provide
          a complete printf replacement. I leave the hairy details to Jacob.
          The #define trick won't quite do it. This has to work correctly:

          #include <stdio.h>
          int main(void)
          {
          #undef printf
          long double d = 123.456;
          printf("d = %Lg\n", d);
          return 0;
          }

          --
          Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
          San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
          We must do something. This is something. Therefore, we must do this.

          Comment

          • Ben Pfaff

            #35
            Re: standard libraries

            CBFalconer <cbfalconer@yah oo.comwrites:
            As an implementor, Jacob can easily catch all printf calls in
            his own run-time library via a suitable #define of printf,
            examine them for long double access, and pass them on lacking
            such.
            I doubt this, because programmers are allowed to #undef standard
            library macros to expose the underlying functions. It sounds
            like the macro you're suggesting would be needed for correct
            operation, not just for an optimization.
            --
            "For those who want to translate C to Pascal, it may be that a lobotomy
            serves your needs better." --M. Ambuhl

            "Here are the steps to create a C-to-Turbo-Pascal translator..." --H. Schildt

            Comment

            • jacob navia

              #36
              Re: standard libraries

              CBFalconer wrote:
              Richard Heathfield wrote:
              >
              >>jacob navia said:
              >>
              >
              ... snip ...
              >
              >>>The problem is that the gcc compiler used by mingw assumes gcc's
              >>>long doubles with 80 bits, and CRTDLL.DLL, the run time library
              >>>assumes microsoft "long doubles" with 64 bits!!
              >>
              >>Oh look. If, for a change, you are correct (and I have no reason
              >>to doubt it here), it appears that some idiot changed the rules by
              >>changing a DLL, and broke working software as a result. That
              >>sounds very familiar. DLLs? Just say no.
              >
              >
              No need to go that far. As an implementor, Jacob can easily catch
              all printf calls in his own run-time library via a suitable #define
              of printf, examine them for long double access, and pass them on
              lacking such. Otherwise it may be possible to substitute for the
              appropriate routine in the CRTDLL printf interpreter, or to provide
              a complete printf replacement. I leave the hairy details to Jacob.
              >
              Yeah, a good printf implementation for C99 is hard.
              I know that :-)

              I have a good one now. I treat even denormal numbers, printing them
              exactly like gcc's printf. I squeeze as much precision in double
              and long double precision as possible. Besides, several extensions
              that lcc-win32 provides (qfloats for instance) are supported
              transparently. You can print qfloats (352 bits floats) just with

              printf("%120.10 0Qf\n",q);

              Other "goodies" I am implementing now are the modifications needed
              for the safe C library, where
              printf_s("%s",s trlen(str),str) ;

              The %s directive takes an integer size of the following string.

              Comment

              • jacob navia

                #37
                Re: standard libraries

                Keith Thompson wrote:
                CBFalconer <cbfalconer@yah oo.comwrites:
                [...]
                >
                >>No need to go that far. As an implementor, Jacob can easily catch
                >>all printf calls in his own run-time library via a suitable #define
                >>of printf, examine them for long double access, and pass them on
                >>lacking such. Otherwise it may be possible to substitute for the
                >>appropriate routine in the CRTDLL printf interpreter, or to provide
                >>a complete printf replacement. I leave the hairy details to Jacob.
                >
                >
                The #define trick won't quite do it. This has to work correctly:
                >
                #include <stdio.h>
                int main(void)
                {
                #undef printf
                long double d = 123.456;
                printf("d = %Lg\n", d);
                return 0;
                }
                >
                Yes. At the beginning I had a hack like that, but now I have
                py own version of printf, C99 compliant.

                Comment

                • Walter Roberson

                  #38
                  Re: standard libraries

                  In article <45255fbd$0$510 7$ba4acef3@news .orange.fr>,
                  jacob navia <jacob@jacob.re mcomp.frwrote:
                  >Other "goodies" I am implementing now are the modifications needed
                  >for the safe C library, where
                  >printf_s("%s", strlen(str),str );
                  >The %s directive takes an integer size of the following string.
                  I must be missing the point?

                  There is already printf("%.*s", (int)strlen(str ), str );
                  where .* causes the precision to be taken from the next argument
                  (which must be an int). The precision passed is the -maximum- number
                  of characters to use from the string -- fewer will be used
                  if the '\0' is hit earlier.

                  Both printf("%.*s", (int)strlen(str ), str ) and
                  printf_s("%s",s trlen(str),str)
                  at first glance would appear to have the same problem: if you
                  are relying on strlen() of the passed string to give you
                  information about the size of the string, then if the string is
                  not properly terminated, then you are going to pass in the wrong
                  size and The Fun Begins.

                  --
                  I was very young in those days, but I was also rather dim.
                  -- Christopher Priest

                  Comment

                  • jacob navia

                    #39
                    Re: standard libraries

                    Walter Roberson wrote:
                    In article <45255fbd$0$510 7$ba4acef3@news .orange.fr>,
                    jacob navia <jacob@jacob.re mcomp.frwrote:
                    >
                    >
                    >>Other "goodies" I am implementing now are the modifications needed
                    >>for the safe C library, where
                    >>printf_s("%s" ,strlen(str),st r);
                    >
                    >
                    >>The %s directive takes an integer size of the following string.
                    >
                    >
                    I must be missing the point?
                    >
                    There is already printf("%.*s", (int)strlen(str ), str );
                    where .* causes the precision to be taken from the next argument
                    (which must be an int). The precision passed is the -maximum- number
                    of characters to use from the string -- fewer will be used
                    if the '\0' is hit earlier.
                    >
                    Both printf("%.*s", (int)strlen(str ), str ) and
                    printf_s("%s",s trlen(str),str)
                    at first glance would appear to have the same problem: if you
                    are relying on strlen() of the passed string to give you
                    information about the size of the string, then if the string is
                    not properly terminated, then you are going to pass in the wrong
                    size and The Fun Begins.
                    >
                    1) I gave a wrong example (strlen, as you remark, is stupid!)
                    2) It is not printf but scanf, and I confused those. The scanf
                    %s argument starts reading and can be dangerous if there is no
                    length specified

                    The TR says:

                    The fscanf_s function is equivalent to fscanf except that the c, s, and
                    [ conversion
                    specifiers apply to a pair of arguments (unless assignment suppression
                    is indicated by a
                    *). The first of these arguments is the same as for fscanf. That argument is
                    immediately followed in the argument list by the second argument, which
                    has type
                    rsize_t and gives the number of elements in the array pointed to by the
                    first argument
                    of the pair. If the first argument points to a scalar object, it is
                    considered to be an array of
                    one element.

                    Comment

                    • CBFalconer

                      #40
                      Re: standard libraries

                      Ben Pfaff wrote:
                      CBFalconer <cbfalconer@yah oo.comwrites:
                      >
                      >As an implementor, Jacob can easily catch all printf calls in
                      >his own run-time library via a suitable #define of printf,
                      >examine them for long double access, and pass them on lacking
                      >such.
                      >
                      I doubt this, because programmers are allowed to #undef standard
                      library macros to expose the underlying functions. It sounds
                      like the macro you're suggesting would be needed for correct
                      operation, not just for an optimization.
                      He only needs to catch the printf calls in some body of code of his
                      own devising. The #define is obviously a flawed technique. But
                      whatever he does is system dependent, and he is controlling that
                      system. A definition of printf in a library loaded before the
                      system library would suffice. At any rate, the how is a murky
                      implementation detail.

                      --
                      Some informative links:
                      <news:news.anno unce.newusers
                      <http://www.geocities.c om/nnqweb/>
                      <http://www.catb.org/~esr/faqs/smart-questions.html>
                      <http://www.caliburn.nl/topposting.html >
                      <http://www.netmeister. org/news/learn2quote.htm l>
                      <http://cfaj.freeshell. org/google/>


                      Comment

                      Working...