void c_main() { // Copy this core's experimental configuration from SDRAM load_config(); // Set up the core map spin1_application_core_map( system_width, system_height , (uint (*)[system_height])&core_map[0] ); // Accept packets freely from the network spin1_callback_on(MC_PACKET_RECEIVED, on_mc_packet_received, -1); // Set up timer spin1_set_timer_tick(config_root.tick_microseconds); spin1_callback_on(TIMER_TICK, on_timer_tick, 3); setup_router(); // Report that we're ready io_printf(IO_BUF, "Waiting for spin1_start barrier...\n"); // Run the experiment spin1_start(); cleanup_router(); store_results(); }
static void print_rules (void) { CockpitRouter *router = NULL; CockpitTransport *transport = cockpit_interact_transport_new (0, 1, "--"); router = setup_router (transport); cockpit_router_dump_rules (router); g_object_unref (router); g_object_unref (transport); }
int main() { int result = 0; if (setup_destination()) { printf("Error initializing destination.\n"); result = 1; goto done; } if (setup_source()) { printf("Done initializing source.\n"); result = 1; goto done; } wait_ready(); if (setup_router()) { printf("Error initializing router.\n"); result = 1; goto done; } loop(); if (sent != received) { printf("Not all sent messages were received.\n"); printf("Updated value %d time%s, but received %d of them.\n", sent, sent == 1 ? "" : "s", received); result = 1; } done: cleanup_destination(); cleanup_source(); printf("Test %s.\n", result ? "FAILED" : "PASSED"); return result; }
static int run_bridge (const gchar *interactive) { CockpitTransport *transport; CockpitRouter *router; gboolean terminated = FALSE; gboolean interupted = FALSE; gboolean closed = FALSE; guint sig_term; guint sig_int; int outfd; cockpit_set_journal_logging (G_LOG_DOMAIN, !isatty (2)); /* * This process talks on stdin/stdout. However lots of stuff wants to write * to stdout, such as g_debug, and uses fd 1 to do that. Reroute fd 1 so that * it goes to stderr, and use another fd for stdout. */ outfd = dup (1); if (outfd < 0 || dup2 (2, 1) < 1) { g_warning ("bridge couldn't redirect stdout to stderr"); if (outfd > -1) close (outfd); outfd = 1; } sig_term = g_unix_signal_add (SIGTERM, on_signal_done, &terminated); sig_int = g_unix_signal_add (SIGINT, on_signal_done, &interupted); g_type_init (); cockpit_dbus_json_allow_external = FALSE; cockpit_dbus_internal_startup (interactive != NULL); if (interactive) { transport = cockpit_interact_transport_new (0, outfd, interactive); } else { transport = cockpit_pipe_transport_new_fds ("stdio", 0, outfd); } g_resources_register (cockpitassets_get_resource ()); cockpit_web_failure_resource = "/org/cockpit-project/Cockpit/fail.html"; /* Set a path if nothing is set */ g_setenv ("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 0); router = setup_router (transport); cockpit_dbus_process_startup (); g_signal_connect (transport, "closed", G_CALLBACK (on_closed_set_flag), &closed); send_init_command (transport, interactive ? TRUE : FALSE); while (!terminated && !closed && !interupted) g_main_context_iteration (NULL, TRUE); g_object_unref (router); g_object_unref (transport); g_source_remove (sig_term); g_source_remove (sig_int); /* So the caller gets the right signal */ if (terminated) raise (SIGTERM); return 0; }