[v3] 3/3 newlib cleanups for "C" compatibility work
Benjamin Kosnik
bkoz@fillmore.constant.com
Tue Jun 18 13:19:00 GMT 2002
Also, this.
The _ansi.h file is a bit contrived, but mostly done. At the moment,
it's switchable between the namespace-enabled version and the
non-namespace-enabled version (ie, current sources.)
2002-06-17 Benjamin Kosnik <bkoz@redhat.com>
* libc/include/time.h: Same.
* libc/include/string.h: Same.
* libc/include/stdlib.h: Same.
* libc/include/signal.h: Same.
* libc/include/setjmp.h: Same.
* libc/include/math.h: Same.
* libc/include/locale.h: Same.
* libc/include/ctype.h: Same.
* libc/include/assert.h: Same.
* libc/include/stdio.h: Untangle, add _BEGIN_STD_C and _END_STD_C.
* libc/include/_ansi.h (_BEGIN_STD_C): Add.
(_END_STD_C): Add.
Index: libc/include/_ansi.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/_ansi.h,v
retrieving revision 1.2
diff -c -p -r1.2 _ansi.h
*** libc/include/_ansi.h 6 Sep 2000 20:46:27 -0000 1.2
--- libc/include/_ansi.h 18 Jun 2002 18:54:48 -0000
***************
*** 74,77 ****
--- 74,94 ----
#define _ATTRIBUTE(attrs)
#endif
+ /* ISO C++. */
+
+ #ifdef __cplusplus
+ #if !(defined(_BEGIN_STD_C) && defined(_END_STD_C))
+ #if 0
+ #define _BEGIN_STD_C extern "C" {
+ #define _END_STD_C }
+ #else
+ #define _BEGIN_STD_C namespace std { extern "C" {
+ #define _END_STD_C } }
+ #endif
+ #endif
+ #else
+ #define _BEGIN_STD_C
+ #define _END_STD_C
+ #endif
+
#endif /* _ANSIDECL_H_ */
Index: libc/include/assert.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/assert.h,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 assert.h
*** libc/include/assert.h 17 Feb 2000 19:39:46 -0000 1.1.1.1
--- libc/include/assert.h 18 Jun 2002 18:54:48 -0000
***************
*** 2,11 ****
assert.h
*/
- #ifdef __cplusplus
- extern "C" {
- #endif
-
#include "_ansi.h"
#undef assert
--- 2,7 ----
*************** extern "C" {
*** 22,29 ****
#endif /* NDEBUG */
void _EXFUN(__assert,(const char *, int, const char *));
! #ifdef __cplusplus
! }
! #endif
--- 18,25 ----
#endif /* NDEBUG */
+ _BEGIN_STD_C
+
void _EXFUN(__assert,(const char *, int, const char *));
! _END_STD_C
Index: libc/include/ctype.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/ctype.h,v
retrieving revision 1.5
diff -c -p -r1.5 ctype.h
*** libc/include/ctype.h 11 Jun 2001 21:51:41 -0000 1.5
--- libc/include/ctype.h 18 Jun 2002 18:54:48 -0000
***************
*** 1,11 ****
#ifndef _CTYPE_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
#define _CTYPE_H_
#include "_ansi.h"
int _EXFUN(isalnum, (int __c));
int _EXFUN(isalpha, (int __c));
int _EXFUN(iscntrl, (int __c));
--- 1,10 ----
#ifndef _CTYPE_H_
#define _CTYPE_H_
#include "_ansi.h"
+ _BEGIN_STD_C
+
int _EXFUN(isalnum, (int __c));
int _EXFUN(isalpha, (int __c));
int _EXFUN(iscntrl, (int __c));
*************** extern __IMPORT _CONST char _ctype_[];
*** 65,71 ****
#define toascii(c) ((c)&0177)
#endif
! #ifdef __cplusplus
! }
! #endif
#endif /* _CTYPE_H_ */
--- 64,69 ----
#define toascii(c) ((c)&0177)
#endif
! _END_STD_C
!
#endif /* _CTYPE_H_ */
Index: libc/include/errno.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/errno.h,v
retrieving revision 1.2
diff -c -p -r1.2 errno.h
*** libc/include/errno.h 14 Jun 2002 20:51:09 -0000 1.2
--- libc/include/errno.h 18 Jun 2002 18:54:48 -0000
***************
*** 1,3 ****
- typedef int error_t;
#include <sys/errno.h>
--- 1,9 ----
+ #include "_ansi.h"
#include <sys/errno.h>
+
+ _BEGIN_STD_C
+
+ typedef int error_t;
+
+ _END_STD_C
Index: libc/include/locale.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/locale.h,v
retrieving revision 1.2
diff -c -p -r1.2 locale.h
*** libc/include/locale.h 5 Feb 2001 21:51:43 -0000 1.2
--- libc/include/locale.h 18 Jun 2002 18:54:48 -0000
***************
*** 5,13 ****
*/
#ifndef _LOCALE_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
#define _LOCALE_H_
#include "_ansi.h"
--- 5,10 ----
*************** extern "C" {
*** 24,29 ****
--- 21,28 ----
#define LC_TIME 5
#define LC_MESSAGES 6
+ _BEGIN_STD_C
+
struct lconv
{
char *decimal_point;
*************** struct _reent;
*** 55,61 ****
char *_EXFUN(_setlocale_r,(struct _reent *, int category, const char *locale));
struct lconv *_EXFUN(_localeconv_r,(struct _reent *));
! #ifdef __cplusplus
! }
! #endif
#endif /* _LOCALE_H_ */
--- 54,59 ----
char *_EXFUN(_setlocale_r,(struct _reent *, int category, const char *locale));
struct lconv *_EXFUN(_localeconv_r,(struct _reent *));
! _END_STD_C
!
#endif /* _LOCALE_H_ */
Index: libc/include/math.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/math.h,v
retrieving revision 1.10
diff -c -p -r1.10 math.h
*** libc/include/math.h 7 Jun 2002 21:59:36 -0000 1.10
--- libc/include/math.h 18 Jun 2002 18:54:49 -0000
***************
*** 1,15 ****
/* math.h -- Definitions for the math floating point package. */
#ifndef _MATH_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
#define _MATH_H_
#include <sys/reent.h>
#include <machine/ieeefp.h>
#include "_ansi.h"
#ifndef HUGE_VAL
/* Define HUGE_VAL as infinity, unless HUGE_VAL is already defined
--- 1,14 ----
/* math.h -- Definitions for the math floating point package. */
#ifndef _MATH_H_
#define _MATH_H_
#include <sys/reent.h>
#include <machine/ieeefp.h>
#include "_ansi.h"
+ _BEGIN_STD_C
+
#ifndef HUGE_VAL
/* Define HUGE_VAL as infinity, unless HUGE_VAL is already defined
*************** extern __IMPORT _CONST _LIB_VERSION_TYPE
*** 359,369 ****
#endif /* ! defined (__STRICT_ANSI__) */
#ifdef __FAST_MATH__
#include <machine/fastmath.h>
#endif
- #ifdef __cplusplus
- }
- #endif
#endif /* _MATH_H_ */
--- 358,367 ----
#endif /* ! defined (__STRICT_ANSI__) */
+ _END_STD_C
+
#ifdef __FAST_MATH__
#include <machine/fastmath.h>
#endif
#endif /* _MATH_H_ */
Index: libc/include/setjmp.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/setjmp.h,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 setjmp.h
*** libc/include/setjmp.h 17 Feb 2000 19:39:46 -0000 1.1.1.1
--- libc/include/setjmp.h 18 Jun 2002 18:54:49 -0000
***************
*** 4,22 ****
*/
#ifndef _SETJMP_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
#define _SETJMP_H_
#include "_ansi.h"
#include <machine/setjmp.h>
void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval));
int _EXFUN(setjmp,(jmp_buf __jmpb));
! #ifdef __cplusplus
! }
! #endif
#endif /* _SETJMP_H_ */
--- 4,20 ----
*/
#ifndef _SETJMP_H_
#define _SETJMP_H_
#include "_ansi.h"
#include <machine/setjmp.h>
+ _BEGIN_STD_C
+
void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval));
int _EXFUN(setjmp,(jmp_buf __jmpb));
! _END_STD_C
!
#endif /* _SETJMP_H_ */
Index: libc/include/signal.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/signal.h,v
retrieving revision 1.1.1.1
diff -c -p -r1.1.1.1 signal.h
*** libc/include/signal.h 17 Feb 2000 19:39:46 -0000 1.1.1.1
--- libc/include/signal.h 18 Jun 2002 18:54:49 -0000
***************
*** 1,12 ****
#ifndef _SIGNAL_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
#define _SIGNAL_H_
#include "_ansi.h"
#include <sys/signal.h>
typedef int sig_atomic_t; /* Atomic entity type (ANSI) */
#if defined(__STDC__) || defined(__cplusplus)
--- 1,11 ----
#ifndef _SIGNAL_H_
#define _SIGNAL_H_
#include "_ansi.h"
#include <sys/signal.h>
+ _BEGIN_STD_C
+
typedef int sig_atomic_t; /* Atomic entity type (ANSI) */
#if defined(__STDC__) || defined(__cplusplus)
*************** _sig_func_ptr _EXFUN(signal, (int, _sig_
*** 31,37 ****
int _EXFUN(raise, (int));
#endif
! #ifdef __cplusplus
! }
! #endif
#endif /* _SIGNAL_H_ */
--- 30,35 ----
int _EXFUN(raise, (int));
#endif
! _END_STD_C
!
#endif /* _SIGNAL_H_ */
Index: libc/include/stdio.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdio.h,v
retrieving revision 1.12
diff -c -p -r1.12 stdio.h
*** libc/include/stdio.h 17 May 2002 23:39:37 -0000 1.12
--- libc/include/stdio.h 18 Jun 2002 18:54:50 -0000
***************
*** 24,32 ****
*/
#ifndef _STDIO_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
#define _STDIO_H_
#include "_ansi.h"
--- 24,29 ----
*************** extern "C" {
*** 49,54 ****
--- 46,53 ----
#include <sys/stdio.h>
+ _BEGIN_STD_C
+
typedef _fpos_t fpos_t;
typedef struct __sFILE FILE;
*************** static __inline int __sputc(int _c, FILE
*** 382,388 ****
#endif
#endif
! #ifdef __cplusplus
! }
! #endif
#endif /* _STDIO_H_ */
--- 381,386 ----
#endif
#endif
! _END_STD_C
!
#endif /* _STDIO_H_ */
Index: libc/include/stdlib.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdlib.h,v
retrieving revision 1.16
diff -c -p -r1.16 stdlib.h
*** libc/include/stdlib.h 13 Jun 2002 23:24:03 -0000 1.16
--- libc/include/stdlib.h 18 Jun 2002 18:54:51 -0000
***************
*** 5,13 ****
*/
#ifndef _STDLIB_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
#define _STDLIB_H_
#include "_ansi.h"
--- 5,10 ----
*************** extern "C" {
*** 22,27 ****
--- 19,26 ----
#include <alloca.h>
#endif
+ _BEGIN_STD_C
+
typedef struct
{
int quot; /* quotient */
*************** int _EXFUN(_system_r,(struct _reent *, c
*** 176,182 ****
_VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *));
! #ifdef __cplusplus
! }
! #endif
#endif /* _STDLIB_H_ */
--- 175,180 ----
_VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *));
! _END_STD_C
!
#endif /* _STDLIB_H_ */
Index: libc/include/string.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/string.h,v
retrieving revision 1.12
diff -c -p -r1.12 string.h
*** libc/include/string.h 5 Jun 2002 20:58:54 -0000 1.12
--- libc/include/string.h 18 Jun 2002 18:54:51 -0000
***************
*** 7,16 ****
#ifndef _STRING_H_
#define _STRING_H_
- #ifdef __cplusplus
- extern "C" {
- #endif
-
#include "_ansi.h"
#include <sys/reent.h>
--- 7,12 ----
*************** extern "C" {
*** 21,26 ****
--- 17,24 ----
#define NULL 0
#endif
+ _BEGIN_STD_C
+
_PTR _EXFUN(memchr,(const _PTR, int, size_t));
int _EXFUN(memcmp,(const _PTR, const _PTR, size_t));
_PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t));
*************** char *_EXFUN(strsignal, (int __signo));
*** 94,100 ****
#endif /* ! __STRICT_ANSI__ */
! #ifdef __cplusplus
! }
! #endif
#endif /* _STRING_H_ */
--- 92,97 ----
#endif /* ! __STRICT_ANSI__ */
! _END_STD_C
!
#endif /* _STRING_H_ */
Index: libc/include/time.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/time.h,v
retrieving revision 1.8
diff -c -p -r1.8 time.h
*** libc/include/time.h 17 Apr 2002 21:23:29 -0000 1.8
--- libc/include/time.h 18 Jun 2002 18:54:51 -0000
***************
*** 10,19 ****
#include "_ansi.h"
#include <sys/reent.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
-
#ifndef NULL
#define NULL 0
#endif
--- 10,15 ----
*************** extern "C" {
*** 32,37 ****
--- 28,35 ----
#include <sys/types.h>
+ _BEGIN_STD_C
+
struct tm
{
int tm_sec;
*************** char *_EXFUN(timezone, (void));
*** 92,103 ****
--- 90,105 ----
#endif /* __CYGWIN__ */
#endif /* !__STRICT_ANSI__ */
+ _END_STD_C
+
#include <sys/features.h>
#if defined(_POSIX_TIMERS)
#include <signal.h>
+ _BEGIN_STD_C
+
/* Clocks, P1003.1b-1993, p. 263 */
int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp));
*************** int _EXFUN(timer_getoverrun, (timer_t ti
*** 125,132 ****
--- 127,138 ----
int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp));
+ _END_STD_C
+
#endif /* _POSIX_TIMERS */
+ _BEGIN_STD_C
+
/* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
/* values for the clock enable attribute */
*************** int _EXFUN(clock_getenable_attr, (clocki
*** 191,198 ****
#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
! #ifdef __cplusplus
! }
! #endif
#endif /* _TIME_H_ */
--- 197,203 ----
#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
! _END_STD_C
!
#endif /* _TIME_H_ */
More information about the Libstdc++
mailing list