pthread_semaphore.h 1.11 KB
Newer Older
Alexey Suhov's avatar
Alexey Suhov committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
// Copyright (C) 2019 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#ifndef PTHREAD_SEMAPHORE_H
#define PTHREAD_SEMAPHORE_H

# include <time.h>
# include <stdint.h>
typedef intptr_t pthread_sem_t;

# ifdef __cplusplus
extern "C" {
# endif
int pthread_sem_init(pthread_sem_t *psem, int pshared, unsigned int value);
int pthread_sem_destroy(pthread_sem_t *psem);
int pthread_sem_post(pthread_sem_t *psem);
int pthread_sem_post_broadcast(pthread_sem_t *psem);
int pthread_sem_wait(pthread_sem_t *psem);
int pthread_sem_timedwait(pthread_sem_t *psem, const struct timespec *abstime);
# ifdef __cplusplus
}
# endif

# ifdef __APPLE__

typedef pthread_sem_t sem_t;

#  ifdef __cplusplus
extern "C" {
#  endif

int sem_init(sem_t *psem, int pshared, unsigned int value);
int sem_destroy(sem_t *psem);
int sem_post(sem_t *psem);
int sem_wait(sem_t *psem);
int sem_timedwait(sem_t *psem, const struct timespec *abstime);

#  ifdef __cplusplus
}
#  endif

# elif defined(_WIN32)
#  error "pthread based semaphores not implemented for WIN32"
# else
#  include <semaphore.h>
# endif  // linux case
#endif  // PTHREAD_SEMAPHORE_H