Coverage Report

Created: 2026-06-10 06:26

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/muduo/muduo/net/Endian.h
Line
Count
Source
1
// Copyright 2010, Shuo Chen.  All rights reserved.
2
// http://code.google.com/p/muduo/
3
//
4
// Use of this source code is governed by a BSD-style license
5
// that can be found in the License file.
6
7
// Author: Shuo Chen (chenshuo at chenshuo dot com)
8
//
9
// This is a public header file, it must only include public header files.
10
11
#ifndef MUDUO_NET_ENDIAN_H
12
#define MUDUO_NET_ENDIAN_H
13
14
#include <stdint.h>
15
#include <endian.h>
16
17
namespace muduo
18
{
19
namespace net
20
{
21
namespace sockets
22
{
23
24
// the inline assembler code makes type blur,
25
// so we disable warnings for a while.
26
#pragma GCC diagnostic push
27
#pragma GCC diagnostic ignored "-Wconversion"
28
#pragma GCC diagnostic ignored "-Wold-style-cast"
29
inline uint64_t hostToNetwork64(uint64_t host64)
30
0
{
31
0
  return htobe64(host64);
32
0
}
33
34
inline uint32_t hostToNetwork32(uint32_t host32)
35
0
{
36
0
  return htobe32(host32);
37
0
}
38
39
inline uint16_t hostToNetwork16(uint16_t host16)
40
0
{
41
0
  return htobe16(host16);
42
0
}
43
44
inline uint64_t networkToHost64(uint64_t net64)
45
0
{
46
0
  return be64toh(net64);
47
0
}
48
49
inline uint32_t networkToHost32(uint32_t net32)
50
0
{
51
0
  return be32toh(net32);
52
0
}
53
54
inline uint16_t networkToHost16(uint16_t net16)
55
0
{
56
  return be16toh(net16);
57
0
}
58
59
#pragma GCC diagnostic pop
60
61
}  // namespace sockets
62
}  // namespace net
63
}  // namespace muduo
64
65
#endif  // MUDUO_NET_ENDIAN_H