[code:1]
typedef unsigned char bool;
enum {false = 0, true = 1};
typedef union SEMUNI
{
int val;
struct semid_ds* buf;
unsigned short* array;
struct seminfo* __buf;
} SEMUNI, *PSEMUNI;
bool CreateSEM(int* pSem, int nKey, int nMax)
{
int sem;
sem = semget(nKey, nMax, 0777|IPC_CREAT);
if ( sem == -1 ) return false;
static SEMUNI semuni = { val: nMax };
semctl(sem, 0, SETVAL, semuni);
*pSem = sem;
return true;
}
bool RemoveSEM(int hSem)
{
static SEMUNI semuni;