本文整理汇总了C++中sc_init函数的典型用法代码示例。如果您正苦于以下问题:C++ sc_init函数的具体用法?C++ sc_init怎么用?C++ sc_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sc_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_parallel
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: start
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);
}
示例3: init
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;
}
示例4: main
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;
}
示例5: test_syscall
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);
}
示例6: main
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;
}
示例7: main
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;
}
示例8: main
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;
}
示例9: main
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;
}
示例10: main
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;
}
示例11: main
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;
}
示例12: test_fd
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]);
}
示例13: main
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;
}
示例14: st_init
int st_init()
{
cn_puts("Initializing system...");
if(sc_init() == 0)
return 0;
cn_puts("ok\n");
return 1;
}
示例15: main
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;
}