| OLD | NEW |
| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 char* OS::StrDup(const char* str) { | 193 char* OS::StrDup(const char* str) { |
| 194 return strdup(str); | 194 return strdup(str); |
| 195 } | 195 } |
| 196 | 196 |
| 197 | 197 |
| 198 char* OS::StrNDup(const char* str, size_t n) { | 198 char* OS::StrNDup(const char* str, size_t n) { |
| 199 // Stupid implementation of strndup since macos isn't born with | 199 // Stupid implementation of strndup since macos isn't born with |
| 200 // one. | 200 // one. |
| 201 size_t len = strlen(str); | 201 size_t len = strlen(str); |
| 202 if (len <= n) | 202 if (len <= n) { |
| 203 return StrDup(str); | 203 return StrDup(str); |
| 204 } |
| 204 char* result = new char[n+1]; | 205 char* result = new char[n+1]; |
| 205 size_t i; | 206 size_t i; |
| 206 for (i = 0; i <= n; i++) | 207 for (i = 0; i <= n; i++) { |
| 207 result[i] = str[i]; | 208 result[i] = str[i]; |
| 209 } |
| 208 result[i] = '\0'; | 210 result[i] = '\0'; |
| 209 return result; | 211 return result; |
| 210 } | 212 } |
| 211 | 213 |
| 212 | 214 |
| 213 // We keep the lowest and highest addresses mapped as a quick way of | 215 // We keep the lowest and highest addresses mapped as a quick way of |
| 214 // determining that pointers are outside the heap (used mostly in assertions | 216 // determining that pointers are outside the heap (used mostly in assertions |
| 215 // and verification). The estimate is conservative, ie, not all addresses in | 217 // and verification). The estimate is conservative, ie, not all addresses in |
| 216 // 'allocated' space are actually allocated to our heap. The range is | 218 // 'allocated' space are actually allocated to our heap. The range is |
| 217 // [lowest, highest), inclusive on the low and and exclusive on the high end. | 219 // [lowest, highest), inclusive on the low and and exclusive on the high end. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 return mbase; | 254 return mbase; |
| 253 } | 255 } |
| 254 | 256 |
| 255 | 257 |
| 256 void OS::Free(void* buf, const size_t length) { | 258 void OS::Free(void* buf, const size_t length) { |
| 257 // TODO(1240712): munmap has a return value which is ignored here. | 259 // TODO(1240712): munmap has a return value which is ignored here. |
| 258 munmap(buf, length); | 260 munmap(buf, length); |
| 259 } | 261 } |
| 260 | 262 |
| 261 | 263 |
| 262 void OS::Sleep(int miliseconds) { | 264 void OS::Sleep(int milliseconds) { |
| 263 usleep(1000 * miliseconds); | 265 usleep(1000 * milliseconds); |
| 264 } | 266 } |
| 265 | 267 |
| 266 | 268 |
| 267 void OS::Abort() { | 269 void OS::Abort() { |
| 268 // Redirect to std abort to signal abnormal program termination | 270 // Redirect to std abort to signal abnormal program termination |
| 269 abort(); | 271 abort(); |
| 270 } | 272 } |
| 271 | 273 |
| 272 | 274 |
| 273 void OS::DebugBreak() { | 275 void OS::DebugBreak() { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 } | 655 } |
| 654 | 656 |
| 655 // This sampler is no longer the active sampler. | 657 // This sampler is no longer the active sampler. |
| 656 active_sampler_ = NULL; | 658 active_sampler_ = NULL; |
| 657 active_ = false; | 659 active_ = false; |
| 658 } | 660 } |
| 659 | 661 |
| 660 #endif // ENABLE_LOGGING_AND_PROFILING | 662 #endif // ENABLE_LOGGING_AND_PROFILING |
| 661 | 663 |
| 662 } } // namespace v8::internal | 664 } } // namespace v8::internal |
| OLD | NEW |