From a340ca191a8fc33485afda123a9fba52f1f529ae Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 31 Mar 2022 08:21:58 +0200 Subject: libcsupport: Use _fwalk_reent() Use _fwalk_reent() instead of _fwalk(), since _fwalk() was removed from Newlib. Include and remove local declarations. --- cpukit/libcsupport/src/sync.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'cpukit/libcsupport/src') 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 #include #include @@ -32,19 +26,22 @@ int fdatasync(int); /* still not always prototyped */ #include #include -/* 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? -- cgit v1.2.3