5 /**************************************************************************
7 * function returning large structures, which go on the stack
8 * functions returning varied sized structs which go on in the registers.
9 ***************************************************************************/
12 /* A large structure (> 64 bits) used to test passing large structures as
16 struct array_rep_info_t
{
22 /*****************************************************************************
23 * Small structures ( <= 64 bits). These are used to test passing small
24 * structures as parameters and test argument size promotion.
25 *****************************************************************************/
29 struct small_rep_info_t
{
34 /* 6 bits : really fits in 8 bits and is promoted to 8 bits
36 struct bit_flags_char_t
{
37 unsigned char alpha
:1;
38 unsigned char beta
:1;
39 unsigned char gamma
:1;
40 unsigned char delta
:1;
41 unsigned char epsilon
:1;
42 unsigned char omega
:1;
45 /* 6 bits : really fits in 8 bits and is promoted to 16 bits
47 struct bit_flags_short_t
{
48 unsigned short alpha
:1;
49 unsigned short beta
:1;
50 unsigned short gamma
:1;
51 unsigned short delta
:1;
52 unsigned short epsilon
:1;
53 unsigned short omega
:1;
56 /* 6 bits : really fits in 8 bits and is promoted to 32 bits
67 /* 22 bits : really fits in 40 bits and is promoted to 64 bits
69 struct bit_flags_combo_t
{
94 /* 24 bits : promoted to 32 bits
102 /* 40 bits : promoted to 64 bits
112 /* 40 bits : promoted to 64 bits
114 struct int_char_combo_t
{
120 /*****************************************************************
122 * A do nothing function. Used to provide a point at which calls can be made.
123 *****************************************************************/
128 for (index
=0; index
<4; index
++);
131 /*****************************************************************
132 * INIT_BIT_FLAGS_CHAR :
133 * Initializes a bit_flags_char_t structure. Can call this function see
134 * the call command behavior when integer arguments do not fit into
135 * registers and must be placed on the stack.
136 * OUT struct bit_flags_char_t *bit_flags -- structure to be filled
137 * IN unsigned a -- 0 or 1
138 * IN unsigned b -- 0 or 1
139 * IN unsigned g -- 0 or 1
140 * IN unsigned d -- 0 or 1
141 * IN unsigned e -- 0 or 1
142 * IN unsigned o -- 0 or 1
143 *****************************************************************/
145 void init_bit_flags_char (
146 struct bit_flags_char_t
*bit_flags
,
154 void init_bit_flags_char (bit_flags
,a
,b
,g
,d
,e
,o
)
155 struct bit_flags_char_t
*bit_flags
;
165 bit_flags
->alpha
= a
;
167 bit_flags
->gamma
= g
;
168 bit_flags
->delta
= d
;
169 bit_flags
->epsilon
= e
;
170 bit_flags
->omega
= o
;
173 /*****************************************************************
174 * INIT_BIT_FLAGS_SHORT :
175 * Initializes a bit_flags_short_t structure. Can call this function see
176 * the call command behavior when integer arguments do not fit into
177 * registers and must be placed on the stack.
178 * OUT struct bit_flags_short_t *bit_flags -- structure to be filled
179 * IN unsigned a -- 0 or 1
180 * IN unsigned b -- 0 or 1
181 * IN unsigned g -- 0 or 1
182 * IN unsigned d -- 0 or 1
183 * IN unsigned e -- 0 or 1
184 * IN unsigned o -- 0 or 1
185 *****************************************************************/
187 void init_bit_flags_short (
188 struct bit_flags_short_t
*bit_flags
,
196 void init_bit_flags_short (bit_flags
,a
,b
,g
,d
,e
,o
)
197 struct bit_flags_short_t
*bit_flags
;
207 bit_flags
->alpha
= a
;
209 bit_flags
->gamma
= g
;
210 bit_flags
->delta
= d
;
211 bit_flags
->epsilon
= e
;
212 bit_flags
->omega
= o
;
215 /*****************************************************************
217 * Initializes a bit_flags_t structure. Can call this function see
218 * the call command behavior when integer arguments do not fit into
219 * registers and must be placed on the stack.
220 * OUT struct bit_flags_t *bit_flags -- structure to be filled
221 * IN unsigned a -- 0 or 1
222 * IN unsigned b -- 0 or 1
223 * IN unsigned g -- 0 or 1
224 * IN unsigned d -- 0 or 1
225 * IN unsigned e -- 0 or 1
226 * IN unsigned o -- 0 or 1
227 *****************************************************************/
229 void init_bit_flags (
230 struct bit_flags_t
*bit_flags
,
238 void init_bit_flags (bit_flags
,a
,b
,g
,d
,e
,o
)
239 struct bit_flags_t
*bit_flags
;
249 bit_flags
->alpha
= a
;
251 bit_flags
->gamma
= g
;
252 bit_flags
->delta
= d
;
253 bit_flags
->epsilon
= e
;
254 bit_flags
->omega
= o
;
257 /*****************************************************************
258 * INIT_BIT_FLAGS_COMBO :
259 * Initializes a bit_flags_combo_t structure. Can call this function
260 * to see the call command behavior when integer and character arguments
261 * do not fit into registers and must be placed on the stack.
262 * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill
263 * IN unsigned a -- 0 or 1
264 * IN unsigned b -- 0 or 1
266 * IN unsigned g -- 0 or 1
267 * IN unsigned d -- 0 or 1
269 * IN unsigned e -- 0 or 1
270 * IN unsigned o -- 0 or 1
271 *****************************************************************/
273 void init_bit_flags_combo (
274 struct bit_flags_combo_t
*bit_flags_combo
,
284 void init_bit_flags_combo (bit_flags_combo
, a
, b
, ch1
, g
, d
, ch2
, e
, o
)
285 struct bit_flags_combo_t
*bit_flags_combo
;
297 bit_flags_combo
->alpha
= a
;
298 bit_flags_combo
->beta
= b
;
299 bit_flags_combo
->ch1
= ch1
;
300 bit_flags_combo
->gamma
= g
;
301 bit_flags_combo
->delta
= d
;
302 bit_flags_combo
->ch2
= ch2
;
303 bit_flags_combo
->epsilon
= e
;
304 bit_flags_combo
->omega
= o
;
308 /*****************************************************************
310 * OUT struct one_double_t *one_double -- structure to fill
312 *****************************************************************/
314 void init_one_double ( struct one_double_t
*one_double
, double init_val
)
316 void init_one_double (one_double
, init_val
)
317 struct one_double_t
*one_double
;
322 one_double
->double1
= init_val
;
325 /*****************************************************************
327 * OUT struct two_floats_t *two_floats -- structure to be filled
330 *****************************************************************/
332 void init_two_floats (
333 struct two_floats_t
*two_floats
,
337 void init_two_floats (two_floats
, init_val1
, init_val2
)
338 struct two_floats_t
*two_floats
;
344 two_floats
->float1
= init_val1
;
345 two_floats
->float2
= init_val2
;
348 /*****************************************************************
350 * OUT struct three_char_t *three_char -- structure to be filled
354 *****************************************************************/
356 void init_three_chars (
357 struct three_char_t
*three_char
,
362 void init_three_chars ( three_char
, init_val1
, init_val2
, init_val3
)
363 struct three_char_t
*three_char
;
370 three_char
->ch1
= init_val1
;
371 three_char
->ch2
= init_val2
;
372 three_char
->ch3
= init_val3
;
375 /*****************************************************************
377 * OUT struct five_char_t *five_char -- structure to be filled
383 *****************************************************************/
385 void init_five_chars (
386 struct five_char_t
*five_char
,
393 void init_five_chars ( five_char
, init_val1
, init_val2
, init_val3
, init_val4
, init_val5
)
394 struct five_char_t
*five_char
;
403 five_char
->ch1
= init_val1
;
404 five_char
->ch2
= init_val2
;
405 five_char
->ch3
= init_val3
;
406 five_char
->ch4
= init_val4
;
407 five_char
->ch5
= init_val5
;
410 /*****************************************************************
411 * INIT_INT_CHAR_COMBO :
412 * OUT struct int_char_combo_t *combo -- structure to be filled
415 *****************************************************************/
417 void init_int_char_combo (
418 struct int_char_combo_t
*combo
,
422 void init_int_char_combo ( combo
, init_val1
, init_val2
)
423 struct int_char_combo_t
*combo
;
429 combo
->int1
= init_val1
;
430 combo
->ch1
= init_val2
;
433 /*****************************************************************
435 * OUT struct small_rep_into_t *small_struct -- structure to be filled
437 *****************************************************************/
439 void init_struct_rep(
440 struct small_rep_info_t
*small_struct
,
443 void init_struct_rep( small_struct
, seed
)
444 struct small_rep_info_t
*small_struct
;
449 small_struct
->value
= 2 + (seed
*2);
450 small_struct
->head
= 0;
453 /*****************************************************************
454 * PRINT_BIT_FLAGS_CHAR :
455 * IN struct bit_flags_char_t bit_flags
456 ****************************************************************/
458 struct bit_flags_char_t
print_bit_flags_char (struct bit_flags_char_t bit_flags
)
460 struct bit_flags_char_t
print_bit_flags_char ( bit_flags
)
461 struct bit_flags_char_t bit_flags
;
465 if (bit_flags
.alpha
) printf("alpha\n");
466 if (bit_flags
.beta
) printf("beta\n");
467 if (bit_flags
.gamma
) printf("gamma\n");
468 if (bit_flags
.delta
) printf("delta\n");
469 if (bit_flags
.epsilon
) printf("epsilon\n");
470 if (bit_flags
.omega
) printf("omega\n");
475 /*****************************************************************
476 * PRINT_BIT_FLAGS_SHORT :
477 * IN struct bit_flags_short_t bit_flags
478 ****************************************************************/
480 struct bit_flags_short_t
print_bit_flags_short (struct bit_flags_short_t bit_flags
)
482 struct bit_flags_short_t
print_bit_flags_short ( bit_flags
)
483 struct bit_flags_short_t bit_flags
;
487 if (bit_flags
.alpha
) printf("alpha\n");
488 if (bit_flags
.beta
) printf("beta\n");
489 if (bit_flags
.gamma
) printf("gamma\n");
490 if (bit_flags
.delta
) printf("delta\n");
491 if (bit_flags
.epsilon
) printf("epsilon\n");
492 if (bit_flags
.omega
) printf("omega\n");
497 /*****************************************************************
499 * IN struct bit_flags_t bit_flags
500 ****************************************************************/
502 struct bit_flags_t
print_bit_flags (struct bit_flags_t bit_flags
)
504 struct bit_flags_t
print_bit_flags ( bit_flags
)
505 struct bit_flags_t bit_flags
;
509 if (bit_flags
.alpha
) printf("alpha\n");
510 if (bit_flags
.beta
) printf("beta\n");
511 if (bit_flags
.gamma
) printf("gamma\n");
512 if (bit_flags
.delta
) printf("delta\n");
513 if (bit_flags
.epsilon
) printf("epsilon\n");
514 if (bit_flags
.omega
) printf("omega\n");
519 /*****************************************************************
520 * PRINT_BIT_FLAGS_COMBO :
521 * IN struct bit_flags_combo_t bit_flags_combo
522 ****************************************************************/
524 struct bit_flags_combo_t
print_bit_flags_combo (struct bit_flags_combo_t bit_flags_combo
)
526 struct bit_flags_combo_t
print_bit_flags_combo ( bit_flags_combo
)
527 struct bit_flags_combo_t bit_flags_combo
;
531 if (bit_flags_combo
.alpha
) printf("alpha\n");
532 if (bit_flags_combo
.beta
) printf("beta\n");
533 if (bit_flags_combo
.gamma
) printf("gamma\n");
534 if (bit_flags_combo
.delta
) printf("delta\n");
535 if (bit_flags_combo
.epsilon
) printf("epsilon\n");
536 if (bit_flags_combo
.omega
) printf("omega\n");
537 printf("ch1: %c\tch2: %c\n", bit_flags_combo
.ch1
, bit_flags_combo
.ch2
);
538 return bit_flags_combo
;
542 /*****************************************************************
544 * IN struct one_double_t one_double
545 ****************************************************************/
547 struct one_double_t
print_one_double (struct one_double_t one_double
)
549 struct one_double_t
print_one_double ( one_double
)
550 struct one_double_t one_double
;
554 printf("Contents of one_double_t: \n\n");
555 printf("%f\n", one_double
.double1
);
560 /*****************************************************************
562 * IN struct two_floats_t two_floats
563 ****************************************************************/
565 struct two_floats_t
print_two_floats (struct two_floats_t two_floats
)
567 struct two_floats_t
print_two_floats ( two_floats
)
568 struct two_floats_t two_floats
;
572 printf("Contents of two_floats_t: \n\n");
573 printf("%f\t%f\n", two_floats
.float1
, two_floats
.float2
);
578 /*****************************************************************
579 * PRINT_THREE_CHARS :
580 * IN struct three_char_t three_char
581 ****************************************************************/
583 struct three_char_t
print_three_chars (struct three_char_t three_char
)
585 struct three_char_t
print_three_chars ( three_char
)
586 struct three_char_t three_char
;
590 printf("Contents of three_char_t: \n\n");
591 printf("%c\t%c\t%c\n", three_char
.ch1
, three_char
.ch2
, three_char
.ch3
);
596 /*****************************************************************
598 * IN struct five_char_t five_char
599 ****************************************************************/
601 struct five_char_t
print_five_chars (struct five_char_t five_char
)
603 struct five_char_t
print_five_chars ( five_char
)
604 struct five_char_t five_char
;
608 printf("Contents of five_char_t: \n\n");
609 printf("%c\t%c\t%c\t%c\t%c\n", five_char
.ch1
, five_char
.ch2
,
610 five_char
.ch3
, five_char
.ch4
,
616 /*****************************************************************
617 * PRINT_INT_CHAR_COMBO :
618 * IN struct int_char_combo_t int_char_combo
619 ****************************************************************/
621 struct int_char_combo_t
print_int_char_combo (struct int_char_combo_t int_char_combo
)
623 struct int_char_combo_t
print_int_char_combo ( int_char_combo
)
624 struct int_char_combo_t int_char_combo
;
628 printf("Contents of int_char_combo_t: \n\n");
629 printf("%d\t%c\n", int_char_combo
.int1
, int_char_combo
.ch1
);
630 return int_char_combo
;
634 /*****************************************************************
636 ****************************************************************/
638 struct small_rep_info_t
print_struct_rep(struct small_rep_info_t struct1
)
640 struct small_rep_info_t
print_struct_rep( struct1
)
641 struct small_rep_info_t struct1
;
645 printf("Contents of struct1: \n\n");
646 printf("%10d%10d\n", struct1
.value
, struct1
.head
);
656 struct array_rep_info_t
print_one_large_struct(struct array_rep_info_t linked_list1
)
658 struct array_rep_info_t
print_one_large_struct( linked_list1
)
659 struct array_rep_info_t linked_list1
;
664 printf("%10d%10d\n", linked_list1
.values
[0],
665 linked_list1
.next_index
[0]);
671 /*****************************************************************
673 * IN struct array_rep_info_t *linked_list
675 ****************************************************************/
677 void init_array_rep(struct array_rep_info_t
*linked_list
, int seed
)
679 void init_array_rep( linked_list
, seed
)
680 struct array_rep_info_t
*linked_list
;
687 for (index
= 0; index
< 10; index
++) {
689 linked_list
->values
[index
] = (2*index
) + (seed
*2);
690 linked_list
->next_index
[index
] = index
+ 1;
692 linked_list
->head
= 0;
698 /* variables for large structure testing
701 struct array_rep_info_t
*list1
;
703 /* variables for testing a small structures and a very long argument list
705 struct small_rep_info_t
*struct1
;
706 struct bit_flags_char_t
*cflags
;
707 struct bit_flags_short_t
*sflags
;
708 struct bit_flags_t
*flags
;
709 struct bit_flags_combo_t
*flags_combo
;
710 struct three_char_t
*three_char
;
711 struct five_char_t
*five_char
;
712 struct int_char_combo_t
*int_char_combo
;
713 struct one_double_t
*d1
;
714 struct two_floats_t
*f3
;
717 /* Allocate space for large structures
719 list1
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
721 /* Initialize large structures
723 init_array_rep(list1
, 2);
725 /* Print large structures
727 print_one_large_struct(*list1
);
729 /* Allocate space for small structures
731 struct1
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
732 cflags
= (struct bit_flags_char_t
*)malloc(sizeof(struct bit_flags_char_t
));
733 sflags
= (struct bit_flags_short_t
*)malloc(sizeof(struct bit_flags_short_t
));
734 flags
= (struct bit_flags_t
*)malloc(sizeof(struct bit_flags_t
));
735 flags_combo
= (struct bit_flags_combo_t
*)malloc(sizeof(struct bit_flags_combo_t
));
736 three_char
= (struct three_char_t
*)malloc(sizeof(struct three_char_t
));
737 five_char
= (struct five_char_t
*)malloc(sizeof(struct five_char_t
));
738 int_char_combo
= (struct int_char_combo_t
*)malloc(sizeof(struct int_char_combo_t
));
740 d1
= (struct one_double_t
*)malloc(sizeof(struct one_double_t
));
741 f3
= (struct two_floats_t
*)malloc(sizeof(struct two_floats_t
));
743 /* Initialize small structures
745 init_one_double ( d1
, 1.11111);
746 init_two_floats ( f3
, -2.345, 1.0);
747 init_bit_flags_char(cflags
, (unsigned)1, (unsigned)0, (unsigned)1,
748 (unsigned)0, (unsigned)1, (unsigned)0 );
749 init_bit_flags_short(sflags
, (unsigned)1, (unsigned)0, (unsigned)1,
750 (unsigned)0, (unsigned)1, (unsigned)0 );
751 init_bit_flags(flags
, (unsigned)1, (unsigned)0, (unsigned)1,
752 (unsigned)0, (unsigned)1, (unsigned)0 );
753 init_bit_flags_combo(flags_combo
, (unsigned)1, (unsigned)0, 'y',
754 (unsigned)1, (unsigned)0, 'n',
755 (unsigned)1, (unsigned)0 );
756 init_three_chars(three_char
, 'x', 'y', 'z');
757 init_five_chars(five_char
, 'h', 'e', 'l', 'l', 'o');
758 init_int_char_combo(int_char_combo
, 13, '!');
759 init_struct_rep(struct1
, 10);
762 /* Print small structures
764 print_one_double(*d1
);
765 print_two_floats(*f3
);
766 print_bit_flags_char(*cflags
);
767 print_bit_flags_short(*sflags
);
768 print_bit_flags(*flags
);
769 print_bit_flags_combo(*flags_combo
);
770 print_three_chars(*three_char
);
771 print_five_chars(*five_char
);
772 print_int_char_combo(*int_char_combo
);
773 print_struct_rep(*struct1
);