| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // Seed the random number generator. | 74 // Seed the random number generator. |
| 75 // Convert the current time to a 64-bit integer first, before converting it | 75 // Convert the current time to a 64-bit integer first, before converting it |
| 76 // to an unsigned. Going directly can cause an overflow and the seed to be | 76 // to an unsigned. Going directly can cause an overflow and the seed to be |
| 77 // set to all ones. The seed will be identical for different instances that | 77 // set to all ones. The seed will be identical for different instances that |
| 78 // call this setup code within the same millisecond. | 78 // call this setup code within the same millisecond. |
| 79 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | 79 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |
| 80 srandom(static_cast<unsigned int>(seed)); | 80 srandom(static_cast<unsigned int>(seed)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 FILE* OS::FOpen(const char* path, const char* mode) { | |
| 85 return fopen(path, mode); | |
| 86 } | |
| 87 | |
| 88 | |
| 89 void OS::Print(const char* format, ...) { | |
| 90 va_list args; | |
| 91 va_start(args, format); | |
| 92 VPrint(format, args); | |
| 93 va_end(args); | |
| 94 } | |
| 95 | |
| 96 | |
| 97 void OS::VPrint(const char* format, va_list args) { | |
| 98 vprintf(format, args); | |
| 99 } | |
| 100 | |
| 101 | |
| 102 void OS::PrintError(const char* format, ...) { | |
| 103 va_list args; | |
| 104 va_start(args, format); | |
| 105 VPrintError(format, args); | |
| 106 va_end(args); | |
| 107 } | |
| 108 | |
| 109 | |
| 110 void OS::VPrintError(const char* format, va_list args) { | |
| 111 vfprintf(stderr, format, args); | |
| 112 } | |
| 113 | |
| 114 | |
| 115 int OS::SNPrintF(Vector<char> str, const char* format, ...) { | |
| 116 va_list args; | |
| 117 va_start(args, format); | |
| 118 int result = VSNPrintF(str, format, args); | |
| 119 va_end(args); | |
| 120 return result; | |
| 121 } | |
| 122 | |
| 123 | |
| 124 int OS::VSNPrintF(Vector<char> str, | |
| 125 const char* format, | |
| 126 va_list args) { | |
| 127 int n = vsnprintf(str.start(), str.length(), format, args); | |
| 128 if (n < 0 || n >= str.length()) { | |
| 129 str[str.length() - 1] = '\0'; | |
| 130 return -1; | |
| 131 } else { | |
| 132 return n; | |
| 133 } | |
| 134 } | |
| 135 | |
| 136 | |
| 137 char* OS::StrChr(char* str, int c) { | |
| 138 return strchr(str, c); | |
| 139 } | |
| 140 | |
| 141 | |
| 142 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | |
| 143 strncpy(dest.start(), src, n); | |
| 144 } | |
| 145 | |
| 146 | |
| 147 double OS::nan_value() { | 84 double OS::nan_value() { |
| 148 return NAN; | 85 return NAN; |
| 149 } | 86 } |
| 150 | 87 |
| 151 | 88 |
| 152 int OS::ActivationFrameAlignment() { | 89 int OS::ActivationFrameAlignment() { |
| 153 // Floating point code runs faster if the stack is 8-byte aligned. | 90 // Floating point code runs faster if the stack is 8-byte aligned. |
| 154 return 8; | 91 return 8; |
| 155 } | 92 } |
| 156 | 93 |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 } | 643 } |
| 707 | 644 |
| 708 // This sampler is no longer the active sampler. | 645 // This sampler is no longer the active sampler. |
| 709 active_sampler_ = NULL; | 646 active_sampler_ = NULL; |
| 710 active_ = false; | 647 active_ = false; |
| 711 } | 648 } |
| 712 | 649 |
| 713 #endif // ENABLE_LOGGING_AND_PROFILING | 650 #endif // ENABLE_LOGGING_AND_PROFILING |
| 714 | 651 |
| 715 } } // namespace v8::internal | 652 } } // namespace v8::internal |
| OLD | NEW |