tor-browser

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

per_target.cc (2193B)


      1 // Copyright 2022 Google LLC
      2 // SPDX-License-Identifier: Apache-2.0
      3 //
      4 // Licensed under the Apache License, Version 2.0 (the "License");
      5 // you may not use this file except in compliance with the License.
      6 // You may obtain a copy of the License at
      7 //
      8 //      http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unless required by applicable law or agreed to in writing, software
     11 // distributed under the License is distributed on an "AS IS" BASIS,
     12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 // See the License for the specific language governing permissions and
     14 // limitations under the License.
     15 
     16 // Enable all targets so that calling Have* does not call into a null pointer.
     17 #ifndef HWY_COMPILE_ALL_ATTAINABLE
     18 #define HWY_COMPILE_ALL_ATTAINABLE
     19 #endif
     20 #include "hwy/per_target.h"
     21 
     22 #include <stddef.h>
     23 #include <stdint.h>
     24 
     25 #undef HWY_TARGET_INCLUDE
     26 #define HWY_TARGET_INCLUDE "hwy/per_target.cc"
     27 #include "hwy/foreach_target.h"  // IWYU pragma: keep
     28 #include "hwy/highway.h"
     29 
     30 HWY_BEFORE_NAMESPACE();
     31 namespace hwy {
     32 namespace HWY_NAMESPACE {
     33 namespace {
     34 int64_t GetTarget() { return HWY_TARGET; }
     35 size_t GetVectorBytes() { return Lanes(ScalableTag<uint8_t>()); }
     36 bool GetHaveInteger64() { return HWY_HAVE_INTEGER64 != 0; }
     37 bool GetHaveFloat16() { return HWY_HAVE_FLOAT16 != 0; }
     38 bool GetHaveFloat64() { return HWY_HAVE_FLOAT64 != 0; }
     39 }  // namespace
     40 // NOLINTNEXTLINE(google-readability-namespace-comments)
     41 }  // namespace HWY_NAMESPACE
     42 
     43 }  // namespace hwy
     44 HWY_AFTER_NAMESPACE();
     45 
     46 #if HWY_ONCE
     47 namespace hwy {
     48 namespace {
     49 HWY_EXPORT(GetTarget);
     50 HWY_EXPORT(GetVectorBytes);
     51 HWY_EXPORT(GetHaveInteger64);
     52 HWY_EXPORT(GetHaveFloat16);
     53 HWY_EXPORT(GetHaveFloat64);
     54 }  // namespace
     55 
     56 HWY_DLLEXPORT int64_t DispatchedTarget() {
     57  return HWY_DYNAMIC_DISPATCH(GetTarget)();
     58 }
     59 
     60 HWY_DLLEXPORT size_t VectorBytes() {
     61  return HWY_DYNAMIC_DISPATCH(GetVectorBytes)();
     62 }
     63 
     64 HWY_DLLEXPORT bool HaveInteger64() {
     65  return HWY_DYNAMIC_DISPATCH(GetHaveInteger64)();
     66 }
     67 
     68 HWY_DLLEXPORT bool HaveFloat16() {
     69  return HWY_DYNAMIC_DISPATCH(GetHaveFloat16)();
     70 }
     71 
     72 HWY_DLLEXPORT bool HaveFloat64() {
     73  return HWY_DYNAMIC_DISPATCH(GetHaveFloat64)();
     74 }
     75 
     76 }  // namespace hwy
     77 #endif  // HWY_ONCE