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

Side by Side Diff: Source/wtf/TCSystemAlloc.cpp

Issue 48663004: Fix more warnings in wtf (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix more warnings in wtf. Created 7 years, 1 month 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
OLDNEW
1 // Copyright (c) 2005, 2007, Google Inc. 1 // Copyright (c) 2005, 2007, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 #if HAVE(MMAP) 73 #if HAVE(MMAP)
74 static bool use_mmap = true; 74 static bool use_mmap = true;
75 #endif 75 #endif
76 76
77 // Flags to keep us from retrying allocators that failed. 77 // Flags to keep us from retrying allocators that failed.
78 static bool devmem_failure = false; 78 static bool devmem_failure = false;
79 static bool sbrk_failure = false; 79 static bool sbrk_failure = false;
80 static bool mmap_failure = false; 80 static bool mmap_failure = false;
81 81
82 static const int32_t FLAGS_malloc_devmem_start = 0;
83 static const int32_t FLAGS_malloc_devmem_limit = 0;
84
85 #if HAVE(MMAP) 82 #if HAVE(MMAP)
86 83
87 static void* TryMmap(size_t size, size_t *actual_size, size_t alignment) { 84 static void* TryMmap(size_t size, size_t *actual_size, size_t alignment) {
88 // Enforce page alignment 85 // Enforce page alignment
89 if (pagesize == 0) pagesize = getpagesize(); 86 if (pagesize == 0) pagesize = getpagesize();
90 if (alignment < pagesize) alignment = pagesize; 87 if (alignment < pagesize) alignment = pagesize;
91 size = ((size + alignment - 1) / alignment) * alignment; 88 size = ((size + alignment - 1) / alignment) * alignment;
92 89
93 // could theoretically return the "extra" bytes here, but this 90 // could theoretically return the "extra" bytes here, but this
94 // is simple and correct. 91 // is simple and correct.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 174
178 void TCMalloc_SystemRelease(void* start, size_t length) 175 void TCMalloc_SystemRelease(void* start, size_t length)
179 { 176 {
180 // MADV_FREE clears the modified bit on pages, which allows 177 // MADV_FREE clears the modified bit on pages, which allows
181 // them to be discarded immediately. 178 // them to be discarded immediately.
182 #if HAVE(MADV_FREE) 179 #if HAVE(MADV_FREE)
183 const int advice = MADV_FREE; 180 const int advice = MADV_FREE;
184 #else 181 #else
185 const int advice = MADV_DONTNEED; 182 const int advice = MADV_DONTNEED;
186 #endif 183 #endif
187 if (FLAGS_malloc_devmem_start) {
188 // It's not safe to use MADV_DONTNEED if we've been mapping
189 // /dev/mem for heap memory
190 return;
191 }
192 if (pagesize == 0) pagesize = getpagesize(); 184 if (pagesize == 0) pagesize = getpagesize();
193 const size_t pagemask = pagesize - 1; 185 const size_t pagemask = pagesize - 1;
194 186
195 size_t new_start = reinterpret_cast<size_t>(start); 187 size_t new_start = reinterpret_cast<size_t>(start);
196 size_t end = new_start + length; 188 size_t end = new_start + length;
197 size_t new_end = end; 189 size_t new_end = end;
198 190
199 // Round up the starting address and round down the ending address 191 // Round up the starting address and round down the ending address
200 // to be page aligned: 192 // to be page aligned:
201 new_start = (new_start + pagesize - 1) & ~pagemask; 193 new_start = (new_start + pagesize - 1) & ~pagemask;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 234
243 #else 235 #else
244 236
245 // Platforms that don't need to explicitly commit memory use an empty inline ver sion of TCMalloc_SystemCommit 237 // Platforms that don't need to explicitly commit memory use an empty inline ver sion of TCMalloc_SystemCommit
246 // declared in TCSystemAlloc.h 238 // declared in TCSystemAlloc.h
247 239
248 #endif 240 #endif
249 241
250 #endif // #if !USE(SYSTEM_MALLOC) 242 #endif // #if !USE(SYSTEM_MALLOC)
251 243
OLDNEW
« no previous file with comments | « Source/wtf/PartitionAlloc.cpp ('k') | Source/wtf/dtoa.cpp » ('j') | Source/wtf/dtoa.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698