Index: src/platform.h |
diff --git a/src/platform.h b/src/platform.h |
index 14f4551f372e2c5faed9e9f8312ad1ab84a0c519..7a32229b5bc6b506e0149c82927bad438232c6f5 100644 |
--- a/src/platform.h |
+++ b/src/platform.h |
@@ -71,6 +71,24 @@ int signbit(double x); |
int strncasecmp(const char* s1, const char* s2, int n); |
+inline int lrint(double flt) { |
+ int intgr; |
+#if defined(V8_TARGET_ARCH_IA32) |
+ __asm { |
+ fld flt |
+ fistp intgr |
+ }; |
+#else |
+ intgr = static_cast<int>(flt + 0.5); |
+ if ((intgr & 1) != 0 && intgr - flt == 0.5) { |
+ // If the number is halfway between two integers, round to the even one. |
+ intgr--; |
+ } |
+ return intgr; |
+#endif |
+} |
+ |
+ |
#endif // _MSC_VER |
// Random is missing on both Visual Studio and MinGW. |