2 Copyright 1999, Be Incorporated. All Rights Reserved.
3 This file may be used under the terms of the Be Sample Code License.
13 typedef struct lock lock
;
14 typedef struct mlock mlock
;
25 extern _IMPEXP_KERNEL
int new_lock(lock
*l
, const char *name
);
26 extern _IMPEXP_KERNEL
int free_lock(lock
*l
);
28 static inline status_t
LOCK(lock
*l
)
30 if (atomic_add(&(l
->c
), -1) <= 0)
31 return acquire_sem(l
->s
);
35 static inline status_t
UNLOCK(lock
*l
)
37 if (atomic_add(&(l
->c
), 1) < 0)
38 return release_sem(l
->s
);
43 //#define LOCK(l) if (atomic_add(&l.c, -1) <= 0) acquire_sem(l.s);
44 //#define UNLOCK(l) if (atomic_add(&l.c, 1) < 0) release_sem(l.s);
46 extern _IMPEXP_KERNEL
int new_mlock(mlock
*l
, long c
, const char *name
);
47 extern _IMPEXP_KERNEL
int free_mlock(mlock
*l
);
49 #define LOCKM(l,cnt) acquire_sem_etc(l.s, cnt, 0, 0)
50 #define UNLOCKM(l,cnt) release_sem_etc(l.s, cnt, 0)