1 /* 2 * Copyright 2007, Ingo Weinhold, bonefish@cs.tu-berlin.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef _KERNEL_WAIT_FOR_OBJECTS_H 7 #define _KERNEL_WAIT_FOR_OBJECTS_H 8 9 #include <OS.h> 10 11 #include <lock.h> 12 13 14 struct select_sync; 15 16 17 typedef struct select_info { 18 struct select_info* next; // next in the object's list 19 struct select_sync* sync; 20 int32 events; 21 uint16 selected_events; 22 } select_info; 23 24 typedef struct select_sync { 25 int32 ref_count; 26 sem_id sem; 27 uint32 count; 28 struct select_info* set; 29 } select_sync; 30 31 #define SELECT_FLAG(type) (1L << (type - 1)) 32 33 #define SELECT_OUTPUT_ONLY_FLAGS \ 34 (B_EVENT_ERROR | B_EVENT_DISCONNECTED | B_EVENT_INVALID) 35 36 #define SELECT_TYPE_IS_OUTPUT_ONLY(type) \ 37 ((SELECT_FLAG(type) & SELECT_OUTPUT_ONLY_FLAGS) != 0) 38 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 45 extern void put_select_sync(select_sync* sync); 46 extern status_t notify_select_events(select_info* info, uint16 events); 47 extern void notify_select_events_list(select_info* list, uint16 events); 48 49 extern ssize_t _user_wait_for_objects(object_wait_info* userInfos, 50 int numInfos, uint32 flags, bigtime_t timeout); 51 52 53 #ifdef __cplusplus 54 } 55 #endif 56 57 #endif // _KERNEL_WAIT_FOR_OBJECTS_H 58