| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Seed the random number generator. | 76 // Seed the random number generator. |
| 77 // Convert the current time to a 64-bit integer first, before converting it | 77 // Convert the current time to a 64-bit integer first, before converting it |
| 78 // to an unsigned. Going directly can cause an overflow and the seed to be | 78 // to an unsigned. Going directly can cause an overflow and the seed to be |
| 79 // set to all ones. The seed will be identical for different instances that | 79 // set to all ones. The seed will be identical for different instances that |
| 80 // call this setup code within the same millisecond. | 80 // call this setup code within the same millisecond. |
| 81 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | 81 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |
| 82 srandom(static_cast<unsigned int>(seed)); | 82 srandom(static_cast<unsigned int>(seed)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 | 85 |
| 86 FILE* OS::FOpen(const char* path, const char* mode) { | |
| 87 return fopen(path, mode); | |
| 88 } | |
| 89 | |
| 90 | |
| 91 void OS::Print(const char* format, ...) { | |
| 92 va_list args; | |
| 93 va_start(args, format); | |
| 94 VPrint(format, args); | |
| 95 va_end(args); | |
| 96 } | |
| 97 | |
| 98 | |
| 99 void OS::VPrint(const char* format, va_list args) { | |
| 100 vprintf(format, args); | |
| 101 } | |
| 102 | |
| 103 | |
| 104 void OS::PrintError(const char* format, ...) { | |
| 105 va_list args; | |
| 106 va_start(args, format); | |
| 107 VPrintError(format, args); | |
| 108 va_end(args); | |
| 109 } | |
| 110 | |
| 111 | |
| 112 void OS::VPrintError(const char* format, va_list args) { | |
| 113 vfprintf(stderr, format, args); | |
| 114 } | |
| 115 | |
| 116 | |
| 117 int OS::SNPrintF(Vector<char> str, const char* format, ...) { | |
| 118 va_list args; | |
| 119 va_start(args, format); | |
| 120 int result = VSNPrintF(str, format, args); | |
| 121 va_end(args); | |
| 122 return result; | |
| 123 } | |
| 124 | |
| 125 | |
| 126 int OS::VSNPrintF(Vector<char> str, | |
| 127 const char* format, | |
| 128 va_list args) { | |
| 129 int n = vsnprintf(str.start(), str.length(), format, args); | |
| 130 if (n < 0 || n >= str.length()) { | |
| 131 str[str.length() - 1] = '\0'; | |
| 132 return -1; | |
| 133 } else { | |
| 134 return n; | |
| 135 } | |
| 136 } | |
| 137 | |
| 138 | |
| 139 char* OS::StrChr(char* str, int c) { | |
| 140 return strchr(str, c); | |
| 141 } | |
| 142 | |
| 143 | |
| 144 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | |
| 145 strncpy(dest.start(), src, n); | |
| 146 } | |
| 147 | |
| 148 | |
| 149 double OS::nan_value() { | 86 double OS::nan_value() { |
| 150 return NAN; | 87 return NAN; |
| 151 } | 88 } |
| 152 | 89 |
| 153 | 90 |
| 154 int OS::ActivationFrameAlignment() { | 91 int OS::ActivationFrameAlignment() { |
| 155 // 16 byte alignment on FreeBSD | 92 // 16 byte alignment on FreeBSD |
| 156 return 16; | 93 return 16; |
| 157 } | 94 } |
| 158 | 95 |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 } | 630 } |
| 694 | 631 |
| 695 // This sampler is no longer the active sampler. | 632 // This sampler is no longer the active sampler. |
| 696 active_sampler_ = NULL; | 633 active_sampler_ = NULL; |
| 697 active_ = false; | 634 active_ = false; |
| 698 } | 635 } |
| 699 | 636 |
| 700 #endif // ENABLE_LOGGING_AND_PROFILING | 637 #endif // ENABLE_LOGGING_AND_PROFILING |
| 701 | 638 |
| 702 } } // namespace v8::internal | 639 } } // namespace v8::internal |
| OLD | NEW |