[Xenomai-git] Gilles Chanteperdrix : cobalt/timer: replace bheap with rbtree

2016-05-17 Thread git repository hosting
Module: xenomai-3
Branch: wip/dovetail
Commit: 15a799e1edf1da86ad80b5d19cb6d3c704c6e614
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=15a799e1edf1da86ad80b5d19cb6d3c704c6e614

Author: Gilles Chanteperdrix 
Date:   Sun Apr  3 22:47:55 2016 +0200

cobalt/timer: replace bheap with rbtree

make rbtree the default on x86_64, so that it gets tested.

---

 include/cobalt/kernel/Makefile.am |1 -
 include/cobalt/kernel/bheap.h |  266 -
 include/cobalt/kernel/timer.h |   80 ++-
 kernel/cobalt/Kconfig |   14 +-
 kernel/cobalt/clock.c |2 +-
 kernel/cobalt/timer.c |   34 -
 6 files changed, 87 insertions(+), 310 deletions(-)

diff --git a/include/cobalt/kernel/Makefile.am 
b/include/cobalt/kernel/Makefile.am
index 757675a..4d95702 100644
--- a/include/cobalt/kernel/Makefile.am
+++ b/include/cobalt/kernel/Makefile.am
@@ -4,7 +4,6 @@ noinst_HEADERS =\
apc.h   \
arith.h \
assert.h\
-   bheap.h \
bufd.h  \
clock.h \
compat.h\
diff --git a/include/cobalt/kernel/bheap.h b/include/cobalt/kernel/bheap.h
deleted file mode 100644
index 4c05bb4..000
--- a/include/cobalt/kernel/bheap.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2006 Gilles Chanteperdrix 
- *
- * Xenomai is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- *
- * Xenomai is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Xenomai; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-#ifndef _COBALT_KERNEL_BHEAP_H
-#define _COBALT_KERNEL_BHEAP_H
-
-/* debug support */
-#include 
-
-/* Priority queue implementation, using a binary heap. */
-
-typedef unsigned long long bheap_key_t;
-
-typedef struct bheaph {
-   bheap_key_t key;
-   unsigned prio;
-   unsigned pos;
-} bheaph_t;
-
-#define bheaph_init(holder) do { } while (0)
-#define bheaph_key(holder)  ((holder)->key)
-#define bheaph_prio(holder) ((holder)->prio)
-#define bheaph_pos(holder)  ((holder)->pos)
-#define bheaph_lt(h1, h2)   ((long long) ((h1)->key - (h2)->key) < 0 ||
\
-((h1)->key == (h2)->key && \
- (h1)->prio > (h2)->prio))
-
-typedef struct bheap {
-   unsigned sz;
-   unsigned last;
-   bheaph_t *elems[]; /* only padding, indexing starts at 1 */
-} bheap_t;
-
-#define DECLARE_BHEAP_CONTAINER(name, sz)   \
-   struct {\
-   bheap_t bheap;  \
-   bheaph_t *elems[sz + 1];\
-   } name
-
-/* Check the binary heap invariant. */
-static inline int bheap_ordered(bheap_t *heap)
-{
-   unsigned i;
-   for (i = 2; i < heap->last; i++)
-   if (bheaph_lt(heap->elems[i], heap->elems[i / 2]))
-   return 0;
-   return 1;
-}
-
-#define BHEAP_CHECK(heap)  \
-   XENO_BUG_ON(COBALT, ((heap)->sz == 0) || !bheap_ordered(heap))
-
-#define bheap_gethead(heap)\
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_gethead(_bheap);   \
-   })
-
-static inline bheaph_t *__internal_bheap_gethead(bheap_t *heap)
-{
-   if (heap->last == 1)
-   return NULL;
-
-   return heap->elems[1];
-}
-
-#define bheap_second(heap) \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_second(_bheap);\
-   })
-
-#define bheap_next(heap, holder)   \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_next(_bheap, holder);  \
-   })
-
-static inline bheaph_t *__internal_bheap_next(bheap_t *heap, bheaph_t *holder)
-{
-   unsigned pos;
-
-   if (unlikely(bheaph_pos(holder) >= heap->last
-|| heap->elems[bheaph_pos(holder)] != holder))
-   

[Xenomai-git] Gilles Chanteperdrix : cobalt/timer: replace bheap with rbtree

2016-05-15 Thread git repository hosting
Module: xenomai-3
Branch: next
Commit: 15a799e1edf1da86ad80b5d19cb6d3c704c6e614
URL:
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=15a799e1edf1da86ad80b5d19cb6d3c704c6e614

Author: Gilles Chanteperdrix 
Date:   Sun Apr  3 22:47:55 2016 +0200

cobalt/timer: replace bheap with rbtree

make rbtree the default on x86_64, so that it gets tested.

---

 include/cobalt/kernel/Makefile.am |1 -
 include/cobalt/kernel/bheap.h |  266 -
 include/cobalt/kernel/timer.h |   80 ++-
 kernel/cobalt/Kconfig |   14 +-
 kernel/cobalt/clock.c |2 +-
 kernel/cobalt/timer.c |   34 -
 6 files changed, 87 insertions(+), 310 deletions(-)

diff --git a/include/cobalt/kernel/Makefile.am 
b/include/cobalt/kernel/Makefile.am
index 757675a..4d95702 100644
--- a/include/cobalt/kernel/Makefile.am
+++ b/include/cobalt/kernel/Makefile.am
@@ -4,7 +4,6 @@ noinst_HEADERS =\
apc.h   \
arith.h \
assert.h\
-   bheap.h \
bufd.h  \
clock.h \
compat.h\
diff --git a/include/cobalt/kernel/bheap.h b/include/cobalt/kernel/bheap.h
deleted file mode 100644
index 4c05bb4..000
--- a/include/cobalt/kernel/bheap.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2006 Gilles Chanteperdrix 
- *
- * Xenomai is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- *
- * Xenomai is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Xenomai; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-#ifndef _COBALT_KERNEL_BHEAP_H
-#define _COBALT_KERNEL_BHEAP_H
-
-/* debug support */
-#include 
-
-/* Priority queue implementation, using a binary heap. */
-
-typedef unsigned long long bheap_key_t;
-
-typedef struct bheaph {
-   bheap_key_t key;
-   unsigned prio;
-   unsigned pos;
-} bheaph_t;
-
-#define bheaph_init(holder) do { } while (0)
-#define bheaph_key(holder)  ((holder)->key)
-#define bheaph_prio(holder) ((holder)->prio)
-#define bheaph_pos(holder)  ((holder)->pos)
-#define bheaph_lt(h1, h2)   ((long long) ((h1)->key - (h2)->key) < 0 ||
\
-((h1)->key == (h2)->key && \
- (h1)->prio > (h2)->prio))
-
-typedef struct bheap {
-   unsigned sz;
-   unsigned last;
-   bheaph_t *elems[]; /* only padding, indexing starts at 1 */
-} bheap_t;
-
-#define DECLARE_BHEAP_CONTAINER(name, sz)   \
-   struct {\
-   bheap_t bheap;  \
-   bheaph_t *elems[sz + 1];\
-   } name
-
-/* Check the binary heap invariant. */
-static inline int bheap_ordered(bheap_t *heap)
-{
-   unsigned i;
-   for (i = 2; i < heap->last; i++)
-   if (bheaph_lt(heap->elems[i], heap->elems[i / 2]))
-   return 0;
-   return 1;
-}
-
-#define BHEAP_CHECK(heap)  \
-   XENO_BUG_ON(COBALT, ((heap)->sz == 0) || !bheap_ordered(heap))
-
-#define bheap_gethead(heap)\
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_gethead(_bheap);   \
-   })
-
-static inline bheaph_t *__internal_bheap_gethead(bheap_t *heap)
-{
-   if (heap->last == 1)
-   return NULL;
-
-   return heap->elems[1];
-}
-
-#define bheap_second(heap) \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_second(_bheap);\
-   })
-
-#define bheap_next(heap, holder)   \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_next(_bheap, holder);  \
-   })
-
-static inline bheaph_t *__internal_bheap_next(bheap_t *heap, bheaph_t *holder)
-{
-   unsigned pos;
-
-   if (unlikely(bheaph_pos(holder) >= heap->last
-|| heap->elems[bheaph_pos(holder)] != holder))
-   

[Xenomai-git] Gilles Chanteperdrix : cobalt/timer: replace bheap with rbtree

2016-05-14 Thread git repository hosting
Module: xenomai-gch
Branch: stable-3.0.x
Commit: 04e0d12f17a0f0c41372818d5e2db6ced8dded3b
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=04e0d12f17a0f0c41372818d5e2db6ced8dded3b

Author: Gilles Chanteperdrix 
Date:   Sun Apr  3 22:47:55 2016 +0200

cobalt/timer: replace bheap with rbtree

make rbtree the default on x86_64, so that it gets tested.

---

 include/cobalt/kernel/Makefile.am |1 -
 include/cobalt/kernel/bheap.h |  266 -
 include/cobalt/kernel/timer.h |   80 ++-
 kernel/cobalt/Kconfig |   14 +-
 kernel/cobalt/clock.c |2 +-
 kernel/cobalt/timer.c |   34 -
 6 files changed, 87 insertions(+), 310 deletions(-)

diff --git a/include/cobalt/kernel/Makefile.am 
b/include/cobalt/kernel/Makefile.am
index 757675a..4d95702 100644
--- a/include/cobalt/kernel/Makefile.am
+++ b/include/cobalt/kernel/Makefile.am
@@ -4,7 +4,6 @@ noinst_HEADERS =\
apc.h   \
arith.h \
assert.h\
-   bheap.h \
bufd.h  \
clock.h \
compat.h\
diff --git a/include/cobalt/kernel/bheap.h b/include/cobalt/kernel/bheap.h
deleted file mode 100644
index 4c05bb4..000
--- a/include/cobalt/kernel/bheap.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2006 Gilles Chanteperdrix 
- *
- * Xenomai is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- *
- * Xenomai is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Xenomai; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-#ifndef _COBALT_KERNEL_BHEAP_H
-#define _COBALT_KERNEL_BHEAP_H
-
-/* debug support */
-#include 
-
-/* Priority queue implementation, using a binary heap. */
-
-typedef unsigned long long bheap_key_t;
-
-typedef struct bheaph {
-   bheap_key_t key;
-   unsigned prio;
-   unsigned pos;
-} bheaph_t;
-
-#define bheaph_init(holder) do { } while (0)
-#define bheaph_key(holder)  ((holder)->key)
-#define bheaph_prio(holder) ((holder)->prio)
-#define bheaph_pos(holder)  ((holder)->pos)
-#define bheaph_lt(h1, h2)   ((long long) ((h1)->key - (h2)->key) < 0 ||
\
-((h1)->key == (h2)->key && \
- (h1)->prio > (h2)->prio))
-
-typedef struct bheap {
-   unsigned sz;
-   unsigned last;
-   bheaph_t *elems[]; /* only padding, indexing starts at 1 */
-} bheap_t;
-
-#define DECLARE_BHEAP_CONTAINER(name, sz)   \
-   struct {\
-   bheap_t bheap;  \
-   bheaph_t *elems[sz + 1];\
-   } name
-
-/* Check the binary heap invariant. */
-static inline int bheap_ordered(bheap_t *heap)
-{
-   unsigned i;
-   for (i = 2; i < heap->last; i++)
-   if (bheaph_lt(heap->elems[i], heap->elems[i / 2]))
-   return 0;
-   return 1;
-}
-
-#define BHEAP_CHECK(heap)  \
-   XENO_BUG_ON(COBALT, ((heap)->sz == 0) || !bheap_ordered(heap))
-
-#define bheap_gethead(heap)\
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_gethead(_bheap);   \
-   })
-
-static inline bheaph_t *__internal_bheap_gethead(bheap_t *heap)
-{
-   if (heap->last == 1)
-   return NULL;
-
-   return heap->elems[1];
-}
-
-#define bheap_second(heap) \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_second(_bheap);\
-   })
-
-#define bheap_next(heap, holder)   \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_next(_bheap, holder);  \
-   })
-
-static inline bheaph_t *__internal_bheap_next(bheap_t *heap, bheaph_t *holder)
-{
-   unsigned pos;
-
-   if (unlikely(bheaph_pos(holder) >= heap->last
-|| heap->elems[bheaph_pos(holder)] != holder))
-   

[Xenomai-git] Gilles Chanteperdrix : cobalt/timer: replace bheap with rbtree

2016-04-03 Thread git repository hosting
Module: xenomai-gch
Branch: next
Commit: 0392e782f490d3d0a5083eaa7ccb1ae5e5d0cd5f
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=0392e782f490d3d0a5083eaa7ccb1ae5e5d0cd5f

Author: Gilles Chanteperdrix 
Date:   Sun Apr  3 22:47:55 2016 +0200

cobalt/timer: replace bheap with rbtree

make rbtree the default on x86_64, so that it gets tested.

---

 include/cobalt/kernel/Makefile.am |1 -
 include/cobalt/kernel/bheap.h |  266 -
 include/cobalt/kernel/timer.h |   80 ++-
 kernel/cobalt/Kconfig |   14 +-
 kernel/cobalt/clock.c |2 +-
 kernel/cobalt/timer.c |   34 -
 6 files changed, 87 insertions(+), 310 deletions(-)

diff --git a/include/cobalt/kernel/Makefile.am 
b/include/cobalt/kernel/Makefile.am
index 757675a..4d95702 100644
--- a/include/cobalt/kernel/Makefile.am
+++ b/include/cobalt/kernel/Makefile.am
@@ -4,7 +4,6 @@ noinst_HEADERS =\
apc.h   \
arith.h \
assert.h\
-   bheap.h \
bufd.h  \
clock.h \
compat.h\
diff --git a/include/cobalt/kernel/bheap.h b/include/cobalt/kernel/bheap.h
deleted file mode 100644
index 4c05bb4..000
--- a/include/cobalt/kernel/bheap.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2006 Gilles Chanteperdrix 
- *
- * Xenomai is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- *
- * Xenomai is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Xenomai; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-#ifndef _COBALT_KERNEL_BHEAP_H
-#define _COBALT_KERNEL_BHEAP_H
-
-/* debug support */
-#include 
-
-/* Priority queue implementation, using a binary heap. */
-
-typedef unsigned long long bheap_key_t;
-
-typedef struct bheaph {
-   bheap_key_t key;
-   unsigned prio;
-   unsigned pos;
-} bheaph_t;
-
-#define bheaph_init(holder) do { } while (0)
-#define bheaph_key(holder)  ((holder)->key)
-#define bheaph_prio(holder) ((holder)->prio)
-#define bheaph_pos(holder)  ((holder)->pos)
-#define bheaph_lt(h1, h2)   ((long long) ((h1)->key - (h2)->key) < 0 ||
\
-((h1)->key == (h2)->key && \
- (h1)->prio > (h2)->prio))
-
-typedef struct bheap {
-   unsigned sz;
-   unsigned last;
-   bheaph_t *elems[]; /* only padding, indexing starts at 1 */
-} bheap_t;
-
-#define DECLARE_BHEAP_CONTAINER(name, sz)   \
-   struct {\
-   bheap_t bheap;  \
-   bheaph_t *elems[sz + 1];\
-   } name
-
-/* Check the binary heap invariant. */
-static inline int bheap_ordered(bheap_t *heap)
-{
-   unsigned i;
-   for (i = 2; i < heap->last; i++)
-   if (bheaph_lt(heap->elems[i], heap->elems[i / 2]))
-   return 0;
-   return 1;
-}
-
-#define BHEAP_CHECK(heap)  \
-   XENO_BUG_ON(COBALT, ((heap)->sz == 0) || !bheap_ordered(heap))
-
-#define bheap_gethead(heap)\
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_gethead(_bheap);   \
-   })
-
-static inline bheaph_t *__internal_bheap_gethead(bheap_t *heap)
-{
-   if (heap->last == 1)
-   return NULL;
-
-   return heap->elems[1];
-}
-
-#define bheap_second(heap) \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_second(_bheap);\
-   })
-
-#define bheap_next(heap, holder)   \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_next(_bheap, holder);  \
-   })
-
-static inline bheaph_t *__internal_bheap_next(bheap_t *heap, bheaph_t *holder)
-{
-   unsigned pos;
-
-   if (unlikely(bheaph_pos(holder) >= heap->last
-|| heap->elems[bheaph_pos(holder)] != holder))
-   

[Xenomai-git] Gilles Chanteperdrix : cobalt/timer: replace bheap with rbtree

2016-04-03 Thread git repository hosting
Module: xenomai-gch
Branch: stable-3.0.x
Commit: 4c937b61c0caff57ef6ccaf31838f2a8a0bab25e
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=4c937b61c0caff57ef6ccaf31838f2a8a0bab25e

Author: Gilles Chanteperdrix 
Date:   Sun Apr  3 22:47:55 2016 +0200

cobalt/timer: replace bheap with rbtree

make rbtree the default on x86_64, so that it gets tested.

---

 include/cobalt/kernel/Makefile.am |1 -
 include/cobalt/kernel/bheap.h |  266 -
 include/cobalt/kernel/timer.h |   80 ++-
 kernel/cobalt/Kconfig |   14 +-
 kernel/cobalt/clock.c |2 +-
 kernel/cobalt/timer.c |   34 -
 6 files changed, 87 insertions(+), 310 deletions(-)

diff --git a/include/cobalt/kernel/Makefile.am 
b/include/cobalt/kernel/Makefile.am
index 757675a..4d95702 100644
--- a/include/cobalt/kernel/Makefile.am
+++ b/include/cobalt/kernel/Makefile.am
@@ -4,7 +4,6 @@ noinst_HEADERS =\
apc.h   \
arith.h \
assert.h\
-   bheap.h \
bufd.h  \
clock.h \
compat.h\
diff --git a/include/cobalt/kernel/bheap.h b/include/cobalt/kernel/bheap.h
deleted file mode 100644
index 4c05bb4..000
--- a/include/cobalt/kernel/bheap.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2006 Gilles Chanteperdrix 
- *
- * Xenomai is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- *
- * Xenomai is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Xenomai; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-#ifndef _COBALT_KERNEL_BHEAP_H
-#define _COBALT_KERNEL_BHEAP_H
-
-/* debug support */
-#include 
-
-/* Priority queue implementation, using a binary heap. */
-
-typedef unsigned long long bheap_key_t;
-
-typedef struct bheaph {
-   bheap_key_t key;
-   unsigned prio;
-   unsigned pos;
-} bheaph_t;
-
-#define bheaph_init(holder) do { } while (0)
-#define bheaph_key(holder)  ((holder)->key)
-#define bheaph_prio(holder) ((holder)->prio)
-#define bheaph_pos(holder)  ((holder)->pos)
-#define bheaph_lt(h1, h2)   ((long long) ((h1)->key - (h2)->key) < 0 ||
\
-((h1)->key == (h2)->key && \
- (h1)->prio > (h2)->prio))
-
-typedef struct bheap {
-   unsigned sz;
-   unsigned last;
-   bheaph_t *elems[]; /* only padding, indexing starts at 1 */
-} bheap_t;
-
-#define DECLARE_BHEAP_CONTAINER(name, sz)   \
-   struct {\
-   bheap_t bheap;  \
-   bheaph_t *elems[sz + 1];\
-   } name
-
-/* Check the binary heap invariant. */
-static inline int bheap_ordered(bheap_t *heap)
-{
-   unsigned i;
-   for (i = 2; i < heap->last; i++)
-   if (bheaph_lt(heap->elems[i], heap->elems[i / 2]))
-   return 0;
-   return 1;
-}
-
-#define BHEAP_CHECK(heap)  \
-   XENO_BUG_ON(COBALT, ((heap)->sz == 0) || !bheap_ordered(heap))
-
-#define bheap_gethead(heap)\
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_gethead(_bheap);   \
-   })
-
-static inline bheaph_t *__internal_bheap_gethead(bheap_t *heap)
-{
-   if (heap->last == 1)
-   return NULL;
-
-   return heap->elems[1];
-}
-
-#define bheap_second(heap) \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_second(_bheap);\
-   })
-
-#define bheap_next(heap, holder)   \
-   ({  \
-   bheap_t *_bheap = &(heap)->bheap;   \
-   BHEAP_CHECK(_bheap);\
-   __internal_bheap_next(_bheap, holder);  \
-   })
-
-static inline bheaph_t *__internal_bheap_next(bheap_t *heap, bheaph_t *holder)
-{
-   unsigned pos;
-
-   if (unlikely(bheaph_pos(holder) >= heap->last
-|| heap->elems[bheaph_pos(holder)] != holder))
-