diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 66461ef1e..e057f2e48 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,18 @@ +2002-06-27 Benjamin Kosnik + + * libc/include/stdio.h: Untangle, add _BEGIN_STD_C and _END_STD_C. + * 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/machine/setjmp.h: Same. + * libc/include/_ansi.h (_BEGIN_STD_C): Add. + (_END_STD_C): Add. + 2002-06-27 Jeff Johnston * libc/include/sys/_types.h: Define _ssize_t as int if int is diff --git a/newlib/libc/include/_ansi.h b/newlib/libc/include/_ansi.h index 8bebd1457..6c7beb3cd 100644 --- a/newlib/libc/include/_ansi.h +++ b/newlib/libc/include/_ansi.h @@ -74,4 +74,21 @@ #define _ATTRIBUTE(attrs) #endif +/* ISO C++. */ + +#ifdef __cplusplus +#if !(defined(_BEGIN_STD_C) && defined(_END_STD_C)) +#ifdef _HAVE_STD_CXX +#define _BEGIN_STD_C namespace std { extern "C" { +#define _END_STD_C } } +#else +#define _BEGIN_STD_C extern "C" { +#define _END_STD_C } +#endif +#endif +#else +#define _BEGIN_STD_C +#define _END_STD_C +#endif + #endif /* _ANSIDECL_H_ */ diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h index 194a52b19..a3581df1b 100644 --- a/newlib/libc/include/ctype.h +++ b/newlib/libc/include/ctype.h @@ -1,11 +1,10 @@ #ifndef _CTYPE_H_ -#ifdef __cplusplus -extern "C" { -#endif #define _CTYPE_H_ #include "_ansi.h" +_BEGIN_STD_C + int _EXFUN(isalnum, (int __c)); int _EXFUN(isalpha, (int __c)); int _EXFUN(iscntrl, (int __c)); @@ -66,7 +65,6 @@ extern __IMPORT _CONST char _ctype_[]; #define toascii(c) ((c)&0177) #endif -#ifdef __cplusplus -} -#endif +_END_STD_C + #endif /* _CTYPE_H_ */ diff --git a/newlib/libc/include/locale.h b/newlib/libc/include/locale.h index 4718248d8..ebe1422fe 100644 --- a/newlib/libc/include/locale.h +++ b/newlib/libc/include/locale.h @@ -5,9 +5,6 @@ */ #ifndef _LOCALE_H_ -#ifdef __cplusplus -extern "C" { -#endif #define _LOCALE_H_ #include "_ansi.h" @@ -24,6 +21,8 @@ extern "C" { #define LC_TIME 5 #define LC_MESSAGES 6 +_BEGIN_STD_C + struct lconv { char *decimal_point; @@ -55,7 +54,6 @@ struct _reent; char *_EXFUN(_setlocale_r,(struct _reent *, int category, const char *locale)); struct lconv *_EXFUN(_localeconv_r,(struct _reent *)); -#ifdef __cplusplus -} -#endif +_END_STD_C + #endif /* _LOCALE_H_ */ diff --git a/newlib/libc/include/machine/setjmp.h b/newlib/libc/include/machine/setjmp.h index dfdedc55e..42c982c91 100644 --- a/newlib/libc/include/machine/setjmp.h +++ b/newlib/libc/include/machine/setjmp.h @@ -1,3 +1,6 @@ + +_BEGIN_STD_C + #if defined(__arm__) || defined(__thumb__) /* * All callee preserved registers: @@ -176,9 +179,15 @@ typedef _JBTYPE jmp_buf[_JBLEN]; typedef int jmp_buf[_JBLEN]; #endif +_END_STD_C + #if defined(__CYGWIN__) || defined(__rtems__) #include +#ifdef __cplusplus +extern "C" { +#endif + /* POSIX sigsetjmp/siglongjmp macros */ typedef int sigjmp_buf[_JBLEN+2]; @@ -197,5 +206,8 @@ typedef int sigjmp_buf[_JBLEN+2]; sigprocmask (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\ longjmp (env, val)) +#ifdef __cplusplus +} +#endif #endif /* __CYGWIN__ or __rtems__ */ #endif diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index c0a743d0f..f1a30ad94 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -1,15 +1,14 @@ /* math.h -- Definitions for the math floating point package. */ #ifndef _MATH_H_ -#ifdef __cplusplus -extern "C" { -#endif #define _MATH_H_ #include #include #include "_ansi.h" +_BEGIN_STD_C + #ifndef HUGE_VAL /* Define HUGE_VAL as infinity, unless HUGE_VAL is already defined @@ -359,11 +358,10 @@ extern __IMPORT _CONST _LIB_VERSION_TYPE _LIB_VERSION; #endif /* ! defined (__STRICT_ANSI__) */ +_END_STD_C + #ifdef __FAST_MATH__ #include #endif -#ifdef __cplusplus -} -#endif #endif /* _MATH_H_ */ diff --git a/newlib/libc/include/setjmp.h b/newlib/libc/include/setjmp.h index 53d0223fd..c958d9042 100644 --- a/newlib/libc/include/setjmp.h +++ b/newlib/libc/include/setjmp.h @@ -4,19 +4,17 @@ */ #ifndef _SETJMP_H_ -#ifdef __cplusplus -extern "C" { -#endif #define _SETJMP_H_ #include "_ansi.h" #include +_BEGIN_STD_C + void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval)); int _EXFUN(setjmp,(jmp_buf __jmpb)); -#ifdef __cplusplus -} -#endif +_END_STD_C + #endif /* _SETJMP_H_ */ diff --git a/newlib/libc/include/signal.h b/newlib/libc/include/signal.h index 311149146..e1170a234 100644 --- a/newlib/libc/include/signal.h +++ b/newlib/libc/include/signal.h @@ -1,12 +1,11 @@ #ifndef _SIGNAL_H_ -#ifdef __cplusplus -extern "C" { -#endif #define _SIGNAL_H_ #include "_ansi.h" #include +_BEGIN_STD_C + typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ #if defined(__STDC__) || defined(__cplusplus) @@ -31,7 +30,6 @@ _sig_func_ptr _EXFUN(signal, (int, _sig_func_ptr)); int _EXFUN(raise, (int)); #endif -#ifdef __cplusplus -} -#endif +_END_STD_C + #endif /* _SIGNAL_H_ */ diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h index 51403a352..cbb53b977 100644 --- a/newlib/libc/include/stdio.h +++ b/newlib/libc/include/stdio.h @@ -24,9 +24,6 @@ */ #ifndef _STDIO_H_ -#ifdef __cplusplus -extern "C" { -#endif #define _STDIO_H_ #include "_ansi.h" @@ -48,6 +45,8 @@ extern "C" { #include #include +_BEGIN_STD_C + typedef _fpos_t fpos_t; typedef struct __sFILE FILE; @@ -385,7 +384,6 @@ static __inline int __sputc(int _c, FILE *_p) { #endif #endif -#ifdef __cplusplus -} -#endif +_END_STD_C + #endif /* _STDIO_H_ */ diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h index e2dab04d8..d7401ec57 100644 --- a/newlib/libc/include/stdlib.h +++ b/newlib/libc/include/stdlib.h @@ -5,9 +5,6 @@ */ #ifndef _STDLIB_H_ -#ifdef __cplusplus -extern "C" { -#endif #define _STDLIB_H_ #include "_ansi.h" @@ -22,6 +19,8 @@ extern "C" { #include #endif +_BEGIN_STD_C + typedef struct { int quot; /* quotient */ @@ -176,7 +175,6 @@ int _EXFUN(_system_r,(struct _reent *, const char *)); _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *)); -#ifdef __cplusplus -} -#endif +_END_STD_C + #endif /* _STDLIB_H_ */ diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h index 9db1767d6..84cb4b15b 100644 --- a/newlib/libc/include/string.h +++ b/newlib/libc/include/string.h @@ -7,10 +7,6 @@ #ifndef _STRING_H_ #define _STRING_H_ -#ifdef __cplusplus -extern "C" { -#endif - #include "_ansi.h" #include @@ -21,6 +17,8 @@ extern "C" { #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)); @@ -94,7 +92,6 @@ char *_EXFUN(strsignal, (int __signo)); #endif /* ! __STRICT_ANSI__ */ -#ifdef __cplusplus -} -#endif +_END_STD_C + #endif /* _STRING_H_ */ diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h index 9b164170c..1ff5b828d 100644 --- a/newlib/libc/include/time.h +++ b/newlib/libc/include/time.h @@ -10,10 +10,6 @@ #include "_ansi.h" #include -#ifdef __cplusplus -extern "C" { -#endif - #ifndef NULL #define NULL 0 #endif @@ -32,6 +28,8 @@ extern "C" { #include +_BEGIN_STD_C + struct tm { int tm_sec; @@ -62,6 +60,12 @@ char *_EXFUN(ctime_r, (const time_t *, char *)); struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *)); struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *)); +_END_STD_C + +#ifdef __cplusplus +extern "C" { +#endif + #ifndef __STRICT_ANSI__ char *_EXFUN(strptime, (const char *, const char *, struct tm *)); _VOID _EXFUN(tzset, (_VOID)); @@ -115,12 +119,20 @@ char *_EXFUN(timezone, (void)); #endif /* __CYGWIN__ */ #endif /* !__STRICT_ANSI__ */ +#ifdef __cplusplus +} +#endif + #include #if defined(_POSIX_TIMERS) #include +#ifdef __cplusplus +extern "C" { +#endif + /* Clocks, P1003.1b-1993, p. 263 */ int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp)); @@ -148,8 +160,15 @@ int _EXFUN(timer_getoverrun, (timer_t timerid)); int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp)); +#ifdef __cplusplus +} +#endif #endif /* _POSIX_TIMERS */ +#ifdef __cplusplus +extern "C" { +#endif + /* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */ /* values for the clock enable attribute */ @@ -217,5 +236,6 @@ int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr)); #ifdef __cplusplus } #endif + #endif /* _TIME_H_ */