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