svn commit: branches/uClibc-nptl: include libm libm/sh libm/sh/fpu
carmelo at uclibc.org
carmelo at uclibc.org
Wed Nov 21 17:21:55 UTC 2007
Author: carmelo
Date: 2007-11-21 09:21:53 -0800 (Wed, 21 Nov 2007)
New Revision: 20462
Log:
Add SH minimal support for floating point exceptioins.
Required for example by qt-embedded libraries.
Signed-off-by: Carmelo Amoroso <carmelo.amoroso at st.com>
Added:
branches/uClibc-nptl/include/fenv.h
branches/uClibc-nptl/libm/sh/
branches/uClibc-nptl/libm/sh/fpu/
branches/uClibc-nptl/libm/sh/fpu/Makefile.arch
branches/uClibc-nptl/libm/sh/fpu/feholdexcpt.c
branches/uClibc-nptl/libm/sh/fpu/fesetenv.c
Modified:
branches/uClibc-nptl/libm/Makefile.in
Changeset:
Added: branches/uClibc-nptl/include/fenv.h
===================================================================
--- branches/uClibc-nptl/include/fenv.h (rev 0)
+++ branches/uClibc-nptl/include/fenv.h 2007-11-21 17:21:53 UTC (rev 20462)
@@ -0,0 +1,69 @@
+/*
+ *
+ * Copyright (c) 2007 STMicroelectronics Ltd
+ * Filippo Arcidiacono (filippo.arcidiacono at st.com)
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * Taken from glibc 2.6
+ *
+ */
+
+
+/*
+ * ISO C99 7.6: Floating-point environment <fenv.h>
+ */
+
+#ifndef _FENV_H
+#define _FENV_H 1
+
+#include <features.h>
+
+/* Get the architecture dependend definitions. The following definitions
+ are expected to be done:
+
+ fenv_t type for object representing an entire floating-point
+ environment
+
+ FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument
+ to functions taking an argument of type fenv_t; in this
+ case the default environment will be used
+
+ fexcept_t type for object representing the floating-point exception
+ flags including status associated with the flags
+
+ The following macros are defined iff the implementation supports this
+ kind of exception.
+ FE_INEXACT inexact result
+ FE_DIVBYZERO division by zero
+ FE_UNDERFLOW result not representable due to underflow
+ FE_OVERFLOW result not representable due to overflow
+ FE_INVALID invalid operation
+
+ FE_ALL_EXCEPT bitwise OR of all supported exceptions
+
+ The next macros are defined iff the appropriate rounding mode is
+ supported by the implementation.
+ FE_TONEAREST round to nearest
+ FE_UPWARD round toward +Inf
+ FE_DOWNWARD round toward -Inf
+ FE_TOWARDZERO round toward 0
+*/
+#include <bits/fenv.h>
+
+__BEGIN_DECLS
+
+/* Floating-point exception handling. */
+
+/* Save the current environment in the object pointed to by ENVP, clear
+ exception flags and install a non-stop mode (if available) for all
+ exceptions. */
+extern int feholdexcept (fenv_t *__envp) __THROW;
+
+/* Establish the floating-point environment represented by the object
+ pointed to by ENVP. */
+extern int fesetenv (__const fenv_t *__envp) __THROW;
+
+__END_DECLS
+
+#endif /* fenv.h */
Modified: branches/uClibc-nptl/libm/Makefile.in
===================================================================
--- branches/uClibc-nptl/libm/Makefile.in 2007-11-21 12:34:41 UTC (rev 20461)
+++ branches/uClibc-nptl/libm/Makefile.in 2007-11-21 17:21:53 UTC (rev 20462)
@@ -38,6 +38,7 @@
ifeq ($(UCLIBC_HAS_FPU),y)
ifeq ($(DO_C99_MATH),y)
-include $(libm_ARCH_DIR)/Makefile.arch
+-include $(libm_ARCH_fpu_DIR)/Makefile.arch
endif
endif
Added: branches/uClibc-nptl/libm/sh/fpu/Makefile.arch
===================================================================
--- branches/uClibc-nptl/libm/sh/fpu/Makefile.arch (rev 0)
+++ branches/uClibc-nptl/libm/sh/fpu/Makefile.arch 2007-11-21 17:21:53 UTC (rev 20462)
@@ -0,0 +1,18 @@
+# Makefile for uClibc
+#
+# Copyright (c) 2007 STMicroelectronics Ltd
+#
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+#
+
+libm_ARCH_SRC:=$(wildcard $(libm_ARCH_fpu_DIR)/*.c)
+libm_ARCH_OBJ:=$(patsubst $(libm_ARCH_fpu_DIR)/%.c,$(libm_ARCH_fpu_OUT)/%.o,$(libm_ARCH_SRC))
+
+libm_ARCH_OBJS:=$(libm_ARCH_OBJ)
+
+ifeq ($(DOPIC),y)
+libm-a-y+=$(libm_ARCH_OBJS:.o=.os)
+else
+libm-a-y+=$(libm_ARCH_OBJS)
+endif
+libm-so-y+=$(libm_ARCH_OBJS:.o=.os)
Added: branches/uClibc-nptl/libm/sh/fpu/feholdexcpt.c
===================================================================
--- branches/uClibc-nptl/libm/sh/fpu/feholdexcpt.c (rev 0)
+++ branches/uClibc-nptl/libm/sh/fpu/feholdexcpt.c 2007-11-21 17:21:53 UTC (rev 20462)
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright (c) 2007 STMicroelectronics Ltd
+ * Filippo Arcidiacono (filippo.arcidiacono at st.com)
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * Taken from glibc 2.6
+ *
+ */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ unsigned long int temp;
+
+ /* Store the environment. */
+ _FPU_GETCW (temp);
+ envp->__fpscr = temp;
+
+ /* Now set all exceptions to non-stop. */
+ temp &= ~FE_ALL_EXCEPT;
+ _FPU_SETCW (temp);
+
+ return 1;
+}
+libm_hidden_def (feholdexcept)
Added: branches/uClibc-nptl/libm/sh/fpu/fesetenv.c
===================================================================
--- branches/uClibc-nptl/libm/sh/fpu/fesetenv.c (rev 0)
+++ branches/uClibc-nptl/libm/sh/fpu/fesetenv.c 2007-11-21 17:21:53 UTC (rev 20462)
@@ -0,0 +1,27 @@
+/*
+ *
+ * Copyright (c) 2007 STMicroelectronics Ltd
+ * Filippo Arcidiacono (filippo.arcidiacono at st.com)
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * Taken from glibc 2.6
+ *
+ */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fesetenv (const fenv_t *envp)
+{
+ if (envp == FE_DFL_ENV)
+ _FPU_SETCW (_FPU_DEFAULT);
+ else
+ {
+ unsigned long int temp = envp->__fpscr;
+ _FPU_SETCW (temp);
+ }
+ return 0;
+}
+libm_hidden_def (fesetenv)
More information about the uClibc-cvs
mailing list