1 /* 2 Copyright (c) 2002, Thomas Kurschel 3 4 5 Part of Radeon driver 6 7 Benaphore definition 8 */ 9 10 11 #ifndef _BENAPHORE_H 12 #define _BENAPHORE_H 13 14 15 typedef struct { 16 sem_id sem; 17 int32 ben; 18 } benaphore; 19 20 21 #define INIT_BEN(x, prefix) ( (x).ben = 0, (x).sem = create_sem(0, #prefix " benaphore"), (x).sem ) 22 #define ACQUIRE_BEN(x) if((atomic_add(&(x.ben), 1)) >= 1) acquire_sem(x.sem); 23 #define RELEASE_BEN(x) if((atomic_add(&(x.ben), -1)) > 1) release_sem(x.sem); 24 #define DELETE_BEN(x) delete_sem(x.sem); 25 26 #endif 27