forwarding a patch that uses the fetch macros to pull in acpica and build it (NicJA).
[AROS.git] / compiler / pthread / pthread_cond_broadcast.c
blob187b659fc193d95fb5c75c7593ccf6c6223f89f5
1 /*
2 Copyright (C) 2014 Szilard Biro
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
21 #include "pthread_intern.h"
22 #include "debug.h"
24 int _pthread_cond_broadcast(pthread_cond_t *cond, BOOL onlyfirst)
26 CondWaiter *waiter;
28 DB2(bug("%s(%p, %d)\n", __FUNCTION__, cond, onlyfirst));
30 if (cond == NULL)
31 return EINVAL;
33 // initialize static conditions
34 if (SemaphoreIsInvalid(&cond->semaphore))
35 pthread_cond_init(cond, NULL);
37 // signal the waiting threads
38 ObtainSemaphore(&cond->semaphore);
39 ForeachNode(&cond->waiters, waiter)
41 Signal(waiter->task, waiter->sigmask);
42 if (onlyfirst) break;
44 ReleaseSemaphore(&cond->semaphore);
46 return 0;
49 int pthread_cond_broadcast(pthread_cond_t *cond)
51 D(bug("%s(%p)\n", __FUNCTION__, cond));
53 return _pthread_cond_broadcast(cond, FALSE);