12 #include <sys/resource.h> 13 #include <sys/syscall.h> 15 #include <sys/types.h> 29 #include "src/base/macros.h" 30 #include "src/base/platform/platform-posix-time.h" 31 #include "src/base/platform/platform-posix.h" 32 #include "src/base/platform/platform.h" 37 TimezoneCache* OS::CreateTimezoneCache() {
38 return new PosixDefaultTimezoneCache();
41 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
42 std::vector<SharedLibraryAddress> result;
46 FILE* fp = fopen(
"/proc/self/maps",
"r");
47 if (fp ==
nullptr)
return result;
50 const int kLibNameLen = FILENAME_MAX + 1;
51 char* lib_name =
reinterpret_cast<char*
>(malloc(kLibNameLen));
56 char attr_r, attr_w, attr_x, attr_p;
58 if (fscanf(fp,
"%" V8PRIxPTR
"-%" V8PRIxPTR, &start, &end) != 2)
break;
59 if (fscanf(fp,
" %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4)
break;
62 if (attr_r ==
'r' && attr_w !=
'w' && attr_x ==
'x') {
67 }
while ((c != EOF) && (c !=
'\n') && (c !=
'/'));
75 if (fgets(lib_name, kLibNameLen, fp) ==
nullptr)
break;
80 lib_name[strlen(lib_name) - 1] =
'\0';
83 snprintf(lib_name, kLibNameLen,
84 "%08" V8PRIxPTR
"-%08" V8PRIxPTR, start, end);
86 result.push_back(SharedLibraryAddress(lib_name, start, end));
92 }
while ((c != EOF) && (c !=
'\n'));
101 void OS::SignalCodeMovingGC() {
110 int size = sysconf(_SC_PAGESIZE);
111 FILE* f = fopen(OS::GetGCFakeMMapFile(),
"w+");
113 OS::PrintError(
"Failed to open %s\n", OS::GetGCFakeMMapFile());
117 mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE, fileno(f), 0);
118 DCHECK(addr != MAP_FAILED);
119 OS::Free(addr, size);