This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

[v3] 1/3 libstdc++ cleanups for "C" compatibility work


Needed to get newlib-based crosses (powerpc-eabisim, xscale-elf) and
--enable-cheaders=c to build without modification. This is not a
completely conformant patch, as I'm hoping to avoid marking up the
newlib "C" headers with using declarations and instead use the
c_compatibility headers I posted a bit ago. 

That final bit of work is pending. This should probably go in anyway.

I suspect this will be all that is needed (for libstdc++-v3) for QNX
to work without modifications.

tested x86/linux
tested x86/linux x powerpc-eabisim --enable-cheaders=c

2002-06-18  Benjamin Kosnik  <bkoz@redhat.com>

	* include/c/std_cwchar.h: Guard. Add mbstate_t bits.
	* include/c/std_cwctype.h: Guard.

	* libsupc++/eh_alloc.cc: Tweak include order.
	* libsupc++/pure.cc: Use cstdio.
	* libsupc++/new_op.cc: Remove malloc forward declaration, as
	cstdlib brings it in. Use std::malloc.

	* src/Makefile.am (sources): Remove cmath.cc.
	* src/Makefile.in: Regenerate.
	* src/cmath.cc: Remove.

Index: include/c/std_cwchar.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c/std_cwchar.h,v
retrieving revision 1.3
diff -c -p -r1.3 std_cwchar.h
*** include/c/std_cwchar.h	27 Mar 2002 04:29:31 -0000	1.3
--- include/c/std_cwchar.h	18 Jun 2002 20:10:02 -0000
***************
*** 36,41 ****
--- 36,62 ----
  
  #pragma GCC system_header
  
+ #include <bits/c++config.h>
+ 
+ #if _GLIBCPP_HAVE_WCHAR_H
  #include_next <wchar.h>
+ #endif
+ 
+ // Need to do a bit of trickery here with mbstate_t as char_traits
+ // assumes it is in wchar.h, regardless of wchar_t specializations.
+ #ifndef _GLIBCPP_HAVE_MBSTATE_T
+ extern "C" 
+ {
+   typedef struct 
+   {
+     int __fill[6];
+   } mbstate_t;
+ }
+ #endif
+ 
+ namespace std 
+ {
+   using ::mbstate_t;
+ }
  
  #endif 
Index: include/c/std_cwctype.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c/std_cwctype.h,v
retrieving revision 1.3
diff -c -p -r1.3 std_cwctype.h
*** include/c/std_cwctype.h	27 Mar 2002 04:29:31 -0000	1.3
--- include/c/std_cwctype.h	18 Jun 2002 20:10:03 -0000
***************
*** 36,41 ****
--- 36,45 ----
  
  #pragma GCC system_header
  
+ #include <bits/c++config.h>
+ 
+ #if _GLIBCPP_HAVE_WCTYPE_H
  #include_next <wctype.h>
+ #endif
  
  #endif 
Index: libsupc++/eh_alloc.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/eh_alloc.cc,v
retrieving revision 1.6
diff -c -p -r1.6 eh_alloc.cc
*** libsupc++/eh_alloc.cc	2 Jul 2001 23:08:28 -0000	1.6
--- libsupc++/eh_alloc.cc	18 Jun 2002 20:10:05 -0000
***************
*** 30,39 ****
  // This is derived from the C++ ABI for IA-64.  Where we diverge
  // for cross-architecture compatibility are noted with "@@@".
  
- #include <exception>
  #include <cstdlib>
  #include <cstring>
  #include <climits>
  #include "unwind-cxx.h"
  #include "bits/c++config.h"
  #include "bits/gthr.h"
--- 30,39 ----
  // This is derived from the C++ ABI for IA-64.  Where we diverge
  // for cross-architecture compatibility are noted with "@@@".
  
  #include <cstdlib>
  #include <cstring>
  #include <climits>
+ #include <exception>
  #include "unwind-cxx.h"
  #include "bits/c++config.h"
  #include "bits/gthr.h"
Index: libsupc++/new_op.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/new_op.cc,v
retrieving revision 1.4
diff -c -p -r1.4 new_op.cc
*** libsupc++/new_op.cc	24 Oct 2001 02:37:55 -0000	1.4
--- libsupc++/new_op.cc	18 Jun 2002 20:10:05 -0000
***************
*** 1,5 ****
  // Support routines for the -*- C++ -*- dynamic memory management.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation
  //
  // This file is part of GNU CC.
  //
--- 1,5 ----
  // Support routines for the -*- C++ -*- dynamic memory management.
! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation
  //
  // This file is part of GNU CC.
  //
***************
*** 33,40 ****
  
  using std::new_handler;
  using std::bad_alloc;
  
- extern "C" void *malloc (std::size_t);
  extern new_handler __new_handler;
  
  void *
--- 33,40 ----
  
  using std::new_handler;
  using std::bad_alloc;
+ using std::malloc;
  
  extern new_handler __new_handler;
  
  void *
Index: libsupc++/pure.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/libsupc++/pure.cc,v
retrieving revision 1.8
diff -c -p -r1.8 pure.cc
*** libsupc++/pure.cc	28 Mar 2001 11:04:50 -0000	1.8
--- libsupc++/pure.cc	18 Jun 2002 20:10:05 -0000
***************
*** 39,46 ****
  /*#  define write(fd, buf, n)	__write((fd), (buf), (n))*/
  # endif
  #else
! # include <stdio.h>
! # define writestr(str)	fputs(str, stderr)
  #endif
  
  extern "C" void
--- 39,46 ----
  /*#  define write(fd, buf, n)	__write((fd), (buf), (n))*/
  # endif
  #else
! # include <cstdio>
! # define writestr(str)	std::fputs(str, stderr)
  #endif
  
  extern "C" void
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/Makefile.am,v
retrieving revision 1.108
diff -c -p -r1.108 Makefile.am
*** src/Makefile.am	6 Jun 2002 07:32:53 -0000	1.108
--- src/Makefile.am	18 Jun 2002 20:10:05 -0000
*************** sources = \
*** 64,70 ****
  	basic_file.cc \
  	bitset.cc \
  	c++locale.cc \
- 	cmath.cc \
  	codecvt.cc \
  	collate.cc \
  	complex_io.cc \
--- 64,69 ----


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