AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
byteorder.h
Go to the documentation of this file.
1
#ifndef _NET_BYTEORDER_H
2
#define _NET_BYTEORDER_H
3
4
#include <
core/system.h
>
5
6
/* Converts between the network's byte order (big-endian) and the CPU's.
7
* Every CPU that AquilaOS runs on (x86, aarch64) is little-endian, where
8
* they swap the bytes; on a big-endian one they would do nothing. */
9
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
10
#define htons(x) ((uint16_t) (x))
11
#define htonl(x) ((uint32_t) (x))
12
#else
13
#define htons(x) ((uint16_t) __builtin_bswap16((uint16_t) (x)))
14
#define htonl(x) ((uint32_t) __builtin_bswap32((uint32_t) (x)))
15
#endif
16
17
#define ntohs(x) htons(x)
18
#define ntohl(x) htonl(x)
19
20
#endif
/* ! _NET_BYTEORDER_H */
system.h
kernel
include
net
byteorder.h
Generated by
1.18.0