Priest of the Order of the Butterfly
Posts: 555 from 2012/6/8
From: Hungary
There seems to be some inconsistency with how va_list type arguments are handled for r12base library functions. cvinclude.pl generates inlines like you see for fontconfig.library and tiff.library. For example:
Code:
#define FcPatternVaBuild(__p0, __p1) \
({ \
FcPattern * __t__p0 = __p0;\
va_list __t__p1 = __p1;\
long __base = (long)(FONTCONFIG_BASE_NAME);\
__asm volatile("mr 12,%0": :"r"(__base):"r12");\
(((FcPattern *(*)(FcPattern *, va_list ))*(void**)(__base - 934))(__t__p0, __t__p1));\
})
Code:
#define TIFFVGetFieldDefaulted(__p0, __p1, __p2) \
({ \
TIFF * __t__p0 = __p0;\
ttag_t __t__p1 = __p1;\
va_list __t__p2 = __p2;\
long __base = (long)(TIFF_BASE_NAME);\
__asm volatile("mr 12,%0": :"r"(__base):"r12");\
(((int (*)(TIFF *, ttag_t , va_list ))*(void**)(__base - 178))(__t__p0, __t__p1, __t__p2));\
})
This does work fine with the cross compiler, but with the native compilers the assignments highlighted in bold give an "invalid initializer" error, possible because va_list is some non-POD type there. In sqlite.library this is worked around by using the va_list macro argument directly, without copying it. For example the __p2 argument here:
Code:
#define sqlite3_vlog(__p0, __p1, __p2) \
({ \
int __t__p0 = __p0;\
const char * __t__p1 = __p1;\
long __base = (long)(SQLITE_BASE_NAME);\
__asm volatile("mr 12,%0": :"r"(__base):"r12");\
(((void (*)(int , const char *, va_list ))*(void**)(__base - 1126))(__t__p0, __t__p1, __p2));\
})
Which one of this is correct? If copying the va_list argument is necessary, then it can be done with va_copy, which works with both the native and cross-compiler. For example:
Code:
va_list __t__p2; \
va_copy(__t__p2, __p2); \
It would be nice if cvinclude.pl could be updated to handle this edge case.
This is just like television, only you can see much further.