• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 COMMON_COMPONENTS_BASE_SYSCALL_H
17 #define COMMON_COMPONENTS_BASE_SYSCALL_H
18 
19 #include <ctime>
20 #if defined(_WIN64)
21 #include <pthread.h>
22 #elif defined(__APPLE__)
23 #include <pthread.h>
24 #include <unistd.h>
25 #else
26 #include <sys/prctl.h>
27 #include "linux/futex.h"
28 #endif
29 
30 namespace common {
31 #if defined(__linux__) || defined(PANDA_TARGET_OHOS)
32 int Futex(const volatile int* uaddr, int op, int val);
33 #endif
34 
35 pid_t GetTid();
36 
37 int GetPid();
38 
39 #if defined(__linux__) || defined(PANDA_TARGET_OHOS)
40 #ifndef PR_SET_VMA
41 #define PR_SET_VMA 0x53564d41
42 #define PR_SET_VMA_ANON_NAME 0
43 #endif
44 
45 // prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME), can set name for anon VMA.
46 // Considering the purpose is for debuging, in windows we just simply remove it.
47 #define COMMON_PRCTL(base_address, allocated_size, mmtag) \
48     (void)prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, base_address, allocated_size, mmtag)
49 #endif
50 } // namespace common
51 
52 #endif // COMMON_COMPONENTS_BASE_SYSCALL_H
53