newlib-2.1.0

git-svn-id: svn://kolibrios.org@4921 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge)
2014-05-10 22:12:19 +00:00
parent 914e67bd24
commit 7315bb05c0
204 changed files with 10781 additions and 3986 deletions

View File

@@ -32,6 +32,98 @@
# 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
against concurrent threads accessing the same data, the locking must also be
secured against thread cancellation.
The below macros have to be used in pairs. The _newlib_XXX_start macro
starts with a opening curly brace, the _newlib_XXX_end macro ends with a
closing curly brace, so the start macro and the end macro mark the code
start and end of a critical section. In case the code leaves the critical
section before reaching the end of the critical section's code end, use
the appropriate _newlib_XXX_exit macro. */
#if !defined (__SINGLE_THREAD__) && defined (_POSIX_THREADS) \
&& !defined (__rtems__)
#define _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
#endif
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
#include <pthread.h>
/* Start a stream oriented critical section: */
# define _newlib_flockfile_start(_fp) \
{ \
int __oldfpcancel; \
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldfpcancel); \
_flockfile (_fp)
/* Exit from a stream oriented critical section prematurely: */
# define _newlib_flockfile_exit(_fp) \
_funlockfile (_fp); \
pthread_setcancelstate (__oldfpcancel, &__oldfpcancel);
/* End a stream oriented critical section: */
# define _newlib_flockfile_end(_fp) \
_funlockfile (_fp); \
pthread_setcancelstate (__oldfpcancel, &__oldfpcancel); \
}
/* Start a stream list oriented critical section: */
# define _newlib_sfp_lock_start() \
{ \
int __oldsfpcancel; \
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldsfpcancel); \
__sfp_lock_acquire ()
/* Exit from a stream list oriented critical section prematurely: */
# define _newlib_sfp_lock_exit() \
__sfp_lock_release (); \
pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel);
/* End a stream list oriented critical section: */
# define _newlib_sfp_lock_end() \
__sfp_lock_release (); \
pthread_setcancelstate (__oldsfpcancel, &__oldsfpcancel); \
}
#else /* !_STDIO_WITH_THREAD_CANCELLATION_SUPPORT */
# define _newlib_flockfile_start(_fp) \
{ \
_flockfile(_fp)
# define _newlib_flockfile_exit(_fp) \
_funlockfile(_fp); \
# define _newlib_flockfile_end(_fp) \
_funlockfile(_fp); \
}
# define _newlib_sfp_lock_start() \
{ \
__sfp_lock_acquire ()
# define _newlib_sfp_lock_exit() \
__sfp_lock_release ();
# define _newlib_sfp_lock_end() \
__sfp_lock_release (); \
}
#endif /* _STDIO_WITH_THREAD_CANCELLATION_SUPPORT */
extern u_char *_EXFUN(__sccl, (char *, u_char *fmt));
extern int _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
@@ -42,26 +134,28 @@ extern int _EXFUN(__svfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_
extern int _EXFUN(__ssvfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
extern int _EXFUN(__svfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
extern int _EXFUN(__ssvfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
int _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *,
int _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *,
va_list)
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
int _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *,
int _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *,
va_list)
_ATTRIBUTE ((__format__ (__printf__, 3, 0))));
int _EXFUN(_svfwprintf_r,(struct _reent *, FILE *, const wchar_t *,
int _EXFUN(_svfwprintf_r,(struct _reent *, FILE *, const wchar_t *,
va_list));
int _EXFUN(_svfiwprintf_r,(struct _reent *, FILE *, const wchar_t *,
int _EXFUN(_svfiwprintf_r,(struct _reent *, FILE *, const wchar_t *,
va_list));
extern FILE *_EXFUN(__sfp,(struct _reent *));
extern int _EXFUN(__sflags,(struct _reent *,_CONST char*, int*));
extern int _EXFUN(__sflush_r,(struct _reent *,FILE *));
extern int _EXFUN(__srefill_r,(struct _reent *,FILE *));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(struct _reent *, void *, char *,
int));
_READ_WRITE_BUFSIZE_TYPE));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__seofread,(struct _reent *, void *,
char *, int));
char *,
_READ_WRITE_BUFSIZE_TYPE));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(struct _reent *, void *,
const char *, int));
const char *,
_READ_WRITE_BUFSIZE_TYPE));
extern _fpos_t _EXFUN(__sseek,(struct _reent *, void *, _fpos_t, int));
extern int _EXFUN(__sclose,(struct _reent *, void *));
extern int _EXFUN(__stextmode,(int));
@@ -76,7 +170,8 @@ extern int _EXFUN(__submore, (struct _reent *, FILE *));
#ifdef __LARGE64_FILES
extern _fpos64_t _EXFUN(__sseek64,(struct _reent *, void *, _fpos64_t, int));
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
const char *, int));
const char *,
_READ_WRITE_BUFSIZE_TYPE));
#endif
/* Called by the main entry point fns to ensure stdio has been initialized. */
@@ -85,22 +180,24 @@ extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
#define CHECK_INIT(ptr, fp) \
do \
{ \
if ((ptr) && !(ptr)->__sdidinit) \
__sinit (ptr); \
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(ptr); \
(fp) = _stdin_r(_check_init_ptr); \
else if ((fp) == (FILE *)&__sf_fake_stdout) \
(fp) = _stdout_r(ptr); \
(fp) = _stdout_r(_check_init_ptr); \
else if ((fp) == (FILE *)&__sf_fake_stderr) \
(fp) = _stderr_r(ptr); \
(fp) = _stderr_r(_check_init_ptr); \
} \
while (0)
#else /* !_REENT_SMALL */
#define CHECK_INIT(ptr, fp) \
do \
{ \
if ((ptr) && !(ptr)->__sdidinit) \
__sinit (ptr); \
struct _reent *_check_init_ptr = (ptr); \
if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \
__sinit (_check_init_ptr); \
} \
while (0)
#endif /* !_REENT_SMALL */
@@ -108,8 +205,9 @@ extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
#define CHECK_STD_INIT(ptr) \
do \
{ \
if ((ptr) && !(ptr)->__sdidinit) \
__sinit (ptr); \
struct _reent *_check_init_ptr = (ptr); \
if ((_check_init_ptr) && !(_check_init_ptr)->__sdidinit) \
__sinit (_check_init_ptr); \
} \
while (0)
@@ -136,6 +234,7 @@ extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
#define FREELB(ptr, fp) { _free_r(ptr,(char *)(fp)->_lb._base); \
(fp)->_lb._base = NULL; }
#ifdef _WIDE_ORIENT
/*
* Set the orientation for a stream. If o > 0, the stream has wide-
* orientation. If o < 0, the stream has byte-orientation.
@@ -153,6 +252,9 @@ extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
} \
} \
while (0)
#else
#define ORIENT(fp,ori)
#endif
/* WARNING: _dcvt is defined in the stdlib directory, not here! */