Пример #1
0
void
_channel_coder_destroy(channel_state_t **ppcs, int is_encoder)
{
        channel_state_t *pcs = *ppcs;

        void (*destroy_state)(u_char**, uint32_t);

        assert(is_encoder == pcs->is_encoder);

        if (is_encoder) {
                destroy_state = table[pcs->coder].enc_destroy_state;
        } else {
                destroy_state = table[pcs->coder].dec_destroy_state;
        }

        if (destroy_state) {
                destroy_state(&pcs->state, pcs->state_len);
                pcs->state_len = 0;
        }

        assert(pcs->state     == NULL);
        assert(pcs->state_len == 0);

        xfree(pcs);
        *ppcs = NULL;
}
Пример #2
0
void
test_pipeline_uniforms (void)
{
  TestState state;

  init_state (&state);

  cogl_framebuffer_orthographic (test_fb,
                                 0, 0,
                                 cogl_framebuffer_get_width (test_fb),
                                 cogl_framebuffer_get_height (test_fb),
                                 -1,
                                 100);

  paint (&state);
  validate_result ();

  /* Try the test again after querying the location of a large
     number of uniforms. This should verify that the bitmasks
     still work even if they have to allocate a separate array to
     store the bits */

  init_long_pipeline_state (&state);
  paint (&state);
  paint_long_pipeline (&state);
  validate_result ();
  validate_long_pipeline_result ();

  destroy_state (&state);

  if (cogl_test_verbose ())
    g_print ("OK\n");
}
Пример #3
0
void
test_cogl_pipeline_uniforms (TestUtilsGTestFixture *fixture,
                             void *user_data)
{
  TestUtilsSharedState *shared_state = user_data;

  /* If shaders aren't supported then we can't run the test */
  if (cogl_features_available (COGL_FEATURE_SHADERS_GLSL))
    {
      TestState state;

      init_state (&state);

      cogl_ortho (/* left, right */
                  0, cogl_framebuffer_get_width (shared_state->fb),
                  /* bottom, top */
                  cogl_framebuffer_get_height (shared_state->fb), 0,
                  /* z near, far */
                  -1, 100);

      paint (&state);
      validate_result ();

      /* Try the test again after querying the location of a large
         number of uniforms. This should verify that the bitmasks
         still work even if they have to allocate a separate array to
         store the bits */

      init_long_pipeline_state (&state);
      paint (&state);
      paint_long_pipeline (&state);
      validate_result ();
      validate_long_pipeline_result ();

      destroy_state (&state);

      if (g_test_verbose ())
        g_print ("OK\n");
    }
  else if (g_test_verbose ())
    g_print ("Skipping\n");
}
Пример #4
0
struct state *create_state(int fd)
{
  struct state *s;

  s = malloc(sizeof(struct state));
  if(s == NULL){
    return NULL;
  }

  s->s_vector = NULL;
  s->s_count = 0;
  s->s_finished = 0;
  s->s_code = 0;

  s->s_up = create_katcl(fd);
  if(s->s_up == NULL){
    destroy_state(s);
    return NULL;
  }

  return s;
}
Пример #5
0
int main_bam2fq(int argc, char *argv[])
{
    int status = EXIT_SUCCESS;
    bam2fq_opts_t* opts = NULL;
    bam2fq_state_t* state = NULL;

    bool valid = parse_opts(argc, argv, &opts);
    if (!valid || opts == NULL) return valid ? EXIT_SUCCESS : EXIT_FAILURE;

    if (!init_state(opts, &state)) return EXIT_FAILURE;

    if (state->fpse) {
        if (!bam2fq_mainloop_singletontrack(state)) status = EXIT_FAILURE;
    } else {
        if (!bam2fq_mainloop(state)) status = EXIT_FAILURE;
    }

    if (!destroy_state(opts, state, &status)) return EXIT_FAILURE;
    sam_global_args_free(&opts->ga);
    free(opts);

    return status;
}
Пример #6
0
FUNCTION objend ()
{
	register Ocb * o;
	extern int aggressive;

  Debug

	o = xqting_ocb;

	destroy_message_vector (o);

	if ( o->centry == DCRT || o->centry == DDES )
	{
		unmark_macro ( o->ci );
	}
	else
	{
		register Msgh * n;

		for ( n = fstigb ( o->ci ); n; n = nxtigb ( n ) )
		{
			if ( n->mtype != DYNDSMSG )
				unmark_macro ( n );
		}
	}

	if ( o->centry == INIT || o->centry == DCRT || o->centry == DDES )
	{
#ifdef SOM

	/* Update the phase's highest-seen ept field to the Ept of the event
	  just completed.  Also update the amount of total unrolled back work
	  done by the phase.  */

		o->Ept = o->sb->Ept;

#endif SOM
		save_state (o);
	}

	if ( o->centry == EVENT )
	{
		o->stats.numecomp++;

		o->eventTimePermitted -= o->sb->effectWork;
#ifdef SOM
	/* Update the phase's highest-seen ept field to the Ept of the event
	  just completed.  Also update the amount of total unrolled back work
	  done by the phase.  */

		o->Ept = o->sb->Ept;

#endif SOM

		save_state ( o );
	}
	else
	if ( o->centry == TERM )
	{
#ifdef RBC
		if ( o->uses_rbc )
			l_destroy ( o->sb );
		else
		/* destroy_state and rollback chip don't mix */
#endif
		destroy_state ( o->sb );

		o->sb = NULL;
		l_destroy ( o->stk );
		o->stk = NULL;
#ifdef RBC
		if ( o->uses_rbc && rollback_op ( o, 1, posinfPlus1 ) )
		{
			printf ( "weird error term objend for %s\n", o->name );
			tester();
		}
#endif

		o->ci = NULL;
		o->co = NULL;
		o->control = EDGE;
		o->runstat = BLKINF;
		if ( ! aggressive )
			cancel_omsgs ( o, o->svt, o->phase_end );
		l_remove ( o );
		o->svt = posinfPlus1;
		l_insert ( l_prev_macro ( _prqhd ), o );
 
		dispatch ();
		return;
	}

	go_forward ( o ) ;

	dispatch ();
}
Пример #7
0
int main(int argc, char **argv)
{
  struct state *ss;
  struct child *cx;
  fd_set fsr, fsw;
  char *cmd;
  int i, j, c, mfd, fd, verbose, result, status;
  sigset_t mask_current, mask_previous;
  struct sigaction action_current, action_previous;
  pid_t pid;

  ss = create_state(STDOUT_FILENO);
  if(ss == NULL){
    return 4;
  }

#if 0
  char *app, *parm, *cmd, *copy, *ptr, *servers;
  int verbose, result, status, base, info, reply, timeout, pos, flags, show;
  int xmit, code;
  unsigned int len;
  
  info = 1;
  reply = 1;
  i = j = 1;
  app = argv[0];
  base = (-1);
  timeout = 5;
  pos = (-1);
  k = NULL;
  show = 1;
  parm = NULL;
#endif

  verbose = 1;
  i = j = 1;

  while (i < argc) {
    if (argv[i][0] == '-') {
      c = argv[i][j];
      switch (c) {

        case 'h' :
          usage(argv[0]);
          return 0;

        case 'v' : 
          verbose++;
          j++;
          break;
        case 'q' : 
          verbose = 0;
          j++;
          break;

        case '-' :
          j++;
          break;
        case '\0':
          j = 1;
          i++;
          break;

        default:
          sync_message_katcl(ss->s_up, KATCP_LEVEL_ERROR, KCPCON_NAME, "unknown option -%c", argv[i][j]);
          return 2;
      }
    } else {
#ifdef DEBUG
      fprintf(stderr, "about to start <%s>\n", argv[i]);
#endif
      if(string_launch_child(ss, argv[i]) < 0){
        sync_message_katcl(ss->s_up, KATCP_LEVEL_ERROR, KCPCON_NAME, "unable to start <%s>", argv[i]);
        return 4;
      }
      i++;
    }
  }

  sigprocmask(SIG_SETMASK, NULL, &mask_current);
  sigaddset(&mask_current, SIGCHLD);

  action_current.sa_handler = &handle_child;
  action_current.sa_flags = SA_NOCLDSTOP;
  sigfillset(&(action_current.sa_mask));
  sigaction(SIGCHLD, &action_current, &action_previous);

  sigprocmask(SIG_SETMASK, &mask_current, &mask_previous);

  sigemptyset(&mask_current);
#if 0
  sigaddset(&mask_current, SIGTERM);
#endif

  for(ss->s_finished = 0; ss->s_finished < ss->s_count;){


    mfd = 0;

    FD_ZERO(&fsr);
    FD_ZERO(&fsw);

    if(flushing_katcl(ss->s_up)){
      mfd = fileno_katcl(ss->s_up);
      FD_SET(mfd, &fsw);
    }

    for(i = 0; i < ss->s_count; i++){
      cx = ss->s_vector[i];
      if(cx->c_line){
        fd = fileno_katcl(cx->c_line);
        if(fd > mfd){
          mfd = fd;
        }
        FD_SET(fd, &fsr);
      } 
    }

    result = pselect(mfd + 1, &fsr, &fsw, NULL, NULL, &mask_current);
#ifdef DEBUG
    fprintf(stderr, "select returns %d\n", result);
#endif
    switch(result){
      case -1 :
        switch(errno){
          case EAGAIN :
          case EINTR  :
            continue; /* WARNING */
          default  :
            sync_message_katcl(ss->s_up, KATCP_LEVEL_ERROR, KCPCON_NAME, "select failed: %s", strerror(errno));
            return 4;
        }
        break;
      case  0 :
        sync_message_katcl(ss->s_up, KATCP_LEVEL_ERROR, KCPCON_NAME, "requests timed out despite having no timeout");
        /* could terminate cleanly here, but ... */
        return 4;
    }


    fd = fileno_katcl(ss->s_up);
    if(FD_ISSET(fd, &fsw)){
      result = write_katcl(ss->s_up);
    }

    for(i = 0; i < ss->s_count; i++){
      cx = ss->s_vector[i];
      if(cx->c_line){
        fd = fileno_katcl(cx->c_line);

        if(FD_ISSET(fd, &fsr)){ /* get things */
          result = read_katcl(cx->c_line);
          if(result){
            if(result < 0){
              sync_message_katcl(ss->s_up, KATCP_LEVEL_ERROR, KCPCON_NAME, "read failed: %s", strerror(error_katcl(cx->c_line)));
            } else {
              if(cx->c_pid > 0){
                log_message_katcl(ss->s_up, KATCP_LEVEL_DEBUG, KCPCON_NAME, "subordinate job %u ended", cx->c_pid);
              }
            }
            destroy_katcl(cx->c_line, 1);
            cx->c_line = NULL;
            ss->s_finished++;
            continue; /* WARNING */
          }
        }

        while(have_katcl(cx->c_line) > 0){ /* compute */
          cmd = arg_string_katcl(cx->c_line, 0);
          if(cmd){
#ifdef DEBUG
            fprintf(stderr, "reading message <%s ...>\n", cmd);
#endif
            switch(cmd[0]){
              case KATCP_INFORM : 
#if 0
                if(!strcmp(KATCP_VERSION_CONNECT_INFORM, cmd)){
                }
                if(!strcmp(KATCP_VERSION_INFORM, cmd)){
                }
                if(!strcmp(KATCP_BUILD_STATE_INFORM, cmd)){
                }
#endif
                relay_katcl(cx->c_line, ss->s_up);
                break;
            }
          }
        }
      }
    }

    /* the position of this logic is rather intricate */
    if(got_child_signal){
      got_child_signal = 0;
      while((pid = waitpid(WAIT_ANY, &status, WNOHANG)) > 0){
        for(i = 0; i < ss->s_count; i++){
          cx = ss->s_vector[i];
          if(cx->c_pid == pid){

            if (WIFEXITED(status)) {
              result = WEXITSTATUS(status);
              log_message_katcl(ss->s_up, KATCP_LEVEL_DEBUG, KCPCON_NAME, "subordinate job[%u] %u exited with code %d", i, cx->c_pid, result);
              cx->c_status = (result > 4) ? 4 : result;
            } else if (WIFSIGNALED(status)) {
              result = WTERMSIG(status);
              log_message_katcl(ss->s_up, KATCP_LEVEL_WARN, KCPCON_NAME, "subordinate job[%u] %u killed by signal %d", i, cx->c_pid, result);
              cx->c_status = 4;
            } else {
              log_message_katcl(ss->s_up, KATCP_LEVEL_WARN, KCPCON_NAME, "subordinate job[%u] %u return unexpected status %d", i, cx->c_pid, status);
              cx->c_status = 4;
            }

            if(cx->c_status > ss->s_code){
              ss->s_code = cx->c_status;
            }

            cx->c_pid = (-1);
          }
        }
      }
    }
  }

  /* force drain */
  while(write_katcl(ss->s_up) == 0);

  result = ss->s_code;

  destroy_state(ss);

  /* WARNING: pointlessly fussy */
  sigaction(SIGCHLD, &action_previous, NULL);
  sigprocmask(SIG_BLOCK, &mask_previous, NULL);

  return result;
}