source: rtems/cpukit/libcsupport/src/sync.c @ b2b143f4

4.104.114.84.9
Last change on this file since b2b143f4 was b2b143f4, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 5, 2004 at 5:58:51 PM

2004-03-05 Joel Sherrill <joel@…>

  • 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/rtems_rpc.c, librpc/src/rpc/svc.c, sapi/include/confdefs.h, score/macros/rtems/score/chain.inl, score/src/objectidtoname.c:
  • Property mode set to 100644
File size: 1.9 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-2003.
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
59   /*
60    *  The sync_wrapper() function will operate on the current thread's
61    *  reent structure so we will temporarily use that.
62    */
63   current_reent = _Thread_Executing->libc_reent;
64   _Thread_Executing->libc_reent = t->libc_reent;
65   _fwalk (t->libc_reent, sync_wrapper);
66   _Thread_Executing->libc_reent = current_reent;
67}
68
69int sync(void)
70{
71  extern struct _reent libc_global_reent;
72
73  /*
74   *  Walk the one used initially by RTEMS.
75   */
76  _fwalk(&libc_global_reent, sync_wrapper);
77
78  /*
79   *  XXX Do we walk the one used globally by newlib?
80   *  XXX Do we need the RTEMS global one?
81   */
82
83  /*
84   *  Now walk all the per-thread reentrancy structures.
85   */
86  rtems_iterate_over_all_threads(sync_per_thread);
87
88  return 0;
89}
Note: See TracBrowser for help on using the repository browser.