Skip to content

Improve ARMv7 support #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 23, 2015
Merged

Improve ARMv7 support #169

merged 6 commits into from
Dec 23, 2015

Conversation

hpux735
Copy link
Contributor

@hpux735 hpux735 commented Dec 21, 2015

This pull request addresses two issues. The first is that Int is used in NSXMLNodeOptions, but it tries to "set the high 12 bits" to '1'. The problem is that swift (correctly) identifies this as an overflow on a signed Int. If it is necessary for this to be Int, I suppose that an overflow bitwise or could be used (does such an operator exist?).

The second bit is a hard-coding of the ABI on ARM. This is a stopgap until it can either be provided by the swift/utils/build-script, or is correctly detected.

@phausler
Copy link
Contributor

unfortunately again this is an API change, the declared types for arm 32 bit and i386 are Int due to the conversion from NSUInteger to Int; the two ways to approach cross arch compatibility here are to either change these to be in the form

public let NSXMLNodePromoteSignificantWhitespace = 1 << 28

or

#if arch(x86_64) // and other 64 bit arches go here
public var NSXMLNodePreserveCharacterReferences: Int { return 1 << 27 }
#else
public var NSXMLNodePreserveCharacterReferences: Int64 { return 1 << 27 }
#endif

I agree that the signed type is inappropriate for these values; but the swift importer changes all access of NSUInteger to Int so either a) we would need to change the declaration in NSXML* on darwin or b) make an exception for 32 bit targets on the open source version.

@hpux735
Copy link
Contributor Author

hpux735 commented Dec 22, 2015

It seems like it’s not such a bad thing to define it to 64-bit on 32-bit platforms. It’s a bit wasteful, but if on the off-chance that someone sends these values from one platform to another, at least they’ll match in size.

On Dec 22, 2015, at 12:11 PM, Philippe Hausler [email protected] wrote:

unfortunately again this is an API change, the declared types for arm 32 bit and i386 are Int due to the conversion from NSUInteger to Int; the two ways to approach cross arch compatibility here are to either change these to be in the form

public let NSXMLNodePromoteSignificantWhitespace = 1 << 28
or

#if arch(x86_64) // and other 64 bit arches go here
public var NSXMLNodePreserveCharacterReferences: Int { return 1 << 27 }
#else
public var NSXMLNodePreserveCharacterReferences: Int64 { return 1 << 27 }
#endif
I agree that the signed type is inappropriate for these values; but the swift importer changes all access of NSUInteger to Int so either a) we would need to change the declaration in NSXML* on darwin or b) make an exception for 32 bit targets on the open source version.


Reply to this email directly or view it on GitHub #169 (comment).

@phausler
Copy link
Contributor

perhaps it might be worthwhile to have a define for 32 bit platforms so that the #if statement can be simple (id guess this won't be the last place we are going to hit with this issue)

@hpux735
Copy link
Contributor Author

hpux735 commented Dec 23, 2015

Yes, I suspect that would be useful. For now, though, do you think a typealias would be appropriate here? I would rather not have the entire file be copy & paste. Something along the lines of:

#if arch(x86_64) 
typealias XMLNodeOptionRawType Int
#else
typealias XMLNodeOptionRawType Int64
#endif

public var NSXMLNodeOptionsNone: XMLNodeOptionRawType { return 0 }

The potential ugliness here (assuming that I understand it well enough that this would work) is that I suspect that alias would start showing up in autocompletes, leading to confusion.

@phausler
Copy link
Contributor

Type alias would be fine, however until we drop the NS prefix, perhaps this should be NSXMLNodeOptionRawType just for consistency sake when the mass change will be applied.

This is intended to smooth issues with alternate
definitions of Int on 32/64 bit platforms.
@phausler
Copy link
Contributor

looks good to me; merging in with one slight addendum to add arm64 checks too

phausler added a commit that referenced this pull request Dec 23, 2015
@phausler phausler merged commit 25d5910 into swiftlang:master Dec 23, 2015
@hpux735
Copy link
Contributor Author

hpux735 commented Dec 23, 2015

Thanks so much! Have a great break!

atrick pushed a commit to atrick/swift-corelibs-foundation that referenced this pull request Jan 12, 2021
[diagnostics] Fix caching of diagnostics across files and reopens
kateinoigakukun pushed a commit to kateinoigakukun/swift-corelibs-foundation that referenced this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants