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

4.104.114.84.95
Last change on this file since bed55af was bed55af, checked in by Joel Sherrill <joel.sherrill@…>, on 08/14/03 at 20:00:46

2003-08-14 Joel Sherrill <joel@…>

  • Makefile.am: Add fileio to list of interactive tests.
  • src/sync.c: New file.
  • Property mode set to 100644
File size: 1.5 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.OARcorp.com/rtems/license.html.
16 *
17 *  $Id$
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24/* this is needed to get the fileno() prototype */
25#if defined(__STRICT_ANSI__)
26#undef __STRICT_ANSI__
27#endif
28#include <unistd.h>
29#include <stdio.h>
30
31#include <rtems.h>
32/*
33#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
34
35#include <rtems/libio_.h>
36#include <rtems/seterr.h>
37*/
38
39/* XXX check standards -- Linux version appears to be void */
40void _fwalk(struct _reent *, void *);
41
42static void sync_wrapper(FILE *f)
43{
44  int fn = fileno(f);
45
46  fsync(fn);
47  fdatasync(fn);
48}
49
50/* iterate over all FILE *'s for this thread */
51static void sync_per_thread(Thread_Control *t)
52{
53   struct reent *current_reent;
54
55   /*
56    *  The sync_wrapper() function will operate on the current thread's
57    *  reent structure so we will temporarily use that.
58    */
59   current_reent = _Thread_Executing->libc_reent;
60   _Thread_Executing->libc_reent = t->libc_reent;
61   _fwalk (t->libc_reent, sync_wrapper);
62   _Thread_Executing->libc_reent = current_reent;
63}
64
65int sync(void)
66{
67  rtems_iterate_over_all_threads(sync_per_thread);
68  return 0;
69}
Note: See TracBrowser for help on using the repository browser.