2 /* { dg-options "-std=gnu99 -Wall -Wextra -O1" } */
4 extern void *memset (void*, int, unsigned long);
5 extern void abort (void);
7 struct radix_tree_root
{
9 struct radix_tree_node
*rnode
;
12 struct radix_tree_node
{
15 unsigned long tags
[2][2];
18 struct radix_tree_path
{
19 struct radix_tree_node
*node
, **slot
;
23 static unsigned long height_to_maxindex
[7] =
24 {0, 63, 4095, 262143, 16777215, 1073741823, 4294967295};
26 static inline void tag_clear(struct radix_tree_node
*node
, int tag
, int offset
)
29 volatile unsigned long *addr
;
33 addr
= &node
->tags
[tag
][0];
36 mask
= 1 << (nr
& 0x1f);
40 void *radix_tree_tag_clear(struct radix_tree_root
*root
, unsigned long index
, int tag
)
42 struct radix_tree_path path
[7], *pathp
= path
;
43 unsigned int height
, shift
;
46 height
= root
->height
;
47 if (index
> height_to_maxindex
[height
])
50 shift
= (height
- 1) * 6;
52 pathp
->slot
= &root
->rnode
;
57 if (*pathp
->slot
== 0)
60 offset
= (index
>> shift
) & (64-1);
61 pathp
[1].offset
= offset
;
62 pathp
[1].node
= *pathp
[0].slot
;
63 pathp
[1].slot
= (struct radix_tree_node
**)
64 (pathp
[1].node
->slots
+ offset
);
77 tag_clear(pathp
[0].node
, tag
, pathp
[0].offset
);
78 for (idx
= 0; idx
< 2; idx
++) {
79 if (pathp
[0].node
->tags
[tag
][idx
])
83 } while (pathp
[0].node
);
90 struct radix_tree_root r
;
91 struct radix_tree_node node
;
92 void *p
= (void *) 0xdeadbeef;
97 memset (&node
, 0, sizeof (node
));
102 radix_tree_tag_clear (&r
, 13, 1);
104 if (r
.rnode
->slots
[13] != p
)