Esempio n. 1
0
/*
 * abort() - terminate current process with dump via SIGABRT
 */
void
abort(void)
{
	sigset_t	set;
	struct sigaction	act;

	if (!sigaction(SIGABRT, NULL, &act) &&
	    act.sa_handler != SIG_DFL && act.sa_handler != SIG_IGN) {
		/*
		 * User handler is installed, invokes user handler before
		 * taking default action.
		 *
		 * Send SIGABRT, unblock SIGABRT if blocked.
		 * If there is pending signal SIGABRT, we only need to unblock
		 * SIGABRT.
		 */
		if (!sigprocmask(SIG_SETMASK, NULL, &set) &&
		    sigismember(&set, SIGABRT)) {
			if (!sigpending(&set) && !sigismember(&set, SIGABRT))
				(void) raise(SIGABRT);
			(void) sigrelse(SIGABRT);
		} else
			(void) raise(SIGABRT);
	}

	if (++pass == 1)
		__cleanup();

	for (;;) {
		(void) signal(SIGABRT, SIG_DFL);
		(void) sigrelse(SIGABRT);
		(void) raise(SIGABRT);
	}
}
Esempio n. 2
0
int stopPLC()
{
    /* Stop the PLC */
    PLC_shutdown = 1;

    /* Wait until PLC task stops */
    rt_task_join(&PLC_task);

    PLC_cleanup_all();
    __cleanup();
    __debug_tick = -1;
    return 0;
}
Esempio n. 3
0
bool Mutation::mutate(Module *m, CfgMutationNode *den, CfgMutationEdge *dee)
{
  VLOG(50) << ">> mutate";
  m->setModified(false);

  CfgMutationEdge *e = dee;
  CfgMutationNode *n = den;

  if(m->mutation() != NULL)
  {
    e = m->mutation()->edge();
    n = m->mutation()->node();
    VLOG(50) << "** Found module specific mutation parameters:" << m->name();
    VLOG(50) << *n;
    VLOG(50) << *e;
  }
  else
  {
    VLOG(50) << "## Did not find module specific mutation parameters:" << m->name();
    VLOG(50) << *n;
    VLOG(50) << *e;
  }

  m->setModified(false);
  VLOG(50) << "### BEFORE MUTATION";
  LOG_MODULE;
  __mutateDelEdge(m,    e->delProbability());
  __mutateModifyEdge(m, e->modifyProbability(),
                        e->modifyDelta(),
                        e->modifyMaxValue());
  __mutateModifyNode(m, n->modifyProbability(),
                        n->modifyDelta(),
                        n->modifyMaxValue());
  __mutateDelNode(m,    n->delProbability());
  __mutateAddNode(m,    n->addProbability(),
                        n->addMaxValue());
  __mutateAddEdge(m,    e->addProbability(),
                        e->addMaxValue(),
                        e->minDistance());
  // __mutateAddSelf(m,    e->selfProbability(),
                        // e->selfMaxValue());
  __cleanup(m);
  VLOG(50) << "<< mutate";
  VLOG(50) << "### AFTER MUTATION";
  LOG_MODULE;
  VLOG(50) << "### AFTER MUTATION";
  return m->modified();
}
Esempio n. 4
0
int stopPLC(void)
{
    __cleanup();
    return 0;
}
Esempio n. 5
0
int main(int argc, char *argv[])
{
    if (2 > argc)
    {
        fprintf(stderr, "Usage: %s <server-address> [<port>]\n", argv[0]);
        return -1;
    }

    unsigned short port = 0;
    if (2 < argc)
    {
        port = (unsigned short) atoi(argv[2]);
        if (!port)
        {
            port = PORT;
        }
    }

    check_mem(shoots = DYNAMIC_ARRAY_CREATE(NotViewerShellEvent *, 16));
    check_mem(explosions = DYNAMIC_ARRAY_CREATE(NotViewerShellEvent *, 16));

    check(client_net_start(), "Failed to initialize net.", "");
    check(client_connect(&viewer_protocol, argv[1], port, false), "Failed to connect.", "");

    puts("Connected to server.");

    l = client_get_landscape(&viewer_protocol);
    check(l, "Failed to get landscape.", "");
    puts("Loaded landscape.");

    camera.x = camera.y = l->landscape_size / 2.0 * l->tile_size;

    check(__init_video(&camera), "Failed to init video.", "");

    check(0 != (display_lists = glGenLists(DISPLAY_LISTS_COUNT)), "Failed to create display list.", "");

    glNewList(display_lists + LANDSCAPE_DISPLAY_LIST, GL_COMPILE);
    check(GL_NO_ERROR == glGetError(), "Failed to create display list.", "");
    draw_landscape(l);
    glEndList();

    glNewList(display_lists + TANK_BODY_DISPLAY_LIST, GL_COMPILE);
    check(GL_NO_ERROR == glGetError(), "Failed to create display list.", "");
    draw_tank_body();
    glEndList();

    glNewList(display_lists + TANK_TURRET_DISPLAY_LIST, GL_COMPILE);
    check(GL_NO_ERROR == glGetError(), "Failed to create display list.", "");
    draw_tank_turret();
    glEndList();

    glNewList(display_lists + TANK_GUN_DISPLAY_LIST, GL_COMPILE);
    check(GL_NO_ERROR == glGetError(), "Failed to create display list.", "");
    draw_tank_gun();
    glEndList();

    while (working)
    {
        bool need_redraw = false;
        if (!process_events(&need_redraw, &camera, tanks, &tanks_count, &viewer_protocol))
        {
            break;
        }

        if (need_redraw)
        {
            draw(l, tanks, tanks_count, &camera, &display_lists, shoots, explosions);
        }
    }

    __cleanup();
    return 0;

    error:
    __cleanup();
    return -1;
}