Ejemplo n.º 1
0
/**
 * @public
 * @brief extract err code from err
 * @param[in] e err
 * @retval uint32_t code
 */
uint32_t
  err_get_code( err_t const *e )
{
  trap( e );
  trap( e->code != CODE_NONE );
  return e->code;
}
Ejemplo n.º 2
0
/**
 * @public
 * @brief pop node from the back of the list
 * @param[in] fifo list root
 * @retval void* popped node
 * @note { not threadsafe }
 */
void *
  fifo_pop( void *fifo )
{
  trap( fifo );
  fifo_t *const f = fifo;
  fifo_t *n = 0;

  if( f->head || f->tail )          /**< 1+ nodes in list                 */
  {
    n = f->tail;                    /**< pop from tail                    */
    trap( n->next == 0 );           /**< last node shouldn't have been    */
                                    /*   pointing to anything next        */
    if( f->head != f->tail )        /**< 2+ nodes in list ?               */
    {
      f->tail = n->prev;            /**< safe to update tail              */
      f->tail->next = 0;            /**< terminate list properly          */
      n->prev = 0;                  /**< not required, but safe           */
    }
    else                            /**< that was last node in the list   */
    {
      trap( n->prev == 0 );         /**< which means it shouldn't have    */
                                    /*   been pointing to anything prev   */
      f->tail = f->head = 0;        /**< now empty                        */
    }
  }

  return n;
}
Ejemplo n.º 3
0
static BOOL FdmDoSaveAction(HWND hwnd, char *szpath, int act, int sact)
{
    switch (act) {
        case 0:
            check_extension(szpath, ".cfg");
            return resources_save(szpath);
        case 1:
            check_extension(szpath, ".vsf");
            return trap(hwnd, save_snapshot, szpath);
        case 2:
            switch (sact) {
                case 0:
                    check_extension(szpath, ".png");
                    break;
                case 1:
                    check_extension(szpath, ".bmp");
                    break;
            }
            return trap(hwnd, save_screenshot, szpath);
        case 3:
            check_extension(szpath, ".vfl");
            return fliplist_save_list(sact+8, szpath);
        case 4:
            return machine_romset_file_save(szpath);
    }
    return -1;
}
Ejemplo n.º 4
0
/* -------------------------------------------------------------------- */
xhallfunc(int roomslot, int xyn, int fl)
{
    int yn;

    if (hallBuf->hall[thisHall].hroomflags[roomslot].inhall)
    {

        yn=getYesNo("Exclude from hall", (char)xyn);
        if (yn == 2) return FALSE;
        if (yn)
        {
            hallBuf->hall[thisHall].hroomflags[roomslot].inhall = FALSE;

            sprintf(msgBuf->mbtext,
            "Room %s excluded from hall %s by %s",
             roomTab[roomslot].rtname,
             hallBuf->hall[thisHall].hallname,
             logBuf.lbname );

            trap(msgBuf->mbtext, T_AIDE);

            if (!fl)
            {
                aideMessage();
            }else{              
                amPrintf(" Excluded %s\n",
                       roomTab[roomslot].rtname,
                       hallBuf->hall[thisHall].hallname);
                changed_room = TRUE;
            }
        }
    }else{
      yn=getYesNo("Add to hall", (char)xyn);
      if (yn == 2) return FALSE;
      if (yn)
      {
          hallBuf->hall[thisHall].hroomflags[roomslot].inhall = TRUE;

          sprintf(msgBuf->mbtext,
             "Room %s added to hall %s by %s",
             roomTab[roomslot].rtname,
             hallBuf->hall[thisHall].hallname,
             logBuf.lbname );

          trap(msgBuf->mbtext, T_AIDE);

            if (!fl)
            {
                aideMessage();
            }else{
                amPrintf(" Added    %s\n",
                       roomTab[roomslot].rtname);
                changed_room = TRUE;
            }
      }
    }
    return TRUE;
}
Ejemplo n.º 5
0
int main() {
	{
		int height[] = { 4,2,3 };
		printf("%d\n", trap(height, sizeof(height) / sizeof(int)));
	}
	{
		int height[] = { 0,1,0,2,1,0,1,3,2,1,2,1 };
		printf("%d\n", trap(height, sizeof(height) / sizeof(int)));
	}
	system("PAUSE");
	return 0;
}
Ejemplo n.º 6
0
void TERMWINDOWMEMBER purgeuserlog(void)
	{
	Bool done = FALSE;

	for (l_slot i = (l_slot) (cfg.MAXLOGTAB - 1); i >= 0 && !done; i--)
		{
		if (LTab(i).IsInuse())
			{
			label UserName;
			LTab(i).GetName(UserName, sizeof(UserName));

			if (!loggedIn || !CurrentUser->IsSameName(UserName))
				{
				char prompt[256];

				sprintf(prompt, getsysmsg(57), cfg.Luser_nym, UserName);

				const int response = getYesNo(prompt, 3);

				if (response == 1)
					{
					LogEntry1 Log1;

					Log1.Clear();

					if (Log1.Save(LTab(i).GetLogIndex()))
						{
                        if(!read_tr_messages())
                            {
                            errorDisp(getmsg(172));
                            done = TRUE;
                            return;
                            }
#ifdef WINCIT
                        trap(T_SYSOP, WindowCaption, gettrmsg(16), UserName);
#else
                        trap(T_SYSOP, gettrmsg(16), UserName);
#endif
                        dump_tr_messages();
						}
					}
				else if (response == 2)
					{
					done = TRUE;
					}
				}
			}
		}
	}
Ejemplo n.º 7
0
static Line_t*
append(char* (*f)(void), Line_t* a, Line_t** r)
{
	register char*		s;
	register Line_t*	a1;
	register Line_t*	a2;
	register Line_t*	a3;
	off_t			t;
	long			added;

	added = 0;
	ed.dot = a;
	while (s = (*f)()) {
		trap();
		if ((ed.dol - ed.zero) + 1 >= ed.all) {
			unsigned long	dot_off = ed.dot - ed.zero;
			unsigned long	dol_off = ed.dol - ed.zero;
			unsigned long	r_off = r ? *r - ed.zero : 0;

			ed.all += BLOCK_LINE;
			if (!(ed.zero = newof(ed.zero, Line_t, ed.all, 0))) {
				error(ERROR_SYSTEM|1, "no space [zero]");
				ed.caught = SIGHUP;
				trap();
			}
			ed.dot = ed.zero + dot_off;
			ed.dol = ed.zero + dol_off;
			if (r)
				*r = ed.zero + r_off;
		}
		t = lineput(s);
		added++;
		a1 = ++ed.dol;
		a2 = a1 + 1;
		a3 = ++ed.dot;
		while (a1 > a3) {
			(--a2)->event = ed.event;
			a2->undo = a2->offset;
			a2->offset = (--a1)->offset;
		}
		a3->event = ed.event;
		a3->undo = a3->offset;
		a3->offset = t;
	}
	if (r)
		*r += added;
	return ed.dot;
}
Ejemplo n.º 8
0
IOErrorHandler::IOErrorHandler(StateFile *stateFile)
    : _stateFile(stateFile),
      _trapped(false),
      _fired(false)
{
    trap();
}
Ejemplo n.º 9
0
static DWORD
getCSR(Processor *p, int csr) {
    switch(csr) {
    case r_MHARTID:
        return p->csr[i_MHARTID];
    case r_MSTATUS:
        return p->csr[i_MSTATUS];
    case r_MTVEC:
        return p->csr[i_MTVEC];
    case r_MEPC:
        return p->csr[i_MEPC];
    case r_MBADADDR:
        return p->csr[i_MBADADDR];
    case r_MCAUSE:
        return p->csr[i_MCAUSE];
    case r_MTOHOST:
        return p->csr[i_MTOHOST];
    case r_MFROMHOST:
        return p->csr[i_MFROMHOST];
    case r_MIE:
        return p->csr[i_MIE];
    case r_MIP:
        return ipr;	/* See address-space.c */
    default:
        trap(p, 2);	// Illegal CSR addresses are now spec'd to trigger illegal instruction traps. (RV64S V1.9)
        fprintf(stderr, "Warning: At $%016llX, attempt to read unsupported CSR %d\n", p->pc-4, csr);
        return 0xCCCCCCCCCCCCCCCC;
    }
}
Ejemplo n.º 10
0
expr_ptr recursive_apply(expr_ptr& expr, expr_ptr (simplifier)(expr_ptr& expr, bool&), bool& mod)
{
	switch(expr->get_type())
	{
		case MULT     : { binary*b=(binary*) expr.release(); expr = Binary{new multiplication{ recursive_apply(b->first, simplifier, mod), recursive_apply(b->second, simplifier, mod) }}; break; }
		case DIV      : { binary*b=(binary*) expr.release(); expr = Binary{new division      { recursive_apply(b->first, simplifier, mod), recursive_apply(b->second, simplifier, mod) }}; break; }
		case ADD      : { binary*b=(binary*) expr.release(); expr = Binary{new addition      { recursive_apply(b->first, simplifier, mod), recursive_apply(b->second, simplifier, mod) }}; break; }
		case SUB      : { binary*b=(binary*) expr.release(); expr = Binary{new subtraction   { recursive_apply(b->first, simplifier, mod), recursive_apply(b->second, simplifier, mod) }}; break; }
		case EXPO     : { break; }
		case LOG      : { break; }
		case NEGATE   : { Negation n{(negation*) expr.release()}; expr = recursive_apply(n->orig, simplifier, mod); break; }
		case VARIABLE : { break; }
		case INTERVAL : { break; }
		case IEEE     : { break; }
		case REAL     : { break; }
		case COMPLEX  : { break; }
		case ZERO     : { break; }
		case UNITY    : { break; }
		case ANYTHING : { break; }
		case NAN      : { break; }
		case INFINITY : { break; }
		default:
			trap("Unable to simplify expression of type: " + expr->get_text());
	}
	return simplifier(expr, mod);
}
Ejemplo n.º 11
0
expr_ptr simplify_an_expression(expr_ptr& expr, bool& mod)
{
//	expr->append_text(std::cout << "simplifying: ") << std::endl;
	switch(expr->get_type())
	{
		case REAL    : /* return simplify     (Real           {(real           *) expr.release()}, mod); */ break;
		case COMPLEX : /* return simplify     (Complex        {(complex        *) expr.release()}, mod); */ break;
		case MULT    :    return  simplify_mult(Multiplication {(multiplication *) expr.release()}, mod);
		case DIV     : /* return simplify     (Division       {(division       *) expr.release()}, mod); */ break;
		case ADD     :    return simplify_add (Addition       {(addition       *) expr.release()}, mod);
		case SUB     : /* return simplify     (Subtraction    {(subtraction    *) expr.release()}, mod); */ break;
		case EXPO    : /* return simplify     (Exponent       {(exponent       *) expr.release()}, mod); */ break;
		case NEGATE  :    return simplify_neg (Negation       {(negation       *) expr.release()}, mod);
		case VARIABLE: /* return simplify     (Variable       {(variable       *) expr.release()}, mod); */ break;

		case LOG     : /* return simplify     (expr_ptr       {(expression_raw *) expr.release()}, mod); */ break;
		case INTERVAL: /* return simplify     (expr_ptr       {(expression_raw *) expr.release()}, mod); */ break;
		case IEEE    : /* return simplify     (expr_ptr       {(expression_raw *) expr.release()}, mod); */ break;

		case ZERO    : /* return expr_ptr{expr.release()};                                               */ break;
		case UNITY   : /* return expr_ptr{expr.release()};                                               */ break;
		case ANYTHING: /* return expr_ptr{expr.release()};                                               */ break;
		case NAN     : /* return expr_ptr{expr.release()};                                               */ break;
		case INFINITY: /* return expr_ptr{expr.release()};                                               */ break;
		default:
			trap("Unable to simplify expression of type: " + expr->get_text());
	}
	return expr_ptr{expr.release()};
}
Ejemplo n.º 12
0
BitField StateConstraints::minimalTrap(const PetriNet& net,
									   const MarkVal* marking,
									   const MarkVal* resultMarking) const{
	const size_t nPlaces = net.numberOfPlaces();
	BitField trap(nPlaces);
	trap.set();
	trap = maxTrap(net, trap, resultMarking);
	if(!isMarked(trap, marking))
		return BitField(nPlaces).clear();

	//Get the exclusion candidates
	BitField EC(trap);
	BitField tmp(nPlaces);
	while(EC.any()){
		int exclude = EC.first();
		tmp = trap;
		tmp.clear(exclude);
		EC.clear(exclude);
		tmp = maxTrap(net, tmp, resultMarking);
		if(isMarked(tmp, marking)){
			trap = tmp;
			EC = tmp;
		}
	}
	return trap;
}
Ejemplo n.º 13
0
/*
 * A very short dispatch, to try and maximise assembler code use
 * between all exception types. Maybe 'true' interrupts should go
 * here, and the trap code can come in separately
 */
void
powerpc_interrupt(struct trapframe *framep)
{
        struct thread *td;
	struct clockframe ckframe;

	td = curthread;

	switch (framep->exc) {
	case EXC_EXI:
		atomic_add_int(&td->td_intr_nesting_level, 1);
		(*powerpc_extintr_handler)();
		atomic_subtract_int(&td->td_intr_nesting_level, 1);	
		break;

	case EXC_DECR:
		atomic_add_int(&td->td_intr_nesting_level, 1);
		ckframe.srr0 = framep->srr0;
		ckframe.srr1 = framep->srr1;
		decr_intr(&ckframe);
		atomic_subtract_int(&td->td_intr_nesting_level, 1);	
		break;

	default:
		/*
		 * Re-enable interrupts and call the generic trap code
		 */
#if 0
		printf("powerpc_interrupt: got trap\n");
#endif
		mtmsr(mfmsr() | PSL_EE);
		isync();
		trap(framep);
	}	        
}
Ejemplo n.º 14
0
void powerpc_mchk_interrupt(struct trapframe *framep)
{

	printf("powerpc_mchk_interrupt: machine check interrupt!\n");
	dump_frame(framep);
	trap(framep);
}
Ejemplo n.º 15
0
//the private recursive method
double RecursiveIntegration::rombergRec(MultiVarFunction* f, int dim, double* a, double* b, int n, double* coords)
{
   //each level of recursion needs storage space
   double* evals = new double[n + 1];
   double h = (b[dim] - a[dim])/n;

   coords[dim] = a[dim];  //need to reset for each pass

   for (int j = 0; j <= n; j++)  //loop over the number of points (number of intervals plus one)
   {
      if (dim == 0)  //base case, function evaluation
      {
         evals[j] = f->evaluate(coords);
      }
      else
      {
         evals[j] = rombergRec(f, dim - 1, a, b, n, coords);
      }

      coords[dim] = coords[dim] + h;
   }
      
   double result = trap(evals, n, a[dim], b[dim]);
   delete[] evals;

   return result;
}
Ejemplo n.º 16
0
int unlink(const char *path)
{
        argstr_t args;
        args.as_len = strlen(path);
        args.as_str = path;
        return trap(SYS_unlink, (uint32_t) &args);
}
Ejemplo n.º 17
0
Archivo: signal.c Proyecto: yugui/ruby
/*
 * call-seq:
 *   Signal.trap( signal, command ) -> obj
 *   Signal.trap( signal ) {| | block } -> obj
 *
 * Specifies the handling of signals. The first parameter is a signal
 * name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a
 * signal number. The characters ``SIG'' may be omitted from the
 * signal name. The command or block specifies code to be run when the
 * signal is raised.
 * If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal
 * will be ignored.
 * If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler
 * will be invoked.
 * If the command is ``EXIT'', the script will be terminated by the signal.
 * If the command is ``SYSTEM_DEFAULT'', the operating system's default
 * handler will be invoked.
 * Otherwise, the given command or block will be run.
 * The special signal name ``EXIT'' or signal number zero will be
 * invoked just prior to program termination.
 * trap returns the previous handler for the given signal.
 *
 *     Signal.trap(0, proc { puts "Terminating: #{$$}" })
 *     Signal.trap("CLD")  { puts "Child died" }
 *     fork && Process.wait
 *
 * produces:
 *     Terminating: 27461
 *     Child died
 *     Terminating: 27460
 */
static VALUE
sig_trap(int argc, VALUE *argv)
{
    int sig;
    sighandler_t func;
    VALUE cmd;

    rb_secure(2);
    rb_check_arity(argc, 1, 2);

    sig = trap_signm(argv[0]);
    if (reserved_signal_p(sig)) {
        const char *name = signo2signm(sig);
        if (name)
            rb_raise(rb_eArgError, "can't trap reserved signal: SIG%s", name);
        else
            rb_raise(rb_eArgError, "can't trap reserved signal: %d", sig);
    }

    if (argc == 1) {
	cmd = rb_block_proc();
	func = sighandler;
    }
    else {
	cmd = argv[1];
	func = trap_handler(&cmd, sig);
    }

    if (OBJ_TAINTED(cmd)) {
	rb_raise(rb_eSecurityError, "Insecure: tainted signal trap");
    }

    return trap(sig, func, cmd);
}
Ejemplo n.º 18
0
static int
getchr(void)
{
	int	n;

	if (ed.lastc = ed.peekc) {
		ed.peekc = 0;
		return ed.lastc;
	}
	if (ed.global) {
		if (ed.lastc = *ed.global++)
			return ed.lastc;
		ed.global = 0;
		return EOF;
	}
	if (!ed.input) {
		if (!(ed.input = sfgetr(sfstdin, '\n', 1))) {
			trap();
			return EOF;
		}
		if ((n = sfvalue(sfstdin) - 2) >= 0 && ed.input[n] == '\r')
			ed.input[n--] = 0;
		ed.spbeg = ed.input;
		ed.spend = (n >= 0 && ed.input[n] == '\\') ? (ed.input + n) : (char*)0;
	}
	if (!(ed.lastc = *ed.input++)) {
		ed.input = 0;
		ed.lastc = '\n';
	}
	return ed.lastc;
}
Ejemplo n.º 19
0
void powerpc_crit_interrupt(struct trapframe *framep)
{

	printf("powerpc_crit_interrupt: critical interrupt!\n");
	dump_frame(framep);
	trap(framep);
}
Ejemplo n.º 20
0
/* -------------------------------------------------------------------- */
void killhall(void)
{
    int empty = TRUE, i;

    if (thisHall == 0 || thisHall == 1)
    {
        mPrintf("\nThe Main and Maintenance hallways cannot be killed.");
        return;
    }
    
    /* Check hall for any rooms */
    for (i = 0; i < MAXROOMS; i++)
    {
        if ( hallBuf->hall[thisHall].hroomflags[i].inhall
          && roomTab[i].rtflags.INUSE) empty = FALSE;
    }

    if (!empty) 
    {
        mPrintf("\n Hall still has rooms.");
        return;
    }

    if (getYesNo(confirm, 0))
    {
        hallBuf->hall[thisHall].h_inuse = FALSE;
        hallBuf->hall[thisHall].owned   = FALSE;
        putHall();

       sprintf(msgBuf->mbtext,
       "Hallway %s deleted", hallBuf->hall[thisHall].hallname );

       trap(msgBuf->mbtext, T_SYSOP);
    }
}
Ejemplo n.º 21
0
void test_trap(void){
  I0 = 0;
  I0 = 0;
  *pcToLoad = 0x012244; //*pcToLoad + 1 = 0x012245
  
//pcl =0x45
//pch =0x22
//pce =0x01 
  YL = 0XE4;
  YH = 0XD6;
  XL = 0XC9;
  XH = 0X68;
  A  = 0XBB;
  CC = 0X55;
  
	uint8_t instr[] = {0XBB};

  TEST_ASSERT_EQUAL_INT8(1, trap(instr));
  TEST_ASSERT_EQUAL_INT16(0x012245, *pcToLoad);
  TEST_ASSERT_EQUAL_INT8(0X55, mcu_pop());
  TEST_ASSERT_EQUAL_INT8(0XBB, mcu_pop());
  TEST_ASSERT_EQUAL_INT8(0X68, mcu_pop());
  TEST_ASSERT_EQUAL_INT8(0XC9, mcu_pop());
  TEST_ASSERT_EQUAL_INT8(0XD6, mcu_pop());
  TEST_ASSERT_EQUAL_INT8(0XE4, mcu_pop());
  TEST_ASSERT_EQUAL_INT8(0X01, mcu_pop());
  TEST_ASSERT_EQUAL_INT8(0X22, mcu_pop());
  TEST_ASSERT_EQUAL_INT8(0X45, mcu_pop());
  
  TEST_ASSERT_EQUAL_INT8(1, I0);
  TEST_ASSERT_EQUAL_INT8(1, I1);
}
Ejemplo n.º 22
0
Archivo: signal.c Proyecto: 217/ruby
/*
 * call-seq:
 *   Signal.trap( signal, command ) -> obj
 *   Signal.trap( signal ) {| | block } -> obj
 *
 * Specifies the handling of signals. The first parameter is a signal
 * name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a
 * signal number. The characters ``SIG'' may be omitted from the
 * signal name. The command or block specifies code to be run when the
 * signal is raised.
 * If the command is the string ``IGNORE'' or ``SIG_IGN'', the signal
 * will be ignored.
 * If the command is ``DEFAULT'' or ``SIG_DFL'', the Ruby's default handler
 * will be invoked.
 * If the command is ``EXIT'', the script will be terminated by the signal.
 * If the command is ``SYSTEM_DEFAULT'', the operating system's default
 * handler will be invoked.
 * Otherwise, the given command or block will be run.
 * The special signal name ``EXIT'' or signal number zero will be
 * invoked just prior to program termination.
 * trap returns the previous handler for the given signal.
 *
 *     Signal.trap(0, proc { puts "Terminating: #{$$}" })
 *     Signal.trap("CLD")  { puts "Child died" }
 *     fork && Process.wait
 *
 * produces:
 *     Terminating: 27461
 *     Child died
 *     Terminating: 27460
 */
static VALUE
sig_trap(int argc, VALUE *argv)
{
    struct trap_arg arg;

    rb_secure(2);
    if (argc < 1 || argc > 2) {
	rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..2)", argc);
    }

    arg.sig = trap_signm(argv[0]);
    if (argc == 1) {
	arg.cmd = rb_block_proc();
	arg.func = sighandler;
    }
    else {
	arg.cmd = argv[1];
	arg.func = trap_handler(&arg.cmd, arg.sig);
    }

    if (OBJ_TAINTED(arg.cmd)) {
	rb_raise(rb_eSecurityError, "Insecure: tainted signal trap");
    }
#if USE_TRAP_MASK
    /* disable interrupt */
    sigfillset(&arg.mask);
    pthread_sigmask(SIG_BLOCK, &arg.mask, &arg.mask);

    return rb_ensure(trap, (VALUE)&arg, trap_ensure, (VALUE)&arg);
#else
    return trap(&arg);
#endif
}
Ejemplo n.º 23
0
void *sbrk(intptr_t incr)
{
        uintptr_t oldbrk;

        /* If we don't have a saved break, find it from the kernel */
        if (!__curbrk) {
                if (0 > (long)(__curbrk = (void *) trap(SYS_brk, (uint32_t) NULL))) {
                        return (void *) -1;
                }
        }

        oldbrk = (uintptr_t) __curbrk;

        /* Increment or decrement the saved break */

        if (incr < 0) {
                if ((uintptr_t) - incr > oldbrk) {
                        return (void *) -1;
                } else if (brk((void *)(oldbrk - (uintptr_t) - incr)) < 0) {
                        return (void *) -1;
                }
        } else if (incr > 0) {
                if (brk((void *)(oldbrk + (uintptr_t) incr)) < 0) {
                        return (void *) -1;
                }
        }
        return (void *) oldbrk;
}
Ejemplo n.º 24
0
void Assembler::movsd(XMMRegister src, Indirect dest) {
    int rex = 0;
    int src_idx = src.regnum;
    int dest_idx = dest.base.regnum;

    if (src_idx >= 8) {
        rex |= REX_R;
        src_idx -= 8;
    }
    if (dest_idx >= 8) {
        trap();
        rex |= REX_B;
        dest_idx -= 8;
    }

    emitByte(0xf2);
    if (rex)
        emitRex(rex);
    emitByte(0x0f);
    emitByte(0x11);

    bool needssib = (dest_idx == 0b100);
    int mode = getModeFromOffset(dest.offset);
    emitModRM(mode, src_idx, dest_idx);

    if (needssib)
        emitSIB(0b00, 0b100, dest_idx);

    if (mode == 0b01) {
        emitByte(dest.offset);
    } else if (mode == 0b10) {
        emitInt(dest.offset, 4);
    }
}
Ejemplo n.º 25
0
int chdir(const char *path)
{
        argstr_t args;
        args.as_len = strlen(path);
        args.as_str = path;
        return trap(SYS_chdir, (uint32_t) &args);
}
Ejemplo n.º 26
0
void
trap_tss(struct i386tss *tss, int trapno, int code)
{
	struct trapframe tf;

	tf.tf_gs = tss->tss_gs;
	tf.tf_fs = tss->tss_fs;
	tf.tf_es = tss->__tss_es;
	tf.tf_ds = tss->__tss_ds;
	tf.tf_edi = tss->__tss_edi;
	tf.tf_esi = tss->__tss_esi;
	tf.tf_ebp = tss->tss_ebp;
	tf.tf_ebx = tss->__tss_ebx;
	tf.tf_edx = tss->__tss_edx;
	tf.tf_ecx = tss->__tss_ecx;
	tf.tf_eax = tss->__tss_eax;
	tf.tf_trapno = trapno;
	tf.tf_err = code | TC_TSS;
	tf.tf_eip = tss->__tss_eip;
	tf.tf_cs = tss->__tss_cs;
	tf.tf_eflags = tss->__tss_eflags;
	tf.tf_esp = tss->tss_esp;
	tf.tf_ss = tss->__tss_ss;
	trap(&tf);
}
Ejemplo n.º 27
0
/// serial main
int main() {
  int n;
  float h, a, b, t, total;

  LOCK;
  proc_id++;
  UNLOCK;

  LOCK;
  if (proc_id == 1){
  printf("Digite o numero de subintervalos:\n");
  /// interval count
  scanf("%d", &n);

  printf("Digite o inicio e o final do intervalo:\n");
  /// interval start
  scanf("%f", &a);
  /// interval end
  scanf("%f", &b);
  
  /// interval size
  h=(b-a)/n;
  total = trap(a,b,n,h);
  
  printf("A estimativa foi: %.15e\n",total);
  }
  proc_id++;
  
  return 0;
}
Ejemplo n.º 28
0
void
main(void)
{
  trap();
  for (;;)
    ;
}
Ejemplo n.º 29
0
void *galloc(long size) {
    void *ret;
    while (( ret = malloc(size))==NULL )
	trap();
    memset(ret,0x3c,size);		/* fill with random junk for debugging */
return( ret );
}
Ejemplo n.º 30
0
static VALUE
sig_trap(VALUE rcv, SEL sel, int argc, VALUE *argv)
{
    struct trap_arg arg;

    rb_secure(2);
    if (argc == 0 || argc > 2) {
	rb_raise(rb_eArgError, "wrong number of arguments -- trap(sig, cmd)/trap(sig){...}");
    }

    arg.sig = trap_signm(argv[0]);
    if (argc == 1) {
	arg.cmd = rb_block_proc();
	arg.func = sighandler;
    }
    else {
	arg.cmd = argv[1];
	arg.func = trap_handler(&arg.cmd, arg.sig);
    }

    if (OBJ_TAINTED(arg.cmd)) {
	rb_raise(rb_eSecurityError, "Insecure: tainted signal trap");
    }

    return trap(&arg);
}