diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 2158397c8..28244340c 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -28,8 +28,15 @@ 2002-05-06 Jeff Johnston - * libc/include/stdlib.h (a64l, l64a, _l64a_r): Added prototypes. - + * libc/machine/powerpc/vfprintf.c[__ALTIVEC__]: Add vector + support for 'p' format. Fix code to print bytes for vector + integer formats that do not specify 'h' or 'l'. + * libc/machine/powerpc/vfscanf.c[__ALTIVEC__]: Add vector support + for 'p' specifier. Fix code to scan 16 bytes for vector integer + formats that do not specify 'h' or 'l'. + + * libc/include/stdlib.h (a64l, l64a, _l64a_r): Added prototypes. + 2002-05-06 Nick Clifton * libc/sys/arm/syscalls.c (_rename): Add parameter names. diff --git a/newlib/libc/machine/powerpc/vfprintf.c b/newlib/libc/machine/powerpc/vfprintf.c index cf054293b..aed3d704f 100644 --- a/newlib/libc/machine/powerpc/vfprintf.c +++ b/newlib/libc/machine/powerpc/vfprintf.c @@ -196,7 +196,7 @@ typedef union int i[16 / sizeof(int)]; long l[4]; short s[8]; - char c[16]; + signed char c[16]; } vec_16_byte_union; #endif /* __ALTIVEC__ */ @@ -448,15 +448,15 @@ _DEFUN (_VFPRINTF_R, (data, fp, fmt0, ap), #define GET_INT(ap) \ (flags&VECTOR ? \ - (vec_print_count < (16 / sizeof(int)) ? \ - vec_tmp.i[16 / sizeof(int) - vec_print_count] : \ - (vec_tmp.v = va_arg(ap, vector int), vec_tmp.i[0])) : \ + (vec_print_count < 16 ? \ + vec_tmp.c[16 - vec_print_count] : \ + (vec_tmp.v = va_arg(ap, vector int), (int)vec_tmp.c[0])) : \ va_arg(ap, int)) #define GET_UINT(ap) \ (flags&VECTOR ? \ - (vec_print_count < (16 / sizeof(int)) ? \ - (u_int)vec_tmp.i[16 / sizeof(int) - vec_print_count] : \ - (vec_tmp.v = va_arg(ap, vector int), (u_int)vec_tmp.i[0])) : \ + (vec_print_count < 16 ? \ + (u_int)((unsigned char)vec_tmp.c[16 - vec_print_count]) : \ + (vec_tmp.v = va_arg(ap, vector int), (u_int)((unsigned char)vec_tmp.c[0]))) : \ (u_int)va_arg(ap, unsigned int)) #else /* !__ALTIVEC__ */ #define GET_SHORT(ap) ((short)va_arg(ap, int)) @@ -634,7 +634,7 @@ reswitch: switch (ch) { case 'v': flags |= VECTOR; vec_print_count = (flags & SHORTINT) ? 8 : - ((flags & LONGINT) ? 4 : (16 / sizeof(int))); + ((flags & LONGINT) ? 4 : 16); goto rflag; #endif case 'q': @@ -704,8 +704,11 @@ reswitch: switch (ch) { _fpvalue = (double) va_arg(ap, _LONG_DOUBLE); #ifdef __ALTIVEC__ } else if (flags & VECTOR) { - if (vec_print_count == 4) - vec_tmp.v = va_arg(ap, vector int); + if (vec_print_count >= 4) + { + vec_print_count = 4; + vec_tmp.v = va_arg(ap, vector int); + } _fpvalue = (double)vec_tmp.f[4 - vec_print_count]; #endif /* __ALTIVEC__ */ } else { @@ -736,8 +739,11 @@ reswitch: switch (ch) { _fpvalue = va_arg(ap, _LONG_DOUBLE); #ifdef __ALTIVEC__ } else if (flags & VECTOR) { - if (vec_print_count == 4) - vec_tmp.v = va_arg(ap, vector int); + if (vec_print_count >= 4) + { + vec_print_count = 4; + vec_tmp.v = va_arg(ap, vector int); + } _fpvalue = (_LONG_DOUBLE)k.f[4 - vec_print_count]; #endif /* __ALTIVEC__ */ } else { @@ -832,8 +838,12 @@ reswitch: switch (ch) { * -- ANSI X3J11 */ /* NOSTRICT */ - flags &= ~VECTOR; - _uquad = (u_long)(unsigned _POINTER_INT)va_arg(ap, void *); +#ifdef __ALTIVEC__ + if (flags & VECTOR) + _uquad = UARG(); + else +#endif /* __ALTIVEC__ */ + _uquad = (u_long)(unsigned _POINTER_INT)va_arg(ap, void *); base = HEX; xdigs = "0123456789abcdef"; flags |= HEXPREFIX; diff --git a/newlib/libc/machine/powerpc/vfscanf.c b/newlib/libc/machine/powerpc/vfscanf.c index b2ea57274..c0bd0e526 100644 --- a/newlib/libc/machine/powerpc/vfscanf.c +++ b/newlib/libc/machine/powerpc/vfscanf.c @@ -370,7 +370,11 @@ __svfscanf_r (rptr, fp, fmt0, ap) flags |= LONGDBL; } else - flags |= LONG; + { + flags |= LONG; + if (flags & VECTOR) + vec_read_count = 4; + } goto again; case 'L': flags |= LONGDBL; @@ -384,7 +388,7 @@ __svfscanf_r (rptr, fp, fmt0, ap) #ifdef __ALTIVEC__ case 'v': flags |= VECTOR; - vec_read_count = (flags & SHORT) ? 8 : 4; + vec_read_count = (flags & SHORT) ? 8 : ((flags & LONG) ? 4 : 16); goto again; #endif case '0': @@ -485,7 +489,6 @@ __svfscanf_r (rptr, fp, fmt0, ap) case 'p': /* pointer format is like hex */ flags |= POINTER | PFXOK; - flags &= ~VECTOR; type = CT_INT; ccfn = _strtoul_r; base = 16; @@ -918,7 +921,7 @@ __svfscanf_r (rptr, fp, fmt0, ap) *p = 0; res = (*ccfn) (rptr, buf, (char **) NULL, base); - if (flags & POINTER) + if ((flags & POINTER) && !(flags & VECTOR)) *(va_arg (ap, _PTR *)) = (_PTR) (unsigned _POINTER_INT) res; else if (flags & SHORT) { @@ -951,10 +954,16 @@ __svfscanf_r (rptr, fp, fmt0, ap) else { if (!(flags & VECTOR)) - ip = va_arg (ap, int *); - else if (!looped) - ip = vec_buf.i; - *ip++ = res; + { + ip = va_arg (ap, int *); + *ip++ = res; + } + else + { + if (!looped) + ch_dest = vec_buf.c; + *ch_dest++ = (char)res; + } } if (!(flags & VECTOR)) nassigned++;