diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-08-14 20:00:46 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2003-08-14 20:00:46 +0000 |
commit | bed55af1ee98b386de9060b6b65e7aa7c9bf1428 (patch) | |
tree | bc84edbca4fedebe56882021ef767e2f7b8e7ca6 /cpukit/libcsupport/src/sync.c | |
parent | 2003-08-14 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-bed55af1ee98b386de9060b6b65e7aa7c9bf1428.tar.bz2 |
2003-08-14 Joel Sherrill <joel@OARcorp.com>
* Makefile.am: Add fileio to list of interactive tests.
* src/sync.c: New file.
Diffstat (limited to '')
-rw-r--r-- | cpukit/libcsupport/src/sync.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/cpukit/libcsupport/src/sync.c b/cpukit/libcsupport/src/sync.c new file mode 100644 index 0000000000..f91dfd52e7 --- /dev/null +++ b/cpukit/libcsupport/src/sync.c @@ -0,0 +1,69 @@ +/* + * sync() - XXX ??? where is this defined + * + * This function operates by as follows: + * for all threads + * for all FILE * + * fsync() + * fdatasync() + * + * COPYRIGHT (c) 1989-2003. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +/* this is needed to get the fileno() prototype */ +#if defined(__STRICT_ANSI__) +#undef __STRICT_ANSI__ +#endif +#include <unistd.h> +#include <stdio.h> + +#include <rtems.h> +/* +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ + +#include <rtems/libio_.h> +#include <rtems/seterr.h> +*/ + +/* XXX check standards -- Linux version appears to be void */ +void _fwalk(struct _reent *, void *); + +static void sync_wrapper(FILE *f) +{ + int fn = fileno(f); + + fsync(fn); + fdatasync(fn); +} + +/* iterate over all FILE *'s for this thread */ +static void sync_per_thread(Thread_Control *t) +{ + struct reent *current_reent; + + /* + * The sync_wrapper() function will operate on the current thread's + * reent structure so we will temporarily use that. + */ + current_reent = _Thread_Executing->libc_reent; + _Thread_Executing->libc_reent = t->libc_reent; + _fwalk (t->libc_reent, sync_wrapper); + _Thread_Executing->libc_reent = current_reent; +} + +int sync(void) +{ + rtems_iterate_over_all_threads(sync_per_thread); + return 0; +} |