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
This commit is contained in:
Lars Rademacher
2013-10-21 01:07:41 +02:00
parent 0bb8ff2fa7
commit 73c39f7787
4 changed files with 29 additions and 25 deletions

View File

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

View File

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

View File

@ -83,9 +83,11 @@
#include <fcntl.h>
#endif
#ifndef __cplusplus
#ifndef true
#define true 1
#define false 0
#endif
#endif // __cplusplus
#endif /* SYSTEM_H */

View File

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