mailing list of musl libc
 help / color / mirror / code / Atom feed
fc197861fe960e57e83c2484f4605917ffa8a723 blob 1149 bytes (raw)

 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
 
#include "stdio_impl.h"

static int __fflush_unlocked(FILE *f)
{
	int r;

	if (f) {
		/* If writing, flush output */
		if (f->wpos > f->wbase) {
			f->write(f, 0, 0);
			if (!f->wpos) return EOF;
		}

		/* If reading, sync position, per POSIX */
		if (f->rpos < f->rend) f->seek(f, f->rpos-f->rend, SEEK_CUR);

		/* Clear read and write modes */
		f->wpos = f->wbase = f->wend = 0;
		f->rpos = f->rend = 0;

		return 0;
	}

	/* fflush_unlocked(NULL) is supported by glibc, mimic that */

	r = __stdout_used ? __fflush_unlocked(__stdout_used) : 0;

	for (f=*__ofl_lock(); f; f=f->next) {
		if (f->wpos > f->wbase) r |= __fflush_unlocked(f);
	}
	__ofl_unlock();

	return r;
}

/* stdout.c will override this if linked */
static FILE *volatile dummy = 0;
weak_alias(dummy, __stdout_used);

int fflush(FILE *f)
{
	int r;

	if (f) {
		FLOCK(f);
		r = __fflush_unlocked(f);
		FUNLOCK(f);
		return r;
	}

	r = __stdout_used ? fflush(__stdout_used) : 0;

	for (f=*__ofl_lock(); f; f=f->next) {
		FLOCK(f);
		if (f->wpos > f->wbase) r |= __fflush_unlocked(f);
		FUNLOCK(f);
	}
	__ofl_unlock();
	
	return r;
}

weak_alias(__fflush_unlocked, fflush_unlocked);
debug log:

solving 06d7a56 ...
found 06d7a56 in https://inbox.vuxu.org/musl/20160918194455.21981-1-vda.linux@googlemail.com/
found 3f462c8 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 3f462c80e8d12f6efbecd144a144d430736ec6eb	src/stdio/fflush.c

applying [1/1] https://inbox.vuxu.org/musl/20160918194455.21981-1-vda.linux@googlemail.com/
diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c
index 3f462c8..06d7a56 100644

Checking patch src/stdio/fflush.c...
Applied patch src/stdio/fflush.c cleanly.

index at:
100644 fc197861fe960e57e83c2484f4605917ffa8a723	src/stdio/fflush.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).