[ORLinux] uClibc patches

Jeremy Bennett jeremy.bennett at embecosm.com
Wed Jun 1 15:36:05 CEST 2011


The following patches fix a number of issues with GCC 4.5 maths and
lseek in uClibc.

These are unified diffs. Note that there is a diff for the defconfig
which turns on thread debugging, and diffs for two files
(include/sys/quota.h and test/regex/testregex.c) which were picked up
solely because they have a $Id field. You might wish to ignore these.

I've added a ChangeLog.or32 to track the changes.

diff --exclude .svn --exclude .git --exclude .gitignore -Naur /home/jeremy/gitdirs/uClibc/ChangeLog.or32 ./ChangeLog.or32
--- /home/jeremy/gitdirs/uClibc/ChangeLog.or32	1970-01-01 01:00:00.000000000 +0100
+++ ./ChangeLog.or32	2011-06-01 11:30:34.629867615 +0100
@@ -0,0 +1,19 @@
+2011-03-02  Joern Rennecke  <joern.rennecke at embecosm.com>
+
+	* libc/sysdeps/linux/common/llseek.c: Try __NR_llseek in addition to
+	__NR__llseek.
+
+	* include/math.h [__GNUC_PREREQ (4, 2)]: Define isnan / isinf in terms
+	of __builtin_isnan / builtin_isinf.
+
+2011-02-26  Joern Rennecke  <joern.rennecke at embecosm.com>
+
+	* include/math.h [__GNUC_PREREQ (4, 4)] (fpclassify):
+	Use __builtin_fpclassify.
+	[__GNUC_PREREQ (4, 2)]: Don't define isnan / isinf.
+
+2011-02-04  Joern Rennecke  <joern.rennecke at embecosm.com>
+
+	* libc/sysdeps/linux/or32/bits/mathinline.h: New file.
+
+	* include/math.h [__GNUC_PREREQ (4, 0)]: Don't define signbit.
diff --exclude .svn --exclude .git --exclude .gitignore -Naur /home/jeremy/gitdirs/uClibc/extra/Configs/defconfigs/or32 ./extra/Configs/defconfigs/or32
--- /home/jeremy/gitdirs/uClibc/extra/Configs/defconfigs/or32	2011-06-01 11:27:42.309865823 +0100
+++ ./extra/Configs/defconfigs/or32	2011-06-01 11:32:28.619866299 +0100
@@ -52,7 +52,7 @@
 # DO_C99_MATH is not set
 # DO_XSI_MATH is not set
 # UCLIBC_HAS_FENV is not set
-KERNEL_HEADERS="${SYSROOT}/usr/include"
+KERNEL_HEADERS="/opt/or32-new/or32-linux/include"
 HAVE_DOT_CONFIG=y
 
 #
@@ -67,7 +67,7 @@
 LINUXTHREADS_OLD=y
 # LINUXTHREADS_NEW is not set
 UCLIBC_HAS_THREADS=y
-# PTHREADS_DEBUG_SUPPORT is not set
+PTHREADS_DEBUG_SUPPORT=y
 UCLIBC_HAS_SYSLOG=y
 UCLIBC_HAS_LFS=y
 # MALLOC is not set
@@ -190,7 +190,7 @@
 # Library Installation Options
 #
 RUNTIME_PREFIX="/"
-DEVEL_PREFIX="/usr"
+DEVEL_PREFIX="/opt/or32-new/or32-linux"
 MULTILIB_DIR="lib"
 HARDWIRED_ABSPATH=y
 
diff --exclude .svn --exclude .git --exclude .gitignore -Naur /home/jeremy/gitdirs/uClibc/include/math.h ./include/math.h
--- /home/jeremy/gitdirs/uClibc/include/math.h	2011-06-01 11:27:42.365866048 +0100
+++ ./include/math.h	2011-06-01 11:33:56.895995601 +0100
@@ -249,7 +249,11 @@
   };
 
 /* Return number of classification appropriate for X.  */
-# ifdef __NO_LONG_DOUBLE_MATH
+# if __GNUC_PREREQ (4, 4)
+# define fpclassify(x) \
+    (__builtin_fpclassify (FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, \
+			   FP_ZERO, (x)))
+# elif defined (__NO_LONG_DOUBLE_MATH)
 #  define fpclassify(x) \
      (sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))
 # else
@@ -261,7 +265,9 @@
 # endif
 
 /* Return nonzero value if sign of X is negative.  */
-# ifdef __NO_LONG_DOUBLE_MATH
+# if __GNUC_PREREQ (4, 0)
+/* GCC has built-in implementations.  */
+# elif defined (__NO_LONG_DOUBLE_MATH)
 #  define signbit(x) \
      (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))
 # else
@@ -289,7 +295,10 @@
 
 /* Return nonzero value if X is a NaN.  We could use `fpclassify' but
    we already have this functions `__isnan' and it is faster.  */
-# ifdef __NO_LONG_DOUBLE_MATH
+# if __GNUC_PREREQ (4, 2)
+/* GCC has built-in implementations.  However, we want the definition to be available even with -fno-builtin, so define to the __builtin version.  */
+# define isnan(x) (__builtin_isnan (x))
+# elif defined (__NO_LONG_DOUBLE_MATH)
 #  define isnan(x) \
      (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
 # else
@@ -301,7 +310,10 @@
 # endif
 
 /* Return nonzero value is X is positive or negative infinity.  */
-# ifdef __NO_LONG_DOUBLE_MATH
+# if __GNUC_PREREQ (4, 2)
+/* GCC has built-in implementations.  Same issue as with isnan above.  */
+# define isinf(x) (__builtin_isinf (x))
+# elif defined (__NO_LONG_DOUBLE_MATH)
 #  define isinf(x) \
      (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))
 # else
diff --exclude .svn --exclude .git --exclude .gitignore -Naur /home/jeremy/gitdirs/uClibc/include/sys/quota.h ./include/sys/quota.h
--- /home/jeremy/gitdirs/uClibc/include/sys/quota.h	2011-06-01 11:27:42.385865753 +0100
+++ ./include/sys/quota.h	2011-06-01 11:41:52.755876511 +0100
@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * Version: $Id: quota.h,v 1.1 2002/01/03 04:00:09 andersen Exp $
+ * Version: $Id: quota.h 1548 2011-06-01 10:41:48Z jeremy $
  */
 
 #ifndef _SYS_QUOTA_H
diff --exclude .svn --exclude .git --exclude .gitignore -Naur /home/jeremy/gitdirs/uClibc/libc/sysdeps/linux/common/llseek.c ./libc/sysdeps/linux/common/llseek.c
--- /home/jeremy/gitdirs/uClibc/libc/sysdeps/linux/common/llseek.c	2011-06-01 11:27:42.630866114 +0100
+++ ./libc/sysdeps/linux/common/llseek.c	2011-06-01 11:34:57.148867646 +0100
@@ -11,7 +11,7 @@
 #include <sys/types.h>
 #include <sys/syscall.h>
 
-#if defined __NR__llseek && defined __UCLIBC_HAS_LFS__
+#if defined (__NR__llseek) && defined (__UCLIBC_HAS_LFS__)
 
 loff_t lseek64(int fd, loff_t offset, int whence)
 {
@@ -20,6 +20,15 @@
 				(off_t) (offset & 0xffffffff), &result, whence) ?: result);
 }
 
+#elif defined (__NR_llseek) && defined (__UCLIBC_HAS_LFS__)
+
+loff_t lseek64(int fd, loff_t offset, int whence)
+{
+	loff_t result;
+	return (loff_t)(INLINE_SYSCALL(llseek, 5, fd, (off_t) (offset >> 32),
+				(off_t) (offset & 0xffffffff), &result, whence) ?: result);
+}
+
 #else
 
 loff_t lseek64(int fd, loff_t offset, int whence)
diff --exclude .svn --exclude .git --exclude .gitignore -Naur /home/jeremy/gitdirs/uClibc/libc/sysdeps/linux/or32/bits/mathinline.h ./libc/sysdeps/linux/or32/bits/mathinline.h
--- /home/jeremy/gitdirs/uClibc/libc/sysdeps/linux/or32/bits/mathinline.h	1970-01-01 01:00:00.000000000 +0100
+++ ./libc/sysdeps/linux/or32/bits/mathinline.h	2011-06-01 11:35:41.161866021 +0100
@@ -0,0 +1,51 @@
+/* Inline math functions for or32
+   Copyright (C) 2004
+   Free Software Foundation, Inc.
+   Copyright (C) 2011 Embecosm Limited
+
+   This file 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 file 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.
+
+   See the file COPYING.LIB in this tarball.  */
+
+#ifndef _MATH_H
+# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
+#endif
+
+#ifdef __cplusplus
+# define __MATH_INLINE __inline
+#else
+# define __MATH_INLINE extern __inline
+#endif
+
+
+#if defined __USE_ISOC99 && defined __GNUC__ && __GNUC__ >= 2
+
+/* __builtin_signbit{,f,l} was added 2004-02-01 to the FSF GCC trunk.
+   The next release branch cut after that was for gcc 4.0 .  */
+# if __GNUC_PREREQ (4, 0)
+/* Test for negative number.  Used in the signbit() macro.  */
+__MATH_INLINE int
+__NTH (__signbitf (float __x))
+{
+  return __builtin__signbitf (__x);
+}
+__MATH_INLINE int
+__NTH (__signbit (double __x))
+{
+  return __builtin__signbit (__x);
+}
+__MATH_INLINE int
+__NTH (__signbitl (long double __x))
+{
+  return __builtin__signbitl (__x);
+}
+# endif
+#endif
diff --exclude .svn --exclude .git --exclude .gitignore -Naur /home/jeremy/gitdirs/uClibc/test/regex/testregex.c ./test/regex/testregex.c
--- /home/jeremy/gitdirs/uClibc/test/regex/testregex.c	2011-06-01 11:27:42.900866758 +0100
+++ ./test/regex/testregex.c	2011-06-01 11:41:54.039867350 +0100
@@ -30,7 +30,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-static const char id[] = "\n@(#)$Id: testregex (AT&T Research) 2005-05-20 $\0\n";
+static const char id[] = "\n@(#)$Id: testregex.c 1548 2011-06-01 10:41:48Z jeremy $\0\n";
 
 #if _PACKAGE_ast
 #include <ast.h>


Jeremy

-- 
Tel:      +44 (1590) 610184
Cell:     +44 (7970) 676050
SkypeID: jeremybennett
Email:   jeremy.bennett at embecosm.com
Web:     www.embecosm.com



More information about the Linux mailing list