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 namespace panda::ecmascript {
MallocUsableSize(void * ptr)23 size_t MallocUsableSize(void *ptr)
24 {
25 return _msize(ptr);
26 }
27
NumberOfCpuCore()28 uint32_t NumberOfCpuCore()
29 {
30 SYSTEM_INFO info;
31 GetSystemInfo(&info);
32 return info.dwNumberOfProcessors;
33 }
34
PhysicalSize()35 size_t PhysicalSize()
36 {
37 MEMORYSTATUSEX status;
38 status.dwLength = sizeof(MEMORYSTATUSEX);
39 GlobalMemoryStatusEx(&status);
40 DWORDLONG physSize = status.ullTotalPhys;
41 return physSize;
42 }
43
PrctlSetVMA(const void * ptr,const size_t size,const char * tag)44 int PrctlSetVMA([[maybe_unused]] const void *ptr, [[maybe_unused]] const size_t size, [[maybe_unused]] const char *tag)
45 {
46 return -1;
47 }
48
PtracePeektext(int pid,uintptr_t addr)49 long PtracePeektext([[maybe_unused]] int pid, [[maybe_unused]] uintptr_t addr)
50 {
51 return static_cast<long>(-1);
52 }
53 } // namespace panda::ecmascript
54