Does FreeBSD have sendmmsg or recvmmsg system calls?

Bruce Evans brde at
Wed Jan 20 10:30:56 UTC 2016

On Wed, 20 Jan 2016, Konstantin Belousov wrote:

> On Tue, Jan 19, 2016 at 01:58:27PM +0200, Boris Astardzhiev wrote:
>> +int
>> +recvmmsg(int s, struct mmsghdr *msgvec, unsigned int vlen, int flags)
>> +{
>> +	int i, ret, rcvd;
> Shouldn't i and rcvd be unsigned as well ?  Shouldn't return value
> also be unsigned ?

None of the above.  Plain recvmsg() returns ssize_t and its len arg has
type size_t.  That is excessively typedefed and excessively large with
64-bit ssize_t, but it is silly for the multiple-message variant to use
smaller types.

Otherwise, all the integer types should be int.

recvmsg() is still declared in syscalls.master as returning int, but
it seems to be correct internallly.  It is like read() and returns
ssize_t in td_retval[0].  No wrong prototypes seem to be generated from
the wrong retun types in syscalls.master.

>> +	rcvd = 0;
>> +	for (i = 0; i < vlen; i++) {
>> +		errno = 0;
>> +		ret = __sys_recvmsg(s, &msgvec[i].msg_hdr, flags);
>> +		if (ret < 0 || errno != 0) {
> I do not see why do you need to clear errno before, and then do this test.
> Just check ret == -1, in which case errno was set from the immediate syscall.

The errno method (and not checking ret at all) is best if for syscalls that
return -1 for a non-error.  It is not needed here.


More information about the freebsd-threads mailing list