Line data Source code
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 nsTextFragmentImpl_h__
8 : #define nsTextFragmentImpl_h__
9 :
10 : #include <stdint.h>
11 :
12 : template<size_t size> struct Non8BitParameters;
13 : template<> struct Non8BitParameters<4> {
14 : static inline size_t mask() { return 0xff00ff00; }
15 : static inline uint32_t alignMask() { return 0x3; }
16 : static inline uint32_t numUnicharsPerWord() { return 2; }
17 : };
18 :
19 : template<> struct Non8BitParameters<8> {
20 151 : static inline size_t mask() {
21 : static const uint64_t maskAsUint64 = 0xff00ff00ff00ff00ULL;
22 : // We have to explicitly cast this 64-bit value to a size_t, or else
23 : // compilers for 32-bit platforms will warn about it being too large to fit
24 : // in the size_t return type. (Fortunately, this code isn't actually
25 : // invoked on 32-bit platforms -- they'll use the <4> specialization above.
26 : // So it is, in fact, OK that this value is too large for a 32-bit size_t.)
27 151 : return (size_t)maskAsUint64;
28 : }
29 0 : static inline uint32_t alignMask() { return 0x7; }
30 151 : static inline uint32_t numUnicharsPerWord() { return 4; }
31 : };
32 :
33 : #endif
|