Home | History | Annotate | Download | only in vintf
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      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 
     17 
     18 #ifndef ANDROID_VINTF_ARCH_H
     19 #define ANDROID_VINTF_ARCH_H
     20 
     21 #include <stdint.h>
     22 #include <string>
     23 #include <array>
     24 
     25 namespace android {
     26 namespace vintf {
     27 
     28 enum class Arch : size_t {
     29     ARCH_EMPTY = 0,
     30     ARCH_32,
     31     ARCH_64,
     32     ARCH_32_64
     33 };
     34 
     35 static const std::array<std::string, 4> gArchStrings = {
     36     {
     37         "",
     38         "32",
     39         "64",
     40         "32+64",
     41     }
     42 };
     43 
     44 inline bool has32(Arch arch) {
     45     return arch == Arch::ARCH_32 || arch == Arch::ARCH_32_64;
     46 }
     47 
     48 inline bool has64(Arch arch) {
     49     return arch == Arch::ARCH_64 || arch == Arch::ARCH_32_64;
     50 }
     51 
     52 inline constexpr Arch operator|(Arch lft, Arch rgt) {
     53     return static_cast<Arch>(static_cast<size_t>(lft) | static_cast<size_t>(rgt));
     54 }
     55 static_assert((Arch::ARCH_32 | Arch::ARCH_64) == Arch::ARCH_32_64, "bad Arch::operator|");
     56 
     57 inline Arch& operator|=(Arch& lft, Arch rgt) {
     58     return (lft = lft | rgt);
     59 }
     60 
     61 } // namespace vintf
     62 } // namespace android
     63 
     64 #endif // ANDROID_VINTF_ARCH_H
     65