[PATCH] libcsupport: Use _fwalk_reent()

Chris Johns chrisj at rtems.org
Thu Mar 31 23:39:10 UTC 2022


OK

On 1/4/2022 2:09 am, Sebastian Huber wrote:
> Use _fwalk_reent() instead of _fwalk(), since _fwalk() was removed from Newlib.
> Include <sys/reent.h> and remove local declarations.
> ---
>  cpukit/libcsupport/src/sync.c | 29 ++++++++++-------------------
>  1 file changed, 10 insertions(+), 19 deletions(-)
> 
> diff --git a/cpukit/libcsupport/src/sync.c b/cpukit/libcsupport/src/sync.c
> index 265c6f07c9..b9d1dcdcc5 100644
> --- a/cpukit/libcsupport/src/sync.c
> +++ b/cpukit/libcsupport/src/sync.c
> @@ -18,13 +18,7 @@
>  #include "config.h"
>  #endif
>  
> -/* Since we compile with strict ANSI we need to undef it to get
> - * prototypes for extensions
> - */
> -#undef __STRICT_ANSI__
> -int fdatasync(int);        /* still not always prototyped */
> -
> -
> +#include <sys/reent.h>
>  #include <unistd.h>
>  #include <stdio.h>
>  
> @@ -32,19 +26,22 @@ int fdatasync(int);        /* still not always prototyped */
>  #include <rtems/score/thread.h>
>  #include <rtems/score/percpu.h>
>  
> -/* XXX check standards -- Linux version appears to be void */
> -void _fwalk(struct _reent *, void *);
> +/* In Newlib this function is declared in a private header file */
> +int _fwalk_reent (struct _reent *, int (*)(struct _reent *, FILE *));
>  
> -
> -static void sync_wrapper(FILE *f)
> +static int sync_wrapper(struct _reent *reent, FILE *f)
>  {
>    int fn = fileno(f);
>  
> +  (void) reent;
> +
>    /*
>     * There is no way to report errors here.  So this is a best-effort approach.
>     */
>    (void) fsync(fn);
>    (void) fdatasync(fn);
> +
> +  return 0;
>  }
>  
>  /* iterate over all FILE *'s for this thread */
> @@ -62,19 +59,13 @@ static bool sync_per_thread(Thread_Control *t, void *arg)
>       Thread_Control *executing = _Thread_Get_executing();
>       current_reent = executing->libc_reent;
>       executing->libc_reent = this_reent;
> -     _fwalk (t->libc_reent, sync_wrapper);
> +     _fwalk_reent (this_reent, sync_wrapper);
>       executing->libc_reent = current_reent;
>     }
>  
>     return false;
>  }
>  
> -/*
> - * _global_impure_ptr is not prototyped in any .h files.
> - * We have to extern it here.
> - */
> -extern struct _reent * const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
> -
>  /**
>   * This function operates by as follows:
>   *    for all threads
> @@ -88,7 +79,7 @@ void sync(void)
>    /*
>     *  Walk the one used initially by RTEMS.
>     */
> -  _fwalk(_global_impure_ptr, sync_wrapper);
> +  _fwalk_reent(_GLOBAL_REENT, sync_wrapper);
>  
>    /*
>     *  XXX Do we walk the one used globally by newlib?


More information about the devel mailing list