This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

uClibc support patch


This patch adds support for uClibc as an alternative library to glibc
on *-*-linux* targets.

The idea is that *-*-linux-gnu* defaults to glibc (but can use uClibc
with -muclibc) and *-*-linux-uclibc* defaults to uClibc (but can use
glibc with -mglibc).  Using one compiler for both libraries is most
convenient with a multilib configuration providing multilibs for both
cases, but with appropriate juggling of sysroots it can be done
without such a multilib configuration.

A more extensive collection of patches for uClibc support is included
in uClibc's buildroot (svn://uclibc.org/trunk/buildroot); the only
part I have used from there is the libstdc++-v3 ctype support (which
is closely based on the glibc files).  Buildroot includes
--enable-clocale=uclibc support, but I haven't included that in my
patch.  I think it's best for other patches from there to be
contributed by people who have a use for them and understand the
purpose they serve; uClibc is very configurable so some patches are
only useful for particular configurations.

In this initial patch I've only added the support for ARM and MIPS;
each Linux target needs dynamic linker configuration similar to that
done in this patch, and the targets not using config/linux.h need
changes corresponding to those in config/linux.h.  I'm willing to do
the full set of mechanical changes to each target if desired, but they
wouldn't be tested.  (Glibc continues to work regardless, but uClibc
support for other processors is broken without the mechanical changes.)

The libstdc++-v3 changes test for uClibc being in use (for the
particular multilib) rather than for a target triplet - this was the
original motivation for bug 25524 - and change cross-compilation of
libstdc++-v3 for Linux targets to use a fuller set of link tests
instead of hardcoding math functions as being present.  Hardcoding
like this cannot work for uClibc because the available set of math
functions depends on how uClibc is configured.  libstdc++-v3
configuration for Linux targets will now definitely require linking
against libc to work, but that was probably the case anyway.

The testsuite changes aren't complete - other tests should be disabled
for uClibc (or sometimes for particular configurations of uClibc only)
with an appropriate effective-target keyword or otherwise - but not
many existing targets have complete configuration of which tests to
skip either.

Tested by building toolchains for arm-linux-uclibceabi,
mipsel-linux-uclibc and arm-linux-gnueabi and checking that programs
are linked correctly in each case, with and without -muclibc or
-mglibc.  OK to commit?

gcc:
2006-02-10  Joseph S. Myers  <joseph@codesourcery.com>

	* config/linux.opt: New file.
	* config/linux.h (CHOOSE_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER,
	LINUX_DYNAMIC_LINKER): Define.
	(TARGET_C99_FUNCTIONS): Define depending on TARGET_GLIBC.
	* config.gcc (*-*-linux*): Define extra_options.
	(*-*-*uclibc*): Define UCLIBC_DEFAULT.
	(arm*-*-linux-gnueabi): Change to arm*-*-linux-*eabi.
	* config/arm/linux-eabi.h (LINUX_TARGET_INTERPRETER): Change to
	GLIBC_DYNAMIC_LINKER.
	* config/arm/linux-elf.h (LINUX_TARGET_INTERPRETER): Likewise.
	(LINUX_TARGET_LINK_SPEC): Use LINUX_DYNAMIC_LINKER.
	* config/mips/linux.h (GLIBC_DYNAMIC_LINKER): Define.
	(LINK_SPEC): Use LINUX_DYNAMIC_LINKER.
	* doc/invoke.texi (GNU/Linux Options): New section.

gcc/testsuite:
2006-02-10  Joseph S. Myers  <joseph@codesourcery.com>

	* gcc.dg/builtins-config.h (HAVE_C99_RUNTIME): Don't define if
	__UCLIBC__ is defined.

libstdc++-v3:
2006-02-10  Joseph S. Myers  <joseph@codesourcery.com>

	* config/os/uclibc/ctype_base.h, config/os/uclibc/ctype_inline.h,
	config/os/uclibc/ctype_noninline.h, config/os/uclibc/os_defines.h:
	New.
	* acinclude.m4 (GLIBCXX_CONFIGURE): Test whether using uClibc.
	* configure.host: Use os/uclibc for uClibc.
	* crossconfig.m4 (*-linux*): Use link tests.  Don't hardcode
	presence of math functions.
	* configure: Regenerate.

diff -rupN GCC.orig/gcc/config/arm/linux-eabi.h GCC/gcc/config/arm/linux-eabi.h
--- GCC.orig/gcc/config/arm/linux-eabi.h	2005-11-16 15:08:50.000000000 +0000
+++ GCC/gcc/config/arm/linux-eabi.h	2006-02-10 02:23:46.000000000 +0000
@@ -1,5 +1,5 @@
 /* Configuration file for ARM GNU/Linux EABI targets.
-   Copyright (C) 2004, 2005
+   Copyright (C) 2004, 2005, 2006
    Free Software Foundation, Inc.
    Contributed by CodeSourcery, LLC   
 
@@ -52,8 +52,8 @@
 
 /* Use ld-linux.so.3 so that it will be possible to run "classic"
    GNU/Linux binaries on an EABI system.  */
-#undef LINUX_TARGET_INTERPRETER
-#define LINUX_TARGET_INTERPRETER "/lib/ld-linux.so.3"
+#undef GLIBC_DYNAMIC_LINKER
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.3"
 
 /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
    use the GNU/Linux version, not the generic BPABI version.  */
diff -rupN GCC.orig/gcc/config/arm/linux-elf.h GCC/gcc/config/arm/linux-elf.h
--- GCC.orig/gcc/config/arm/linux-elf.h	2005-11-22 13:49:21.000000000 +0000
+++ GCC/gcc/config/arm/linux-elf.h	2006-02-10 02:23:49.000000000 +0000
@@ -1,6 +1,6 @@
 /* Definitions for ARM running Linux-based GNU systems using ELF
    Copyright (C) 1993, 1994, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005
+   2005, 2006
    Free Software Foundation, Inc.
    Contributed by Philip Blundell <philb@gnu.org>
 
@@ -51,7 +51,7 @@
 
 #define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
 
-#define LINUX_TARGET_INTERPRETER "/lib/ld-linux.so.2"
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
 
 #define LINUX_TARGET_LINK_SPEC  "%{h*} %{version:-v} \
    %{b} \
@@ -59,7 +59,7 @@
    %{shared:-shared} \
    %{symbolic:-Bsymbolic} \
    %{rdynamic:-export-dynamic} \
-   %{!dynamic-linker:-dynamic-linker " LINUX_TARGET_INTERPRETER "} \
+   %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER "} \
    -X \
    %{mbig-endian:-EB}" \
    SUBTARGET_EXTRA_LINK_SPEC
diff -rupN GCC.orig/gcc/config/linux.h GCC/gcc/config/linux.h
--- GCC.orig/gcc/config/linux.h	2005-10-28 23:34:08.000000000 +0000
+++ GCC/gcc/config/linux.h	2006-02-10 02:23:38.000000000 +0000
@@ -1,5 +1,5 @@
 /* Definitions for Linux-based GNU systems with ELF format
-   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
    Contributed by Eric Youngdale.
    Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
@@ -99,8 +99,24 @@ Boston, MA 02110-1301, USA.  */
 #define USE_LD_AS_NEEDED 1
 #endif
 
+/* Determine which dynamic linker to use depending on whether GLIBC or
+   uClibc is the default C library and whether -muclibc or -mglibc has
+   been passed to change the default.  */
+#ifdef UCLIBC_DEFAULT
+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
+#else
+#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
+#endif
+
+/* For most targets with a single dynamic linker the following
+   definitions suffice; GLIBC_DYNAMIC_LINKER must be defined for each
+   target using them.  */
+#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
+#define LINUX_DYNAMIC_LINKER \
+  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
+
 /* Determine whether the entire c99 runtime
    is present in the runtime library.  */
-#define TARGET_C99_FUNCTIONS 1
+#define TARGET_C99_FUNCTIONS (TARGET_GLIBC)
 
 #define TARGET_POSIX_IO
diff -rupN GCC.orig/gcc/config/linux.opt GCC/gcc/config/linux.opt
--- GCC.orig/gcc/config/linux.opt	1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/config/linux.opt	2006-02-10 02:13:09.000000000 +0000
@@ -0,0 +1,29 @@
+; Processor-independent options for GNU/Linux.
+;
+; Copyright (C) 2006 Free Software Foundation, Inc.
+; Contributed by CodeSourcery.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 2, or (at your option) any later
+; version.
+;
+; GCC 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 General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING.  If not, write to the Free
+; Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+; 02110-1301, USA.
+
+muclibc
+Target RejectNegative Report Mask(UCLIBC)
+Use uClibc instead of GNU libc
+
+mglibc
+Target RejectNegative Report InverseMask(UCLIBC, GLIBC)
+Use GNU libc instead of uClibc
diff -rupN GCC.orig/gcc/config/mips/linux.h GCC/gcc/config/mips/linux.h
--- GCC.orig/gcc/config/mips/linux.h	2005-11-22 13:49:21.000000000 +0000
+++ GCC/gcc/config/mips/linux.h	2006-02-10 02:23:55.000000000 +0000
@@ -1,5 +1,5 @@
 /* Definitions for MIPS running Linux-based GNU systems with ELF format.
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -98,6 +98,8 @@ Boston, MA 02110-1301, USA.  */
 #undef MIPS_DEFAULT_GVALUE
 #define MIPS_DEFAULT_GVALUE 0
 
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
+
 /* Borrowed from sparc/linux.h */
 #undef LINK_SPEC
 #define LINK_SPEC \
@@ -107,7 +109,7 @@ Boston, MA 02110-1301, USA.  */
     %{!ibcs: \
       %{!static: \
         %{rdynamic:-export-dynamic} \
-        %{!dynamic-linker:-dynamic-linker /lib/ld.so.1}} \
+        %{!dynamic-linker:-dynamic-linker " LINUX_DYNAMIC_LINKER "}} \
         %{static:-static}}}"
 
 #undef SUBTARGET_ASM_SPEC
diff -rupN GCC.orig/gcc/config.gcc GCC/gcc/config.gcc
--- GCC.orig/gcc/config.gcc	2006-02-08 23:52:59.000000000 +0000
+++ GCC/gcc/config.gcc	2006-02-10 01:53:22.000000000 +0000
@@ -1,5 +1,5 @@
 # GCC target-specific configuration file.
-# Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
 # Free Software Foundation, Inc.
 
 #This file is part of GCC.
@@ -446,12 +446,18 @@ case ${target} in
 *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
   # Must come before *-*-gnu* (because of *-*-linux-gnu* systems).
   extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o"
+  extra_options="${extra_options} linux.opt"
   gas=yes
   gnu_ld=yes
   case ${enable_threads} in
     "" | yes | posix) thread_file='posix' ;;
   esac
   tmake_file="t-slibgcc-elf-ver t-linux"
+  case ${target} in
+    *-*-*uclibc*)
+      tm_defines="${tm_defines} UCLIBC_DEFAULT"
+      ;;
+  esac
   ;;
 *-*-gnu*)
   # On the Hurd, the setup is just about the same on
@@ -674,7 +680,7 @@ arm*-*-linux*)			# ARM GNU/Linux with EL
 	tm_file="dbxelf.h elfos.h linux.h arm/elf.h arm/linux-gas.h arm/linux-elf.h" 
 	tmake_file="${tmake_file} t-linux arm/t-arm"
 	case ${target} in
-	arm*-*-linux-gnueabi)
+	arm*-*-linux-*eabi)
 	    tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
 	    tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi"
   	    # The BPABI long long divmod functions return a 128-bit value in 
diff -rupN GCC.orig/gcc/doc/invoke.texi GCC/gcc/doc/invoke.texi
--- GCC.orig/gcc/doc/invoke.texi	2006-02-09 21:09:42.000000000 +0000
+++ GCC/gcc/doc/invoke.texi	2006-02-10 16:42:44.000000000 +0000
@@ -503,6 +503,9 @@ Objective-C and Objective-C++ Dialects}.
 -mTLS -mtls @gol
 -mcpu=@var{cpu}}
 
+@emph{GNU/Linux Options}
+@gccoptlist{-muclibc}
+
 @emph{H8/300 Options}
 @gccoptlist{-mrelax  -mh  -ms  -mn  -mint32  -malign-300}
 
@@ -7189,6 +7192,7 @@ platform.
 * DEC Alpha Options::
 * DEC Alpha/VMS Options::
 * FRV Options::
+* GNU/Linux Options::
 * H8/300 Options::
 * HPPA Options::
 * i386 and x86-64 Options::
@@ -8779,6 +8783,24 @@ Select the processor type for which to g
 
 @end table
 
+@node GNU/Linux Options
+@subsection GNU/Linux Options
+
+These @samp{-m} options are defined for GNU/Linux targets:
+
+@table @gcctabopt
+@item -mglibc
+@opindex mglibc
+Use the GNU C library instead of uClibc.  This is the default except
+on @samp{*-*-linux-*uclibc*} targets.
+
+@item -muclibc
+@opindex muclibc
+Use uClibc instead of the GNU C library.  This is the default on
+@samp{*-*-linux-*uclibc*} targets.  GCC currently only supports uClibc
+on ARM and MIPS targets.
+@end table
+
 @node H8/300 Options
 @subsection H8/300 Options
 
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/builtins-config.h GCC/gcc/testsuite/gcc.dg/builtins-config.h
--- GCC.orig/gcc/testsuite/gcc.dg/builtins-config.h	2005-10-28 23:28:51.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/builtins-config.h	2006-02-10 02:22:59.000000000 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 Free Software Foundation.
+/* Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation.
 
    Define macros useful in tests for bulitin functions.  */
 
@@ -38,9 +38,10 @@
    too, but the GLIBC math inlines cause us to generate inferior code,
    which causes the test to fail, so it is not safe.  Including <limits.h>
    also fails because the include search paths are ordered such that GCC's
-   version will be found before the newlib version.  */
+   version will be found before the newlib version.  Similarly, uClibc
+   lacks the C99 functions.  */
 #include <sys/types.h>
-#ifdef _NEWLIB_VERSION
+#if defined(_NEWLIB_VERSION) || defined(__UCLIBC__)
 #else
 #define HAVE_C99_RUNTIME
 #endif
diff -rupN GCC.orig/libstdc++-v3/acinclude.m4 GCC/libstdc++-v3/acinclude.m4
--- GCC.orig/libstdc++-v3/acinclude.m4	2006-02-08 01:17:03.000000000 +0000
+++ GCC/libstdc++-v3/acinclude.m4	2006-02-10 01:17:39.000000000 +0000
@@ -125,6 +125,15 @@ AC_DEFUN([GLIBCXX_CONFIGURE], [
   ## other macros from doing the same.  This should be automated.)  -pme
   need_libmath=no
 
+  # Check for uClibc since Linux platforms use different configuration
+  # directories depending on the C library in use.
+  AC_EGREP_CPP([_using_uclibc], [
+  #include <stdio.h>
+  #if __UCLIBC__
+    _using_uclibc
+  #endif
+  ], uclibc=yes, uclibc=no)
+
   # Find platform-specific directories containing configuration info.
   # Also possibly modify flags used elsewhere, as needed by the platform.
   GLIBCXX_CHECK_HOST
diff -rupN GCC.orig/libstdc++-v3/config/os/uclibc/ctype_base.h GCC/libstdc++-v3/config/os/uclibc/ctype_base.h
--- GCC.orig/libstdc++-v3/config/os/uclibc/ctype_base.h	1970-01-01 00:00:00.000000000 +0000
+++ GCC/libstdc++-v3/config/os/uclibc/ctype_base.h	2006-02-10 01:31:43.000000000 +0000
@@ -0,0 +1,64 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+  
+/** @file ctype_base.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
+ */
+
+// Information as gleaned from /usr/include/ctype.h
+  
+  /// @brief  Base class for ctype.
+  struct ctype_base
+  {
+    // Note: In uClibc, the following two types depend on configuration.
+ 
+    // Non-standard typedefs.
+    typedef const __ctype_touplow_t* __to_type;
+
+    // NB: Offsets into ctype<char>::_M_table force a particular size
+    // on the mask type. Because of this, we don't use an enum.
+    typedef __ctype_mask_t	mask;   
+    static const mask upper    	= _ISupper;
+    static const mask lower 	= _ISlower;
+    static const mask alpha 	= _ISalpha;
+    static const mask digit 	= _ISdigit;
+    static const mask xdigit 	= _ISxdigit;
+    static const mask space 	= _ISspace;
+    static const mask print 	= _ISprint;
+    static const mask graph 	= _ISalpha | _ISdigit | _ISpunct;
+    static const mask cntrl 	= _IScntrl;
+    static const mask punct 	= _ISpunct;
+    static const mask alnum 	= _ISalpha | _ISdigit;
+  };
diff -rupN GCC.orig/libstdc++-v3/config/os/uclibc/ctype_inline.h GCC/libstdc++-v3/config/os/uclibc/ctype_inline.h
--- GCC.orig/libstdc++-v3/config/os/uclibc/ctype_inline.h	1970-01-01 00:00:00.000000000 +0000
+++ GCC/libstdc++-v3/config/os/uclibc/ctype_inline.h	2006-02-10 01:31:38.000000000 +0000
@@ -0,0 +1,69 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+  
+// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
+// functions go in ctype.cc
+  
+  bool
+  ctype<char>::
+  is(mask __m, char __c) const
+  { return _M_table[static_cast<unsigned char>(__c)] & __m; }
+
+  const char*
+  ctype<char>::
+  is(const char* __low, const char* __high, mask* __vec) const
+  {
+    while (__low < __high)
+      *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
+    return __high;
+  }
+
+  const char*
+  ctype<char>::
+  scan_is(mask __m, const char* __low, const char* __high) const
+  {
+    while (__low < __high 
+	   && !(_M_table[static_cast<unsigned char>(*__low)] & __m))
+      ++__low;
+    return __low;
+  }
+
+  const char*
+  ctype<char>::
+  scan_not(mask __m, const char* __low, const char* __high) const
+  {
+    while (__low < __high 
+	   && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
+      ++__low;
+    return __low;
+  }
diff -rupN GCC.orig/libstdc++-v3/config/os/uclibc/ctype_noninline.h GCC/libstdc++-v3/config/os/uclibc/ctype_noninline.h
--- GCC.orig/libstdc++-v3/config/os/uclibc/ctype_noninline.h	1970-01-01 00:00:00.000000000 +0000
+++ GCC/libstdc++-v3/config/os/uclibc/ctype_noninline.h	2006-02-10 01:31:32.000000000 +0000
@@ -0,0 +1,92 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+//
+// ISO C++ 14882: 22.1  Locales
+//
+  
+// Information as gleaned from /usr/include/ctype.h
+
+  const ctype_base::mask*
+  ctype<char>::classic_table() throw()
+  { return __C_ctype_b; }
+
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+		     size_t __refs) 
+  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()), 
+  _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
+  {
+    _M_toupper = __C_ctype_toupper;
+    _M_tolower = __C_ctype_tolower;
+    _M_table = __table ? __table : __C_ctype_b;
+    memset(_M_widen, 0, sizeof(_M_widen));
+    memset(_M_narrow, 0, sizeof(_M_narrow));
+  }
+
+  ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
+  : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()), 
+  _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
+  {
+    _M_toupper = __C_ctype_toupper;
+    _M_tolower = __C_ctype_tolower;
+    _M_table = __table ? __table : __C_ctype_b;
+    memset(_M_widen, 0, sizeof(_M_widen));
+    memset(_M_narrow, 0, sizeof(_M_narrow));
+  }
+
+  char
+  ctype<char>::do_toupper(char __c) const
+  { return _M_toupper[static_cast<unsigned char>(__c)]; }
+
+  const char*
+  ctype<char>::do_toupper(char* __low, const char* __high) const
+  {
+    while (__low < __high)
+      {
+	*__low = _M_toupper[static_cast<unsigned char>(*__low)];
+	++__low;
+      }
+    return __high;
+  }
+
+  char
+  ctype<char>::do_tolower(char __c) const
+  { return _M_tolower[static_cast<unsigned char>(__c)]; }
+
+  const char* 
+  ctype<char>::do_tolower(char* __low, const char* __high) const
+  {
+    while (__low < __high)
+      {
+	*__low = _M_tolower[static_cast<unsigned char>(*__low)];
+	++__low;
+      }
+    return __high;
+  }
diff -rupN GCC.orig/libstdc++-v3/config/os/uclibc/os_defines.h GCC/libstdc++-v3/config/os/uclibc/os_defines.h
--- GCC.orig/libstdc++-v3/config/os/uclibc/os_defines.h	1970-01-01 00:00:00.000000000 +0000
+++ GCC/libstdc++-v3/config/os/uclibc/os_defines.h	2006-02-10 01:31:26.000000000 +0000
@@ -0,0 +1,44 @@
+// Specific definitions for GNU/Linux with uClibc  -*- C++ -*-
+
+// Copyright (C) 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#ifndef _GLIBCXX_OS_DEFINES
+#define _GLIBCXX_OS_DEFINES 1
+
+// System-specific #define, typedefs, corrections, etc, go here.  This
+// file will come before all others.
+
+// This keeps isanum, et al from being propagated as macros.
+#define __NO_CTYPE 1
+
+#include <features.h>
+
+// We must not see the optimized string functions GNU libc defines.
+#define __NO_STRING_INLINES
+
+#endif
diff -rupN GCC.orig/libstdc++-v3/configure.host GCC/libstdc++-v3/configure.host
--- GCC.orig/libstdc++-v3/configure.host	2005-11-18 03:00:40.000000000 +0000
+++ GCC/libstdc++-v3/configure.host	2006-02-10 01:18:19.000000000 +0000
@@ -206,7 +206,11 @@ case "${host_os}" in
     os_include_dir="os/bsd/freebsd"
     ;;
   gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
-    os_include_dir="os/gnu-linux"
+    if [ "$uclibc" = "yes" ]; then
+      os_include_dir="os/uclibc"
+    else
+      os_include_dir="os/gnu-linux"
+    fi
     ;;
   hpux*)
     os_include_dir="os/hpux"
diff -rupN GCC.orig/libstdc++-v3/crossconfig.m4 GCC/libstdc++-v3/crossconfig.m4
--- GCC.orig/libstdc++-v3/crossconfig.m4	2006-01-14 21:47:10.000000000 +0000
+++ GCC/libstdc++-v3/crossconfig.m4	2006-02-10 01:21:55.000000000 +0000
@@ -149,9 +149,13 @@ case "${host}" in
       fp.h float.h endian.h inttypes.h locale.h float.h stdint.h])
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
     AC_SUBST(SECTION_FLAGS)
+    GLIBCXX_CHECK_COMPILER_FEATURES
     GLIBCXX_CHECK_LINKER_FEATURES
+    GLIBCXX_CHECK_MATH_SUPPORT
+    GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
     GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
     GLIBCXX_CHECK_ICONV_SUPPORT
+    GLIBCXX_CHECK_STDLIB_SUPPORT
 
     # For LFS.
     AC_DEFINE(HAVE_INT64_T)
@@ -171,68 +175,6 @@ case "${host}" in
     # For xsputn_2().
     AC_CHECK_HEADERS(sys/uio.h)
     GLIBCXX_CHECK_WRITEV
-
-    AC_DEFINE(HAVE_ACOSF)
-    AC_DEFINE(HAVE_ASINF)
-    AC_DEFINE(HAVE_ATANF)
-    AC_DEFINE(HAVE_ATAN2F)
-    AC_DEFINE(HAVE_CEILF)
-    AC_DEFINE(HAVE_COPYSIGN)
-    AC_DEFINE(HAVE_COPYSIGNF)
-    AC_DEFINE(HAVE_COSF)
-    AC_DEFINE(HAVE_COSHF)
-    AC_DEFINE(HAVE_EXPF)
-    AC_DEFINE(HAVE_FABSF)
-    AC_DEFINE(HAVE_FINITE)
-    AC_DEFINE(HAVE_FINITEF)
-    AC_DEFINE(HAVE_FLOORF)
-    AC_DEFINE(HAVE_FMODF)
-    AC_DEFINE(HAVE_FREXPF)
-    AC_DEFINE(HAVE_HYPOT)
-    AC_DEFINE(HAVE_HYPOTF)
-    AC_DEFINE(HAVE_ISINF)
-    AC_DEFINE(HAVE_ISINFF)
-    AC_DEFINE(HAVE_ISNAN)
-    AC_DEFINE(HAVE_ISNANF)
-    AC_DEFINE(HAVE_LOGF)
-    AC_DEFINE(HAVE_LOG10F)
-    AC_DEFINE(HAVE_MODFF)
-    AC_DEFINE(HAVE_SINF)
-    AC_DEFINE(HAVE_SINHF)
-    AC_DEFINE(HAVE_SINCOS)
-    AC_DEFINE(HAVE_SINCOSF)
-    AC_DEFINE(HAVE_SQRTF)
-    AC_DEFINE(HAVE_TANF)
-    AC_DEFINE(HAVE_TANHF)
-    if test x"long_double_math_on_this_cpu" = x"yes"; then
-      AC_DEFINE(HAVE_ACOSL)
-      AC_DEFINE(HAVE_ASINL)
-      AC_DEFINE(HAVE_ATANL)
-      AC_DEFINE(HAVE_ATAN2L)
-      AC_DEFINE(HAVE_CEILL)
-      AC_DEFINE(HAVE_COPYSIGNL)
-      AC_DEFINE(HAVE_COSL)
-      AC_DEFINE(HAVE_COSHL)
-      AC_DEFINE(HAVE_EXPL)
-      AC_DEFINE(HAVE_FABSL)
-      AC_DEFINE(HAVE_FINITEL)
-      AC_DEFINE(HAVE_FLOORL)
-      AC_DEFINE(HAVE_FMODL)
-      AC_DEFINE(HAVE_FREXPL)
-      AC_DEFINE(HAVE_HYPOTL)
-      AC_DEFINE(HAVE_ISINFL)
-      AC_DEFINE(HAVE_ISNANL)
-      AC_DEFINE(HAVE_LOGL)
-      AC_DEFINE(HAVE_LOG10L)
-      AC_DEFINE(HAVE_MODFL)
-      AC_DEFINE(HAVE_POWL)
-      AC_DEFINE(HAVE_SINL)
-      AC_DEFINE(HAVE_SINHL)
-      AC_DEFINE(HAVE_SINCOSL)
-      AC_DEFINE(HAVE_SQRTL)
-      AC_DEFINE(HAVE_TANL)
-      AC_DEFINE(HAVE_TANHL)
-    fi
     ;;
   *-mingw32*)
     AC_CHECK_HEADERS([sys/types.h locale.h float.h])


-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]