Coverage Report

Created: 2026-01-10 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/tmux/compat/tree.h
Line
Count
Source
1
/*  $OpenBSD: tree.h,v 1.13 2011/07/09 00:19:45 pirofti Exp $ */
2
/*
3
 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions
8
 * are met:
9
 * 1. Redistributions of source code must retain the above copyright
10
 *    notice, this list of conditions and the following disclaimer.
11
 * 2. Redistributions in binary form must reproduce the above copyright
12
 *    notice, this list of conditions and the following disclaimer in the
13
 *    documentation and/or other materials provided with the distribution.
14
 *
15
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 */
26
27
#ifndef _SYS_TREE_H_
28
#define _SYS_TREE_H_
29
30
/*
31
 * This file defines data structures for different types of trees:
32
 * splay trees and red-black trees.
33
 *
34
 * A splay tree is a self-organizing data structure.  Every operation
35
 * on the tree causes a splay to happen.  The splay moves the requested
36
 * node to the root of the tree and partly rebalances it.
37
 *
38
 * This has the benefit that request locality causes faster lookups as
39
 * the requested nodes move to the top of the tree.  On the other hand,
40
 * every lookup causes memory writes.
41
 *
42
 * The Balance Theorem bounds the total access time for m operations
43
 * and n inserts on an initially empty tree as O((m + n)lg n).  The
44
 * amortized cost for a sequence of m accesses to a splay tree is O(lg n);
45
 *
46
 * A red-black tree is a binary search tree with the node color as an
47
 * extra attribute.  It fulfills a set of conditions:
48
 *  - every search path from the root to a leaf consists of the
49
 *    same number of black nodes,
50
 *  - each red node (except for the root) has a black parent,
51
 *  - each leaf node is black.
52
 *
53
 * Every operation on a red-black tree is bounded as O(lg n).
54
 * The maximum height of a red-black tree is 2lg (n+1).
55
 */
56
57
#define SPLAY_HEAD(name, type)            \
58
struct name {               \
59
  struct type *sph_root; /* root of the tree */     \
60
}
61
62
#define SPLAY_INITIALIZER(root)           \
63
  { NULL }
64
65
#define SPLAY_INIT(root) do {           \
66
  (root)->sph_root = NULL;          \
67
} while (0)
68
69
#define SPLAY_ENTRY(type)           \
70
struct {                \
71
  struct type *spe_left; /* left element */     \
72
  struct type *spe_right; /* right element */     \
73
}
74
75
#define SPLAY_LEFT(elm, field)    (elm)->field.spe_left
76
#define SPLAY_RIGHT(elm, field)   (elm)->field.spe_right
77
#define SPLAY_ROOT(head)    (head)->sph_root
78
#define SPLAY_EMPTY(head)   (SPLAY_ROOT(head) == NULL)
79
80
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
81
#define SPLAY_ROTATE_RIGHT(head, tmp, field) do {     \
82
  SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field);  \
83
  SPLAY_RIGHT(tmp, field) = (head)->sph_root;     \
84
  (head)->sph_root = tmp;           \
85
} while (0)
86
  
87
#define SPLAY_ROTATE_LEFT(head, tmp, field) do {      \
88
  SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field);  \
89
  SPLAY_LEFT(tmp, field) = (head)->sph_root;      \
90
  (head)->sph_root = tmp;           \
91
} while (0)
92
93
#define SPLAY_LINKLEFT(head, tmp, field) do {       \
94
  SPLAY_LEFT(tmp, field) = (head)->sph_root;      \
95
  tmp = (head)->sph_root;           \
96
  (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);   \
97
} while (0)
98
99
#define SPLAY_LINKRIGHT(head, tmp, field) do {        \
100
  SPLAY_RIGHT(tmp, field) = (head)->sph_root;     \
101
  tmp = (head)->sph_root;           \
102
  (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);  \
103
} while (0)
104
105
#define SPLAY_ASSEMBLE(head, node, left, right, field) do {   \
106
  SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
107
  SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
108
  SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
109
  SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
110
} while (0)
111
112
/* Generates prototypes and inline functions */
113
114
#define SPLAY_PROTOTYPE(name, type, field, cmp)       \
115
void name##_SPLAY(struct name *, struct type *);      \
116
void name##_SPLAY_MINMAX(struct name *, int);       \
117
struct type *name##_SPLAY_INSERT(struct name *, struct type *);   \
118
struct type *name##_SPLAY_REMOVE(struct name *, struct type *);   \
119
                  \
120
/* Finds the node with the same key as elm */       \
121
static __inline struct type *           \
122
name##_SPLAY_FIND(struct name *head, struct type *elm)      \
123
{                 \
124
  if (SPLAY_EMPTY(head))            \
125
    return(NULL);           \
126
  name##_SPLAY(head, elm);          \
127
  if ((cmp)(elm, (head)->sph_root) == 0)        \
128
    return (head->sph_root);        \
129
  return (NULL);              \
130
}                 \
131
                  \
132
static __inline struct type *           \
133
name##_SPLAY_NEXT(struct name *head, struct type *elm)      \
134
{                 \
135
  name##_SPLAY(head, elm);          \
136
  if (SPLAY_RIGHT(elm, field) != NULL) {        \
137
    elm = SPLAY_RIGHT(elm, field);        \
138
    while (SPLAY_LEFT(elm, field) != NULL) {    \
139
      elm = SPLAY_LEFT(elm, field);     \
140
    }             \
141
  } else                \
142
    elm = NULL;           \
143
  return (elm);             \
144
}                 \
145
                  \
146
static __inline struct type *           \
147
name##_SPLAY_MIN_MAX(struct name *head, int val)      \
148
{                 \
149
  name##_SPLAY_MINMAX(head, val);         \
150
        return (SPLAY_ROOT(head));          \
151
}
152
153
/* Main splay operation.
154
 * Moves node close to the key of elm to top
155
 */
156
#define SPLAY_GENERATE(name, type, field, cmp)        \
157
struct type *               \
158
name##_SPLAY_INSERT(struct name *head, struct type *elm)    \
159
{                 \
160
    if (SPLAY_EMPTY(head)) {            \
161
      SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL;  \
162
    } else {                \
163
      int __comp;             \
164
      name##_SPLAY(head, elm);          \
165
      __comp = (cmp)(elm, (head)->sph_root);      \
166
      if(__comp < 0) {            \
167
        SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
168
        SPLAY_RIGHT(elm, field) = (head)->sph_root;   \
169
        SPLAY_LEFT((head)->sph_root, field) = NULL;   \
170
      } else if (__comp > 0) {          \
171
        SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
172
        SPLAY_LEFT(elm, field) = (head)->sph_root;    \
173
        SPLAY_RIGHT((head)->sph_root, field) = NULL;  \
174
      } else              \
175
        return ((head)->sph_root);        \
176
    }                 \
177
    (head)->sph_root = (elm);           \
178
    return (NULL);              \
179
}                 \
180
                  \
181
struct type *               \
182
name##_SPLAY_REMOVE(struct name *head, struct type *elm)    \
183
{                 \
184
  struct type *__tmp;           \
185
  if (SPLAY_EMPTY(head))            \
186
    return (NULL);            \
187
  name##_SPLAY(head, elm);          \
188
  if ((cmp)(elm, (head)->sph_root) == 0) {      \
189
    if (SPLAY_LEFT((head)->sph_root, field) == NULL) {  \
190
      (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
191
    } else {            \
192
      __tmp = SPLAY_RIGHT((head)->sph_root, field); \
193
      (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
194
      name##_SPLAY(head, elm);      \
195
      SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
196
    }             \
197
    return (elm);           \
198
  }               \
199
  return (NULL);              \
200
}                 \
201
                  \
202
void                  \
203
name##_SPLAY(struct name *head, struct type *elm)     \
204
{                 \
205
  struct type __node, *__left, *__right, *__tmp;      \
206
  int __comp;             \
207
\
208
  SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
209
  __left = __right = &__node;         \
210
\
211
  while ((__comp = (cmp)(elm, (head)->sph_root))) {   \
212
    if (__comp < 0) {         \
213
      __tmp = SPLAY_LEFT((head)->sph_root, field);  \
214
      if (__tmp == NULL)        \
215
        break;          \
216
      if ((cmp)(elm, __tmp) < 0){     \
217
        SPLAY_ROTATE_RIGHT(head, __tmp, field); \
218
        if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
219
          break;        \
220
      }           \
221
      SPLAY_LINKLEFT(head, __right, field);   \
222
    } else if (__comp > 0) {        \
223
      __tmp = SPLAY_RIGHT((head)->sph_root, field); \
224
      if (__tmp == NULL)        \
225
        break;          \
226
      if ((cmp)(elm, __tmp) > 0){     \
227
        SPLAY_ROTATE_LEFT(head, __tmp, field);  \
228
        if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
229
          break;        \
230
      }           \
231
      SPLAY_LINKRIGHT(head, __left, field);   \
232
    }             \
233
  }               \
234
  SPLAY_ASSEMBLE(head, &__node, __left, __right, field);    \
235
}                 \
236
                  \
237
/* Splay with either the minimum or the maximum element     \
238
 * Used to find minimum or maximum element in tree.     \
239
 */                 \
240
void name##_SPLAY_MINMAX(struct name *head, int __comp) \
241
{                 \
242
  struct type __node, *__left, *__right, *__tmp;      \
243
\
244
  SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
245
  __left = __right = &__node;         \
246
\
247
  while (1) {             \
248
    if (__comp < 0) {         \
249
      __tmp = SPLAY_LEFT((head)->sph_root, field);  \
250
      if (__tmp == NULL)        \
251
        break;          \
252
      if (__comp < 0){        \
253
        SPLAY_ROTATE_RIGHT(head, __tmp, field); \
254
        if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
255
          break;        \
256
      }           \
257
      SPLAY_LINKLEFT(head, __right, field);   \
258
    } else if (__comp > 0) {        \
259
      __tmp = SPLAY_RIGHT((head)->sph_root, field); \
260
      if (__tmp == NULL)        \
261
        break;          \
262
      if (__comp > 0) {       \
263
        SPLAY_ROTATE_LEFT(head, __tmp, field);  \
264
        if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
265
          break;        \
266
      }           \
267
      SPLAY_LINKRIGHT(head, __left, field);   \
268
    }             \
269
  }               \
270
  SPLAY_ASSEMBLE(head, &__node, __left, __right, field);    \
271
}
272
273
#define SPLAY_NEGINF  -1
274
#define SPLAY_INF 1
275
276
#define SPLAY_INSERT(name, x, y)  name##_SPLAY_INSERT(x, y)
277
#define SPLAY_REMOVE(name, x, y)  name##_SPLAY_REMOVE(x, y)
278
#define SPLAY_FIND(name, x, y)    name##_SPLAY_FIND(x, y)
279
#define SPLAY_NEXT(name, x, y)    name##_SPLAY_NEXT(x, y)
280
#define SPLAY_MIN(name, x)    (SPLAY_EMPTY(x) ? NULL  \
281
          : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
282
#define SPLAY_MAX(name, x)    (SPLAY_EMPTY(x) ? NULL  \
283
          : name##_SPLAY_MIN_MAX(x, SPLAY_INF))
284
285
#define SPLAY_FOREACH(x, name, head)          \
286
  for ((x) = SPLAY_MIN(name, head);       \
287
       (x) != NULL;           \
288
       (x) = SPLAY_NEXT(name, head, x))
289
290
/* Macros that define a red-black tree */
291
#define RB_HEAD(name, type)           \
292
struct name {               \
293
  struct type *rbh_root; /* root of the tree */     \
294
}
295
296
#define RB_INITIALIZER(root)            \
297
  { NULL }
298
299
87.2k
#define RB_INIT(root) do {           \
300
87.2k
  (root)->rbh_root = NULL;          \
301
87.2k
} while (0)
302
303
224k
#define RB_BLACK  0
304
178k
#define RB_RED    1
305
#define RB_ENTRY(type)              \
306
struct {                \
307
  struct type *rbe_left;    /* left element */    \
308
  struct type *rbe_right;   /* right element */   \
309
  struct type *rbe_parent;  /* parent element */    \
310
  int rbe_color;      /* node color */    \
311
}
312
313
707k
#define RB_LEFT(elm, field)   (elm)->field.rbe_left
314
832k
#define RB_RIGHT(elm, field)    (elm)->field.rbe_right
315
507k
#define RB_PARENT(elm, field)   (elm)->field.rbe_parent
316
407k
#define RB_COLOR(elm, field)    (elm)->field.rbe_color
317
917k
#define RB_ROOT(head)     (head)->rbh_root
318
0
#define RB_EMPTY(head)      (RB_ROOT(head) == NULL)
319
320
59.7k
#define RB_SET(elm, parent, field) do {         \
321
59.7k
  RB_PARENT(elm, field) = parent;          \
322
59.7k
  RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL;    \
323
59.7k
  RB_COLOR(elm, field) = RB_RED;         \
324
59.7k
} while (0)
325
326
29.4k
#define RB_SET_BLACKRED(black, red, field) do {       \
327
29.4k
  RB_COLOR(black, field) = RB_BLACK;       \
328
29.4k
  RB_COLOR(red, field) = RB_RED;         \
329
29.4k
} while (0)
330
331
#ifndef RB_AUGMENT
332
103k
#define RB_AUGMENT(x) do {} while (0)
333
#endif
334
335
15.7k
#define RB_ROTATE_LEFT(head, elm, tmp, field) do {     \
336
15.7k
  (tmp) = RB_RIGHT(elm, field);         \
337
15.7k
  if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field))) {   \
338
8.16k
    RB_PARENT(RB_LEFT(tmp, field), field) = (elm);   \
339
8.16k
  }                \
340
15.7k
  RB_AUGMENT(elm);            \
341
15.7k
  if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) {   \
342
12.0k
    if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
343
12.0k
      RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
344
12.0k
    else              \
345
12.0k
      RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
346
12.0k
  } else               \
347
15.7k
    (head)->rbh_root = (tmp);       \
348
15.7k
  RB_LEFT(tmp, field) = (elm);         \
349
15.7k
  RB_PARENT(elm, field) = (tmp);         \
350
15.7k
  RB_AUGMENT(tmp);            \
351
15.7k
  if ((RB_PARENT(tmp, field)))          \
352
15.7k
    RB_AUGMENT(RB_PARENT(tmp, field));      \
353
15.7k
} while (0)
354
355
4.73k
#define RB_ROTATE_RIGHT(head, elm, tmp, field) do {     \
356
4.73k
  (tmp) = RB_LEFT(elm, field);         \
357
4.73k
  if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field))) {   \
358
2.66k
    RB_PARENT(RB_RIGHT(tmp, field), field) = (elm);    \
359
2.66k
  }                \
360
4.73k
  RB_AUGMENT(elm);            \
361
4.73k
  if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) {   \
362
4.09k
    if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
363
4.09k
      RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
364
4.09k
    else              \
365
4.09k
      RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
366
4.09k
  } else               \
367
4.73k
    (head)->rbh_root = (tmp);       \
368
4.73k
  RB_RIGHT(tmp, field) = (elm);         \
369
4.73k
  RB_PARENT(elm, field) = (tmp);         \
370
4.73k
  RB_AUGMENT(tmp);            \
371
4.73k
  if ((RB_PARENT(tmp, field)))          \
372
4.73k
    RB_AUGMENT(RB_PARENT(tmp, field));      \
373
4.73k
} while (0)
374
375
/* Generates prototypes and inline functions */
376
#define RB_PROTOTYPE(name, type, field, cmp)        \
377
  RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
378
#define RB_PROTOTYPE_STATIC(name, type, field, cmp)     \
379
  RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static)
380
#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr)   \
381
attr void name##_RB_INSERT_COLOR(struct name *, struct type *);   \
382
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
383
attr struct type *name##_RB_REMOVE(struct name *, struct type *); \
384
attr struct type *name##_RB_INSERT(struct name *, struct type *); \
385
attr struct type *name##_RB_FIND(struct name *, struct type *);   \
386
attr struct type *name##_RB_NFIND(struct name *, struct type *);  \
387
attr struct type *name##_RB_NEXT(struct type *);      \
388
attr struct type *name##_RB_PREV(struct type *);      \
389
attr struct type *name##_RB_MINMAX(struct name *, int);     \
390
                  \
391
392
/* Main rb operation.
393
 * Moves node close to the key of elm to top
394
 */
395
#define RB_GENERATE(name, type, field, cmp)       \
396
  RB_GENERATE_INTERNAL(name, type, field, cmp,)
397
#define RB_GENERATE_STATIC(name, type, field, cmp)      \
398
  RB_GENERATE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static)
399
#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr)    \
400
attr void               \
401
59.7k
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
59.7k
{                 \
403
59.7k
  struct type *parent, *gparent, *tmp;        \
404
84.7k
  while ((parent = RB_PARENT(elm, field)) &&      \
405
84.7k
      RB_COLOR(parent, field) == RB_RED) {     \
406
25.0k
    gparent = RB_PARENT(parent, field);      \
407
25.0k
    if (parent == RB_LEFT(gparent, field)) {   \
408
5.18k
      tmp = RB_RIGHT(gparent, field);     \
409
5.18k
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
2.56k
        RB_COLOR(tmp, field) = RB_BLACK; \
411
2.56k
        RB_SET_BLACKRED(parent, gparent, field);\
412
2.56k
        elm = gparent;        \
413
2.56k
        continue;       \
414
2.56k
      }            \
415
5.18k
      if (RB_RIGHT(parent, field) == elm) {   \
416
306
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
306
        tmp = parent;       \
418
306
        parent = elm;       \
419
306
        elm = tmp;        \
420
306
      }            \
421
2.61k
      RB_SET_BLACKRED(parent, gparent, field); \
422
2.61k
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
19.8k
    } else {           \
424
19.8k
      tmp = RB_LEFT(gparent, field);     \
425
19.8k
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
9.29k
        RB_COLOR(tmp, field) = RB_BLACK; \
427
9.29k
        RB_SET_BLACKRED(parent, gparent, field);\
428
9.29k
        elm = gparent;        \
429
9.29k
        continue;       \
430
9.29k
      }            \
431
19.8k
      if (RB_LEFT(parent, field) == elm) {   \
432
233
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
233
        tmp = parent;       \
434
233
        parent = elm;       \
435
233
        elm = tmp;        \
436
233
      }            \
437
10.5k
      RB_SET_BLACKRED(parent, gparent, field); \
438
10.5k
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
10.5k
    }              \
440
25.0k
  }                \
441
59.7k
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
59.7k
}                  \
Unexecuted instantiation: arguments.c:args_tree_RB_INSERT_COLOR
Unexecuted instantiation: cmd-wait-for.c:wait_channels_RB_INSERT_COLOR
Unexecuted instantiation: control.c:control_panes_RB_INSERT_COLOR
Unexecuted instantiation: control.c:control_subs_RB_INSERT_COLOR
Unexecuted instantiation: control.c:control_sub_panes_RB_INSERT_COLOR
Unexecuted instantiation: control.c:control_sub_windows_RB_INSERT_COLOR
Unexecuted instantiation: environ.c:environ_RB_INSERT_COLOR
Unexecuted instantiation: client_files_RB_INSERT_COLOR
format.c:format_entry_tree_RB_INSERT_COLOR
Line
Count
Source
401
17.3k
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
17.3k
{                 \
403
17.3k
  struct type *parent, *gparent, *tmp;        \
404
18.1k
  while ((parent = RB_PARENT(elm, field)) &&      \
405
18.1k
      RB_COLOR(parent, field) == RB_RED) {     \
406
781
    gparent = RB_PARENT(parent, field);      \
407
781
    if (parent == RB_LEFT(gparent, field)) {   \
408
0
      tmp = RB_RIGHT(gparent, field);     \
409
0
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
0
        RB_COLOR(tmp, field) = RB_BLACK; \
411
0
        RB_SET_BLACKRED(parent, gparent, field);\
412
0
        elm = gparent;        \
413
0
        continue;       \
414
0
      }           \
415
0
      if (RB_RIGHT(parent, field) == elm) {   \
416
0
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
0
        tmp = parent;       \
418
0
        parent = elm;       \
419
0
        elm = tmp;        \
420
0
      }           \
421
0
      RB_SET_BLACKRED(parent, gparent, field); \
422
0
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
781
    } else {           \
424
781
      tmp = RB_LEFT(gparent, field);     \
425
781
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
0
        RB_COLOR(tmp, field) = RB_BLACK; \
427
0
        RB_SET_BLACKRED(parent, gparent, field);\
428
0
        elm = gparent;        \
429
0
        continue;       \
430
0
      }            \
431
781
      if (RB_LEFT(parent, field) == elm) {   \
432
0
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
0
        tmp = parent;       \
434
0
        parent = elm;       \
435
0
        elm = tmp;        \
436
0
      }            \
437
781
      RB_SET_BLACKRED(parent, gparent, field); \
438
781
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
781
    }             \
440
781
  }                \
441
17.3k
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
17.3k
}                  \
Unexecuted instantiation: format.c:format_job_tree_RB_INSERT_COLOR
hyperlinks.c:hyperlinks_by_uri_tree_RB_INSERT_COLOR
Line
Count
Source
401
6.54k
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
6.54k
{                 \
403
6.54k
  struct type *parent, *gparent, *tmp;        \
404
14.2k
  while ((parent = RB_PARENT(elm, field)) &&      \
405
14.2k
      RB_COLOR(parent, field) == RB_RED) {     \
406
7.69k
    gparent = RB_PARENT(parent, field);      \
407
7.69k
    if (parent == RB_LEFT(gparent, field)) {   \
408
1.21k
      tmp = RB_RIGHT(gparent, field);     \
409
1.21k
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
636
        RB_COLOR(tmp, field) = RB_BLACK; \
411
636
        RB_SET_BLACKRED(parent, gparent, field);\
412
636
        elm = gparent;        \
413
636
        continue;       \
414
636
      }            \
415
1.21k
      if (RB_RIGHT(parent, field) == elm) {   \
416
186
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
186
        tmp = parent;       \
418
186
        parent = elm;       \
419
186
        elm = tmp;        \
420
186
      }            \
421
582
      RB_SET_BLACKRED(parent, gparent, field); \
422
582
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
6.48k
    } else {           \
424
6.48k
      tmp = RB_LEFT(gparent, field);     \
425
6.48k
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
3.12k
        RB_COLOR(tmp, field) = RB_BLACK; \
427
3.12k
        RB_SET_BLACKRED(parent, gparent, field);\
428
3.12k
        elm = gparent;        \
429
3.12k
        continue;       \
430
3.12k
      }            \
431
6.48k
      if (RB_LEFT(parent, field) == elm) {   \
432
217
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
217
        tmp = parent;       \
434
217
        parent = elm;       \
435
217
        elm = tmp;        \
436
217
      }            \
437
3.35k
      RB_SET_BLACKRED(parent, gparent, field); \
438
3.35k
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
3.35k
    }              \
440
7.69k
  }                \
441
6.54k
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
6.54k
}                  \
hyperlinks.c:hyperlinks_by_inner_tree_RB_INSERT_COLOR
Line
Count
Source
401
6.54k
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
6.54k
{                 \
403
6.54k
  struct type *parent, *gparent, *tmp;        \
404
14.8k
  while ((parent = RB_PARENT(elm, field)) &&      \
405
14.8k
      RB_COLOR(parent, field) == RB_RED) {     \
406
8.35k
    gparent = RB_PARENT(parent, field);      \
407
8.35k
    if (parent == RB_LEFT(gparent, field)) {   \
408
0
      tmp = RB_RIGHT(gparent, field);     \
409
0
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
0
        RB_COLOR(tmp, field) = RB_BLACK; \
411
0
        RB_SET_BLACKRED(parent, gparent, field);\
412
0
        elm = gparent;        \
413
0
        continue;       \
414
0
      }           \
415
0
      if (RB_RIGHT(parent, field) == elm) {   \
416
0
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
0
        tmp = parent;       \
418
0
        parent = elm;       \
419
0
        elm = tmp;        \
420
0
      }           \
421
0
      RB_SET_BLACKRED(parent, gparent, field); \
422
0
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
8.35k
    } else {           \
424
8.35k
      tmp = RB_LEFT(gparent, field);     \
425
8.35k
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
4.00k
        RB_COLOR(tmp, field) = RB_BLACK; \
427
4.00k
        RB_SET_BLACKRED(parent, gparent, field);\
428
4.00k
        elm = gparent;        \
429
4.00k
        continue;       \
430
4.00k
      }            \
431
8.35k
      if (RB_LEFT(parent, field) == elm) {   \
432
0
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
0
        tmp = parent;       \
434
0
        parent = elm;       \
435
0
        elm = tmp;        \
436
0
      }            \
437
4.34k
      RB_SET_BLACKRED(parent, gparent, field); \
438
4.34k
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
4.34k
    }              \
440
8.35k
  }                \
441
6.54k
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
6.54k
}                  \
Unexecuted instantiation: input-keys.c:input_key_tree_RB_INSERT_COLOR
Unexecuted instantiation: key-bindings.c:key_tables_RB_INSERT_COLOR
Unexecuted instantiation: key-bindings.c:key_bindings_RB_INSERT_COLOR
options.c:options_tree_RB_INSERT_COLOR
Line
Count
Source
401
672
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
672
{                 \
403
672
  struct type *parent, *gparent, *tmp;        \
404
1.28k
  while ((parent = RB_PARENT(elm, field)) &&      \
405
1.28k
      RB_COLOR(parent, field) == RB_RED) {     \
406
612
    gparent = RB_PARENT(parent, field);      \
407
612
    if (parent == RB_LEFT(gparent, field)) {   \
408
108
      tmp = RB_RIGHT(gparent, field);     \
409
108
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
18
        RB_COLOR(tmp, field) = RB_BLACK; \
411
18
        RB_SET_BLACKRED(parent, gparent, field);\
412
18
        elm = gparent;        \
413
18
        continue;       \
414
18
      }            \
415
108
      if (RB_RIGHT(parent, field) == elm) {   \
416
84
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
84
        tmp = parent;       \
418
84
        parent = elm;       \
419
84
        elm = tmp;        \
420
84
      }            \
421
90
      RB_SET_BLACKRED(parent, gparent, field); \
422
90
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
504
    } else {           \
424
504
      tmp = RB_LEFT(gparent, field);     \
425
504
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
278
        RB_COLOR(tmp, field) = RB_BLACK; \
427
278
        RB_SET_BLACKRED(parent, gparent, field);\
428
278
        elm = gparent;        \
429
278
        continue;       \
430
278
      }            \
431
504
      if (RB_LEFT(parent, field) == elm) {   \
432
14
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
14
        tmp = parent;       \
434
14
        parent = elm;       \
435
14
        elm = tmp;        \
436
14
      }            \
437
226
      RB_SET_BLACKRED(parent, gparent, field); \
438
226
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
226
    }              \
440
612
  }                \
441
672
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
672
}                  \
options.c:options_array_RB_INSERT_COLOR
Line
Count
Source
401
44
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
44
{                 \
403
44
  struct type *parent, *gparent, *tmp;        \
404
72
  while ((parent = RB_PARENT(elm, field)) &&      \
405
72
      RB_COLOR(parent, field) == RB_RED) {     \
406
28
    gparent = RB_PARENT(parent, field);      \
407
28
    if (parent == RB_LEFT(gparent, field)) {   \
408
0
      tmp = RB_RIGHT(gparent, field);     \
409
0
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
0
        RB_COLOR(tmp, field) = RB_BLACK; \
411
0
        RB_SET_BLACKRED(parent, gparent, field);\
412
0
        elm = gparent;        \
413
0
        continue;       \
414
0
      }           \
415
0
      if (RB_RIGHT(parent, field) == elm) {   \
416
0
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
0
        tmp = parent;       \
418
0
        parent = elm;       \
419
0
        elm = tmp;        \
420
0
      }           \
421
0
      RB_SET_BLACKRED(parent, gparent, field); \
422
0
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
28
    } else {           \
424
28
      tmp = RB_LEFT(gparent, field);     \
425
28
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
10
        RB_COLOR(tmp, field) = RB_BLACK; \
427
10
        RB_SET_BLACKRED(parent, gparent, field);\
428
10
        elm = gparent;        \
429
10
        continue;       \
430
10
      }            \
431
28
      if (RB_LEFT(parent, field) == elm) {   \
432
0
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
0
        tmp = parent;       \
434
0
        parent = elm;       \
435
0
        elm = tmp;        \
436
0
      }            \
437
18
      RB_SET_BLACKRED(parent, gparent, field); \
438
18
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
18
    }              \
440
28
  }                \
441
44
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
44
}                  \
paste.c:paste_name_tree_RB_INSERT_COLOR
Line
Count
Source
401
2.18k
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
2.18k
{                 \
403
2.18k
  struct type *parent, *gparent, *tmp;        \
404
5.95k
  while ((parent = RB_PARENT(elm, field)) &&      \
405
5.95k
      RB_COLOR(parent, field) == RB_RED) {     \
406
3.76k
    gparent = RB_PARENT(parent, field);      \
407
3.76k
    if (parent == RB_LEFT(gparent, field)) {   \
408
37
      tmp = RB_RIGHT(gparent, field);     \
409
37
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
1
        RB_COLOR(tmp, field) = RB_BLACK; \
411
1
        RB_SET_BLACKRED(parent, gparent, field);\
412
1
        elm = gparent;        \
413
1
        continue;       \
414
1
      }            \
415
37
      if (RB_RIGHT(parent, field) == elm) {   \
416
36
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
36
        tmp = parent;       \
418
36
        parent = elm;       \
419
36
        elm = tmp;        \
420
36
      }           \
421
36
      RB_SET_BLACKRED(parent, gparent, field); \
422
36
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
3.72k
    } else {           \
424
3.72k
      tmp = RB_LEFT(gparent, field);     \
425
3.72k
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
1.87k
        RB_COLOR(tmp, field) = RB_BLACK; \
427
1.87k
        RB_SET_BLACKRED(parent, gparent, field);\
428
1.87k
        elm = gparent;        \
429
1.87k
        continue;       \
430
1.87k
      }            \
431
3.72k
      if (RB_LEFT(parent, field) == elm) {   \
432
2
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
2
        tmp = parent;       \
434
2
        parent = elm;       \
435
2
        elm = tmp;        \
436
2
      }            \
437
1.85k
      RB_SET_BLACKRED(parent, gparent, field); \
438
1.85k
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
1.85k
    }              \
440
3.76k
  }                \
441
2.18k
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
2.18k
}                  \
paste.c:paste_time_tree_RB_INSERT_COLOR
Line
Count
Source
401
2.18k
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
2.18k
{                 \
403
2.18k
  struct type *parent, *gparent, *tmp;        \
404
6.00k
  while ((parent = RB_PARENT(elm, field)) &&      \
405
6.00k
      RB_COLOR(parent, field) == RB_RED) {     \
406
3.82k
    gparent = RB_PARENT(parent, field);      \
407
3.82k
    if (parent == RB_LEFT(gparent, field)) {   \
408
3.82k
      tmp = RB_RIGHT(gparent, field);     \
409
3.82k
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
1.90k
        RB_COLOR(tmp, field) = RB_BLACK; \
411
1.90k
        RB_SET_BLACKRED(parent, gparent, field);\
412
1.90k
        elm = gparent;        \
413
1.90k
        continue;       \
414
1.90k
      }            \
415
3.82k
      if (RB_RIGHT(parent, field) == elm) {   \
416
0
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
0
        tmp = parent;       \
418
0
        parent = elm;       \
419
0
        elm = tmp;        \
420
0
      }            \
421
1.91k
      RB_SET_BLACKRED(parent, gparent, field); \
422
1.91k
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
1.91k
    } else {           \
424
0
      tmp = RB_LEFT(gparent, field);     \
425
0
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
0
        RB_COLOR(tmp, field) = RB_BLACK; \
427
0
        RB_SET_BLACKRED(parent, gparent, field);\
428
0
        elm = gparent;        \
429
0
        continue;       \
430
0
      }           \
431
0
      if (RB_LEFT(parent, field) == elm) {   \
432
0
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
0
        tmp = parent;       \
434
0
        parent = elm;       \
435
0
        elm = tmp;        \
436
0
      }           \
437
0
      RB_SET_BLACKRED(parent, gparent, field); \
438
0
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
0
    }              \
440
3.82k
  }                \
441
2.18k
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
2.18k
}                  \
Unexecuted instantiation: server-acl.c:server_acl_entries_RB_INSERT_COLOR
Unexecuted instantiation: client_windows_RB_INSERT_COLOR
Unexecuted instantiation: sessions_RB_INSERT_COLOR
Unexecuted instantiation: session_groups_RB_INSERT_COLOR
Unexecuted instantiation: utf8.c:utf8_width_cache_RB_INSERT_COLOR
Unexecuted instantiation: utf8.c:utf8_index_tree_RB_INSERT_COLOR
Unexecuted instantiation: utf8.c:utf8_data_tree_RB_INSERT_COLOR
windows_RB_INSERT_COLOR
Line
Count
Source
401
12.0k
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
12.0k
{                 \
403
12.0k
  struct type *parent, *gparent, *tmp;        \
404
12.0k
  while ((parent = RB_PARENT(elm, field)) &&      \
405
12.0k
      RB_COLOR(parent, field) == RB_RED) {     \
406
0
    gparent = RB_PARENT(parent, field);      \
407
0
    if (parent == RB_LEFT(gparent, field)) {   \
408
0
      tmp = RB_RIGHT(gparent, field);     \
409
0
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
0
        RB_COLOR(tmp, field) = RB_BLACK; \
411
0
        RB_SET_BLACKRED(parent, gparent, field);\
412
0
        elm = gparent;        \
413
0
        continue;       \
414
0
      }           \
415
0
      if (RB_RIGHT(parent, field) == elm) {   \
416
0
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
0
        tmp = parent;       \
418
0
        parent = elm;       \
419
0
        elm = tmp;        \
420
0
      }           \
421
0
      RB_SET_BLACKRED(parent, gparent, field); \
422
0
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
0
    } else {           \
424
0
      tmp = RB_LEFT(gparent, field);     \
425
0
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
0
        RB_COLOR(tmp, field) = RB_BLACK; \
427
0
        RB_SET_BLACKRED(parent, gparent, field);\
428
0
        elm = gparent;        \
429
0
        continue;       \
430
0
      }           \
431
0
      if (RB_LEFT(parent, field) == elm) {   \
432
0
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
0
        tmp = parent;       \
434
0
        parent = elm;       \
435
0
        elm = tmp;        \
436
0
      }           \
437
0
      RB_SET_BLACKRED(parent, gparent, field); \
438
0
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
0
    }             \
440
0
  }                \
441
12.0k
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
12.0k
}                  \
Unexecuted instantiation: winlinks_RB_INSERT_COLOR
window_pane_tree_RB_INSERT_COLOR
Line
Count
Source
401
12.0k
name##_RB_INSERT_COLOR(struct name *head, struct type *elm)   \
402
12.0k
{                 \
403
12.0k
  struct type *parent, *gparent, *tmp;        \
404
12.0k
  while ((parent = RB_PARENT(elm, field)) &&      \
405
12.0k
      RB_COLOR(parent, field) == RB_RED) {     \
406
0
    gparent = RB_PARENT(parent, field);      \
407
0
    if (parent == RB_LEFT(gparent, field)) {   \
408
0
      tmp = RB_RIGHT(gparent, field);     \
409
0
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
410
0
        RB_COLOR(tmp, field) = RB_BLACK; \
411
0
        RB_SET_BLACKRED(parent, gparent, field);\
412
0
        elm = gparent;        \
413
0
        continue;       \
414
0
      }           \
415
0
      if (RB_RIGHT(parent, field) == elm) {   \
416
0
        RB_ROTATE_LEFT(head, parent, tmp, field);\
417
0
        tmp = parent;       \
418
0
        parent = elm;       \
419
0
        elm = tmp;        \
420
0
      }           \
421
0
      RB_SET_BLACKRED(parent, gparent, field); \
422
0
      RB_ROTATE_RIGHT(head, gparent, tmp, field);  \
423
0
    } else {           \
424
0
      tmp = RB_LEFT(gparent, field);     \
425
0
      if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
426
0
        RB_COLOR(tmp, field) = RB_BLACK; \
427
0
        RB_SET_BLACKRED(parent, gparent, field);\
428
0
        elm = gparent;        \
429
0
        continue;       \
430
0
      }           \
431
0
      if (RB_LEFT(parent, field) == elm) {   \
432
0
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
433
0
        tmp = parent;       \
434
0
        parent = elm;       \
435
0
        elm = tmp;        \
436
0
      }           \
437
0
      RB_SET_BLACKRED(parent, gparent, field); \
438
0
      RB_ROTATE_LEFT(head, gparent, tmp, field);  \
439
0
    }             \
440
0
  }                \
441
12.0k
  RB_COLOR(head->rbh_root, field) = RB_BLACK;     \
442
12.0k
}                  \
443
                  \
444
attr void               \
445
57.9k
name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \
446
57.9k
{                 \
447
57.9k
  struct type *tmp;           \
448
69.4k
  while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) &&  \
449
69.4k
      elm != RB_ROOT(head)) {         \
450
13.5k
    if (RB_LEFT(parent, field) == elm) {     \
451
9.90k
      tmp = RB_RIGHT(parent, field);      \
452
9.90k
      if (RB_COLOR(tmp, field) == RB_RED) {   \
453
3.31k
        RB_SET_BLACKRED(tmp, parent, field); \
454
3.31k
        RB_ROTATE_LEFT(head, parent, tmp, field);\
455
3.31k
        tmp = RB_RIGHT(parent, field);    \
456
3.31k
      }            \
457
9.90k
      if ((RB_LEFT(tmp, field) == NULL ||   \
458
9.90k
          RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
459
9.90k
          (RB_RIGHT(tmp, field) == NULL ||   \
460
9.37k
          RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
461
8.50k
        RB_COLOR(tmp, field) = RB_RED;   \
462
8.50k
        elm = parent;       \
463
8.50k
        parent = RB_PARENT(elm, field);   \
464
8.50k
      } else {         \
465
1.40k
        if (RB_RIGHT(tmp, field) == NULL || \
466
1.40k
            RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\
467
89
          struct type *oleft;   \
468
89
          if ((oleft = RB_LEFT(tmp, field)))\
469
89
            RB_COLOR(oleft, field) = RB_BLACK;\
470
89
          RB_COLOR(tmp, field) = RB_RED; \
471
89
          RB_ROTATE_RIGHT(head, tmp, oleft, field);\
472
89
          tmp = RB_RIGHT(parent, field);  \
473
89
        }          \
474
1.40k
        RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
475
1.40k
        RB_COLOR(parent, field) = RB_BLACK; \
476
1.40k
        if (RB_RIGHT(tmp, field))   \
477
1.40k
          RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\
478
1.40k
        RB_ROTATE_LEFT(head, parent, tmp, field);\
479
1.40k
        elm = RB_ROOT(head);     \
480
1.40k
        break;          \
481
1.40k
      }            \
482
9.90k
    } else {           \
483
3.67k
      tmp = RB_LEFT(parent, field);      \
484
3.67k
      if (RB_COLOR(tmp, field) == RB_RED) {   \
485
1.09k
        RB_SET_BLACKRED(tmp, parent, field); \
486
1.09k
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
487
1.09k
        tmp = RB_LEFT(parent, field);    \
488
1.09k
      }            \
489
3.67k
      if ((RB_LEFT(tmp, field) == NULL ||   \
490
3.67k
          RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
491
3.67k
          (RB_RIGHT(tmp, field) == NULL ||   \
492
3.10k
          RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
493
2.97k
        RB_COLOR(tmp, field) = RB_RED;   \
494
2.97k
        elm = parent;       \
495
2.97k
        parent = RB_PARENT(elm, field);   \
496
2.97k
      } else {         \
497
696
        if (RB_LEFT(tmp, field) == NULL || \
498
696
            RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\
499
135
          struct type *oright;    \
500
135
          if ((oright = RB_RIGHT(tmp, field)))\
501
135
            RB_COLOR(oright, field) = RB_BLACK;\
502
135
          RB_COLOR(tmp, field) = RB_RED; \
503
135
          RB_ROTATE_LEFT(head, tmp, oright, field);\
504
135
          tmp = RB_LEFT(parent, field);  \
505
135
        }          \
506
696
        RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
507
696
        RB_COLOR(parent, field) = RB_BLACK; \
508
696
        if (RB_LEFT(tmp, field))   \
509
696
          RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\
510
696
        RB_ROTATE_RIGHT(head, parent, tmp, field);\
511
696
        elm = RB_ROOT(head);     \
512
696
        break;          \
513
696
      }            \
514
3.67k
    }              \
515
13.5k
  }                \
516
57.9k
  if (elm)             \
517
57.9k
    RB_COLOR(elm, field) = RB_BLACK;     \
518
57.9k
}                  \
Unexecuted instantiation: input-keys.c:input_key_tree_RB_REMOVE_COLOR
Unexecuted instantiation: utf8.c:utf8_data_tree_RB_REMOVE_COLOR
Unexecuted instantiation: utf8.c:utf8_index_tree_RB_REMOVE_COLOR
519
                  \
520
attr struct type *              \
521
59.1k
name##_RB_REMOVE(struct name *head, struct type *elm)     \
522
59.1k
{                 \
523
59.1k
  struct type *child, *parent, *old = elm;      \
524
59.1k
  int color;              \
525
59.1k
  if (RB_LEFT(elm, field) == NULL)       \
526
59.1k
    child = RB_RIGHT(elm, field);       \
527
59.1k
  else if (RB_RIGHT(elm, field) == NULL)       \
528
3.80k
    child = RB_LEFT(elm, field);       \
529
3.80k
  else {               \
530
2.07k
    struct type *left;          \
531
2.07k
    elm = RB_RIGHT(elm, field);       \
532
3.43k
    while ((left = RB_LEFT(elm, field)))     \
533
2.07k
      elm = left;         \
534
2.07k
    child = RB_RIGHT(elm, field);       \
535
2.07k
    parent = RB_PARENT(elm, field);       \
536
2.07k
    color = RB_COLOR(elm, field);       \
537
2.07k
    if (child)           \
538
2.07k
      RB_PARENT(child, field) = parent;   \
539
2.07k
    if (parent) {           \
540
2.07k
      if (RB_LEFT(parent, field) == elm)   \
541
2.07k
        RB_LEFT(parent, field) = child;   \
542
2.07k
      else            \
543
2.07k
        RB_RIGHT(parent, field) = child; \
544
2.07k
      RB_AUGMENT(parent);       \
545
2.07k
    } else              \
546
2.07k
      RB_ROOT(head) = child;       \
547
2.07k
    if (RB_PARENT(elm, field) == old)     \
548
2.07k
      parent = elm;         \
549
2.07k
    (elm)->field = (old)->field;        \
550
2.07k
    if (RB_PARENT(old, field)) {       \
551
1.38k
      if (RB_LEFT(RB_PARENT(old, field), field) == old)\
552
1.38k
        RB_LEFT(RB_PARENT(old, field), field) = elm;\
553
1.38k
      else            \
554
1.38k
        RB_RIGHT(RB_PARENT(old, field), field) = elm;\
555
1.38k
      RB_AUGMENT(RB_PARENT(old, field));    \
556
1.38k
    } else             \
557
2.07k
      RB_ROOT(head) = elm;       \
558
2.07k
    RB_PARENT(RB_LEFT(old, field), field) = elm;   \
559
2.07k
    if (RB_RIGHT(old, field))       \
560
2.07k
      RB_PARENT(RB_RIGHT(old, field), field) = elm; \
561
2.07k
    if (parent) {           \
562
2.07k
      left = parent;          \
563
5.84k
      do {           \
564
5.84k
        RB_AUGMENT(left);     \
565
5.84k
      } while ((left = RB_PARENT(left, field)));  \
566
2.07k
    }             \
567
2.07k
    goto color;           \
568
2.07k
  }                \
569
59.1k
  parent = RB_PARENT(elm, field);         \
570
57.0k
  color = RB_COLOR(elm, field);         \
571
57.0k
  if (child)             \
572
57.0k
    RB_PARENT(child, field) = parent;     \
573
57.0k
  if (parent) {             \
574
13.8k
    if (RB_LEFT(parent, field) == elm)     \
575
13.8k
      RB_LEFT(parent, field) = child;     \
576
13.8k
    else              \
577
13.8k
      RB_RIGHT(parent, field) = child;   \
578
13.8k
    RB_AUGMENT(parent);         \
579
13.8k
  } else               \
580
59.1k
    RB_ROOT(head) = child;         \
581
59.1k
color:                  \
582
59.1k
  if (color == RB_BLACK)           \
583
59.1k
    name##_RB_REMOVE_COLOR(head, parent, child);   \
584
59.1k
  return (old);             \
585
57.0k
}                  \
Unexecuted instantiation: input-keys.c:input_key_tree_RB_REMOVE
Unexecuted instantiation: utf8.c:utf8_data_tree_RB_REMOVE
Unexecuted instantiation: utf8.c:utf8_index_tree_RB_REMOVE
586
                  \
587
/* Inserts a node into the RB tree */         \
588
attr struct type *              \
589
59.7k
name##_RB_INSERT(struct name *head, struct type *elm)     \
590
59.7k
{                 \
591
59.7k
  struct type *tmp;           \
592
59.7k
  struct type *parent = NULL;         \
593
59.7k
  int comp = 0;             \
594
59.7k
  tmp = RB_ROOT(head);           \
595
167k
  while (tmp) {             \
596
108k
    parent = tmp;           \
597
108k
    comp = (cmp)(elm, parent);        \
598
108k
    if (comp < 0)           \
599
108k
      tmp = RB_LEFT(tmp, field);     \
600
108k
    else if (comp > 0)         \
601
83.6k
      tmp = RB_RIGHT(tmp, field);     \
602
83.6k
    else              \
603
83.6k
      return (tmp);         \
604
108k
  }                \
605
59.7k
  RB_SET(elm, parent, field);         \
606
59.7k
  if (parent != NULL) {           \
607
23.5k
    if (comp < 0)           \
608
23.5k
      RB_LEFT(parent, field) = elm;     \
609
23.5k
    else              \
610
23.5k
      RB_RIGHT(parent, field) = elm;     \
611
23.5k
    RB_AUGMENT(parent);         \
612
23.5k
  } else               \
613
59.7k
    RB_ROOT(head) = elm;         \
614
59.7k
  name##_RB_INSERT_COLOR(head, elm);        \
615
59.7k
  return (NULL);              \
616
59.7k
}                  \
617
                  \
618
/* Finds the node with the same key as elm */       \
619
attr struct type *              \
620
600k
name##_RB_FIND(struct name *head, struct type *elm)     \
621
600k
{                 \
622
600k
  struct type *tmp = RB_ROOT(head);       \
623
600k
  int comp;             \
624
1.32M
  while (tmp) {             \
625
896k
    comp = cmp(elm, tmp);         \
626
896k
    if (comp < 0)           \
627
896k
      tmp = RB_LEFT(tmp, field);     \
628
896k
    else if (comp > 0)         \
629
603k
      tmp = RB_RIGHT(tmp, field);     \
630
603k
    else              \
631
603k
      return (tmp);         \
632
896k
  }                \
633
600k
  return (NULL);             \
634
600k
}                  \
635
                  \
636
/* Finds the first node greater than or equal to the search key */  \
637
attr struct type *              \
638
0
name##_RB_NFIND(struct name *head, struct type *elm)      \
639
0
{                 \
640
0
  struct type *tmp = RB_ROOT(head);       \
641
0
  struct type *res = NULL;          \
642
0
  int comp;             \
643
0
  while (tmp) {             \
644
0
    comp = cmp(elm, tmp);         \
645
0
    if (comp < 0) {           \
646
0
      res = tmp;          \
647
0
      tmp = RB_LEFT(tmp, field);     \
648
0
    }             \
649
0
    else if (comp > 0)         \
650
0
      tmp = RB_RIGHT(tmp, field);     \
651
0
    else              \
652
0
      return (tmp);         \
653
0
  }               \
654
0
  return (res);             \
655
0
}                  \
Unexecuted instantiation: arguments.c:args_tree_RB_NFIND
Unexecuted instantiation: cmd-wait-for.c:wait_channels_RB_NFIND
Unexecuted instantiation: control.c:control_panes_RB_NFIND
Unexecuted instantiation: control.c:control_subs_RB_NFIND
Unexecuted instantiation: control.c:control_sub_panes_RB_NFIND
Unexecuted instantiation: control.c:control_sub_windows_RB_NFIND
Unexecuted instantiation: environ.c:environ_RB_NFIND
Unexecuted instantiation: format.c:format_job_tree_RB_NFIND
Unexecuted instantiation: format.c:format_entry_tree_RB_NFIND
Unexecuted instantiation: hyperlinks.c:hyperlinks_by_uri_tree_RB_NFIND
Unexecuted instantiation: hyperlinks.c:hyperlinks_by_inner_tree_RB_NFIND
Unexecuted instantiation: input-keys.c:input_key_tree_RB_NFIND
Unexecuted instantiation: key-bindings.c:key_bindings_RB_NFIND
Unexecuted instantiation: key-bindings.c:key_tables_RB_NFIND
Unexecuted instantiation: options.c:options_array_RB_NFIND
Unexecuted instantiation: options.c:options_tree_RB_NFIND
Unexecuted instantiation: paste.c:paste_name_tree_RB_NFIND
Unexecuted instantiation: paste.c:paste_time_tree_RB_NFIND
Unexecuted instantiation: server-acl.c:server_acl_entries_RB_NFIND
Unexecuted instantiation: utf8.c:utf8_width_cache_RB_NFIND
Unexecuted instantiation: utf8.c:utf8_data_tree_RB_NFIND
Unexecuted instantiation: utf8.c:utf8_index_tree_RB_NFIND
656
                  \
657
/* ARGSUSED */                \
658
attr struct type *              \
659
41.4k
name##_RB_NEXT(struct type *elm)          \
660
41.4k
{                 \
661
41.4k
  if (RB_RIGHT(elm, field)) {         \
662
15.2k
    elm = RB_RIGHT(elm, field);       \
663
15.2k
    while (RB_LEFT(elm, field))       \
664
15.2k
      elm = RB_LEFT(elm, field);     \
665
26.1k
  } else {             \
666
26.1k
    if (RB_PARENT(elm, field) &&       \
667
26.1k
        (elm == RB_LEFT(RB_PARENT(elm, field), field))) \
668
26.1k
      elm = RB_PARENT(elm, field);     \
669
26.1k
    else {             \
670
27.8k
      while (RB_PARENT(elm, field) &&     \
671
27.8k
          (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
672
21.7k
        elm = RB_PARENT(elm, field);   \
673
21.7k
      elm = RB_PARENT(elm, field);     \
674
21.7k
    }              \
675
26.1k
  }                \
676
41.4k
  return (elm);             \
677
41.4k
}                  \
Unexecuted instantiation: arguments.c:args_tree_RB_NEXT
Unexecuted instantiation: cmd-wait-for.c:wait_channels_RB_NEXT
Unexecuted instantiation: control.c:control_panes_RB_NEXT
Unexecuted instantiation: control.c:control_subs_RB_NEXT
Unexecuted instantiation: control.c:control_sub_panes_RB_NEXT
Unexecuted instantiation: control.c:control_sub_windows_RB_NEXT
Unexecuted instantiation: environ.c:environ_RB_NEXT
Unexecuted instantiation: client_files_RB_NEXT
Unexecuted instantiation: format.c:format_job_tree_RB_NEXT
format.c:format_entry_tree_RB_NEXT
Line
Count
Source
659
34.7k
name##_RB_NEXT(struct type *elm)          \
660
34.7k
{                 \
661
34.7k
  if (RB_RIGHT(elm, field)) {         \
662
12.2k
    elm = RB_RIGHT(elm, field);       \
663
12.2k
    while (RB_LEFT(elm, field))       \
664
12.2k
      elm = RB_LEFT(elm, field);     \
665
22.4k
  } else {             \
666
22.4k
    if (RB_PARENT(elm, field) &&       \
667
22.4k
        (elm == RB_LEFT(RB_PARENT(elm, field), field))) \
668
22.4k
      elm = RB_PARENT(elm, field);     \
669
22.4k
    else {             \
670
27.0k
      while (RB_PARENT(elm, field) &&     \
671
27.0k
          (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
672
20.9k
        elm = RB_PARENT(elm, field);   \
673
20.9k
      elm = RB_PARENT(elm, field);     \
674
20.9k
    }              \
675
22.4k
  }                \
676
34.7k
  return (elm);             \
677
34.7k
}                  \
hyperlinks.c:hyperlinks_by_inner_tree_RB_NEXT
Line
Count
Source
659
6.54k
name##_RB_NEXT(struct type *elm)          \
660
6.54k
{                 \
661
6.54k
  if (RB_RIGHT(elm, field)) {         \
662
3.00k
    elm = RB_RIGHT(elm, field);       \
663
3.00k
    while (RB_LEFT(elm, field))       \
664
3.00k
      elm = RB_LEFT(elm, field);     \
665
3.54k
  } else {             \
666
3.54k
    if (RB_PARENT(elm, field) &&       \
667
3.54k
        (elm == RB_LEFT(RB_PARENT(elm, field), field))) \
668
3.54k
      elm = RB_PARENT(elm, field);     \
669
3.54k
    else {             \
670
649
      while (RB_PARENT(elm, field) &&     \
671
649
          (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
672
649
        elm = RB_PARENT(elm, field);   \
673
649
      elm = RB_PARENT(elm, field);     \
674
649
    }              \
675
3.54k
  }                \
676
6.54k
  return (elm);             \
677
6.54k
}                  \
Unexecuted instantiation: hyperlinks.c:hyperlinks_by_uri_tree_RB_NEXT
Unexecuted instantiation: input-keys.c:input_key_tree_RB_NEXT
Unexecuted instantiation: key-bindings.c:key_tables_RB_NEXT
Unexecuted instantiation: key-bindings.c:key_bindings_RB_NEXT
options.c:options_tree_RB_NEXT
Line
Count
Source
659
167
name##_RB_NEXT(struct type *elm)          \
660
167
{                 \
661
167
  if (RB_RIGHT(elm, field)) {         \
662
0
    elm = RB_RIGHT(elm, field);       \
663
0
    while (RB_LEFT(elm, field))       \
664
0
      elm = RB_LEFT(elm, field);     \
665
167
  } else {             \
666
167
    if (RB_PARENT(elm, field) &&       \
667
167
        (elm == RB_LEFT(RB_PARENT(elm, field), field))) \
668
167
      elm = RB_PARENT(elm, field);     \
669
167
    else {             \
670
167
      while (RB_PARENT(elm, field) &&     \
671
167
          (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
672
167
        elm = RB_PARENT(elm, field);   \
673
167
      elm = RB_PARENT(elm, field);     \
674
167
    }             \
675
167
  }               \
676
167
  return (elm);             \
677
167
}                  \
options.c:options_array_RB_NEXT
Line
Count
Source
659
12
name##_RB_NEXT(struct type *elm)          \
660
12
{                 \
661
12
  if (RB_RIGHT(elm, field)) {         \
662
6
    elm = RB_RIGHT(elm, field);       \
663
8
    while (RB_LEFT(elm, field))       \
664
6
      elm = RB_LEFT(elm, field);     \
665
6
  } else {             \
666
6
    if (RB_PARENT(elm, field) &&       \
667
6
        (elm == RB_LEFT(RB_PARENT(elm, field), field)))  \
668
6
      elm = RB_PARENT(elm, field);     \
669
6
    else {             \
670
8
      while (RB_PARENT(elm, field) &&     \
671
8
          (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
672
6
        elm = RB_PARENT(elm, field);   \
673
2
      elm = RB_PARENT(elm, field);     \
674
2
    }              \
675
6
  }                \
676
12
  return (elm);             \
677
12
}                  \
Unexecuted instantiation: paste.c:paste_time_tree_RB_NEXT
Unexecuted instantiation: paste.c:paste_name_tree_RB_NEXT
Unexecuted instantiation: server-acl.c:server_acl_entries_RB_NEXT
Unexecuted instantiation: client_windows_RB_NEXT
Unexecuted instantiation: sessions_RB_NEXT
Unexecuted instantiation: session_groups_RB_NEXT
Unexecuted instantiation: utf8.c:utf8_width_cache_RB_NEXT
Unexecuted instantiation: utf8.c:utf8_data_tree_RB_NEXT
Unexecuted instantiation: utf8.c:utf8_index_tree_RB_NEXT
Unexecuted instantiation: windows_RB_NEXT
Unexecuted instantiation: winlinks_RB_NEXT
Unexecuted instantiation: window_pane_tree_RB_NEXT
678
                  \
679
/* ARGSUSED */                \
680
attr struct type *              \
681
4.32k
name##_RB_PREV(struct type *elm)          \
682
4.32k
{                 \
683
4.32k
  if (RB_LEFT(elm, field)) {         \
684
2.13k
    elm = RB_LEFT(elm, field);       \
685
2.13k
    while (RB_RIGHT(elm, field))       \
686
2.13k
      elm = RB_RIGHT(elm, field);     \
687
2.18k
  } else {             \
688
2.18k
    if (RB_PARENT(elm, field) &&       \
689
2.18k
        (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
690
2.18k
      elm = RB_PARENT(elm, field);     \
691
2.18k
    else {             \
692
1
      while (RB_PARENT(elm, field) &&     \
693
1
          (elm == RB_LEFT(RB_PARENT(elm, field), field)))\
694
1
        elm = RB_PARENT(elm, field);   \
695
1
      elm = RB_PARENT(elm, field);     \
696
1
    }              \
697
2.18k
  }                \
698
4.32k
  return (elm);             \
699
4.32k
}                  \
Unexecuted instantiation: arguments.c:args_tree_RB_PREV
Unexecuted instantiation: cmd-wait-for.c:wait_channels_RB_PREV
Unexecuted instantiation: control.c:control_panes_RB_PREV
Unexecuted instantiation: control.c:control_subs_RB_PREV
Unexecuted instantiation: control.c:control_sub_panes_RB_PREV
Unexecuted instantiation: control.c:control_sub_windows_RB_PREV
Unexecuted instantiation: environ.c:environ_RB_PREV
Unexecuted instantiation: client_files_RB_PREV
Unexecuted instantiation: format.c:format_job_tree_RB_PREV
Unexecuted instantiation: format.c:format_entry_tree_RB_PREV
Unexecuted instantiation: hyperlinks.c:hyperlinks_by_uri_tree_RB_PREV
Unexecuted instantiation: hyperlinks.c:hyperlinks_by_inner_tree_RB_PREV
Unexecuted instantiation: input-keys.c:input_key_tree_RB_PREV
Unexecuted instantiation: key-bindings.c:key_bindings_RB_PREV
Unexecuted instantiation: key-bindings.c:key_tables_RB_PREV
Unexecuted instantiation: options.c:options_array_RB_PREV
Unexecuted instantiation: options.c:options_tree_RB_PREV
paste.c:paste_time_tree_RB_PREV
Line
Count
Source
681
4.32k
name##_RB_PREV(struct type *elm)          \
682
4.32k
{                 \
683
4.32k
  if (RB_LEFT(elm, field)) {         \
684
2.13k
    elm = RB_LEFT(elm, field);       \
685
2.13k
    while (RB_RIGHT(elm, field))       \
686
2.13k
      elm = RB_RIGHT(elm, field);     \
687
2.18k
  } else {             \
688
2.18k
    if (RB_PARENT(elm, field) &&       \
689
2.18k
        (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
690
2.18k
      elm = RB_PARENT(elm, field);     \
691
2.18k
    else {             \
692
1
      while (RB_PARENT(elm, field) &&     \
693
1
          (elm == RB_LEFT(RB_PARENT(elm, field), field)))\
694
1
        elm = RB_PARENT(elm, field);   \
695
1
      elm = RB_PARENT(elm, field);     \
696
1
    }              \
697
2.18k
  }                \
698
4.32k
  return (elm);             \
699
4.32k
}                  \
Unexecuted instantiation: paste.c:paste_name_tree_RB_PREV
Unexecuted instantiation: server-acl.c:server_acl_entries_RB_PREV
Unexecuted instantiation: client_windows_RB_PREV
Unexecuted instantiation: sessions_RB_PREV
Unexecuted instantiation: session_groups_RB_PREV
Unexecuted instantiation: utf8.c:utf8_width_cache_RB_PREV
Unexecuted instantiation: utf8.c:utf8_data_tree_RB_PREV
Unexecuted instantiation: utf8.c:utf8_index_tree_RB_PREV
Unexecuted instantiation: windows_RB_PREV
Unexecuted instantiation: winlinks_RB_PREV
Unexecuted instantiation: window_pane_tree_RB_PREV
700
                  \
701
attr struct type *              \
702
123k
name##_RB_MINMAX(struct name *head, int val)        \
703
123k
{                 \
704
123k
  struct type *tmp = RB_ROOT(head);       \
705
123k
  struct type *parent = NULL;         \
706
182k
  while (tmp) {             \
707
58.8k
    parent = tmp;           \
708
58.8k
    if (val < 0)           \
709
58.8k
      tmp = RB_LEFT(tmp, field);     \
710
58.8k
    else              \
711
58.8k
      tmp = RB_RIGHT(tmp, field);     \
712
58.8k
  }                \
713
123k
  return (parent);            \
714
123k
}
Unexecuted instantiation: hyperlinks.c:hyperlinks_by_uri_tree_RB_MINMAX
Unexecuted instantiation: paste.c:paste_name_tree_RB_MINMAX
Unexecuted instantiation: utf8.c:utf8_data_tree_RB_MINMAX
Unexecuted instantiation: utf8.c:utf8_index_tree_RB_MINMAX
715
716
121k
#define RB_NEGINF -1
717
2.18k
#define RB_INF  1
718
719
59.7k
#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y)
720
59.1k
#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
721
600k
#define RB_FIND(name, x, y) name##_RB_FIND(x, y)
722
#define RB_NFIND(name, x, y)  name##_RB_NFIND(x, y)
723
12
#define RB_NEXT(name, x, y) name##_RB_NEXT(y)
724
0
#define RB_PREV(name, x, y) name##_RB_PREV(y)
725
121k
#define RB_MIN(name, x)   name##_RB_MINMAX(x, RB_NEGINF)
726
2.18k
#define RB_MAX(name, x)   name##_RB_MINMAX(x, RB_INF)
727
728
#define RB_FOREACH(x, name, head)         \
729
42.1k
  for ((x) = RB_MIN(name, head);         \
730
59.5k
       (x) != NULL;           \
731
42.1k
       (x) = name##_RB_NEXT(x))
732
733
#define RB_FOREACH_SAFE(x, name, head, y)       \
734
62.9k
  for ((x) = RB_MIN(name, head);         \
735
87.0k
      ((x) != NULL) && ((y) = name##_RB_NEXT(x), 1);   \
736
62.9k
       (x) = (y))
737
738
#define RB_FOREACH_REVERSE(x, name, head)       \
739
  for ((x) = RB_MAX(name, head);          \
740
       (x) != NULL;           \
741
       (x) = name##_RB_PREV(x))
742
743
#define RB_FOREACH_REVERSE_SAFE(x, name, head, y)     \
744
2.18k
  for ((x) = RB_MAX(name, head);         \
745
4.32k
      ((x) != NULL) && ((y) = name##_RB_PREV(x), 1);   \
746
2.18k
       (x) = (y))
747
748
#endif  /* _SYS_TREE_H_ */