[Groonga-commit] groonga/grnxx at 6ea93eb [new_data_types] Use feature macros. (#96)

Back to archive index

susumu.yata null+****@clear*****
Thu Oct 30 11:41:35 JST 2014


susumu.yata	2014-10-30 11:41:35 +0900 (Thu, 30 Oct 2014)

  New Revision: 6ea93ebfa627d46f6b1609fc03f2010c3d927a04
  https://github.com/groonga/grnxx/commit/6ea93ebfa627d46f6b1609fc03f2010c3d927a04

  Message:
    Use feature macros. (#96)

  Modified files:
    include/grnxx/data_types/scalar/int.hpp

  Modified: include/grnxx/data_types/scalar/int.hpp (+12 -11)
===================================================================
--- include/grnxx/data_types/scalar/int.hpp    2014-10-30 11:41:08 +0900 (391108a)
+++ include/grnxx/data_types/scalar/int.hpp    2014-10-30 11:41:35 +0900 (0c6de11)
@@ -4,6 +4,7 @@
 #include <cstdint>
 #include <limits>
 
+#include "grnxx/features.hpp"
 #include "grnxx/data_types/na.hpp"
 
 namespace grnxx {
@@ -240,8 +241,9 @@ class Int {
  private:
   int64_t value_;
 
-#if defined(GRNXX_HAVE_X86_64)
- #if defined(GRNXX_HAVE_GNUC)
+#if defined(GRNXX_GNUC) && defined(GRNXX_X86_64)
+  // TODO: Implementations for MSC should be written.
+  // NOTE: These implementations use x86_64 instructions for speed.
   static Int add(Int lhs, Int rhs) {
     if (lhs.is_na() || rhs.is_na()) {
       return na();
@@ -281,13 +283,12 @@ class Int {
              : "cc");
     return lhs;
   }
- #else  // !defined(GRNXX_HAVE_GNUC)
-  // TODO: Use assmbly for VC++.
- #endif  // defined(GRNXX_HAVE_GNUC), etc.
-#elif defined(GRNXX_HAVE_WRAP_AROUND)  // !defined(GRNXX_HAVE_X86_64)
-  // NOTE: These implementations assume silent two's complement wrap-around,
-  //       although a signed integer overflow causes undefined behavior in
-  //       C/C++.
+#elif defined(GRNXX_WRAP_AROUND)
+  // TODO: The following implementations should be used if the above
+  //       implementations are not available.
+  // NOTE: These implementations assume silent two's complement wrap-around.
+  //       The C/C++ standards say that a signed integer overflow causes
+  //       undefined behavior.
   static Int add(Int lhs, Int rhs) {
     if (lhs.is_na() || rhs.is_na()) {
       return na();
@@ -325,7 +326,7 @@ class Int {
     }
     return Int(result);
   }
-#else  // !defined(GRNXX_HAVE_X86_64) && !defined(GRNXX_HAVE_WRAP_AROUND)
+# else  // defined(GRNXX_WRAP_AROUND)
   // NOTE: These implementations are portable but slow.
   static Int add(Int lhs, Int rhs) {
     if (lhs.is_na() || rhs.is_na()) {
@@ -385,7 +386,7 @@ class Int {
     }
     return Int(lhs.value_ * rhs.value_);
   }
-#endif  // defined(GRNXX_HAVE_X86_64), etc.
+# endif  // GRNXX_WRAP_AROUND
 };
 
 }  // namespace grnxx
-------------- next part --------------
HTML����������������������������...
Descargar 



More information about the Groonga-commit mailing list
Back to archive index