Ejemplo n.º 1
0
static void colourgui_set_colour_option(Options *colour_scheme,
        const char *opt_name, const char *colour_name,
        void (*set_fn)(Options *, const char *))
{
    set_fn(colour_scheme, colour_name);
    capplet_set_string(colour_scheme, opt_name, colour_name);
}
Ejemplo n.º 2
0
static int _clk_set_rate(struct clk *clk, unsigned long rate,
			 int (*set_fn)(struct clk *, unsigned long))
{
	unsigned long start_rate, flags;
	int rc;

	if (!set_fn)
		return -ENOSYS;

	spin_lock_irqsave(&clk->lock, flags);
	if (clk->count) {
		start_rate = clk->rate;
		/* Enforce vdd requirements for target frequency. */
		rc = vote_rate_vdd(clk, rate);
		if (rc)
			goto err_vote_vdd;
		rc = set_fn(clk, rate);
		if (rc)
			goto err_set_rate;
		/* Release vdd requirements for starting frequency. */
		unvote_rate_vdd(clk, start_rate);
	} else {
		rc = set_fn(clk, rate);
	}

	if (!rc)
		clk->rate = rate;

	spin_unlock_irqrestore(&clk->lock, flags);
	return rc;

err_set_rate:
	unvote_rate_vdd(clk, rate);
err_vote_vdd:
	spin_unlock_irqrestore(&clk->lock, flags);
	return rc;
}
Ejemplo n.º 3
0
/* ------------------------------------------------------------------
 * *** INTERRUPT HANDLER ***
 * Sets up transfer table changes needed for:
 *   - Synchronous handling of asynchronous events.
 *   - Single-stepping and breakpoints
 * Note:
 *   - Call here from a routine specific to each event type.
 *   - Pass in a single value to pass on to xfer_table set function
 *     for that type. Calling routine should record any other event
 *     info, if needed, in volatile global variables.
 *   - If this is first event logged, will call back to the function
 *     provided and pass along parameter.
 * Future:
 *   - mdb_condition_handler does not call here -- should change it.
 *   - Ditto for routines related to zbreak and zstep.
 *   - Should put handler prototypes in a header file & include it here,
 *     if can use with some way to ensure type checking.
 *   - A higher-level interface (e.g. change sets) might be better.
 * ------------------------------------------------------------------
 */
boolean_t xfer_set_handlers(int4  event_type, void (*set_fn)(int4 param), int4 param_val)
{
	boolean_t 	is_first_event = FALSE;

	/* ------------------------------------------------------------
	 * Keep track of what event types have come in.
	 * - Get and set value atomically in case of concurrent
	 *   events and/or resetting while setting.
	 * ------------------------------------------------------------------
	 * Use interlocked operations to prevent races between set and reset,
	 * and to avoid missing overlapping sets.
	 * On HPUX-HPPA:
	 *    OK only if there's no a risk a conflicting operation is
	 *    in progress  (can deadlock in micro-lock).
	 * On all platforms:
	 *    Don't want I/O from a sensitive area.
	 * Avoid both by testing fast_lock_count, and doing interlocks and
	 * I/O only if it is non-zero. Can't be resetting then, so worst
	 * risk is missing an event when there's already one happening.
	 * ------------------------------------------------------------------
	 */
	VMS_ONLY(assert(lib$ast_in_prog()));
	if (fast_lock_count == 0)
	{
		DBGDFRDEVNT((stderr, "xfer_set_handlers: Before interlocked operations:  "
			     "xfer_table_events[%d]=%d, first_event=%s, num_deferred=%d\n",
			     event_type, xfer_table_events[event_type], (is_first_event ? "TRUE" : "FALSE"),
			     num_deferred));
		if (1 == INCR_CNT_SP(&xfer_table_events[event_type], &defer_latch))
			/* Concurrent events can collide here, too */
			is_first_event =  (1 == INCR_CNT_SP(&num_deferred, &defer_latch));
		DBGDFRDEVNT((stderr, "xfer_set_handlers: After interlocked operations:   "
			     "xfer_table_events[%d]=%d, first_event=%s, num_deferred=%d\n",
			     event_type,xfer_table_events[event_type], (is_first_event ? "TRUE" : "FALSE"),
			     num_deferred));
	} else if (1 == ++xfer_table_events[event_type])
		is_first_event = (1 == ++num_deferred);
	if (is_first_event)
	{
		first_event = event_type;
#		ifdef DEBUG_DEFERRED_EVENT
		if (0 != fast_lock_count)
			DBGDFRDEVNT((stderr, "xfer_set_handlers: Setting xfer_table for event type %d\n",
				     event_type));
#		endif
		/* -------------------------------------------------------
		 * If table changed, it was not synchronized.
		 * (Assumes these entries are all that would be changed)
		 * Note asserts bypassed for Itanium due to nature of the
		 * fixed up addresses making direct comparisions non-trivial.
		 * --------------------------------------------------------
		 */
#		ifndef __ia64
		assert((xfer_table[xf_linefetch] == op_linefetch) ||
		       (xfer_table[xf_linefetch] == op_zstepfetch) ||
		       (xfer_table[xf_linefetch] == op_zst_fet_over) ||
		       (xfer_table[xf_linefetch] == op_mproflinefetch));
		assert((xfer_table[xf_linestart] == op_linestart) ||
		       (xfer_table[xf_linestart] == op_zstepstart) ||
		       (xfer_table[xf_linestart] == op_zst_st_over) ||
		       (xfer_table[xf_linestart] == op_mproflinestart));
		assert((xfer_table[xf_zbfetch] == op_zbfetch) ||
		       (xfer_table[xf_zbfetch] == op_zstzb_fet_over) ||
		       (xfer_table[xf_zbfetch] == op_zstzbfetch));
		assert((xfer_table[xf_zbstart] == op_zbstart) ||
		       (xfer_table[xf_zbstart] == op_zstzb_st_over) ||
		       (xfer_table[xf_zbstart] == op_zstzbstart));
		assert((xfer_table[xf_forchk1] == op_forchk1) ||
		       (xfer_table[xf_forchk1] == op_mprofforchk1));
		assert((xfer_table[xf_forloop] == op_forloop));
		assert(xfer_table[xf_ret] == opp_ret ||
		       xfer_table[xf_ret] == opp_zst_over_ret ||
		       xfer_table[xf_ret] == opp_zstepret);
		assert(xfer_table[xf_retarg] == op_retarg ||
		       xfer_table[xf_retarg] == opp_zst_over_retarg ||
		       xfer_table[xf_retarg] == opp_zstepretarg);
#		endif /* !IA64 */
		/* -----------------------------------------------
		 * Now call the specified set function to swap in
		 * the desired handlers (and set flags or whatever).
		 * -----------------------------------------------
		 */
		DBGDFRDEVNT((stderr, "xfer_set_handlers: Driving event setup handler\n"));
		set_fn(param_val);
	}
#	ifdef DEBUG_DEFERRED_EVENT
	else if (0 != fast_lock_count)
	{
		DBGDFRDEVNT((stderr, "xfer_set_handlers: ---Multiple deferred events---\n"
			     "Event type %d occurred while type %d was pending\n", event_type, first_event));
	} else
	{
		DBGDFRDEVNT((stderr, "xfer_set_handlers: Event bypassed -- was not first event\n"));
	}
#	endif
 	assert(no_event != first_event);
	return is_first_event;
}
Ejemplo n.º 4
0
int exec_cmd(int under_glob, int under_until)
	{
	register int status;
	register char *p;
	int n;

	if((status = getrange()) <= ERROR)
		return( status );
	status = ERROR9;

	switch( *lp++ ) {

	case 'i':
		laddr2 = prevln(laddr2);

	case 'a':
		status = append(laddr2, under_glob);
		break;

	case 'b':
			if(!under_glob  &&  !under_until)
				status = branch();
		break;

	case 'c':
		if((status = delete(laddr1, laddr2, SAVE)) == OK)
			status = append(prevln(laddr1), under_glob);
		break;

	case 'd':
		if((status = delete(laddr1, laddr2, SAVE)) == OK && nextln(curln) != 0)
			curln = nextln(curln);
		break;

	case 'e':
		if(lastln  &&  dirty  &&  *lp != 'e') {
			status = ERROR4;
			break;
			}

		if(*lp == 'e')
			++lp;

		if(nladdrs == 0  &&  !under_glob  &&  !under_until  &&
			(status = getfn()) == OK) {
			set_fn(curfile, lp);
			if(lastln != 0)
				delete(1, lastln, NOSAVE);
			num_delete_lines = 0;
			if((status = _read( lp, 0, 0)) == OK) {
				dirty = 0;
				if(lastln)
					curln = 1;
				}
			}
		lp = "\n";
		break;

	case 'f':
		if(nladdrs == 0  &&  (status = getfn()) == OK) {
			set_fn(curfile, lp);
			putmsg(curfile);
			lp = "\n";
			}
		change_state(CMD);
		break;

	case 'g':
		if(!under_glob) {
			if(*lp == '^') {
				++lp;
				n = 0;
				}
			else
				n = 1;
			status = exec_glob(n, under_until);
			}
		break;

	case 'h':
		n = getint();
#ifndef __STDC__
		while(n--)
			for(n1 = 0; n1 < 10; ++n1)
				time_slice();
#endif
		status = OK;
		break;

	case 'j':
		status = join(laddr2);
		break;

	case 'k':
		if((status = get_laddr_expr(&n)) == OK)
			status = kopy(n);
		break;

	case 'l':
		if(nladdrs == 0)
			status = learn();
		break;

	case 'm':
		if((status = get_laddr_expr(&n)) == OK)
			status = move(n);
		break;

	case 'o':
		status = option();
		break;

	case 'p':
	case 'P':
		status = prnt(laddr1, laddr2);
		break;

	case 'q':
		if(nladdrs==0 && !under_glob) {
			if((*lp=='\n' && !dirty) || *lp=='q'  ||  lastln == 0)
				status = EOF;
			else
				status = ERROR4;
		}
		break;

	case 'r':
		if(!under_glob  &&  !under_until  &&  (status = getfn()) == OK)
			status = _read(lp, laddr2, 0);
		lp = "\n";
		break;

	case 's':
		n = getint(); /* read occurance if present */
		if((status=getpat()) == OK  &&  (status=getsubst_str(tbuff)) == OK)
			status = substitute(tbuff, under_glob, n);
		break;

	case 't':
	case 'T':
		if(nladdrs == 0)
			status = translate(*(lp - 1) == 't');
		break;

	case 'u':
		status = until(laddr1, laddr2, under_glob);
		break;

	case 'v':
		if(nladdrs <= 1)
			status = view(laddr1);
		break;

	case 'w':
		n = 0;
		if(*lp == 'w') {
			n |= 2;
			++lp;
			}
		if(*lp == 'a') {
			n |= 1;
			++lp;
			}

		if((status = getfn()) == OK) {
			if(nladdrs == 0) {
				if(curfile[0] == '\0')
					set_fn(curfile, lp);
				else {
					if((n & 2) == 0  &&  strcmp(curfile, lp) != 0) {
						for(p = lp ; *p ; ++p)
							if(*p == '$')
								goto ok;
						puterr(-19);
						lp = "\n";
						break;
						}
					}
				ok:
				if((status = _write(lp, 1, lastln, n & 1, 0)) == OK)
					dirty = 0;
				}
			} else {
				status = _write(lp, laddr1, laddr2, n & 1, 0);
			}
		lp = "\n";
		break;

    case 'x':
		if(!under_glob  &&  !under_until  &&  (status = getfn()) == OK)
			if(nladdrs == 0)
				status = exec_file(lp, under_glob, under_until);
		lp = "\n";
		break;

	case 'y':
		status = yut();
		break;

	case 'z':
		status = zap();
		break;

	case '\n':
		--lp; /* put back newline for main */
		if(laddr2 < 0  ||  laddr2 > lastln)
			status = lastln ? ERROR5 : OK;
		else {
			curln = laddr2;
			status = OK;
			}
		break;

	case ' ':
	case '\t':
	case CMD_CHAR:
		status = OK;
		break;

	case '=':
		dtoc(rbuff, laddr2);
		if(under_glob)
			prnt_screen(rbuff, 1);
		else
			putmsg(rbuff);
		status = OK;
		break;

	case '"':
		lp = "\n";	/* Ignore rest of line */
		status = OK;
		break;

	case '!':
		if(escape_char == 0  ||  restrict_flag) {
			putmsg("Escape from ED inhibited");
			status = NOTHING;
			}
		else
			status = exec_sys_cmd(under_glob, under_until);
		break;

	default:
		status = ERROR2;
		}
	return(status);
	}