blob: 6c0f721d1ab0dad098ab68917101315b26110330 [file] [log] [blame]
// Copyright (C) 2016 The Android Open Source Project
//
// 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.
package device
var (
UnknownABI = abi("unknown", UnknownOS, UnknownArchitecture)
// Android ARM defaults to v7a which is the lowest that we support.
AndroidARM = abi("armeabi", Android, ARMv7a)
AndroidARMv7a = abi("armeabi-v7a", Android, ARMv7a)
AndroidARMv7aHard = abi("armeabi-v7a-hard", Android, ARMv7a)
AndroidARM64v8a = abi("arm64-v8a", Android, ARMv8a)
AndroidX86 = abi("x86", Android, X86)
AndroidX86_64 = abi("x86-64", Android, X86_64)
AndroidMIPS = abi("mips", Android, MIPS)
AndroidMIPS64 = abi("mips64", Android, MIPS64)
LinuxX86_64 = abi("linux_x64", Linux, X86_64)
OSXX86_64 = abi("osx_x64", OSX, X86_64)
WindowsX86_64 = abi("windows_x64", Windows, X86_64)
)
var abiByName = map[string]ABI{}
func abi(name string, os OSKind, arch Architecture) ABI {
abi := ABI{
Name: name,
OS: os,
Architecture: arch,
MemoryLayout: arch.MemoryLayout(),
}
abiByName[name] = abi
return abi
}
// ABIByName returns the ABI that matches the provided human name.
// If there is no standard ABI that matches the name, then the returned ABI will have an UnknownOS and
// UnknownArchitecture.
func ABIByName(name string) ABI {
abi, ok := abiByName[name]
if !ok {
abi = ABI{
Name: name,
OS: UnknownOS,
Architecture: UnknownArchitecture,
}
}
return abi
}
// SameABI returns true if the two abi objects are a match.
// This is intended for matching an executable binary against a target ABI, so
// ABI's are a match if both their os and architecture are the same, and the
// name and memory layout are not considered.
func SameABI(a, b ABI) bool {
return (a.OS == b.OS) && (a.Architecture == b.Architecture)
}