This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
register_printf_specifier
- From: Geoff Winkless <geoff at defgeoff dot co dot uk>
- To: libc-help at sourceware dot org
- Date: Wed, 7 Jan 2015 17:29:39 +0000
- Subject: register_printf_specifier
- Authentication-results: sourceware.org; auth=none
Hi
I'm working on a printf hook and the example code
https://sourceware.org/bugzilla/attachment.cgi?id=3874 is very useful;
however I'm a little confused by the xmm_ais function - it doesn't
seem to be checking info->user for any of the modifier values.
I was expecting something like:
static int
xmm_ais (const struct printf_info *info, size_t n, int *argtype, int *size)
{
if (info->user & mod_v4f) {
argtype[0] = pa_xmm;
size[0] = sizeof (__m128);
return 1;
} else if (info->user & mod_v2d) {
argtype[0] = pa_xmm;
size[0]=sizeof(__m128d);
} else if /* other mod_ checks here */ .... {
// now do the original sizes
} else if (info->is_long_double) {
argtype[0]=PA_DOUBLE | PA_FLAG_LONG_DOUBLE;
size[0]=sizeof(long double);
} else if (info->is_long) {
argtype[0]=PA_DOUBLE;
size[0]=sizeof(double);
} else {
argtype[0]=PA_FLOAT;
size[0]=sizeof(float);
}
return 1;
}
Is this simply because the arginfo function doesn't need to be
accurate as long as the argtype is as large as the largest possible
expected value?
My question really is, can I rely on this behaviour going forward and
simply set size[0] to the maximum I expect?
Apologies if this is either the wrong place for this question or it's
answered elsewhere, I really have spent quite some time searching for
answers on the Right Way to use these hooks.
Thanks!
Geoff