2004-06-11 Antony King <antony.king@st.com>
* libc/include/sys/_types.h: Include <sys/lock.h> and change
        _flock_t to be of type _LOCK_RECURSIVE_T.
        * libc/include/sys/reent.h: (_REENT_INIT): Reformat.
        (_REENT_INIT_PTR): Ditto.  Use memset where appropriate.
        (_global_impure_ptr): New declaration.
        (_GLOBAL_REENT): Change to be _global_impure_ptr.
        * libc/include/sys/stdio.h: Include <sys/lock.h> and
        <sys/reent.h>.
        (_flockfile)[!_SINGLE_THREAD]: Add code for lock call.
        (_funlockfile)[!SINGLE_THREAD]: Ditto.
        * libc/reent/impure.c: Set _global_impure_ptr to _impure_ptr.
        * libc/stdio/fclose.c: Remove casting of fp lock to
        _LOCK_RECURSIVE_T.
        * libc/stdio/findfp.c: Ditto.
        * libc/stdio/fopen.c: Ditto.
        * libc/stdio/freopen.c: Ditto.
        * libc/stdio/vfprintf.c: Ditto.
        * libc/stdio64/fopen64.c: Ditto.
        * libc/stdlib/envlock.c: Add default stubs that use generic
        locking code.
        * libc/stdlib/mlock.c: Ditto.
        Jeff Johnston  <jjohnstn@redhat.com>
        * libc/sys/linux/sys/_types.h (__flock_mutex_t): New subtype.
        (_flock_t): Change to be a struct containing a single member
        named mutex which is of type __flock_mutex_t.
			
			
This commit is contained in:
		| @@ -1,3 +1,32 @@ | |||||||
|  | 2004-06-11  Antony King  <antony.king@st.com> | ||||||
|  |  | ||||||
|  | 	* libc/include/sys/_types.h: Include <sys/lock.h> and change | ||||||
|  | 	_flock_t to be of type _LOCK_RECURSIVE_T. | ||||||
|  | 	* libc/include/sys/reent.h: (_REENT_INIT): Reformat. | ||||||
|  | 	(_REENT_INIT_PTR): Ditto.  Use memset where appropriate. | ||||||
|  | 	(_global_impure_ptr): New declaration. | ||||||
|  | 	(_GLOBAL_REENT): Change to be _global_impure_ptr. | ||||||
|  | 	* libc/include/sys/stdio.h: Include <sys/lock.h> and | ||||||
|  | 	<sys/reent.h>. | ||||||
|  | 	(_flockfile)[!_SINGLE_THREAD]: Add code for lock call. | ||||||
|  | 	(_funlockfile)[!SINGLE_THREAD]: Ditto. | ||||||
|  | 	* libc/reent/impure.c: Set _global_impure_ptr to _impure_ptr. | ||||||
|  | 	* libc/stdio/fclose.c: Remove casting of fp lock to | ||||||
|  | 	_LOCK_RECURSIVE_T. | ||||||
|  | 	* libc/stdio/findfp.c: Ditto. | ||||||
|  | 	* libc/stdio/fopen.c: Ditto. | ||||||
|  | 	* libc/stdio/freopen.c: Ditto. | ||||||
|  | 	* libc/stdio/vfprintf.c: Ditto. | ||||||
|  | 	* libc/stdio64/fopen64.c: Ditto. | ||||||
|  | 	* libc/stdlib/envlock.c: Add default stubs that use generic | ||||||
|  | 	locking code. | ||||||
|  | 	* libc/stdlib/mlock.c: Ditto. | ||||||
|  |  | ||||||
|  | 	Jeff Johnston  <jjohnstn@redhat.com> | ||||||
|  | 	* libc/sys/linux/sys/_types.h (__flock_mutex_t): New subtype. | ||||||
|  | 	(_flock_t): Change to be a struct containing a single member | ||||||
|  | 	named mutex which is of type __flock_mutex_t. | ||||||
|  |  | ||||||
| 2004-06-09  Jeff Johnston  <jjohnstn@redhat.com> | 2004-06-09  Jeff Johnston  <jjohnstn@redhat.com> | ||||||
|  |  | ||||||
| 	* libc/sys/linux/Makefile.am: Change siglist.inc to be generated | 	* libc/sys/linux/Makefile.am: Change siglist.inc to be generated | ||||||
|   | |||||||
| @@ -9,6 +9,8 @@ | |||||||
| #ifndef	_SYS__TYPES_H | #ifndef	_SYS__TYPES_H | ||||||
| #define _SYS__TYPES_H | #define _SYS__TYPES_H | ||||||
|  |  | ||||||
|  | #include <sys/lock.h> | ||||||
|  |  | ||||||
| typedef long _off_t; | typedef long _off_t; | ||||||
| __extension__ typedef long long _off64_t; | __extension__ typedef long long _off64_t; | ||||||
|  |  | ||||||
| @@ -32,7 +34,7 @@ typedef struct | |||||||
|   } __value;		/* Value so far.  */ |   } __value;		/* Value so far.  */ | ||||||
| } _mbstate_t; | } _mbstate_t; | ||||||
|  |  | ||||||
| typedef int _flock_t; | typedef _LOCK_RECURSIVE_T _flock_t; | ||||||
|  |  | ||||||
| /* Iconv descriptor type */ | /* Iconv descriptor type */ | ||||||
| typedef void *_iconv_t; | typedef void *_iconv_t; | ||||||
|   | |||||||
| @@ -381,10 +381,31 @@ struct _reent | |||||||
| }; | }; | ||||||
|  |  | ||||||
| #define _REENT_INIT(var) \ | #define _REENT_INIT(var) \ | ||||||
|   { (__FILE *)&var.__sf_fake, (__FILE *)&var.__sf_fake, \ |   { (__FILE *)&var.__sf_fake, \ | ||||||
|     (__FILE *)&var.__sf_fake, 0, 0, _NULL, 0, 0, \ |     (__FILE *)&var.__sf_fake, \ | ||||||
|     "C", _NULL, _NULL, 0, 0, _NULL, _NULL, _NULL, _NULL, _NULL, \ |     (__FILE *)&var.__sf_fake, \ | ||||||
|     { 0, _NULL, _NULL, 0 }, { _NULL, 0, _NULL }, _NULL, 0, _NULL, _NULL } |     0, \ | ||||||
|  |     0, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     0, \ | ||||||
|  |     0, \ | ||||||
|  |     "C", \ | ||||||
|  |     _NULL, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     0, \ | ||||||
|  |     0, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     {0, {_NULL}, _NULL}, \ | ||||||
|  |     {_NULL, 0, _NULL}, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     {_NULL, 0, 0, 0, 0, {_NULL, 0}, 0, _NULL}, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     _NULL \ | ||||||
|  |   } | ||||||
|  |  | ||||||
| #define _REENT_INIT_PTR(var) \ | #define _REENT_INIT_PTR(var) \ | ||||||
|   { var->_stdin = (__FILE *)&var->__sf_fake; \ |   { var->_stdin = (__FILE *)&var->__sf_fake; \ | ||||||
| @@ -412,16 +433,17 @@ struct _reent | |||||||
|     var->__sglue._niobs = 0; \ |     var->__sglue._niobs = 0; \ | ||||||
|     var->__sglue._iobs = _NULL; \ |     var->__sglue._iobs = _NULL; \ | ||||||
|     var->__sf = 0; \ |     var->__sf = 0; \ | ||||||
|     var->_misc = _NULL; \ |  | ||||||
|     var->_signal_buf = _NULL; \ |  | ||||||
|     var->_getdate_err = 0; \ |  | ||||||
|     var->__sf_fake._p = _NULL; \ |     var->__sf_fake._p = _NULL; \ | ||||||
|     var->__sf_fake._r = 0; \ |     var->__sf_fake._r = 0; \ | ||||||
|     var->__sf_fake._w = 0; \ |     var->__sf_fake._w = 0; \ | ||||||
|     var->__sf_fake._flags = 0; \ |     var->__sf_fake._flags = 0; \ | ||||||
|     var->__sf_fake._file = 0; \ |     var->__sf_fake._file = 0; \ | ||||||
|  |     var->__sf_fake._bf._base = _NULL; \ | ||||||
|  |     var->__sf_fake._bf._size = 0; \ | ||||||
|     var->__sf_fake._lbfsize = 0; \ |     var->__sf_fake._lbfsize = 0; \ | ||||||
|     var->__sf_fake._data = _NULL; \ |     var->__sf_fake._data = _NULL; \ | ||||||
|  |     var->_misc = _NULL; \ | ||||||
|  |     var->_signal_buf = _NULL; \ | ||||||
|   } |   } | ||||||
|  |  | ||||||
| /* Only built the assert() calls if we are built with debugging.  */ | /* Only built the assert() calls if we are built with debugging.  */ | ||||||
| @@ -608,23 +630,61 @@ struct _reent | |||||||
| }; | }; | ||||||
|  |  | ||||||
| #define _REENT_INIT(var) \ | #define _REENT_INIT(var) \ | ||||||
|   { 0, &var.__sf[0], &var.__sf[1], &var.__sf[2], 0, "", 0, "C", \ |   { 0, \ | ||||||
|     0, _NULL, _NULL, 0, _NULL, _NULL, 0, _NULL, { {0, _NULL, "", \ |     &var.__sf[0], \ | ||||||
|     { 0,0,0,0,0,0,0,0}, 0, 1, \ |     &var.__sf[1], \ | ||||||
|     {{_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \ |     &var.__sf[2], \ | ||||||
|      {_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, _RAND48_ADD}, \ |     0, \ | ||||||
|     {0, {0}}, {0, {0}}, {0, {0}}, "", "", 0, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}} } } } |     "", \ | ||||||
|  |     0, \ | ||||||
|  |     "C", \ | ||||||
|  |     0, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     0, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     0, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     { \ | ||||||
|  |       { \ | ||||||
|  |         0, \ | ||||||
|  |         _NULL, \ | ||||||
|  |         "", \ | ||||||
|  |         {0, 0, 0, 0, 0, 0, 0, 0, 0}, \ | ||||||
|  |         0, \ | ||||||
|  |         1, \ | ||||||
|  |         { \ | ||||||
|  |           {_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, \ | ||||||
|  |           {_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, \ | ||||||
|  |           _RAND48_ADD \ | ||||||
|  |         }, \ | ||||||
|  |         {0, {0}}, \ | ||||||
|  |         {0, {0}}, \ | ||||||
|  |         {0, {0}}, \ | ||||||
|  |         "", \ | ||||||
|  |         "", \ | ||||||
|  |         0, \ | ||||||
|  |         {0, {0}}, \ | ||||||
|  |         {0, {0}}, \ | ||||||
|  |         {0, {0}}, \ | ||||||
|  |         {0, {0}}, \ | ||||||
|  |         {0, {0}} \ | ||||||
|  |       } \ | ||||||
|  |     }, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     {_NULL, 0, {_NULL}, {{_NULL}, 0}}, \ | ||||||
|  |     _NULL, \ | ||||||
|  |     {_NULL, 0, _NULL} \ | ||||||
|  |   } | ||||||
|  |  | ||||||
| #define _REENT_INIT_PTR(var) \ | #define _REENT_INIT_PTR(var) \ | ||||||
|   { int i; \ |   { var->_errno = 0; \ | ||||||
|     char *tmp_ptr; \ |  | ||||||
|     var->_errno = 0; \ |  | ||||||
|     var->_stdin = &var->__sf[0]; \ |     var->_stdin = &var->__sf[0]; \ | ||||||
|     var->_stdout = &var->__sf[1]; \ |     var->_stdout = &var->__sf[1]; \ | ||||||
|     var->_stderr = &var->__sf[2]; \ |     var->_stderr = &var->__sf[2]; \ | ||||||
|     var->_inc = 0; \ |     var->_inc = 0; \ | ||||||
|     for (i = 0; i < _REENT_EMERGENCY_SIZE; ++i) \ |     memset(&var->_emergency, 0, sizeof(var->_emergency)); \ | ||||||
|       var->_emergency[i] = 0; \ |  | ||||||
|     var->_current_category = 0; \ |     var->_current_category = 0; \ | ||||||
|     var->_current_locale = "C"; \ |     var->_current_locale = "C"; \ | ||||||
|     var->__sdidinit = 0; \ |     var->__sdidinit = 0; \ | ||||||
| @@ -638,9 +698,7 @@ struct _reent | |||||||
|     var->_new._reent._unused_rand = 0; \ |     var->_new._reent._unused_rand = 0; \ | ||||||
|     var->_new._reent._strtok_last = _NULL; \ |     var->_new._reent._strtok_last = _NULL; \ | ||||||
|     var->_new._reent._asctime_buf[0] = 0; \ |     var->_new._reent._asctime_buf[0] = 0; \ | ||||||
|     tmp_ptr = (char *)&var->_new._reent._localtime_buf; \ |     memset(&var->_new._reent._localtime_buf, 0, sizeof(var->_new._reent._localtime_buf)); \ | ||||||
|     for (i = 0; i < sizeof(struct __tm); ++i) \ |  | ||||||
|       tmp_ptr[i] = 0; \ |  | ||||||
|     var->_new._reent._gamma_signgam = 0; \ |     var->_new._reent._gamma_signgam = 0; \ | ||||||
|     var->_new._reent._rand_next = 1; \ |     var->_new._reent._rand_next = 1; \ | ||||||
|     var->_new._reent._r48._seed[0] = _RAND48_SEED_0; \ |     var->_new._reent._r48._seed[0] = _RAND48_SEED_0; \ | ||||||
| @@ -670,6 +728,7 @@ struct _reent | |||||||
|     var->_new._reent._signal_buf[0] = '\0'; \ |     var->_new._reent._signal_buf[0] = '\0'; \ | ||||||
|     var->_new._reent._getdate_err = 0; \ |     var->_new._reent._getdate_err = 0; \ | ||||||
|     var->_atexit = _NULL; \ |     var->_atexit = _NULL; \ | ||||||
|  |     var->_atexit0._next = _NULL; \ | ||||||
|     var->_atexit0._ind = 0; \ |     var->_atexit0._ind = 0; \ | ||||||
|     var->_atexit0._fns[0] = _NULL; \ |     var->_atexit0._fns[0] = _NULL; \ | ||||||
|     var->_atexit0._on_exit_args._fntypes = 0; \ |     var->_atexit0._on_exit_args._fntypes = 0; \ | ||||||
| @@ -678,7 +737,7 @@ struct _reent | |||||||
|     var->__sglue._next = _NULL; \ |     var->__sglue._next = _NULL; \ | ||||||
|     var->__sglue._niobs = 0; \ |     var->__sglue._niobs = 0; \ | ||||||
|     var->__sglue._iobs = _NULL; \ |     var->__sglue._iobs = _NULL; \ | ||||||
|     memset(var->__sf,0,sizeof(var->__sf)); \ |     memset(&var->__sf, 0, sizeof(var->__sf)); \ | ||||||
|   } |   } | ||||||
|  |  | ||||||
| #define _REENT_CHECK_RAND48(ptr)	/* nothing */ | #define _REENT_CHECK_RAND48(ptr)	/* nothing */ | ||||||
| @@ -728,6 +787,7 @@ struct _reent | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__; | extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__; | ||||||
|  | extern struct _reent *_CONST _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__; | ||||||
|  |  | ||||||
| void _reclaim_reent _PARAMS ((struct _reent *)); | void _reclaim_reent _PARAMS ((struct _reent *)); | ||||||
|  |  | ||||||
| @@ -746,7 +806,7 @@ void _reclaim_reent _PARAMS ((struct _reent *)); | |||||||
|  |  | ||||||
| #endif /* !_REENT_ONLY */ | #endif /* !_REENT_ONLY */ | ||||||
|  |  | ||||||
| #define _GLOBAL_REENT _impure_ptr | #define _GLOBAL_REENT _global_impure_ptr | ||||||
|  |  | ||||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,14 +1,25 @@ | |||||||
| #ifndef _NEWLIB_STDIO_H | #ifndef _NEWLIB_STDIO_H | ||||||
| #define _NEWLIB_STDIO_H | #define _NEWLIB_STDIO_H | ||||||
|  |  | ||||||
|  | #include <sys/lock.h> | ||||||
|  | #include <sys/reent.h> | ||||||
|  |  | ||||||
| /* Internal locking macros, used to protect stdio functions.  In the | /* Internal locking macros, used to protect stdio functions.  In the | ||||||
|    general case, expand to nothing. */ |    general case, expand to nothing. */ | ||||||
| #if !defined(_flockfile) | #if !defined(_flockfile) | ||||||
|  | #ifndef __SINGLE_THREAD__ | ||||||
|  | #  define _flockfile(fp) __lock_acquire_recursive(fp->_lock) | ||||||
|  | #else | ||||||
| #  define _flockfile(fp) | #  define _flockfile(fp) | ||||||
| #endif | #endif | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #if !defined(_funlockfile) | #if !defined(_funlockfile) | ||||||
|  | #ifndef __SINGLE_THREAD__ | ||||||
|  | #  define _funlockfile(fp) __lock_release_recursive(fp->_lock) | ||||||
|  | #else | ||||||
| #  define _funlockfile(fp) | #  define _funlockfile(fp) | ||||||
| #endif | #endif | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #endif /* _NEWLIB_STDIO_H */ | #endif /* _NEWLIB_STDIO_H */ | ||||||
|   | |||||||
| @@ -11,3 +11,4 @@ | |||||||
|  |  | ||||||
| static struct _reent __ATTRIBUTE_IMPURE_DATA__ impure_data = _REENT_INIT (impure_data); | static struct _reent __ATTRIBUTE_IMPURE_DATA__ impure_data = _REENT_INIT (impure_data); | ||||||
| struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr = &impure_data; | struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr = &impure_data; | ||||||
|  | struct _reent *_CONST __ATTRIBUTE_IMPURE_PTR__ _global_impure_ptr = &impure_data; | ||||||
|   | |||||||
| @@ -98,7 +98,7 @@ _DEFUN(_fclose_r, (rptr, fp), | |||||||
|   fp->_flags = 0;		/* release this FILE for reuse */ |   fp->_flags = 0;		/* release this FILE for reuse */ | ||||||
|   _funlockfile (fp); |   _funlockfile (fp); | ||||||
| #ifndef __SINGLE_THREAD__ | #ifndef __SINGLE_THREAD__ | ||||||
|   __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock); |   __lock_close_recursive (fp->_lock); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   __sfp_lock_release (); |   __sfp_lock_release (); | ||||||
|   | |||||||
| @@ -47,7 +47,7 @@ _DEFUN(std, (ptr, flags, file, data), | |||||||
|   ptr->_seek = __sseek; |   ptr->_seek = __sseek; | ||||||
|   ptr->_close = __sclose; |   ptr->_close = __sclose; | ||||||
| #if !defined(__SINGLE_THREAD__) && !defined(_REENT_SMALL) | #if !defined(__SINGLE_THREAD__) && !defined(_REENT_SMALL) | ||||||
|   __lock_init_recursive (*(_LOCK_RECURSIVE_T *)&ptr->_lock); |   __lock_init_recursive (ptr->_lock); | ||||||
|   /* |   /* | ||||||
|    * #else |    * #else | ||||||
|    * lock is already initialized in __sfp |    * lock is already initialized in __sfp | ||||||
| @@ -112,7 +112,7 @@ found: | |||||||
|   fp->_file = -1;		/* no file */ |   fp->_file = -1;		/* no file */ | ||||||
|   fp->_flags = 1;		/* reserve this slot; caller sets real flags */ |   fp->_flags = 1;		/* reserve this slot; caller sets real flags */ | ||||||
| #ifndef __SINGLE_THREAD__ | #ifndef __SINGLE_THREAD__ | ||||||
|   __lock_init_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock); |   __lock_init_recursive (fp->_lock); | ||||||
| #endif | #endif | ||||||
|   __sfp_lock_release ();  |   __sfp_lock_release ();  | ||||||
|  |  | ||||||
| @@ -143,8 +143,8 @@ _VOID | |||||||
| _DEFUN(_cleanup_r, (ptr), | _DEFUN(_cleanup_r, (ptr), | ||||||
|        struct _reent *ptr) |        struct _reent *ptr) | ||||||
| { | { | ||||||
|   /* _CAST_VOID _fwalk(fclose); */ |   _CAST_VOID _fwalk(ptr, fclose); | ||||||
|   _CAST_VOID _fwalk (ptr, fflush);	/* `cheating' */ |   /* _CAST_VOID _fwalk (ptr, fflush); */	/* `cheating' */ | ||||||
| } | } | ||||||
|  |  | ||||||
| #ifndef _REENT_ONLY | #ifndef _REENT_ONLY | ||||||
|   | |||||||
| @@ -143,7 +143,7 @@ _DEFUN(_fopen_r, (ptr, file, mode), | |||||||
|       __sfp_lock_acquire ();  |       __sfp_lock_acquire ();  | ||||||
|       fp->_flags = 0;		/* release */ |       fp->_flags = 0;		/* release */ | ||||||
| #ifndef __SINGLE_THREAD__ | #ifndef __SINGLE_THREAD__ | ||||||
|       __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock); |       __lock_close_recursive (fp->_lock); | ||||||
| #endif | #endif | ||||||
|       __sfp_lock_release ();  |       __sfp_lock_release ();  | ||||||
|       return NULL; |       return NULL; | ||||||
|   | |||||||
| @@ -157,7 +157,7 @@ _DEFUN(_freopen_r, (ptr, file, mode, fp), | |||||||
|       ptr->_errno = e;		/* restore in case _close clobbered */ |       ptr->_errno = e;		/* restore in case _close clobbered */ | ||||||
|       _funlockfile (fp); |       _funlockfile (fp); | ||||||
| #ifndef __SINGLE_THREAD__ | #ifndef __SINGLE_THREAD__ | ||||||
|       __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock); |       __lock_close_recursive (fp->_lock); | ||||||
| #endif | #endif | ||||||
|       __sfp_lock_release (); |       __sfp_lock_release (); | ||||||
|       return NULL; |       return NULL; | ||||||
|   | |||||||
| @@ -255,7 +255,7 @@ _DEFUN(__sbprintf, (rptr, fp, fmt, ap), | |||||||
| 	fake._bf._size = fake._w = sizeof (buf); | 	fake._bf._size = fake._w = sizeof (buf); | ||||||
| 	fake._lbfsize = 0;	/* not actually used, but Just In Case */ | 	fake._lbfsize = 0;	/* not actually used, but Just In Case */ | ||||||
| #ifndef __SINGLE_THREAD__ | #ifndef __SINGLE_THREAD__ | ||||||
| 	__lock_init_recursive (*(_LOCK_RECURSIVE_T *)&fake._lock); | 	__lock_init_recursive (fake._lock); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| 	/* do the work, then copy any error status */ | 	/* do the work, then copy any error status */ | ||||||
| @@ -266,7 +266,7 @@ _DEFUN(__sbprintf, (rptr, fp, fmt, ap), | |||||||
| 		fp->_flags |= __SERR; | 		fp->_flags |= __SERR; | ||||||
|  |  | ||||||
| #ifndef __SINGLE_THREAD__ | #ifndef __SINGLE_THREAD__ | ||||||
| 	__lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fake._lock); | 	__lock_close_recursive (fake._lock); | ||||||
| #endif | #endif | ||||||
| 	return (ret); | 	return (ret); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -94,7 +94,7 @@ _DEFUN (_fopen64_r, (ptr, file, mode), | |||||||
|       __sfp_lock_acquire ();  |       __sfp_lock_acquire ();  | ||||||
|       fp->_flags = 0;		/* release */ |       fp->_flags = 0;		/* release */ | ||||||
| #ifndef __SINGLE_THREAD__ | #ifndef __SINGLE_THREAD__ | ||||||
|       __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock); |       __lock_close_recursive (fp->_lock); | ||||||
| #endif | #endif | ||||||
|       __sfp_lock_release ();  |       __sfp_lock_release ();  | ||||||
|       return NULL; |       return NULL; | ||||||
|   | |||||||
| @@ -9,24 +9,24 @@ INDEX | |||||||
|  |  | ||||||
| ANSI_SYNOPSIS | ANSI_SYNOPSIS | ||||||
| 	#include "envlock.h" | 	#include "envlock.h" | ||||||
|        void __env_lock (struct _reent *<[reent]>); | 	void __env_lock (struct _reent *<[reent]>); | ||||||
|        void __env_unlock (struct _reent *<[reent]>); | 	void __env_unlock (struct _reent *<[reent]>); | ||||||
|  |  | ||||||
| TRAD_SYNOPSIS | TRAD_SYNOPSIS | ||||||
| 	void __env_lock(<[reent]>) | 	void __env_lock(<[reent]>) | ||||||
|        struct _reent *<[reent]>; | 	struct _reent *<[reent]>; | ||||||
|  |  | ||||||
| 	void __env_unlock(<[reent]>) | 	void __env_unlock(<[reent]>) | ||||||
|        struct _reent *<[reent]>; | 	struct _reent *<[reent]>; | ||||||
|  |  | ||||||
| DESCRIPTION | DESCRIPTION | ||||||
| The <<setenv>> family of routines call these functions when they need | The <<setenv>> family of routines call these functions when they need to | ||||||
| to modify the environ variable.  The version of these routines supplied | modify the environ variable.  The version of these routines supplied in the | ||||||
| in the library does not do anything.  If multiple threads of execution | library use the lock API defined in sys/lock.h.  If multiple threads of | ||||||
| can call <<setenv>>, or if <<setenv>> can be called reentrantly, then | execution can call <<setenv>>, or if <<setenv>> can be called reentrantly, | ||||||
| you need to define your own versions of these functions in order to | then you need to define your own versions of these functions in order to | ||||||
| safely lock the memory pool during a call.  If you do not, the memory | safely lock the memory pool during a call.  If you do not, the memory pool | ||||||
| pool may become corrupted. | may become corrupted. | ||||||
|  |  | ||||||
| A call to <<setenv>> may call <<__env_lock>> recursively; that is, | A call to <<setenv>> may call <<__env_lock>> recursively; that is, | ||||||
| the sequence of calls may go <<__env_lock>>, <<__env_lock>>, | the sequence of calls may go <<__env_lock>>, <<__env_lock>>, | ||||||
| @@ -36,16 +36,26 @@ that it already holds. | |||||||
| */ | */ | ||||||
|  |  | ||||||
| #include "envlock.h" | #include "envlock.h" | ||||||
|  | #include <sys/lock.h> | ||||||
|  |  | ||||||
|  | #ifndef __SINGLE_THREAD__ | ||||||
|  | __LOCK_INIT_RECURSIVE(static, __env_lock_object); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| void | void | ||||||
| __env_lock (ptr) | __env_lock (ptr) | ||||||
|      struct _reent *ptr; |      struct _reent *ptr; | ||||||
| { | { | ||||||
|  | #ifndef __SINGLE_THREAD__ | ||||||
|  |   __lock_acquire_recursive (__env_lock_object); | ||||||
|  | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| __env_unlock (ptr) | __env_unlock (ptr) | ||||||
|      struct _reent *ptr; |      struct _reent *ptr; | ||||||
| { | { | ||||||
|  | #ifndef __SINGLE_THREAD__ | ||||||
|  |   __lock_release_recursive (__env_lock_object); | ||||||
|  | #endif | ||||||
| } | } | ||||||
|   | |||||||
| @@ -21,13 +21,13 @@ TRAD_SYNOPSIS | |||||||
| 	struct _reent *<[reent]>; | 	struct _reent *<[reent]>; | ||||||
|  |  | ||||||
| DESCRIPTION | DESCRIPTION | ||||||
| The <<malloc>> family of routines call these functions when they need | The <<malloc>> family of routines call these functions when they need to lock | ||||||
| to lock the memory pool.  The version of these routines supplied in | the memory pool.  The version of these routines supplied in the library use | ||||||
| the library does not do anything.  If multiple threads of execution | the lock API defined in sys/lock.h.  If multiple threads of execution can | ||||||
| can call <<malloc>>, or if <<malloc>> can be called reentrantly, then | call <<malloc>>, or if <<malloc>> can be called reentrantly, then you need to | ||||||
| you need to define your own versions of these functions in order to | define your own versions of these functions in order to safely lock the | ||||||
| safely lock the memory pool during a call.  If you do not, the memory | memory pool during a call.  If you do not, the memory pool may become | ||||||
| pool may become corrupted. | corrupted. | ||||||
|  |  | ||||||
| A call to <<malloc>> may call <<__malloc_lock>> recursively; that is, | A call to <<malloc>> may call <<__malloc_lock>> recursively; that is, | ||||||
| the sequence of calls may go <<__malloc_lock>>, <<__malloc_lock>>, | the sequence of calls may go <<__malloc_lock>>, <<__malloc_lock>>, | ||||||
| @@ -37,16 +37,28 @@ that it already holds. | |||||||
| */ | */ | ||||||
|  |  | ||||||
| #include <malloc.h> | #include <malloc.h> | ||||||
|  | #include <sys/lock.h> | ||||||
|  |  | ||||||
|  | #ifndef __SINGLE_THREAD__ | ||||||
|  | __LOCK_INIT_RECURSIVE(static, __malloc_lock_object); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| void | void | ||||||
| __malloc_lock (ptr) | __malloc_lock (ptr) | ||||||
|      struct _reent *ptr; |      struct _reent *ptr; | ||||||
| { | { | ||||||
|  | #ifndef __SINGLE_THREAD__ | ||||||
|  |   __lock_acquire_recursive (__malloc_lock_object); | ||||||
|  | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void | void | ||||||
| __malloc_unlock (ptr) | __malloc_unlock (ptr) | ||||||
|      struct _reent *ptr; |      struct _reent *ptr; | ||||||
| { | { | ||||||
| } | #ifndef __SINGLE_THREAD__ | ||||||
|  |   __lock_release_recursive (__malloc_lock_object); | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ typedef struct | |||||||
|   } __value;		/* Value so far.  */ |   } __value;		/* Value so far.  */ | ||||||
| } _mbstate_t; | } _mbstate_t; | ||||||
|  |  | ||||||
| struct __flock_t_tmp; | struct __flock_mutex_t_tmp; | ||||||
| typedef struct | typedef struct | ||||||
| { | { | ||||||
|   int __a; |   int __a; | ||||||
| @@ -43,7 +43,9 @@ typedef struct | |||||||
|     int __c2; |     int __c2; | ||||||
|   } __c; |   } __c; | ||||||
|   int __d; |   int __d; | ||||||
|   struct __flock_t_tmp * __e; |   struct __flock_mutex_t_tmp * __e; | ||||||
| } _flock_t; | } __flock_mutex_t; | ||||||
|  |  | ||||||
|  | typedef struct { __flock_mutex_t mutex; } _flock_t; | ||||||
|  |  | ||||||
| #endif	/* _SYS__TYPES_H */ | #endif	/* _SYS__TYPES_H */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user