From 6a54276d55c217f980591001e558e1f53e4f720a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 25 Mar 2013 14:38:58 +0100 Subject: [PATCH] software/include/base: C++ compatibility --- software/include/base/board.h | 8 ++++++++ software/include/base/console.h | 8 ++++++++ software/include/base/crc.h | 8 ++++++++ software/include/base/ctype.h | 8 ++++++++ software/include/base/endian.h | 8 ++++++++ software/include/base/errno.h | 8 ++++++++ software/include/base/float.h | 8 ++++++++ software/include/base/irq.h | 8 ++++++++ software/include/base/limits.h | 8 ++++++++ software/include/base/setjmp.h | 9 ++++++++- software/include/base/stdarg.h | 8 ++++++++ software/include/base/stddef.h | 8 ++++++++ software/include/base/stdint.h | 8 ++++++++ software/include/base/stdio.h | 7 +++++++ software/include/base/stdlib.h | 8 ++++++++ software/include/base/string.h | 8 ++++++++ software/include/base/system.h | 10 ++++++++-- software/include/base/timer.h | 8 ++++++++ software/include/base/uart.h | 8 ++++++++ 19 files changed, 151 insertions(+), 3 deletions(-) diff --git a/software/include/base/board.h b/software/include/base/board.h index ef873160..5c5f54c2 100644 --- a/software/include/base/board.h +++ b/software/include/base/board.h @@ -1,6 +1,10 @@ #ifndef __BOARD_H #define __BOARD_H +#ifdef __cplusplus +extern "C" { +#endif + #define BOARD_NAME_LEN 32 struct board_desc { @@ -16,4 +20,8 @@ void get_soc_version_formatted(char *version); extern const struct board_desc *brd_desc; void board_init(void); +#ifdef __cplusplus +} +#endif + #endif /* __BOARD_H */ diff --git a/software/include/base/console.h b/software/include/base/console.h index 182a80a3..a1cf5992 100644 --- a/software/include/base/console.h +++ b/software/include/base/console.h @@ -1,6 +1,10 @@ #ifndef __CONSOLE_H #define __CONSOLE_H +#ifdef __cplusplus +extern "C" { +#endif + typedef void (*console_write_hook)(char); typedef char (*console_read_hook)(void); typedef int (*console_read_nonblock_hook)(void); @@ -13,4 +17,8 @@ int readchar_nonblock(void); void putsnonl(const char *s); +#ifdef __cplusplus +} +#endif + #endif /* __CONSOLE_H */ diff --git a/software/include/base/crc.h b/software/include/base/crc.h index 61cc036b..88c8d953 100644 --- a/software/include/base/crc.h +++ b/software/include/base/crc.h @@ -1,7 +1,15 @@ #ifndef __CRC_H #define __CRC_H +#ifdef __cplusplus +extern "C" { +#endif + unsigned short crc16(const unsigned char *buffer, int len); unsigned int crc32(const unsigned char *buffer, unsigned int len); +#ifdef __cplusplus +} +#endif + #endif diff --git a/software/include/base/ctype.h b/software/include/base/ctype.h index a996b288..69368593 100644 --- a/software/include/base/ctype.h +++ b/software/include/base/ctype.h @@ -1,6 +1,10 @@ #ifndef __CTYPE_H #define __CTYPE_H +#ifdef __cplusplus +extern "C" { +#endif + /* * NOTE! This ctype does not handle EOF like the standard C * library is required to. @@ -52,4 +56,8 @@ static inline unsigned char __toupper(unsigned char c) #define tolower(c) __tolower(c) #define toupper(c) __toupper(c) +#ifdef __cplusplus +} +#endif + #endif /* __CTYPE_H */ diff --git a/software/include/base/endian.h b/software/include/base/endian.h index 03a0d449..81cf2153 100644 --- a/software/include/base/endian.h +++ b/software/include/base/endian.h @@ -1,6 +1,10 @@ #ifndef __ENDIAN_H #define __ENDIAN_H +#ifdef __cplusplus +extern "C" { +#endif + #define __LITTLE_ENDIAN 0 #define __BIG_ENDIAN 1 #define __BYTE_ORDER __BIG_ENDIAN @@ -19,4 +23,8 @@ static inline unsigned short le16toh(unsigned short val) (val & 0xff00) >> 8; } +#ifdef __cplusplus +} +#endif + #endif /* __ENDIAN_H */ diff --git a/software/include/base/errno.h b/software/include/base/errno.h index 8c202a2f..be05873a 100644 --- a/software/include/base/errno.h +++ b/software/include/base/errno.h @@ -1,6 +1,10 @@ #ifndef __ERRNO_H #define __ERRNO_H +#ifdef __cplusplus +extern "C" { +#endif + extern int errno; #define EPERM 1 @@ -250,4 +254,8 @@ extern int errno; #define EMEDIUMTYPE 124 #define EMEDIUMTYPE_STR "Wrong medium type" +#ifdef __cplusplus +} +#endif + #endif /* __ERRNO_H */ diff --git a/software/include/base/float.h b/software/include/base/float.h index bb462d5a..2d0bf676 100644 --- a/software/include/base/float.h +++ b/software/include/base/float.h @@ -1,6 +1,10 @@ #ifndef __FLOAT_H #define __FLOAT_H +#ifdef __cplusplus +extern "C" { +#endif + #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ #define FLT_ROUNDS (__builtin_flt_rounds()) #define FLT_RADIX __FLT_RADIX__ @@ -47,4 +51,8 @@ #define DBL_TRUE_MIN __DBL_DENORM_MIN__ #define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ +#ifdef __cplusplus +} +#endif + #endif /* __FLOAT_H */ diff --git a/software/include/base/irq.h b/software/include/base/irq.h index e2599614..504f2972 100644 --- a/software/include/base/irq.h +++ b/software/include/base/irq.h @@ -1,6 +1,10 @@ #ifndef __IRQ_H #define __IRQ_H +#ifdef __cplusplus +extern "C" { +#endif + static inline unsigned int irq_getie(void) { unsigned int ie; @@ -32,4 +36,8 @@ static inline unsigned int irq_pending(void) return pending; } +#ifdef __cplusplus +} +#endif + #endif /* __IRQ_H */ diff --git a/software/include/base/limits.h b/software/include/base/limits.h index 95234d25..49ac6ffe 100644 --- a/software/include/base/limits.h +++ b/software/include/base/limits.h @@ -1,6 +1,10 @@ #ifndef __LIMITS_H #define __LIMITS_H +#ifdef __cplusplus +extern "C" { +#endif + #define ULONG_MAX 0xffffffff #define UINT_MAX 0xffffffff @@ -15,4 +19,8 @@ #define CHAR_BIT 8 +#ifdef __cplusplus +} +#endif + #endif /* __LIMITS_H */ diff --git a/software/include/base/setjmp.h b/software/include/base/setjmp.h index c4246c14..a63e846b 100644 --- a/software/include/base/setjmp.h +++ b/software/include/base/setjmp.h @@ -1,6 +1,10 @@ #ifndef __SETJMP_H #define __SETJMP_H +#ifdef __cplusplus +extern "C" { +#endif + #define _JBLEN 19 typedef int jmp_buf[_JBLEN]; @@ -8,5 +12,8 @@ typedef int jmp_buf[_JBLEN]; int setjmp(jmp_buf env); void longjmp(jmp_buf env, int val); -#endif /* __SETJMP_H */ +#ifdef __cplusplus +} +#endif +#endif /* __SETJMP_H */ diff --git a/software/include/base/stdarg.h b/software/include/base/stdarg.h index 1d15836a..6df50930 100644 --- a/software/include/base/stdarg.h +++ b/software/include/base/stdarg.h @@ -3,6 +3,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #define va_start(v, l) __builtin_va_start((v), l) #define va_arg(ap, type) __builtin_va_arg((ap), type) #define va_copy(aq, ap) __builtin_va_copy((aq), (ap)) @@ -13,4 +17,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); int vsprintf(char *buf, const char *fmt, va_list args); +#ifdef __cplusplus +} +#endif + #endif /* __STDARG_H */ diff --git a/software/include/base/stddef.h b/software/include/base/stddef.h index 6f00c4fa..d1afa95e 100644 --- a/software/include/base/stddef.h +++ b/software/include/base/stddef.h @@ -1,6 +1,10 @@ #ifndef __STDDEF_H #define __STDDEF_H +#ifdef __cplusplus +extern "C" { +#endif + #ifdef __cplusplus #define NULL 0 #else @@ -12,4 +16,8 @@ typedef long ptrdiff_t; #define offsetof(s,m) (size_t)&(((s *)0)->m) +#ifdef __cplusplus +} +#endif + #endif /* __STDDEF_H */ diff --git a/software/include/base/stdint.h b/software/include/base/stdint.h index 89f8af38..fadee90e 100644 --- a/software/include/base/stdint.h +++ b/software/include/base/stdint.h @@ -1,6 +1,10 @@ #ifndef __STDINT_H #define __STDINT_H +#ifdef __cplusplus +extern "C" { +#endif + typedef unsigned int uintptr_t; typedef unsigned long long uint64_t; @@ -22,4 +26,8 @@ typedef char int8_t; #define INT32_C(v) v #define UINT32_C(v) v##U +#ifdef __cplusplus +} +#endif + #endif /* __STDINT_H */ diff --git a/software/include/base/stdio.h b/software/include/base/stdio.h index 91f59d7a..5e872d64 100644 --- a/software/include/base/stdio.h +++ b/software/include/base/stdio.h @@ -3,6 +3,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + int putchar(int c); int puts(const char *s); @@ -66,5 +70,8 @@ int fclose(FILE *fp); int fseek(FILE *stream, long offset, int whence); long ftell(FILE *stream); +#ifdef __cplusplus +} +#endif #endif /* __STDIO_H */ diff --git a/software/include/base/stdlib.h b/software/include/base/stdlib.h index 94cde303..64ddabfd 100644 --- a/software/include/base/stdlib.h +++ b/software/include/base/stdlib.h @@ -21,6 +21,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + #define PRINTF_ZEROPAD 1 /* pad with zero */ #define PRINTF_SIGN 2 /* unsigned/signed long */ #define PRINTF_PLUS 4 /* show plus */ @@ -72,4 +76,8 @@ void *malloc(size_t size); void free(void *ptr); void *realloc(void *ptr, size_t size); +#ifdef __cplusplus +} +#endif + #endif /* __STDLIB_H */ diff --git a/software/include/base/string.h b/software/include/base/string.h index f997a007..9a4c22fe 100644 --- a/software/include/base/string.h +++ b/software/include/base/string.h @@ -21,6 +21,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + char *strchr(const char *s, int c); char *strpbrk(const char *,const char *); char *strrchr(const char *s, int c); @@ -43,4 +47,8 @@ void *memchr(const void *s, int c, size_t n); char *strerror(int errnum); +#ifdef __cplusplus +} +#endif + #endif /* __STRING_H */ diff --git a/software/include/base/system.h b/software/include/base/system.h index fbdd78c2..7ec2cded 100644 --- a/software/include/base/system.h +++ b/software/include/base/system.h @@ -1,9 +1,15 @@ #ifndef __SYSTEM_H #define __SYSTEM_H +#ifdef __cplusplus +extern "C" { +#endif + void flush_cpu_icache(void); void flush_cpu_dcache(void); -__attribute__((noreturn)) void reboot(void); -__attribute__((noreturn)) void reconf(void); + +#ifdef __cplusplus +} +#endif #endif /* __SYSTEM_H */ diff --git a/software/include/base/timer.h b/software/include/base/timer.h index 91546255..e33e26f5 100644 --- a/software/include/base/timer.h +++ b/software/include/base/timer.h @@ -1,6 +1,10 @@ #ifndef __TIMER_H #define __TIMER_H +#ifdef __cplusplus +extern "C" { +#endif + unsigned int get_system_frequency(void); void timer_enable(int en); unsigned int timer_get(void); @@ -8,4 +12,8 @@ void timer_set_counter(unsigned int value); void timer_set_reload(unsigned int value); void busy_wait(unsigned int ms); +#ifdef __cplusplus +} +#endif + #endif /* __TIMER_H */ diff --git a/software/include/base/uart.h b/software/include/base/uart.h index 86c61a84..3d8a4fcf 100644 --- a/software/include/base/uart.h +++ b/software/include/base/uart.h @@ -1,6 +1,10 @@ #ifndef __UART_H #define __UART_H +#ifdef __cplusplus +extern "C" { +#endif + void uart_init(void); void uart_isr(void); void uart_sync(void); @@ -9,4 +13,8 @@ void uart_write(char c); char uart_read(void); int uart_read_nonblock(void); +#ifdef __cplusplus +} +#endif + #endif -- 2.30.2