* Copyright 2015, Hamish Morrison, hamishm53@gmail.com.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_SELECT_OPS_H
#define _KERNEL_SELECT_OPS_H
struct select_ops {
status_t (*select)(int32 object, struct select_info* info, bool kernel);
status_t (*deselect)(int32 object, struct select_info* info, bool kernel);
};
static const select_ops kSelectOps[] = {
{
select_fd,
deselect_fd
},
{
select_sem,
deselect_sem
},
{
select_port,
deselect_port
},
{
select_thread,
deselect_thread
}
};
static inline status_t
select_object(uint32 type, int32 object, struct select_info* sync, bool kernel)
{
if (type >= B_COUNT_OF(kSelectOps))
return B_BAD_VALUE;
return kSelectOps[type].select(object, sync, kernel);
}
static inline status_t
deselect_object(uint32 type, int32 object, struct select_info* sync, bool kernel)
{
if (type >= B_COUNT_OF(kSelectOps))
return B_BAD_VALUE;
return kSelectOps[type].deselect(object, sync, kernel);
}
#endif