0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd::util: Update syscall() comments; minor cleanup.

This commit is contained in:
Jason Volk 2018-01-11 03:21:19 -08:00
parent c698101d6d
commit b0acc95559

View file

@ -32,10 +32,11 @@ namespace ircd::util
template<long number, class... args> long syscall_nointr(args&&... a);
}
//
// Error-checking closure for POSIX system calls. Note the usage is
// syscall(read, foo, bar, baz) not a macro like syscall(read(foo, bar, baz));
//
/// Posix system call template to check for returned error value and throw the
/// approps errno in the proper std::system_error exception. Note the usage
/// here, the libc wrapper function is the first argument i.e:
/// syscall(::foo, bar, baz) not syscall(::foo(bar, baz));
///
template<class function,
class... args>
long
@ -56,10 +57,12 @@ ircd::util::syscall(function&& f,
return ret;
}
//
// Error-checking closure for POSIX system calls. Note the usage is
// syscall(read, foo, bar, baz) not a macro like syscall(read(foo, bar, baz));
//
/// Posix system call template to check for returned error value and throw the
/// approps errno in the proper std::system_error exception. This template
/// requires a system call number in the parameters. The arguments are only
/// the actual arguments passed to the syscall because the number is given
/// in the template.
///
template<long number,
class... args>
long
@ -79,10 +82,13 @@ ircd::util::syscall(args&&... a)
return ret;
}
//
// Error-checking closure for POSIX system calls. Note the usage is
// syscall(read, foo, bar, baz) not a macro like syscall(read(foo, bar, baz));
//
/// Uninterruptible posix system call template to check for returned error
/// value and throw the approps errno in the proper std::system_error
/// exception. Note the usage here, the libc wrapper function is the first
/// argument i.e: syscall(::foo, bar, baz) not syscall(::foo(bar, baz));
///
/// The syscall is restarted until it no longer returns with EINTR.
///
template<class function,
class... args>
long
@ -96,15 +102,22 @@ ircd::util::syscall_nointr(function&& f,
while(unlikely(ret == -1 && errno == EINTR));
if(unlikely(ret == -1))
throw std::system_error(errno, std::system_category());
throw std::system_error
{
errno, std::system_category()
};
return ret;
}
//
// Error-checking closure for POSIX system calls. Note the usage is
// syscall(read, foo, bar, baz) not a macro like syscall(read(foo, bar, baz));
//
/// Uninterruptible posix system call template to check for returned error
/// value and throw the approps errno in the proper std::system_error
/// exception. This template requires a system call number in the parameters.
/// The arguments are only the actual arguments passed to the syscall because
/// the number is given in the template.
///
/// The syscall is restarted until it no longer returns with EINTR.
///
template<long number,
class... args>
long
@ -117,7 +130,10 @@ ircd::util::syscall_nointr(args&&... a)
while(unlikely(ret == -1 && errno == EINTR));
if(unlikely(ret == -1))
throw std::system_error(errno, std::system_category());
throw std::system_error
{
errno, std::system_category()
};
return ret;
}