Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / thread / createcondition.c
blob82aa1db2215d8af1d0cf81e3d2790e4e51c027b7
1 /*
2 * thread.library - threading and synchronisation primitives
4 * Copyright © 2007 Robert Norris
6 * This program is free software; you can redistribute it and/or modify it
7 * under the same terms as AROS itself.
8 */
10 #include "thread_intern.h"
12 #include <exec/memory.h>
13 #include <exec/lists.h>
14 #include <proto/exec.h>
16 /*****************************************************************************
18 NAME */
19 AROS_LH0(void *, CreateCondition,
21 /* SYNOPSIS */
23 /* LOCATION */
24 struct ThreadBase *, ThreadBase, 15, Thread)
26 /* FUNCTION
27 Creates a condition variable.
29 INPUTS
30 None.
32 RESULT
33 The newly created condition, or NULL if one couldn't be created.
35 NOTES
36 Condition cond = CreateCondition();
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 DestroyCondition(), WaitCondition(), SignalCondition(),
44 BroadcastCondition()
46 INTERNALS
48 *****************************************************************************/
50 AROS_LIBFUNC_INIT
52 struct _Condition *c;
54 /* allocate */
55 if ((c = AllocMem(sizeof(struct _Condition), MEMF_PUBLIC)) == NULL)
56 return NULL;
58 /* initialise */
59 InitSemaphore(&c->lock);
60 NEWLIST(&c->waiters);
61 c->count = 0;
63 return (void *) c;
65 AROS_LIBFUNC_EXIT
66 } /* CreateCondition */