Example #1
0
/**
 * Chain node: execute left operand and decide whether to run
 * the right one based on left one's return value
 */
static int do_chain(CommandNode *node)
{
  int retval;
  int exec_second;

  retval = do_execute(node->op1);
  switch (node->type)
  {
    case CN_CHAIN:
      exec_second = 1;
      break;
    case CN_AND:
      exec_second = !retval;
      break;
    case CN_OR:
      exec_second = retval;
      break;

    default: /* this isn't going to happen */
      assert(0);
  }
  if (exec_second)
    return do_execute(node->op2);
  else
    return retval;
}
Example #2
0
int execute(CommandNode *node)
{
  if (node==NULL)
    return 0;
  else if (node->type==CN_SUBSHELL)
    return do_execute(node->op1);
  else
    return do_execute(node);
}
Example #3
0
		void do_checked_execute(const std::vector<std::basic_string<CharType>>& args)
		{
			if (do_execute(args) != 0)
			{
				throw boost::system::system_error(make_error_code(executeplus_error::external_process_failed));
			}
		}
Example #4
0
static void do_int(Z80Context* ctx)
{
    unhalt(ctx);
	ctx->IFF1 = 0;
	ctx->IFF2 = 0;
	ctx->int_req = 0;
    if (ctx->IM == 0)
    {
		ctx->exec_int_vector = 1;
		do_execute(ctx);
		ctx->exec_int_vector = 0;
    }
    else if (ctx->IM == 1)
    {
        doPush(ctx, ctx->PC);
        ctx->PC = 0x0038;
		ctx->tstates += 7;
    }
    else if (ctx->IM == 2)
    {
        doPush(ctx, ctx->PC);
		ushort vector_address = (ctx->I << 8) | ctx->int_vector;
		ctx->PC = read16(ctx, vector_address);
		ctx->tstates += 7;
    }
}
Example #5
0
      void
      executable::execute(context::swap& a)
      {
        TRACE("hugh::render::interface::executable::execute");

        do_execute(a);
      }
void OSLShaderGroupExec::execute_shading(
    const ShaderGroup&              shader_group,
    const ShadingPoint&             shading_point) const
{
    do_execute(
        shader_group,
        shading_point,
        shading_point.get_ray().m_flags);
}
void OSLShaderGroupExec::execute_npr(
    const ShaderGroup&              shader_group,
    const ShadingPoint&             shading_point) const
{
    do_execute(
        shader_group,
        shading_point,
        VisibilityFlags::NPRRay);
}
Example #8
0
File: job.c Project: Tayyib/uludag
static int
do_call_package(int node, const char *app, struct pack *p)
{
	log_debug(LOG_JOB, "CallPackage(%s,%s)\n", model_get_path(node), app);

	do_execute(node, app, p);

	return 0;
}
void OSLShaderGroupExec::execute_subsurface(
    const ShaderGroup&              shader_group,
    const ShadingPoint&             shading_point) const
{
    do_execute(
        shader_group,
        shading_point,
        VisibilityFlags::SubsurfaceRay);
}
void OSLShaderGroupExec::execute_emission(
    const ShaderGroup&              shader_group,
    const ShadingPoint&             shading_point) const
{
    do_execute(
        shader_group,
        shading_point,
        VisibilityFlags::LightRay);
}
void OSLShaderGroupExec::execute_transparency_and_matte(
    const ShaderGroup&              shader_group,
    const ShadingPoint&             shading_point) const
{
    do_execute(
        shader_group,
        shading_point,
        VisibilityFlags::TransparencyRay);
}
Example #12
0
File: job.c Project: Tayyib/uludag
static int
do_call(int node)
{
	char *apps;

	log_debug(LOG_JOB, "Call(%s)\n", model_get_path(node));

	if (db_get_apps(model_parent(node), &apps) != 0) {
		send_result(CMD_ERROR, "no app", 6);
		exit(1);
	}

	if (strchr(apps, '/') == NULL) {
		// there is only one script
		do_execute(node, apps);
	} else {
		// multiple scripts, run concurrently
		char *t, *s;
		struct ProcChild *p;
		int cmd;
		int cnt = 0;
		size_t size;

		// FIXME: package count
		send_result(CMD_RESULT_START, NULL, 0);
		for (t = apps; t; t = s) {
			s = strchr(t, '/');
			if (s) {
				*s = '\0';
				++s;
			}
			bk_node = node;
			bk_app = t;
			p = proc_fork(exec_proc, "SubJob");
			if (p) {
				++cnt;
			} else {
				send_result(CMD_ERROR, "fork failed", 11);
			}
		}
		while(1) {
			struct ipc_data *ipc;
			proc_listen(&p, &cmd, &size, -1);
			if (cmd == CMD_FINISH) {
				--cnt;
				if (!cnt) break;
			} else {
				proc_recv(p, &ipc, size);
				proc_send(TO_PARENT, cmd, ipc, size);
			}
		}
		send_result(CMD_RESULT_END, NULL, 0);
	}

	return 0;
}
Example #13
0
/**
 * Background node: fork and execute left operand in background, while 
 * continuing to do_execute right operand
 */
static int do_background(CommandNode *node)
{
  pid_t pid;

  if (((pid=fork()))==0)
  {
    /* child */
    exit(do_execute(node->op1));
  }
  else if (pid>0)
  {
    trace("Spawned bg process %d", pid);
    return do_execute(node->op2);
  }
  else
  {
    perror("do_background");
    exit(1);
  }
}
void OSLShaderGroupExec::execute_transparency(
    const ShaderGroup&              shader_group,
    const ShadingPoint&             shading_point,
    Alpha&                          alpha) const
{
    do_execute(
        shader_group,
        shading_point,
        VisibilityFlags::TransparencyRay);

    process_transparency_tree(shading_point.get_osl_shader_globals().Ci, alpha);
}
Example #15
0
void Z80Execute (Z80Context* ctx)
{
	if (ctx->nmi_req)
		do_nmi(ctx);
	else if (ctx->int_req && !ctx->defer_int && ctx->IFF1)
		do_int(ctx);
	else
	{
		ctx->defer_int = 0;
		do_execute(ctx);
	}
}
Example #16
0
/*
 * Execute command on a filename that can be on VFS.
 * Errors are reported to the user.
 */
void
execute_with_vfs_arg (const char *command, const char *filename)
{
    char *localcopy;
    char *fn;
    struct stat st;
    time_t mtime;

    /* Simplest case, this file is local */
    if (!filename || vfs_file_is_local (filename)) {
	do_execute (command, filename, EXECUTE_INTERNAL);
	return;
    }

    /* FIXME: Creation of new files on VFS is not supported */
    if (!*filename)
	return;

    localcopy = mc_getlocalcopy (filename);
    if (localcopy == NULL) {
	message (1, MSG_ERROR, _(" Cannot fetch a local copy of %s "),
		 filename);
	return;
    }

    /*
     * filename can be an entry on panel, it can be changed by executing
     * the command, so make a copy.  Smarter VFS code would make the code
     * below unnecessary.
     */
    fn = g_strdup (filename);
    mc_stat (localcopy, &st);
    mtime = st.st_mtime;
    do_execute (command, localcopy, EXECUTE_INTERNAL);
    mc_stat (localcopy, &st);
    mc_ungetlocalcopy (fn, localcopy, mtime != st.st_mtime);
    g_free (localcopy);
    g_free (fn);
}
Example #17
0
TInt CPARAM_MESS_NAMEStep::Exec_SendReceive()
	{
	_LIT(KEsockSessStartMutex,"KESSMTX"); //Keep the descriptor short
	RMutex mutex;
	TInt r;
	// Protect the openning of the session
	// with a mutex to stop thread collision
	FOREVER
		{
		r = mutex.CreateGlobal(KEsockSessStartMutex());
		if (r == KErrNone)
			break;
		if (r != KErrAlreadyExists)
			return r;
		r=mutex.OpenGlobal(KEsockSessStartMutex());
		if (r == KErrNone)
			break;
		if (r != KErrNotFound)
			return r;
		}
	mutex.Wait(); // the exclusion ensures the session is started atomically
	iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version());
	// Because ESock is now loaded by the Comms Root Server which is generally started during
	// the boot this should commonly succeed; however for test code this is still a possibility
	// Hence here we try starting it; this is an atomic operation (and cheap if it's already started)
	if (iResult_Server==KErrNotFound)
		{
		r=StartC32();
		if (r==KErrNone || r==KErrAlreadyExists)
			{
			iResult_Server=CreateSession(SOCKET_SERVER_NAME,Version());
			}
		}
	mutex.Signal();
	mutex.Close();

	if (iResult_Server == KErrNone)
		{
		iSessionCreated = ETrue;

		const TInt test_id = dispatch_num<PARAM_MESS_VALUE>::result;

		iResult_SR = do_execute(Int2Type<test_id>());
		}
	else
		{
		iSessionCreated = EFalse;
		return 0;
		}
	return r;
	}
Example #18
0
File: execute.c Project: LubkaB/mc
void
shell_execute (const char *command, int flags)
{
    char *cmd = NULL;

    if (flags & EXECUTE_HIDE)
    {
        cmd = g_strconcat (" ", command, (char *) NULL);
        flags ^= EXECUTE_HIDE;
    }

#ifdef ENABLE_SUBSHELL
    if (mc_global.tty.use_subshell)
        if (subshell_state == INACTIVE)
            do_execute (mc_global.tty.shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);
        else
            message (D_ERROR, MSG_ERROR, _("The shell is already running a command"));
    else
#endif /* ENABLE_SUBSHELL */
        do_execute (mc_global.tty.shell, cmd ? cmd : command, flags | EXECUTE_AS_SHELL);

    g_free (cmd);
}
Example #19
0
static int do_go(int argc, char *argv[])
{
	void	*addr;
	int     rcode = 1;
	int	fd = -1;
	int	(*func)(int argc, char *argv[]);

	if (argc < 2)
		return COMMAND_ERROR_USAGE;

	if (!isdigit(*argv[1])) {
		fd = open(argv[1], O_RDONLY);
		if (fd < 0) {
			perror("open");
			goto out;
		}

		addr = memmap(fd, PROT_READ);
		if (addr == (void *)-1) {
			perror("memmap");
			goto out;
		}
	} else
		addr = (void *)simple_strtoul(argv[1], NULL, 16);

	printf("## Starting application at 0x%p ...\n", addr);

	console_flush();

	func = addr;

	shutdown_barebox();

	if (do_execute)
		do_execute(func, argc - 1, &argv[1]);
	else
		func(argc - 1, &argv[1]);

	/*
	 * The application returned. Since we have shutdown barebox and
	 * we know nothing about the state of the cpu/memory we can't
	 * do anything here.
	 */
	while (1);
out:
	if (fd > 0)
		close(fd);

	return rcode;
}
void OSLShaderGroupExec::execute_bump(
    const ShaderGroup&              shader_group,
    const ShadingPoint&             shading_point,
    const Vector2f&                 s) const
{
    // Choose between BSSRDF and BSDF.
    if (shader_group.has_subsurface() && s[0] < 0.5f)
    {
        do_execute(
            shader_group,
            shading_point,
            VisibilityFlags::SubsurfaceRay);

        CompositeSubsurfaceClosure c(
            Basis3f(shading_point.get_shading_basis()),
            shading_point.get_osl_shader_globals().Ci,
            m_arena);

        // Pick a shading basis from one of the BSSRDF closures.
        if (c.get_closure_count() > 0)
        {
            const size_t index = c.choose_closure(s[1]);
            shading_point.set_shading_basis(
                Basis3d(c.get_closure_shading_basis(index)));
        }
    }
    else
    {
        do_execute(
            shader_group,
            shading_point,
            VisibilityFlags::CameraRay);

        choose_bsdf_closure_shading_basis(shading_point, s);
    }
}
Example #21
0
File: execute.c Project: LubkaB/mc
void
execute_with_vfs_arg (const char *command, const vfs_path_t * filename_vpath)
{
    vfs_path_t *localcopy_vpath = NULL;
    const vfs_path_t *do_execute_vpath;
    time_t mtime;

    if (!execute_prepare_with_vfs_arg (filename_vpath, &localcopy_vpath, &mtime))
        return;

    do_execute_vpath = (localcopy_vpath == NULL) ? filename_vpath : localcopy_vpath;

    do_execute (command, vfs_path_get_last_path_str (do_execute_vpath), EXECUTE_INTERNAL);

    execute_cleanup_with_vfs_arg (filename_vpath, &localcopy_vpath, &mtime);
}
Example #22
0
void action_result::execute()
{
	is_execution_ = true;
	init_for_execution();
	check_before();
	if (is_success()){
		try {
			do_execute();
		} catch (return_to_play_side_exception&) {
			if (!is_ok()) { DBG_AI_ACTIONS << "Return value of AI ACTION was not checked." << std::endl; } //Demotes to DBG "unchecked result" warning
			throw;
		}
	}
	if (is_success()){
		check_after();
	}
	is_execution_ = false;
}
Example #23
0
static void
workloop( void *x )
{
	idev_t *idev = (idev_t*)x;
	scsi_ureq_t *u;

	for( ;; ) {
		LOCK( idev );
		if( !(u=idev->rqueue) )
			break;
		idev->rqueue = u->next;
		UNLOCK( idev );

		do_execute( u, idev );
	}

	idev->running = 0;
	UNLOCK( idev );
}
Example #24
0
void action_result::execute()
{
	is_execution_ = true;
	init_for_execution();
	check_before();
	if (is_success()){
		do_execute();
		try {
			resources::controller->check_victory();
		} catch (...) {
			is_ok(); //Silences "unchecked result" warning
			throw;
		}
	}
	if (is_success()){
		check_after();
	}
	is_execution_ = false;
}
Example #25
0
/**
 * Subshell node: fork synchronously and setup environment for subshell 
 */
static int do_subshell(CommandNode *node)
{
  pid_t pid;

  if (((pid = fork())) == 0)
  {
    /* child */
    setup_redirections(node);
    exit(do_execute(node->op1));
    /* noreturn */
  }
  else if (pid > 0)
  {
    /* parent */
    return check_wait(pid);
  }
  /* else */ 
  perror("do_subshell");
  exit(1);
}
Example #26
0
//------------------------------------------------------------------------------
// Function: process_state_executing_nonruntime
//
// Parameters:
//------------------------------------------------------------------------------
void uvm_common_phase::process_state_executing_nonruntime(sc_core::sc_module *pmod)
{
    std::ostringstream outmsg;

    if (get_phase_type() != UVM_POSTRUN_PHASE) { // postrun phases are not generalized yet
        int result = do_execute(pmod);

        if (result && (CHECK_STOP_AT_PHASE_END() == true)) {
            SC_REPORT_INFO(UVM_PHASE_CTRL_STOP_USER, "");
#ifdef UVM_ML_PORTABLE
            // TODO - should be be incorporated into the phase controller instead?
            sc_get_curr_simcontext()->stop();
#endif
	    //  result = 0;
        }
    }
    else {
        uvm_component* pcomp = DCAST<uvm_component*>(pmod); 
        if (pcomp != NULL) {
            if (_name.compare("final") == 0)
                pcomp->final_phase(this);
            else if (_name.compare("extract") == 0)
                pcomp->extract_phase(this);
            else if (_name.compare("check") == 0)
                pcomp->check_phase(this);
            else if (_name.compare("report") == 0)
                pcomp->report_phase(this);
            else
            {
                outmsg << _name << endl;
                SC_REPORT_FATAL(UVM_PHASE_UNKNOWN, outmsg.str().c_str());
                exit(1);        // TODO - is 'exit()' needed here after a FATAL?
            }
        }
    }
}
Example #27
0
void
exec_shell (void)
{
    do_execute (shell, 0, 0);
}
Example #28
0
File: execute.c Project: LubkaB/mc
void
exec_shell (void)
{
    do_execute (mc_global.tty.shell, 0, 0);
}
Example #29
0
File: job.c Project: Tayyib/uludag
static void
exec_proc(void)
{
	do_execute(bk_node, bk_app, bk_pak);
}
Example #30
0
File: job.c Project: Tayyib/uludag
static int
do_call(int node, struct pack *pak)
{
	struct pack *p = NULL;
	char *apps;
	int ok = 0;

	log_debug(LOG_JOB, "Call(%s)\n", model_get_path(node));

	if (model_flags(node) & P_GLOBAL) {
		p = pack_dup(pak);
	}

	if (db_get_apps(model_parent(node), &apps) != 0) {
		send_result(CMD_NONE, "noapp", 5);
		// FIXME: ok diyecek betik yoksa profile kayıt etmeli mi acaba
		exit(1);
	}

	if (strchr(apps, '/') == NULL) {
		// there is only one script
		if (0 == do_execute(node, apps, pak))
			ok = 1;
	} else {
		// multiple scripts, run concurrently
		char *t, *s;
		struct ProcChild *p;
		int cmd;
		int cnt = 0;
		size_t size;

		// FIXME: package count
		send_result(CMD_RESULT_START, NULL, 0);
		for (t = apps; t; t = s) {
			s = strchr(t, '/');
			if (s) {
				*s = '\0';
				++s;
			}
			bk_node = node;
			bk_app = t;
			bk_pak = pak;
			p = proc_fork(exec_proc, "ComarSubJob");
			if (p) {
				++cnt;
			} else {
				send_result(CMD_ERROR, "fork failed", 11);
			}
		}
		while(1) {
			struct ipc_struct ipc;
			struct pack *pak;
			pak = pack_new(128);
			proc_listen(&p, &cmd, &size, -1);
			if (cmd == CMD_FINISH) {
				--cnt;
				if (!cnt) break;
			} else {
				if (cmd == CMD_RESULT) ok++;
				proc_get(p, &ipc, pak, size);
				proc_put(TO_PARENT, cmd, &ipc, pak);
			}
		}
		send_result(CMD_RESULT_END, NULL, 0);
	}

    if ((model_flags(node) & P_GLOBAL) && ok) {
		db_put_profile(node, NULL, p);
		pack_delete(p);
	}

	return 0;
}