avr-libc-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-commit] [2428] Provide a proper sqrtf declaration in math.h .


From: Joern Rennecke
Subject: [avr-libc-commit] [2428] Provide a proper sqrtf declaration in math.h .
Date: Thu, 01 May 2014 14:13:18 +0000

Revision: 2428
          http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2428
Author:   amylaar
Date:     2014-05-01 14:13:18 +0000 (Thu, 01 May 2014)
Log Message:
-----------
Provide a proper sqrtf declaration in math.h .
While we could have also get a functional header declaration using
__asm__ to make references use the sqrt symbol, it is preferable to
provide an actual sqrtf symbol in the library, so that code that
expects to be able to use sqrtf directly - like
gcc/gcc/testsuite/gcc.dg/pr41963.c - will work.

        * include/math.h (sqrtf): Don't #define, declare.
        * libm/fplib/asmdef.h (ALIAS_ENTRY): Define.
        * libm/fplib/sqrt.S (sqrtf): New ALIAS_ENTRY.

Modified Paths:
--------------
    trunk/avr-libc/ChangeLog
    trunk/avr-libc/include/math.h
    trunk/avr-libc/libm/fplib/asmdef.h
    trunk/avr-libc/libm/fplib/sqrt.S

Modified: trunk/avr-libc/ChangeLog
===================================================================
--- trunk/avr-libc/ChangeLog    2014-05-01 14:06:03 UTC (rev 2427)
+++ trunk/avr-libc/ChangeLog    2014-05-01 14:13:18 UTC (rev 2428)
@@ -1,5 +1,11 @@
 2014-05-01  Joern Rennecke  <address@hidden>
 
+       * include/math.h (sqrtf): Don't #define, declare.
+       * libm/fplib/asmdef.h (ALIAS_ENTRY): Define.
+       * libm/fplib/sqrt.S (sqrtf): New ALIAS_ENTRY.
+
+2014-05-01  Joern Rennecke  <address@hidden>
+
        * configure.ac (AC_CONFIG_FILES): Add include/sys/Makefile.
        * include/Makefile.am (avr_HEADERS): Add fcntl.h, locale.h, unistd.h.
        (SUBDIRS): Add sys.

Modified: trunk/avr-libc/include/math.h
===================================================================
--- trunk/avr-libc/include/math.h       2014-05-01 14:06:03 UTC (rev 2427)
+++ trunk/avr-libc/include/math.h       2014-05-01 14:13:18 UTC (rev 2428)
@@ -175,7 +175,7 @@
     The sqrt() function returns the non-negative square root of \a __x.
  */
 extern double sqrt(double __x) __ATTR_CONST__;
-#define sqrtf  sqrt            /**< The alias for sqrt().      */
+extern float sqrtf (float) __ATTR_CONST__;
 
 /**
     The cbrt() function returns the cube root of \a __x.

Modified: trunk/avr-libc/libm/fplib/asmdef.h
===================================================================
--- trunk/avr-libc/libm/fplib/asmdef.h  2014-05-01 14:06:03 UTC (rev 2427)
+++ trunk/avr-libc/libm/fplib/asmdef.h  2014-05-01 14:13:18 UTC (rev 2428)
@@ -83,6 +83,18 @@
 _U(\name):
 .endm
 
+/* Because we define the double type to have the same representation as
+   float, we want to share some code for multiple function definitions.
+   While we could also provide aliases in header files using
+   __asm__ in the declaration to specifiy the symbol to reference,
+   it is preferable to provide actual symbols in the library, so
+   that code that expects to be able to use them directly -
+   like gcc/gcc/testsuite/gcc.dg/pr41963.c using sqrtf - will work.  */
+.macro ALIAS_ENTRY     name
+       .global _U(\name)
+_U(\name):
+.endm
+
 .macro ENDFUNC
 .LEND:
 .endm

Modified: trunk/avr-libc/libm/fplib/sqrt.S
===================================================================
--- trunk/avr-libc/libm/fplib/sqrt.S    2014-05-01 14:06:03 UTC (rev 2427)
+++ trunk/avr-libc/libm/fplib/sqrt.S    2014-05-01 14:13:18 UTC (rev 2428)
@@ -46,6 +46,7 @@
 .L_pk: rjmp    _U(__fp_mpack)
 
 ENTRY sqrt
+ALIAS_ENTRY sqrtf
   ; split and check arg.
        rcall   _U(__fp_splitA)
        brcs    .L_nf           ; !isfinite(A)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]