mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 10:36:02 +00:00
AK: Modify IntrusiveRedBlackTree for Windows
IntrusiveRedBlackTree relies on a member pointer for accessing the value of a node. On windows member pointers can be of variable length, depending on the inheritance structure of the class. This commit casts the 4 byte member pointer, or rather offset to a full pointer type, so that the bit_cast to u8* works, as previously the source was smaller than the destination, which fails inside __builtin_bit_cast().
This commit is contained in:
parent
e879fd29b3
commit
5226a566e9
Notes:
github-actions[bot]
2025-04-02 16:23:10 +00:00
Author: https://github.com/R-Goc
Commit: 5226a566e9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3602
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/gmta
1 changed files with 7 additions and 0 deletions
|
@ -174,7 +174,14 @@ private:
|
||||||
|
|
||||||
static V* node_to_value(TreeNode& node)
|
static V* node_to_value(TreeNode& node)
|
||||||
{
|
{
|
||||||
|
#ifdef AK_OS_WINDOWS
|
||||||
|
// NOTE: https://learn.microsoft.com/en-us/cpp/build/reference/vmb-vmg-representation-method?view=msvc-170
|
||||||
|
static_assert(sizeof(member) == 4);
|
||||||
|
auto distance = bit_cast<u8*>(static_cast<FlatPtr>(bit_cast<u32>(member)));
|
||||||
|
return bit_cast<V*>(bit_cast<u8*>(&node) - distance);
|
||||||
|
#else
|
||||||
return bit_cast<V*>(bit_cast<u8*>(&node) - bit_cast<u8*>(member));
|
return bit_cast<V*>(bit_cast<u8*>(&node) - bit_cast<u8*>(member));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue