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