1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 // These tests call the pw_sync module counting_semaphore API from C. The return
16 // values are checked in the main C++ tests.
17
18 #include <stdbool.h>
19
20 #include "pw_sync/counting_semaphore.h"
21
pw_sync_CountingSemaphore_CallRelease(pw_sync_CountingSemaphore * semaphore)22 void pw_sync_CountingSemaphore_CallRelease(
23 pw_sync_CountingSemaphore* semaphore) {
24 pw_sync_CountingSemaphore_Release(semaphore);
25 }
26
pw_sync_CountingSemaphore_CallReleaseNum(pw_sync_CountingSemaphore * semaphore,ptrdiff_t update)27 void pw_sync_CountingSemaphore_CallReleaseNum(
28 pw_sync_CountingSemaphore* semaphore, ptrdiff_t update) {
29 pw_sync_CountingSemaphore_ReleaseNum(semaphore, update);
30 }
31
pw_sync_CountingSemaphore_CallAcquire(pw_sync_CountingSemaphore * semaphore)32 void pw_sync_CountingSemaphore_CallAcquire(
33 pw_sync_CountingSemaphore* semaphore) {
34 pw_sync_CountingSemaphore_Acquire(semaphore);
35 }
36
pw_sync_CountingSemaphore_CallTryAcquire(pw_sync_CountingSemaphore * semaphore)37 bool pw_sync_CountingSemaphore_CallTryAcquire(
38 pw_sync_CountingSemaphore* semaphore) {
39 return pw_sync_CountingSemaphore_TryAcquire(semaphore);
40 }
41
pw_sync_CountingSemaphore_CallTryAcquireFor(pw_sync_CountingSemaphore * semaphore,pw_chrono_SystemClock_Duration for_at_least)42 bool pw_sync_CountingSemaphore_CallTryAcquireFor(
43 pw_sync_CountingSemaphore* semaphore,
44 pw_chrono_SystemClock_Duration for_at_least) {
45 return pw_sync_CountingSemaphore_TryAcquireFor(semaphore, for_at_least);
46 }
47
pw_sync_CountingSemaphore_CallTryAcquireUntil(pw_sync_CountingSemaphore * semaphore,pw_chrono_SystemClock_TimePoint until_at_least)48 bool pw_sync_CountingSemaphore_CallTryAcquireUntil(
49 pw_sync_CountingSemaphore* semaphore,
50 pw_chrono_SystemClock_TimePoint until_at_least) {
51 return pw_sync_CountingSemaphore_TryAcquireUntil(semaphore, until_at_least);
52 }
53
pw_sync_CountingSemaphore_CallMax(void)54 ptrdiff_t pw_sync_CountingSemaphore_CallMax(void) {
55 return pw_sync_CountingSemaphore_Max();
56 }
57