| 1 |
/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */ |
| 2 |
|
| 3 |
struct w |
| 4 |
{ |
| 5 |
int top; |
| 6 |
int left; |
| 7 |
int height; |
| 8 |
int width; |
| 9 |
struct w *next; |
| 10 |
struct w *parent; |
| 11 |
struct w *child; |
| 12 |
}; |
| 13 |
|
| 14 |
extern struct w *Qnil; |
| 15 |
|
| 16 |
void use (struct w *); |
| 17 |
|
| 18 |
void |
| 19 |
set_size (struct w *w, int new_size, int nodelete, int set_height) |
| 20 |
{ |
| 21 |
int old_size = set_height? w->height : w->width; |
| 22 |
|
| 23 |
if (nodelete || w->parent == Qnil) |
| 24 |
{ |
| 25 |
int last_pos, last_old_pos, pos, old_pos, first; |
| 26 |
int div_val = old_size << 1; |
| 27 |
struct w *c; |
| 28 |
|
| 29 |
last_pos = first = set_height? w->top : w->left; |
| 30 |
last_old_pos = 0; |
| 31 |
|
| 32 |
for (c = w->child; c != Qnil; c = c->next) |
| 33 |
{ |
| 34 |
if (set_height) |
| 35 |
old_pos = last_old_pos + c->height; |
| 36 |
else |
| 37 |
old_pos = last_old_pos + c->width; |
| 38 |
|
| 39 |
pos = (((old_pos * new_size) << 1) + old_size) / div_val; |
| 40 |
set_size (c, pos + first - last_pos, 1, set_height); |
| 41 |
last_pos = pos + first; |
| 42 |
last_old_pos = old_pos; |
| 43 |
} |
| 44 |
|
| 45 |
if (!nodelete) |
| 46 |
for (c = w->child; c != Qnil; c = c->next) |
| 47 |
use (c); |
| 48 |
} |
| 49 |
} |
| 50 |
|