diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-02-13 12:47:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-13 12:47:23 -0500 |
| commit | cfef27e56ef3246a261ee0bf2810a46c08eebf8f (patch) | |
| tree | ac66ba3d1f7a037ad51f21bd54a236d5388f5916 /lib/openbsd-tree.h | |
| parent | 01490ba25da576ec0a72c896559ebc6fa71484be (diff) | |
| parent | 8ed561e1f13d0afb019a7963238bdd43ad017bec (diff) | |
Merge pull request #3622 from mjstapp/fix_cpp_compile
libs, daemons: changes to permit c++ compilation
Diffstat (limited to 'lib/openbsd-tree.h')
| -rw-r--r-- | lib/openbsd-tree.h | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/openbsd-tree.h b/lib/openbsd-tree.h index 1383ef6de0..d2f0781333 100644 --- a/lib/openbsd-tree.h +++ b/lib/openbsd-tree.h @@ -27,6 +27,10 @@ #ifndef _SYS_TREE_H_ #define _SYS_TREE_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* * This file defines data structures for different types of trees: * splay trees and red-black trees. @@ -397,31 +401,36 @@ int _rb_check(const struct rb_type *, void *, unsigned long); __attribute__((__unused__)) static inline struct _type \ *_name##_RB_INSERT(struct _name *head, struct _type *elm) \ { \ - return _rb_insert(_name##_RB_TYPE, &head->rbh_root, elm); \ + return (struct _type *)_rb_insert( \ + _name##_RB_TYPE, &head->rbh_root, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_REMOVE(struct _name *head, struct _type *elm) \ { \ - return _rb_remove(_name##_RB_TYPE, &head->rbh_root, elm); \ + return (struct _type *)_rb_remove( \ + _name##_RB_TYPE, &head->rbh_root, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_FIND(struct _name *head, const struct _type *key) \ { \ - return _rb_find(_name##_RB_TYPE, &head->rbh_root, key); \ + return (struct _type *)_rb_find( \ + _name##_RB_TYPE, &head->rbh_root, key); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_NFIND(struct _name *head, const struct _type *key) \ { \ - return _rb_nfind(_name##_RB_TYPE, &head->rbh_root, key); \ + return (struct _type *)_rb_nfind( \ + _name##_RB_TYPE, &head->rbh_root, key); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_ROOT(struct _name *head) \ { \ - return _rb_root(_name##_RB_TYPE, &head->rbh_root); \ + return (struct _type *)_rb_root( \ + _name##_RB_TYPE, &head->rbh_root); \ } \ \ __attribute__((__unused__)) static inline int _name##_RB_EMPTY( \ @@ -433,43 +442,45 @@ int _rb_check(const struct rb_type *, void *, unsigned long); __attribute__((__unused__)) static inline struct _type \ *_name##_RB_MIN(struct _name *head) \ { \ - return _rb_min(_name##_RB_TYPE, &head->rbh_root); \ + return (struct _type *)_rb_min( \ + _name##_RB_TYPE, &head->rbh_root); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_MAX(struct _name *head) \ { \ - return _rb_max(_name##_RB_TYPE, &head->rbh_root); \ + return (struct _type *)_rb_max( \ + _name##_RB_TYPE, &head->rbh_root); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_NEXT(struct _type *elm) \ { \ - return _rb_next(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_next(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_PREV(struct _type *elm) \ { \ - return _rb_prev(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_prev(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_LEFT(struct _type *elm) \ { \ - return _rb_left(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_left(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_RIGHT(struct _type *elm) \ { \ - return _rb_right(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_right(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline struct _type \ *_name##_RB_PARENT(struct _type *elm) \ { \ - return _rb_parent(_name##_RB_TYPE, elm); \ + return (struct _type *)_rb_parent(_name##_RB_TYPE, elm); \ } \ \ __attribute__((__unused__)) static inline void _name##_RB_SET_LEFT( \ @@ -560,4 +571,8 @@ int _rb_check(const struct rb_type *, void *, unsigned long); for ((_e) = RB_MAX(_name, (_head)); \ (_e) != NULL && ((_n) = RB_PREV(_name, (_e)), 1); (_e) = (_n)) +#ifdef __cplusplus +} +#endif + #endif /* _SYS_TREE_H_ */ |
