All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
as_arch.h
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Aerospike, Inc.
3  *
4  * Portions may be licensed to Aerospike, Inc. under one or more contributor
5  * license agreements.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
8  * use this file except in compliance with the License. You may obtain a copy of
9  * the License at http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14  * License for the specific language governing permissions and limitations under
15  * the License.
16  */
17 
18 #pragma once
19 
20 #if defined _MSC_VER
21 
22 #define as_arch_prefetch_nt(_p)
23 #define as_arch_pause() YieldProcessor()
24 
25 #else // gcc & clang
26 
27 #define as_arch_compiler_barrier() asm volatile ("" : : : "memory")
28 
29 #define as_arch_prefetch_nt(_p) __builtin_prefetch((_p), 0, 0)
30 
31 #if defined __x86_64__
32 
33 #define as_arch_pause() asm volatile("pause" : : : "memory")
34 
35 #elif defined __aarch64__
36 
37 #define as_arch_pause() asm volatile("isb" : : : "memory")
38 
39 #endif
40 
41 #endif // gcc & clang