| // 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 |
| |
| // ABI represents an application binary interface specification. |
| // A device supports a set of ABI's, and an application has an abi it is compiled for. |
| type ABI struct { |
| // Name is the human understandable name for the abi. |
| Name string |
| // OS is the type of OS this abi is targetted at, which normally controls things like calling convention. |
| OS OSKind |
| // Architecture is the processor type for the abi, controlling the instruction and feature set available. |
| Architecture Architecture |
| // MemoryLayout specifies things like size and alignment of types used directly buy the ABI. |
| MemoryLayout MemoryLayout |
| } |
| |
| 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", OSKind_LINUX, X86_64) |
| OSXX86_64 = abi("osx_x64", OSKind_OSX, X86_64) |
| WindowsX86_64 = abi("windows_x64", OSKind_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 |
| } |