34 |
|
#include <unistd.h> |
35 |
|
#include <signal.h> |
36 |
|
#include <pthread.h> |
37 |
– |
#include <semaphore.h> |
37 |
|
|
38 |
|
|
39 |
|
/* Thread stack size */ |
49 |
|
extern int __clone(int (*fn)(void *), void *, int, void *); |
50 |
|
|
51 |
|
/* struct sem_t */ |
52 |
+ |
typedef struct { |
53 |
+ |
struct _pthread_fastlock __sem_lock; |
54 |
+ |
int __sem_value; |
55 |
+ |
_pthread_descr __sem_waiting; |
56 |
+ |
} sem_t; |
57 |
+ |
|
58 |
+ |
#define SEM_VALUE_MAX 64 |
59 |
|
#define status __status |
60 |
|
#define spinlock __spinlock |
61 |
|
#define sem_lock __sem_lock |
364 |
|
|
365 |
|
int sem_wait(sem_t *sem) |
366 |
|
{ |
361 |
– |
int cnt = 0; |
362 |
– |
struct timespec tm; |
363 |
– |
|
367 |
|
if (sem == NULL) { |
368 |
|
errno = EINVAL; |
369 |
|
return -1; |