| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 VPrint(format, args); | 681 VPrint(format, args); |
| 682 va_end(args); | 682 va_end(args); |
| 683 } | 683 } |
| 684 | 684 |
| 685 | 685 |
| 686 void OS::VPrint(const char* format, va_list args) { | 686 void OS::VPrint(const char* format, va_list args) { |
| 687 VPrintHelper(stdout, format, args); | 687 VPrintHelper(stdout, format, args); |
| 688 } | 688 } |
| 689 | 689 |
| 690 | 690 |
| 691 void OS::FPrint(FILE* out, const char* format, ...) { |
| 692 va_list args; |
| 693 va_start(args, format); |
| 694 VFPrint(out, format, args); |
| 695 va_end(args); |
| 696 } |
| 697 |
| 698 |
| 699 void OS::VFPrint(FILE* out, const char* format, va_list args) { |
| 700 VPrintHelper(out, format, args); |
| 701 } |
| 702 |
| 703 |
| 691 // Print error message to console. | 704 // Print error message to console. |
| 692 void OS::PrintError(const char* format, ...) { | 705 void OS::PrintError(const char* format, ...) { |
| 693 va_list args; | 706 va_list args; |
| 694 va_start(args, format); | 707 va_start(args, format); |
| 695 VPrintError(format, args); | 708 VPrintError(format, args); |
| 696 va_end(args); | 709 va_end(args); |
| 697 } | 710 } |
| 698 | 711 |
| 699 | 712 |
| 700 void OS::VPrintError(const char* format, va_list args) { | 713 void OS::VPrintError(const char* format, va_list args) { |
| 701 VPrintHelper(stderr, format, args); | 714 VPrintHelper(stderr, format, args); |
| 702 } | 715 } |
| 703 | 716 |
| 704 | 717 |
| 705 int OS::SNPrintF(Vector<char> str, const char* format, ...) { | 718 int OS::SNPrintF(Vector<char> str, const char* format, ...) { |
| 706 va_list args; | 719 va_list args; |
| 707 va_start(args, format); | 720 va_start(args, format); |
| 708 int result = VSNPrintF(str, format, args); | 721 int result = VSNPrintF(str, format, args); |
| 709 va_end(args); | 722 va_end(args); |
| 710 return result; | 723 return result; |
| 711 } | 724 } |
| 712 | 725 |
| 713 | 726 |
| 714 int OS::VSNPrintF(Vector<char> str, const char* format, va_list args) { | 727 int OS::VSNPrintF(Vector<char> str, const char* format, va_list args) { |
| 715 int n = _vsnprintf_s(str.start(), str.length(), _TRUNCATE, format, args); | 728 int n = _vsnprintf_s(str.start(), str.length(), _TRUNCATE, format, args); |
| 716 // Make sure to zero-terminate the string if the output was | 729 // Make sure to zero-terminate the string if the output was |
| 717 // truncated or if there was an error. | 730 // truncated or if there was an error. |
| 718 if (n < 0 || n >= str.length()) { | 731 if (n < 0 || n >= str.length()) { |
| 719 str[str.length() - 1] = '\0'; | 732 if (str.length() > 0) |
| 733 str[str.length() - 1] = '\0'; |
| 720 return -1; | 734 return -1; |
| 721 } else { | 735 } else { |
| 722 return n; | 736 return n; |
| 723 } | 737 } |
| 724 } | 738 } |
| 725 | 739 |
| 726 | 740 |
| 727 char* OS::StrChr(char* str, int c) { | 741 char* OS::StrChr(char* str, int c) { |
| 728 return const_cast<char*>(strchr(str, c)); | 742 return const_cast<char*>(strchr(str, c)); |
| 729 } | 743 } |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 | 1920 |
| 1907 // Release the thread handles | 1921 // Release the thread handles |
| 1908 CloseHandle(data_->sampler_thread_); | 1922 CloseHandle(data_->sampler_thread_); |
| 1909 CloseHandle(data_->profiled_thread_); | 1923 CloseHandle(data_->profiled_thread_); |
| 1910 } | 1924 } |
| 1911 | 1925 |
| 1912 | 1926 |
| 1913 #endif // ENABLE_LOGGING_AND_PROFILING | 1927 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1914 | 1928 |
| 1915 } } // namespace v8::internal | 1929 } } // namespace v8::internal |
| OLD | NEW |