Skip to content

dispatch: make public interfaces LLP64 friendly #409

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 1 commit into from
Nov 5, 2018

Conversation

compnerd
Copy link
Member

This attempts to replace the public uses of unsigned long with
uintptr_t and long with intptr_t. The use of long and unsigned long here was as a type suitable for matching pointer width. However,
on LLP64 targets, this does not hold. Replace them with intptr_t
which gives a proper pointer sized type. This is done only for the
argument types and not for named types to ensure that the ABI is not
modified for C++ (where a template may be specialized on the named
type).

@compnerd
Copy link
Member Author

CC: @parkera @das @MadCoder

@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

CC: @ktopley-apple

This attempts to replace the public uses of `unsigned long` with
`uintptr_t` and `long` with `intptr_t`.  The use of `long` and `unsigned
long` here was as a type suitable for matching pointer width.  However,
on LLP64 targets, this does not hold.  Replace them with `intptr_t`
which gives a proper pointer sized type.  This is done only for the
argument types and not for named types to ensure that the ABI is not
modified for C++ (where a template may be specialized on the named
type).
@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

Okay, so, this almost works for everything. The problem becomes dispatch_block_flags_t which is a named type and a typed enumeration. The current enumeration is typedefed to an unsigned long which is not machine word sized on LLP64. Changing the underlying type to uintptr_t would resolve the issue. However, doing so would change the underlying type, which is a problem for C++ code. This would matter specifically where dispatch_block_flags_t is used for a C++ function definition or used in a template specialization, where the change to the underlying type would result in a decoration change and thus break ABI. This obviously would not change the interfaces for libdispatch itself as it is a pure C library. I would love some hints on how to best address that particular type (Is it acceptable to break users in such a way? Or do we want to change the underlying type only on certain targets?)

@compnerd
Copy link
Member Author

Once we know if we can break the ABI or not, we can figure out what to do with #414. If we can break the ABI for C++ users, then that should just work.

@ktopley-apple ktopley-apple merged commit 9ec95bf into swiftlang:master Nov 5, 2018
@compnerd compnerd deleted the llp64 branch November 5, 2018 18:13
rokhinip pushed a commit that referenced this pull request Nov 5, 2021
dispatch: make public interfaces LLP64 friendly
Signed-off-by: Kim Topley <[email protected]>
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.

3 participants