This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fputc and initialisation of buffer stdout


Hi all,

I'm a newbies in the utilization of newlib, and i have a lot of
questions :

1) Each thread must be execute this line "  _REENT_INIT_PTR(_REENT); "
to initialize the reentrant structure, right?

2) The first instruction of my thread is  :

int main()
{
  _REENT_INIT_PTR(_REENT);

  fputc  ('0'  ,stdout);
  fputs  ("1\n",stdout);
  fputc  ('2'  ,stdout);
  fputs  ("3\n",stdout);
}

But '0' is not print. A element of respons is that _REENT_INIT_PTR and
CHECK_INIT in the case of a !_REENT_SMAAL have not malloc all std
buffer.

if i add test in /newlib/libc/stdio/fputc.c 

int
_DEFUN(fputc, (ch, file),
       int ch _AND
       FILE * file)
{
  int result;
  CHECK_INIT(_REENT);
   _flockfile (file);
   
   if (cantwrite(file))
     result = EOF;
   else
     result = putc (ch, file);

  _funlockfile (file);
  return result;
}

The buffer is effectively create. Is an error or a false manipulation by
me?

regards,
 mathieu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]