Annotation of coherent/b/lib/libc/sys/i8086/msgop.c,v, revision 1.1.1.1

1.1       root        1: head     1.3;
                      2: access   ;
                      3: symbols  ;
                      4: locks    bin:1.3;
                      5: comment  @ * @;
                      6: 
                      7: 
                      8: 1.3
                      9: date     91.06.03.21.46.56;  author bin;  state Exp;
                     10: branches ;
                     11: next   1.2;
                     12: 
                     13: 1.2
                     14: date     91.05.30.00.06.23;  author bin;  state Exp;
                     15: branches ;
                     16: next   1.1;
                     17: 
                     18: 1.1
                     19: date     91.05.29.23.57.18;  author bin;  state Exp;
                     20: branches ;
                     21: next   ;
                     22: 
                     23: 
                     24: desc
                     25: @steve 5/29/91
                     26: Initial MWC RCS revision.
                     27: @
                     28: 
                     29: 
                     30: 1.3
                     31: log
                     32: @steve 6/3/91
                     33: Corrected bug introduced by last source revision: key is 4 bytes, not 2.
                     34: @
                     35: text
                     36: @/*
                     37:  * libc/sys/msgop.c
                     38:  * User Message Functions.
                     39:  * Note: msgget() must be first function called.
                     40:  */
                     41: 
                     42: #include <sys/msg.h>
                     43: #include <errno.h>
                     44: 
                     45: static int  msgfno   = -1;
                     46: static char msgdev[] = "/dev/msg";
                     47: 
                     48: /*
                     49:  * Message Control Operations.
                     50:  */
                     51: msgctl(msqid, cmd, buf) int msqid, cmd; struct msqid_ds * buf;
                     52: {
                     53:        int parm[4];
                     54: 
                     55:        if (msgfno < 0) {
                     56:                errno = ENODEV;
                     57:                return -1;
                     58:        }
                     59: 
                     60:        parm[0] = -1;
                     61:        parm[1] = msqid;
                     62:        parm[2] = cmd;
                     63:        parm[3] = (int) buf;
                     64: 
                     65:        ioctl(msgfno, MSGCTL, parm);
                     66:        return parm[0];
                     67: }
                     68: 
                     69: /*
                     70:  * Get Message Queue.
                     71:  */
                     72: msgget(key, msgflg) key_t key; int msgflg;
                     73: {
                     74:        int parm[4];
                     75: 
                     76:        if (msgfno < 0) {
                     77:                if ((msgfno = open(msgdev, 0)) < 0) {
                     78:                        perror(msgdev);
                     79:                        errno = ENODEV;
                     80:                        return -1;
                     81:                }
                     82:        }
                     83: 
                     84:        parm[0] = -1;
                     85:        parm[1] = key;
                     86:        parm[2] = key >> 16;
                     87:        parm[3] = msgflg;
                     88: 
                     89:        ioctl(msgfno, MSGGET, parm);
                     90:        return parm[0];
                     91: }
                     92: 
                     93: /*
                     94:  * Send Message.
                     95:  */
                     96: msgsnd(msqid, msgp, msgsz, msgflg) int msqid; struct msgbuf *msgp; int msgsz, msgflg;
                     97: {
                     98:        int parm[5];
                     99: 
                    100:        if (msgfno < 0) {
                    101:                errno = ENODEV;
                    102:                return -1;
                    103:        }
                    104: 
                    105:        parm[0] = -1;
                    106:        parm[1] = msqid;
                    107:        parm[2] = (int) msgp;
                    108:        parm[3] = msgsz;
                    109:        parm[4] = msgflg;
                    110: 
                    111:        ioctl(msgfno, MSGSND, parm);
                    112:        return parm[0];
                    113: }
                    114: 
                    115: /*
                    116:  * Receive Message.
                    117:  */
                    118: msgrcv(msqid, msgp, msgsz, msgtyp, msgflg)
                    119: int msqid; struct msgbuf *msgp; int msgsz; long msgtyp; int msgflg;
                    120: {
                    121:        int parm[7];
                    122: 
                    123:        if (msgfno < 0) {
                    124:                errno = ENODEV;
                    125:                return -1;
                    126:        }
                    127: 
                    128:        parm[0] = -1;
                    129:        parm[1] = msqid;
                    130:        parm[2] = (int) msgp;
                    131:        parm[3] = msgsz;
                    132:        parm[4] = (int) msgtyp;
                    133:        parm[5] = (int) (msgtyp >> 16);
                    134:        parm[6] = msgflg;
                    135: 
                    136:        ioctl(msgfno, MSGRCV, parm);
                    137:        return parm[0];
                    138: }
                    139: 
                    140: /* end of msgop.c */
                    141: @
                    142: 
                    143: 
                    144: 1.2
                    145: log
                    146: @steve 5/29/91
                    147: Added changes from hal.
                    148: Nonsubstantive changes to whitespace.
                    149: @
                    150: text
                    151: @d6 1
                    152: a6 1
                    153:  
                    154: d39 1
                    155: a39 1
                    156:        int parm[3];
                    157: d51 2
                    158: a52 1
                    159:        parm[2] = msgflg;
                    160: d61 1
                    161: a61 2
                    162: msgsnd(msqid, msgp, msgsz, msgflg)
                    163: int msqid; struct msgbuf *msgp; int msgsz, msgflg;
                    164: @
                    165: 
                    166: 
                    167: 1.1
                    168: log
                    169: @Initial revision
                    170: @
                    171: text
                    172: @d2 1
                    173: d4 1
                    174: a4 5
                    175:  *
                    176:  *     Note: msgget() must be first function called.
                    177:  *
                    178:  *     91/02/07        Hal Snyder      mwchwc!/u/libc/sys/msgop.c
                    179:  *     msgget():  sizeof(key_t) is 4, not 2.
                    180: d6 1
                    181: d16 1
                    182: a16 7
                    183: 
                    184: msgctl( msqid, cmd, buf )
                    185: 
                    186: int msqid;
                    187: int cmd;
                    188: struct msqid_ds * buf;
                    189: 
                    190: d20 1
                    191: a20 1
                    192:        if ( msgfno < 0 ) {
                    193: d30 1
                    194: a30 1
                    195:        ioctl( msgfno, MSGCTL, parm );
                    196: d37 3
                    197: d41 2
                    198: a42 13
                    199: msgget( key, msgflg )
                    200: 
                    201: key_t key;
                    202: int msgflg;
                    203: 
                    204: {
                    205:        int parm[4];
                    206: 
                    207:        if ( msgfno < 0 ) {
                    208: 
                    209:                msgfno = open(msgdev, 0);
                    210: 
                    211:                if ( msgfno < 0 ) {
                    212: d51 1
                    213: a51 2
                    214:        parm[2] = key >> 16;
                    215:        parm[3] = msgflg;
                    216: d53 1
                    217: a53 1
                    218:        ioctl( msgfno, MSGGET, parm );
                    219: d60 2
                    220: a61 8
                    221:  
                    222: msgsnd( msqid, msgp, msgsz, msgflg )
                    223: 
                    224: int msqid;
                    225: struct msgbuf *msgp;
                    226: int msgsz;
                    227: int msgflg;
                    228: 
                    229: d65 1
                    230: a65 1
                    231:        if ( msgfno < 0 ) {
                    232: d76 1
                    233: a76 1
                    234:        ioctl( msgfno, MSGSND, parm );
                    235: d83 2
                    236: a84 9
                    237:  
                    238: msgrcv( msqid, msgp, msgsz, msgtyp, msgflg )
                    239: 
                    240: int msqid;
                    241: struct msgbuf *msgp;
                    242: int msgsz;
                    243: long msgtyp;
                    244: int msgflg;
                    245: 
                    246: d88 1
                    247: a88 1
                    248:        if ( msgfno < 0 ) {
                    249: d101 1
                    250: a101 1
                    251:        ioctl( msgfno, MSGRCV, parm );
                    252: d104 2
                    253: @

unix.superglobalmegacorp.com

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