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

Side by Side Diff: src/platform-macos.cc

Issue 45063: Moved stdio and string functions to POSIX platform file (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-posix.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // Seed the random number generator. 79 // Seed the random number generator.
80 // Convert the current time to a 64-bit integer first, before converting it 80 // Convert the current time to a 64-bit integer first, before converting it
81 // to an unsigned. Going directly will cause an overflow and the seed to be 81 // to an unsigned. Going directly will cause an overflow and the seed to be
82 // set to all ones. The seed will be identical for different instances that 82 // set to all ones. The seed will be identical for different instances that
83 // call this setup code within the same millisecond. 83 // call this setup code within the same millisecond.
84 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); 84 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
85 srandom(static_cast<unsigned int>(seed)); 85 srandom(static_cast<unsigned int>(seed));
86 } 86 }
87 87
88 88
89 FILE* OS::FOpen(const char* path, const char* mode) {
90 return fopen(path, mode);
91 }
92
93
94 void OS::Print(const char* format, ...) {
95 va_list args;
96 va_start(args, format);
97 VPrint(format, args);
98 va_end(args);
99 }
100
101
102 void OS::VPrint(const char* format, va_list args) {
103 vprintf(format, args);
104 }
105
106
107 void OS::PrintError(const char* format, ...) {
108 va_list args;
109 va_start(args, format);
110 VPrintError(format, args);
111 va_end(args);
112 }
113
114
115 void OS::VPrintError(const char* format, va_list args) {
116 vfprintf(stderr, format, args);
117 }
118
119
120 int OS::SNPrintF(Vector<char> str, const char* format, ...) {
121 va_list args;
122 va_start(args, format);
123 int result = VSNPrintF(str, format, args);
124 va_end(args);
125 return result;
126 }
127
128
129 int OS::VSNPrintF(Vector<char> str,
130 const char* format,
131 va_list args) {
132 int n = vsnprintf(str.start(), str.length(), format, args);
133 if (n < 0 || n >= str.length()) {
134 str[str.length() - 1] = '\0';
135 return -1;
136 } else {
137 return n;
138 }
139 }
140
141
142 char* OS::StrChr(char* str, int c) {
143 return strchr(str, c);
144 }
145
146
147 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
148 strncpy(dest.start(), src, n);
149 }
150
151
152 // We keep the lowest and highest addresses mapped as a quick way of 89 // We keep the lowest and highest addresses mapped as a quick way of
153 // determining that pointers are outside the heap (used mostly in assertions 90 // determining that pointers are outside the heap (used mostly in assertions
154 // and verification). The estimate is conservative, ie, not all addresses in 91 // and verification). The estimate is conservative, ie, not all addresses in
155 // 'allocated' space are actually allocated to our heap. The range is 92 // 'allocated' space are actually allocated to our heap. The range is
156 // [lowest, highest), inclusive on the low and and exclusive on the high end. 93 // [lowest, highest), inclusive on the low and and exclusive on the high end.
157 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1); 94 static void* lowest_ever_allocated = reinterpret_cast<void*>(-1);
158 static void* highest_ever_allocated = reinterpret_cast<void*>(0); 95 static void* highest_ever_allocated = reinterpret_cast<void*>(0);
159 96
160 97
161 static void UpdateAllocatedSpaceLimits(void* address, int size) { 98 static void UpdateAllocatedSpaceLimits(void* address, int size) {
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 } 557 }
621 558
622 // This sampler is no longer the active sampler. 559 // This sampler is no longer the active sampler.
623 active_sampler_ = NULL; 560 active_sampler_ = NULL;
624 active_ = false; 561 active_ = false;
625 } 562 }
626 563
627 #endif // ENABLE_LOGGING_AND_PROFILING 564 #endif // ENABLE_LOGGING_AND_PROFILING
628 565
629 } } // namespace v8::internal 566 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698