summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.5.0
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.5.0')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/100-uclibc-conf.patch37
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/103-uclibc-conf-noupstream.patch15
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/200-uclibc-locale.patch2840
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/203-uclibc-locale-no__x.patch233
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/204-uclibc-locale-wchar_fix.patch48
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/205-uclibc-locale-update.patch519
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/301-missing-execinfo_h.patch13
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/302-c99-snprintf.patch13
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/303-c99-complex-ugly-hack.patch14
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/304-index_macro.patch28
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/305-libmudflap-susv3-legacy.patch49
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/306-libstdc++-namespace.patch38
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/307-locale_facets.patch19
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/602-sdk-libstdc++-includes.patch20
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/64bithack.patch33
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/740-sh-pr24836.patch29
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/800-arm-bigendian.patch34
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/904-flatten-switch-stmt-00.patch74
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/arm-bswapsi2.patch13
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/arm-nolibfloat.patch24
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/arm-softfloat.patch16
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/arm-unbreak-eabi-armv4t.dpatch36
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/cache-amnesia.patch31
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-c++-builtin-redecl.patch114
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-cpp-pragma.patch284
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-i386-libgomp.patch65
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-ia64-libunwind.patch550
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-java-debug-iface-type.patch19
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-java-nomulti.patch48
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-libgomp-speedup.patch2797
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-ppc32-retaddr.patch90
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr27898.patch16
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr32139.patch19
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr33763.patch159
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh251682.patch89
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh330771.patch31
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh341221.patch32
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/fortran-cross-compile-hack.patch30
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.0.2-e300c2c3.patch319
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch31
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch114
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.5.0_to_svn_162697.patch.bz2bin0 -> 6957305 bytes
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-arm-frename-registers.patch25
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-flags-for-build.patch178
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch331
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-poison-system-directories.patch149
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-pr43698-arm-rev-instr.patch117
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc-uclibc-locale-ctype_touplow_t.patch67
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/gcc_revert_base_version_to_4.5.0.patch9
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/libstdc++-emit-__cxa_end_cleanup-in-text.patch40
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/libstdc++-pic.dpatch71
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/optional_libstdc.patch23
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/pr30961.dpatch179
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/pr35942.patch38
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/zecke-no-host-includes.patch31
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.5.0/zecke-xgcc-cpp.patch28
56 files changed, 10269 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/100-uclibc-conf.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/100-uclibc-conf.patch
new file mode 100644
index 0000000000..0b799607e8
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/100-uclibc-conf.patch
@@ -0,0 +1,37 @@
1Index: gcc-4.3.1/contrib/regression/objs-gcc.sh
2===================================================================
3--- gcc-4.3.1.orig/contrib/regression/objs-gcc.sh 2007-12-24 15:18:57.000000000 -0800
4+++ gcc-4.3.1/contrib/regression/objs-gcc.sh 2008-08-16 01:15:12.000000000 -0700
5@@ -105,6 +105,10 @@
6 then
7 make all-gdb all-dejagnu all-ld || exit 1
8 make install-gdb install-dejagnu install-ld || exit 1
9+elif [ $H_REAL_TARGET = $H_REAL_HOST -a $H_REAL_TARGET = i686-pc-linux-uclibc ]
10+ then
11+ make all-gdb all-dejagnu all-ld || exit 1
12+ make install-gdb install-dejagnu install-ld || exit 1
13 elif [ $H_REAL_TARGET = $H_REAL_HOST ] ; then
14 make bootstrap || exit 1
15 make install || exit 1
16Index: gcc-4.3.1/libjava/classpath/ltconfig
17===================================================================
18--- gcc-4.3.1.orig/libjava/classpath/ltconfig 2007-06-03 16:18:43.000000000 -0700
19+++ gcc-4.3.1/libjava/classpath/ltconfig 2008-08-16 01:15:12.000000000 -0700
20@@ -603,7 +603,7 @@
21
22 # Transform linux* to *-*-linux-gnu*, to support old configure scripts.
23 case $host_os in
24-linux-gnu*) ;;
25+linux-gnu*|linux-uclibc*) ;;
26 linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
27 esac
28
29@@ -1251,7 +1251,7 @@
30 ;;
31
32 # This must be Linux ELF.
33-linux-gnu*)
34+linux*)
35 version_type=linux
36 need_lib_prefix=no
37 need_version=no
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/103-uclibc-conf-noupstream.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/103-uclibc-conf-noupstream.patch
new file mode 100644
index 0000000000..f9d8ad9252
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/103-uclibc-conf-noupstream.patch
@@ -0,0 +1,15 @@
1Corrects sub machine arch corectly
2
3Index: gcc-4.5.0/gcc/config.gcc
4===================================================================
5--- gcc-4.5.0.orig/gcc/config.gcc 2010-06-25 10:17:43.809880847 -0700
6+++ gcc-4.5.0/gcc/config.gcc 2010-06-25 10:38:09.689882136 -0700
7@@ -2171,7 +2171,7 @@
8 ;;
9 sh-*-elf* | sh[12346l]*-*-elf* | \
10 sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \
11- sh-*-linux* | sh[2346lbe]*-*-linux* | \
12+ sh*-*-linux* | sh[2346lbe]*-*-linux* | \
13 sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
14 sh64-*-netbsd* | sh64l*-*-netbsd*)
15 tmake_file="${tmake_file} sh/t-sh sh/t-elf"
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/200-uclibc-locale.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/200-uclibc-locale.patch
new file mode 100644
index 0000000000..32de11fc74
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/200-uclibc-locale.patch
@@ -0,0 +1,2840 @@
1Index: gcc-4.5.0/libstdc++-v3/acinclude.m4
2===================================================================
3--- gcc-4.5.0.orig/libstdc++-v3/acinclude.m4 2010-04-05 18:27:44.000000000 -0700
4+++ gcc-4.5.0/libstdc++-v3/acinclude.m4 2010-06-25 10:42:34.913881064 -0700
5@@ -1703,7 +1703,7 @@
6 AC_DEFUN([GLIBCXX_ENABLE_CLOCALE], [
7 GLIBCXX_ENABLE(clocale,auto,[@<:@=MODEL@:>@],
8 [use MODEL for target locale package],
9- [permit generic|gnu|ieee_1003.1-2001|yes|no|auto])
10+ [permit generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto])
11
12 # Deal with gettext issues. Default to not using it (=no) until we detect
13 # support for it later. Let the user turn it off via --e/d, but let that
14@@ -1724,6 +1724,9 @@
15 # Default to "generic".
16 if test $enable_clocale_flag = auto; then
17 case ${target_os} in
18+ *-uclibc*)
19+ enable_clocale_flag=uclibc
20+ ;;
21 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
22 enable_clocale_flag=gnu
23 ;;
24@@ -1895,6 +1898,40 @@
25 CTIME_CC=config/locale/generic/time_members.cc
26 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
27 ;;
28+ uclibc)
29+ AC_MSG_RESULT(uclibc)
30+
31+ # Declare intention to use gettext, and add support for specific
32+ # languages.
33+ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
34+ ALL_LINGUAS="de fr"
35+
36+ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
37+ AC_CHECK_PROG(check_msgfmt, msgfmt, yes, no)
38+ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
39+ USE_NLS=yes
40+ fi
41+ # Export the build objects.
42+ for ling in $ALL_LINGUAS; do \
43+ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
44+ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
45+ done
46+ AC_SUBST(glibcxx_MOFILES)
47+ AC_SUBST(glibcxx_POFILES)
48+
49+ CLOCALE_H=config/locale/uclibc/c_locale.h
50+ CLOCALE_CC=config/locale/uclibc/c_locale.cc
51+ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
52+ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
53+ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
54+ CMESSAGES_H=config/locale/uclibc/messages_members.h
55+ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
56+ CMONEY_CC=config/locale/uclibc/monetary_members.cc
57+ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
58+ CTIME_H=config/locale/uclibc/time_members.h
59+ CTIME_CC=config/locale/uclibc/time_members.cc
60+ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
61+ ;;
62 esac
63
64 # This is where the testsuite looks for locale catalogs, using the
65Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
66===================================================================
67--- /dev/null 1970-01-01 00:00:00.000000000 +0000
68+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2010-06-25 10:42:34.913881064 -0700
69@@ -0,0 +1,63 @@
70+// Prototypes for GLIBC thread locale __-prefixed functions -*- C++ -*-
71+
72+// Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
73+//
74+// This file is part of the GNU ISO C++ Library. This library is free
75+// software; you can redistribute it and/or modify it under the
76+// terms of the GNU General Public License as published by the
77+// Free Software Foundation; either version 2, or (at your option)
78+// any later version.
79+
80+// This library is distributed in the hope that it will be useful,
81+// but WITHOUT ANY WARRANTY; without even the implied warranty of
82+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83+// GNU General Public License for more details.
84+
85+// You should have received a copy of the GNU General Public License along
86+// with this library; see the file COPYING. If not, write to the Free
87+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
88+// USA.
89+
90+// As a special exception, you may use this file as part of a free software
91+// library without restriction. Specifically, if other files instantiate
92+// templates or use macros or inline functions from this file, or you compile
93+// this file and link it with other files to produce an executable, this
94+// file does not by itself cause the resulting executable to be covered by
95+// the GNU General Public License. This exception does not however
96+// invalidate any other reasons why the executable file might be covered by
97+// the GNU General Public License.
98+
99+// Written by Jakub Jelinek <jakub@redhat.com>
100+
101+#include <bits/c++config.h>
102+#include <clocale>
103+
104+#ifdef __UCLIBC_MJN3_ONLY__
105+#warning clean this up
106+#endif
107+
108+#ifdef __UCLIBC_HAS_XLOCALE__
109+
110+extern "C" __typeof(nl_langinfo_l) __nl_langinfo_l;
111+extern "C" __typeof(strcoll_l) __strcoll_l;
112+extern "C" __typeof(strftime_l) __strftime_l;
113+extern "C" __typeof(strtod_l) __strtod_l;
114+extern "C" __typeof(strtof_l) __strtof_l;
115+extern "C" __typeof(strtold_l) __strtold_l;
116+extern "C" __typeof(strxfrm_l) __strxfrm_l;
117+extern "C" __typeof(newlocale) __newlocale;
118+extern "C" __typeof(freelocale) __freelocale;
119+extern "C" __typeof(duplocale) __duplocale;
120+extern "C" __typeof(uselocale) __uselocale;
121+
122+#ifdef _GLIBCXX_USE_WCHAR_T
123+extern "C" __typeof(iswctype_l) __iswctype_l;
124+extern "C" __typeof(towlower_l) __towlower_l;
125+extern "C" __typeof(towupper_l) __towupper_l;
126+extern "C" __typeof(wcscoll_l) __wcscoll_l;
127+extern "C" __typeof(wcsftime_l) __wcsftime_l;
128+extern "C" __typeof(wcsxfrm_l) __wcsxfrm_l;
129+extern "C" __typeof(wctype_l) __wctype_l;
130+#endif
131+
132+#endif // GLIBC 2.3 and later
133Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/c_locale.cc
134===================================================================
135--- /dev/null 1970-01-01 00:00:00.000000000 +0000
136+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/c_locale.cc 2010-06-25 10:42:34.913881064 -0700
137@@ -0,0 +1,160 @@
138+// Wrapper for underlying C-language localization -*- C++ -*-
139+
140+// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
141+//
142+// This file is part of the GNU ISO C++ Library. This library is free
143+// software; you can redistribute it and/or modify it under the
144+// terms of the GNU General Public License as published by the
145+// Free Software Foundation; either version 2, or (at your option)
146+// any later version.
147+
148+// This library is distributed in the hope that it will be useful,
149+// but WITHOUT ANY WARRANTY; without even the implied warranty of
150+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
151+// GNU General Public License for more details.
152+
153+// You should have received a copy of the GNU General Public License along
154+// with this library; see the file COPYING. If not, write to the Free
155+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
156+// USA.
157+
158+// As a special exception, you may use this file as part of a free software
159+// library without restriction. Specifically, if other files instantiate
160+// templates or use macros or inline functions from this file, or you compile
161+// this file and link it with other files to produce an executable, this
162+// file does not by itself cause the resulting executable to be covered by
163+// the GNU General Public License. This exception does not however
164+// invalidate any other reasons why the executable file might be covered by
165+// the GNU General Public License.
166+
167+//
168+// ISO C++ 14882: 22.8 Standard locale categories.
169+//
170+
171+// Written by Benjamin Kosnik <bkoz@redhat.com>
172+
173+#include <cerrno> // For errno
174+#include <locale>
175+#include <stdexcept>
176+#include <langinfo.h>
177+#include <bits/c++locale_internal.h>
178+
179+#ifndef __UCLIBC_HAS_XLOCALE__
180+#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
181+#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
182+#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
183+#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
184+#define __strtof_l(S, E, L) strtof((S), (E))
185+#define __strtod_l(S, E, L) strtod((S), (E))
186+#define __strtold_l(S, E, L) strtold((S), (E))
187+#warning should dummy __newlocale check for C|POSIX ?
188+#define __newlocale(a, b, c) NULL
189+#define __freelocale(a) ((void)0)
190+#define __duplocale(a) __c_locale()
191+#endif
192+
193+namespace std
194+{
195+ template<>
196+ void
197+ __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
198+ const __c_locale& __cloc)
199+ {
200+ if (!(__err & ios_base::failbit))
201+ {
202+ char* __sanity;
203+ errno = 0;
204+ float __f = __strtof_l(__s, &__sanity, __cloc);
205+ if (__sanity != __s && errno != ERANGE)
206+ __v = __f;
207+ else
208+ __err |= ios_base::failbit;
209+ }
210+ }
211+
212+ template<>
213+ void
214+ __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
215+ const __c_locale& __cloc)
216+ {
217+ if (!(__err & ios_base::failbit))
218+ {
219+ char* __sanity;
220+ errno = 0;
221+ double __d = __strtod_l(__s, &__sanity, __cloc);
222+ if (__sanity != __s && errno != ERANGE)
223+ __v = __d;
224+ else
225+ __err |= ios_base::failbit;
226+ }
227+ }
228+
229+ template<>
230+ void
231+ __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
232+ const __c_locale& __cloc)
233+ {
234+ if (!(__err & ios_base::failbit))
235+ {
236+ char* __sanity;
237+ errno = 0;
238+ long double __ld = __strtold_l(__s, &__sanity, __cloc);
239+ if (__sanity != __s && errno != ERANGE)
240+ __v = __ld;
241+ else
242+ __err |= ios_base::failbit;
243+ }
244+ }
245+
246+ void
247+ locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
248+ __c_locale __old)
249+ {
250+ __cloc = __newlocale(1 << LC_ALL, __s, __old);
251+#ifdef __UCLIBC_HAS_XLOCALE__
252+ if (!__cloc)
253+ {
254+ // This named locale is not supported by the underlying OS.
255+ __throw_runtime_error(__N("locale::facet::_S_create_c_locale "
256+ "name not valid"));
257+ }
258+#endif
259+ }
260+
261+ void
262+ locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
263+ {
264+ if (_S_get_c_locale() != __cloc)
265+ __freelocale(__cloc);
266+ }
267+
268+ __c_locale
269+ locale::facet::_S_clone_c_locale(__c_locale& __cloc)
270+ { return __duplocale(__cloc); }
271+} // namespace std
272+
273+namespace __gnu_cxx
274+{
275+ const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
276+ {
277+ "LC_CTYPE",
278+ "LC_NUMERIC",
279+ "LC_TIME",
280+ "LC_COLLATE",
281+ "LC_MONETARY",
282+ "LC_MESSAGES",
283+#if _GLIBCXX_NUM_CATEGORIES != 0
284+ "LC_PAPER",
285+ "LC_NAME",
286+ "LC_ADDRESS",
287+ "LC_TELEPHONE",
288+ "LC_MEASUREMENT",
289+ "LC_IDENTIFICATION"
290+#endif
291+ };
292+}
293+
294+namespace std
295+{
296+ const char* const* const locale::_S_categories = __gnu_cxx::category_names;
297+} // namespace std
298Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/c_locale.h
299===================================================================
300--- /dev/null 1970-01-01 00:00:00.000000000 +0000
301+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/c_locale.h 2010-06-25 10:42:34.913881064 -0700
302@@ -0,0 +1,117 @@
303+// Wrapper for underlying C-language localization -*- C++ -*-
304+
305+// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
306+//
307+// This file is part of the GNU ISO C++ Library. This library is free
308+// software; you can redistribute it and/or modify it under the
309+// terms of the GNU General Public License as published by the
310+// Free Software Foundation; either version 2, or (at your option)
311+// any later version.
312+
313+// This library is distributed in the hope that it will be useful,
314+// but WITHOUT ANY WARRANTY; without even the implied warranty of
315+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
316+// GNU General Public License for more details.
317+
318+// You should have received a copy of the GNU General Public License along
319+// with this library; see the file COPYING. If not, write to the Free
320+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
321+// USA.
322+
323+// As a special exception, you may use this file as part of a free software
324+// library without restriction. Specifically, if other files instantiate
325+// templates or use macros or inline functions from this file, or you compile
326+// this file and link it with other files to produce an executable, this
327+// file does not by itself cause the resulting executable to be covered by
328+// the GNU General Public License. This exception does not however
329+// invalidate any other reasons why the executable file might be covered by
330+// the GNU General Public License.
331+
332+//
333+// ISO C++ 14882: 22.8 Standard locale categories.
334+//
335+
336+// Written by Benjamin Kosnik <bkoz@redhat.com>
337+
338+#ifndef _C_LOCALE_H
339+#define _C_LOCALE_H 1
340+
341+#pragma GCC system_header
342+
343+#include <cstring> // get std::strlen
344+#include <cstdio> // get std::snprintf or std::sprintf
345+#include <clocale>
346+#include <langinfo.h> // For codecvt
347+#ifdef __UCLIBC_MJN3_ONLY__
348+#warning fix this
349+#endif
350+#ifdef __UCLIBC_HAS_LOCALE__
351+#include <iconv.h> // For codecvt using iconv, iconv_t
352+#endif
353+#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
354+#include <libintl.h> // For messages
355+#endif
356+
357+#ifdef __UCLIBC_MJN3_ONLY__
358+#warning what is _GLIBCXX_C_LOCALE_GNU for
359+#endif
360+#define _GLIBCXX_C_LOCALE_GNU 1
361+
362+#ifdef __UCLIBC_MJN3_ONLY__
363+#warning fix categories
364+#endif
365+// #define _GLIBCXX_NUM_CATEGORIES 6
366+#define _GLIBCXX_NUM_CATEGORIES 0
367+
368+#ifdef __UCLIBC_HAS_XLOCALE__
369+namespace __gnu_cxx
370+{
371+ extern "C" __typeof(uselocale) __uselocale;
372+}
373+#endif
374+
375+namespace std
376+{
377+#ifdef __UCLIBC_HAS_XLOCALE__
378+ typedef __locale_t __c_locale;
379+#else
380+ typedef int* __c_locale;
381+#endif
382+
383+ // Convert numeric value of type _Tv to string and return length of
384+ // string. If snprintf is available use it, otherwise fall back to
385+ // the unsafe sprintf which, in general, can be dangerous and should
386+ // be avoided.
387+ template<typename _Tv>
388+ int
389+ __convert_from_v(char* __out,
390+ const int __size __attribute__ ((__unused__)),
391+ const char* __fmt,
392+#ifdef __UCLIBC_HAS_XCLOCALE__
393+ _Tv __v, const __c_locale& __cloc, int __prec)
394+ {
395+ __c_locale __old = __gnu_cxx::__uselocale(__cloc);
396+#else
397+ _Tv __v, const __c_locale&, int __prec)
398+ {
399+# ifdef __UCLIBC_HAS_LOCALE__
400+ char* __old = std::setlocale(LC_ALL, NULL);
401+ char* __sav = new char[std::strlen(__old) + 1];
402+ std::strcpy(__sav, __old);
403+ std::setlocale(LC_ALL, "C");
404+# endif
405+#endif
406+
407+ const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
408+
409+#ifdef __UCLIBC_HAS_XCLOCALE__
410+ __gnu_cxx::__uselocale(__old);
411+#elif defined __UCLIBC_HAS_LOCALE__
412+ std::setlocale(LC_ALL, __sav);
413+ delete [] __sav;
414+#endif
415+ return __ret;
416+ }
417+}
418+
419+#endif
420Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/codecvt_members.cc
421===================================================================
422--- /dev/null 1970-01-01 00:00:00.000000000 +0000
423+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/codecvt_members.cc 2010-06-25 10:42:34.913881064 -0700
424@@ -0,0 +1,308 @@
425+// std::codecvt implementation details, GNU version -*- C++ -*-
426+
427+// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
428+//
429+// This file is part of the GNU ISO C++ Library. This library is free
430+// software; you can redistribute it and/or modify it under the
431+// terms of the GNU General Public License as published by the
432+// Free Software Foundation; either version 2, or (at your option)
433+// any later version.
434+
435+// This library is distributed in the hope that it will be useful,
436+// but WITHOUT ANY WARRANTY; without even the implied warranty of
437+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
438+// GNU General Public License for more details.
439+
440+// You should have received a copy of the GNU General Public License along
441+// with this library; see the file COPYING. If not, write to the Free
442+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
443+// USA.
444+
445+// As a special exception, you may use this file as part of a free software
446+// library without restriction. Specifically, if other files instantiate
447+// templates or use macros or inline functions from this file, or you compile
448+// this file and link it with other files to produce an executable, this
449+// file does not by itself cause the resulting executable to be covered by
450+// the GNU General Public License. This exception does not however
451+// invalidate any other reasons why the executable file might be covered by
452+// the GNU General Public License.
453+
454+//
455+// ISO C++ 14882: 22.2.1.5 - Template class codecvt
456+//
457+
458+// Written by Benjamin Kosnik <bkoz@redhat.com>
459+
460+#include <locale>
461+#include <cstdlib> // For MB_CUR_MAX
462+#include <climits> // For MB_LEN_MAX
463+#include <bits/c++locale_internal.h>
464+
465+namespace std
466+{
467+ // Specializations.
468+#ifdef _GLIBCXX_USE_WCHAR_T
469+ codecvt_base::result
470+ codecvt<wchar_t, char, mbstate_t>::
471+ do_out(state_type& __state, const intern_type* __from,
472+ const intern_type* __from_end, const intern_type*& __from_next,
473+ extern_type* __to, extern_type* __to_end,
474+ extern_type*& __to_next) const
475+ {
476+ result __ret = ok;
477+ state_type __tmp_state(__state);
478+
479+#ifdef __UCLIBC_HAS_XLOCALE__
480+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
481+#endif
482+
483+ // wcsnrtombs is *very* fast but stops if encounters NUL characters:
484+ // in case we fall back to wcrtomb and then continue, in a loop.
485+ // NB: wcsnrtombs is a GNU extension
486+ for (__from_next = __from, __to_next = __to;
487+ __from_next < __from_end && __to_next < __to_end
488+ && __ret == ok;)
489+ {
490+ const intern_type* __from_chunk_end = wmemchr(__from_next, L'\0',
491+ __from_end - __from_next);
492+ if (!__from_chunk_end)
493+ __from_chunk_end = __from_end;
494+
495+ __from = __from_next;
496+ const size_t __conv = wcsnrtombs(__to_next, &__from_next,
497+ __from_chunk_end - __from_next,
498+ __to_end - __to_next, &__state);
499+ if (__conv == static_cast<size_t>(-1))
500+ {
501+ // In case of error, in order to stop at the exact place we
502+ // have to start again from the beginning with a series of
503+ // wcrtomb.
504+ for (; __from < __from_next; ++__from)
505+ __to_next += wcrtomb(__to_next, *__from, &__tmp_state);
506+ __state = __tmp_state;
507+ __ret = error;
508+ }
509+ else if (__from_next && __from_next < __from_chunk_end)
510+ {
511+ __to_next += __conv;
512+ __ret = partial;
513+ }
514+ else
515+ {
516+ __from_next = __from_chunk_end;
517+ __to_next += __conv;
518+ }
519+
520+ if (__from_next < __from_end && __ret == ok)
521+ {
522+ extern_type __buf[MB_LEN_MAX];
523+ __tmp_state = __state;
524+ const size_t __conv = wcrtomb(__buf, *__from_next, &__tmp_state);
525+ if (__conv > static_cast<size_t>(__to_end - __to_next))
526+ __ret = partial;
527+ else
528+ {
529+ memcpy(__to_next, __buf, __conv);
530+ __state = __tmp_state;
531+ __to_next += __conv;
532+ ++__from_next;
533+ }
534+ }
535+ }
536+
537+#ifdef __UCLIBC_HAS_XLOCALE__
538+ __uselocale(__old);
539+#endif
540+
541+ return __ret;
542+ }
543+
544+ codecvt_base::result
545+ codecvt<wchar_t, char, mbstate_t>::
546+ do_in(state_type& __state, const extern_type* __from,
547+ const extern_type* __from_end, const extern_type*& __from_next,
548+ intern_type* __to, intern_type* __to_end,
549+ intern_type*& __to_next) const
550+ {
551+ result __ret = ok;
552+ state_type __tmp_state(__state);
553+
554+#ifdef __UCLIBC_HAS_XLOCALE__
555+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
556+#endif
557+
558+ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
559+ // in case we store a L'\0' and then continue, in a loop.
560+ // NB: mbsnrtowcs is a GNU extension
561+ for (__from_next = __from, __to_next = __to;
562+ __from_next < __from_end && __to_next < __to_end
563+ && __ret == ok;)
564+ {
565+ const extern_type* __from_chunk_end;
566+ __from_chunk_end = static_cast<const extern_type*>(memchr(__from_next, '\0',
567+ __from_end
568+ - __from_next));
569+ if (!__from_chunk_end)
570+ __from_chunk_end = __from_end;
571+
572+ __from = __from_next;
573+ size_t __conv = mbsnrtowcs(__to_next, &__from_next,
574+ __from_chunk_end - __from_next,
575+ __to_end - __to_next, &__state);
576+ if (__conv == static_cast<size_t>(-1))
577+ {
578+ // In case of error, in order to stop at the exact place we
579+ // have to start again from the beginning with a series of
580+ // mbrtowc.
581+ for (;; ++__to_next, __from += __conv)
582+ {
583+ __conv = mbrtowc(__to_next, __from, __from_end - __from,
584+ &__tmp_state);
585+ if (__conv == static_cast<size_t>(-1)
586+ || __conv == static_cast<size_t>(-2))
587+ break;
588+ }
589+ __from_next = __from;
590+ __state = __tmp_state;
591+ __ret = error;
592+ }
593+ else if (__from_next && __from_next < __from_chunk_end)
594+ {
595+ // It is unclear what to return in this case (see DR 382).
596+ __to_next += __conv;
597+ __ret = partial;
598+ }
599+ else
600+ {
601+ __from_next = __from_chunk_end;
602+ __to_next += __conv;
603+ }
604+
605+ if (__from_next < __from_end && __ret == ok)
606+ {
607+ if (__to_next < __to_end)
608+ {
609+ // XXX Probably wrong for stateful encodings
610+ __tmp_state = __state;
611+ ++__from_next;
612+ *__to_next++ = L'\0';
613+ }
614+ else
615+ __ret = partial;
616+ }
617+ }
618+
619+#ifdef __UCLIBC_HAS_XLOCALE__
620+ __uselocale(__old);
621+#endif
622+
623+ return __ret;
624+ }
625+
626+ int
627+ codecvt<wchar_t, char, mbstate_t>::
628+ do_encoding() const throw()
629+ {
630+ // XXX This implementation assumes that the encoding is
631+ // stateless and is either single-byte or variable-width.
632+ int __ret = 0;
633+#ifdef __UCLIBC_HAS_XLOCALE__
634+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
635+#endif
636+ if (MB_CUR_MAX == 1)
637+ __ret = 1;
638+#ifdef __UCLIBC_HAS_XLOCALE__
639+ __uselocale(__old);
640+#endif
641+ return __ret;
642+ }
643+
644+ int
645+ codecvt<wchar_t, char, mbstate_t>::
646+ do_max_length() const throw()
647+ {
648+#ifdef __UCLIBC_HAS_XLOCALE__
649+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
650+#endif
651+ // XXX Probably wrong for stateful encodings.
652+ int __ret = MB_CUR_MAX;
653+#ifdef __UCLIBC_HAS_XLOCALE__
654+ __uselocale(__old);
655+#endif
656+ return __ret;
657+ }
658+
659+ int
660+ codecvt<wchar_t, char, mbstate_t>::
661+ do_length(state_type& __state, const extern_type* __from,
662+ const extern_type* __end, size_t __max) const
663+ {
664+ int __ret = 0;
665+ state_type __tmp_state(__state);
666+
667+#ifdef __UCLIBC_HAS_XLOCALE__
668+ __c_locale __old = __uselocale(_M_c_locale_codecvt);
669+#endif
670+
671+ // mbsnrtowcs is *very* fast but stops if encounters NUL characters:
672+ // in case we advance past it and then continue, in a loop.
673+ // NB: mbsnrtowcs is a GNU extension
674+
675+ // A dummy internal buffer is needed in order for mbsnrtocws to consider
676+ // its fourth parameter (it wouldn't with NULL as first parameter).
677+ wchar_t* __to = static_cast<wchar_t*>(__builtin_alloca(sizeof(wchar_t)
678+ * __max));
679+ while (__from < __end && __max)
680+ {
681+ const extern_type* __from_chunk_end;
682+ __from_chunk_end = static_cast<const extern_type*>(memchr(__from, '\0',
683+ __end
684+ - __from));
685+ if (!__from_chunk_end)
686+ __from_chunk_end = __end;
687+
688+ const extern_type* __tmp_from = __from;
689+ size_t __conv = mbsnrtowcs(__to, &__from,
690+ __from_chunk_end - __from,
691+ __max, &__state);
692+ if (__conv == static_cast<size_t>(-1))
693+ {
694+ // In case of error, in order to stop at the exact place we
695+ // have to start again from the beginning with a series of
696+ // mbrtowc.
697+ for (__from = __tmp_from;; __from += __conv)
698+ {
699+ __conv = mbrtowc(NULL, __from, __end - __from,
700+ &__tmp_state);
701+ if (__conv == static_cast<size_t>(-1)
702+ || __conv == static_cast<size_t>(-2))
703+ break;
704+ }
705+ __state = __tmp_state;
706+ __ret += __from - __tmp_from;
707+ break;
708+ }
709+ if (!__from)
710+ __from = __from_chunk_end;
711+
712+ __ret += __from - __tmp_from;
713+ __max -= __conv;
714+
715+ if (__from < __end && __max)
716+ {
717+ // XXX Probably wrong for stateful encodings
718+ __tmp_state = __state;
719+ ++__from;
720+ ++__ret;
721+ --__max;
722+ }
723+ }
724+
725+#ifdef __UCLIBC_HAS_XLOCALE__
726+ __uselocale(__old);
727+#endif
728+
729+ return __ret;
730+ }
731+#endif
732+}
733Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/collate_members.cc
734===================================================================
735--- /dev/null 1970-01-01 00:00:00.000000000 +0000
736+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/collate_members.cc 2010-06-25 10:42:34.913881064 -0700
737@@ -0,0 +1,80 @@
738+// std::collate implementation details, GNU version -*- C++ -*-
739+
740+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
741+//
742+// This file is part of the GNU ISO C++ Library. This library is free
743+// software; you can redistribute it and/or modify it under the
744+// terms of the GNU General Public License as published by the
745+// Free Software Foundation; either version 2, or (at your option)
746+// any later version.
747+
748+// This library is distributed in the hope that it will be useful,
749+// but WITHOUT ANY WARRANTY; without even the implied warranty of
750+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
751+// GNU General Public License for more details.
752+
753+// You should have received a copy of the GNU General Public License along
754+// with this library; see the file COPYING. If not, write to the Free
755+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
756+// USA.
757+
758+// As a special exception, you may use this file as part of a free software
759+// library without restriction. Specifically, if other files instantiate
760+// templates or use macros or inline functions from this file, or you compile
761+// this file and link it with other files to produce an executable, this
762+// file does not by itself cause the resulting executable to be covered by
763+// the GNU General Public License. This exception does not however
764+// invalidate any other reasons why the executable file might be covered by
765+// the GNU General Public License.
766+
767+//
768+// ISO C++ 14882: 22.2.4.1.2 collate virtual functions
769+//
770+
771+// Written by Benjamin Kosnik <bkoz@redhat.com>
772+
773+#include <locale>
774+#include <bits/c++locale_internal.h>
775+
776+#ifndef __UCLIBC_HAS_XLOCALE__
777+#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
778+#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
779+#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
780+#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
781+#endif
782+
783+namespace std
784+{
785+ // These are basically extensions to char_traits, and perhaps should
786+ // be put there instead of here.
787+ template<>
788+ int
789+ collate<char>::_M_compare(const char* __one, const char* __two) const
790+ {
791+ int __cmp = __strcoll_l(__one, __two, _M_c_locale_collate);
792+ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
793+ }
794+
795+ template<>
796+ size_t
797+ collate<char>::_M_transform(char* __to, const char* __from,
798+ size_t __n) const
799+ { return __strxfrm_l(__to, __from, __n, _M_c_locale_collate); }
800+
801+#ifdef _GLIBCXX_USE_WCHAR_T
802+ template<>
803+ int
804+ collate<wchar_t>::_M_compare(const wchar_t* __one,
805+ const wchar_t* __two) const
806+ {
807+ int __cmp = __wcscoll_l(__one, __two, _M_c_locale_collate);
808+ return (__cmp >> (8 * sizeof (int) - 2)) | (__cmp != 0);
809+ }
810+
811+ template<>
812+ size_t
813+ collate<wchar_t>::_M_transform(wchar_t* __to, const wchar_t* __from,
814+ size_t __n) const
815+ { return __wcsxfrm_l(__to, __from, __n, _M_c_locale_collate); }
816+#endif
817+}
818Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/ctype_members.cc
819===================================================================
820--- /dev/null 1970-01-01 00:00:00.000000000 +0000
821+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2010-06-25 10:42:34.913881064 -0700
822@@ -0,0 +1,300 @@
823+// std::ctype implementation details, GNU version -*- C++ -*-
824+
825+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
826+//
827+// This file is part of the GNU ISO C++ Library. This library is free
828+// software; you can redistribute it and/or modify it under the
829+// terms of the GNU General Public License as published by the
830+// Free Software Foundation; either version 2, or (at your option)
831+// any later version.
832+
833+// This library is distributed in the hope that it will be useful,
834+// but WITHOUT ANY WARRANTY; without even the implied warranty of
835+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
836+// GNU General Public License for more details.
837+
838+// You should have received a copy of the GNU General Public License along
839+// with this library; see the file COPYING. If not, write to the Free
840+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
841+// USA.
842+
843+// As a special exception, you may use this file as part of a free software
844+// library without restriction. Specifically, if other files instantiate
845+// templates or use macros or inline functions from this file, or you compile
846+// this file and link it with other files to produce an executable, this
847+// file does not by itself cause the resulting executable to be covered by
848+// the GNU General Public License. This exception does not however
849+// invalidate any other reasons why the executable file might be covered by
850+// the GNU General Public License.
851+
852+//
853+// ISO C++ 14882: 22.2.1.1.2 ctype virtual functions.
854+//
855+
856+// Written by Benjamin Kosnik <bkoz@redhat.com>
857+
858+#define _LIBC
859+#include <locale>
860+#undef _LIBC
861+#include <bits/c++locale_internal.h>
862+
863+#ifndef __UCLIBC_HAS_XLOCALE__
864+#define __wctype_l(S, L) wctype((S))
865+#define __towupper_l(C, L) towupper((C))
866+#define __towlower_l(C, L) towlower((C))
867+#define __iswctype_l(C, M, L) iswctype((C), (M))
868+#endif
869+
870+namespace std
871+{
872+ // NB: The other ctype<char> specializations are in src/locale.cc and
873+ // various /config/os/* files.
874+ template<>
875+ ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
876+ : ctype<char>(0, false, __refs)
877+ {
878+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
879+ {
880+ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
881+ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
882+#ifdef __UCLIBC_HAS_XLOCALE__
883+ this->_M_toupper = this->_M_c_locale_ctype->__ctype_toupper;
884+ this->_M_tolower = this->_M_c_locale_ctype->__ctype_tolower;
885+ this->_M_table = this->_M_c_locale_ctype->__ctype_b;
886+#endif
887+ }
888+ }
889+
890+#ifdef _GLIBCXX_USE_WCHAR_T
891+ ctype<wchar_t>::__wmask_type
892+ ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const
893+ {
894+ __wmask_type __ret;
895+ switch (__m)
896+ {
897+ case space:
898+ __ret = __wctype_l("space", _M_c_locale_ctype);
899+ break;
900+ case print:
901+ __ret = __wctype_l("print", _M_c_locale_ctype);
902+ break;
903+ case cntrl:
904+ __ret = __wctype_l("cntrl", _M_c_locale_ctype);
905+ break;
906+ case upper:
907+ __ret = __wctype_l("upper", _M_c_locale_ctype);
908+ break;
909+ case lower:
910+ __ret = __wctype_l("lower", _M_c_locale_ctype);
911+ break;
912+ case alpha:
913+ __ret = __wctype_l("alpha", _M_c_locale_ctype);
914+ break;
915+ case digit:
916+ __ret = __wctype_l("digit", _M_c_locale_ctype);
917+ break;
918+ case punct:
919+ __ret = __wctype_l("punct", _M_c_locale_ctype);
920+ break;
921+ case xdigit:
922+ __ret = __wctype_l("xdigit", _M_c_locale_ctype);
923+ break;
924+ case alnum:
925+ __ret = __wctype_l("alnum", _M_c_locale_ctype);
926+ break;
927+ case graph:
928+ __ret = __wctype_l("graph", _M_c_locale_ctype);
929+ break;
930+ default:
931+ __ret = __wmask_type();
932+ }
933+ return __ret;
934+ }
935+
936+ wchar_t
937+ ctype<wchar_t>::do_toupper(wchar_t __c) const
938+ { return __towupper_l(__c, _M_c_locale_ctype); }
939+
940+ const wchar_t*
941+ ctype<wchar_t>::do_toupper(wchar_t* __lo, const wchar_t* __hi) const
942+ {
943+ while (__lo < __hi)
944+ {
945+ *__lo = __towupper_l(*__lo, _M_c_locale_ctype);
946+ ++__lo;
947+ }
948+ return __hi;
949+ }
950+
951+ wchar_t
952+ ctype<wchar_t>::do_tolower(wchar_t __c) const
953+ { return __towlower_l(__c, _M_c_locale_ctype); }
954+
955+ const wchar_t*
956+ ctype<wchar_t>::do_tolower(wchar_t* __lo, const wchar_t* __hi) const
957+ {
958+ while (__lo < __hi)
959+ {
960+ *__lo = __towlower_l(*__lo, _M_c_locale_ctype);
961+ ++__lo;
962+ }
963+ return __hi;
964+ }
965+
966+ bool
967+ ctype<wchar_t>::
968+ do_is(mask __m, wchar_t __c) const
969+ {
970+ // Highest bitmask in ctype_base == 10, but extra in "C"
971+ // library for blank.
972+ bool __ret = false;
973+ const size_t __bitmasksize = 11;
974+ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
975+ if (__m & _M_bit[__bitcur]
976+ && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
977+ {
978+ __ret = true;
979+ break;
980+ }
981+ return __ret;
982+ }
983+
984+ const wchar_t*
985+ ctype<wchar_t>::
986+ do_is(const wchar_t* __lo, const wchar_t* __hi, mask* __vec) const
987+ {
988+ for (; __lo < __hi; ++__vec, ++__lo)
989+ {
990+ // Highest bitmask in ctype_base == 10, but extra in "C"
991+ // library for blank.
992+ const size_t __bitmasksize = 11;
993+ mask __m = 0;
994+ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
995+ if (__iswctype_l(*__lo, _M_wmask[__bitcur], _M_c_locale_ctype))
996+ __m |= _M_bit[__bitcur];
997+ *__vec = __m;
998+ }
999+ return __hi;
1000+ }
1001+
1002+ const wchar_t*
1003+ ctype<wchar_t>::
1004+ do_scan_is(mask __m, const wchar_t* __lo, const wchar_t* __hi) const
1005+ {
1006+ while (__lo < __hi && !this->do_is(__m, *__lo))
1007+ ++__lo;
1008+ return __lo;
1009+ }
1010+
1011+ const wchar_t*
1012+ ctype<wchar_t>::
1013+ do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
1014+ {
1015+ while (__lo < __hi && this->do_is(__m, *__lo) != 0)
1016+ ++__lo;
1017+ return __lo;
1018+ }
1019+
1020+ wchar_t
1021+ ctype<wchar_t>::
1022+ do_widen(char __c) const
1023+ { return _M_widen[static_cast<unsigned char>(__c)]; }
1024+
1025+ const char*
1026+ ctype<wchar_t>::
1027+ do_widen(const char* __lo, const char* __hi, wchar_t* __dest) const
1028+ {
1029+ while (__lo < __hi)
1030+ {
1031+ *__dest = _M_widen[static_cast<unsigned char>(*__lo)];
1032+ ++__lo;
1033+ ++__dest;
1034+ }
1035+ return __hi;
1036+ }
1037+
1038+ char
1039+ ctype<wchar_t>::
1040+ do_narrow(wchar_t __wc, char __dfault) const
1041+ {
1042+ if (__wc >= 0 && __wc < 128 && _M_narrow_ok)
1043+ return _M_narrow[__wc];
1044+#ifdef __UCLIBC_HAS_XLOCALE__
1045+ __c_locale __old = __uselocale(_M_c_locale_ctype);
1046+#endif
1047+ const int __c = wctob(__wc);
1048+#ifdef __UCLIBC_HAS_XLOCALE__
1049+ __uselocale(__old);
1050+#endif
1051+ return (__c == EOF ? __dfault : static_cast<char>(__c));
1052+ }
1053+
1054+ const wchar_t*
1055+ ctype<wchar_t>::
1056+ do_narrow(const wchar_t* __lo, const wchar_t* __hi, char __dfault,
1057+ char* __dest) const
1058+ {
1059+#ifdef __UCLIBC_HAS_XLOCALE__
1060+ __c_locale __old = __uselocale(_M_c_locale_ctype);
1061+#endif
1062+ if (_M_narrow_ok)
1063+ while (__lo < __hi)
1064+ {
1065+ if (*__lo >= 0 && *__lo < 128)
1066+ *__dest = _M_narrow[*__lo];
1067+ else
1068+ {
1069+ const int __c = wctob(*__lo);
1070+ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
1071+ }
1072+ ++__lo;
1073+ ++__dest;
1074+ }
1075+ else
1076+ while (__lo < __hi)
1077+ {
1078+ const int __c = wctob(*__lo);
1079+ *__dest = (__c == EOF ? __dfault : static_cast<char>(__c));
1080+ ++__lo;
1081+ ++__dest;
1082+ }
1083+#ifdef __UCLIBC_HAS_XLOCALE__
1084+ __uselocale(__old);
1085+#endif
1086+ return __hi;
1087+ }
1088+
1089+ void
1090+ ctype<wchar_t>::_M_initialize_ctype()
1091+ {
1092+#ifdef __UCLIBC_HAS_XLOCALE__
1093+ __c_locale __old = __uselocale(_M_c_locale_ctype);
1094+#endif
1095+ wint_t __i;
1096+ for (__i = 0; __i < 128; ++__i)
1097+ {
1098+ const int __c = wctob(__i);
1099+ if (__c == EOF)
1100+ break;
1101+ else
1102+ _M_narrow[__i] = static_cast<char>(__c);
1103+ }
1104+ if (__i == 128)
1105+ _M_narrow_ok = true;
1106+ else
1107+ _M_narrow_ok = false;
1108+ for (size_t __j = 0;
1109+ __j < sizeof(_M_widen) / sizeof(wint_t); ++__j)
1110+ _M_widen[__j] = btowc(__j);
1111+
1112+ for (size_t __k = 0; __k <= 11; ++__k)
1113+ {
1114+ _M_bit[__k] = static_cast<mask>(_ISbit(__k));
1115+ _M_wmask[__k] = _M_convert_to_wmask(_M_bit[__k]);
1116+ }
1117+#ifdef __UCLIBC_HAS_XLOCALE__
1118+ __uselocale(__old);
1119+#endif
1120+ }
1121+#endif // _GLIBCXX_USE_WCHAR_T
1122+}
1123Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/messages_members.cc
1124===================================================================
1125--- /dev/null 1970-01-01 00:00:00.000000000 +0000
1126+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/messages_members.cc 2010-06-25 10:42:34.913881064 -0700
1127@@ -0,0 +1,100 @@
1128+// std::messages implementation details, GNU version -*- C++ -*-
1129+
1130+// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
1131+//
1132+// This file is part of the GNU ISO C++ Library. This library is free
1133+// software; you can redistribute it and/or modify it under the
1134+// terms of the GNU General Public License as published by the
1135+// Free Software Foundation; either version 2, or (at your option)
1136+// any later version.
1137+
1138+// This library is distributed in the hope that it will be useful,
1139+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1140+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1141+// GNU General Public License for more details.
1142+
1143+// You should have received a copy of the GNU General Public License along
1144+// with this library; see the file COPYING. If not, write to the Free
1145+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1146+// USA.
1147+
1148+// As a special exception, you may use this file as part of a free software
1149+// library without restriction. Specifically, if other files instantiate
1150+// templates or use macros or inline functions from this file, or you compile
1151+// this file and link it with other files to produce an executable, this
1152+// file does not by itself cause the resulting executable to be covered by
1153+// the GNU General Public License. This exception does not however
1154+// invalidate any other reasons why the executable file might be covered by
1155+// the GNU General Public License.
1156+
1157+//
1158+// ISO C++ 14882: 22.2.7.1.2 messages virtual functions
1159+//
1160+
1161+// Written by Benjamin Kosnik <bkoz@redhat.com>
1162+
1163+#include <locale>
1164+#include <bits/c++locale_internal.h>
1165+
1166+#ifdef __UCLIBC_MJN3_ONLY__
1167+#warning fix gettext stuff
1168+#endif
1169+#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
1170+extern "C" char *__dcgettext(const char *domainname,
1171+ const char *msgid, int category);
1172+#undef gettext
1173+#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
1174+#else
1175+#undef gettext
1176+#define gettext(msgid) (msgid)
1177+#endif
1178+
1179+namespace std
1180+{
1181+ // Specializations.
1182+ template<>
1183+ string
1184+ messages<char>::do_get(catalog, int, int, const string& __dfault) const
1185+ {
1186+#ifdef __UCLIBC_HAS_XLOCALE__
1187+ __c_locale __old = __uselocale(_M_c_locale_messages);
1188+ const char* __msg = const_cast<const char*>(gettext(__dfault.c_str()));
1189+ __uselocale(__old);
1190+ return string(__msg);
1191+#elif defined __UCLIBC_HAS_LOCALE__
1192+ char* __old = strdup(setlocale(LC_ALL, NULL));
1193+ setlocale(LC_ALL, _M_name_messages);
1194+ const char* __msg = gettext(__dfault.c_str());
1195+ setlocale(LC_ALL, __old);
1196+ free(__old);
1197+ return string(__msg);
1198+#else
1199+ const char* __msg = gettext(__dfault.c_str());
1200+ return string(__msg);
1201+#endif
1202+ }
1203+
1204+#ifdef _GLIBCXX_USE_WCHAR_T
1205+ template<>
1206+ wstring
1207+ messages<wchar_t>::do_get(catalog, int, int, const wstring& __dfault) const
1208+ {
1209+# ifdef __UCLIBC_HAS_XLOCALE__
1210+ __c_locale __old = __uselocale(_M_c_locale_messages);
1211+ char* __msg = gettext(_M_convert_to_char(__dfault));
1212+ __uselocale(__old);
1213+ return _M_convert_from_char(__msg);
1214+# elif defined __UCLIBC_HAS_LOCALE__
1215+ char* __old = strdup(setlocale(LC_ALL, NULL));
1216+ setlocale(LC_ALL, _M_name_messages);
1217+ char* __msg = gettext(_M_convert_to_char(__dfault));
1218+ setlocale(LC_ALL, __old);
1219+ free(__old);
1220+ return _M_convert_from_char(__msg);
1221+# else
1222+ char* __msg = gettext(_M_convert_to_char(__dfault));
1223+ return _M_convert_from_char(__msg);
1224+# endif
1225+ }
1226+#endif
1227+}
1228Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/messages_members.h
1229===================================================================
1230--- /dev/null 1970-01-01 00:00:00.000000000 +0000
1231+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/messages_members.h 2010-06-25 10:42:34.913881064 -0700
1232@@ -0,0 +1,118 @@
1233+// std::messages implementation details, GNU version -*- C++ -*-
1234+
1235+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
1236+//
1237+// This file is part of the GNU ISO C++ Library. This library is free
1238+// software; you can redistribute it and/or modify it under the
1239+// terms of the GNU General Public License as published by the
1240+// Free Software Foundation; either version 2, or (at your option)
1241+// any later version.
1242+
1243+// This library is distributed in the hope that it will be useful,
1244+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1245+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1246+// GNU General Public License for more details.
1247+
1248+// You should have received a copy of the GNU General Public License along
1249+// with this library; see the file COPYING. If not, write to the Free
1250+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1251+// USA.
1252+
1253+// As a special exception, you may use this file as part of a free software
1254+// library without restriction. Specifically, if other files instantiate
1255+// templates or use macros or inline functions from this file, or you compile
1256+// this file and link it with other files to produce an executable, this
1257+// file does not by itself cause the resulting executable to be covered by
1258+// the GNU General Public License. This exception does not however
1259+// invalidate any other reasons why the executable file might be covered by
1260+// the GNU General Public License.
1261+
1262+//
1263+// ISO C++ 14882: 22.2.7.1.2 messages functions
1264+//
1265+
1266+// Written by Benjamin Kosnik <bkoz@redhat.com>
1267+
1268+#ifdef __UCLIBC_MJN3_ONLY__
1269+#warning fix prototypes for *textdomain funcs
1270+#endif
1271+#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
1272+extern "C" char *__textdomain(const char *domainname);
1273+extern "C" char *__bindtextdomain(const char *domainname,
1274+ const char *dirname);
1275+#else
1276+#undef __textdomain
1277+#undef __bindtextdomain
1278+#define __textdomain(D) ((void)0)
1279+#define __bindtextdomain(D,P) ((void)0)
1280+#endif
1281+
1282+ // Non-virtual member functions.
1283+ template<typename _CharT>
1284+ messages<_CharT>::messages(size_t __refs)
1285+ : facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
1286+ _M_name_messages(_S_get_c_name())
1287+ { }
1288+
1289+ template<typename _CharT>
1290+ messages<_CharT>::messages(__c_locale __cloc, const char* __s,
1291+ size_t __refs)
1292+ : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
1293+ _M_name_messages(__s)
1294+ {
1295+ char* __tmp = new char[std::strlen(__s) + 1];
1296+ std::strcpy(__tmp, __s);
1297+ _M_name_messages = __tmp;
1298+ }
1299+
1300+ template<typename _CharT>
1301+ typename messages<_CharT>::catalog
1302+ messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
1303+ const char* __dir) const
1304+ {
1305+ __bindtextdomain(__s.c_str(), __dir);
1306+ return this->do_open(__s, __loc);
1307+ }
1308+
1309+ // Virtual member functions.
1310+ template<typename _CharT>
1311+ messages<_CharT>::~messages()
1312+ {
1313+ if (_M_name_messages != _S_get_c_name())
1314+ delete [] _M_name_messages;
1315+ _S_destroy_c_locale(_M_c_locale_messages);
1316+ }
1317+
1318+ template<typename _CharT>
1319+ typename messages<_CharT>::catalog
1320+ messages<_CharT>::do_open(const basic_string<char>& __s,
1321+ const locale&) const
1322+ {
1323+ // No error checking is done, assume the catalog exists and can
1324+ // be used.
1325+ __textdomain(__s.c_str());
1326+ return 0;
1327+ }
1328+
1329+ template<typename _CharT>
1330+ void
1331+ messages<_CharT>::do_close(catalog) const
1332+ { }
1333+
1334+ // messages_byname
1335+ template<typename _CharT>
1336+ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
1337+ : messages<_CharT>(__refs)
1338+ {
1339+ if (this->_M_name_messages != locale::facet::_S_get_c_name())
1340+ delete [] this->_M_name_messages;
1341+ char* __tmp = new char[std::strlen(__s) + 1];
1342+ std::strcpy(__tmp, __s);
1343+ this->_M_name_messages = __tmp;
1344+
1345+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
1346+ {
1347+ this->_S_destroy_c_locale(this->_M_c_locale_messages);
1348+ this->_S_create_c_locale(this->_M_c_locale_messages, __s);
1349+ }
1350+ }
1351Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/monetary_members.cc
1352===================================================================
1353--- /dev/null 1970-01-01 00:00:00.000000000 +0000
1354+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2010-06-25 10:42:34.913881064 -0700
1355@@ -0,0 +1,692 @@
1356+// std::moneypunct implementation details, GNU version -*- C++ -*-
1357+
1358+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
1359+//
1360+// This file is part of the GNU ISO C++ Library. This library is free
1361+// software; you can redistribute it and/or modify it under the
1362+// terms of the GNU General Public License as published by the
1363+// Free Software Foundation; either version 2, or (at your option)
1364+// any later version.
1365+
1366+// This library is distributed in the hope that it will be useful,
1367+// but WITHOUT ANY WARRANTY; without even the implied warranty of
1368+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1369+// GNU General Public License for more details.
1370+
1371+// You should have received a copy of the GNU General Public License along
1372+// with this library; see the file COPYING. If not, write to the Free
1373+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
1374+// USA.
1375+
1376+// As a special exception, you may use this file as part of a free software
1377+// library without restriction. Specifically, if other files instantiate
1378+// templates or use macros or inline functions from this file, or you compile
1379+// this file and link it with other files to produce an executable, this
1380+// file does not by itself cause the resulting executable to be covered by
1381+// the GNU General Public License. This exception does not however
1382+// invalidate any other reasons why the executable file might be covered by
1383+// the GNU General Public License.
1384+
1385+//
1386+// ISO C++ 14882: 22.2.6.3.2 moneypunct virtual functions
1387+//
1388+
1389+// Written by Benjamin Kosnik <bkoz@redhat.com>
1390+
1391+#define _LIBC
1392+#include <locale>
1393+#undef _LIBC
1394+#include <bits/c++locale_internal.h>
1395+
1396+#ifdef __UCLIBC_MJN3_ONLY__
1397+#warning optimize this for uclibc
1398+#warning tailor for stub locale support
1399+#endif
1400+
1401+#ifndef __UCLIBC_HAS_XLOCALE__
1402+#define __nl_langinfo_l(N, L) nl_langinfo((N))
1403+#endif
1404+
1405+namespace std
1406+{
1407+ // Construct and return valid pattern consisting of some combination of:
1408+ // space none symbol sign value
1409+ money_base::pattern
1410+ money_base::_S_construct_pattern(char __precedes, char __space, char __posn)
1411+ {
1412+ pattern __ret;
1413+
1414+ // This insanely complicated routine attempts to construct a valid
1415+ // pattern for use with monyepunct. A couple of invariants:
1416+
1417+ // if (__precedes) symbol -> value
1418+ // else value -> symbol
1419+
1420+ // if (__space) space
1421+ // else none
1422+
1423+ // none == never first
1424+ // space never first or last
1425+
1426+ // Any elegant implementations of this are welcome.
1427+ switch (__posn)
1428+ {
1429+ case 0:
1430+ case 1:
1431+ // 1 The sign precedes the value and symbol.
1432+ __ret.field[0] = sign;
1433+ if (__space)
1434+ {
1435+ // Pattern starts with sign.
1436+ if (__precedes)
1437+ {
1438+ __ret.field[1] = symbol;
1439+ __ret.field[3] = value;
1440+ }
1441+ else
1442+ {
1443+ __ret.field[1] = value;
1444+ __ret.field[3] = symbol;
1445+ }
1446+ __ret.field[2] = space;
1447+ }
1448+ else
1449+ {
1450+ // Pattern starts with sign and ends with none.
1451+ if (__precedes)
1452+ {
1453+ __ret.field[1] = symbol;
1454+ __ret.field[2] = value;
1455+ }
1456+ else
1457+ {
1458+ __ret.field[1] = value;
1459+ __ret.field[2] = symbol;
1460+ }
1461+ __ret.field[3] = none;
1462+ }
1463+ break;
1464+ case 2:
1465+ // 2 The sign follows the value and symbol.
1466+ if (__space)
1467+ {
1468+ // Pattern either ends with sign.
1469+ if (__precedes)
1470+ {
1471+ __ret.field[0] = symbol;
1472+ __ret.field[2] = value;
1473+ }
1474+ else
1475+ {
1476+ __ret.field[0] = value;
1477+ __ret.field[2] = symbol;
1478+ }
1479+ __ret.field[1] = space;
1480+ __ret.field[3] = sign;
1481+ }
1482+ else
1483+ {
1484+ // Pattern ends with sign then none.
1485+ if (__precedes)
1486+ {
1487+ __ret.field[0] = symbol;
1488+ __ret.field[1] = value;
1489+ }
1490+ else
1491+ {
1492+ __ret.field[0] = value;
1493+ __ret.field[1] = symbol;
1494+ }
1495+ __ret.field[2] = sign;
1496+ __ret.field[3] = none;
1497+ }
1498+ break;
1499+ case 3:
1500+ // 3 The sign immediately precedes the symbol.
1501+ if (__precedes)
1502+ {
1503+ __ret.field[0] = sign;
1504+ __ret.field[1] = symbol;
1505+ if (__space)
1506+ {
1507+ __ret.field[2] = space;
1508+ __ret.field[3] = value;
1509+ }
1510+ else
1511+ {
1512+ __ret.field[2] = value;
1513+ __ret.field[3] = none;
1514+ }
1515+ }
1516+ else
1517+ {
1518+ __ret.field[0] = value;
1519+ if (__space)
1520+ {
1521+ __ret.field[1] = space;
1522+ __ret.field[2] = sign;
1523+ __ret.field[3] = symbol;
1524+ }
1525+ else
1526+ {
1527+ __ret.field[1] = sign;
1528+ __ret.field[2] = symbol;
1529+ __ret.field[3] = none;
1530+ }
1531+ }
1532+ break;
1533+ case 4:
1534+ // 4 The sign immediately follows the symbol.
1535+ if (__precedes)
1536+ {
1537+ __ret.field[0] = symbol;
1538+ __ret.field[1] = sign;
1539+ if (__space)
1540+ {
1541+ __ret.field[2] = space;
1542+ __ret.field[3] = value;
1543+ }
1544+ else
1545+ {
1546+ __ret.field[2] = value;
1547+ __ret.field[3] = none;
1548+ }
1549+ }
1550+ else
1551+ {
1552+ __ret.field[0] = value;
1553+ if (__space)
1554+ {
1555+ __ret.field[1] = space;
1556+ __ret.field[2] = symbol;
1557+ __ret.field[3] = sign;
1558+ }
1559+ else
1560+ {
1561+ __ret.field[1] = symbol;
1562+ __ret.field[2] = sign;
1563+ __ret.field[3] = none;
1564+ }
1565+ }
1566+ break;
1567+ default:
1568+ ;
1569+ }
1570+ return __ret;
1571+ }
1572+
1573+ template<>
1574+ void
1575+ moneypunct<char, true>::_M_initialize_moneypunct(__c_locale __cloc,
1576+ const char*)
1577+ {
1578+ if (!_M_data)
1579+ _M_data = new __moneypunct_cache<char, true>;
1580+
1581+ if (!__cloc)
1582+ {
1583+ // "C" locale
1584+ _M_data->_M_decimal_point = '.';
1585+ _M_data->_M_thousands_sep = ',';
1586+ _M_data->_M_grouping = "";
1587+ _M_data->_M_grouping_size = 0;
1588+ _M_data->_M_curr_symbol = "";
1589+ _M_data->_M_curr_symbol_size = 0;
1590+ _M_data->_M_positive_sign = "";
1591+ _M_data->_M_positive_sign_size = 0;
1592+ _M_data->_M_negative_sign = "";
1593+ _M_data->_M_negative_sign_size = 0;
1594+ _M_data->_M_frac_digits = 0;
1595+ _M_data->_M_pos_format = money_base::_S_default_pattern;
1596+ _M_data->_M_neg_format = money_base::_S_default_pattern;
1597+
1598+ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
1599+ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
1600+ }
1601+ else
1602+ {
1603+ // Named locale.
1604+ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
1605+ __cloc));
1606+ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
1607+ __cloc));
1608+ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
1609+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
1610+ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
1611+ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
1612+
1613+ char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
1614+ if (!__nposn)
1615+ _M_data->_M_negative_sign = "()";
1616+ else
1617+ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
1618+ __cloc);
1619+ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
1620+
1621+ // _Intl == true
1622+ _M_data->_M_curr_symbol = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
1623+ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
1624+ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
1625+ __cloc));
1626+ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
1627+ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
1628+ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
1629+ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
1630+ __pposn);
1631+ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
1632+ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
1633+ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
1634+ __nposn);
1635+ }
1636+ }
1637+
1638+ template<>
1639+ void
1640+ moneypunct<char, false>::_M_initialize_moneypunct(__c_locale __cloc,
1641+ const char*)
1642+ {
1643+ if (!_M_data)
1644+ _M_data = new __moneypunct_cache<char, false>;
1645+
1646+ if (!__cloc)
1647+ {
1648+ // "C" locale
1649+ _M_data->_M_decimal_point = '.';
1650+ _M_data->_M_thousands_sep = ',';
1651+ _M_data->_M_grouping = "";
1652+ _M_data->_M_grouping_size = 0;
1653+ _M_data->_M_curr_symbol = "";
1654+ _M_data->_M_curr_symbol_size = 0;
1655+ _M_data->_M_positive_sign = "";
1656+ _M_data->_M_positive_sign_size = 0;
1657+ _M_data->_M_negative_sign = "";
1658+ _M_data->_M_negative_sign_size = 0;
1659+ _M_data->_M_frac_digits = 0;
1660+ _M_data->_M_pos_format = money_base::_S_default_pattern;
1661+ _M_data->_M_neg_format = money_base::_S_default_pattern;
1662+
1663+ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
1664+ _M_data->_M_atoms[__i] = money_base::_S_atoms[__i];
1665+ }
1666+ else
1667+ {
1668+ // Named locale.
1669+ _M_data->_M_decimal_point = *(__nl_langinfo_l(__MON_DECIMAL_POINT,
1670+ __cloc));
1671+ _M_data->_M_thousands_sep = *(__nl_langinfo_l(__MON_THOUSANDS_SEP,
1672+ __cloc));
1673+ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
1674+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
1675+ _M_data->_M_positive_sign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
1676+ _M_data->_M_positive_sign_size = strlen(_M_data->_M_positive_sign);
1677+
1678+ char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
1679+ if (!__nposn)
1680+ _M_data->_M_negative_sign = "()";
1681+ else
1682+ _M_data->_M_negative_sign = __nl_langinfo_l(__NEGATIVE_SIGN,
1683+ __cloc);
1684+ _M_data->_M_negative_sign_size = strlen(_M_data->_M_negative_sign);
1685+
1686+ // _Intl == false
1687+ _M_data->_M_curr_symbol = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
1688+ _M_data->_M_curr_symbol_size = strlen(_M_data->_M_curr_symbol);
1689+ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
1690+ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
1691+ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
1692+ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
1693+ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
1694+ __pposn);
1695+ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
1696+ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
1697+ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
1698+ __nposn);
1699+ }
1700+ }
1701+
1702+ template<>
1703+ moneypunct<char, true>::~moneypunct()
1704+ { delete _M_data; }
1705+
1706+ template<>
1707+ moneypunct<char, false>::~moneypunct()
1708+ { delete _M_data; }
1709+
1710+#ifdef _GLIBCXX_USE_WCHAR_T
1711+ template<>
1712+ void
1713+ moneypunct<wchar_t, true>::_M_initialize_moneypunct(__c_locale __cloc,
1714+#ifdef __UCLIBC_HAS_XLOCALE__
1715+ const char*)
1716+#else
1717+ const char* __name)
1718+#endif
1719+ {
1720+ if (!_M_data)
1721+ _M_data = new __moneypunct_cache<wchar_t, true>;
1722+
1723+ if (!__cloc)
1724+ {
1725+ // "C" locale
1726+ _M_data->_M_decimal_point = L'.';
1727+ _M_data->_M_thousands_sep = L',';
1728+ _M_data->_M_grouping = "";
1729+ _M_data->_M_grouping_size = 0;
1730+ _M_data->_M_curr_symbol = L"";
1731+ _M_data->_M_curr_symbol_size = 0;
1732+ _M_data->_M_positive_sign = L"";
1733+ _M_data->_M_positive_sign_size = 0;
1734+ _M_data->_M_negative_sign = L"";
1735+ _M_data->_M_negative_sign_size = 0;
1736+ _M_data->_M_frac_digits = 0;
1737+ _M_data->_M_pos_format = money_base::_S_default_pattern;
1738+ _M_data->_M_neg_format = money_base::_S_default_pattern;
1739+
1740+ // Use ctype::widen code without the facet...
1741+ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
1742+ _M_data->_M_atoms[__i] =
1743+ static_cast<wchar_t>(money_base::_S_atoms[__i]);
1744+ }
1745+ else
1746+ {
1747+ // Named locale.
1748+#ifdef __UCLIBC_HAS_XLOCALE__
1749+ __c_locale __old = __uselocale(__cloc);
1750+#else
1751+ // Switch to named locale so that mbsrtowcs will work.
1752+ char* __old = strdup(setlocale(LC_ALL, NULL));
1753+ setlocale(LC_ALL, __name);
1754+#endif
1755+
1756+#ifdef __UCLIBC_MJN3_ONLY__
1757+#warning fix this... should be monetary
1758+#endif
1759+#ifdef __UCLIBC__
1760+# ifdef __UCLIBC_HAS_XLOCALE__
1761+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
1762+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
1763+# else
1764+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
1765+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
1766+# endif
1767+#else
1768+ union { char *__s; wchar_t __w; } __u;
1769+ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
1770+ _M_data->_M_decimal_point = __u.__w;
1771+
1772+ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
1773+ _M_data->_M_thousands_sep = __u.__w;
1774+#endif
1775+ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
1776+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
1777+
1778+ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
1779+ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
1780+ const char* __ccurr = __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc);
1781+
1782+ wchar_t* __wcs_ps = 0;
1783+ wchar_t* __wcs_ns = 0;
1784+ const char __nposn = *(__nl_langinfo_l(__INT_N_SIGN_POSN, __cloc));
1785+ try
1786+ {
1787+ mbstate_t __state;
1788+ size_t __len = strlen(__cpossign);
1789+ if (__len)
1790+ {
1791+ ++__len;
1792+ memset(&__state, 0, sizeof(mbstate_t));
1793+ __wcs_ps = new wchar_t[__len];
1794+ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
1795+ _M_data->_M_positive_sign = __wcs_ps;
1796+ }
1797+ else
1798+ _M_data->_M_positive_sign = L"";
1799+ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
1800+
1801+ __len = strlen(__cnegsign);
1802+ if (!__nposn)
1803+ _M_data->_M_negative_sign = L"()";
1804+ else if (__len)
1805+ {
1806+ ++__len;
1807+ memset(&__state, 0, sizeof(mbstate_t));
1808+ __wcs_ns = new wchar_t[__len];
1809+ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
1810+ _M_data->_M_negative_sign = __wcs_ns;
1811+ }
1812+ else
1813+ _M_data->_M_negative_sign = L"";
1814+ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
1815+
1816+ // _Intl == true.
1817+ __len = strlen(__ccurr);
1818+ if (__len)
1819+ {
1820+ ++__len;
1821+ memset(&__state, 0, sizeof(mbstate_t));
1822+ wchar_t* __wcs = new wchar_t[__len];
1823+ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
1824+ _M_data->_M_curr_symbol = __wcs;
1825+ }
1826+ else
1827+ _M_data->_M_curr_symbol = L"";
1828+ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
1829+ }
1830+ catch (...)
1831+ {
1832+ delete _M_data;
1833+ _M_data = 0;
1834+ delete __wcs_ps;
1835+ delete __wcs_ns;
1836+#ifdef __UCLIBC_HAS_XLOCALE__
1837+ __uselocale(__old);
1838+#else
1839+ setlocale(LC_ALL, __old);
1840+ free(__old);
1841+#endif
1842+ __throw_exception_again;
1843+ }
1844+
1845+ _M_data->_M_frac_digits = *(__nl_langinfo_l(__INT_FRAC_DIGITS,
1846+ __cloc));
1847+ char __pprecedes = *(__nl_langinfo_l(__INT_P_CS_PRECEDES, __cloc));
1848+ char __pspace = *(__nl_langinfo_l(__INT_P_SEP_BY_SPACE, __cloc));
1849+ char __pposn = *(__nl_langinfo_l(__INT_P_SIGN_POSN, __cloc));
1850+ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
1851+ __pposn);
1852+ char __nprecedes = *(__nl_langinfo_l(__INT_N_CS_PRECEDES, __cloc));
1853+ char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
1854+ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
1855+ __nposn);
1856+
1857+#ifdef __UCLIBC_HAS_XLOCALE__
1858+ __uselocale(__old);
1859+#else
1860+ setlocale(LC_ALL, __old);
1861+ free(__old);
1862+#endif
1863+ }
1864+ }
1865+
1866+ template<>
1867+ void
1868+ moneypunct<wchar_t, false>::_M_initialize_moneypunct(__c_locale __cloc,
1869+#ifdef __UCLIBC_HAS_XLOCALE__
1870+ const char*)
1871+#else
1872+ const char* __name)
1873+#endif
1874+ {
1875+ if (!_M_data)
1876+ _M_data = new __moneypunct_cache<wchar_t, false>;
1877+
1878+ if (!__cloc)
1879+ {
1880+ // "C" locale
1881+ _M_data->_M_decimal_point = L'.';
1882+ _M_data->_M_thousands_sep = L',';
1883+ _M_data->_M_grouping = "";
1884+ _M_data->_M_grouping_size = 0;
1885+ _M_data->_M_curr_symbol = L"";
1886+ _M_data->_M_curr_symbol_size = 0;
1887+ _M_data->_M_positive_sign = L"";
1888+ _M_data->_M_positive_sign_size = 0;
1889+ _M_data->_M_negative_sign = L"";
1890+ _M_data->_M_negative_sign_size = 0;
1891+ _M_data->_M_frac_digits = 0;
1892+ _M_data->_M_pos_format = money_base::_S_default_pattern;
1893+ _M_data->_M_neg_format = money_base::_S_default_pattern;
1894+
1895+ // Use ctype::widen code without the facet...
1896+ for (size_t __i = 0; __i < money_base::_S_end; ++__i)
1897+ _M_data->_M_atoms[__i] =
1898+ static_cast<wchar_t>(money_base::_S_atoms[__i]);
1899+ }
1900+ else
1901+ {
1902+ // Named locale.
1903+#ifdef __UCLIBC_HAS_XLOCALE__
1904+ __c_locale __old = __uselocale(__cloc);
1905+#else
1906+ // Switch to named locale so that mbsrtowcs will work.
1907+ char* __old = strdup(setlocale(LC_ALL, NULL));
1908+ setlocale(LC_ALL, __name);
1909+#endif
1910+
1911+#ifdef __UCLIBC_MJN3_ONLY__
1912+#warning fix this... should be monetary
1913+#endif
1914+#ifdef __UCLIBC__
1915+# ifdef __UCLIBC_HAS_XLOCALE__
1916+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
1917+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
1918+# else
1919+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
1920+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
1921+# endif
1922+#else
1923+ union { char *__s; wchar_t __w; } __u;
1924+ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
1925+ _M_data->_M_decimal_point = __u.__w;
1926+
1927+ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
1928+ _M_data->_M_thousands_sep = __u.__w;
1929+#endif
1930+ _M_data->_M_grouping = __nl_langinfo_l(__MON_GROUPING, __cloc);
1931+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
1932+
1933+ const char* __cpossign = __nl_langinfo_l(__POSITIVE_SIGN, __cloc);
1934+ const char* __cnegsign = __nl_langinfo_l(__NEGATIVE_SIGN, __cloc);
1935+ const char* __ccurr = __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc);
1936+
1937+ wchar_t* __wcs_ps = 0;
1938+ wchar_t* __wcs_ns = 0;
1939+ const char __nposn = *(__nl_langinfo_l(__N_SIGN_POSN, __cloc));
1940+ try
1941+ {
1942+ mbstate_t __state;
1943+ size_t __len;
1944+ __len = strlen(__cpossign);
1945+ if (__len)
1946+ {
1947+ ++__len;
1948+ memset(&__state, 0, sizeof(mbstate_t));
1949+ __wcs_ps = new wchar_t[__len];
1950+ mbsrtowcs(__wcs_ps, &__cpossign, __len, &__state);
1951+ _M_data->_M_positive_sign = __wcs_ps;
1952+ }
1953+ else
1954+ _M_data->_M_positive_sign = L"";
1955+ _M_data->_M_positive_sign_size = wcslen(_M_data->_M_positive_sign);
1956+
1957+ __len = strlen(__cnegsign);
1958+ if (!__nposn)
1959+ _M_data->_M_negative_sign = L"()";
1960+ else if (__len)
1961+ {
1962+ ++__len;
1963+ memset(&__state, 0, sizeof(mbstate_t));
1964+ __wcs_ns = new wchar_t[__len];
1965+ mbsrtowcs(__wcs_ns, &__cnegsign, __len, &__state);
1966+ _M_data->_M_negative_sign = __wcs_ns;
1967+ }
1968+ else
1969+ _M_data->_M_negative_sign = L"";
1970+ _M_data->_M_negative_sign_size = wcslen(_M_data->_M_negative_sign);
1971+
1972+ // _Intl == true.
1973+ __len = strlen(__ccurr);
1974+ if (__len)
1975+ {
1976+ ++__len;
1977+ memset(&__state, 0, sizeof(mbstate_t));
1978+ wchar_t* __wcs = new wchar_t[__len];
1979+ mbsrtowcs(__wcs, &__ccurr, __len, &__state);
1980+ _M_data->_M_curr_symbol = __wcs;
1981+ }
1982+ else
1983+ _M_data->_M_curr_symbol = L"";
1984+ _M_data->_M_curr_symbol_size = wcslen(_M_data->_M_curr_symbol);
1985+ }
1986+ catch (...)
1987+ {
1988+ delete _M_data;
1989+ _M_data = 0;
1990+ delete __wcs_ps;
1991+ delete __wcs_ns;
1992+#ifdef __UCLIBC_HAS_XLOCALE__
1993+ __uselocale(__old);
1994+#else
1995+ setlocale(LC_ALL, __old);
1996+ free(__old);
1997+#endif
1998+ __throw_exception_again;
1999+ }
2000+
2001+ _M_data->_M_frac_digits = *(__nl_langinfo_l(__FRAC_DIGITS, __cloc));
2002+ char __pprecedes = *(__nl_langinfo_l(__P_CS_PRECEDES, __cloc));
2003+ char __pspace = *(__nl_langinfo_l(__P_SEP_BY_SPACE, __cloc));
2004+ char __pposn = *(__nl_langinfo_l(__P_SIGN_POSN, __cloc));
2005+ _M_data->_M_pos_format = _S_construct_pattern(__pprecedes, __pspace,
2006+ __pposn);
2007+ char __nprecedes = *(__nl_langinfo_l(__N_CS_PRECEDES, __cloc));
2008+ char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
2009+ _M_data->_M_neg_format = _S_construct_pattern(__nprecedes, __nspace,
2010+ __nposn);
2011+
2012+#ifdef __UCLIBC_HAS_XLOCALE__
2013+ __uselocale(__old);
2014+#else
2015+ setlocale(LC_ALL, __old);
2016+ free(__old);
2017+#endif
2018+ }
2019+ }
2020+
2021+ template<>
2022+ moneypunct<wchar_t, true>::~moneypunct()
2023+ {
2024+ if (_M_data->_M_positive_sign_size)
2025+ delete [] _M_data->_M_positive_sign;
2026+ if (_M_data->_M_negative_sign_size
2027+ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
2028+ delete [] _M_data->_M_negative_sign;
2029+ if (_M_data->_M_curr_symbol_size)
2030+ delete [] _M_data->_M_curr_symbol;
2031+ delete _M_data;
2032+ }
2033+
2034+ template<>
2035+ moneypunct<wchar_t, false>::~moneypunct()
2036+ {
2037+ if (_M_data->_M_positive_sign_size)
2038+ delete [] _M_data->_M_positive_sign;
2039+ if (_M_data->_M_negative_sign_size
2040+ && wcscmp(_M_data->_M_negative_sign, L"()") != 0)
2041+ delete [] _M_data->_M_negative_sign;
2042+ if (_M_data->_M_curr_symbol_size)
2043+ delete [] _M_data->_M_curr_symbol;
2044+ delete _M_data;
2045+ }
2046+#endif
2047+}
2048Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/numeric_members.cc
2049===================================================================
2050--- /dev/null 1970-01-01 00:00:00.000000000 +0000
2051+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2010-06-25 10:42:34.913881064 -0700
2052@@ -0,0 +1,160 @@
2053+// std::numpunct implementation details, GNU version -*- C++ -*-
2054+
2055+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2056+//
2057+// This file is part of the GNU ISO C++ Library. This library is free
2058+// software; you can redistribute it and/or modify it under the
2059+// terms of the GNU General Public License as published by the
2060+// Free Software Foundation; either version 2, or (at your option)
2061+// any later version.
2062+
2063+// This library is distributed in the hope that it will be useful,
2064+// but WITHOUT ANY WARRANTY; without even the implied warranty of
2065+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2066+// GNU General Public License for more details.
2067+
2068+// You should have received a copy of the GNU General Public License along
2069+// with this library; see the file COPYING. If not, write to the Free
2070+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2071+// USA.
2072+
2073+// As a special exception, you may use this file as part of a free software
2074+// library without restriction. Specifically, if other files instantiate
2075+// templates or use macros or inline functions from this file, or you compile
2076+// this file and link it with other files to produce an executable, this
2077+// file does not by itself cause the resulting executable to be covered by
2078+// the GNU General Public License. This exception does not however
2079+// invalidate any other reasons why the executable file might be covered by
2080+// the GNU General Public License.
2081+
2082+//
2083+// ISO C++ 14882: 22.2.3.1.2 numpunct virtual functions
2084+//
2085+
2086+// Written by Benjamin Kosnik <bkoz@redhat.com>
2087+
2088+#define _LIBC
2089+#include <locale>
2090+#undef _LIBC
2091+#include <bits/c++locale_internal.h>
2092+
2093+#ifdef __UCLIBC_MJN3_ONLY__
2094+#warning tailor for stub locale support
2095+#endif
2096+#ifndef __UCLIBC_HAS_XLOCALE__
2097+#define __nl_langinfo_l(N, L) nl_langinfo((N))
2098+#endif
2099+
2100+namespace std
2101+{
2102+ template<>
2103+ void
2104+ numpunct<char>::_M_initialize_numpunct(__c_locale __cloc)
2105+ {
2106+ if (!_M_data)
2107+ _M_data = new __numpunct_cache<char>;
2108+
2109+ if (!__cloc)
2110+ {
2111+ // "C" locale
2112+ _M_data->_M_grouping = "";
2113+ _M_data->_M_grouping_size = 0;
2114+ _M_data->_M_use_grouping = false;
2115+
2116+ _M_data->_M_decimal_point = '.';
2117+ _M_data->_M_thousands_sep = ',';
2118+
2119+ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
2120+ _M_data->_M_atoms_out[__i] = __num_base::_S_atoms_out[__i];
2121+
2122+ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
2123+ _M_data->_M_atoms_in[__j] = __num_base::_S_atoms_in[__j];
2124+ }
2125+ else
2126+ {
2127+ // Named locale.
2128+ _M_data->_M_decimal_point = *(__nl_langinfo_l(DECIMAL_POINT,
2129+ __cloc));
2130+ _M_data->_M_thousands_sep = *(__nl_langinfo_l(THOUSANDS_SEP,
2131+ __cloc));
2132+
2133+ // Check for NULL, which implies no grouping.
2134+ if (_M_data->_M_thousands_sep == '\0')
2135+ _M_data->_M_grouping = "";
2136+ else
2137+ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
2138+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
2139+ }
2140+
2141+ // NB: There is no way to extact this info from posix locales.
2142+ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
2143+ _M_data->_M_truename = "true";
2144+ _M_data->_M_truename_size = 4;
2145+ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
2146+ _M_data->_M_falsename = "false";
2147+ _M_data->_M_falsename_size = 5;
2148+ }
2149+
2150+ template<>
2151+ numpunct<char>::~numpunct()
2152+ { delete _M_data; }
2153+
2154+#ifdef _GLIBCXX_USE_WCHAR_T
2155+ template<>
2156+ void
2157+ numpunct<wchar_t>::_M_initialize_numpunct(__c_locale __cloc)
2158+ {
2159+ if (!_M_data)
2160+ _M_data = new __numpunct_cache<wchar_t>;
2161+
2162+ if (!__cloc)
2163+ {
2164+ // "C" locale
2165+ _M_data->_M_grouping = "";
2166+ _M_data->_M_grouping_size = 0;
2167+ _M_data->_M_use_grouping = false;
2168+
2169+ _M_data->_M_decimal_point = L'.';
2170+ _M_data->_M_thousands_sep = L',';
2171+
2172+ // Use ctype::widen code without the facet...
2173+ for (size_t __i = 0; __i < __num_base::_S_oend; ++__i)
2174+ _M_data->_M_atoms_out[__i] =
2175+ static_cast<wchar_t>(__num_base::_S_atoms_out[__i]);
2176+
2177+ for (size_t __j = 0; __j < __num_base::_S_iend; ++__j)
2178+ _M_data->_M_atoms_in[__j] =
2179+ static_cast<wchar_t>(__num_base::_S_atoms_in[__j]);
2180+ }
2181+ else
2182+ {
2183+ // Named locale.
2184+ // NB: In the GNU model wchar_t is always 32 bit wide.
2185+ union { char *__s; wchar_t __w; } __u;
2186+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
2187+ _M_data->_M_decimal_point = __u.__w;
2188+
2189+ __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
2190+ _M_data->_M_thousands_sep = __u.__w;
2191+
2192+ if (_M_data->_M_thousands_sep == L'\0')
2193+ _M_data->_M_grouping = "";
2194+ else
2195+ _M_data->_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
2196+ _M_data->_M_grouping_size = strlen(_M_data->_M_grouping);
2197+ }
2198+
2199+ // NB: There is no way to extact this info from posix locales.
2200+ // _M_truename = __nl_langinfo_l(YESSTR, __cloc);
2201+ _M_data->_M_truename = L"true";
2202+ _M_data->_M_truename_size = 4;
2203+ // _M_falsename = __nl_langinfo_l(NOSTR, __cloc);
2204+ _M_data->_M_falsename = L"false";
2205+ _M_data->_M_falsename_size = 5;
2206+ }
2207+
2208+ template<>
2209+ numpunct<wchar_t>::~numpunct()
2210+ { delete _M_data; }
2211+ #endif
2212+}
2213Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/time_members.cc
2214===================================================================
2215--- /dev/null 1970-01-01 00:00:00.000000000 +0000
2216+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/time_members.cc 2010-06-25 10:42:34.913881064 -0700
2217@@ -0,0 +1,406 @@
2218+// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
2219+
2220+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2221+//
2222+// This file is part of the GNU ISO C++ Library. This library is free
2223+// software; you can redistribute it and/or modify it under the
2224+// terms of the GNU General Public License as published by the
2225+// Free Software Foundation; either version 2, or (at your option)
2226+// any later version.
2227+
2228+// This library is distributed in the hope that it will be useful,
2229+// but WITHOUT ANY WARRANTY; without even the implied warranty of
2230+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2231+// GNU General Public License for more details.
2232+
2233+// You should have received a copy of the GNU General Public License along
2234+// with this library; see the file COPYING. If not, write to the Free
2235+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2236+// USA.
2237+
2238+// As a special exception, you may use this file as part of a free software
2239+// library without restriction. Specifically, if other files instantiate
2240+// templates or use macros or inline functions from this file, or you compile
2241+// this file and link it with other files to produce an executable, this
2242+// file does not by itself cause the resulting executable to be covered by
2243+// the GNU General Public License. This exception does not however
2244+// invalidate any other reasons why the executable file might be covered by
2245+// the GNU General Public License.
2246+
2247+//
2248+// ISO C++ 14882: 22.2.5.1.2 - time_get virtual functions
2249+// ISO C++ 14882: 22.2.5.3.2 - time_put virtual functions
2250+//
2251+
2252+// Written by Benjamin Kosnik <bkoz@redhat.com>
2253+
2254+#include <locale>
2255+#include <bits/c++locale_internal.h>
2256+
2257+#ifdef __UCLIBC_MJN3_ONLY__
2258+#warning tailor for stub locale support
2259+#endif
2260+#ifndef __UCLIBC_HAS_XLOCALE__
2261+#define __nl_langinfo_l(N, L) nl_langinfo((N))
2262+#endif
2263+
2264+namespace std
2265+{
2266+ template<>
2267+ void
2268+ __timepunct<char>::
2269+ _M_put(char* __s, size_t __maxlen, const char* __format,
2270+ const tm* __tm) const
2271+ {
2272+#ifdef __UCLIBC_HAS_XLOCALE__
2273+ const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
2274+ _M_c_locale_timepunct);
2275+#else
2276+ char* __old = strdup(setlocale(LC_ALL, NULL));
2277+ setlocale(LC_ALL, _M_name_timepunct);
2278+ const size_t __len = strftime(__s, __maxlen, __format, __tm);
2279+ setlocale(LC_ALL, __old);
2280+ free(__old);
2281+#endif
2282+ // Make sure __s is null terminated.
2283+ if (__len == 0)
2284+ __s[0] = '\0';
2285+ }
2286+
2287+ template<>
2288+ void
2289+ __timepunct<char>::_M_initialize_timepunct(__c_locale __cloc)
2290+ {
2291+ if (!_M_data)
2292+ _M_data = new __timepunct_cache<char>;
2293+
2294+ if (!__cloc)
2295+ {
2296+ // "C" locale
2297+ _M_c_locale_timepunct = _S_get_c_locale();
2298+
2299+ _M_data->_M_date_format = "%m/%d/%y";
2300+ _M_data->_M_date_era_format = "%m/%d/%y";
2301+ _M_data->_M_time_format = "%H:%M:%S";
2302+ _M_data->_M_time_era_format = "%H:%M:%S";
2303+ _M_data->_M_date_time_format = "";
2304+ _M_data->_M_date_time_era_format = "";
2305+ _M_data->_M_am = "AM";
2306+ _M_data->_M_pm = "PM";
2307+ _M_data->_M_am_pm_format = "";
2308+
2309+ // Day names, starting with "C"'s Sunday.
2310+ _M_data->_M_day1 = "Sunday";
2311+ _M_data->_M_day2 = "Monday";
2312+ _M_data->_M_day3 = "Tuesday";
2313+ _M_data->_M_day4 = "Wednesday";
2314+ _M_data->_M_day5 = "Thursday";
2315+ _M_data->_M_day6 = "Friday";
2316+ _M_data->_M_day7 = "Saturday";
2317+
2318+ // Abbreviated day names, starting with "C"'s Sun.
2319+ _M_data->_M_aday1 = "Sun";
2320+ _M_data->_M_aday2 = "Mon";
2321+ _M_data->_M_aday3 = "Tue";
2322+ _M_data->_M_aday4 = "Wed";
2323+ _M_data->_M_aday5 = "Thu";
2324+ _M_data->_M_aday6 = "Fri";
2325+ _M_data->_M_aday7 = "Sat";
2326+
2327+ // Month names, starting with "C"'s January.
2328+ _M_data->_M_month01 = "January";
2329+ _M_data->_M_month02 = "February";
2330+ _M_data->_M_month03 = "March";
2331+ _M_data->_M_month04 = "April";
2332+ _M_data->_M_month05 = "May";
2333+ _M_data->_M_month06 = "June";
2334+ _M_data->_M_month07 = "July";
2335+ _M_data->_M_month08 = "August";
2336+ _M_data->_M_month09 = "September";
2337+ _M_data->_M_month10 = "October";
2338+ _M_data->_M_month11 = "November";
2339+ _M_data->_M_month12 = "December";
2340+
2341+ // Abbreviated month names, starting with "C"'s Jan.
2342+ _M_data->_M_amonth01 = "Jan";
2343+ _M_data->_M_amonth02 = "Feb";
2344+ _M_data->_M_amonth03 = "Mar";
2345+ _M_data->_M_amonth04 = "Apr";
2346+ _M_data->_M_amonth05 = "May";
2347+ _M_data->_M_amonth06 = "Jun";
2348+ _M_data->_M_amonth07 = "Jul";
2349+ _M_data->_M_amonth08 = "Aug";
2350+ _M_data->_M_amonth09 = "Sep";
2351+ _M_data->_M_amonth10 = "Oct";
2352+ _M_data->_M_amonth11 = "Nov";
2353+ _M_data->_M_amonth12 = "Dec";
2354+ }
2355+ else
2356+ {
2357+ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
2358+
2359+ _M_data->_M_date_format = __nl_langinfo_l(D_FMT, __cloc);
2360+ _M_data->_M_date_era_format = __nl_langinfo_l(ERA_D_FMT, __cloc);
2361+ _M_data->_M_time_format = __nl_langinfo_l(T_FMT, __cloc);
2362+ _M_data->_M_time_era_format = __nl_langinfo_l(ERA_T_FMT, __cloc);
2363+ _M_data->_M_date_time_format = __nl_langinfo_l(D_T_FMT, __cloc);
2364+ _M_data->_M_date_time_era_format = __nl_langinfo_l(ERA_D_T_FMT,
2365+ __cloc);
2366+ _M_data->_M_am = __nl_langinfo_l(AM_STR, __cloc);
2367+ _M_data->_M_pm = __nl_langinfo_l(PM_STR, __cloc);
2368+ _M_data->_M_am_pm_format = __nl_langinfo_l(T_FMT_AMPM, __cloc);
2369+
2370+ // Day names, starting with "C"'s Sunday.
2371+ _M_data->_M_day1 = __nl_langinfo_l(DAY_1, __cloc);
2372+ _M_data->_M_day2 = __nl_langinfo_l(DAY_2, __cloc);
2373+ _M_data->_M_day3 = __nl_langinfo_l(DAY_3, __cloc);
2374+ _M_data->_M_day4 = __nl_langinfo_l(DAY_4, __cloc);
2375+ _M_data->_M_day5 = __nl_langinfo_l(DAY_5, __cloc);
2376+ _M_data->_M_day6 = __nl_langinfo_l(DAY_6, __cloc);
2377+ _M_data->_M_day7 = __nl_langinfo_l(DAY_7, __cloc);
2378+
2379+ // Abbreviated day names, starting with "C"'s Sun.
2380+ _M_data->_M_aday1 = __nl_langinfo_l(ABDAY_1, __cloc);
2381+ _M_data->_M_aday2 = __nl_langinfo_l(ABDAY_2, __cloc);
2382+ _M_data->_M_aday3 = __nl_langinfo_l(ABDAY_3, __cloc);
2383+ _M_data->_M_aday4 = __nl_langinfo_l(ABDAY_4, __cloc);
2384+ _M_data->_M_aday5 = __nl_langinfo_l(ABDAY_5, __cloc);
2385+ _M_data->_M_aday6 = __nl_langinfo_l(ABDAY_6, __cloc);
2386+ _M_data->_M_aday7 = __nl_langinfo_l(ABDAY_7, __cloc);
2387+
2388+ // Month names, starting with "C"'s January.
2389+ _M_data->_M_month01 = __nl_langinfo_l(MON_1, __cloc);
2390+ _M_data->_M_month02 = __nl_langinfo_l(MON_2, __cloc);
2391+ _M_data->_M_month03 = __nl_langinfo_l(MON_3, __cloc);
2392+ _M_data->_M_month04 = __nl_langinfo_l(MON_4, __cloc);
2393+ _M_data->_M_month05 = __nl_langinfo_l(MON_5, __cloc);
2394+ _M_data->_M_month06 = __nl_langinfo_l(MON_6, __cloc);
2395+ _M_data->_M_month07 = __nl_langinfo_l(MON_7, __cloc);
2396+ _M_data->_M_month08 = __nl_langinfo_l(MON_8, __cloc);
2397+ _M_data->_M_month09 = __nl_langinfo_l(MON_9, __cloc);
2398+ _M_data->_M_month10 = __nl_langinfo_l(MON_10, __cloc);
2399+ _M_data->_M_month11 = __nl_langinfo_l(MON_11, __cloc);
2400+ _M_data->_M_month12 = __nl_langinfo_l(MON_12, __cloc);
2401+
2402+ // Abbreviated month names, starting with "C"'s Jan.
2403+ _M_data->_M_amonth01 = __nl_langinfo_l(ABMON_1, __cloc);
2404+ _M_data->_M_amonth02 = __nl_langinfo_l(ABMON_2, __cloc);
2405+ _M_data->_M_amonth03 = __nl_langinfo_l(ABMON_3, __cloc);
2406+ _M_data->_M_amonth04 = __nl_langinfo_l(ABMON_4, __cloc);
2407+ _M_data->_M_amonth05 = __nl_langinfo_l(ABMON_5, __cloc);
2408+ _M_data->_M_amonth06 = __nl_langinfo_l(ABMON_6, __cloc);
2409+ _M_data->_M_amonth07 = __nl_langinfo_l(ABMON_7, __cloc);
2410+ _M_data->_M_amonth08 = __nl_langinfo_l(ABMON_8, __cloc);
2411+ _M_data->_M_amonth09 = __nl_langinfo_l(ABMON_9, __cloc);
2412+ _M_data->_M_amonth10 = __nl_langinfo_l(ABMON_10, __cloc);
2413+ _M_data->_M_amonth11 = __nl_langinfo_l(ABMON_11, __cloc);
2414+ _M_data->_M_amonth12 = __nl_langinfo_l(ABMON_12, __cloc);
2415+ }
2416+ }
2417+
2418+#ifdef _GLIBCXX_USE_WCHAR_T
2419+ template<>
2420+ void
2421+ __timepunct<wchar_t>::
2422+ _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
2423+ const tm* __tm) const
2424+ {
2425+#ifdef __UCLIBC_HAS_XLOCALE__
2426+ __wcsftime_l(__s, __maxlen, __format, __tm, _M_c_locale_timepunct);
2427+ const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
2428+ _M_c_locale_timepunct);
2429+#else
2430+ char* __old = strdup(setlocale(LC_ALL, NULL));
2431+ setlocale(LC_ALL, _M_name_timepunct);
2432+ const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
2433+ setlocale(LC_ALL, __old);
2434+ free(__old);
2435+#endif
2436+ // Make sure __s is null terminated.
2437+ if (__len == 0)
2438+ __s[0] = L'\0';
2439+ }
2440+
2441+ template<>
2442+ void
2443+ __timepunct<wchar_t>::_M_initialize_timepunct(__c_locale __cloc)
2444+ {
2445+ if (!_M_data)
2446+ _M_data = new __timepunct_cache<wchar_t>;
2447+
2448+#warning wide time stuff
2449+// if (!__cloc)
2450+ {
2451+ // "C" locale
2452+ _M_c_locale_timepunct = _S_get_c_locale();
2453+
2454+ _M_data->_M_date_format = L"%m/%d/%y";
2455+ _M_data->_M_date_era_format = L"%m/%d/%y";
2456+ _M_data->_M_time_format = L"%H:%M:%S";
2457+ _M_data->_M_time_era_format = L"%H:%M:%S";
2458+ _M_data->_M_date_time_format = L"";
2459+ _M_data->_M_date_time_era_format = L"";
2460+ _M_data->_M_am = L"AM";
2461+ _M_data->_M_pm = L"PM";
2462+ _M_data->_M_am_pm_format = L"";
2463+
2464+ // Day names, starting with "C"'s Sunday.
2465+ _M_data->_M_day1 = L"Sunday";
2466+ _M_data->_M_day2 = L"Monday";
2467+ _M_data->_M_day3 = L"Tuesday";
2468+ _M_data->_M_day4 = L"Wednesday";
2469+ _M_data->_M_day5 = L"Thursday";
2470+ _M_data->_M_day6 = L"Friday";
2471+ _M_data->_M_day7 = L"Saturday";
2472+
2473+ // Abbreviated day names, starting with "C"'s Sun.
2474+ _M_data->_M_aday1 = L"Sun";
2475+ _M_data->_M_aday2 = L"Mon";
2476+ _M_data->_M_aday3 = L"Tue";
2477+ _M_data->_M_aday4 = L"Wed";
2478+ _M_data->_M_aday5 = L"Thu";
2479+ _M_data->_M_aday6 = L"Fri";
2480+ _M_data->_M_aday7 = L"Sat";
2481+
2482+ // Month names, starting with "C"'s January.
2483+ _M_data->_M_month01 = L"January";
2484+ _M_data->_M_month02 = L"February";
2485+ _M_data->_M_month03 = L"March";
2486+ _M_data->_M_month04 = L"April";
2487+ _M_data->_M_month05 = L"May";
2488+ _M_data->_M_month06 = L"June";
2489+ _M_data->_M_month07 = L"July";
2490+ _M_data->_M_month08 = L"August";
2491+ _M_data->_M_month09 = L"September";
2492+ _M_data->_M_month10 = L"October";
2493+ _M_data->_M_month11 = L"November";
2494+ _M_data->_M_month12 = L"December";
2495+
2496+ // Abbreviated month names, starting with "C"'s Jan.
2497+ _M_data->_M_amonth01 = L"Jan";
2498+ _M_data->_M_amonth02 = L"Feb";
2499+ _M_data->_M_amonth03 = L"Mar";
2500+ _M_data->_M_amonth04 = L"Apr";
2501+ _M_data->_M_amonth05 = L"May";
2502+ _M_data->_M_amonth06 = L"Jun";
2503+ _M_data->_M_amonth07 = L"Jul";
2504+ _M_data->_M_amonth08 = L"Aug";
2505+ _M_data->_M_amonth09 = L"Sep";
2506+ _M_data->_M_amonth10 = L"Oct";
2507+ _M_data->_M_amonth11 = L"Nov";
2508+ _M_data->_M_amonth12 = L"Dec";
2509+ }
2510+#if 0
2511+ else
2512+ {
2513+ _M_c_locale_timepunct = _S_clone_c_locale(__cloc);
2514+
2515+ union { char *__s; wchar_t *__w; } __u;
2516+
2517+ __u.__s = __nl_langinfo_l(_NL_WD_FMT, __cloc);
2518+ _M_data->_M_date_format = __u.__w;
2519+ __u.__s = __nl_langinfo_l(_NL_WERA_D_FMT, __cloc);
2520+ _M_data->_M_date_era_format = __u.__w;
2521+ __u.__s = __nl_langinfo_l(_NL_WT_FMT, __cloc);
2522+ _M_data->_M_time_format = __u.__w;
2523+ __u.__s = __nl_langinfo_l(_NL_WERA_T_FMT, __cloc);
2524+ _M_data->_M_time_era_format = __u.__w;
2525+ __u.__s = __nl_langinfo_l(_NL_WD_T_FMT, __cloc);
2526+ _M_data->_M_date_time_format = __u.__w;
2527+ __u.__s = __nl_langinfo_l(_NL_WERA_D_T_FMT, __cloc);
2528+ _M_data->_M_date_time_era_format = __u.__w;
2529+ __u.__s = __nl_langinfo_l(_NL_WAM_STR, __cloc);
2530+ _M_data->_M_am = __u.__w;
2531+ __u.__s = __nl_langinfo_l(_NL_WPM_STR, __cloc);
2532+ _M_data->_M_pm = __u.__w;
2533+ __u.__s = __nl_langinfo_l(_NL_WT_FMT_AMPM, __cloc);
2534+ _M_data->_M_am_pm_format = __u.__w;
2535+
2536+ // Day names, starting with "C"'s Sunday.
2537+ __u.__s = __nl_langinfo_l(_NL_WDAY_1, __cloc);
2538+ _M_data->_M_day1 = __u.__w;
2539+ __u.__s = __nl_langinfo_l(_NL_WDAY_2, __cloc);
2540+ _M_data->_M_day2 = __u.__w;
2541+ __u.__s = __nl_langinfo_l(_NL_WDAY_3, __cloc);
2542+ _M_data->_M_day3 = __u.__w;
2543+ __u.__s = __nl_langinfo_l(_NL_WDAY_4, __cloc);
2544+ _M_data->_M_day4 = __u.__w;
2545+ __u.__s = __nl_langinfo_l(_NL_WDAY_5, __cloc);
2546+ _M_data->_M_day5 = __u.__w;
2547+ __u.__s = __nl_langinfo_l(_NL_WDAY_6, __cloc);
2548+ _M_data->_M_day6 = __u.__w;
2549+ __u.__s = __nl_langinfo_l(_NL_WDAY_7, __cloc);
2550+ _M_data->_M_day7 = __u.__w;
2551+
2552+ // Abbreviated day names, starting with "C"'s Sun.
2553+ __u.__s = __nl_langinfo_l(_NL_WABDAY_1, __cloc);
2554+ _M_data->_M_aday1 = __u.__w;
2555+ __u.__s = __nl_langinfo_l(_NL_WABDAY_2, __cloc);
2556+ _M_data->_M_aday2 = __u.__w;
2557+ __u.__s = __nl_langinfo_l(_NL_WABDAY_3, __cloc);
2558+ _M_data->_M_aday3 = __u.__w;
2559+ __u.__s = __nl_langinfo_l(_NL_WABDAY_4, __cloc);
2560+ _M_data->_M_aday4 = __u.__w;
2561+ __u.__s = __nl_langinfo_l(_NL_WABDAY_5, __cloc);
2562+ _M_data->_M_aday5 = __u.__w;
2563+ __u.__s = __nl_langinfo_l(_NL_WABDAY_6, __cloc);
2564+ _M_data->_M_aday6 = __u.__w;
2565+ __u.__s = __nl_langinfo_l(_NL_WABDAY_7, __cloc);
2566+ _M_data->_M_aday7 = __u.__w;
2567+
2568+ // Month names, starting with "C"'s January.
2569+ __u.__s = __nl_langinfo_l(_NL_WMON_1, __cloc);
2570+ _M_data->_M_month01 = __u.__w;
2571+ __u.__s = __nl_langinfo_l(_NL_WMON_2, __cloc);
2572+ _M_data->_M_month02 = __u.__w;
2573+ __u.__s = __nl_langinfo_l(_NL_WMON_3, __cloc);
2574+ _M_data->_M_month03 = __u.__w;
2575+ __u.__s = __nl_langinfo_l(_NL_WMON_4, __cloc);
2576+ _M_data->_M_month04 = __u.__w;
2577+ __u.__s = __nl_langinfo_l(_NL_WMON_5, __cloc);
2578+ _M_data->_M_month05 = __u.__w;
2579+ __u.__s = __nl_langinfo_l(_NL_WMON_6, __cloc);
2580+ _M_data->_M_month06 = __u.__w;
2581+ __u.__s = __nl_langinfo_l(_NL_WMON_7, __cloc);
2582+ _M_data->_M_month07 = __u.__w;
2583+ __u.__s = __nl_langinfo_l(_NL_WMON_8, __cloc);
2584+ _M_data->_M_month08 = __u.__w;
2585+ __u.__s = __nl_langinfo_l(_NL_WMON_9, __cloc);
2586+ _M_data->_M_month09 = __u.__w;
2587+ __u.__s = __nl_langinfo_l(_NL_WMON_10, __cloc);
2588+ _M_data->_M_month10 = __u.__w;
2589+ __u.__s = __nl_langinfo_l(_NL_WMON_11, __cloc);
2590+ _M_data->_M_month11 = __u.__w;
2591+ __u.__s = __nl_langinfo_l(_NL_WMON_12, __cloc);
2592+ _M_data->_M_month12 = __u.__w;
2593+
2594+ // Abbreviated month names, starting with "C"'s Jan.
2595+ __u.__s = __nl_langinfo_l(_NL_WABMON_1, __cloc);
2596+ _M_data->_M_amonth01 = __u.__w;
2597+ __u.__s = __nl_langinfo_l(_NL_WABMON_2, __cloc);
2598+ _M_data->_M_amonth02 = __u.__w;
2599+ __u.__s = __nl_langinfo_l(_NL_WABMON_3, __cloc);
2600+ _M_data->_M_amonth03 = __u.__w;
2601+ __u.__s = __nl_langinfo_l(_NL_WABMON_4, __cloc);
2602+ _M_data->_M_amonth04 = __u.__w;
2603+ __u.__s = __nl_langinfo_l(_NL_WABMON_5, __cloc);
2604+ _M_data->_M_amonth05 = __u.__w;
2605+ __u.__s = __nl_langinfo_l(_NL_WABMON_6, __cloc);
2606+ _M_data->_M_amonth06 = __u.__w;
2607+ __u.__s = __nl_langinfo_l(_NL_WABMON_7, __cloc);
2608+ _M_data->_M_amonth07 = __u.__w;
2609+ __u.__s = __nl_langinfo_l(_NL_WABMON_8, __cloc);
2610+ _M_data->_M_amonth08 = __u.__w;
2611+ __u.__s = __nl_langinfo_l(_NL_WABMON_9, __cloc);
2612+ _M_data->_M_amonth09 = __u.__w;
2613+ __u.__s = __nl_langinfo_l(_NL_WABMON_10, __cloc);
2614+ _M_data->_M_amonth10 = __u.__w;
2615+ __u.__s = __nl_langinfo_l(_NL_WABMON_11, __cloc);
2616+ _M_data->_M_amonth11 = __u.__w;
2617+ __u.__s = __nl_langinfo_l(_NL_WABMON_12, __cloc);
2618+ _M_data->_M_amonth12 = __u.__w;
2619+ }
2620+#endif // 0
2621+ }
2622+#endif
2623+}
2624Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/time_members.h
2625===================================================================
2626--- /dev/null 1970-01-01 00:00:00.000000000 +0000
2627+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/time_members.h 2010-06-25 10:42:34.913881064 -0700
2628@@ -0,0 +1,68 @@
2629+// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
2630+
2631+// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2632+//
2633+// This file is part of the GNU ISO C++ Library. This library is free
2634+// software; you can redistribute it and/or modify it under the
2635+// terms of the GNU General Public License as published by the
2636+// Free Software Foundation; either version 2, or (at your option)
2637+// any later version.
2638+
2639+// This library is distributed in the hope that it will be useful,
2640+// but WITHOUT ANY WARRANTY; without even the implied warranty of
2641+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2642+// GNU General Public License for more details.
2643+
2644+// You should have received a copy of the GNU General Public License along
2645+// with this library; see the file COPYING. If not, write to the Free
2646+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2647+// USA.
2648+
2649+// As a special exception, you may use this file as part of a free software
2650+// library without restriction. Specifically, if other files instantiate
2651+// templates or use macros or inline functions from this file, or you compile
2652+// this file and link it with other files to produce an executable, this
2653+// file does not by itself cause the resulting executable to be covered by
2654+// the GNU General Public License. This exception does not however
2655+// invalidate any other reasons why the executable file might be covered by
2656+// the GNU General Public License.
2657+
2658+//
2659+// ISO C++ 14882: 22.2.5.1.2 - time_get functions
2660+// ISO C++ 14882: 22.2.5.3.2 - time_put functions
2661+//
2662+
2663+// Written by Benjamin Kosnik <bkoz@redhat.com>
2664+
2665+ template<typename _CharT>
2666+ __timepunct<_CharT>::__timepunct(size_t __refs)
2667+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
2668+ _M_name_timepunct(_S_get_c_name())
2669+ { _M_initialize_timepunct(); }
2670+
2671+ template<typename _CharT>
2672+ __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
2673+ : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
2674+ _M_name_timepunct(_S_get_c_name())
2675+ { _M_initialize_timepunct(); }
2676+
2677+ template<typename _CharT>
2678+ __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
2679+ size_t __refs)
2680+ : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
2681+ _M_name_timepunct(__s)
2682+ {
2683+ char* __tmp = new char[std::strlen(__s) + 1];
2684+ std::strcpy(__tmp, __s);
2685+ _M_name_timepunct = __tmp;
2686+ _M_initialize_timepunct(__cloc);
2687+ }
2688+
2689+ template<typename _CharT>
2690+ __timepunct<_CharT>::~__timepunct()
2691+ {
2692+ if (_M_name_timepunct != _S_get_c_name())
2693+ delete [] _M_name_timepunct;
2694+ delete _M_data;
2695+ _S_destroy_c_locale(_M_c_locale_timepunct);
2696+ }
2697Index: gcc-4.5.0/libstdc++-v3/configure
2698===================================================================
2699--- gcc-4.5.0.orig/libstdc++-v3/configure 2010-04-05 18:27:44.000000000 -0700
2700+++ gcc-4.5.0/libstdc++-v3/configure 2010-06-25 10:48:10.124633072 -0700
2701@@ -15577,7 +15577,7 @@
2702 if test "${enable_clocale+set}" = set; then :
2703 enableval=$enable_clocale;
2704 case "$enableval" in
2705- generic|gnu|ieee_1003.1-2001|yes|no|auto) ;;
2706+ generic|gnu|ieee_1003.1-2001|uclibc|yes|no|auto) ;;
2707 *) as_fn_error "Unknown argument to enable/disable clocale" "$LINENO" 5 ;;
2708 esac
2709
2710@@ -15609,6 +15609,9 @@
2711 # Default to "generic".
2712 if test $enable_clocale_flag = auto; then
2713 case ${target_os} in
2714+ *-uclibc*)
2715+ enable_clocale_flag=uclibc
2716+ ;;
2717 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu)
2718 enable_clocale_flag=gnu
2719 ;;
2720@@ -15885,6 +15888,76 @@
2721 CTIME_CC=config/locale/generic/time_members.cc
2722 CLOCALE_INTERNAL_H=config/locale/generic/c++locale_internal.h
2723 ;;
2724+ uclibc)
2725+ echo "$as_me:$LINENO: result: uclibc" >&5
2726+echo "${ECHO_T}uclibc" >&6
2727+
2728+ # Declare intention to use gettext, and add support for specific
2729+ # languages.
2730+ # For some reason, ALL_LINGUAS has to be before AM-GNU-GETTEXT
2731+ ALL_LINGUAS="de fr"
2732+
2733+ # Don't call AM-GNU-GETTEXT here. Instead, assume glibc.
2734+ # Extract the first word of "msgfmt", so it can be a program name with args.
2735+set dummy msgfmt; ac_word=$2
2736+echo "$as_me:$LINENO: checking for $ac_word" >&5
2737+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
2738+if test "${ac_cv_prog_check_msgfmt+set}" = set; then
2739+ echo $ECHO_N "(cached) $ECHO_C" >&6
2740+else
2741+ if test -n "$check_msgfmt"; then
2742+ ac_cv_prog_check_msgfmt="$check_msgfmt" # Let the user override the test.
2743+else
2744+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2745+for as_dir in $PATH
2746+do
2747+ IFS=$as_save_IFS
2748+ test -z "$as_dir" && as_dir=.
2749+ for ac_exec_ext in '' $ac_executable_extensions; do
2750+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2751+ ac_cv_prog_check_msgfmt="yes"
2752+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2753+ break 2
2754+ fi
2755+done
2756+done
2757+
2758+ test -z "$ac_cv_prog_check_msgfmt" && ac_cv_prog_check_msgfmt="no"
2759+fi
2760+fi
2761+check_msgfmt=$ac_cv_prog_check_msgfmt
2762+if test -n "$check_msgfmt"; then
2763+ echo "$as_me:$LINENO: result: $check_msgfmt" >&5
2764+echo "${ECHO_T}$check_msgfmt" >&6
2765+else
2766+ echo "$as_me:$LINENO: result: no" >&5
2767+echo "${ECHO_T}no" >&6
2768+fi
2769+
2770+ if test x"$check_msgfmt" = x"yes" && test x"$enable_nls" = x"yes"; then
2771+ USE_NLS=yes
2772+ fi
2773+ # Export the build objects.
2774+ for ling in $ALL_LINGUAS; do \
2775+ glibcxx_MOFILES="$glibcxx_MOFILES $ling.mo"; \
2776+ glibcxx_POFILES="$glibcxx_POFILES $ling.po"; \
2777+ done
2778+
2779+
2780+
2781+ CLOCALE_H=config/locale/uclibc/c_locale.h
2782+ CLOCALE_CC=config/locale/uclibc/c_locale.cc
2783+ CCODECVT_CC=config/locale/uclibc/codecvt_members.cc
2784+ CCOLLATE_CC=config/locale/uclibc/collate_members.cc
2785+ CCTYPE_CC=config/locale/uclibc/ctype_members.cc
2786+ CMESSAGES_H=config/locale/uclibc/messages_members.h
2787+ CMESSAGES_CC=config/locale/uclibc/messages_members.cc
2788+ CMONEY_CC=config/locale/uclibc/monetary_members.cc
2789+ CNUMERIC_CC=config/locale/uclibc/numeric_members.cc
2790+ CTIME_H=config/locale/uclibc/time_members.h
2791+ CTIME_CC=config/locale/uclibc/time_members.cc
2792+ CLOCALE_INTERNAL_H=config/locale/uclibc/c++locale_internal.h
2793+ ;;
2794 esac
2795
2796 # This is where the testsuite looks for locale catalogs, using the
2797@@ -16940,6 +17013,7 @@
2798
2799 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2800 /* end confdefs.h. */
2801+#line 17016 "configure"
2802 #include <wctype.h>
2803 int
2804 main ()
2805@@ -58165,7 +58239,6 @@
2806 fi
2807 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2808 /* end confdefs.h. */
2809-
2810 int
2811 main ()
2812 {
2813Index: gcc-4.5.0/libstdc++-v3/include/c_compatibility/wchar.h
2814===================================================================
2815--- gcc-4.5.0.orig/libstdc++-v3/include/c_compatibility/wchar.h 2009-04-09 08:00:19.000000000 -0700
2816+++ gcc-4.5.0/libstdc++-v3/include/c_compatibility/wchar.h 2010-06-25 10:42:34.949880937 -0700
2817@@ -101,7 +101,9 @@
2818 using std::wmemcpy;
2819 using std::wmemmove;
2820 using std::wmemset;
2821+#if _GLIBCXX_HAVE_WCSFTIME
2822 using std::wcsftime;
2823+#endif
2824
2825 #if _GLIBCXX_USE_C99
2826 using std::wcstold;
2827Index: gcc-4.5.0/libstdc++-v3/include/c_std/cwchar
2828===================================================================
2829--- gcc-4.5.0.orig/libstdc++-v3/include/c_std/cwchar 2010-02-04 10:20:34.000000000 -0800
2830+++ gcc-4.5.0/libstdc++-v3/include/c_std/cwchar 2010-06-25 10:42:34.949880937 -0700
2831@@ -177,7 +177,9 @@
2832 using ::wcscoll;
2833 using ::wcscpy;
2834 using ::wcscspn;
2835+#if _GLIBCXX_HAVE_WCSFTIME
2836 using ::wcsftime;
2837+#endif
2838 using ::wcslen;
2839 using ::wcsncat;
2840 using ::wcsncmp;
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/203-uclibc-locale-no__x.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/203-uclibc-locale-no__x.patch
new file mode 100644
index 0000000000..f39e65220c
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/203-uclibc-locale-no__x.patch
@@ -0,0 +1,233 @@
1Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
2===================================================================
3--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2008-08-16 01:29:20.000000000 -0700
4+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2008-08-16 01:33:23.000000000 -0700
5@@ -60,4 +60,49 @@
6 extern "C" __typeof(wctype_l) __wctype_l;
7 #endif
8
9+# define __nl_langinfo_l nl_langinfo_l
10+# define __strcoll_l strcoll_l
11+# define __strftime_l strftime_l
12+# define __strtod_l strtod_l
13+# define __strtof_l strtof_l
14+# define __strtold_l strtold_l
15+# define __strxfrm_l strxfrm_l
16+# define __newlocale newlocale
17+# define __freelocale freelocale
18+# define __duplocale duplocale
19+# define __uselocale uselocale
20+
21+# ifdef _GLIBCXX_USE_WCHAR_T
22+# define __iswctype_l iswctype_l
23+# define __towlower_l towlower_l
24+# define __towupper_l towupper_l
25+# define __wcscoll_l wcscoll_l
26+# define __wcsftime_l wcsftime_l
27+# define __wcsxfrm_l wcsxfrm_l
28+# define __wctype_l wctype_l
29+# endif
30+
31+#else
32+# define __nl_langinfo_l(N, L) nl_langinfo((N))
33+# define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
34+# define __strtod_l(S, E, L) strtod((S), (E))
35+# define __strtof_l(S, E, L) strtof((S), (E))
36+# define __strtold_l(S, E, L) strtold((S), (E))
37+# define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
38+# warning should dummy __newlocale check for C|POSIX ?
39+# define __newlocale(a, b, c) NULL
40+# define __freelocale(a) ((void)0)
41+# define __duplocale(a) __c_locale()
42+//# define __uselocale ?
43+//
44+# ifdef _GLIBCXX_USE_WCHAR_T
45+# define __iswctype_l(C, M, L) iswctype((C), (M))
46+# define __towlower_l(C, L) towlower((C))
47+# define __towupper_l(C, L) towupper((C))
48+# define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
49+//# define __wcsftime_l(S, M, F, T, L) wcsftime((S), (M), (F), (T))
50+# define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
51+# define __wctype_l(S, L) wctype((S))
52+# endif
53+
54 #endif // GLIBC 2.3 and later
55Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.cc
56===================================================================
57--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-08-16 01:29:20.000000000 -0700
58+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-08-16 01:33:00.000000000 -0700
59@@ -39,20 +39,6 @@
60 #include <langinfo.h>
61 #include <bits/c++locale_internal.h>
62
63-#ifndef __UCLIBC_HAS_XLOCALE__
64-#define __strtol_l(S, E, B, L) strtol((S), (E), (B))
65-#define __strtoul_l(S, E, B, L) strtoul((S), (E), (B))
66-#define __strtoll_l(S, E, B, L) strtoll((S), (E), (B))
67-#define __strtoull_l(S, E, B, L) strtoull((S), (E), (B))
68-#define __strtof_l(S, E, L) strtof((S), (E))
69-#define __strtod_l(S, E, L) strtod((S), (E))
70-#define __strtold_l(S, E, L) strtold((S), (E))
71-#warning should dummy __newlocale check for C|POSIX ?
72-#define __newlocale(a, b, c) NULL
73-#define __freelocale(a) ((void)0)
74-#define __duplocale(a) __c_locale()
75-#endif
76-
77 namespace std
78 {
79 template<>
80Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/collate_members.cc
81===================================================================
82--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/collate_members.cc 2008-08-16 01:29:20.000000000 -0700
83+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/collate_members.cc 2008-08-16 01:30:31.000000000 -0700
84@@ -36,13 +36,6 @@
85 #include <locale>
86 #include <bits/c++locale_internal.h>
87
88-#ifndef __UCLIBC_HAS_XLOCALE__
89-#define __strcoll_l(S1, S2, L) strcoll((S1), (S2))
90-#define __strxfrm_l(S1, S2, N, L) strxfrm((S1), (S2), (N))
91-#define __wcscoll_l(S1, S2, L) wcscoll((S1), (S2))
92-#define __wcsxfrm_l(S1, S2, N, L) wcsxfrm((S1), (S2), (N))
93-#endif
94-
95 namespace std
96 {
97 // These are basically extensions to char_traits, and perhaps should
98Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/monetary_members.cc
99===================================================================
100--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-08-16 01:29:20.000000000 -0700
101+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-08-16 01:30:31.000000000 -0700
102@@ -43,10 +43,6 @@
103 #warning tailor for stub locale support
104 #endif
105
106-#ifndef __UCLIBC_HAS_XLOCALE__
107-#define __nl_langinfo_l(N, L) nl_langinfo((N))
108-#endif
109-
110 namespace std
111 {
112 // Construct and return valid pattern consisting of some combination of:
113Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/numeric_members.cc
114===================================================================
115--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-08-16 01:29:20.000000000 -0700
116+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-08-16 01:30:31.000000000 -0700
117@@ -41,9 +41,6 @@
118 #ifdef __UCLIBC_MJN3_ONLY__
119 #warning tailor for stub locale support
120 #endif
121-#ifndef __UCLIBC_HAS_XLOCALE__
122-#define __nl_langinfo_l(N, L) nl_langinfo((N))
123-#endif
124
125 namespace std
126 {
127Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/time_members.cc
128===================================================================
129--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/time_members.cc 2008-08-16 01:29:20.000000000 -0700
130+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/time_members.cc 2008-08-16 01:30:31.000000000 -0700
131@@ -40,9 +40,6 @@
132 #ifdef __UCLIBC_MJN3_ONLY__
133 #warning tailor for stub locale support
134 #endif
135-#ifndef __UCLIBC_HAS_XLOCALE__
136-#define __nl_langinfo_l(N, L) nl_langinfo((N))
137-#endif
138
139 namespace std
140 {
141Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/ctype_members.cc
142===================================================================
143--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-08-16 01:29:20.000000000 -0700
144+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-08-16 01:30:31.000000000 -0700
145@@ -38,13 +38,6 @@
146 #undef _LIBC
147 #include <bits/c++locale_internal.h>
148
149-#ifndef __UCLIBC_HAS_XLOCALE__
150-#define __wctype_l(S, L) wctype((S))
151-#define __towupper_l(C, L) towupper((C))
152-#define __towlower_l(C, L) towlower((C))
153-#define __iswctype_l(C, M, L) iswctype((C), (M))
154-#endif
155-
156 namespace std
157 {
158 // NB: The other ctype<char> specializations are in src/locale.cc and
159Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/messages_members.cc
160===================================================================
161--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/messages_members.cc 2008-08-16 01:27:18.000000000 -0700
162+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/messages_members.cc 2008-08-16 01:30:31.000000000 -0700
163@@ -39,13 +39,10 @@
164 #ifdef __UCLIBC_MJN3_ONLY__
165 #warning fix gettext stuff
166 #endif
167-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
168-extern "C" char *__dcgettext(const char *domainname,
169- const char *msgid, int category);
170 #undef gettext
171-#define gettext(msgid) __dcgettext(NULL, msgid, LC_MESSAGES)
172+#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
173+#define gettext(msgid) dcgettext(NULL, msgid, LC_MESSAGES)
174 #else
175-#undef gettext
176 #define gettext(msgid) (msgid)
177 #endif
178
179Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/messages_members.h
180===================================================================
181--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-08-16 01:29:20.000000000 -0700
182+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-08-16 01:31:43.000000000 -0700
183@@ -36,15 +36,11 @@
184 #ifdef __UCLIBC_MJN3_ONLY__
185 #warning fix prototypes for *textdomain funcs
186 #endif
187-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
188-extern "C" char *__textdomain(const char *domainname);
189-extern "C" char *__bindtextdomain(const char *domainname,
190- const char *dirname);
191-#else
192-#undef __textdomain
193-#undef __bindtextdomain
194-#define __textdomain(D) ((void)0)
195-#define __bindtextdomain(D,P) ((void)0)
196+#ifndef __UCLIBC_HAS_GETTEXT_AWARENESS__
197+#undef textdomain
198+#undef bindtextdomain
199+#define textdomain(D) ((void)0)
200+#define bindtextdomain(D,P) ((void)0)
201 #endif
202
203 // Non-virtual member functions.
204@@ -70,7 +66,7 @@
205 messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc,
206 const char* __dir) const
207 {
208- __bindtextdomain(__s.c_str(), __dir);
209+ bindtextdomain(__s.c_str(), __dir);
210 return this->do_open(__s, __loc);
211 }
212
213@@ -90,7 +86,7 @@
214 {
215 // No error checking is done, assume the catalog exists and can
216 // be used.
217- __textdomain(__s.c_str());
218+ textdomain(__s.c_str());
219 return 0;
220 }
221
222Index: gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.h
223===================================================================
224--- gcc-4.3.1.orig/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-08-16 01:29:20.000000000 -0700
225+++ gcc-4.3.1/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-08-16 01:30:31.000000000 -0700
226@@ -68,6 +68,7 @@
227 {
228 extern "C" __typeof(uselocale) __uselocale;
229 }
230+#define __uselocale uselocale
231 #endif
232
233 namespace std
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/204-uclibc-locale-wchar_fix.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/204-uclibc-locale-wchar_fix.patch
new file mode 100644
index 0000000000..160ab35bb3
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/204-uclibc-locale-wchar_fix.patch
@@ -0,0 +1,48 @@
1--- gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
2+++ gcc/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2006-03-10 15:37:27 +0100
3@@ -401,7 +401,7 @@
4 # ifdef __UCLIBC_HAS_XLOCALE__
5 _M_data->_M_decimal_point = __cloc->decimal_point_wc;
6 _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
7-# else
8+# elif defined __UCLIBC_HAS_LOCALE__
9 _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
10 _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
11 # endif
12@@ -556,7 +556,7 @@
13 # ifdef __UCLIBC_HAS_XLOCALE__
14 _M_data->_M_decimal_point = __cloc->decimal_point_wc;
15 _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
16-# else
17+# elif defined __UCLIBC_HAS_LOCALE__
18 _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
19 _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
20 # endif
21--- gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc.uclibc200_wchar~ 2006-03-10 15:32:37 +0100
22+++ gcc/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2006-03-10 15:37:27 +0100
23@@ -127,12 +127,25 @@
24 {
25 // Named locale.
26 // NB: In the GNU model wchar_t is always 32 bit wide.
27+#ifdef __UCLIBC_MJN3_ONLY__
28+#warning fix this... should be numeric
29+#endif
30+#ifdef __UCLIBC__
31+# ifdef __UCLIBC_HAS_XLOCALE__
32+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
33+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
34+# elif defined __UCLIBC_HAS_LOCALE__
35+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
36+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
37+# endif
38+#else
39 union { char *__s; wchar_t __w; } __u;
40 __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
41 _M_data->_M_decimal_point = __u.__w;
42
43 __u.__s = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc);
44 _M_data->_M_thousands_sep = __u.__w;
45+#endif
46
47 if (_M_data->_M_thousands_sep == L'\0')
48 _M_data->_M_grouping = "";
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/205-uclibc-locale-update.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/205-uclibc-locale-update.patch
new file mode 100644
index 0000000000..48eaa1d442
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/205-uclibc-locale-update.patch
@@ -0,0 +1,519 @@
1Index: gcc-4.3.2/libstdc++-v3/config/locale/uclibc/c_locale.cc
2===================================================================
3--- gcc-4.3.2.orig/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-09-17 22:35:28.000000000 -0700
4+++ gcc-4.3.2/libstdc++-v3/config/locale/uclibc/c_locale.cc 2008-09-17 22:35:29.000000000 -0700
5@@ -39,23 +39,20 @@
6 #include <langinfo.h>
7 #include <bits/c++locale_internal.h>
8
9-namespace std
10-{
11+_GLIBCXX_BEGIN_NAMESPACE(std)
12+
13 template<>
14 void
15 __convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
16 const __c_locale& __cloc)
17 {
18- if (!(__err & ios_base::failbit))
19- {
20- char* __sanity;
21- errno = 0;
22- float __f = __strtof_l(__s, &__sanity, __cloc);
23- if (__sanity != __s && errno != ERANGE)
24- __v = __f;
25- else
26- __err |= ios_base::failbit;
27- }
28+ char* __sanity;
29+ errno = 0;
30+ float __f = __strtof_l(__s, &__sanity, __cloc);
31+ if (__sanity != __s && errno != ERANGE)
32+ __v = __f;
33+ else
34+ __err |= ios_base::failbit;
35 }
36
37 template<>
38@@ -63,16 +60,13 @@
39 __convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
40 const __c_locale& __cloc)
41 {
42- if (!(__err & ios_base::failbit))
43- {
44- char* __sanity;
45- errno = 0;
46- double __d = __strtod_l(__s, &__sanity, __cloc);
47- if (__sanity != __s && errno != ERANGE)
48- __v = __d;
49- else
50- __err |= ios_base::failbit;
51- }
52+ char* __sanity;
53+ errno = 0;
54+ double __d = __strtod_l(__s, &__sanity, __cloc);
55+ if (__sanity != __s && errno != ERANGE)
56+ __v = __d;
57+ else
58+ __err |= ios_base::failbit;
59 }
60
61 template<>
62@@ -80,16 +74,13 @@
63 __convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
64 const __c_locale& __cloc)
65 {
66- if (!(__err & ios_base::failbit))
67- {
68- char* __sanity;
69- errno = 0;
70- long double __ld = __strtold_l(__s, &__sanity, __cloc);
71- if (__sanity != __s && errno != ERANGE)
72- __v = __ld;
73- else
74- __err |= ios_base::failbit;
75- }
76+ char* __sanity;
77+ errno = 0;
78+ long double __ld = __strtold_l(__s, &__sanity, __cloc);
79+ if (__sanity != __s && errno != ERANGE)
80+ __v = __ld;
81+ else
82+ __err |= ios_base::failbit;
83 }
84
85 void
86@@ -110,17 +101,18 @@
87 void
88 locale::facet::_S_destroy_c_locale(__c_locale& __cloc)
89 {
90- if (_S_get_c_locale() != __cloc)
91+ if (__cloc && _S_get_c_locale() != __cloc)
92 __freelocale(__cloc);
93 }
94
95 __c_locale
96 locale::facet::_S_clone_c_locale(__c_locale& __cloc)
97 { return __duplocale(__cloc); }
98-} // namespace std
99
100-namespace __gnu_cxx
101-{
102+_GLIBCXX_END_NAMESPACE
103+
104+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
105+
106 const char* const category_names[6 + _GLIBCXX_NUM_CATEGORIES] =
107 {
108 "LC_CTYPE",
109@@ -138,9 +130,11 @@
110 "LC_IDENTIFICATION"
111 #endif
112 };
113-}
114
115-namespace std
116-{
117+_GLIBCXX_END_NAMESPACE
118+
119+_GLIBCXX_BEGIN_NAMESPACE(std)
120+
121 const char* const* const locale::_S_categories = __gnu_cxx::category_names;
122-} // namespace std
123+
124+_GLIBCXX_END_NAMESPACE
125Index: gcc-4.3.2/libstdc++-v3/config/locale/uclibc/ctype_members.cc
126===================================================================
127--- gcc-4.3.2.orig/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-09-17 22:35:28.000000000 -0700
128+++ gcc-4.3.2/libstdc++-v3/config/locale/uclibc/ctype_members.cc 2008-09-17 23:09:49.000000000 -0700
129@@ -33,16 +33,20 @@
130
131 // Written by Benjamin Kosnik <bkoz@redhat.com>
132
133+#include <features.h>
134+#ifdef __UCLIBC_HAS_LOCALE__
135 #define _LIBC
136 #include <locale>
137 #undef _LIBC
138+#else
139+#include <locale>
140+#endif
141 #include <bits/c++locale_internal.h>
142
143-namespace std
144-{
145+_GLIBCXX_BEGIN_NAMESPACE(std)
146+
147 // NB: The other ctype<char> specializations are in src/locale.cc and
148 // various /config/os/* files.
149- template<>
150 ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
151 : ctype<char>(0, false, __refs)
152 {
153@@ -57,6 +61,8 @@
154 #endif
155 }
156 }
157+ ctype_byname<char>::~ctype_byname()
158+ { }
159
160 #ifdef _GLIBCXX_USE_WCHAR_T
161 ctype<wchar_t>::__wmask_type
162@@ -138,17 +144,33 @@
163 ctype<wchar_t>::
164 do_is(mask __m, wchar_t __c) const
165 {
166- // Highest bitmask in ctype_base == 10, but extra in "C"
167- // library for blank.
168+ // The case of __m == ctype_base::space is particularly important,
169+ // due to its use in many istream functions. Therefore we deal with
170+ // it first, exploiting the knowledge that on GNU systems _M_bit[5]
171+ // is the mask corresponding to ctype_base::space. NB: an encoding
172+ // change would not affect correctness!
173+
174 bool __ret = false;
175- const size_t __bitmasksize = 11;
176- for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
177- if (__m & _M_bit[__bitcur]
178- && __iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
179- {
180- __ret = true;
181- break;
182- }
183+ if (__m == _M_bit[5])
184+ __ret = __iswctype_l(__c, _M_wmask[5], _M_c_locale_ctype);
185+ else
186+ {
187+ // Highest bitmask in ctype_base == 10, but extra in "C"
188+ // library for blank.
189+ const size_t __bitmasksize = 11;
190+ for (size_t __bitcur = 0; __bitcur <= __bitmasksize; ++__bitcur)
191+ if (__m & _M_bit[__bitcur])
192+ {
193+ if (__iswctype_l(__c, _M_wmask[__bitcur], _M_c_locale_ctype))
194+ {
195+ __ret = true;
196+ break;
197+ }
198+ else if (__m == _M_bit[__bitcur])
199+ break;
200+ }
201+ }
202+
203 return __ret;
204 }
205
206@@ -290,4 +312,5 @@
207 #endif
208 }
209 #endif // _GLIBCXX_USE_WCHAR_T
210-}
211+
212+_GLIBCXX_END_NAMESPACE
213Index: gcc-4.3.2/libstdc++-v3/config/locale/uclibc/messages_members.h
214===================================================================
215--- gcc-4.3.2.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-09-17 22:35:28.000000000 -0700
216+++ gcc-4.3.2/libstdc++-v3/config/locale/uclibc/messages_members.h 2008-09-17 23:13:34.000000000 -0700
217@@ -53,12 +53,16 @@
218 template<typename _CharT>
219 messages<_CharT>::messages(__c_locale __cloc, const char* __s,
220 size_t __refs)
221- : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
222- _M_name_messages(__s)
223+ : facet(__refs), _M_c_locale_messages(NULL),
224+ _M_name_messages(NULL)
225 {
226- char* __tmp = new char[std::strlen(__s) + 1];
227- std::strcpy(__tmp, __s);
228+ const size_t __len = std::strlen(__s) + 1;
229+ char* __tmp = new char[__len];
230+ std::memcpy(__tmp, __s, __len);
231 _M_name_messages = __tmp;
232+
233+ // Last to avoid leaking memory if new throws.
234+ _M_c_locale_messages = _S_clone_c_locale(__cloc);
235 }
236
237 template<typename _CharT>
238Index: gcc-4.3.2/libstdc++-v3/config/locale/uclibc/monetary_members.cc
239===================================================================
240--- gcc-4.3.2.orig/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-09-17 22:35:28.000000000 -0700
241+++ gcc-4.3.2/libstdc++-v3/config/locale/uclibc/monetary_members.cc 2008-09-17 22:35:29.000000000 -0700
242@@ -33,9 +33,14 @@
243
244 // Written by Benjamin Kosnik <bkoz@redhat.com>
245
246+#include <features.h>
247+#ifdef __UCLIBC_HAS_LOCALE__
248 #define _LIBC
249 #include <locale>
250 #undef _LIBC
251+#else
252+#include <locale>
253+#endif
254 #include <bits/c++locale_internal.h>
255
256 #ifdef __UCLIBC_MJN3_ONLY__
257@@ -206,7 +211,7 @@
258 }
259 break;
260 default:
261- ;
262+ __ret = pattern();
263 }
264 return __ret;
265 }
266@@ -390,7 +395,9 @@
267 __c_locale __old = __uselocale(__cloc);
268 #else
269 // Switch to named locale so that mbsrtowcs will work.
270- char* __old = strdup(setlocale(LC_ALL, NULL));
271+ char* __old = setlocale(LC_ALL, NULL);
272+ const size_t __llen = strlen(__old) + 1;
273+ char* __sav = new char[__llen];
274 setlocale(LC_ALL, __name);
275 #endif
276
277@@ -477,8 +484,8 @@
278 #ifdef __UCLIBC_HAS_XLOCALE__
279 __uselocale(__old);
280 #else
281- setlocale(LC_ALL, __old);
282- free(__old);
283+ setlocale(LC_ALL, __sav);
284+ delete [] __sav;
285 #endif
286 __throw_exception_again;
287 }
288@@ -498,8 +505,8 @@
289 #ifdef __UCLIBC_HAS_XLOCALE__
290 __uselocale(__old);
291 #else
292- setlocale(LC_ALL, __old);
293- free(__old);
294+ setlocale(LC_ALL, __sav);
295+ delete [] __sav;
296 #endif
297 }
298 }
299@@ -545,8 +552,11 @@
300 __c_locale __old = __uselocale(__cloc);
301 #else
302 // Switch to named locale so that mbsrtowcs will work.
303- char* __old = strdup(setlocale(LC_ALL, NULL));
304- setlocale(LC_ALL, __name);
305+ char* __old = setlocale(LC_ALL, NULL);
306+ const size_t __llen = strlen(__old) + 1;
307+ char* __sav = new char[__llen];
308+ memcpy(__sav, __old, __llen);
309+ setlocale(LC_ALL, __name);
310 #endif
311
312 #ifdef __UCLIBC_MJN3_ONLY__
313@@ -633,8 +643,8 @@
314 #ifdef __UCLIBC_HAS_XLOCALE__
315 __uselocale(__old);
316 #else
317- setlocale(LC_ALL, __old);
318- free(__old);
319+ setlocale(LC_ALL, __sav);
320+ delete [] __sav;
321 #endif
322 __throw_exception_again;
323 }
324@@ -653,8 +663,8 @@
325 #ifdef __UCLIBC_HAS_XLOCALE__
326 __uselocale(__old);
327 #else
328- setlocale(LC_ALL, __old);
329- free(__old);
330+ setlocale(LC_ALL, __sav);
331+ delete [] __sav;
332 #endif
333 }
334 }
335Index: gcc-4.3.2/libstdc++-v3/config/locale/uclibc/numeric_members.cc
336===================================================================
337--- gcc-4.3.2.orig/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-09-17 22:35:28.000000000 -0700
338+++ gcc-4.3.2/libstdc++-v3/config/locale/uclibc/numeric_members.cc 2008-09-17 22:35:29.000000000 -0700
339@@ -33,9 +33,14 @@
340
341 // Written by Benjamin Kosnik <bkoz@redhat.com>
342
343+#include <features.h>
344+#ifdef __UCLIBC_HAS_LOCALE__
345 #define _LIBC
346 #include <locale>
347 #undef _LIBC
348+#else
349+#include <locale>
350+#endif
351 #include <bits/c++locale_internal.h>
352
353 #ifdef __UCLIBC_MJN3_ONLY__
354Index: gcc-4.3.2/libstdc++-v3/config/locale/uclibc/time_members.h
355===================================================================
356--- gcc-4.3.2.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2008-09-17 22:35:27.000000000 -0700
357+++ gcc-4.3.2/libstdc++-v3/config/locale/uclibc/time_members.h 2008-09-17 23:13:34.000000000 -0700
358@@ -50,12 +50,21 @@
359 __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
360 size_t __refs)
361 : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
362- _M_name_timepunct(__s)
363+ _M_name_timepunct(NULL)
364 {
365- char* __tmp = new char[std::strlen(__s) + 1];
366- std::strcpy(__tmp, __s);
367+ const size_t __len = std::strlen(__s) + 1;
368+ char* __tmp = new char[__len];
369+ std::memcpy(__tmp, __s, __len);
370 _M_name_timepunct = __tmp;
371- _M_initialize_timepunct(__cloc);
372+
373+ try
374+ { _M_initialize_timepunct(__cloc); }
375+ catch(...)
376+ {
377+ delete [] _M_name_timepunct;
378+ __throw_exception_again;
379+ }
380+
381 }
382
383 template<typename _CharT>
384Index: gcc-4.3.2/libstdc++-v3/config/locale/uclibc/c_locale.h
385===================================================================
386--- gcc-4.3.2.orig/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-09-17 22:35:28.000000000 -0700
387+++ gcc-4.3.2/libstdc++-v3/config/locale/uclibc/c_locale.h 2008-09-17 22:35:29.000000000 -0700
388@@ -39,21 +39,23 @@
389 #pragma GCC system_header
390
391 #include <cstring> // get std::strlen
392-#include <cstdio> // get std::snprintf or std::sprintf
393+#include <cstdio> // get std::vsnprintf or std::vsprintf
394 #include <clocale>
395 #include <langinfo.h> // For codecvt
396 #ifdef __UCLIBC_MJN3_ONLY__
397 #warning fix this
398 #endif
399-#ifdef __UCLIBC_HAS_LOCALE__
400+#ifdef _GLIBCXX_USE_ICONV
401 #include <iconv.h> // For codecvt using iconv, iconv_t
402 #endif
403-#ifdef __UCLIBC_HAS_GETTEXT_AWARENESS__
404-#include <libintl.h> // For messages
405+#ifdef HAVE_LIBINTL_H
406+#include <libintl.h> // For messages
407 #endif
408+#include <cstdarg>
409
410 #ifdef __UCLIBC_MJN3_ONLY__
411 #warning what is _GLIBCXX_C_LOCALE_GNU for
412+// psm: used in os/gnu-linux/ctype_noninline.h
413 #endif
414 #define _GLIBCXX_C_LOCALE_GNU 1
415
416@@ -78,23 +80,25 @@
417 #else
418 typedef int* __c_locale;
419 #endif
420-
421- // Convert numeric value of type _Tv to string and return length of
422- // string. If snprintf is available use it, otherwise fall back to
423- // the unsafe sprintf which, in general, can be dangerous and should
424+ // Convert numeric value of type double to string and return length of
425+ // string. If vsnprintf is available use it, otherwise fall back to
426+ // the unsafe vsprintf which, in general, can be dangerous and should
427 // be avoided.
428- template<typename _Tv>
429- int
430- __convert_from_v(char* __out,
431- const int __size __attribute__ ((__unused__)),
432- const char* __fmt,
433-#ifdef __UCLIBC_HAS_XCLOCALE__
434- _Tv __v, const __c_locale& __cloc, int __prec)
435+ inline int
436+ __convert_from_v(const __c_locale&
437+#ifndef __UCLIBC_HAS_XCLOCALE__
438+ __cloc __attribute__ ((__unused__))
439+#endif
440+ ,
441+ char* __out,
442+ const int __size,
443+ const char* __fmt, ...)
444 {
445+ va_list __args;
446+#ifdef __UCLIBC_HAS_XCLOCALE__
447+
448 __c_locale __old = __gnu_cxx::__uselocale(__cloc);
449 #else
450- _Tv __v, const __c_locale&, int __prec)
451- {
452 # ifdef __UCLIBC_HAS_LOCALE__
453 char* __old = std::setlocale(LC_ALL, NULL);
454 char* __sav = new char[std::strlen(__old) + 1];
455@@ -103,7 +107,9 @@
456 # endif
457 #endif
458
459- const int __ret = std::snprintf(__out, __size, __fmt, __prec, __v);
460+ va_start(__args, __fmt);
461+ const int __ret = std::vsnprintf(__out, __size, __fmt, __args);
462+ va_end(__args);
463
464 #ifdef __UCLIBC_HAS_XCLOCALE__
465 __gnu_cxx::__uselocale(__old);
466Index: gcc-4.3.2/libstdc++-v3/config/locale/uclibc/time_members.cc
467===================================================================
468--- gcc-4.3.2.orig/libstdc++-v3/config/locale/uclibc/time_members.cc 2008-09-17 22:35:28.000000000 -0700
469+++ gcc-4.3.2/libstdc++-v3/config/locale/uclibc/time_members.cc 2008-09-17 22:35:29.000000000 -0700
470@@ -53,11 +53,14 @@
471 const size_t __len = __strftime_l(__s, __maxlen, __format, __tm,
472 _M_c_locale_timepunct);
473 #else
474- char* __old = strdup(setlocale(LC_ALL, NULL));
475+ char* __old = setlocale(LC_ALL, NULL);
476+ const size_t __llen = strlen(__old) + 1;
477+ char* __sav = new char[__llen];
478+ memcpy(__sav, __old, __llen);
479 setlocale(LC_ALL, _M_name_timepunct);
480 const size_t __len = strftime(__s, __maxlen, __format, __tm);
481- setlocale(LC_ALL, __old);
482- free(__old);
483+ setlocale(LC_ALL, __sav);
484+ delete [] __sav;
485 #endif
486 // Make sure __s is null terminated.
487 if (__len == 0)
488@@ -207,11 +210,14 @@
489 const size_t __len = __wcsftime_l(__s, __maxlen, __format, __tm,
490 _M_c_locale_timepunct);
491 #else
492- char* __old = strdup(setlocale(LC_ALL, NULL));
493+ char* __old = setlocale(LC_ALL, NULL);
494+ const size_t __llen = strlen(__old) + 1;
495+ char* __sav = new char[__llen];
496+ memcpy(__sav, __old, __llen);
497 setlocale(LC_ALL, _M_name_timepunct);
498 const size_t __len = wcsftime(__s, __maxlen, __format, __tm);
499- setlocale(LC_ALL, __old);
500- free(__old);
501+ setlocale(LC_ALL, __sav);
502+ delete [] __sav;
503 #endif
504 // Make sure __s is null terminated.
505 if (__len == 0)
506Index: gcc-4.3.2/libstdc++-v3/config/locale/uclibc/c++locale_internal.h
507===================================================================
508--- gcc-4.3.2.orig/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2008-09-17 22:35:28.000000000 -0700
509+++ gcc-4.3.2/libstdc++-v3/config/locale/uclibc/c++locale_internal.h 2008-09-17 22:35:29.000000000 -0700
510@@ -31,6 +31,9 @@
511
512 #include <bits/c++config.h>
513 #include <clocale>
514+#include <cstdlib>
515+#include <cstring>
516+#include <cstddef>
517
518 #ifdef __UCLIBC_MJN3_ONLY__
519 #warning clean this up
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/301-missing-execinfo_h.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/301-missing-execinfo_h.patch
new file mode 100644
index 0000000000..aaa5cee8c8
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/301-missing-execinfo_h.patch
@@ -0,0 +1,13 @@
1Index: gcc-4.5.0/boehm-gc/include/gc.h
2===================================================================
3--- gcc-4.5.0.orig/boehm-gc/include/gc.h 2007-04-23 14:10:09.000000000 -0700
4+++ gcc-4.5.0/boehm-gc/include/gc.h 2010-06-25 10:49:12.768883509 -0700
5@@ -503,7 +503,7 @@
6 #if defined(__linux__) || defined(__GLIBC__)
7 # include <features.h>
8 # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
9- && !defined(__ia64__)
10+ && !defined(__ia64__) && !defined(__UCLIBC__)
11 # ifndef GC_HAVE_BUILTIN_BACKTRACE
12 # define GC_HAVE_BUILTIN_BACKTRACE
13 # endif
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/302-c99-snprintf.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/302-c99-snprintf.patch
new file mode 100644
index 0000000000..12be2da79c
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/302-c99-snprintf.patch
@@ -0,0 +1,13 @@
1Index: gcc-4.5.0/libstdc++-v3/include/c_std/cstdio
2===================================================================
3--- gcc-4.5.0.orig/libstdc++-v3/include/c_std/cstdio 2010-02-04 10:20:34.000000000 -0800
4+++ gcc-4.5.0/libstdc++-v3/include/c_std/cstdio 2010-06-25 10:51:12.712631679 -0700
5@@ -139,7 +139,7 @@
6
7 _GLIBCXX_END_NAMESPACE
8
9-#if _GLIBCXX_USE_C99
10+#if _GLIBCXX_USE_C99 || defined(__UCLIBC__)
11
12 #undef snprintf
13 #undef vfscanf
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/303-c99-complex-ugly-hack.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/303-c99-complex-ugly-hack.patch
new file mode 100644
index 0000000000..56aa78cdd2
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/303-c99-complex-ugly-hack.patch
@@ -0,0 +1,14 @@
1Index: gcc-4.5.0/libstdc++-v3/configure
2===================================================================
3--- gcc-4.5.0.orig/libstdc++-v3/configure 2010-06-25 10:48:37.488384191 -0700
4+++ gcc-4.5.0/libstdc++-v3/configure 2010-06-25 10:51:23.804380413 -0700
5@@ -18262,6 +18262,9 @@
6 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
7 /* end confdefs.h. */
8 #include <complex.h>
9+#ifdef __UCLIBC__
10+#error ugly hack to make sure configure test fails here for cross until uClibc supports the complex funcs
11+#endif
12 int
13 main ()
14 {
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/304-index_macro.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/304-index_macro.patch
new file mode 100644
index 0000000000..bbb6563513
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/304-index_macro.patch
@@ -0,0 +1,28 @@
1Index: gcc-4.5.0/libstdc++-v3/include/ext/rope
2===================================================================
3--- gcc-4.5.0.orig/libstdc++-v3/include/ext/rope 2009-04-09 08:00:19.000000000 -0700
4+++ gcc-4.5.0/libstdc++-v3/include/ext/rope 2010-06-25 10:51:33.613383077 -0700
5@@ -54,6 +54,9 @@
6 #include <bits/gthr.h>
7 #include <tr1/functional>
8
9+/* cope w/ index defined as macro, SuSv3 proposal */
10+#undef index
11+
12 # ifdef __GC
13 # define __GC_CONST const
14 # else
15Index: gcc-4.5.0/libstdc++-v3/include/ext/ropeimpl.h
16===================================================================
17--- gcc-4.5.0.orig/libstdc++-v3/include/ext/ropeimpl.h 2009-04-09 08:00:19.000000000 -0700
18+++ gcc-4.5.0/libstdc++-v3/include/ext/ropeimpl.h 2010-06-25 10:51:33.621381669 -0700
19@@ -49,6 +49,9 @@
20 #include <ext/memory> // For uninitialized_copy_n
21 #include <ext/numeric> // For power
22
23+/* cope w/ index defined as macro, SuSv3 proposal */
24+#undef index
25+
26 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
27
28 using std::size_t;
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/305-libmudflap-susv3-legacy.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/305-libmudflap-susv3-legacy.patch
new file mode 100644
index 0000000000..f890acb813
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/305-libmudflap-susv3-legacy.patch
@@ -0,0 +1,49 @@
1Index: gcc-4.5.0/libmudflap/mf-hooks2.c
2===================================================================
3--- gcc-4.5.0.orig/libmudflap/mf-hooks2.c 2009-04-09 08:00:19.000000000 -0700
4+++ gcc-4.5.0/libmudflap/mf-hooks2.c 2010-06-25 10:52:13.937636901 -0700
5@@ -421,7 +421,7 @@
6 {
7 TRACE ("%s\n", __PRETTY_FUNCTION__);
8 MF_VALIDATE_EXTENT(s, n, __MF_CHECK_WRITE, "bzero region");
9- bzero (s, n);
10+ memset (s, 0, n);
11 }
12
13
14@@ -431,7 +431,7 @@
15 TRACE ("%s\n", __PRETTY_FUNCTION__);
16 MF_VALIDATE_EXTENT(src, n, __MF_CHECK_READ, "bcopy src");
17 MF_VALIDATE_EXTENT(dest, n, __MF_CHECK_WRITE, "bcopy dest");
18- bcopy (src, dest, n);
19+ memmove (dest, src, n);
20 }
21
22
23@@ -441,7 +441,7 @@
24 TRACE ("%s\n", __PRETTY_FUNCTION__);
25 MF_VALIDATE_EXTENT(s1, n, __MF_CHECK_READ, "bcmp 1st arg");
26 MF_VALIDATE_EXTENT(s2, n, __MF_CHECK_READ, "bcmp 2nd arg");
27- return bcmp (s1, s2, n);
28+ return n == 0 ? 0 : memcmp (s1, s2, n);
29 }
30
31
32@@ -450,7 +450,7 @@
33 size_t n = strlen (s);
34 TRACE ("%s\n", __PRETTY_FUNCTION__);
35 MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "index region");
36- return index (s, c);
37+ return strchr (s, c);
38 }
39
40
41@@ -459,7 +459,7 @@
42 size_t n = strlen (s);
43 TRACE ("%s\n", __PRETTY_FUNCTION__);
44 MF_VALIDATE_EXTENT(s, CLAMPADD(n, 1), __MF_CHECK_READ, "rindex region");
45- return rindex (s, c);
46+ return strrchr (s, c);
47 }
48
49 /* XXX: stpcpy, memccpy */
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/306-libstdc++-namespace.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/306-libstdc++-namespace.patch
new file mode 100644
index 0000000000..75c7401373
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/306-libstdc++-namespace.patch
@@ -0,0 +1,38 @@
1Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/messages_members.h
2===================================================================
3--- gcc-4.5.0.orig/libstdc++-v3/config/locale/uclibc/messages_members.h 2010-06-25 10:49:07.024632961 -0700
4+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/messages_members.h 2010-06-25 10:52:33.980632645 -0700
5@@ -32,7 +32,8 @@
6 //
7
8 // Written by Benjamin Kosnik <bkoz@redhat.com>
9-
10+namespace std
11+{
12 #ifdef __UCLIBC_MJN3_ONLY__
13 #warning fix prototypes for *textdomain funcs
14 #endif
15@@ -116,3 +117,4 @@
16 this->_S_create_c_locale(this->_M_c_locale_messages, __s);
17 }
18 }
19+}
20Index: gcc-4.5.0/libstdc++-v3/config/locale/uclibc/time_members.h
21===================================================================
22--- gcc-4.5.0.orig/libstdc++-v3/config/locale/uclibc/time_members.h 2010-06-25 10:49:07.024632961 -0700
23+++ gcc-4.5.0/libstdc++-v3/config/locale/uclibc/time_members.h 2010-06-25 10:52:33.980632645 -0700
24@@ -33,7 +33,8 @@
25 //
26
27 // Written by Benjamin Kosnik <bkoz@redhat.com>
28-
29+namespace std
30+{
31 template<typename _CharT>
32 __timepunct<_CharT>::__timepunct(size_t __refs)
33 : facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
34@@ -75,3 +76,4 @@
35 delete _M_data;
36 _S_destroy_c_locale(_M_c_locale_timepunct);
37 }
38+}
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/307-locale_facets.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/307-locale_facets.patch
new file mode 100644
index 0000000000..774fcfa2ca
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/307-locale_facets.patch
@@ -0,0 +1,19 @@
1This patch fixes a bug into ostream::operator<<(double) due to the wrong size
2passed into the __convert_from_v method. The wrong size is then passed to
3std::snprintf function, that, on uClibc, doens't handle sized 0 buffer.
4
5Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
6
7Index: gcc-4.3.1/libstdc++-v3/include/bits/locale_facets.tcc
8===================================================================
9--- gcc-4.3.1.orig/libstdc++-v3/include/bits/locale_facets.tcc 2007-11-26 17:59:41.000000000 -0800
10+++ gcc-4.3.1/libstdc++-v3/include/bits/locale_facets.tcc 2008-08-16 02:14:48.000000000 -0700
11@@ -1004,7 +1004,7 @@
12 const int __cs_size = __fixed ? __max_exp + __prec + 4
13 : __max_digits * 2 + __prec;
14 char* __cs = static_cast<char*>(__builtin_alloca(__cs_size));
15- __len = std::__convert_from_v(_S_get_c_locale(), __cs, 0, __fbuf,
16+ __len = std::__convert_from_v(_S_get_c_locale(), __cs, __cs_size, __fbuf,
17 __prec, __v);
18 #endif
19
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/602-sdk-libstdc++-includes.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/602-sdk-libstdc++-includes.patch
new file mode 100644
index 0000000000..23fce7544d
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/602-sdk-libstdc++-includes.patch
@@ -0,0 +1,20 @@
1--- gcc-4.1.0/libstdc++-v3/fragment.am 2005-03-21 11:40:14.000000000 -0600
2+++ gcc-4.1.0-patched/libstdc++-v3/fragment.am 2005-04-25 20:14:39.856251785 -0500
3@@ -21,5 +21,5 @@
4 $(WARN_FLAGS) $(WERROR) -fdiagnostics-show-location=once
5
6 # -I/-D flags to pass when compiling.
7-AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
8+AM_CPPFLAGS = $(GLIBCXX_INCLUDES) -I$(toplevel_srcdir)/include
9
10--- gcc-4.1.0/libstdc++-v3/libmath/Makefile.am 2005-03-21 11:40:18.000000000 -0600
11+++ gcc-4.1.0-patched/libstdc++-v3/libmath/Makefile.am 2005-04-25 20:14:39.682280735 -0500
12@@ -35,7 +35,7 @@
13
14 libmath_la_SOURCES = stubs.c
15
16-AM_CPPFLAGS = $(CANADIAN_INCLUDES)
17+AM_CPPFLAGS = $(CANADIAN_INCLUDES) -I$(toplevel_srcdir)/include
18
19 # Only compiling "C" sources in this directory.
20 LIBTOOL = @LIBTOOL@ --tag CC
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/64bithack.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/64bithack.patch
new file mode 100644
index 0000000000..067676ab63
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/64bithack.patch
@@ -0,0 +1,33 @@
1By default gcc places 64 bit libs in a lib64 directory. This makes it use
2"lib" instead.
3
4RP 25/7/10
5
6Index: gcc-4.5.0/gcc/config/i386/t-linux64
7===================================================================
8--- gcc-4.5.0.orig/gcc/config/i386/t-linux64 2010-08-10 15:47:42.000000000 +0100
9+++ gcc-4.5.0/gcc/config/i386/t-linux64 2010-08-10 15:47:47.000000000 +0100
10@@ -24,8 +24,8 @@
11 # MULTILIB_OSDIRNAMES according to what is found on the target.
12
13 MULTILIB_OPTIONS = m64/m32
14-MULTILIB_DIRNAMES = 64 32
15-MULTILIB_OSDIRNAMES = ../lib64 $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)
16+MULTILIB_DIRNAMES = . 32
17+MULTILIB_OSDIRNAMES = . $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)
18
19 LIBGCC = stmp-multilib
20 INSTALL_LIBGCC = install-multilib
21Index: gcc-4.5.0/gcc/config/i386/linux64.h
22===================================================================
23--- gcc-4.5.0.orig/gcc/config/i386/linux64.h 2010-08-10 15:49:06.000000000 +0100
24+++ gcc-4.5.0/gcc/config/i386/linux64.h 2010-08-10 15:49:16.000000000 +0100
25@@ -59,7 +59,7 @@
26 done. */
27
28 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
29-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
30+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld-linux-x86-64.so.2"
31
32 #if TARGET_64BIT_DEFAULT
33 #define SPEC_32 "m32"
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/740-sh-pr24836.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/740-sh-pr24836.patch
new file mode 100644
index 0000000000..d84889259d
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/740-sh-pr24836.patch
@@ -0,0 +1,29 @@
1http://sourceforge.net/mailarchive/forum.php?thread_id=8959304&forum_id=5348
2http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24836
3
4Index: gcc-4.5.0/gcc/configure.ac
5===================================================================
6--- gcc-4.5.0.orig/gcc/configure.ac 2010-03-25 22:40:32.000000000 -0700
7+++ gcc-4.5.0/gcc/configure.ac 2010-06-25 11:02:48.489057877 -0700
8@@ -2784,7 +2784,7 @@
9 tls_first_minor=14
10 tls_as_opt="-m64 -Aesame --fatal-warnings"
11 ;;
12- sh-*-* | sh[34]-*-*)
13+ sh-*-* | sh[34]*-*-*)
14 conftest_s='
15 .section ".tdata","awT",@progbits
16 foo: .long 25
17Index: gcc-4.5.0/gcc/configure
18===================================================================
19--- gcc-4.5.0.orig/gcc/configure 2010-03-25 22:40:32.000000000 -0700
20+++ gcc-4.5.0/gcc/configure 2010-06-25 11:02:48.508381845 -0700
21@@ -22156,7 +22156,7 @@
22 tls_first_minor=14
23 tls_as_opt="-m64 -Aesame --fatal-warnings"
24 ;;
25- sh-*-* | sh[34]-*-*)
26+ sh-*-* | sh[34]*-*-*)
27 conftest_s='
28 .section ".tdata","awT",@progbits
29 foo: .long 25
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/800-arm-bigendian.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/800-arm-bigendian.patch
new file mode 100644
index 0000000000..77d02c3abd
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/800-arm-bigendian.patch
@@ -0,0 +1,34 @@
1By Lennert Buytenhek <buytenh@wantstofly.org>
2Adds support for arm*b-linux* big-endian ARM targets
3
4See http://gcc.gnu.org/PR16350
5
6Index: gcc-4.5.0/gcc/config/arm/linux-elf.h
7===================================================================
8--- gcc-4.5.0.orig/gcc/config/arm/linux-elf.h 2009-11-05 06:47:45.000000000 -0800
9+++ gcc-4.5.0/gcc/config/arm/linux-elf.h 2010-06-25 11:03:06.997132728 -0700
10@@ -51,7 +51,7 @@
11
12 #undef MULTILIB_DEFAULTS
13 #define MULTILIB_DEFAULTS \
14- { "marm", "mlittle-endian", "mhard-float", "mno-thumb-interwork" }
15+ { "marm", TARGET_ENDIAN_OPTION, "mhard-float", "mno-thumb-interwork" }
16
17 /* Now we define the strings used to build the spec file. */
18 #undef LIB_SPEC
19Index: gcc-4.5.0/gcc/config.gcc
20===================================================================
21--- gcc-4.5.0.orig/gcc/config.gcc 2010-06-25 10:40:33.321880880 -0700
22+++ gcc-4.5.0/gcc/config.gcc 2010-06-25 11:03:07.013133525 -0700
23@@ -734,6 +734,11 @@
24 esac
25 tmake_file="${tmake_file} t-linux arm/t-arm"
26 case ${target} in
27+ arm*b-*)
28+ tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1"
29+ ;;
30+ esac
31+ case ${target} in
32 arm*-*-linux-*eabi)
33 tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h"
34 tmake_file="$tmake_file arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi t-slibgcc-libgcc"
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/904-flatten-switch-stmt-00.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/904-flatten-switch-stmt-00.patch
new file mode 100644
index 0000000000..c4641dc63e
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/904-flatten-switch-stmt-00.patch
@@ -0,0 +1,74 @@
1Hi,
2
3The attached patch makes sure that we create smaller object code for
4simple switch statements. We just make sure to flatten the switch
5statement into an if-else chain, basically.
6
7This fixes a size-regression as compared to gcc-3.4, as can be seen
8below.
9
102007-04-15 Bernhard Fischer <..>
11
12 * stmt.c (expand_case): Do not create a complex binary tree when
13 optimizing for size but rather use the simple ordered list.
14 (emit_case_nodes): do not emit jumps to the default_label when
15 optimizing for size.
16
17Not regtested so far.
18Comments?
19
20Attached is the test switch.c mentioned below.
21
22$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
23gcc-$i -DCHAIN -Os -o switch-CHAIN-$i.o -c switch.c ;done
24$ for i in 2.95 3.3 3.4 4.0 4.1 4.2.orig-HEAD 4.3.orig-HEAD 4.3-HEAD;do
25gcc-$i -UCHAIN -Os -o switch-$i.o -c switch.c ;done
26
27$ size switch-*.o
28 text data bss dec hex filename
29 169 0 0 169 a9 switch-2.95.o
30 115 0 0 115 73 switch-3.3.o
31 103 0 0 103 67 switch-3.4.o
32 124 0 0 124 7c switch-4.0.o
33 124 0 0 124 7c switch-4.1.o
34 124 0 0 124 7c switch-4.2.orig-HEAD.o
35 95 0 0 95 5f switch-4.3-HEAD.o
36 124 0 0 124 7c switch-4.3.orig-HEAD.o
37 166 0 0 166 a6 switch-CHAIN-2.95.o
38 111 0 0 111 6f switch-CHAIN-3.3.o
39 95 0 0 95 5f switch-CHAIN-3.4.o
40 95 0 0 95 5f switch-CHAIN-4.0.o
41 95 0 0 95 5f switch-CHAIN-4.1.o
42 95 0 0 95 5f switch-CHAIN-4.2.orig-HEAD.o
43 95 0 0 95 5f switch-CHAIN-4.3-HEAD.o
44 95 0 0 95 5f switch-CHAIN-4.3.orig-HEAD.o
45
46
47Content-Type: text/x-diff; charset=us-ascii
48Content-Disposition: attachment; filename="gcc-4.3.gcc-flatten-switch-stmt.00.diff"
49
50Index: gcc-4.5.0/gcc/stmt.c
51===================================================================
52--- gcc-4.5.0.orig/gcc/stmt.c 2010-02-19 01:53:51.000000000 -0800
53+++ gcc-4.5.0/gcc/stmt.c 2010-06-25 11:05:31.816881094 -0700
54@@ -2440,7 +2440,11 @@
55 default code is emitted. */
56
57 use_cost_table = estimate_case_costs (case_list);
58- balance_case_nodes (&case_list, NULL);
59+ /* When optimizing for size, we want a straight list to avoid
60+ jumps as much as possible. This basically creates an if-else
61+ chain. */
62+ if (!optimize_size)
63+ balance_case_nodes (&case_list, NULL);
64 emit_case_nodes (index, case_list, default_label, index_type);
65 if (default_label)
66 emit_jump (default_label);
67@@ -3008,6 +3012,7 @@
68 {
69 if (!node_has_low_bound (node, index_type))
70 {
71+ if (!optimize_size) /* don't jl to the .default_label. */
72 emit_cmp_and_jump_insns (index,
73 convert_modes
74 (mode, imode,
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/arm-bswapsi2.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/arm-bswapsi2.patch
new file mode 100644
index 0000000000..7ac61a6d63
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/arm-bswapsi2.patch
@@ -0,0 +1,13 @@
1Index: gcc-4.5/gcc/config/arm/arm.md
2===================================================================
3--- gcc-4.5.orig/gcc/config/arm/arm.md 2010-06-17 09:13:07.000000000 -0700
4+++ gcc-4.5/gcc/config/arm/arm.md 2010-06-22 08:08:45.397212002 -0700
5@@ -11267,7 +11267,7 @@
6 (define_expand "bswapsi2"
7 [(set (match_operand:SI 0 "s_register_operand" "=r")
8 (bswap:SI (match_operand:SI 1 "s_register_operand" "r")))]
9-"TARGET_EITHER"
10+"TARGET_EITHER && (arm_arch6 && !optimize_size)"
11 "
12 if (!arm_arch6)
13 {
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/arm-nolibfloat.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/arm-nolibfloat.patch
new file mode 100644
index 0000000000..99f2b20d50
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/arm-nolibfloat.patch
@@ -0,0 +1,24 @@
1# Dimitry Andric <dimitry@andric.com>, 2004-05-01
2#
3# * Removed the extra -lfloat option from LIBGCC_SPEC, since it isn't needed
4# anymore. (The required functions are now in libgcc.)
5#
6# Fixes errors like
7# arm-softfloat-linux-gnu/3.4.0/../../../../arm-softfloat-linux-gnu/bin/ld: cannot find -lfloat
8# collect2: ld returned 1 exit status
9# make[2]: *** [arm-softfloat-linux-gnu/gcc-3.4.0-glibc-2.3.2/build-glibc/iconvdata/ISO8859-1.so] Error 1
10# when building glibc-2.3.3 with gcc-3.4.0 for arm-softfloat
11
12Index: gcc-4.5.0/gcc/config/arm/linux-elf.h
13===================================================================
14--- gcc-4.5.0.orig/gcc/config/arm/linux-elf.h 2010-06-25 11:04:49.572437901 -0700
15+++ gcc-4.5.0/gcc/config/arm/linux-elf.h 2010-06-25 11:06:12.273162283 -0700
16@@ -60,7 +60,7 @@
17 %{shared:-lc} \
18 %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
19
20-#define LIBGCC_SPEC "%{msoft-float:-lfloat} %{mfloat-abi=soft*:-lfloat} -lgcc"
21+#define LIBGCC_SPEC "-lgcc"
22
23 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
24
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/arm-softfloat.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/arm-softfloat.patch
new file mode 100644
index 0000000000..181d4fbf5a
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/arm-softfloat.patch
@@ -0,0 +1,16 @@
1Index: gcc-4.5.0/gcc/config/arm/t-linux
2===================================================================
3--- gcc-4.5.0.orig/gcc/config/arm/t-linux 2009-04-21 12:03:23.000000000 -0700
4+++ gcc-4.5.0/gcc/config/arm/t-linux 2010-06-25 11:11:06.836381365 -0700
5@@ -23,7 +23,10 @@
6
7 LIB1ASMSRC = arm/lib1funcs.asm
8 LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_lnx _clzsi2 _clzdi2 \
9- _arm_addsubdf3 _arm_addsubsf3
10+ _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
11+ _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
12+ _fixsfsi _fixunssfsi _floatdidf _floatdisf _floatundisf _floatundidf
13+# _arm_addsubdf3 _arm_addsubsf3
14
15 # MULTILIB_OPTIONS = mhard-float/msoft-float
16 # MULTILIB_DIRNAMES = hard-float soft-float
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/arm-unbreak-eabi-armv4t.dpatch b/meta/recipes-devtools/gcc/gcc-4.5.0/arm-unbreak-eabi-armv4t.dpatch
new file mode 100644
index 0000000000..7bb8887068
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/arm-unbreak-eabi-armv4t.dpatch
@@ -0,0 +1,36 @@
1#! /bin/sh -e
2
3# DP: Fix armv4t build on ARM
4
5dir=
6if [ $# -eq 3 -a "$2" = '-d' ]; then
7 pdir="-d $3"
8 dir="$3/"
9elif [ $# -ne 1 ]; then
10 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
11 exit 1
12fi
13case "$1" in
14 -patch)
15 patch $pdir -f --no-backup-if-mismatch -p1 < $0
16 ;;
17 -unpatch)
18 patch $pdir -f --no-backup-if-mismatch -R -p1 < $0
19 ;;
20 *)
21 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
22 exit 1
23esac
24exit 0
25
26--- src/gcc/config/arm/linux-eabi.h.orig 2007-11-24 12:37:38.000000000 +0000
27+++ src/gcc/config/arm/linux-eabi.h 2007-11-24 12:39:41.000000000 +0000
28@@ -44,7 +44,7 @@
29 The ARM10TDMI core is the default for armv5t, so set
30 SUBTARGET_CPU_DEFAULT to achieve this. */
31 #undef SUBTARGET_CPU_DEFAULT
32-#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm10tdmi
33+#define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm9tdmi
34
35 /* TARGET_BIG_ENDIAN_DEFAULT is set in
36 config.gcc for big endian configurations. */
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/cache-amnesia.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/cache-amnesia.patch
new file mode 100644
index 0000000000..b889f9b6ca
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/cache-amnesia.patch
@@ -0,0 +1,31 @@
1---
2 gcc/configure | 2 +-
3 gcc/configure.ac | 2 +-
4 2 files changed, 2 insertions(+), 2 deletions(-)
5
6Index: gcc-4.5+svnr155514/gcc/configure
7===================================================================
8--- gcc-4.5+svnr155514.orig/gcc/configure 2009-12-29 22:00:40.000000000 -0800
9+++ gcc-4.5+svnr155514/gcc/configure 2009-12-29 23:52:43.381592113 -0800
10@@ -10467,7 +10467,7 @@ else
11 saved_CFLAGS="${CFLAGS}"
12 CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
13 LDFLAGS="${LDFLAGS_FOR_BUILD}" \
14- ${realsrcdir}/configure \
15+ CONFIG_SITE= ${realsrcdir}/configure --cache-file=./other.cache \
16 --enable-languages=${enable_languages-all} \
17 --target=$target_alias --host=$build_alias --build=$build_alias
18 CFLAGS="${saved_CFLAGS}"
19Index: gcc-4.5+svnr155514/gcc/configure.ac
20===================================================================
21--- gcc-4.5+svnr155514.orig/gcc/configure.ac 2009-12-29 22:00:40.000000000 -0800
22+++ gcc-4.5+svnr155514/gcc/configure.ac 2009-12-29 23:51:54.589091778 -0800
23@@ -1458,7 +1458,7 @@ else
24 saved_CFLAGS="${CFLAGS}"
25 CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
26 LDFLAGS="${LDFLAGS_FOR_BUILD}" \
27- ${realsrcdir}/configure \
28+ CONFIG_SITE= ${realsrcdir}/configure --cache-file=./other.cache \
29 --enable-languages=${enable_languages-all} \
30 --target=$target_alias --host=$build_alias --build=$build_alias
31 CFLAGS="${saved_CFLAGS}"
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-c++-builtin-redecl.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-c++-builtin-redecl.patch
new file mode 100644
index 0000000000..a149eae98e
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-c++-builtin-redecl.patch
@@ -0,0 +1,114 @@
12007-10-02 Jakub Jelinek <jakub@redhat.com>
2
3 * decl.c (duplicate_decls): When redeclaring a builtin function,
4 keep the merged decl builtin whenever types match, even if new
5 decl defines a function.
6
7 * gcc.dg/builtins-65.c: New test.
8 * g++.dg/ext/builtin10.C: New test.
9
10Index: gcc/cp/decl.c
11===================================================================
12--- gcc/cp/decl.c.orig 2010-04-01 11:48:46.000000000 -0700
13+++ gcc/cp/decl.c 2010-06-25 10:10:54.749131719 -0700
14@@ -2021,23 +2021,21 @@
15 DECL_ARGUMENTS (olddecl) = DECL_ARGUMENTS (newdecl);
16 DECL_RESULT (olddecl) = DECL_RESULT (newdecl);
17 }
18+ /* If redeclaring a builtin function, it stays built in. */
19+ if (types_match && DECL_BUILT_IN (olddecl))
20+ {
21+ DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
22+ DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
23+ /* If we're keeping the built-in definition, keep the rtl,
24+ regardless of declaration matches. */
25+ COPY_DECL_RTL (olddecl, newdecl);
26+ }
27 if (new_defines_function)
28 /* If defining a function declared with other language
29 linkage, use the previously declared language linkage. */
30 SET_DECL_LANGUAGE (newdecl, DECL_LANGUAGE (olddecl));
31 else if (types_match)
32 {
33- /* If redeclaring a builtin function, and not a definition,
34- it stays built in. */
35- if (DECL_BUILT_IN (olddecl))
36- {
37- DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
38- DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
39- /* If we're keeping the built-in definition, keep the rtl,
40- regardless of declaration matches. */
41- COPY_DECL_RTL (olddecl, newdecl);
42- }
43-
44 DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
45 /* Don't clear out the arguments if we're just redeclaring a
46 function. */
47Index: gcc/testsuite/gcc.dg/builtins-65.c
48===================================================================
49--- gcc/testsuite/gcc.dg/builtins-65.c.orig 2009-06-26 02:02:04.000000000 -0700
50+++ gcc/testsuite/gcc.dg/builtins-65.c 2010-06-25 10:10:54.784464429 -0700
51@@ -1,3 +1,28 @@
52+/* { dg-do compile } */
53+/* { dg-options "-O2" } */
54+
55+typedef __SIZE_TYPE__ size_t;
56+extern void __chk_fail (void);
57+extern int snprintf (char *, size_t, const char *, ...);
58+extern inline __attribute__((gnu_inline, always_inline)) int snprintf (char *a, size_t b, const char *fmt, ...)
59+{
60+ if (__builtin_object_size (a, 0) != -1UL && __builtin_object_size (a, 0) < b)
61+ __chk_fail ();
62+ return __builtin_snprintf (a, b, fmt, __builtin_va_arg_pack ());
63+}
64+extern int snprintf (char *, size_t, const char *, ...) __asm ("mysnprintf");
65+
66+char buf[10];
67+
68+int
69+main (void)
70+{
71+ snprintf (buf, 10, "%d%d\n", 10, 10);
72+ return 0;
73+}
74+
75+/* { dg-final { scan-assembler "mysnprintf" } } */
76+/* { dg-final { scan-assembler-not "__chk_fail" } } */
77 /* { dg-do link } */
78 /* { dg-options "-O2 -ffast-math" } */
79 /* { dg-require-effective-target c99_runtime } */
80Index: gcc/testsuite/g++.dg/ext/builtin10.C
81===================================================================
82--- gcc/testsuite/g++.dg/ext/builtin10.C.orig 2009-02-02 03:27:50.000000000 -0800
83+++ gcc/testsuite/g++.dg/ext/builtin10.C 2010-06-25 10:10:54.816467202 -0700
84@@ -1,3 +1,30 @@
85+// { dg-do compile }
86+// { dg-options "-O2" }
87+
88+typedef __SIZE_TYPE__ size_t;
89+extern "C" {
90+extern void __chk_fail (void);
91+extern int snprintf (char *, size_t, const char *, ...);
92+extern inline __attribute__((gnu_inline, always_inline)) int snprintf (char *a, size_t b, const char *fmt, ...)
93+{
94+ if (__builtin_object_size (a, 0) != -1UL && __builtin_object_size (a, 0) < b)
95+ __chk_fail ();
96+ return __builtin_snprintf (a, b, fmt, __builtin_va_arg_pack ());
97+}
98+extern int snprintf (char *, size_t, const char *, ...) __asm ("mysnprintf");
99+}
100+
101+char buf[10];
102+
103+int
104+main (void)
105+{
106+ snprintf (buf, 10, "%d%d\n", 10, 10);
107+ return 0;
108+}
109+
110+// { dg-final { scan-assembler "mysnprintf" } }
111+// { dg-final { scan-assembler-not "__chk_fail" } }
112 // { dg-do compile { target correct_iso_cpp_string_wchar_protos } }
113 // { dg-options "-O2 -fdump-tree-optimized" }
114
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-cpp-pragma.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-cpp-pragma.patch
new file mode 100644
index 0000000000..00d37bd7ce
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-cpp-pragma.patch
@@ -0,0 +1,284 @@
12008-02-26 Jakub Jelinek <jakub@redhat.com>
2
3 * c-ppoutput.c (scan_translation_unit): Handle CPP_PRAGMA
4 and CPP_PRAGMA_EOL.
5 * c-pragma.c (pragma_ns_name): New typedef.
6 (registered_pp_pragmas): New variable.
7 (c_pp_lookup_pragma): New function.
8 (c_register_pragma_1): If flag_preprocess_only, do nothing
9 for non-expanded pragmas, for expanded ones push pragma's
10 namespace and name into registered_pp_pragmas vector.
11 (c_invoke_pragma_handler): Register OpenMP pragmas even when
12 flag_preprocess_only, don't register GCC pch_preprocess
13 pragma if flag_preprocess_only.
14 * c-opts.c (c_common_init): Call init_pragma even if
15 flag_preprocess_only.
16 * c-pragma.c (c_pp_lookup_pragma): New prototype.
17 * config/darwin.h (DARWIN_REGISTER_TARGET_PRAGMAS): Don't call
18 cpp_register_pragma if flag_preprocess_only.
19
20 * gcc.dg/gomp/preprocess-1.c: New test.
21
22--- gcc/c-ppoutput.c.jj 2008-01-26 18:01:16.000000000 +0100
23+++ gcc/c-ppoutput.c 2008-02-26 22:54:57.000000000 +0100
24@@ -1,6 +1,6 @@
25 /* Preprocess only, using cpplib.
26- Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007
27- Free Software Foundation, Inc.
28+ Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007,
29+ 2008 Free Software Foundation, Inc.
30 Written by Per Bothner, 1994-95.
31
32 This program is free software; you can redistribute it and/or modify it
33@@ -177,7 +177,24 @@ scan_translation_unit (cpp_reader *pfile
34 avoid_paste = false;
35 print.source = NULL;
36 print.prev = token;
37- cpp_output_token (token, print.outf);
38+ if (token->type == CPP_PRAGMA)
39+ {
40+ const char *space;
41+ const char *name;
42+
43+ maybe_print_line (token->src_loc);
44+ fputs ("#pragma ", print.outf);
45+ c_pp_lookup_pragma (token->val.pragma, &space, &name);
46+ if (space)
47+ fprintf (print.outf, "%s %s", space, name);
48+ else
49+ fprintf (print.outf, "%s", name);
50+ print.printed = 1;
51+ }
52+ else if (token->type == CPP_PRAGMA_EOL)
53+ maybe_print_line (token->src_loc);
54+ else
55+ cpp_output_token (token, print.outf);
56
57 if (token->type == CPP_COMMENT)
58 account_for_newlines (token->val.str.text, token->val.str.len);
59--- gcc/c-pragma.c.jj 2008-02-15 18:43:03.000000000 +0100
60+++ gcc/c-pragma.c 2008-02-26 22:59:44.000000000 +0100
61@@ -1,6 +1,6 @@
62 /* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
63 Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
64- 2006, 2007 Free Software Foundation, Inc.
65+ 2006, 2007, 2008 Free Software Foundation, Inc.
66
67 This file is part of GCC.
68
69@@ -872,6 +872,61 @@ DEF_VEC_ALLOC_O (pragma_handler, heap);
70
71 static VEC(pragma_handler, heap) *registered_pragmas;
72
73+typedef struct
74+{
75+ const char *space;
76+ const char *name;
77+} pragma_ns_name;
78+
79+DEF_VEC_O (pragma_ns_name);
80+DEF_VEC_ALLOC_O (pragma_ns_name, heap);
81+
82+static VEC(pragma_ns_name, heap) *registered_pp_pragmas;
83+
84+struct omp_pragma_def { const char *name; unsigned int id; };
85+static const struct omp_pragma_def omp_pragmas[] = {
86+ { "atomic", PRAGMA_OMP_ATOMIC },
87+ { "barrier", PRAGMA_OMP_BARRIER },
88+ { "critical", PRAGMA_OMP_CRITICAL },
89+ { "flush", PRAGMA_OMP_FLUSH },
90+ { "for", PRAGMA_OMP_FOR },
91+ { "master", PRAGMA_OMP_MASTER },
92+ { "ordered", PRAGMA_OMP_ORDERED },
93+ { "parallel", PRAGMA_OMP_PARALLEL },
94+ { "section", PRAGMA_OMP_SECTION },
95+ { "sections", PRAGMA_OMP_SECTIONS },
96+ { "single", PRAGMA_OMP_SINGLE },
97+ { "threadprivate", PRAGMA_OMP_THREADPRIVATE }
98+};
99+
100+void
101+c_pp_lookup_pragma (unsigned int id, const char **space, const char **name)
102+{
103+ const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
104+ int i;
105+
106+ for (i = 0; i < n_omp_pragmas; ++i)
107+ if (omp_pragmas[i].id == id)
108+ {
109+ *space = "omp";
110+ *name = omp_pragmas[i].name;
111+ return;
112+ }
113+
114+ if (id >= PRAGMA_FIRST_EXTERNAL
115+ && (id < PRAGMA_FIRST_EXTERNAL
116+ + VEC_length (pragma_ns_name, registered_pp_pragmas)))
117+ {
118+ *space = VEC_index (pragma_ns_name, registered_pp_pragmas,
119+ id - PRAGMA_FIRST_EXTERNAL)->space;
120+ *name = VEC_index (pragma_ns_name, registered_pp_pragmas,
121+ id - PRAGMA_FIRST_EXTERNAL)->name;
122+ return;
123+ }
124+
125+ gcc_unreachable ();
126+}
127+
128 /* Front-end wrappers for pragma registration to avoid dragging
129 cpplib.h in almost everywhere. */
130
131@@ -881,13 +936,29 @@ c_register_pragma_1 (const char *space,
132 {
133 unsigned id;
134
135- VEC_safe_push (pragma_handler, heap, registered_pragmas, &handler);
136- id = VEC_length (pragma_handler, registered_pragmas);
137- id += PRAGMA_FIRST_EXTERNAL - 1;
138-
139- /* The C++ front end allocates 6 bits in cp_token; the C front end
140- allocates 7 bits in c_token. At present this is sufficient. */
141- gcc_assert (id < 64);
142+ if (flag_preprocess_only)
143+ {
144+ pragma_ns_name ns_name;
145+
146+ if (!allow_expansion)
147+ return;
148+
149+ ns_name.space = space;
150+ ns_name.name = name;
151+ VEC_safe_push (pragma_ns_name, heap, registered_pp_pragmas, &ns_name);
152+ id = VEC_length (pragma_ns_name, registered_pp_pragmas);
153+ id += PRAGMA_FIRST_EXTERNAL - 1;
154+ }
155+ else
156+ {
157+ VEC_safe_push (pragma_handler, heap, registered_pragmas, &handler);
158+ id = VEC_length (pragma_handler, registered_pragmas);
159+ id += PRAGMA_FIRST_EXTERNAL - 1;
160+
161+ /* The C++ front end allocates 6 bits in cp_token; the C front end
162+ allocates 7 bits in c_token. At present this is sufficient. */
163+ gcc_assert (id < 64);
164+ }
165
166 cpp_register_deferred_pragma (parse_in, space, name, id,
167 allow_expansion, false);
168@@ -921,24 +992,8 @@ c_invoke_pragma_handler (unsigned int id
169 void
170 init_pragma (void)
171 {
172- if (flag_openmp && !flag_preprocess_only)
173+ if (flag_openmp)
174 {
175- struct omp_pragma_def { const char *name; unsigned int id; };
176- static const struct omp_pragma_def omp_pragmas[] = {
177- { "atomic", PRAGMA_OMP_ATOMIC },
178- { "barrier", PRAGMA_OMP_BARRIER },
179- { "critical", PRAGMA_OMP_CRITICAL },
180- { "flush", PRAGMA_OMP_FLUSH },
181- { "for", PRAGMA_OMP_FOR },
182- { "master", PRAGMA_OMP_MASTER },
183- { "ordered", PRAGMA_OMP_ORDERED },
184- { "parallel", PRAGMA_OMP_PARALLEL },
185- { "section", PRAGMA_OMP_SECTION },
186- { "sections", PRAGMA_OMP_SECTIONS },
187- { "single", PRAGMA_OMP_SINGLE },
188- { "threadprivate", PRAGMA_OMP_THREADPRIVATE }
189- };
190-
191 const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
192 int i;
193
194@@ -947,8 +1002,9 @@ init_pragma (void)
195 omp_pragmas[i].id, true, true);
196 }
197
198- cpp_register_deferred_pragma (parse_in, "GCC", "pch_preprocess",
199- PRAGMA_GCC_PCH_PREPROCESS, false, false);
200+ if (!flag_preprocess_only)
201+ cpp_register_deferred_pragma (parse_in, "GCC", "pch_preprocess",
202+ PRAGMA_GCC_PCH_PREPROCESS, false, false);
203
204 #ifdef HANDLE_PRAGMA_PACK
205 #ifdef HANDLE_PRAGMA_PACK_WITH_EXPANSION
206--- gcc/c-opts.c.jj 2008-02-26 22:53:23.000000000 +0100
207+++ gcc/c-opts.c 2008-02-26 22:54:57.000000000 +0100
208@@ -1,5 +1,5 @@
209 /* C/ObjC/C++ command line option handling.
210- Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007
211+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
212 Free Software Foundation, Inc.
213 Contributed by Neil Booth.
214
215@@ -1239,6 +1239,9 @@ c_common_init (void)
216 if (version_flag)
217 c_common_print_pch_checksum (stderr);
218
219+ /* Has to wait until now so that cpplib has its hash table. */
220+ init_pragma ();
221+
222 if (flag_preprocess_only)
223 {
224 finish_options ();
225@@ -1246,9 +1249,6 @@ c_common_init (void)
226 return false;
227 }
228
229- /* Has to wait until now so that cpplib has its hash table. */
230- init_pragma ();
231-
232 return true;
233 }
234
235--- gcc/c-pragma.h.jj 2008-01-26 18:01:16.000000000 +0100
236+++ gcc/c-pragma.h 2008-02-26 22:54:57.000000000 +0100
237@@ -1,6 +1,6 @@
238 /* Pragma related interfaces.
239 Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
240- 2007 Free Software Foundation, Inc.
241+ 2007, 2008 Free Software Foundation, Inc.
242
243 This file is part of GCC.
244
245@@ -124,4 +124,6 @@ extern enum cpp_ttype pragma_lex (tree *
246 extern enum cpp_ttype c_lex_with_flags (tree *, location_t *, unsigned char *,
247 int);
248
249+extern void c_pp_lookup_pragma (unsigned int, const char **, const char **);
250+
251 #endif /* GCC_C_PRAGMA_H */
252--- gcc/config/darwin.h.jj 2008-02-11 14:48:12.000000000 +0100
253+++ gcc/config/darwin.h 2008-02-26 22:54:57.000000000 +0100
254@@ -892,8 +892,9 @@ enum machopic_addr_class {
255
256 #define DARWIN_REGISTER_TARGET_PRAGMAS() \
257 do { \
258- cpp_register_pragma (parse_in, NULL, "mark", \
259- darwin_pragma_ignore, false); \
260+ if (!flag_preprocess_only) \
261+ cpp_register_pragma (parse_in, NULL, "mark", \
262+ darwin_pragma_ignore, false); \
263 c_register_pragma (0, "options", darwin_pragma_options); \
264 c_register_pragma (0, "segment", darwin_pragma_ignore); \
265 c_register_pragma (0, "unused", darwin_pragma_unused); \
266--- gcc/testsuite/gcc.dg/gomp/preprocess-1.c.jj 2008-02-26 22:54:57.000000000 +0100
267+++ gcc/testsuite/gcc.dg/gomp/preprocess-1.c 2008-02-26 22:54:57.000000000 +0100
268@@ -0,0 +1,16 @@
269+/* { dg-do preprocess } */
270+
271+void foo (void)
272+{
273+ int i1, j1, k1;
274+#define p parallel
275+#define P(x) private (x##1)
276+#define S(x) shared (x##1)
277+#define F(x) firstprivate (x##1)
278+#pragma omp p P(i) \
279+ S(j) \
280+ F(k)
281+ ;
282+}
283+
284+/* { dg-final { scan-file preprocess-1.i "(^|\n)#pragma omp parallel private \\(i1\\) shared \\(j1\\) firstprivate \\(k1\\)($|\n)" } } */
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-i386-libgomp.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-i386-libgomp.patch
new file mode 100644
index 0000000000..a588db28e8
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-i386-libgomp.patch
@@ -0,0 +1,65 @@
1Build i386.rpm libgomp and libsupc++.a(guard.o) as i486+, pre-i486
2hardware isn't supported because NPTL doesn't support it anyway.
3
4Index: libgomp/configure.tgt
5===================================================================
6--- libgomp/configure.tgt.orig 2010-01-28 13:47:59.000000000 -0800
7+++ libgomp/configure.tgt 2010-06-25 10:32:26.706135558 -0700
8@@ -48,14 +48,14 @@
9 ;;
10
11 # Note that bare i386 is not included here. We need cmpxchg.
12- i[456]86-*-linux*)
13+ i[3456]86-*-linux*)
14 config_path="linux/x86 linux posix"
15 case " ${CC} ${CFLAGS} " in
16 *" -m64 "*)
17 ;;
18 *)
19 if test -z "$with_arch"; then
20- XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
21+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
22 fi
23 esac
24 ;;
25@@ -67,7 +67,7 @@
26 config_path="linux/x86 linux posix"
27 case " ${CC} ${CFLAGS} " in
28 *" -m32 "*)
29- XCFLAGS="${XCFLAGS} -march=i486 -mtune=i686"
30+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
31 ;;
32 esac
33 ;;
34Index: libstdc++-v3/libsupc++/guard.cc
35===================================================================
36--- libstdc++-v3/libsupc++/guard.cc.orig 2009-11-09 14:09:30.000000000 -0800
37+++ libstdc++-v3/libsupc++/guard.cc 2010-06-25 10:32:26.710135964 -0700
38@@ -30,6 +30,27 @@
39 #include <new>
40 #include <ext/atomicity.h>
41 #include <ext/concurrence.h>
42+#if defined __i386__ && !defined _GLIBCXX_ATOMIC_BUILTINS
43+# define _GLIBCXX_ATOMIC_BUILTINS 1
44+# define __sync_val_compare_and_swap(a, b, c) \
45+ ({ \
46+ typedef char sltast[sizeof (*a) == sizeof (int) ? 1 : -1]; \
47+ int sltas; \
48+ __asm __volatile ("lock; cmpxchgl %3, (%1)" \
49+ : "=a" (sltas) \
50+ : "r" (a), "0" (b), "r" (c) : "memory"); \
51+ sltas; \
52+ })
53+# define __sync_lock_test_and_set(a, b) \
54+ ({ \
55+ typedef char sltast[sizeof (*a) == sizeof (int) ? 1 : -1]; \
56+ int sltas; \
57+ __asm __volatile ("xchgl (%1), %0" \
58+ : "=r" (sltas) \
59+ : "r" (a), "0" (b) : "memory"); \
60+ sltas; \
61+ })
62+#endif
63 #if defined(__GTHREADS) && defined(__GTHREAD_HAS_COND) \
64 && defined(_GLIBCXX_ATOMIC_BUILTINS_4) && defined(_GLIBCXX_HAVE_LINUX_FUTEX)
65 # include <climits>
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-ia64-libunwind.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-ia64-libunwind.patch
new file mode 100644
index 0000000000..cad13d1228
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-ia64-libunwind.patch
@@ -0,0 +1,550 @@
12004-11-27 Jakub Jelinek <jakub@redhat.com>
2
3 * config.gcc (ia64*-*-linux*): If native and libelf is installed,
4 use ia64/t-glibc-no-libunwind instead of the other t-*unwind*
5 fragments.
6 * config/ia64/t-glibc-no-libunwind: New file.
7 * config/ia64/change-symver.c: New file.
8 * config/ia64/unwind-ia64.c: If USE_SYMVER_GLOBAL and SHARED,
9 define _Unwind_* to __symverglobal_Unwind_*.
10 (alias): Undefine.
11 (symverglobal): Define. Use it on _Unwind_*.
12 * config/ia64/mkmap-symver-multi.awk: New file.
13 * config/ia64/libgcc-ia64-no-libunwind.ver: New file.
14
15Index: gcc/config.gcc
16===================================================================
17--- gcc/config.gcc.orig 2010-04-07 03:34:00.000000000 -0700
18+++ gcc/config.gcc 2010-06-25 10:15:25.133131055 -0700
19@@ -1457,9 +1457,16 @@
20 ;;
21 ia64*-*-linux*)
22 tm_file="${tm_file} dbxelf.h elfos.h svr4.h linux.h glibc-stdint.h ia64/sysv4.h ia64/linux.h"
23- tmake_file="${tmake_file} ia64/t-ia64 t-libunwind ia64/t-glibc"
24- if test x$with_system_libunwind != xyes ; then
25- tmake_file="${tmake_file} t-libunwind-elf ia64/t-glibc-libunwind"
26+ tmake_file="${tmake_file} ia64/t-ia64"
27+ if test x${target} = x${host} && test x${target} = x${build} \
28+ && grep gelf_getverdef /usr/include/gelf.h > /dev/null 2>&1 \
29+ && test -f /usr/lib/libelf.so; then
30+ tmake_file="${tmake_file} ia64/t-glibc-no-libunwind"
31+ else
32+ tmake_file="${tmake_file} t-libunwind ia64/t-glibc"
33+ if test x$with_system_libunwind != xyes ; then
34+ tmake_file="${tmake_file} t-libunwind-elf ia64/t-glibc-libunwind"
35+ fi
36 fi
37 target_cpu_default="MASK_GNU_AS|MASK_GNU_LD"
38 extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtfastmath.o"
39Index: gcc/config/ia64/t-glibc-no-libunwind
40===================================================================
41--- /dev/null 1970-01-01 00:00:00.000000000 +0000
42+++ gcc/config/ia64/t-glibc-no-libunwind 2010-06-25 10:14:32.521880765 -0700
43@@ -0,0 +1,30 @@
44+# Don't use system libunwind library on IA-64 GLIBC based system,
45+# but make _Unwind_* symbols unversioned, so that created programs
46+# are usable even when libgcc_s uses libunwind.
47+LIB2ADDEH += $(srcdir)/config/ia64/fde-glibc.c
48+SHLIB_MAPFILES += $(srcdir)/config/ia64/libgcc-ia64-no-libunwind.ver
49+SHLIB_MKMAP = $(srcdir)/config/ia64/mkmap-symver-multi.awk
50+
51+SHLIB_LINK = $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
52+ -Wl,--soname=$(SHLIB_SONAME) \
53+ -Wl,--version-script=$(SHLIB_MAP) \
54+ -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ $(SHLIB_OBJS) -lc && \
55+ rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
56+ if [ -f $(SHLIB_DIR)/$(SHLIB_SONAME) ]; then \
57+ mv -f $(SHLIB_DIR)/$(SHLIB_SONAME) \
58+ $(SHLIB_DIR)/$(SHLIB_SONAME).backup; \
59+ else true; fi && \
60+ gcc -O2 -o $(SHLIB_DIR)/$(SHLIB_SONAME).tweak \
61+ $$(gcc_srcdir)/config/ia64/change-symver.c -lelf && \
62+ $(SHLIB_DIR)/$(SHLIB_SONAME).tweak $(SHLIB_DIR)/$(SHLIB_SONAME).tmp \
63+ GCC_3.4.2 _GLOBAL_ \
64+ _Unwind_GetGR _Unwind_RaiseException _Unwind_GetRegionStart _Unwind_SetIP \
65+ _Unwind_GetIP _Unwind_GetLanguageSpecificData _Unwind_Resume \
66+ _Unwind_DeleteException _Unwind_SetGR _Unwind_ForcedUnwind \
67+ _Unwind_Backtrace _Unwind_FindEnclosingFunction _Unwind_GetCFA \
68+ _Unwind_Resume_or_Rethrow _Unwind_GetBSP && \
69+ rm -f $(SHLIB_DIR)/$(SHLIB_SONAME).tweak && \
70+ mv $(SHLIB_DIR)/$(SHLIB_SONAME).tmp $(SHLIB_DIR)/$(SHLIB_SONAME) && \
71+ $(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK)
72+
73+TARGET_LIBGCC2_CFLAGS += -DUSE_SYMVER_GLOBAL
74Index: gcc/config/ia64/change-symver.c
75===================================================================
76--- /dev/null 1970-01-01 00:00:00.000000000 +0000
77+++ gcc/config/ia64/change-symver.c 2010-06-25 10:14:32.521880765 -0700
78@@ -0,0 +1,211 @@
79+#define _GNU_SOURCE 1
80+#define _FILE_OFFSET_BITS 64
81+#include <endian.h>
82+#include <errno.h>
83+#include <error.h>
84+#include <fcntl.h>
85+#include <fnmatch.h>
86+#include <gelf.h>
87+#include <stdlib.h>
88+#include <string.h>
89+#include <unistd.h>
90+
91+int
92+compute_veridx (const char *name, Elf *elf, Elf_Data *verd, GElf_Shdr *verd_shdr)
93+{
94+ if (strcmp (name, "_GLOBAL_") == 0)
95+ return 1;
96+
97+ int cnt;
98+ size_t offset = 0;
99+ for (cnt = verd_shdr->sh_info; --cnt >= 0; )
100+ {
101+ GElf_Verdef defmem;
102+ GElf_Verdef *def;
103+ GElf_Verdaux auxmem;
104+ GElf_Verdaux *aux;
105+ unsigned int auxoffset;
106+
107+ /* Get the data at the next offset. */
108+ def = gelf_getverdef (verd, offset, &defmem);
109+ if (def == NULL)
110+ break;
111+
112+ auxoffset = offset + def->vd_aux;
113+ aux = gelf_getverdaux (verd, auxoffset, &auxmem);
114+ if (aux == NULL)
115+ break;
116+
117+ if (strcmp (name, elf_strptr (elf, verd_shdr->sh_link,
118+ aux->vda_name)) == 0)
119+ return def->vd_ndx;
120+
121+ /* Find the next offset. */
122+ offset += def->vd_next;
123+ }
124+
125+ return -1;
126+}
127+
128+int
129+main (int argc, char **argv)
130+{
131+ if (argc < 4)
132+ error (1, 0, "Usage: change_symver library from_symver to_symver symbol...\nExample: change_symver libfoo.so FOO_1.0 *global* bar baz");
133+
134+ const char *fname = argv[1];
135+
136+ /* Open the file. */
137+ int fd;
138+ fd = open (fname, O_RDWR);
139+ if (fd == -1)
140+ error (1, errno, fname);
141+
142+ elf_version (EV_CURRENT);
143+
144+ /* Now get the ELF descriptor. */
145+ Elf *elf = elf_begin (fd, ELF_C_READ_MMAP, NULL);
146+ if (elf == NULL || elf_kind (elf) != ELF_K_ELF)
147+ error (1, 0, "Couldn't open %s: %s", fname, elf_errmsg (-1));
148+
149+ size_t shstrndx;
150+ /* Get the section header string table index. */
151+ if (elf_getshstrndx (elf, &shstrndx) < 0)
152+ error (1, 0, "cannot get shstrndx from %s", fname);
153+
154+ GElf_Ehdr ehdr_mem;
155+ GElf_Ehdr *ehdr;
156+
157+ /* We need the ELF header in a few places. */
158+ ehdr = gelf_getehdr (elf, &ehdr_mem);
159+ if (ehdr == NULL)
160+ error (1, 0, "couldn't get ELF headers %s: %s", fname, elf_errmsg (-1));
161+
162+ Elf_Scn *scn = NULL;
163+ GElf_Shdr shdr_mem, verd_shdr, ver_shdr, dynsym_shdr;
164+ Elf_Data *ver = NULL, *verd = NULL, *dynsym = NULL;
165+
166+ while ((scn = elf_nextscn (elf, scn)) != NULL)
167+ {
168+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
169+
170+ if (shdr == NULL)
171+ error (1, 0, "couldn't get shdr from %s", fname);
172+
173+ if ((shdr->sh_flags & SHF_ALLOC) != 0)
174+ {
175+ const char *name = elf_strptr (elf, shstrndx, shdr->sh_name);
176+ Elf_Data **p;
177+
178+ if (strcmp (name, ".gnu.version") == 0)
179+ {
180+ p = &ver;
181+ ver_shdr = *shdr;
182+ }
183+ else if (strcmp (name, ".gnu.version_d") == 0)
184+ {
185+ p = &verd;
186+ verd_shdr = *shdr;
187+ }
188+ else if (strcmp (name, ".dynsym") == 0)
189+ {
190+ p = &dynsym;
191+ dynsym_shdr = *shdr;
192+ }
193+ else
194+ continue;
195+
196+ if (*p != NULL)
197+ error (1, 0, "Two %s sections in %s", name, fname);
198+ *p = elf_getdata (scn, NULL);
199+ if (*p == NULL || elf_getdata (scn, *p) != NULL)
200+ error (1, 0, "No data or non-contiguous data in %s section in %s",
201+ name, fname);
202+ }
203+ }
204+
205+ if (ver == NULL || verd == NULL || dynsym == NULL)
206+ error (1, 0, "Couldn't find one of the needed sections in %s", fname);
207+
208+ int from_idx = compute_veridx (argv[2], elf, verd, &verd_shdr);
209+ if (from_idx == -1)
210+ error (1, 0, "Could not find symbol version %s in %s", argv[2], fname);
211+
212+ int to_idx = compute_veridx (argv[3], elf, verd, &verd_shdr);
213+ if (to_idx == -1)
214+ error (1, 0, "Could not find symbol version %s in %s", argv[3], fname);
215+
216+ if (dynsym_shdr.sh_entsize != gelf_fsize (elf, ELF_T_SYM, 1, ehdr->e_version)
217+ || dynsym_shdr.sh_size % dynsym_shdr.sh_entsize
218+ || ver_shdr.sh_entsize != 2
219+ || (ver_shdr.sh_size & 1)
220+ || dynsym_shdr.sh_size / dynsym_shdr.sh_entsize != ver_shdr.sh_size / 2)
221+ error (1, 0, "Unexpected sh_size or sh_entsize in %s", fname);
222+
223+ size_t nentries = ver_shdr.sh_size / 2;
224+ size_t cnt;
225+ GElf_Versym array[nentries];
226+ for (cnt = 0; cnt < nentries; ++cnt)
227+ {
228+ GElf_Versym vsymmem;
229+ GElf_Versym *vsym;
230+
231+ vsym = gelf_getversym (ver, cnt, &vsymmem);
232+ if (vsym == NULL)
233+ error (1, 0, "gelt_getversym failed in %s: %s", fname, elf_errmsg (-1));
234+
235+ array[cnt] = *vsym;
236+ if (*vsym != from_idx)
237+ continue;
238+
239+ GElf_Sym sym_mem;
240+ GElf_Sym *sym;
241+ sym = gelf_getsym (dynsym, cnt, &sym_mem);
242+ if (sym == NULL)
243+ error (1, 0, "gelt_getsym failed in %s: %s", fname, elf_errmsg (-1));
244+
245+ const char *name = elf_strptr (elf, dynsym_shdr.sh_link, sym->st_name);
246+
247+ int argn;
248+ for (argn = 4; argn < argc; ++argn)
249+ if (fnmatch (argv[argn], name, 0) == 0)
250+ {
251+ array[cnt] = to_idx;
252+ break;
253+ }
254+ }
255+
256+ if (sizeof (array[0]) != 2)
257+ abort ();
258+
259+#if __BYTE_ORDER == __LITTLE_ENDIAN
260+ if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)
261+ ;
262+ else if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
263+#elif __BYTE_ORDER == __BIG_ENDIAN
264+ if (ehdr->e_ident[EI_DATA] == ELFDATA2MSB)
265+ ;
266+ else if (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)
267+#else
268+# error Unsupported endianity
269+#endif
270+ {
271+ for (cnt = 0; cnt < nentries; ++cnt)
272+ array[cnt] = ((array[cnt] & 0xff) << 8) | ((array[cnt] & 0xff00) >> 8);
273+ }
274+ else
275+ error (1, 0, "Unknown EI_DATA %d in %s", ehdr->e_ident[EI_DATA], fname);
276+
277+ if (elf_end (elf) != 0)
278+ error (1, 0, "couldn't close %s: %s", fname, elf_errmsg (-1));
279+
280+ if (lseek (fd, ver_shdr.sh_offset, SEEK_SET) != (off_t) ver_shdr.sh_offset)
281+ error (1, 0, "failed to seek to %zd in %s", (size_t) ver_shdr.sh_offset,
282+ fname);
283+
284+ if (write (fd, array, 2 * nentries) != (ssize_t) (2 * nentries))
285+ error (1, 0, "failed to write .gnu.version section into %s", fname);
286+
287+ close (fd);
288+ return 0;
289+}
290Index: gcc/config/ia64/unwind-ia64.c
291===================================================================
292--- gcc/config/ia64/unwind-ia64.c.orig 2009-09-07 08:41:52.000000000 -0700
293+++ gcc/config/ia64/unwind-ia64.c 2010-06-25 10:14:32.521880765 -0700
294@@ -48,6 +48,51 @@
295 #define MD_UNW_COMPATIBLE_PERSONALITY_P(HEADER) 1
296 #endif
297
298+#if defined (USE_SYMVER_GLOBAL) && defined (SHARED)
299+extern _Unwind_Reason_Code __symverglobal_Unwind_Backtrace
300+ (_Unwind_Trace_Fn, void *);
301+extern void __symverglobal_Unwind_DeleteException
302+ (struct _Unwind_Exception *);
303+extern void * __symverglobal_Unwind_FindEnclosingFunction (void *);
304+extern _Unwind_Reason_Code __symverglobal_Unwind_ForcedUnwind
305+ (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
306+extern _Unwind_Word __symverglobal_Unwind_GetCFA
307+ (struct _Unwind_Context *);
308+extern _Unwind_Word __symverglobal_Unwind_GetBSP
309+ (struct _Unwind_Context *);
310+extern _Unwind_Word __symverglobal_Unwind_GetGR
311+ (struct _Unwind_Context *, int );
312+extern _Unwind_Ptr __symverglobal_Unwind_GetIP (struct _Unwind_Context *);
313+extern void *__symverglobal_Unwind_GetLanguageSpecificData
314+ (struct _Unwind_Context *);
315+extern _Unwind_Ptr __symverglobal_Unwind_GetRegionStart
316+ (struct _Unwind_Context *);
317+extern _Unwind_Reason_Code __symverglobal_Unwind_RaiseException
318+ (struct _Unwind_Exception *);
319+extern void __symverglobal_Unwind_Resume (struct _Unwind_Exception *);
320+extern _Unwind_Reason_Code __symverglobal_Unwind_Resume_or_Rethrow
321+ (struct _Unwind_Exception *);
322+extern void __symverglobal_Unwind_SetGR
323+ (struct _Unwind_Context *, int, _Unwind_Word);
324+extern void __symverglobal_Unwind_SetIP
325+ (struct _Unwind_Context *, _Unwind_Ptr);
326+#define _Unwind_Backtrace __symverglobal_Unwind_Backtrace
327+#define _Unwind_DeleteException __symverglobal_Unwind_DeleteException
328+#define _Unwind_FindEnclosingFunction __symverglobal_Unwind_FindEnclosingFunction
329+#define _Unwind_ForcedUnwind __symverglobal_Unwind_ForcedUnwind
330+#define _Unwind_GetBSP __symverglobal_Unwind_GetBSP
331+#define _Unwind_GetCFA __symverglobal_Unwind_GetCFA
332+#define _Unwind_GetGR __symverglobal_Unwind_GetGR
333+#define _Unwind_GetIP __symverglobal_Unwind_GetIP
334+#define _Unwind_GetLanguageSpecificData __symverglobal_Unwind_GetLanguageSpecificData
335+#define _Unwind_GetRegionStart __symverglobal_Unwind_GetRegionStart
336+#define _Unwind_RaiseException __symverglobal_Unwind_RaiseException
337+#define _Unwind_Resume __symverglobal_Unwind_Resume
338+#define _Unwind_Resume_or_Rethrow __symverglobal_Unwind_Resume_or_Rethrow
339+#define _Unwind_SetGR __symverglobal_Unwind_SetGR
340+#define _Unwind_SetIP __symverglobal_Unwind_SetIP
341+#endif
342+
343 enum unw_application_register
344 {
345 UNW_AR_BSP,
346@@ -2457,4 +2502,44 @@
347 alias (_Unwind_SetIP);
348 #endif
349
350+#if defined (USE_SYMVER_GLOBAL) && defined (SHARED)
351+#undef alias
352+#define symverglobal(name, version) \
353+__typeof (__symverglobal##name) __symverlocal##name \
354+ __attribute__ ((alias ("__symverglobal" #name))); \
355+__asm__ (".symver __symverglobal" #name"," #name "@@GCC_3.4.2");\
356+__asm__ (".symver __symverlocal" #name"," #name "@" #version)
357+
358+#undef _Unwind_Backtrace
359+#undef _Unwind_DeleteException
360+#undef _Unwind_FindEnclosingFunction
361+#undef _Unwind_ForcedUnwind
362+#undef _Unwind_GetBSP
363+#undef _Unwind_GetCFA
364+#undef _Unwind_GetGR
365+#undef _Unwind_GetIP
366+#undef _Unwind_GetLanguageSpecificData
367+#undef _Unwind_GetRegionStart
368+#undef _Unwind_RaiseException
369+#undef _Unwind_Resume
370+#undef _Unwind_Resume_or_Rethrow
371+#undef _Unwind_SetGR
372+#undef _Unwind_SetIP
373+symverglobal (_Unwind_Backtrace, GCC_3.3);
374+symverglobal (_Unwind_DeleteException, GCC_3.0);
375+symverglobal (_Unwind_FindEnclosingFunction, GCC_3.3);
376+symverglobal (_Unwind_ForcedUnwind, GCC_3.0);
377+symverglobal (_Unwind_GetBSP, GCC_3.3.2);
378+symverglobal (_Unwind_GetCFA, GCC_3.3);
379+symverglobal (_Unwind_GetGR, GCC_3.0);
380+symverglobal (_Unwind_GetIP, GCC_3.0);
381+symverglobal (_Unwind_GetLanguageSpecificData, GCC_3.0);
382+symverglobal (_Unwind_GetRegionStart, GCC_3.0);
383+symverglobal (_Unwind_RaiseException, GCC_3.0);
384+symverglobal (_Unwind_Resume, GCC_3.0);
385+symverglobal (_Unwind_Resume_or_Rethrow, GCC_3.3);
386+symverglobal (_Unwind_SetGR, GCC_3.0);
387+symverglobal (_Unwind_SetIP, GCC_3.0);
388+#endif
389+
390 #endif
391Index: gcc/config/ia64/mkmap-symver-multi.awk
392===================================================================
393--- /dev/null 1970-01-01 00:00:00.000000000 +0000
394+++ gcc/config/ia64/mkmap-symver-multi.awk 2010-06-25 10:14:32.521880765 -0700
395@@ -0,0 +1,133 @@
396+# Generate an ELF symbol version map a-la Solaris and GNU ld.
397+# Contributed by Richard Henderson <rth@cygnus.com>
398+#
399+# This file is part of GCC.
400+#
401+# GCC is free software; you can redistribute it and/or modify it under
402+# the terms of the GNU General Public License as published by the Free
403+# Software Foundation; either version 2, or (at your option) any later
404+# version.
405+#
406+# GCC is distributed in the hope that it will be useful, but WITHOUT
407+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
408+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
409+# License for more details.
410+#
411+# You should have received a copy of the GNU General Public License
412+# along with GCC; see the file COPYING. If not, write to the Free
413+# Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
414+# 02110-1301, USA.
415+
416+BEGIN {
417+ state = "nm";
418+ sawsymbol = 0;
419+}
420+
421+# Remove comment and blank lines.
422+/^ *#/ || /^ *$/ {
423+ next;
424+}
425+
426+# We begin with nm input. Collect the set of symbols that are present
427+# so that we can not emit them into the final version script -- Solaris
428+# complains at us if we do.
429+
430+state == "nm" && /^%%/ {
431+ state = "ver";
432+ next;
433+}
434+
435+state == "nm" && ($1 == "U" || $2 == "U") {
436+ next;
437+}
438+
439+state == "nm" && NF == 3 {
440+ if ($3 ~ /^[^@]*@GCC_[0-9.]*$/) {
441+ def[$3] = 1
442+ tl=$3
443+ sub(/^.*@/,"",tl)
444+ ver[$3] = tl
445+ } else {
446+ sub(/@@?GCC_[0-9.]*$/,"",$3)
447+ def[$3] = 1;
448+ }
449+ sawsymbol = 1;
450+ next;
451+}
452+
453+state == "nm" {
454+ next;
455+}
456+
457+# Now we process a simplified variant of the Solaris symbol version
458+# script. We have one symbol per line, no semicolons, simple markers
459+# for beginning and ending each section, and %inherit markers for
460+# describing version inheritence. A symbol may appear in more than
461+# one symbol version, and the last seen takes effect.
462+
463+NF == 3 && $1 == "%inherit" {
464+ inherit[$2] = $3;
465+ next;
466+}
467+
468+NF == 2 && $2 == "{" {
469+ libs[$1] = 1;
470+ thislib = $1;
471+ next;
472+}
473+
474+$1 == "}" {
475+ thislib = "";
476+ next;
477+}
478+
479+{
480+ ver[$1] = thislib;
481+ next;
482+}
483+
484+END {
485+ if (!sawsymbol)
486+ {
487+ print "No symbols seen -- broken or mis-installed nm?" | "cat 1>&2";
488+ exit 1;
489+ }
490+ for (l in libs)
491+ output(l);
492+}
493+
494+function output(lib) {
495+ if (done[lib])
496+ return;
497+ done[lib] = 1;
498+ if (inherit[lib])
499+ output(inherit[lib]);
500+
501+ empty=1
502+ for (sym in ver)
503+ if ((ver[sym] == lib) && (sym in def))
504+ {
505+ if (empty)
506+ {
507+ printf("%s {\n", lib);
508+ printf(" global:\n");
509+ empty = 0;
510+ }
511+ symp = sym;
512+ sub(/@GCC_[0-9.]*$/,"",symp);
513+ printf("\t%s;\n", symp);
514+ if (dotsyms)
515+ printf("\t.%s;\n", symp);
516+ }
517+
518+ if (empty)
519+ {
520+ for (l in libs)
521+ if (inherit[l] == lib)
522+ inherit[l] = inherit[lib];
523+ }
524+ else if (inherit[lib])
525+ printf("} %s;\n", inherit[lib]);
526+ else
527+ printf ("\n local:\n\t*;\n};\n");
528+}
529Index: gcc/config/ia64/libgcc-ia64-no-libunwind.ver
530===================================================================
531--- /dev/null 1970-01-01 00:00:00.000000000 +0000
532+++ gcc/config/ia64/libgcc-ia64-no-libunwind.ver 2010-06-25 10:14:32.525880902 -0700
533@@ -0,0 +1,17 @@
534+GCC_3.4.2 {
535+ _Unwind_GetGR
536+ _Unwind_RaiseException
537+ _Unwind_GetRegionStart
538+ _Unwind_SetIP
539+ _Unwind_GetIP
540+ _Unwind_GetLanguageSpecificData
541+ _Unwind_Resume
542+ _Unwind_DeleteException
543+ _Unwind_SetGR
544+ _Unwind_ForcedUnwind
545+ _Unwind_Backtrace
546+ _Unwind_FindEnclosingFunction
547+ _Unwind_GetCFA
548+ _Unwind_Resume_or_Rethrow
549+ _Unwind_GetBSP
550+}
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-java-debug-iface-type.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-java-debug-iface-type.patch
new file mode 100644
index 0000000000..de14a50018
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-java-debug-iface-type.patch
@@ -0,0 +1,19 @@
12008-01-25 Jakub Jelinek <jakub@redhat.com>
2
3 * lang.c (java_classify_record): Revert 2007-12-20 change.
4
5Index: gcc/java/lang.c
6===================================================================
7--- gcc/java/lang.c.orig 2010-01-20 00:17:00.000000000 -0800
8+++ gcc/java/lang.c 2010-06-25 10:28:46.569383189 -0700
9@@ -881,9 +881,7 @@
10 if (! CLASS_P (type))
11 return RECORD_IS_STRUCT;
12
13- /* ??? GDB does not support DW_TAG_interface_type as of December,
14- 2007. Re-enable this at a later time. */
15- if (0 && CLASS_INTERFACE (TYPE_NAME (type)))
16+ if (CLASS_INTERFACE (TYPE_NAME (type)))
17 return RECORD_IS_INTERFACE;
18
19 return RECORD_IS_CLASS;
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-java-nomulti.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-java-nomulti.patch
new file mode 100644
index 0000000000..3cb10f3c23
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-java-nomulti.patch
@@ -0,0 +1,48 @@
1Index: libjava/configure.ac
2===================================================================
3--- libjava/configure.ac.orig 2010-03-21 12:41:37.000000000 -0700
4+++ libjava/configure.ac 2010-06-25 10:17:47.489886278 -0700
5@@ -139,6 +139,13 @@
6 [allow rebuilding of .class and .h files]))
7 AM_CONDITIONAL(JAVA_MAINTAINER_MODE, test "$enable_java_maintainer_mode" = yes)
8
9+AC_ARG_ENABLE(libjava-multilib,
10+ AS_HELP_STRING([--enable-libjava-multilib], [build libjava as multilib]))
11+if test "$enable_libjava_multilib" = no; then
12+ multilib=no
13+ ac_configure_args="$ac_configure_args --disable-multilib"
14+fi
15+
16 # It may not be safe to run linking tests in AC_PROG_CC/AC_PROG_CXX.
17 GCC_NO_EXECUTABLES
18
19Index: libjava/configure
20===================================================================
21--- libjava/configure.orig 2010-04-02 11:18:06.000000000 -0700
22+++ libjava/configure 2010-06-25 10:17:47.516381209 -0700
23@@ -1609,6 +1609,8 @@
24 default=yes
25 --enable-java-maintainer-mode
26 allow rebuilding of .class and .h files
27+ --enable-libjava-multilib
28+ build libjava as multilib
29 --disable-dependency-tracking speeds up one-time build
30 --enable-dependency-tracking do not reject slow dependency extractors
31 --enable-maintainer-mode enable make rules and dependencies not useful
32@@ -3346,6 +3348,16 @@
33 fi
34
35
36+# Check whether --enable-libjava-multilib was given.
37+if test "${enable_libjava_multilib+set}" = set; then
38+ enableval=$enable_libjava_multilib;
39+fi
40+
41+if test "$enable_libjava_multilib" = no; then
42+ multilib=no
43+ ac_configure_args="$ac_configure_args --disable-multilib"
44+fi
45+
46 # It may not be safe to run linking tests in AC_PROG_CC/AC_PROG_CXX.
47
48
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-libgomp-speedup.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-libgomp-speedup.patch
new file mode 100644
index 0000000000..da85e556ec
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-libgomp-speedup.patch
@@ -0,0 +1,2797 @@
12008-03-28 Jakub Jelinek <jakub@redhat.com>
2
3 * config/linux/sparc/futex.h (atomic_write_barrier): Fix membar
4 argument.
5
62008-03-27 Jakub Jelinek <jakub@redhat.com>
7
8 * libgomp.h (struct gomp_team_state): Remove single_count field
9 ifndef HAVE_SYNC_BUILTINS.
10 (struct gomp_team): Likewise. Add work_share_list_free_lock
11 ifndef HAVE_SYNC_BUILTINS.
12 * team.c (gomp_new_team): If HAVE_SYNC_BUILTINS is not defined,
13 don't initialize single_count, but instead initialize
14 work_share_list_free_lock.
15 (free_team): Destroy work_share_list_free_lock ifndef
16 HAVE_SYNC_BUILTINS.
17 (gomp_team_start): Don't initialize ts.single_count ifndef
18 HAVE_SYNC_BUILTINS.
19 * work.c (alloc_work_share, free_work_share): Use
20 work_share_list_free_lock instead of atomic chaining ifndef
21 HAVE_SYNC_BUILTINS.
22
232008-03-26 Jakub Jelinek <jakub@redhat.com>
24
25 * loop.c (gomp_loop_init): Fix GFS_DYNAMIC ws->mode setting.
26 * testsuite/libgomp.c/loop-4.c: New test.
27
28 * libgomp.h (struct gomp_team_state): Add single_count field.
29 (struct gomp_team): Likewise.
30 * team.c (gomp_new_team): Clear single_count.
31 (gomp_team_start): Likewise.
32 * single.c (GOMP_single_start): Rewritten if HAVE_SYNC_BUILTINS.
33
342008-03-25 Jakub Jelinek <jakub@redhat.com>
35
36 * team.c (gomp_thread_start): Don't clear ts.static_trip here.
37 * loop.c (gomp_loop_static_start, gomp_loop_dynamic_start): Clear
38 ts.static_trip here.
39 * work.c (gomp_work_share_start): Don't clear ts.static_trip here.
40
412008-03-21 Jakub Jelinek <jakub@redhat.com>
42
43 * libgomp.h: Include ptrlock.h.
44 (struct gomp_work_share): Reshuffle fields. Add next_alloc,
45 next_ws, next_free and inline_ordered_team_ids fields, change
46 ordered_team_ids into pointer from flexible array member.
47 (struct gomp_team_state): Add last_work_share field, remove
48 work_share_generation.
49 (struct gomp_team): Remove work_share_lock, generation_mask,
50 oldest_live_gen, num_live_gen and init_work_shares fields, add
51 work work_share_list_alloc, work_share_list_free and work_share_chunk
52 fields. Change work_shares from pointer to pointers into an array.
53 (gomp_new_team): New prototype.
54 (gomp_team_start): Change type of last argument.
55 (gomp_new_work_share): Removed.
56 (gomp_init_work_share, gomp_fini_work_share): New prototypes.
57 (gomp_work_share_init_done): New static inline.
58 * team.c (gomp_thread_start): Clear ts.last_work_share, don't clear
59 ts.work_share_generation.
60 (new_team): Removed.
61 (gomp_new_team): New function.
62 (free_team): Free gomp_work_share blocks chained through next_alloc,
63 instead of freeing work_shares and destroying work_share_lock.
64 (gomp_team_start): Change last argument from ws to team, don't create
65 new team, set ts.work_share to &team->work_shares[0] and clear
66 ts.last_work_share. Don't clear ts.work_share_generation.
67 (gomp_team_end): Call gomp_fini_work_share.
68 * work.c (gomp_new_work_share): Removed.
69 (alloc_work_share, gomp_init_work_share, gomp_fini_work_share): New
70 functions.
71 (free_work_share): Add team argument. Call gomp_fini_work_share
72 and then either free ws if orphaned, or put it into
73 work_share_list_free list of the current team.
74 (gomp_work_share_start, gomp_work_share_end,
75 gomp_work_share_end_nowait): Rewritten.
76 * sections.c (GOMP_sections_start): Call gomp_work_share_init_done
77 after gomp_sections_init. If HAVE_SYNC_BUILTINS, call
78 gomp_iter_dynamic_next instead of the _locked variant and don't take
79 lock around it, otherwise acquire it before calling
80 gomp_iter_dynamic_next_locked.
81 (GOMP_sections_next): If HAVE_SYNC_BUILTINS, call
82 gomp_iter_dynamic_next instead of the _locked variant and don't take
83 lock around it.
84 (GOMP_parallel_sections_start): Call gomp_new_team instead of
85 gomp_new_work_share. Call gomp_sections_init on &team->work_shares[0].
86 Adjust gomp_team_start caller.
87 * loop.c (gomp_loop_static_start, gomp_loop_ordered_static_start): Call
88 gomp_work_share_init_done after gomp_loop_init. Don't unlock ws->lock.
89 (gomp_loop_dynamic_start, gomp_loop_guided_start): Call
90 gomp_work_share_init_done after gomp_loop_init. If HAVE_SYNC_BUILTINS,
91 don't unlock ws->lock, otherwise lock it.
92 (gomp_loop_ordered_dynamic_start, gomp_loop_ordered_guided_start): Call
93 gomp_work_share_init_done after gomp_loop_init. Lock ws->lock.
94 (gomp_parallel_loop_start): Call gomp_new_team instead of
95 gomp_new_work_share. Call gomp_loop_init on &team->work_shares[0].
96 Adjust gomp_team_start caller.
97 * single.c (GOMP_single_start, GOMP_single_copy_start): Call
98 gomp_work_share_init_done if gomp_work_share_start returned true.
99 Don't unlock ws->lock.
100 * parallel.c (GOMP_parallel_start): Call gomp_new_team and pass that
101 as last argument to gomp_team_start.
102 * config/linux/ptrlock.c: New file.
103 * config/linux/ptrlock.h: New file.
104 * config/posix/ptrlock.c: New file.
105 * config/posix/ptrlock.h: New file.
106 * Makefile.am (libgomp_la_SOURCES): Add ptrlock.c.
107 * Makefile.in: Regenerated.
108 * testsuite/Makefile.in: Regenerated.
109
1102008-03-19 Jakub Jelinek <jakub@redhat.com>
111
112 * libgomp.h (gomp_active_wait_policy): Remove decl.
113 (gomp_throttled_spin_count_var, gomp_available_cpus,
114 gomp_managed_threads): New extern decls.
115 * team.c (gomp_team_start, gomp_team_end): If number of threads
116 changed, adjust atomically gomp_managed_threads.
117 * env.c (gomp_active_wait_policy, gomp_block_time_var): Remove.
118 (gomp_throttled_spin_count_var, gomp_available_cpus,
119 gomp_managed_threads): New variables.
120 (parse_millis): Removed.
121 (parse_spincount): New function.
122 (parse_wait_policy): Return -1/0/1 instead of setting
123 gomp_active_wait_policy.
124 (initialize_env): Call gomp_init_num_threads unconditionally.
125 Initialize gomp_available_cpus. Call parse_spincount instead
126 of parse_millis, initialize gomp_{,throttled_}spin_count_var
127 depending on presence and value of OMP_WAIT_POLICY and
128 GOMP_SPINCOUNT env vars.
129 * config/linux/wait.h (do_wait): Use gomp_throttled_spin_count_var
130 instead of gomp_spin_count_var if gomp_managed_threads >
131 gomp_available_cpus.
132
133 * config/linux/wait.h: Include errno.h.
134 (FUTEX_WAIT, FUTEX_WAKE, FUTEX_PRIVATE_FLAG): Define.
135 (gomp_futex_wake, gomp_futex_wait): New extern decls.
136 * config/linux/mutex.c (gomp_futex_wake, gomp_futex_wait): New
137 variables.
138 * config/linux/powerpc/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove.
139 (sys_futex0): Return error code.
140 (futex_wake, futex_wait): If ENOSYS was returned, clear
141 FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry.
142 * config/linux/alpha/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove.
143 (futex_wake, futex_wait): If ENOSYS was returned, clear
144 FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry.
145 * config/linux/x86/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove.
146 (sys_futex0): Return error code.
147 (futex_wake, futex_wait): If ENOSYS was returned, clear
148 FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry.
149 * config/linux/s390/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove.
150 (sys_futex0): Return error code.
151 (futex_wake, futex_wait): If ENOSYS was returned, clear
152 FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry.
153 * config/linux/ia64/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove.
154 (sys_futex0): Return error code.
155 (futex_wake, futex_wait): If ENOSYS was returned, clear
156 FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry.
157 * config/linux/sparc/futex.h (FUTEX_WAIT, FUTEX_WAKE): Remove.
158 (sys_futex0): Return error code.
159 (futex_wake, futex_wait): If ENOSYS was returned, clear
160 FUTEX_PRIVATE_FLAG in gomp_futex_wa{ke,it} and retry.
161
1622008-03-18 Jakub Jelinek <jakub@redhat.com>
163
164 * libgomp.h (struct gomp_work_share): Add mode field. Put lock and
165 next into a different cache line from most of the write-once fields.
166 * loop.c: Include limits.h.
167 (gomp_loop_init): For GFS_DYNAMIC, multiply ws->chunk_size by incr.
168 If adding ws->chunk_size nthreads + 1 times after end won't
169 overflow, set ws->mode to 1.
170 * iter.c (gomp_iter_dynamic_next_locked): Don't multiply
171 ws->chunk_size by incr.
172 (gomp_iter_dynamic_next): Likewise. If ws->mode, use more efficient
173 code.
174 * work.c: Include stddef.h.
175 (gomp_new_work_share): Use offsetof rather than sizeof.
176
1772008-03-17 Jakub Jelinek <jakub@redhat.com>
178
179 * libgomp.h (struct gomp_team): Change ordered_release field
180 into gomp_sem_t ** from flexible array member. Add implicit_task
181 and initial_work_shares fields.
182 (gomp_new_task): Removed.
183 (gomp_init_task): New prototype.
184 * team.c (new_team): Allocate implicit_task for each thread
185 and initial work_shares together with gomp_team allocation.
186 (free_team): Only free work_shares if it is not init_work_shares.
187 (gomp_team_start): Use gomp_init_task instead of gomp_new_task,
188 set thr->task to the corresponding implicit_task array entry.
189 * task.c (gomp_new_task): Removed.
190 (gomp_init_task): New function.
191 (gomp_end_task): Don't free the task.
192 (GOMP_task): Allocate struct gomp_task on the stack, call
193 gomp_init_task rather than gomp_new_task.
194 * work.c (gomp_work_share_start): If work_shares ==
195 init_work_shares, gomp_malloc + memcpy rather than gomp_realloc.
196
1972008-03-15 Jakub Jelinek <jakub@redhat.com>
198 Ulrich Drepper <drepper@redhat.com>
199
200 * config/linux/bar.h (gomp_barrier_state_t): Rewritten.
201 (gomp_barrier_state_t): Change to unsigned int.
202 (gomp_barrier_init, gomp_barrier_reinit, gomp_barrier_destroy,
203 gomp_barrier_wait_start, gomp_barrier_last_thread): Rewritten.
204 (gomp_barrier_wait_last): Prototype rather than inline.
205 * config/linux/bar.c (gomp_barrier_wait_end): Rewritten.
206 (gomp_barrier_wait_last): New function.
207
2082008-03-15 Jakub Jelinek <jakub@redhat.com>
209
210 * team.c (gomp_thread_start): Use gomp_barrier_wait_last instead
211 of gomp_barrier_wait.
212 * env.c (gomp_block_time_var, gomp_spin_count_var): New variables.
213 (parse_millis): New function.
214 (initialize_env): Handle GOMP_BLOCKTIME env var.
215 * libgomp.h (struct gomp_team): Move close to the end of the struct.
216 (gomp_spin_count_var): New extern var decl.
217 * work.c (gomp_work_share_end): Use gomp_barrier_state_t bstate
218 var instead of bool last, call gomp_barrier_last_thread to check
219 for last thread, pass bstate to gomp_barrier_wait_end.
220 * config/linux/wait.h: New file.
221 * config/linux/mutex.c: Include wait.h instead of libgomp.h and
222 futex.h.
223 (gomp_mutex_lock_slow): Call do_wait instead of futex_wait.
224 * config/linux/bar.c: Include wait.h instead of libgomp.h and
225 futex.h.
226 (gomp_barrier_wait_end): Change second argument to
227 gomp_barrier_state_t. Call do_wait instead of futex_wait.
228 * config/linux/sem.c: Include wait.h instead of libgomp.h and
229 futex.h.
230 (gomp_sem_wait_slow): Call do_wait instead of futex_wait.
231 * config/linux/lock.c: Include wait.h instead of libgomp.h and
232 futex.h.
233 (gomp_set_nest_lock_25): Call do_wait instead of futex_wait.
234 * config/linux/affinity.c: Assume HAVE_SYNC_BUILTINS.
235 * config/linux/bar.h (gomp_barrier_state_t): New typedef.
236 (gomp_barrier_wait_end): Change second argument to
237 gomp_barrier_state_t.
238 (gomp_barrier_wait_start): Return gomp_barrier_state_t.
239 (gomp_barrier_last_thread, gomp_barrier_wait_last): New static
240 inlines.
241 * config/linux/powerpc/futex.h (cpu_relax, atomic_write_barrier): New
242 static inlines.
243 * config/linux/alpha/futex.h (cpu_relax, atomic_write_barrier):
244 Likewise.
245 * config/linux/x86/futex.h (cpu_relax, atomic_write_barrier):
246 Likewise.
247 * config/linux/s390/futex.h (cpu_relax, atomic_write_barrier):
248 Likewise.
249 * config/linux/ia64/futex.h (cpu_relax, atomic_write_barrier):
250 Likewise.
251 * config/linux/sparc/futex.h (cpu_relax, atomic_write_barrier):
252 Likewise.
253 * config/posix/bar.c (gomp_barrier_wait_end): Change second argument
254 to gomp_barrier_state_t.
255 * config/posix/bar.h (gomp_barrier_state_t): New typedef.
256 (gomp_barrier_wait_end): Change second argument to
257 gomp_barrier_state_t.
258 (gomp_barrier_wait_start): Return gomp_barrier_state_t.
259 (gomp_barrier_last_thread, gomp_barrier_wait_last): New static
260 inlines.
261
262--- libgomp/parallel.c.jj 2007-12-07 14:41:01.000000000 +0100
263+++ libgomp/parallel.c 2008-03-26 15:32:06.000000000 +0100
264@@ -68,7 +68,7 @@ void
265 GOMP_parallel_start (void (*fn) (void *), void *data, unsigned num_threads)
266 {
267 num_threads = gomp_resolve_num_threads (num_threads);
268- gomp_team_start (fn, data, num_threads, NULL);
269+ gomp_team_start (fn, data, num_threads, gomp_new_team (num_threads));
270 }
271
272 void
273--- libgomp/sections.c.jj 2007-12-07 14:41:01.000000000 +0100
274+++ libgomp/sections.c 2008-03-26 15:33:06.000000000 +0100
275@@ -59,14 +59,24 @@ GOMP_sections_start (unsigned count)
276 long s, e, ret;
277
278 if (gomp_work_share_start (false))
279- gomp_sections_init (thr->ts.work_share, count);
280+ {
281+ gomp_sections_init (thr->ts.work_share, count);
282+ gomp_work_share_init_done ();
283+ }
284
285+#ifdef HAVE_SYNC_BUILTINS
286+ if (gomp_iter_dynamic_next (&s, &e))
287+ ret = s;
288+ else
289+ ret = 0;
290+#else
291+ gomp_mutex_lock (&thr->ts.work_share->lock);
292 if (gomp_iter_dynamic_next_locked (&s, &e))
293 ret = s;
294 else
295 ret = 0;
296-
297 gomp_mutex_unlock (&thr->ts.work_share->lock);
298+#endif
299
300 return ret;
301 }
302@@ -83,15 +93,23 @@ GOMP_sections_start (unsigned count)
303 unsigned
304 GOMP_sections_next (void)
305 {
306- struct gomp_thread *thr = gomp_thread ();
307 long s, e, ret;
308
309+#ifdef HAVE_SYNC_BUILTINS
310+ if (gomp_iter_dynamic_next (&s, &e))
311+ ret = s;
312+ else
313+ ret = 0;
314+#else
315+ struct gomp_thread *thr = gomp_thread ();
316+
317 gomp_mutex_lock (&thr->ts.work_share->lock);
318 if (gomp_iter_dynamic_next_locked (&s, &e))
319 ret = s;
320 else
321 ret = 0;
322 gomp_mutex_unlock (&thr->ts.work_share->lock);
323+#endif
324
325 return ret;
326 }
327@@ -103,15 +121,15 @@ void
328 GOMP_parallel_sections_start (void (*fn) (void *), void *data,
329 unsigned num_threads, unsigned count)
330 {
331- struct gomp_work_share *ws;
332+ struct gomp_team *team;
333
334 num_threads = gomp_resolve_num_threads (num_threads);
335 if (gomp_dyn_var && num_threads > count)
336 num_threads = count;
337
338- ws = gomp_new_work_share (false, num_threads);
339- gomp_sections_init (ws, count);
340- gomp_team_start (fn, data, num_threads, ws);
341+ team = gomp_new_team (num_threads);
342+ gomp_sections_init (&team->work_shares[0], count);
343+ gomp_team_start (fn, data, num_threads, team);
344 }
345
346 /* The GOMP_section_end* routines are called after the thread is told
347--- libgomp/env.c.jj 2007-12-07 14:41:01.000000000 +0100
348+++ libgomp/env.c 2008-03-26 16:40:26.000000000 +0100
349@@ -44,6 +44,11 @@ enum gomp_schedule_type gomp_run_sched_v
350 unsigned long gomp_run_sched_chunk = 1;
351 unsigned short *gomp_cpu_affinity;
352 size_t gomp_cpu_affinity_len;
353+#ifndef HAVE_SYNC_BUILTINS
354+gomp_mutex_t gomp_remaining_threads_lock;
355+#endif
356+unsigned long gomp_available_cpus = 1, gomp_managed_threads = 1;
357+unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var;
358
359 /* Parse the OMP_SCHEDULE environment variable. */
360
361@@ -147,6 +152,79 @@ parse_unsigned_long (const char *name, u
362 return false;
363 }
364
365+/* Parse the GOMP_SPINCOUNT environment varible. Return true if one was
366+ present and it was successfully parsed. */
367+
368+static bool
369+parse_spincount (const char *name, unsigned long long *pvalue)
370+{
371+ char *env, *end;
372+ unsigned long long value, mult = 1;
373+
374+ env = getenv (name);
375+ if (env == NULL)
376+ return false;
377+
378+ while (isspace ((unsigned char) *env))
379+ ++env;
380+ if (*env == '\0')
381+ goto invalid;
382+
383+ if (strncasecmp (env, "infinite", 8) == 0
384+ || strncasecmp (env, "infinity", 8) == 0)
385+ {
386+ value = ~0ULL;
387+ end = env + 8;
388+ goto check_tail;
389+ }
390+
391+ errno = 0;
392+ value = strtoull (env, &end, 10);
393+ if (errno)
394+ goto invalid;
395+
396+ while (isspace ((unsigned char) *end))
397+ ++end;
398+ if (*end != '\0')
399+ {
400+ switch (tolower (*end))
401+ {
402+ case 'k':
403+ mult = 1000LL;
404+ break;
405+ case 'm':
406+ mult = 1000LL * 1000LL;
407+ break;
408+ case 'g':
409+ mult = 1000LL * 1000LL * 1000LL;
410+ break;
411+ case 't':
412+ mult = 1000LL * 1000LL * 1000LL * 1000LL;
413+ break;
414+ default:
415+ goto invalid;
416+ }
417+ ++end;
418+ check_tail:
419+ while (isspace ((unsigned char) *end))
420+ ++end;
421+ if (*end != '\0')
422+ goto invalid;
423+ }
424+
425+ if (value > ~0ULL / mult)
426+ value = ~0ULL;
427+ else
428+ value *= mult;
429+
430+ *pvalue = value;
431+ return true;
432+
433+ invalid:
434+ gomp_error ("Invalid value for environment variable %s", name);
435+ return false;
436+}
437+
438 /* Parse a boolean value for environment variable NAME and store the
439 result in VALUE. */
440
441@@ -281,10 +359,25 @@ initialize_env (void)
442 parse_schedule ();
443 parse_boolean ("OMP_DYNAMIC", &gomp_dyn_var);
444 parse_boolean ("OMP_NESTED", &gomp_nest_var);
445+ gomp_init_num_threads ();
446+ gomp_available_cpus = gomp_nthreads_var;
447 if (!parse_unsigned_long ("OMP_NUM_THREADS", &gomp_nthreads_var))
448- gomp_init_num_threads ();
449+ gomp_nthreads_var = gomp_available_cpus;
450 if (parse_affinity ())
451 gomp_init_affinity ();
452+ if (!parse_spincount ("GOMP_SPINCOUNT", &gomp_spin_count_var))
453+ {
454+ /* Using a rough estimation of 100000 spins per msec,
455+ use 200 msec blocking.
456+ Depending on the CPU speed, this can be e.g. 5 times longer
457+ or 5 times shorter. */
458+ gomp_spin_count_var = 20000000LL;
459+ }
460+ /* gomp_throttled_spin_count_var is used when there are more libgomp
461+ managed threads than available CPUs. Use very short spinning. */
462+ gomp_throttled_spin_count_var = 100LL;
463+ if (gomp_throttled_spin_count_var > gomp_spin_count_var)
464+ gomp_throttled_spin_count_var = gomp_spin_count_var;
465
466 /* Not strictly environment related, but ordering constructors is tricky. */
467 pthread_attr_init (&gomp_thread_attr);
468--- libgomp/libgomp.h.jj 2007-12-07 14:41:01.000000000 +0100
469+++ libgomp/libgomp.h 2008-03-27 12:21:51.000000000 +0100
470@@ -50,6 +50,7 @@
471 #include "sem.h"
472 #include "mutex.h"
473 #include "bar.h"
474+#include "ptrlock.h"
475
476
477 /* This structure contains the data to control one work-sharing construct,
478@@ -70,6 +71,8 @@ struct gomp_work_share
479 If this is a SECTIONS construct, this value will always be DYNAMIC. */
480 enum gomp_schedule_type sched;
481
482+ int mode;
483+
484 /* This is the chunk_size argument to the SCHEDULE clause. */
485 long chunk_size;
486
487@@ -81,17 +84,38 @@ struct gomp_work_share
488 is always 1. */
489 long incr;
490
491- /* This lock protects the update of the following members. */
492- gomp_mutex_t lock;
493+ /* This is a circular queue that details which threads will be allowed
494+ into the ordered region and in which order. When a thread allocates
495+ iterations on which it is going to work, it also registers itself at
496+ the end of the array. When a thread reaches the ordered region, it
497+ checks to see if it is the one at the head of the queue. If not, it
498+ blocks on its RELEASE semaphore. */
499+ unsigned *ordered_team_ids;
500
501- union {
502- /* This is the next iteration value to be allocated. In the case of
503- GFS_STATIC loops, this the iteration start point and never changes. */
504- long next;
505+ /* This is the number of threads that have registered themselves in
506+ the circular queue ordered_team_ids. */
507+ unsigned ordered_num_used;
508
509- /* This is the returned data structure for SINGLE COPYPRIVATE. */
510- void *copyprivate;
511- };
512+ /* This is the team_id of the currently acknowledged owner of the ordered
513+ section, or -1u if the ordered section has not been acknowledged by
514+ any thread. This is distinguished from the thread that is *allowed*
515+ to take the section next. */
516+ unsigned ordered_owner;
517+
518+ /* This is the index into the circular queue ordered_team_ids of the
519+ current thread that's allowed into the ordered reason. */
520+ unsigned ordered_cur;
521+
522+ /* This is a chain of allocated gomp_work_share blocks, valid only
523+ in the first gomp_work_share struct in the block. */
524+ struct gomp_work_share *next_alloc;
525+
526+ /* The above fields are written once during workshare initialization,
527+ or related to ordered worksharing. Make sure the following fields
528+ are in a different cache line. */
529+
530+ /* This lock protects the update of the following members. */
531+ gomp_mutex_t lock __attribute__((aligned (64)));
532
533 /* This is the count of the number of threads that have exited the work
534 share construct. If the construct was marked nowait, they have moved on
535@@ -99,27 +123,28 @@ struct gomp_work_share
536 of the team to exit the work share construct must deallocate it. */
537 unsigned threads_completed;
538
539- /* This is the index into the circular queue ordered_team_ids of the
540- current thread that's allowed into the ordered reason. */
541- unsigned ordered_cur;
542+ union {
543+ /* This is the next iteration value to be allocated. In the case of
544+ GFS_STATIC loops, this the iteration start point and never changes. */
545+ long next;
546
547- /* This is the number of threads that have registered themselves in
548- the circular queue ordered_team_ids. */
549- unsigned ordered_num_used;
550+ /* This is the returned data structure for SINGLE COPYPRIVATE. */
551+ void *copyprivate;
552+ };
553
554- /* This is the team_id of the currently acknoledged owner of the ordered
555- section, or -1u if the ordered section has not been acknowledged by
556- any thread. This is distinguished from the thread that is *allowed*
557- to take the section next. */
558- unsigned ordered_owner;
559+ union {
560+ /* Link to gomp_work_share struct for next work sharing construct
561+ encountered after this one. */
562+ gomp_ptrlock_t next_ws;
563+
564+ /* gomp_work_share structs are chained in the free work share cache
565+ through this. */
566+ struct gomp_work_share *next_free;
567+ };
568
569- /* This is a circular queue that details which threads will be allowed
570- into the ordered region and in which order. When a thread allocates
571- iterations on which it is going to work, it also registers itself at
572- the end of the array. When a thread reaches the ordered region, it
573- checks to see if it is the one at the head of the queue. If not, it
574- blocks on its RELEASE semaphore. */
575- unsigned ordered_team_ids[];
576+ /* If only few threads are in the team, ordered_team_ids can point
577+ to this array which fills the padding at the end of this struct. */
578+ unsigned inline_ordered_team_ids[0];
579 };
580
581 /* This structure contains all of the thread-local data associated with
582@@ -133,21 +158,24 @@ struct gomp_team_state
583
584 /* This is the work share construct which this thread is currently
585 processing. Recall that with NOWAIT, not all threads may be
586- processing the same construct. This value is NULL when there
587- is no construct being processed. */
588+ processing the same construct. */
589 struct gomp_work_share *work_share;
590
591+ /* This is the previous work share construct or NULL if there wasn't any.
592+ When all threads are done with the current work sharing construct,
593+ the previous one can be freed. The current one can't, as its
594+ next_ws field is used. */
595+ struct gomp_work_share *last_work_share;
596+
597 /* This is the ID of this thread within the team. This value is
598 guaranteed to be between 0 and N-1, where N is the number of
599 threads in the team. */
600 unsigned team_id;
601
602- /* The work share "generation" is a number that increases by one for
603- each work share construct encountered in the dynamic flow of the
604- program. It is used to find the control data for the work share
605- when encountering it for the first time. This particular number
606- reflects the generation of the work_share member of this struct. */
607- unsigned work_share_generation;
608+#ifdef HAVE_SYNC_BUILTINS
609+ /* Number of single stmts encountered. */
610+ unsigned long single_count;
611+#endif
612
613 /* For GFS_RUNTIME loops that resolved to GFS_STATIC, this is the
614 trip number through the loop. So first time a particular loop
615@@ -163,41 +191,53 @@ struct gomp_team_state
616
617 struct gomp_team
618 {
619- /* This lock protects access to the following work shares data structures. */
620- gomp_mutex_t work_share_lock;
621-
622- /* This is a dynamically sized array containing pointers to the control
623- structs for all "live" work share constructs. Here "live" means that
624- the construct has been encountered by at least one thread, and not
625- completed by all threads. */
626- struct gomp_work_share **work_shares;
627-
628- /* The work_shares array is indexed by "generation & generation_mask".
629- The mask will be 2**N - 1, where 2**N is the size of the array. */
630- unsigned generation_mask;
631-
632- /* These two values define the bounds of the elements of the work_shares
633- array that are currently in use. */
634- unsigned oldest_live_gen;
635- unsigned num_live_gen;
636-
637 /* This is the number of threads in the current team. */
638 unsigned nthreads;
639
640+ /* This is number of gomp_work_share structs that have been allocated
641+ as a block last time. */
642+ unsigned work_share_chunk;
643+
644 /* This is the saved team state that applied to a master thread before
645 the current thread was created. */
646 struct gomp_team_state prev_ts;
647
648- /* This barrier is used for most synchronization of the team. */
649- gomp_barrier_t barrier;
650-
651 /* This semaphore should be used by the master thread instead of its
652 "native" semaphore in the thread structure. Required for nested
653 parallels, as the master is a member of two teams. */
654 gomp_sem_t master_release;
655
656- /* This array contains pointers to the release semaphore of the threads
657- in the team. */
658+ /* List of gomp_work_share structs chained through next_free fields.
659+ This is populated and taken off only by the first thread in the
660+ team encountering a new work sharing construct, in a critical
661+ section. */
662+ struct gomp_work_share *work_share_list_alloc;
663+
664+ /* List of gomp_work_share structs freed by free_work_share. New
665+ entries are atomically added to the start of the list, and
666+ alloc_work_share can safely only move all but the first entry
667+ to work_share_list alloc, as free_work_share can happen concurrently
668+ with alloc_work_share. */
669+ struct gomp_work_share *work_share_list_free;
670+
671+#ifdef HAVE_SYNC_BUILTINS
672+ /* Number of simple single regions encountered by threads in this
673+ team. */
674+ unsigned long single_count;
675+#else
676+ /* Mutex protecting addition of workshares to work_share_list_free. */
677+ gomp_mutex_t work_share_list_free_lock;
678+#endif
679+
680+ /* This barrier is used for most synchronization of the team. */
681+ gomp_barrier_t barrier;
682+
683+ /* Initial work shares, to avoid allocating any gomp_work_share
684+ structs in the common case. */
685+ struct gomp_work_share work_shares[8];
686+
687+ /* This is an array with pointers to the release semaphore
688+ of the threads in the team. */
689 gomp_sem_t *ordered_release[];
690 };
691
692@@ -242,6 +282,11 @@ extern bool gomp_dyn_var;
693 extern bool gomp_nest_var;
694 extern enum gomp_schedule_type gomp_run_sched_var;
695 extern unsigned long gomp_run_sched_chunk;
696+#ifndef HAVE_SYNC_BUILTINS
697+extern gomp_mutex_t gomp_remaining_threads_lock;
698+#endif
699+extern unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var;
700+extern unsigned long gomp_available_cpus, gomp_managed_threads;
701
702 /* The attributes to be used during thread creation. */
703 extern pthread_attr_t gomp_thread_attr;
704@@ -306,17 +351,27 @@ extern unsigned gomp_dynamic_max_threads
705
706 /* team.c */
707
708+extern struct gomp_team *gomp_new_team (unsigned);
709 extern void gomp_team_start (void (*) (void *), void *, unsigned,
710- struct gomp_work_share *);
711+ struct gomp_team *);
712 extern void gomp_team_end (void);
713
714 /* work.c */
715
716-extern struct gomp_work_share * gomp_new_work_share (bool, unsigned);
717+extern void gomp_init_work_share (struct gomp_work_share *, bool, unsigned);
718+extern void gomp_fini_work_share (struct gomp_work_share *);
719 extern bool gomp_work_share_start (bool);
720 extern void gomp_work_share_end (void);
721 extern void gomp_work_share_end_nowait (void);
722
723+static inline void
724+gomp_work_share_init_done (void)
725+{
726+ struct gomp_thread *thr = gomp_thread ();
727+ if (__builtin_expect (thr->ts.last_work_share != NULL, 1))
728+ gomp_ptrlock_set (&thr->ts.last_work_share->next_ws, thr->ts.work_share);
729+}
730+
731 #ifdef HAVE_ATTRIBUTE_VISIBILITY
732 # pragma GCC visibility pop
733 #endif
734--- libgomp/iter.c.jj 2008-03-26 14:48:34.000000000 +0100
735+++ libgomp/iter.c 2008-03-26 15:11:23.000000000 +0100
736@@ -1,4 +1,4 @@
737-/* Copyright (C) 2005 Free Software Foundation, Inc.
738+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
739 Contributed by Richard Henderson <rth@redhat.com>.
740
741 This file is part of the GNU OpenMP Library (libgomp).
742@@ -154,7 +154,7 @@ gomp_iter_dynamic_next_locked (long *pst
743 if (start == ws->end)
744 return false;
745
746- chunk = ws->chunk_size * ws->incr;
747+ chunk = ws->chunk_size;
748 left = ws->end - start;
749 if (ws->incr < 0)
750 {
751@@ -186,11 +186,38 @@ gomp_iter_dynamic_next (long *pstart, lo
752 struct gomp_work_share *ws = thr->ts.work_share;
753 long start, end, nend, chunk, incr;
754
755- start = ws->next;
756 end = ws->end;
757 incr = ws->incr;
758- chunk = ws->chunk_size * incr;
759+ chunk = ws->chunk_size;
760+
761+ if (__builtin_expect (ws->mode, 1))
762+ {
763+ long tmp = __sync_fetch_and_add (&ws->next, chunk);
764+ if (incr > 0)
765+ {
766+ if (tmp >= end)
767+ return false;
768+ nend = tmp + chunk;
769+ if (nend > end)
770+ nend = end;
771+ *pstart = tmp;
772+ *pend = nend;
773+ return true;
774+ }
775+ else
776+ {
777+ if (tmp <= end)
778+ return false;
779+ nend = tmp + chunk;
780+ if (nend < end)
781+ nend = end;
782+ *pstart = tmp;
783+ *pend = nend;
784+ return true;
785+ }
786+ }
787
788+ start = ws->next;
789 while (1)
790 {
791 long left = end - start;
792--- libgomp/work.c.jj 2007-12-07 14:41:01.000000000 +0100
793+++ libgomp/work.c 2008-03-27 12:21:51.000000000 +0100
794@@ -1,4 +1,4 @@
795-/* Copyright (C) 2005 Free Software Foundation, Inc.
796+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
797 Contributed by Richard Henderson <rth@redhat.com>.
798
799 This file is part of the GNU OpenMP Library (libgomp).
800@@ -29,39 +29,138 @@
801 of threads. */
802
803 #include "libgomp.h"
804+#include <stddef.h>
805 #include <stdlib.h>
806 #include <string.h>
807
808
809-/* Create a new work share structure. */
810+/* Allocate a new work share structure, preferably from current team's
811+ free gomp_work_share cache. */
812
813-struct gomp_work_share *
814-gomp_new_work_share (bool ordered, unsigned nthreads)
815+static struct gomp_work_share *
816+alloc_work_share (struct gomp_team *team)
817 {
818 struct gomp_work_share *ws;
819- size_t size;
820+ unsigned int i;
821
822- size = sizeof (*ws);
823- if (ordered)
824- size += nthreads * sizeof (ws->ordered_team_ids[0]);
825+ /* This is called in a critical section. */
826+ if (team->work_share_list_alloc != NULL)
827+ {
828+ ws = team->work_share_list_alloc;
829+ team->work_share_list_alloc = ws->next_free;
830+ return ws;
831+ }
832
833- ws = gomp_malloc_cleared (size);
834- gomp_mutex_init (&ws->lock);
835- ws->ordered_owner = -1;
836+#ifdef HAVE_SYNC_BUILTINS
837+ ws = team->work_share_list_free;
838+ /* We need atomic read from work_share_list_free,
839+ as free_work_share can be called concurrently. */
840+ __asm ("" : "+r" (ws));
841+
842+ if (ws && ws->next_free)
843+ {
844+ struct gomp_work_share *next = ws->next_free;
845+ ws->next_free = NULL;
846+ team->work_share_list_alloc = next->next_free;
847+ return next;
848+ }
849+#else
850+ gomp_mutex_lock (&team->work_share_list_free_lock);
851+ ws = team->work_share_list_free;
852+ if (ws)
853+ {
854+ team->work_share_list_alloc = ws->next_free;
855+ team->work_share_list_free = NULL;
856+ gomp_mutex_unlock (&team->work_share_list_free_lock);
857+ return ws;
858+ }
859+ gomp_mutex_unlock (&team->work_share_list_free_lock);
860+#endif
861
862+ team->work_share_chunk *= 2;
863+ ws = gomp_malloc (team->work_share_chunk * sizeof (struct gomp_work_share));
864+ ws->next_alloc = team->work_shares[0].next_alloc;
865+ team->work_shares[0].next_alloc = ws;
866+ team->work_share_list_alloc = &ws[1];
867+ for (i = 1; i < team->work_share_chunk - 1; i++)
868+ ws[i].next_free = &ws[i + 1];
869+ ws[i].next_free = NULL;
870 return ws;
871 }
872
873+/* Initialize an already allocated struct gomp_work_share.
874+ This shouldn't touch the next_alloc field. */
875+
876+void
877+gomp_init_work_share (struct gomp_work_share *ws, bool ordered,
878+ unsigned nthreads)
879+{
880+ gomp_mutex_init (&ws->lock);
881+ if (__builtin_expect (ordered, 0))
882+ {
883+#define INLINE_ORDERED_TEAM_IDS_CNT \
884+ ((sizeof (struct gomp_work_share) \
885+ - offsetof (struct gomp_work_share, inline_ordered_team_ids)) \
886+ / sizeof (((struct gomp_work_share *) 0)->inline_ordered_team_ids[0]))
887+
888+ if (nthreads > INLINE_ORDERED_TEAM_IDS_CNT)
889+ ws->ordered_team_ids
890+ = gomp_malloc (nthreads * sizeof (*ws->ordered_team_ids));
891+ else
892+ ws->ordered_team_ids = ws->inline_ordered_team_ids;
893+ memset (ws->ordered_team_ids, '\0',
894+ nthreads * sizeof (*ws->ordered_team_ids));
895+ ws->ordered_num_used = 0;
896+ ws->ordered_owner = -1;
897+ ws->ordered_cur = 0;
898+ }
899+ else
900+ ws->ordered_team_ids = NULL;
901+ gomp_ptrlock_init (&ws->next_ws, NULL);
902+ ws->threads_completed = 0;
903+}
904
905-/* Free a work share structure. */
906+/* Do any needed destruction of gomp_work_share fields before it
907+ is put back into free gomp_work_share cache or freed. */
908
909-static void
910-free_work_share (struct gomp_work_share *ws)
911+void
912+gomp_fini_work_share (struct gomp_work_share *ws)
913 {
914 gomp_mutex_destroy (&ws->lock);
915- free (ws);
916+ if (ws->ordered_team_ids != ws->inline_ordered_team_ids)
917+ free (ws->ordered_team_ids);
918+ gomp_ptrlock_destroy (&ws->next_ws);
919 }
920
921+/* Free a work share struct, if not orphaned, put it into current
922+ team's free gomp_work_share cache. */
923+
924+static inline void
925+free_work_share (struct gomp_team *team, struct gomp_work_share *ws)
926+{
927+ gomp_fini_work_share (ws);
928+ if (__builtin_expect (team == NULL, 0))
929+ free (ws);
930+ else
931+ {
932+ struct gomp_work_share *next_ws;
933+#ifdef HAVE_SYNC_BUILTINS
934+ do
935+ {
936+ next_ws = team->work_share_list_free;
937+ ws->next_free = next_ws;
938+ }
939+ while (!__sync_bool_compare_and_swap (&team->work_share_list_free,
940+ next_ws, ws));
941+#else
942+ gomp_mutex_lock (&team->work_share_list_free_lock);
943+ next_ws = team->work_share_list_free;
944+ ws->next_free = next_ws;
945+ team->work_share_list_free = ws;
946+ gomp_mutex_unlock (&team->work_share_list_free_lock);
947+#endif
948+ }
949+}
950
951 /* The current thread is ready to begin the next work sharing construct.
952 In all cases, thr->ts.work_share is updated to point to the new
953@@ -74,71 +173,34 @@ gomp_work_share_start (bool ordered)
954 struct gomp_thread *thr = gomp_thread ();
955 struct gomp_team *team = thr->ts.team;
956 struct gomp_work_share *ws;
957- unsigned ws_index, ws_gen;
958
959 /* Work sharing constructs can be orphaned. */
960 if (team == NULL)
961 {
962- ws = gomp_new_work_share (ordered, 1);
963+ ws = gomp_malloc (sizeof (*ws));
964+ gomp_init_work_share (ws, ordered, 1);
965 thr->ts.work_share = ws;
966- thr->ts.static_trip = 0;
967- gomp_mutex_lock (&ws->lock);
968- return true;
969+ return ws;
970 }
971
972- gomp_mutex_lock (&team->work_share_lock);
973-
974- /* This thread is beginning its next generation. */
975- ws_gen = ++thr->ts.work_share_generation;
976-
977- /* If this next generation is not newer than any other generation in
978- the team, then simply reference the existing construct. */
979- if (ws_gen - team->oldest_live_gen < team->num_live_gen)
980+ ws = thr->ts.work_share;
981+ thr->ts.last_work_share = ws;
982+ ws = gomp_ptrlock_get (&ws->next_ws);
983+ if (ws == NULL)
984 {
985- ws_index = ws_gen & team->generation_mask;
986- ws = team->work_shares[ws_index];
987+ /* This thread encountered a new ws first. */
988+ struct gomp_work_share *ws = alloc_work_share (team);
989+ gomp_init_work_share (ws, ordered, team->nthreads);
990 thr->ts.work_share = ws;
991- thr->ts.static_trip = 0;
992-
993- gomp_mutex_lock (&ws->lock);
994- gomp_mutex_unlock (&team->work_share_lock);
995-
996- return false;
997+ return true;
998 }
999-
1000- /* Resize the work shares queue if we've run out of space. */
1001- if (team->num_live_gen++ == team->generation_mask)
1002+ else
1003 {
1004- team->work_shares = gomp_realloc (team->work_shares,
1005- 2 * team->num_live_gen
1006- * sizeof (*team->work_shares));
1007-
1008- /* Unless oldest_live_gen is zero, the sequence of live elements
1009- wraps around the end of the array. If we do nothing, we break
1010- lookup of the existing elements. Fix that by unwrapping the
1011- data from the front to the end. */
1012- if (team->oldest_live_gen > 0)
1013- memcpy (team->work_shares + team->num_live_gen,
1014- team->work_shares,
1015- (team->oldest_live_gen & team->generation_mask)
1016- * sizeof (*team->work_shares));
1017-
1018- team->generation_mask = team->generation_mask * 2 + 1;
1019- }
1020-
1021- ws_index = ws_gen & team->generation_mask;
1022- ws = gomp_new_work_share (ordered, team->nthreads);
1023- thr->ts.work_share = ws;
1024- thr->ts.static_trip = 0;
1025- team->work_shares[ws_index] = ws;
1026-
1027- gomp_mutex_lock (&ws->lock);
1028- gomp_mutex_unlock (&team->work_share_lock);
1029-
1030- return true;
1031+ thr->ts.work_share = ws;
1032+ return false;
1033+ }
1034 }
1035
1036-
1037 /* The current thread is done with its current work sharing construct.
1038 This version does imply a barrier at the end of the work-share. */
1039
1040@@ -147,36 +209,28 @@ gomp_work_share_end (void)
1041 {
1042 struct gomp_thread *thr = gomp_thread ();
1043 struct gomp_team *team = thr->ts.team;
1044- struct gomp_work_share *ws = thr->ts.work_share;
1045- bool last;
1046-
1047- thr->ts.work_share = NULL;
1048+ gomp_barrier_state_t bstate;
1049
1050 /* Work sharing constructs can be orphaned. */
1051 if (team == NULL)
1052 {
1053- free_work_share (ws);
1054+ free_work_share (NULL, thr->ts.work_share);
1055+ thr->ts.work_share = NULL;
1056 return;
1057 }
1058
1059- last = gomp_barrier_wait_start (&team->barrier);
1060+ bstate = gomp_barrier_wait_start (&team->barrier);
1061
1062- if (last)
1063+ if (gomp_barrier_last_thread (bstate))
1064 {
1065- unsigned ws_index;
1066-
1067- ws_index = thr->ts.work_share_generation & team->generation_mask;
1068- team->work_shares[ws_index] = NULL;
1069- team->oldest_live_gen++;
1070- team->num_live_gen = 0;
1071-
1072- free_work_share (ws);
1073+ if (__builtin_expect (thr->ts.last_work_share != NULL, 1))
1074+ free_work_share (team, thr->ts.last_work_share);
1075 }
1076
1077- gomp_barrier_wait_end (&team->barrier, last);
1078+ gomp_barrier_wait_end (&team->barrier, bstate);
1079+ thr->ts.last_work_share = NULL;
1080 }
1081
1082-
1083 /* The current thread is done with its current work sharing construct.
1084 This version does NOT imply a barrier at the end of the work-share. */
1085
1086@@ -188,15 +242,17 @@ gomp_work_share_end_nowait (void)
1087 struct gomp_work_share *ws = thr->ts.work_share;
1088 unsigned completed;
1089
1090- thr->ts.work_share = NULL;
1091-
1092 /* Work sharing constructs can be orphaned. */
1093 if (team == NULL)
1094 {
1095- free_work_share (ws);
1096+ free_work_share (NULL, ws);
1097+ thr->ts.work_share = NULL;
1098 return;
1099 }
1100
1101+ if (__builtin_expect (thr->ts.last_work_share == NULL, 0))
1102+ return;
1103+
1104 #ifdef HAVE_SYNC_BUILTINS
1105 completed = __sync_add_and_fetch (&ws->threads_completed, 1);
1106 #else
1107@@ -206,18 +262,6 @@ gomp_work_share_end_nowait (void)
1108 #endif
1109
1110 if (completed == team->nthreads)
1111- {
1112- unsigned ws_index;
1113-
1114- gomp_mutex_lock (&team->work_share_lock);
1115-
1116- ws_index = thr->ts.work_share_generation & team->generation_mask;
1117- team->work_shares[ws_index] = NULL;
1118- team->oldest_live_gen++;
1119- team->num_live_gen--;
1120-
1121- gomp_mutex_unlock (&team->work_share_lock);
1122-
1123- free_work_share (ws);
1124- }
1125+ free_work_share (team, thr->ts.last_work_share);
1126+ thr->ts.last_work_share = NULL;
1127 }
1128--- libgomp/single.c.jj 2007-12-07 14:41:01.000000000 +0100
1129+++ libgomp/single.c 2008-03-26 15:11:32.000000000 +0100
1130@@ -1,4 +1,4 @@
1131-/* Copyright (C) 2005 Free Software Foundation, Inc.
1132+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
1133 Contributed by Richard Henderson <rth@redhat.com>.
1134
1135 This file is part of the GNU OpenMP Library (libgomp).
1136@@ -37,10 +37,24 @@
1137 bool
1138 GOMP_single_start (void)
1139 {
1140+#ifdef HAVE_SYNC_BUILTINS
1141+ struct gomp_thread *thr = gomp_thread ();
1142+ struct gomp_team *team = thr->ts.team;
1143+ unsigned long single_count;
1144+
1145+ if (__builtin_expect (team == NULL, 0))
1146+ return true;
1147+
1148+ single_count = thr->ts.single_count++;
1149+ return __sync_bool_compare_and_swap (&team->single_count, single_count,
1150+ single_count + 1L);
1151+#else
1152 bool ret = gomp_work_share_start (false);
1153- gomp_mutex_unlock (&gomp_thread ()->ts.work_share->lock);
1154+ if (ret)
1155+ gomp_work_share_init_done ();
1156 gomp_work_share_end_nowait ();
1157 return ret;
1158+#endif
1159 }
1160
1161 /* This routine is called when first encountering a SINGLE construct that
1162@@ -57,10 +71,12 @@ GOMP_single_copy_start (void)
1163 void *ret;
1164
1165 first = gomp_work_share_start (false);
1166- gomp_mutex_unlock (&thr->ts.work_share->lock);
1167
1168 if (first)
1169- ret = NULL;
1170+ {
1171+ gomp_work_share_init_done ();
1172+ ret = NULL;
1173+ }
1174 else
1175 {
1176 gomp_barrier_wait (&thr->ts.team->barrier);
1177--- libgomp/loop.c.jj 2007-12-07 14:41:01.000000000 +0100
1178+++ libgomp/loop.c 2008-03-26 18:47:04.000000000 +0100
1179@@ -27,8 +27,9 @@
1180
1181 /* This file handles the LOOP (FOR/DO) construct. */
1182
1183-#include "libgomp.h"
1184+#include <limits.h>
1185 #include <stdlib.h>
1186+#include "libgomp.h"
1187
1188
1189 /* Initialize the given work share construct from the given arguments. */
1190@@ -44,6 +45,39 @@ gomp_loop_init (struct gomp_work_share *
1191 ? start : end;
1192 ws->incr = incr;
1193 ws->next = start;
1194+ if (sched == GFS_DYNAMIC)
1195+ {
1196+ ws->chunk_size *= incr;
1197+
1198+#ifdef HAVE_SYNC_BUILTINS
1199+ {
1200+ /* For dynamic scheduling prepare things to make each iteration
1201+ faster. */
1202+ struct gomp_thread *thr = gomp_thread ();
1203+ struct gomp_team *team = thr->ts.team;
1204+ long nthreads = team ? team->nthreads : 1;
1205+
1206+ if (__builtin_expect (incr > 0, 1))
1207+ {
1208+ /* Cheap overflow protection. */
1209+ if (__builtin_expect ((nthreads | ws->chunk_size)
1210+ >= 1UL << (sizeof (long)
1211+ * __CHAR_BIT__ / 2 - 1), 0))
1212+ ws->mode = 0;
1213+ else
1214+ ws->mode = ws->end < (LONG_MAX
1215+ - (nthreads + 1) * ws->chunk_size);
1216+ }
1217+ /* Cheap overflow protection. */
1218+ else if (__builtin_expect ((nthreads | -ws->chunk_size)
1219+ >= 1UL << (sizeof (long)
1220+ * __CHAR_BIT__ / 2 - 1), 0))
1221+ ws->mode = 0;
1222+ else
1223+ ws->mode = ws->end > (nthreads + 1) * -ws->chunk_size - LONG_MAX;
1224+ }
1225+#endif
1226+ }
1227 }
1228
1229 /* The *_start routines are called when first encountering a loop construct
1230@@ -68,10 +102,13 @@ gomp_loop_static_start (long start, long
1231 {
1232 struct gomp_thread *thr = gomp_thread ();
1233
1234+ thr->ts.static_trip = 0;
1235 if (gomp_work_share_start (false))
1236- gomp_loop_init (thr->ts.work_share, start, end, incr,
1237- GFS_STATIC, chunk_size);
1238- gomp_mutex_unlock (&thr->ts.work_share->lock);
1239+ {
1240+ gomp_loop_init (thr->ts.work_share, start, end, incr,
1241+ GFS_STATIC, chunk_size);
1242+ gomp_work_share_init_done ();
1243+ }
1244
1245 return !gomp_iter_static_next (istart, iend);
1246 }
1247@@ -84,13 +121,16 @@ gomp_loop_dynamic_start (long start, lon
1248 bool ret;
1249
1250 if (gomp_work_share_start (false))
1251- gomp_loop_init (thr->ts.work_share, start, end, incr,
1252- GFS_DYNAMIC, chunk_size);
1253+ {
1254+ gomp_loop_init (thr->ts.work_share, start, end, incr,
1255+ GFS_DYNAMIC, chunk_size);
1256+ gomp_work_share_init_done ();
1257+ }
1258
1259 #ifdef HAVE_SYNC_BUILTINS
1260- gomp_mutex_unlock (&thr->ts.work_share->lock);
1261 ret = gomp_iter_dynamic_next (istart, iend);
1262 #else
1263+ gomp_mutex_lock (&thr->ts.work_share->lock);
1264 ret = gomp_iter_dynamic_next_locked (istart, iend);
1265 gomp_mutex_unlock (&thr->ts.work_share->lock);
1266 #endif
1267@@ -106,13 +146,16 @@ gomp_loop_guided_start (long start, long
1268 bool ret;
1269
1270 if (gomp_work_share_start (false))
1271- gomp_loop_init (thr->ts.work_share, start, end, incr,
1272- GFS_GUIDED, chunk_size);
1273+ {
1274+ gomp_loop_init (thr->ts.work_share, start, end, incr,
1275+ GFS_GUIDED, chunk_size);
1276+ gomp_work_share_init_done ();
1277+ }
1278
1279 #ifdef HAVE_SYNC_BUILTINS
1280- gomp_mutex_unlock (&thr->ts.work_share->lock);
1281 ret = gomp_iter_guided_next (istart, iend);
1282 #else
1283+ gomp_mutex_lock (&thr->ts.work_share->lock);
1284 ret = gomp_iter_guided_next_locked (istart, iend);
1285 gomp_mutex_unlock (&thr->ts.work_share->lock);
1286 #endif
1287@@ -149,13 +192,14 @@ gomp_loop_ordered_static_start (long sta
1288 {
1289 struct gomp_thread *thr = gomp_thread ();
1290
1291+ thr->ts.static_trip = 0;
1292 if (gomp_work_share_start (true))
1293 {
1294 gomp_loop_init (thr->ts.work_share, start, end, incr,
1295 GFS_STATIC, chunk_size);
1296 gomp_ordered_static_init ();
1297+ gomp_work_share_init_done ();
1298 }
1299- gomp_mutex_unlock (&thr->ts.work_share->lock);
1300
1301 return !gomp_iter_static_next (istart, iend);
1302 }
1303@@ -168,8 +212,14 @@ gomp_loop_ordered_dynamic_start (long st
1304 bool ret;
1305
1306 if (gomp_work_share_start (true))
1307- gomp_loop_init (thr->ts.work_share, start, end, incr,
1308- GFS_DYNAMIC, chunk_size);
1309+ {
1310+ gomp_loop_init (thr->ts.work_share, start, end, incr,
1311+ GFS_DYNAMIC, chunk_size);
1312+ gomp_mutex_lock (&thr->ts.work_share->lock);
1313+ gomp_work_share_init_done ();
1314+ }
1315+ else
1316+ gomp_mutex_lock (&thr->ts.work_share->lock);
1317
1318 ret = gomp_iter_dynamic_next_locked (istart, iend);
1319 if (ret)
1320@@ -187,8 +237,14 @@ gomp_loop_ordered_guided_start (long sta
1321 bool ret;
1322
1323 if (gomp_work_share_start (true))
1324- gomp_loop_init (thr->ts.work_share, start, end, incr,
1325- GFS_GUIDED, chunk_size);
1326+ {
1327+ gomp_loop_init (thr->ts.work_share, start, end, incr,
1328+ GFS_GUIDED, chunk_size);
1329+ gomp_mutex_lock (&thr->ts.work_share->lock);
1330+ gomp_work_share_init_done ();
1331+ }
1332+ else
1333+ gomp_mutex_lock (&thr->ts.work_share->lock);
1334
1335 ret = gomp_iter_guided_next_locked (istart, iend);
1336 if (ret)
1337@@ -375,12 +431,12 @@ gomp_parallel_loop_start (void (*fn) (vo
1338 long incr, enum gomp_schedule_type sched,
1339 long chunk_size)
1340 {
1341- struct gomp_work_share *ws;
1342+ struct gomp_team *team;
1343
1344 num_threads = gomp_resolve_num_threads (num_threads);
1345- ws = gomp_new_work_share (false, num_threads);
1346- gomp_loop_init (ws, start, end, incr, sched, chunk_size);
1347- gomp_team_start (fn, data, num_threads, ws);
1348+ team = gomp_new_team (num_threads);
1349+ gomp_loop_init (&team->work_shares[0], start, end, incr, sched, chunk_size);
1350+ gomp_team_start (fn, data, num_threads, team);
1351 }
1352
1353 void
1354--- libgomp/Makefile.in.jj 2008-01-10 20:53:47.000000000 +0100
1355+++ libgomp/Makefile.in 2008-03-26 18:51:01.000000000 +0100
1356@@ -83,7 +83,7 @@ libgomp_la_LIBADD =
1357 am_libgomp_la_OBJECTS = alloc.lo barrier.lo critical.lo env.lo \
1358 error.lo iter.lo loop.lo ordered.lo parallel.lo sections.lo \
1359 single.lo team.lo work.lo lock.lo mutex.lo proc.lo sem.lo \
1360- bar.lo time.lo fortran.lo affinity.lo
1361+ bar.lo ptrlock.lo time.lo fortran.lo affinity.lo
1362 libgomp_la_OBJECTS = $(am_libgomp_la_OBJECTS)
1363 DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
1364 depcomp = $(SHELL) $(top_srcdir)/../depcomp
1365@@ -292,7 +292,7 @@ libgomp_version_info = -version-info $(l
1366 libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script)
1367 libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \
1368 loop.c ordered.c parallel.c sections.c single.c team.c work.c \
1369- lock.c mutex.c proc.c sem.c bar.c time.c fortran.c affinity.c
1370+ lock.c mutex.c proc.c sem.c bar.c ptrlock.c time.c fortran.c affinity.c
1371
1372 nodist_noinst_HEADERS = libgomp_f.h
1373 nodist_libsubinclude_HEADERS = omp.h
1374@@ -434,6 +434,7 @@ distclean-compile:
1375 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ordered.Plo@am__quote@
1376 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parallel.Plo@am__quote@
1377 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/proc.Plo@am__quote@
1378+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptrlock.Plo@am__quote@
1379 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sections.Plo@am__quote@
1380 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sem.Plo@am__quote@
1381 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/single.Plo@am__quote@
1382--- libgomp/testsuite/libgomp.c/loop-4.c.jj 2008-03-26 18:47:04.000000000 +0100
1383+++ libgomp/testsuite/libgomp.c/loop-4.c 2008-03-26 18:47:04.000000000 +0100
1384@@ -0,0 +1,28 @@
1385+/* { dg-do run } */
1386+
1387+extern void abort (void);
1388+
1389+int
1390+main (void)
1391+{
1392+ int e = 0;
1393+#pragma omp parallel num_threads (4) reduction(+:e)
1394+ {
1395+ long i;
1396+ #pragma omp for schedule(dynamic,1)
1397+ for (i = __LONG_MAX__ - 30001; i <= __LONG_MAX__ - 10001; i += 10000)
1398+ if (i != __LONG_MAX__ - 30001
1399+ && i != __LONG_MAX__ - 20001
1400+ && i != __LONG_MAX__ - 10001)
1401+ e = 1;
1402+ #pragma omp for schedule(dynamic,1)
1403+ for (i = -__LONG_MAX__ + 30000; i >= -__LONG_MAX__ + 10000; i -= 10000)
1404+ if (i != -__LONG_MAX__ + 30000
1405+ && i != -__LONG_MAX__ + 20000
1406+ && i != -__LONG_MAX__ + 10000)
1407+ e = 1;
1408+ }
1409+ if (e)
1410+ abort ();
1411+ return 0;
1412+}
1413--- libgomp/Makefile.am.jj 2007-12-07 14:41:01.000000000 +0100
1414+++ libgomp/Makefile.am 2008-03-26 15:15:19.000000000 +0100
1415@@ -31,7 +31,7 @@ libgomp_la_LDFLAGS = $(libgomp_version_i
1416
1417 libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \
1418 loop.c ordered.c parallel.c sections.c single.c team.c work.c \
1419- lock.c mutex.c proc.c sem.c bar.c time.c fortran.c affinity.c
1420+ lock.c mutex.c proc.c sem.c bar.c ptrlock.c time.c fortran.c affinity.c
1421
1422 nodist_noinst_HEADERS = libgomp_f.h
1423 nodist_libsubinclude_HEADERS = omp.h
1424--- libgomp/team.c.jj 2007-12-07 14:41:01.000000000 +0100
1425+++ libgomp/team.c 2008-03-27 12:22:26.000000000 +0100
1426@@ -94,7 +94,7 @@ gomp_thread_start (void *xdata)
1427 {
1428 gomp_barrier_wait (&thr->ts.team->barrier);
1429 local_fn (local_data);
1430- gomp_barrier_wait (&thr->ts.team->barrier);
1431+ gomp_barrier_wait_last (&thr->ts.team->barrier);
1432 }
1433 else
1434 {
1435@@ -114,11 +114,10 @@ gomp_thread_start (void *xdata)
1436 thr->data = NULL;
1437 thr->ts.team = NULL;
1438 thr->ts.work_share = NULL;
1439+ thr->ts.last_work_share = NULL;
1440 thr->ts.team_id = 0;
1441- thr->ts.work_share_generation = 0;
1442- thr->ts.static_trip = 0;
1443
1444- gomp_barrier_wait (&team->barrier);
1445+ gomp_barrier_wait_last (&team->barrier);
1446 gomp_barrier_wait (&gomp_threads_dock);
1447
1448 local_fn = thr->fn;
1449@@ -133,21 +132,29 @@ gomp_thread_start (void *xdata)
1450
1451 /* Create a new team data structure. */
1452
1453-static struct gomp_team *
1454-new_team (unsigned nthreads, struct gomp_work_share *work_share)
1455+struct gomp_team *
1456+gomp_new_team (unsigned nthreads)
1457 {
1458 struct gomp_team *team;
1459 size_t size;
1460+ int i;
1461
1462 size = sizeof (*team) + nthreads * sizeof (team->ordered_release[0]);
1463 team = gomp_malloc (size);
1464- gomp_mutex_init (&team->work_share_lock);
1465
1466- team->work_shares = gomp_malloc (4 * sizeof (struct gomp_work_share *));
1467- team->generation_mask = 3;
1468- team->oldest_live_gen = work_share == NULL;
1469- team->num_live_gen = work_share != NULL;
1470- team->work_shares[0] = work_share;
1471+ team->work_share_chunk = 8;
1472+#ifdef HAVE_SYNC_BUILTINS
1473+ team->single_count = 0;
1474+#else
1475+ gomp_mutex_init (&team->work_share_list_free_lock);
1476+#endif
1477+ gomp_init_work_share (&team->work_shares[0], false, nthreads);
1478+ team->work_shares[0].next_alloc = NULL;
1479+ team->work_share_list_free = NULL;
1480+ team->work_share_list_alloc = &team->work_shares[1];
1481+ for (i = 1; i < 7; i++)
1482+ team->work_shares[i].next_free = &team->work_shares[i + 1];
1483+ team->work_shares[i].next_free = NULL;
1484
1485 team->nthreads = nthreads;
1486 gomp_barrier_init (&team->barrier, nthreads);
1487@@ -164,10 +171,22 @@ new_team (unsigned nthreads, struct gomp
1488 static void
1489 free_team (struct gomp_team *team)
1490 {
1491- free (team->work_shares);
1492- gomp_mutex_destroy (&team->work_share_lock);
1493+ if (__builtin_expect (team->work_shares[0].next_alloc != NULL, 0))
1494+ {
1495+ struct gomp_work_share *ws = team->work_shares[0].next_alloc;
1496+ do
1497+ {
1498+ struct gomp_work_share *next_ws = ws->next_alloc;
1499+ free (ws);
1500+ ws = next_ws;
1501+ }
1502+ while (ws != NULL);
1503+ }
1504 gomp_barrier_destroy (&team->barrier);
1505 gomp_sem_destroy (&team->master_release);
1506+#ifndef HAVE_SYNC_BUILTINS
1507+ gomp_mutex_destroy (&team->work_share_list_free_lock);
1508+#endif
1509 free (team);
1510 }
1511
1512@@ -176,11 +195,10 @@ free_team (struct gomp_team *team)
1513
1514 void
1515 gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads,
1516- struct gomp_work_share *work_share)
1517+ struct gomp_team *team)
1518 {
1519 struct gomp_thread_start_data *start_data;
1520 struct gomp_thread *thr, *nthr;
1521- struct gomp_team *team;
1522 bool nested;
1523 unsigned i, n, old_threads_used = 0;
1524 pthread_attr_t thread_attr, *attr;
1525@@ -188,17 +206,18 @@ gomp_team_start (void (*fn) (void *), vo
1526 thr = gomp_thread ();
1527 nested = thr->ts.team != NULL;
1528
1529- team = new_team (nthreads, work_share);
1530-
1531 /* Always save the previous state, even if this isn't a nested team.
1532 In particular, we should save any work share state from an outer
1533 orphaned work share construct. */
1534 team->prev_ts = thr->ts;
1535
1536 thr->ts.team = team;
1537- thr->ts.work_share = work_share;
1538 thr->ts.team_id = 0;
1539- thr->ts.work_share_generation = 0;
1540+ thr->ts.work_share = &team->work_shares[0];
1541+ thr->ts.last_work_share = NULL;
1542+#ifdef HAVE_SYNC_BUILTINS
1543+ thr->ts.single_count = 0;
1544+#endif
1545 thr->ts.static_trip = 0;
1546
1547 if (nthreads == 1)
1548@@ -241,9 +260,12 @@ gomp_team_start (void (*fn) (void *), vo
1549 {
1550 nthr = gomp_threads[i];
1551 nthr->ts.team = team;
1552- nthr->ts.work_share = work_share;
1553+ nthr->ts.work_share = &team->work_shares[0];
1554+ nthr->ts.last_work_share = NULL;
1555 nthr->ts.team_id = i;
1556- nthr->ts.work_share_generation = 0;
1557+#ifdef HAVE_SYNC_BUILTINS
1558+ nthr->ts.single_count = 0;
1559+#endif
1560 nthr->ts.static_trip = 0;
1561 nthr->fn = fn;
1562 nthr->data = data;
1563@@ -266,8 +288,24 @@ gomp_team_start (void (*fn) (void *), vo
1564 }
1565 }
1566
1567+ if (__builtin_expect (nthreads > old_threads_used, 0))
1568+ {
1569+ long diff = (long) nthreads - (long) old_threads_used;
1570+
1571+ if (old_threads_used == 0)
1572+ --diff;
1573+
1574+#ifdef HAVE_SYNC_BUILTINS
1575+ __sync_fetch_and_add (&gomp_managed_threads, diff);
1576+#else
1577+ gomp_mutex_lock (&gomp_remaining_threads_lock);
1578+ gomp_managed_threads += diff;
1579+ gomp_mutex_unlock (&gomp_remaining_threads_lock);
1580+#endif
1581+ }
1582+
1583 attr = &gomp_thread_attr;
1584- if (gomp_cpu_affinity != NULL)
1585+ if (__builtin_expect (gomp_cpu_affinity != NULL, 0))
1586 {
1587 size_t stacksize;
1588 pthread_attr_init (&thread_attr);
1589@@ -287,9 +325,12 @@ gomp_team_start (void (*fn) (void *), vo
1590 int err;
1591
1592 start_data->ts.team = team;
1593- start_data->ts.work_share = work_share;
1594+ start_data->ts.work_share = &team->work_shares[0];
1595+ start_data->ts.last_work_share = NULL;
1596 start_data->ts.team_id = i;
1597- start_data->ts.work_share_generation = 0;
1598+#ifdef HAVE_SYNC_BUILTINS
1599+ start_data->ts.single_count = 0;
1600+#endif
1601 start_data->ts.static_trip = 0;
1602 start_data->fn = fn;
1603 start_data->fn_data = data;
1604@@ -303,7 +344,7 @@ gomp_team_start (void (*fn) (void *), vo
1605 gomp_fatal ("Thread creation failed: %s", strerror (err));
1606 }
1607
1608- if (gomp_cpu_affinity != NULL)
1609+ if (__builtin_expect (gomp_cpu_affinity != NULL, 0))
1610 pthread_attr_destroy (&thread_attr);
1611
1612 do_release:
1613@@ -313,8 +354,20 @@ gomp_team_start (void (*fn) (void *), vo
1614 that should arrive back at the end of this team. The extra
1615 threads should be exiting. Note that we arrange for this test
1616 to never be true for nested teams. */
1617- if (nthreads < old_threads_used)
1618- gomp_barrier_reinit (&gomp_threads_dock, nthreads);
1619+ if (__builtin_expect (nthreads < old_threads_used, 0))
1620+ {
1621+ long diff = (long) nthreads - (long) old_threads_used;
1622+
1623+ gomp_barrier_reinit (&gomp_threads_dock, nthreads);
1624+
1625+#ifdef HAVE_SYNC_BUILTINS
1626+ __sync_fetch_and_add (&gomp_managed_threads, diff);
1627+#else
1628+ gomp_mutex_lock (&gomp_remaining_threads_lock);
1629+ gomp_managed_threads += diff;
1630+ gomp_mutex_unlock (&gomp_remaining_threads_lock);
1631+#endif
1632+ }
1633 }
1634
1635
1636@@ -329,8 +382,21 @@ gomp_team_end (void)
1637
1638 gomp_barrier_wait (&team->barrier);
1639
1640+ gomp_fini_work_share (thr->ts.work_share);
1641+
1642 thr->ts = team->prev_ts;
1643
1644+ if (__builtin_expect (thr->ts.team != NULL, 0))
1645+ {
1646+#ifdef HAVE_SYNC_BUILTINS
1647+ __sync_fetch_and_add (&gomp_managed_threads, 1L - team->nthreads);
1648+#else
1649+ gomp_mutex_lock (&gomp_remaining_threads_lock);
1650+ gomp_managed_threads -= team->nthreads - 1L;
1651+ gomp_mutex_unlock (&gomp_remaining_threads_lock);
1652+#endif
1653+ }
1654+
1655 free_team (team);
1656 }
1657
1658--- libgomp/config/posix/bar.h.jj 2007-12-07 14:41:01.000000000 +0100
1659+++ libgomp/config/posix/bar.h 2008-03-26 15:11:32.000000000 +0100
1660@@ -1,4 +1,4 @@
1661-/* Copyright (C) 2005 Free Software Foundation, Inc.
1662+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
1663 Contributed by Richard Henderson <rth@redhat.com>.
1664
1665 This file is part of the GNU OpenMP Library (libgomp).
1666@@ -46,18 +46,32 @@ typedef struct
1667 unsigned total;
1668 unsigned arrived;
1669 } gomp_barrier_t;
1670+typedef bool gomp_barrier_state_t;
1671
1672 extern void gomp_barrier_init (gomp_barrier_t *, unsigned);
1673 extern void gomp_barrier_reinit (gomp_barrier_t *, unsigned);
1674 extern void gomp_barrier_destroy (gomp_barrier_t *);
1675
1676 extern void gomp_barrier_wait (gomp_barrier_t *);
1677-extern void gomp_barrier_wait_end (gomp_barrier_t *, bool);
1678+extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t);
1679
1680-static inline bool gomp_barrier_wait_start (gomp_barrier_t *bar)
1681+static inline gomp_barrier_state_t
1682+gomp_barrier_wait_start (gomp_barrier_t *bar)
1683 {
1684 gomp_mutex_lock (&bar->mutex1);
1685 return ++bar->arrived == bar->total;
1686 }
1687
1688+static inline bool
1689+gomp_barrier_last_thread (gomp_barrier_state_t state)
1690+{
1691+ return state;
1692+}
1693+
1694+static inline void
1695+gomp_barrier_wait_last (gomp_barrier_t *bar)
1696+{
1697+ gomp_barrier_wait (bar);
1698+}
1699+
1700 #endif /* GOMP_BARRIER_H */
1701--- libgomp/config/posix/ptrlock.h.jj 2008-03-26 15:11:32.000000000 +0100
1702+++ libgomp/config/posix/ptrlock.h 2008-03-26 15:11:32.000000000 +0100
1703@@ -0,0 +1,69 @@
1704+/* Copyright (C) 2008 Free Software Foundation, Inc.
1705+ Contributed by Jakub Jelinek <jakub@redhat.com>.
1706+
1707+ This file is part of the GNU OpenMP Library (libgomp).
1708+
1709+ Libgomp is free software; you can redistribute it and/or modify it
1710+ under the terms of the GNU Lesser General Public License as published by
1711+ the Free Software Foundation; either version 2.1 of the License, or
1712+ (at your option) any later version.
1713+
1714+ Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
1715+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1716+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
1717+ more details.
1718+
1719+ You should have received a copy of the GNU Lesser General Public License
1720+ along with libgomp; see the file COPYING.LIB. If not, write to the
1721+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
1722+ MA 02110-1301, USA. */
1723+
1724+/* As a special exception, if you link this library with other files, some
1725+ of which are compiled with GCC, to produce an executable, this library
1726+ does not by itself cause the resulting executable to be covered by the
1727+ GNU General Public License. This exception does not however invalidate
1728+ any other reasons why the executable file might be covered by the GNU
1729+ General Public License. */
1730+
1731+/* This is a Linux specific implementation of a mutex synchronization
1732+ mechanism for libgomp. This type is private to the library. This
1733+ implementation uses atomic instructions and the futex syscall. */
1734+
1735+#ifndef GOMP_PTRLOCK_H
1736+#define GOMP_PTRLOCK_H 1
1737+
1738+typedef struct { void *ptr; gomp_mutex_t lock; } gomp_ptrlock_t;
1739+
1740+static inline void gomp_ptrlock_init (gomp_ptrlock_t *ptrlock, void *ptr)
1741+{
1742+ ptrlock->ptr = ptr;
1743+ gomp_mutex_init (&ptrlock->lock);
1744+}
1745+
1746+static inline void *gomp_ptrlock_get (gomp_ptrlock_t *ptrlock)
1747+{
1748+ if (ptrlock->ptr != NULL)
1749+ return ptrlock->ptr;
1750+
1751+ gomp_mutex_lock (&ptrlock->lock);
1752+ if (ptrlock->ptr != NULL)
1753+ {
1754+ gomp_mutex_unlock (&ptrlock->lock);
1755+ return ptrlock->ptr;
1756+ }
1757+
1758+ return NULL;
1759+}
1760+
1761+static inline void gomp_ptrlock_set (gomp_ptrlock_t *ptrlock, void *ptr)
1762+{
1763+ ptrlock->ptr = ptr;
1764+ gomp_mutex_unlock (&ptrlock->lock);
1765+}
1766+
1767+static inline void gomp_ptrlock_destroy (gomp_ptrlock_t *ptrlock)
1768+{
1769+ gomp_mutex_destroy (&ptrlock->lock);
1770+}
1771+
1772+#endif /* GOMP_PTRLOCK_H */
1773--- libgomp/config/posix/ptrlock.c.jj 2008-03-26 15:11:32.000000000 +0100
1774+++ libgomp/config/posix/ptrlock.c 2008-03-26 15:11:32.000000000 +0100
1775@@ -0,0 +1 @@
1776+/* Everything is in the header. */
1777--- libgomp/config/posix/bar.c.jj 2007-12-07 14:41:01.000000000 +0100
1778+++ libgomp/config/posix/bar.c 2008-03-26 15:11:32.000000000 +0100
1779@@ -1,4 +1,4 @@
1780-/* Copyright (C) 2005 Free Software Foundation, Inc.
1781+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
1782 Contributed by Richard Henderson <rth@redhat.com>.
1783
1784 This file is part of the GNU OpenMP Library (libgomp).
1785@@ -70,7 +70,7 @@ gomp_barrier_reinit (gomp_barrier_t *bar
1786 }
1787
1788 void
1789-gomp_barrier_wait_end (gomp_barrier_t *bar, bool last)
1790+gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t last)
1791 {
1792 unsigned int n;
1793
1794--- libgomp/config/linux/alpha/futex.h.jj 2007-12-07 14:41:00.000000000 +0100
1795+++ libgomp/config/linux/alpha/futex.h 2008-03-26 15:11:32.000000000 +0100
1796@@ -1,4 +1,4 @@
1797-/* Copyright (C) 2005 Free Software Foundation, Inc.
1798+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
1799 Contributed by Richard Henderson <rth@redhat.com>.
1800
1801 This file is part of the GNU OpenMP Library (libgomp).
1802@@ -30,8 +30,6 @@
1803 #ifndef SYS_futex
1804 #define SYS_futex 394
1805 #endif
1806-#define FUTEX_WAIT 0
1807-#define FUTEX_WAKE 1
1808
1809
1810 static inline void
1811@@ -45,7 +43,7 @@ futex_wait (int *addr, int val)
1812
1813 sc_0 = SYS_futex;
1814 sc_16 = (long) addr;
1815- sc_17 = FUTEX_WAIT;
1816+ sc_17 = gomp_futex_wait;
1817 sc_18 = val;
1818 sc_19 = 0;
1819 __asm volatile ("callsys"
1820@@ -53,6 +51,20 @@ futex_wait (int *addr, int val)
1821 : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18), "1"(sc_19)
1822 : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",
1823 "$22", "$23", "$24", "$25", "$27", "$28", "memory");
1824+ if (__builtin_expect (sc_19, 0) && sc_0 == ENOSYS)
1825+ {
1826+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
1827+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
1828+ sc_0 = SYS_futex;
1829+ sc_17 &= ~FUTEX_PRIVATE_FLAG;
1830+ sc_19 = 0;
1831+ __asm volatile ("callsys"
1832+ : "=r" (sc_0), "=r"(sc_19)
1833+ : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18),
1834+ "1"(sc_19)
1835+ : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",
1836+ "$22", "$23", "$24", "$25", "$27", "$28", "memory");
1837+ }
1838 }
1839
1840 static inline void
1841@@ -66,11 +78,35 @@ futex_wake (int *addr, int count)
1842
1843 sc_0 = SYS_futex;
1844 sc_16 = (long) addr;
1845- sc_17 = FUTEX_WAKE;
1846+ sc_17 = gomp_futex_wake;
1847 sc_18 = count;
1848 __asm volatile ("callsys"
1849 : "=r" (sc_0), "=r"(sc_19)
1850 : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18)
1851 : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",
1852 "$22", "$23", "$24", "$25", "$27", "$28", "memory");
1853+ if (__builtin_expect (sc_19, 0) && sc_0 == ENOSYS)
1854+ {
1855+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
1856+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
1857+ sc_0 = SYS_futex;
1858+ sc_17 &= ~FUTEX_PRIVATE_FLAG;
1859+ __asm volatile ("callsys"
1860+ : "=r" (sc_0), "=r"(sc_19)
1861+ : "0"(sc_0), "r" (sc_16), "r"(sc_17), "r"(sc_18)
1862+ : "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",
1863+ "$22", "$23", "$24", "$25", "$27", "$28", "memory");
1864+ }
1865+}
1866+
1867+static inline void
1868+cpu_relax (void)
1869+{
1870+ __asm volatile ("" : : : "memory");
1871+}
1872+
1873+static inline void
1874+atomic_write_barrier (void)
1875+{
1876+ __asm volatile ("wmb" : : : "memory");
1877 }
1878--- libgomp/config/linux/affinity.c.jj 2007-12-07 14:41:00.000000000 +0100
1879+++ libgomp/config/linux/affinity.c 2008-03-26 15:11:32.000000000 +0100
1880@@ -1,4 +1,4 @@
1881-/* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
1882+/* Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
1883 Contributed by Jakub Jelinek <jakub@redhat.com>.
1884
1885 This file is part of the GNU OpenMP Library (libgomp).
1886@@ -38,9 +38,6 @@
1887 #ifdef HAVE_PTHREAD_AFFINITY_NP
1888
1889 static unsigned int affinity_counter;
1890-#ifndef HAVE_SYNC_BUILTINS
1891-static gomp_mutex_t affinity_lock;
1892-#endif
1893
1894 void
1895 gomp_init_affinity (void)
1896@@ -76,9 +73,6 @@ gomp_init_affinity (void)
1897 CPU_SET (gomp_cpu_affinity[0], &cpuset);
1898 pthread_setaffinity_np (pthread_self (), sizeof (cpuset), &cpuset);
1899 affinity_counter = 1;
1900-#ifndef HAVE_SYNC_BUILTINS
1901- gomp_mutex_init (&affinity_lock);
1902-#endif
1903 }
1904
1905 void
1906@@ -87,13 +81,7 @@ gomp_init_thread_affinity (pthread_attr_
1907 unsigned int cpu;
1908 cpu_set_t cpuset;
1909
1910-#ifdef HAVE_SYNC_BUILTINS
1911 cpu = __sync_fetch_and_add (&affinity_counter, 1);
1912-#else
1913- gomp_mutex_lock (&affinity_lock);
1914- cpu = affinity_counter++;
1915- gomp_mutex_unlock (&affinity_lock);
1916-#endif
1917 cpu %= gomp_cpu_affinity_len;
1918 CPU_ZERO (&cpuset);
1919 CPU_SET (gomp_cpu_affinity[cpu], &cpuset);
1920--- libgomp/config/linux/bar.h.jj 2007-12-07 14:41:00.000000000 +0100
1921+++ libgomp/config/linux/bar.h 2008-03-26 15:11:32.000000000 +0100
1922@@ -1,4 +1,4 @@
1923-/* Copyright (C) 2005 Free Software Foundation, Inc.
1924+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
1925 Contributed by Richard Henderson <rth@redhat.com>.
1926
1927 This file is part of the GNU OpenMP Library (libgomp).
1928@@ -36,40 +36,49 @@
1929
1930 typedef struct
1931 {
1932- gomp_mutex_t mutex;
1933- unsigned total;
1934- unsigned arrived;
1935- int generation;
1936+ /* Make sure total/generation is in a mostly read cacheline, while
1937+ awaited in a separate cacheline. */
1938+ unsigned total __attribute__((aligned (64)));
1939+ unsigned generation;
1940+ unsigned awaited __attribute__((aligned (64)));
1941 } gomp_barrier_t;
1942+typedef unsigned int gomp_barrier_state_t;
1943
1944 static inline void gomp_barrier_init (gomp_barrier_t *bar, unsigned count)
1945 {
1946- gomp_mutex_init (&bar->mutex);
1947 bar->total = count;
1948- bar->arrived = 0;
1949+ bar->awaited = count;
1950 bar->generation = 0;
1951 }
1952
1953 static inline void gomp_barrier_reinit (gomp_barrier_t *bar, unsigned count)
1954 {
1955- gomp_mutex_lock (&bar->mutex);
1956+ __sync_fetch_and_add (&bar->awaited, count - bar->total);
1957 bar->total = count;
1958- gomp_mutex_unlock (&bar->mutex);
1959 }
1960
1961 static inline void gomp_barrier_destroy (gomp_barrier_t *bar)
1962 {
1963- /* Before destroying, make sure all threads have left the barrier. */
1964- gomp_mutex_lock (&bar->mutex);
1965 }
1966
1967 extern void gomp_barrier_wait (gomp_barrier_t *);
1968-extern void gomp_barrier_wait_end (gomp_barrier_t *, bool);
1969+extern void gomp_barrier_wait_last (gomp_barrier_t *);
1970+extern void gomp_barrier_wait_end (gomp_barrier_t *, gomp_barrier_state_t);
1971
1972-static inline bool gomp_barrier_wait_start (gomp_barrier_t *bar)
1973+static inline gomp_barrier_state_t
1974+gomp_barrier_wait_start (gomp_barrier_t *bar)
1975 {
1976- gomp_mutex_lock (&bar->mutex);
1977- return ++bar->arrived == bar->total;
1978+ unsigned int ret = bar->generation;
1979+ /* Do we need any barrier here or is __sync_add_and_fetch acting
1980+ as the needed LoadLoad barrier already? */
1981+ ret += __sync_add_and_fetch (&bar->awaited, -1) == 0;
1982+ return ret;
1983+}
1984+
1985+static inline bool
1986+gomp_barrier_last_thread (gomp_barrier_state_t state)
1987+{
1988+ return state & 1;
1989 }
1990
1991 #endif /* GOMP_BARRIER_H */
1992--- libgomp/config/linux/ptrlock.h.jj 2008-03-26 15:11:32.000000000 +0100
1993+++ libgomp/config/linux/ptrlock.h 2008-03-26 15:11:32.000000000 +0100
1994@@ -0,0 +1,65 @@
1995+/* Copyright (C) 2008 Free Software Foundation, Inc.
1996+ Contributed by Jakub Jelinek <jakub@redhat.com>.
1997+
1998+ This file is part of the GNU OpenMP Library (libgomp).
1999+
2000+ Libgomp is free software; you can redistribute it and/or modify it
2001+ under the terms of the GNU Lesser General Public License as published by
2002+ the Free Software Foundation; either version 2.1 of the License, or
2003+ (at your option) any later version.
2004+
2005+ Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
2006+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2007+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
2008+ more details.
2009+
2010+ You should have received a copy of the GNU Lesser General Public License
2011+ along with libgomp; see the file COPYING.LIB. If not, write to the
2012+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
2013+ MA 02110-1301, USA. */
2014+
2015+/* As a special exception, if you link this library with other files, some
2016+ of which are compiled with GCC, to produce an executable, this library
2017+ does not by itself cause the resulting executable to be covered by the
2018+ GNU General Public License. This exception does not however invalidate
2019+ any other reasons why the executable file might be covered by the GNU
2020+ General Public License. */
2021+
2022+/* This is a Linux specific implementation of a mutex synchronization
2023+ mechanism for libgomp. This type is private to the library. This
2024+ implementation uses atomic instructions and the futex syscall. */
2025+
2026+#ifndef GOMP_PTRLOCK_H
2027+#define GOMP_PTRLOCK_H 1
2028+
2029+typedef void *gomp_ptrlock_t;
2030+
2031+static inline void gomp_ptrlock_init (gomp_ptrlock_t *ptrlock, void *ptr)
2032+{
2033+ *ptrlock = ptr;
2034+}
2035+
2036+extern void *gomp_ptrlock_get_slow (gomp_ptrlock_t *ptrlock);
2037+static inline void *gomp_ptrlock_get (gomp_ptrlock_t *ptrlock)
2038+{
2039+ if ((uintptr_t) *ptrlock > 2)
2040+ return *ptrlock;
2041+
2042+ if (__sync_bool_compare_and_swap (ptrlock, NULL, (uintptr_t) 1))
2043+ return NULL;
2044+
2045+ return gomp_ptrlock_get_slow (ptrlock);
2046+}
2047+
2048+extern void gomp_ptrlock_set_slow (gomp_ptrlock_t *ptrlock, void *ptr);
2049+static inline void gomp_ptrlock_set (gomp_ptrlock_t *ptrlock, void *ptr)
2050+{
2051+ if (!__sync_bool_compare_and_swap (ptrlock, (uintptr_t) 1, ptr))
2052+ gomp_ptrlock_set_slow (ptrlock, ptr);
2053+}
2054+
2055+static inline void gomp_ptrlock_destroy (gomp_ptrlock_t *ptrlock)
2056+{
2057+}
2058+
2059+#endif /* GOMP_PTRLOCK_H */
2060--- libgomp/config/linux/lock.c.jj 2007-12-07 14:41:00.000000000 +0100
2061+++ libgomp/config/linux/lock.c 2008-03-26 15:11:32.000000000 +0100
2062@@ -29,11 +29,10 @@
2063 primitives. This implementation uses atomic instructions and the futex
2064 syscall. */
2065
2066-#include "libgomp.h"
2067 #include <string.h>
2068 #include <unistd.h>
2069 #include <sys/syscall.h>
2070-#include "futex.h"
2071+#include "wait.h"
2072
2073
2074 /* The internal gomp_mutex_t and the external non-recursive omp_lock_t
2075@@ -137,7 +136,7 @@ omp_set_nest_lock (omp_nest_lock_t *lock
2076 return;
2077 }
2078
2079- futex_wait (&lock->owner, otid);
2080+ do_wait (&lock->owner, otid);
2081 }
2082 }
2083
2084--- libgomp/config/linux/ptrlock.c.jj 2008-03-26 15:11:32.000000000 +0100
2085+++ libgomp/config/linux/ptrlock.c 2008-03-26 15:11:32.000000000 +0100
2086@@ -0,0 +1,70 @@
2087+/* Copyright (C) 2008 Free Software Foundation, Inc.
2088+ Contributed by Jakub Jelinek <jakub@redhat.com>.
2089+
2090+ This file is part of the GNU OpenMP Library (libgomp).
2091+
2092+ Libgomp is free software; you can redistribute it and/or modify it
2093+ under the terms of the GNU Lesser General Public License as published by
2094+ the Free Software Foundation; either version 2.1 of the License, or
2095+ (at your option) any later version.
2096+
2097+ Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
2098+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2099+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
2100+ more details.
2101+
2102+ You should have received a copy of the GNU Lesser General Public License
2103+ along with libgomp; see the file COPYING.LIB. If not, write to the
2104+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
2105+ MA 02110-1301, USA. */
2106+
2107+/* As a special exception, if you link this library with other files, some
2108+ of which are compiled with GCC, to produce an executable, this library
2109+ does not by itself cause the resulting executable to be covered by the
2110+ GNU General Public License. This exception does not however invalidate
2111+ any other reasons why the executable file might be covered by the GNU
2112+ General Public License. */
2113+
2114+/* This is a Linux specific implementation of a mutex synchronization
2115+ mechanism for libgomp. This type is private to the library. This
2116+ implementation uses atomic instructions and the futex syscall. */
2117+
2118+#include <endian.h>
2119+#include <limits.h>
2120+#include "wait.h"
2121+
2122+void *
2123+gomp_ptrlock_get_slow (gomp_ptrlock_t *ptrlock)
2124+{
2125+ int *intptr;
2126+ __sync_bool_compare_and_swap (ptrlock, 1, 2);
2127+
2128+ /* futex works on ints, not pointers.
2129+ But a valid work share pointer will be at least
2130+ 8 byte aligned, so it is safe to assume the low
2131+ 32-bits of the pointer won't contain values 1 or 2. */
2132+ __asm volatile ("" : "=r" (intptr) : "0" (ptrlock));
2133+#if __BYTE_ORDER == __BIG_ENDIAN
2134+ if (sizeof (*ptrlock) > sizeof (int))
2135+ intptr += (sizeof (*ptrlock) / sizeof (int)) - 1;
2136+#endif
2137+ do
2138+ do_wait (intptr, 2);
2139+ while (*intptr == 2);
2140+ __asm volatile ("" : : : "memory");
2141+ return *ptrlock;
2142+}
2143+
2144+void
2145+gomp_ptrlock_set_slow (gomp_ptrlock_t *ptrlock, void *ptr)
2146+{
2147+ int *intptr;
2148+
2149+ *ptrlock = ptr;
2150+ __asm volatile ("" : "=r" (intptr) : "0" (ptrlock));
2151+#if __BYTE_ORDER == __BIG_ENDIAN
2152+ if (sizeof (*ptrlock) > sizeof (int))
2153+ intptr += (sizeof (*ptrlock) / sizeof (int)) - 1;
2154+#endif
2155+ futex_wake (intptr, INT_MAX);
2156+}
2157--- libgomp/config/linux/x86/futex.h.jj 2007-12-07 14:41:00.000000000 +0100
2158+++ libgomp/config/linux/x86/futex.h 2008-03-26 15:11:32.000000000 +0100
2159@@ -1,4 +1,4 @@
2160-/* Copyright (C) 2005 Free Software Foundation, Inc.
2161+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2162 Contributed by Richard Henderson <rth@redhat.com>.
2163
2164 This file is part of the GNU OpenMP Library (libgomp).
2165@@ -27,9 +27,6 @@
2166
2167 /* Provide target-specific access to the futex system call. */
2168
2169-#define FUTEX_WAIT 0
2170-#define FUTEX_WAKE 1
2171-
2172 #ifdef __LP64__
2173 # ifndef SYS_futex
2174 # define SYS_futex 202
2175@@ -38,14 +35,26 @@
2176 static inline void
2177 futex_wait (int *addr, int val)
2178 {
2179- register long r10 __asm__("%r10") = 0;
2180+ register long r10 __asm__("%r10");
2181 long res;
2182
2183+ r10 = 0;
2184 __asm volatile ("syscall"
2185 : "=a" (res)
2186- : "0"(SYS_futex), "D" (addr), "S"(FUTEX_WAIT),
2187- "d"(val), "r"(r10)
2188+ : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wait),
2189+ "d" (val), "r" (r10)
2190 : "r11", "rcx", "memory");
2191+ if (__builtin_expect (res == -ENOSYS, 0))
2192+ {
2193+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2194+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2195+ r10 = 0;
2196+ __asm volatile ("syscall"
2197+ : "=a" (res)
2198+ : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wait),
2199+ "d" (val), "r" (r10)
2200+ : "r11", "rcx", "memory");
2201+ }
2202 }
2203
2204 static inline void
2205@@ -55,8 +64,19 @@ futex_wake (int *addr, int count)
2206
2207 __asm volatile ("syscall"
2208 : "=a" (res)
2209- : "0"(SYS_futex), "D" (addr), "S"(FUTEX_WAKE), "d"(count)
2210+ : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wake),
2211+ "d" (count)
2212 : "r11", "rcx", "memory");
2213+ if (__builtin_expect (res == -ENOSYS, 0))
2214+ {
2215+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2216+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2217+ __asm volatile ("syscall"
2218+ : "=a" (res)
2219+ : "0" (SYS_futex), "D" (addr), "S" (gomp_futex_wake),
2220+ "d" (count)
2221+ : "r11", "rcx", "memory");
2222+ }
2223 }
2224 #else
2225 # ifndef SYS_futex
2226@@ -65,7 +85,7 @@ futex_wake (int *addr, int count)
2227
2228 # ifdef __PIC__
2229
2230-static inline void
2231+static inline long
2232 sys_futex0 (int *addr, int op, int val)
2233 {
2234 long res;
2235@@ -77,11 +97,12 @@ sys_futex0 (int *addr, int op, int val)
2236 : "0"(SYS_futex), "r" (addr), "c"(op),
2237 "d"(val), "S"(0)
2238 : "memory");
2239+ return res;
2240 }
2241
2242 # else
2243
2244-static inline void
2245+static inline long
2246 sys_futex0 (int *addr, int op, int val)
2247 {
2248 long res;
2249@@ -91,6 +112,7 @@ sys_futex0 (int *addr, int op, int val)
2250 : "0"(SYS_futex), "b" (addr), "c"(op),
2251 "d"(val), "S"(0)
2252 : "memory");
2253+ return res;
2254 }
2255
2256 # endif /* __PIC__ */
2257@@ -98,13 +120,37 @@ sys_futex0 (int *addr, int op, int val)
2258 static inline void
2259 futex_wait (int *addr, int val)
2260 {
2261- sys_futex0 (addr, FUTEX_WAIT, val);
2262+ long res = sys_futex0 (addr, gomp_futex_wait, val);
2263+ if (__builtin_expect (res == -ENOSYS, 0))
2264+ {
2265+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2266+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2267+ sys_futex0 (addr, gomp_futex_wait, val);
2268+ }
2269 }
2270
2271 static inline void
2272 futex_wake (int *addr, int count)
2273 {
2274- sys_futex0 (addr, FUTEX_WAKE, count);
2275+ long res = sys_futex0 (addr, gomp_futex_wake, count);
2276+ if (__builtin_expect (res == -ENOSYS, 0))
2277+ {
2278+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2279+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2280+ sys_futex0 (addr, gomp_futex_wake, count);
2281+ }
2282 }
2283
2284 #endif /* __LP64__ */
2285+
2286+static inline void
2287+cpu_relax (void)
2288+{
2289+ __asm volatile ("rep; nop" : : : "memory");
2290+}
2291+
2292+static inline void
2293+atomic_write_barrier (void)
2294+{
2295+ __sync_synchronize ();
2296+}
2297--- libgomp/config/linux/wait.h.jj 2008-03-26 15:11:32.000000000 +0100
2298+++ libgomp/config/linux/wait.h 2008-03-26 15:11:32.000000000 +0100
2299@@ -0,0 +1,68 @@
2300+/* Copyright (C) 2008 Free Software Foundation, Inc.
2301+ Contributed by Jakub Jelinek <jakub@redhat.com>.
2302+
2303+ This file is part of the GNU OpenMP Library (libgomp).
2304+
2305+ Libgomp is free software; you can redistribute it and/or modify it
2306+ under the terms of the GNU Lesser General Public License as published by
2307+ the Free Software Foundation; either version 2.1 of the License, or
2308+ (at your option) any later version.
2309+
2310+ Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
2311+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2312+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
2313+ more details.
2314+
2315+ You should have received a copy of the GNU Lesser General Public License
2316+ along with libgomp; see the file COPYING.LIB. If not, write to the
2317+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
2318+ MA 02110-1301, USA. */
2319+
2320+/* As a special exception, if you link this library with other files, some
2321+ of which are compiled with GCC, to produce an executable, this library
2322+ does not by itself cause the resulting executable to be covered by the
2323+ GNU General Public License. This exception does not however invalidate
2324+ any other reasons why the executable file might be covered by the GNU
2325+ General Public License. */
2326+
2327+/* This is a Linux specific implementation of a mutex synchronization
2328+ mechanism for libgomp. This type is private to the library. This
2329+ implementation uses atomic instructions and the futex syscall. */
2330+
2331+#ifndef GOMP_WAIT_H
2332+#define GOMP_WAIT_H 1
2333+
2334+#include "libgomp.h"
2335+#include <errno.h>
2336+
2337+#define FUTEX_WAIT 0
2338+#define FUTEX_WAKE 1
2339+#define FUTEX_PRIVATE_FLAG 128L
2340+
2341+#ifdef HAVE_ATTRIBUTE_VISIBILITY
2342+# pragma GCC visibility push(hidden)
2343+#endif
2344+
2345+extern long int gomp_futex_wait, gomp_futex_wake;
2346+
2347+#include "futex.h"
2348+
2349+static inline void do_wait (int *addr, int val)
2350+{
2351+ unsigned long long i, count = gomp_spin_count_var;
2352+
2353+ if (__builtin_expect (gomp_managed_threads > gomp_available_cpus, 0))
2354+ count = gomp_throttled_spin_count_var;
2355+ for (i = 0; i < count; i++)
2356+ if (__builtin_expect (*addr != val, 0))
2357+ return;
2358+ else
2359+ cpu_relax ();
2360+ futex_wait (addr, val);
2361+}
2362+
2363+#ifdef HAVE_ATTRIBUTE_VISIBILITY
2364+# pragma GCC visibility pop
2365+#endif
2366+
2367+#endif /* GOMP_WAIT_H */
2368--- libgomp/config/linux/sparc/futex.h.jj 2007-12-07 14:41:00.000000000 +0100
2369+++ libgomp/config/linux/sparc/futex.h 2008-03-26 15:11:32.000000000 +0100
2370@@ -1,4 +1,4 @@
2371-/* Copyright (C) 2005 Free Software Foundation, Inc.
2372+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2373 Contributed by Jakub Jelinek <jakub@redhat.com>.
2374
2375 This file is part of the GNU OpenMP Library (libgomp).
2376@@ -28,10 +28,8 @@
2377 /* Provide target-specific access to the futex system call. */
2378
2379 #include <sys/syscall.h>
2380-#define FUTEX_WAIT 0
2381-#define FUTEX_WAKE 1
2382
2383-static inline void
2384+static inline long
2385 sys_futex0 (int *addr, int op, int val)
2386 {
2387 register long int g1 __asm__ ("g1");
2388@@ -47,9 +45,9 @@ sys_futex0 (int *addr, int op, int val)
2389 o3 = 0;
2390
2391 #ifdef __arch64__
2392-# define SYSCALL_STRING "ta\t0x6d"
2393+# define SYSCALL_STRING "ta\t0x6d; bcs,a,pt %%xcc, 1f; sub %%g0, %%o0, %%o0; 1:"
2394 #else
2395-# define SYSCALL_STRING "ta\t0x10"
2396+# define SYSCALL_STRING "ta\t0x10; bcs,a 1f; sub %%g0, %%o0, %%o0; 1:"
2397 #endif
2398
2399 __asm volatile (SYSCALL_STRING
2400@@ -65,16 +63,49 @@ sys_futex0 (int *addr, int op, int val)
2401 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",
2402 #endif
2403 "cc", "memory");
2404+ return o0;
2405 }
2406
2407 static inline void
2408 futex_wait (int *addr, int val)
2409 {
2410- sys_futex0 (addr, FUTEX_WAIT, val);
2411+ long err = sys_futex0 (addr, gomp_futex_wait, val);
2412+ if (__builtin_expect (err == ENOSYS, 0))
2413+ {
2414+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2415+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2416+ sys_futex0 (addr, gomp_futex_wait, val);
2417+ }
2418 }
2419
2420 static inline void
2421 futex_wake (int *addr, int count)
2422 {
2423- sys_futex0 (addr, FUTEX_WAKE, count);
2424+ long err = sys_futex0 (addr, gomp_futex_wake, count);
2425+ if (__builtin_expect (err == ENOSYS, 0))
2426+ {
2427+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2428+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2429+ sys_futex0 (addr, gomp_futex_wake, count);
2430+ }
2431+}
2432+
2433+static inline void
2434+cpu_relax (void)
2435+{
2436+#if defined __arch64__ || defined __sparc_v9__
2437+ __asm volatile ("membar #LoadLoad" : : : "memory");
2438+#else
2439+ __asm volatile ("" : : : "memory");
2440+#endif
2441+}
2442+
2443+static inline void
2444+atomic_write_barrier (void)
2445+{
2446+#if defined __arch64__ || defined __sparc_v9__
2447+ __asm volatile ("membar #StoreStore" : : : "memory");
2448+#else
2449+ __sync_synchronize ();
2450+#endif
2451 }
2452--- libgomp/config/linux/ia64/futex.h.jj 2007-12-07 14:41:00.000000000 +0100
2453+++ libgomp/config/linux/ia64/futex.h 2008-03-26 15:11:32.000000000 +0100
2454@@ -1,4 +1,4 @@
2455-/* Copyright (C) 2005 Free Software Foundation, Inc.
2456+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2457 Contributed by Richard Henderson <rth@redhat.com>.
2458
2459 This file is part of the GNU OpenMP Library (libgomp).
2460@@ -29,23 +29,24 @@
2461
2462 #include <sys/syscall.h>
2463
2464-#define FUTEX_WAIT 0
2465-#define FUTEX_WAKE 1
2466
2467
2468-static inline void
2469-sys_futex0(int *addr, int op, int val)
2470+static inline long
2471+sys_futex0(int *addr, long op, int val)
2472 {
2473 register long out0 asm ("out0") = (long) addr;
2474 register long out1 asm ("out1") = op;
2475 register long out2 asm ("out2") = val;
2476 register long out3 asm ("out3") = 0;
2477+ register long r8 asm ("r8");
2478+ register long r10 asm ("r10");
2479 register long r15 asm ("r15") = SYS_futex;
2480
2481 __asm __volatile ("break 0x100000"
2482- : "=r"(r15), "=r"(out0), "=r"(out1), "=r"(out2), "=r"(out3)
2483+ : "=r"(r15), "=r"(out0), "=r"(out1), "=r"(out2), "=r"(out3),
2484+ "=r"(r8), "=r"(r10)
2485 : "r"(r15), "r"(out0), "r"(out1), "r"(out2), "r"(out3)
2486- : "memory", "r8", "r10", "out4", "out5", "out6", "out7",
2487+ : "memory", "out4", "out5", "out6", "out7",
2488 /* Non-stacked integer registers, minus r8, r10, r15. */
2489 "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18",
2490 "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27",
2491@@ -56,16 +57,41 @@ sys_futex0(int *addr, int op, int val)
2492 "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
2493 /* Branch registers. */
2494 "b6");
2495+ return r8 & r10;
2496 }
2497
2498 static inline void
2499 futex_wait (int *addr, int val)
2500 {
2501- sys_futex0 (addr, FUTEX_WAIT, val);
2502+ long err = sys_futex0 (addr, gomp_futex_wait, val);
2503+ if (__builtin_expect (err == ENOSYS, 0))
2504+ {
2505+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2506+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2507+ sys_futex0 (addr, gomp_futex_wait, val);
2508+ }
2509 }
2510
2511 static inline void
2512 futex_wake (int *addr, int count)
2513 {
2514- sys_futex0 (addr, FUTEX_WAKE, count);
2515+ long err = sys_futex0 (addr, gomp_futex_wake, count);
2516+ if (__builtin_expect (err == ENOSYS, 0))
2517+ {
2518+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2519+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2520+ sys_futex0 (addr, gomp_futex_wake, count);
2521+ }
2522+}
2523+
2524+static inline void
2525+cpu_relax (void)
2526+{
2527+ __asm volatile ("hint @pause" : : : "memory");
2528+}
2529+
2530+static inline void
2531+atomic_write_barrier (void)
2532+{
2533+ __sync_synchronize ();
2534 }
2535--- libgomp/config/linux/s390/futex.h.jj 2007-12-07 14:41:00.000000000 +0100
2536+++ libgomp/config/linux/s390/futex.h 2008-03-26 15:11:32.000000000 +0100
2537@@ -1,4 +1,4 @@
2538-/* Copyright (C) 2005 Free Software Foundation, Inc.
2539+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2540 Contributed by Jakub Jelinek <jakub@redhat.com>.
2541
2542 This file is part of the GNU OpenMP Library (libgomp).
2543@@ -28,10 +28,8 @@
2544 /* Provide target-specific access to the futex system call. */
2545
2546 #include <sys/syscall.h>
2547-#define FUTEX_WAIT 0
2548-#define FUTEX_WAKE 1
2549
2550-static inline void
2551+static inline long
2552 sys_futex0 (int *addr, int op, int val)
2553 {
2554 register long int gpr2 __asm__ ("2");
2555@@ -49,16 +47,41 @@ sys_futex0 (int *addr, int op, int val)
2556 : "i" (SYS_futex),
2557 "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
2558 : "memory");
2559+ return gpr2;
2560 }
2561
2562 static inline void
2563 futex_wait (int *addr, int val)
2564 {
2565- sys_futex0 (addr, FUTEX_WAIT, val);
2566+ long err = sys_futex0 (addr, gomp_futex_wait, val);
2567+ if (__builtin_expect (err == -ENOSYS, 0))
2568+ {
2569+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2570+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2571+ sys_futex0 (addr, gomp_futex_wait, val);
2572+ }
2573 }
2574
2575 static inline void
2576 futex_wake (int *addr, int count)
2577 {
2578- sys_futex0 (addr, FUTEX_WAKE, count);
2579+ long err = sys_futex0 (addr, gomp_futex_wake, count);
2580+ if (__builtin_expect (err == -ENOSYS, 0))
2581+ {
2582+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2583+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2584+ sys_futex0 (addr, gomp_futex_wake, count);
2585+ }
2586+}
2587+
2588+static inline void
2589+cpu_relax (void)
2590+{
2591+ __asm volatile ("" : : : "memory");
2592+}
2593+
2594+static inline void
2595+atomic_write_barrier (void)
2596+{
2597+ __sync_synchronize ();
2598 }
2599--- libgomp/config/linux/mutex.c.jj 2007-12-07 14:41:00.000000000 +0100
2600+++ libgomp/config/linux/mutex.c 2008-03-26 15:11:32.000000000 +0100
2601@@ -1,4 +1,4 @@
2602-/* Copyright (C) 2005 Free Software Foundation, Inc.
2603+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2604 Contributed by Richard Henderson <rth@redhat.com>.
2605
2606 This file is part of the GNU OpenMP Library (libgomp).
2607@@ -29,9 +29,10 @@
2608 mechanism for libgomp. This type is private to the library. This
2609 implementation uses atomic instructions and the futex syscall. */
2610
2611-#include "libgomp.h"
2612-#include "futex.h"
2613+#include "wait.h"
2614
2615+long int gomp_futex_wake = FUTEX_WAKE | FUTEX_PRIVATE_FLAG;
2616+long int gomp_futex_wait = FUTEX_WAIT | FUTEX_PRIVATE_FLAG;
2617
2618 void
2619 gomp_mutex_lock_slow (gomp_mutex_t *mutex)
2620@@ -40,7 +41,7 @@ gomp_mutex_lock_slow (gomp_mutex_t *mute
2621 {
2622 int oldval = __sync_val_compare_and_swap (mutex, 1, 2);
2623 if (oldval != 0)
2624- futex_wait (mutex, 2);
2625+ do_wait (mutex, 2);
2626 }
2627 while (!__sync_bool_compare_and_swap (mutex, 0, 2));
2628 }
2629--- libgomp/config/linux/sem.c.jj 2007-12-07 14:41:00.000000000 +0100
2630+++ libgomp/config/linux/sem.c 2008-03-26 15:11:32.000000000 +0100
2631@@ -1,4 +1,4 @@
2632-/* Copyright (C) 2005 Free Software Foundation, Inc.
2633+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2634 Contributed by Richard Henderson <rth@redhat.com>.
2635
2636 This file is part of the GNU OpenMP Library (libgomp).
2637@@ -29,8 +29,7 @@
2638 mechanism for libgomp. This type is private to the library. This
2639 implementation uses atomic instructions and the futex syscall. */
2640
2641-#include "libgomp.h"
2642-#include "futex.h"
2643+#include "wait.h"
2644
2645
2646 void
2647@@ -44,7 +43,7 @@ gomp_sem_wait_slow (gomp_sem_t *sem)
2648 if (__sync_bool_compare_and_swap (sem, val, val - 1))
2649 return;
2650 }
2651- futex_wait (sem, -1);
2652+ do_wait (sem, -1);
2653 }
2654 }
2655
2656--- libgomp/config/linux/powerpc/futex.h.jj 2007-12-07 14:41:00.000000000 +0100
2657+++ libgomp/config/linux/powerpc/futex.h 2008-03-26 15:11:32.000000000 +0100
2658@@ -1,4 +1,4 @@
2659-/* Copyright (C) 2005 Free Software Foundation, Inc.
2660+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2661 Contributed by Richard Henderson <rth@redhat.com>.
2662
2663 This file is part of the GNU OpenMP Library (libgomp).
2664@@ -28,10 +28,8 @@
2665 /* Provide target-specific access to the futex system call. */
2666
2667 #include <sys/syscall.h>
2668-#define FUTEX_WAIT 0
2669-#define FUTEX_WAKE 1
2670
2671-static inline void
2672+static inline long
2673 sys_futex0 (int *addr, int op, int val)
2674 {
2675 register long int r0 __asm__ ("r0");
2676@@ -50,21 +48,48 @@ sys_futex0 (int *addr, int op, int val)
2677 doesn't. It doesn't much matter for us. In the interest of unity,
2678 go ahead and clobber it always. */
2679
2680- __asm volatile ("sc"
2681+ __asm volatile ("sc; mfcr %0"
2682 : "=r"(r0), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6)
2683 : "r"(r0), "r"(r3), "r"(r4), "r"(r5), "r"(r6)
2684 : "r7", "r8", "r9", "r10", "r11", "r12",
2685 "cr0", "ctr", "memory");
2686+ if (__builtin_expect (r0 & (1 << 28), 0))
2687+ return r3;
2688+ return 0;
2689 }
2690
2691 static inline void
2692 futex_wait (int *addr, int val)
2693 {
2694- sys_futex0 (addr, FUTEX_WAIT, val);
2695+ long err = sys_futex0 (addr, gomp_futex_wait, val);
2696+ if (__builtin_expect (err == ENOSYS, 0))
2697+ {
2698+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2699+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2700+ sys_futex0 (addr, gomp_futex_wait, val);
2701+ }
2702 }
2703
2704 static inline void
2705 futex_wake (int *addr, int count)
2706 {
2707- sys_futex0 (addr, FUTEX_WAKE, count);
2708+ long err = sys_futex0 (addr, gomp_futex_wake, count);
2709+ if (__builtin_expect (err == ENOSYS, 0))
2710+ {
2711+ gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG;
2712+ gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG;
2713+ sys_futex0 (addr, gomp_futex_wake, count);
2714+ }
2715+}
2716+
2717+static inline void
2718+cpu_relax (void)
2719+{
2720+ __asm volatile ("" : : : "memory");
2721+}
2722+
2723+static inline void
2724+atomic_write_barrier (void)
2725+{
2726+ __asm volatile ("eieio" : : : "memory");
2727 }
2728--- libgomp/config/linux/bar.c.jj 2007-12-07 14:41:00.000000000 +0100
2729+++ libgomp/config/linux/bar.c 2008-03-26 15:11:32.000000000 +0100
2730@@ -1,4 +1,4 @@
2731-/* Copyright (C) 2005 Free Software Foundation, Inc.
2732+/* Copyright (C) 2005, 2008 Free Software Foundation, Inc.
2733 Contributed by Richard Henderson <rth@redhat.com>.
2734
2735 This file is part of the GNU OpenMP Library (libgomp).
2736@@ -29,32 +29,29 @@
2737 mechanism for libgomp. This type is private to the library. This
2738 implementation uses atomic instructions and the futex syscall. */
2739
2740-#include "libgomp.h"
2741-#include "futex.h"
2742 #include <limits.h>
2743+#include "wait.h"
2744
2745
2746 void
2747-gomp_barrier_wait_end (gomp_barrier_t *bar, bool last)
2748+gomp_barrier_wait_end (gomp_barrier_t *bar, gomp_barrier_state_t state)
2749 {
2750- if (last)
2751+ if (__builtin_expect ((state & 1) != 0, 0))
2752 {
2753- bar->generation++;
2754- futex_wake (&bar->generation, INT_MAX);
2755+ /* Next time we'll be awaiting TOTAL threads again. */
2756+ bar->awaited = bar->total;
2757+ atomic_write_barrier ();
2758+ bar->generation += 2;
2759+ futex_wake ((int *) &bar->generation, INT_MAX);
2760 }
2761 else
2762 {
2763- unsigned int generation = bar->generation;
2764-
2765- gomp_mutex_unlock (&bar->mutex);
2766+ unsigned int generation = state;
2767
2768 do
2769- futex_wait (&bar->generation, generation);
2770+ do_wait ((int *) &bar->generation, generation);
2771 while (bar->generation == generation);
2772 }
2773-
2774- if (__sync_add_and_fetch (&bar->arrived, -1) == 0)
2775- gomp_mutex_unlock (&bar->mutex);
2776 }
2777
2778 void
2779@@ -62,3 +59,18 @@ gomp_barrier_wait (gomp_barrier_t *barri
2780 {
2781 gomp_barrier_wait_end (barrier, gomp_barrier_wait_start (barrier));
2782 }
2783+
2784+/* Like gomp_barrier_wait, except that if the encountering thread
2785+ is not the last one to hit the barrier, it returns immediately.
2786+ The intended usage is that a thread which intends to gomp_barrier_destroy
2787+ this barrier calls gomp_barrier_wait, while all other threads
2788+ call gomp_barrier_wait_last. When gomp_barrier_wait returns,
2789+ the barrier can be safely destroyed. */
2790+
2791+void
2792+gomp_barrier_wait_last (gomp_barrier_t *barrier)
2793+{
2794+ gomp_barrier_state_t state = gomp_barrier_wait_start (barrier);
2795+ if (state & 1)
2796+ gomp_barrier_wait_end (barrier, state);
2797+}
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-ppc32-retaddr.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-ppc32-retaddr.patch
new file mode 100644
index 0000000000..3de4158eb0
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-ppc32-retaddr.patch
@@ -0,0 +1,90 @@
12005-11-28 Jakub Jelinek <jakub@redhat.com>
2
3 * config/rs6000/rs6000.c (rs6000_return_addr): If COUNT == 0,
4 read word RETURN_ADDRESS_OFFSET bytes above arg_pointer_rtx
5 instead of doing an extran indirection from frame_pointer_rtx.
6
7 * gcc.dg/20051128-1.c: New test.
8
9Index: gcc/config/rs6000/rs6000.c
10===================================================================
11--- gcc/config/rs6000/rs6000.c.orig 2010-03-27 03:27:39.000000000 -0700
12+++ gcc/config/rs6000/rs6000.c 2010-06-25 10:18:04.053381930 -0700
13@@ -17646,17 +17646,22 @@
14 don't try to be too clever here. */
15 if (count != 0 || (DEFAULT_ABI != ABI_AIX && flag_pic))
16 {
17+ rtx x;
18 cfun->machine->ra_needs_full_frame = 1;
19
20- return
21- gen_rtx_MEM
22- (Pmode,
23- memory_address
24- (Pmode,
25- plus_constant (copy_to_reg
26- (gen_rtx_MEM (Pmode,
27- memory_address (Pmode, frame))),
28- RETURN_ADDRESS_OFFSET)));
29+ if (count == 0)
30+ {
31+ gcc_assert (frame == frame_pointer_rtx);
32+ x = arg_pointer_rtx;
33+ }
34+ else
35+ {
36+ x = memory_address (Pmode, frame);
37+ x = copy_to_reg (gen_rtx_MEM (Pmode, x));
38+ }
39+
40+ x = plus_constant (x, RETURN_ADDRESS_OFFSET);
41+ return gen_rtx_MEM (Pmode, memory_address (Pmode, x));
42 }
43
44 cfun->machine->ra_need_lr = 1;
45Index: gcc/testsuite/gcc.dg/20051128-1.c
46===================================================================
47--- /dev/null 1970-01-01 00:00:00.000000000 +0000
48+++ gcc/testsuite/gcc.dg/20051128-1.c 2010-06-25 10:18:04.061382856 -0700
49@@ -0,0 +1,41 @@
50+/* { dg-do run } */
51+/* { dg-options "-O2 -fpic" } */
52+
53+extern void exit (int);
54+extern void abort (void);
55+
56+int b;
57+
58+struct A
59+{
60+ void *pad[147];
61+ void *ra, *h;
62+ long o;
63+};
64+
65+void
66+__attribute__((noinline))
67+foo (struct A *a, void *x)
68+{
69+ __builtin_memset (a, 0, sizeof (a));
70+ if (!b)
71+ exit (0);
72+}
73+
74+void
75+__attribute__((noinline))
76+bar (void)
77+{
78+ struct A a;
79+
80+ __builtin_unwind_init ();
81+ foo (&a, __builtin_return_address (0));
82+}
83+
84+int
85+main (void)
86+{
87+ bar ();
88+ abort ();
89+ return 0;
90+}
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr27898.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr27898.patch
new file mode 100644
index 0000000000..172bb81171
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr27898.patch
@@ -0,0 +1,16 @@
12006-08-18 Jakub Jelinek <jakub@redhat.com>
2
3 PR c/27898
4 * gcc.dg/pr27898.c: New test.
5
6--- gcc/testsuite/gcc.dg/pr27898.c.jj 2006-08-18 09:19:33.000000000 +0200
7+++ gcc/testsuite/gcc.dg/pr27898.c 2006-08-18 09:19:27.000000000 +0200
8@@ -0,0 +1,8 @@
9+/* PR c/27898 */
10+/* { dg-do compile } */
11+/* { dg-options "--combine" } */
12+/* { dg-additional-sources "pr27898.c" } */
13+
14+union u { struct { int i; }; };
15+
16+extern int foo (union u *);
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr32139.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr32139.patch
new file mode 100644
index 0000000000..f35696703d
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr32139.patch
@@ -0,0 +1,19 @@
12007-06-01 Jakub Jelinek <jakub@redhat.com>
2
3 PR tree-optimization/32139
4 * gcc.c-torture/compile/20070531-1.c: New test.
5
6--- gcc/testsuite/gcc.c-torture/compile/20070531-1.c.jj 2007-05-31 13:47:22.000000000 +0200
7+++ gcc/testsuite/gcc.c-torture/compile/20070531-1.c 2007-06-01 10:57:15.000000000 +0200
8@@ -0,0 +1,11 @@
9+/* PR tree-optimization/32139 */
10+int foo (void);
11+int bar (void) __attribute__ ((const));
12+
13+int
14+test (int x)
15+{
16+ int a = (x == 10000 ? foo : bar) ();
17+ int b = (x == 10000 ? foo : bar) ();
18+ return a + b;
19+}
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr33763.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr33763.patch
new file mode 100644
index 0000000000..68c30650ff
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-pr33763.patch
@@ -0,0 +1,159 @@
12007-11-06 Jakub Jelinek <jakub@redhat.com>
2
3 PR tree-optimization/33763
4 * gcc.dg/pr33763.c: New test.
5 * g++.dg/opt/inline13.C: New test.
6
72007-11-06 Jan Hubicka <jh@suse.cz>
8
9 PR tree-optimization/33763
10 * tree-inline.c (expand_call_inline): Silently ignore always_inline
11 attribute for redefined extern inline functions.
12
13Index: gcc/tree-inline.c
14===================================================================
15--- gcc/tree-inline.c.orig 2010-03-18 13:07:13.000000000 -0700
16+++ gcc/tree-inline.c 2010-06-25 10:18:51.230139825 -0700
17@@ -3545,6 +3545,12 @@
18 goto egress;
19
20 if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn))
21+ /* For extern inline functions that get redefined we always
22+ silently ignored alway_inline flag. Better behaviour would
23+ be to be able to keep both bodies and use extern inline body
24+ for inlining, but we can't do that because frontends overwrite
25+ the body. */
26+ && !cg_edge->callee->local.redefined_extern_inline
27 /* Avoid warnings during early inline pass. */
28 && cgraph_global_info_ready)
29 {
30Index: gcc/testsuite/gcc.dg/pr33763.c
31===================================================================
32--- /dev/null 1970-01-01 00:00:00.000000000 +0000
33+++ gcc/testsuite/gcc.dg/pr33763.c 2010-06-25 10:18:51.234141302 -0700
34@@ -0,0 +1,60 @@
35+/* PR tree-optimization/33763 */
36+/* { dg-do compile } */
37+/* { dg-options "-O2" } */
38+
39+typedef struct
40+{
41+ void *a;
42+ void *b;
43+} T;
44+extern void *foo (const char *, const char *);
45+extern void *bar (void *, const char *, T);
46+extern int baz (const char *, int);
47+
48+extern inline __attribute__ ((always_inline, gnu_inline)) int
49+baz (const char *x, int y)
50+{
51+ return 2;
52+}
53+
54+int
55+baz (const char *x, int y)
56+{
57+ return 1;
58+}
59+
60+int xa, xb;
61+
62+static void *
63+inl (const char *x, const char *y)
64+{
65+ T t = { &xa, &xb };
66+ int *f = (int *) __builtin_malloc (sizeof (int));
67+ const char *z;
68+ int o = 0;
69+ void *r = 0;
70+
71+ for (z = y; *z; z++)
72+ {
73+ if (*z == 'r')
74+ o |= 1;
75+ if (*z == 'w')
76+ o |= 2;
77+ }
78+ if (o == 1)
79+ *f = baz (x, 0);
80+ if (o == 2)
81+ *f = baz (x, 1);
82+ if (o == 3)
83+ *f = baz (x, 2);
84+
85+ if (o && *f > 0)
86+ r = bar (f, "w", t);
87+ return r;
88+}
89+
90+void *
91+foo (const char *x, const char *y)
92+{
93+ return inl (x, y);
94+}
95Index: gcc/testsuite/g++.dg/opt/inline13.C
96===================================================================
97--- /dev/null 1970-01-01 00:00:00.000000000 +0000
98+++ gcc/testsuite/g++.dg/opt/inline13.C 2010-06-25 10:18:51.261052137 -0700
99@@ -0,0 +1,60 @@
100+// PR tree-optimization/33763
101+// { dg-do compile }
102+// { dg-options "-O2" }
103+
104+typedef struct
105+{
106+ void *a;
107+ void *b;
108+} T;
109+extern void *foo (const char *, const char *);
110+extern void *bar (void *, const char *, T);
111+extern int baz (const char *, int);
112+
113+extern inline __attribute__ ((always_inline, gnu_inline)) int
114+baz (const char *x, int y)
115+{
116+ return 2;
117+}
118+
119+int
120+baz (const char *x, int y)
121+{
122+ return 1;
123+}
124+
125+int xa, xb;
126+
127+static void *
128+inl (const char *x, const char *y)
129+{
130+ T t = { &xa, &xb };
131+ int *f = (int *) __builtin_malloc (sizeof (int));
132+ const char *z;
133+ int o = 0;
134+ void *r = 0;
135+
136+ for (z = y; *z; z++)
137+ {
138+ if (*z == 'r')
139+ o |= 1;
140+ if (*z == 'w')
141+ o |= 2;
142+ }
143+ if (o == 1)
144+ *f = baz (x, 0);
145+ if (o == 2)
146+ *f = baz (x, 1);
147+ if (o == 3)
148+ *f = baz (x, 2);
149+
150+ if (o && *f > 0)
151+ r = bar (f, "w", t);
152+ return r;
153+}
154+
155+void *
156+foo (const char *x, const char *y)
157+{
158+ return inl (x, y);
159+}
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh251682.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh251682.patch
new file mode 100644
index 0000000000..e96ae6f134
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh251682.patch
@@ -0,0 +1,89 @@
12008-04-01 Jakub Jelinek <jakub@redhat.com>
2
3 PR pch/13675
4 * files.c (struct _cpp_file): Remove pch field.
5 (pch_open_file): Don't set file->pch, just file->pchname.
6 (should_stack_file): After pfile->cb.read_pch call
7 free pchname and clear pchname, don't close file->fd.
8 Test file->pchname instead of file->pch. Don't close fd after cb.
9 (_cpp_stack_include): Test file->pchname instead of file->pch.
10
11 * c-pch.c (c_common_read_pch): On error close (fd) resp. fclose (f).
12
13--- libcpp/files.c.jj 2008-02-18 23:50:17.000000000 +0100
14+++ libcpp/files.c 2008-03-31 15:59:01.000000000 +0200
15@@ -106,9 +106,6 @@ struct _cpp_file
16
17 /* If BUFFER above contains the true contents of the file. */
18 bool buffer_valid;
19-
20- /* File is a PCH (on return from find_include_file). */
21- bool pch;
22 };
23
24 /* A singly-linked list for all searches for a given file name, with
25@@ -322,9 +319,7 @@ pch_open_file (cpp_reader *pfile, _cpp_f
26 }
27 closedir (pchdir);
28 }
29- if (valid)
30- file->pch = true;
31- else
32+ if (!valid)
33 *invalid_pch = true;
34 }
35
36@@ -703,11 +698,12 @@ should_stack_file (cpp_reader *pfile, _c
37 return false;
38
39 /* Handle PCH files immediately; don't stack them. */
40- if (file->pch)
41+ if (file->pchname)
42 {
43 pfile->cb.read_pch (pfile, file->pchname, file->fd, file->path);
44- close (file->fd);
45 file->fd = -1;
46+ free ((void *) file->pchname);
47+ file->pchname = NULL;
48 return false;
49 }
50
51@@ -916,7 +912,7 @@ _cpp_stack_include (cpp_reader *pfile, c
52 complicates LAST_SOURCE_LINE_LOCATION. This does not apply if we
53 found a PCH file (in which case linemap_add is not called) or we
54 were included from the command-line. */
55- if (! file->pch && file->err_no == 0 && type != IT_CMDLINE)
56+ if (file->pchname == NULL && file->err_no == 0 && type != IT_CMDLINE)
57 pfile->line_table->highest_location--;
58
59 return _cpp_stack_file (pfile, file, type == IT_IMPORT);
60--- gcc/c-pch.c.jj 2008-02-18 23:46:08.000000000 +0100
61+++ gcc/c-pch.c 2008-03-31 15:56:00.000000000 +0200
62@@ -372,6 +372,7 @@ c_common_read_pch (cpp_reader *pfile, co
63 if (f == NULL)
64 {
65 cpp_errno (pfile, CPP_DL_ERROR, "calling fdopen");
66+ close (fd);
67 return;
68 }
69
70@@ -380,6 +381,7 @@ c_common_read_pch (cpp_reader *pfile, co
71 if (fread (&h, sizeof (h), 1, f) != 1)
72 {
73 cpp_errno (pfile, CPP_DL_ERROR, "reading");
74+ fclose (f);
75 return;
76 }
77
78@@ -425,7 +427,10 @@ c_common_read_pch (cpp_reader *pfile, co
79 gt_pch_restore (f);
80
81 if (cpp_read_state (pfile, name, f, smd) != 0)
82- return;
83+ {
84+ fclose (f);
85+ return;
86+ }
87
88 fclose (f);
89
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh330771.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh330771.patch
new file mode 100644
index 0000000000..4888ac47dd
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh330771.patch
@@ -0,0 +1,31 @@
12007-10-16 Jakub Jelinek <jakub@redhat.com>
2
3 * Makefile.am (libgcj_tools_la_LIBADD): Add.
4 * Makefile.in: Regenerated.
5
6Index: libjava/Makefile.am
7===================================================================
8--- libjava/Makefile.am.orig 2010-03-21 12:41:37.000000000 -0700
9+++ libjava/Makefile.am 2010-06-25 10:22:11.394130458 -0700
10@@ -507,6 +507,8 @@
11 libgcj_tools_la_GCJFLAGS = $(AM_GCJFLAGS) -findirect-dispatch \
12 -fno-bootstrap-classes -fno-indirect-classes \
13 -fsource-filename=$(here)/classpath/tools/all-classes.lst
14+## See jv_convert_LDADD.
15+libgcj_tools_la_LIBADD = -L$(here)/.libs libgcj.la
16 libgcj_tools_la_LDFLAGS = -rpath $(toolexeclibdir) \
17 -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
18 $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBJAVA_LDFLAGS_NOUNDEF)
19Index: libjava/Makefile.in
20===================================================================
21--- libjava/Makefile.in.orig 2010-04-02 11:18:06.000000000 -0700
22+++ libjava/Makefile.in 2010-06-25 10:27:41.841708512 -0700
23@@ -1190,7 +1190,7 @@
24 -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
25 $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBJAVA_LDFLAGS_NOUNDEF)
26
27-libgcj_tools_la_LIBADD = libgcj.la -lm
28+libgcj_tools_la_LIBADD = -L$(here)/.libs libgcj.la -lm
29 libgcj_tools_la_DEPENDENCIES = libgcj.la libgcj.spec $(am__append_22)
30 libgcj_tools_la_LINK = $(LIBLINK) $(libgcj_tools_la_LDFLAGS)
31 libjvm_la_SOURCES = jni-libjvm.cc
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh341221.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh341221.patch
new file mode 100644
index 0000000000..7e2801b99b
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fedora/gcc43-rh341221.patch
@@ -0,0 +1,32 @@
12007-10-21 Jakub Jelinek <jakub@redhat.com>
2
3 * doc/Makefile.am (POD2MAN): Set date from cp-tools.texinfo
4 timestamp rather than from current date.
5 * doc/Makefile.in: Regenerated.
6
7Index: libjava/classpath/doc/Makefile.am
8===================================================================
9--- libjava/classpath/doc/Makefile.am.orig 2008-10-21 10:55:01.000000000 -0700
10+++ libjava/classpath/doc/Makefile.am 2010-06-25 10:28:30.237631599 -0700
11@@ -31,7 +31,7 @@
12 gtnameserv.1 \
13 gjdoc.1
14
15-POD2MAN = pod2man --center="GNU" --release="$(VERSION)"
16+POD2MAN = pod2man --center="GNU" --release="$(VERSION)" --date="$(shell ls --time-style=+%F -l $(srcdir)/cp-tools.texinfo | awk '{print $$6}')"
17 TEXI2POD = perl $(srcdir)/texi2pod.pl
18 STAMP = echo timestamp >
19
20Index: libjava/classpath/doc/Makefile.in
21===================================================================
22--- libjava/classpath/doc/Makefile.in.orig 2010-04-02 11:18:06.000000000 -0700
23+++ libjava/classpath/doc/Makefile.in 2010-06-25 10:28:30.245635728 -0700
24@@ -376,7 +376,7 @@
25 gtnameserv.1 \
26 gjdoc.1
27
28-POD2MAN = pod2man --center="GNU" --release="$(VERSION)"
29+POD2MAN = pod2man --center="GNU" --release="$(VERSION)" --date="$(shell ls --time-style=+%F -l $(srcdir)/cp-tools.texinfo | awk '{print $$6}')"
30 TEXI2POD = perl $(srcdir)/texi2pod.pl
31 STAMP = echo timestamp >
32 @GENINSRC_FALSE@STAMP_GENINSRC =
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/fortran-cross-compile-hack.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/fortran-cross-compile-hack.patch
new file mode 100644
index 0000000000..348c77006f
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/fortran-cross-compile-hack.patch
@@ -0,0 +1,30 @@
1* Fortran would have searched for arm-angstrom-gnueabi-gfortran but would have used
2 used gfortan. For gcc_4.2.2.bb we want to use the gfortran compiler from our cross
3 directory.
4
5Index: gcc-4.5+svnr155514/libgfortran/configure
6===================================================================
7--- gcc-4.5+svnr155514.orig/libgfortran/configure 2009-12-29 22:02:01.000000000 -0800
8+++ gcc-4.5+svnr155514/libgfortran/configure 2009-12-30 08:12:40.889091657 -0800
9@@ -11655,7 +11655,7 @@ CC="$lt_save_CC"
10
11 # We need gfortran to compile parts of the library
12 #AC_PROG_FC(gfortran)
13-FC="$GFORTRAN"
14+#FC="$GFORTRAN"
15 ac_ext=${ac_fc_srcext-f}
16 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
17 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
18Index: gcc-4.5+svnr155514/libgfortran/configure.ac
19===================================================================
20--- gcc-4.5+svnr155514.orig/libgfortran/configure.ac 2009-12-29 22:02:01.000000000 -0800
21+++ gcc-4.5+svnr155514/libgfortran/configure.ac 2009-12-30 08:12:13.453094218 -0800
22@@ -187,7 +187,7 @@ AC_SUBST(enable_static)
23
24 # We need gfortran to compile parts of the library
25 #AC_PROG_FC(gfortran)
26-FC="$GFORTRAN"
27+#FC="$GFORTRAN"
28 AC_PROG_FC(gfortran)
29
30 # extra LD Flags which are required for targets
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.0.2-e300c2c3.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.0.2-e300c2c3.patch
new file mode 100644
index 0000000000..d1df8b2716
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.0.2-e300c2c3.patch
@@ -0,0 +1,319 @@
1Adds support for Freescale Power architecture e300c2 and e300c3 cores.
2http://www.bitshrine.org/gpp/tc-fsl-x86lnx-e300c3-nptl-4.0.2-2.src.rpm
3
4Leon Woestenberg <leonw@mailcan.com>
5
6---
7 gcc/config.gcc | 2
8 gcc/config/rs6000/e300c2c3.md | 189 ++++++++++++++++++++++++++++++++++++++++++
9 gcc/config/rs6000/rs6000.c | 24 +++++
10 gcc/config/rs6000/rs6000.h | 4
11 gcc/config/rs6000/rs6000.md | 3
12 5 files changed, 220 insertions(+), 2 deletions(-)
13
14Index: gcc-4.3.1/gcc/config/rs6000/e300c2c3.md
15===================================================================
16--- /dev/null 1970-01-01 00:00:00.000000000 +0000
17+++ gcc-4.3.1/gcc/config/rs6000/e300c2c3.md 2008-08-23 16:51:33.000000000 -0700
18@@ -0,0 +1,189 @@
19+;; Pipeline description for Motorola PowerPC e300c3 core.
20+;; Copyright (C) 2003 Free Software Foundation, Inc.
21+;;
22+;; This file is part of GCC.
23+
24+;; GCC is free software; you can redistribute it and/or modify it
25+;; under the terms of the GNU General Public License as published
26+;; by the Free Software Foundation; either version 2, or (at your
27+;; option) any later version.
28+
29+;; GCC is distributed in the hope that it will be useful, but WITHOUT
30+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
31+;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
32+;; License for more details.
33+
34+;; You should have received a copy of the GNU General Public License
35+;; along with GCC; see the file COPYING. If not, write to the
36+;; Free Software Foundation, 59 Temple Place - Suite 330, Boston,
37+;; MA 02111-1307, USA.
38+
39+(define_automaton "ppce300c3_most,ppce300c3_long,ppce300c3_retire")
40+(define_cpu_unit "ppce300c3_decode_0,ppce300c3_decode_1" "ppce300c3_most")
41+
42+;; We don't simulate general issue queue (GIC). If we have SU insn
43+;; and then SU1 insn, they can not be issued on the same cycle
44+;; (although SU1 insn and then SU insn can be issued) because the SU
45+;; insn will go to SU1 from GIC0 entry. Fortunately, the first cycle
46+;; multipass insn scheduling will find the situation and issue the SU1
47+;; insn and then the SU insn.
48+(define_cpu_unit "ppce300c3_issue_0,ppce300c3_issue_1" "ppce300c3_most")
49+
50+;; We could describe completion buffers slots in combination with the
51+;; retirement units and the order of completion but the result
52+;; automaton would behave in the same way because we can not describe
53+;; real latency time with taking in order completion into account.
54+;; Actually we could define the real latency time by querying reserved
55+;; automaton units but the current scheduler uses latency time before
56+;; issuing insns and making any reservations.
57+;;
58+;; So our description is aimed to achieve a insn schedule in which the
59+;; insns would not wait in the completion buffer.
60+(define_cpu_unit "ppce300c3_retire_0,ppce300c3_retire_1" "ppce300c3_retire")
61+
62+;; Branch unit:
63+(define_cpu_unit "ppce300c3_bu" "ppce300c3_most")
64+
65+;; IU:
66+(define_cpu_unit "ppce300c3_iu0_stage0,ppce300c3_iu1_stage0" "ppce300c3_most")
67+
68+;; IU: This used to describe non-pipelined division.
69+(define_cpu_unit "ppce300c3_mu_div" "ppce300c3_long")
70+
71+;; SRU:
72+(define_cpu_unit "ppce300c3_sru_stage0" "ppce300c3_most")
73+
74+;; Here we simplified LSU unit description not describing the stages.
75+(define_cpu_unit "ppce300c3_lsu" "ppce300c3_most")
76+
77+;; FPU:
78+(define_cpu_unit "ppce300c3_fpu" "ppce300c3_most")
79+
80+;; The following units are used to make automata deterministic
81+(define_cpu_unit "present_ppce300c3_decode_0" "ppce300c3_most")
82+(define_cpu_unit "present_ppce300c3_issue_0" "ppce300c3_most")
83+(define_cpu_unit "present_ppce300c3_retire_0" "ppce300c3_retire")
84+(define_cpu_unit "present_ppce300c3_iu0_stage0" "ppce300c3_most")
85+
86+;; The following sets to make automata deterministic when option ndfa is used.
87+(presence_set "present_ppce300c3_decode_0" "ppce300c3_decode_0")
88+(presence_set "present_ppce300c3_issue_0" "ppce300c3_issue_0")
89+(presence_set "present_ppce300c3_retire_0" "ppce300c3_retire_0")
90+(presence_set "present_ppce300c3_iu0_stage0" "ppce300c3_iu0_stage0")
91+
92+;; Some useful abbreviations.
93+(define_reservation "ppce300c3_decode"
94+ "ppce300c3_decode_0|ppce300c3_decode_1+present_ppce300c3_decode_0")
95+(define_reservation "ppce300c3_issue"
96+ "ppce300c3_issue_0|ppce300c3_issue_1+present_ppce300c3_issue_0")
97+(define_reservation "ppce300c3_retire"
98+ "ppce300c3_retire_0|ppce300c3_retire_1+present_ppce300c3_retire_0")
99+(define_reservation "ppce300c3_iu_stage0"
100+ "ppce300c3_iu0_stage0|ppce300c3_iu1_stage0+present_ppce300c3_iu0_stage0")
101+
102+;; Compares can be executed either one of the IU or SRU
103+(define_insn_reservation "ppce300c3_cmp" 1
104+ (and (eq_attr "type" "cmp,compare,delayed_compare,fast_compare")
105+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
106+ "ppce300c3_decode,ppce300c3_issue+(ppce300c3_iu_stage0|ppce300c3_sru_stage0) \
107+ +ppce300c3_retire")
108+
109+;; Other one cycle IU insns
110+(define_insn_reservation "ppce300c3_iu" 1
111+ (and (eq_attr "type" "integer,insert_word")
112+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
113+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_iu_stage0+ppce300c3_retire")
114+
115+;; Branch. Actually this latency time is not used by the scheduler.
116+(define_insn_reservation "ppce300c3_branch" 1
117+ (and (eq_attr "type" "jmpreg,branch")
118+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
119+ "ppce300c3_decode,ppce300c3_bu,ppce300c3_retire")
120+
121+;; Multiply is non-pipelined but can be executed in any IU
122+(define_insn_reservation "ppce300c3_multiply" 2
123+ (and (eq_attr "type" "imul,imul2,imul3,imul_compare")
124+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
125+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_iu_stage0, \
126+ ppce300c3_iu_stage0+ppce300c3_retire")
127+
128+;; Divide. We use the average latency time here. We omit reserving a
129+;; retire unit because of the result automata will be huge.
130+(define_insn_reservation "ppce300c3_divide" 20
131+ (and (eq_attr "type" "idiv")
132+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
133+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_iu_stage0+ppce300c3_mu_div,\
134+ ppce300c3_mu_div*19")
135+
136+;; CR logical
137+(define_insn_reservation "ppce300c3_cr_logical" 1
138+ (and (eq_attr "type" "cr_logical,delayed_cr")
139+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
140+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_sru_stage0+ppce300c3_retire")
141+
142+;; Mfcr
143+(define_insn_reservation "ppce300c3_mfcr" 1
144+ (and (eq_attr "type" "mfcr")
145+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
146+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_sru_stage0+ppce300c3_retire")
147+
148+;; Mtcrf
149+(define_insn_reservation "ppce300c3_mtcrf" 1
150+ (and (eq_attr "type" "mtcr")
151+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
152+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_sru_stage0+ppce300c3_retire")
153+
154+;; Mtjmpr
155+(define_insn_reservation "ppce300c3_mtjmpr" 1
156+ (and (eq_attr "type" "mtjmpr,mfjmpr")
157+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
158+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_sru_stage0+ppce300c3_retire")
159+
160+;; Float point instructions
161+(define_insn_reservation "ppce300c3_fpcompare" 3
162+ (and (eq_attr "type" "fpcompare")
163+ (eq_attr "cpu" "ppce300c3"))
164+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_fpu,nothing,ppce300c3_retire")
165+
166+(define_insn_reservation "ppce300c3_fp" 3
167+ (and (eq_attr "type" "fp")
168+ (eq_attr "cpu" "ppce300c3"))
169+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_fpu,nothing,ppce300c3_retire")
170+
171+(define_insn_reservation "ppce300c3_dmul" 4
172+ (and (eq_attr "type" "dmul")
173+ (eq_attr "cpu" "ppce300c3"))
174+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_fpu,ppce300c3_fpu,nothing,ppce300c3_retire")
175+
176+; Divides are not pipelined
177+(define_insn_reservation "ppce300c3_sdiv" 18
178+ (and (eq_attr "type" "sdiv")
179+ (eq_attr "cpu" "ppce300c3"))
180+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_fpu,ppce300c3_fpu*17")
181+
182+(define_insn_reservation "ppce300c3_ddiv" 33
183+ (and (eq_attr "type" "ddiv")
184+ (eq_attr "cpu" "ppce300c3"))
185+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_fpu,ppce300c3_fpu*32")
186+
187+;; Loads
188+(define_insn_reservation "ppce300c3_load" 2
189+ (and (eq_attr "type" "load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u")
190+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
191+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_lsu,ppce300c3_retire")
192+
193+(define_insn_reservation "ppce300c3_fpload" 2
194+ (and (eq_attr "type" "fpload,fpload_ux,fpload_u")
195+ (eq_attr "cpu" "ppce300c3"))
196+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_lsu,ppce300c3_retire")
197+
198+;; Stores.
199+(define_insn_reservation "ppce300c3_store" 2
200+ (and (eq_attr "type" "store,store_ux,store_u")
201+ (ior (eq_attr "cpu" "ppce300c2") (eq_attr "cpu" "ppce300c3")))
202+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_lsu,ppce300c3_retire")
203+
204+(define_insn_reservation "ppce300c3_fpstore" 2
205+ (and (eq_attr "type" "fpstore,fpstore_ux,fpstore_u")
206+ (eq_attr "cpu" "ppce300c3"))
207+ "ppce300c3_decode,ppce300c3_issue+ppce300c3_lsu,ppce300c3_retire")
208Index: gcc-4.3.1/gcc/config/rs6000/rs6000.c
209===================================================================
210--- gcc-4.3.1.orig/gcc/config/rs6000/rs6000.c 2008-08-23 16:49:39.000000000 -0700
211+++ gcc-4.3.1/gcc/config/rs6000/rs6000.c 2008-08-23 16:54:25.000000000 -0700
212@@ -669,6 +669,21 @@ struct processor_costs ppc8540_cost = {
213 1, /* prefetch streams /*/
214 };
215
216+/* Instruction costs on E300C2 and E300C3 cores. */
217+static const
218+struct processor_costs ppce300c2c3_cost = {
219+ COSTS_N_INSNS (4), /* mulsi */
220+ COSTS_N_INSNS (4), /* mulsi_const */
221+ COSTS_N_INSNS (4), /* mulsi_const9 */
222+ COSTS_N_INSNS (4), /* muldi */
223+ COSTS_N_INSNS (19), /* divsi */
224+ COSTS_N_INSNS (19), /* divdi */
225+ COSTS_N_INSNS (3), /* fp */
226+ COSTS_N_INSNS (4), /* dmul */
227+ COSTS_N_INSNS (18), /* sdiv */
228+ COSTS_N_INSNS (33), /* ddiv */
229+};
230+
231 /* Instruction costs on POWER4 and POWER5 processors. */
232 static const
233 struct processor_costs power4_cost = {
234@@ -1420,6 +1435,8 @@ rs6000_override_options (const char *def
235 {"8540", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN},
236 /* 8548 has a dummy entry for now. */
237 {"8548", PROCESSOR_PPC8540, POWERPC_BASE_MASK | MASK_STRICT_ALIGN},
238+ {"e300c2", PROCESSOR_PPCE300C2, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
239+ {"e300c3", PROCESSOR_PPCE300C3, POWERPC_BASE_MASK},
240 {"860", PROCESSOR_MPCCORE, POWERPC_BASE_MASK | MASK_SOFT_FLOAT},
241 {"970", PROCESSOR_POWER4,
242 POWERPC_7400_MASK | MASK_PPC_GPOPT | MASK_MFCRF | MASK_POWERPC64},
243@@ -1845,6 +1862,11 @@ rs6000_override_options (const char *def
244 rs6000_cost = &ppc8540_cost;
245 break;
246
247+ case PROCESSOR_PPCE300C2:
248+ case PROCESSOR_PPCE300C3:
249+ rs6000_cost = &ppce300c2c3_cost;
250+ break;
251+
252 case PROCESSOR_POWER4:
253 case PROCESSOR_POWER5:
254 rs6000_cost = &power4_cost;
255@@ -18606,6 +18628,8 @@ rs6000_issue_rate (void)
256 case CPU_PPC7400:
257 case CPU_PPC8540:
258 case CPU_CELL:
259+ case CPU_PPCE300C2:
260+ case CPU_PPCE300C3:
261 return 2;
262 case CPU_RIOS2:
263 case CPU_PPC604:
264Index: gcc-4.3.1/gcc/config/rs6000/rs6000.h
265===================================================================
266--- gcc-4.3.1.orig/gcc/config/rs6000/rs6000.h 2008-01-26 09:18:35.000000000 -0800
267+++ gcc-4.3.1/gcc/config/rs6000/rs6000.h 2008-08-23 16:55:30.000000000 -0700
268@@ -117,6 +117,8 @@
269 %{mcpu=G5: -mpower4 -maltivec} \
270 %{mcpu=8540: -me500} \
271 %{mcpu=8548: -me500} \
272+%{mcpu=e300c2: -mppc} \
273+%{mcpu=e300c3: -mppc -mpmr} \
274 %{maltivec: -maltivec} \
275 -many"
276
277@@ -262,6 +264,8 @@ enum processor_type
278 PROCESSOR_PPC7400,
279 PROCESSOR_PPC7450,
280 PROCESSOR_PPC8540,
281+ PROCESSOR_PPCE300C2,
282+ PROCESSOR_PPCE300C3,
283 PROCESSOR_POWER4,
284 PROCESSOR_POWER5,
285 PROCESSOR_POWER6,
286Index: gcc-4.3.1/gcc/config/rs6000/rs6000.md
287===================================================================
288--- gcc-4.3.1.orig/gcc/config/rs6000/rs6000.md 2008-02-13 16:14:45.000000000 -0800
289+++ gcc-4.3.1/gcc/config/rs6000/rs6000.md 2008-08-23 16:57:29.000000000 -0700
290@@ -133,7 +133,7 @@
291 ;; Processor type -- this attribute must exactly match the processor_type
292 ;; enumeration in rs6000.h.
293
294-(define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5,power6,cell"
295+(define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5,power6,cell,ppce300c2,ppce300c3"
296 (const (symbol_ref "rs6000_cpu_attr")))
297
298
299@@ -166,6 +166,7 @@
300 (include "7xx.md")
301 (include "7450.md")
302 (include "8540.md")
303+(include "e300c2c3.md")
304 (include "power4.md")
305 (include "power5.md")
306 (include "power6.md")
307Index: gcc-4.3.1/gcc/config.gcc
308===================================================================
309--- gcc-4.3.1.orig/gcc/config.gcc 2008-08-23 16:49:43.000000000 -0700
310+++ gcc-4.3.1/gcc/config.gcc 2008-08-23 17:03:55.000000000 -0700
311@@ -3144,7 +3144,7 @@ case "${target}" in
312 | rios | rios1 | rios2 | rsc | rsc1 | rs64a \
313 | 401 | 403 | 405 | 405fp | 440 | 440fp | 505 \
314 | 601 | 602 | 603 | 603e | ec603e | 604 \
315- | 604e | 620 | 630 | 740 | 750 | 7400 | 7450 \
316+ | 604e | 620 | 630 | 740 | 750 | 7400 | 7450 | e300c[23] \
317 | 854[08] | 801 | 821 | 823 | 860 | 970 | G3 | G4 | G5 | cell)
318 # OK
319 ;;
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
new file mode 100644
index 0000000000..f33e6c1ea6
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
@@ -0,0 +1,31 @@
1---
2 configure | 2 +-
3 configure.ac | 2 +-
4 2 files changed, 2 insertions(+), 2 deletions(-)
5
6Index: gcc-4.3.1/configure.ac
7===================================================================
8--- gcc-4.3.1.orig/configure.ac 2008-07-21 12:29:18.000000000 -0700
9+++ gcc-4.3.1/configure.ac 2008-07-21 12:29:35.000000000 -0700
10@@ -2352,7 +2352,7 @@ fi
11 # for target_alias and gcc doesn't manage it consistently.
12 target_configargs="--cache-file=./config.cache ${target_configargs}"
13
14-FLAGS_FOR_TARGET=
15+FLAGS_FOR_TARGET="$ARCH_FLAGS_FOR_TARGET"
16 case " $target_configdirs " in
17 *" newlib "*)
18 case " $target_configargs " in
19Index: gcc-4.3.1/configure
20===================================================================
21--- gcc-4.3.1.orig/configure 2008-07-21 12:29:48.000000000 -0700
22+++ gcc-4.3.1/configure 2008-07-21 12:29:59.000000000 -0700
23@@ -5841,7 +5841,7 @@ fi
24 # for target_alias and gcc doesn't manage it consistently.
25 target_configargs="--cache-file=./config.cache ${target_configargs}"
26
27-FLAGS_FOR_TARGET=
28+FLAGS_FOR_TARGET="$ARCH_FLAGS_FOR_TARGET"
29 case " $target_configdirs " in
30 *" newlib "*)
31 case " $target_configargs " in
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch
new file mode 100644
index 0000000000..af0b81ba4c
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch
@@ -0,0 +1,114 @@
1Before committing, I noticed that PR/32161 was marked as a dup of PR/32009, but my previous patch did not fix it.
2
3This alternative patch is better because it lets you just use CFLAGS_FOR_TARGET to set the compilation flags for libgcc. Since bootstrapped target libraries are never compiled with the native compiler, it makes little sense to use different flags for stage1 and later stages. And it also makes little sense to use a different variable than CFLAGS_FOR_TARGET.
4
5Other changes I had to do include:
6
7- moving the creation of default CFLAGS_FOR_TARGET from Makefile.am to configure.ac, because otherwise the BOOT_CFLAGS are substituted into CFLAGS_FOR_TARGET (which is "-O2 -g $(CFLAGS)") via $(CFLAGS). It is also cleaner this way though.
8
9- passing the right CFLAGS to configure scripts as exported environment variables
10
11I also stopped passing LIBCFLAGS to configure scripts since they are unused in the whole src tree. And I updated the documentation as H-P reminded me to do.
12
13Bootstrapped/regtested i686-pc-linux-gnu, will commit to 4.4 shortly. Ok for 4.3?
14
15Paolo
16
172008-02-19 Paolo Bonzini <bonzini@gnu.org>
18
19 PR bootstrap/32009
20 PR bootstrap/32161
21
22 * configure.ac (CFLAGS_FOR_TARGET, CXXFLAGS_FOR_TARGET): Compute here.
23 * configure: Regenerate.
24
25 * Makefile.def: Define stage_libcflags for all bootstrap stages.
26 * Makefile.tpl (BOOT_LIBCFLAGS, STAGE2_LIBCFLAGS, STAGE3_LIBCFLAGS,
27 STAGE4_LIBCFLAGS): New.
28 (CFLAGS_FOR_TARGET, CXXFLAGS_FOR_TARGET): Subst from autoconf, without
29 $(SYSROOT_CFLAGS_FOR_TARGET) and $(DEBUG_PREFIX_CFLAGS_FOR_TARGET).
30 (BASE_TARGET_EXPORTS): Append them here to C{,XX}FLAGS.
31 (EXTRA_TARGET_FLAGS): Append them here to {LIB,}C{,XX}FLAGS.
32 (configure-stage[+id+]-[+prefix+][+module+]): Pass stage_libcflags
33 for target modules. Don't export LIBCFLAGS.
34 (all-stage[+id+]-[+prefix+][+module+]): Pass stage_libcflags; pass
35 $(BASE_FLAGS_TO_PASS) where [+args+] was passed, and [+args+] after
36 the overridden CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
37 (invocations of `all'): Replace $(TARGET_FLAGS_TO_PASS) with
38 $(EXTRA_TARGET_FLAGS), $(FLAGS_TO_PASS) with $(EXTRA_HOST_FLAGS).
39 * Makefile.in: Regenerate.
40
41config:
422008-02-19 Paolo Bonzini <bonzini@gnu.org>
43
44 PR bootstrap/32009
45 * mh-ppc-darwin (BOOT_CFLAGS): Reenable.
46
47gcc:
482008-02-19 Paolo Bonzini <bonzini@gnu.org>
49
50 PR bootstrap/32009
51 * doc/install.texi: Correct references to CFLAGS, replacing them
52 with BOOT_CFLAGS. Document flags used during bootstrap for
53 target libraries.
54
55
56---
57 Makefile.def | 25
58 Makefile.in | 1845 ++++++++++++++++++++++++++++++-------------------
59 Makefile.tpl | 91 +-
60 config/mh-ppc-darwin | 3
61 configure | 36
62 configure.ac | 32
63 gcc/Makefile.in | 2
64 gcc/configure | 6
65 gcc/configure.ac | 3
66 gcc/doc/install.texi | 56 -
67 libiberty/Makefile.in | 162 ++--
68 libiberty/configure | 46 -
69 libiberty/configure.ac | 43 -
70 13 files changed, 1454 insertions(+), 896 deletions(-)
71
72Index: gcc-4.5.0/configure
73===================================================================
74--- gcc-4.5.0.orig/configure 2010-06-25 14:51:59.409382073 -0700
75+++ gcc-4.5.0/configure 2010-06-25 14:52:35.157132702 -0700
76@@ -7130,6 +7130,38 @@
77 fi
78
79
80+# During gcc bootstrap, if we use some random cc for stage1 then CFLAGS
81+# might be empty or "-g". We don't require a C++ compiler, so CXXFLAGS
82+# might also be empty (or "-g", if a non-GCC C++ compiler is in the path).
83+# We want to ensure that TARGET libraries (which we know are built with
84+# gcc) are built with "-O2 -g", so include those options when setting
85+# CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
86+if test "x$CFLAGS_FOR_TARGET" = x; then
87+ CFLAGS_FOR_TARGET=$CFLAGS
88+ case " $CFLAGS " in
89+ *" -O2 "*) ;;
90+ *) CFLAGS_FOR_TARGET="-O2 $CFLAGS" ;;
91+ esac
92+ case " $CFLAGS " in
93+ *" -g "* | *" -g3 "*) ;;
94+ *) CFLAGS_FOR_TARGET="-g $CFLAGS" ;;
95+ esac
96+fi
97+
98+
99+if test "x$CXXFLAGS_FOR_TARGET" = x; then
100+ CXXFLAGS_FOR_TARGET=$CXXFLAGS
101+ case " $CXXFLAGS " in
102+ *" -O2 "*) ;;
103+ *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS" ;;
104+ esac
105+ case " $CXXFLAGS " in
106+ *" -g "* | *" -g3 "*) ;;
107+ *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS" ;;
108+ esac
109+fi
110+
111+
112 # Handle --with-headers=XXX. If the value is not "yes", the contents of
113 # the named directory are copied to $(tooldir)/sys-include.
114 if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.5.0_to_svn_162697.patch.bz2 b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.5.0_to_svn_162697.patch.bz2
new file mode 100644
index 0000000000..d37a2c0329
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-4.5.0_to_svn_162697.patch.bz2
Binary files differ
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-arm-frename-registers.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-arm-frename-registers.patch
new file mode 100644
index 0000000000..280b90358e
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-arm-frename-registers.patch
@@ -0,0 +1,25 @@
1http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35964
2Index: gcc-4.3.0/gcc/regrename.c
3===================================================================
4--- gcc-4.3.0.orig/gcc/regrename.c 2008-05-28 08:31:15.000000000 -0700
5+++ gcc-4.3.0/gcc/regrename.c 2008-05-28 08:34:00.000000000 -0700
6@@ -782,6 +782,10 @@
7 || (predicated && recog_data.operand_type[i] == OP_OUT))
8 recog_data.operand_type[i] = OP_INOUT;
9 }
10+ /* Unshare dup_loc RTL */
11+ for (i = 0; i < recog_data.n_dups; i++)
12+ *recog_data.dup_loc[i] = copy_rtx(*recog_data.dup_loc[i]);
13+
14
15 /* Step 1: Close chains for which we have overlapping reads. */
16 for (i = 0; i < n_ops; i++)
17@@ -813,7 +817,7 @@
18 OP_IN, 0);
19
20 for (i = 0; i < recog_data.n_dups; i++)
21- *recog_data.dup_loc[i] = copy_rtx (old_dups[i]);
22+ *recog_data.dup_loc[i] = old_dups[i];
23 for (i = 0; i < n_ops; i++)
24 *recog_data.operand_loc[i] = old_operands[i];
25 if (recog_data.n_dups)
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-flags-for-build.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-flags-for-build.patch
new file mode 100644
index 0000000000..51892855af
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-flags-for-build.patch
@@ -0,0 +1,178 @@
1Index: gcc-4.5/Makefile.def
2===================================================================
3--- gcc-4.5.orig/Makefile.def
4+++ gcc-4.5/Makefile.def
5@@ -240,6 +240,7 @@ flags_to_pass = { flag= AWK ; };
6 flags_to_pass = { flag= BISON ; };
7 flags_to_pass = { flag= CC_FOR_BUILD ; };
8 flags_to_pass = { flag= CFLAGS_FOR_BUILD ; };
9+flags_to_pass = { flag= CPPFLAGS_FOR_BUILD ; };
10 flags_to_pass = { flag= CXX_FOR_BUILD ; };
11 flags_to_pass = { flag= EXPECT ; };
12 flags_to_pass = { flag= FLEX ; };
13Index: gcc-4.5/gcc/Makefile.in
14===================================================================
15--- gcc-4.5.orig/gcc/Makefile.in
16+++ gcc-4.5/gcc/Makefile.in
17@@ -766,7 +766,7 @@ BUILD_LINKERFLAGS = $(BUILD_CFLAGS)
18
19 # Native linker and preprocessor flags. For x-fragment overrides.
20 BUILD_LDFLAGS=@BUILD_LDFLAGS@
21-BUILD_CPPFLAGS=$(ALL_CPPFLAGS)
22+BUILD_CPPFLAGS=$(INCLUDES) @BUILD_CPPFLAGS@ $(X_CPPFLAGS)
23
24 # Actual name to use when installing a native compiler.
25 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
26Index: gcc-4.5/gcc/configure.ac
27===================================================================
28--- gcc-4.5.orig/gcc/configure.ac
29+++ gcc-4.5/gcc/configure.ac
30@@ -1798,16 +1798,18 @@ AC_SUBST(inhibit_libc)
31 # Also, we cannot run fixincludes.
32
33 # These are the normal (build=host) settings:
34-CC_FOR_BUILD='$(CC)' AC_SUBST(CC_FOR_BUILD)
35-BUILD_CFLAGS='$(ALL_CFLAGS)' AC_SUBST(BUILD_CFLAGS)
36-BUILD_LDFLAGS='$(LDFLAGS)' AC_SUBST(BUILD_LDFLAGS)
37-STMP_FIXINC=stmp-fixinc AC_SUBST(STMP_FIXINC)
38+CC_FOR_BUILD='$(CC)' AC_SUBST(CC_FOR_BUILD)
39+BUILD_CFLAGS='$(ALL_CFLAGS)' AC_SUBST(BUILD_CFLAGS)
40+BUILD_LDFLAGS='$(LDFLAGS)' AC_SUBST(BUILD_LDFLAGS)
41+BUILD_CPPFLAGS='$(ALL_CPPFLAGS)' AC_SUBST(BUILD_CPPFLAGS)
42+STMP_FIXINC=stmp-fixinc AC_SUBST(STMP_FIXINC)
43
44 # And these apply if build != host, or we are generating coverage data
45 if test x$build != x$host || test "x$coverage_flags" != x
46 then
47 BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)'
48 BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)'
49+ BUILD_CPPFLAGS='$(CPPFLAGS_FOR_BUILD)'
50 fi
51
52 # Expand extra_headers to include complete path.
53Index: gcc-4.5/Makefile.in
54===================================================================
55--- gcc-4.5.orig/Makefile.in
56+++ gcc-4.5/Makefile.in
57@@ -333,6 +333,7 @@ AR_FOR_BUILD = @AR_FOR_BUILD@
58 AS_FOR_BUILD = @AS_FOR_BUILD@
59 CC_FOR_BUILD = @CC_FOR_BUILD@
60 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
61+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
62 CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@
63 CXX_FOR_BUILD = @CXX_FOR_BUILD@
64 DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@
65@@ -662,6 +663,7 @@ BASE_FLAGS_TO_PASS = \
66 "BISON=$(BISON)" \
67 "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
68 "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
69+ "CPPFLAGS_FOR_BUILD=$(CPPFLAGS_FOR_BUILD)" \
70 "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
71 "EXPECT=$(EXPECT)" \
72 "FLEX=$(FLEX)" \
73Index: gcc-4.5/gcc/configure
74===================================================================
75--- gcc-4.5.orig/gcc/configure
76+++ gcc-4.5/gcc/configure
77@@ -707,6 +707,7 @@ SED
78 LIBTOOL
79 collect2
80 STMP_FIXINC
81+BUILD_CPPFLAGS
82 BUILD_LDFLAGS
83 BUILD_CFLAGS
84 CC_FOR_BUILD
85@@ -10982,6 +10983,7 @@ fi
86 CC_FOR_BUILD='$(CC)'
87 BUILD_CFLAGS='$(ALL_CFLAGS)'
88 BUILD_LDFLAGS='$(LDFLAGS)'
89+BUILD_CPPFLAGS='$(ALL_CPPFLAGS)'
90 STMP_FIXINC=stmp-fixinc
91
92 # And these apply if build != host, or we are generating coverage data
93@@ -10989,6 +10991,7 @@ if test x$build != x$host || test "x$cov
94 then
95 BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)'
96 BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)'
97+ BUILD_CPPFLAGS='$(CPPFLAGS_FOR_BUILD)'
98 fi
99
100 # Expand extra_headers to include complete path.
101@@ -17108,7 +17111,7 @@ else
102 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
103 lt_status=$lt_dlunknown
104 cat > conftest.$ac_ext <<_LT_EOF
105-#line 17111 "configure"
106+#line 17114 "configure"
107 #include "confdefs.h"
108
109 #if HAVE_DLFCN_H
110@@ -17214,7 +17217,7 @@ else
111 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
112 lt_status=$lt_dlunknown
113 cat > conftest.$ac_ext <<_LT_EOF
114-#line 17217 "configure"
115+#line 17220 "configure"
116 #include "confdefs.h"
117
118 #if HAVE_DLFCN_H
119Index: gcc-4.5/Makefile.tpl
120===================================================================
121--- gcc-4.5.orig/Makefile.tpl
122+++ gcc-4.5/Makefile.tpl
123@@ -336,6 +336,7 @@ AR_FOR_BUILD = @AR_FOR_BUILD@
124 AS_FOR_BUILD = @AS_FOR_BUILD@
125 CC_FOR_BUILD = @CC_FOR_BUILD@
126 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
127+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
128 CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@
129 CXX_FOR_BUILD = @CXX_FOR_BUILD@
130 DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@
131Index: gcc-4.5/configure
132===================================================================
133--- gcc-4.5.orig/configure
134+++ gcc-4.5/configure
135@@ -651,6 +651,7 @@ GCJ_FOR_BUILD
136 DLLTOOL_FOR_BUILD
137 CXX_FOR_BUILD
138 CXXFLAGS_FOR_BUILD
139+CPPFLAGS_FOR_BUILD
140 CFLAGS_FOR_BUILD
141 CC_FOR_BUILD
142 AS_FOR_BUILD
143@@ -8036,6 +8037,7 @@ esac
144 # our build compiler if desired.
145 if test x"${build}" = x"${host}" ; then
146 CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
147+ CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}}
148 CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}}
149 LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}}
150 fi
151@@ -8101,6 +8103,7 @@ done
152
153
154
155+
156
157
158
159Index: gcc-4.5/configure.ac
160===================================================================
161--- gcc-4.5.orig/configure.ac
162+++ gcc-4.5/configure.ac
163@@ -3089,6 +3089,7 @@ esac
164 # our build compiler if desired.
165 if test x"${build}" = x"${host}" ; then
166 CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
167+ CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}}
168 CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}}
169 LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}}
170 fi
171@@ -3155,6 +3156,7 @@ AC_SUBST(AR_FOR_BUILD)
172 AC_SUBST(AS_FOR_BUILD)
173 AC_SUBST(CC_FOR_BUILD)
174 AC_SUBST(CFLAGS_FOR_BUILD)
175+AC_SUBST(CPPFLAGS_FOR_BUILD)
176 AC_SUBST(CXXFLAGS_FOR_BUILD)
177 AC_SUBST(CXX_FOR_BUILD)
178 AC_SUBST(DLLTOOL_FOR_BUILD)
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch
new file mode 100644
index 0000000000..84c5ef2ebd
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-ice-hack.dpatch
@@ -0,0 +1,331 @@
1#! /bin/sh -e
2
3# DP: Retry the build on an ice, save the calling options and preprocessed
4# DP: source when the ice is reproducible.
5
6dir=
7if [ $# -eq 3 -a "$2" = '-d' ]; then
8 pdir="-d $3"
9 dir="$3/"
10elif [ $# -ne 1 ]; then
11 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
12 exit 1
13fi
14case "$1" in
15 -patch)
16 patch $pdir -f --no-backup-if-mismatch -p0 < $0
17 ;;
18 -unpatch)
19 patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
20 ;;
21 *)
22 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
23 exit 1
24esac
25exit 0
26
272004-01-23 Jakub Jelinek <jakub@redhat.com>
28
29 * system.h (ICE_EXIT_CODE): Define.
30 * gcc.c (execute): Don't free first string early, but at the end
31 of the function. Call retry_ice if compiler exited with
32 ICE_EXIT_CODE.
33 (retry_ice): New function.
34 * diagnostic.c (diagnostic_count_diagnostic,
35 diagnostic_action_after_output, error_recursion): Exit with
36 ICE_EXIT_CODE instead of FATAL_EXIT_CODE.
37
38--- gcc/diagnostic.c.orig 2007-09-30 10:48:13.000000000 +0000
39+++ gcc/diagnostic.c 2007-09-30 10:49:57.000000000 +0000
40@@ -244,7 +244,7 @@
41 fnotice (stderr, "Please submit a full bug report,\n"
42 "with preprocessed source if appropriate.\n"
43 "See %s for instructions.\n", bug_report_url);
44- exit (ICE_EXIT_CODE);
45+ exit (FATAL_EXIT_CODE);
46
47 case DK_FATAL:
48 if (context->abort_on_error)
49--- gcc/gcc.c.orig 2007-09-30 10:48:13.000000000 +0000
50+++ gcc/gcc.c 2007-09-30 10:48:39.000000000 +0000
51@@ -357,6 +357,9 @@
52 #if defined(HAVE_TARGET_OBJECT_SUFFIX) || defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
53 static const char *convert_filename (const char *, int, int);
54 #endif
55+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
56+static void retry_ice (const char *prog, const char **argv);
57+#endif
58
59 static const char *getenv_spec_function (int, const char **);
60 static const char *if_exists_spec_function (int, const char **);
61@@ -2999,7 +3002,7 @@
62 }
63 }
64
65- if (string != commands[i].prog)
66+ if (i && string != commands[i].prog)
67 free (CONST_CAST (char *, string));
68 }
69
70@@ -3056,6 +3059,16 @@
71 else if (WIFEXITED (status)
72 && WEXITSTATUS (status) >= MIN_FATAL_STATUS)
73 {
74+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
75+ /* For ICEs in cc1, cc1obj, cc1plus see if it is
76+ reproducible or not. */
77+ char *p;
78+ if (WEXITSTATUS (status) == ICE_EXIT_CODE
79+ && i == 0
80+ && (p = strrchr (commands[0].argv[0], DIR_SEPARATOR))
81+ && ! strncmp (p + 1, "cc1", 3))
82+ retry_ice (commands[0].prog, commands[0].argv);
83+#endif
84 if (WEXITSTATUS (status) > greatest_status)
85 greatest_status = WEXITSTATUS (status);
86 ret_code = -1;
87@@ -3076,6 +3089,9 @@
88 }
89 }
90
91+ if (commands[0].argv[0] != commands[0].prog)
92+ free ((PTR) commands[0].argv[0]);
93+
94 return ret_code;
95 }
96 }
97@@ -6016,6 +6032,224 @@
98 switches[switchnum].validated = 1;
99 }
100
101+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
102+#define RETRY_ICE_ATTEMPTS 2
103+
104+static void
105+retry_ice (const char *prog, const char **argv)
106+{
107+ int nargs, out_arg = -1, quiet = 0, attempt;
108+ int pid, retries, sleep_interval;
109+ const char **new_argv;
110+ char *temp_filenames[RETRY_ICE_ATTEMPTS * 2 + 2];
111+
112+ if (input_filename == NULL || ! strcmp (input_filename, "-"))
113+ return;
114+
115+ for (nargs = 0; argv[nargs] != NULL; ++nargs)
116+ /* Only retry compiler ICEs, not preprocessor ones. */
117+ if (! strcmp (argv[nargs], "-E"))
118+ return;
119+ else if (argv[nargs][0] == '-' && argv[nargs][1] == 'o')
120+ {
121+ if (out_arg == -1)
122+ out_arg = nargs;
123+ else
124+ return;
125+ }
126+ /* If the compiler is going to output any time information,
127+ it might vary between invocations. */
128+ else if (! strcmp (argv[nargs], "-quiet"))
129+ quiet = 1;
130+ else if (! strcmp (argv[nargs], "-ftime-report"))
131+ return;
132+
133+ if (out_arg == -1 || !quiet)
134+ return;
135+
136+ memset (temp_filenames, '\0', sizeof (temp_filenames));
137+ new_argv = alloca ((nargs + 3) * sizeof (const char *));
138+ memcpy (new_argv, argv, (nargs + 1) * sizeof (const char *));
139+ new_argv[nargs++] = "-frandom-seed=0";
140+ new_argv[nargs] = NULL;
141+ if (new_argv[out_arg][2] == '\0')
142+ new_argv[out_arg + 1] = "-";
143+ else
144+ new_argv[out_arg] = "-o-";
145+
146+ for (attempt = 0; attempt < RETRY_ICE_ATTEMPTS + 1; ++attempt)
147+ {
148+ int fd = -1;
149+ int status;
150+
151+ temp_filenames[attempt * 2] = make_temp_file (".out");
152+ temp_filenames[attempt * 2 + 1] = make_temp_file (".err");
153+
154+ if (attempt == RETRY_ICE_ATTEMPTS)
155+ {
156+ int i;
157+ int fd1, fd2;
158+ struct stat st1, st2;
159+ size_t n, len;
160+ char *buf;
161+
162+ buf = xmalloc (8192);
163+
164+ for (i = 0; i < 2; ++i)
165+ {
166+ fd1 = open (temp_filenames[i], O_RDONLY);
167+ fd2 = open (temp_filenames[2 + i], O_RDONLY);
168+
169+ if (fd1 < 0 || fd2 < 0)
170+ {
171+ i = -1;
172+ close (fd1);
173+ close (fd2);
174+ break;
175+ }
176+
177+ if (fstat (fd1, &st1) < 0 || fstat (fd2, &st2) < 0)
178+ {
179+ i = -1;
180+ close (fd1);
181+ close (fd2);
182+ break;
183+ }
184+
185+ if (st1.st_size != st2.st_size)
186+ {
187+ close (fd1);
188+ close (fd2);
189+ break;
190+ }
191+
192+ len = 0;
193+ for (n = st1.st_size; n; n -= len)
194+ {
195+ len = n;
196+ if (len > 4096)
197+ len = 4096;
198+
199+ if (read (fd1, buf, len) != (int) len
200+ || read (fd2, buf + 4096, len) != (int) len)
201+ {
202+ i = -1;
203+ break;
204+ }
205+
206+ if (memcmp (buf, buf + 4096, len) != 0)
207+ break;
208+ }
209+
210+ close (fd1);
211+ close (fd2);
212+
213+ if (n)
214+ break;
215+ }
216+
217+ free (buf);
218+ if (i == -1)
219+ break;
220+
221+ if (i != 2)
222+ {
223+ notice ("The bug is not reproducible, so it is likely a hardware or OS problem.\n");
224+ break;
225+ }
226+
227+ fd = open (temp_filenames[attempt * 2], O_RDWR);
228+ if (fd < 0)
229+ break;
230+ write (fd, "//", 2);
231+ for (i = 0; i < nargs; i++)
232+ {
233+ write (fd, " ", 1);
234+ write (fd, new_argv[i], strlen (new_argv[i]));
235+ }
236+ write (fd, "\n", 1);
237+ new_argv[nargs] = "-E";
238+ new_argv[nargs + 1] = NULL;
239+ }
240+
241+ /* Fork a subprocess; wait and retry if it fails. */
242+ sleep_interval = 1;
243+ pid = -1;
244+ for (retries = 0; retries < 4; retries++)
245+ {
246+ pid = fork ();
247+ if (pid >= 0)
248+ break;
249+ sleep (sleep_interval);
250+ sleep_interval *= 2;
251+ }
252+
253+ if (pid < 0)
254+ break;
255+ else if (pid == 0)
256+ {
257+ if (attempt != RETRY_ICE_ATTEMPTS)
258+ fd = open (temp_filenames[attempt * 2], O_RDWR);
259+ if (fd < 0)
260+ exit (-1);
261+ if (fd != 1)
262+ {
263+ close (1);
264+ dup (fd);
265+ close (fd);
266+ }
267+
268+ fd = open (temp_filenames[attempt * 2 + 1], O_RDWR);
269+ if (fd < 0)
270+ exit (-1);
271+ if (fd != 2)
272+ {
273+ close (2);
274+ dup (fd);
275+ close (fd);
276+ }
277+
278+ if (prog == new_argv[0])
279+ execvp (prog, (char *const *) new_argv);
280+ else
281+ execv (new_argv[0], (char *const *) new_argv);
282+ exit (-1);
283+ }
284+
285+ if (waitpid (pid, &status, 0) < 0)
286+ break;
287+
288+ if (attempt < RETRY_ICE_ATTEMPTS
289+ && (! WIFEXITED (status) || WEXITSTATUS (status) != ICE_EXIT_CODE))
290+ {
291+ notice ("The bug is not reproducible, so it is likely a hardware or OS problem.\n");
292+ break;
293+ }
294+ else if (attempt == RETRY_ICE_ATTEMPTS)
295+ {
296+ close (fd);
297+ if (WIFEXITED (status)
298+ && WEXITSTATUS (status) == SUCCESS_EXIT_CODE)
299+ {
300+ notice ("Preprocessed source stored into %s file, please attach this to your bugreport.\n",
301+ temp_filenames[attempt * 2]);
302+ /* Make sure it is not deleted. */
303+ free (temp_filenames[attempt * 2]);
304+ temp_filenames[attempt * 2] = NULL;
305+ break;
306+ }
307+ }
308+ }
309+
310+ for (attempt = 0; attempt < RETRY_ICE_ATTEMPTS * 2 + 2; attempt++)
311+ if (temp_filenames[attempt])
312+ {
313+ unlink (temp_filenames[attempt]);
314+ free (temp_filenames[attempt]);
315+ }
316+}
317+#endif
318+
319 /* Search for a file named NAME trying various prefixes including the
320 user's -B prefix and some standard ones.
321 Return the absolute file name found. If nothing is found, return NAME. */
322--- gcc/Makefile.in.orig 2007-09-30 10:48:13.000000000 +0000
323+++ gcc/Makefile.in 2007-09-30 10:48:39.000000000 +0000
324@@ -192,6 +192,7 @@
325 build/gengtype-lex.o-warn = -Wno-error
326 # SYSCALLS.c misses prototypes
327 SYSCALLS.c.X-warn = -Wno-strict-prototypes -Wno-error
328+build/gcc.o-warn = -Wno-error
329
330 # All warnings have to be shut off in stage1 if the compiler used then
331 # isn't gcc; configure determines that. WARN_CFLAGS will be either
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-poison-system-directories.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-poison-system-directories.patch
new file mode 100644
index 0000000000..e68a2de2a2
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-poison-system-directories.patch
@@ -0,0 +1,149 @@
1 gcc/
2 2008-07-02 Joseph Myers <joseph@codesourcery.com>
3 * c-incpath.c: Include toplev.h.
4 (merge_include_chains): Use warning instead of cpp_error for
5 system directory poisoning diagnostic.
6 * Makefile.in (c-incpath.o): Depend on toplev.h.
7 * gcc.c (LINK_COMMAND_SPEC): Pass
8 --error-poison-system-directories if
9 -Werror=poison-system-directories.
10
11 2007-06-13 Joseph Myers <joseph@codesourcery.com>
12 * common.opt (--Wno-poison-system-directories): New.
13 * doc/invoke.texi (-Wno-poison-system-directories): Document.
14 * c-incpath.c: Include flags.h.
15 (merge_include_chains): Check flag_poison_system_directories.
16 * gcc.c (LINK_COMMAND_SPEC): Pass --no-poison-system-directories
17 to linker if -Wno-poison-system-directories.
18 * Makefile.in (c-incpath.o): Depend on $(FLAGS_H).
19
20 2007-03-20 Daniel Jacobowitz <dan@codesourcery.com>
21 Joseph Myers <joseph@codesourcery.com>
22 * configure.ac (--enable-poison-system-directories): New option.
23 * configure, config.in: Regenerate.
24 * c-incpath.c (merge_include_chains): If
25 ENABLE_POISON_SYSTEM_DIRECTORIES defined, warn for use of
26 /usr/include, /usr/local/include or /usr/X11R6/include.
27
28Index: gcc-4.5.0/gcc/common.opt
29===================================================================
30--- gcc-4.5.0.orig/gcc/common.opt 2010-03-17 20:01:09.000000000 -0700
31+++ gcc-4.5.0/gcc/common.opt 2010-06-25 11:35:39.965383734 -0700
32@@ -152,6 +152,10 @@
33 Common Var(warn_padded) Warning
34 Warn when padding is required to align structure members
35
36+Wpoison-system-directories
37+Common Var(flag_poison_system_directories) Init(1)
38+Warn for -I and -L options using system directories if cross compiling
39+
40 Wshadow
41 Common Var(warn_shadow) Warning
42 Warn when one local variable shadows another
43Index: gcc-4.5.0/gcc/config.in
44===================================================================
45--- gcc-4.5.0.orig/gcc/config.in 2010-04-14 02:30:07.000000000 -0700
46+++ gcc-4.5.0/gcc/config.in 2010-06-25 11:35:39.969383588 -0700
47@@ -132,6 +132,12 @@
48 #endif
49
50
51+/* Define to warn for use of native system header directories */
52+#ifndef USED_FOR_TARGET
53+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
54+#endif
55+
56+
57 /* Define if you want all operations on RTL (the basic data structure of the
58 optimizer and back end) to be checked for dynamic type safety at runtime.
59 This is quite expensive. */
60Index: gcc-4.5.0/gcc/configure.ac
61===================================================================
62--- gcc-4.5.0.orig/gcc/configure.ac 2010-06-25 11:34:01.433382161 -0700
63+++ gcc-4.5.0/gcc/configure.ac 2010-06-25 11:35:39.969383588 -0700
64@@ -4276,6 +4276,16 @@
65 fi)
66 AC_SUBST(slibdir)
67
68+AC_ARG_ENABLE([poison-system-directories],
69+ AS_HELP_STRING([--enable-poison-system-directories],
70+ [warn for use of native system header directories]),,
71+ [enable_poison_system_directories=no])
72+if test "x${enable_poison_system_directories}" = "xyes"; then
73+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
74+ [1],
75+ [Define to warn for use of native system header directories])
76+fi
77+
78 # Substitute configuration variables
79 AC_SUBST(subdirs)
80 AC_SUBST(srcdir)
81Index: gcc-4.5.0/gcc/doc/invoke.texi
82===================================================================
83--- gcc-4.5.0.orig/gcc/doc/invoke.texi 2010-04-06 07:02:22.000000000 -0700
84+++ gcc-4.5.0/gcc/doc/invoke.texi 2010-06-25 11:35:39.992666345 -0700
85@@ -252,6 +252,7 @@
86 -Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded @gol
87 -Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
88 -Wpointer-arith -Wno-pointer-to-int-cast @gol
89+-Wno-poison-system-directories @gol
90 -Wredundant-decls @gol
91 -Wreturn-type -Wsequence-point -Wshadow @gol
92 -Wsign-compare -Wsign-conversion -Wstack-protector @gol
93@@ -3603,6 +3604,14 @@
94 option will @emph{not} warn about unknown pragmas in system
95 headers---for that, @option{-Wunknown-pragmas} must also be used.
96
97+@item -Wno-poison-system-directories
98+@opindex Wno-poison-system-directories
99+Do not warn for @option{-I} or @option{-L} options using system
100+directories such as @file{/usr/include} when cross compiling. This
101+option is intended for use in chroot environments when such
102+directories contain the correct headers and libraries for the target
103+system rather than the host.
104+
105 @item -Wfloat-equal
106 @opindex Wfloat-equal
107 @opindex Wno-float-equal
108Index: gcc-4.5.0/gcc/gcc.c
109===================================================================
110--- gcc-4.5.0.orig/gcc/gcc.c 2010-02-11 04:23:08.000000000 -0800
111+++ gcc-4.5.0/gcc/gcc.c 2010-06-25 11:35:40.009381858 -0700
112@@ -792,6 +792,8 @@
113 %{flto} %{fwhopr} %l " LINK_PIE_SPEC \
114 "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
115 %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
116+ %{Wno-poison-system-directories:--no-poison-system-directories}\
117+ %{Werror=poison-system-directories:--error-poison-system-directories}\
118 %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
119 %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
120 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov}\
121Index: gcc-4.5.0/gcc/incpath.c
122===================================================================
123--- gcc-4.5.0.orig/gcc/incpath.c 2009-11-25 02:55:54.000000000 -0800
124+++ gcc-4.5.0/gcc/incpath.c 2010-06-25 11:35:40.017209818 -0700
125@@ -353,6 +353,24 @@
126 }
127 fprintf (stderr, _("End of search list.\n"));
128 }
129+
130+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
131+ if (flag_poison_system_directories)
132+ {
133+ struct cpp_dir *p;
134+
135+ for (p = heads[QUOTE]; p; p = p->next)
136+ {
137+ if ((!strncmp (p->name, "/usr/include", 12))
138+ || (!strncmp (p->name, "/usr/local/include", 18))
139+ || (!strncmp (p->name, "/usr/X11R6/include", 18)))
140+ warning (OPT_Wpoison_system_directories,
141+ "include location \"%s\" is unsafe for "
142+ "cross-compilation",
143+ p->name);
144+ }
145+ }
146+#endif
147 }
148
149 /* Use given -I paths for #include "..." but not #include <...>, and
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-pr43698-arm-rev-instr.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-pr43698-arm-rev-instr.patch
new file mode 100644
index 0000000000..61c883e1ff
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-pr43698-arm-rev-instr.patch
@@ -0,0 +1,117 @@
1backport http://gcc.gnu.org/viewcvs?view=revision&revision=162404
2from trunk
3
4Which fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43698
5
62010-07-22 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
7
8 PR target/43698
9 * config/arm/arm.md: Split arm_rev into *arm_rev
10 and *thumb1_rev. Set *arm_rev to be predicable.
11
122010-07-22 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
13
14 PR target/43698
15 * gcc.target/arm/pr43698.c: New test.
16
17
18/scratch/oe/sysroots/i686-linux/usr/share/quilt/compat/date
19Usage: date [OPTION]... [+FORMAT]
20Display the current time in the given FORMAT.
21
22 -d, --date=STRING display time described by STRING, not `now'
23 -f, --file=DATEFILE like --date once for each line of DATEFILE
24 -R, --rfc-822 output RFC-822 compliant date string
25 -u, --utc, --universal print or set Coordinated Universal Time
26 --help display this help and exit
27date is /scratch/oe/sysroots/i686-linux/usr/share/quilt/compat/date
28date is /scratch/oe/sysroots/i686-linux/usr/share/quilt/compat/date
29date is /bin/date
30date is /scratch/oe/sysroots/i686-linux/usr/share/quilt/compat/date
31date is /scratch/oe/sysroots/i686-linux/usr/share/quilt/compat/date
32date is /bin/date
33date is /scratch/oe/sysroots/i686-linux/usr/share/quilt/compat/date
34date is /scratch/oe/sysroots/i686-linux/usr/share/quilt/compat/date
35date is /bin/date
36date is /scratch/oe/sysroots/i686-linux/usr/share/quilt/compat/date
37date is /scratch/oe/sysroots/i686-linux/usr/share/quilt/compat/date
38date is /bin/date
39date
40Khem
41Index: gcc-4.5/gcc/config/arm/arm.md
42===================================================================
43--- gcc-4.5.orig/gcc/config/arm/arm.md 2010-07-20 20:31:25.000000000 -0700
44+++ gcc-4.5/gcc/config/arm/arm.md 2010-07-22 14:55:54.303169081 -0700
45@@ -11197,15 +11197,21 @@
46 (set_attr "length" "4")]
47 )
48
49-(define_insn "arm_rev"
50+(define_insn "*arm_rev"
51 [(set (match_operand:SI 0 "s_register_operand" "=r")
52 (bswap:SI (match_operand:SI 1 "s_register_operand" "r")))]
53- "TARGET_EITHER && arm_arch6"
54- "rev\t%0, %1"
55- [(set (attr "length")
56- (if_then_else (eq_attr "is_thumb" "yes")
57- (const_int 2)
58- (const_int 4)))]
59+ "TARGET_32BIT && arm_arch6"
60+ "rev%?\t%0, %1"
61+ [(set_attr "predicable" "yes")
62+ (set_attr "length" "4")]
63+)
64+
65+(define_insn "*thumb1_rev"
66+ [(set (match_operand:SI 0 "s_register_operand" "=l")
67+ (bswap:SI (match_operand:SI 1 "s_register_operand" "l")))]
68+ "TARGET_THUMB1 && arm_arch6"
69+ "rev\t%0, %1"
70+ [(set_attr "length" "2")]
71 )
72
73 (define_expand "arm_legacy_rev"
74Index: gcc-4.5/gcc/testsuite/gcc.target/arm/pr43698.c
75===================================================================
76--- /dev/null 1970-01-01 00:00:00.000000000 +0000
77+++ gcc-4.5/gcc/testsuite/gcc.target/arm/pr43698.c 2010-07-22 14:56:35.406670213 -0700
78@@ -0,0 +1,39 @@
79+/* { dg-do run } */
80+/* { dg-options "-Os -march=armv7-a" } */
81+#include <stdint.h>
82+#include <stdlib.h>
83+
84+
85+char do_reverse_endian = 0;
86+
87+# define bswap_32(x) \
88+ ((((x) & 0xff000000) >> 24) | \
89+ (((x) & 0x00ff0000) >> 8) | \
90+ (((x) & 0x0000ff00) << 8) | \
91+ (((x) & 0x000000ff) << 24))
92+
93+#define EGET(X) \
94+ (__extension__ ({ \
95+ uint64_t __res; \
96+ if (!do_reverse_endian) { __res = (X); \
97+ } else if (sizeof(X) == 4) { __res = bswap_32((X)); \
98+ } \
99+ __res; \
100+ }))
101+
102+void __attribute__((noinline)) X(char **phdr, char **data, int *phoff)
103+{
104+ *phdr = *data + EGET(*phoff);
105+}
106+
107+int main()
108+{
109+ char *phdr;
110+ char *data = (char *)0x40164000;
111+ int phoff = 0x34;
112+ X(&phdr, &data, &phoff);
113+ if (phdr != (char *)0x40164034)
114+ abort ();
115+ exit (0);
116+}
117+
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-uclibc-locale-ctype_touplow_t.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-uclibc-locale-ctype_touplow_t.patch
new file mode 100644
index 0000000000..4f94fc9d66
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-uclibc-locale-ctype_touplow_t.patch
@@ -0,0 +1,67 @@
1Index: gcc-4.5/libstdc++-v3/config/locale/generic/c_locale.h
2===================================================================
3--- gcc-4.5.orig/libstdc++-v3/config/locale/generic/c_locale.h 2010-06-30 22:30:53.993316002 -0700
4+++ gcc-4.5/libstdc++-v3/config/locale/generic/c_locale.h 2010-06-30 22:31:26.043316001 -0700
5@@ -41,12 +41,17 @@
6
7 #include <clocale>
8 #include <cstddef>
9+#include <features.h>
10+#include <ctype.h>
11
12 #define _GLIBCXX_NUM_CATEGORIES 0
13
14 _GLIBCXX_BEGIN_NAMESPACE(std)
15-
16- typedef int* __c_locale;
17+#ifdef __UCLIBC__
18+ typedef __ctype_touplow_t* __c_locale;
19+#else
20+ typedef int* __c_locale;
21+#endif
22
23 // Convert numeric value of type double and long double to string and
24 // return length of string. If vsnprintf is available use it, otherwise
25Index: gcc-4.5/libstdc++-v3/config/os/gnu-linux/ctype_base.h
26===================================================================
27--- gcc-4.5.orig/libstdc++-v3/config/os/gnu-linux/ctype_base.h 2010-06-30 22:30:54.013316002 -0700
28+++ gcc-4.5/libstdc++-v3/config/os/gnu-linux/ctype_base.h 2010-06-30 22:31:26.053316001 -0700
29@@ -33,14 +33,21 @@
30 */
31
32 // Information as gleaned from /usr/include/ctype.h
33-
34+
35+#include <features.h>
36+#include <ctype.h>
37+
38 _GLIBCXX_BEGIN_NAMESPACE(std)
39
40 /// @brief Base class for ctype.
41 struct ctype_base
42 {
43 // Non-standard typedefs.
44- typedef const int* __to_type;
45+#ifdef __UCLIBC__
46+ typedef const __ctype_touplow_t* __to_type;
47+#else
48+ typedef const int* __to_type;
49+#endif
50
51 // NB: Offsets into ctype<char>::_M_table force a particular size
52 // on the mask type. Because of this, we don't use an enum.
53Index: gcc-4.5/libstdc++-v3/config/locale/generic/c_locale.cc
54===================================================================
55--- gcc-4.5.orig/libstdc++-v3/config/locale/generic/c_locale.cc 2010-06-28 12:12:42.000000000 -0700
56+++ gcc-4.5/libstdc++-v3/config/locale/generic/c_locale.cc 2010-06-30 22:31:26.063316001 -0700
57@@ -256,5 +256,10 @@ _GLIBCXX_END_NAMESPACE
58 #ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
59 #define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
60 extern "C" void ldbl (void) __attribute__ ((alias (#dbl)))
61+#ifdef __UCLIBC__
62+// This is because __c_locale is of type __ctype_touplow_t* which is short on uclibc. for glibc its int*
63+_GLIBCXX_LDBL_COMPAT(_ZSt14__convert_to_vIdEvPKcRT_RSt12_Ios_IostateRKPs, _ZSt14__convert_to_vIeEvPKcRT_RSt12_Ios_IostateRKPs);
64+#else
65 _GLIBCXX_LDBL_COMPAT(_ZSt14__convert_to_vIdEvPKcRT_RSt12_Ios_IostateRKPi, _ZSt14__convert_to_vIeEvPKcRT_RSt12_Ios_IostateRKPi);
66+#endif
67 #endif // _GLIBCXX_LONG_DOUBLE_COMPAT
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc_revert_base_version_to_4.5.0.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc_revert_base_version_to_4.5.0.patch
new file mode 100644
index 0000000000..5f134ef338
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc_revert_base_version_to_4.5.0.patch
@@ -0,0 +1,9 @@
1the svn patch changed the BASE-VER to 4.5.1, bring it back to 4.5.0
2- Nitin A Kamble nitin.a.kamble@intel.com
3- 2010/07/20
4
5--- gcc-4.5.0/gcc/BASE-VER 2010-07-20 00:57:37.000000000 -0700
6+++ gcc-4.5.0.new/gcc/BASE-VER 2010-07-20 01:06:17.000000000 -0700
7@@ -1 +1 @@
8-4.5.1
9+4.5.0
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/libstdc++-emit-__cxa_end_cleanup-in-text.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/libstdc++-emit-__cxa_end_cleanup-in-text.patch
new file mode 100644
index 0000000000..ada36a5914
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/libstdc++-emit-__cxa_end_cleanup-in-text.patch
@@ -0,0 +1,40 @@
12010-06-07 Khem Raj <raj.khem@gmail.com>
2
3 * libsupc++/eh_arm.cc (__cxa_end_cleanup): Use .pushsection/.popsection
4 to emit inline assembly into .text section.
5
6Index: gcc-4.5/libstdc++-v3/libsupc++/eh_arm.cc
7===================================================================
8--- gcc-4.5.orig/libstdc++-v3/libsupc++/eh_arm.cc 2010-06-04 23:20:18.000000000 -0700
9+++ gcc-4.5/libstdc++-v3/libsupc++/eh_arm.cc 2010-06-08 11:27:34.247541722 -0700
10@@ -157,22 +157,26 @@ __gnu_end_cleanup(void)
11 // Assembly wrapper to call __gnu_end_cleanup without clobbering r1-r3.
12 // Also push r4 to preserve stack alignment.
13 #ifdef __thumb__
14-asm (".global __cxa_end_cleanup\n"
15+asm (" .pushsection .text.__cxa_end_cleanup\n"
16+" .global __cxa_end_cleanup\n"
17 " .type __cxa_end_cleanup, \"function\"\n"
18 " .thumb_func\n"
19 "__cxa_end_cleanup:\n"
20 " push\t{r1, r2, r3, r4}\n"
21 " bl\t__gnu_end_cleanup\n"
22 " pop\t{r1, r2, r3, r4}\n"
23-" bl\t_Unwind_Resume @ Never returns\n");
24+" bl\t_Unwind_Resume @ Never returns\n"
25+" .popsection\n");
26 #else
27-asm (".global __cxa_end_cleanup\n"
28+asm (" .pushsection .text.__cxa_end_cleanup\n"
29+" .global __cxa_end_cleanup\n"
30 " .type __cxa_end_cleanup, \"function\"\n"
31 "__cxa_end_cleanup:\n"
32 " stmfd\tsp!, {r1, r2, r3, r4}\n"
33 " bl\t__gnu_end_cleanup\n"
34 " ldmfd\tsp!, {r1, r2, r3, r4}\n"
35-" bl\t_Unwind_Resume @ Never returns\n");
36+" bl\t_Unwind_Resume @ Never returns\n"
37+" .popsection\n");
38 #endif
39
40 #endif
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/libstdc++-pic.dpatch b/meta/recipes-devtools/gcc/gcc-4.5.0/libstdc++-pic.dpatch
new file mode 100644
index 0000000000..70c9e81542
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/libstdc++-pic.dpatch
@@ -0,0 +1,71 @@
1#! /bin/sh -e
2
3# DP: Build and install libstdc++_pic.a library.
4
5dir=
6if [ $# -eq 3 -a "$2" = '-d' ]; then
7 pdir="-d $3"
8 dir="$3/"
9elif [ $# -ne 1 ]; then
10 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
11 exit 1
12fi
13case "$1" in
14 -patch)
15 patch $pdir -f --no-backup-if-mismatch -p0 < $0
16 ;;
17 -unpatch)
18 patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
19 ;;
20 *)
21 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
22 exit 1
23esac
24exit 0
25
26diff -ur libstdc++-v3/src/Makefile.am libstdc++-v3/src/Makefile.am
27--- libstdc++-v3/src/Makefile.am~ 2004-04-16 21:04:05.000000000 +0200
28+++ libstdc++-v3/src/Makefile.am 2004-07-03 20:22:43.000000000 +0200
29@@ -210,6 +210,10 @@
30 $(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LDFLAGS) -o $@
31
32
33+install-exec-local:
34+ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o || touch libstdc++_pic.a
35+ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
36+
37 # Added bits to build debug library.
38 if GLIBCXX_BUILD_DEBUG
39 all-local: build_debug
40diff -ur libstdc++-v3/src/Makefile.in libstdc++-v3/src/Makefile.in
41--- libstdc++-v3/src/Makefile.in 2004-07-03 06:41:13.000000000 +0200
42+++ libstdc++-v3/src/Makefile.in 2004-07-03 20:25:05.000000000 +0200
43@@ -611,7 +611,7 @@
44
45 install-data-am: install-data-local
46
47-install-exec-am: install-toolexeclibLTLIBRARIES
48+install-exec-am: install-toolexeclibLTLIBRARIES install-exec-local
49
50 install-info: install-info-am
51
52@@ -644,6 +644,7 @@
53 distclean-libtool distclean-tags distdir dvi dvi-am html \
54 html-am info info-am install install-am install-data \
55 install-data-am install-data-local install-exec \
56+ install-exec-local \
57 install-exec-am install-info install-info-am install-man \
58 install-strip install-toolexeclibLTLIBRARIES installcheck \
59 installcheck-am installdirs maintainer-clean \
60@@ -729,6 +730,11 @@
61 install_debug:
62 (cd ${debugdir} && $(MAKE) \
63 toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)
64+
65+install-exec-local:
66+ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o || touch libstdc++_pic.a
67+ $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)
68+
69 # Tell versions [3.59,3.63) of GNU make to not export all variables.
70 # Otherwise a system limit (for SysV at least) may be exceeded.
71 .NOEXPORT:
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/optional_libstdc.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/optional_libstdc.patch
new file mode 100644
index 0000000000..0f74353a1f
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/optional_libstdc.patch
@@ -0,0 +1,23 @@
1gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++
2will not run correctly since my default the linker will try and link against libstdc++
3which shouldn't exist yet. We need an option to disable the automatically added -lstdc++
4option whilst leaving -lc, -lgcc and other automatic library dependencies. This patch
5adds such an option which only disables the -lstdc++ linkage.
6
7A "standard" gcc build uses xgcc and hence avoids this. We should ask upstream how to
8do this officially, the likely answer is don't build libstdc++ separately.
9
10RP 29/6/10
11
12Index: gcc-4.3.3/gcc/cp/g++spec.c
13===================================================================
14--- gcc-4.3.3.orig/gcc/cp/g++spec.c 2010-06-29 00:06:03.901695025 +0100
15+++ gcc-4.3.3/gcc/cp/g++spec.c 2010-06-29 00:06:58.800325439 +0100
16@@ -131,6 +131,7 @@
17 if (argv[i][0] == '-')
18 {
19 if (strcmp (argv[i], "-nostdlib") == 0
20+ || strcmp (argv[i], "-nostdlib++") == 0
21 || strcmp (argv[i], "-nodefaultlibs") == 0)
22 {
23 library = -1;
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/pr30961.dpatch b/meta/recipes-devtools/gcc/gcc-4.5.0/pr30961.dpatch
new file mode 100644
index 0000000000..b20fdf5bf5
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/pr30961.dpatch
@@ -0,0 +1,179 @@
1#! /bin/sh -e
2
3# DP: <your description>
4
5dir=
6if [ $# -eq 3 -a "$2" = '-d' ]; then
7 pdir="-d $3"
8 dir="$3/"
9elif [ $# -ne 1 ]; then
10 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
11 exit 1
12fi
13case "$1" in
14 -patch)
15 patch $pdir -f --no-backup-if-mismatch -p0 < $0
16 ;;
17 -unpatch)
18 patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
19 ;;
20 *)
21 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
22 exit 1
23esac
24exit 0
25
26From: "H.J. Lu" <hjl@lucon.org>
27Sender: gcc-patches-owner@gcc.gnu.org
28To: gcc-patches@gcc.gnu.org
29Subject: PATCH: PR target/30961: [4.1/4.2/4.3 regression] redundant reg/mem stores/moves
30Date: Mon, 27 Aug 2007 11:34:12 -0700
31
32We start with
33
34(note:HI 3 4 22 2 NOTE_INSN_FUNCTION_BEG)
35
36(insn:HI 6 3 10 2 c.c:3 (set (reg:DF 58 [ <result> ])
37 (subreg:DF (reg/v:DI 59 [ in ]) 0)) 102 {*movdf_integer_rex64} (expr_list:REG_DEAD (reg/v:DI 59 [ in ])
38 (nil)))
39
40(insn:HI 10 6 16 2 c.c:7 (set (reg/i:DF 21 xmm0 [ <result> ])
41 (reg:DF 58 [ <result> ])) 102 {*movdf_integer_rex64} (expr_list:REG_DEAD (reg:DF 58 [ <result> ])
42 (nil)))
43
44(insn:HI 16 10 0 2 c.c:7 (use (reg/i:DF 21 xmm0 [ <result> ])) -1 (nil))
45
46we are trying to allocate registers for insn 6 and we allocate
47xmm0 for the return value. Reload doesn't check if xmm0 can be used for
48DF 59, it allocates xmm1 for DF 59 and generates:
49
50Reloads for insn # 6
51Reload 0: reload_in (DF) = (reg:DF 5 di)
52 SSE_REGS, RELOAD_FOR_INPUT (opnum = 1), can't combine
53 reload_in_reg: (subreg:DF (reg/v:DI 5 di [orig:59 in ] [59]) 0)
54 reload_reg_rtx: (reg:DF 22 xmm1)
55...
56
57(note:HI 4 1 3 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
58
59(note:HI 3 4 22 2 NOTE_INSN_FUNCTION_BEG)
60
61(insn 22 3 23 2 c.c:3 (set (mem/c:DF (plus:DI (reg/f:DI 7 sp)
62 (const_int -8 [0xfffffffffffffff8])) [0 S8 A8])
63 (reg:DF 5 di)) 102 {*movdf_integer_rex64} (nil))
64
65(insn 23 22 6 2 c.c:3 (set (reg:DF 22 xmm1)
66 (mem/c:DF (plus:DI (reg/f:DI 7 sp)
67 (const_int -8 [0xfffffffffffffff8])) [0 S8 A8])) 102 {*movdf_integer_rex64} (nil))
68
69(insn:HI 6 23 16 2 c.c:3 (set (reg:DF 21 xmm0 [orig:58 <result> ] [58])
70 (reg:DF 22 xmm1)) 102 {*movdf_integer_rex64} (nil))
71
72(insn 16 6 21 2 c.c:7 (use (reg/i:DF 21 xmm0 [ <result> ])) -1 (nil))
73
74This patch tries to use the destination register when reloading for input. It
75generates
76
77Reloads for insn # 6
78Reload 0: reload_in (DF) = (reg:DF 5 di)
79 SSE_REGS, RELOAD_FOR_INPUT (opnum = 1), can't combine
80 reload_in_reg: (subreg:DF (reg/v:DI 5 di [orig:59 in ] [59]) 0)
81 reload_reg_rtx: (reg:DF 21 xmm0)
82...
83(note:HI 4 1 3 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
84
85(note:HI 3 4 22 2 NOTE_INSN_FUNCTION_BEG)
86
87(insn 22 3 23 2 c.c:3 (set (mem/c:DF (plus:DI (reg/f:DI 7 sp)
88 (const_int -8 [0xfffffffffffffff8])) [0 S8 A8])
89 (reg:DF 5 di)) 102 {*movdf_integer_rex64} (nil))
90
91(insn 23 22 6 2 c.c:3 (set (reg:DF 21 xmm0)
92 (mem/c:DF (plus:DI (reg/f:DI 7 sp)
93 (const_int -8 [0xfffffffffffffff8])) [0 S8 A8])) 102 {*movdf_integer_rex64} (nil))
94
95(insn:HI 6 23 10 2 c.c:3 (set (reg:DF 22 xmm1 [orig:58 <result> ] [58])
96 (reg:DF 21 xmm0)) 102 {*movdf_integer_rex64} (nil))
97
98(insn:HI 10 6 16 2 c.c:7 (set (reg/i:DF 21 xmm0 [ <result> ])
99 (reg:DF 22 xmm1 [orig:58 <result> ] [58])) 102 {*movdf_integer_rex64} (nil))
100
101(insn 16 10 21 2 c.c:7 (use (reg/i:DF 21 xmm0 [ <result> ])) -1 (nil))
102
103
104H.J.
105----
106gcc/
107
1082007-08-27 H.J. Lu <hongjiu.lu@intel.com>
109
110 PR target/30961
111 * reload1.c (find_reg): Favor the hard register in destination
112 if it is usable and a memory location is needed for reload
113 input.
114
115gcc/testsuite/
116
1172007-08-27 H.J. Lu <hongjiu.lu@intel.com>
118
119 PR target/30961
120 * gcc.target/i386/pr30961-1.c: New.
121
122--- gcc/reload1.c.second 2007-08-27 09:35:08.000000000 -0700
123+++ gcc/reload1.c 2007-08-27 09:36:33.000000000 -0700
124@@ -1781,6 +1781,20 @@ find_reg (struct insn_chain *chain, int
125 HARD_REG_SET not_usable;
126 HARD_REG_SET used_by_other_reload;
127 reg_set_iterator rsi;
128+#ifdef SECONDARY_MEMORY_NEEDED
129+ rtx body = PATTERN (chain->insn);
130+ unsigned int dest_reg = FIRST_PSEUDO_REGISTER;
131+
132+ if (GET_CODE (body) == SET)
133+ {
134+ rtx dest = SET_DEST (body);
135+
136+ if ((REG_P (dest)
137+ || (GET_CODE (dest) == SUBREG
138+ && REG_P (SUBREG_REG (dest)))))
139+ dest_reg = reg_or_subregno (dest);
140+ }
141+#endif
142
143 COPY_HARD_REG_SET (not_usable, bad_spill_regs);
144 IOR_HARD_REG_SET (not_usable, bad_spill_regs_global);
145@@ -1821,6 +1835,18 @@ find_reg (struct insn_chain *chain, int
146 this_cost--;
147 if (rl->out && REG_P (rl->out) && REGNO (rl->out) == regno)
148 this_cost--;
149+#ifdef SECONDARY_MEMORY_NEEDED
150+ /* If a memory location is needed for rl->in and dest_reg
151+ is usable, we will favor it. */
152+ else if (dest_reg == regno
153+ && rl->in
154+ && REG_P (rl->in)
155+ && REGNO (rl->in) < FIRST_PSEUDO_REGISTER
156+ && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (REGNO (rl->in)),
157+ rl->class,
158+ rl->mode))
159+ this_cost = 0;
160+#endif
161 if (this_cost < best_cost
162 /* Among registers with equal cost, prefer caller-saved ones, or
163 use REG_ALLOC_ORDER if it is defined. */
164--- gcc/testsuite/gcc.target/i386/pr30961-1.c.second 2007-08-27 11:01:59.000000000 -0700
165+++ gcc/testsuite/gcc.target/i386/pr30961-1.c 2007-08-27 11:02:51.000000000 -0700
166@@ -0,0 +1,13 @@
167+/* { dg-do compile } */
168+/* { dg-require-effective-target lp64 } */
169+/* { dg-options "-O2" } */
170+
171+double
172+convert (long long in)
173+{
174+ double f;
175+ __builtin_memcpy( &f, &in, sizeof( in ) );
176+ return f;
177+}
178+
179+/* { dg-final { scan-assembler-not "movapd" } } */
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/pr35942.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/pr35942.patch
new file mode 100644
index 0000000000..da610f5189
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/pr35942.patch
@@ -0,0 +1,38 @@
1Fix PR 35942: remove -lstdc++ from libtool postdeps for CXX.
2
3libstdc++-v3/ChangeLog:
42010-01-04 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
5
6 PR libstdc++/35942
7 * configure.ac: Remove -lstdc++ from libtool's postdeps_CXX.
8 * configure: Regenerate.
9
10
11Index: gcc-4.3.3/libstdc++-v3/configure
12===================================================================
13--- gcc-4.3.3.orig/libstdc++-v3/configure 2010-03-26 17:57:51.000000000 +0000
14+++ gcc-4.3.3/libstdc++-v3/configure 2010-03-26 17:57:58.000000000 +0000
15@@ -13759,6 +13759,9 @@
16
17
18
19+# Eliminate -lstdc++ addition to postdeps for cross compiles.
20+postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ ,,g'`
21+
22 # Possibly disable most of the library.
23 ## TODO: Consider skipping unncessary tests altogether in this case, rather
24 ## than just ignoring the results. Faster /and/ more correct, win win.
25Index: gcc-4.3.3/libstdc++-v3/configure.ac
26===================================================================
27--- gcc-4.3.3.orig/libstdc++-v3/configure.ac 2010-03-26 17:57:54.000000000 +0000
28+++ gcc-4.3.3/libstdc++-v3/configure.ac 2010-03-26 17:57:58.000000000 +0000
29@@ -89,6 +89,9 @@
30 AC_SUBST(enable_shared)
31 AC_SUBST(enable_static)
32
33+# Eliminate -lstdc++ addition to postdeps for cross compiles.
34+postdeps_CXX=`echo " $postdeps_CXX " | sed 's, -lstdc++ ,,g'`
35+
36 # Possibly disable most of the library.
37 ## TODO: Consider skipping unncessary tests altogether in this case, rather
38 ## than just ignoring the results. Faster /and/ more correct, win win.
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/zecke-no-host-includes.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/zecke-no-host-includes.patch
new file mode 100644
index 0000000000..4ccf35f627
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/zecke-no-host-includes.patch
@@ -0,0 +1,31 @@
1Index: gcc-4.4+svnr145550/gcc/incpath.c
2===================================================================
3--- gcc-4.4+svnr145550.orig/gcc/incpath.c 2009-04-04 13:48:31.000000000 -0700
4+++ gcc-4.4+svnr145550/gcc/incpath.c 2009-04-04 14:49:29.000000000 -0700
5@@ -417,6 +417,26 @@
6 p->construct = 0;
7 p->user_supplied_p = user_supplied_p;
8
9+#ifdef CROSS_COMPILE
10+ /* A common error when cross compiling is including
11+ host headers. This code below will try to fail fast
12+ for cross compiling. Currently we consider /usr/include,
13+ /opt/include and /sw/include as harmful. */
14+ {
15+ /* printf("Adding Path: %s\n", p->name ); */
16+ if( strstr(p->name, "/usr/include" ) == p->name ) {
17+ fprintf(stderr, _("CROSS COMPILE Badness: /usr/include in INCLUDEPATH: %s\n"), p->name);
18+ abort();
19+ } else if( strstr(p->name, "/sw/include") == p->name ) {
20+ fprintf(stderr, _("CROSS COMPILE Badness: /sw/include in INCLUDEPATH: %s\n"), p->name);
21+ abort();
22+ } else if( strstr(p->name, "/opt/include") == p->name ) {
23+ fprintf(stderr, _("CROSS COMPILE Badness: /opt/include in INCLUDEPATH: %s\n"), p->name);
24+ abort();
25+ }
26+ }
27+#endif
28+
29 add_cpp_dir_path (p, chain);
30 }
31
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/zecke-xgcc-cpp.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/zecke-xgcc-cpp.patch
new file mode 100644
index 0000000000..4b827d6397
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.5.0/zecke-xgcc-cpp.patch
@@ -0,0 +1,28 @@
1upstream: n/a
2comment: Use the preprocessor we have just compiled instead the one of
3the system. There might be incompabilities between us and them.
4
5Index: gcc-4.5.0/Makefile.in
6===================================================================
7--- gcc-4.5.0.orig/Makefile.in 2010-02-17 03:01:44.000000000 -0800
8+++ gcc-4.5.0/Makefile.in 2010-06-25 11:22:08.421381364 -0700
9@@ -266,6 +266,7 @@
10 AR="$(AR_FOR_TARGET)"; export AR; \
11 AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
12 CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
13+ CPP="$(CC_FOR_TARGET) -E"; export CPP; \
14 CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
15 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
16 CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
17Index: gcc-4.5.0/Makefile.tpl
18===================================================================
19--- gcc-4.5.0.orig/Makefile.tpl 2010-02-17 03:01:44.000000000 -0800
20+++ gcc-4.5.0/Makefile.tpl 2010-06-25 11:22:16.945631990 -0700
21@@ -269,6 +269,7 @@
22 AR="$(AR_FOR_TARGET)"; export AR; \
23 AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
24 CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
25+ CPP="$(CC_FOR_TARGET) -E"; export CPP; \
26 CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
27 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
28 CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \