Uploaded image for project: 'Qpid Dispatch'
  1. Qpid Dispatch
  2. DISPATCH-2027 Support the Windows OS
  3. DISPATCH-2270

Do not rely on long type being large enough to transfer C pointer values from C to Python

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.17.0
    • 1.19.0
    • None
    • None

    Description

      // 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);
      

      This is wrong on Win64, where long is 4 bytes. There is multiple possible solutions:

      1. use long long, trivial workaround
      2. construct the python value explicitly, probably the nicest solution, and should not even add extra overhead
      3. use PyCapsules, not a good fit for existing code, requires changing signature in C on the callee side

      and maybe even more possibilities. I am inclined to go with the PyLong_FromVoidPtr value constructor.

      Attachments

        Activity

          People

            jdanek Jiri Daněk
            jdanek Jiri Daněk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: