Semaphore.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. #pragma once
  17. #ifndef _WIN32
  18. #include <semaphore.h>
  19. #else
  20. #include <limits.h>
  21. #define SEM_VALUE_MAX INT_MAX
  22. namespace folly::portability::semaphore {
  23. using sem_t = struct sem_t_*;
  24. int sem_init(sem_t* s, int shared, unsigned int value);
  25. int sem_destroy(sem_t* s);
  26. int sem_post(sem_t* s);
  27. int sem_trywait(sem_t* s);
  28. int sem_wait(sem_t* s);
  29. } // namespace folly::portability::semaphore
  30. /* using override */ using namespace folly::portability::semaphore;
  31. #endif