mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-07 14:11:46 +00:00
57 lines
1.8 KiB
C
57 lines
1.8 KiB
C
/*
|
|
|
|
*** uWSGI, stripped down version of Linux rbtree ***
|
|
|
|
|
|
Red Black Trees
|
|
(C) 1999 Andrea Arcangeli <andrea@suse.de>
|
|
|
|
This program 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.
|
|
|
|
This program 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 this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
struct rb_node
|
|
{
|
|
unsigned long rb_parent_color;
|
|
#define RB_RED 0
|
|
#define RB_BLACK 1
|
|
struct rb_node *rb_right;
|
|
struct rb_node *rb_left;
|
|
} __attribute__((aligned(sizeof(long))));
|
|
/* The alignment might seem pointless, but allegedly CRIS needs it */
|
|
|
|
struct rb_root
|
|
{
|
|
struct rb_node *rb_node;
|
|
};
|
|
|
|
#define rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~3))
|
|
#define rb_color(r) ((r)->rb_parent_color & 1)
|
|
#define rb_is_red(r) (!rb_color(r))
|
|
#define rb_is_black(r) rb_color(r)
|
|
#define rb_set_red(r) do { (r)->rb_parent_color &= ~1; } while (0)
|
|
#define rb_set_black(r) do { (r)->rb_parent_color |= 1; } while (0)
|
|
|
|
void rb_insert_color(struct rb_node *, struct rb_root *);
|
|
void rb_erase(struct rb_node *, struct rb_root *);
|
|
|
|
#ifdef __clang__
|
|
void rb_link_node(struct rb_node *, struct rb_node *,
|
|
struct rb_node **);
|
|
#else
|
|
inline void rb_link_node(struct rb_node *, struct rb_node *,
|
|
struct rb_node **);
|
|
#endif
|