You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/11/20 22:06:00 UTC

[jira] [Commented] (DISPATCH-2270) Do not rely on long type being large enough to transfer C pointer values from C to Python

    [ https://issues.apache.org/jira/browse/DISPATCH-2270?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17446881#comment-17446881 ] 

ASF GitHub Bot commented on DISPATCH-2270:
------------------------------------------

jiridanek commented on pull request #1409:
URL: https://github.com/apache/qpid-dispatch/pull/1409#issuecomment-974717940


   This is IMO useful on all platforms, so it can be merged even if Windows is to remain unsupported.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Do not rely on long type being large enough to transfer C pointer values from C to Python
> -----------------------------------------------------------------------------------------
>
>                 Key: DISPATCH-2270
>                 URL: https://issues.apache.org/jira/browse/DISPATCH-2270
>             Project: Qpid Dispatch
>          Issue Type: Sub-task
>    Affects Versions: 1.17.0
>            Reporter: Jiri Daněk
>            Priority: Major
>
> {code}
> // We pass pointers as longs via the python interface, make sure this is safe.
> STATIC_ASSERT(sizeof(long) >= sizeof(void*), pointer_is_bigger_than_long);
> {code}
> This is wrong on Win64, where long is 4 bytes. There is multiple possible solutions:
> # use {{long long}}, trivial workaround
> ** https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue
> # construct the python value explicitly, probably the nicest solution, and should not even add extra overhead
> ** https://docs.python.org/3/c-api/long.html#c.PyLong_FromVoidPtr
> # use PyCapsules, not a good fit for existing code, requires changing signature in C on the callee side
> ** https://docs.python.org/3/c-api/capsule.html
> ** https://docs.python.org/3/extending/extending.html?highlight=capsule#providing-a-c-api-for-an-extension-module
> and maybe even more possibilities. I am inclined to go with the PyLong_FromVoidPtr value constructor.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org