Home | History | Annotate | Line # | Download | only in gdb.base
call-ar-st.c revision 1.1
      1  1.1  christos 
      2  1.1  christos #include <stdio.h>
      3  1.1  christos #include <stdlib.h>
      4  1.1  christos #include <string.h>
      5  1.1  christos 
      6  1.1  christos /**************************************************************************
      7  1.1  christos  * TESTS :
      8  1.1  christos  *   -- function arguments that are enumerated types
      9  1.1  christos  *   -- small structure arguments ( <= 64 bits )
     10  1.1  christos  *            -- stored in registers
     11  1.1  christos  *            -- stored on the stack
     12  1.1  christos  *   -- large structure arguments ( > 64 bits )
     13  1.1  christos  *            -- stored in registers
     14  1.1  christos  *            -- stored on the stack
     15  1.1  christos  *   -- array arguments
     16  1.1  christos  *   -- caller is a leaf routine :
     17  1.1  christos  *            -- use the call command from within an init routine (i.e.
     18  1.1  christos  *               init_bit_flags, init_bit_flags_combo, init_array_rep)
     19  1.1  christos  *   -- caller doesn't have enough space for all the function arguments :
     20  1.1  christos  *            -- call print_long_arg_list from inside print_small_structs
     21  1.1  christos  ***************************************************************************/
     22  1.1  christos 
     23  1.1  christos /* Some enumerated types -- used to test that the structureal data type is
     24  1.1  christos  * retrieved for function arguments with typedef data types.
     25  1.1  christos  */
     26  1.1  christos typedef int id_int;
     27  1.1  christos 
     28  1.1  christos typedef enum {
     29  1.1  christos 	      BLACK,
     30  1.1  christos 	      BLUE,
     31  1.1  christos 	      BROWN,
     32  1.1  christos 	      ECRUE,
     33  1.1  christos 	      GOLD,
     34  1.1  christos 	      GRAY,
     35  1.1  christos 	      GREEN,
     36  1.1  christos 	      IVORY,
     37  1.1  christos 	      MAUVE,
     38  1.1  christos 	      ORANGE,
     39  1.1  christos 	      PINK,
     40  1.1  christos 	      PURPLE,
     41  1.1  christos 	      RED,
     42  1.1  christos 	      SILVER,
     43  1.1  christos 	      TAN,
     44  1.1  christos 	      VIOLET,
     45  1.1  christos 	      WHITE,
     46  1.1  christos 	      YELLOW} colors;
     47  1.1  christos 
     48  1.1  christos /* A large structure (> 64 bits) used to test passing large structures as
     49  1.1  christos  * parameters
     50  1.1  christos  */
     51  1.1  christos 
     52  1.1  christos struct array_rep_info_t {
     53  1.1  christos    int   next_index[10];
     54  1.1  christos    int   values[10];
     55  1.1  christos    int   head;
     56  1.1  christos };
     57  1.1  christos 
     58  1.1  christos /*****************************************************************************
     59  1.1  christos  * Small structures ( <= 64 bits). These are used to test passing small
     60  1.1  christos  * structures as parameters and test argument size promotion.
     61  1.1  christos  *****************************************************************************/
     62  1.1  christos 
     63  1.1  christos  /* 64 bits
     64  1.1  christos   */
     65  1.1  christos struct small_rep_info_t {
     66  1.1  christos    int   value;
     67  1.1  christos    int   head;
     68  1.1  christos };
     69  1.1  christos 
     70  1.1  christos /* 6 bits : really fits in 8 bits and is promoted to 32 bits
     71  1.1  christos  */
     72  1.1  christos struct bit_flags_t {
     73  1.1  christos        unsigned alpha   :1;
     74  1.1  christos        unsigned beta    :1;
     75  1.1  christos        unsigned gamma   :1;
     76  1.1  christos        unsigned delta   :1;
     77  1.1  christos        unsigned epsilon :1;
     78  1.1  christos        unsigned omega   :1;
     79  1.1  christos };
     80  1.1  christos 
     81  1.1  christos /* 22 bits : really fits in 40 bits and is promoted to 64 bits
     82  1.1  christos  */
     83  1.1  christos struct bit_flags_combo_t {
     84  1.1  christos        unsigned alpha   :1;
     85  1.1  christos        unsigned beta    :1;
     86  1.1  christos        char     ch1;
     87  1.1  christos        unsigned gamma   :1;
     88  1.1  christos        unsigned delta   :1;
     89  1.1  christos        char     ch2;
     90  1.1  christos        unsigned epsilon :1;
     91  1.1  christos        unsigned omega   :1;
     92  1.1  christos };
     93  1.1  christos 
     94  1.1  christos /* 64 bits
     95  1.1  christos  */
     96  1.1  christos struct one_double_t {
     97  1.1  christos        double double1;
     98  1.1  christos };
     99  1.1  christos 
    100  1.1  christos /* 64 bits
    101  1.1  christos  */
    102  1.1  christos struct two_floats_t {
    103  1.1  christos        float float1;
    104  1.1  christos        float float2;
    105  1.1  christos };
    106  1.1  christos 
    107  1.1  christos /* 16 bits : promoted to 32 bits
    108  1.1  christos  */
    109  1.1  christos struct two_char_t {
    110  1.1  christos        char ch1;
    111  1.1  christos        char ch2;
    112  1.1  christos };
    113  1.1  christos 
    114  1.1  christos /* 24 bits : promoted to 32 bits
    115  1.1  christos  */
    116  1.1  christos struct three_char_t {
    117  1.1  christos        char ch1;
    118  1.1  christos        char ch2;
    119  1.1  christos        char ch3;
    120  1.1  christos };
    121  1.1  christos 
    122  1.1  christos /* 40 bits : promoted to 64 bits
    123  1.1  christos  */
    124  1.1  christos struct five_char_t {
    125  1.1  christos        char ch1;
    126  1.1  christos        char ch2;
    127  1.1  christos        char ch3;
    128  1.1  christos        char ch4;
    129  1.1  christos        char ch5;
    130  1.1  christos };
    131  1.1  christos 
    132  1.1  christos /* 40 bits : promoted to 64 bits
    133  1.1  christos  */
    134  1.1  christos struct int_char_combo_t {
    135  1.1  christos        int  int1;
    136  1.1  christos        char ch1;
    137  1.1  christos };
    138  1.1  christos 
    139  1.1  christos /*****************************************************************
    140  1.1  christos  * PRINT_STUDENT_ID_SHIRT_COLOR :
    141  1.1  christos  * IN     id_int student       -- enumerated type
    142  1.1  christos  * IN     colors shirt         -- enumerated type
    143  1.1  christos  *****************************************************************/
    144  1.1  christos #ifdef PROTOTYPES
    145  1.1  christos void print_student_id_shirt_color (id_int student, colors shirt)
    146  1.1  christos #else
    147  1.1  christos void print_student_id_shirt_color ( student, shirt )
    148  1.1  christos  id_int student;
    149  1.1  christos  colors shirt;
    150  1.1  christos #endif
    151  1.1  christos {
    152  1.1  christos 
    153  1.1  christos  printf("student id : %d\t", student);
    154  1.1  christos  printf("shirt color : ");
    155  1.1  christos  switch (shirt) {
    156  1.1  christos    case BLACK :  printf("BLACK\n");
    157  1.1  christos 		 break;
    158  1.1  christos    case BLUE :   printf("BLUE\n");
    159  1.1  christos 		 break;
    160  1.1  christos    case BROWN :  printf("BROWN\n");
    161  1.1  christos 		 break;
    162  1.1  christos    case ECRUE :  printf("ECRUE\n");
    163  1.1  christos 		 break;
    164  1.1  christos    case GOLD :   printf("GOLD\n");
    165  1.1  christos 		 break;
    166  1.1  christos    case GRAY :   printf("GRAY\n");
    167  1.1  christos 		 break;
    168  1.1  christos    case GREEN :  printf("GREEN\n");
    169  1.1  christos 		 break;
    170  1.1  christos    case IVORY :  printf("IVORY\n");
    171  1.1  christos 		 break;
    172  1.1  christos    case MAUVE :  printf("MAUVE\n");
    173  1.1  christos 		 break;
    174  1.1  christos    case ORANGE : printf("ORANGE\n");
    175  1.1  christos 		 break;
    176  1.1  christos    case PINK :   printf("PINK\n");
    177  1.1  christos 		 break;
    178  1.1  christos    case PURPLE : printf("PURPLE\n");
    179  1.1  christos 		 break;
    180  1.1  christos    case RED :    printf("RED\n");
    181  1.1  christos 		 break;
    182  1.1  christos    case SILVER : printf("SILVER\n");
    183  1.1  christos 		 break;
    184  1.1  christos    case TAN :    printf("TAN\n");
    185  1.1  christos 		 break;
    186  1.1  christos    case VIOLET : printf("VIOLET\n");
    187  1.1  christos 		 break;
    188  1.1  christos    case WHITE :  printf("WHITE\n");
    189  1.1  christos 		 break;
    190  1.1  christos    case YELLOW : printf("YELLOW\n");
    191  1.1  christos 		 break;
    192  1.1  christos  }
    193  1.1  christos }
    194  1.1  christos 
    195  1.1  christos /*****************************************************************
    196  1.1  christos  * PRINT_CHAR_ARRAY :
    197  1.1  christos  * IN     char  array_c[]      -- character array
    198  1.1  christos  *****************************************************************/
    199  1.1  christos #ifdef PROTOTYPES
    200  1.1  christos void print_char_array (char array_c[])
    201  1.1  christos #else
    202  1.1  christos void print_char_array ( array_c )
    203  1.1  christos      char    array_c[];
    204  1.1  christos #endif
    205  1.1  christos {
    206  1.1  christos 
    207  1.1  christos   int index;
    208  1.1  christos 
    209  1.1  christos   printf("array_c :\n");
    210  1.1  christos   printf("=========\n\n");
    211  1.1  christos   for (index = 0; index < 120; index++) {
    212  1.1  christos       printf("%1c", array_c[index]);
    213  1.1  christos       if ((index%50) == 0) printf("\n");
    214  1.1  christos   }
    215  1.1  christos   printf("\n\n");
    216  1.1  christos }
    217  1.1  christos 
    218  1.1  christos /*****************************************************************
    219  1.1  christos  * PRINT_DOUBLE_ARRAY :
    220  1.1  christos  * IN     double array_d[]      -- array of doubles
    221  1.1  christos  *****************************************************************/
    222  1.1  christos #ifdef PROTOTYPES
    223  1.1  christos void print_double_array (double  array_d[])
    224  1.1  christos #else
    225  1.1  christos void print_double_array (array_d)
    226  1.1  christos      double  array_d[];
    227  1.1  christos #endif
    228  1.1  christos {
    229  1.1  christos 
    230  1.1  christos   int index;
    231  1.1  christos 
    232  1.1  christos   printf("array_d :\n");
    233  1.1  christos   printf("=========\n\n");
    234  1.1  christos   for (index = 0; index < 9; index++) {
    235  1.1  christos       printf("%f  ", array_d[index]);
    236  1.1  christos       if ((index%8) == 0) printf("\n");
    237  1.1  christos   }
    238  1.1  christos   printf("\n\n");
    239  1.1  christos }
    240  1.1  christos 
    241  1.1  christos /*****************************************************************
    242  1.1  christos  * PRINT_FLOAT_ARRAY:
    243  1.1  christos  * IN     float array_f[]      -- array of floats
    244  1.1  christos  *****************************************************************/
    245  1.1  christos #ifdef PROTOTYPES
    246  1.1  christos void print_float_array (float array_f[])
    247  1.1  christos #else
    248  1.1  christos void print_float_array ( array_f )
    249  1.1  christos      float array_f[];
    250  1.1  christos #endif
    251  1.1  christos {
    252  1.1  christos 
    253  1.1  christos   int index;
    254  1.1  christos 
    255  1.1  christos   printf("array_f :\n");
    256  1.1  christos   printf("=========\n\n");
    257  1.1  christos   for (index = 0; index < 15; index++) {
    258  1.1  christos       printf("%f  ", array_f[index]);
    259  1.1  christos       if ((index%8) == 0) printf("\n");
    260  1.1  christos 
    261  1.1  christos   }
    262  1.1  christos   printf("\n\n");
    263  1.1  christos }
    264  1.1  christos 
    265  1.1  christos /*****************************************************************
    266  1.1  christos  * PRINT_INT_ARRAY:
    267  1.1  christos  * IN     int  array_i[]      -- array of integers
    268  1.1  christos  *****************************************************************/
    269  1.1  christos #ifdef PROTOTYPES
    270  1.1  christos void print_int_array (int array_i[])
    271  1.1  christos #else
    272  1.1  christos void print_int_array ( array_i )
    273  1.1  christos      int array_i[];
    274  1.1  christos #endif
    275  1.1  christos {
    276  1.1  christos 
    277  1.1  christos   int index;
    278  1.1  christos 
    279  1.1  christos   printf("array_i :\n");
    280  1.1  christos   printf("=========\n\n");
    281  1.1  christos   for (index = 0; index < 50; index++) {
    282  1.1  christos       printf("%d  ", array_i[index]);
    283  1.1  christos       if ((index%8) == 0) printf("\n");
    284  1.1  christos   }
    285  1.1  christos   printf("\n\n");
    286  1.1  christos 
    287  1.1  christos }
    288  1.1  christos 
    289  1.1  christos /*****************************************************************
    290  1.1  christos  * PRINT_ALL_ARRAYS:
    291  1.1  christos  * IN     int  array_i[]      -- array of integers
    292  1.1  christos  * IN     char array_c[]      -- array of characters
    293  1.1  christos  * IN     float array_f[]      -- array of floats
    294  1.1  christos  * IN     double array_d[]      -- array of doubles
    295  1.1  christos  *****************************************************************/
    296  1.1  christos #ifdef PROTOTYPES
    297  1.1  christos void print_all_arrays(int array_i[], char array_c[], float array_f[], double array_d[])
    298  1.1  christos #else
    299  1.1  christos void print_all_arrays( array_i, array_c, array_f, array_d )
    300  1.1  christos      int array_i[];
    301  1.1  christos      char array_c[];
    302  1.1  christos      float array_f[];
    303  1.1  christos      double array_d[];
    304  1.1  christos #endif
    305  1.1  christos {
    306  1.1  christos   print_int_array(array_i);
    307  1.1  christos   print_char_array(array_c);
    308  1.1  christos   print_float_array(array_f);
    309  1.1  christos   print_double_array(array_d);
    310  1.1  christos }
    311  1.1  christos 
    312  1.1  christos /*****************************************************************
    313  1.1  christos  * LOOP_COUNT :
    314  1.1  christos  * A do nothing function. Used to provide a point at which calls can be made.
    315  1.1  christos  *****************************************************************/
    316  1.1  christos void loop_count () {
    317  1.1  christos 
    318  1.1  christos      int index;
    319  1.1  christos 
    320  1.1  christos      for (index=0; index<4; index++);
    321  1.1  christos }
    322  1.1  christos 
    323  1.1  christos /*****************************************************************
    324  1.1  christos  * COMPUTE_WITH_SMALL_STRUCTS :
    325  1.1  christos  * A do nothing function. Used to provide a point at which calls can be made.
    326  1.1  christos  * IN  int seed
    327  1.1  christos  *****************************************************************/
    328  1.1  christos #ifdef PROTOTYPES
    329  1.1  christos void compute_with_small_structs (int seed)
    330  1.1  christos #else
    331  1.1  christos void compute_with_small_structs ( seed )
    332  1.1  christos  int seed;
    333  1.1  christos #endif
    334  1.1  christos {
    335  1.1  christos 
    336  1.1  christos      struct small_rep_info_t array[4];
    337  1.1  christos      int index;
    338  1.1  christos 
    339  1.1  christos      for (index = 0; index < 4; index++) {
    340  1.1  christos          array[index].value = index*seed;
    341  1.1  christos 	 array[index].head = (index+1)*seed;
    342  1.1  christos      }
    343  1.1  christos 
    344  1.1  christos      for (index = 1; index < 4; index++) {
    345  1.1  christos 	 array[index].value = array[index].value + array[index-1].value;
    346  1.1  christos 	 array[index].head = array[index].head + array[index-1].head;
    347  1.1  christos      }
    348  1.1  christos }
    349  1.1  christos 
    350  1.1  christos /*****************************************************************
    351  1.1  christos  * INIT_BIT_FLAGS :
    352  1.1  christos  * Initializes a bit_flags_t structure. Can call this function see
    353  1.1  christos  * the call command behavior when integer arguments do not fit into
    354  1.1  christos  * registers and must be placed on the stack.
    355  1.1  christos  * OUT struct bit_flags_t *bit_flags -- structure to be filled
    356  1.1  christos  * IN  unsigned a  -- 0 or 1
    357  1.1  christos  * IN  unsigned b  -- 0 or 1
    358  1.1  christos  * IN  unsigned g  -- 0 or 1
    359  1.1  christos  * IN  unsigned d  -- 0 or 1
    360  1.1  christos  * IN  unsigned e  -- 0 or 1
    361  1.1  christos  * IN  unsigned o  -- 0 or 1
    362  1.1  christos  *****************************************************************/
    363  1.1  christos #ifdef PROTOTYPES
    364  1.1  christos void init_bit_flags (struct bit_flags_t *bit_flags, unsigned a, unsigned b, unsigned g, unsigned d, unsigned e, unsigned o)
    365  1.1  christos #else
    366  1.1  christos void init_bit_flags ( bit_flags, a, b, g, d, e, o )
    367  1.1  christos struct bit_flags_t *bit_flags;
    368  1.1  christos unsigned a;
    369  1.1  christos unsigned b;
    370  1.1  christos unsigned g;
    371  1.1  christos unsigned d;
    372  1.1  christos unsigned e;
    373  1.1  christos unsigned o;
    374  1.1  christos #endif
    375  1.1  christos {
    376  1.1  christos 
    377  1.1  christos    bit_flags->alpha = a;
    378  1.1  christos    bit_flags->beta = b;
    379  1.1  christos    bit_flags->gamma = g;
    380  1.1  christos    bit_flags->delta = d;
    381  1.1  christos    bit_flags->epsilon = e;
    382  1.1  christos    bit_flags->omega = o;
    383  1.1  christos }
    384  1.1  christos 
    385  1.1  christos /*****************************************************************
    386  1.1  christos  * INIT_BIT_FLAGS_COMBO :
    387  1.1  christos  * Initializes a bit_flags_combo_t structure. Can call this function
    388  1.1  christos  * to see the call command behavior when integer and character arguments
    389  1.1  christos  * do not fit into registers and must be placed on the stack.
    390  1.1  christos  * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill
    391  1.1  christos  * IN  unsigned a  -- 0 or 1
    392  1.1  christos  * IN  unsigned b  -- 0 or 1
    393  1.1  christos  * IN  char     ch1
    394  1.1  christos  * IN  unsigned g  -- 0 or 1
    395  1.1  christos  * IN  unsigned d  -- 0 or 1
    396  1.1  christos  * IN  char     ch2
    397  1.1  christos  * IN  unsigned e  -- 0 or 1
    398  1.1  christos  * IN  unsigned o  -- 0 or 1
    399  1.1  christos  *****************************************************************/
    400  1.1  christos #ifdef PROTOTYPES
    401  1.1  christos void 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)
    402  1.1  christos #else
    403  1.1  christos void init_bit_flags_combo ( bit_flags_combo, a, b, ch1, g, d, ch2, e, o )
    404  1.1  christos      struct bit_flags_combo_t *bit_flags_combo;
    405  1.1  christos      unsigned a;
    406  1.1  christos      unsigned b;
    407  1.1  christos      char     ch1;
    408  1.1  christos      unsigned g;
    409  1.1  christos      unsigned d;
    410  1.1  christos      char     ch2;
    411  1.1  christos      unsigned e;
    412  1.1  christos      unsigned o;
    413  1.1  christos #endif
    414  1.1  christos {
    415  1.1  christos 
    416  1.1  christos    bit_flags_combo->alpha = a;
    417  1.1  christos    bit_flags_combo->beta = b;
    418  1.1  christos    bit_flags_combo->ch1 = ch1;
    419  1.1  christos    bit_flags_combo->gamma = g;
    420  1.1  christos    bit_flags_combo->delta = d;
    421  1.1  christos    bit_flags_combo->ch2 = ch2;
    422  1.1  christos    bit_flags_combo->epsilon = e;
    423  1.1  christos    bit_flags_combo->omega = o;
    424  1.1  christos }
    425  1.1  christos 
    426  1.1  christos 
    427  1.1  christos /*****************************************************************
    428  1.1  christos  * INIT_ONE_DOUBLE :
    429  1.1  christos  * OUT  struct one_double_t *one_double  -- structure to fill
    430  1.1  christos  * IN   double init_val
    431  1.1  christos  *****************************************************************/
    432  1.1  christos #ifdef PROTOTYPES
    433  1.1  christos void init_one_double (struct one_double_t *one_double, double init_val)
    434  1.1  christos #else
    435  1.1  christos void init_one_double ( one_double, init_val )
    436  1.1  christos      struct one_double_t *one_double;
    437  1.1  christos      double init_val;
    438  1.1  christos #endif
    439  1.1  christos {
    440  1.1  christos 
    441  1.1  christos      one_double->double1  = init_val;
    442  1.1  christos }
    443  1.1  christos 
    444  1.1  christos /*****************************************************************
    445  1.1  christos  * INIT_TWO_FLOATS :
    446  1.1  christos  * OUT struct two_floats_t *two_floats -- structure to be filled
    447  1.1  christos  * IN  float init_val1
    448  1.1  christos  * IN  float init_val2
    449  1.1  christos  *****************************************************************/
    450  1.1  christos #ifdef PROTOTYPES
    451  1.1  christos void init_two_floats (struct two_floats_t *two_floats, float init_val1, float init_val2)
    452  1.1  christos #else
    453  1.1  christos void init_two_floats ( two_floats, init_val1, init_val2 )
    454  1.1  christos      struct two_floats_t *two_floats;
    455  1.1  christos      float init_val1;
    456  1.1  christos      float init_val2;
    457  1.1  christos #endif
    458  1.1  christos {
    459  1.1  christos      two_floats->float1 = init_val1;
    460  1.1  christos      two_floats->float2 = init_val2;
    461  1.1  christos }
    462  1.1  christos 
    463  1.1  christos /*****************************************************************
    464  1.1  christos  * INIT_TWO_CHARS :
    465  1.1  christos  * OUT struct two_char_t *two_char -- structure to be filled
    466  1.1  christos  * IN  char init_val1
    467  1.1  christos  * IN  char init_val2
    468  1.1  christos  *****************************************************************/
    469  1.1  christos #ifdef PROTOTYPES
    470  1.1  christos void init_two_chars (struct two_char_t *two_char, char init_val1, char init_val2)
    471  1.1  christos #else
    472  1.1  christos void init_two_chars ( two_char, init_val1, init_val2 )
    473  1.1  christos      struct two_char_t *two_char;
    474  1.1  christos      char init_val1;
    475  1.1  christos      char init_val2;
    476  1.1  christos #endif
    477  1.1  christos {
    478  1.1  christos 
    479  1.1  christos      two_char->ch1 = init_val1;
    480  1.1  christos      two_char->ch2 = init_val2;
    481  1.1  christos }
    482  1.1  christos 
    483  1.1  christos /*****************************************************************
    484  1.1  christos  * INIT_THREE_CHARS :
    485  1.1  christos  * OUT struct three_char_t *three_char -- structure to be filled
    486  1.1  christos  * IN  char init_val1
    487  1.1  christos  * IN  char init_val2
    488  1.1  christos  * IN  char init_val3
    489  1.1  christos  *****************************************************************/
    490  1.1  christos #ifdef PROTOTYPES
    491  1.1  christos void init_three_chars (struct three_char_t *three_char, char init_val1, char init_val2, char init_val3)
    492  1.1  christos #else
    493  1.1  christos void init_three_chars ( three_char, init_val1, init_val2, init_val3 )
    494  1.1  christos      struct three_char_t *three_char;
    495  1.1  christos      char init_val1;
    496  1.1  christos      char init_val2;
    497  1.1  christos      char init_val3;
    498  1.1  christos #endif
    499  1.1  christos {
    500  1.1  christos 
    501  1.1  christos      three_char->ch1 = init_val1;
    502  1.1  christos      three_char->ch2 = init_val2;
    503  1.1  christos      three_char->ch3 = init_val3;
    504  1.1  christos }
    505  1.1  christos 
    506  1.1  christos /*****************************************************************
    507  1.1  christos  * INIT_FIVE_CHARS :
    508  1.1  christos  * OUT struct five_char_t *five_char -- structure to be filled
    509  1.1  christos  * IN  char init_val1
    510  1.1  christos  * IN  char init_val2
    511  1.1  christos  * IN  char init_val3
    512  1.1  christos  * IN  char init_val4
    513  1.1  christos  * IN  char init_val5
    514  1.1  christos  *****************************************************************/
    515  1.1  christos #ifdef PROTOTYPES
    516  1.1  christos void init_five_chars (struct five_char_t *five_char, char init_val1, char init_val2, char init_val3, char init_val4, char init_val5)
    517  1.1  christos #else
    518  1.1  christos void init_five_chars ( five_char, init_val1, init_val2, init_val3,init_val4,init_val5 )
    519  1.1  christos      struct five_char_t *five_char;
    520  1.1  christos      char init_val1;
    521  1.1  christos      char init_val2;
    522  1.1  christos      char init_val3;
    523  1.1  christos      char init_val4;
    524  1.1  christos      char init_val5;
    525  1.1  christos #endif
    526  1.1  christos {
    527  1.1  christos      five_char->ch1 = init_val1;
    528  1.1  christos      five_char->ch2 = init_val2;
    529  1.1  christos      five_char->ch3 = init_val3;
    530  1.1  christos      five_char->ch4 = init_val4;
    531  1.1  christos      five_char->ch5 = init_val5;
    532  1.1  christos }
    533  1.1  christos 
    534  1.1  christos /*****************************************************************
    535  1.1  christos  * INIT_INT_CHAR_COMBO :
    536  1.1  christos  * OUT struct int_char_combo_t *combo -- structure to be filled
    537  1.1  christos  * IN  int  init_val1
    538  1.1  christos  * IN  char init_val2
    539  1.1  christos  *****************************************************************/
    540  1.1  christos #ifdef PROTOTYPES
    541  1.1  christos void init_int_char_combo (struct int_char_combo_t *combo, int init_val1, char init_val2)
    542  1.1  christos #else
    543  1.1  christos void init_int_char_combo ( combo, init_val1, init_val2 )
    544  1.1  christos      struct int_char_combo_t *combo;
    545  1.1  christos      int init_val1;
    546  1.1  christos      char init_val2;
    547  1.1  christos #endif
    548  1.1  christos {
    549  1.1  christos 
    550  1.1  christos      combo->int1 = init_val1;
    551  1.1  christos      combo->ch1 = init_val2;
    552  1.1  christos }
    553  1.1  christos 
    554  1.1  christos /*****************************************************************
    555  1.1  christos  * INIT_STRUCT_REP :
    556  1.1  christos  * OUT struct small_rep_into_t *small_struct -- structure to be filled
    557  1.1  christos  * IN  int  seed
    558  1.1  christos  *****************************************************************/
    559  1.1  christos #ifdef PROTOTYPES
    560  1.1  christos void init_struct_rep(struct small_rep_info_t *small_struct, int seed)
    561  1.1  christos #else
    562  1.1  christos void init_struct_rep( small_struct, seed )
    563  1.1  christos      struct small_rep_info_t *small_struct;
    564  1.1  christos      int    seed;
    565  1.1  christos #endif
    566  1.1  christos {
    567  1.1  christos 
    568  1.1  christos       small_struct->value = 2 + (seed*2);
    569  1.1  christos       small_struct->head = 0;
    570  1.1  christos }
    571  1.1  christos 
    572  1.1  christos /*****************************************************************
    573  1.1  christos  * INIT_SMALL_STRUCTS :
    574  1.1  christos  * Takes all the small structures as input and calls the appropriate
    575  1.1  christos  * initialization routine for each structure
    576  1.1  christos  *****************************************************************/
    577  1.1  christos #ifdef PROTOTYPES
    578  1.1  christos void init_small_structs (
    579  1.1  christos      struct small_rep_info_t  *struct1,
    580  1.1  christos      struct small_rep_info_t  *struct2,
    581  1.1  christos      struct small_rep_info_t  *struct3,
    582  1.1  christos      struct small_rep_info_t  *struct4,
    583  1.1  christos      struct bit_flags_t       *flags,
    584  1.1  christos      struct bit_flags_combo_t *flags_combo,
    585  1.1  christos      struct three_char_t      *three_char,
    586  1.1  christos      struct five_char_t       *five_char,
    587  1.1  christos      struct int_char_combo_t  *int_char_combo,
    588  1.1  christos      struct one_double_t      *d1,
    589  1.1  christos      struct one_double_t      *d2,
    590  1.1  christos      struct one_double_t      *d3,
    591  1.1  christos      struct two_floats_t      *f1,
    592  1.1  christos      struct two_floats_t      *f2,
    593  1.1  christos      struct two_floats_t      *f3)
    594  1.1  christos #else
    595  1.1  christos void init_small_structs (struct1, struct2, struct3,struct4,flags,flags_combo,
    596  1.1  christos three_char, five_char,int_char_combo, d1, d2,d3,f1,f2,f3)
    597  1.1  christos      struct small_rep_info_t  *struct1;
    598  1.1  christos      struct small_rep_info_t  *struct2;
    599  1.1  christos      struct small_rep_info_t  *struct3;
    600  1.1  christos      struct small_rep_info_t  *struct4;
    601  1.1  christos      struct bit_flags_t       *flags;
    602  1.1  christos      struct bit_flags_combo_t *flags_combo;
    603  1.1  christos      struct three_char_t      *three_char;
    604  1.1  christos      struct five_char_t       *five_char;
    605  1.1  christos      struct int_char_combo_t  *int_char_combo;
    606  1.1  christos      struct one_double_t      *d1;
    607  1.1  christos      struct one_double_t      *d2;
    608  1.1  christos      struct one_double_t      *d3;
    609  1.1  christos      struct two_floats_t      *f1;
    610  1.1  christos      struct two_floats_t      *f2;
    611  1.1  christos      struct two_floats_t      *f3;
    612  1.1  christos #endif
    613  1.1  christos {
    614  1.1  christos 
    615  1.1  christos      init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1,
    616  1.1  christos 		           (unsigned)0, (unsigned)1, (unsigned)0 );
    617  1.1  christos      init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y',
    618  1.1  christos 				       (unsigned)1, (unsigned)0, 'n',
    619  1.1  christos                     		       (unsigned)1, (unsigned)0 );
    620  1.1  christos      init_three_chars(three_char, 'a', 'b', 'c');
    621  1.1  christos      init_five_chars(five_char, 'l', 'm', 'n', 'o', 'p');
    622  1.1  christos      init_int_char_combo(int_char_combo, 123, 'z');
    623  1.1  christos      init_struct_rep(struct1, 2);
    624  1.1  christos      init_struct_rep(struct2, 4);
    625  1.1  christos      init_struct_rep(struct3, 5);
    626  1.1  christos      init_struct_rep(struct4, 6);
    627  1.1  christos      init_one_double ( d1, 10.5);
    628  1.1  christos      init_one_double ( d2, -3.375);
    629  1.1  christos      init_one_double ( d3, 675.09375);
    630  1.1  christos      init_two_floats ( f1, 45.234, 43.6);
    631  1.1  christos      init_two_floats ( f2, 78.01, 122.10);
    632  1.1  christos      init_two_floats ( f3, -1232.345, -199.21);
    633  1.1  christos }
    634  1.1  christos 
    635  1.1  christos /*****************************************************************
    636  1.1  christos  * PRINT_TEN_DOUBLES :
    637  1.1  christos  * ?????????????????????????????
    638  1.1  christos  ****************************************************************/
    639  1.1  christos #ifdef PROTOTYPES
    640  1.1  christos void print_ten_doubles (
    641  1.1  christos      double d1,
    642  1.1  christos      double d2,
    643  1.1  christos      double d3,
    644  1.1  christos      double d4,
    645  1.1  christos      double d5,
    646  1.1  christos      double d6,
    647  1.1  christos      double d7,
    648  1.1  christos      double d8,
    649  1.1  christos      double d9,
    650  1.1  christos      double d10)
    651  1.1  christos #else
    652  1.1  christos void print_ten_doubles ( d1, d2, d3, d4, d5, d6, d7, d8, d9, d10 )
    653  1.1  christos      double d1;
    654  1.1  christos      double d2;
    655  1.1  christos      double d3;
    656  1.1  christos      double d4;
    657  1.1  christos      double d5;
    658  1.1  christos      double d6;
    659  1.1  christos      double d7;
    660  1.1  christos      double d8;
    661  1.1  christos      double d9;
    662  1.1  christos      double d10;
    663  1.1  christos #endif
    664  1.1  christos {
    665  1.1  christos 
    666  1.1  christos   printf("Two Doubles : %f\t%f\n", d1, d2);
    667  1.1  christos   printf("Two Doubles : %f\t%f\n", d3, d4);
    668  1.1  christos   printf("Two Doubles : %f\t%f\n", d5, d6);
    669  1.1  christos   printf("Two Doubles : %f\t%f\n", d7, d8);
    670  1.1  christos   printf("Two Doubles : %f\t%f\n", d9, d10);
    671  1.1  christos }
    672  1.1  christos 
    673  1.1  christos /*****************************************************************
    674  1.1  christos  * PRINT_BIT_FLAGS :
    675  1.1  christos  * IN struct bit_flags_t bit_flags
    676  1.1  christos  ****************************************************************/
    677  1.1  christos #ifdef PROTOTYPES
    678  1.1  christos void print_bit_flags (struct bit_flags_t bit_flags)
    679  1.1  christos #else
    680  1.1  christos void print_bit_flags ( bit_flags )
    681  1.1  christos struct bit_flags_t bit_flags;
    682  1.1  christos #endif
    683  1.1  christos {
    684  1.1  christos 
    685  1.1  christos      if (bit_flags.alpha) printf("alpha\n");
    686  1.1  christos      if (bit_flags.beta) printf("beta\n");
    687  1.1  christos      if (bit_flags.gamma) printf("gamma\n");
    688  1.1  christos      if (bit_flags.delta) printf("delta\n");
    689  1.1  christos      if (bit_flags.epsilon) printf("epsilon\n");
    690  1.1  christos      if (bit_flags.omega) printf("omega\n");
    691  1.1  christos }
    692  1.1  christos 
    693  1.1  christos /*****************************************************************
    694  1.1  christos  * PRINT_BIT_FLAGS_COMBO :
    695  1.1  christos  * IN struct bit_flags_combo_t bit_flags_combo
    696  1.1  christos  ****************************************************************/
    697  1.1  christos #ifdef PROTOTYPES
    698  1.1  christos void print_bit_flags_combo (struct bit_flags_combo_t bit_flags_combo)
    699  1.1  christos #else
    700  1.1  christos void print_bit_flags_combo ( bit_flags_combo )
    701  1.1  christos      struct bit_flags_combo_t bit_flags_combo;
    702  1.1  christos #endif
    703  1.1  christos {
    704  1.1  christos 
    705  1.1  christos      if (bit_flags_combo.alpha) printf("alpha\n");
    706  1.1  christos      if (bit_flags_combo.beta) printf("beta\n");
    707  1.1  christos      if (bit_flags_combo.gamma) printf("gamma\n");
    708  1.1  christos      if (bit_flags_combo.delta) printf("delta\n");
    709  1.1  christos      if (bit_flags_combo.epsilon) printf("epsilon\n");
    710  1.1  christos      if (bit_flags_combo.omega) printf("omega\n");
    711  1.1  christos      printf("ch1: %c\tch2: %c\n", bit_flags_combo.ch1, bit_flags_combo.ch2);
    712  1.1  christos }
    713  1.1  christos 
    714  1.1  christos /*****************************************************************
    715  1.1  christos  * PRINT_ONE_DOUBLE :
    716  1.1  christos  * IN struct one_double_t one_double
    717  1.1  christos  ****************************************************************/
    718  1.1  christos #ifdef PROTOTYPES
    719  1.1  christos void print_one_double (struct one_double_t one_double)
    720  1.1  christos #else
    721  1.1  christos void print_one_double ( one_double )
    722  1.1  christos struct one_double_t one_double;
    723  1.1  christos #endif
    724  1.1  christos {
    725  1.1  christos 
    726  1.1  christos      printf("Contents of one_double_t: \n\n");
    727  1.1  christos      printf("%f\n", one_double.double1);
    728  1.1  christos }
    729  1.1  christos 
    730  1.1  christos /*****************************************************************
    731  1.1  christos  * PRINT_TWO_FLOATS :
    732  1.1  christos  * IN struct two_floats_t two_floats
    733  1.1  christos  ****************************************************************/
    734  1.1  christos #ifdef PROTOTYPES
    735  1.1  christos void print_two_floats (struct two_floats_t two_floats)
    736  1.1  christos #else
    737  1.1  christos void print_two_floats ( two_floats )
    738  1.1  christos struct two_floats_t two_floats;
    739  1.1  christos #endif
    740  1.1  christos {
    741  1.1  christos 
    742  1.1  christos      printf("Contents of two_floats_t: \n\n");
    743  1.1  christos      printf("%f\t%f\n", two_floats.float1, two_floats.float2);
    744  1.1  christos }
    745  1.1  christos 
    746  1.1  christos /*****************************************************************
    747  1.1  christos  * PRINT_TWO_CHARS :
    748  1.1  christos  * IN struct two_char_t two_char
    749  1.1  christos  ****************************************************************/
    750  1.1  christos #ifdef PROTOTYPES
    751  1.1  christos void print_two_chars (struct two_char_t two_char)
    752  1.1  christos #else
    753  1.1  christos void print_two_chars ( two_char )
    754  1.1  christos struct two_char_t two_char;
    755  1.1  christos #endif
    756  1.1  christos {
    757  1.1  christos 
    758  1.1  christos      printf("Contents of two_char_t: \n\n");
    759  1.1  christos      printf("%c\t%c\n", two_char.ch1, two_char.ch2);
    760  1.1  christos }
    761  1.1  christos 
    762  1.1  christos /*****************************************************************
    763  1.1  christos  * PRINT_THREE_CHARS :
    764  1.1  christos  * IN struct three_char_t three_char
    765  1.1  christos  ****************************************************************/
    766  1.1  christos #ifdef PROTOTYPES
    767  1.1  christos void print_three_chars (struct three_char_t three_char)
    768  1.1  christos #else
    769  1.1  christos void print_three_chars ( three_char )
    770  1.1  christos struct three_char_t three_char;
    771  1.1  christos #endif
    772  1.1  christos {
    773  1.1  christos 
    774  1.1  christos      printf("Contents of three_char_t: \n\n");
    775  1.1  christos      printf("%c\t%c\t%c\n", three_char.ch1, three_char.ch2, three_char.ch3);
    776  1.1  christos }
    777  1.1  christos 
    778  1.1  christos /*****************************************************************
    779  1.1  christos  * PRINT_FIVE_CHARS :
    780  1.1  christos  * IN struct five_char_t five_char
    781  1.1  christos  ****************************************************************/
    782  1.1  christos #ifdef PROTOTYPES
    783  1.1  christos void print_five_chars (struct five_char_t five_char)
    784  1.1  christos #else
    785  1.1  christos void print_five_chars ( five_char )
    786  1.1  christos struct five_char_t five_char;
    787  1.1  christos #endif
    788  1.1  christos {
    789  1.1  christos 
    790  1.1  christos      printf("Contents of five_char_t: \n\n");
    791  1.1  christos      printf("%c\t%c\t%c\t%c\t%c\n", five_char.ch1, five_char.ch2,
    792  1.1  christos 				    five_char.ch3, five_char.ch4,
    793  1.1  christos 				    five_char.ch5);
    794  1.1  christos }
    795  1.1  christos 
    796  1.1  christos /*****************************************************************
    797  1.1  christos  * PRINT_INT_CHAR_COMBO :
    798  1.1  christos  * IN struct int_char_combo_t int_char_combo
    799  1.1  christos  ****************************************************************/
    800  1.1  christos #ifdef PROTOTYPES
    801  1.1  christos void print_int_char_combo (struct int_char_combo_t int_char_combo)
    802  1.1  christos #else
    803  1.1  christos void print_int_char_combo ( int_char_combo )
    804  1.1  christos struct int_char_combo_t int_char_combo;
    805  1.1  christos #endif
    806  1.1  christos {
    807  1.1  christos 
    808  1.1  christos      printf("Contents of int_char_combo_t: \n\n");
    809  1.1  christos      printf("%d\t%c\n", int_char_combo.int1, int_char_combo.ch1);
    810  1.1  christos }
    811  1.1  christos 
    812  1.1  christos /*****************************************************************
    813  1.1  christos  * PRINT_STRUCT_REP :
    814  1.1  christos  * The last parameter must go onto the stack rather than into a register.
    815  1.1  christos  * This is a good function to call to test small structures.
    816  1.1  christos  * IN struct small_rep_info_t  struct1
    817  1.1  christos  * IN struct small_rep_info_t  struct2
    818  1.1  christos  * IN struct small_rep_info_t  struct3
    819  1.1  christos  ****************************************************************/
    820  1.1  christos #ifdef PROTOTYPES
    821  1.1  christos void print_struct_rep(
    822  1.1  christos      struct small_rep_info_t struct1,
    823  1.1  christos      struct small_rep_info_t struct2,
    824  1.1  christos      struct small_rep_info_t struct3)
    825  1.1  christos #else
    826  1.1  christos void print_struct_rep( struct1, struct2, struct3)
    827  1.1  christos      struct small_rep_info_t struct1;
    828  1.1  christos      struct small_rep_info_t struct2;
    829  1.1  christos      struct small_rep_info_t struct3;
    830  1.1  christos #endif
    831  1.1  christos {
    832  1.1  christos 
    833  1.1  christos 
    834  1.1  christos   printf("Contents of struct1: \n\n");
    835  1.1  christos   printf("%10d%10d\n", struct1.value, struct1.head);
    836  1.1  christos   printf("Contents of struct2: \n\n");
    837  1.1  christos   printf("%10d%10d\n", struct2.value, struct2.head);
    838  1.1  christos   printf("Contents of struct3: \n\n");
    839  1.1  christos   printf("%10d%10d\n", struct3.value, struct3.head);
    840  1.1  christos 
    841  1.1  christos }
    842  1.1  christos 
    843  1.1  christos /*****************************************************************
    844  1.1  christos  * SUM_STRUCT_PRINT :
    845  1.1  christos  * The last two parameters must go onto the stack rather than into a register.
    846  1.1  christos  * This is a good function to call to test small structures.
    847  1.1  christos  * IN struct small_rep_info_t  struct1
    848  1.1  christos  * IN struct small_rep_info_t  struct2
    849  1.1  christos  * IN struct small_rep_info_t  struct3
    850  1.1  christos  * IN struct small_rep_info_t  struct4
    851  1.1  christos  ****************************************************************/
    852  1.1  christos #ifdef PROTOTYPES
    853  1.1  christos void sum_struct_print (
    854  1.1  christos      int seed,
    855  1.1  christos      struct small_rep_info_t struct1,
    856  1.1  christos      struct small_rep_info_t struct2,
    857  1.1  christos      struct small_rep_info_t struct3,
    858  1.1  christos      struct small_rep_info_t struct4)
    859  1.1  christos #else
    860  1.1  christos void sum_struct_print ( seed, struct1, struct2, struct3, struct4)
    861  1.1  christos      int seed;
    862  1.1  christos      struct small_rep_info_t struct1;
    863  1.1  christos      struct small_rep_info_t struct2;
    864  1.1  christos      struct small_rep_info_t struct3;
    865  1.1  christos      struct small_rep_info_t struct4;
    866  1.1  christos #endif
    867  1.1  christos {
    868  1.1  christos      int sum;
    869  1.1  christos 
    870  1.1  christos      printf("Sum of the 4 struct values and seed : \n\n");
    871  1.1  christos      sum = seed + struct1.value + struct2.value + struct3.value + struct4.value;
    872  1.1  christos      printf("%10d\n", sum);
    873  1.1  christos }
    874  1.1  christos 
    875  1.1  christos /*****************************************************************
    876  1.1  christos  * PRINT_SMALL_STRUCTS :
    877  1.1  christos  * This is a good function to call to test small structures.
    878  1.1  christos  * All of the small structures of odd sizes (40 bits, 8bits, etc.)
    879  1.1  christos  * are pushed onto the stack.
    880  1.1  christos  ****************************************************************/
    881  1.1  christos #ifdef PROTOTYPES
    882  1.1  christos void print_small_structs (
    883  1.1  christos      struct small_rep_info_t  struct1,
    884  1.1  christos      struct small_rep_info_t  struct2,
    885  1.1  christos      struct small_rep_info_t  struct3,
    886  1.1  christos      struct small_rep_info_t  struct4,
    887  1.1  christos      struct bit_flags_t       flags,
    888  1.1  christos      struct bit_flags_combo_t flags_combo,
    889  1.1  christos      struct three_char_t      three_char,
    890  1.1  christos      struct five_char_t       five_char,
    891  1.1  christos      struct int_char_combo_t  int_char_combo,
    892  1.1  christos      struct one_double_t      d1,
    893  1.1  christos      struct one_double_t      d2,
    894  1.1  christos      struct one_double_t      d3,
    895  1.1  christos      struct two_floats_t      f1,
    896  1.1  christos      struct two_floats_t      f2,
    897  1.1  christos      struct two_floats_t      f3)
    898  1.1  christos #else
    899  1.1  christos void print_small_structs ( struct1, struct2, struct3,  struct4, flags,
    900  1.1  christos flags_combo, three_char, five_char, int_char_combo, d1, d2,d3,f1,f2,f3)
    901  1.1  christos      struct small_rep_info_t  struct1;
    902  1.1  christos      struct small_rep_info_t  struct2;
    903  1.1  christos      struct small_rep_info_t  struct3;
    904  1.1  christos      struct small_rep_info_t  struct4;
    905  1.1  christos      struct bit_flags_t       flags;
    906  1.1  christos      struct bit_flags_combo_t flags_combo;
    907  1.1  christos      struct three_char_t      three_char;
    908  1.1  christos      struct five_char_t       five_char;
    909  1.1  christos      struct int_char_combo_t  int_char_combo;
    910  1.1  christos      struct one_double_t      d1;
    911  1.1  christos      struct one_double_t      d2;
    912  1.1  christos      struct one_double_t      d3;
    913  1.1  christos      struct two_floats_t      f1;
    914  1.1  christos      struct two_floats_t      f2;
    915  1.1  christos      struct two_floats_t      f3;
    916  1.1  christos #endif
    917  1.1  christos {
    918  1.1  christos    print_bit_flags(flags);
    919  1.1  christos    print_bit_flags_combo(flags_combo);
    920  1.1  christos    print_three_chars(three_char);
    921  1.1  christos    print_five_chars(five_char);
    922  1.1  christos    print_int_char_combo(int_char_combo);
    923  1.1  christos    sum_struct_print(10, struct1, struct2, struct3, struct4);
    924  1.1  christos    print_struct_rep(struct1, struct2, struct3);
    925  1.1  christos    print_one_double(d1);
    926  1.1  christos    print_one_double(d2);
    927  1.1  christos    print_one_double(d3);
    928  1.1  christos    print_two_floats(f1);
    929  1.1  christos    print_two_floats(f2);
    930  1.1  christos    print_two_floats(f3);
    931  1.1  christos }
    932  1.1  christos 
    933  1.1  christos /*****************************************************************
    934  1.1  christos  * PRINT_LONG_ARG_LIST :
    935  1.1  christos  * This is a good function to call to test small structures.
    936  1.1  christos  * The first two parameters ( the doubles ) go into registers. The
    937  1.1  christos  * remaining arguments are pushed onto the stack. Depending on where
    938  1.1  christos  * print_long_arg_list is called from, the size of the argument list
    939  1.1  christos  * may force more space to be pushed onto the stack as part of the callers
    940  1.1  christos  * frame.
    941  1.1  christos  ****************************************************************/
    942  1.1  christos #ifdef PROTOTYPES
    943  1.1  christos void print_long_arg_list (
    944  1.1  christos      double a,
    945  1.1  christos      double b,
    946  1.1  christos      int c,
    947  1.1  christos      int d,
    948  1.1  christos      int e,
    949  1.1  christos      int f,
    950  1.1  christos      struct small_rep_info_t  struct1,
    951  1.1  christos      struct small_rep_info_t  struct2,
    952  1.1  christos      struct small_rep_info_t  struct3,
    953  1.1  christos      struct small_rep_info_t  struct4,
    954  1.1  christos      struct bit_flags_t       flags,
    955  1.1  christos      struct bit_flags_combo_t flags_combo,
    956  1.1  christos      struct three_char_t      three_char,
    957  1.1  christos      struct five_char_t       five_char,
    958  1.1  christos      struct int_char_combo_t  int_char_combo,
    959  1.1  christos      struct one_double_t      d1,
    960  1.1  christos      struct one_double_t      d2,
    961  1.1  christos      struct one_double_t      d3,
    962  1.1  christos      struct two_floats_t      f1,
    963  1.1  christos      struct two_floats_t      f2,
    964  1.1  christos      struct two_floats_t      f3)
    965  1.1  christos #else
    966  1.1  christos void print_long_arg_list ( a, b, c, d, e, f, struct1, struct2, struct3,
    967  1.1  christos struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1,d2,d3,
    968  1.1  christos f1, f2, f3 )
    969  1.1  christos      double a;
    970  1.1  christos      double b;
    971  1.1  christos      int c;
    972  1.1  christos      int d;
    973  1.1  christos      int e;
    974  1.1  christos      int f;
    975  1.1  christos      struct small_rep_info_t  struct1;
    976  1.1  christos      struct small_rep_info_t  struct2;
    977  1.1  christos      struct small_rep_info_t  struct3;
    978  1.1  christos      struct small_rep_info_t  struct4;
    979  1.1  christos      struct bit_flags_t       flags;
    980  1.1  christos      struct bit_flags_combo_t flags_combo;
    981  1.1  christos      struct three_char_t      three_char;
    982  1.1  christos      struct five_char_t       five_char;
    983  1.1  christos      struct int_char_combo_t  int_char_combo;
    984  1.1  christos      struct one_double_t      d1;
    985  1.1  christos      struct one_double_t      d2;
    986  1.1  christos      struct one_double_t      d3;
    987  1.1  christos      struct two_floats_t      f1;
    988  1.1  christos      struct two_floats_t      f2;
    989  1.1  christos      struct two_floats_t      f3;
    990  1.1  christos #endif
    991  1.1  christos {
    992  1.1  christos     printf("double : %f\n", a);
    993  1.1  christos     printf("double : %f\n", b);
    994  1.1  christos     printf("int : %d\n", c);
    995  1.1  christos     printf("int : %d\n", d);
    996  1.1  christos     printf("int : %d\n", e);
    997  1.1  christos     printf("int : %d\n", f);
    998  1.1  christos     print_small_structs( struct1, struct2, struct3, struct4, flags, flags_combo,
    999  1.1  christos 			 three_char, five_char, int_char_combo, d1, d2, d3,
   1000  1.1  christos 			 f1, f2, f3);
   1001  1.1  christos }
   1002  1.1  christos 
   1003  1.1  christos 
   1004  1.1  christos #ifdef PROTOTYPES
   1005  1.1  christos void print_one_large_struct (struct array_rep_info_t linked_list1)
   1006  1.1  christos #else
   1007  1.1  christos void print_one_large_struct( linked_list1 )
   1008  1.1  christos      struct array_rep_info_t linked_list1;
   1009  1.1  christos #endif
   1010  1.1  christos {
   1011  1.1  christos 
   1012  1.1  christos  /* printf("Contents of linked list1: \n\n");
   1013  1.1  christos   printf("Element Value | Index of Next Element\n");
   1014  1.1  christos   printf("-------------------------------------\n");
   1015  1.1  christos   printf("              |                      \n");*/
   1016  1.1  christos   /*for (index = 0; index < 10; index++) {*/
   1017  1.1  christos 
   1018  1.1  christos       printf("%10d%10d\n", linked_list1.values[0],
   1019  1.1  christos 			   linked_list1.next_index[0]);
   1020  1.1  christos   /*}*/
   1021  1.1  christos }
   1022  1.1  christos 
   1023  1.1  christos /*****************************************************************
   1024  1.1  christos  * PRINT_ARRAY_REP :
   1025  1.1  christos  * The three structure parameters should fit into registers.
   1026  1.1  christos  * IN struct array_rep_info_t linked_list1
   1027  1.1  christos  * IN struct array_rep_info_t linked_list2
   1028  1.1  christos  * IN struct array_rep_info_t linked_list3
   1029  1.1  christos  ****************************************************************/
   1030  1.1  christos #ifdef PROTOTYPES
   1031  1.1  christos void print_array_rep(
   1032  1.1  christos      struct array_rep_info_t linked_list1,
   1033  1.1  christos      struct array_rep_info_t linked_list2,
   1034  1.1  christos      struct array_rep_info_t linked_list3)
   1035  1.1  christos #else
   1036  1.1  christos void print_array_rep( linked_list1, linked_list2, linked_list3 )
   1037  1.1  christos      struct array_rep_info_t linked_list1;
   1038  1.1  christos      struct array_rep_info_t linked_list2;
   1039  1.1  christos      struct array_rep_info_t linked_list3;
   1040  1.1  christos #endif
   1041  1.1  christos {
   1042  1.1  christos 
   1043  1.1  christos   int index;
   1044  1.1  christos 
   1045  1.1  christos   printf("Contents of linked list1: \n\n");
   1046  1.1  christos   printf("Element Value | Index of Next Element\n");
   1047  1.1  christos   printf("-------------------------------------\n");
   1048  1.1  christos   printf("              |                      \n");
   1049  1.1  christos   for (index = 0; index < 10; index++) {
   1050  1.1  christos 
   1051  1.1  christos       printf("%10d%10d\n", linked_list1.values[index],
   1052  1.1  christos 			   linked_list1.next_index[index]);
   1053  1.1  christos   }
   1054  1.1  christos 
   1055  1.1  christos   printf("Contents of linked list2: \n\n");
   1056  1.1  christos   printf("Element Value | Index of Next Element\n");
   1057  1.1  christos   printf("-------------------------------------\n");
   1058  1.1  christos   printf("              |                      \n");
   1059  1.1  christos   for (index = 0; index < 10; index++) {
   1060  1.1  christos 
   1061  1.1  christos       printf("%10d%10d\n", linked_list2.values[index],
   1062  1.1  christos 			   linked_list2.next_index[index]);
   1063  1.1  christos   }
   1064  1.1  christos 
   1065  1.1  christos   printf("Contents of linked list3: \n\n");
   1066  1.1  christos   printf("Element Value | Index of Next Element\n");
   1067  1.1  christos   printf("-------------------------------------\n");
   1068  1.1  christos   printf("              |                      \n");
   1069  1.1  christos   for (index = 0; index < 10; index++) {
   1070  1.1  christos 
   1071  1.1  christos       printf("%10d%10d\n", linked_list3.values[index],
   1072  1.1  christos 			   linked_list3.next_index[index]);
   1073  1.1  christos   }
   1074  1.1  christos 
   1075  1.1  christos }
   1076  1.1  christos 
   1077  1.1  christos /*****************************************************************
   1078  1.1  christos  * SUM_ARRAY_PRINT :
   1079  1.1  christos  * The last structure parameter must be pushed onto the stack
   1080  1.1  christos  * IN int    seed
   1081  1.1  christos  * IN struct array_rep_info_t linked_list1
   1082  1.1  christos  * IN struct array_rep_info_t linked_list2
   1083  1.1  christos  * IN struct array_rep_info_t linked_list3
   1084  1.1  christos  * IN struct array_rep_info_t linked_list4
   1085  1.1  christos  ****************************************************************/
   1086  1.1  christos #ifdef PROTOTYPES
   1087  1.1  christos void sum_array_print (
   1088  1.1  christos      int seed,
   1089  1.1  christos      struct array_rep_info_t linked_list1,
   1090  1.1  christos      struct array_rep_info_t linked_list2,
   1091  1.1  christos      struct array_rep_info_t linked_list3,
   1092  1.1  christos      struct array_rep_info_t linked_list4)
   1093  1.1  christos #else
   1094  1.1  christos void sum_array_print ( seed, linked_list1, linked_list2, linked_list3,linked_list4)
   1095  1.1  christos      int seed;
   1096  1.1  christos      struct array_rep_info_t linked_list1;
   1097  1.1  christos      struct array_rep_info_t linked_list2;
   1098  1.1  christos      struct array_rep_info_t linked_list3;
   1099  1.1  christos      struct array_rep_info_t linked_list4;
   1100  1.1  christos #endif
   1101  1.1  christos {
   1102  1.1  christos      int index;
   1103  1.1  christos      int sum;
   1104  1.1  christos 
   1105  1.1  christos      printf("Sum of 4 arrays, by element (add in seed as well): \n\n");
   1106  1.1  christos      printf("Seed: %d\n", seed);
   1107  1.1  christos      printf("Element Index | Sum \n");
   1108  1.1  christos      printf("-------------------------\n");
   1109  1.1  christos      printf("              |          \n");
   1110  1.1  christos 
   1111  1.1  christos      for (index = 0; index < 10; index++) {
   1112  1.1  christos 
   1113  1.1  christos          sum = seed + linked_list1.values[index] + linked_list2.values[index] +
   1114  1.1  christos 	       linked_list3.values[index] + linked_list4.values[index];
   1115  1.1  christos          printf("%10d%10d\n", index, sum);
   1116  1.1  christos      }
   1117  1.1  christos }
   1118  1.1  christos 
   1119  1.1  christos /*****************************************************************
   1120  1.1  christos  * INIT_ARRAY_REP :
   1121  1.1  christos  * IN struct array_rep_info_t *linked_list
   1122  1.1  christos  * IN int    seed
   1123  1.1  christos  ****************************************************************/
   1124  1.1  christos #ifdef PROTOTYPES
   1125  1.1  christos void init_array_rep(
   1126  1.1  christos      struct array_rep_info_t *linked_list,
   1127  1.1  christos      int    seed)
   1128  1.1  christos #else
   1129  1.1  christos void init_array_rep( linked_list, seed )
   1130  1.1  christos      struct array_rep_info_t *linked_list;
   1131  1.1  christos      int    seed;
   1132  1.1  christos #endif
   1133  1.1  christos {
   1134  1.1  christos 
   1135  1.1  christos   int index;
   1136  1.1  christos 
   1137  1.1  christos   for (index = 0; index < 10; index++) {
   1138  1.1  christos 
   1139  1.1  christos       linked_list->values[index] = (2*index) + (seed*2);
   1140  1.1  christos       linked_list->next_index[index] = index + 1;
   1141  1.1  christos   }
   1142  1.1  christos   linked_list->head = 0;
   1143  1.1  christos }
   1144  1.1  christos 
   1145  1.1  christos 
   1146  1.1  christos int main ()  {
   1147  1.1  christos 
   1148  1.1  christos   /* variables for array and enumerated type testing
   1149  1.1  christos    */
   1150  1.1  christos   static char     char_array[121];
   1151  1.1  christos   static double   double_array[9];
   1152  1.1  christos   static float    float_array[15];
   1153  1.1  christos   static int      integer_array[50];
   1154  1.1  christos   static int      index;
   1155  1.1  christos   static id_int   student_id = 23;
   1156  1.1  christos   static colors   my_shirt = YELLOW;
   1157  1.1  christos 
   1158  1.1  christos   /* variables for large structure testing
   1159  1.1  christos    */
   1160  1.1  christos   static int number = 10;
   1161  1.1  christos   static struct array_rep_info_t *list1;
   1162  1.1  christos   static struct array_rep_info_t *list2;
   1163  1.1  christos   static struct array_rep_info_t *list3;
   1164  1.1  christos   static struct array_rep_info_t *list4;
   1165  1.1  christos 
   1166  1.1  christos   /* variables for testing a very long argument list
   1167  1.1  christos    */
   1168  1.1  christos    static double                    a;
   1169  1.1  christos    static double                    b;
   1170  1.1  christos    static int                       c;
   1171  1.1  christos    static int                       d;
   1172  1.1  christos    static int                       e;
   1173  1.1  christos    static int                       f;
   1174  1.1  christos 
   1175  1.1  christos   /* variables for testing a small structures and a very long argument list
   1176  1.1  christos    */
   1177  1.1  christos    static struct small_rep_info_t  *struct1;
   1178  1.1  christos    static struct small_rep_info_t  *struct2;
   1179  1.1  christos    static struct small_rep_info_t  *struct3;
   1180  1.1  christos    static struct small_rep_info_t  *struct4;
   1181  1.1  christos    static struct bit_flags_t       *flags;
   1182  1.1  christos    static struct bit_flags_combo_t *flags_combo;
   1183  1.1  christos    static struct three_char_t      *three_char;
   1184  1.1  christos    static struct five_char_t       *five_char;
   1185  1.1  christos    static struct int_char_combo_t  *int_char_combo;
   1186  1.1  christos    static struct one_double_t      *d1;
   1187  1.1  christos    static struct one_double_t      *d2;
   1188  1.1  christos    static struct one_double_t      *d3;
   1189  1.1  christos    static struct two_floats_t      *f1;
   1190  1.1  christos    static struct two_floats_t      *f2;
   1191  1.1  christos    static struct two_floats_t      *f3;
   1192  1.1  christos 
   1193  1.1  christos   /* Initialize arrays
   1194  1.1  christos    */
   1195  1.1  christos   for (index = 0; index < 120; index++) {
   1196  1.1  christos       if ((index%2) == 0) char_array[index] = 'Z';
   1197  1.1  christos 	 else char_array[index] = 'a';
   1198  1.1  christos   }
   1199  1.1  christos   char_array[120] = '\0';
   1200  1.1  christos 
   1201  1.1  christos   for (index = 0; index < 9; index++) {
   1202  1.1  christos       double_array[index] = index*23.4567;
   1203  1.1  christos   }
   1204  1.1  christos 
   1205  1.1  christos   for (index = 0; index < 15; index++) {
   1206  1.1  christos       float_array[index] = index/7.02;
   1207  1.1  christos   }
   1208  1.1  christos 
   1209  1.1  christos   for (index = 0; index < 50; index++) {
   1210  1.1  christos       integer_array[index] = -index;
   1211  1.1  christos   }
   1212  1.1  christos 
   1213  1.1  christos   /* Print arrays
   1214  1.1  christos    */
   1215  1.1  christos   print_char_array(char_array);
   1216  1.1  christos   print_double_array(double_array);
   1217  1.1  christos   print_float_array(float_array);
   1218  1.1  christos   print_student_id_shirt_color(student_id, my_shirt);
   1219  1.1  christos   print_int_array(integer_array);
   1220  1.1  christos   print_all_arrays(integer_array, char_array, float_array, double_array);
   1221  1.1  christos 
   1222  1.1  christos   /* Allocate space for large structures
   1223  1.1  christos    */
   1224  1.1  christos   list1 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));
   1225  1.1  christos   list2 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));
   1226  1.1  christos   list3 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));
   1227  1.1  christos   list4 = (struct array_rep_info_t *)malloc(sizeof(struct array_rep_info_t));
   1228  1.1  christos 
   1229  1.1  christos   /* Initialize large structures
   1230  1.1  christos    */
   1231  1.1  christos   init_array_rep(list1, 2);
   1232  1.1  christos   init_array_rep(list2, 4);
   1233  1.1  christos   init_array_rep(list3, 5);
   1234  1.1  christos   init_array_rep(list4, 10);
   1235  1.1  christos   printf("HELLO WORLD\n");
   1236  1.1  christos   printf("BYE BYE FOR NOW\n");
   1237  1.1  christos   printf("VERY GREEN GRASS\n");
   1238  1.1  christos 
   1239  1.1  christos   /* Print large structures
   1240  1.1  christos    */
   1241  1.1  christos   sum_array_print(10, *list1, *list2, *list3, *list4);
   1242  1.1  christos   print_array_rep(*list1, *list2, *list3);
   1243  1.1  christos   print_one_large_struct(*list1);
   1244  1.1  christos 
   1245  1.1  christos   /* Allocate space for small structures
   1246  1.1  christos    */
   1247  1.1  christos   struct1     = (struct small_rep_info_t  *)malloc(sizeof(struct small_rep_info_t));
   1248  1.1  christos   struct2     = (struct small_rep_info_t  *)malloc(sizeof(struct small_rep_info_t));
   1249  1.1  christos   struct3     = (struct small_rep_info_t  *)malloc(sizeof(struct small_rep_info_t));
   1250  1.1  christos   struct4     = (struct small_rep_info_t  *)malloc(sizeof(struct small_rep_info_t));
   1251  1.1  christos   flags       = (struct bit_flags_t *)malloc(sizeof(struct bit_flags_t));
   1252  1.1  christos   flags_combo = (struct bit_flags_combo_t *)malloc(sizeof(struct bit_flags_combo_t));
   1253  1.1  christos   three_char  = (struct three_char_t *)malloc(sizeof(struct three_char_t));
   1254  1.1  christos   five_char   = (struct five_char_t *)malloc(sizeof(struct five_char_t));
   1255  1.1  christos   int_char_combo = (struct int_char_combo_t *)malloc(sizeof(struct int_char_combo_t));
   1256  1.1  christos 
   1257  1.1  christos   d1 = (struct one_double_t *)malloc(sizeof(struct one_double_t));
   1258  1.1  christos   d2 = (struct one_double_t *)malloc(sizeof(struct one_double_t));
   1259  1.1  christos   d3 = (struct one_double_t *)malloc(sizeof(struct one_double_t));
   1260  1.1  christos 
   1261  1.1  christos   f1 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t));
   1262  1.1  christos   f2 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t));
   1263  1.1  christos   f3 = (struct two_floats_t *)malloc(sizeof(struct two_floats_t));
   1264  1.1  christos 
   1265  1.1  christos   /* Initialize small structures
   1266  1.1  christos    */
   1267  1.1  christos   init_small_structs ( struct1, struct2, struct3, struct4, flags,
   1268  1.1  christos 		       flags_combo, three_char, five_char, int_char_combo,
   1269  1.1  christos 		       d1, d2, d3, f1, f2, f3);
   1270  1.1  christos 
   1271  1.1  christos   /* Print small structures
   1272  1.1  christos    */
   1273  1.1  christos   print_small_structs ( *struct1, *struct2, *struct3, *struct4, *flags,
   1274  1.1  christos 			*flags_combo, *three_char, *five_char, *int_char_combo,
   1275  1.1  christos 			*d1, *d2, *d3, *f1, *f2, *f3);
   1276  1.1  christos 
   1277  1.1  christos   /* Print a very long arg list
   1278  1.1  christos    */
   1279  1.1  christos   a = 22.25;
   1280  1.1  christos   b = 33.375;
   1281  1.1  christos   c = 0;
   1282  1.1  christos   d = -25;
   1283  1.1  christos   e = 100;
   1284  1.1  christos   f = 2345;
   1285  1.1  christos 
   1286  1.1  christos   print_long_arg_list ( a, b, c, d, e, f, *struct1, *struct2, *struct3, *struct4,
   1287  1.1  christos 			*flags, *flags_combo, *three_char, *five_char, *int_char_combo,
   1288  1.1  christos 			*d1, *d2, *d3, *f1, *f2, *f3);
   1289  1.1  christos 
   1290  1.1  christos   /* Initialize small structures
   1291  1.1  christos    */
   1292  1.1  christos   init_one_double ( d1, 1.11111);
   1293  1.1  christos   init_one_double ( d2, -345.34);
   1294  1.1  christos   init_one_double ( d3, 546464.2);
   1295  1.1  christos   init_two_floats ( f1, 0.234, 453.1);
   1296  1.1  christos   init_two_floats ( f2, 78.345, 23.09);
   1297  1.1  christos   init_two_floats ( f3, -2.345, 1.0);
   1298  1.1  christos   init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1,
   1299  1.1  christos 		 (unsigned)0, (unsigned)1, (unsigned)0 );
   1300  1.1  christos   init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y',
   1301  1.1  christos 				     (unsigned)1, (unsigned)0, 'n',
   1302  1.1  christos 				     (unsigned)1, (unsigned)0 );
   1303  1.1  christos   init_three_chars(three_char, 'x', 'y', 'z');
   1304  1.1  christos   init_five_chars(five_char, 'h', 'e', 'l', 'l', 'o');
   1305  1.1  christos   init_int_char_combo(int_char_combo, 13, '!');
   1306  1.1  christos   init_struct_rep(struct1, 10);
   1307  1.1  christos   init_struct_rep(struct2, 20);
   1308  1.1  christos   init_struct_rep(struct3, 30);
   1309  1.1  christos   init_struct_rep(struct4, 40);
   1310  1.1  christos 
   1311  1.1  christos   compute_with_small_structs(35);
   1312  1.1  christos   loop_count();
   1313  1.1  christos   printf("HELLO WORLD\n");
   1314  1.1  christos   printf("BYE BYE FOR NOW\n");
   1315  1.1  christos   printf("VERY GREEN GRASS\n");
   1316  1.1  christos 
   1317  1.1  christos   /* Print small structures
   1318  1.1  christos    */
   1319  1.1  christos   print_one_double(*d1);
   1320  1.1  christos   print_one_double(*d2);
   1321  1.1  christos   print_one_double(*d3);
   1322  1.1  christos   print_two_floats(*f1);
   1323  1.1  christos   print_two_floats(*f2);
   1324  1.1  christos   print_two_floats(*f3);
   1325  1.1  christos   print_bit_flags(*flags);
   1326  1.1  christos   print_bit_flags_combo(*flags_combo);
   1327  1.1  christos   print_three_chars(*three_char);
   1328  1.1  christos   print_five_chars(*five_char);
   1329  1.1  christos   print_int_char_combo(*int_char_combo);
   1330  1.1  christos   sum_struct_print(10, *struct1, *struct2, *struct3, *struct4);
   1331  1.1  christos   print_struct_rep(*struct1, *struct2, *struct3);
   1332  1.1  christos 
   1333  1.1  christos   return 0;
   1334  1.1  christos }
   1335  1.1  christos 
   1336  1.1  christos 
   1337  1.1  christos 
   1338  1.1  christos 
   1339  1.1  christos 
   1340