Skip to content

Commit

Permalink
Merge pull request #341 from python-greenlet/issue302
Browse files Browse the repository at this point in the history
Stop using 'const PyObject*', per @vstinner
  • Loading branch information
jamadden committed Jan 27, 2023
2 parents 880825b + 616df60 commit ae570c5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U twine
- name: Install greenlet
- name: Install greenlet (non-Mac)
if: ${{ ! startsWith(runner.os, 'Mac') }}
run: |
python setup.py bdist_wheel
python -m pip install -U -e ".[test,docs]"
Expand All @@ -53,6 +54,18 @@ jobs:
# process-wide effects), we test with Ofast here, because we
# expect that some people will compile it themselves with that setting.
CPPFLAGS: "-Ofast -UNDEBUG"
- name: Install greenlet (Mac)
if: startsWith(runner.os, 'Mac')
run: |
python setup.py bdist_wheel
python -m pip install -U -e ".[test,docs]"
env:
# Unlike the above, we are actually distributing these
# wheels, so they need to be built for production use.
CPPFLAGS: "-O3"
# Build for both architectures
ARCHFLAGS: "-arch x86_64 -arch arm64"

- name: Check greenlet build
run: |
ls -l dist
Expand Down
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
- Fix calling ``greenlet.settrace()`` with the same tracer object that
was currently active. See `issue 332
<https://github.com/python-greenlet/greenlet/issues/332>`_.
- Various compilation and standards conformance fixes. See #335, #336, #300.
- Various compilation and standards conformance fixes. See #335, #336,
#300, #302.



2.0.1 (2022-11-07)
Expand Down
14 changes: 7 additions & 7 deletions src/greenlet/greenlet_refs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ namespace greenlet {
inline OwnedObject PyRequireAttr(const ImmortalObject& name) const;
inline OwnedObject PyCall(const BorrowedObject& arg) const;
inline OwnedObject PyCall(PyGreenlet* arg) const ;
inline OwnedObject PyCall(const PyObject* arg) const ;
inline OwnedObject PyCall(PyObject* arg) const ;
// PyObject_Call(this, args, kwargs);
inline OwnedObject PyCall(const BorrowedObject args,
const BorrowedObject kwargs) const;
Expand Down Expand Up @@ -714,11 +714,11 @@ namespace greenlet {
template<typename T, TypeChecker TC>
inline OwnedObject PyObjectPointer<T, TC>::PyCall(PyGreenlet* arg) const
{
return this->PyCall(reinterpret_cast<const PyObject*>(arg));
return this->PyCall(reinterpret_cast<PyObject*>(arg));
}

template<typename T, TypeChecker TC>
inline OwnedObject PyObjectPointer<T, TC>::PyCall(const PyObject* arg) const
inline OwnedObject PyObjectPointer<T, TC>::PyCall(PyObject* arg) const
{
assert(this->p);
return OwnedObject::consuming(PyObject_CallFunctionObjArgs(this->p, arg, NULL));
Expand Down Expand Up @@ -845,16 +845,16 @@ namespace greenlet {
this->PyAddObject(name, new_object.borrow());
}

void PyAddObject(const char* name, const PyTypeObject& type)
void PyAddObject(const char* name, PyTypeObject& type)
{
this->PyAddObject(name, reinterpret_cast<const PyObject*>(&type));
this->PyAddObject(name, reinterpret_cast<PyObject*>(&type));
}

void PyAddObject(const char* name, const PyObject* new_object)
void PyAddObject(const char* name, PyObject* new_object)
{
Py_INCREF(new_object);
try {
Require(PyModule_AddObject(this->p, name, const_cast<PyObject*>(new_object)));
Require(PyModule_AddObject(this->p, name, new_object));
}
catch (const PyErrOccurred&) {
Py_DECREF(p);
Expand Down
11 changes: 10 additions & 1 deletion src/greenlet/platform/switch_aarch64_gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ slp_switch(void)
{
int err;
void *fp;
register long *stackref, stsizediff;
long *stackref, stsizediff;
__asm__ volatile ("" : : : REGS_TO_SAVE);
__asm__ volatile ("str x29, %0" : "=m"(fp) : : );
__asm__ ("mov %0, sp" : "=r" (stackref));
Expand Down Expand Up @@ -59,6 +59,15 @@ slp_switch(void)
stack space), and the simplest is to call a function
that returns an unknown value (which happens to be zero),
so the saved/restored value is unused. */
/* XXX: This line produces warnings:

value size does not match register size specified by the
constraint and modifier

The suggested fix is to change %0 to %w0.

TODO: Validate and change that.
*/
__asm__ volatile ("mov %0, #0" : "=r" (err));
}
__asm__ volatile ("ldr x29, %0" : : "m" (fp) :);
Expand Down

0 comments on commit ae570c5

Please sign in to comment.