当前位置: 首页>>代码示例>>C++>>正文


C++ restore函数代码示例

本文整理汇总了C++中restore函数的典型用法代码示例。如果您正苦于以下问题:C++ restore函数的具体用法?C++ restore怎么用?C++ restore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了restore函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: udpRead

/**
 * Read a packet's data and put that data into the user buffer
 * @param devptr UDP device table entry
 * @param buf User buffer
 * @param len Length of data to be read and put into user buffer
 * @return OK if data read completes properly, otherwise SYSERR
 */
devcall udpRead(device *devptr, void *buf, uint len)
{
    struct udp *udpptr;
    struct udpPkt *udppkt;
    uchar *buffer = buf;
    uchar *data;
    int count = 0;
    irqmask im;

    udpptr = &udptab[devptr->minor];

    im = disable();

    if ((udpptr->flags & UDP_FLAG_NOBLOCK) && (udpptr->icount < 1))
    {
        restore(im);
        return 0;
    }

    restore(im);
    wait(udpptr->isem);
    im = disable();

    /* Get a pointer to the stored packet in the current position */
    udppkt = udpptr->in[udpptr->istart];

    /* Make sure the packet is not NULL */
    if (NULL == udppkt)
    {
        restore(im);
        return SYSERR;
    }

    /* Increment the start value to preserve the circular buffer */
    udpptr->istart = (udpptr->istart + 1) % UDP_MAX_PKTS;

    /* Decrement the count value before removing the packet from the buffer */
    udpptr->icount--;

    /* Put the UDP packet's data in the user's buffer */
    if (UDP_FLAG_INCHDR & udpptr->flags)
    {
        count = udppkt->len;
        data = (uchar *)udppkt;
    }
    else
    {
        count = udppkt->len - UDP_HDR_LEN;
        data = udppkt->data;
    }

    restore(im);
    if (count > len)
    {
        count = len;
    }
    memcpy(buffer, data, count);

    /* Free the packet buffer */
    udpFreebuf(udppkt);

    return count;
}
开发者ID:36Chambers,项目名称:xinu-arm,代码行数:70,代码来源:udpRead.c

示例2: restore

void worker::workMedium_anti(MediumWorkMsg *m)
{
  restore(this);
}
开发者ID:brog2610,项目名称:quinoa,代码行数:4,代码来源:Worker.C

示例3: udp_in

/*------------------------------------------------------------------------
 * udp_in - handle an incoming UDP packet
 *------------------------------------------------------------------------
 */
void	udp_in(void) {			/* currpkt points to the packet	*/

    intmask	mask;			/* saved interrupt mask		*/
    int32	i;			/* index into udptab		*/
    struct	udpentry *udptr;	/* pointer to udptab entry	*/
    struct  ipv4_packet *ippkt = (struct ipv4_packet *)(currpkt->net_ethdata);
    struct  udp_packet * udppkt = (struct udp_packet *)(ippkt->net_ipdata);

    /* Insure only one process can access the UDP table at a time */

    mask = disable();

    //kprintf("Inside udp_in\r\n");
    /* Convert IP and UDP header fields to host byte order */

    udp_ntoh(udppkt);



    /*
    if (ippkt->net_ipproto == IP_UDP) {
            kprintf("proto UDP (%d), length %d",
                            ippkt->net_ipproto, ntohs(ippkt->net_iplen));
            kprintf(")\n");
            kprintf("\t%d.%d.%d.%d > ",
                            ((ippkt->net_ipsrc)>>24)&0xff,
                            ((ippkt->net_ipsrc)>>16)&0xff,
                            ((ippkt->net_ipsrc)>>8)&0xff,
                            ((ippkt->net_ipsrc)&0xff));
            kprintf("%d.%d.%d.%d: ",
                            ((ippkt->net_ipdst)>>24)&0xff,
                            ((ippkt->net_ipdst)>>16)&0xff,
                            ((ippkt->net_ipdst)>>8)&0xff,
                            ((ippkt->net_ipdst)&0xff));
            //kprintf("PDUMP Check 9\r\n");
            kprintf("[udp checksum none] ");
            kprintf("UDP, src port %d, dst port %d, length %d\n",
                            (udppkt->net_udpsport),
                            (udppkt->net_udpdport),
                            (udppkt->net_udplen) - UDP_HDR_LEN);
    }
    */


    for (i=0; i<UDP_SLOTS; i++) {
        udptr = &udptab[i];
        if ( (udptr->udstate != UDP_FREE) &&
                (udppkt->net_udpdport == udptr->udlocport)  &&
                ((udptr->udremport == 0) ||
                 (udppkt->net_udpsport == udptr->udremport)) &&
                (  ((udptr->udremip==0)     ||
                    (ippkt->net_ipsrc == udptr->udremip)))    ) {

            /* Entry matches incoming packet */

            if (udptr->udcount < UDP_QSIZ) {
                udptr->udcount++;
                udptr->udqueue[udptr->udtail++] = (struct eth_packet *)currpkt;
                if (udptr->udtail >= UDP_QSIZ) {
                    udptr->udtail = 0;
                }
                currpkt = (struct eth_packet *)getbuf(netbufpool);
                if (udptr->udstate == UDP_RECV) {
                    udptr->udstate = UDP_USED;
                    send (udptr->udpid, OK);
                }
                restore(mask);
                return;
            }
        }
    }

    /* No match - simply discard packet */
    //kprintf("Done with udp_in\r\n");
    restore(mask);
    return;
}
开发者ID:eerpini,项目名称:Xinu-RPL,代码行数:81,代码来源:udp.c

示例4: Object

	WrestlerAddress::WrestlerAddress( int id, Keeper *keeper ) : Object(keeper)
	{
		init();
		restore( id );
	}
开发者ID:alexey-zayats,项目名称:melampig,代码行数:5,代码来源:wrestleraddress.cpp

示例5: ethloopControl

/**
 * Control function for ethloop devices.
 * @param devptr ethloop device table entry
 * @param func control function to execute
 * @param arg1 first argument for the control function
 * @param arg2 second argument for the control function
 * @return the result of the control function
 */
devcall ethloopControl(device *devptr, int func, long arg1, long arg2)
{
    struct ethloop *elpptr;
    struct netaddr *addr;
    uchar old;
    irqmask im;
    char *buf;
    char *hold;
    int holdlen;

    elpptr = &elooptab[devptr->minor];

    im = disable();
    if (ELOOP_STATE_ALLOC != elpptr->state)
    {
        restore(im);
        return SYSERR;
    }

    switch (func)
    {
/* Get link header length. */
    case NET_GET_LINKHDRLEN:
        restore(im);
        return ETH_HDR_LEN;

/* Get MAC address from card. */
    case NET_GET_HWADDR:
        restore(im);
        addr = (struct netaddr *)arg1;
        addr->type = NETADDR_ETHERNET;
        addr->len = ETH_ADDR_LEN;
        addr->addr[0] = 0xAA;
        addr->addr[1] = 0xBB;
        addr->addr[2] = 0xCC;
        addr->addr[3] = 0xDD;
        addr->addr[4] = 0xEE;
        addr->addr[5] = 0xFF;
        break;

/* Get broadcast MAC address. */
    case NET_GET_HWBRC:
        restore(im);
        addr = (struct netaddr *)arg1;
        addr->type = NETADDR_ETHERNET;
        addr->len = ETH_ADDR_LEN;
        addr->addr[0] = 0xFF;
        addr->addr[1] = 0xFF;
        addr->addr[2] = 0xFF;
        addr->addr[3] = 0xFF;
        addr->addr[4] = 0xFF;
        addr->addr[5] = 0xFF;
        break;

/* Get MTU. */
    case NET_GET_MTU:
        restore(im);
        return ELOOP_MTU;

/* Get next packet off hold queue */
    case ELOOP_CTRL_GETHOLD:
        buf = (char *)arg1;
        /* Wait for held packet */
        wait(elpptr->hsem);
        /* Get and clear held packet */
        hold = elpptr->hold;
        holdlen = elpptr->holdlen;
        elpptr->hold = NULL;
        elpptr->holdlen = 0;
        restore(im);
        /* Copy held packet to buffer */
        if (arg2 < holdlen)
        {
            holdlen = arg2;
        }
        memcpy(buf, hold, holdlen);
        /* Free hold buffer */
        buffree(hold);
        return holdlen;

/* Set flags */
    case ELOOP_CTRL_SETFLAG:
        old = elpptr->flags & arg1;
        elpptr->flags |= (arg1);
        restore(im);
        return old;

/* Clear flags */
    case ELOOP_CTRL_CLRFLAG:
        old = elpptr->flags & arg1;
        elpptr->flags &= ~(arg1);
        restore(im);
//.........这里部分代码省略.........
开发者ID:36Chambers,项目名称:xinu-arm,代码行数:101,代码来源:ethloopControl.c

示例6: main

int main (int argc, char *argv[])
{

    int my_rank, proc_num;
    MPI_Status status;
    MPI_Init(&argc, &argv);

    MPI_Comm_size(MPI_COMM_WORLD, &proc_num);
    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

    double diff;  /* change in value */
    int    i, j, m, n;
    int N=DEFAULT_N;
    double epsilon=0.01;
    double mean;
    FILE *fp;

    /* Argument processing */
    int edgeElems = DEFAULT_ELEM; /* edge elements */
    int cfreq = DEFAULT_FREQ; /* checkpoint frequency */
    char *cpath = DEFAULT_PATH; /* checkpoint path */
    int nok = 0; /* arguments not OK */
    int pinit=1;

    char *s;
    while (--argc > 0 && (*++argv)[0] == '-') {
        for(s=argv[0]+1;*s;s++)
        switch (*s) {
        case 'd':
            if (isdigit(s[1]))
                edgeElems = atoi(s+1);
            else
                nok = 1;
            s+=strlen(s+1);
            break;
        case 'c':
            if (isdigit(s[i]))
                cfreq = atoi(s+1);
            else
                nok = 1;
            s+=strlen(s+1);
            break;
        case 'p':
            cpath = s+1;
            s+=strlen(s+1);
            break;
        case 'r':
            pinit = 0;
            break;
        case 'n':
            if (isdigit(s[1])) 
                N = atoi(s+1);
            else
                nok = 1;
            s+=strlen(s+1);
            break;
        case 'e':
            if (isdigit(s[1]))
                epsilon = atof(s+1);
            else
                nok = 1;
            s+=strlen(s+1);
            break;
        default:
            nok = 1;
            break;
        }
    }

    if (nok) {
        fprintf(stderr, "Usage: %s -e<int> -c<int> -p<str> -r -n<int> -epsilon<double>\n", argv[0]);
        fprintf(stderr, "  -d  edge elements, default: %d\n", DEFAULT_ELEM);
        fprintf(stderr, "  -c  checkpoint frequency, default: %d\n", DEFAULT_FREQ);
        fprintf(stderr, "  -p  path to checkpoint file, default: %s\n", DEFAULT_PATH);
        fprintf(stderr, "  -r  restore\n");
        fprintf(stderr, "  -n  size of n, default:1000\n");
        fprintf(stderr, "  -e  epsilon, default:0.01\n");

        exit(EXIT_FAILURE);
    }

#ifdef DEBUG
    if(my_rank==0)
        printf("n=%d, epsilon=%lf\n", N, epsilon);
#endif

	if(N>1000){
		printf("Too big value for N, use no more than 1000, or change DEFAULT_N\n");
		return 0;
	}
   // Persistent memory initialization 
   const char *mode = (pinit) ? "w+" : "r+";
   char back_fname[128];
   char my_rank_str[4];
   perm(PERM_START, PERM_SIZE);
   strcpy(back_fname, cpath);
   strcat(back_fname,"hw5_mpi.back.");
   sprintf(my_rank_str, "%d", my_rank);
   strcat(back_fname,my_rank_str);
//   printf("mopen: %s\n", back_fname);
//.........这里部分代码省略.........
开发者ID:houjun,项目名称:CSC548_Parallel_Systems,代码行数:101,代码来源:hw5_mpi.c

示例7: create

void create()
{
   if( !restore() && !mapp(emote) )
     emote = ([]);
}
开发者ID:jackfnx,项目名称:xyj-ali,代码行数:5,代码来源:emoted.c

示例8: create

void create()
{
   seteuid(getuid());
   restore();
}
开发者ID:gongfuPanada,项目名称:xyj45,代码行数:5,代码来源:chinesed.c

示例9: p_parent

 Camera::Camera(Node *parent)
 : p_parent(parent)
 {
     FZ_ASSERT(parent, "Parent can not be NULL.");
     restore();
 }
开发者ID:manucorporat,项目名称:FORZE2D,代码行数:6,代码来源:FZCamera.cpp

示例10: create_9_4

/*------------------------------------------------------------------------
 *  create  -  create a process to start running a procedure
 *------------------------------------------------------------------------
 */
pid32	create_9_4(
	  void		*procaddr,	/* procedure address		*/
	  uint32	ssize,		/* stack size in words		*/
	  pri16		priority,	/* process priority > 0		*/
	  char		*name,		/* name (for debugging)		*/
	  uint32	nargs,		/* number of args that follow	*/
	  ...
	)
{
	uint32		savsp, *pushsp;
	intmask 	mask;    	/* interrupt mask		*/
	pid32		pid;		/* stores new process id	*/
	struct	procent	*prptr;		/* pointer to proc. table entry */
	int32		i;
	uint32		*a;		/* points to list of args	*/
	uint32		*saddr;		/* stack address		*/

	mask = disable();
	if (ssize < MINSTK)
		ssize = MINSTK;
	ssize = (uint32) roundew(ssize);
	if (((saddr = (uint32 *)getstk_new(ssize)) ==
	    (uint32 *)SYSERR ) ||
	    (pid=newpid()) == SYSERR || priority < 1 ) {
		restore(mask);
		return SYSERR;
	}

	prcount++;
	prptr = &proctab[pid];

	/* initialize process table entry for new process */
	prptr->prstate = PR_SUSP;	/* initial state is suspended	*/
	prptr->prprio = priority;
	prptr->prstkbase = (char *)saddr;
	prptr->prstklen = ssize;
	prptr->prname[PNMLEN-1] = NULLCH;
	for (i=0 ; i<PNMLEN-1 && (prptr->prname[i]=name[i])!=NULLCH; i++)
		;
	prptr->prsem = -1;
	prptr->prparent = (pid32)getpid();
	prptr->prhasmsg = FALSE;

	/* set up initial device descriptors for the shell		*/
	prptr->prdesc[0] = CONSOLE;	/* stdin  is CONSOLE device	*/
	prptr->prdesc[1] = CONSOLE;	/* stdout is CONSOLE device	*/
	prptr->prdesc[2] = CONSOLE;	/* stderr is CONSOLE device	*/

	/* Initialize stack as if the process was called		*/

	*saddr = STACKMAGIC;
	savsp = (uint32)saddr;

	/* push arguments */
	a = (uint32 *)(&nargs + 1);	/* start of args		*/
	a += nargs -1;			/* last argument		*/
	for ( ; nargs > 4 ; nargs--)	/* machine dependent; copy args	*/
		*--saddr = *a--;	/* onto created process' stack	*/
	*--saddr = (long)procaddr;
	for(i = 11; i >= 4; i--)
		*--saddr = 0;
	for(i = 4; i > 0; i--) {
		if(i <= nargs)
			*--saddr = *a--;
		else
			*--saddr = 0;
	}
	*--saddr = (long)INITRET;	/* push on return address	*/
	*--saddr = (long)0x00000053;	/* CPSR, A, F bits set,		*/
					/* Supervisor mode		*/
	prptr->prstkptr = (char *)saddr;
	restore(mask);
	return pid;

	/* The following entries on the stack must match what ctxsw	*/
	/*   expects a saved process state to contain: ret address,	*/
	/*   ebp, interrupt mask, flags, registerss, and an old SP	*/

	*--saddr = (long)procaddr;	/* Make the stack look like it's*/
					/*  half-way through a call to	*/
					/*  ctxsw that "returns" to the	*/
					/*  new process			*/
	*--saddr = savsp;		/* This will be register ebp	*/
					/*  for process exit		*/
	savsp = (uint32) saddr;		/* start of frame for ctxsw	*/
	*--saddr = 0x00000200;		/* New process runs with	*/
					/*  interrupts enabled		*/

	/* Basically, the following emulates a x86 "pushal" instruction	*/

	*--saddr = 0;		/* %eax */
	*--saddr = 0;		/* %ecx */
	*--saddr = 0;		/* %edx */
	*--saddr = 0;		/* %ebx */
	*--saddr = 0;		/* %esp; value filled in below */
	pushsp = saddr;		/*  remember this location */
//.........这里部分代码省略.........
开发者ID:gouravshenoy,项目名称:XINU-Kernel-Programming,代码行数:101,代码来源:create_9_4.c

示例11: buffer

//------------------------------ generate_exception_blob ---------------------------
// creates exception blob at the end
// Using exception blob, this code is jumped from a compiled method.
// (see emit_exception_handler in sparc.ad file)
//
// Given an exception pc at a call we call into the runtime for the
// handler in this method. This handler might merely restore state
// (i.e. callee save registers) unwind the frame and jump to the
// exception handler for the nmethod if there is no Java level handler
// for the nmethod.
//
// This code is entered with a jmp.
//
// Arguments:
//   O0: exception oop
//   O1: exception pc
//
// Results:
//   O0: exception oop
//   O1: exception pc in caller or ???
//   destination: exception handler of caller
//
// Note: the exception pc MUST be at a call (precise debug information)
//
void OptoRuntime::generate_exception_blob() {
  // allocate space for code
  ResourceMark rm;
  int pad = VerifyThread ? 256 : 0;// Extra slop space for more verify code

  // setup code generation tools
  // Measured 8/7/03 at 256 in 32bit debug build (no VerifyThread)
  // Measured 8/7/03 at 528 in 32bit debug build (VerifyThread)
  CodeBuffer buffer("exception_blob", 600+pad, 512);
  MacroAssembler* masm     = new MacroAssembler(&buffer);

  int framesize_in_bytes = __ total_frame_size_in_bytes(0);
  int framesize_in_words = framesize_in_bytes / wordSize;
  int framesize_in_slots = framesize_in_bytes / sizeof(jint);

  Label L;

  int start = __ offset();

  __ verify_thread();
  __ st_ptr(Oexception,  G2_thread, JavaThread::exception_oop_offset());
  __ st_ptr(Oissuing_pc, G2_thread, JavaThread::exception_pc_offset());

  // This call does all the hard work. It checks if an exception catch
  // exists in the method.
  // If so, it returns the handler address.
  // If the nmethod has been deoptimized and it had a handler the handler
  // address is the deopt blob unpack_with_exception entry.
  //
  // If no handler exists it prepares for stack-unwinding, restoring the callee-save
  // registers of the frame being removed.
  //
  __ save_frame(0);

  __ mov(G2_thread, O0);
  __ set_last_Java_frame(SP, noreg);
  __ save_thread(L7_thread_cache);

  // This call can block at exit and nmethod can be deoptimized at that
  // point. If the nmethod had a catch point we would jump to the
  // now deoptimized catch point and fall thru the vanilla deopt
  // path and lose the exception
  // Sure would be simpler if this call didn't block!
  __ call(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C), relocInfo::runtime_call_type);
  __ delayed()->mov(L7_thread_cache, O0);

  // Set an oopmap for the call site.  This oopmap will only be used if we
  // are unwinding the stack.  Hence, all locations will be dead.
  // Callee-saved registers will be the same as the frame above (i.e.,
  // handle_exception_stub), since they were restored when we got the
  // exception.

  OopMapSet *oop_maps = new OopMapSet();
  oop_maps->add_gc_map( __ offset()-start, new OopMap(framesize_in_slots, 0));

  __ bind(L);
  __ restore_thread(L7_thread_cache);
  __ reset_last_Java_frame();

  __ mov(O0, G3_scratch);             // Move handler address to temp
  __ restore();

  // Restore SP from L7 if the exception PC is a MethodHandle call site.
  __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), O7);
  __ tst(O7);
  __ movcc(Assembler::notZero, false, Assembler::icc, L7_mh_SP_save, SP);

  // G3_scratch contains handler address
  // Since this may be the deopt blob we must set O7 to look like we returned
  // from the original pc that threw the exception

  __ ld_ptr(G2_thread, JavaThread::exception_pc_offset(), O7);
  __ sub(O7, frame::pc_return_offset, O7);


  assert(Assembler::is_simm13(in_bytes(JavaThread::exception_oop_offset())), "exception offset overflows simm13, following ld instruction cannot be in delay slot");
//.........这里部分代码省略.........
开发者ID:4T-Shirt,项目名称:OpenJDK-Research,代码行数:101,代码来源:runtime_sparc.cpp

示例12: mouse_doing

int mouse_doing(void)
{
    int fd;
    int press_flag = 0;
    int end_flag = 0;
    mouse_event m_event;
    fd = open("/dev/input/mice", O_RDWR|O_NONBLOCK); //?
    if (fd == -1) 
    {
        perror("mice");
        exit(0);
    }

    mx = fb_v.w / 2;    //initial the coordinates.
    my = fb_v.h / 2;

    draw_cursor(mx, my);

    while (1) 
    {
        if (get_m_info(fd, &m_event) > 0) 
        {
            restore(mx, my);
            mx += m_event.dx;
            my += m_event.dy;
            mx = (mx < 0) ? 0 : mx;
            my = (my < 0) ? 0 : my;

            if (mx > (fb_v.w - C_W)) 
            {
                mx = fb_v.w - C_W;
            }
            if (my > (fb_v.h - C_H)) 
            {
                my = fb_v.h - C_H;
            }

            switch (m_event.button)
            {
                case 0: 
                    if (press_flag == 1) 
                    {
                        press_flag = 0;
                        if (end_flag == 0) 
                        {
                            end_flag = chess_do();
                        }
                        else 
                        {
                            print_board(GRAY, YELLOW);
                            end_flag = 0;
                        }
                    }
                    else if (press_flag == 2) 
                    {
                        press_flag = 0;
                        chess_do();
                    }
                    break;
                case 1: press_flag = 1; break;
                case 2: press_flag = 2; break;
                case 3:  break;
                case 4:  break;
                default: break;
            }

            draw_cursor(mx, my);
        }
        usleep(1000);
    }
    
    return 0;
}
开发者ID:guozesheng,项目名称:test,代码行数:73,代码来源:mouse_op.c

示例13: disable

/*------------------------------------------------------------------------
 *  getmem  -  Allocate heap storage, returning lowest word address
 *------------------------------------------------------------------------
 */
char  	*getmem(
	  uint32	nbytes		/* Size of memory requested	*/
	)
{
	intmask	mask;			/* Saved interrupt mask		*/
	struct	memblk	*prev, *curr, *leftover;

	mask = disable();
	if (nbytes == 0) {
		restore(mask);
		return (char *)SYSERR;
	}

	nbytes = (uint32) roundmb(nbytes);	/* Use memblk multiples	*/

	prev = &memlist;
	curr = memlist.mnext;
	while (curr != NULL) {			/* Search free list	*/

		if (curr->mlength == nbytes) {	/* Block is exact match	*/
			prev->mnext = curr->mnext;
            /* jteague6 - allow prev node re-linking to support
             * from-the-back node searching */
            if( curr == memtail.mprev ) {
                memtail.mprev = prev;
            }
            else {
                curr->mnext->mprev = prev;
            }

			memlist.mlength -= nbytes;
			restore(mask);
			return (char *)(curr);

		} else if (curr->mlength > nbytes) { /* Split big block	*/
			leftover = (struct memblk *)((uint32) curr +
					nbytes);
			prev->mnext = leftover;
			leftover->mnext = curr->mnext;
			leftover->mlength = curr->mlength - nbytes;
			memlist.mlength -= nbytes;

            /* jteague6 - support prev node re-linking to allow
             * from-the-back memory searching */
            leftover->mprev = curr->mprev;
            if( curr == memtail.mprev ) {
                memtail.mprev = leftover;
            }
            else {
                curr->mnext->mprev = leftover;
            }
			restore(mask);
			return (char *)(curr);
		} else {			/* Move to next block	*/
			prev = curr;
			curr = curr->mnext;
		}
	}
	restore(mask);
	return (char *)SYSERR;
}
开发者ID:teaguejt,项目名称:xinu-mm,代码行数:65,代码来源:getmem.c

示例14: switch

OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {

  OopMapSet* oop_maps = NULL;
  // for better readability
  const bool must_gc_arguments = true;
  const bool dont_gc_arguments = false;

  // stub code & info for the different stubs
  switch (id) {
    case forward_exception_id:
      {
        oop_maps = generate_handle_exception(id, sasm);
      }
      break;

    case new_instance_id:
    case fast_new_instance_id:
    case fast_new_instance_init_check_id:
      {
        Register G5_klass = G5; // Incoming
        Register O0_obj   = O0; // Outgoing

        if (id == new_instance_id) {
          __ set_info("new_instance", dont_gc_arguments);
        } else if (id == fast_new_instance_id) {
          __ set_info("fast new_instance", dont_gc_arguments);
        } else {
          assert(id == fast_new_instance_init_check_id, "bad StubID");
          __ set_info("fast new_instance init check", dont_gc_arguments);
        }

        if ((id == fast_new_instance_id || id == fast_new_instance_init_check_id) &&
            UseTLAB && FastTLABRefill) {
          Label slow_path;
          Register G1_obj_size = G1;
          Register G3_t1 = G3;
          Register G4_t2 = G4;
          assert_different_registers(G5_klass, G1_obj_size, G3_t1, G4_t2);

          // Push a frame since we may do dtrace notification for the
          // allocation which requires calling out and we don't want
          // to stomp the real return address.
          __ save_frame(0);

          if (id == fast_new_instance_init_check_id) {
            // make sure the klass is initialized
            __ ldub(G5_klass, in_bytes(InstanceKlass::init_state_offset()), G3_t1);
            __ cmp_and_br_short(G3_t1, InstanceKlass::fully_initialized, Assembler::notEqual, Assembler::pn, slow_path);
          }
#ifdef ASSERT
          // assert object can be fast path allocated
          {
            Label ok, not_ok;
          __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size);
          // make sure it's an instance (LH > 0)
          __ cmp_and_br_short(G1_obj_size, 0, Assembler::lessEqual, Assembler::pn, not_ok);
          __ btst(Klass::_lh_instance_slow_path_bit, G1_obj_size);
          __ br(Assembler::zero, false, Assembler::pn, ok);
          __ delayed()->nop();
          __ bind(not_ok);
          __ stop("assert(can be fast path allocated)");
          __ should_not_reach_here();
          __ bind(ok);
          }
#endif // ASSERT
          // if we got here then the TLAB allocation failed, so try
          // refilling the TLAB or allocating directly from eden.
          Label retry_tlab, try_eden;
          __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves G5_klass

          __ bind(retry_tlab);

          // get the instance size
          __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size);

          __ tlab_allocate(O0_obj, G1_obj_size, 0, G3_t1, slow_path);

          __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2);
          __ verify_oop(O0_obj);
          __ mov(O0, I0);
          __ ret();
          __ delayed()->restore();

          __ bind(try_eden);
          // get the instance size
          __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size);
          __ eden_allocate(O0_obj, G1_obj_size, 0, G3_t1, G4_t2, slow_path);
          __ incr_allocated_bytes(G1_obj_size, G3_t1, G4_t2);

          __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2);
          __ verify_oop(O0_obj);
          __ mov(O0, I0);
          __ ret();
          __ delayed()->restore();

          __ bind(slow_path);

          // pop this frame so generate_stub_call can push it's own
          __ restore();
        }
//.........这里部分代码省略.........
开发者ID:pombreda,项目名称:graal,代码行数:101,代码来源:c1_Runtime1_sparc.cpp

示例15: switch

int Context2D::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: changed((*reinterpret_cast< const QImage(*)>(_a[1]))); break;
        case 1: save(); break;
        case 2: restore(); break;
        case 3: scale((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2]))); break;
        case 4: rotate((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        case 5: translate((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2]))); break;
        case 6: transform((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])),(*reinterpret_cast< qreal(*)>(_a[5])),(*reinterpret_cast< qreal(*)>(_a[6]))); break;
        case 7: setTransform((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])),(*reinterpret_cast< qreal(*)>(_a[5])),(*reinterpret_cast< qreal(*)>(_a[6]))); break;
        case 8: { CanvasGradient _r = createLinearGradient((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])));
            if (_a[0]) *reinterpret_cast< CanvasGradient*>(_a[0]) = _r; }  break;
        case 9: { CanvasGradient _r = createRadialGradient((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])),(*reinterpret_cast< qreal(*)>(_a[5])),(*reinterpret_cast< qreal(*)>(_a[6])));
            if (_a[0]) *reinterpret_cast< CanvasGradient*>(_a[0]) = _r; }  break;
        case 10: clearRect((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4]))); break;
        case 11: fillRect((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4]))); break;
        case 12: strokeRect((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4]))); break;
        case 13: beginPath(); break;
        case 14: closePath(); break;
        case 15: moveTo((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2]))); break;
        case 16: lineTo((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2]))); break;
        case 17: quadraticCurveTo((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4]))); break;
        case 18: bezierCurveTo((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])),(*reinterpret_cast< qreal(*)>(_a[5])),(*reinterpret_cast< qreal(*)>(_a[6]))); break;
        case 19: arcTo((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])),(*reinterpret_cast< qreal(*)>(_a[5]))); break;
        case 20: rect((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4]))); break;
        case 21: arc((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])),(*reinterpret_cast< qreal(*)>(_a[5])),(*reinterpret_cast< bool(*)>(_a[6]))); break;
        case 22: fill(); break;
        case 23: stroke(); break;
        case 24: clip(); break;
        case 25: { bool _r = isPointInPath((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 26: drawImage((*reinterpret_cast< DomImage*(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3]))); break;
        case 27: drawImage((*reinterpret_cast< DomImage*(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])),(*reinterpret_cast< qreal(*)>(_a[5]))); break;
        case 28: drawImage((*reinterpret_cast< DomImage*(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])),(*reinterpret_cast< qreal(*)>(_a[5])),(*reinterpret_cast< qreal(*)>(_a[6])),(*reinterpret_cast< qreal(*)>(_a[7])),(*reinterpret_cast< qreal(*)>(_a[8])),(*reinterpret_cast< qreal(*)>(_a[9]))); break;
        case 29: { ImageData _r = getImageData((*reinterpret_cast< qreal(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3])),(*reinterpret_cast< qreal(*)>(_a[4])));
            if (_a[0]) *reinterpret_cast< ImageData*>(_a[0]) = _r; }  break;
        case 30: putImageData((*reinterpret_cast< ImageData(*)>(_a[1])),(*reinterpret_cast< qreal(*)>(_a[2])),(*reinterpret_cast< qreal(*)>(_a[3]))); break;
        default: ;
        }
        _id -= 31;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< qreal*>(_v) = globalAlpha(); break;
        case 1: *reinterpret_cast< QString*>(_v) = globalCompositeOperation(); break;
        case 2: *reinterpret_cast< QVariant*>(_v) = strokeStyle(); break;
        case 3: *reinterpret_cast< QVariant*>(_v) = fillStyle(); break;
        case 4: *reinterpret_cast< qreal*>(_v) = lineWidth(); break;
        case 5: *reinterpret_cast< QString*>(_v) = lineCap(); break;
        case 6: *reinterpret_cast< QString*>(_v) = lineJoin(); break;
        case 7: *reinterpret_cast< qreal*>(_v) = miterLimit(); break;
        case 8: *reinterpret_cast< qreal*>(_v) = shadowOffsetX(); break;
        case 9: *reinterpret_cast< qreal*>(_v) = shadowOffsetY(); break;
        case 10: *reinterpret_cast< qreal*>(_v) = shadowBlur(); break;
        case 11: *reinterpret_cast< QString*>(_v) = shadowColor(); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setGlobalAlpha(*reinterpret_cast< qreal*>(_v)); break;
        case 1: setGlobalCompositeOperation(*reinterpret_cast< QString*>(_v)); break;
        case 2: setStrokeStyle(*reinterpret_cast< QVariant*>(_v)); break;
        case 3: setFillStyle(*reinterpret_cast< QVariant*>(_v)); break;
        case 4: setLineWidth(*reinterpret_cast< qreal*>(_v)); break;
        case 5: setLineCap(*reinterpret_cast< QString*>(_v)); break;
        case 6: setLineJoin(*reinterpret_cast< QString*>(_v)); break;
        case 7: setMiterLimit(*reinterpret_cast< qreal*>(_v)); break;
        case 8: setShadowOffsetX(*reinterpret_cast< qreal*>(_v)); break;
        case 9: setShadowOffsetY(*reinterpret_cast< qreal*>(_v)); break;
        case 10: setShadowBlur(*reinterpret_cast< qreal*>(_v)); break;
        case 11: setShadowColor(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 12;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 12;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 12;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
开发者ID:venkatarajasekhar,项目名称:ECE497,代码行数:97,代码来源:moc_context2d.cpp


注:本文中的restore函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。