Annotation of coherent/f/etc/conf/streams/src/test.c, revision 1.1.1.1

1.1       root        1: #define        _DDI_DKI        1
                      2: #define        _SYSV3          1
                      3: 
                      4: #include <common/xdebug.h>
                      5: #include <sys/confinfo.h>
                      6: #include <sys/types.h>
                      7: #include <string.h>
                      8: 
                      9: #ifdef __MSDOS__
                     10: #include <sys/_con.h>
                     11: #else
                     12: #include <sys/con.h>
                     13: #endif
                     14: 
                     15: /*
                     16:  * Fix this up for non-ISO C systems. In actual fact, these symbols are
                     17:  * allowed to be enumerations rather than #define macros....
                     18:  */
                     19: 
                     20: #ifndef        EXIT_SUCCESS
                     21: 
                     22: #define        EXIT_SUCCESS    0
                     23: #define        EXIT_FAILURE    -1
                     24: 
                     25: #endif
                     26: 
                     27: __EXTERN_C_BEGIN__
                     28: 
                     29: int            testX86         __PROTO ((void));
                     30: 
                     31: __EXTERN_C_END__
                     32: 
                     33: #include <dos.h>
                     34: #include <sys/io.h>
                     35: 
                     36: /*
                     37:  *
                     38:  */
                     39: 
                     40: #if    __USE_PROTO__
                     41: __LOCAL__ void (foo) (void * __NOTUSED (unused))
                     42: #else
                     43: __LOCAL__ void
                     44: foo __ARGS (())
                     45: #endif
                     46: {
                     47:        (* (char __far *) MK_FP (0xB800, 10)) ++;
                     48: 
                     49:        itimeout (foo, 0, 3, pltimeout);
                     50:        untimeout (itimeout (foo, 0, 1, pltimeout));
                     51: }
                     52: 
                     53: 
                     54: #include <sys/file.h>
                     55: #include <stropts.h>
                     56: 
                     57: __CONST__ char TEST_STRING [] = "Foo bar and Grill";
                     58: 
                     59: #if    __USE_PROTO__
                     60: int main (void)
                     61: #else
                     62: int
                     63: main ()
                     64: #endif
                     65: {
                     66:        CON           * con;
                     67:        IO              io;
                     68:        o_dev_t         dev;
                     69: 
                     70:        /*
                     71:         * Ensure that the atomic operations are at least doing the operations
                     72:         * as defined (testing for atomicity is beyond us as yet).
                     73:         */
                     74: 
                     75:        while (testX86 ())
                     76:                return -1;
                     77: 
                     78:        STREAMS_INIT ();
                     79: 
                     80:        itimeout (foo, 0, 2, pltimeout);
                     81:        untimeout (itimeout (foo, 0, 1, pltimeout));
                     82: 
                     83:        sleep (1);
                     84: 
                     85:        if ((con = STREAMS_GETCON (dev = 0x2000)) == NULL)
                     86:                return -1;
                     87:        if ((* con->c_open) (dev, IPR|IPW, DFCHR) == 0) {
                     88: 
                     89:                (* con->c_ioctl) (dev, I_PUSH, "dump", IPR|IPW);
                     90: 
                     91:                io.io_seg = IOUSR;
                     92:                io.io_ioc = sizeof (TEST_STRING);
                     93:                io.io_base = TEST_STRING;
                     94:                io.io_seek = 0;
                     95:                io.io_flag = 0;
                     96: 
                     97:                (* con->c_write) (dev, & io);
                     98: 
                     99:                (* con->c_close) (dev, IPR|IPW, DFCHR);
                    100:        }
                    101: 
                    102:        sleep (1);
                    103: 
                    104:        if ((con = STREAMS_GETCON (dev = 0x2100)) == NULL)
                    105:                return -1;
                    106:        if ((* con->c_open) (dev, IPR|IPW, DFCHR) == 0) {
                    107:                char            buf [sizeof (TEST_STRING) + 10];
                    108: 
                    109:                (* con->c_ioctl) (dev, I_PUSH, "dump", IPR|IPW);
                    110: 
                    111:                io.io_seg = IOUSR;
                    112:                io.io_ioc = sizeof (TEST_STRING);
                    113:                io.io_base = TEST_STRING;
                    114:                io.io_seek = 0;
                    115:                io.io_flag = 0;
                    116: 
                    117:                (* con->c_write) (dev, & io);
                    118: 
                    119:                (* con->c_ioctl) (dev, I_SRDOPT, RMSGN, IPR|IPW);
                    120: 
                    121:                io.io_base = buf;
                    122:                io.io_ioc = sizeof (buf);
                    123: 
                    124:                (* con->c_read) (dev, & io);
                    125: 
                    126:                if (io.io_ioc != 10 ||
                    127:                    memcmp (TEST_STRING, buf, sizeof (TEST_STRING)) != 0)
                    128:                        ASSERT ("Data mutated!\n" == NULL);
                    129: 
                    130:                (* con->c_close) (dev, IPR|IPW, DFCHR);
                    131:        }
                    132: 
                    133:        return EXIT_SUCCESS;
                    134: }

unix.superglobalmegacorp.com

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