sdk-core
v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Toggle main menu visibility
Loading...
Searching...
No Matches
byteorder.h
Go to the documentation of this file.
1
/*
2
# _____ ___ ____ ___ ____
3
# ____| | ____| | | |____|
4
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5
#-----------------------------------------------------------------------
6
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7
# Licenced under Academic Free License version 2.0
8
# Review ps2sdk README & LICENSE files for further details.
9
*/
10
16
17
#ifndef BYTEORDER_H
18
#define BYTEORDER_H
19
20
#include <stdint.h>
21
22
#ifdef BIG_ENDIAN
23
inline
uint64_t ntohll(x) {
return
x; }
24
inline
uint32_t ntohl(x) {
return
x; }
25
inline
uint16_t ntohs(x) {
return
x; }
26
#else
27
// LITTLE_ENDIAN
28
#ifndef htonll
29
inline
uint64_t
30
htonll(uint64_t x)
31
{
32
return
((x & 0x00000000000000ffull) << 56) |
33
((x & 0x000000000000ff00ull) << 40) |
34
((x & 0x0000000000ff0000ull) << 24) |
35
((x & 0x00000000ff000000ull) << 8) |
36
((x & 0x000000ff00000000ull) >> 8) |
37
((x & 0x0000ff0000000000ull) >> 24) |
38
((x & 0x00ff000000000000ull) >> 40) |
39
((x & 0xff00000000000000ull) >> 56);
40
}
41
#endif
42
43
#ifndef htonl
44
inline
uint32_t
45
htonl(uint32_t x)
46
{
47
return
((x & 0x000000ff) << 24) |
48
((x & 0x0000ff00) << 8) |
49
((x & 0x00ff0000) >> 8) |
50
((x & 0xff000000) >> 24);
51
}
52
#endif
53
54
#ifndef htons
55
inline
uint16_t
56
htons(uint16_t x)
57
{
58
return
((x & 0x00ff) << 8) |
59
((x & 0xff00) >> 8);
60
}
61
#endif
62
63
#endif
64
65
#endif
/* BYTEORDER_H */
core
netfs
src
byteorder.h
Generated by
1.18.0