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

📄 meas.c

📁 system C源码 一种替代verilog的语言
💻 C
📖 第 1 页 / 共 2 页
字号:
  t = t_alloc();  va_start (ap, nbytes);  t->qt = QT_VARGS (t->top, nbytes, ap, t, start, f, cleanup);  va_end (ap);  return (t);}  static voidtest09_cleanup (void *pt, void *vuserf_retval){  assert (vuserf_retval == (void *)17);  QT_ABORT (t_splat, &((thread_t *)pt)->qt, 0,	    ((thread_t *)pt)->next->qt);}  static voidtest09_start (void *pt){}  static void *test09_user0 (void){  QT_BLOCKI (t_splat, &test09_t0->qt, 0, test09_t1->qt);  return ((void *)17);}  static void *test09_user2 (int one, int two){  assert (one == 1);  assert (two == 2);  QT_BLOCKI (t_splat, &test09_t1->qt, 0, test09_t2->qt);  assert (one == 1);  assert (two == 2);  return ((void *)17);}  static void *test09_user10 (int one, int two, int three, int four, int five,	      int six, int seven, int eight, int nine, int ten){  assert (one == 1);  assert (two == 2);  assert (three == 3);  assert (four == 4);  assert (five == 5);  assert (six == 6);  assert (seven == 7);  assert (eight == 8);  assert (nine == 9);  assert (ten == 10);  QT_BLOCKI (t_splat, &test09_t2->qt, 0, test09_main->qt);  assert (one == 1);  assert (two == 2);  assert (three == 3);  assert (four == 4);  assert (five == 5);  assert (six == 6);  assert (seven == 7);  assert (eight == 8);  assert (nine == 9);  assert (ten == 10);  return ((void *)17);}  voidtest09 (int n){  thread_t main;  test09_main = &main;  while (--n >= 0) {    test09_t0 = test09_create (test09_start, (qt_vuserf_t*)test09_user0,			       test09_cleanup, 0);    test09_t1 = test09_create (test09_start, (qt_vuserf_t*)test09_user2,			       test09_cleanup, 2 * sizeof(qt_word_t), 1, 2);    test09_t2 = test09_create (test09_start, (qt_vuserf_t*)test09_user10,			       test09_cleanup, 10 * sizeof(qt_word_t),			       1, 2, 3, 4, 5, 6, 7, 8, 9, 10);    /* Chaining used by `test09_cleanup' to determine who is next. */    test09_t0->next = test09_t1;    test09_t1->next = test09_t2;    test09_t2->next = test09_main;    QT_BLOCKI (t_splat, &test09_main->qt, 0, test09_t0->qt);    QT_BLOCKI (t_splat, &test09_main->qt, 0, test09_t0->qt);    t_free (test09_t0);    t_free (test09_t1);    t_free (test09_t2);  }}/* Test 10/11/12: time the cost of various number of args. */char const test10_msg[] = { "*Test varargs init & startup w/ 0 args." };char const *test10_descr[] = {  "Start and stop threads that use variant argument lists (varargs).",  "Each thread is initialized by calling a routine that calls",  "QT_VARARGS.  Then runs the thread by calling QT_BLOCKI to hald the",  "main thread, a helper that saves the main thread's stack pointer,",  "a null startup function, a null user function, a cleanup function",  "that calls QT_ABORT and restarts the main thread.  Copies no user",  "parameters.",  ":: varargs start/stop = QT_BLOCKI + QT_ABORT + 6 function calls.",  NULL};/* Helper function to send control back to main.   Don't save anything. *//* Helper function for starting the varargs thread.  Save the stack   pointer of the main thread so we can get back there eventually. *//* Startup function for a varargs thread. */  static voidtest10_startup (void *pt){}/* User function for a varargs thread. */  static void *test10_run (int arg0, ...){  /* return (garbage); */}/* Cleanup function for a varargs thread.  Send control   back to the main thread.  Don't save any state from the thread that   is halting. */  voidtest10_cleanup (void *pt, void *vuserf_retval){  QT_ABORT (t_null, 0, 0, ((thread_t *)pt)->qt);}  voidtest10_init (thread_t *new, thread_t *next, int nbytes, ...){  va_list ap;  va_start (ap, nbytes);  new->qt = QT_VARGS (new->top, nbytes, ap, next, test10_startup,		      test10_run, test10_cleanup);  va_end (ap);}  voidtest10 (int n){  thread_t main;  thread_t *t;  t = t_alloc();  t->next = &main;  while (--n >= 0) {    test10_init (t, &main, 0);    QT_BLOCKI (t_splat, &main.qt, 0, t->qt);  }  t_free (t);}char const test11_msg[] = { "*Test varargs init & startup w/ 2 args." };char const *test11_descr[] = {  "Varargs initialization/run.  Copies 2 user arguments.",  ":: varargs 2 start/stop = QT_VARGS(2 args), QT_BLOCKI, QT_ABORT, 6 f() calls.",  NULL};  voidtest11 (int n){  thread_t main;  thread_t *t;  t = t_alloc();  t->next = &main;  while (--n >= 0) {    test10_init (t, &main, 2 * sizeof(int), 2, 1);    QT_BLOCKI (t_splat, &main.qt, 0, t->qt);  }  t_free (t);}char const test12_msg[] = { "*Test varargs init & startup w/ 4 args." };char const *test12_descr[] = {  "Varargs initialization/run.  Copies 4 user arguments.",  ":: varargs 4 start/stop = QT_VARGS(4 args), QT_BLOCKI, QT_ABORT, 6 f() calls.",  NULL};  voidtest12 (int n){  thread_t main;  thread_t *t;  t = t_alloc();  t->next = &main;  while (--n >= 0) {    test10_init (t, &main, 4 * sizeof(int), 4, 3, 2, 1);    QT_BLOCKI (t_splat, &main.qt, 0, t->qt);  }  t_free (t);}char const test13_msg[] = { "*Test varargs init & startup w/ 8 args." };char const *test13_descr[] = {  "Varargs initialization/run.  Copies 8 user arguments.",  ":: varargs 8 start/stop = QT_VARGS(8 args), QT_BLOCKI, QT_ABORT, 6 f() calls.",  NULL};  voidtest13 (int n){  thread_t main;  thread_t *t;  t = t_alloc();  t->next = &main;  while (--n >= 0) {    test10_init (t, &main, 8 * sizeof(int), 8, 7, 6, 5, 4, 3, 2, 1);    QT_BLOCKI (t_splat, &main.qt, 0, t->qt);  }  t_free (t);}char const test14_msg[] = { "*Test varargs initialization w/ 0 args." };char const *test14_descr[] = {  "Varargs initialization without running the thread.  Just calls",  "QT_VARGS.",  ":: varargs 0 init = QT_VARGS()",  NULL};  voidtest14 (int n){  thread_t main;  thread_t *t;  t = t_alloc();  t->next = &main;  while (--n >= 0) {    test10_init (t, &main, 0 * sizeof(int));  }  t_free (t);}char const test15_msg[] = { "*Test varargs initialization w/ 2 args." };char const *test15_descr[] = {  "Varargs initialization without running the thread.  Just calls",  "QT_VARGS.",  ":: varargs 2 init = QT_VARGS(2 args)",  NULL};  voidtest15 (int n){  thread_t main;  thread_t *t;  t = t_alloc();  t->next = &main;  while (--n >= 0) {    test10_init (t, &main, 2 * sizeof(int), 2, 1);  }  t_free (t);}char const test16_msg[] = { "*Test varargs initialization w/ 4 args." };char const *test16_descr[] = {  "Varargs initialization without running the thread.  Just calls",  "QT_VARGS.",  ":: varargs 4 init = QT_VARGS(4 args)",  NULL};  voidtest16 (int n){  thread_t main;  thread_t *t;  t = t_alloc();  t->next = &main;  while (--n >= 0) {    test10_init (t, &main, 4 * sizeof(int), 4, 3, 2, 1);  }  t_free (t);}char const test17_msg[] = { "*Test varargs initialization w/ 8 args." };char const *test17_descr[] = {  "Varargs initialization without running the thread.  Just calls",  "QT_VARGS.",  ":: varargs 8 init = QT_VARGS(8 args)",  NULL};  voidtest17 (int n){  thread_t main;  thread_t *t;  t = t_alloc();  t->next = &main;  while (--n >= 0) {    test10_init (t, &main, 8 * sizeof(int), 8, 7, 6, 5, 4, 3, 2, 1);  }  t_free (t);}/* Test times for basic machine operations. */char const test18_msg[] = { "*Call register indirect." };char const *test18_descr[] = { NULL };  voidtest18 (int n){  b_call_reg (n);}char const test19_msg[] = { "*Call immediate." };char const *test19_descr[] = { NULL };  voidtest19 (int n){  b_call_imm (n);}char const test20_msg[] = { "*Add register-to-register." };char const *test20_descr[] = { NULL };  voidtest20 (int n){  b_add (n);}char const test21_msg[] = { "*Load memory to a register." };char const *test21_descr[] = { NULL };  voidtest21 (int n){  b_load (n);}/* Driver. */typedef struct foo_t {    char const *msg;	/* Message to print for generic help. */    char const **descr;	/* A description of what is done by the test. */    void (*f)(int n);} foo_t;static foo_t foo[] = {  { "Usage:\n", NULL, (void(*)(int n))usage },  { test01_msg, test01_descr, test01 },  { test02_msg, NULL, test02 },  { test03_msg, NULL, test03 },  { test04_msg, NULL, test04 },  { test05_msg, NULL, test05 },  { test06_msg, test06_descr, test06 },  { test07_msg, test07_descr, test07 },  { test08_msg, test08_descr, test08 },  { test09_msg, NULL, test09 },  { test10_msg, test10_descr, test10 },  { test11_msg, test11_descr, test11 },  { test12_msg, test12_descr, test12 },  { test13_msg, test13_descr, test13 },  { test14_msg, test14_descr, test14 },  { test15_msg, test15_descr, test15 },  { test16_msg, test16_descr, test16 },  { test17_msg, test17_descr, test17 },  { test18_msg, test18_descr, test18 },  { test19_msg, test19_descr, test19 },  { test20_msg, test20_descr, test20 },  { test21_msg, test21_descr, test21 },  { 0, 0 }};static int tv = 0;  voidtracer (){  fprintf (stderr, "tracer\t%d\n", tv++);  fflush (stderr);}  voidtracer2 (void *val){  fprintf (stderr, "tracer2\t%d val=0x%p", tv++, val);  fflush (stderr);}  voiddescribe(){  int i;  FILE *out = stdout;  for (i=0; foo[i].msg; ++i) {    if (foo[i].descr) {      int j;      putc ('\n', out);      fprintf (out, "[%d]\n", i);      for (j=0; foo[i].descr[j]; ++j) {	fputs (foo[i].descr[j], out);	putc ('\n', out);      }    }  }  exit (0);}  voidusage(){  int i;  fputs (foo[0].msg, stderr);  for (i=1; foo[i].msg; ++i) {    fprintf (stderr, "%2d\t%s\n", i, foo[i].msg);  }  exit (1);}  voidargs (int *which, int *n, int argc, char **argv){  static int nfuncs = 0;  if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'h') {    describe();  }  if (nfuncs == 0) {    for (nfuncs=0; foo[nfuncs].msg; ++nfuncs)      ;  }  if (argc != 2 && argc != 3) {    usage();  }  *which = atoi (argv[1]);  if (*which < 0 || *which >= nfuncs) {    usage();  }  *n = (argc == 3)    ? atoi (argv[2])    : 1;}  intmain (int argc, char **argv){  int which, n;  args (&which, &n, argc, argv);  (*(foo[which].f))(n);  exit (0);  return (0);}

⌨️ 快捷键说明

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