| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 28 // Platform specific code for Win32. | 28 // Platform specific code for Win32. |
| 29 | 29 |
| 30 #define V8_WIN32_HEADERS_FULL | 30 #define V8_WIN32_HEADERS_FULL |
| 31 #include "win32-headers.h" | 31 #include "win32-headers.h" |
| 32 | 32 |
| 33 #include "v8.h" | 33 #include "v8.h" |
| 34 | 34 |
| 35 #include "platform.h" | 35 #include "platform.h" |
| 36 #include "vm-state-inl.h" | 36 #include "vm-state-inl.h" |
| 37 | 37 |
| 38 // Extra POSIX/ANSI routines for Win32 when when using Visual Studio C++. Please | |
| 39 // refer to The Open Group Base Specification for specification of the correct | |
| 40 // semantics for these functions. | |
| 41 // (http://www.opengroup.org/onlinepubs/000095399/) | |
| 42 #ifdef _MSC_VER | 38 #ifdef _MSC_VER |
| 43 | 39 |
| 44 namespace v8 { | |
| 45 namespace internal { | |
| 46 | |
| 47 // Test for finite value - usually defined in math.h | |
| 48 int isfinite(double x) { | |
| 49 return _finite(x); | |
| 50 } | |
| 51 | |
| 52 } // namespace v8 | |
| 53 } // namespace internal | |
| 54 | |
| 55 // Test for a NaN (not a number) value - usually defined in math.h | |
| 56 int isnan(double x) { | |
| 57 return _isnan(x); | |
| 58 } | |
| 59 | |
| 60 | |
| 61 // Test for infinity - usually defined in math.h | |
| 62 int isinf(double x) { | |
| 63 return (_fpclass(x) & (_FPCLASS_PINF | _FPCLASS_NINF)) != 0; | |
| 64 } | |
| 65 | |
| 66 | |
| 67 // Test if x is less than y and both nominal - usually defined in math.h | |
| 68 int isless(double x, double y) { | |
| 69 return isnan(x) || isnan(y) ? 0 : x < y; | |
| 70 } | |
| 71 | |
| 72 | |
| 73 // Test if x is greater than y and both nominal - usually defined in math.h | |
| 74 int isgreater(double x, double y) { | |
| 75 return isnan(x) || isnan(y) ? 0 : x > y; | |
| 76 } | |
| 77 | |
| 78 | |
| 79 // Classify floating point number - usually defined in math.h | |
| 80 int fpclassify(double x) { | |
| 81 // Use the MS-specific _fpclass() for classification. | |
| 82 int flags = _fpclass(x); | |
| 83 | |
| 84 // Determine class. We cannot use a switch statement because | |
| 85 // the _FPCLASS_ constants are defined as flags. | |
| 86 if (flags & (_FPCLASS_PN | _FPCLASS_NN)) return FP_NORMAL; | |
| 87 if (flags & (_FPCLASS_PZ | _FPCLASS_NZ)) return FP_ZERO; | |
| 88 if (flags & (_FPCLASS_PD | _FPCLASS_ND)) return FP_SUBNORMAL; | |
| 89 if (flags & (_FPCLASS_PINF | _FPCLASS_NINF)) return FP_INFINITE; | |
| 90 | |
| 91 // All cases should be covered by the code above. | |
| 92 ASSERT(flags & (_FPCLASS_SNAN | _FPCLASS_QNAN)); | |
| 93 return FP_NAN; | |
| 94 } | |
| 95 | |
| 96 | |
| 97 // Test sign - usually defined in math.h | |
| 98 int signbit(double x) { | |
| 99 // We need to take care of the special case of both positive | |
| 100 // and negative versions of zero. | |
| 101 if (x == 0) | |
| 102 return _fpclass(x) & _FPCLASS_NZ; | |
| 103 else | |
| 104 return x < 0; | |
| 105 } | |
| 106 | |
| 107 | |
| 108 // Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually | 40 // Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually |
| 109 // defined in strings.h. | 41 // defined in strings.h. |
| 110 int strncasecmp(const char* s1, const char* s2, int n) { | 42 int strncasecmp(const char* s1, const char* s2, int n) { |
| 111 return _strnicmp(s1, s2, n); | 43 return _strnicmp(s1, s2, n); |
| 112 } | 44 } |
| 113 | 45 |
| 114 #endif // _MSC_VER | 46 #endif // _MSC_VER |
| 115 | 47 |
| 116 | 48 |
| 117 // Extra functions for MinGW. Most of these are the _s functions which are in | 49 // Extra functions for MinGW. Most of these are the _s functions which are in |
| (...skipping 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 | 1970 |
| 2039 | 1971 |
| 2040 void Sampler::Stop() { | 1972 void Sampler::Stop() { |
| 2041 ASSERT(IsActive()); | 1973 ASSERT(IsActive()); |
| 2042 SamplerThread::RemoveActiveSampler(this); | 1974 SamplerThread::RemoveActiveSampler(this); |
| 2043 SetActive(false); | 1975 SetActive(false); |
| 2044 } | 1976 } |
| 2045 | 1977 |
| 2046 | 1978 |
| 2047 } } // namespace v8::internal | 1979 } } // namespace v8::internal |
| OLD | NEW |