Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / thread / createmutex.c
blobf8c82f6fb0fb61a22ca3d6eb43812f0fbccfeb2c
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/semaphores.h>
13 #include <exec/memory.h>
14 #include <proto/exec.h>
16 /*****************************************************************************
18 NAME */
19 AROS_LH0(void *, CreateMutex,
21 /* SYNOPSIS */
23 /* LOCATION */
24 struct ThreadBase *, ThreadBase, 10, Thread)
26 /* FUNCTION
27 Creates a mutual exclusion device (aka lock).
29 INPUTS
30 None.
32 RESULT
33 The newly created mutex, or NULL if a mutex couldn't be created.
35 NOTES
37 EXAMPLE
38 Mutex mutex = CreateMutex();
40 BUGS
42 SEE ALSO
43 DestroyMutex(), LockMutex(), TryLockMutex(), UnlockMutex()
45 INTERNALS
46 Mutexes are implemented as thin wrappers around Exec semaphores.
48 *****************************************************************************/
50 AROS_LIBFUNC_INIT
52 struct SignalSemaphore *sem;
54 if ((sem = (struct SignalSemaphore *) AllocMem(sizeof(struct SignalSemaphore), MEMF_PUBLIC)) == NULL)
55 return NULL;
57 InitSemaphore(sem);
59 return (void *) sem;
61 AROS_LIBFUNC_EXIT
62 } /* CreateMutex */