diff --git a/SimpleBaseLib/src/Misc/SbpBinaryPrimitives.pas b/SimpleBaseLib/src/Misc/SbpBinaryPrimitives.pas index ec4300a..597d50b 100644 --- a/SimpleBaseLib/src/Misc/SbpBinaryPrimitives.pas +++ b/SimpleBaseLib/src/Misc/SbpBinaryPrimitives.pas @@ -145,56 +145,80 @@ class procedure TBinaryPrimitives.CheckBounds(const AData: TSimpleBaseLibByteArr class function TBinaryPrimitives.LeToNativeUInt16(AValue: UInt16): UInt16; begin -{$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} - Result := AValue; +{$IFDEF FPC} + Result := LEtoN(AValue); {$ELSE} + {$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} + Result := AValue; + {$ELSE} Result := TBitOperations.ReverseBytesUInt16(AValue); -{$ENDIF} + {$ENDIF SIMPLEBASELIB_LITTLE_ENDIAN} +{$ENDIF FPC} end; class function TBinaryPrimitives.LeToNativeUInt32(AValue: UInt32): UInt32; begin -{$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} - Result := AValue; +{$IFDEF FPC} + Result := LEtoN(AValue); {$ELSE} + {$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} + Result := AValue; + {$ELSE} Result := TBitOperations.ReverseBytesUInt32(AValue); -{$ENDIF} + {$ENDIF SIMPLEBASELIB_LITTLE_ENDIAN} +{$ENDIF FPC} end; class function TBinaryPrimitives.LeToNativeUInt64(AValue: UInt64): UInt64; begin -{$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} - Result := AValue; +{$IFDEF FPC} + Result := LEtoN(AValue); {$ELSE} + {$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} + Result := AValue; + {$ELSE} Result := TBitOperations.ReverseBytesUInt64(AValue); -{$ENDIF} + {$ENDIF SIMPLEBASELIB_LITTLE_ENDIAN} +{$ENDIF FPC} end; class function TBinaryPrimitives.BeToNativeUInt16(AValue: UInt16): UInt16; begin -{$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} - Result := TBitOperations.ReverseBytesUInt16(AValue); +{$IFDEF FPC} + Result := BEtoN(AValue); {$ELSE} + {$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} + Result := TBitOperations.ReverseBytesUInt16(AValue); + {$ELSE} Result := AValue; -{$ENDIF} + {$ENDIF SIMPLEBASELIB_LITTLE_ENDIAN} +{$ENDIF FPC} end; class function TBinaryPrimitives.BeToNativeUInt32(AValue: UInt32): UInt32; begin -{$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} - Result := TBitOperations.ReverseBytesUInt32(AValue); +{$IFDEF FPC} + Result := BEtoN(AValue); {$ELSE} + {$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} + Result := TBitOperations.ReverseBytesUInt32(AValue); + {$ELSE} Result := AValue; -{$ENDIF} + {$ENDIF SIMPLEBASELIB_LITTLE_ENDIAN} +{$ENDIF FPC} end; class function TBinaryPrimitives.BeToNativeUInt64(AValue: UInt64): UInt64; begin -{$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} - Result := TBitOperations.ReverseBytesUInt64(AValue); +{$IFDEF FPC} + Result := BEtoN(AValue); {$ELSE} + {$IFDEF SIMPLEBASELIB_LITTLE_ENDIAN} + Result := TBitOperations.ReverseBytesUInt64(AValue); + {$ELSE} Result := AValue; -{$ENDIF} + {$ENDIF SIMPLEBASELIB_LITTLE_ENDIAN} +{$ENDIF FPC} end; // ============================================================================