[haiku-commits] haiku: hrev44846 - src/system/libroot/posix/glibc/arch/arm src/system/libroot/posix/glibc/include/arch/arm/bits src/system/libroot/os/arch/arm build/jam

  • From: ithamar.adema@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 16 Nov 2012 03:05:05 +0100 (CET)

hrev44846 adds 4 changesets to branch 'master'
old head: 6c54ebe5d51733f614ee989c068b90fef4604273
new head: a03044aa5bdcd7b9cc8256fc7c346f57fe750cd0

----------------------------------------------------------------------------

9ffc3c3: ARM/libroot: stub out the missing functions for now
  
  This will get libroot.so to build, which should give us much more compilation
  coverage for ARM now too. Will have to go through all the libroot code with
  a tooth comb anyway once userland comes up...
  
  (Will consider replacing the glibc mess with bsd for all non gcc2 platforms)

63fe8ec: wchar.h: fix header comment style.
  
  Comment uses C++ style, while it can be compiled in a C-only environment. This
  broke the ICU cross compilation (done for ARM).

d9e5bb0: ARM/ICU: add "optional" packages for ICU on ARM

a03044a: ARM/libroot: Add more floating point code to get UCI happy

                          [ Ithamar R. Adema <ithamar@xxxxxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

12 files changed, 496 insertions(+), 10 deletions(-)
build/jam/OptionalBuildFeatures                  |   7 +-
build/jam/OptionalPackages                       |  10 +-
headers/posix/wchar.h                            |   2 +-
src/system/libroot/os/arch/arm/Jamfile           |   1 +
src/system/libroot/os/arch/arm/stack_frame.c     |  27 +++
src/system/libroot/os/arch/arm/system_time.c     |  30 ++-
src/system/libroot/posix/glibc/arch/arm/Jamfile  |  27 +++
src/system/libroot/posix/glibc/arch/arm/e_log.c  | 203 +++++++++++++++++++
src/system/libroot/posix/glibc/arch/arm/e_sqrt.c |  88 ++++++++
src/system/libroot/posix/glibc/arch/arm/uroot.h  |  44 ++++
.../posix/glibc/include/arch/arm/bits/fenv.h     |  58 ++++++
.../posix/glibc/include/arch/arm/bits/mathdef.h  |   9 +

############################################################################

Commit:      9ffc3c3d8ae7b5f34cb1ee8dc58ec54edb04d7cf
URL:         http://cgit.haiku-os.org/haiku/commit/?id=9ffc3c3
Author:      Ithamar R. Adema <ithamar@xxxxxxxxxxxxxxxxxxx>
Date:        Thu Nov 15 17:41:57 2012 UTC

ARM/libroot: stub out the missing functions for now

This will get libroot.so to build, which should give us much more compilation
coverage for ARM now too. Will have to go through all the libroot code with
a tooth comb anyway once userland comes up...

(Will consider replacing the glibc mess with bsd for all non gcc2 platforms)

----------------------------------------------------------------------------

diff --git a/src/system/libroot/os/arch/arm/Jamfile 
b/src/system/libroot/os/arch/arm/Jamfile
index 52b5f24..2ebb171 100644
--- a/src/system/libroot/os/arch/arm/Jamfile
+++ b/src/system/libroot/os/arch/arm/Jamfile
@@ -9,6 +9,7 @@ MergeObject os_arch_$(TARGET_ARCH).o :
        atomic.S
        byteorder.S
        system_time.c
+       stack_frame.c
        thread.c
        time.c
        tls.c
diff --git a/src/system/libroot/os/arch/arm/stack_frame.c 
b/src/system/libroot/os/arch/arm/stack_frame.c
new file mode 100644
index 0000000..30223cb
--- /dev/null
+++ b/src/system/libroot/os/arch/arm/stack_frame.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2012, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             FranÃois Revol <revol@xxxxxxx>
+ */
+
+#include <SupportDefs.h>
+
+#include <libroot_private.h>
+
+
+void*
+get_stack_frame(void)
+{
+       // TODO: Implement!
+       return NULL;
+}
+
+
+void*
+__arch_get_caller(void)
+{
+       // TODO: Implement!
+       return NULL;
+}
diff --git a/src/system/libroot/os/arch/arm/system_time.c 
b/src/system/libroot/os/arch/arm/system_time.c
index 7fd1fd4..6514ae9 100644
--- a/src/system/libroot/os/arch/arm/system_time.c
+++ b/src/system/libroot/os/arch/arm/system_time.c
@@ -1,6 +1,9 @@
 /*
- * Copyright 2006, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
- * All rights reserved. Distributed under the terms of the MIT License.
+ * Copyright 2012, Haiku, Inc.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             FranÃois Revol <revol@xxxxxxx>
  */
 
 #include <OS.h>
@@ -9,10 +12,29 @@
 #include <libroot_private.h>
 #include <real_time_data.h>
 
+static vint32 *sConversionFactor;
+
+void
+__arm_setup_system_time(vint32 *cvFactor)
+{
+       sConversionFactor = cvFactor;
+}
+
+
+//XXX: this is a hack
+// remove me when platform code works
+static int64
+__arm_get_time_base(void)
+{
+       static uint64 time_dilation_field = 0;
+       return time_dilation_field++;
+}
 
 bigtime_t
 system_time(void)
 {
-#warning ARM:WRITEME
-       return 0;
+       uint64 timeBase = __arm_get_time_base();
+
+       uint32 cv = *sConversionFactor;
+       return (timeBase >> 32) * cv + (((timeBase & 0xffffffff) * cv) >> 32);
 }

############################################################################

Commit:      63fe8ecdd98f53cc8710746ec9343a9b08838594
URL:         http://cgit.haiku-os.org/haiku/commit/?id=63fe8ec
Author:      Ithamar R. Adema <ithamar@xxxxxxxxxxxxxxxxxxx>
Date:        Thu Nov 15 23:48:14 2012 UTC

wchar.h: fix header comment style.

Comment uses C++ style, while it can be compiled in a C-only environment. This
broke the ICU cross compilation (done for ARM).

----------------------------------------------------------------------------

diff --git a/headers/posix/wchar.h b/headers/posix/wchar.h
index eebc4e5..8b4f79e 100644
--- a/headers/posix/wchar.h
+++ b/headers/posix/wchar.h
@@ -30,7 +30,7 @@ typedef struct {
        void* converter;
        char charset[64];
        unsigned int count;
-       char data[1024 + 8];    // 1024 bytes for data, 8 for alignment space
+       char data[1024 + 8];    /* 1024 bytes for data, 8 for alignment space */
 } mbstate_t;
 
 

############################################################################

Commit:      d9e5bb0df70f0773fc8d4b88e55c8e35c92b5c1d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d9e5bb0
Author:      Ithamar R. Adema <ithamar@xxxxxxxxxxxxxxxxxxx>
Date:        Fri Nov 16 02:01:19 2012 UTC

ARM/ICU: add "optional" packages for ICU on ARM

----------------------------------------------------------------------------

diff --git a/build/jam/OptionalBuildFeatures b/build/jam/OptionalBuildFeatures
index ca0097a..dd4ea9a 100644
--- a/build/jam/OptionalBuildFeatures
+++ b/build/jam/OptionalBuildFeatures
@@ -69,12 +69,15 @@ if $(HAIKU_BUILD_FEATURE_SSL) {
 HAIKU_ICU_GCC_2_PACKAGE = icu-4.8.1.1-r1a4-x86-gcc2-2012-08-29.zip ;
 HAIKU_ICU_GCC_4_PACKAGE = icu-4.8.1.1-r1a4-x86-gcc4-2012-08-29.zip ;
 HAIKU_ICU_PPC_PACKAGE = icu-4.8.1-ppc-2011-08-20.zip ;
-
-if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 {
+HAIKU_ICU_ARM_PACKAGE = icu-4.8.1.1-arm-2012-11-16.zip ;
+if $(TARGET_ARCH) = ppc || $(TARGET_ARCH) = x86 || $(TARGET_ARCH) = arm {
        local icu_package ;
        if $(TARGET_ARCH) = ppc {
                icu_package = $(HAIKU_ICU_PPC_PACKAGE) ;
                HAIKU_ICU_DEVEL_PACKAGE = icu-devel-4.8.1-ppc-2011-12-19.zip ;
+       } else if $(TARGET_ARCH) = arm {
+               icu_package = $(HAIKU_ICU_ARM_PACKAGE) ;
+               HAIKU_ICU_DEVEL_PACKAGE = icu-devel-4.8.1.1-arm-2012-11-16.zip ;
        } else if $(HAIKU_GCC_VERSION[1]) = 2 {
                icu_package = $(HAIKU_ICU_GCC_2_PACKAGE) ;
                HAIKU_ICU_DEVEL_PACKAGE = 
icu-devel-4.8.1.1-x86-gcc2-2011-12-20.zip ;
diff --git a/build/jam/OptionalPackages b/build/jam/OptionalPackages
index 3875fc7..710dba7 100644
--- a/build/jam/OptionalPackages
+++ b/build/jam/OptionalPackages
@@ -1100,9 +1100,7 @@ if [ IsOptionalHaikuImagePackageAdded HGrep ] {
 
 # ICU
 if [ IsOptionalHaikuImagePackageAdded ICU ] {
-       if $(TARGET_ARCH) != x86 {
-               Echo "No optional package ICU available for $(TARGET_ARCH)" ;
-       } else {
+       if $(TARGET_ARCH) = x86 {
                if $(HAIKU_GCC_VERSION[1]) = 2 {
                        # unzip gcc2
                        InstallOptionalHaikuImagePackage 
$(HAIKU_ICU_GCC_2_PACKAGE)
@@ -1126,6 +1124,12 @@ if [ IsOptionalHaikuImagePackageAdded ICU ] {
                                        : system lib gcc2 ;
                        }
                }
+       } else if $(TARGET_ARCH) = arm {
+               InstallOptionalHaikuImagePackage $(HAIKU_ICU_ARM_PACKAGE)
+                       : $(baseURL)/(HAIKU_ICU_ARM_PACKAGE)
+                       : system lib ;
+       } else {
+               Echo "No optional package ICU available for $(TARGET_ARCH)" ;
        }
 }
 

############################################################################

Revision:    hrev44846
Commit:      a03044aa5bdcd7b9cc8256fc7c346f57fe750cd0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a03044a
Author:      Ithamar R. Adema <ithamar@xxxxxxxxxxxxxxxxxxx>
Date:        Fri Nov 16 02:02:18 2012 UTC

ARM/libroot: Add more floating point code to get UCI happy

----------------------------------------------------------------------------

diff --git a/src/system/libroot/posix/glibc/arch/arm/Jamfile 
b/src/system/libroot/posix/glibc/arch/arm/Jamfile
index b4c2f6d..deb19a0 100644
--- a/src/system/libroot/posix/glibc/arch/arm/Jamfile
+++ b/src/system/libroot/posix/glibc/arch/arm/Jamfile
@@ -33,14 +33,41 @@ local genericSources =
        s_isinf.c s_isinff.c
        s_isnan.c s_isnanf.c
        s_signbit.c s_signbitf.c s_signbitl.c
+
+       s_floor.c
+       s_ceil.c s_ceilf.c
+       s_modf.c
+       w_pow.c e_pow.c slowpow.c
+       e_exp.c slowexp.c
+       dosincos.c
+       doasin.c
+       sincos32.c
+       branred.c
+       halfulp.c
+       mpa.c mplog.c mpexp.c
+       s_sin.c
+       s_atan.c
+       s_tan.c
+       e_asin.c w_asin.c
+       e_log10.c w_log10.c
+       e_acos.c w_acos.c
+       e_atan2.c w_atan2.c mpatan2.c mpatan.c mptan.c mpsqrt.c
+       e_fmod.c w_fmod.c
+       e_log.c w_log.c
+       s_ldexp.c s_ldexpf.c
 ;
 
 MergeObject posix_gnu_arch_$(TARGET_ARCH)_generic.o :
        $(genericSources)
 ;
 
+MergeObject posix_gnu_arch_$(TARGET_ARCH)_others.o :
+       e_sqrt.c
+;
+
 MergeObjectFromObjects posix_gnu_arch_$(TARGET_ARCH).o : :
        posix_gnu_arch_$(TARGET_ARCH)_generic.o
+       posix_gnu_arch_$(TARGET_ARCH)_others.o
 ;
 
 SEARCH on [ FGristFiles $(genericSources) ]
diff --git a/src/system/libroot/posix/glibc/arch/arm/e_log.c 
b/src/system/libroot/posix/glibc/arch/arm/e_log.c
new file mode 100644
index 0000000..1a9967b
--- /dev/null
+++ b/src/system/libroot/posix/glibc/arch/arm/e_log.c
@@ -0,0 +1,203 @@
+/*
+ * IBM Accurate Mathematical Library
+ * written by International Business Machines Corp.
+ * Copyright (C) 2001 Free Software Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+/*********************************************************************/
+/*                                                                   */
+/*      MODULE_NAME:ulog.c                                           */
+/*                                                                   */
+/*      FUNCTION:ulog                                                */
+/*                                                                   */
+/*      FILES NEEDED: dla.h endian.h mpa.h mydefs.h ulog.h           */
+/*                    mpexp.c mplog.c mpa.c                          */
+/*                    ulog.tbl                                       */
+/*                                                                   */
+/* An ultimate log routine. Given an IEEE double machine number x    */
+/* it computes the correctly rounded (to nearest) value of log(x).   */
+/* Assumption: Machine arithmetic operations are performed in        */
+/* round to nearest mode of IEEE 754 standard.                       */
+/*                                                                   */
+/*********************************************************************/
+
+
+#include "endian.h"
+#include "dla.h"
+#include "mpa.h"
+#include "MathLib.h"
+#include "math_private.h"
+
+void __mplog(mp_no *, mp_no *, int);
+
+/*********************************************************************/
+/* An ultimate log routine. Given an IEEE double machine number x     */
+/* it computes the correctly rounded (to nearest) value of log(x).   */
+/*********************************************************************/
+double __ieee754_log(double x) {
+#define M 4
+  static const int pr[M]={8,10,18,32};
+  int i,j,n,ux,dx,p;
+#if 0
+  int k;
+#endif
+  double dbl_n,u,p0,q,r0,w,nln2a,luai,lubi,lvaj,lvbj,
+         sij,ssij,ttij,A,B,B0,y,y1,y2,polI,polII,sa,sb,
+         t1,t2,t3,t4,t5,t6,t7,t8,t,ra,rb,ww,
+         a0,aa0,s1,s2,ss2,s3,ss3,a1,aa1,a,aa,b,bb,c;
+  number num;
+  mp_no mpx,mpy,mpy1,mpy2,mperr;
+
+#include "ulog.tbl"
+#include "ulog.h"
+
+  /* Treating special values of x ( x<=0, x=INF, x=NaN etc.). */
+
+  num.d = x;  ux = num.i[HIGH_HALF];  dx = num.i[LOW_HALF];
+  n=0;
+  if (ux < 0x00100000) {
+    if (((ux & 0x7fffffff) | dx) == 0)  return MHALF/ZERO; /* return -INF */
+    if (ux < 0) return (x-x)/ZERO;                         /* return NaN  */
+    n -= 54;    x *= two54.d;                              /* scale x     */
+    num.d = x;
+  }
+  if (ux >= 0x7ff00000) return x+x;                        /* INF or NaN  */
+
+  /* Regular values of x */
+
+  w = x-ONE;
+  if (ABS(w) > U03) { goto case_03; }
+
+
+  /*--- Stage I, the case abs(x-1) < 0.03 */
+
+  t8 = MHALF*w;
+  EMULV(t8,w,a,aa,t1,t2,t3,t4,t5)
+  EADD(w,a,b,bb)
+
+  /* Evaluate polynomial II */
+  polII = (b0.d+w*(b1.d+w*(b2.d+w*(b3.d+w*(b4.d+
+          w*(b5.d+w*(b6.d+w*(b7.d+w*b8.d))))))))*w*w*w;
+  c = (aa+bb)+polII;
+
+  /* End stage I, case abs(x-1) < 0.03 */
+  if ((y=b+(c+b*E2)) == b+(c-b*E2))  return y;
+
+  /*--- Stage II, the case abs(x-1) < 0.03 */
+
+  a = d11.d+w*(d12.d+w*(d13.d+w*(d14.d+w*(d15.d+w*(d16.d+
+            w*(d17.d+w*(d18.d+w*(d19.d+w*d20.d))))))));
+  EMULV(w,a,s2,ss2,t1,t2,t3,t4,t5)
+  ADD2(d10.d,dd10.d,s2,ss2,s3,ss3,t1,t2)
+  MUL2(w,ZERO,s3,ss3,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(d9.d,dd9.d,s2,ss2,s3,ss3,t1,t2)
+  MUL2(w,ZERO,s3,ss3,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(d8.d,dd8.d,s2,ss2,s3,ss3,t1,t2)
+  MUL2(w,ZERO,s3,ss3,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(d7.d,dd7.d,s2,ss2,s3,ss3,t1,t2)
+  MUL2(w,ZERO,s3,ss3,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(d6.d,dd6.d,s2,ss2,s3,ss3,t1,t2)
+  MUL2(w,ZERO,s3,ss3,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(d5.d,dd5.d,s2,ss2,s3,ss3,t1,t2)
+  MUL2(w,ZERO,s3,ss3,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(d4.d,dd4.d,s2,ss2,s3,ss3,t1,t2)
+  MUL2(w,ZERO,s3,ss3,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(d3.d,dd3.d,s2,ss2,s3,ss3,t1,t2)
+  MUL2(w,ZERO,s3,ss3,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(d2.d,dd2.d,s2,ss2,s3,ss3,t1,t2)
+  MUL2(w,ZERO,s3,ss3,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  MUL2(w,ZERO,s2,ss2,s3,ss3,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(w,ZERO,    s3,ss3, b, bb,t1,t2)
+
+  /* End stage II, case abs(x-1) < 0.03 */
+  if ((y=b+(bb+b*E4)) == b+(bb-b*E4))  return y;
+  goto stage_n;
+
+  /*--- Stage I, the case abs(x-1) > 0.03 */
+  case_03:
+
+  /* Find n,u such that x = u*2**n,   1/sqrt(2) < u < sqrt(2)  */
+  n += (num.i[HIGH_HALF] >> 20) - 1023;
+  num.i[HIGH_HALF] = (num.i[HIGH_HALF] & 0x000fffff) | 0x3ff00000;
+  if (num.d > SQRT_2) { num.d *= HALF;  n++; }
+  u = num.d;  dbl_n = (double) n;
+
+  /* Find i such that ui=1+(i-75)/2**8 is closest to u (i= 0,1,2,...,181) */
+  num.d += h1.d;
+  i = (num.i[HIGH_HALF] & 0x000fffff) >> 12;
+
+  /* Find j such that vj=1+(j-180)/2**16 is closest to v=u/ui (j= 0,...,361) */
+  num.d = u*Iu[i].d + h2.d;
+  j = (num.i[HIGH_HALF] & 0x000fffff) >> 4;
+
+  /* Compute w=(u-ui*vj)/(ui*vj) */
+  p0=(ONE+(i-75)*DEL_U)*(ONE+(j-180)*DEL_V);
+  q=u-p0;   r0=Iu[i].d*Iv[j].d;   w=q*r0;
+
+  /* Evaluate polynomial I */
+  polI = w+(a2.d+a3.d*w)*w*w;
+
+  /* Add up everything */
+  nln2a = dbl_n*LN2A;
+  luai  = Lu[i][0].d;   lubi  = Lu[i][1].d;
+  lvaj  = Lv[j][0].d;   lvbj  = Lv[j][1].d;
+  EADD(luai,lvaj,sij,ssij)
+  EADD(nln2a,sij,A  ,ttij)
+  B0 = (((lubi+lvbj)+ssij)+ttij)+dbl_n*LN2B;
+  B  = polI+B0;
+
+  /* End stage I, case abs(x-1) >= 0.03 */
+  if ((y=A+(B+E1)) == A+(B-E1))  return y;
+
+
+  /*--- Stage II, the case abs(x-1) > 0.03 */
+
+  /* Improve the accuracy of r0 */
+  EMULV(p0,r0,sa,sb,t1,t2,t3,t4,t5)
+  t=r0*((ONE-sa)-sb);
+  EADD(r0,t,ra,rb)
+
+  /* Compute w */
+  MUL2(q,ZERO,ra,rb,w,ww,t1,t2,t3,t4,t5,t6,t7,t8)
+
+  EADD(A,B0,a0,aa0)
+
+  /* Evaluate polynomial III */
+  s1 = (c3.d+(c4.d+c5.d*w)*w)*w;
+  EADD(c2.d,s1,s2,ss2)
+  MUL2(s2,ss2,w,ww,s3,ss3,t1,t2,t3,t4,t5,t6,t7,t8)
+  MUL2(s3,ss3,w,ww,s2,ss2,t1,t2,t3,t4,t5,t6,t7,t8)
+  ADD2(s2,ss2,w,ww,s3,ss3,t1,t2)
+  ADD2(s3,ss3,a0,aa0,a1,aa1,t1,t2)
+
+  /* End stage II, case abs(x-1) >= 0.03 */
+  if ((y=a1+(aa1+E3)) == a1+(aa1-E3)) return y;
+
+
+  /* Final stages. Use multi-precision arithmetic. */
+  stage_n:
+
+  for (i=0; i<M; i++) {
+    p = pr[i];
+    __dbl_mp(x,&mpx,p);  __dbl_mp(y,&mpy,p);
+    __mplog(&mpx,&mpy,p);
+    __dbl_mp(e[i].d,&mperr,p);
+    __add(&mpy,&mperr,&mpy1,p);  __sub(&mpy,&mperr,&mpy2,p);
+    __mp_dbl(&mpy1,&y1,p);       __mp_dbl(&mpy2,&y2,p);
+    if (y1==y2)   return y1;
+  }
+  return y1;
+}
diff --git a/src/system/libroot/posix/glibc/arch/arm/e_sqrt.c 
b/src/system/libroot/posix/glibc/arch/arm/e_sqrt.c
new file mode 100644
index 0000000..f7e8055
--- /dev/null
+++ b/src/system/libroot/posix/glibc/arch/arm/e_sqrt.c
@@ -0,0 +1,88 @@
+/*
+ * IBM Accurate Mathematical Library
+ * written by International Business Machines Corp.
+ * Copyright (C) 2001 Free Software Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+/*********************************************************************/
+/* MODULE_NAME: uroot.c                                              */
+/*                                                                   */
+/* FUNCTION:    usqrt                                                */
+/*                                                                   */
+/* FILES NEEDED: dla.h endian.h mydefs.h uroot.h                     */
+/*               uroot.tbl                                           */
+/*                                                                   */
+/* An ultimate sqrt routine. Given an IEEE double machine number x   */
+/* it computes the correctly rounded (to nearest) value of square    */
+/* root of x.                                                        */
+/* Assumption: Machine arithmetic operations are performed in        */
+/* round to nearest mode of IEEE 754 standard.                       */
+/*                                                                   */
+/*********************************************************************/
+
+#include "endian.h"
+#include "mydefs.h"
+#include "dla.h"
+#include "MathLib.h"
+#include "root.tbl"
+#include "math_private.h"
+
+/*********************************************************************/
+/* An ultimate sqrt routine. Given an IEEE double machine number x   */
+/* it computes the correctly rounded (to nearest) value of square    */
+/* root of x.                                                        */
+/*********************************************************************/
+double __ieee754_sqrt(double x) {
+#include "uroot.h"
+  static const double
+    rt0 = 9.99999999859990725855365213134618E-01,
+    rt1 = 4.99999999495955425917856814202739E-01,
+    rt2 = 3.75017500867345182581453026130850E-01,
+    rt3 = 3.12523626554518656309172508769531E-01;
+  static const double big =  134217728.0;
+  double y,t,del,res,res1,hy,z,zz,p,hx,tx,ty,s;
+  mynumber a,c={{0,0}};
+  int4 k;
+
+  a.x=x;
+  k=a.i[HIGH_HALF];
+  a.i[HIGH_HALF]=(k&0x001fffff)|0x3fe00000;
+  t=inroot[(k&0x001fffff)>>14];
+  s=a.x;
+  /*----------------- 2^-1022  <= | x |< 2^1024  -----------------*/
+  if (k>0x000fffff && k<0x7ff00000) {
+    y=1.0-t*(t*s);
+    t=t*(rt0+y*(rt1+y*(rt2+y*rt3)));
+    c.i[HIGH_HALF]=0x20000000+((k&0x7fe00000)>>1);
+    y=t*s;
+    hy=(y+big)-big;
+    del=0.5*t*((s-hy*hy)-(y-hy)*(y+hy));
+    res=y+del;
+    if (res == (res+1.002*((y-res)+del))) return res*c.x;
+    else {
+      res1=res+1.5*((y-res)+del);
+      EMULV(res,res1,z,zz,p,hx,tx,hy,ty);  /* (z+zz)=res*res1 */
+      return ((((z-s)+zz)<0)?max(res,res1):min(res,res1))*c.x;
+    }
+  }
+  else {
+    if ((k & 0x7ff00000) == 0x7ff00000)
+      return x*x+x;    /* sqrt(NaN)=NaN, sqrt(+inf)=+inf, sqrt(-inf)=sNaN */
+    if (x==0) return x;        /* sqrt(+0)=+0, sqrt(-0)=-0 */
+    if (k<0) return (x-x)/(x-x); /* sqrt(-ve)=sNaN */
+    return tm256.x*__ieee754_sqrt(x*t512.x);
+  }
+}
diff --git a/src/system/libroot/posix/glibc/arch/arm/uroot.h 
b/src/system/libroot/posix/glibc/arch/arm/uroot.h
new file mode 100644
index 0000000..02b74cb
--- /dev/null
+++ b/src/system/libroot/posix/glibc/arch/arm/uroot.h
@@ -0,0 +1,44 @@
+/*
+ * IBM Accurate Mathematical Library
+ * Written by International Business Machines Corp.
+ * Copyright (C) 2001 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/******************************************************************/
+/*                                                                */
+/* MODULE_NAME:uroot.h                                            */
+/*                                                                */
+/* common data and variables prototype and definition             */
+/******************************************************************/
+
+#ifndef UROOT_H
+#define UROOT_H
+
+#ifdef BIG_ENDI
+ static const  mynumber
+/**/           t512 = {{0x5ff00000, 0x00000000 }},  /* 2^512  */
+/**/          tm256 = {{0x2ff00000, 0x00000000 }};  /* 2^-256 */
+
+#else
+#ifdef LITTLE_ENDI
+ static const  mynumber
+/**/           t512 = {{0x00000000, 0x5ff00000 }}, /* 2^512  */
+/**/          tm256 = {{0x00000000, 0x2ff00000 }}; /* 2^-256 */
+#endif
+#endif
+
+#endif
diff --git a/src/system/libroot/posix/glibc/include/arch/arm/bits/fenv.h 
b/src/system/libroot/posix/glibc/include/arch/arm/bits/fenv.h
new file mode 100644
index 0000000..7bd2423
--- /dev/null
+++ b/src/system/libroot/posix/glibc/include/arch/arm/bits/fenv.h
@@ -0,0 +1,58 @@
+/* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+/* Define bits representing exceptions in the FPU status word.  */
+enum
+  {
+    FE_INVALID = 1,
+#define FE_INVALID FE_INVALID
+    FE_DIVBYZERO = 2,
+#define FE_DIVBYZERO FE_DIVBYZERO
+    FE_OVERFLOW = 4,
+#define FE_OVERFLOW FE_OVERFLOW
+    FE_UNDERFLOW = 8,
+#define FE_UNDERFLOW FE_UNDERFLOW
+  };
+
+/* Amount to shift by to convert an exception to a mask bit.  */
+#define FE_EXCEPT_SHIFT        16
+
+/* All supported exceptions.  */
+#define FE_ALL_EXCEPT  \
+       (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)
+
+/* The ARM FPU basically only supports round-to-nearest.  Other rounding
+   modes exist, but you have to encode them in the actual instruction.  */
+#define FE_TONEAREST   0
+
+/* Type representing exception flags. */
+typedef unsigned long int fexcept_t;
+
+/* Type representing floating-point environment.  */
+typedef struct
+  {
+    unsigned long int __cw;
+  }
+fenv_t;
+
+/* If the default argument is used we use this value.  */
+#define FE_DFL_ENV     ((fenv_t *) -1l)
diff --git a/src/system/libroot/posix/glibc/include/arch/arm/bits/fenvinline.h 
b/src/system/libroot/posix/glibc/include/arch/arm/bits/fenvinline.h
new file mode 100644
index 0000000..e69de29
diff --git a/src/system/libroot/posix/glibc/include/arch/arm/bits/mathdef.h 
b/src/system/libroot/posix/glibc/include/arch/arm/bits/mathdef.h
index daca110..5d9a334 100644
--- a/src/system/libroot/posix/glibc/include/arch/arm/bits/mathdef.h
+++ b/src/system/libroot/posix/glibc/include/arch/arm/bits/mathdef.h
@@ -30,6 +30,12 @@ typedef float float_t;               /* `float' expressions 
are evaluated as
 typedef double double_t;       /* `double' expressions are evaluated as
                                   `double'.  */
 
+/* Signal that both types are `long double'.  */
+# define FLT_EVAL_METHOD       2
+
+/* Define `INFINITY' as value of type `float'.  */
+# define INFINITY      HUGE_VALF
+
 /* The values returned by `ilogb' for 0 and NaN respectively.  */
 # define FP_ILOGB0     (-2147483647)
 # define FP_ILOGBNAN   (2147483647)
@@ -41,3 +47,6 @@ typedef double double_t;      /* `double' expressions are 
evaluated as
    declaration of all the `long double' function variants.  */
 # define __NO_LONG_DOUBLE_MATH 1
 #endif
+
+/* Number of decimal digits for the `long double' type.  */
+# define DECIMAL_DIG   21


Other related posts:

  • » [haiku-commits] haiku: hrev44846 - src/system/libroot/posix/glibc/arch/arm src/system/libroot/posix/glibc/include/arch/arm/bits src/system/libroot/os/arch/arm build/jam - ithamar . adema