mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibC: Add htonl() and ntohl().
This commit is contained in:
parent
02033873b7
commit
3c7b46a85a
Notes:
sideshowbarker
2024-07-19 13:59:52 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3c7b46a85ae
1 changed files with 11 additions and 0 deletions
|
@ -21,5 +21,16 @@ static inline uint16_t ntohs(uint16_t ns)
|
|||
return htons(ns);
|
||||
}
|
||||
|
||||
static inline uint32_t htonl(uint32_t hs)
|
||||
{
|
||||
uint8_t* s = (uint8_t*)&hs;
|
||||
return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
|
||||
}
|
||||
|
||||
static inline uint32_t ntohl(uint32_t ns)
|
||||
{
|
||||
return htonl(ns);
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue