• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #include "ecmascript/platform/os.h"
17 
18 #include <malloc.h>
19 #include <sysinfoapi.h>
20 #include <timezoneapi.h>
21 
22 #include "ecmascript/log_wrapper.h"
23 
24 namespace panda::ecmascript {
MallocUsableSize(void * ptr)25 size_t MallocUsableSize(void *ptr)
26 {
27     return _msize(ptr);
28 }
29 
NumberOfCpuCore()30 uint32_t NumberOfCpuCore()
31 {
32     SYSTEM_INFO info;
33     GetSystemInfo(&info);
34     return info.dwNumberOfProcessors;
35 }
36 
PhysicalSize()37 size_t PhysicalSize()
38 {
39     MEMORYSTATUSEX status;
40     status.dwLength = sizeof(MEMORYSTATUSEX);
41     GlobalMemoryStatusEx(&status);
42     DWORDLONG physSize = status.ullTotalPhys;
43     return physSize;
44 }
45 
PrctlSetVMA(const void * ptr,const size_t size,const char * tag)46 int PrctlSetVMA([[maybe_unused]] const void *ptr, [[maybe_unused]] const size_t size, [[maybe_unused]] const char *tag)
47 {
48     return -1;
49 }
50 
PtracePeektext(int pid,uintptr_t addr)51 long PtracePeektext([[maybe_unused]] int pid, [[maybe_unused]] uintptr_t addr)
52 {
53     return static_cast<long>(-1);
54 }
55 
BindSmallCpuCore()56 void BindSmallCpuCore()
57 {
58     LOG_ECMA(INFO) << "Bind Small Core in windows not support";
59 }
60 
PageMapExecFortSpace(void * addr,size_t size,int prot)61 void *PageMapExecFortSpace(void *addr, [[maybe_unused]] size_t size, [[maybe_unused]] int prot)
62 {
63     // basically no op
64     return addr;
65 }
66 
SetSecurityLabel(const std::string & path)67 void SetSecurityLabel([[maybe_unused]] const std::string& path)
68 {
69     LOG_ECMA(INFO) << "Set Security Label in windows not support";
70 }
71 }  // namespace panda::ecmascript
72