On 06/03/2019 17:52, Wei Liu wrote: > @@ -128,16 +154,25 @@ fsimage_file_dealloc(fsimage_file_t *file) > PyObject_DEL(file); > } > > +/* Compatibility for 2.5 and earlier */ > +#ifndef PyVarObject_HEAD_INIT > +#define PyVarObject_HEAD_INIT(type, size) \ > + PyObject_HEAD_INIT(type) size, > +#endif > + > static char fsimage_file_type__doc__[] = "Filesystem image file"; > PyTypeObject fsimage_file_type = { > - PyObject_HEAD_INIT(&PyType_Type) > - 0, /* ob_size */ > + PyVarObject_HEAD_INIT(&PyType_Type, 0) > "xenfsimage.file", /* tp_name */ > sizeof(fsimage_file_t), /* tp_size */ > 0, /* tp_itemsize */ > (destructor) fsimage_file_dealloc, /* tp_dealloc */ > 0, /* tp_print */ > +#if PY_MAJOR_VERSION < 3 > (getattrfunc) fsimage_file_getattr, /* tp_getattr */ > +#else > + 0, /* tp_getattr */ > +#endif > 0, /* tp_setattr */ > 0, /* tp_compare */ > 0, /* tp_repr */ > @@ -151,7 +186,16 @@ PyTypeObject fsimage_file_type = { > 0, /* tp_setattro */ > 0, /* tp_as_buffer */ > Py_TPFLAGS_DEFAULT, /* tp_flags */ > - fsimage_file_type__doc__, > + fsimage_file_type__doc__, /* tp_doc */ > +#if PY_MAJOR_VERSION >= 3 > + 0, /* tp_traverse */ > + 0, /* tp_clear */ > + 0, /* tp_richcompare */ > + 0, /* tp_weaklistoffset */ > + 0, /* tp_iter */ > + 0, /* tp_iternext */ > + fsimage_file_methods, /* tp_methods */ > +#endif > PY_PAD
PY_PAD is very WTF. I've got no idea why it is necessary in the first place. Either way, most of the fields are zero, so why not use named initialisation? PyTypeObject fsimage_file_type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "xenfsimage.file", .tp_size = sizeof(fsimage_file_t), ... }; ~Andrew _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel