Bug 272783 - Clean up libm use of the __ieee754_ prefix
Summary: Clean up libm use of the __ieee754_ prefix
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-numerics (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-28 20:58 UTC by Steve Kargl
Modified: 2023-08-13 08:45 UTC (History)
2 users (show)

See Also:


Attachments
patch to remove __ieee754_ prefix (40.79 KB, patch)
2023-07-28 20:58 UTC, Steve Kargl
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Kargl freebsd_committer freebsd_triage 2023-07-28 20:58:15 UTC
Created attachment 243675 [details]
patch to remove __ieee754_ prefix

This patch removes the __ieee754_ prefix from a number of the math
functions.  msun/src/math_private.h contains the statement that

  /*
   * ieee style elementary functions
   *
   * We rename functions here to improve other sources' diffability
   * against fdlibm.
   */
   #define        __ieee754_sqrt  sqrt
   ...

Here, fdlibm refers to https://netlib.org/fdlibm.  It is seen from
https://netlib.org/fdlibm/readme that this prefix was used to 
differentiate between different standards:

   Wrapper functions will twist the result of the ieee754 
   function to comply to the standard specified by the value 
   of _LIB_VERSION 
      if _LIB_VERSION = _IEEE_, return the ieee754 result;
      if _LIB_VERSION = _SVID_, return SVID result;
      if _LIB_VERSION = _XOPEN_, return XOPEN result;
      if _LIB_VERSION = _POSIX_, return POSIX/ANSI result.
   (These are macros, see fdlibm.h for their definition.)

AFAICT, FreeBSD has never supported these wrappers.  In addition, as
C99, principally the long double, functions were added to libm, this
convention was not maintained.  Given that only 148 of 324 files under
lib/msun contain a "Copyright (C) 1993 by Sun Microsystems" statement,
the removal of the __ieee754_ prefix provides consistency across all
source files.

The last time someone compared lib/msun to fdlibm appears to be

  commit 3f70824172feb82ea3dcdb3866b54fe0eb7cd890
  Author: David Schultz <das@FreeBSD.org>
  Date:   Fri Feb 4 18:26:06 2005 +0000

  Reduce diffs against vendor source (Sun fdlibm 5.3).

The most recent fdlibm RCS string that appears in a Sun Microsystem
copyrighted file is date "95/01/18".  With Oracle Corporation's
acquisition of Sun Microsystems in 2009, it is unlikely that fdlibm 
will ever be updated. A search for fdlibm at https://opensource.oracle.com/
yields no hits.

Finally, OpenBSD removed the use of this prefix over 21 years ago.
pSee revision 1.6 of OpenBSD's math_private.h.
Comment 1 Steve Kargl freebsd_committer freebsd_triage 2023-07-28 21:30:37 UTC
I forgot to mention that the patch does not drop the __ieee754_ prefix from the trigonometric argument reduction functions, e.g., __ieee754_rem_pio2.  These functions are internal to the libm and exported through Symbol.map; and thus, reserved for the implementation.
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-08-03 19:52:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=99843eb89954dac76afe7cf18d962eddfe7a7987

commit 99843eb89954dac76afe7cf18d962eddfe7a7987
Author:     Steve Kargl <kargl@FreeBSD.org>
AuthorDate: 2023-08-03 19:51:17 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-08-03 19:51:53 +0000

    Clean up libm use of the __ieee754_ prefix

    This removes the __ieee754_ prefix from a number of the math functions.
    msun/src/math_private.h contains the statement that

      /*
       * ieee style elementary functions
       *
       * We rename functions here to improve other sources' diffability
       * against fdlibm.
       */
       #define        __ieee754_sqrt  sqrt
       ...

    Here, fdlibm refers to https://netlib.org/fdlibm. It is seen from
    https://netlib.org/fdlibm/readme that this prefix was used to
    differentiate between different standards:

       Wrapper functions will twist the result of the ieee754
       function to comply to the standard specified by the value
       of _LIB_VERSION
          if _LIB_VERSION = _IEEE_, return the ieee754 result;
          if _LIB_VERSION = _SVID_, return SVID result;
          if _LIB_VERSION = _XOPEN_, return XOPEN result;
          if _LIB_VERSION = _POSIX_, return POSIX/ANSI result.
       (These are macros, see fdlibm.h for their definition.)

    AFAICT, FreeBSD has never supported these wrappers. In addition, as C99,
    principally the long double, functions were added to libm, this
    convention was not maintained. Given that only 148 of 324 files under
    lib/msun contain a "Copyright (C) 1993 by Sun Microsystems" statement,
    the removal of the __ieee754_ prefix provides consistency across all
    source files.

    The last time someone compared lib/msun to fdlibm appears to be

      commit 3f70824172feb82ea3dcdb3866b54fe0eb7cd890
      Author: David Schultz <das@FreeBSD.org>
      Date:   Fri Feb 4 18:26:06 2005 +0000

      Reduce diffs against vendor source (Sun fdlibm 5.3).

    The most recent fdlibm RCS string that appears in a Sun Microsystem
    copyrighted file is date "95/01/18". With Oracle Corporation's
    acquisition of Sun Microsystems in 2009, it is unlikely that fdlibm will
    ever be updated. A search for fdlibm at https://opensource.oracle.com/
    yields no hits.

    Finally, OpenBSD removed the use of this prefix over 21 years ago. pSee
    revision 1.6 of OpenBSD's math_private.h.

    Note: this does not drop the __ieee754_ prefix from the trigonometric
    argument reduction functions, e.g., __ieee754_rem_pio2. These functions
    are internal to the libm and exported through Symbol.map; and thus,
    reserved for the implementation.

    PR:             272783
    MFC after:      1 week

 lib/msun/src/e_acos.c         |  4 +--
 lib/msun/src/e_acosf.c        |  2 +-
 lib/msun/src/e_acosh.c        |  8 +++---
 lib/msun/src/e_acoshf.c       |  8 +++---
 lib/msun/src/e_asin.c         |  4 +--
 lib/msun/src/e_asinf.c        |  2 +-
 lib/msun/src/e_atan2.c        |  4 +--
 lib/msun/src/e_atan2f.c       |  2 +-
 lib/msun/src/e_atanh.c        |  4 +--
 lib/msun/src/e_atanhf.c       |  2 +-
 lib/msun/src/e_cosh.c         |  8 +++---
 lib/msun/src/e_coshf.c        |  6 ++---
 lib/msun/src/e_exp.c          |  4 +--
 lib/msun/src/e_expf.c         |  2 +-
 lib/msun/src/e_fmod.c         |  4 +--
 lib/msun/src/e_fmodf.c        |  4 +--
 lib/msun/src/e_gamma.c        |  8 +++---
 lib/msun/src/e_gamma_r.c      |  8 +++---
 lib/msun/src/e_gammaf.c       |  8 +++---
 lib/msun/src/e_gammaf_r.c     |  8 +++---
 lib/msun/src/e_hypot.c        |  4 +--
 lib/msun/src/e_hypotf.c       |  6 ++---
 lib/msun/src/e_j0.c           | 10 +++----
 lib/msun/src/e_j0f.c          |  8 +++---
 lib/msun/src/e_j1.c           |  8 +++---
 lib/msun/src/e_j1f.c          |  6 ++---
 lib/msun/src/e_jn.c           | 28 ++++++++++----------
 lib/msun/src/e_jnf.c          | 26 +++++++++---------
 lib/msun/src/e_lgamma.c       |  8 +++---
 lib/msun/src/e_lgamma_r.c     | 16 ++++++------
 lib/msun/src/e_lgammaf.c      |  8 +++---
 lib/msun/src/e_lgammaf_r.c    | 14 +++++-----
 lib/msun/src/e_log.c          |  4 +--
 lib/msun/src/e_log10.c        |  2 +-
 lib/msun/src/e_log10f.c       |  2 +-
 lib/msun/src/e_log2.c         |  2 +-
 lib/msun/src/e_log2f.c        |  2 +-
 lib/msun/src/e_logf.c         |  2 +-
 lib/msun/src/e_pow.c          |  4 +--
 lib/msun/src/e_powf.c         |  4 +--
 lib/msun/src/e_remainder.c    |  6 ++---
 lib/msun/src/e_remainderf.c   |  4 +--
 lib/msun/src/e_scalb.c        |  6 ++---
 lib/msun/src/e_scalbf.c       |  4 +--
 lib/msun/src/e_sinh.c         |  6 ++---
 lib/msun/src/e_sinhf.c        |  4 +--
 lib/msun/src/e_sqrt.c         |  6 ++---
 lib/msun/src/e_sqrtf.c        |  4 +--
 lib/msun/src/math_private.h   | 61 -------------------------------------------
 lib/msun/src/s_asinh.c        |  6 ++---
 lib/msun/src/s_asinhf.c       |  6 ++---
 lib/msun/src/s_erf.c          |  4 +--
 lib/msun/src/s_significand.c  |  2 +-
 lib/msun/src/s_significandf.c |  2 +-
 54 files changed, 162 insertions(+), 223 deletions(-)
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2023-08-03 19:54:15 UTC
Thanks Steve. I tested a make universe just to be sure, and this all worked fine. I will MFC the commit after about a week.
Comment 4 Steve Kargl freebsd_committer freebsd_triage 2023-08-03 20:37:45 UTC
You're welcomed, and thanks for committing the patch.  msun sources are headache to read as there is no consistent across files.
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-08-13 08:43:27 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e0a00355265097ac916398bdc58cbe94fa2fbc10

commit e0a00355265097ac916398bdc58cbe94fa2fbc10
Author:     Steve Kargl <kargl@FreeBSD.org>
AuthorDate: 2023-08-03 19:51:17 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-08-13 08:38:17 +0000

    Clean up libm use of the __ieee754_ prefix

    This removes the __ieee754_ prefix from a number of the math functions.
    msun/src/math_private.h contains the statement that

      /*
       * ieee style elementary functions
       *
       * We rename functions here to improve other sources' diffability
       * against fdlibm.
       */
       #define        __ieee754_sqrt  sqrt
       ...

    Here, fdlibm refers to https://netlib.org/fdlibm. It is seen from
    https://netlib.org/fdlibm/readme that this prefix was used to
    differentiate between different standards:

       Wrapper functions will twist the result of the ieee754
       function to comply to the standard specified by the value
       of _LIB_VERSION
          if _LIB_VERSION = _IEEE_, return the ieee754 result;
          if _LIB_VERSION = _SVID_, return SVID result;
          if _LIB_VERSION = _XOPEN_, return XOPEN result;
          if _LIB_VERSION = _POSIX_, return POSIX/ANSI result.
       (These are macros, see fdlibm.h for their definition.)

    AFAICT, FreeBSD has never supported these wrappers. In addition, as C99,
    principally the long double, functions were added to libm, this
    convention was not maintained. Given that only 148 of 324 files under
    lib/msun contain a "Copyright (C) 1993 by Sun Microsystems" statement,
    the removal of the __ieee754_ prefix provides consistency across all
    source files.

    The last time someone compared lib/msun to fdlibm appears to be

      commit 3f70824172feb82ea3dcdb3866b54fe0eb7cd890
      Author: David Schultz <das@FreeBSD.org>
      Date:   Fri Feb 4 18:26:06 2005 +0000

      Reduce diffs against vendor source (Sun fdlibm 5.3).

    The most recent fdlibm RCS string that appears in a Sun Microsystem
    copyrighted file is date "95/01/18". With Oracle Corporation's
    acquisition of Sun Microsystems in 2009, it is unlikely that fdlibm will
    ever be updated. A search for fdlibm at https://opensource.oracle.com/
    yields no hits.

    Finally, OpenBSD removed the use of this prefix over 21 years ago. pSee
    revision 1.6 of OpenBSD's math_private.h.

    Note: this does not drop the __ieee754_ prefix from the trigonometric
    argument reduction functions, e.g., __ieee754_rem_pio2. These functions
    are internal to the libm and exported through Symbol.map; and thus,
    reserved for the implementation.

    PR:             272783
    MFC after:      1 week

    (cherry picked from commit 99843eb89954dac76afe7cf18d962eddfe7a7987)

 lib/msun/src/e_acos.c         |  4 +--
 lib/msun/src/e_acosf.c        |  2 +-
 lib/msun/src/e_acosh.c        |  8 +++---
 lib/msun/src/e_acoshf.c       |  8 +++---
 lib/msun/src/e_asin.c         |  4 +--
 lib/msun/src/e_asinf.c        |  2 +-
 lib/msun/src/e_atan2.c        |  4 +--
 lib/msun/src/e_atan2f.c       |  2 +-
 lib/msun/src/e_atanh.c        |  4 +--
 lib/msun/src/e_atanhf.c       |  2 +-
 lib/msun/src/e_cosh.c         |  8 +++---
 lib/msun/src/e_coshf.c        |  6 ++---
 lib/msun/src/e_exp.c          |  4 +--
 lib/msun/src/e_expf.c         |  2 +-
 lib/msun/src/e_fmod.c         |  4 +--
 lib/msun/src/e_fmodf.c        |  4 +--
 lib/msun/src/e_gamma.c        |  8 +++---
 lib/msun/src/e_gamma_r.c      |  8 +++---
 lib/msun/src/e_gammaf.c       |  8 +++---
 lib/msun/src/e_gammaf_r.c     |  8 +++---
 lib/msun/src/e_hypot.c        |  4 +--
 lib/msun/src/e_hypotf.c       |  6 ++---
 lib/msun/src/e_j0.c           | 10 +++----
 lib/msun/src/e_j0f.c          |  8 +++---
 lib/msun/src/e_j1.c           |  8 +++---
 lib/msun/src/e_j1f.c          |  6 ++---
 lib/msun/src/e_jn.c           | 28 ++++++++++----------
 lib/msun/src/e_jnf.c          | 26 +++++++++---------
 lib/msun/src/e_lgamma.c       |  8 +++---
 lib/msun/src/e_lgamma_r.c     | 16 ++++++------
 lib/msun/src/e_lgammaf.c      |  8 +++---
 lib/msun/src/e_lgammaf_r.c    | 14 +++++-----
 lib/msun/src/e_log.c          |  4 +--
 lib/msun/src/e_log10.c        |  2 +-
 lib/msun/src/e_log10f.c       |  2 +-
 lib/msun/src/e_log2.c         |  2 +-
 lib/msun/src/e_log2f.c        |  2 +-
 lib/msun/src/e_logf.c         |  2 +-
 lib/msun/src/e_pow.c          |  4 +--
 lib/msun/src/e_powf.c         |  4 +--
 lib/msun/src/e_remainder.c    |  6 ++---
 lib/msun/src/e_remainderf.c   |  4 +--
 lib/msun/src/e_scalb.c        |  6 ++---
 lib/msun/src/e_scalbf.c       |  4 +--
 lib/msun/src/e_sinh.c         |  6 ++---
 lib/msun/src/e_sinhf.c        |  4 +--
 lib/msun/src/e_sqrt.c         |  6 ++---
 lib/msun/src/e_sqrtf.c        |  4 +--
 lib/msun/src/math_private.h   | 61 -------------------------------------------
 lib/msun/src/s_asinh.c        |  6 ++---
 lib/msun/src/s_asinhf.c       |  6 ++---
 lib/msun/src/s_erf.c          |  4 +--
 lib/msun/src/s_significand.c  |  2 +-
 lib/msun/src/s_significandf.c |  2 +-
 54 files changed, 162 insertions(+), 223 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-08-13 08:44:29 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=afa7546359d3ad1c82d46a5a99f3cef36229ea71

commit afa7546359d3ad1c82d46a5a99f3cef36229ea71
Author:     Steve Kargl <kargl@FreeBSD.org>
AuthorDate: 2023-08-03 19:51:17 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-08-13 08:39:13 +0000

    Clean up libm use of the __ieee754_ prefix

    This removes the __ieee754_ prefix from a number of the math functions.
    msun/src/math_private.h contains the statement that

      /*
       * ieee style elementary functions
       *
       * We rename functions here to improve other sources' diffability
       * against fdlibm.
       */
       #define        __ieee754_sqrt  sqrt
       ...

    Here, fdlibm refers to https://netlib.org/fdlibm. It is seen from
    https://netlib.org/fdlibm/readme that this prefix was used to
    differentiate between different standards:

       Wrapper functions will twist the result of the ieee754
       function to comply to the standard specified by the value
       of _LIB_VERSION
          if _LIB_VERSION = _IEEE_, return the ieee754 result;
          if _LIB_VERSION = _SVID_, return SVID result;
          if _LIB_VERSION = _XOPEN_, return XOPEN result;
          if _LIB_VERSION = _POSIX_, return POSIX/ANSI result.
       (These are macros, see fdlibm.h for their definition.)

    AFAICT, FreeBSD has never supported these wrappers. In addition, as C99,
    principally the long double, functions were added to libm, this
    convention was not maintained. Given that only 148 of 324 files under
    lib/msun contain a "Copyright (C) 1993 by Sun Microsystems" statement,
    the removal of the __ieee754_ prefix provides consistency across all
    source files.

    The last time someone compared lib/msun to fdlibm appears to be

      commit 3f70824172feb82ea3dcdb3866b54fe0eb7cd890
      Author: David Schultz <das@FreeBSD.org>
      Date:   Fri Feb 4 18:26:06 2005 +0000

      Reduce diffs against vendor source (Sun fdlibm 5.3).

    The most recent fdlibm RCS string that appears in a Sun Microsystem
    copyrighted file is date "95/01/18". With Oracle Corporation's
    acquisition of Sun Microsystems in 2009, it is unlikely that fdlibm will
    ever be updated. A search for fdlibm at https://opensource.oracle.com/
    yields no hits.

    Finally, OpenBSD removed the use of this prefix over 21 years ago. pSee
    revision 1.6 of OpenBSD's math_private.h.

    Note: this does not drop the __ieee754_ prefix from the trigonometric
    argument reduction functions, e.g., __ieee754_rem_pio2. These functions
    are internal to the libm and exported through Symbol.map; and thus,
    reserved for the implementation.

    PR:             272783
    MFC after:      1 week

    (cherry picked from commit 99843eb89954dac76afe7cf18d962eddfe7a7987)

 lib/msun/src/e_acos.c         |  4 +--
 lib/msun/src/e_acosf.c        |  2 +-
 lib/msun/src/e_acosh.c        |  8 +++---
 lib/msun/src/e_acoshf.c       |  8 +++---
 lib/msun/src/e_asin.c         |  4 +--
 lib/msun/src/e_asinf.c        |  2 +-
 lib/msun/src/e_atan2.c        |  4 +--
 lib/msun/src/e_atan2f.c       |  2 +-
 lib/msun/src/e_atanh.c        |  4 +--
 lib/msun/src/e_atanhf.c       |  2 +-
 lib/msun/src/e_cosh.c         |  8 +++---
 lib/msun/src/e_coshf.c        |  6 ++---
 lib/msun/src/e_exp.c          |  4 +--
 lib/msun/src/e_expf.c         |  2 +-
 lib/msun/src/e_fmod.c         |  4 +--
 lib/msun/src/e_fmodf.c        |  4 +--
 lib/msun/src/e_gamma.c        |  8 +++---
 lib/msun/src/e_gamma_r.c      |  8 +++---
 lib/msun/src/e_gammaf.c       |  8 +++---
 lib/msun/src/e_gammaf_r.c     |  8 +++---
 lib/msun/src/e_hypot.c        |  4 +--
 lib/msun/src/e_hypotf.c       |  6 ++---
 lib/msun/src/e_j0.c           | 10 +++----
 lib/msun/src/e_j0f.c          |  8 +++---
 lib/msun/src/e_j1.c           |  8 +++---
 lib/msun/src/e_j1f.c          |  6 ++---
 lib/msun/src/e_jn.c           | 28 ++++++++++----------
 lib/msun/src/e_jnf.c          | 26 +++++++++---------
 lib/msun/src/e_lgamma.c       |  8 +++---
 lib/msun/src/e_lgamma_r.c     | 16 ++++++------
 lib/msun/src/e_lgammaf.c      |  8 +++---
 lib/msun/src/e_lgammaf_r.c    | 14 +++++-----
 lib/msun/src/e_log.c          |  4 +--
 lib/msun/src/e_log10.c        |  2 +-
 lib/msun/src/e_log10f.c       |  2 +-
 lib/msun/src/e_log2.c         |  2 +-
 lib/msun/src/e_log2f.c        |  2 +-
 lib/msun/src/e_logf.c         |  2 +-
 lib/msun/src/e_pow.c          |  4 +--
 lib/msun/src/e_powf.c         |  4 +--
 lib/msun/src/e_remainder.c    |  6 ++---
 lib/msun/src/e_remainderf.c   |  4 +--
 lib/msun/src/e_scalb.c        |  6 ++---
 lib/msun/src/e_scalbf.c       |  4 +--
 lib/msun/src/e_sinh.c         |  6 ++---
 lib/msun/src/e_sinhf.c        |  4 +--
 lib/msun/src/e_sqrt.c         |  6 ++---
 lib/msun/src/e_sqrtf.c        |  4 +--
 lib/msun/src/math_private.h   | 61 -------------------------------------------
 lib/msun/src/s_asinh.c        |  6 ++---
 lib/msun/src/s_asinhf.c       |  6 ++---
 lib/msun/src/s_erf.c          |  4 +--
 lib/msun/src/s_significand.c  |  2 +-
 lib/msun/src/s_significandf.c |  2 +-
 54 files changed, 162 insertions(+), 223 deletions(-)