mailing list of musl libc
 help / color / mirror / code / Atom feed
ea6038544e7b9c385beb7aec7a33ff36e141cfcb blob 1413 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
 
#define _GNU_SOURCE
#include <sys/socket.h>
#include <limits.h>
#include <errno.h>
#include <time.h>
#include "syscall.h"

#define IS32BIT(x) !((x)+0x80000000ULL>>32)
#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))

hidden void __convert_scm_timestamps(struct msghdr *, socklen_t);

int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout)
{
#if LONG_MAX > INT_MAX
	struct mmsghdr *mh = msgvec;
	unsigned int i;
	for (i = vlen; i; i--, mh++)
		mh->msg_hdr.__pad1 = mh->msg_hdr.__pad2 = 0;
#endif
#ifdef SYS_recvmmsg_time64
	static int use_recvmmsg_time64 = 1;
	time_t s = timeout ? timeout->tv_sec : 0;
	long ns = timeout ? timeout->tv_nsec : 0;
	int r;
	if (use_recvmmsg_time64) {
		r = __syscall_cp(SYS_recvmmsg_time64, fd, msgvec, vlen, flags,
				timeout ? ((long long[]){s, ns}) : 0);
		if (SYS_recvmmsg == SYS_recvmmsg_time64 || r!=-ENOSYS)
			return __syscall_ret(r);
		else use_recvmmsg_time64 = 0;
	}
	if (vlen > IOV_MAX) vlen = IOV_MAX;
	socklen_t csize[vlen];
	for (int i=0; i<vlen; i++) csize[i] = msgvec[i].msg_hdr.msg_controllen;
	r = __syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags,
		timeout ? ((long[]){CLAMP(s), ns}) : 0);
	for (int i=0; i<r; i++)
		__convert_scm_timestamps(&msgvec[i].msg_hdr, csize[i]);
	return __syscall_ret(r);
#else
	return syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags, timeout);
#endif
}
debug log:

solving ea603854 ...
found ea603854 in https://inbox.vuxu.org/musl/CAHHiRUTn__COy59J78MMGSyU52Fyn7HBJdzrM6VvcuFq5Rj6HQ@mail.gmail.com/
found 2978e2f6 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 2978e2f64f34ed07a1a7c65bfd910bf72f63b668	src/network/recvmmsg.c

applying [1/1] https://inbox.vuxu.org/musl/CAHHiRUTn__COy59J78MMGSyU52Fyn7HBJdzrM6VvcuFq5Rj6HQ@mail.gmail.com/
diff --git a/src/network/recvmmsg.c b/src/network/recvmmsg.c
index 2978e2f6..ea603854 100644

Checking patch src/network/recvmmsg.c...
Applied patch src/network/recvmmsg.c cleanly.

index at:
100644 ea6038544e7b9c385beb7aec7a33ff36e141cfcb	src/network/recvmmsg.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).