Quellcode durchsuchen

Fixed (u)int64 MSB/LSB handling on BE archs

Jakub Čajka vor 11 Jahren
Ursprung
Commit
8977e6d010
1 geänderte Dateien mit 4 neuen und 8 gelöschten Zeilen
  1. 4 8
      glm/detail/func_integer.inl

+ 4 - 8
glm/detail/func_integer.inl

@@ -248,10 +248,8 @@ namespace detail
 		GLM_STATIC_ASSERT(sizeof(uint) == sizeof(uint32), "uint and uint32 size mismatch");
 
 		uint64 Value64 = static_cast<uint64>(x) * static_cast<uint64>(y);
-		uint32* PointerMSB = (reinterpret_cast<uint32*>(&Value64) + 1);
-		msb = *PointerMSB;
-		uint32* PointerLSB = (reinterpret_cast<uint32*>(&Value64) + 0);
-		lsb = *PointerLSB;
+		msb = Value64 >> 32;
+		lsb = Value64;
 	}
 
 	template <precision P, template <typename, precision> class vecType>
@@ -270,10 +268,8 @@ namespace detail
 		GLM_STATIC_ASSERT(sizeof(int) == sizeof(int32), "int and int32 size mismatch");
 
 		int64 Value64 = static_cast<int64>(x) * static_cast<int64>(y);
-		int32* PointerMSB = (reinterpret_cast<int32*>(&Value64) + 1);
-		msb = *PointerMSB;
-		int32* PointerLSB = (reinterpret_cast<int32*>(&Value64));
-		lsb = *PointerLSB;
+		msb = Value64 >> 32;
+		lsb = Value64;
 	}
 
 	template <precision P, template <typename, precision> class vecType>