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;
15 typedef pipe structtype pipe_structtype;
23 [out,ref] struct msg *out1,
24 [out] pipe_structtype outp,
25 [in] pipe_structtype inp,
29 long midltests_ping( [in] struct msg in1);
33 #elif MIDLTESTS_C_CODE
35 struct pipe_char_state {
\r
37 unsigned long count;
\r
38 unsigned long sleep;
\r
41 void pipe_char_pull(
\r
43 unsigned char * buf,
\r
44 unsigned long esize,
\r
45 unsigned long * ecount)
\r
47 struct pipe_char_state *state = (struct pipe_char_state *)_state;
\r
49 printf("pull1:%s: esize[%u] ecount[%u]\n",
\r
50 state->name, esize, *ecount);
\r
51 *ecount = state->count--;
\r
52 if (*ecount > esize) {
\r
55 memset(buf, 0xDD, *ecount * sizeof(*buf));
56 printf("pull2:%s: esize[%u] ecount[%u]\n",
\r
57 state->name, esize, *ecount);
\r
60 void pipe_char_push(
\r
62 unsigned char * buf,
\r
63 unsigned long ecount)
\r
65 struct pipe_char_state *state = (struct pipe_char_state *)_state;
\r
67 printf("push:%s: ecount[%u]\n",
\r
68 state->name, ecount);
\r
71 void pipe_char_alloc(
\r
73 unsigned long bsize,
\r
74 unsigned char * * buf,
\r
75 unsigned long * bcount)
\r
77 struct pipe_char_state *state = (struct pipe_char_state *)_state;
\r
79 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
\r
80 state->name, bsize, *bcount);
\r
81 *bcount = bsize / sizeof(**buf);
\r
82 *buf = malloc(*bcount * sizeof(**buf));
\r
83 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
\r
84 state->name, bsize, *bcount);
\r
87 struct pipe_hyper_state {
97 unsigned long * ecount)
99 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
101 printf("pull1:%s: esize[%u] ecount[%u]\n",
102 state->name, esize, *ecount);
103 *ecount = state->count--;
104 if (*ecount > esize) {
107 memset(buf, 0xDD, *ecount * sizeof(*buf));
108 printf("pull2:%s: esize[%u] ecount[%u]\n",
109 state->name, esize, *ecount);
112 void pipe_hyper_push(
115 unsigned long ecount)
117 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
119 printf("push:%s: ecount[%u]\n",
120 state->name, ecount);
123 void pipe_hyper_alloc(
127 unsigned long * bcount)
129 struct pipe_hyper_state *state = (struct pipe_hyper_state *)_state;
131 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
132 state->name, bsize, *bcount);
133 *bcount = bsize / sizeof(**buf);
134 *buf = malloc(*bcount * sizeof(**buf));
135 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
136 state->name, bsize, *bcount);
138 struct pipe_structtype_state {
144 void pipe_structtype_pull(
148 unsigned long * ecount)
150 struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
152 printf("pull1:%s: esize[%u] ecount[%u]\n",
153 state->name, esize, *ecount);
154 *ecount = state->count--;
155 if (*ecount > esize) {
158 memset(buf, 0xDD, *ecount * sizeof(*buf));
159 printf("pull2:%s: esize[%u] ecount[%u]\n",
160 state->name, esize, *ecount);
163 void pipe_structtype_push(
166 unsigned long ecount)
168 struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
170 printf("push:%s: ecount[%u]\n",
171 state->name, ecount);
174 void pipe_structtype_alloc(
178 unsigned long * bcount)
180 struct pipe_structtype_state *state = (struct pipe_structtype_state *)_state;
182 printf("alloc1:%s: bsize[%u], bcount[%u]\n",
183 state->name, bsize, *bcount);
184 *bcount = bsize / sizeof(**buf);
185 *buf = malloc(*bcount * sizeof(**buf));
186 printf("alloc2:%s: bsize[%u], bcount[%u]\n",
187 state->name, bsize, *bcount);
189 static void midltests(void)
192 unsigned char out1b[3];
193 struct pipe_structtype_state outs;
194 pipe_structtype outp;
195 struct pipe_structtype_state ins;
198 unsigned char in1b[3];
200 in1.l = sizeof(in1b);
201 memset(&in1b, 0xAA, sizeof(in1b));
204 memset(&outs, 0, sizeof(outs));
206 memset(&outp, 0, sizeof(outp));
207 outp.pull = pipe_structtype_pull;
208 outp.push = pipe_structtype_push;
209 outp.alloc = pipe_structtype_alloc;
210 outp.state = (char *)&outs;
212 memset(&ins, 0, sizeof(ins));
215 memset(&inp, 0, sizeof(inp));
216 inp.pull = pipe_structtype_pull;
217 inp.push = pipe_structtype_push;
218 inp.alloc = pipe_structtype_alloc;
219 inp.state = (char *)&ins;
221 out1.l = sizeof(out1b);
222 memset(&out1b, 0xFF, sizeof(out1b));
225 cli_midltests_ping(in1);
226 cli_midltests_fn(&out1, outp, inp, in1);
229 long srv_midltests_fn(
230 /* [ref][out] */ struct msg *out1,
\r
231 /* [out] */ pipe_structtype outp,
232 /* [in] */ pipe_structtype inp,
233 /* [in] */ struct msg in1)
236 unsigned long inb_len = 0;
237 structtype *outb = NULL;
238 unsigned long outb_size = 0;
239 unsigned long outb_len = 0;
241 printf("srv_midltests_fn: Start\n");
244 inp.pull(inp.state, inb, sizeof(inb), &inb_len);
245 printf("pull inp_len[%u]\n", inb_len);
246 } while (inb_len > 0);
250 outp.alloc(outp.state, outb_size, &outb, &outb_len);
251 memset(outb, 0xCC, outb_len * sizeof(*outb));
252 outp.push(outp.state, outb, outb_len);
253 printf("push outb_len[%u]\n", outb_len);
256 } while (outb_len > 0);
259 out1->m = (unsigned char *)malloc(out1->l);
260 memset(out1->m, 0xBB, out1->l);
261 printf("srv_midltests_fn: End\n");
265 long srv_midltests_ping(
266 /* [in] */ struct msg in1)
268 printf("srv_midltests_fn: Start\n");
269 printf("srv_midltests_fn: End\n");