blob: 1f6cad6406a78121fdc09382cecaf0aee157b3c2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/*
* 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
/* this is needed to get the fileno() prototype */
#if defined(__STRICT_ANSI__)
#undef __STRICT_ANSI__
#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;
}
|