Annotation of coherent/b/lib/libc/sys/semop.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * User Semaphore Functions.
        !             3:  *
        !             4:  *     Note: Semget() must be first function called.
        !             5:  *
        !             6:  * $Log:       semop.c,v $
        !             7:  * Revision 1.1  92/06/30  10:32:02  bin
        !             8:  * Initial revision
        !             9:  * 
        !            10:  * 87/04/26    Allan Cornish
        !            11:  * Support for 32 bit 'key' added to semget.
        !            12:  */
        !            13:  
        !            14: #include <sys/sem.h>
        !            15: 
        !            16: static int  semfno   = -1;
        !            17: static char semdev[] = "/dev/sem";
        !            18: 
        !            19: /*
        !            20:  * Semaphore Control Operations.
        !            21:  */
        !            22: 
        !            23: semctl( semid, semnum, cmd, arg )
        !            24: 
        !            25: int semid;
        !            26: int semnum;
        !            27: int cmd;
        !            28: int arg;
        !            29: 
        !            30: {
        !            31:        int parm[5];
        !            32: 
        !            33:        if ( semfno < 0 )
        !            34:                return -1;
        !            35: 
        !            36:        parm[0] = -1;
        !            37:        parm[1] = semid;
        !            38:        parm[2] = semnum;
        !            39:        parm[3] = cmd;
        !            40:        parm[4] = arg;
        !            41: 
        !            42:        ioctl( semfno, SEMCTL, parm );
        !            43:        return parm[0];
        !            44: }
        !            45: 
        !            46: /*
        !            47:  * Get Set of Semaphores.
        !            48:  */
        !            49: 
        !            50: semget( key, nsems, semflg )
        !            51: 
        !            52: key_t key;
        !            53: int nsems;
        !            54: int semflg;
        !            55: 
        !            56: {
        !            57:        int parm[5];
        !            58: 
        !            59:        if ( semfno < 0 ) {
        !            60: 
        !            61:                if ( (semfno = open(semdev, 0)) < 0 ) {
        !            62: 
        !            63:                        perror( semdev );
        !            64:                        return -1;
        !            65:                }
        !            66:        }
        !            67: 
        !            68:        parm[0] = -1;
        !            69:        parm[1] = key;
        !            70:        parm[2] = key >> 16;
        !            71:        parm[3] = nsems;
        !            72:        parm[4] = semflg;
        !            73: 
        !            74:        ioctl( semfno, SEMGET, parm );
        !            75:        return parm[0];
        !            76: }
        !            77: 
        !            78: /*
        !            79:  * Semaphore Operations.
        !            80:  */
        !            81:  
        !            82: semop( semid, sops, nsops )
        !            83: 
        !            84: int semid;
        !            85: struct sembuf (*sops)[];
        !            86: int nsops;
        !            87: 
        !            88: {
        !            89:        int parm[4];
        !            90: 
        !            91:        if ( semfno < 0 )
        !            92:                return -1;
        !            93: 
        !            94:        parm[0] = -1;
        !            95:        parm[1] = semid;
        !            96:        parm[2] = sops;
        !            97:        parm[3] = nsops;
        !            98: 
        !            99:        ioctl( semfno, SEMOP, parm );
        !           100:        return parm[0];
        !           101: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.