guiyanakuang commented on a change in pull request #917: URL: https://github.com/apache/orc/pull/917#discussion_r717771143
########## File path: c++/include/orc/orc-config.hh.in ########## @@ -75,4 +75,38 @@ } #endif +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) + namespace orc { + /** + * Compute value * repetitions, return false if overflow, return true otherwise + * and save the result at the address pointed to by result + * imitates the jdk Math.multiplyExact implementation + * but this method makes the assumption that repetitions > 1 + */ + static bool multiplyExact(int64_t value, int64_t repetitions, int64_t* result) { + int64_t r = value * repetitions; + if (((value < 0 ? -value : value) | repetitions) >> 31 != 0 && r / repetitions != value) { + return false; + } + *result = r; + return true; + } Review comment: Hi @dongjoon-hyun @wgtmac. Finally passed the test. But it needs a strict review. The window environment overflow check I've mimicked the JDK implementation. If there is a better way, please let me know. In fact it doesn't work well on clang (the compiler has some unknown behaviour that I don't know about) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@orc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org