source: rtems/cpukit/libcsupport/src/sync.c @ 98b785e

4.115
Last change on this file since 98b785e was d40da79b, checked in by Joel Sherrill <joel.sherrill@…>, on 09/17/08 at 16:12:04

2008-09-17 Miao Yan <yanmiaobest@…>

  • 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.
  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  sync() - XXX ??? where is this defined
3 *
4 *  This function operates by as follows:
5 *    for all threads
6 *      for all FILE *
7 *         fsync()
8 *         fdatasync()
9 *
10 *  COPYRIGHT (c) 1989-2008.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24/* Since we compile with strict ANSI we need to undef it to get
25 * prototypes for extensions
26 */
27#undef __STRICT_ANSI__
28int fdatasync(int);        /* still not always prototyped */
29
30
31#include <unistd.h>
32#include <stdio.h>
33
34#include <rtems.h>
35/*
36#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
37
38#include <rtems/libio_.h>
39#include <rtems/seterr.h>
40*/
41
42/* XXX check standards -- Linux version appears to be void */
43void _fwalk(struct _reent *, void *);
44
45
46static void sync_wrapper(FILE *f)
47{
48  int fn = fileno(f);
49
50  fsync(fn);
51  fdatasync(fn);
52}
53
54/* iterate over all FILE *'s for this thread */
55static void sync_per_thread(Thread_Control *t)
56{
57   struct _reent *current_reent;
58   struct _reent *this_reent;
59
60   /*
61    *  The sync_wrapper() function will operate on the current thread's
62    *  reent structure so we will temporarily use that.
63    */
64   this_reent = t->libc_reent;
65   if ( this_reent ) {
66     current_reent = _Thread_Executing->libc_reent;
67     _Thread_Executing->libc_reent = this_reent;
68     _fwalk (t->libc_reent, sync_wrapper);
69     _Thread_Executing->libc_reent = current_reent;
70   }
71}
72
73/*
74 * _global_impure_ptr is not prototyped in any .h files.
75 * We have to extern it here.
76 */
77extern struct _reent * const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
78
79void sync(void)
80{
81
82  /*
83   *  Walk the one used initially by RTEMS.
84   */
85  _fwalk(_global_impure_ptr, sync_wrapper);
86
87  /*
88   *  XXX Do we walk the one used globally by newlib?
89   *  XXX Do we need the RTEMS global one?
90   */
91
92  /*
93   *  Now walk all the per-thread reentrancy structures.
94   */
95  rtems_iterate_over_all_threads(sync_per_thread);
96}
Note: See TracBrowser for help on using the repository browser.