Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/2d/BigEndianInts.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef mozilla_BigEndianInts_h
8
#define mozilla_BigEndianInts_h
9
10
#include "mozilla/EndianUtils.h"
11
12
namespace mozilla {
13
14
#pragma pack(push, 1)
15
16
struct BigEndianUint16
17
{
18
#ifdef __SUNPRO_CC
19
  BigEndianUint16& operator=(const uint16_t aValue)
20
  {
21
    value = NativeEndian::swapToBigEndian(aValue);
22
    return *this;
23
  }
24
#else
25
  MOZ_IMPLICIT BigEndianUint16(const uint16_t aValue)
26
39
  {
27
39
    value = NativeEndian::swapToBigEndian(aValue);
28
39
  }
29
#endif
30
31
  operator uint16_t() const
32
0
  {
33
0
    return NativeEndian::swapFromBigEndian(value);
34
0
  }
35
36
  friend inline bool
37
  operator==(const BigEndianUint16& lhs, const BigEndianUint16& rhs)
38
0
  {
39
0
    return lhs.value == rhs.value;
40
0
  }
41
42
  friend inline bool
43
  operator!=(const BigEndianUint16& lhs, const BigEndianUint16& rhs)
44
0
  {
45
0
    return !(lhs == rhs);
46
0
  }
47
48
private:
49
  uint16_t value;
50
};
51
52
struct BigEndianUint32
53
{
54
#ifdef __SUNPRO_CC
55
  BigEndianUint32& operator=(const uint32_t aValue)
56
  {
57
    value = NativeEndian::swapToBigEndian(aValue);
58
    return *this;
59
  }
60
#else
61
  MOZ_IMPLICIT BigEndianUint32(const uint32_t aValue)
62
0
  {
63
0
    value = NativeEndian::swapToBigEndian(aValue);
64
0
  }
65
#endif
66
67
  operator uint32_t() const
68
0
  {
69
0
    return NativeEndian::swapFromBigEndian(value);
70
0
  }
71
72
private:
73
  uint32_t  value;
74
};
75
76
#pragma pack(pop)
77
78
} // mozilla
79
80
#endif // mozilla_BigEndianInts_h