From 73c39f778739f55cc40f5bb421229e875d1ec466 Mon Sep 17 00:00:00 2001 From: Lars Rademacher Date: Mon, 21 Oct 2013 01:07:41 +0200 Subject: [PATCH] openocd: header fix * If included by cpp-file, this will cause trouble. So it gets restricted to use in c only. * Prevent usage of "new" as variable name * No redifinition of true and false, if included by C++ * Definition of bool fixed Change-Id: Ic5403bd576afd9d2900a8ecfbcfdc50561ba0633 --- debuggers/openocd/src/helper/binarybuffer.h | 2 + debuggers/openocd/src/helper/list.h | 42 ++++++++++----------- debuggers/openocd/src/helper/system.h | 2 + debuggers/openocd/src/helper/types.h | 8 ++-- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/debuggers/openocd/src/helper/binarybuffer.h b/debuggers/openocd/src/helper/binarybuffer.h index 633ed9e5..f542659c 100644 --- a/debuggers/openocd/src/helper/binarybuffer.h +++ b/debuggers/openocd/src/helper/binarybuffer.h @@ -126,10 +126,12 @@ int str_to_buf(const char *str, unsigned len, char *buf_to_str(const void *buf, unsigned size, unsigned radix); /* read a uint32_t from a buffer in target memory endianness */ +#ifndef __cplusplus static inline uint32_t fast_target_buffer_get_u32(const void *p, bool le) { return le ? le_to_h_u32(p) : be_to_h_u32(p); } +#endif static inline void bit_copy(uint8_t *dst, unsigned dst_offset, const uint8_t *src, unsigned src_offset, unsigned bit_count) diff --git a/debuggers/openocd/src/helper/list.h b/debuggers/openocd/src/helper/list.h index 302b9109..85e17010 100644 --- a/debuggers/openocd/src/helper/list.h +++ b/debuggers/openocd/src/helper/list.h @@ -47,17 +47,17 @@ static inline void INIT_LIST_HEAD(struct list_head *list) * the prev/next entries already! */ #ifndef CONFIG_DEBUG_LIST -static inline void __list_add(struct list_head *new, +static inline void __list_add(struct list_head *n, struct list_head *prev, struct list_head *next) { - next->prev = new; - new->next = next; - new->prev = prev; - prev->next = new; + next->prev = n; + n->next = next; + n->prev = prev; + prev->next = n; } #else -extern void __list_add(struct list_head *new, +extern void __list_add(struct list_head *n, struct list_head *prev, struct list_head *next); #endif @@ -70,9 +70,9 @@ extern void __list_add(struct list_head *new, * Insert a new entry after the specified head. * This is good for implementing stacks. */ -static inline void list_add(struct list_head *new, struct list_head *head) +static inline void list_add(struct list_head *n, struct list_head *head) { - __list_add(new, head, head->next); + __list_add(n, head, head->next); } @@ -84,9 +84,9 @@ static inline void list_add(struct list_head *new, struct list_head *head) * Insert a new entry before the specified head. * This is useful for implementing queues. */ -static inline void list_add_tail(struct list_head *new, struct list_head *head) +static inline void list_add_tail(struct list_head *n, struct list_head *head) { - __list_add(new, head->prev, head); + __list_add(n, head->prev, head); } /* @@ -133,18 +133,18 @@ extern void list_del(struct list_head *entry); * If @old was empty, it will be overwritten. */ static inline void list_replace(struct list_head *old, - struct list_head *new) + struct list_head *n) { - new->next = old->next; - new->next->prev = new; - new->prev = old->prev; - new->prev->next = new; + n->next = old->next; + n->next->prev = n; + n->prev = old->prev; + n->prev->next = n; } static inline void list_replace_init(struct list_head *old, - struct list_head *new) + struct list_head *n) { - list_replace(old, new); + list_replace(old, n); INIT_LIST_HEAD(old); } @@ -666,11 +666,11 @@ static inline void hlist_add_fake(struct hlist_node *n) * reference of the first entry if it exists. */ static inline void hlist_move_list(struct hlist_head *old, - struct hlist_head *new) + struct hlist_head *n) { - new->first = old->first; - if (new->first) - new->first->pprev = &new->first; + n->first = old->first; + if (n->first) + n->first->pprev = &n->first; old->first = NULL; } diff --git a/debuggers/openocd/src/helper/system.h b/debuggers/openocd/src/helper/system.h index 82d0cae7..6fbf435d 100644 --- a/debuggers/openocd/src/helper/system.h +++ b/debuggers/openocd/src/helper/system.h @@ -83,9 +83,11 @@ #include #endif +#ifndef __cplusplus #ifndef true #define true 1 #define false 0 #endif +#endif // __cplusplus #endif /* SYSTEM_H */ diff --git a/debuggers/openocd/src/helper/types.h b/debuggers/openocd/src/helper/types.h index 6866f560..35bddbec 100644 --- a/debuggers/openocd/src/helper/types.h +++ b/debuggers/openocd/src/helper/types.h @@ -43,15 +43,15 @@ #ifndef __cplusplus #define false 0 -#define true 1 +#define true 1 -typedef int _Bool; +//typedef int _Bool; #else -typedef bool _Bool; +typedef bool _Bool ; #endif /* __cplusplus */ #endif /* HAVE__BOOL */ -#define bool _Bool +#define bool int #endif /* HAVE_STDBOOL_H */