This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Dec 14 09:57, Sebastian Huber wrote:
> Provide a _REENT_INIT_PTR_ZEROED() macro to initialize an already
> zero-initialized struct _reent.
Why? This might be nice to have, but since this patch is missing
a use-case, we just don't know...
>
> * libc/include/sys/reent.h (_REENT_INIT_PTR_ZEROED): New.
> (_REENT_INIT_PTR): Define only once and use
> _REENT_INIT_PTR_ZEROED().
> ---
> newlib/libc/include/sys/reent.h | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h
> index ce5b3ed..5481ca2 100644
> --- a/newlib/libc/include/sys/reent.h
> +++ b/newlib/libc/include/sys/reent.h
> @@ -446,9 +446,8 @@ extern const struct __sFILE_fake __sf_fake_stderr;
> _NULL \
> }
>
> -#define _REENT_INIT_PTR(var) \
> - { memset((var), 0, sizeof(*(var))); \
> - (var)->_stdin = (__FILE *)&__sf_fake_stdin; \
> +#define _REENT_INIT_PTR_ZEROED(var) \
> + { (var)->_stdin = (__FILE *)&__sf_fake_stdin; \
> (var)->_stdout = (__FILE *)&__sf_fake_stdout; \
> (var)->_stderr = (__FILE *)&__sf_fake_stderr; \
> (var)->_current_locale = "C"; \
> @@ -694,9 +693,8 @@ struct _reent
> {_NULL, 0, _NULL} \
> }
>
> -#define _REENT_INIT_PTR(var) \
> - { memset((var), 0, sizeof(*(var))); \
> - (var)->_stdin = &(var)->__sf[0]; \
> +#define _REENT_INIT_PTR_ZEROED(var) \
> + { (var)->_stdin = &(var)->__sf[0]; \
> (var)->_stdout = &(var)->__sf[1]; \
> (var)->_stderr = &(var)->__sf[2]; \
> (var)->_current_locale = "C"; \
> @@ -745,6 +743,11 @@ struct _reent
>
> #endif /* !_REENT_SMALL */
>
> +#define _REENT_INIT_PTR(var) \
> + { memset((var), 0, sizeof(*(var))); \
> + _REENT_INIT_PTR_ZEROED(var); \
> + }
> +
> /* This value is used in stdlib/misc.c. reent/reent.c has to know it
> as well to make sure the freelist is correctly free'd. Therefore
> we define it here, rather than in stdlib/misc.c, as before. */
> --
> 1.8.4.5
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
Attachment:
pgpDuy8h7Lw0N.pgp
Description: PGP signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |