Revision f230a1cf deps/v8/src/platform-posix.cc

View differences:

deps/v8/src/platform-posix.cc
29 29
// own but contains the parts which are the same across POSIX platforms Linux,
30 30
// Mac OS, FreeBSD and OpenBSD.
31 31

  
32
#include "platform-posix.h"
33

  
34 32
#include <dlfcn.h>
35 33
#include <pthread.h>
36 34
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
......
102 100
}
103 101

  
104 102

  
103
uint64_t OS::TotalPhysicalMemory() {
104
#if V8_OS_MACOSX
105
  int mib[2];
106
  mib[0] = CTL_HW;
107
  mib[1] = HW_MEMSIZE;
108
  int64_t size = 0;
109
  size_t len = sizeof(size);
110
  if (sysctl(mib, 2, &size, &len, NULL, 0) != 0) {
111
    UNREACHABLE();
112
    return 0;
113
  }
114
  return static_cast<uint64_t>(size);
115
#elif V8_OS_FREEBSD
116
  int pages, page_size;
117
  size_t size = sizeof(pages);
118
  sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0);
119
  sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0);
120
  if (pages == -1 || page_size == -1) {
121
    UNREACHABLE();
122
    return 0;
123
  }
124
  return static_cast<uint64_t>(pages) * page_size;
125
#elif V8_OS_CYGWIN
126
  MEMORYSTATUS memory_info;
127
  memory_info.dwLength = sizeof(memory_info);
128
  if (!GlobalMemoryStatus(&memory_info)) {
129
    UNREACHABLE();
130
    return 0;
131
  }
132
  return static_cast<uint64_t>(memory_info.dwTotalPhys);
133
#else
134
  intptr_t pages = sysconf(_SC_PHYS_PAGES);
135
  intptr_t page_size = sysconf(_SC_PAGESIZE);
136
  if (pages == -1 || page_size == -1) {
137
    UNREACHABLE();
138
    return 0;
139
  }
140
  return static_cast<uint64_t>(pages) * page_size;
141
#endif
142
}
143

  
144

  
105 145
int OS::ActivationFrameAlignment() {
106 146
#if V8_TARGET_ARCH_ARM
107 147
  // On EABI ARM targets this is required for fp correctness in the

Also available in: Unified diff