5 #include "../lib/unbuffer_output.c"
7 /**************************************************************************
9 * function returning large structures, which go on the stack
10 * functions returning varied sized structs which go on in the registers.
11 ***************************************************************************/
14 /* A large structure (> 64 bits) used to test passing large structures as
18 struct array_rep_info_t
{
24 /*****************************************************************************
25 * Small structures ( <= 64 bits). These are used to test passing small
26 * structures as parameters and test argument size promotion.
27 *****************************************************************************/
31 struct small_rep_info_t
{
36 /* 6 bits : really fits in 8 bits and is promoted to 8 bits
38 struct bit_flags_char_t
{
39 unsigned char alpha
:1;
40 unsigned char beta
:1;
41 unsigned char gamma
:1;
42 unsigned char delta
:1;
43 unsigned char epsilon
:1;
44 unsigned char omega
:1;
47 /* 6 bits : really fits in 8 bits and is promoted to 16 bits
49 struct bit_flags_short_t
{
50 unsigned short alpha
:1;
51 unsigned short beta
:1;
52 unsigned short gamma
:1;
53 unsigned short delta
:1;
54 unsigned short epsilon
:1;
55 unsigned short omega
:1;
58 /* 6 bits : really fits in 8 bits and is promoted to 32 bits
69 /* 22 bits : really fits in 40 bits and is promoted to 64 bits
71 struct bit_flags_combo_t
{
96 /* 24 bits : promoted to 32 bits
104 /* 40 bits : promoted to 64 bits
114 /* 40 bits : promoted to 64 bits
116 struct int_char_combo_t
{
122 /*****************************************************************
124 * A do nothing function. Used to provide a point at which calls can be made.
125 *****************************************************************/
130 for (index
=0; index
<4; index
++); /* -break1- */
133 /*****************************************************************
134 * INIT_BIT_FLAGS_CHAR :
135 * Initializes a bit_flags_char_t structure. Can call this function see
136 * the call command behavior when integer arguments do not fit into
137 * registers and must be placed on the stack.
138 * OUT struct bit_flags_char_t *bit_flags -- structure to be filled
139 * IN unsigned a -- 0 or 1
140 * IN unsigned b -- 0 or 1
141 * IN unsigned g -- 0 or 1
142 * IN unsigned d -- 0 or 1
143 * IN unsigned e -- 0 or 1
144 * IN unsigned o -- 0 or 1
145 *****************************************************************/
146 void init_bit_flags_char (
147 struct bit_flags_char_t
*bit_flags
,
156 bit_flags
->alpha
= a
;
158 bit_flags
->gamma
= g
;
159 bit_flags
->delta
= d
;
160 bit_flags
->epsilon
= e
;
161 bit_flags
->omega
= o
;
164 /*****************************************************************
165 * INIT_BIT_FLAGS_SHORT :
166 * Initializes a bit_flags_short_t structure. Can call this function see
167 * the call command behavior when integer arguments do not fit into
168 * registers and must be placed on the stack.
169 * OUT struct bit_flags_short_t *bit_flags -- structure to be filled
170 * IN unsigned a -- 0 or 1
171 * IN unsigned b -- 0 or 1
172 * IN unsigned g -- 0 or 1
173 * IN unsigned d -- 0 or 1
174 * IN unsigned e -- 0 or 1
175 * IN unsigned o -- 0 or 1
176 *****************************************************************/
177 void init_bit_flags_short (
178 struct bit_flags_short_t
*bit_flags
,
187 bit_flags
->alpha
= a
;
189 bit_flags
->gamma
= g
;
190 bit_flags
->delta
= d
;
191 bit_flags
->epsilon
= e
;
192 bit_flags
->omega
= o
;
195 /*****************************************************************
197 * Initializes a bit_flags_t structure. Can call this function see
198 * the call command behavior when integer arguments do not fit into
199 * registers and must be placed on the stack.
200 * OUT struct bit_flags_t *bit_flags -- structure to be filled
201 * IN unsigned a -- 0 or 1
202 * IN unsigned b -- 0 or 1
203 * IN unsigned g -- 0 or 1
204 * IN unsigned d -- 0 or 1
205 * IN unsigned e -- 0 or 1
206 * IN unsigned o -- 0 or 1
207 *****************************************************************/
208 void init_bit_flags (
209 struct bit_flags_t
*bit_flags
,
218 bit_flags
->alpha
= a
;
220 bit_flags
->gamma
= g
;
221 bit_flags
->delta
= d
;
222 bit_flags
->epsilon
= e
;
223 bit_flags
->omega
= o
;
226 /*****************************************************************
227 * INIT_BIT_FLAGS_COMBO :
228 * Initializes a bit_flags_combo_t structure. Can call this function
229 * to see the call command behavior when integer and character arguments
230 * do not fit into registers and must be placed on the stack.
231 * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill
232 * IN unsigned a -- 0 or 1
233 * IN unsigned b -- 0 or 1
235 * IN unsigned g -- 0 or 1
236 * IN unsigned d -- 0 or 1
238 * IN unsigned e -- 0 or 1
239 * IN unsigned o -- 0 or 1
240 *****************************************************************/
241 void init_bit_flags_combo (
242 struct bit_flags_combo_t
*bit_flags_combo
,
253 bit_flags_combo
->alpha
= a
;
254 bit_flags_combo
->beta
= b
;
255 bit_flags_combo
->ch1
= ch1
;
256 bit_flags_combo
->gamma
= g
;
257 bit_flags_combo
->delta
= d
;
258 bit_flags_combo
->ch2
= ch2
;
259 bit_flags_combo
->epsilon
= e
;
260 bit_flags_combo
->omega
= o
;
264 /*****************************************************************
266 * OUT struct one_double_t *one_double -- structure to fill
268 *****************************************************************/
269 void init_one_double ( struct one_double_t
*one_double
, double init_val
)
272 one_double
->double1
= init_val
;
275 /*****************************************************************
277 * OUT struct two_floats_t *two_floats -- structure to be filled
280 *****************************************************************/
281 void init_two_floats (
282 struct two_floats_t
*two_floats
,
287 two_floats
->float1
= init_val1
;
288 two_floats
->float2
= init_val2
;
291 /*****************************************************************
293 * OUT struct three_char_t *three_char -- structure to be filled
297 *****************************************************************/
298 void init_three_chars (
299 struct three_char_t
*three_char
,
305 three_char
->ch1
= init_val1
;
306 three_char
->ch2
= init_val2
;
307 three_char
->ch3
= init_val3
;
310 /*****************************************************************
312 * OUT struct five_char_t *five_char -- structure to be filled
318 *****************************************************************/
319 void init_five_chars (
320 struct five_char_t
*five_char
,
328 five_char
->ch1
= init_val1
;
329 five_char
->ch2
= init_val2
;
330 five_char
->ch3
= init_val3
;
331 five_char
->ch4
= init_val4
;
332 five_char
->ch5
= init_val5
;
335 /*****************************************************************
336 * INIT_INT_CHAR_COMBO :
337 * OUT struct int_char_combo_t *combo -- structure to be filled
340 *****************************************************************/
341 void init_int_char_combo (
342 struct int_char_combo_t
*combo
,
347 combo
->int1
= init_val1
;
348 combo
->ch1
= init_val2
;
351 /*****************************************************************
353 * OUT struct small_rep_into_t *small_struct -- structure to be filled
355 *****************************************************************/
356 void init_struct_rep(
357 struct small_rep_info_t
*small_struct
,
361 small_struct
->value
= 2 + (seed
*2);
362 small_struct
->head
= 0;
365 /*****************************************************************
366 * PRINT_BIT_FLAGS_CHAR :
367 * IN struct bit_flags_char_t bit_flags
368 ****************************************************************/
369 struct bit_flags_char_t
print_bit_flags_char (struct bit_flags_char_t bit_flags
)
372 if (bit_flags
.alpha
) printf("alpha\n");
373 if (bit_flags
.beta
) printf("beta\n");
374 if (bit_flags
.gamma
) printf("gamma\n");
375 if (bit_flags
.delta
) printf("delta\n");
376 if (bit_flags
.epsilon
) printf("epsilon\n");
377 if (bit_flags
.omega
) printf("omega\n");
382 /*****************************************************************
383 * PRINT_BIT_FLAGS_SHORT :
384 * IN struct bit_flags_short_t bit_flags
385 ****************************************************************/
386 struct bit_flags_short_t
print_bit_flags_short (struct bit_flags_short_t bit_flags
)
389 if (bit_flags
.alpha
) printf("alpha\n");
390 if (bit_flags
.beta
) printf("beta\n");
391 if (bit_flags
.gamma
) printf("gamma\n");
392 if (bit_flags
.delta
) printf("delta\n");
393 if (bit_flags
.epsilon
) printf("epsilon\n");
394 if (bit_flags
.omega
) printf("omega\n");
399 /*****************************************************************
401 * IN struct bit_flags_t bit_flags
402 ****************************************************************/
403 struct bit_flags_t
print_bit_flags (struct bit_flags_t bit_flags
)
406 if (bit_flags
.alpha
) printf("alpha\n");
407 if (bit_flags
.beta
) printf("beta\n");
408 if (bit_flags
.gamma
) printf("gamma\n");
409 if (bit_flags
.delta
) printf("delta\n");
410 if (bit_flags
.epsilon
) printf("epsilon\n");
411 if (bit_flags
.omega
) printf("omega\n");
416 /*****************************************************************
417 * PRINT_BIT_FLAGS_COMBO :
418 * IN struct bit_flags_combo_t bit_flags_combo
419 ****************************************************************/
420 struct bit_flags_combo_t
print_bit_flags_combo (struct bit_flags_combo_t bit_flags_combo
)
423 if (bit_flags_combo
.alpha
) printf("alpha\n");
424 if (bit_flags_combo
.beta
) printf("beta\n");
425 if (bit_flags_combo
.gamma
) printf("gamma\n");
426 if (bit_flags_combo
.delta
) printf("delta\n");
427 if (bit_flags_combo
.epsilon
) printf("epsilon\n");
428 if (bit_flags_combo
.omega
) printf("omega\n");
429 printf("ch1: %c\tch2: %c\n", bit_flags_combo
.ch1
, bit_flags_combo
.ch2
);
430 return bit_flags_combo
;
434 /*****************************************************************
436 * IN struct one_double_t one_double
437 ****************************************************************/
438 struct one_double_t
print_one_double (struct one_double_t one_double
)
441 printf("Contents of one_double_t: \n\n");
442 printf("%f\n", one_double
.double1
);
447 /*****************************************************************
449 * IN struct two_floats_t two_floats
450 ****************************************************************/
451 struct two_floats_t
print_two_floats (struct two_floats_t two_floats
)
454 printf("Contents of two_floats_t: \n\n");
455 printf("%f\t%f\n", two_floats
.float1
, two_floats
.float2
);
460 /*****************************************************************
461 * PRINT_THREE_CHARS :
462 * IN struct three_char_t three_char
463 ****************************************************************/
464 struct three_char_t
print_three_chars (struct three_char_t three_char
)
467 printf("Contents of three_char_t: \n\n");
468 printf("%c\t%c\t%c\n", three_char
.ch1
, three_char
.ch2
, three_char
.ch3
);
473 /*****************************************************************
475 * IN struct five_char_t five_char
476 ****************************************************************/
477 struct five_char_t
print_five_chars (struct five_char_t five_char
)
480 printf("Contents of five_char_t: \n\n");
481 printf("%c\t%c\t%c\t%c\t%c\n", five_char
.ch1
, five_char
.ch2
,
482 five_char
.ch3
, five_char
.ch4
,
488 /*****************************************************************
489 * PRINT_INT_CHAR_COMBO :
490 * IN struct int_char_combo_t int_char_combo
491 ****************************************************************/
492 struct int_char_combo_t
print_int_char_combo (struct int_char_combo_t int_char_combo
)
495 printf("Contents of int_char_combo_t: \n\n");
496 printf("%d\t%c\n", int_char_combo
.int1
, int_char_combo
.ch1
);
497 return int_char_combo
;
501 /*****************************************************************
503 ****************************************************************/
504 struct small_rep_info_t
print_struct_rep(struct small_rep_info_t struct1
)
507 printf("Contents of struct1: \n\n");
508 printf("%10d%10d\n", struct1
.value
, struct1
.head
);
517 struct array_rep_info_t
print_one_large_struct(struct array_rep_info_t linked_list1
)
521 printf("%10d%10d\n", linked_list1
.values
[0],
522 linked_list1
.next_index
[0]);
528 /*****************************************************************
530 * IN struct array_rep_info_t *linked_list
532 ****************************************************************/
533 void init_array_rep(struct array_rep_info_t
*linked_list
, int seed
)
538 for (index
= 0; index
< 10; index
++) {
540 linked_list
->values
[index
] = (2*index
) + (seed
*2);
541 linked_list
->next_index
[index
] = index
+ 1;
543 linked_list
->head
= 0;
549 /* variables for large structure testing
552 struct array_rep_info_t
*list1
;
554 /* variables for testing a small structures and a very long argument list
556 struct small_rep_info_t
*struct1
;
557 struct bit_flags_char_t
*cflags
;
558 struct bit_flags_short_t
*sflags
;
559 struct bit_flags_t
*flags
;
560 struct bit_flags_combo_t
*flags_combo
;
561 struct three_char_t
*three_char
;
562 struct five_char_t
*five_char
;
563 struct int_char_combo_t
*int_char_combo
;
564 struct one_double_t
*d1
;
565 struct two_floats_t
*f3
;
567 gdb_unbuffer_output ();
569 /* Allocate space for large structures
571 list1
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
573 /* Initialize large structures
575 init_array_rep(list1
, 2);
577 /* Print large structures
579 print_one_large_struct(*list1
);
581 /* Allocate space for small structures
583 struct1
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
584 cflags
= (struct bit_flags_char_t
*)malloc(sizeof(struct bit_flags_char_t
));
585 sflags
= (struct bit_flags_short_t
*)malloc(sizeof(struct bit_flags_short_t
));
586 flags
= (struct bit_flags_t
*)malloc(sizeof(struct bit_flags_t
));
587 flags_combo
= (struct bit_flags_combo_t
*)malloc(sizeof(struct bit_flags_combo_t
));
588 three_char
= (struct three_char_t
*)malloc(sizeof(struct three_char_t
));
589 five_char
= (struct five_char_t
*)malloc(sizeof(struct five_char_t
));
590 int_char_combo
= (struct int_char_combo_t
*)malloc(sizeof(struct int_char_combo_t
));
592 d1
= (struct one_double_t
*)malloc(sizeof(struct one_double_t
));
593 f3
= (struct two_floats_t
*)malloc(sizeof(struct two_floats_t
));
595 /* Initialize small structures
597 init_one_double ( d1
, 1.11111);
598 init_two_floats ( f3
, -2.345, 1.0);
599 init_bit_flags_char(cflags
, (unsigned)1, (unsigned)0, (unsigned)1,
600 (unsigned)0, (unsigned)1, (unsigned)0 );
601 init_bit_flags_short(sflags
, (unsigned)1, (unsigned)0, (unsigned)1,
602 (unsigned)0, (unsigned)1, (unsigned)0 );
603 init_bit_flags(flags
, (unsigned)1, (unsigned)0, (unsigned)1,
604 (unsigned)0, (unsigned)1, (unsigned)0 );
605 init_bit_flags_combo(flags_combo
, (unsigned)1, (unsigned)0, 'y',
606 (unsigned)1, (unsigned)0, 'n',
607 (unsigned)1, (unsigned)0 );
608 init_three_chars(three_char
, 'x', 'y', 'z');
609 init_five_chars(five_char
, 'h', 'e', 'l', 'l', 'o');
610 init_int_char_combo(int_char_combo
, 13, '!');
611 init_struct_rep(struct1
, 10);
614 /* Print small structures
616 print_one_double(*d1
);
617 print_two_floats(*f3
);
618 print_bit_flags_char(*cflags
);
619 print_bit_flags_short(*sflags
);
620 print_bit_flags(*flags
);
621 print_bit_flags_combo(*flags_combo
);
622 print_three_chars(*three_char
);
623 print_five_chars(*five_char
);
624 print_int_char_combo(*int_char_combo
);
625 print_struct_rep(*struct1
);
627 loop_count(); /* -finish2- */
629 return 0; /* -finish1- */