mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:07:35 +00:00
LibC: Make <netinet/in.h> more POSIX compliant
1. Move htonl() etc. from <arpa/inet.h> to <netinet/in.h> (which <arpa/inet.h> includes). The htonl(), htons(), ntohl(), and ntohs() functions shall be available as described in <arpa/inet.h>. Inclusion of the <netinet/in.h> header may also make visible all symbols from <arpa/inet.h>. - POSIX 2. Define IN6_IS_ADDR_LOOPBACK() and IN6_IS_ADDR_V4MAPPED()
This commit is contained in:
parent
f16aba405f
commit
db92e66902
2 changed files with 35 additions and 29 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <endian.h>
|
||||
#include <inttypes.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
@ -27,32 +26,4 @@ static inline int inet_aton(const char* cp, struct in_addr* inp)
|
|||
|
||||
char* inet_ntoa(struct in_addr);
|
||||
|
||||
static inline uint16_t htons(uint16_t value)
|
||||
{
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
return __builtin_bswap16(value);
|
||||
#else
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint16_t ntohs(uint16_t value)
|
||||
{
|
||||
return htons(value);
|
||||
}
|
||||
|
||||
static inline uint32_t htonl(uint32_t value)
|
||||
{
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
return __builtin_bswap32(value);
|
||||
#else
|
||||
return value;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t ntohl(uint32_t value)
|
||||
{
|
||||
return htonl(value);
|
||||
}
|
||||
|
||||
__END_DECLS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue