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