⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 call-ar-st.c

📁 这个是LINUX下的GDB调度工具的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>/************************************************************************** * TESTS : *   -- function arguments that are enumerated types *   -- small structure arguments ( <= 64 bits )  *            -- stored in registers *            -- stored on the stack *   -- large structure arguments ( > 64 bits ) *            -- stored in registers *            -- stored on the stack *   -- array arguments *   -- caller is a leaf routine : *            -- use the call command from within an init routine (i.e. *               init_bit_flags, init_bit_flags_combo, init_array_rep) *   -- caller doesn't have enough space for all the function arguments : *            -- call print_long_arg_list from inside print_small_structs ***************************************************************************//* Some enumerated types -- used to test that the structureal data type is * retrieved for function arguments with typedef data types. */typedef int id_int;typedef enum { 	      BLACK,	      BLUE,	      BROWN,	      ECRUE,	      GOLD,	      GRAY,	      GREEN,	      IVORY,	      MAUVE,	      ORANGE,	      PINK,	      PURPLE,	      RED,	      SILVER,	      TAN,	      VIOLET,	      WHITE,	      YELLOW} colors;/* A large structure (> 64 bits) used to test passing large structures as * parameters */struct array_rep_info_t {   int   next_index[10];    int   values[10];   int   head;};/***************************************************************************** * Small structures ( <= 64 bits). These are used to test passing small  * structures as parameters and test argument size promotion. *****************************************************************************/ /* 64 bits  */struct small_rep_info_t {   int   value;   int   head;};/* 6 bits : really fits in 8 bits and is promoted to 32 bits */struct bit_flags_t {       unsigned alpha   :1;       unsigned beta    :1;       unsigned gamma   :1;       unsigned delta   :1;       unsigned epsilon :1;       unsigned omega   :1;};/* 22 bits : really fits in 40 bits and is promoted to 64 bits */struct bit_flags_combo_t {       unsigned alpha   :1;       unsigned beta    :1;       char     ch1;       unsigned gamma   :1;       unsigned delta   :1;       char     ch2;       unsigned epsilon :1;       unsigned omega   :1;};/* 64 bits */struct one_double_t {       double double1;};/* 64 bits */struct two_floats_t {       float float1;       float float2;};/* 16 bits : promoted to 32 bits */struct two_char_t {       char ch1;       char ch2;};/* 24 bits : promoted to 32 bits */struct three_char_t {       char ch1;       char ch2;       char ch3;};/* 40 bits : promoted to 64 bits */struct five_char_t {       char ch1;       char ch2;       char ch3;       char ch4;       char ch5;};/* 40 bits : promoted to 64 bits */struct int_char_combo_t {       int  int1;       char ch1;};/***************************************************************** * PRINT_STUDENT_ID_SHIRT_COLOR :  * IN     id_int student       -- enumerated type * IN     colors shirt         -- enumerated type *****************************************************************/#ifdef PROTOTYPESvoid print_student_id_shirt_color (id_int student, colors shirt)#elsevoid print_student_id_shirt_color ( student, shirt )  id_int student; colors shirt;#endif{ printf("student id : %d\t", student); printf("shirt color : "); switch (shirt) {   case BLACK :  printf("BLACK\n"); 		 break;   case BLUE :   printf("BLUE\n");		 break;   case BROWN :  printf("BROWN\n");		 break;   case ECRUE :  printf("ECRUE\n");		 break;   case GOLD :   printf("GOLD\n");		 break;   case GRAY :   printf("GRAY\n");		 break;   case GREEN :  printf("GREEN\n");		 break;   case IVORY :  printf("IVORY\n");		 break;   case MAUVE :  printf("MAUVE\n");		 break;   case ORANGE : printf("ORANGE\n");		 break;   case PINK :   printf("PINK\n");		 break;   case PURPLE : printf("PURPLE\n");		 break;   case RED :    printf("RED\n");		 break;   case SILVER : printf("SILVER\n");		 break;   case TAN :    printf("TAN\n");		 break;   case VIOLET : printf("VIOLET\n");		 break;   case WHITE :  printf("WHITE\n");		 break;   case YELLOW : printf("YELLOW\n");		 break; }}/***************************************************************** * PRINT_CHAR_ARRAY :  * IN     char  array_c[]      -- character array  *****************************************************************/#ifdef PROTOTYPESvoid print_char_array (char array_c[])#elsevoid print_char_array ( array_c )      char    array_c[];#endif{  int index;  printf("array_c :\n");  printf("=========\n\n");  for (index = 0; index < 120; index++) {      printf("%1c", array_c[index]);       if ((index%50) == 0) printf("\n");  }  printf("\n\n");}/***************************************************************** * PRINT_DOUBLE_ARRAY :  * IN     double array_d[]      -- array of doubles *****************************************************************/#ifdef PROTOTYPESvoid print_double_array (double  array_d[])#elsevoid print_double_array (array_d)      double  array_d[];#endif{  int index;  printf("array_d :\n");  printf("=========\n\n");  for (index = 0; index < 9; index++) {      printf("%f  ", array_d[index]);       if ((index%8) == 0) printf("\n");  }  printf("\n\n");}/***************************************************************** * PRINT_FLOAT_ARRAY:  * IN     float array_f[]      -- array of floats  *****************************************************************/#ifdef PROTOTYPESvoid print_float_array (float array_f[])#elsevoid print_float_array ( array_f )     float array_f[];#endif{  int index;  printf("array_f :\n");  printf("=========\n\n");  for (index = 0; index < 15; index++) {      printf("%f  ", array_f[index]);       if ((index%8) == 0) printf("\n");  }  printf("\n\n");}/***************************************************************** * PRINT_INT_ARRAY:  * IN     int  array_i[]      -- array of integers  *****************************************************************/#ifdef PROTOTYPESvoid print_int_array (int array_i[])#elsevoid print_int_array ( array_i )     int array_i[];#endif{  int index;  printf("array_i :\n");  printf("=========\n\n");  for (index = 0; index < 50; index++) {      printf("%d  ", array_i[index]);       if ((index%8) == 0) printf("\n");  }  printf("\n\n");}/***************************************************************** * PRINT_ALL_ARRAYS:  * IN     int  array_i[]      -- array of integers  * IN     char array_c[]      -- array of characters  * IN     float array_f[]      -- array of floats  * IN     double array_d[]      -- array of doubles  *****************************************************************/#ifdef PROTOTYPESvoid print_all_arrays(int array_i[], char array_c[], float array_f[], double array_d[])#elsevoid print_all_arrays( array_i, array_c, array_f, array_d )     int array_i[];     char array_c[];     float array_f[];     double array_d[];#endif{  print_int_array(array_i);  print_char_array(array_c);  print_float_array(array_f);  print_double_array(array_d);}/***************************************************************** * LOOP_COUNT :  * A do nothing function. Used to provide a point at which calls can be made.   *****************************************************************/void loop_count () {     int index;     for (index=0; index<4; index++);}/***************************************************************** * COMPUTE_WITH_SMALL_STRUCTS :  * A do nothing function. Used to provide a point at which calls can be made.   * IN  int seed *****************************************************************/#ifdef PROTOTYPESvoid compute_with_small_structs (int seed)#elsevoid compute_with_small_structs ( seed )  int seed;#endif{     struct small_rep_info_t array[4];     int index;     for (index = 0; index < 4; index++) {         array[index].value = index*seed;	 array[index].head = (index+1)*seed;     }     for (index = 1; index < 4; index++) {	 array[index].value = array[index].value + array[index-1].value;	 array[index].head = array[index].head + array[index-1].head;     }}/***************************************************************** * INIT_BIT_FLAGS : * Initializes a bit_flags_t structure. Can call this function see * the call command behavior when integer arguments do not fit into * registers and must be placed on the stack. * OUT struct bit_flags_t *bit_flags -- structure to be filled * IN  unsigned a  -- 0 or 1  * IN  unsigned b  -- 0 or 1  * IN  unsigned g  -- 0 or 1  * IN  unsigned d  -- 0 or 1  * IN  unsigned e  -- 0 or 1  * IN  unsigned o  -- 0 or 1  *****************************************************************/#ifdef PROTOTYPESvoid init_bit_flags (struct bit_flags_t *bit_flags, unsigned a, unsigned b, unsigned g, unsigned d, unsigned e, unsigned o)#elsevoid init_bit_flags ( bit_flags, a, b, g, d, e, o )struct bit_flags_t *bit_flags;unsigned a;unsigned b;unsigned g;unsigned d;unsigned e;unsigned o; #endif{   bit_flags->alpha = a;   bit_flags->beta = b;   bit_flags->gamma = g;   bit_flags->delta = d;   bit_flags->epsilon = e;   bit_flags->omega = o;}/***************************************************************** * INIT_BIT_FLAGS_COMBO : * Initializes a bit_flags_combo_t structure. Can call this function * to see the call command behavior when integer and character arguments * do not fit into registers and must be placed on the stack. * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill * IN  unsigned a  -- 0 or 1  * IN  unsigned b  -- 0 or 1  * IN  char     ch1 * IN  unsigned g  -- 0 or 1  * IN  unsigned d  -- 0 or 1  * IN  char     ch2 * IN  unsigned e  -- 0 or 1  * IN  unsigned o  -- 0 or 1  *****************************************************************/#ifdef PROTOTYPESvoid 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)#elsevoid init_bit_flags_combo ( bit_flags_combo, a, b, ch1, g, d, ch2, e, o )     struct bit_flags_combo_t *bit_flags_combo;     unsigned a;     unsigned b;     char     ch1;     unsigned g;     unsigned d;     char     ch2;     unsigned e;     unsigned o; #endif{   bit_flags_combo->alpha = a;   bit_flags_combo->beta = b;   bit_flags_combo->ch1 = ch1;   bit_flags_combo->gamma = g;   bit_flags_combo->delta = d;   bit_flags_combo->ch2 = ch2;   bit_flags_combo->epsilon = e;   bit_flags_combo->omega = o;}/***************************************************************** * INIT_ONE_DOUBLE :  * OUT  struct one_double_t *one_double  -- structure to fill  * IN   double init_val *****************************************************************/#ifdef PROTOTYPESvoid init_one_double (struct one_double_t *one_double, double init_val)#elsevoid init_one_double ( one_double, init_val )     struct one_double_t *one_double;     double init_val; #endif{     one_double->double1  = init_val;}/***************************************************************** * INIT_TWO_FLOATS :  * OUT struct two_floats_t *two_floats -- structure to be filled * IN  float init_val1 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -