void set_elem_on_map(t_ctrl *c, t_frame *node, int x, int y) { t_frame *old; node->next = NULL; node->prev = NULL; if ((old = getframe(c, x, y))) { old->prev = node; node->next = old; } getframe(c, x, y) = node; }
void elevate_players(t_ctrl *c, int x, int y, int lvl) { t_frame *f; char buff[64]; t_player *p; snprintf(buff, sizeof(buff) - 1, "niveau actuel : %d", lvl + 1); f = getframe(c, x, y); while (f) { if (f->type == PLAYER && (p = (t_player *)f->p) && p->lvl == lvl) { p->lvl++; p->t->nblvlmax++; printf(CYAN"Player #%d is now lvl %d"END, p->id, p->lvl); jm_writeln(p->fd, buff); if (p->lvl >= 8 && p->t->nblvlmax >= 6) { gfx_end_of_game(c, p->t->name); printf(GREEN"Team %s won!"END, p->t->name); c->flag = 0; return ; } } f = f->next; } }
static void sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask) { struct lwp *l = curlwp; struct proc *p = l->l_proc; struct sigacts *ps = p->p_sigacts; struct trapframe *tf = l->l_md.md_regs; int sig = ksi->ksi_signo, error; sig_t catcher = SIGACTION(p, sig).sa_handler; struct sigframe_siginfo *fp, frame; int onstack; switch (ps->sa_sigdesc[sig].sd_vers) { case 0: /* FALLTHROUGH */ /* handled by sendsig_sigcontext */ case 1: /* FALLTHROUGH */ /* handled by sendsig_sigcontext */ default: /* unknown version */ printf("sendsig_siginfo: bad version %d\n", ps->sa_sigdesc[sig].sd_vers); sigexit(l, SIGILL); /* NOTREACHED */ case 2: break; } fp = getframe(l, sig, &onstack); --fp; frame.sf_si._info = ksi->ksi_info; frame.sf_uc.uc_link = l->l_ctxlink; frame.sf_uc.uc_sigmask = *mask; frame.sf_uc.uc_flags = _UC_SIGMASK; frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK) ? _UC_SETSTACK : _UC_CLRSTACK; memset(&frame.sf_uc.uc_stack, 0, sizeof(frame.sf_uc.uc_stack)); sendsig_reset(l, sig); mutex_exit(p->p_lock); cpu_getmcontext(l, &frame.sf_uc.uc_mcontext, &frame.sf_uc.uc_flags); error = copyout(&frame, fp, sizeof(frame)); mutex_enter(p->p_lock); if (error != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ sigexit(l, SIGILL); /* NOTREACHED */ } tf->tf_r4 = sig; /* "signum" argument for handler */ tf->tf_r5 = (int)&fp->sf_si; /* "sip" argument for handler */ tf->tf_r6 = (int)&fp->sf_uc; /* "ucp" argument for handler */ tf->tf_spc = (int)catcher; tf->tf_r15 = (int)fp; tf->tf_pr = (int)ps->sa_sigdesc[sig].sd_tramp; /* Remember if we're now on the signal stack. */ if (onstack) l->l_sigstk.ss_flags |= SS_ONSTACK; }
INTEGER getframe_(INTEGER *long_vector) { if (sizeof(WFDB_Sample) == sizeof(INTEGER)) { return (getframe((WFDB_Sample *)long_vector)); } else { WFDB_Sample v[WFDB_MAXSIG*WFDB_MAXSPF]; int i, j, k; i = getframe(v); for (j = 0; j < i; j += k) for (k = 0; k < sinfo[i].spf; k++) long_vector[j+k] = v[j+k]; return (i); } }
void remove_player(t_ctrl *c, t_player *p) { t_frame *tmp; if (!p) { fprintf(stderr, RED"Player doesn't exists"END); return ; } printf(GREEN"Removing player #%d in (%d, %d)"END, p->id, p->x, p->y); if (p->lvl >= 8) p->t->nblvlmax--; remove_life_node(c, p); _remove_from_team(p->t, p); free_events(p->e); p->e = NULL; tmp = getframe(c, p->x, p->y); while (tmp && (void *)tmp->p != (void *)p) tmp = tmp->next; if (tmp) { unset_elem_from_map(c, tmp, p->x, p->y); free(tmp); free(p); } else fprintf(stderr, RED"Player #%d not found"END, p->id); }
/* * Find the current stack frame when debugging the kernel. * If we're looking at a crash dump and this was not a ``clean'' * crash, then we must search the interrupt stack carefully * looking for a valid frame. */ findstackframe() { char *panicstr, buf[256]; register struct frame *fp; caddr_t addr; register char *cp; int mask; if (lookup("_panicstr") == 0) return; lseek(fcor, KVTOPH(cursym->n_value), L_SET); read(fcor, &panicstr, sizeof (panicstr)); if (panicstr == 0) return; lseek(fcor, KVTOPH((off_t)panicstr), L_SET); read(fcor, buf, sizeof (buf)); for (cp = buf; cp < &buf[sizeof (buf)] && *cp; cp++) if (!isascii(*cp) || (!isprint(*cp) && !isspace(*cp))) *cp = '?'; if (*cp) *cp = '\0'; printf("panic: %s\n", buf); /* * After a panic, look at the top of the rpb stack to * find a stack frame. If this was a clean crash, * i.e. one which left the interrupt and kernel stacks * in a reasonable state, then we should find a pointer * to the proper stack frame here (at location scb-4). * If we don't find a reasonable frame here, then we * must search down through the interrupt stack. */ intstack = lookup("_intstack")->n_value; #define NISP 3 /* from locore.s */ eintstack = intstack + NISP*NBPG; rpb = lookup("_rpb")->n_value; scb = lookup("_scb")->n_value; lookup("_u"); ustack = cursym->n_value + (int)&((struct user *)0)->u_stack[0]; eustack = cursym->n_value + ctob(UPAGES); physrw(fcor, KVTOPH((int)scb - sizeof (caddr_t)), &addr, 1); fp = getframe(fcor, addr); if (fp == 0) fp = checkintstack(); /* search kernel stack? */ if (fp == 0) { printf("can't locate stack frame\n"); return; } /* probably shouldn't clobber pcb, but for now this is easy */ pcb.pcb_fp = addr; pcb.pcb_pc = fp->fr_savpc; pcb.pcb_ap = addr + sizeof (struct frame) + fp->fr_spa; for (mask = fp->fr_mask; mask; mask >>= 1) if (mask & 01) pcb.pcb_ap += sizeof (caddr_t); }
// virtual int StompStreamSocket::receive_event() { int flen; char buf[4096], *line, *next, *value; if ((flen = getframe(buf, sizeof(buf))) < 0) return flen; if (flen == 0) return 0; // it's not an error printf("%s: frame length = %d\n", __func__, flen); // command line = getline(&next, buf); printf("%s: command = %s\n", __func__, line); StompProtocol* proto = StompProtocol::create(buf, this); if (proto == NULL) { printf("%s: protocol create failed: command='%s'\n", __func__, buf); return -1; } // headers while (next != NULL) { line = getline(&next, next); if (line[0] == 0) break; if ((value = strchr(line, ':')) != NULL) { *(value++) = 0; while (isspace(*value)) value++; proto->set_header(line, value); } } // message body int mlen = flen - (next - buf) - 1; if (next == NULL || mlen == 0) { printf("%s: no message body\n", __func__); proto->execute(NULL, 0); } else { printf("%s: message='%s', len=%d\n", __func__, next, mlen); proto->execute(next, mlen); } delete proto; return 0; }
t_frame *get_elem_from_map(t_ctrl *c, int x, int y, e_elem e) { t_frame *b; b = getframe(c, x, y); if (e == ALL) return (b); while (b) { if (b->type == e) return (b); b = b->next; } return (NULL); }
static void _fill_ids(t_ctrl *c, t_player *p, int *ids) { t_frame *f; t_player *tmp; int i; i = 0; f = getframe(c, p->x, p->y); while (f) { if (f->type == PLAYER && (tmp = f->p) && tmp != p && tmp->lvl == p->lvl) ids[i++] = tmp->id; f = f->next; } ids[i] = 0; }
int main(int argc, char *argv[]) { struct frame *newframe, *lp; int base, count; if (!get_args(argc, argv)) { return 1; } if (verbose) fprintf(stderr, "scriptsort: starting.\n"); BU_LIST_INIT(&head); globals.text=NULL; globals.tp=globals.tl = 0; globals.flags=globals.location=globals.length = 0; globals.l.magic = MAGIC; if (verbose) fprintf(stderr, "scriptsort: reading.\n"); while ((newframe=getframe(stdin)) != NULL) { BU_LIST_INSERT(&head, &newframe->l); } if (verbose) fprintf(stderr, "scriptsort: sorting.\n"); bubblesort(); if (verbose) fprintf(stderr, "scriptsort: merging.\n"); merge(); if (verbose) fprintf(stderr, "scriptsort: squirting.\n"); if (specify_base) { base = user_base; } else { base = 1; /* prints frames in natural order */ } if (base <= 0) { /*compute base as largest power of 2 less than num of frames*/ base = 1; count = 2; for (BU_LIST_FOR(lp, frame, &head)) { if (count-- <= 0) { base *= 2; count = base - 1; } } } else {
static int _parse_players(t_ctrl *c, t_player *p, int *ids) { t_frame *f; t_frame *f2; int flag; flag = 0; f = getframe(c, p->x, p->y); while (f) { f2 = f->next; if (f->type == PLAYER && f->p && f->p != p) { _expulse_player(c, f, (t_player *)f->p, p->d); ids[flag++] = ((t_player *)f->p)->id; } f = f2; } return (flag); }
int main(int argc, char *argv[]){ extern char *progname; extern char *filename; FILE *fp; id3v2header *header; id3v2frame *frame; progname = argv[0]; filename = argv[1]; if(argc != 2){ printf("Usage: %s filename\n", progname); exit(EXIT_FAILURE); } if((fp = fopen(filename, "r")) == NULL){ perror(progname); exit(EXIT_FAILURE); } if((header = getheader(fp)) == NULL){ fprintf(stderr, "%s error: not a valid MP3 file.\n", progname); exit(EXIT_FAILURE); } printheader(header); while(((frame = getframe(fp)) != NULL) && frame->body != NULL){ printframe(frame, 1); free(frame->body); frame->body = NULL; } (void) fclose(fp); return 0; }
FRAME *curframe() { static FRAME frame; FRAME *frp; ADDRESS *dp, *disp; int i; frp = &frame; dp = curdp(); disp = contents(dp); if (dispblk(dp) <= MAINBLK) { return NIL; } else { getframe(frp, disp); for (i = 1; i < MAXDEPTH; i++) { display[i] = dispval(i); } dispindex = dispblk(dp); return frp; } }
void dispatch_elems(t_ctrl *c, int x, int y) { t_frame *tmp; t_frame *tmp2; int newx; int newy; tmp = getframe(c, x, y); while (tmp) { tmp2 = tmp->next; if (tmp->type != PLAYER) { unset_elem_from_map(c, tmp, x, y); newx = rand() % c->options->map_x; newy = rand() % c->options->map_y; set_elem_on_map(c, tmp, newx, newy); gfx_send_frame_content(c, newx, newy); } tmp = tmp2; } gfx_send_frame_content(c, x, y); }
/* * Send an interrupt to process. */ void sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *mask) { struct lwp *l = curlwp; struct proc *p = l->l_proc; struct sigacts *ps = p->p_sigacts; struct frame *frame = (struct frame *)l->l_md.md_regs; int onstack; int sig = ksi->ksi_signo; u_long code = KSI_TRAPCODE(ksi); struct sigframe_sigcontext *fp = getframe(l, sig, &onstack), kf; sig_t catcher = SIGACTION(p, sig).sa_handler; short ft = frame->f_format; fp--; #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig(%d): sig %d ssp %p usp %p scp %p ft %d\n", p->p_pid, sig, &onstack, fp, &fp->sf_sc, ft); #endif /* Build stack frame for signal trampoline. */ switch (ps->sa_sigdesc[sig].sd_vers) { case 0: /* legacy on-stack sigtramp */ kf.sf_ra = (int)p->p_sigctx.ps_sigcode; break; case 1: kf.sf_ra = (int)ps->sa_sigdesc[sig].sd_tramp; break; default: /* Don't know what trampoline version; kill it. */ sigexit(l, SIGILL); } kf.sf_signum = sig; kf.sf_code = code; kf.sf_scp = &fp->sf_sc; /* * Save necessary hardware state. Currently this includes: * - general registers * - original exception frame (if not a "normal" frame) * - FP coprocessor state */ kf.sf_state.ss_flags = SS_USERREGS; memcpy(kf.sf_state.ss_frame.f_regs, frame->f_regs, sizeof(frame->f_regs)); if (ft >= FMT4) { #ifdef DEBUG if (ft > 15 || exframesize[ft] < 0) panic("sendsig: bogus frame type"); #endif kf.sf_state.ss_flags |= SS_RTEFRAME; kf.sf_state.ss_frame.f_format = frame->f_format; kf.sf_state.ss_frame.f_vector = frame->f_vector; memcpy(&kf.sf_state.ss_frame.F_u, &frame->F_u, (size_t) exframesize[ft]); /* * Leave an indicator that we need to clean up the kernel * stack. We do this by setting the "pad word" above the * hardware stack frame to the amount the stack must be * adjusted by. * * N.B. we increment rather than just set f_stackadj in * case we are called from syscall when processing a * sigreturn. In that case, f_stackadj may be non-zero. */ frame->f_stackadj += exframesize[ft]; frame->f_format = frame->f_vector = 0; #ifdef DEBUG if (sigdebug & SDB_FOLLOW) printf("sendsig(%d): copy out %d of frame %d\n", p->p_pid, exframesize[ft], ft); #endif } if (fputype) { kf.sf_state.ss_flags |= SS_FPSTATE; m68881_save(&kf.sf_state.ss_fpstate); } #ifdef DEBUG if ((sigdebug & SDB_FPSTATE) && *(char *)&kf.sf_state.ss_fpstate) printf("sendsig(%d): copy out FP state (%x) to %p\n", p->p_pid, *(u_int *)&kf.sf_state.ss_fpstate, &kf.sf_state.ss_fpstate); #endif /* Build the signal context to be used by sigreturn. */ kf.sf_sc.sc_sp = frame->f_regs[SP]; kf.sf_sc.sc_fp = frame->f_regs[A6]; kf.sf_sc.sc_ap = (int)&fp->sf_state; kf.sf_sc.sc_pc = frame->f_pc; kf.sf_sc.sc_ps = frame->f_sr; /* Save signal stack. */ kf.sf_sc.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK; /* Save signal mask. */ kf.sf_sc.sc_mask = *mask; #ifdef COMPAT_13 /* * XXX We always have to save an old style signal mask because * XXX we might be delivering a signal to a process which will * XXX escape from the signal in a non-standard way and invoke * XXX sigreturn() directly. */ native_sigset_to_sigset13(mask, &kf.sf_sc.__sc_mask13); #endif if (copyout(&kf, fp, sizeof(kf)) != 0) { #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig(%d): copyout failed on sig %d\n", p->p_pid, sig); #endif /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ sigexit(l, SIGILL); /* NOTREACHED */ } #ifdef DEBUG if (sigdebug & SDB_FOLLOW) printf("sendsig(%d): sig %d scp %p fp %p sc_sp %x sc_ap %x\n", p->p_pid, sig, kf.sf_scp, fp, kf.sf_sc.sc_sp, kf.sf_sc.sc_ap); #endif buildcontext(l, catcher, fp); /* Remember that we're now on the signal stack. */ if (onstack) p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK; #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig(%d): sig %d returns\n", p->p_pid, sig); #endif }
int fetchsignals(void) { int first = 1, framelen, i, imax, imin, j, *m, *mp, n; WFDB_Calinfo cal; WFDB_Sample **sb, **sp, *sbo, *spo, *v; WFDB_Time t, ts0, tsf; /* Do nothing if no samples were requested. */ if (nosig < 1 || t0 >= tf) return (0); /* Open the signal calibration database. */ (void)calopen("wfdbcal"); if (tfreq != ffreq) { ts0 = (WFDB_Time)(t0*tfreq/ffreq + 0.5); tsf = (WFDB_Time)(tf*tfreq/ffreq + 0.5); } else { ts0 = t0; tsf = tf; } /* Allocate buffers and buffer pointers for each selected signal. */ SUALLOC(sb, nsig, sizeof(WFDB_Sample *)); SUALLOC(sp, nsig, sizeof(WFDB_Sample *)); for (n = framelen = 0; n < nsig; framelen += s[n++].spf) if (sigmap[n] >= 0) { SUALLOC(sb[n], (int)((tf-t0)*s[n].spf + 0.5), sizeof(WFDB_Sample)); sp[n] = sb[n]; } /* Allocate a frame buffer and construct the frame map. */ SUALLOC(v, framelen, sizeof(WFDB_Sample)); /* frame buffer */ SUALLOC(m, framelen, sizeof(int)); /* frame map */ for (i = n = 0; n < nsig; n++) { for (j = 0; j < s[n].spf; j++) m[i++] = sigmap[n]; } for (imax = framelen-1; imax > 0 && m[imax] < 0; imax--) ; for (imin = 0; imin < imax && m[imin] < 0; imin++) ; /* Fill the buffers. */ isigsettime(t0); for (t = t0; t < tf && getframe(v) > 0; t++) for (i = imin, mp = m + imin; i <= imax; i++, mp++) if ((n = *mp) >= 0) *(sp[n]++) = v[i]; /* Generate output. */ printf(" { \"signal\":\n [\n"); for (n = 0; n < nsig; n++) { if (sigmap[n] >= 0) { char *p; int delta, prev; if (!first) printf(",\n"); else first = 0; printf(" { \"name\": %s,\n", p = strjson(sname[n])); SFREE(p); if (s[n].units) { printf(" \"units\": %s,\n", p = strjson(s[n].units)); SFREE(p); } else printf(" \"units\": \"mV\",\n"); printf(" \"t0\": %ld,\n", (long)ts0); printf(" \"tf\": %ld,\n", (long)tsf); printf(" \"gain\": %g,\n", s[n].gain ? s[n].gain : WFDB_DEFGAIN); printf(" \"base\": %d,\n", s[n].baseline); printf(" \"tps\": %d,\n", (int)(tfreq/(ffreq*s[n].spf)+0.5)); if (getcal(sname[n], s[n].units, &cal) == 0) printf(" \"scale\": %g,\n", cal.scale); else printf(" \"scale\": 1,\n"); printf(" \"samp\": [ "); for (sbo = sb[n], prev = 0, spo = sp[n]-1; sbo < spo; sbo++) { delta = *sbo - prev; printf("%d,", delta); prev = *sbo; } printf("%d ]\n }", *sbo - prev); } } printf("\n ]%s", nann ? ",\n" : "\n }\n"); flushcal(); for (n = 0; n < nsig; n++) SFREE(sb[n]); SFREE(sb); SFREE(sp); SFREE(v); SFREE(m); return (1); /* output was written */ }
void sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *mask) { struct lwp *l = curlwp; struct proc *p = l->l_proc; struct sigacts *ps = p->p_sigacts; int onstack, sig = ksi->ksi_signo; struct sigframe_sigcontext *fp, frame; struct trapframe *tf; sig_t catcher = SIGACTION(p, sig).sa_handler; tf = l->l_md.md_tf; fp = getframe(l, sig, &onstack), frame; fp--; #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig_sigcontext(%d): sig %d ssp %p usp %p\n", p->p_pid, sig, &onstack, fp); #endif /* Build stack frame for signal trampoline. */ frame.sf_sc.sc_pc = tf->tf_regs[FRAME_PC]; frame.sf_sc.sc_ps = tf->tf_regs[FRAME_PS]; /* Save register context. */ frametoreg(tf, (struct reg *)frame.sf_sc.sc_regs); frame.sf_sc.sc_regs[R_ZERO] = 0xACEDBADE; /* magic number */ frame.sf_sc.sc_regs[R_SP] = alpha_pal_rdusp(); /* save the floating-point state, if necessary, then copy it. */ if (l->l_addr->u_pcb.pcb_fpcpu != NULL) fpusave_proc(l, 1); frame.sf_sc.sc_ownedfp = l->l_md.md_flags & MDP_FPUSED; memcpy((struct fpreg *)frame.sf_sc.sc_fpregs, &l->l_addr->u_pcb.pcb_fp, sizeof(struct fpreg)); frame.sf_sc.sc_fp_control = alpha_read_fp_c(l); memset(frame.sf_sc.sc_reserved, 0, sizeof frame.sf_sc.sc_reserved); memset(frame.sf_sc.sc_xxx, 0, sizeof frame.sf_sc.sc_xxx); /* XXX */ /* Save signal stack. */ frame.sf_sc.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK; /* Save signal mask. */ frame.sf_sc.sc_mask = *mask; #ifdef COMPAT_13 /* * XXX We always have to save an old style signal mask because * XXX we might be delivering a signal to a process which will * XXX escape from the signal in a non-standard way and invoke * XXX sigreturn() directly. */ { /* Note: it's a long in the stack frame. */ sigset13_t mask13; native_sigset_to_sigset13(mask, &mask13); frame.sf_sc.__sc_mask13 = mask13; } #endif #ifdef COMPAT_OSF1 /* * XXX Create an OSF/1-style sigcontext and associated goo. */ #endif if (copyout(&frame, (caddr_t)fp, sizeof(frame)) != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig_sigcontext(%d): copyout failed on sig %d\n", p->p_pid, sig); #endif sigexit(l, SIGILL); /* NOTREACHED */ } #ifdef DEBUG if (sigdebug & SDB_FOLLOW) printf("sendsig_sigcontext(%d): sig %d usp %p code %x\n", p->p_pid, sig, fp, ksi->ksi_code); #endif /* * Set up the registers to directly invoke the signal handler. The * signal trampoline is then used to return from the signal. Note * the trampoline version numbers are coordinated with machine- * dependent code in libc. */ switch (ps->sa_sigdesc[sig].sd_vers) { case 0: /* legacy on-stack sigtramp */ buildcontext(l,(void *)catcher, (void *)p->p_sigctx.ps_sigcode, (void *)fp); break; case 1: buildcontext(l,(void *)catcher, (void *)ps->sa_sigdesc[sig].sd_tramp, (void *)fp); break; default: /* Don't know what trampoline version; kill it. */ sigexit(l, SIGILL); } /* sigcontext specific trap frame */ tf->tf_regs[FRAME_A0] = sig; /* tf->tf_regs[FRAME_A1] = ksi->ksi_code; */ tf->tf_regs[FRAME_A1] = KSI_TRAPCODE(ksi); tf->tf_regs[FRAME_A2] = (u_int64_t)&fp->sf_sc; /* Remember that we're now on the signal stack. */ if (onstack) p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK; #ifdef DEBUG if (sigdebug & SDB_FOLLOW) printf("sendsig(%d): pc %lx, catcher %lx\n", p->p_pid, tf->tf_regs[FRAME_PC], tf->tf_regs[FRAME_A3]); if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig(%d): sig %d returns\n", p->p_pid, sig); #endif }
/***************************************** * * Actually check to see if we have a frame, and process it if we do. * *****************************************/ int eapol_execute(struct interface_data *workint) { char newframe[1518], respframe[1518]; int framesize, respsize, retval=0; struct eapol_header *temp; char *inframe; // A pointer to our frame data. (Normally will point // to the newframe[] array.) if (!workint) { debug_printf(DEBUG_NORMAL, "NULL data passed in to eapol_execute()!\n"); return XEMALLOC; } bzero(&newframe, 1518); if (getframe(workint, (char *)&newframe, &framesize) < 0) { debug_printf(DEBUG_EXCESSIVE, "There are no frames to process.\n"); framesize = 0; retval = XENOFRAMES; inframe = NULL; // Have the EAP types process, if they are in // a state to request information from the GUI. } else { // We want to let getframe be called, even if we don't have any // config information. That will keep the frame queue empty so that // when we do have enough config information we can start by processing // an EAP request that is valid. If we don't have any config informtion, // we should just bail here, and not return an error. inframe = (char *)&newframe; if (workint->userdata == NULL) return XEMALLOC; temp = (struct eapol_header *)&newframe[OFFSET_PAST_MAC]; if (ntohs(temp->frame_type) == 0x888e) { if (temp->eapol_version > MAX_EAPOL_VER) { debug_printf(DEBUG_EVERYTHING, "Got invalid EAPOL frame!\n"); framesize = 0; } else { switch (temp->eapol_type) { case EAP_PACKET: // Process the EAP header, and determine if we need to set // any state machine variables. eap_process_header(workint, (char *)&newframe, framesize); break; case EAPOL_START: debug_printf(DEBUG_NORMAL, "Got EAPoL-Start! Ignoring!\n"); return XEIGNOREDFRAME; case EAPOL_LOGOFF: debug_printf(DEBUG_NORMAL, "Got EAPoL-Logoff! Ignoring!\n"); return XEIGNOREDFRAME; case EAPOL_KEY: debug_printf(DEBUG_NORMAL, "Processing EAPoL-Key!\n"); workint->statemachine->rxKey = TRUE; run_key_statemachine(workint, (char *)&newframe, framesize); return XGOODKEYFRAME; case EAPOL_ASF_ALERT: debug_printf(DEBUG_NORMAL, "Got EAPoL-ASF-Alert!\n"); return XEIGNOREDFRAME; default: debug_printf(DEBUG_NORMAL, "Unknown EAPoL type! (%02X)\n", temp->eapol_type); return XEIGNOREDFRAME; } } } else { debug_printf(DEBUG_EVERYTHING, "Got a frame, but it isn't an EAPoL frame, ignoring.\n"); } } // Process our state machine. if (statemachine_run(workint, inframe, framesize, (char *)&respframe, &respsize) == XDATA) { // Send a frame out. sendframe(workint, (char *)&respframe, respsize); } return XENONE; }
/* * Stack is set up to allow sigcode stored * in u. to call routine, followed by kcall * to sigreturn routine below. After sigreturn * resets the signal mask, the stack, and the * frame pointer, it returns to the user * specified pc, psl. */ static void sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *mask) { struct lwp *l = curlwp; struct proc *p = l->l_proc; struct sigacts *ps = p->p_sigacts; struct trapframe *tf = l->l_md.md_regs; int sig = ksi->ksi_info._signo; sig_t catcher = SIGACTION(p, sig).sa_handler; struct sigframe_sigcontext *fp, frame; int onstack, error; fp = getframe(l, sig, &onstack); --fp; /* Save register context. */ frame.sf_sc.sc_ssr = tf->tf_ssr; frame.sf_sc.sc_spc = tf->tf_spc; frame.sf_sc.sc_pr = tf->tf_pr; frame.sf_sc.sc_r15 = tf->tf_r15; frame.sf_sc.sc_r14 = tf->tf_r14; frame.sf_sc.sc_r13 = tf->tf_r13; frame.sf_sc.sc_r12 = tf->tf_r12; frame.sf_sc.sc_r11 = tf->tf_r11; frame.sf_sc.sc_r10 = tf->tf_r10; frame.sf_sc.sc_r9 = tf->tf_r9; frame.sf_sc.sc_r8 = tf->tf_r8; frame.sf_sc.sc_r7 = tf->tf_r7; frame.sf_sc.sc_r6 = tf->tf_r6; frame.sf_sc.sc_r5 = tf->tf_r5; frame.sf_sc.sc_r4 = tf->tf_r4; frame.sf_sc.sc_r3 = tf->tf_r3; frame.sf_sc.sc_r2 = tf->tf_r2; frame.sf_sc.sc_r1 = tf->tf_r1; frame.sf_sc.sc_r0 = tf->tf_r0; frame.sf_sc.sc_expevt = tf->tf_expevt; /* Save signal stack. */ frame.sf_sc.sc_onstack = l->l_sigstk.ss_flags & SS_ONSTACK; /* Save signal mask. */ frame.sf_sc.sc_mask = *mask; sendsig_reset(l, sig); mutex_exit(p->p_lock); error = copyout(&frame, fp, sizeof(frame)); mutex_enter(p->p_lock); if (error != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ sigexit(l, SIGILL); /* NOTREACHED */ } /* * Build context to run handler in. We invoke the handler * directly, only returning via the trampoline. */ switch (ps->sa_sigdesc[sig].sd_vers) { case 0: /* legacy on-stack sigtramp */ tf->tf_pr = (int)p->p_sigctx.ps_sigcode; break; case 1: tf->tf_pr = (int)ps->sa_sigdesc[sig].sd_tramp; break; default: /* Don't know what trampoline version; kill it. */ printf("sendsig_sigcontext: bad version %d\n", ps->sa_sigdesc[sig].sd_vers); sigexit(l, SIGILL); } tf->tf_r4 = sig; tf->tf_r5 = ksi->ksi_code; tf->tf_r6 = (int)&fp->sf_sc; tf->tf_spc = (int)catcher; tf->tf_r15 = (int)fp; /* Remember if we're now on the signal stack. */ if (onstack) l->l_sigstk.ss_flags |= SS_ONSTACK; }
main(int argc, char **argv) { char *record = NULL, *prog_name(); int aindex = 0, alen = 0, framelen = 0; int i, nsig, s, vflag = 0; WFDB_Sample *frame; WFDB_Siginfo *si; void help(); pname = prog_name(argv[0]); for (i = 1; i < argc; i++) { if (*argv[i] == '-') switch (*(argv[i]+1)) { case 'F': if (++i >= argc) { (void)fprintf(stderr, "%s: sampling frequency must follow -F\n", pname); exit(1); } sscanf(argv[i], "%lf", &sfreq); if (sfreq <= 0.0) sfreq = 1.0; break; case 'h': /* help requested */ help(); exit(0); break; case 'r': /* record name */ if (++i >= argc) { (void)fprintf(stderr, "%s: record name must follow -r\n", pname); exit(1); } record = argv[i]; break; case 'v': /* verbose output -- include column headings */ vflag = 1; break; default: (void)fprintf(stderr, "%s: unrecognized option %s\n", pname, argv[i]); exit(1); } else { (void)fprintf(stderr, "%s: unrecognized argument %s\n", pname, argv[i]); exit(1); } } if (record == NULL) { help(); exit(1); } setgvmode(WFDB_HIGHRES); if ((nsig = isigopen(record, NULL, 0)) <= 0) exit(2); if ((si = malloc(nsig * sizeof(WFDB_Siginfo))) == NULL) { (void)fprintf(stderr, "%s: insufficient memory\n", pname); exit(2); } if ((nsig = isigopen(record, si, nsig)) <= 0) exit(2); for (i = framelen = 0; i < nsig; i++) { if (strcmp(si[i].desc, "EDF Annotations") == 0) { aindex = framelen; alen = si[i].spf; } framelen += si[i].spf; } if (alen == 0) { (void)fprintf(stderr, "%s: record %s has no EDF annotations\n", pname, record); (void)free(si); wfdbquit(); exit(3); } if ((frame = (int *)malloc((unsigned)framelen*sizeof(WFDB_Sample)))==NULL) { (void)fprintf(stderr, "%s: insufficient memory\n", pname); (void)free(si); exit(2); } if (sfreq > 0.0) { setgvmode(WFDB_LOWRES); setsampfreq(sfreq); } else sfreq = sampfreq(NULL); /* Print column headers if '-v' option selected. */ if (vflag) (void)printf(" Time Sample # Type Sub Chan Num\tAux\n"); while (getframe(frame) > 0) { WFDB_Sample *p; state = 0; for (i = 0, p = (frame + aindex); i < alen; i++, p++) { if (*p) { proc(*p); proc(*p >> 8); } else break; } }
/* * Send an interrupt to process. * * Stack is set up to allow sigcode stored * in u. to call routine, followed by kcall * to sigreturn routine below. After sigreturn * resets the signal mask, the stack, and the * frame pointer, it returns to the user * specified pc, psl. */ void sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *mask) { struct lwp *l = curlwp; struct proc *p = l->l_proc; struct sigacts *ps = p->p_sigacts; struct reg *regs; int sig = ksi->ksi_signo; int onstack; struct sigframe *fp = getframe(l, sig, &onstack), frame; sig_t catcher = SIGACTION(p, sig).sa_handler; regs = l->l_md.md_regs; fp--; /* Build stack frame for signal trampoline. */ switch (ps->sa_sigdesc[sig].sd_vers) { case 0: frame.sf_ra = (int)p->p_sigctx.ps_sigcode; break; case 1: frame.sf_ra = (int)ps->sa_sigdesc[sig].sd_tramp; break; default: /* Don't know what trampoline version; kill it. */ sigexit(l, SIGILL); } frame.sf_signum = sig; frame.sf_code = ksi->ksi_trap; frame.sf_scp = &fp->sf_sc; /* Save the register context. */ frame.sf_sc.sc_fp = regs->r_fp; frame.sf_sc.sc_sp = regs->r_sp; frame.sf_sc.sc_pc = regs->r_pc; frame.sf_sc.sc_ps = regs->r_psr; frame.sf_sc.sc_sb = regs->r_sb; frame.sf_sc.sc_reg[REG_R7] = regs->r_r7; frame.sf_sc.sc_reg[REG_R6] = regs->r_r6; frame.sf_sc.sc_reg[REG_R5] = regs->r_r5; frame.sf_sc.sc_reg[REG_R4] = regs->r_r4; frame.sf_sc.sc_reg[REG_R3] = regs->r_r3; frame.sf_sc.sc_reg[REG_R2] = regs->r_r2; frame.sf_sc.sc_reg[REG_R1] = regs->r_r1; frame.sf_sc.sc_reg[REG_R0] = regs->r_r0; /* Save signal stack. */ frame.sf_sc.sc_onstack = p->p_sigctx.ps_sigstk.ss_flags & SS_ONSTACK; /* Save the signal mask. */ frame.sf_sc.sc_mask = *mask; #ifdef COMPAT_13 /* * XXX We always have to save an old style signal mask because * XXX we might be delivering a signal to a process which will * XXX escape from the signal in a non-standard way and invoke * XXX sigreturn() directly. */ native_sigset_to_sigset13(mask, &frame.sf_sc.__sc_mask13); #endif if (copyout(&frame, fp, sizeof(frame)) != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ sigexit(l, SIGILL); /* NOTREACHED */ } /* * Build context to run handler in. We invoke the handler * directly, only returning via the trampoline. Note the * trampoline version numbers are coordinated with machine- * dependent code in libc. */ regs->r_sp = (int)fp; regs->r_pc = (int)catcher; /* Remember that we're now on the signal stack. */ if (onstack) p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK; }
/* * Send an interrupt to process. * * Stack is set up to allow sigcode stored * in u. to call routine, followed by kcall * to sigreturn routine below. After sigreturn * resets the signal mask, the stack, and the * frame pointer, it returns to the user * specified pc, psl. */ void freebsd_sendsig(const ksiginfo_t *ksi, const sigset_t *mask) { int sig = ksi->ksi_signo; u_long code = KSI_TRAPCODE(ksi); struct lwp *l = curlwp; struct proc *p = l->l_proc; int onstack, error; struct freebsd_sigframe *fp = getframe(l, sig, &onstack), frame; sig_t catcher = SIGACTION(p, sig).sa_handler; struct trapframe *tf = l->l_md.md_regs; fp--; /* Build stack frame for signal trampoline. */ frame.sf_signum = sig; frame.sf_code = code; frame.sf_scp = &fp->sf_sc; frame.sf_addr = (char *)rcr2(); frame.sf_handler = catcher; /* Save context. */ #ifdef VM86 if (tf->tf_eflags & PSL_VM) { frame.sf_sc.sc_gs = tf->tf_vm86_gs; frame.sf_sc.sc_fs = tf->tf_vm86_fs; frame.sf_sc.sc_es = tf->tf_vm86_es; frame.sf_sc.sc_ds = tf->tf_vm86_ds; frame.sf_sc.sc_efl = get_vflags(l); (*p->p_emul->e_syscall_intern)(p); } else #endif { frame.sf_sc.sc_gs = tf->tf_gs; frame.sf_sc.sc_fs = tf->tf_fs; frame.sf_sc.sc_es = tf->tf_es; frame.sf_sc.sc_ds = tf->tf_ds; frame.sf_sc.sc_efl = tf->tf_eflags; } frame.sf_sc.sc_edi = tf->tf_edi; frame.sf_sc.sc_esi = tf->tf_esi; frame.sf_sc.sc_ebp = tf->tf_ebp; frame.sf_sc.sc_isp = 0; /* don't have to pass kernel sp to user. */ frame.sf_sc.sc_ebx = tf->tf_ebx; frame.sf_sc.sc_edx = tf->tf_edx; frame.sf_sc.sc_ecx = tf->tf_ecx; frame.sf_sc.sc_eax = tf->tf_eax; frame.sf_sc.sc_eip = tf->tf_eip; frame.sf_sc.sc_cs = tf->tf_cs; frame.sf_sc.sc_esp = tf->tf_esp; frame.sf_sc.sc_ss = tf->tf_ss; /* Save signal stack. */ frame.sf_sc.sc_onstack = l->l_sigstk.ss_flags & SS_ONSTACK; /* Save signal mask. */ /* XXX freebsd_osigcontext compat? */ frame.sf_sc.sc_mask = *mask; sendsig_reset(l, sig); mutex_exit(p->p_lock); error = copyout(&frame, fp, sizeof(frame)); mutex_enter(p->p_lock); if (error != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ sigexit(l, SIGILL); /* NOTREACHED */ } buildcontext(l, GUCODEBIG_SEL, p->p_sigctx.ps_sigcode, fp); /* Remember that we're now on the signal stack. */ if (onstack) l->l_sigstk.ss_flags |= SS_ONSTACK; }
void demo::makemap_ICP(){ ros::Time start, end; Eigen::Matrix4d T_backup; T_backup.setIdentity(); PCloud cloud_s; PCloud cloud_d; //take 1 frame cloud_s = getframe(); pub_pointcloud.publish(cloud_s); std::cout<< 0 << "\n"; *cloud_key = *cloud_s; cloud_d = getframe(); ICP icp(cloud_s,cloud_d); RGBFeaturesInit rgbf(cloud_s,cloud_d); rgbf_key.setRansacThreshold(th); rgbf_key.setDesiredP(prob); rgbf.setRansacThreshold(th); rgbf.setDesiredP(prob); icp.setRThreshold (THRESH_dr); icp.setTThreshold (THRESH_dt); icp.setDisThreshold(D); icp.setNiterations (max_iterations); icp.setMaxPairs (MAXPAIRS); icp.setMinPairs (MINPAIRS); Eigen::Vector3d p1(0.0,0.0,0.0); Eigen::Vector3d p2(0.0,0.0,0.1); camera_positions.push_back(std::make_pair(p1, p2)); int i=1; float a1,a2; int ft; while(ros::ok()) { ROS_INFO("%d ", i); start = ros::Time::now(); ft = rgbf.compute(); end = ros::Time::now(); a1 = (end-start).toSec(); start = ros::Time::now(); if ( ft > f_th ){ icp.align(rgbf.T,rgbf.getInliers()); }else{ icp.align(T_backup); } end = ros::Time::now(); a2 = (end-start).toSec(); //update transformation T_backup=icp.returnTr(); T = T*icp.returnTr(); ROS_INFO("RGB: %.6f seconds | ICP: %.6f seconds | inliears= %d", a1, a2,ft); //update camera position p1 = T.block<3,3>(0,0)*camera_positions[0].first + T.block<3,1>(0,3); p2 = T.block<3,3>(0,0)*camera_positions[0].second + T.block<3,1>(0,3); camera_positions.push_back(std::make_pair(p1, p2)); if(checkIfIsNewKeyframe(cloud_d)){ ApplyRTto(cloud_d); pub_pointcloud.publish(cloud_d); } cloud_d = getframe(); //update icp clouds rgbf.setNewinputCloud(cloud_d); icp.setNewICPinputCloud(cloud_d); i++; } WriteCameraPLY(cameras_filename.data(), camera_positions); }
void glueMpeg2_get(Mpeg2 *mpg, Texture *dst, int sync_channel, float fps, int border, int skip_frames, int reset_on_error) { unsigned char *tmpbuf; int framecnt=0; float curtime; #ifdef USE_FMODEX if(sync_channel==-1) // no audio sync curtime = timeGetTime(); else // get time from audio channel curtime = fmod_gettick_channel(sync_channel)+(1000.0/fps); #else curtime = timeGetTime(); #endif if (mpg->end==1) { glueMpeg2_reset(mpg); } if (mpg->prevtime==0) { getframe(mpg, dst); if (mpg->end==2) { glueMpeg2_reset(mpg); return; } if (mpg->end==3) { if (reset_on_error) glueMpeg2_reset(mpg); return; } } else if (curtime-mpg->prevtime < 1000.0/fps) return; else { int x; framecnt=(curtime-mpg->prevtime)/(1000.0/fps); if (skip_frames==0 && framecnt>1) framecnt=1; for (x=0; x<framecnt; x++) { getframe(mpg, dst); if (mpg->end==2) { glueMpeg2_reset(mpg); return; } if (mpg->end==3) { if (reset_on_error) glueMpeg2_reset(mpg); return; } } } if (mpg->prevtime==0) mpg->prevtime=curtime; else mpg->prevtime+=1000.0/fps*framecnt; //mpg->prevtime=timeGetTime(); tmpbuf=tmpmalloc(dst->xres*dst->yres*4); if (mpg->info->display_fbuf) { int w, h; w=mpg->info->sequence->width; h=mpg->info->sequence->height; if (dst->xres==w && dst->yres==h && (!border)) { glueReloadtexture(dst, mpg->info->display_fbuf->buf[0]); } else { int x; memset(tmpbuf, 0, dst->xres*dst->yres*4); if (dst->xres < w || dst->yres < h) glueErrorf("erreur: ur texture too small for ur videoz (%ix%i vs %ix%i)", w, h, dst->xres, dst->yres); for (x=0; x<h; x++) memcpy(tmpbuf+x*dst->xres*4, mpg->info->display_fbuf->buf[0]+x*w*4, dst->xres*4); if (border) { for (x=0; x<w; x++) { blask(tmpbuf, x); blask(tmpbuf, x+(h-1)*dst->xres); } for (x=0; x<h; x++) { blask(tmpbuf, x*dst->xres); blask(tmpbuf, x*dst->xres+w-1); } } dst->scale.x=(float)w/dst->xres; dst->scale.y=(float)h/dst->yres; glueReloadtexture(dst, tmpbuf); } } tmpfree(tmpbuf); }
/* * Send a signal to process. */ void sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *returnmask) { int sig = ksi->ksi_signo; struct lwp * const l = curlwp; struct proc * const p = l->l_proc; struct sigacts * const ps = p->p_sigacts; struct pcb * const pcb = lwp_getpcb(l); int onstack, error; struct sigcontext *scp = getframe(l, sig, &onstack); struct sigcontext ksc; struct trapframe * const tf = l->l_md.md_utf; sig_t catcher = SIGACTION(p, sig).sa_handler; #if !defined(__mips_o32) if (p->p_md.md_abi != _MIPS_BSD_API_O32) sigexit(l, SIGILL); #endif scp--; #ifdef DEBUG if ((sigdebug & SDB_FOLLOW) || ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)) printf("sendsig(%d): sig %d ssp %p scp %p\n", p->p_pid, sig, &onstack, scp); #endif /* Build stack frame for signal trampoline. */ ksc.sc_pc = tf->tf_regs[_R_PC]; ksc.mullo = tf->tf_regs[_R_MULLO]; ksc.mulhi = tf->tf_regs[_R_MULHI]; /* Save register context. */ ksc.sc_regs[_R_ZERO] = 0xACEDBADE; /* magic number */ #if defined(__mips_o32) memcpy(&ksc.sc_regs[1], &tf->tf_regs[1], sizeof(ksc.sc_regs) - sizeof(ksc.sc_regs[0])); #else for (size_t i = 1; i < 32; i++) ksc.sc_regs[i] = tf->tf_regs[i]; #endif /* Save the FP state, if necessary, then copy it. */ ksc.sc_fpused = fpu_used_p(); #if !defined(NOFPU) if (ksc.sc_fpused) { /* if FPU has current state, save it first */ fpu_save(); } #endif *(struct fpreg *)ksc.sc_fpregs = *(struct fpreg *)&pcb->pcb_fpregs; /* Save signal stack. */ ksc.sc_onstack = l->l_sigstk.ss_flags & SS_ONSTACK; /* Save signal mask. */ ksc.sc_mask = *returnmask; #if defined(COMPAT_13) || defined(COMPAT_ULTRIX) /* * XXX We always have to save an old style signal mask because * XXX we might be delivering a signal to a process which will * XXX escape from the signal in a non-standard way and invoke * XXX sigreturn() directly. */ native_sigset_to_sigset13(returnmask, &ksc.__sc_mask13); #endif sendsig_reset(l, sig); mutex_exit(p->p_lock); error = copyout(&ksc, (void *)scp, sizeof(ksc)); mutex_enter(p->p_lock); if (error != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ #ifdef DEBUG if ((sigdebug & SDB_FOLLOW) || ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)) printf("sendsig(%d): copyout failed on sig %d\n", p->p_pid, sig); #endif sigexit(l, SIGILL); /* NOTREACHED */ } /* * Set up the registers to directly invoke the signal * handler. The return address will be set up to point * to the signal trampoline to bounce us back. */ tf->tf_regs[_R_A0] = sig; tf->tf_regs[_R_A1] = ksi->ksi_trap; tf->tf_regs[_R_A2] = (intptr_t)scp; tf->tf_regs[_R_A3] = (intptr_t)catcher; /* XXX ??? */ tf->tf_regs[_R_PC] = (intptr_t)catcher; tf->tf_regs[_R_T9] = (intptr_t)catcher; tf->tf_regs[_R_SP] = (intptr_t)scp; switch (ps->sa_sigdesc[sig].sd_vers) { case 0: /* legacy on-stack sigtramp */ tf->tf_regs[_R_RA] = (intptr_t)p->p_sigctx.ps_sigcode; break; #ifdef COMPAT_16 case 1: tf->tf_regs[_R_RA] = (intptr_t)ps->sa_sigdesc[sig].sd_tramp; break; #endif default: /* Don't know what trampoline version; kill it. */ sigexit(l, SIGILL); } /* Remember that we're now on the signal stack. */ if (onstack) l->l_sigstk.ss_flags |= SS_ONSTACK; #ifdef DEBUG if ((sigdebug & SDB_FOLLOW) || ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)) printf("sendsig(%d): sig %d returns\n", p->p_pid, sig); #endif }
/* * Send an interrupt to process. * * Stack is set up to allow sigcode stored * in u. to call routine, followed by kcall * to sigreturn routine below. After sigreturn * resets the signal mask, the stack, and the * frame pointer, it returns to the user * specified pc, psl. */ void sendsig_sigcontext(const ksiginfo_t *ksi, const sigset_t *mask) { struct lwp *l = curlwp; struct proc *p = l->l_proc; struct pmap *pmap = vm_map_pmap(&p->p_vmspace->vm_map); int sel = pmap->pm_hiexec > I386_MAX_EXE_ADDR ? GUCODEBIG_SEL : GUCODE_SEL; struct sigacts *ps = p->p_sigacts; struct trapframe *tf = l->l_md.md_regs; int onstack, error; int sig = ksi->ksi_signo; u_long code = KSI_TRAPCODE(ksi); struct sigframe_sigcontext *fp = getframe(l, sig, &onstack), frame; sig_t catcher = SIGACTION(p, sig).sa_handler; fp--; /* Build stack frame for signal trampoline. */ switch (ps->sa_sigdesc[sig].sd_vers) { case 0: /* legacy on-stack sigtramp */ frame.sf_ra = (int)p->p_sigctx.ps_sigcode; break; case 1: frame.sf_ra = (int)ps->sa_sigdesc[sig].sd_tramp; break; default: /* Don't know what trampoline version; kill it. */ sigexit(l, SIGILL); } frame.sf_signum = sig; frame.sf_code = code; frame.sf_scp = &fp->sf_sc; /* Save register context. */ #ifdef VM86 if (tf->tf_eflags & PSL_VM) { frame.sf_sc.sc_gs = tf->tf_vm86_gs; frame.sf_sc.sc_fs = tf->tf_vm86_fs; frame.sf_sc.sc_es = tf->tf_vm86_es; frame.sf_sc.sc_ds = tf->tf_vm86_ds; frame.sf_sc.sc_eflags = get_vflags(l); (*p->p_emul->e_syscall_intern)(p); } else #endif { frame.sf_sc.sc_gs = tf->tf_gs; frame.sf_sc.sc_fs = tf->tf_fs; frame.sf_sc.sc_es = tf->tf_es; frame.sf_sc.sc_ds = tf->tf_ds; frame.sf_sc.sc_eflags = tf->tf_eflags; } frame.sf_sc.sc_edi = tf->tf_edi; frame.sf_sc.sc_esi = tf->tf_esi; frame.sf_sc.sc_ebp = tf->tf_ebp; frame.sf_sc.sc_ebx = tf->tf_ebx; frame.sf_sc.sc_edx = tf->tf_edx; frame.sf_sc.sc_ecx = tf->tf_ecx; frame.sf_sc.sc_eax = tf->tf_eax; frame.sf_sc.sc_eip = tf->tf_eip; frame.sf_sc.sc_cs = tf->tf_cs; frame.sf_sc.sc_esp = tf->tf_esp; frame.sf_sc.sc_ss = tf->tf_ss; frame.sf_sc.sc_trapno = tf->tf_trapno; frame.sf_sc.sc_err = tf->tf_err; /* Save signal stack. */ frame.sf_sc.sc_onstack = l->l_sigstk.ss_flags & SS_ONSTACK; /* Save signal mask. */ frame.sf_sc.sc_mask = *mask; #ifdef COMPAT_13 /* * XXX We always have to save an old style signal mask because * XXX we might be delivering a signal to a process which will * XXX escape from the signal in a non-standard way and invoke * XXX sigreturn() directly. */ native_sigset_to_sigset13(mask, &frame.sf_sc.__sc_mask13); #endif sendsig_reset(l, sig); mutex_exit(p->p_lock); error = copyout(&frame, fp, sizeof(frame)); mutex_enter(p->p_lock); if (error != 0) { /* * Process has trashed its stack; give it an illegal * instruction to halt it in its tracks. */ sigexit(l, SIGILL); /* NOTREACHED */ } int svufpu = l->l_md.md_flags & MDL_USEDFPU; buildcontext(l, sel, catcher, fp); l->l_md.md_flags |= svufpu; /* Remember that we're now on the signal stack. */ if (onstack) l->l_sigstk.ss_flags |= SS_ONSTACK; }