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 32 bits
45 /* 22 bits : really fits in 40 bits and is promoted to 64 bits
47 struct bit_flags_combo_t
{
72 /* 24 bits : promoted to 32 bits
80 /* 40 bits : promoted to 64 bits
90 /* 40 bits : promoted to 64 bits
92 struct int_char_combo_t
{
98 /*****************************************************************
100 * A do nothing function. Used to provide a point at which calls can be made.
101 *****************************************************************/
106 for (index
=0; index
<4; index
++);
109 /*****************************************************************
111 * Initializes a bit_flags_t structure. Can call this function see
112 * the call command behavior when integer arguments do not fit into
113 * registers and must be placed on the stack.
114 * OUT struct bit_flags_t *bit_flags -- structure to be filled
115 * IN unsigned a -- 0 or 1
116 * IN unsigned b -- 0 or 1
117 * IN unsigned g -- 0 or 1
118 * IN unsigned d -- 0 or 1
119 * IN unsigned e -- 0 or 1
120 * IN unsigned o -- 0 or 1
121 *****************************************************************/
122 void init_bit_flags (bit_flags
,a
,b
,g
,d
,e
,o
)
123 struct bit_flags_t
*bit_flags
;
132 bit_flags
->alpha
= a
;
134 bit_flags
->gamma
= g
;
135 bit_flags
->delta
= d
;
136 bit_flags
->epsilon
= e
;
137 bit_flags
->omega
= o
;
140 /*****************************************************************
141 * INIT_BIT_FLAGS_COMBO :
142 * Initializes a bit_flags_combo_t structure. Can call this function
143 * to see the call command behavior when integer and character arguments
144 * do not fit into registers and must be placed on the stack.
145 * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill
146 * IN unsigned a -- 0 or 1
147 * IN unsigned b -- 0 or 1
149 * IN unsigned g -- 0 or 1
150 * IN unsigned d -- 0 or 1
152 * IN unsigned e -- 0 or 1
153 * IN unsigned o -- 0 or 1
154 *****************************************************************/
155 void init_bit_flags_combo (bit_flags_combo
, a
, b
, ch1
, g
, d
, ch2
, e
, o
)
156 struct bit_flags_combo_t
*bit_flags_combo
;
167 bit_flags_combo
->alpha
= a
;
168 bit_flags_combo
->beta
= b
;
169 bit_flags_combo
->ch1
= ch1
;
170 bit_flags_combo
->gamma
= g
;
171 bit_flags_combo
->delta
= d
;
172 bit_flags_combo
->ch2
= ch2
;
173 bit_flags_combo
->epsilon
= e
;
174 bit_flags_combo
->omega
= o
;
178 /*****************************************************************
180 * OUT struct one_double_t *one_double -- structure to fill
182 *****************************************************************/
183 void init_one_double (one_double
, init_val
)
184 struct one_double_t
*one_double
;
188 one_double
->double1
= init_val
;
191 /*****************************************************************
193 * OUT struct two_floats_t *two_floats -- structure to be filled
196 *****************************************************************/
197 void init_two_floats (two_floats
, init_val1
, init_val2
)
198 struct two_floats_t
*two_floats
;
203 two_floats
->float1
= init_val1
;
204 two_floats
->float2
= init_val2
;
207 /*****************************************************************
209 * OUT struct three_char_t *three_char -- structure to be filled
213 *****************************************************************/
214 void init_three_chars ( three_char
, init_val1
, init_val2
, init_val3
)
215 struct three_char_t
*three_char
;
221 three_char
->ch1
= init_val1
;
222 three_char
->ch2
= init_val2
;
223 three_char
->ch3
= init_val3
;
226 /*****************************************************************
228 * OUT struct five_char_t *five_char -- structure to be filled
234 *****************************************************************/
235 void init_five_chars ( five_char
, init_val1
, init_val2
, init_val3
, init_val4
, init_val5
)
236 struct five_char_t
*five_char
;
244 five_char
->ch1
= init_val1
;
245 five_char
->ch2
= init_val2
;
246 five_char
->ch3
= init_val3
;
247 five_char
->ch4
= init_val4
;
248 five_char
->ch5
= init_val5
;
251 /*****************************************************************
252 * INIT_INT_CHAR_COMBO :
253 * OUT struct int_char_combo_t *combo -- structure to be filled
256 *****************************************************************/
257 void init_int_char_combo ( combo
, init_val1
, init_val2
)
258 struct int_char_combo_t
*combo
;
263 combo
->int1
= init_val1
;
264 combo
->ch1
= init_val2
;
267 /*****************************************************************
269 * OUT struct small_rep_into_t *small_struct -- structure to be filled
271 *****************************************************************/
272 void init_struct_rep( small_struct
, seed
)
273 struct small_rep_info_t
*small_struct
;
278 small_struct
->value
= 2 + (seed
*2);
279 small_struct
->head
= 0;
282 /*****************************************************************
284 * IN struct bit_flags_t bit_flags
285 ****************************************************************/
286 struct bit_flags_t
print_bit_flags ( bit_flags
)
287 struct bit_flags_t bit_flags
;
290 if (bit_flags
.alpha
) printf("alpha\n");
291 if (bit_flags
.beta
) printf("beta\n");
292 if (bit_flags
.gamma
) printf("gamma\n");
293 if (bit_flags
.delta
) printf("delta\n");
294 if (bit_flags
.epsilon
) printf("epsilon\n");
295 if (bit_flags
.omega
) printf("omega\n");
300 /*****************************************************************
301 * PRINT_BIT_FLAGS_COMBO :
302 * IN struct bit_flags_combo_t bit_flags_combo
303 ****************************************************************/
304 struct bit_flags_combo_t
print_bit_flags_combo ( bit_flags_combo
)
305 struct bit_flags_combo_t bit_flags_combo
;
308 if (bit_flags_combo
.alpha
) printf("alpha\n");
309 if (bit_flags_combo
.beta
) printf("beta\n");
310 if (bit_flags_combo
.gamma
) printf("gamma\n");
311 if (bit_flags_combo
.delta
) printf("delta\n");
312 if (bit_flags_combo
.epsilon
) printf("epsilon\n");
313 if (bit_flags_combo
.omega
) printf("omega\n");
314 printf("ch1: %c\tch2: %c\n", bit_flags_combo
.ch1
, bit_flags_combo
.ch2
);
315 return bit_flags_combo
;
319 /*****************************************************************
321 * IN struct one_double_t one_double
322 ****************************************************************/
323 struct one_double_t
print_one_double ( one_double
)
324 struct one_double_t one_double
;
327 printf("Contents of one_double_t: \n\n");
328 printf("%f\n", one_double
.double1
);
333 /*****************************************************************
335 * IN struct two_floats_t two_floats
336 ****************************************************************/
337 struct two_floats_t
print_two_floats ( two_floats
)
338 struct two_floats_t two_floats
;
341 printf("Contents of two_floats_t: \n\n");
342 printf("%f\t%f\n", two_floats
.float1
, two_floats
.float2
);
347 /*****************************************************************
348 * PRINT_THREE_CHARS :
349 * IN struct three_char_t three_char
350 ****************************************************************/
351 struct three_char_t
print_three_chars ( three_char
)
352 struct three_char_t three_char
;
355 printf("Contents of three_char_t: \n\n");
356 printf("%c\t%c\t%c\n", three_char
.ch1
, three_char
.ch2
, three_char
.ch3
);
361 /*****************************************************************
363 * IN struct five_char_t five_char
364 ****************************************************************/
365 struct five_char_t
print_five_chars ( five_char
)
366 struct five_char_t five_char
;
369 printf("Contents of five_char_t: \n\n");
370 printf("%c\t%c\t%c\t%c\t%c\n", five_char
.ch1
, five_char
.ch2
,
371 five_char
.ch3
, five_char
.ch4
,
377 /*****************************************************************
378 * PRINT_INT_CHAR_COMBO :
379 * IN struct int_char_combo_t int_char_combo
380 ****************************************************************/
381 struct int_char_combo_t
print_int_char_combo ( int_char_combo
)
382 struct int_char_combo_t int_char_combo
;
385 printf("Contents of int_char_combo_t: \n\n");
386 printf("%d\t%c\n", int_char_combo
.int1
, int_char_combo
.ch1
);
387 return int_char_combo
;
391 /*****************************************************************
393 ****************************************************************/
394 struct small_rep_info_t
print_struct_rep( struct1
)
395 struct small_rep_info_t struct1
;
399 printf("Contents of struct1: \n\n");
400 printf("%10d%10d\n", struct1
.value
, struct1
.head
);
409 struct array_rep_info_t
print_one_large_struct( linked_list1
)
410 struct array_rep_info_t linked_list1
;
414 printf("%10d%10d\n", linked_list1
.values
[0],
415 linked_list1
.next_index
[0]);
421 /*****************************************************************
423 * IN struct array_rep_info_t *linked_list
425 ****************************************************************/
426 void init_array_rep( linked_list
, seed
)
427 struct array_rep_info_t
*linked_list
;
434 for (index
= 0; index
< 10; index
++) {
436 linked_list
->values
[index
] = (2*index
) + (seed
*2);
437 linked_list
->next_index
[index
] = index
+ 1;
439 linked_list
->head
= 0;
445 /* variables for large structure testing
448 struct array_rep_info_t
*list1
;
450 /* variables for testing a small structures and a very long argument list
452 struct small_rep_info_t
*struct1
;
453 struct bit_flags_t
*flags
;
454 struct bit_flags_combo_t
*flags_combo
;
455 struct three_char_t
*three_char
;
456 struct five_char_t
*five_char
;
457 struct int_char_combo_t
*int_char_combo
;
458 struct one_double_t
*d1
;
459 struct two_floats_t
*f3
;
462 /* Allocate space for large structures
464 list1
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
466 /* Initialize large structures
468 init_array_rep(list1
, 2);
470 /* Print large structures
472 print_one_large_struct(*list1
);
474 /* Allocate space for small structures
476 struct1
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
477 flags
= (struct bit_flags_t
*)malloc(sizeof(struct bit_flags_t
));
478 flags_combo
= (struct bit_flags_combo_t
*)malloc(sizeof(struct bit_flags_combo_t
));
479 three_char
= (struct three_char_t
*)malloc(sizeof(struct three_char_t
));
480 five_char
= (struct five_char_t
*)malloc(sizeof(struct five_char_t
));
481 int_char_combo
= (struct int_char_combo_t
*)malloc(sizeof(struct int_char_combo_t
));
483 d1
= (struct one_double_t
*)malloc(sizeof(struct one_double_t
));
484 f3
= (struct two_floats_t
*)malloc(sizeof(struct two_floats_t
));
486 /* Initialize small structures
488 init_one_double ( d1
, 1.11111);
489 init_two_floats ( f3
, -2.345, 1.0);
490 init_bit_flags(flags
, (unsigned)1, (unsigned)0, (unsigned)1,
491 (unsigned)0, (unsigned)1, (unsigned)0 );
492 init_bit_flags_combo(flags_combo
, (unsigned)1, (unsigned)0, 'y',
493 (unsigned)1, (unsigned)0, 'n',
494 (unsigned)1, (unsigned)0 );
495 init_three_chars(three_char
, 'x', 'y', 'z');
496 init_five_chars(five_char
, 'h', 'e', 'l', 'l', 'o');
497 init_int_char_combo(int_char_combo
, 13, '!');
498 init_struct_rep(struct1
, 10);
501 /* Print small structures
503 print_one_double(*d1
);
504 print_two_floats(*f3
);
505 print_bit_flags(*flags
);
506 print_bit_flags_combo(*flags_combo
);
507 print_three_chars(*three_char
);
508 print_five_chars(*five_char
);
509 print_int_char_combo(*int_char_combo
);
510 print_struct_rep(*struct1
);