1 #ifndef MIDLTESTS_C_CODE
4 uuid("225b9fcb-eb3d-497b-8b0b-591f049a2507"),
5 pointer_default(unique)
9 typedef pipe char pipe_char;
10 typedef pipe hyper pipe_hyper;
18 [out,ref] struct msg *out1,
19 [out] pipe_hyper outp,
25 #elif MIDLTESTS_C_CODE
27 struct pipe_char_state {
\r
29 unsigned long count;
\r
30 unsigned long sleep;
\r
33 void pipe_char_pull(
\r
35 unsigned char * buf,
\r
36 unsigned long esize,
\r
37 unsigned long * ecount)
\r
39 struct pipe_char_state *state = (struct pipe_char_state *)_state;
\r
41 printf("pull1:%s: esize[%u] ecount[%u]\n",
\r
42 state->name, esize, *ecount);
\r
43 *ecount = state->count--;
\r
44 if (*ecount > esize) {
\r
47 memset(buf, 0xDD, *ecount * sizeof(*buf));
48 printf("pull2:%s: esize[%u] ecount[%u]\n",
\r
49 state->name, esize, *ecount);
\r
52 void pipe_char_push(
\r
54 unsigned char * buf,
\r
55 unsigned long ecount)
\r
57 struct pipe_char_state *state = (struct pipe_char_state *)_state;
\r
59 printf("push:%s: ecount[%u]\n",
\r
60 state->name, ecount);
\r
63 void pipe_char_alloc(
\r
65 unsigned long bsize,
\r
66 unsigned char * * buf,
\r
67 unsigned long * bcount)
\r
69 struct pipe_char_state *state = (struct pipe_char_state *)_state;
\r
71 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
\r
72 state->name, bsize, *bcount);
\r
73 *bcount = bsize / sizeof(**buf);
\r
74 *buf = malloc(*bcount * sizeof(**buf));
\r
75 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
\r
76 state->name, bsize, *bcount);
\r
79 struct pipe_hyper_state {
89 unsigned long * ecount)
91 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
93 printf("pull1:%s: esize[%u] ecount[%u]\n",
94 state->name, esize, *ecount);
95 *ecount = state->count--;
96 if (*ecount > esize) {
99 memset(buf, 0xDD, *ecount * sizeof(*buf));
100 printf("pull2:%s: esize[%u] ecount[%u]\n",
101 state->name, esize, *ecount);
104 void pipe_hyper_push(
107 unsigned long ecount)
109 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
111 printf("push:%s: ecount[%u]\n",
112 state->name, ecount);
115 void pipe_hyper_alloc(
119 unsigned long * bcount)
121 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
123 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
124 state->name, bsize, *bcount);
125 *bcount = bsize / sizeof(**buf);
126 *buf = malloc(*bcount * sizeof(**buf));
127 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
128 state->name, bsize, *bcount);
130 static void midltests(void)
133 unsigned char out1b[3];
134 struct pipe_hyper_state outs;
136 struct pipe_hyper_state ins;
139 unsigned char in1b[3];
141 in1.l = sizeof(in1b);
142 memset(&in1b, 0xAA, sizeof(in1b));
145 memset(&outs, 0, sizeof(outs));
147 memset(&outp, 0, sizeof(outp));
148 outp.pull = pipe_hyper_pull;
149 outp.push = pipe_hyper_push;
150 outp.alloc = pipe_hyper_alloc;
151 outp.state = (char *)&outs;
153 memset(&ins, 0, sizeof(ins));
156 memset(&inp, 0, sizeof(inp));
157 inp.pull = pipe_hyper_pull;
158 inp.push = pipe_hyper_push;
159 inp.alloc = pipe_hyper_alloc;
160 inp.state = (char *)&ins;
162 out1.l = sizeof(out1b);
163 memset(&out1b, 0xFF, sizeof(out1b));
166 cli_midltests_fn(&out1, outp, inp, in1);
169 long srv_midltests_fn(
170 /* [ref][out] */ struct msg *out1,
\r
171 /* [out] */ pipe_hyper outp,
172 /* [in] */ pipe_hyper inp,
173 /* [in] */ struct msg in1)
176 unsigned long inb_len = 0;
178 unsigned long outb_size = 0;
179 unsigned long outb_len = 0;
181 printf("srv_midltests_fn: Start\n");
184 inp.pull(inp.state, inb, sizeof(inb), &inb_len);
185 printf("pull inp_len[%u]\n", inb_len);
186 } while (inb_len > 0);
190 outp.alloc(outp.state, outb_size, &outb, &outb_len);
191 memset(outb, 0xCC, outb_len * sizeof(*outb));
192 outp.push(outp.state, outb, outb_len);
193 printf("push outb_len[%u]\n", outb_len);
196 } while (outb_len > 0);
199 out1->m = (unsigned char *)malloc(out1->l);
200 memset(out1->m, 0xBB, out1->l);
201 printf("srv_midltests_fn: End\n");