_CODE_ACCESS int fprintf(FILE *_fp, const char *_format, ...) { va_list _ap; int rval; char *fptr = (char *)_format; /*------------------------------------------------------------------------*/ /* The current thread in a multi-threaded application must protect access */ /* to the file stream. In this case, _fp may be updated, so we must */ /* ensure that the local copy of _fp is flushed to shared memory before */ /* leaving the critical section (invalidated if it is not modified). */ /*------------------------------------------------------------------------*/ __TI_file_lock(_fp); /*------------------------------------------------------------------------*/ /* If the current stream is not associated with a file, return an error. */ /*------------------------------------------------------------------------*/ if (_fp->fd == -1) { __TI_data_synch_INV(_fp, sizeof(FILE)); __TI_file_unlock(_fp); return (-1); } va_start(_ap, _format); rval = __TI_printfi(&fptr, _ap, (void *)_fp, _outc, _outs); va_end(_ap); __TI_data_synch_WBINV(_fp, sizeof(FILE)); __TI_file_unlock(_fp); return (rval); }
_CODE_ACCESS int vprintf(const char *_format, va_list _ap) { int result; char *fptr = (char *)_format; /*------------------------------------------------------------------------*/ /* The current thread in a multi-threaded application must protect access */ /* to stdout. In this case, stdout may be updated, so we must ensure that */ /* the local copy of stdout is flushed to shared memory before leaving the*/ /* critical section (invalidated if it is not modified). */ /*------------------------------------------------------------------------*/ __TI_file_lock(stdout); /*------------------------------------------------------------------------*/ /* If the current stream is not associated with a file, return an error. */ /*------------------------------------------------------------------------*/ if (stdout->fd == -1) { __TI_data_synch_INV(stdout, sizeof(FILE)); __TI_file_unlock(stdout); return (EOF); } result = (__TI_printfi(&fptr, _ap, (void *)stdout, _outc, _outs)); __TI_data_synch_WBINV(stdout, sizeof(FILE)); __TI_file_unlock(stdout); return (result); }
_CODE_ACCESS int vsprintf(char *_string, const char *_format, va_list _ap) { int rval; char *fptr = (char *)_format; char *out_end = _string; rval = __TI_printfi(&fptr, _ap, (void *)&out_end, _outc, _outs); *out_end = '\0'; return rval; }
_CODE_ACCESS int sprintf(char *_string, const char *_format, ...) { va_list _ap; int rval; char *fptr = (char *)_format; char *out_end = _string; va_start(_ap, _format); rval = __TI_printfi(&fptr, _ap, (void *)&out_end, _outc, _outs); va_end(_ap); *out_end = '\0'; return (rval); }
_CODE_ACCESS int vsnprintf(char *_string, size_t _n, const char *_format, va_list _ap) { int rval; char *fptr = (char *)_format; struct holder holder; if (_n == 0) /* write nothing */ holder.n = 0; else /* set up buffer */ holder.n = _n - 1; holder.written = 0; holder.out_end = _string; rval = __TI_printfi(&fptr, _ap, (void *)&holder, _outc, _outs); if (_n) *holder.out_end = '\0'; return rval; }