1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PANDA_RUNTIME_ARCH_MEMORY_HELPERS_H_ 17 #define PANDA_RUNTIME_ARCH_MEMORY_HELPERS_H_ 18 19 #if defined(PANDA_TARGET_ARM64) 20 #include "aarch64/memory.h" 21 #elif defined(PANDA_TARGET_ARM32) 22 #include "arm/memory.h" 23 #elif defined(PANDA_TARGET_X86) 24 #include "x86/memory.h" 25 #elif defined(PANDA_TARGET_AMD64) 26 #include "amd64/memory.h" 27 #else 28 #error "Unsupported target" 29 #endif 30 31 namespace panda::arch { 32 33 // Forces system-wide full memory synchronization 34 // NB! It is assumed all panda targets provide such synchronization, which might not be true on all CPU architectures 35 // Architecture-agnostic C++ memory order provides no reordering guarantees in case just one thread contains memory 36 // fence while FullMemoryBarrier callers expect all previous reads and writes to be visible in all threads FullMemoryBarrier()37inline void FullMemoryBarrier() 38 { 39 archSpecific::FullMemoryBarrier(); 40 } 41 42 } // namespace panda::arch 43 44 #endif // PANDA_RUNTIME_ARCH_MEMORY_HELPERS_H_ 45