diff options
Diffstat (limited to 'modules/woff2/src/woff2_common.cc')
-rw-r--r-- | modules/woff2/src/woff2_common.cc | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/modules/woff2/src/woff2_common.cc b/modules/woff2/src/woff2_common.cc index 9dc7cbd5c..fe0a3beda 100644 --- a/modules/woff2/src/woff2_common.cc +++ b/modules/woff2/src/woff2_common.cc @@ -1,23 +1,17 @@ -// Copyright 2013 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Helpers common across multiple parts of woff2 +/* Copyright 2013 Google Inc. All Rights Reserved. + + Distributed under MIT license. + See file LICENSE for detail or copy at https://opensource.org/licenses/MIT +*/ + +/* Helpers common across multiple parts of woff2 */ #include <algorithm> #include "./woff2_common.h" +#include "./port.h" + namespace woff2 { @@ -25,13 +19,12 @@ uint32_t ComputeULongSum(const uint8_t* buf, size_t size) { uint32_t checksum = 0; size_t aligned_size = size & ~3; for (size_t i = 0; i < aligned_size; i += 4) { - uint32_t v; - memcpy(&v, buf + i, 4); -#if (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) +#if defined(WOFF_LITTLE_ENDIAN) + uint32_t v = *reinterpret_cast<const uint32_t*>(buf + i); checksum += (((v & 0xFF) << 24) | ((v & 0xFF00) << 8) | ((v & 0xFF0000) >> 8) | ((v & 0xFF000000) >> 24)); -#elif (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) - checksum += v; +#elif defined(WOFF_BIG_ENDIAN) + checksum += *reinterpret_cast<const uint32_t*>(buf + i); #else checksum += (buf[i] << 24) | (buf[i + 1] << 16) | (buf[i + 2] << 8) | buf[i + 3]; |