Skip to content
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

gh-111178: Fix function signatures in longobject.c #124895

Merged
merged 2 commits into from
Oct 2, 2024

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 2, 2024

  • Add _PyLong_CAST() macro.
  • Move forward declarations to the top of longobject.c.
  • Change long_add(), long_sub(), long_mul(), long_neg(), long_lshift(), long_abs() to take PyLongObject* and return PyLongObject*. Avoid CHECK_BINOP() test.
  • Add long_add_method(), long_sub_method(), long_mul_method(), long_neg_method(), long_lshift_method(), and long_abs_method() which take PyObject* and return PyObject*. Implement CHECK_BINOP() test.
  • Add long_lshift_int64() function.
  • _PyLong_DivmodNear() calls long_lshift_int64(obj, 1) instead of long_lshift_obj(obj, one).

* Add _PyLong_CAST() macro.
* Move forward declarations to the top of longobject.c.
* Change long_add(), long_sub(), long_mul(), long_neg(),
  long_lshift(), long_abs() to take PyLongObject* and return
  PyLongObject*. Avoid CHECK_BINOP() test.
* Add long_add_method(), long_sub_method(), long_mul_method(),
  long_neg_method(), long_lshift_method(), and long_abs_method()
  which take PyObject* and return PyObject*. Implement CHECK_BINOP()
  test.
* Add long_lshift_int64() function.
* _PyLong_DivmodNear() calls long_lshift_int64(obj, 1) instead of
  long_lshift_obj(obj, one).
@vstinner
Copy link
Member Author

vstinner commented Oct 2, 2024

I didn't fix the warning on the signature generated by Argument Clinic:

Objects/methodobject.c:441:24: runtime error: call to function int_from_bytes through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *const *, long, struct _object *)'
/home/vstinner/python/main/Objects/clinic/longobject.c.h:396: note: int_from_bytes defined here

@vstinner vstinner closed this Oct 2, 2024
@vstinner vstinner reopened this Oct 2, 2024
@vstinner
Copy link
Member Author

vstinner commented Oct 2, 2024

The CI was stuck, so I closed/reopened the PR.

@vstinner vstinner merged commit 113b2d7 into python:main Oct 2, 2024
37 of 52 checks passed
@vstinner vstinner deleted the ubsan_long branch October 2, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant