Skip to content

Commit cee7efc

Browse files
author
Max Moiseev
committed
Un-implement dividingFullWidth for 64bit types on 32bit platforms
The implementation uses DoubleWidth<T> that needs to be removed due to library binary size issues. Even extracting the single DoubleWidth method that's used in it would likely result in having to copy a large portion of the rest of DoubleWidth implementation along with it, this defeating the purpose. This change restores the behavior of dividingFullWidth as it was shipped with Swift 4.1, therefore it's not a breaking change.
1 parent 8ebb45f commit cee7efc

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

stdlib/public/core/Integers.swift.gyb

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3552,23 +3552,11 @@ ${assignmentOperatorComment(x.operator, True)}
35523552
) -> (quotient: ${Self}, remainder: ${Self}) {
35533553
// FIXME(integers): tests
35543554
% # 128-bit types are not provided by the 32-bit LLVM
3555-
% #if word_bits == 32 and bits == 64:
3555+
% if word_bits == 32 and bits == 64:
35563556
% # FIXME(integers): uncomment the above after using the right conditional
35573557
% # compilation block to exclude 64-bit Windows, which does not support
35583558
% # 128-bit operations
3559-
% if bits == 64:
3560-
% HalfWidth = 'Int32' if signed else 'UInt32'
3561-
let lhsHigh =
3562-
unsafeBitCast(dividend.high, to: DoubleWidth<${HalfWidth}>.self)
3563-
let lhsLow = unsafeBitCast(dividend.low, to: DoubleWidth<UInt32>.self)
3564-
let rhs_ = unsafeBitCast(self, to: DoubleWidth<${HalfWidth}>.self)
3565-
3566-
let (quotient_, remainder_) = rhs_.dividingFullWidth((lhsHigh, lhsLow))
3567-
3568-
let quotient = unsafeBitCast(quotient_, to: ${Self}.self)
3569-
let remainder = unsafeBitCast(remainder_, to: ${Self}.self)
3570-
3571-
return (quotient: quotient, remainder: remainder)
3559+
fatalError("Operation is not supported")
35723560
% else:
35733561
// FIXME(integers): handle division by zero and overflows
35743562
_precondition(self != 0, "Division by zero")

0 commit comments

Comments
 (0)