Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / muimaster / classes / semaphore.c
blob79bbd2c1a0cd9caa5e999e1f003785de95bf66e4
1 /*
2 Copyright © 2002-2006, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/semaphores.h>
7 #include <clib/alib_protos.h>
8 #include <proto/exec.h>
9 #include <proto/intuition.h>
10 #include <proto/muimaster.h>
12 #include "mui.h"
13 #include "muimaster_intern.h"
14 #include "support.h"
16 extern struct Library *MUIMasterBase;
18 struct MUI_SemaphoreData
20 struct SignalSemaphore sem;
23 /**************************************************************************
24 OM_NEW
25 **************************************************************************/
26 IPTR Semaphore__OM_NEW(struct IClass *cl, Object *obj, struct opSet *msg)
28 struct MUI_SemaphoreData *data;
30 obj = (Object *)DoSuperMethodA(cl, obj, (Msg)msg);
31 if (obj)
33 data = INST_DATA(cl, obj);
35 InitSemaphore(&data->sem);
38 return (IPTR)obj;
41 /**************************************************************************
42 MUIM_Semaphore_Attempt
43 **************************************************************************/
44 IPTR Semaphore__MUIM_Attempt(struct IClass *cl, Object *obj, struct MUIP_Semaphore_Attempt *msg)
46 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
48 return (IPTR)AttemptSemaphore(&data->sem);
51 /**************************************************************************
52 MUIM_Semaphore_AttemptShared
53 **************************************************************************/
54 IPTR Semaphore__MUIM_AttemptShared(struct IClass *cl, Object *obj, struct MUIP_Semaphore_AttemptShared *msg)
56 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
58 return (IPTR)AttemptSemaphoreShared(&data->sem);
61 /**************************************************************************
62 MUIM_Semaphore_Obtain
63 **************************************************************************/
64 IPTR Semaphore__MUIM_Obtain(struct IClass *cl, Object *obj, struct MUIP_Semaphore_Obtain *msg)
66 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
68 ObtainSemaphore(&data->sem);
70 return 0;
73 /**************************************************************************
74 MUIM_Semaphore_ObtainShared
75 **************************************************************************/
76 IPTR Semaphore__MUIM_ObtainShared(struct IClass *cl, Object *obj, struct MUIP_Semaphore_ObtainShared *msg)
78 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
80 ObtainSemaphoreShared(&data->sem);
82 return 0;
85 /**************************************************************************
86 MUIM_Semaphore_Release
87 **************************************************************************/
88 IPTR Semaphore__MUIM_Release(struct IClass *cl, Object *obj, struct MUIP_Semaphore_Release *msg)
90 struct MUI_SemaphoreData *data = INST_DATA(cl, obj);
92 ReleaseSemaphore(&data->sem);
94 return 0;
98 BOOPSI_DISPATCHER(IPTR, Semaphore_Dispatcher, cl, obj, msg)
100 switch (msg->MethodID)
102 case OM_NEW: return Semaphore__OM_NEW(cl, obj, (struct opSet *)msg);
103 case MUIM_Semaphore_Attempt: return Semaphore__MUIM_Attempt(cl, obj, (struct MUIP_Semaphore_Attempt *)msg);
104 case MUIM_Semaphore_AttemptShared: return Semaphore__MUIM_AttemptShared(cl, obj, (struct MUIP_Semaphore_AttemptShared *)msg);
105 case MUIM_Semaphore_Obtain: return Semaphore__MUIM_Obtain(cl, obj, (struct MUIP_Semaphore_Obtain *)msg);
106 case MUIM_Semaphore_ObtainShared: return Semaphore__MUIM_ObtainShared(cl, obj, (struct MUIP_Semaphore_ObtainShared *)msg);
107 case MUIM_Semaphore_Release: return Semaphore__MUIM_Release(cl, obj, (struct MUIP_Semaphore_Release *)msg);
110 return DoSuperMethodA(cl, obj, msg);
112 BOOPSI_DISPATCHER_END
115 * Class descriptor.
117 const struct __MUIBuiltinClass _MUI_Semaphore_desc = {
118 MUIC_Semaphore,
119 ROOTCLASS,
120 sizeof(struct MUI_SemaphoreData),
121 (void*)Semaphore_Dispatcher