tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CharacterDataBufferImpl.h (1387B)


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