Path: blob/master/thirdparty/astcenc/astcenc_mathlib.cpp
9903 views
// SPDX-License-Identifier: Apache-2.01// ----------------------------------------------------------------------------2// Copyright 2011-2021 Arm Limited3//4// Licensed under the Apache License, Version 2.0 (the "License"); you may not5// use this file except in compliance with the License. You may obtain a copy6// of the License at:7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing, software11// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT12// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the13// License for the specific language governing permissions and limitations14// under the License.15// ----------------------------------------------------------------------------1617#include "astcenc_mathlib.h"1819/**20* @brief 64-bit rotate left.21*22* @param val The value to rotate.23* @param count The rotation, in bits.24*/25static inline uint64_t rotl(uint64_t val, int count)26{27return (val << count) | (val >> (64 - count));28}2930/* See header for documentation. */31void astc::rand_init(uint64_t state[2])32{33state[0] = 0xfaf9e171cea1ec6bULL;34state[1] = 0xf1b318cc06af5d71ULL;35}3637/* See header for documentation. */38uint64_t astc::rand(uint64_t state[2])39{40uint64_t s0 = state[0];41uint64_t s1 = state[1];42uint64_t res = s0 + s1;43s1 ^= s0;44state[0] = rotl(s0, 24) ^ s1 ^ (s1 << 16);45state[1] = rotl(s1, 37);46return res;47}484950