mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-28 02:08:41 +08:00
* Makefile.am, preinstall.am, libcsupport/Makefile.am, libcsupport/include/rtems/libcsupport.h, libcsupport/include/rtems/libio.h, libcsupport/src/base_fs.c, libcsupport/src/libio_init.c, libcsupport/src/newlibc_exit.c, libcsupport/src/newlibc_init.c, libcsupport/src/sync.c, libfs/Makefile.am, libfs/src/imfs/deviceio.c, sapi/include/confdefs.h: Merge GSOC project code to add simple device only filesystem (devfs), optionally completely drop out filesystem, and to clean up disabling newlib reentrancy support. This dropped 17K from the minimum.exe for sparc/sis and arm/rtl22xx_t now has a 15K code space. * libcsupport/src/__usrenv.c, libcsupport/src/newlibc_reent.c, libfs/src/devfs/devclose.c, libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_eval.c, libfs/src/devfs/devfs_init.c, libfs/src/devfs/devfs_mknod.c, libfs/src/devfs/devfs_node_type.c, libfs/src/devfs/devfs_show.c, libfs/src/devfs/devioctl.c, libfs/src/devfs/devopen.c, libfs/src/devfs/devread.c, libfs/src/devfs/devstat.c, libfs/src/devfs/devwrite.c, libfs/src/imfs/deviceerrno.c: New files. * libcsupport/src/newlibc.c: Removed.
97 lines
2.1 KiB
C
97 lines
2.1 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-2008.
|
|
* 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
|
|
|
|
/* 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 <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;
|
|
struct _reent *this_reent;
|
|
|
|
/*
|
|
* The sync_wrapper() function will operate on the current thread's
|
|
* reent structure so we will temporarily use that.
|
|
*/
|
|
this_reent = t->libc_reent;
|
|
if ( this_reent ) {
|
|
current_reent = _Thread_Executing->libc_reent;
|
|
_Thread_Executing->libc_reent = this_reent;
|
|
_fwalk (t->libc_reent, sync_wrapper);
|
|
_Thread_Executing->libc_reent = current_reent;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* _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__;
|
|
|
|
void sync(void)
|
|
{
|
|
|
|
/*
|
|
* Walk the one used initially by RTEMS.
|
|
*/
|
|
_fwalk(_global_impure_ptr, sync_wrapper);
|
|
|
|
/*
|
|
* XXX Do we walk the one used globally by newlib?
|
|
* XXX Do we need the RTEMS global one?
|
|
*/
|
|
|
|
/*
|
|
* Now walk all the per-thread reentrancy structures.
|
|
*/
|
|
rtems_iterate_over_all_threads(sync_per_thread);
|
|
}
|