This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
[PATCH] (Re: Query concerning use of flockfile/funlockfile in stdioFILE related functions)
- From: Antony KING <antony dot king at st dot com>
- To: newlib at sources dot redhat dot com
- Date: Mon, 13 Sep 2004 18:06:02 +0100
- Subject: [PATCH] (Re: Query concerning use of flockfile/funlockfile in stdioFILE related functions)
- Organization: STMicroelectronics (R&D) Ltd
- References: <413CA202.3090901@st.com> <413E1635.5030201@redhat.com> <413F4820.7000704@st.com>
Please find attached a patch to newlib (CVS snapshot 10-Sep-2004) which
solves the problem I was having with being able to use sprintf/sscanf et
al from RTOS contexts where using locking was not permissible and where
no REENT structure exists.
Please note that I have re-enabled the definition of _GLOBAL_REENT to be
_global_impure_ptr when not CYGWIN; I hope this compromise is OK.
I have also made a number of other minor changes which I also hope are
OK (missing documentation, missing initialisations, default tz_lock
implementation a la env_lock, walking GLOBAL_REENT multiple times).
Cheers,
Antony.
--
-----------------------------------------------------------------
Antony King |
STMicroelectronics (R&D) Ltd. |
Bristol, BS32 4SQ. United Kingdom. |
diff -ru newlib.orig/newlib/ChangeLog newlib/newlib/ChangeLog
--- newlib.orig/newlib/ChangeLog Thu Sep 9 20:46:53 2004
+++ newlib/newlib/ChangeLog Fri Sep 10 14:01:57 2004
@@ -21,6 +21,37 @@
* libc/reent/reent.c [_REENT_SMALL]: Fix reference to
_on_exit_args_ptr.
+2004-09-09 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]: Added 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.
+ * libc/ctype/ctype.tex: Added missing documentation.
+ * libc/stdio/stdio.tex Ditto.
+ * libc/stdlib/stdlib.tex Ditto.
+ * libc/string/strings.tex Ditto.
+ * libc/time/time.tex: Ditto.
+ * libc/stdio/setbuffer.c: Removed setlinebuf documentation.
+
+2004-09-03 Antony King <antony.king@st.com>
+
+ * libc/time/tzlock.c: Add default stubs that use generic
+ locking code.
+
2004-08-23 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/sys/unistd.h (getpass): Change prototype to use
@@ -88,6 +119,12 @@
same dependencies as libm.info.
* libm/Makefile.in: Regenerated.
+2004-06-29 Antony King <antony.king@st.com>
+
+ * libc/include/sys/reent.h (_GLOBAL_REENT): Restore change
+ to set _GLOBAL_REENT to _global_impure_ptr but only if not
+ Cygwin (see change from 2004-06-17).
+
2004-06-29 Artem B. Bityuckiy <dedekind@oktetlabs.ru>
* acinclude.m4: Move --enable-newlib-iconv option back here.
@@ -317,6 +354,18 @@
* libc/include/sys/reent.h (_GLOBAL_REENT): Back
out change which set _GLOBAL_REENT to _global_impure_ptr until
we understand why Cygwin breaks because of it.
+
+2004-06-16 Antony King <antony.king@st.com>
+
+ * libc/stdio/fwalk.c (_fwalk): Remove check for _GLOBAL_REENT
+ and only walk the reentrancy parameter.
+ * libc/stdio/fwalk.c (_fwalk_reent): Ditto.
+ * libc/stdlib/exit.c: Remove out of date _REENT_ONLY check.
+
+2004-06-14 Antony King <antony.king@st.com>
+
+ * libc/stdio64/freopen64.c: Remove casting of fp lock to
+ _LOCK_RECURSIVE_T.
2004-06-14 Jeff Johnston <jjohnstn@redhat.com>
diff -ru newlib.orig/newlib/libc/ctype/ctype.tex newlib/newlib/libc/ctype/ctype.tex
--- newlib.orig/newlib/libc/ctype/ctype.tex Fri Sep 20 21:13:10 2002
+++ newlib/newlib/libc/ctype/ctype.tex Thu Sep 9 20:12:45 2004
@@ -23,6 +23,7 @@
* toupper:: Translate characters to upper case
* iswalnum:: Alphanumeric wide-character predicate
* iswalpha:: Alphabetic wide-character predicate
+* iswblank:: Blank wide-character predicate
* iswcntrl:: Control wide-character predicate
* iswdigit:: Decimal digit wide-character predicate
* iswgraph:: Graphic wide-character predicate
@@ -90,6 +91,9 @@
@page
@include ctype/iswcntrl.def
+
+@page
+@include ctype/iswblank.def
@page
@include ctype/iswdigit.def
diff -ru newlib.orig/newlib/libc/include/sys/lock.h newlib/newlib/libc/include/sys/lock.h
--- newlib.orig/newlib/libc/include/sys/lock.h Tue Sep 3 20:40:35 2002
+++ newlib/newlib/libc/include/sys/lock.h Thu Sep 9 10:58:58 2004
@@ -8,15 +8,15 @@
#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 -ru newlib.orig/newlib/libc/include/sys/reent.h newlib/newlib/libc/include/sys/reent.h
--- newlib.orig/newlib/libc/include/sys/reent.h Thu Sep 9 20:46:54 2004
+++ newlib/newlib/libc/include/sys/reent.h Fri Sep 10 14:01:53 2004
@@ -816,7 +816,11 @@
#endif /* !_REENT_ONLY */
+#ifdef __CYGWIN__
#define _GLOBAL_REENT _impure_ptr
+#else
+#define _GLOBAL_REENT _global_impure_ptr
+#endif
#ifdef __cplusplus
}
diff -ru newlib.orig/newlib/libc/include/sys/stdio.h newlib/newlib/libc/include/sys/stdio.h
--- newlib.orig/newlib/libc/include/sys/stdio.h Fri Jun 11 21:37:09 2004
+++ newlib/newlib/libc/include/sys/stdio.h Thu Sep 9 11:06:37 2004
@@ -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 -ru newlib.orig/newlib/libc/stdio/fwalk.c newlib/newlib/libc/stdio/fwalk.c
--- newlib.orig/newlib/libc/stdio/fwalk.c Wed Apr 28 19:02:38 2004
+++ newlib/newlib/libc/stdio/fwalk.c Wed Jun 30 15:48:47 2004
@@ -82,12 +82,9 @@
__sfp_lock_acquire ();
- /* Must traverse given list for std streams. */
- if (ptr != _GLOBAL_REENT)
- ret |= __fwalk (ptr, function);
-
- /* Must traverse global list for all other streams. */
- ret |= __fwalk (_GLOBAL_REENT, function);
+ /* Must traverse given list for streams. Note that _GLOBAL_REENT
+ only walked once in exit(). */
+ ret |= __fwalk (ptr, function);
__sfp_lock_release ();
@@ -105,12 +102,9 @@
__sfp_lock_acquire ();
- /* Must traverse given list for std streams. */
- if (ptr != _GLOBAL_REENT)
- ret |= __fwalk_reent (ptr, reent_function);
-
- /* Must traverse global list for all other streams. */
- ret |= __fwalk_reent (_GLOBAL_REENT, reent_function);
+ /* Must traverse given list for streams. Note that _GLOBAL_REENT
+ only walked once in exit(). */
+ ret |= __fwalk_reent (ptr, reent_function);
__sfp_lock_release ();
diff -ru newlib.orig/newlib/libc/stdio/local.h newlib/newlib/libc/stdio/local.h
--- newlib.orig/newlib/libc/stdio/local.h Wed Apr 28 19:02:38 2004
+++ newlib/newlib/libc/stdio/local.h Thu Sep 9 10:59:15 2004
@@ -48,11 +48,11 @@
/* 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 -ru newlib.orig/newlib/libc/stdio/setbuffer.c newlib/newlib/libc/stdio/setbuffer.c
--- newlib.orig/newlib/libc/stdio/setbuffer.c Fri Apr 23 21:01:55 2004
+++ newlib/newlib/libc/stdio/setbuffer.c Thu Sep 9 20:12:35 2004
@@ -65,41 +65,6 @@
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
-
-
-FUNCTION
-<<setlinebuf>>---specify line buffering for a file or stream
-
-INDEX
- setlinebuf
-
-ANSI_SYNOPSIS
- #include <stdio.h>
- void setlinebuf(FILE *<[fp]>);
-
-TRAD_SYNOPSIS
- #include <stdio.h>
- void setlinebuf(<[fp]>)
- FILE *<[fp]>;
-
-DESCRIPTION
-<<setlinebuf>> specifies that output to the file or stream identified by
-<[fp]> should be line buffered. This causes the file or stream to pass
-on output to the host system at every newline, as well as when the
-buffer is full, or when an input operation intervenes.
-
-WARNINGS
-You may only use <<setlinebuf>> before performing any file operation
-other than opening the file.
-
-RETURNS
-<<setlinebuf>> returns as per setvbuf.
-
-PORTABILITY
-This function comes from BSD not ANSI or POSIX.
-
-Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
-<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
#include <_ansi.h>
diff -ru newlib.orig/newlib/libc/stdio/siprintf.c newlib/newlib/libc/stdio/siprintf.c
--- newlib.orig/newlib/libc/stdio/siprintf.c Fri May 7 22:00:41 2004
+++ newlib/newlib/libc/stdio/siprintf.c Thu Sep 9 10:59:46 2004
@@ -85,6 +85,7 @@
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 @@
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 -ru newlib.orig/newlib/libc/stdio/snprintf.c newlib/newlib/libc/stdio/snprintf.c
--- newlib.orig/newlib/libc/stdio/snprintf.c Fri Apr 23 21:01:55 2004
+++ newlib/newlib/libc/stdio/snprintf.c Thu Sep 9 10:59:57 2004
@@ -51,6 +51,7 @@
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 @@
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 -ru newlib.orig/newlib/libc/stdio/sscanf.c newlib/newlib/libc/stdio/sscanf.c
--- newlib.orig/newlib/libc/stdio/sscanf.c Fri Apr 23 21:01:55 2004
+++ newlib/newlib/libc/stdio/sscanf.c Thu Sep 9 11:00:46 2004
@@ -402,12 +402,13 @@
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 @@
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 -ru newlib.orig/newlib/libc/stdio/stdio.tex newlib/newlib/libc/stdio/stdio.tex
--- newlib.orig/newlib/libc/stdio/stdio.tex Thu Jul 18 00:25:44 2002
+++ newlib/newlib/libc/stdio/stdio.tex Thu Sep 9 20:12:59 2004
@@ -26,12 +26,14 @@
@menu
* clearerr:: Clear file or stream error indicator
* fclose:: Close a file
+* fcloseall:: Close all files
* feof:: Test for end of file
* ferror:: Test whether read/write error has occurred
* fflush:: Flush buffered file output
* fgetc:: Get a character from a file or stream
* fgetpos:: Record position in a stream or file
* fgets:: Get character string from a file or stream
+* fileno:: Get file descriptor associated with stream
* fiprintf:: Write formatted output to file (integer only)
* fopen:: Open a file
* fdopen:: Turn an open file into a stream
@@ -44,20 +46,28 @@
* ftell:: Return position in a stream or file
* fwrite:: Write array elements from memory to a file or stream
* getc:: Get a character from a file or stream (macro)
+* getc_unlocked:: Get a character from a file or stream (macro)
* getchar:: Get a character from standard input (macro)
+* getchar_unlocked:: Get a character from standard input (macro)
+* getdelim:: Get character string from a file or stream
+* getline:: Get character string from a file or stream
* gets:: Get character string from standard input (obsolete)
* getw:: Get a word (int) from a file or stream
* iprintf:: Write formatted output (integer only)
* mktemp:: Generate unused file name
* perror:: Print an error message on standard error
* putc:: Write a character on a stream or file (macro)
+* putc_unlocked:: Write a character on a stream or file (macro)
* putchar:: Write a character on standard output (macro)
+* putchar_unlocked:: Write a character on standard output (macro)
* puts:: Write a character string on standard output
* putw:: Write a word (int) to a file or stream
* remove:: Delete a file's name
* rename:: Rename a file
* rewind:: Reinitialize a file or stream
* setbuf:: Specify full buffering for a file or stream
+* setbuffer:: Specify full buffering for a file or stream with size
+* setlinebuf:: Specify line buffering for a file or stream
* setvbuf:: Specify buffering for a file or stream
* siprintf:: Write formatted output (integer only)
* printf:: Write formatted output
@@ -65,6 +75,7 @@
* tmpfile:: Create a temporary file
* tmpnam:: Generate name for a temporary file
* vprintf:: Format variable argument list
+* vscanf:: Format variable argument list
@end menu
@page
@@ -74,6 +85,9 @@
@include stdio/fclose.def
@page
+@include stdio/fcloseall.def
+
+@page
@include stdio/feof.def
@page
@@ -92,6 +106,9 @@
@include stdio/fgets.def
@page
+@include stdio/fileno.def
+
+@page
@include stdio/fiprintf.def
@page
@@ -128,8 +145,20 @@
@include stdio/getc.def
@page
+@include stdio/getc_u.def
+
+@page
@include stdio/getchar.def
+@page
+@include stdio/getchar_u.def
+
+@page
+@include stdio/getdelim.def
+
+@page
+@include stdio/getline.def
+
@page
@include stdio/gets.def
@@ -149,9 +178,15 @@
@include stdio/putc.def
@page
+@include stdio/putc_u.def
+
+@page
@include stdio/putchar.def
@page
+@include stdio/putchar_u.def
+
+@page
@include stdio/puts.def
@page
@@ -170,6 +205,12 @@
@include stdio/setbuf.def
@page
+@include stdio/setbuffer.def
+
+@page
+@include stdio/setlinebuf.def
+
+@page
@include stdio/setvbuf.def
@page
@@ -190,3 +231,5 @@
@page
@include stdio/vfprintf.def
+@page
+@include stdio/vfscanf.def
diff -ru newlib.orig/newlib/libc/stdio/vsnprintf.c newlib/newlib/libc/stdio/vsnprintf.c
--- newlib.orig/newlib/libc/stdio/vsnprintf.c Fri Apr 23 21:01:55 2004
+++ newlib/newlib/libc/stdio/vsnprintf.c Thu Sep 9 11:00:07 2004
@@ -45,6 +45,7 @@
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 @@
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 -ru newlib.orig/newlib/libc/stdio/vsscanf.c newlib/newlib/libc/stdio/vsscanf.c
--- newlib.orig/newlib/libc/stdio/vsscanf.c Fri Apr 23 21:01:55 2004
+++ newlib/newlib/libc/stdio/vsscanf.c Thu Sep 9 11:00:57 2004
@@ -63,12 +63,12 @@
{
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);
}
-
diff -ru newlib.orig/newlib/libc/stdio64/freopen64.c newlib/newlib/libc/stdio64/freopen64.c
--- newlib.orig/newlib/libc/stdio64/freopen64.c Thu Apr 8 23:26:50 2004
+++ newlib/newlib/libc/stdio64/freopen64.c Wed Jun 30 15:48:13 2004
@@ -157,7 +157,7 @@
ptr->_errno = e; /* restore in case _close clobbered */
_funlockfile(fp);
#ifndef __SINGLE_THREAD__
- __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock);
+ __lock_close_recursive (fp->_lock);
#endif
__sfp_lock_release ();
return NULL;
diff -ru newlib.orig/newlib/libc/stdlib/exit.c newlib/newlib/libc/stdlib/exit.c
--- newlib.orig/newlib/libc/stdlib/exit.c Thu Sep 9 20:46:54 2004
+++ newlib/newlib/libc/stdlib/exit.c Fri Sep 10 14:01:55 2004
@@ -50,8 +50,6 @@
#include <reent.h>
#include "atexit.h"
-#ifndef _REENT_ONLY
-
/*
* Exit, flushing stdio buffers if necessary.
*/
@@ -66,5 +64,3 @@
(*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT);
_exit (code);
}
-
-#endif
diff -ru newlib.orig/newlib/libc/stdlib/stdlib.tex newlib/newlib/libc/stdlib/stdlib.tex
--- newlib.orig/newlib/libc/stdlib/stdlib.tex Thu Nov 27 19:47:19 2003
+++ newlib/newlib/libc/stdlib/stdlib.tex Thu Sep 9 20:13:03 2004
@@ -5,6 +5,8 @@
The corresponding declarations are in the header file @file{stdlib.h}.
@menu
+* _Exit:: End program execution without cleaning up
+* a64l:: String to long long
* abort:: Abnormal termination of a program
* abs:: Integer absolute value (magnitude)
* assert:: Macro for Debugging Diagnostics
@@ -30,17 +32,26 @@
* mbstowcs:: Minimal multibyte string to wide string converter
* mblen:: Minimal multibyte length
* mbtowc:: Minimal multibyte to wide character converter
+* on_exit:: Request execution of functions at program exit
* rand:: Pseudo-random numbers
* rand48:: Uniformly distributed pseudo-random numbers
* strtod:: String to double or float
* strtol:: String to long
+* strtoll:: String to long long
* strtoul:: String to unsigned long
+* strtoull:: String to unsigned long long
* system:: Execute command string
* wcstombs:: Minimal wide string to multibyte string converter
* wctomb:: Minimal wide character to multibyte converter
@end menu
@page
+@include stdlib/_Exit.def
+
+@page
+@include stdlib/a64l.def
+
+@page
@include stdlib/abort.def
@page
@@ -113,6 +124,9 @@
@include stdlib/mbtowc.def
@page
+@include stdlib/on_exit.def
+
+@page
@include stdlib/rand.def
@page
@@ -125,7 +139,13 @@
@include stdlib/strtol.def
@page
+@include stdlib/strtoll.def
+
+@page
@include stdlib/strtoul.def
+
+@page
+@include stdlib/strtoull.def
@page
@include stdlib/system.def
diff -ru newlib.orig/newlib/libc/string/strings.tex newlib/newlib/libc/string/strings.tex
--- newlib.orig/newlib/libc/string/strings.tex Fri Jul 26 16:26:42 2002
+++ newlib/newlib/libc/string/strings.tex Thu Sep 9 20:13:06 2004
@@ -26,12 +26,14 @@
* strcpy:: Copy string
* strcspn:: Count chars not in string
* strerror:: Convert error number to string
+* strerror_r:: Convert error number to string
* strlen:: Character string length
* strlwr:: Convert string to lower case
* strncasecmp:: Compare strings ignoring case
* strncat:: Concatenate strings
* strncmp:: Character string compare
* strncpy:: Counted copy string
+* strnlen:: Character string length
* strpbrk:: Find chars in string
* strrchr:: Reverse search for character in string
* strspn:: Find initial match
@@ -103,6 +105,9 @@
@include string/strerror.def
@page
+@include string/strerror_r.def
+
+@page
@include string/strlen.def
@page
@@ -119,6 +124,9 @@
@page
@include string/strncpy.def
+
+@page
+@include string/strnlen.def
@page
@include string/strpbrk.def
diff -ru newlib.orig/newlib/libc/time/time.tex newlib/newlib/libc/time/time.tex
--- newlib.orig/newlib/libc/time/time.tex Wed Apr 17 22:37:07 2002
+++ newlib/newlib/libc/time/time.tex Thu Sep 9 20:13:07 2004
@@ -56,6 +56,7 @@
* mktime:: Convert time to arithmetic representation
* strftime:: Flexible calendar time formatter
* time:: Get current calendar time (as single number)
+* __tz_lock:: Lock time zone global variables
* tzset:: Set timezone info
@end menu
@@ -85,6 +86,9 @@
@page
@include time/time.def
+
+@page
+@include time/tzlock.def
@page
@include time/tzset.def
diff -ru newlib.orig/newlib/libc/time/tzlock.c newlib/newlib/libc/time/tzlock.c
--- newlib.orig/newlib/libc/time/tzlock.c Wed Apr 17 22:23:31 2002
+++ newlib/newlib/libc/time/tzlock.c Fri Sep 3 09:09:44 2004
@@ -17,13 +17,14 @@
void __tz_unlock();
DESCRIPTION
-The <<tzset>> facility functions call these functions when they need
-to ensure the values of global variables. The version of these routines supplied
-in the library do not do anything. If multiple threads of execution
-can call the time functions and give up scheduling in the middle, then you
-you need to define your own versions of these functions in order to
-safely lock the time zone variables during a call. If you do not, the results
-of <<localtime>>, <<mktime>>, <<ctime>>, and <<strftime>> are undefined.
+The <<tzset>> facility functions call these functions when they need to
+ensure the values of global variables. The version of these routines
+supplied in the library use the lock API defined in sys/lock.h. If multiple
+threads of execution can call the time functions and give up scheduling in
+the middle, then you you need to define your own versions of these functions
+in order to safely lock the time zone variables during a call. If you do
+not, the results of <<localtime>>, <<mktime>>, <<ctime>>, and <<strftime>>
+are undefined.
The lock <<__tz_lock>> may not be called recursively; that is,
a call <<__tz_lock>> will always lock all subsequent <<__tz_lock>> calls
@@ -32,13 +33,24 @@
#include <_ansi.h>
#include "local.h"
+#include <sys/lock.h>
+
+#ifndef __SINGLE_THREAD__
+__LOCK_INIT(static, __tz_lock_object);
+#endif
_VOID
_DEFUN_VOID (__tz_lock)
{
+#ifndef __SINGLE_THREAD__
+ __lock_acquire(__tz_lock_object);
+#endif
}
_VOID
_DEFUN_VOID (__tz_unlock)
{
+#ifndef __SINGLE_THREAD__
+ __lock_release(__tz_lock_object);
+#endif
}