1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2018 The Android Open Source Project 3*795d594fSAndroid Build Coastguard Worker * 4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*795d594fSAndroid Build Coastguard Worker * 8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*795d594fSAndroid Build Coastguard Worker * 10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*795d594fSAndroid Build Coastguard Worker * limitations under the License. 15*795d594fSAndroid Build Coastguard Worker */ 16*795d594fSAndroid Build Coastguard Worker 17*795d594fSAndroid Build Coastguard Worker #ifndef ART_LIBARTBASE_BASE_MEMBARRIER_H_ 18*795d594fSAndroid Build Coastguard Worker #define ART_LIBARTBASE_BASE_MEMBARRIER_H_ 19*795d594fSAndroid Build Coastguard Worker 20*795d594fSAndroid Build Coastguard Worker namespace art { 21*795d594fSAndroid Build Coastguard Worker // Command types for the linux membarrier system call. Different Linux installation may include 22*795d594fSAndroid Build Coastguard Worker // different subsets of these commands (at the same codepoints). 23*795d594fSAndroid Build Coastguard Worker // 24*795d594fSAndroid Build Coastguard Worker // Hardcoding these values is temporary until bionic and prebuilts glibc have an up to date 25*795d594fSAndroid Build Coastguard Worker // linux/membarrier.h. The order and values follow the current linux definitions. 26*795d594fSAndroid Build Coastguard Worker enum class MembarrierCommand : int { 27*795d594fSAndroid Build Coastguard Worker // MEMBARRIER_CMD_QUERY 28*795d594fSAndroid Build Coastguard Worker kQuery = 0, 29*795d594fSAndroid Build Coastguard Worker // MEMBARRIER_CMD_GLOBAL 30*795d594fSAndroid Build Coastguard Worker kGlobal = (1 << 0), 31*795d594fSAndroid Build Coastguard Worker // MEMBARRIER_CMD_GLOBAL_EXPEDITED 32*795d594fSAndroid Build Coastguard Worker kGlobalExpedited = (1 << 1), 33*795d594fSAndroid Build Coastguard Worker // MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED 34*795d594fSAndroid Build Coastguard Worker kRegisterGlobalExpedited = (1 << 2), 35*795d594fSAndroid Build Coastguard Worker // MEMBARRIER_CMD_PRIVATE_EXPEDITED 36*795d594fSAndroid Build Coastguard Worker kPrivateExpedited = (1 << 3), 37*795d594fSAndroid Build Coastguard Worker // MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED 38*795d594fSAndroid Build Coastguard Worker kRegisterPrivateExpedited = (1 << 4), 39*795d594fSAndroid Build Coastguard Worker // MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE 40*795d594fSAndroid Build Coastguard Worker kPrivateExpeditedSyncCore = (1 << 5), 41*795d594fSAndroid Build Coastguard Worker // MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE 42*795d594fSAndroid Build Coastguard Worker kRegisterPrivateExpeditedSyncCore = (1 << 6) 43*795d594fSAndroid Build Coastguard Worker }; 44*795d594fSAndroid Build Coastguard Worker 45*795d594fSAndroid Build Coastguard Worker // Call membarrier(2) if available on platform and return result. This method can fail if the 46*795d594fSAndroid Build Coastguard Worker // command is not supported by the kernel. The underlying system call is linux specific. 47*795d594fSAndroid Build Coastguard Worker int membarrier(MembarrierCommand command); 48*795d594fSAndroid Build Coastguard Worker 49*795d594fSAndroid Build Coastguard Worker } // namespace art 50*795d594fSAndroid Build Coastguard Worker 51*795d594fSAndroid Build Coastguard Worker #endif // ART_LIBARTBASE_BASE_MEMBARRIER_H_ 52