本文整理汇总了C++中sc_init函数的典型用法代码示例。如果您正苦于以下问题:C++ sc_init函数的具体用法?C++ sc_init怎么用?C++ sc_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sc_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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]);
}
开发者ID:Nukem9,项目名称:Dune,代码行数:34,代码来源:test.c
示例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);
}
开发者ID:Falcon-peregrinus,项目名称:mlplayer,代码行数:27,代码来源:plugin.c
示例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;
}
开发者ID:fstd,项目名称:imme,代码行数:33,代码来源:immectl.c
示例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;
}
开发者ID:xyuan,项目名称:p4est,代码行数:27,代码来源:test_geometry3.c
示例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);
}
开发者ID:Nukem9,项目名称:Dune,代码行数:25,代码来源:test.c
示例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;
}
开发者ID:rambo,项目名称:control-board,代码行数:32,代码来源:main-radio.c
示例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;
}
开发者ID:cburstedde,项目名称:p4est,代码行数:60,代码来源:test_valid2.c
示例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;
}
开发者ID:johannrudi,项目名称:libsc,代码行数:29,代码来源:openmp.c
示例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;
}
开发者ID:lvshaco,项目名称:shaco_first,代码行数:34,代码来源:shaco.c
示例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;
}
开发者ID:cburstedde,项目名称:p4est,代码行数:33,代码来源:test_connrefine2.c
示例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;
}
开发者ID:00liujj,项目名称:p4est,代码行数:35,代码来源:test_join2.c
示例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]);
}
开发者ID:Nukem9,项目名称:Dune,代码行数:32,代码来源:test.c
示例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;
}
开发者ID:johannrudi,项目名称:libsc,代码行数:29,代码来源:warp.c
示例14: st_init
int st_init()
{
cn_puts("Initializing system...");
if(sc_init() == 0)
return 0;
cn_puts("ok\n");
return 1;
}
开发者ID:JustSid,项目名称:NANOS,代码行数:10,代码来源:system.c
示例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;
}
开发者ID:johannrudi,项目名称:libsc,代码行数:12,代码来源:dmatrix.c
示例16: main
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;
}
开发者ID:rambo,项目名称:control-board,代码行数:40,代码来源:main-pleco.c
示例17: sc_open
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;
}
开发者ID:magical,项目名称:dr_meter,代码行数:13,代码来源:main.c
示例18: PetscP4estInitialize
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);
}
开发者ID:tom-klotz,项目名称:petsc,代码行数:50,代码来源:petsc_p4est_package.c
示例19: main
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;
}
开发者ID:ChenShaoning,项目名称:p4est,代码行数:49,代码来源:ptest2.c
示例20: sc_init
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;
}
开发者ID:Nukem9,项目名称:Dune,代码行数:16,代码来源:test.c
注:本文中的sc_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论