mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-24 22:21:16 +08:00
* libblock/src/bdbuf.c, libblock/src/ramdisk.c, libcsupport/src/newlibc.c, libcsupport/src/sync.c, libmisc/cpuuse/cpuuse.c, libmisc/monitor/mon-symbols.c, libmisc/shell/cmds.c, libmisc/shell/shell.c, libnetworking/kern/kern_sysctl.c, libnetworking/lib/ftpfs.c, libnetworking/lib/tftpDriver.c, libnetworking/libc/gethostbydns.c, libnetworking/libc/gethostbyht.c, libnetworking/libc/gethostnamadr.c, libnetworking/libc/getnetbyht.c, libnetworking/libc/getnetnamadr.c, libnetworking/libc/inet_addr.c, libnetworking/libc/linkaddr.c, libnetworking/libc/map_v4v6.c, libnetworking/libc/ns_print.c, libnetworking/libc/ns_ttl.c, libnetworking/libc/nsap_addr.c, libnetworking/libc/rcmd.c, libnetworking/libc/res_debug.c, libnetworking/libc/res_mkupdate.c, libnetworking/libc/res_query.c, libnetworking/libc/res_send.c, libnetworking/libc/res_update.c, libnetworking/net/radix.c, libnetworking/rtems/mkrootfs.c, librpc/src/rpc/clnt_perror.c, librpc/src/rpc/svc.c, score/macros/rtems/score/chain.inl, score/src/objectidtoname.c: Too much was accidentally committed -- revert.
66 lines
1.4 KiB
C
66 lines
1.4 KiB
C
/*
|
|
* 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.rtems.com/license/LICENSE.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#if HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#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;
|
|
}
|