#include <sys/sem.h>

/*
** The last argument to the C library routine semctl()
** is a union, passed by value. 
**
** On the COBOL side, a C union can be represented as
** a group with various REDEFINES clauses. 
** However, the COBOL compiler does not provide support
** for passing a COBOL group by value. 
**
** Because of this, we create our own wrapper routine 
** for semctl(), which constructs the C union itself.
*/ 
int mysemctl(int sem_id, int sem_num, int command)
{
        union semun {
                int val;
                struct semid_ds *buf;
                unsigned short *array;
        } arg;
        arg.val = command;
        return (semctl(sem_id, sem_num, command, arg));
}
