mailing list of musl libc
 help / color / mirror / code / Atom feed
2587268bcad2fcfa71a5cb2762e1e8a53e054f39 blob 693 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
 
#include "stdio_impl.h"
#include <string.h>

#define MIN(a,b) ((a)<(b) ? (a) : (b))

size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f)
{
	unsigned char *dest = destv;
	size_t len = size*nmemb, l = len, k;
	if (!size) nmemb = 0;

	FLOCK(f);

	f->mode |= f->mode-1;

	if (f->rpos != f->rend) {
		/* First exhaust the buffer. */
		k = MIN(f->rend - f->rpos, l);
		memcpy(dest, f->rpos, k);
		f->rpos += k;
		dest += k;
		l -= k;
	}

	/* Read the remainder directly */
	for (; l; l-=k, dest+=k) {
		k = __toread(f) ? 0 : f->read(f, dest, l);
		if (!k) {
			FUNLOCK(f);
			return (len-l)/size;
		}
	}

	FUNLOCK(f);
	return nmemb;
}

weak_alias(fread, fread_unlocked);
debug log:

solving 2587268b ...
found 2587268b in https://inbox.vuxu.org/musl/20220503155655.11222-2-jmaselbas@kalray.eu/ ||
	https://inbox.vuxu.org/musl/20220504122426.11529-2-jmaselbas@kalray.eu/
found a2116da6 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 a2116da61370bd829c634353ad6f6fa6732d0d8b	src/stdio/fread.c

applying [1/2] https://inbox.vuxu.org/musl/20220503155655.11222-2-jmaselbas@kalray.eu/
diff --git a/src/stdio/fread.c b/src/stdio/fread.c
index a2116da6..2587268b 100644

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

skipping https://inbox.vuxu.org/musl/20220504122426.11529-2-jmaselbas@kalray.eu/ for 2587268b
index at:
100644 2587268bcad2fcfa71a5cb2762e1e8a53e054f39	src/stdio/fread.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).