[v3] Abstract target specific ABI tweaks
Paul Brook
paul@codesourcery.com
Fri Jul 2 17:14:00 GMT 2004
It was pointed out to me that I've added arm-specific defines into generic
bits of libstdc++, and this is probably a bad thing.
The patch below creates cpu/cxxabi_tweaks.h, and confines target specific
conditionals to there. Some changes to the common code are still necessary
but these now relate to the ABI change rather than a particular target.
Any further comments/suggestions on how to handle these ABI differences are
more than welcome.
Paul
P.S. I'll update my cxa_vec_ctor patch accordingly once this patch has been
resolved.
2004-07-02 Paul Brook <paul@codesourcery.com>
* configure.ac: Set ABI_TWEAKS_SRCDIR.
* configure.host: Set abi_tweaks_dir. Check for atomicity.h when
setting atomicity_dir. Override type_cpu for arm based targets.
* include/Makefile.am (host_headers): Add cxxabi_tweaks.h.
* libsupc++/cxxabi.h: Include bits/cxxabi.h. Don't declare __guard.
* libsupc++/guard.cc: Use definitions from cxxabi_tweaks.h.
* libsupc++/vec.cc: Ditto.
* config/cpu/arm/cxxabi_tweaks.h: New file.
* config/cpu/generic/cxxabi_tweaks.h: New file.
* */Makefile.in: Regenerate.
* configure: Regenerate.
Index: configure.ac
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/configure.ac,v
retrieving revision 1.20
diff -u -p -r1.20 configure.ac
--- configure.ac 15 Jun 2004 14:47:47 -0000 1.20
+++ configure.ac 2 Jul 2004 13:37:10 -0000
@@ -272,8 +272,10 @@ GLIBCXX_CONFIGURE_TESTSUITE
ATOMICITY_SRCDIR=config/${atomicity_dir}
ATOMIC_WORD_SRCDIR=config/${atomic_word_dir}
OS_INC_SRCDIR=config/${os_include_dir}
+ABI_TWEAKS_SRCDIR=config/${abi_tweaks_dir}
AC_SUBST(ATOMICITY_SRCDIR)
AC_SUBST(ATOMIC_WORD_SRCDIR)
+AC_SUBST(ABI_TWEAKS_SRCDIR)
AC_SUBST(OS_INC_SRCDIR)
# Determine cross-compile flags and AM_CONDITIONALs.
Index: configure.host
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/configure.host,v
retrieving revision 1.25
diff -u -p -r1.25 configure.host
--- configure.host 27 Feb 2004 20:56:43 -0000 1.25
+++ configure.host 2 Jul 2004 13:40:34 -0000
@@ -97,8 +97,11 @@ case "${host_cpu}" in
sparc* | ultrasparc)
try_cpu=sparc
;;
+ arm* | xscale | ep9312)
+ try_cpu=arm
+ ;;
*)
- if test -f ${glibcxx_srcdir}/config/cpu/${host_cpu}/atomicity.h; then
+ if test -d ${glibcxx_srcdir}/config/cpu/${host_cpu}; then
try_cpu=${host_cpu}
else
try_cpu=generic
@@ -121,9 +124,19 @@ esac
# default choices for those if they haven't been explicitly set
# already.
cpu_include_dir="cpu/${try_cpu}"
-atomicity_dir=$cpu_include_dir
abi_baseline_pair=${try_cpu}-${host_os}
+if test -f ${glibcxx_srcdir}/config/${cpu_include_dir}/atomicity.h ; then
+ atomicity_dir=$cpu_include_dir
+else
+ atomicity_dir="cpu/generic"
+fi
+
+if test -f ${glibcxx_srcdir}/config/${cpu_include_dir}/cxxabi_tweaks.h ; then
+ abi_tweaks_dir=$cpu_include_dir
+else
+ abi_tweaks_dir="cpu/generic"
+fi
# Set any OS-dependent bits.
# Set the os_include_dir.
Index: config/cpu/arm/cxxabi_tweaks.h
===================================================================
RCS file: config/cpu/arm/cxxabi_tweaks.h
diff -N config/cpu/arm/cxxabi_tweaks.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config/cpu/arm/cxxabi_tweaks.h 2 Jul 2004 13:20:37 -0000
@@ -0,0 +1,59 @@
+// Control various target specific ABI tweaks. ARM version.
+
+// Copyright (C) 2004 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#ifndef _CXXABI_TWEAKS_H
+#define _CXXABI_TWEAKS_H 1
+
+#ifdef __cplusplus
+namespace __cxxabiv1
+{
+#endif
+
+#ifdef __ARM_EABI__
+ // The ARM EABI uses the least significan bit of a 32-bit
+ // guard variable. */
+#define _GLIBCXX_GUARD_ACQUIRE(x) (!(*(x) & 1))
+#define _GLIBCXX_GUARD_RELEASE(x) *(x) = 1
+ typedef int __guard;
+
+ // We also want the element size in array cookies.
+#define _GLIBCXX_ELTSIZE_IN_COOKIE 1
+
+#else
+ // The generic ABI uses the first byte of a 64-bit guard variable.
+#define _GLIBCXX_GUARD_ACQUIRE(x) (!*(char *) (x))
+#define _GLIBCXX_GUARD_RELEASE(x) *(char *) (x) = 1
+ __extension__ typedef int __guard __attribute__((mode (__DI__)));
+#endif
+
+#ifdef __cplusplus
+} // namespace __cxxabiv1
+#endif
+
+#endif // __cxxabiv1
Index: config/cpu/generic/cxxabi_tweaks.h
===================================================================
RCS file: config/cpu/generic/cxxabi_tweaks.h
diff -N config/cpu/generic/cxxabi_tweaks.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ config/cpu/generic/cxxabi_tweaks.h 2 Jul 2004 13:14:51 -0000
@@ -0,0 +1,47 @@
+// Control various target specific ABI tweaks. Generic version.
+
+// Copyright (C) 2004 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#ifndef _CXXABI_TWEAKS_H
+#define _CXXABI_TWEAKS_H 1
+
+#ifdef __cplusplus
+namespace __cxxabiv1
+{
+#endif
+
+ // The generic ABI uses the first byte of a 64-bit guard variable.
+#define _GLIBCXX_GUARD_ACQUIRE(x) (!*(char *) (x))
+#define _GLIBCXX_GUARD_RELEASE(x) *(char *) (x) = 1
+ __extension__ typedef int __guard __attribute__((mode (__DI__)));
+
+#ifdef __cplusplus
+} // namespace __cxxabiv1
+#endif
+
+#endif // __cxxabiv1
Index: include/Makefile.am
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/include/Makefile.am,v
retrieving revision 1.81
diff -u -p -r1.81 Makefile.am
--- include/Makefile.am 28 Jun 2004 11:14:44 -0000 1.81
+++ include/Makefile.am 2 Jul 2004 13:54:03 -0000
@@ -340,7 +340,8 @@ host_headers = \
${host_srcdir}/ctype_inline.h \
${host_srcdir}/ctype_noninline.h \
${host_srcdir}/os_defines.h \
- ${glibcxx_srcdir}/$(ATOMIC_WORD_SRCDIR)/atomic_word.h
+ ${glibcxx_srcdir}/$(ATOMIC_WORD_SRCDIR)/atomic_word.h \
+ ${glibcxx_srcdir}/$(ABI_TWEAKS_SRCDIR)/cxxabi_tweaks.h
# Non-installed host_header files.
host_headers_noinst = \
Index: libsupc++/cxxabi.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/libsupc++/cxxabi.h,v
retrieving revision 1.17
diff -u -p -r1.17 cxxabi.h
--- libsupc++/cxxabi.h 25 Jun 2004 17:15:46 -0000 1.17
+++ libsupc++/cxxabi.h 2 Jul 2004 14:23:33 -0000
@@ -43,6 +43,7 @@
#define _CXXABI_H 1
#include <stddef.h>
+#include <bits/cxxabi_tweaks.h>
#ifdef __cplusplus
namespace __cxxabiv1
@@ -104,14 +105,6 @@ namespace __cxxabiv1
size_t __padding_size, void (*__destructor) (void*),
void (*__dealloc) (void*, size_t));
-#ifdef __ARM_EABI__
- // The ARM EABI says this is a 32-bit type.
- typedef int __guard;
-#else
- // The ABI requires a 64-bit type.
- __extension__ typedef int __guard __attribute__((mode (__DI__)));
-#endif
-
int
__cxa_guard_acquire(__guard*);
Index: libsupc++/guard.cc
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/libsupc++/guard.cc,v
retrieving revision 1.2
diff -u -p -r1.2 guard.cc
--- libsupc++/guard.cc 25 Jun 2004 17:15:46 -0000 1.2
+++ libsupc++/guard.cc 2 Jul 2004 13:13:47 -0000
@@ -38,21 +38,13 @@ namespace __cxxabiv1
extern "C"
int __cxa_guard_acquire (__guard *g)
{
-#ifdef __ARM_EABI__
- return !(*g & 1);
-#else
- return !*(char *)(g);
-#endif
+ return _GLIBCXX_GUARD_ACQUIRE (g);
}
extern "C"
void __cxa_guard_release (__guard *g)
{
-#ifdef __ARM_EABI__
- *g = 1;
-#else
- *(char *)g = 1;
-#endif
+ _GLIBCXX_GUARD_RELEASE (g);
}
extern "C"
Index: libsupc++/vec.cc
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/libstdc++-v3/libsupc++/vec.cc,v
retrieving revision 1.15
diff -u -p -r1.15 vec.cc
--- libsupc++/vec.cc 29 Jun 2004 14:50:35 -0000 1.15
+++ libsupc++/vec.cc 2 Jul 2004 13:17:20 -0000
@@ -96,8 +96,7 @@ namespace __cxxabiv1
{
base += padding_size;
reinterpret_cast <std::size_t *> (base)[-1] = element_count;
-#ifdef __ARM_EABI__
- // ARM EABI array cookies also contain the element size.
+#ifdef _GLIBCXX_ELTSIZE_IN_COOKIE
reinterpret_cast <std::size_t *> (base)[-2] = element_size;
#endif
}
@@ -135,8 +134,7 @@ namespace __cxxabiv1
{
base += padding_size;
reinterpret_cast<std::size_t *>(base)[-1] = element_count;
-#ifdef __ARM_EABI__
- // ARM EABI array cookies also contain the element size.
+#ifdef _GLIBCXX_ELTSIZE_IN_COOKIE
reinterpret_cast <std::size_t *> (base)[-2] = element_size;
#endif
}
More information about the Libstdc++
mailing list