File:  [DVB] / dietlibc / libstdio / fputc_unlocked.c
Revision 1.16: download - view: text, annotated - select for diffs
Tue Jun 19 12:53:48 2012 UTC (11 years, 11 months ago) by leitner
Branches: MAIN
CVS tags: HEAD
try to accomodate current pedantic gnu configure scripts

#include <dietstdio.h>
#include <unistd.h>
#include <endian.h>

int fputc_unlocked(int c, FILE *stream) {
  if (!__likely(stream->flags&CANWRITE) || __fflush4(stream,0)) {
kaputt:
    stream->flags|=ERRORINDICATOR;
    return EOF;
  }
  if (__unlikely(stream->bm>=stream->buflen-1))
    if (fflush_unlocked(stream)) goto kaputt;
  if (stream->flags&NOBUF) {
#if __BYTE_ORDER == __LITTLE_ENDIAN
    if (__libc_write(stream->fd,&c,1) != 1)
#else
    if (__libc_write(stream->fd,(char*)&c+sizeof(c)-1,1) != 1)
#endif
      goto kaputt;
    return (unsigned char)c;
  }
  stream->buf[stream->bm]=c;
  ++stream->bm;
  if (((stream->flags&BUFLINEWISE) && c=='\n') ||
      ((stream->flags&NOBUF))) /* puke */
    if (fflush_unlocked(stream)) goto kaputt;
  return (unsigned char)c;
}

int fputc(int c,FILE* stream) __attribute__((weak,alias("fputc_unlocked")));

LinuxTV legacy CVS <linuxtv.org/cvs>