1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | /*============================================================================= |
29 | VideoCore OS Abstraction Layer - public header file |
30 | =============================================================================*/ |
31 | |
32 | #ifndef VCOS_ATOMIC_FLAGS_H |
33 | #define VCOS_ATOMIC_FLAGS_H |
34 | |
35 | #ifdef __cplusplus |
36 | extern "C" { |
37 | #endif |
38 | |
39 | #include "interface/vcos/vcos_types.h" |
40 | #include "vcos.h" |
41 | |
42 | /** |
43 | * \file vcos_atomic_flags.h |
44 | * |
45 | * Defines atomic flags API. |
46 | * |
47 | * 32 flags. Atomic "or" and "get and clear" operations |
48 | */ |
49 | |
50 | /** |
51 | * Create an atomic flags instance. |
52 | * |
53 | * @param atomic_flags Pointer to atomic flags instance, filled in on return |
54 | * |
55 | * @return VCOS_SUCCESS if succeeded. |
56 | */ |
57 | VCOS_INLINE_DECL |
58 | VCOS_STATUS_T vcos_atomic_flags_create(VCOS_ATOMIC_FLAGS_T *atomic_flags); |
59 | |
60 | /** |
61 | * Atomically set the specified flags. |
62 | * |
63 | * @param atomic_flags Instance to set flags on |
64 | * @param flags Mask of flags to set |
65 | */ |
66 | VCOS_INLINE_DECL |
67 | void vcos_atomic_flags_or(VCOS_ATOMIC_FLAGS_T *atomic_flags, uint32_t flags); |
68 | |
69 | /** |
70 | * Retrieve the current flags and then clear them. The entire operation is |
71 | * atomic. |
72 | * |
73 | * @param atomic_flags Instance to get/clear flags from/on |
74 | * |
75 | * @return Mask of flags which were set (and we cleared) |
76 | */ |
77 | VCOS_INLINE_DECL |
78 | uint32_t vcos_atomic_flags_get_and_clear(VCOS_ATOMIC_FLAGS_T *atomic_flags); |
79 | |
80 | /** |
81 | * Delete an atomic flags instance. |
82 | * |
83 | * @param atomic_flags Instance to delete |
84 | */ |
85 | VCOS_INLINE_DECL |
86 | void vcos_atomic_flags_delete(VCOS_ATOMIC_FLAGS_T *atomic_flags); |
87 | |
88 | #ifdef __cplusplus |
89 | } |
90 | #endif |
91 | |
92 | #endif |
93 | |