示例#1
0
___END_C_LINKAGE

int main (int argc, char **argv)
{
  char *temp;

  /*
   * Setup the Scheme library by calling "___setup" with appropriate
   * parameters.  The call to "___setup_params_reset" sets all parameters
   * to their default setting.
   */

  ___setup_params_struct setup_params;

  ___setup_params_reset (&setup_params);

  setup_params.version = ___VERSION;
  setup_params.linker  = SCHEME_LIBRARY_LINKER;

  ___setup (&setup_params);

  /* Main part of program: call Scheme functions */

  temp = eval_string ("(define x 200)");
  if (temp != 0)
    {
      printf ("result = %s\n", temp);
      ___release_string (temp); /* don't forget to reclaim string */
    }

  temp = eval_string ("(expt 2 x)");
  if (temp != 0)
    {
      printf ("result = %s\n", temp);
      ___release_string (temp);
    }

  temp = eval_string ("(+ 1 2"); /* note: missing closing parenthesis */
  if (temp != 0)
    {
      printf ("result = %s\n", temp);
      ___release_string (temp);
    }

  temp = eval_string ("(+ x y)"); /* note: y is unbound */
  if (temp != 0)
    {
      printf ("result = %s\n", temp);
      ___release_string (temp);
    }

  fflush (stdout);

  /* Cleanup the Scheme library */

  ___cleanup ();

  return 0;
}
示例#2
0
int main (int argc, char **argv)
{
  /*
   * Setup the Scheme library by calling "___setup" with appropriate
   * parameters.  The call to "___setup_params_reset" sets all parameters
   * to their default setting.
   */

  ___setup_params_struct setup_params;

  ___setup_params_reset (&setup_params);

  setup_params.version = ___VERSION;
  setup_params.linker  = SCHEME_LIBRARY_LINKER;

  ___setup (&setup_params);

  /* Main part of program: start N threads that increment a counter */

  counter = new_counter (); /* create a new counter */

  pthread_mutex_init (&mut, NULL); /* initialize mutex */

  {
    int i;
    pthread_t tid[N];
    void* results[N];

    for (i = 0; i<N; i++)
      pthread_create (&tid[i], NULL, thread_main, NULL);

    for (i = 0; i<N; i++)
      pthread_join (tid[i], &results[i]);
  }

  {
    int got_throw = 0;
    int count = 0;

    ___ON_THROW(count = get_counter (counter), got_throw=1);

    if (got_throw)
      printf ("Scheme threw an exception\n");
    else
      printf ("final count = %d\n", count);
  }

  /* we don't need the counter anymore */

  ___ON_THROW(release_counter (counter),);

  /* Cleanup the Scheme library */

  ___cleanup ();

  return 0;
}
示例#3
0
void lambdanative_payload_cleanup()
{
  DMSG("lambdanative_payload_cleanup [scm]");
  ___cleanup();
}