tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: EV_SET() better C++ compat with alternative implementations
On Wed, Aug 14, 2019 at 06:06:18 +0300, Valery Ushakov wrote:
> static inline void
> EV_SET_(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
> uint32_t _flags, uint32_t _fflags, int64_t _data,
> uintptr_t _udata)
> {
> _kevp->ident = _ident;
> _kevp->filter = _filter;
> _kevp->flags = _flags;
> _kevp->fflags = _fflags;
> _kevp->data = _data;
> _kevp->udata = _udata;
> }
Oops, s/uintptr_t/intptr_t/
And this is actually already defined for C, so we need to just provide
the templates.
template <typename _U>
static inline void __always_inline
EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
uint32_t _flags, uint32_t _fflags, int64_t _data,
_U _udata)
{
EV_SET_(_kevp, _ident, _filter, _flags, _fflags, _data,
static_cast<intptr_t>(_udata));
}
/* specialize for std::nullptr_t */
template <>
inline void __always_inline
EV_SET(struct kevent *_kevp, uintptr_t _ident, uint32_t _filter,
uint32_t _flags, uint32_t _fflags, int64_t _data,
decltype(nullptr) _udata __unused)
{
EV_SET_(_kevp, _ident, _filter, _flags, _fflags, _data, 0);
}
-uwe
Home |
Main Index |
Thread Index |
Old Index