Bug 1876335 - use GRADLE_MAVEN_REPOSITORIES in more places. r=owlish,geckoview-review...
[gecko.git] / gfx / 2d / BigEndianInts.h
blobb50a2e2148e831f2f93ea11a24d569c1333c98fc
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/. */
7 #ifndef mozilla_BigEndianInts_h
8 #define mozilla_BigEndianInts_h
10 #include "mozilla/EndianUtils.h"
12 namespace mozilla {
14 #pragma pack(push, 1)
16 struct BigEndianUint16 {
17 #ifdef __SUNPRO_CC
18 BigEndianUint16& operator=(const uint16_t aValue) {
19 value = NativeEndian::swapToBigEndian(aValue);
20 return *this;
22 #else
23 MOZ_IMPLICIT BigEndianUint16(const uint16_t aValue) {
24 value = NativeEndian::swapToBigEndian(aValue);
26 #endif
28 operator uint16_t() const { return NativeEndian::swapFromBigEndian(value); }
30 friend inline bool operator==(const BigEndianUint16& lhs,
31 const BigEndianUint16& rhs) {
32 return lhs.value == rhs.value;
35 friend inline bool operator!=(const BigEndianUint16& lhs,
36 const BigEndianUint16& rhs) {
37 return !(lhs == rhs);
40 private:
41 uint16_t value;
44 struct BigEndianUint32 {
45 #ifdef __SUNPRO_CC
46 BigEndianUint32& operator=(const uint32_t aValue) {
47 value = NativeEndian::swapToBigEndian(aValue);
48 return *this;
50 #else
51 MOZ_IMPLICIT BigEndianUint32(const uint32_t aValue) {
52 value = NativeEndian::swapToBigEndian(aValue);
54 #endif
56 operator uint32_t() const { return NativeEndian::swapFromBigEndian(value); }
58 private:
59 uint32_t value;
62 #pragma pack(pop)
64 } // namespace mozilla
66 #endif // mozilla_BigEndianInts_h