Пример #1
0
Файл: test.c Проект: Nukem9/Dune
static void test_parallel(void)
{
	sthread_t st[2];
	sc_t sc[2];
	int p[2];
	void *ret;

	if (pipe(p) == -1)
		err(1, "pipe()");

	sc_init(&sc[0]);
	sc_fd_add(&sc[0], p[0], PROT_READ | PROT_WRITE);

	if (sthread_create(&st[0], &sc[0], parallel_read, (void*) (long) p[0]))
		err(1, "sthread_create()");

	sc_init(&sc[1]);
	sc_fd_add(&sc[1], p[1], PROT_READ | PROT_WRITE);

	if (sthread_create(&st[1], &sc[1], parallel_write, (void*) (long) p[1]))
		err(1, "sthread_create()");

	if (sthread_join(st[0], &ret) == -1)
		err(1, "sthread_join()");

	if (sthread_join(st[1], NULL) == -1)
		err(1, "sthread_join()");

	if (ret != (void*) 0x666)
		errx(1, "ret is %p", ret);

	close(p[0]);
	close(p[1]);
}
Пример #2
0
void rnc_init(void) {
  if(!initialized) { initialized=1;
    rn_init();
    len_p=LEN_P; path=(char*)m_alloc(len_p,sizeof(char));
    /* initialize scopes */
    sc_init(&nss); sc_init(&dts); sc_init(&defs); sc_init(&refs); sc_init(&prefs);
  }
}
Пример #3
0
void start(void) {
	sc_going = 1;

	gchar * username = mlp_get_string ("audioscrobbler", "username");
	gchar * password = mlp_get_string ("audioscrobbler", "password");
	gchar * sc_url = mlp_get_string ("audioscrobbler", "sc_url");

	if ((!username || !password) || (!*username || !*password))
	{
		AUDDBG("username/password not found - not starting last.fm support");
		sc_going = 0;
	}
	else
		sc_init(username, password, sc_url);

	g_free (username);
	g_free (password);
	g_free (sc_url);

	m_scrobbler = g_mutex_new();

	hook_associate("playback begin", mlp_hook_playback_begin, NULL);
	hook_associate("playback stop", mlp_hook_playback_end, NULL);

	AUDDBG("plugin started");
	sc_idle(m_scrobbler);
}
Пример #4
0
void sig_init(void) 
{

    p1 = sem_get(SEMKEY1); 
    p2 = sem_get(SEMKEY2); 
    p3 = sem_get(SEMKEY3); 
#ifdef NONBLOCK
	V(p3);
#endif
       
    int shm_id;
    shm_id = shmget(key,sbuf_size*sizeof(char),NULL);
    shm = shmat(shm_id,NULL,NULL);
    if(shm == -1)
    {   
        printf("Create share memory error");
    }
#ifdef DEBUG
	printf("initl file\n");
    printf("share memory address is %p\n", shm);
#endif
#if 0
	int i;
	for(i=1;i<1024;i++)
	{
		sc_init(6);
		insert_sc_arg(0, i, 0,0);
		dispatch_sc();
	}
#endif
	gettimeofday(&start, NULL);
	seminit=1;
}
Пример #5
0
static void
init(int *argc, char ***argv)
{
	process_args(argc, argv);

	if (!ev_init())
		C("failed to initialize eval/dispatch");
	
	if (s_sercommd) {
		if (!s_dev)
			s_dev = strdup(DEF_TRG);

		if (!s_baud)
			s_baud = DEF_PORT;

		if (!sc_init_tcp(s_dev, (uint16_t)s_baud))
			C("failed to initialize sercomm (trg: '%s', port: %d)",
			    s_dev, s_baud);
	} else {
		if (!s_dev)
			s_dev = strdup(DEF_DEV);

		if (!s_baud)
			s_baud = DEF_BAUD;

		if (!sc_init(s_dev, s_baud))
			C("failed to initialize sercomm (dev: '%s', baud: %d)",
			    s_dev, s_baud);
	}

	if (*argc)
		s_stdin = false;
}
Пример #6
0
int
main (int argc, char **argv)
{
    MPI_Comm            mpicomm;
    int                 mpiret;
    int                 N;

    mpiret = MPI_Init (&argc, &argv);
    SC_CHECK_MPI (mpiret);
    mpicomm = MPI_COMM_WORLD;

    sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT);
    p4est_init (NULL, SC_LP_DEFAULT);

    N = 43;
    test_identity (N);
    test_shell (N);
    test_sphere (N);

    /* clean up and exit */
    sc_finalize ();

    mpiret = MPI_Finalize ();
    SC_CHECK_MPI (mpiret);

    return 0;
}
Пример #7
0
Файл: test.c Проект: Nukem9/Dune
static void test_syscall(void)
{
	sc_t sc;
	tag_t t;
	char *buf;
	sthread_t st;

	t = tag_new();
	buf = smalloc(t, 1024);
	assert(buf);

	sc_init(&sc);
	sc_mem_add(&sc, t, PROT_READ | PROT_WRITE);
	sc_sys_add(&sc, SYS_open);
	sc_sys_add(&sc, SYS_close);

	if (sthread_create(&st, &sc, sys_st, buf))
		err(1, "sthread_create()");

	if (sthread_join(st, NULL))
		err(1, "sthread_join()");

	if (strncmp(buf, "root", 4) != 0)
		errx(1, "buf is %s", buf);
}
Пример #8
0
int main(void)
{
  halInit();
  /* Initialize ChibiOS core */
  chSysInit();

  sc_init(SC_MODULE_UART2 | SC_MODULE_GPIO | SC_MODULE_LED | SC_MODULE_SDU | SC_MODULE_RADIO);
  sc_uart_default_usb(TRUE);

  sc_log_output_uart(SC_UART_USB);

  // Start event loop. This will start a new thread and return
  sc_event_loop_start();

  // Register callbacks.
  // These will be called from Event Loop thread. It's OK to do some
  // calculations etc. time consuming there, but not to sleep or block
  // for longer periods of time.
  sc_event_register_handle_byte(cb_handle_byte);
  sc_event_register_blob_available(cb_blob_available);
  sc_event_register_extint(0, cb_pa0_changed);
  sc_extint_set_event(GPIOA, 0, SC_EXTINT_EDGE_BOTH);

  // Loop forever waiting for callbacks
  while(1) {
    uint8_t msg[] = {'d', ':', ' ', 'p','i','n','g','\r','\n'};
    chThdSleepMilliseconds(1000);
    sc_uart_send_msg(SC_UART_USB, msg, sizeof(msg));
  }

  return 0;
}
Пример #9
0
int main(void)
{
  halInit();
  /* Initialize ChibiOS core */
  chSysInit();

  sc_init(SC_MODULE_LED);

  // Start event loop. This will start a new thread and return
  sc_event_loop_start();

#if defined CH_NO_IDLE_THREAD && CH_NO_IDLE_THREAD
  chThdSetPriority(IDLEPRIO);
#endif

  // Loop forever waiting for callbacks
  while(1) {
    sc_led_toggle();

#if defined CH_NO_IDLE_THREAD && CH_NO_IDLE_THREAD
    chDbgAssert(0, "Can't call chThdSleepMilliseconds() without idle thread");
#endif
    chThdSleepMilliseconds(1000);
  }

  return 0;
}
Пример #10
0
int
main (int argc, char **argv)
{
  sc_MPI_Comm         mpicomm;
  int                 mpiret;
  int                 size, rank;

  mpiret = sc_MPI_Init (&argc, &argv);
  SC_CHECK_MPI (mpiret);
  mpicomm = sc_MPI_COMM_WORLD;
  mpiret = sc_MPI_Comm_size (mpicomm, &size);
  SC_CHECK_MPI (mpiret);
  mpiret = sc_MPI_Comm_rank (mpicomm, &rank);
  SC_CHECK_MPI (mpiret);

  sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT);
  p4est_init (NULL, SC_LP_DEFAULT);

  (void) check_backward_compatibility ();
  check_int_types ();

#ifndef P4_TO_P8
  check_all (mpicomm, p4est_connectivity_new_unitsquare (),
             "test_unitsquare", 0xef45243bU, 0xbc5d0907U);
  check_all (mpicomm, p4est_connectivity_new_rotwrap (),
             "test_rotwrap2", 0x266d2739U, 0x29a31248U);
  check_all (mpicomm, p4est_connectivity_new_corner (),
             "test_corner", 0x9dad92ccU, 0x937b27afU);
  check_all (mpicomm, p4est_connectivity_new_moebius (),
             "test_moebius", 0xbbc10f7fU, 0x09b6319eU);
  check_all (mpicomm, p4est_connectivity_new_star (),
             "test_star", 0xfb28233fU, 0x8e8a32b3);
#else
  check_all (mpicomm, p8est_connectivity_new_unitcube (),
             "test_unitcube", 0x2574801fU, 0x312559a7U);
  check_all (mpicomm, p8est_connectivity_new_periodic (),
             "test_periodic3", 0xdc7e8a93U, 0x0787ca2dU);
  check_all (mpicomm, p8est_connectivity_new_rotwrap (),
             "test_rotwrap", 0xa675888dU, 0x626cbe90U);
  check_all (mpicomm, p8est_connectivity_new_twocubes (),
             "test_twocubes", 0x7188978aU, 0x4124bcabU);
  check_all (mpicomm, p8est_connectivity_new_twowrap (),
             "test_twowrap", 0x8e3f994cU, 0x9dd49e94);
  check_all (mpicomm, p8est_connectivity_new_rotcubes (),
             "test_rotcubes", 0xc0e1b235U, 0x974af07a);
  check_all (mpicomm, p8est_connectivity_new_shell (),
             "test_shell", 0x558723a2U, 0x4dedf35eU);
  check_all (mpicomm,
             p8est_connectivity_new_brick (2, 3, 4, 0, 0, 1),
             "test_brick", 0x82174e14U, 0x211da6c5);
#endif

  /* clean up and exit */
  sc_finalize ();

  mpiret = sc_MPI_Finalize ();
  SC_CHECK_MPI (mpiret);

  return 0;
}
Пример #11
0
int
main (int argc, char *argv[])
{
  int                 mpiret, mpisize;
  int                 thread_lvl, num_threads;

  mpiret =
    sc_MPI_Init_thread (&argc, &argv, sc_MPI_THREAD_MULTIPLE, &thread_lvl);
  SC_CHECK_MPI (mpiret);
  sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT);

  if (thread_lvl < sc_MPI_THREAD_MULTIPLE) {
    SC_GLOBAL_PRODUCTIONF ("Mpi only supports thread level %d\n", thread_lvl);
  }
  else {
    mpiret = sc_MPI_Comm_size (sc_MPI_COMM_WORLD, &mpisize);
    SC_CHECK_MPI (mpiret);
    num_threads = omp_get_max_threads ();
    SC_GLOBAL_PRODUCTIONF ("Running on %i processes with %i threads each.\n",
                           mpisize, num_threads);
    omp_set_num_threads (num_threads);
    omp_init_lock (&writelock);
#pragma omp parallel
    {
      openmp_print_tid ();
    }
  }
  return 0;
}
Пример #12
0
int 
main(int argc, char* argv[]) {
    const char* file = "config.lua";
    if (argc > 1) {
        file = argv[1];
    }
    
    sc_env_init();
    sc_env_load(file);

    int lastarg;
    int i;
    for (i=2; i<argc; ++i) {
        lastarg = i==argc-1;
        if (!strncmp(argv[i], "--", 2) && 
             argv[i][2] != '\0' &&
            !lastarg) {
            sc_setenv(&(argv[i][2]), argv[i+1]);
            i++;
        } else {
            usage(argv[0]);
            return 1;
        }
    }

    if (sc_getint("sc_daemon", 0)) {
        daemon(1, 1);
    }
    
    sc_init();
    sc_start();
    sc_env_fini();
    return 0;
}
Пример #13
0
int
main (int argc, char **argv)
{
  int                 mpiret;
  p4est_connectivity_t *conn_in, *conn_out;
  p4est_t            *p4est;

  mpiret = sc_MPI_Init (&argc, &argv);
  SC_CHECK_MPI (mpiret);

  sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT);
  p4est_init (NULL, SC_LP_DEFAULT);

#ifndef P4_TO_P8
  conn_in = p4est_connectivity_new_cubed ();
#else
  conn_in = p8est_connectivity_new_rotcubes ();
#endif
  conn_out = p4est_connectivity_refine (conn_in, 5);
  p4est_connectivity_destroy (conn_in);

  p4est = p4est_new (sc_MPI_COMM_WORLD, conn_out, 0, NULL, NULL);
  p4est_vtk_write_file (p4est, NULL, P4EST_STRING "_test_connrefine");

  p4est_destroy (p4est);
  p4est_connectivity_destroy (conn_out);

  sc_finalize ();

  mpiret = sc_MPI_Finalize ();
  SC_CHECK_MPI (mpiret);
  return 0;
}
Пример #14
0
int
main (int argc, char **argv)
{
  int                 mpiret;
  p4est_connectivity_t *conn1, *conn2;

  mpiret = sc_MPI_Init (&argc, &argv);
  SC_CHECK_MPI (mpiret);

  sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT);
  p4est_init (NULL, SC_LP_DEFAULT);

#ifndef P4_TO_P8
  conn1 = p4est_connectivity_new_unitsquare ();
  conn2 = p4est_connectivity_new_rotwrap ();
#else
  conn1 = p8est_connectivity_new_unitcube ();
  conn2 = p8est_connectivity_new_rotwrap ();
#endif

  p4est_connectivity_join_faces (conn1, 0, 0, 0, 1, 0);
  p4est_connectivity_join_faces (conn1, 0, 0, P4EST_FACES - 2,
                                 P4EST_FACES - 1, 1);

  SC_CHECK_ABORT (p4est_connectivity_is_equivalent (conn1, conn2),
                  "rotwrap not reproduced");

  p4est_connectivity_destroy (conn1);
  p4est_connectivity_destroy (conn2);

  sc_finalize ();
  mpiret = sc_MPI_Finalize ();
  SC_CHECK_MPI (mpiret);
  return 0;
}
Пример #15
0
Файл: test.c Проект: Nukem9/Dune
static void test_fd(void)
{
	int p[2];
	sc_t sc;
	char buf[1024];
	int rc;
	sthread_t st;

	if (pipe(p) == -1)
		err(1, "pipe()");

	sc_init(&sc);
	sc_fd_add(&sc, p[1], PROT_WRITE);

	if (sthread_create(&st, &sc, fd_st, (void*) (long) p[1]))
		err(1, "sthread_create()");

	if (sthread_join(st, NULL))
		err(1, "sthread_join()");

	rc = read(p[0], buf, sizeof(buf) - 1);
	if (rc <= 0)
		err(1, "read()");

	buf[rc] = 0;

	if (strcmp(buf, "bye") != 0)
		errx(1, "buf is %s", buf);

	close(p[0]);
	close(p[1]);
}
Пример #16
0
int
main (void)
{
  double              round1[3];
  double              round2[3];
  sc_warp_interval_t *root;

  sc_init (sc_MPI_COMM_NULL, 1, 1, NULL, SC_LP_DEFAULT);

  root = sc_warp_new (0., 1.);

  round1[0] = .3;
  round1[1] = .58;
  round1[2] = .86;
  sc_warp_update (root, 3, round1, 0.10, 7);
  sc_warp_write (root, stdout);

  round2[0] = .3;
  round2[1] = .86;
  round2[2] = .92;
  sc_warp_update (root, 3, round2, 0.15, 7);
  sc_warp_write (root, stdout);

  sc_warp_destroy (root);

  sc_finalize ();

  return 0;
}
Пример #17
0
int st_init()
{
	cn_puts("Initializing system...");
	
	if(sc_init() == 0)
		return 0;
	
	cn_puts("ok\n");
	return 1;
}
Пример #18
0
int
main (int argc, char **argv)
{
  sc_init (sc_MPI_COMM_NULL, 1, 1, NULL, SC_LP_DEFAULT);

  check_matrix_vector ();
  check_matrix_multiply ();

  sc_finalize ();

  return 0;
}
Пример #19
0
int main(void)
{
  halInit();
  /* Initialize ChibiOS core */
  chSysInit();

  // Init SC framework, with USB if not F1 Discovery
#if defined(BOARD_ST_STM32VL_DISCOVERY)
  sc_init(SC_MODULE_UART1 | SC_MODULE_PWM | SC_MODULE_ADC | SC_MODULE_GPIO | SC_MODULE_LED);
#else
  sc_init(SC_MODULE_UART1 | SC_MODULE_PWM | SC_MODULE_SDU | SC_MODULE_ADC | SC_MODULE_GPIO | SC_MODULE_LED);
  sc_uart_default_usb(TRUE);
#endif

  // Start event loop. This will start a new thread and return
  sc_event_loop_start();

  // Register callbacks.
  // These will be called from Event Loop thread. It's OK to do some
  // calculations etc. time consuming there, but not to sleep or block.
  sc_event_register_handle_byte(cb_handle_byte);
  sc_event_register_adc_available(cb_adc_available);

  // Start periodic ADC readings
#if defined(BOARD_ST_STM32VL_DISCOVERY)
  // FIXME: Not tested
  sc_adc_start_conversion(3, 1000, ADC_SAMPLE_55P5);
#else
  sc_adc_start_conversion(3, 1000, ADC_SAMPLE_56);
#endif

  // Loop forever waiting for callbacks
  while(1) {
    uint8_t msg[] = {'d', ':', ' ', 'p','i','n','g','\r','\n'};
    chThdSleepMilliseconds(1000);
    sc_uart_send_msg(SC_UART_LAST, msg, 9);
  }

  return 0;
}
Пример #20
0
int sc_open(struct stream_context *self, const char *filename) {
	int err;

	sc_init(self);
	err = avformat_open_input(&self->format_ctx, filename, NULL, NULL);
	if (err < 0) { return err; }
	err = avformat_find_stream_info(self->format_ctx, NULL);
	if (err < 0) { return err; }

	self->state = STATE_OPEN;

	return 0;
}
Пример #21
0
PetscErrorCode PetscP4estInitialize(void)
{
  PetscBool      psc_catch_signals    = PETSC_FALSE;
  PetscBool      psc_print_backtrace  = PETSC_TRUE;
  int            psc_log_threshold    = SC_LP_DEFAULT;
  int            pp4est_log_threshold = SC_LP_DEFAULT;
  char           logList[256], *className;
  PetscBool      opt;
  PetscErrorCode ierr;

  PetscFunctionBegin;
  if (PetscP4estInitialized) PetscFunctionReturn(0);
  PetscP4estInitialized = PETSC_TRUE;

  ierr = PetscClassIdRegister("p4est logging",&P4ESTLOGGING_CLASSID);CHKERRQ(ierr);
  ierr = PetscOptionsGetString(NULL,NULL, "-info_exclude", logList, 256, &opt);CHKERRQ(ierr);
  if (opt) {
    ierr = PetscStrstr(logList, "p4est", &className);CHKERRQ(ierr);
    if (className) {
      ierr = PetscInfoDeactivateClass(P4ESTLOGGING_CLASSID);CHKERRQ(ierr);
    }
  }
  ierr = PetscHeaderCreate(P4estLoggingObject,P4ESTLOGGING_CLASSID,"p4est","p4est logging","DM",PETSC_COMM_WORLD,NULL,PetscObjectView);CHKERRQ(ierr);
  if (sc_package_id == -1) {
    int       log_threshold_shifted = psc_log_threshold + 1;
    PetscBool set;

    PetscBeganSc = PETSC_TRUE;
    ierr         = PetscOptionsGetBool(NULL,NULL,"-petsc_sc_catch_signals",&psc_catch_signals,NULL);CHKERRQ(ierr);
    ierr         = PetscOptionsGetBool(NULL,NULL,"-petsc_sc_print_backtrace",&psc_print_backtrace,NULL);CHKERRQ(ierr);
    ierr         = PetscOptionsGetEnum(NULL,NULL,"-petsc_sc_log_threshold",SCLogTypes,(PetscEnum*)&log_threshold_shifted,&set);CHKERRQ(ierr);
    if (set) psc_log_threshold = log_threshold_shifted - 1;
    sc_init(PETSC_COMM_WORLD,(int)psc_catch_signals,(int)psc_print_backtrace,PetscScLogHandler,psc_log_threshold);
    if (sc_package_id == -1) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_LIB,"Could not initialize libsc package used by p4est");
    sc_set_abort_handler(PetscScAbort);
  }
  if (p4est_package_id == -1) {
    int       log_threshold_shifted = pp4est_log_threshold + 1;
    PetscBool set;

    ierr = PetscOptionsGetEnum(NULL,NULL,"-petsc_p4est_log_threshold",SCLogTypes,(PetscEnum*)&log_threshold_shifted,&set);CHKERRQ(ierr);
    if (set) pp4est_log_threshold = log_threshold_shifted - 1;
    PetscStackCallP4est(p4est_init,(PetscScLogHandler,pp4est_log_threshold));
    if (p4est_package_id == -1) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_LIB,"Could not initialize p4est");
  }
  ierr = DMForestRegisterType(DMP4EST);CHKERRQ(ierr);
  ierr = DMForestRegisterType(DMP8EST);CHKERRQ(ierr);
  ierr = PetscRegisterFinalize(PetscP4estFinalize);CHKERRQ(ierr);
  PetscFunctionReturn(0);
}
Пример #22
0
int
main (int argc, char **argv)
{
  int                 mpiret;
  mpi_context_t       mpi_context, *mpi = &mpi_context;
  p4est_t            *p4est;
  p4est_connectivity_t *connectivity;
  p4est_ghost_t      *ghost;

  /* initialize MPI and p4est internals */
  mpiret = MPI_Init (&argc, &argv);
  SC_CHECK_MPI (mpiret);
  mpi->mpicomm = MPI_COMM_WORLD;        /* your favourite comm here */
  mpiret = MPI_Comm_size (mpi->mpicomm, &mpi->mpisize);
  SC_CHECK_MPI (mpiret);
  mpiret = MPI_Comm_rank (mpi->mpicomm, &mpi->mpirank);
  SC_CHECK_MPI (mpiret);

  /* this should alwaps be MPI_COMM_WORLD (no effect on p4est) */
  sc_init (MPI_COMM_WORLD, 0, 0, NULL, SC_LP_DEFAULT);
  p4est_init (NULL, SC_LP_DEFAULT);

  /* create 2D connectivity and forest structures */
  connectivity = p4est_connectivity_new_unitsquare ();
  p4est = p4est_new_ext (mpi->mpicomm, connectivity, 0, 0, 1, 0, NULL, NULL);

  /* refine and partition */
  p4est_refine (p4est, 1, refine_fn, NULL);
  p4est_partition (p4est, NULL);

  /* write vtk output */
  p4est_vtk_write_file (p4est, NULL, "p4est_ptest2");

  /* create and destroy ghost layer */
  ghost = p4est_ghost_new (p4est, P4EST_CONNECT_FULL);
  p4est_ghost_destroy (ghost);

  /* destroy the p4est and its connectivity structure */
  p4est_destroy (p4est);
  p4est_connectivity_destroy (connectivity);

  /* clean up and exit */
  sc_finalize ();

  mpiret = MPI_Finalize ();
  SC_CHECK_MPI (mpiret);

  return 0;
}
Пример #23
0
Файл: test.c Проект: Nukem9/Dune
static void *launch_sthread(stcb_t cb, void *arg)
{
	sc_t sc;
	sthread_t st;
	void *ret;

	sc_init(&sc);

	if (sthread_create(&st, &sc, cb, arg))
		err(1, "sthread_create()");

	if (sthread_join(st, &ret))
		err(1, "sthread_join()");

	return ret;
}
Пример #24
0
int
main (int argc, char *argv[])
{
  int                 mpiret;

  /* initialize MPI and p4est internals */
  mpiret = sc_MPI_Init (&argc, &argv);
  SC_CHECK_MPI (mpiret);
  sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT);
  p4est_init (NULL, SC_LP_DEFAULT);

#ifndef P4_TO_P8
  test_reduce (p4est_connectivity_new_unitsquare (), "unitsquare");
  test_reduce (p4est_connectivity_new_periodic (), "periodic");
  test_reduce (p4est_connectivity_new_rotwrap (), "rotwrap");
  test_reduce (p4est_connectivity_new_corner (), "corner");
  test_reduce (p4est_connectivity_new_pillow (), "pillow");
  test_reduce (p4est_connectivity_new_moebius (), "moebius");
  test_reduce (p4est_connectivity_new_star (), "star");
  test_reduce (p4est_connectivity_new_cubed (), "cubed");
  test_reduce (p4est_connectivity_new_disk (), "disk");
  test_reduce (p4est_connectivity_new_brick (3, 2, 0, 0), "brick00");
  test_reduce (p4est_connectivity_new_brick (3, 2, 0, 1), "brick01");
  test_reduce (p4est_connectivity_new_brick (3, 2, 1, 0), "brick10");
  test_reduce (p4est_connectivity_new_brick (3, 2, 1, 1), "brick11");
#else
  test_reduce (p8est_connectivity_new_unitcube (), "unitcube");
  test_reduce (p8est_connectivity_new_periodic (), "periodic");
  test_reduce (p8est_connectivity_new_rotwrap (), "rotwrap");
  test_reduce (p8est_connectivity_new_twocubes (), "twocubes");
  test_reduce (p8est_connectivity_new_twowrap (), "twowrap");
  test_reduce (p8est_connectivity_new_rotcubes (), "rotcubes");
  test_reduce (p8est_connectivity_new_brick (4, 3, 2, 0, 0, 0), "brick000");
  test_reduce (p8est_connectivity_new_brick (4, 3, 2, 0, 0, 1), "brick001");
  test_reduce (p8est_connectivity_new_brick (4, 3, 2, 0, 1, 0), "brick010");
  test_reduce (p8est_connectivity_new_brick (4, 3, 2, 0, 1, 1), "brick011");
  test_reduce (p8est_connectivity_new_brick (4, 3, 2, 1, 0, 0), "brick100");
  test_reduce (p8est_connectivity_new_brick (4, 3, 2, 1, 0, 1), "brick101");
  test_reduce (p8est_connectivity_new_brick (4, 3, 2, 1, 1, 1), "brick111");
#endif
  /* clean up and exit */
  sc_finalize ();

  mpiret = sc_MPI_Finalize ();
  SC_CHECK_MPI (mpiret);
  return 0;
}
Пример #25
0
/**
 * @brief compile handler which starts lexing and parsing
 *
 * @param raw_code pl0 source code
 * @retval int TRUE or FALSE
 */
int compile(FILE *raw_code) {
	SOURCECODE pl0_code = sc_init();
	int status;

	puts("Start lexical scanning...");

	lexer(pl0_code, raw_code);

	puts("Finished lexical scanning!\n");

	puts("Start parsing...\n");

	status = init_parsing(pl0_code);

	sc_destroy(pl0_code);

	return status;
}
Пример #26
0
bool
init_agents()
/*
 * Here we create all of the individual agents
 */
{
	bool	ok;				 /* Status of last operation  */

	agents_sc = sc_init();			 /* Create sync controller    */

	if(!agents_sc)				 /* Failed ?		      */
		return FALSE;

	sc_begin(agents_sc);			 /* Start synchronisation     */

#ifdef DEBUG
	ok = try_each_obj(qsheets, (t_try_obj)db_new_agent,
			GINT_TO_POINTER(atype_cue))
		&& new_agent(NULL, GINT_TO_POINTER(atype_dek), "Decks")
		&& new_agent(NULL, GINT_TO_POINTER(atype_mxr), "Mixers");
#else
	ok = try_each_obj(qsheets, (t_try_obj)new_agent,
			GINT_TO_POINTER(atype_cue))
		&& new_agent(NULL, GINT_TO_POINTER(atype_dek))
		&& new_agent(NULL, GINT_TO_POINTER(atype_mxr));
#endif

	new_am_pool();				 /* Create pool of msg args   */

	sc_ready(agents_sc);			 /* Signal we are ready	      */

	if(ok)					 /* Everything OK?	      */
		sc_wait(agents_sc);		 /* Wait for agents to start  */
	else
	{
		E("Startup failed, killing agents...");
		sc_wait(agents_sc);		 /* Wait for agents to start  */
		term_agents();			 /* Terminate all agents      */
	}

	sc_reset(agents_sc);			 /* Kill sync controller      */

	return ok;
}						 /* init_agents()	      */
Пример #27
0
int
main (int argc, char **argv)
{
  sc_MPI_Comm         mpicomm;
  int                 mpiret, retval;
  int                 level;
  const char         *filename;
  p4est_connectivity_t *conn;
  sc_options_t       *opt;

  mpiret = sc_MPI_Init (&argc, &argv);
  SC_CHECK_MPI (mpiret);
  mpicomm = sc_MPI_COMM_WORLD;

  sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT);
  p4est_init (NULL, SC_LP_DEFAULT);

  opt = sc_options_new (argv[0]);
  sc_options_add_int (opt, 'l', "level", &level, 0,
                      "Upfront refinement level");
  retval = sc_options_parse (p4est_package_id, SC_LP_ERROR, opt, argc, argv);
  if (retval == -1 || retval + 1 != argc) {
    sc_options_print_usage (p4est_package_id, SC_LP_PRODUCTION, opt, NULL);
    sc_abort_collective ("Usage error");
  }
  filename = argv[retval];
  P4EST_LDEBUGF ("Loading %s\n", filename);
  conn = p4est_connectivity_load (filename, NULL);

  run_load (mpicomm, conn, level);

  p4est_connectivity_destroy (conn);
  sc_options_destroy (opt);

  sc_finalize ();

  mpiret = sc_MPI_Finalize ();
  SC_CHECK_MPI (mpiret);

  return 0;
}
Пример #28
0
static int
sc_private_encrypt(int flen, u_char *from, u_char *to, RSA *rsa,
    int padding)
{
	u_char *padded = NULL;
	int sw, len, status = -1;

	len = sw = 0;
	if (sc_fd < 0) {
		status = sc_init();
		if (status < 0 )
			goto err;
	}
	if (padding != RSA_PKCS1_PADDING)
		goto err;

	debug("sc_private_encrypt called");
	len = BN_num_bytes(rsa->n);
	padded = xmalloc(len);

	if (RSA_padding_add_PKCS1_type_1(padded, len, (u_char *)from, flen) <= 0) {
		error("RSA_padding_add_PKCS1_type_1 failed");
		goto err;
	}
	sectok_apdu(sc_fd, CLA_SSH, INS_DECRYPT, 0, 0, len, padded, len, to, &sw);
	if (sw == 0x6982) {
		if (try_AUT0() < 0)
			goto err;
		sectok_apdu(sc_fd, CLA_SSH, INS_DECRYPT, 0, 0, len, padded, len, to, &sw);
	}
	if (!sectok_swOK(sw)) {
		error("sc_private_encrypt: INS_DECRYPT failed: %s",
		    sectok_get_sw(sw));
		goto err;
	}
err:
	if (padded)
		xfree(padded);
	sc_close();
	return (len >= 0 ? len : status);
}
Пример #29
0
int
main (int argc, char **argv)
{
  int                 mpiret;

  mpiret = sc_MPI_Init (&argc, &argv);
  SC_CHECK_MPI (mpiret);

  sc_init (sc_MPI_COMM_WORLD, 1, 1, NULL, SC_LP_DEFAULT);
  p4est_init (NULL, SC_LP_DEFAULT);

#ifndef P4_TO_P8
  test_complete (p4est_connectivity_new_unitsquare (), "unitsquare", 1);
  test_complete (p4est_connectivity_new_periodic (), "2D periodic", 0);
  test_complete (p4est_connectivity_new_rotwrap (), "rotwrap", 0);
  test_complete (p4est_connectivity_new_corner (), "corner", 1);
  test_complete (p4est_connectivity_new_moebius (), "moebius", 1);
  test_complete (p4est_connectivity_new_star (), "star", 1);
  test_complete (p4est_connectivity_new_brick (3, 18, 0, 1),
                 "2D periodic brick", 0);
  test_complete (p4est_connectivity_new_brick (3, 18, 0, 0), "2D brick", 1);
#else
  test_complete (p8est_connectivity_new_unitcube (), "unitcube", 1);
  test_complete (p8est_connectivity_new_periodic (), "3D periodic", 0);
  test_complete (p8est_connectivity_new_rotwrap (), "rotwrap", 0);
  test_complete (p8est_connectivity_new_twowrap (), "twowrap", 1);
  test_complete (p8est_connectivity_new_twocubes (), "twocubes", 1);
  test_complete (p8est_connectivity_new_rotcubes (), "rotcubes", 1);
  test_complete (p8est_connectivity_new_brick (3, 2, 8, 1, 0, 1),
                 "3D periodic brick", 0);
  test_complete (p8est_connectivity_new_brick (3, 2, 8, 0, 0, 0),
                 "3D brick", 1);
#endif

  sc_finalize ();

  mpiret = sc_MPI_Finalize ();
  SC_CHECK_MPI (mpiret);

  return 0;
}
Пример #30
0
int
main (int argc, char **argv)
{
  int                 mpirank, mpisize;
  int                 mpiret;
  sc_MPI_Comm         mpicomm;
  p4est_t            *p4est;
  p4est_connectivity_t *connectivity;

  mpiret = sc_MPI_Init (&argc, &argv);
  SC_CHECK_MPI (mpiret);
  mpicomm = sc_MPI_COMM_WORLD;
  mpiret = sc_MPI_Comm_size (mpicomm, &mpisize);
  SC_CHECK_MPI (mpiret);
  mpiret = sc_MPI_Comm_rank (mpicomm, &mpirank);
  SC_CHECK_MPI (mpiret);

  sc_init (mpicomm, 1, 1, NULL, SC_LP_DEFAULT);
  p4est_init (NULL, SC_LP_DEFAULT);

  /* create connectivity and forest structures */
#ifdef P4_TO_P8
  connectivity = p8est_connectivity_new_rotcubes ();
#else
  connectivity = p4est_connectivity_new_star ();
#endif
  p4est = p4est_new_ext (mpicomm, connectivity, 15, 0, 0, 1, NULL, NULL);
  p4est_refine_ext (p4est, 1, P4EST_QMAXLEVEL, refine_fn, NULL, replace_fn);
  p4est_coarsen_ext (p4est, 1, 0, coarsen_fn, NULL, replace_fn);
  p4est_balance_ext (p4est, P4EST_CONNECT_FULL, NULL, replace_fn);

  p4est_destroy (p4est);
  p4est_connectivity_destroy (connectivity);
  sc_finalize ();

  mpiret = sc_MPI_Finalize ();
  SC_CHECK_MPI (mpiret);

  return 0;
}