1 | /* |
2 | * Copyright 2017-present Facebook, Inc. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | #pragma once |
18 | |
19 | #ifndef _WIN32 |
20 | #include <semaphore.h> |
21 | #else |
22 | #include <limits.h> |
23 | |
24 | #define SEM_VALUE_MAX INT_MAX |
25 | namespace folly::portability::semaphore { |
26 | using sem_t = struct sem_t_*; |
27 | int sem_init(sem_t* s, int shared, unsigned int value); |
28 | int sem_destroy(sem_t* s); |
29 | int sem_post(sem_t* s); |
30 | int sem_trywait(sem_t* s); |
31 | int sem_wait(sem_t* s); |
32 | } // namespace folly::portability::semaphore |
33 | |
34 | /* using override */ using namespace folly::portability::semaphore; |
35 | #endif |
36 | |