software/include/base: C++ compatibility

This commit is contained in:
Sebastien Bourdeauducq 2013-03-25 14:38:58 +01:00
parent 3640cab439
commit 6a54276d55
19 changed files with 151 additions and 3 deletions

View file

@ -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 */

View file

@ -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 */

View file

@ -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

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -3,6 +3,10 @@
#include <stdlib.h>
#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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -3,6 +3,10 @@
#include <stddef.h>
#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 */

View file

@ -21,6 +21,10 @@
#include <stddef.h>
#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 */

View file

@ -21,6 +21,10 @@
#include <stddef.h>
#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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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