diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2004-09-16 21:30:51 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2004-09-16 21:30:51 +0000 |
commit | ed6859b8f02e456699f85918e4b81457537900fa (patch) | |
tree | 301f85ef34f78d17a7497ae6d1807a6e25ccbca5 /newlib | |
parent | 7a0f696676736d2d8b1d214f9f0cfa5ce8ce76c1 (diff) | |
download | newlib-ed6859b8f02e456699f85918e4b81457537900fa.zip newlib-ed6859b8f02e456699f85918e4b81457537900fa.tar.gz newlib-ed6859b8f02e456699f85918e4b81457537900fa.tar.bz2 |
2004-09-16 Antony King <antony.king@st.com>
* libc/include/sys/lock.h: Replaced empty {} with (0) to conform
with locking API.
* libc/include/sys/stdio.h: (_flockfile)[!_SINGLE_THREAD]: Add
check for__SSTR in _flags and if set, skip lock request.
(_funlockfile)[!SINGLE_THREAD]: Ditto.
* libc/stdio/local.h (CHECK_INIT): Added check that _REENT is
not NULL.
* libc/stdio/siprintf.c (siprintf, _siprintf_r): Added missing
initialisation of _file to -1 in local FILE.
* libc/stdio/snprintf.c (snprintf, _snprintf_r): Ditto.
* libc/stdio/sscanf.c (sscanf, _sscanf_r): Ditto.
* libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Ditto.
* libc/stdio/vsscanf.c (_vsscanf_r): Ditto.
* libc/stdio/sscanf.c (sscanf, _sscanf_r): Added __SSTR flag to
_flags in local FILE to prevent locking.
* libc/stdio/vsscanf.c (_vsscanf_r): Ditto.
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/ChangeLog | 19 | ||||
-rw-r--r-- | newlib/libc/include/sys/lock.h | 20 | ||||
-rw-r--r-- | newlib/libc/include/sys/stdio.h | 8 | ||||
-rw-r--r-- | newlib/libc/stdio/local.h | 10 | ||||
-rw-r--r-- | newlib/libc/stdio/siprintf.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio/snprintf.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio/sscanf.c | 6 | ||||
-rw-r--r-- | newlib/libc/stdio/vsnprintf.c | 2 | ||||
-rw-r--r-- | newlib/libc/stdio/vsscanf.c | 6 |
9 files changed, 52 insertions, 23 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 9c4b35f..d81a547 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,5 +1,24 @@ 2004-09-16 Antony King <antony.king@st.com> + * libc/include/sys/lock.h: Replaced empty {} with (0) to conform + with locking API. + * libc/include/sys/stdio.h: (_flockfile)[!_SINGLE_THREAD]: Add + check for__SSTR in _flags and if set, skip lock request. + (_funlockfile)[!SINGLE_THREAD]: Ditto. + * libc/stdio/local.h (CHECK_INIT): Added check that _REENT is + not NULL. + * libc/stdio/siprintf.c (siprintf, _siprintf_r): Added missing + initialisation of _file to -1 in local FILE. + * libc/stdio/snprintf.c (snprintf, _snprintf_r): Ditto. + * libc/stdio/sscanf.c (sscanf, _sscanf_r): Ditto. + * libc/stdio/vsnprintf.c (vsnprintf, _vsnprintf_r): Ditto. + * libc/stdio/vsscanf.c (_vsscanf_r): Ditto. + * libc/stdio/sscanf.c (sscanf, _sscanf_r): Added __SSTR flag to + _flags in local FILE to prevent locking. + * libc/stdio/vsscanf.c (_vsscanf_r): Ditto. + +2004-09-16 Antony King <antony.king@st.com> + * libc/stdio/fwalk.c (_fwalk): Remove check for _GLOBAL_REENT and only walk the reentrancy parameter. (_fwalk_reent): Ditto. diff --git a/newlib/libc/include/sys/lock.h b/newlib/libc/include/sys/lock.h index 984bc5f..c05814a 100644 --- a/newlib/libc/include/sys/lock.h +++ b/newlib/libc/include/sys/lock.h @@ -8,15 +8,15 @@ typedef int _LOCK_RECURSIVE_T; #define __LOCK_INIT(class,lock) static int lock = 0; #define __LOCK_INIT_RECURSIVE(class,lock) static int lock = 0; -#define __lock_init(lock) {} -#define __lock_init_recursive(lock) {} -#define __lock_close(lock) {} -#define __lock_close_recursive(lock) {} -#define __lock_acquire(lock) {} -#define __lock_acquire_recursive(lock) {} -#define __lock_try_acquire(lock) {} -#define __lock_try_acquire_recursive(lock) {} -#define __lock_release(lock) {} -#define __lock_release_recursive(lock) {} +#define __lock_init(lock) (0) +#define __lock_init_recursive(lock) (0) +#define __lock_close(lock) (0) +#define __lock_close_recursive(lock) (0) +#define __lock_acquire(lock) (0) +#define __lock_acquire_recursive(lock) (0) +#define __lock_try_acquire(lock) (0) +#define __lock_try_acquire_recursive(lock) (0) +#define __lock_release(lock) (0) +#define __lock_release_recursive(lock) (0) #endif /* __SYS_LOCK_H__ */ diff --git a/newlib/libc/include/sys/stdio.h b/newlib/libc/include/sys/stdio.h index c0cf338..fa9cd5d 100644 --- a/newlib/libc/include/sys/stdio.h +++ b/newlib/libc/include/sys/stdio.h @@ -5,10 +5,12 @@ #include <sys/reent.h> /* Internal locking macros, used to protect stdio functions. In the - general case, expand to nothing. */ + general case, expand to nothing. Use __SSTR flag in FILE _flags to + detect if FILE is private to sprintf/sscanf class of functions; if + set then do nothing as lock is not initialised. */ #if !defined(_flockfile) #ifndef __SINGLE_THREAD__ -# define _flockfile(fp) __lock_acquire_recursive(fp->_lock) +# define _flockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_acquire_recursive((fp)->_lock)) #else # define _flockfile(fp) #endif @@ -16,7 +18,7 @@ #if !defined(_funlockfile) #ifndef __SINGLE_THREAD__ -# define _funlockfile(fp) __lock_release_recursive(fp->_lock) +# define _funlockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_release_recursive((fp)->_lock)) #else # define _funlockfile(fp) #endif diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index e3d5da5..e62f341 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -48,11 +48,11 @@ extern int _EXFUN(__srefill,(FILE *fp)); /* Called by the main entry point fns to ensure stdio has been initialized. */ #define CHECK_INIT(fp) \ - do \ - { \ - if (!_REENT->__sdidinit) \ - __sinit (_REENT); \ - } \ + do \ + { \ + if (_REENT && !_REENT->__sdidinit) \ + __sinit (_REENT); \ + } \ while (0) /* Return true iff the given FILE cannot be written now. */ diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c index 95ff808..8382008 100644 --- a/newlib/libc/stdio/siprintf.c +++ b/newlib/libc/stdio/siprintf.c @@ -85,6 +85,7 @@ siprintf(str, fmt, va_alist) f._flags = __SWR | __SSTR; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; + f._file = -1; /* No file. */ #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -119,6 +120,7 @@ _siprintf_r(rptr, str, fmt, va_alist) f._flags = __SWR | __SSTR; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = INT_MAX; + f._file = -1; /* No file. */ #ifdef _HAVE_STDC va_start (ap, fmt); #else diff --git a/newlib/libc/stdio/snprintf.c b/newlib/libc/stdio/snprintf.c index fc818d2..9c5c7cb 100644 --- a/newlib/libc/stdio/snprintf.c +++ b/newlib/libc/stdio/snprintf.c @@ -51,6 +51,7 @@ _snprintf_r(ptr, str, size, fmt, va_alist) f._flags = __SWR | __SSTR; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); + f._file = -1; /* No file. */ #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -86,6 +87,7 @@ snprintf(str, size, fmt, va_alist) f._flags = __SWR | __SSTR; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); + f._file = -1; /* No file. */ #ifdef _HAVE_STDC va_start (ap, fmt); #else diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c index 1aca405..687f53e 100644 --- a/newlib/libc/stdio/sscanf.c +++ b/newlib/libc/stdio/sscanf.c @@ -402,12 +402,13 @@ sscanf(str, fmt, va_alist) va_list ap; FILE f; - f._flags = __SRD; + f._flags = __SRD | __SSTR; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = strlen (str); f._read = eofread; f._ub._base = NULL; f._lb._base = NULL; + f._file = -1; /* No file. */ #ifdef _HAVE_STDC va_start (ap, fmt); #else @@ -439,12 +440,13 @@ _sscanf_r(ptr, str, fmt, va_alist) va_list ap; FILE f; - f._flags = __SRD; + f._flags = __SRD | __SSTR; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = strlen (str); f._read = eofread; f._ub._base = NULL; f._lb._base = NULL; + f._file = -1; /* No file. */ #ifdef _HAVE_STDC va_start (ap, fmt); #else diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.c index fb80f41..9fc1b2d 100644 --- a/newlib/libc/stdio/vsnprintf.c +++ b/newlib/libc/stdio/vsnprintf.c @@ -45,6 +45,7 @@ _DEFUN(vsnprintf, (str, size, fmt, ap), f._flags = __SWR | __SSTR; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); + f._file = -1; /* No file. */ ret = _vfprintf_r (_REENT, &f, fmt, ap); if (size > 0) *f._p = 0; @@ -67,6 +68,7 @@ _DEFUN(_vsnprintf_r, (ptr, str, size, fmt, ap), f._flags = __SWR | __SSTR; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._w = (size > 0 ? size - 1 : 0); + f._file = -1; /* No file. */ ret = _vfprintf_r (ptr, &f, fmt, ap); if (size > 0) *f._p = 0; diff --git a/newlib/libc/stdio/vsscanf.c b/newlib/libc/stdio/vsscanf.c index c623711..22ed9cd 100644 --- a/newlib/libc/stdio/vsscanf.c +++ b/newlib/libc/stdio/vsscanf.c @@ -63,12 +63,12 @@ _DEFUN(_vsscanf_r, (ptr, str, fmt, ap), { FILE f; - f._flags = __SRD; + f._flags = __SRD | __SSTR; f._bf._base = f._p = (unsigned char *) str; f._bf._size = f._r = strlen (str); f._read = eofread1; f._ub._base = NULL; f._lb._base = NULL; - return __svfscanf_r (ptr, &f, fmt, ap); + f._file = -1; /* No file. */ + return __svfscanf_r (ptr, &f, fmt, ap); } - |