1a1ba9ba4Schristos #include <stdio.h>
2a1ba9ba4Schristos #include <stdlib.h>
3a1ba9ba4Schristos #include <string.h>
4a1ba9ba4Schristos
5*b2396a7bSchristos #include "../lib/unbuffer_output.c"
6*b2396a7bSchristos
7a1ba9ba4Schristos /**************************************************************************
8a1ba9ba4Schristos * TESTS :
9a1ba9ba4Schristos * function returning large structures, which go on the stack
10a1ba9ba4Schristos * functions returning varied sized structs which go on in the registers.
11a1ba9ba4Schristos ***************************************************************************/
12a1ba9ba4Schristos
13a1ba9ba4Schristos
14a1ba9ba4Schristos /* A large structure (> 64 bits) used to test passing large structures as
15a1ba9ba4Schristos * parameters
16a1ba9ba4Schristos */
17a1ba9ba4Schristos
18a1ba9ba4Schristos struct array_rep_info_t {
19a1ba9ba4Schristos int next_index[10];
20a1ba9ba4Schristos int values[10];
21a1ba9ba4Schristos int head;
22a1ba9ba4Schristos };
23a1ba9ba4Schristos
24a1ba9ba4Schristos /*****************************************************************************
25a1ba9ba4Schristos * Small structures ( <= 64 bits). These are used to test passing small
26a1ba9ba4Schristos * structures as parameters and test argument size promotion.
27a1ba9ba4Schristos *****************************************************************************/
28a1ba9ba4Schristos
29a1ba9ba4Schristos /* 64 bits
30a1ba9ba4Schristos */
31a1ba9ba4Schristos struct small_rep_info_t {
32a1ba9ba4Schristos int value;
33a1ba9ba4Schristos int head;
34a1ba9ba4Schristos };
35a1ba9ba4Schristos
36a1ba9ba4Schristos /* 6 bits : really fits in 8 bits and is promoted to 8 bits
37a1ba9ba4Schristos */
38a1ba9ba4Schristos struct bit_flags_char_t {
39a1ba9ba4Schristos unsigned char alpha :1;
40a1ba9ba4Schristos unsigned char beta :1;
41a1ba9ba4Schristos unsigned char gamma :1;
42a1ba9ba4Schristos unsigned char delta :1;
43a1ba9ba4Schristos unsigned char epsilon :1;
44a1ba9ba4Schristos unsigned char omega :1;
45a1ba9ba4Schristos };
46a1ba9ba4Schristos
47a1ba9ba4Schristos /* 6 bits : really fits in 8 bits and is promoted to 16 bits
48a1ba9ba4Schristos */
49a1ba9ba4Schristos struct bit_flags_short_t {
50a1ba9ba4Schristos unsigned short alpha :1;
51a1ba9ba4Schristos unsigned short beta :1;
52a1ba9ba4Schristos unsigned short gamma :1;
53a1ba9ba4Schristos unsigned short delta :1;
54a1ba9ba4Schristos unsigned short epsilon :1;
55a1ba9ba4Schristos unsigned short omega :1;
56a1ba9ba4Schristos };
57a1ba9ba4Schristos
58a1ba9ba4Schristos /* 6 bits : really fits in 8 bits and is promoted to 32 bits
59a1ba9ba4Schristos */
60a1ba9ba4Schristos struct bit_flags_t {
61a1ba9ba4Schristos unsigned alpha :1;
62a1ba9ba4Schristos unsigned beta :1;
63a1ba9ba4Schristos unsigned gamma :1;
64a1ba9ba4Schristos unsigned delta :1;
65a1ba9ba4Schristos unsigned epsilon :1;
66a1ba9ba4Schristos unsigned omega :1;
67a1ba9ba4Schristos };
68a1ba9ba4Schristos
69a1ba9ba4Schristos /* 22 bits : really fits in 40 bits and is promoted to 64 bits
70a1ba9ba4Schristos */
71a1ba9ba4Schristos struct bit_flags_combo_t {
72a1ba9ba4Schristos unsigned alpha :1;
73a1ba9ba4Schristos unsigned beta :1;
74a1ba9ba4Schristos char ch1;
75a1ba9ba4Schristos unsigned gamma :1;
76a1ba9ba4Schristos unsigned delta :1;
77a1ba9ba4Schristos char ch2;
78a1ba9ba4Schristos unsigned epsilon :1;
79a1ba9ba4Schristos unsigned omega :1;
80a1ba9ba4Schristos };
81a1ba9ba4Schristos
82a1ba9ba4Schristos /* 64 bits
83a1ba9ba4Schristos */
84a1ba9ba4Schristos struct one_double_t {
85a1ba9ba4Schristos double double1;
86a1ba9ba4Schristos };
87a1ba9ba4Schristos
88a1ba9ba4Schristos /* 64 bits
89a1ba9ba4Schristos */
90a1ba9ba4Schristos struct two_floats_t {
91a1ba9ba4Schristos float float1;
92a1ba9ba4Schristos float float2;
93a1ba9ba4Schristos };
94a1ba9ba4Schristos
95a1ba9ba4Schristos
96a1ba9ba4Schristos /* 24 bits : promoted to 32 bits
97a1ba9ba4Schristos */
98a1ba9ba4Schristos struct three_char_t {
99a1ba9ba4Schristos char ch1;
100a1ba9ba4Schristos char ch2;
101a1ba9ba4Schristos char ch3;
102a1ba9ba4Schristos };
103a1ba9ba4Schristos
104a1ba9ba4Schristos /* 40 bits : promoted to 64 bits
105a1ba9ba4Schristos */
106a1ba9ba4Schristos struct five_char_t {
107a1ba9ba4Schristos char ch1;
108a1ba9ba4Schristos char ch2;
109a1ba9ba4Schristos char ch3;
110a1ba9ba4Schristos char ch4;
111a1ba9ba4Schristos char ch5;
112a1ba9ba4Schristos };
113a1ba9ba4Schristos
114a1ba9ba4Schristos /* 40 bits : promoted to 64 bits
115a1ba9ba4Schristos */
116a1ba9ba4Schristos struct int_char_combo_t {
117a1ba9ba4Schristos int int1;
118a1ba9ba4Schristos char ch1;
119a1ba9ba4Schristos };
120a1ba9ba4Schristos
121a1ba9ba4Schristos
122a1ba9ba4Schristos /*****************************************************************
123a1ba9ba4Schristos * LOOP_COUNT :
124a1ba9ba4Schristos * A do nothing function. Used to provide a point at which calls can be made.
125a1ba9ba4Schristos *****************************************************************/
loop_count()126a1ba9ba4Schristos void loop_count () {
127a1ba9ba4Schristos
128a1ba9ba4Schristos int index;
129a1ba9ba4Schristos
130a1ba9ba4Schristos for (index=0; index<4; index++); /* -break1- */
131a1ba9ba4Schristos }
132a1ba9ba4Schristos
133a1ba9ba4Schristos /*****************************************************************
134a1ba9ba4Schristos * INIT_BIT_FLAGS_CHAR :
135a1ba9ba4Schristos * Initializes a bit_flags_char_t structure. Can call this function see
136a1ba9ba4Schristos * the call command behavior when integer arguments do not fit into
137a1ba9ba4Schristos * registers and must be placed on the stack.
138a1ba9ba4Schristos * OUT struct bit_flags_char_t *bit_flags -- structure to be filled
139a1ba9ba4Schristos * IN unsigned a -- 0 or 1
140a1ba9ba4Schristos * IN unsigned b -- 0 or 1
141a1ba9ba4Schristos * IN unsigned g -- 0 or 1
142a1ba9ba4Schristos * IN unsigned d -- 0 or 1
143a1ba9ba4Schristos * IN unsigned e -- 0 or 1
144a1ba9ba4Schristos * IN unsigned o -- 0 or 1
145a1ba9ba4Schristos *****************************************************************/
init_bit_flags_char(struct bit_flags_char_t * bit_flags,unsigned a,unsigned b,unsigned g,unsigned d,unsigned e,unsigned o)146a1ba9ba4Schristos void init_bit_flags_char (
147a1ba9ba4Schristos struct bit_flags_char_t *bit_flags,
148a1ba9ba4Schristos unsigned a,
149a1ba9ba4Schristos unsigned b,
150a1ba9ba4Schristos unsigned g,
151a1ba9ba4Schristos unsigned d,
152a1ba9ba4Schristos unsigned e,
153a1ba9ba4Schristos unsigned o)
154a1ba9ba4Schristos {
155a1ba9ba4Schristos
156a1ba9ba4Schristos bit_flags->alpha = a;
157a1ba9ba4Schristos bit_flags->beta = b;
158a1ba9ba4Schristos bit_flags->gamma = g;
159a1ba9ba4Schristos bit_flags->delta = d;
160a1ba9ba4Schristos bit_flags->epsilon = e;
161a1ba9ba4Schristos bit_flags->omega = o;
162a1ba9ba4Schristos }
163a1ba9ba4Schristos
164a1ba9ba4Schristos /*****************************************************************
165a1ba9ba4Schristos * INIT_BIT_FLAGS_SHORT :
166a1ba9ba4Schristos * Initializes a bit_flags_short_t structure. Can call this function see
167a1ba9ba4Schristos * the call command behavior when integer arguments do not fit into
168a1ba9ba4Schristos * registers and must be placed on the stack.
169a1ba9ba4Schristos * OUT struct bit_flags_short_t *bit_flags -- structure to be filled
170a1ba9ba4Schristos * IN unsigned a -- 0 or 1
171a1ba9ba4Schristos * IN unsigned b -- 0 or 1
172a1ba9ba4Schristos * IN unsigned g -- 0 or 1
173a1ba9ba4Schristos * IN unsigned d -- 0 or 1
174a1ba9ba4Schristos * IN unsigned e -- 0 or 1
175a1ba9ba4Schristos * IN unsigned o -- 0 or 1
176a1ba9ba4Schristos *****************************************************************/
init_bit_flags_short(struct bit_flags_short_t * bit_flags,unsigned a,unsigned b,unsigned g,unsigned d,unsigned e,unsigned o)177a1ba9ba4Schristos void init_bit_flags_short (
178a1ba9ba4Schristos struct bit_flags_short_t *bit_flags,
179a1ba9ba4Schristos unsigned a,
180a1ba9ba4Schristos unsigned b,
181a1ba9ba4Schristos unsigned g,
182a1ba9ba4Schristos unsigned d,
183a1ba9ba4Schristos unsigned e,
184a1ba9ba4Schristos unsigned o)
185a1ba9ba4Schristos {
186a1ba9ba4Schristos
187a1ba9ba4Schristos bit_flags->alpha = a;
188a1ba9ba4Schristos bit_flags->beta = b;
189a1ba9ba4Schristos bit_flags->gamma = g;
190a1ba9ba4Schristos bit_flags->delta = d;
191a1ba9ba4Schristos bit_flags->epsilon = e;
192a1ba9ba4Schristos bit_flags->omega = o;
193a1ba9ba4Schristos }
194a1ba9ba4Schristos
195a1ba9ba4Schristos /*****************************************************************
196a1ba9ba4Schristos * INIT_BIT_FLAGS :
197a1ba9ba4Schristos * Initializes a bit_flags_t structure. Can call this function see
198a1ba9ba4Schristos * the call command behavior when integer arguments do not fit into
199a1ba9ba4Schristos * registers and must be placed on the stack.
200a1ba9ba4Schristos * OUT struct bit_flags_t *bit_flags -- structure to be filled
201a1ba9ba4Schristos * IN unsigned a -- 0 or 1
202a1ba9ba4Schristos * IN unsigned b -- 0 or 1
203a1ba9ba4Schristos * IN unsigned g -- 0 or 1
204a1ba9ba4Schristos * IN unsigned d -- 0 or 1
205a1ba9ba4Schristos * IN unsigned e -- 0 or 1
206a1ba9ba4Schristos * IN unsigned o -- 0 or 1
207a1ba9ba4Schristos *****************************************************************/
init_bit_flags(struct bit_flags_t * bit_flags,unsigned a,unsigned b,unsigned g,unsigned d,unsigned e,unsigned o)208a1ba9ba4Schristos void init_bit_flags (
209a1ba9ba4Schristos struct bit_flags_t *bit_flags,
210a1ba9ba4Schristos unsigned a,
211a1ba9ba4Schristos unsigned b,
212a1ba9ba4Schristos unsigned g,
213a1ba9ba4Schristos unsigned d,
214a1ba9ba4Schristos unsigned e,
215a1ba9ba4Schristos unsigned o)
216a1ba9ba4Schristos {
217a1ba9ba4Schristos
218a1ba9ba4Schristos bit_flags->alpha = a;
219a1ba9ba4Schristos bit_flags->beta = b;
220a1ba9ba4Schristos bit_flags->gamma = g;
221a1ba9ba4Schristos bit_flags->delta = d;
222a1ba9ba4Schristos bit_flags->epsilon = e;
223a1ba9ba4Schristos bit_flags->omega = o;
224a1ba9ba4Schristos }
225a1ba9ba4Schristos
226a1ba9ba4Schristos /*****************************************************************
227a1ba9ba4Schristos * INIT_BIT_FLAGS_COMBO :
228a1ba9ba4Schristos * Initializes a bit_flags_combo_t structure. Can call this function
229a1ba9ba4Schristos * to see the call command behavior when integer and character arguments
230a1ba9ba4Schristos * do not fit into registers and must be placed on the stack.
231a1ba9ba4Schristos * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill
232a1ba9ba4Schristos * IN unsigned a -- 0 or 1
233a1ba9ba4Schristos * IN unsigned b -- 0 or 1
234a1ba9ba4Schristos * IN char ch1
235a1ba9ba4Schristos * IN unsigned g -- 0 or 1
236a1ba9ba4Schristos * IN unsigned d -- 0 or 1
237a1ba9ba4Schristos * IN char ch2
238a1ba9ba4Schristos * IN unsigned e -- 0 or 1
239a1ba9ba4Schristos * IN unsigned o -- 0 or 1
240a1ba9ba4Schristos *****************************************************************/
init_bit_flags_combo(struct bit_flags_combo_t * bit_flags_combo,unsigned a,unsigned b,char ch1,unsigned g,unsigned d,char ch2,unsigned e,unsigned o)241a1ba9ba4Schristos void init_bit_flags_combo (
242a1ba9ba4Schristos struct bit_flags_combo_t *bit_flags_combo,
243a1ba9ba4Schristos unsigned a,
244a1ba9ba4Schristos unsigned b,
245a1ba9ba4Schristos char ch1,
246a1ba9ba4Schristos unsigned g,
247a1ba9ba4Schristos unsigned d,
248a1ba9ba4Schristos char ch2,
249a1ba9ba4Schristos unsigned e,
250a1ba9ba4Schristos unsigned o)
251a1ba9ba4Schristos {
252a1ba9ba4Schristos
253a1ba9ba4Schristos bit_flags_combo->alpha = a;
254a1ba9ba4Schristos bit_flags_combo->beta = b;
255a1ba9ba4Schristos bit_flags_combo->ch1 = ch1;
256a1ba9ba4Schristos bit_flags_combo->gamma = g;
257a1ba9ba4Schristos bit_flags_combo->delta = d;
258a1ba9ba4Schristos bit_flags_combo->ch2 = ch2;
259a1ba9ba4Schristos bit_flags_combo->epsilon = e;
260a1ba9ba4Schristos bit_flags_combo->omega = o;
261a1ba9ba4Schristos }
262a1ba9ba4Schristos
263a1ba9ba4Schristos
264a1ba9ba4Schristos /*****************************************************************
265a1ba9ba4Schristos * INIT_ONE_DOUBLE :
266a1ba9ba4Schristos * OUT struct one_double_t *one_double -- structure to fill
267a1ba9ba4Schristos * IN double init_val
268a1ba9ba4Schristos *****************************************************************/
init_one_double(struct one_double_t * one_double,double init_val)269a1ba9ba4Schristos void init_one_double ( struct one_double_t *one_double, double init_val)
270a1ba9ba4Schristos {
271a1ba9ba4Schristos
272a1ba9ba4Schristos one_double->double1 = init_val;
273a1ba9ba4Schristos }
274a1ba9ba4Schristos
275a1ba9ba4Schristos /*****************************************************************
276a1ba9ba4Schristos * INIT_TWO_FLOATS :
277a1ba9ba4Schristos * OUT struct two_floats_t *two_floats -- structure to be filled
278a1ba9ba4Schristos * IN float init_val1
279a1ba9ba4Schristos * IN float init_val2
280a1ba9ba4Schristos *****************************************************************/
init_two_floats(struct two_floats_t * two_floats,float init_val1,float init_val2)281a1ba9ba4Schristos void init_two_floats (
282a1ba9ba4Schristos struct two_floats_t *two_floats,
283a1ba9ba4Schristos float init_val1,
284a1ba9ba4Schristos float init_val2)
285a1ba9ba4Schristos {
286a1ba9ba4Schristos
287a1ba9ba4Schristos two_floats->float1 = init_val1;
288a1ba9ba4Schristos two_floats->float2 = init_val2;
289a1ba9ba4Schristos }
290a1ba9ba4Schristos
291a1ba9ba4Schristos /*****************************************************************
292a1ba9ba4Schristos * INIT_THREE_CHARS :
293a1ba9ba4Schristos * OUT struct three_char_t *three_char -- structure to be filled
294a1ba9ba4Schristos * IN char init_val1
295a1ba9ba4Schristos * IN char init_val2
296a1ba9ba4Schristos * IN char init_val3
297a1ba9ba4Schristos *****************************************************************/
init_three_chars(struct three_char_t * three_char,char init_val1,char init_val2,char init_val3)298a1ba9ba4Schristos void init_three_chars (
299a1ba9ba4Schristos struct three_char_t *three_char,
300a1ba9ba4Schristos char init_val1,
301a1ba9ba4Schristos char init_val2,
302a1ba9ba4Schristos char init_val3)
303a1ba9ba4Schristos {
304a1ba9ba4Schristos
305a1ba9ba4Schristos three_char->ch1 = init_val1;
306a1ba9ba4Schristos three_char->ch2 = init_val2;
307a1ba9ba4Schristos three_char->ch3 = init_val3;
308a1ba9ba4Schristos }
309a1ba9ba4Schristos
310a1ba9ba4Schristos /*****************************************************************
311a1ba9ba4Schristos * INIT_FIVE_CHARS :
312a1ba9ba4Schristos * OUT struct five_char_t *five_char -- structure to be filled
313a1ba9ba4Schristos * IN char init_val1
314a1ba9ba4Schristos * IN char init_val2
315a1ba9ba4Schristos * IN char init_val3
316a1ba9ba4Schristos * IN char init_val4
317a1ba9ba4Schristos * IN char init_val5
318a1ba9ba4Schristos *****************************************************************/
init_five_chars(struct five_char_t * five_char,char init_val1,char init_val2,char init_val3,char init_val4,char init_val5)319a1ba9ba4Schristos void init_five_chars (
320a1ba9ba4Schristos struct five_char_t *five_char,
321a1ba9ba4Schristos char init_val1,
322a1ba9ba4Schristos char init_val2,
323a1ba9ba4Schristos char init_val3,
324a1ba9ba4Schristos char init_val4,
325a1ba9ba4Schristos char init_val5)
326a1ba9ba4Schristos {
327a1ba9ba4Schristos
328a1ba9ba4Schristos five_char->ch1 = init_val1;
329a1ba9ba4Schristos five_char->ch2 = init_val2;
330a1ba9ba4Schristos five_char->ch3 = init_val3;
331a1ba9ba4Schristos five_char->ch4 = init_val4;
332a1ba9ba4Schristos five_char->ch5 = init_val5;
333a1ba9ba4Schristos }
334a1ba9ba4Schristos
335a1ba9ba4Schristos /*****************************************************************
336a1ba9ba4Schristos * INIT_INT_CHAR_COMBO :
337a1ba9ba4Schristos * OUT struct int_char_combo_t *combo -- structure to be filled
338a1ba9ba4Schristos * IN int init_val1
339a1ba9ba4Schristos * IN char init_val2
340a1ba9ba4Schristos *****************************************************************/
init_int_char_combo(struct int_char_combo_t * combo,int init_val1,char init_val2)341a1ba9ba4Schristos void init_int_char_combo (
342a1ba9ba4Schristos struct int_char_combo_t *combo,
343a1ba9ba4Schristos int init_val1,
344a1ba9ba4Schristos char init_val2)
345a1ba9ba4Schristos {
346a1ba9ba4Schristos
347a1ba9ba4Schristos combo->int1 = init_val1;
348a1ba9ba4Schristos combo->ch1 = init_val2;
349a1ba9ba4Schristos }
350a1ba9ba4Schristos
351a1ba9ba4Schristos /*****************************************************************
352a1ba9ba4Schristos * INIT_STRUCT_REP :
353a1ba9ba4Schristos * OUT struct small_rep_into_t *small_struct -- structure to be filled
354a1ba9ba4Schristos * IN int seed
355a1ba9ba4Schristos *****************************************************************/
init_struct_rep(struct small_rep_info_t * small_struct,int seed)356a1ba9ba4Schristos void init_struct_rep(
357a1ba9ba4Schristos struct small_rep_info_t *small_struct,
358a1ba9ba4Schristos int seed)
359a1ba9ba4Schristos {
360a1ba9ba4Schristos
361a1ba9ba4Schristos small_struct->value = 2 + (seed*2);
362a1ba9ba4Schristos small_struct->head = 0;
363a1ba9ba4Schristos }
364a1ba9ba4Schristos
365a1ba9ba4Schristos /*****************************************************************
366a1ba9ba4Schristos * PRINT_BIT_FLAGS_CHAR :
367a1ba9ba4Schristos * IN struct bit_flags_char_t bit_flags
368a1ba9ba4Schristos ****************************************************************/
print_bit_flags_char(struct bit_flags_char_t bit_flags)369a1ba9ba4Schristos struct bit_flags_char_t print_bit_flags_char (struct bit_flags_char_t bit_flags)
370a1ba9ba4Schristos {
371a1ba9ba4Schristos
372a1ba9ba4Schristos if (bit_flags.alpha) printf("alpha\n");
373a1ba9ba4Schristos if (bit_flags.beta) printf("beta\n");
374a1ba9ba4Schristos if (bit_flags.gamma) printf("gamma\n");
375a1ba9ba4Schristos if (bit_flags.delta) printf("delta\n");
376a1ba9ba4Schristos if (bit_flags.epsilon) printf("epsilon\n");
377a1ba9ba4Schristos if (bit_flags.omega) printf("omega\n");
378a1ba9ba4Schristos return bit_flags;
379a1ba9ba4Schristos
380a1ba9ba4Schristos }
381a1ba9ba4Schristos
382a1ba9ba4Schristos /*****************************************************************
383a1ba9ba4Schristos * PRINT_BIT_FLAGS_SHORT :
384a1ba9ba4Schristos * IN struct bit_flags_short_t bit_flags
385a1ba9ba4Schristos ****************************************************************/
print_bit_flags_short(struct bit_flags_short_t bit_flags)386a1ba9ba4Schristos struct bit_flags_short_t print_bit_flags_short (struct bit_flags_short_t bit_flags)
387a1ba9ba4Schristos {
388a1ba9ba4Schristos
389a1ba9ba4Schristos if (bit_flags.alpha) printf("alpha\n");
390a1ba9ba4Schristos if (bit_flags.beta) printf("beta\n");
391a1ba9ba4Schristos if (bit_flags.gamma) printf("gamma\n");
392a1ba9ba4Schristos if (bit_flags.delta) printf("delta\n");
393a1ba9ba4Schristos if (bit_flags.epsilon) printf("epsilon\n");
394a1ba9ba4Schristos if (bit_flags.omega) printf("omega\n");
395a1ba9ba4Schristos return bit_flags;
396a1ba9ba4Schristos
397a1ba9ba4Schristos }
398a1ba9ba4Schristos
399a1ba9ba4Schristos /*****************************************************************
400a1ba9ba4Schristos * PRINT_BIT_FLAGS :
401a1ba9ba4Schristos * IN struct bit_flags_t bit_flags
402a1ba9ba4Schristos ****************************************************************/
print_bit_flags(struct bit_flags_t bit_flags)403a1ba9ba4Schristos struct bit_flags_t print_bit_flags (struct bit_flags_t bit_flags)
404a1ba9ba4Schristos {
405a1ba9ba4Schristos
406a1ba9ba4Schristos if (bit_flags.alpha) printf("alpha\n");
407a1ba9ba4Schristos if (bit_flags.beta) printf("beta\n");
408a1ba9ba4Schristos if (bit_flags.gamma) printf("gamma\n");
409a1ba9ba4Schristos if (bit_flags.delta) printf("delta\n");
410a1ba9ba4Schristos if (bit_flags.epsilon) printf("epsilon\n");
411a1ba9ba4Schristos if (bit_flags.omega) printf("omega\n");
412a1ba9ba4Schristos return bit_flags;
413a1ba9ba4Schristos
414a1ba9ba4Schristos }
415a1ba9ba4Schristos
416a1ba9ba4Schristos /*****************************************************************
417a1ba9ba4Schristos * PRINT_BIT_FLAGS_COMBO :
418a1ba9ba4Schristos * IN struct bit_flags_combo_t bit_flags_combo
419a1ba9ba4Schristos ****************************************************************/
print_bit_flags_combo(struct bit_flags_combo_t bit_flags_combo)420a1ba9ba4Schristos struct bit_flags_combo_t print_bit_flags_combo (struct bit_flags_combo_t bit_flags_combo)
421a1ba9ba4Schristos {
422a1ba9ba4Schristos
423a1ba9ba4Schristos if (bit_flags_combo.alpha) printf("alpha\n");
424a1ba9ba4Schristos if (bit_flags_combo.beta) printf("beta\n");
425a1ba9ba4Schristos if (bit_flags_combo.gamma) printf("gamma\n");
426a1ba9ba4Schristos if (bit_flags_combo.delta) printf("delta\n");
427a1ba9ba4Schristos if (bit_flags_combo.epsilon) printf("epsilon\n");
428a1ba9ba4Schristos if (bit_flags_combo.omega) printf("omega\n");
429a1ba9ba4Schristos printf("ch1: %c\tch2: %c\n", bit_flags_combo.ch1, bit_flags_combo.ch2);
430a1ba9ba4Schristos return bit_flags_combo;
431a1ba9ba4Schristos
432a1ba9ba4Schristos }
433a1ba9ba4Schristos
434a1ba9ba4Schristos /*****************************************************************
435a1ba9ba4Schristos * PRINT_ONE_DOUBLE :
436a1ba9ba4Schristos * IN struct one_double_t one_double
437a1ba9ba4Schristos ****************************************************************/
print_one_double(struct one_double_t one_double)438a1ba9ba4Schristos struct one_double_t print_one_double (struct one_double_t one_double)
439a1ba9ba4Schristos {
440a1ba9ba4Schristos
441a1ba9ba4Schristos printf("Contents of one_double_t: \n\n");
442a1ba9ba4Schristos printf("%f\n", one_double.double1);
443a1ba9ba4Schristos return one_double;
444a1ba9ba4Schristos
445a1ba9ba4Schristos }
446a1ba9ba4Schristos
447a1ba9ba4Schristos /*****************************************************************
448a1ba9ba4Schristos * PRINT_TWO_FLOATS :
449a1ba9ba4Schristos * IN struct two_floats_t two_floats
450a1ba9ba4Schristos ****************************************************************/
print_two_floats(struct two_floats_t two_floats)451a1ba9ba4Schristos struct two_floats_t print_two_floats (struct two_floats_t two_floats)
452a1ba9ba4Schristos {
453a1ba9ba4Schristos
454a1ba9ba4Schristos printf("Contents of two_floats_t: \n\n");
455a1ba9ba4Schristos printf("%f\t%f\n", two_floats.float1, two_floats.float2);
456a1ba9ba4Schristos return two_floats;
457a1ba9ba4Schristos
458a1ba9ba4Schristos }
459a1ba9ba4Schristos
460a1ba9ba4Schristos /*****************************************************************
461a1ba9ba4Schristos * PRINT_THREE_CHARS :
462a1ba9ba4Schristos * IN struct three_char_t three_char
463a1ba9ba4Schristos ****************************************************************/
print_three_chars(struct three_char_t three_char)464a1ba9ba4Schristos struct three_char_t print_three_chars (struct three_char_t three_char)
465a1ba9ba4Schristos {
466a1ba9ba4Schristos
467a1ba9ba4Schristos printf("Contents of three_char_t: \n\n");
468a1ba9ba4Schristos printf("%c\t%c\t%c\n", three_char.ch1, three_char.ch2, three_char.ch3);
469a1ba9ba4Schristos return three_char;
470a1ba9ba4Schristos
471a1ba9ba4Schristos }
472a1ba9ba4Schristos
473a1ba9ba4Schristos /*****************************************************************
474a1ba9ba4Schristos * PRINT_FIVE_CHARS :
475a1ba9ba4Schristos * IN struct five_char_t five_char
476a1ba9ba4Schristos ****************************************************************/
print_five_chars(struct five_char_t five_char)477a1ba9ba4Schristos struct five_char_t print_five_chars (struct five_char_t five_char)
478a1ba9ba4Schristos {
479a1ba9ba4Schristos
480a1ba9ba4Schristos printf("Contents of five_char_t: \n\n");
481a1ba9ba4Schristos printf("%c\t%c\t%c\t%c\t%c\n", five_char.ch1, five_char.ch2,
482a1ba9ba4Schristos five_char.ch3, five_char.ch4,
483a1ba9ba4Schristos five_char.ch5);
484a1ba9ba4Schristos return five_char;
485a1ba9ba4Schristos
486a1ba9ba4Schristos }
487a1ba9ba4Schristos
488a1ba9ba4Schristos /*****************************************************************
489a1ba9ba4Schristos * PRINT_INT_CHAR_COMBO :
490a1ba9ba4Schristos * IN struct int_char_combo_t int_char_combo
491a1ba9ba4Schristos ****************************************************************/
print_int_char_combo(struct int_char_combo_t int_char_combo)492a1ba9ba4Schristos struct int_char_combo_t print_int_char_combo (struct int_char_combo_t int_char_combo)
493a1ba9ba4Schristos {
494a1ba9ba4Schristos
495a1ba9ba4Schristos printf("Contents of int_char_combo_t: \n\n");
496a1ba9ba4Schristos printf("%d\t%c\n", int_char_combo.int1, int_char_combo.ch1);
497a1ba9ba4Schristos return int_char_combo;
498a1ba9ba4Schristos
499a1ba9ba4Schristos }
500a1ba9ba4Schristos
501a1ba9ba4Schristos /*****************************************************************
502a1ba9ba4Schristos * PRINT_STRUCT_REP :
503a1ba9ba4Schristos ****************************************************************/
print_struct_rep(struct small_rep_info_t struct1)504a1ba9ba4Schristos struct small_rep_info_t print_struct_rep(struct small_rep_info_t struct1)
505a1ba9ba4Schristos {
506a1ba9ba4Schristos
507a1ba9ba4Schristos printf("Contents of struct1: \n\n");
508a1ba9ba4Schristos printf("%10d%10d\n", struct1.value, struct1.head);
509a1ba9ba4Schristos struct1.value =+5;
510a1ba9ba4Schristos
511a1ba9ba4Schristos return struct1;
512a1ba9ba4Schristos
513a1ba9ba4Schristos
514a1ba9ba4Schristos }
515a1ba9ba4Schristos
516a1ba9ba4Schristos
print_one_large_struct(struct array_rep_info_t linked_list1)517a1ba9ba4Schristos struct array_rep_info_t print_one_large_struct(struct array_rep_info_t linked_list1)
518a1ba9ba4Schristos {
519a1ba9ba4Schristos
520a1ba9ba4Schristos
521a1ba9ba4Schristos printf("%10d%10d\n", linked_list1.values[0],
522a1ba9ba4Schristos linked_list1.next_index[0]);
523a1ba9ba4Schristos
524a1ba9ba4Schristos return linked_list1;
525a1ba9ba4Schristos
526a1ba9ba4Schristos }
527a1ba9ba4Schristos
528a1ba9ba4Schristos /*****************************************************************
529a1ba9ba4Schristos * INIT_ARRAY_REP :
530a1ba9ba4Schristos * IN struct array_rep_info_t *linked_list
531a1ba9ba4Schristos * IN int seed
532a1ba9ba4Schristos ****************************************************************/
init_array_rep(struct array_rep_info_t * linked_list,int seed)533a1ba9ba4Schristos void init_array_rep(struct array_rep_info_t *linked_list, int seed)
534a1ba9ba4Schristos {
535a1ba9ba4Schristos
536a1ba9ba4Schristos int index;
537a1ba9ba4Schristos
538a1ba9ba4Schristos for (index = 0; index < 10; index++) {
539a1ba9ba4Schristos
540a1ba9ba4Schristos linked_list->values[index] = (2*index) + (seed*2);
541a1ba9ba4Schristos linked_list->next_index[index] = index + 1;
542a1ba9ba4Schristos }
543a1ba9ba4Schristos linked_list->head = 0;
544a1ba9ba4Schristos }
545a1ba9ba4Schristos
546a1ba9ba4Schristos
main()547a1ba9ba4Schristos int main () {
548a1ba9ba4Schristos
549a1ba9ba4Schristos /* variables for large structure testing
550a1ba9ba4Schristos */
551a1ba9ba4Schristos int number = 10;
552a1ba9ba4Schristos struct array_rep_info_t *list1;
553a1ba9ba4Schristos
554a1ba9ba4Schristos /* variables for testing a small structures and a very long argument list
555a1ba9ba4Schristos */
556a1ba9ba4Schristos struct small_rep_info_t *struct1;
557a1ba9ba4Schristos struct bit_flags_char_t *cflags;
558a1ba9ba4Schristos struct bit_flags_short_t *sflags;
559a1ba9ba4Schristos struct bit_flags_t *flags;
560a1ba9ba4Schristos struct bit_flags_combo_t *flags_combo;
561a1ba9ba4Schristos struct three_char_t *three_char;
562a1ba9ba4Schristos struct five_char_t *five_char;
563a1ba9ba4Schristos struct int_char_combo_t *int_char_combo;
564a1ba9ba4Schristos struct one_double_t *d1;
565a1ba9ba4Schristos struct two_floats_t *f3;
566a1ba9ba4Schristos
567*b2396a7bSchristos gdb_unbuffer_output ();
568a1ba9ba4Schristos
569a1ba9ba4Schristos /* Allocate space for large structures
570a1ba9ba4Schristos */
571a1ba9ba4Schristos list1 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));
572a1ba9ba4Schristos
573a1ba9ba4Schristos /* Initialize large structures
574a1ba9ba4Schristos */
575a1ba9ba4Schristos init_array_rep(list1, 2);
576a1ba9ba4Schristos
577a1ba9ba4Schristos /* Print large structures
578a1ba9ba4Schristos */
579a1ba9ba4Schristos print_one_large_struct(*list1);
580a1ba9ba4Schristos
581a1ba9ba4Schristos /* Allocate space for small structures
582a1ba9ba4Schristos */
583a1ba9ba4Schristos struct1 = (struct small_rep_info_t *)malloc(sizeof(struct small_rep_info_t));
584a1ba9ba4Schristos cflags = (struct bit_flags_char_t *)malloc(sizeof(struct bit_flags_char_t));
585a1ba9ba4Schristos sflags = (struct bit_flags_short_t *)malloc(sizeof(struct bit_flags_short_t));
586a1ba9ba4Schristos flags = (struct bit_flags_t *)malloc(sizeof(struct bit_flags_t));
587a1ba9ba4Schristos flags_combo = (struct bit_flags_combo_t *)malloc(sizeof(struct bit_flags_combo_t));
588a1ba9ba4Schristos three_char = (struct three_char_t *)malloc(sizeof(struct three_char_t));
589a1ba9ba4Schristos five_char = (struct five_char_t *)malloc(sizeof(struct five_char_t));
590a1ba9ba4Schristos int_char_combo = (struct int_char_combo_t *)malloc(sizeof(struct int_char_combo_t));
591a1ba9ba4Schristos
592a1ba9ba4Schristos d1 = (struct one_double_t *)malloc(sizeof(struct one_double_t));
593a1ba9ba4Schristos f3 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t));
594a1ba9ba4Schristos
595a1ba9ba4Schristos /* Initialize small structures
596a1ba9ba4Schristos */
597a1ba9ba4Schristos init_one_double ( d1, 1.11111);
598a1ba9ba4Schristos init_two_floats ( f3, -2.345, 1.0);
599a1ba9ba4Schristos init_bit_flags_char(cflags, (unsigned)1, (unsigned)0, (unsigned)1,
600a1ba9ba4Schristos (unsigned)0, (unsigned)1, (unsigned)0 );
601a1ba9ba4Schristos init_bit_flags_short(sflags, (unsigned)1, (unsigned)0, (unsigned)1,
602a1ba9ba4Schristos (unsigned)0, (unsigned)1, (unsigned)0 );
603a1ba9ba4Schristos init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1,
604a1ba9ba4Schristos (unsigned)0, (unsigned)1, (unsigned)0 );
605a1ba9ba4Schristos init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y',
606a1ba9ba4Schristos (unsigned)1, (unsigned)0, 'n',
607a1ba9ba4Schristos (unsigned)1, (unsigned)0 );
608a1ba9ba4Schristos init_three_chars(three_char, 'x', 'y', 'z');
609a1ba9ba4Schristos init_five_chars(five_char, 'h', 'e', 'l', 'l', 'o');
610a1ba9ba4Schristos init_int_char_combo(int_char_combo, 13, '!');
611a1ba9ba4Schristos init_struct_rep(struct1, 10);
612a1ba9ba4Schristos
613a1ba9ba4Schristos
614a1ba9ba4Schristos /* Print small structures
615a1ba9ba4Schristos */
616a1ba9ba4Schristos print_one_double(*d1);
617a1ba9ba4Schristos print_two_floats(*f3);
618a1ba9ba4Schristos print_bit_flags_char(*cflags);
619a1ba9ba4Schristos print_bit_flags_short(*sflags);
620a1ba9ba4Schristos print_bit_flags(*flags);
621a1ba9ba4Schristos print_bit_flags_combo(*flags_combo);
622a1ba9ba4Schristos print_three_chars(*three_char);
623a1ba9ba4Schristos print_five_chars(*five_char);
624a1ba9ba4Schristos print_int_char_combo(*int_char_combo);
625a1ba9ba4Schristos print_struct_rep(*struct1);
626a1ba9ba4Schristos
627a1ba9ba4Schristos loop_count(); /* -finish2- */
628a1ba9ba4Schristos
629a1ba9ba4Schristos return 0; /* -finish1- */
630a1ba9ba4Schristos }
631a1ba9ba4Schristos
632a1ba9ba4Schristos
633a1ba9ba4Schristos
634a1ba9ba4Schristos
635a1ba9ba4Schristos
636a1ba9ba4Schristos
637a1ba9ba4Schristos
638a1ba9ba4Schristos
639a1ba9ba4Schristos
640a1ba9ba4Schristos
641a1ba9ba4Schristos
642a1ba9ba4Schristos
643a1ba9ba4Schristos
644a1ba9ba4Schristos
645a1ba9ba4Schristos
646