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

Side by Side Diff: src/base/platform/platform.h

Issue 1872203005: Fix printf formats (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix unused param found by GC mole Created 4 years, 8 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/macros.h ('k') | src/compilation-statistics.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // This module contains the platform-specific code. This make the rest of the 5 // This module contains the platform-specific code. This make the rest of the
6 // code less dependent on operating system, compilers and runtime libraries. 6 // code less dependent on operating system, compilers and runtime libraries.
7 // This module does specifically not deal with differences between different 7 // This module does specifically not deal with differences between different
8 // processor architecture. 8 // processor architecture.
9 // The platform classes have the same definition for all platforms. The 9 // The platform classes have the same definition for all platforms. The
10 // implementation for a particular platform is put in platform_<os>.cc. 10 // implementation for a particular platform is put in platform_<os>.cc.
11 // The build system then uses the implementation for the target platform. 11 // The build system then uses the implementation for the target platform.
12 // 12 //
13 // This design has been chosen because it is simple and fast. Alternatively, 13 // This design has been chosen because it is simple and fast. Alternatively,
14 // the platform dependent classes could have been implemented using abstract 14 // the platform dependent classes could have been implemented using abstract
15 // superclasses with virtual methods and having specializations for each 15 // superclasses with virtual methods and having specializations for each
16 // platform. This design was rejected because it was more complicated and 16 // platform. This design was rejected because it was more complicated and
17 // slower. It would require factory methods for selecting the right 17 // slower. It would require factory methods for selecting the right
18 // implementation and the overhead of virtual methods for performance 18 // implementation and the overhead of virtual methods for performance
19 // sensitive like mutex locking/unlocking. 19 // sensitive like mutex locking/unlocking.
20 20
21 #ifndef V8_BASE_PLATFORM_PLATFORM_H_ 21 #ifndef V8_BASE_PLATFORM_PLATFORM_H_
22 #define V8_BASE_PLATFORM_PLATFORM_H_ 22 #define V8_BASE_PLATFORM_PLATFORM_H_
23 23
24 #include <cstdarg> 24 #include <cstdarg>
25 #include <string> 25 #include <string>
26 #include <vector> 26 #include <vector>
27 27
28 #include "src/base/build_config.h" 28 #include "src/base/build_config.h"
29 #include "src/base/compiler-specific.h"
29 #include "src/base/platform/mutex.h" 30 #include "src/base/platform/mutex.h"
30 #include "src/base/platform/semaphore.h" 31 #include "src/base/platform/semaphore.h"
31 32
32 #if V8_OS_QNX 33 #if V8_OS_QNX
33 #include "src/base/qnx-math.h" 34 #include "src/base/qnx-math.h"
34 #endif 35 #endif
35 36
36 namespace v8 { 37 namespace v8 {
37 namespace base { 38 namespace base {
38 39
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 148
148 // Opens a temporary file, the file is auto removed on close. 149 // Opens a temporary file, the file is auto removed on close.
149 static FILE* OpenTemporaryFile(); 150 static FILE* OpenTemporaryFile();
150 151
151 // Log file open mode is platform-dependent due to line ends issues. 152 // Log file open mode is platform-dependent due to line ends issues.
152 static const char* const LogFileOpenMode; 153 static const char* const LogFileOpenMode;
153 154
154 // Print output to console. This is mostly used for debugging output. 155 // Print output to console. This is mostly used for debugging output.
155 // On platforms that has standard terminal output, the output 156 // On platforms that has standard terminal output, the output
156 // should go to stdout. 157 // should go to stdout.
157 static void Print(const char* format, ...); 158 static PRINTF_FORMAT(1, 2) void Print(const char* format, ...);
158 static void VPrint(const char* format, va_list args); 159 static PRINTF_FORMAT(1, 0) void VPrint(const char* format, va_list args);
159 160
160 // Print output to a file. This is mostly used for debugging output. 161 // Print output to a file. This is mostly used for debugging output.
161 static void FPrint(FILE* out, const char* format, ...); 162 static PRINTF_FORMAT(2, 3) void FPrint(FILE* out, const char* format, ...);
162 static void VFPrint(FILE* out, const char* format, va_list args); 163 static PRINTF_FORMAT(2, 0) void VFPrint(FILE* out, const char* format,
164 va_list args);
163 165
164 // Print error output to console. This is mostly used for error message 166 // Print error output to console. This is mostly used for error message
165 // output. On platforms that has standard terminal output, the output 167 // output. On platforms that has standard terminal output, the output
166 // should go to stderr. 168 // should go to stderr.
167 static void PrintError(const char* format, ...); 169 static PRINTF_FORMAT(1, 2) void PrintError(const char* format, ...);
168 static void VPrintError(const char* format, va_list args); 170 static PRINTF_FORMAT(1, 0) void VPrintError(const char* format, va_list args);
169 171
170 // Allocate/Free memory used by JS heap. Pages are readable/writable, but 172 // Allocate/Free memory used by JS heap. Pages are readable/writable, but
171 // they are not guaranteed to be executable unless 'executable' is true. 173 // they are not guaranteed to be executable unless 'executable' is true.
172 // Returns the address of allocated memory, or NULL if failed. 174 // Returns the address of allocated memory, or NULL if failed.
173 static void* Allocate(const size_t requested, 175 static void* Allocate(const size_t requested,
174 size_t* allocated, 176 size_t* allocated,
175 bool is_executable); 177 bool is_executable);
176 static void Free(void* address, const size_t size); 178 static void Free(void* address, const size_t size);
177 179
178 // This is the granularity at which the ProtectCode(...) call can set page 180 // This is the granularity at which the ProtectCode(...) call can set page
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 virtual void* memory() const = 0; 217 virtual void* memory() const = 0;
216 virtual size_t size() const = 0; 218 virtual size_t size() const = 0;
217 219
218 static MemoryMappedFile* open(const char* name); 220 static MemoryMappedFile* open(const char* name);
219 static MemoryMappedFile* create(const char* name, size_t size, 221 static MemoryMappedFile* create(const char* name, size_t size,
220 void* initial); 222 void* initial);
221 }; 223 };
222 224
223 // Safe formatting print. Ensures that str is always null-terminated. 225 // Safe formatting print. Ensures that str is always null-terminated.
224 // Returns the number of chars written, or -1 if output was truncated. 226 // Returns the number of chars written, or -1 if output was truncated.
225 static int SNPrintF(char* str, int length, const char* format, ...); 227 static PRINTF_FORMAT(3, 4) int SNPrintF(char* str, int length,
226 static int VSNPrintF(char* str, 228 const char* format, ...);
227 int length, 229 static PRINTF_FORMAT(3, 0) int VSNPrintF(char* str, int length,
228 const char* format, 230 const char* format, va_list args);
229 va_list args);
230 231
231 static char* StrChr(char* str, int c); 232 static char* StrChr(char* str, int c);
232 static void StrNCpy(char* dest, int length, const char* src, size_t n); 233 static void StrNCpy(char* dest, int length, const char* src, size_t n);
233 234
234 // Support for the profiler. Can do nothing, in which case ticks 235 // Support for the profiler. Can do nothing, in which case ticks
235 // occuring in shared libraries will not be properly accounted for. 236 // occuring in shared libraries will not be properly accounted for.
236 struct SharedLibraryAddress { 237 struct SharedLibraryAddress {
237 SharedLibraryAddress( 238 SharedLibraryAddress(
238 const std::string& library_path, uintptr_t start, uintptr_t end) 239 const std::string& library_path, uintptr_t start, uintptr_t end)
239 : library_path(library_path), start(start), end(end) {} 240 : library_path(library_path), start(start), end(end) {}
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 int stack_size_; 482 int stack_size_;
482 Semaphore* start_semaphore_; 483 Semaphore* start_semaphore_;
483 484
484 DISALLOW_COPY_AND_ASSIGN(Thread); 485 DISALLOW_COPY_AND_ASSIGN(Thread);
485 }; 486 };
486 487
487 } // namespace base 488 } // namespace base
488 } // namespace v8 489 } // namespace v8
489 490
490 #endif // V8_BASE_PLATFORM_PLATFORM_H_ 491 #endif // V8_BASE_PLATFORM_PLATFORM_H_
OLDNEW
« no previous file with comments | « src/base/macros.h ('k') | src/compilation-statistics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698