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

📄 builtin-prefetch-2.c

📁 用于进行gcc测试
💻 C
字号:
/* Test that __builtin_prefetch does no harm.   Prefetch data using a variety of storage classes and address   expressions.  */int glob_int_arr[100];int *glob_ptr_int = glob_int_arr;int glob_int = 4;static stat_int_arr[100];static int *stat_ptr_int = stat_int_arr;static int stat_int;struct S {  int a;  short b, c;  char d[8];  struct S *next;};struct S str;struct S *ptr_str = &str;/* Prefetch global variables using the address of the variable.  */voidsimple_global (){  __builtin_prefetch (glob_int_arr, 0, 0);  __builtin_prefetch (glob_ptr_int, 0, 0);  __builtin_prefetch (&glob_int, 0, 0);}/* Prefetch file-level static variables using the address of the variable.  */voidsimple_file (){  __builtin_prefetch (stat_int_arr, 0, 0);  __builtin_prefetch (stat_ptr_int, 0, 0);  __builtin_prefetch (&stat_int, 0, 0);}/* Prefetch local static variables using the address of the variable.  */voidsimple_static_local (){  static int gx[100];  static int *hx = gx;  static int ix;  __builtin_prefetch (gx, 0, 0);  __builtin_prefetch (hx, 0, 0);  __builtin_prefetch (&ix, 0, 0);}/* Prefetch local stack variables using the address of the variable.  */voidsimple_local (){  int gx[100];  int *hx = gx;  int ix;  __builtin_prefetch (gx, 0, 0);  __builtin_prefetch (hx, 0, 0);  __builtin_prefetch (&ix, 0, 0);}/* Prefetch arguments using the address of the variable.  */voidsimple_arg (int g[100], int *h, int i){  __builtin_prefetch (g, 0, 0);  __builtin_prefetch (h, 0, 0);  __builtin_prefetch (&i, 0, 0);}/* Prefetch using address expressions involving global variables.  */voidexpr_global (void){  __builtin_prefetch (&str, 0, 0);  __builtin_prefetch (ptr_str, 0, 0);  __builtin_prefetch (&str.b, 0, 0);  __builtin_prefetch (&ptr_str->b, 0, 0);  __builtin_prefetch (&str.d, 0, 0);  __builtin_prefetch (&ptr_str->d, 0, 0);  __builtin_prefetch (str.next, 0, 0);  __builtin_prefetch (ptr_str->next, 0, 0);  __builtin_prefetch (str.next->d, 0, 0);  __builtin_prefetch (ptr_str->next->d, 0, 0);  __builtin_prefetch (&glob_int_arr, 0, 0);  __builtin_prefetch (glob_ptr_int, 0, 0);  __builtin_prefetch (&glob_int_arr[2], 0, 0);  __builtin_prefetch (&glob_ptr_int[3], 0, 0);  __builtin_prefetch (glob_int_arr+3, 0, 0);  __builtin_prefetch (glob_int_arr+glob_int, 0, 0);  __builtin_prefetch (glob_ptr_int+5, 0, 0);  __builtin_prefetch (glob_ptr_int+glob_int, 0, 0);}/* Prefetch using address expressions involving local variables.  */voidexpr_local (void){  int b[10];  int *pb = b;  struct S t;  struct S *pt = &t;  int j = 4;  __builtin_prefetch (&t, 0, 0);  __builtin_prefetch (pt, 0, 0);  __builtin_prefetch (&t.b, 0, 0);  __builtin_prefetch (&pt->b, 0, 0);  __builtin_prefetch (&t.d, 0, 0);  __builtin_prefetch (&pt->d, 0, 0);  __builtin_prefetch (t.next, 0, 0);  __builtin_prefetch (pt->next, 0, 0);  __builtin_prefetch (t.next->d, 0, 0);  __builtin_prefetch (pt->next->d, 0, 0);  __builtin_prefetch (&b, 0, 0);  __builtin_prefetch (pb, 0, 0);  __builtin_prefetch (&b[2], 0, 0);  __builtin_prefetch (&pb[3], 0, 0);  __builtin_prefetch (b+3, 0, 0);  __builtin_prefetch (b+j, 0, 0);  __builtin_prefetch (pb+5, 0, 0);  __builtin_prefetch (pb+j, 0, 0);}intmain (){  simple_global ();  simple_file ();  simple_static_local ();  simple_local ();  simple_arg (glob_int_arr, glob_ptr_int, glob_int);  str.next = &str;  expr_global ();  expr_local ();  exit (0);}

⌨️ 快捷键说明

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