| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: completion.h,v 1.1.2.2 2013/07/24 03:15:59 riastradh Exp $ */ | | 1 | /* $NetBSD: completion.h,v 1.1.2.3 2013/07/24 03:29:43 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -107,29 +107,34 @@ complete_all(struct completion *completi | | | @@ -107,29 +107,34 @@ complete_all(struct completion *completi |
107 | cv_broadcast(&completion->c_cv); | | 107 | cv_broadcast(&completion->c_cv); |
108 | } else { | | 108 | } else { |
109 | KASSERT(completion->c_done == -1); | | 109 | KASSERT(completion->c_done == -1); |
110 | } | | 110 | } |
111 | | | 111 | |
112 | mutex_exit(&completion->c_lock); | | 112 | mutex_exit(&completion->c_lock); |
113 | } | | 113 | } |
114 | | | 114 | |
115 | /* | | 115 | /* |
116 | * Reverse the effect of complete_all so that subsequent waiters block | | 116 | * Reverse the effect of complete_all so that subsequent waiters block |
117 | * until someone calls complete or complete_all. | | 117 | * until someone calls complete or complete_all. |
118 | * | | 118 | * |
119 | * This operation is very different from its lowercase counterpart. | | 119 | * This operation is very different from its lowercase counterpart. |
| | | 120 | * |
| | | 121 | * For some reason this works on the completion object itself, not on a |
| | | 122 | * pointer thereto, so it must be a macro. |
120 | */ | | 123 | */ |
| | | 124 | #define INIT_COMPLETION(COMPLETION) INIT_COMPLETION_blorp(&(COMPLETION)) |
| | | 125 | |
121 | static inline void | | 126 | static inline void |
122 | INIT_COMPLETION(struct completion *completion) | | 127 | INIT_COMPLETION_blorp(struct completion *completion) |
123 | { | | 128 | { |
124 | | | 129 | |
125 | mutex_enter(&completion->c_lock); | | 130 | mutex_enter(&completion->c_lock); |
126 | completion->c_done = 0; | | 131 | completion->c_done = 0; |
127 | /* No notify -- waiters are interested only in nonzero values. */ | | 132 | /* No notify -- waiters are interested only in nonzero values. */ |
128 | mutex_exit(&completion->c_lock); | | 133 | mutex_exit(&completion->c_lock); |
129 | } | | 134 | } |
130 | | | 135 | |
131 | /* | | 136 | /* |
132 | * Wait interruptibly with a timeout for someone to call complete or | | 137 | * Wait interruptibly with a timeout for someone to call complete or |
133 | * complete_all. | | 138 | * complete_all. |
134 | */ | | 139 | */ |
135 | static inline int | | 140 | static inline int |