[Libre-soc-bugs] [Bug 981] Support PowerPC ABI in cavatools

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Fri Sep 22 14:42:11 BST 2023


https://bugs.libre-soc.org/show_bug.cgi?id=981

--- Comment #18 from Luke Kenneth Casson Leighton <lkcl at lkcl.net> ---
(In reply to Luke Kenneth Casson Leighton from comment #17)

> there will be literally dozens of examples online.

*snort*. how hard is that.
https://realpython.com/build-python-c-extension-module/

#include <Python.h>

static PyObject *method_fputs(PyObject *self, PyObject *args) {
    char *str, *filename = NULL;
    int bytes_copied = -1;

    /* Parse arguments */
    if(!PyArg_ParseTuple(args, "ss", &str, &filename)) {
        return NULL;
    }

    FILE *fp = fopen(filename, "w");
    bytes_copied = fputs(str, fp);
    fclose(fp);

    return PyLong_FromLong(bytes_copied);
}

modify that PyArgParseTuple to be a bunch of ints (from the GPR)
put the syscall in place of fopen/fputs/fc!ose, blat, done

if you really want to get fancy pass a list of the GPRs and use
the example here to do it, remember to correct the example by
using PyLong_AsLong as advised in the answers

https://stackoverflow.com/questions/48328309/pass-python-list-of-ints-to-c-function-using-python-c-api

PyTuple is faster but i could not immediately find a suitable example
to cut/paste. getting the GPRs as a list is just of
course list(self.sim.values())

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the libre-soc-bugs mailing list