Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: src/base/platform/platform-aix.cc

Issue 1111733002: [clang] Use -Wshorten-64-to-32 to enable warnings about 64bit to 32bit truncations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win warnings. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/base/platform/platform.h ('k') | src/base/platform/platform-cygwin.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Platform specific code for AIX goes here. For the POSIX comaptible parts 5 // Platform specific code for AIX goes here. For the POSIX comaptible parts
6 // the implementation is in platform-posix.cc. 6 // the implementation is in platform-posix.cc.
7 7
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <semaphore.h> 9 #include <semaphore.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 const size_t msize = RoundUp(requested, getpagesize()); 66 const size_t msize = RoundUp(requested, getpagesize());
67 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); 67 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0);
68 void* mbase = mmapHelper(msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 68 void* mbase = mmapHelper(msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
69 69
70 if (mbase == MAP_FAILED) return NULL; 70 if (mbase == MAP_FAILED) return NULL;
71 *allocated = msize; 71 *allocated = msize;
72 return mbase; 72 return mbase;
73 } 73 }
74 74
75 75
76 class PosixMemoryMappedFile : public OS::MemoryMappedFile {
77 public:
78 PosixMemoryMappedFile(FILE* file, void* memory, int size)
79 : file_(file), memory_(memory), size_(size) {}
80 virtual ~PosixMemoryMappedFile();
81 virtual void* memory() { return memory_; }
82 virtual int size() { return size_; }
83
84 private:
85 FILE* file_;
86 void* memory_;
87 int size_;
88 };
89
90
91 OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
92 FILE* file = fopen(name, "r+");
93 if (file == NULL) return NULL;
94
95 fseek(file, 0, SEEK_END);
96 int size = ftell(file);
97
98 void* memory =
99 mmapHelper(size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
100 return new PosixMemoryMappedFile(file, memory, size);
101 }
102
103
104 OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size,
105 void* initial) {
106 FILE* file = fopen(name, "w+");
107 if (file == NULL) return NULL;
108 int result = fwrite(initial, size, 1, file);
109 if (result < 1) {
110 fclose(file);
111 return NULL;
112 }
113 void* memory =
114 mmapHelper(size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
115 return new PosixMemoryMappedFile(file, memory, size);
116 }
117
118
119 PosixMemoryMappedFile::~PosixMemoryMappedFile() {
120 if (memory_) munmap(memory_, size_);
121 fclose(file_);
122 }
123
124
125 static unsigned StringToLong(char* buffer) { 76 static unsigned StringToLong(char* buffer) {
126 return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT 77 return static_cast<unsigned>(strtol(buffer, NULL, 16)); // NOLINT
127 } 78 }
128 79
129 80
130 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() { 81 std::vector<OS::SharedLibraryAddress> OS::GetSharedLibraryAddresses() {
131 std::vector<SharedLibraryAddress> result; 82 std::vector<SharedLibraryAddress> result;
132 static const int MAP_LENGTH = 1024; 83 static const int MAP_LENGTH = 1024;
133 int fd = open("/proc/self/maps", O_RDONLY); 84 int fd = open("/proc/self/maps", O_RDONLY);
134 if (fd < 0) return result; 85 if (fd < 0) return result;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 234
284 235
285 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { 236 bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
286 return munmap(base, size) == 0; 237 return munmap(base, size) == 0;
287 } 238 }
288 239
289 240
290 bool VirtualMemory::HasLazyCommits() { return true; } 241 bool VirtualMemory::HasLazyCommits() { return true; }
291 } 242 }
292 } // namespace v8::base 243 } // namespace v8::base
OLDNEW
« no previous file with comments | « src/base/platform/platform.h ('k') | src/base/platform/platform-cygwin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698