]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/recvmmsg.c
c214321e94bed2d3e6397a08a26e2823e913c059
1 /* Copyright (C) 2010-2021 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #include <sys/socket.h>
20 #include <socketcall.h>
23 __recvmmsg64 (int fd
, struct mmsghdr
*vmessages
, unsigned int vlen
, int flags
,
24 struct __timespec64
*timeout
)
26 #ifndef __NR_recvmmsg_time64
27 # define __NR_recvmmsg_time64 __NR_recvmmsg
29 int r
= SYSCALL_CANCEL (recvmmsg_time64
, fd
, vmessages
, vlen
, flags
,
31 #ifndef __ASSUME_TIME64_SYSCALLS
32 if (r
>= 0 || errno
!= ENOSYS
)
35 struct timespec ts32
, *pts32
= NULL
;
38 if (! in_time_t_range (timeout
->tv_sec
))
43 ts32
= valid_timespec64_to_timespec (*timeout
);
47 socklen_t csize
[IOV_MAX
];
50 for (int i
= 0; i
< vlen
; i
++)
51 csize
[i
] = vmessages
[i
].msg_hdr
.msg_controllen
;
53 # ifdef __ASSUME_RECVMMSG_SYSCALL
54 r
= SYSCALL_CANCEL (recvmmsg
, fd
, vmessages
, vlen
, flags
, pts32
);
56 r
= SOCKETCALL_CANCEL (recvmmsg
, fd
, vmessages
, vlen
, flags
, pts32
);
61 *timeout
= valid_timespec_to_timespec64 (ts32
);
63 for (int i
=0; i
< r
; i
++)
64 __convert_scm_timestamps (&vmessages
[i
].msg_hdr
, csize
[i
]);
66 #endif /* __ASSUME_TIME64_SYSCALLS */
70 libc_hidden_def (__recvmmsg64
)
73 __recvmmsg (int fd
, struct mmsghdr
*vmessages
, unsigned int vlen
, int flags
,
74 struct timespec
*timeout
)
76 struct __timespec64 ts64
, *pts64
= NULL
;
79 ts64
= valid_timespec_to_timespec64 (*timeout
);
82 int r
= __recvmmsg64 (fd
, vmessages
, vlen
, flags
, pts64
);
83 if (r
>= 0 && timeout
!= NULL
)
84 /* The remanining timeout will be always less the input TIMEOUT. */
85 *timeout
= valid_timespec64_to_timespec (ts64
);
89 weak_alias (__recvmmsg
, recvmmsg
)