diff options
Diffstat (limited to 'newlib/libc/stdio/local.h')
-rw-r--r-- | newlib/libc/stdio/local.h | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index cbfeac77d..54854b49d 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -32,6 +32,16 @@ # include <io.h> #endif +/* The following define determines if the per-reent stdin, stdout and stderr + streams are closed during _reclaim_reent(). The stdin, stdout and stderr + streams are initialized to use file descriptors 0, 1 and 2 respectively. In + case _STDIO_CLOSE_PER_REENT_STD_STREAMS is defined these file descriptors + will be closed via close() provided the owner of the reent structure + triggerd the on demand reent initilization, see CHECK_INIT(). */ +#ifndef __rtems__ +#define _STDIO_CLOSE_PER_REENT_STD_STREAMS +#endif + /* The following macros are supposed to replace calls to _flockfile/_funlockfile and __sfp_lock_acquire/__sfp_lock_release. In case of multi-threaded environments using pthreads, it's not sufficient to lock the stdio functions @@ -165,34 +175,37 @@ extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *, #ifdef _REENT_SMALL #define CHECK_INIT(ptr, fp) \ - do \ - { \ - if ((ptr) && !(ptr)->__sdidinit) \ - __sinit (ptr); \ - if ((fp) == (FILE *)&__sf_fake_stdin) \ - (fp) = _stdin_r(ptr); \ - else if ((fp) == (FILE *)&__sf_fake_stdout) \ - (fp) = _stdout_r(ptr); \ - else if ((fp) == (FILE *)&__sf_fake_stderr) \ - (fp) = _stderr_r(ptr); \ - } \ + do \ + { \ + struct _reent *_check_init_ptr = (ptr); \ + if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \ + __sinit (_check_init_ptr); \ + if ((fp) == (FILE *)&__sf_fake_stdin) \ + (fp) = _stdin_r(_check_init_ptr); \ + else if ((fp) == (FILE *)&__sf_fake_stdout) \ + (fp) = _stdout_r(_check_init_ptr); \ + else if ((fp) == (FILE *)&__sf_fake_stderr) \ + (fp) = _stderr_r(_check_init_ptr); \ + } \ while (0) #else /* !_REENT_SMALL */ #define CHECK_INIT(ptr, fp) \ - do \ - { \ - if ((ptr) && !(ptr)->__sdidinit) \ - __sinit (ptr); \ - } \ + do \ + { \ + struct _reent *_check_init_ptr = (ptr); \ + if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \ + __sinit (_check_init_ptr); \ + } \ while (0) #endif /* !_REENT_SMALL */ #define CHECK_STD_INIT(ptr) \ - do \ - { \ - if ((ptr) && !(ptr)->__sdidinit) \ - __sinit (ptr); \ - } \ + do \ + { \ + struct _reent *_check_init_ptr = (ptr); \ + if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \ + __sinit (_check_init_ptr); \ + } \ while (0) /* Return true and set errno and stream error flag iff the given FILE |