wgtmac commented on a change in pull request #917:
URL: https://github.com/apache/orc/pull/917#discussion_r718126855



##########
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:
       `#ifdef _MSC_VER` is enough to assert that it is on Windows. You may 
also leverage cmake_modules/CheckSourceCompiles.cmake to figure out if the gcc 
builtin functions are available or not. BTW, orc-config.hh.in is to address 
capability of older c++ standards. If would be better to handle these kinds of 
functions in Adaptor.hh.in.




-- 
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


Reply via email to