Bug 216863

Summary: C11 conformance: clog(), clogf, and clogl are missing
Product: Base System Reporter: sgk
Component: standardsAssignee: Konstantin Belousov <kib>
Status: Closed FIXED    
Severity: Affects Many People CC: emaste, jhyphenkeck, kargl, kib, rhurlin
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221341
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=175811
Attachments:
Description Flags
clog, clogf, clogl implementations with docs
none
Update patch to trunk as of 11/08/17
none
The patch with the today trivial conflicts resolved.
none
Update with move of s_clogl.c to LDBL_PREC != 53 section of the Makefile. none

Description sgk 2017-02-06 19:47:57 UTC
#include <complex.h>
double complex
foo(double complex z)
{
   return (clog(z));
}
float complex
foof(float complex z)
{
   return (clogf(z));
}

long double complex
fool(long double complex z)
{
   return (clogl(z));
}

 cc -c foo.c
foo.c:7:12: warning: implicitly declaring library function 'clog' with type
      '_Complex double (_Complex double)' [-Wimplicit-function-declaration]
   return (clog(z));
           ^
foo.c:7:12: note: include the header <complex.h> or explicitly provide a
      declaration for 'clog'
foo.c:12:12: warning: implicitly declaring library function 'clogf' with type
      '_Complex float (_Complex float)' [-Wimplicit-function-declaration]
   return (clogf(z));
           ^
foo.c:12:12: note: include the header <complex.h> or explicitly provide a
      declaration for 'clogf'
foo.c:18:12: warning: implicitly declaring library function 'clogl' with type
      '_Complex long double (_Complex long double)'
      [-Wimplicit-function-declaration]
   return (clogl(z));
           ^
foo.c:18:12: note: include the header <complex.h> or explicitly provide a
      declaration for 'clogl'
3 warnings generated.
Comment 1 sgk 2017-02-15 19:11:49 UTC
Created attachment 180028 [details]
clog, clogf, clogl implementations with docs

The complete was provided/taken from bde@

The patch includes a bonus patch.  Someone smart or interested
in patch will figure out what it does  Although it is unclear
whether it is needed for FreeBSD as I don't use a target where 
it is applicable.

* include/complex.h:
  . Add prototypes for clog[fl].

* lib/libc/softfloat/bits64/softfloat-macros
  . Bonus patch.

* lib/msun/Makefile:
  . Add s_clog[fl].c to build.
  . Add clog[fl].3 to installed docs.

* lib/msun/Symbol.map:
  . Add symbols to map.

* lib/msun/man/clog.3:
  . Document clog[fl].

* lib/msun/man/complex.3:
  . Document that clog[fl] now exist.

* lib/msun/src/math_private.h:
  . Add ENTERIT().

* lib/msun/src/s_clog[fl].c:
  . Implementation of clog[fl]().
Comment 2 sgk 2017-02-15 19:13:06 UTC
>
> The complete was provided/taken from bde@
>
 Ugh.  s/complete/code
Comment 3 Steve Kargl freebsd_committer freebsd_triage 2017-11-09 01:19:58 UTC
Created attachment 187872 [details]
Update patch to trunk as of 11/08/17

Here is an updated diff.  Oddly, my old diff applied to an 
up-to-date trunk without the issues reported at

https://lists.freebsd.org/pipermail/freebsd-numerics/2017-November/000754.html

* include/complex.h:
  . Add prototypes for complex.h.

* lib/msun/Makefile:
  . Add s_clog.c s_clogf.c s_clogl.c to SRC.
  . Add clog.3 to MAN.
  . MLINKS for clogf.3 amd clogl.3

* lib/msun/Symbol.map:
  . Expose clog, clogf, and clogl.

* lib/msun/man/clog.3:
  . Document the functions.

* lib/msun/man/complex.3:
  . Document availability of functions.

* lib/msun/src/math_private.h:
  . Update ENTERI() macro.
  . Add ENTERIT() macro.

* lib/msun/src/s_clog.c:
  . Implementation of double clog(double x).

* lib/msun/src/s_clogf.c:
  . Implementation of float clogf(float x).

* lib/msun/src/s_clogl.c
  . Implementation of long double clogl(long double x).
Comment 4 Ed Maste freebsd_committer freebsd_triage 2018-01-13 12:40:45 UTC
Fails to build on (32-bit) arm:

lib/msun/src/s_clogl.c:56:2: error: "Unsupported long double format"
#error "Unsupported long double format"
 ^
Comment 5 sgk 2018-01-13 17:05:11 UTC
(In reply to Ed Maste from comment #4)
> Fails to build on (32-bit) arm:
>
> lib/msun/src/s_clogl.c:56:2: error: "Unsupported long double format"
> #error "Unsupported long double format"

Whoops.  Move s_clogl.c from COMMON_SRCS to 
COMMON_SRCS in the .if ${LDBL_PREC} != 53
section of Makefile.  I have too many changes
in Makefile to create a diff.
Comment 6 Ed Maste freebsd_committer freebsd_triage 2018-01-20 00:43:04 UTC
I've moved it in my WIP branch[1] and will commit to FreeBSD shortly.

[1] https://github.com/emaste/freebsd/commit/c6bb5bc750d15eeae1ecfa8795e939829289191c
Comment 7 sgk 2018-05-12 15:25:07 UTC
Any progress?
Comment 8 Konstantin Belousov freebsd_committer freebsd_triage 2018-05-12 17:09:08 UTC
(In reply to sgk from comment #7)
I am starting the make universe and will commit when the job finishes.
Comment 9 Konstantin Belousov freebsd_committer freebsd_triage 2018-05-12 17:21:53 UTC
Created attachment 193337 [details]
The patch with the today trivial conflicts resolved.

BTW, am I right that the commit should state
Submitted by: bde, Steven G. Kargl <sgk@troutmask.apl.washington.edu>
Comment 10 Konstantin Belousov freebsd_committer freebsd_triage 2018-05-12 20:41:33 UTC
Created attachment 193340 [details]
Update with move of s_clogl.c to LDBL_PREC != 53 section of the Makefile.
Comment 11 commit-hook freebsd_committer freebsd_triage 2018-05-13 09:54:58 UTC
A commit references this bug:

Author: kib
Date: Sun May 13 09:54:36 UTC 2018
New revision: 333577
URL: https://svnweb.freebsd.org/changeset/base/333577

Log:
  Add implementations for clog(3), clogf(3), and clog(3).

  PR:	216863
  Submitted by:	bde, Steven G. Kargl <sgk@troutmask.apl.washington.edu>
  MFC after:	2 weeks

Changes:
  head/include/complex.h
  head/lib/libc/softfloat/bits64/softfloat-macros
  head/lib/msun/Makefile
  head/lib/msun/Symbol.map
  head/lib/msun/man/clog.3
  head/lib/msun/man/complex.3
  head/lib/msun/src/math_private.h
  head/lib/msun/src/s_clog.c
  head/lib/msun/src/s_clogf.c
  head/lib/msun/src/s_clogl.c
Comment 12 commit-hook freebsd_committer freebsd_triage 2018-06-05 13:47:11 UTC
A commit references this bug:

Author: kib
Date: Tue Jun  5 13:46:20 UTC 2018
New revision: 334654
URL: https://svnweb.freebsd.org/changeset/base/334654

Log:
  MFC r333577:
  Add implementations for clog(3), clogf(3), and clogl(3).

  PR:	216863

Changes:
_U  stable/11/
  stable/11/include/complex.h
  stable/11/lib/libc/softfloat/bits64/softfloat-macros
  stable/11/lib/msun/Makefile
  stable/11/lib/msun/Symbol.map
  stable/11/lib/msun/man/clog.3
  stable/11/lib/msun/man/complex.3
  stable/11/lib/msun/src/math_private.h
  stable/11/lib/msun/src/s_clog.c
  stable/11/lib/msun/src/s_clogf.c
  stable/11/lib/msun/src/s_clogl.c
Comment 13 Pedro F. Giffuni freebsd_committer freebsd_triage 2018-07-15 06:30:28 UTC
Seems like this can be closed?