Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
byteorder.h
Go to the documentation of this file.
1// Copyright 2019 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CORE_FXCRT_BYTEORDER_H_
6#define CORE_FXCRT_BYTEORDER_H_
7
8#include "build/build_config.h"
9#include "third_party/base/sys_byteorder.h"
10
11namespace fxcrt {
12
13// Converts the bytes in |x| from host order (endianness) to little endian, and
14// returns the result.
15inline uint16_t ByteSwapToLE16(uint16_t x) {
16 return pdfium::base::ByteSwapToLE16(x);
17}
18
19inline uint32_t ByteSwapToLE32(uint32_t x) {
20 return pdfium::base::ByteSwapToLE32(x);
21}
22
23// Converts the bytes in |x| from host order (endianness) to big endian, and
24// returns the result.
25inline uint16_t ByteSwapToBE16(uint16_t x) {
26#if defined(ARCH_CPU_LITTLE_ENDIAN)
27 return pdfium::base::ByteSwap(x);
28#else
29 return x;
30#endif
31}
32
33inline uint32_t ByteSwapToBE32(uint32_t x) {
34#if defined(ARCH_CPU_LITTLE_ENDIAN)
35 return pdfium::base::ByteSwap(x);
36#else
37 return x;
38#endif
39}
40
41} // namespace fxcrt
42
43#endif // CORE_FXCRT_BYTEORDER_H_
uint16_t ByteSwapToLE16(uint16_t x)
Definition byteorder.h:15
uint32_t ByteSwapToLE32(uint32_t x)
Definition byteorder.h:19
TEST(ByteOrder, ByteSwapToLE16)
uint32_t ByteSwapToBE32(uint32_t x)
Definition byteorder.h:33
uint16_t ByteSwapToBE16(uint16_t x)
Definition byteorder.h:25