62,7 → 62,11 |
ptr->_flags |= __SL64; |
#endif /* __LARGE64_FILES */ |
ptr->_seek = __sseek; |
#ifdef _STDIO_CLOSE_PER_REENT_STD_STREAMS |
ptr->_close = __sclose; |
#else /* _STDIO_CLOSE_STD_STREAMS */ |
ptr->_close = NULL; |
#endif /* _STDIO_CLOSE_STD_STREAMS */ |
#if !defined(__SINGLE_THREAD__) && !defined(_REENT_SMALL) |
__lock_init_recursive (ptr->_lock); |
/* |
77,23 → 81,27 |
#endif |
} |
|
struct glue_with_file { |
struct _glue glue; |
FILE file; |
}; |
|
struct _glue * |
_DEFUN(__sfmoreglue, (d, n), |
struct _reent *d _AND |
register int n) |
{ |
struct _glue *g; |
FILE *p; |
struct glue_with_file *g; |
|
g = (struct _glue *) _malloc_r (d, sizeof (*g) + n * sizeof (FILE)); |
g = (struct glue_with_file *) |
_malloc_r (d, sizeof (*g) + (n - 1) * sizeof (FILE)); |
if (g == NULL) |
return NULL; |
p = (FILE *) (g + 1); |
g->_next = NULL; |
g->_niobs = n; |
g->_iobs = p; |
memset (p, 0, n * sizeof (FILE)); |
return g; |
g->glue._next = NULL; |
g->glue._niobs = n; |
g->glue._iobs = &g->file; |
memset (&g->file, 0, n * sizeof (FILE)); |
return &g->glue; |
} |
|
/* |
108,7 → 116,7 |
int n; |
struct _glue *g; |
|
__sfp_lock_acquire (); |
_newlib_sfp_lock_start (); |
|
if (!_GLOBAL_REENT->__sdidinit) |
__sinit (_GLOBAL_REENT); |
121,7 → 129,7 |
(g->_next = __sfmoreglue (d, NDYNAMIC)) == NULL) |
break; |
} |
__sfp_lock_release (); |
_newlib_sfp_lock_exit (); |
d->_errno = ENOMEM; |
return NULL; |
|
132,7 → 140,7 |
#ifndef __SINGLE_THREAD__ |
__lock_init_recursive (fp->_lock); |
#endif |
__sfp_lock_release (); |
_newlib_sfp_lock_end (); |
|
fp->_p = NULL; /* no current pointer */ |
fp->_w = 0; /* nothing to read or write */ |
192,7 → 200,6 |
|
/* make sure we clean up on exit */ |
s->__cleanup = _cleanup_r; /* conservative */ |
s->__sdidinit = 1; |
|
s->__sglue._next = NULL; |
#ifndef _REENT_SMALL |
201,6 → 208,11 |
#else |
s->__sglue._niobs = 0; |
s->__sglue._iobs = NULL; |
/* Avoid infinite recursion when calling __sfp for _GLOBAL_REENT. The |
problem is that __sfp checks for _GLOBAL_REENT->__sdidinit and calls |
__sinit if it's 0. */ |
if (s == _GLOBAL_REENT) |
s->__sdidinit = 1; |
s->_stdin = __sfp(s); |
s->_stdout = __sfp(s); |
s->_stderr = __sfp(s); |
224,6 → 236,8 |
when the underlying fd 2 is write-only. */ |
std (s->_stderr, __SRW | __SNBF, 2, s); |
|
s->__sdidinit = 1; |
|
__sinit_lock_release (); |
} |
|
235,25 → 249,25 |
_VOID |
_DEFUN_VOID(__sfp_lock_acquire) |
{ |
__lock_acquire_recursive (__sfp_lock); |
//__lock_acquire_recursive (__sfp_lock); |
} |
|
_VOID |
_DEFUN_VOID(__sfp_lock_release) |
{ |
__lock_release_recursive (__sfp_lock); |
//__lock_release_recursive (__sfp_lock); |
} |
|
_VOID |
_DEFUN_VOID(__sinit_lock_acquire) |
{ |
__lock_acquire_recursive (__sinit_lock); |
//__lock_acquire_recursive (__sinit_lock); |
} |
|
_VOID |
_DEFUN_VOID(__sinit_lock_release) |
{ |
__lock_release_recursive (__sinit_lock); |
//__lock_release_recursive (__sinit_lock); |
} |
|
/* Walkable file locking routine. */ |