Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | --- vfwprintf.c.orig 2004-11-25 11:38:36.000000000 -0800 +++ vfwprintf.c 2005-02-24 15:17:14.000000000 -0800 @@ -42,6 +42,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/lib/libc/stdio/vfwprintf.c,v 1.23 2004/08/26 06:25:28 des Exp $"); +#include "xlocale_private.h" + /* * Actual wprintf innards. * @@ -63,12 +65,19 @@ #include <string.h> #include <wchar.h> #include <wctype.h> +#include <errno.h> #include "un-namespace.h" #include "libc_private.h" #include "local.h" #include "fvwrite.h" +#ifdef ALTIVEC +#include <machine/cpu_capabilities.h> + +#define VECTORTYPE vector unsigned char +#endif /* ALTIVEC */ + union arg { int intarg; u_int uintarg; @@ -96,6 +105,16 @@ #endif wint_t wintarg; wchar_t *pwchararg; +#ifdef ALTIVEC + VECTORTYPE vectorarg; + unsigned char vuchararg[16]; + signed char vchararg[16]; + unsigned short vushortarg[8]; + signed short vshortarg[8]; + unsigned int vuintarg[4]; + signed int vintarg[4]; + float vfloatarg[4]; +#endif /* ALTIVEC */ }; /* @@ -106,26 +125,63 @@ T_LONG, T_U_LONG, TP_LONG, T_LLONG, T_U_LLONG, TP_LLONG, T_PTRDIFFT, TP_PTRDIFFT, T_SIZET, TP_SIZET, T_INTMAXT, T_UINTMAXT, TP_INTMAXT, TP_VOID, TP_CHAR, TP_SCHAR, +#ifdef ALTIVEC + T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR, T_VECTOR +#else /* ! ALTIVEC */ T_DOUBLE, T_LONG_DOUBLE, T_WINT, TP_WCHAR +#endif /* ALTIVEC */ }; -static int __sbprintf(FILE *, const wchar_t *, va_list); -static wint_t __xfputwc(wchar_t, FILE *); +static int __sbprintf(FILE *, locale_t, const wchar_t *, va_list); +static wint_t __xfputwc(wchar_t, FILE *, locale_t); static wchar_t *__ujtoa(uintmax_t, wchar_t *, int, int, const char *, int, char, const char *); static wchar_t *__ultoa(u_long, wchar_t *, int, int, const char *, int, char, const char *); -static wchar_t *__mbsconv(char *, int); +static wchar_t *__mbsconv(char *, int, locale_t); static void __find_arguments(const wchar_t *, va_list, union arg **); static void __grow_type_table(int, enum typeid **, int *); + /* + * Get the argument indexed by nextarg. If the argument table is + * built, use it to get the argument. If its not, get the next + * argument (and arguments must be gotten sequentially). + */ +#define GETARG(type) \ + ((argtable != NULL) ? *((type*)(&argtable[nextarg++])) : \ + (nextarg++, va_arg(ap, type))) + +#ifdef ALTIVEC +#define hasAltivec (_cpu_capabilities & kHasAltivec) +/*----------------------------------------------------------------------- + * getvec() must be a real subroutine. If it is a #define, then __vfprintf() + * would have its calling sequence changed by Altivec so that a non-Altivec + * processor would crash on illegal instruction. By isolating the calling + * sequence in getvec(), __vprintf() is callable by a non-Altivec processor. + *-----------------------------------------------------------------------*/ +static va_list getvec(union arg *, const union arg *, int, va_list) __attribute__((noinline)); + +static va_list +getvec(union arg *dst, const union arg *argtable, int nextarg, va_list ap) +{ + dst->vectorarg = GETARG(VECTORTYPE); + return ap; +} + +#define SETVEC(dst) \ +{ \ + ap = getvec(&dst, argtable, nextarg, ap); \ + nextarg++; \ +} +#endif /* ALTIVEC */ + /* * Helper function for `fprintf to unbuffered unix file': creates a * temporary buffer. We only work on write-only files; this avoids * worries about ungetc buffers and so forth. */ static int -__sbprintf(FILE *fp, const wchar_t *fmt, va_list ap) +__sbprintf(FILE *fp, locale_t loc, const wchar_t *fmt, va_list ap) { int ret; FILE fake; @@ -144,7 +200,7 @@ fake._lbfsize = 0; /* not actually used, but Just In Case */ /* do the work, then copy any error status */ - ret = __vfwprintf(&fake, fmt, ap); + ret = __vfwprintf(&fake, loc, fmt, ap); if (ret >= 0 && __fflush(&fake)) ret = WEOF; if (fake._flags & __SERR) @@ -157,7 +213,7 @@ * File must already be locked. */ static wint_t -__xfputwc(wchar_t wc, FILE *fp) +__xfputwc(wchar_t wc, FILE *fp, locale_t loc) { static const mbstate_t initial; mbstate_t mbs; @@ -167,10 +223,10 @@ size_t len; if ((fp->_flags & __SSTR) == 0) - return (__fputwc(wc, fp)); + return (__fputwc(wc, fp, loc)); mbs = initial; - if ((len = wcrtomb(buf, wc, &mbs)) == (size_t)-1) { + if ((len = wcrtomb_l(buf, wc, &mbs, loc)) == (size_t)-1) { fp->_flags |= __SERR; return (WEOF); } @@ -350,13 +406,14 @@ * that the multibyte char. string ends in a null character. */ static wchar_t * -__mbsconv(char *mbsarg, int prec) +__mbsconv(char *mbsarg, int prec, locale_t loc) { static const mbstate_t initial; mbstate_t mbs; wchar_t *convbuf, *wcp; const char *p; size_t insize, nchars, nconv; + int mb_cur_max = MB_CUR_MAX_L(loc); if (mbsarg == NULL) return (NULL); @@ -374,7 +431,7 @@ insize = nchars = 0; mbs = initial; while (nchars != (size_t)prec) { - nconv = mbrlen(p, MB_CUR_MAX, &mbs); + nconv = mbrlen_l(p, mb_cur_max, &mbs, loc); if (nconv == 0 || nconv == (size_t)-1 || nconv == (size_t)-2) break; @@ -399,7 +456,7 @@ p = mbsarg; mbs = initial; while (insize != 0) { - nconv = mbrtowc(wcp, p, insize, &mbs); + nconv = mbrtowc_l(wcp, p, insize, &mbs, loc); if (nconv == 0 || nconv == (size_t)-1 || nconv == (size_t)-2) break; wcp++; @@ -425,7 +482,21 @@ int ret; FLOCKFILE(fp); - ret = __vfwprintf(fp, fmt0, ap); + ret = __vfwprintf(fp, __current_locale(), fmt0, ap); + FUNLOCKFILE(fp); + return (ret); +} + +int +vfwprintf_l(FILE * __restrict fp, locale_t loc, const wchar_t * __restrict fmt0, + va_list ap) + +{ + int ret; + + NORMALIZE_LOCALE(loc); + FLOCKFILE(fp); + ret = __vfwprintf(fp, loc, fmt0, ap); FUNLOCKFILE(fp); return (ret); } @@ -474,12 +545,15 @@ #define PTRDIFFT 0x800 /* ptrdiff_t */ #define INTMAXT 0x1000 /* intmax_t */ #define CHARINT 0x2000 /* print char using int format */ +#ifdef ALTIVEC +#define VECTOR 0x4000 /* Altivec vector */ +#endif /* ALTIVEC */ /* * Non-MT-safe version */ -int -__vfwprintf(FILE *fp, const wchar_t *fmt0, va_list ap) +__private_extern__ int +__vfwprintf(FILE *fp, locale_t loc, const wchar_t *fmt0, va_list ap) { wchar_t *fmt; /* format string */ wchar_t ch; /* character from fmt */ @@ -524,6 +598,11 @@ int nseps; /* number of group separators with ' */ int nrepeats; /* number of repeats of the last group */ #endif +#ifdef ALTIVEC + union arg vval; /* Vector argument. */ + wchar_t *pct; /* Pointer to '%' at beginning of specifier. */ + wchar_t vsep; /* Vector separator character. */ +#endif u_long ulval; /* integer arguments %[diouxX] */ uintmax_t ujval; /* %j, %ll, %q, %t, %z integers */ int base; /* base for [diouxX] conversion */ @@ -560,7 +639,7 @@ */ #define PRINT(ptr, len) do { \ for (n3 = 0; n3 < (len); n3++) \ - __xfputwc((ptr)[n3], fp); \ + __xfputwc((ptr)[n3], fp, loc); \ } while (0) #define PAD(howmany, with) do { \ if ((n = (howmany)) > 0) { \ @@ -581,15 +660,6 @@ } while(0) /* - * Get the argument indexed by nextarg. If the argument table is - * built, use it to get the argument. If its not, get the next - * argument (and arguments must be gotten sequentially). - */ -#define GETARG(type) \ - ((argtable != NULL) ? *((type*)(&argtable[nextarg++])) : \ - (nextarg++, va_arg(ap, type))) - - /* * To extend shorts properly, we need both signed and unsigned * argument extraction methods. */ @@ -640,21 +710,22 @@ val = GETARG (int); \ } - thousands_sep = '\0'; grouping = NULL; #ifndef NO_FLOATING_POINT - decimal_point = localeconv()->decimal_point; + decimal_point = localeconv_l(loc)->decimal_point; #endif convbuf = NULL; /* sorry, fwprintf(read_only_file, L"") returns WEOF, not 0 */ - if (prepwrite(fp) != 0) + if (prepwrite(fp) != 0) { + errno = EBADF; return (EOF); + } /* optimise fprintf(stderr) (and other unbuffered Unix files) */ if ((fp->_flags & (__SNBF|__SWR|__SRW)) == (__SNBF|__SWR) && fp->_file >= 0) - return (__sbprintf(fp, fmt0, ap)); + return (__sbprintf(fp, loc, fmt0, ap)); fmt = (wchar_t *)fmt0; argtable = NULL; @@ -678,6 +749,9 @@ } if (ch == '\0') goto done; +#ifdef ALTIVEC + pct = fmt; +#endif /* ALTIVEC */ fmt++; /* skip over '%' */ flags = 0; @@ -686,6 +760,9 @@ prec = -1; sign = '\0'; ox[1] = '\0'; +#ifdef ALTIVEC + vsep = 'X'; /* Illegal value, changed to defaults later. */ +#endif /* ALTIVEC */ rflag: ch = *fmt++; reswitch: switch (ch) { @@ -701,6 +778,11 @@ case '#': flags |= ALT; goto rflag; +#ifdef ALTIVEC + case ',': case ';': case ':': case '_': + vsep = ch; + goto rflag; +#endif /* ALTIVEC */ case '*': /*- * ``A negative field width argument is taken as a @@ -721,8 +803,8 @@ goto rflag; case '\'': flags |= GROUPING; - thousands_sep = *(localeconv()->thousands_sep); - grouping = localeconv()->grouping; + thousands_sep = *(localeconv_l(loc)->thousands_sep); + grouping = localeconv_l(loc)->grouping; goto rflag; case '.': if ((ch = *fmt++) == '*') { @@ -796,10 +878,16 @@ flags |= LONGINT; /*FALLTHROUGH*/ case 'c': +#ifdef ALTIVEC + if (flags & VECTOR) { + SETVEC(vval); + break; + } +#endif /* ALTIVEC */ if (flags & LONGINT) *(cp = buf) = (wchar_t)GETARG(wint_t); else - *(cp = buf) = (wchar_t)btowc(GETARG(int)); + *(cp = buf) = (wchar_t)btowc_l(GETARG(int), loc); size = 1; sign = '\0'; break; @@ -808,6 +896,12 @@ /*FALLTHROUGH*/ case 'd': case 'i': +#ifdef ALTIVEC + if (flags & VECTOR) { + SETVEC(vval); + break; + } +#endif /* ALTIVEC */ if (flags & INTMAX_SIZE) { ujval = SJARG(); if ((intmax_t)ujval < 0) { @@ -837,6 +931,12 @@ } if (prec >= 0) prec++; +#ifdef LDBL_COMPAT + fparg.dbl = GETARG(double); + dtoaresult = + __hdtoa(fparg.dbl, xdigs, prec, + &expt, &signflag, &dtoaend); +#else /* !LDBL_COMPAT */ if (flags & LONGDBL) { fparg.ldbl = GETARG(long double); dtoaresult = @@ -848,6 +948,7 @@ __hdtoa(fparg.dbl, xdigs, prec, &expt, &signflag, &dtoaend); } +#endif /* LDBL_COMPAT */ if (prec < 0) prec = dtoaend - dtoaresult; if (expt == INT_MAX) @@ -855,7 +956,7 @@ if (convbuf != NULL) free(convbuf); ndig = dtoaend - dtoaresult; - cp = convbuf = __mbsconv(dtoaresult, -1); + cp = convbuf = __mbsconv(dtoaresult, -1, loc); freedtoa(dtoaresult); goto fp_common; case 'e': @@ -868,10 +969,24 @@ goto fp_begin; case 'f': case 'F': +#ifdef ALTIVEC + if (flags & VECTOR) { + flags |= FPT; + SETVEC(vval); + break; + } +#endif /* ALTIVEC */ expchar = '\0'; goto fp_begin; case 'g': case 'G': +#ifdef ALTIVEC + if (flags & VECTOR) { + flags |= FPT; + SETVEC(vval); + break; + } +#endif /* ALTIVEC */ expchar = ch - ('g' - 'e'); if (prec == 0) prec = 1; @@ -880,6 +995,14 @@ prec = DEFPREC; if (convbuf != NULL) free(convbuf); +#ifdef LDBL_COMPAT + fparg.dbl = GETARG(double); + dtoaresult = + dtoa(fparg.dbl, expchar ? 2 : 3, prec, + &expt, &signflag, &dtoaend); + if (expt == 9999) + expt = INT_MAX; +#else /* !LDBL_COMPAT */ if (flags & LONGDBL) { fparg.ldbl = GETARG(long double); dtoaresult = @@ -893,8 +1016,9 @@ if (expt == 9999) expt = INT_MAX; } +#endif /* LDBL_COMPAT */ ndig = dtoaend - dtoaresult; - cp = convbuf = __mbsconv(dtoaresult, -1); + cp = convbuf = __mbsconv(dtoaresult, -1, loc); freedtoa(dtoaresult); fp_common: if (signflag) @@ -989,6 +1113,12 @@ flags |= LONGINT; /*FALLTHROUGH*/ case 'o': +#ifdef ALTIVEC + if (flags & VECTOR) { + SETVEC(vval); + break; + } +#endif /* ALTIVEC */ if (flags & INTMAX_SIZE) ujval = UJARG(); else @@ -1003,6 +1133,12 @@ * defined manner.'' * -- ANSI X3J11 */ +#ifdef ALTIVEC + if (flags & VECTOR) { + SETVEC(vval); + break; + } +#endif /* ALTIVEC */ ujval = (uintmax_t)(uintptr_t)GETARG(void *); base = 16; xdigs = xdigs_lower; @@ -1024,7 +1160,7 @@ if ((mbp = GETARG(char *)) == NULL) cp = L"(null)"; else { - convbuf = __mbsconv(mbp, prec); + convbuf = __mbsconv(mbp, prec, loc); if (convbuf == NULL) { fp->_flags |= __SERR; goto error; @@ -1055,6 +1191,12 @@ flags |= LONGINT; /*FALLTHROUGH*/ case 'u': +#ifdef ALTIVEC + if (flags & VECTOR) { + SETVEC(vval); + break; + } +#endif /* ALTIVEC */ if (flags & INTMAX_SIZE) ujval = UJARG(); else @@ -1067,6 +1209,12 @@ case 'x': xdigs = xdigs_lower; hex: +#ifdef ALTIVEC + if (flags & VECTOR) { + SETVEC(vval); + break; + } +#endif /* ALTIVEC */ if (flags & INTMAX_SIZE) ujval = UJARG(); else @@ -1111,6 +1259,14 @@ if (size > BUF) /* should never happen */ abort(); break; +#ifdef ALTIVEC + case 'v': + if (hasAltivec) { + flags |= VECTOR; + goto rflag; + } + /* drop through */ +#endif /* ALTIVEC */ default: /* "%?" prints ?, unless ? is NUL */ if (ch == '\0') goto done; @@ -1122,6 +1278,183 @@ break; } +#ifdef ALTIVEC + if (flags & VECTOR) { + /* + * Do the minimum amount of work necessary to construct + * a format specifier that can be used to recursively + * call vfprintf() for each element in the vector. + */ + int i, j; /* Counter. */ + int vcnt; /* Number of elements in vector. */ + char *vfmt; /* Pointer to format specifier. */ + char vfmt_buf[32]; /* Static buffer for format spec. */ + int vwidth = 0; /* Width specified via '*'. */ + int vprec = 0; /* Precision specified via '*'. */ + union { /* Element. */ + int i; + float f; + } velm; + char *vstr; /* Used for asprintf(). */ + int vlen; /* Length returned by asprintf(). */ + + /* + * Set vfmt. If vfmt_buf may not be big enough, + * malloc() space, taking care to free it later. + */ + if (&fmt[-1] - pct < sizeof(vfmt_buf)) + vfmt = vfmt_buf; + else + vfmt = (char *)malloc(&fmt[-1] - pct + 1); + + /* Set the separator character, if not specified. */ + if (vsep == 'X') { + if (ch == 'c') + vsep = '\0'; + else + vsep = ' '; + } + + /* Create the format specifier. */ + for (i = j = 0; i < &fmt[-1] - pct; i++) { + switch (pct[i]) { + case ',': case ';': case ':': case '_': + case 'v': case 'h': case 'l': + /* Ignore. */ + break; + case '*': + if (pct[i - 1] != '.') + vwidth = 1; + else + vprec = 1; + /* FALLTHROUGH */ + default: + vfmt[j++] = pct[i]; + } + } + + /* + * Determine the number of elements in the vector and + * finish up the format specifier. + */ + if (flags & SHORTINT) { + if (ch != 'c') + vfmt[j++] = 'h'; + vcnt = 8; + } else if (flags & LONGINT) { + if (ch != 'c') + vfmt[j++] = 'l'; + vcnt = 4; + } else { + switch (ch) { + case 'a': + case 'A': + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + vcnt = 4; + break; + default: + /* + * The default case should never + * happen. + */ + case 'c': + case 'd': + case 'i': + case 'u': + case 'o': + case 'p': + case 'x': + case 'X': + vcnt = 16; + } + } + vfmt[j++] = ch; + vfmt[j++] = '\0'; + +/* Get a vector element. */ +#define VPRINT(cnt, ind, args...) do { \ + if (flags & FPT) { \ + velm.f = vval.vfloatarg[ind]; \ + vlen = asprintf_l(&vstr, loc, vfmt , ## args, velm.f); \ + } else { \ + switch (cnt) { \ + default: \ + /* The default case should never happen. */ \ + case 4: \ + velm.i = (unsigned)vval.vintarg[ind]; \ + break; \ + case 8: \ + velm.i = (unsigned short)vval.vshortarg[ind]; \ + break; \ + case 16: \ + velm.i = (unsigned char)vval.vchararg[ind]; \ + break; \ + } \ + vlen = asprintf_l(&vstr, loc, vfmt , ## args, velm.i); \ + } \ + ret += vlen; \ + PRINT(vstr, vlen); \ + free(vstr); \ +} while (0) + + /* Actually print. */ + if (vwidth == 0) { + if (vprec == 0) { + /* First element. */ + VPRINT(vcnt, 0); + for (i = 1; i < vcnt; i++) { + /* Separator. */ + PRINT(&vsep, 1); + + /* Element. */ + VPRINT(vcnt, i); + } + } else { + /* First element. */ + VPRINT(vcnt, 0, prec); + for (i = 1; i < vcnt; i++) { + /* Separator. */ + PRINT(&vsep, 1); + + /* Element. */ + VPRINT(vcnt, i, prec); + } + } + } else { + if (vprec == 0) { + /* First element. */ + VPRINT(vcnt, 0, width); + for (i = 1; i < vcnt; i++) { + /* Separator. */ + PRINT(&vsep, 1); + + /* Element. */ + VPRINT(vcnt, i, width); + } + } else { + /* First element. */ + VPRINT(vcnt, 0, width, prec); + for (i = 1; i < vcnt; i++) { + /* Separator. */ + PRINT(&vsep, 1); + + /* Element. */ + VPRINT(vcnt, i, width, prec); + } + } + } +#undef VPRINT + + if (vfmt != vfmt_buf) + free(vfmt); + + continue; + } +#endif /* ALTIVEC */ /* * All reasonable formats wind up here. At this point, `cp' * points to a string which (if not flags&LADJUST) should be @@ -1401,6 +1734,11 @@ if (flags & LONGINT) ADDTYPE(T_WINT); else +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif /* ALTIVEC */ ADDTYPE(T_INT); break; case 'D': @@ -1418,6 +1756,11 @@ case 'f': case 'g': case 'G': +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif /* ALTIVEC */ if (flags & LONGDBL) ADDTYPE(T_LONG_DOUBLE); else @@ -1446,9 +1789,19 @@ flags |= LONGINT; /*FALLTHROUGH*/ case 'o': +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif /* ALTIVEC */ ADDUARG(); break; case 'p': +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif /* ALTIVEC */ ADDTYPE(TP_VOID); break; case 'S': @@ -1466,6 +1819,11 @@ case 'u': case 'X': case 'x': +#ifdef ALTIVEC + if (flags & VECTOR) + ADDTYPE(T_VECTOR); + else +#endif /* ALTIVEC */ ADDUARG(); break; default: /* "%?" prints ?, unless ? is NUL */ @@ -1532,7 +1890,7 @@ (*argtable) [n].sizearg = va_arg (ap, size_t); break; case TP_SIZET: - (*argtable) [n].psizearg = va_arg (ap, ssize_t *); + (*argtable) [n].psizearg = va_arg (ap, size_t *); break; case T_INTMAXT: (*argtable) [n].intmaxarg = va_arg (ap, intmax_t); @@ -1551,6 +1909,12 @@ (*argtable) [n].longdoublearg = va_arg (ap, long double); break; #endif +#ifdef ALTIVEC + case T_VECTOR: + if (hasAltivec) + ap = getvec( &((*argtable) [n]), NULL, 0, ap ); + break; +#endif /* ALTIVEC */ case TP_CHAR: (*argtable) [n].pchararg = va_arg (ap, char *); break; |