本文整理汇总了C++中CLR函数的典型用法代码示例。如果您正苦于以下问题:C++ CLR函数的具体用法?C++ CLR怎么用?C++ CLR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CLR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: stty_open
int
stty_open(dev_t dev, int flags, int mode, struct lwp *l)
{
struct spif_softc *csc;
struct stty_softc *sc;
struct stty_port *sp;
struct tty *tp;
int card = SPIF_CARD(dev);
int port = SPIF_PORT(dev);
sc = device_lookup_private(&stty_cd, card);
csc = device_lookup_private(&spif_cd, card);
if (sc == NULL || csc == NULL)
return (ENXIO);
if (port >= sc->sc_nports)
return (ENXIO);
sp = &sc->sc_port[port];
tp = sp->sp_tty;
tp->t_dev = dev;
if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp))
return (EBUSY);
mutex_spin_enter(&tty_lock);
if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG;
tp->t_oflag = TTYDEF_OFLAG;
tp->t_cflag = TTYDEF_CFLAG;
if (ISSET(sp->sp_openflags, TIOCFLAG_CLOCAL))
SET(tp->t_cflag, CLOCAL);
if (ISSET(sp->sp_openflags, TIOCFLAG_CRTSCTS))
SET(tp->t_cflag, CRTSCTS);
if (ISSET(sp->sp_openflags, TIOCFLAG_MDMBUF))
SET(tp->t_cflag, MDMBUF);
tp->t_lflag = TTYDEF_LFLAG;
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
sp->sp_rput = sp->sp_rget = sp->sp_rbuf;
STC_WRITE(csc, STC_CAR, sp->sp_channel);
stty_write_ccr(csc, CD180_CCR_CMD_RESET|CD180_CCR_RESETCHAN);
STC_WRITE(csc, STC_CAR, sp->sp_channel);
stty_param(tp, &tp->t_termios);
ttsetwater(tp);
STC_WRITE(csc, STC_SRER, CD180_SRER_CD | CD180_SRER_RXD);
if (ISSET(sp->sp_openflags, TIOCFLAG_SOFTCAR) || sp->sp_carrier)
SET(tp->t_state, TS_CARR_ON);
else
CLR(tp->t_state, TS_CARR_ON);
}
if (!ISSET(flags, O_NONBLOCK)) {
while (!ISSET(tp->t_cflag, CLOCAL) &&
!ISSET(tp->t_state, TS_CARR_ON)) {
int error;
error = ttysleep(tp, &tp->t_rawcv, true, 0);
if (error != 0) {
mutex_spin_exit(&tty_lock);
return (error);
}
}
}
mutex_spin_exit(&tty_lock);
return ((*tp->t_linesw->l_open)(dev, tp));
}
开发者ID:eyberg,项目名称:rumpkernel-netbsd-src,代码行数:73,代码来源:spif.c
示例2: at91usart_open
int
at91usart_open(dev_t dev, int flag, int mode, struct lwp *l)
{
struct at91usart_softc *sc;
struct tty *tp;
int s;
int error;
sc = device_lookup_private(&at91usart_cd, COMUNIT(dev));
if (sc == NULL || !ISSET(sc->sc_hwflags, COM_HW_DEV_OK))
return (ENXIO);
if (!device_is_active(sc->sc_dev))
return (ENXIO);
#ifdef KGDB
/*
* If this is the kgdb port, no other use is permitted.
*/
if (ISSET(sc->sc_hwflags, COM_HW_KGDB))
return (EBUSY);
#endif
tp = sc->sc_tty;
if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, tp))
return (EBUSY);
s = spltty();
/*
* Do the following iff this is a first open.
*/
if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
struct termios t;
tp->t_dev = dev;
if (sc->enable) {
if ((*sc->enable)(sc)) {
splx(s);
printf("%s: device enable failed\n",
device_xname(sc->sc_dev));
return (EIO);
}
sc->enabled = 1;
#if 0
/* XXXXXXXXXXXXXXX */
com_config(sc);
#endif
}
/* reset fifos: */
AT91PDC_RESET_FIFO(sc->sc_iot, sc->sc_ioh, sc->sc_dmat, US_PDC, &sc->sc_rx_fifo, 0);
AT91PDC_RESET_FIFO(sc->sc_iot, sc->sc_ioh, sc->sc_dmat, US_PDC, &sc->sc_tx_fifo, 1);
/* reset receive */
at91usart_writereg(sc, US_CR, US_CR_RSTSTA | US_CR_STTTO);
/* Turn on interrupts. */
sc->sc_ier = US_CSR_ENDRX|US_CSR_RXBUFF|US_CSR_TIMEOUT|US_CSR_RXBRK;
at91usart_writereg(sc, US_IER, sc->sc_ier);
/* enable DMA: */
at91usart_writereg(sc, US_PDC + PDC_PTCR, PDC_PTCR_RXTEN);
/*
* Initialize the termios status to the defaults. Add in the
* sticky bits from TIOCSFLAGS.
*/
t.c_ispeed = 0;
/* if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
t.c_ospeed = usart_cn_sc.sc_ospeed;
t.c_cflag = usart_cn_sc.sc_cflag;
} else*/ {
t.c_ospeed = TTYDEF_SPEED;
t.c_cflag = TTYDEF_CFLAG;
}
if (ISSET(sc->sc_swflags, TIOCFLAG_CLOCAL))
SET(t.c_cflag, CLOCAL);
if (ISSET(sc->sc_swflags, TIOCFLAG_CRTSCTS))
SET(t.c_cflag, CRTSCTS);
if (ISSET(sc->sc_swflags, TIOCFLAG_MDMBUF))
SET(t.c_cflag, MDMBUF);
/* Make sure at91usart_param() will do something. */
tp->t_ospeed = 0;
(void) at91usart_param(tp, &t);
tp->t_iflag = TTYDEF_IFLAG;
tp->t_oflag = TTYDEF_OFLAG;
tp->t_lflag = TTYDEF_LFLAG;
ttychars(tp);
ttsetwater(tp);
/* and unblock. */
CLR(sc->sc_rx_flags, RX_ANY_BLOCK);
#ifdef COM_DEBUG
if (at91usart_debug)
comstatus(sc, "at91usart_open ");
//.........这里部分代码省略.........
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:101,代码来源:at91usart.c
示例3: wwiomux
//.........这里部分代码省略.........
millis = 30000;
} else {
millis = 10;
}
wwnselect++;
i = poll(pfd, nfd, millis);
wwsetjmp = 0;
noblock = 0;
if (i < 0)
wwnselecte++;
else if (i == 0)
wwnselectz++;
else {
if (dostdin != -1 && (pfd[dostdin].revents & POLLIN) != 0)
wwrint();
nfd = 0;
for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw) {
int n;
if (w->ww_pty < 0)
continue;
if (w->ww_pty != pfd[nfd].fd)
continue;
if ((pfd[nfd++].revents & POLLIN) == 0)
continue;
wwnwread++;
p = w->ww_obq;
if (w->ww_type == WWT_PTY) {
if (p == w->ww_ob) {
w->ww_obp++;
w->ww_obq++;
} else
p--;
c = *p;
}
n = read(w->ww_pty, p, w->ww_obe - p);
if (n < 0) {
wwnwreade++;
(void) close(w->ww_pty);
w->ww_pty = -1;
} else if (n == 0) {
wwnwreadz++;
(void) close(w->ww_pty);
w->ww_pty = -1;
} else if (w->ww_type != WWT_PTY) {
wwnwreadd++;
wwnwreadc += n;
w->ww_obq += n;
} else if (*p == TIOCPKT_DATA) {
n--;
wwnwreadd++;
wwnwreadc += n;
w->ww_obq += n;
} else {
wwnwreadp++;
if (*p & TIOCPKT_STOP)
SET(w->ww_pflags, WWP_STOPPED);
if (*p & TIOCPKT_START)
CLR(w->ww_pflags, WWP_STOPPED);
if (*p & TIOCPKT_FLUSHWRITE) {
CLR(w->ww_pflags, WWP_STOPPED);
w->ww_obq = w->ww_obp =
w->ww_ob;
}
}
if (w->ww_type == WWT_PTY)
*p = c;
}
}
/*
* Try the current window first, if there is output
* then process it and go back to the top to try again.
* This can lead to starvation of the other windows,
* but presumably that what we want.
* Update will eventually happen when output from wwcurwin
* dies down.
*/
if ((w = wwcurwin) != NULL && w->ww_pty >= 0 &&
w->ww_obq > w->ww_obp &&
!ISSET(w->ww_pflags, WWP_STOPPED)) {
int n = wwwrite(w, w->ww_obp, w->ww_obq - w->ww_obp);
if ((w->ww_obp += n) == w->ww_obq)
w->ww_obq = w->ww_obp = w->ww_ob;
noblock = 1;
continue;
}
for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw)
if (w->ww_pty >= 0 && w->ww_obq > w->ww_obp &&
!ISSET(w->ww_pflags, WWP_STOPPED)) {
int n = wwwrite(w, w->ww_obp,
w->ww_obq - w->ww_obp);
if ((w->ww_obp += n) == w->ww_obq)
w->ww_obq = w->ww_obp = w->ww_ob;
if (wwinterrupt())
break;
}
}
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:101,代码来源:wwiomux.c
示例4: vnop_open_9p
static int
vnop_open_9p(struct vnop_open_args *ap)
{
openfid_9p *op;
node_9p *np;
fid_9p fid;
qid_9p qid;
uint32_t iounit;
int e, flags, mode;
TRACE();
flags = 0;
if (ap->a_mode)
flags = OFLAGS(ap->a_mode);
mode = flags & O_ACCMODE;
CLR(flags, O_ACCMODE);
CLR(flags, O_DIRECTORY|O_NONBLOCK|O_NOFOLLOW);
CLR(flags, O_APPEND);
/* locks implemented on the vfs layer */
CLR(flags, O_EXLOCK|O_SHLOCK);
if (ISSET(flags, O_TRUNC)) {
SET(mode, OTRUNC);
CLR(flags, O_TRUNC);
}
if (ISSET(flags, O_CLOEXEC)) {
SET(mode, OCEXEC);
CLR(flags, O_CLOEXEC);
}
if (ISSET(flags, O_EXCL)) {
SET(mode, OEXCL);
CLR(flags, O_EXCL);
}
/* vnop_creat just called */
CLR(flags, O_CREAT);
if (ISSET(flags, O_EVTONLY))
CLR(flags, O_EVTONLY);
if (ISSET(flags, FNOCACHE))
CLR(flags, FNOCACHE);
if (ISSET(flags, FNORDAHEAD))
CLR(flags, FNORDAHEAD);
if (flags) {
DEBUG("unexpected open mode %x", flags);
return ENOTSUP;
}
np = NTO9P(ap->a_vp);
nlock_9p(np, NODE_LCK_EXCLUSIVE);
op = ofidget(np, ap->a_mode);
if (op->fid == NOFID) {
if ((e=walk_9p(np->nmp, np->fid, NULL, 0, &fid, &qid)))
goto error;
if ((e=open_9p(np->nmp, fid, mode, &qid, &iounit)))
goto error;
np->iounit = iounit;
op->fid = fid;
}
/* no cache for dirs, .u or synthetic files */
if (!vnode_isreg(np->vp) || np->dir.qid.vers==0) {
vnode_setnocache(np->vp);
vnode_setnoreadahead(np->vp);
}
OSIncrementAtomic(&op->ref);
nunlock_9p(np);
return 0;
error:
clunk_9p(np->nmp, fid);
nunlock_9p(np);
return e;
}
开发者ID:aredridel,项目名称:mac9p,代码行数:82,代码来源:vnops.c
示例5: setflags
void
setflags(int n)
{
tcflag_t iflag, oflag, cflag, lflag;
switch (n) {
case 0:
if (C0set && I0set && L0set && O0set) {
tmode.c_cflag = C0;
tmode.c_iflag = I0;
tmode.c_lflag = L0;
tmode.c_oflag = O0;
return;
}
break;
case 1:
if (C1set && I1set && L1set && O1set) {
tmode.c_cflag = C1;
tmode.c_iflag = I1;
tmode.c_lflag = L1;
tmode.c_oflag = O1;
return;
}
break;
default:
if (C2set && I2set && L2set && O2set) {
tmode.c_cflag = C2;
tmode.c_iflag = I2;
tmode.c_lflag = L2;
tmode.c_oflag = O2;
return;
}
break;
}
iflag = omode.c_iflag;
oflag = omode.c_oflag;
cflag = omode.c_cflag;
lflag = omode.c_lflag;
if (NP) {
CLR(cflag, CSIZE|PARENB);
SET(cflag, CS8);
CLR(iflag, ISTRIP|INPCK|IGNPAR);
} else if (AP || EP || OP) {
CLR(cflag, CSIZE);
SET(cflag, CS7|PARENB);
SET(iflag, ISTRIP);
if (OP && !EP) {
SET(iflag, INPCK|IGNPAR);
SET(cflag, PARODD);
if (AP)
CLR(iflag, INPCK);
} else if (EP && !OP) {
SET(iflag, INPCK|IGNPAR);
CLR(cflag, PARODD);
if (AP)
CLR(iflag, INPCK);
} else if (AP || (EP && OP)) {
CLR(iflag, INPCK|IGNPAR);
CLR(cflag, PARODD);
}
} /* else, leave as is */
if (UC) {
SET(iflag, IUCLC);
SET(oflag, OLCUC);
SET(lflag, XCASE);
}
if (HC)
SET(cflag, HUPCL);
else
CLR(cflag, HUPCL);
if (MB)
SET(cflag, MDMBUF);
else
CLR(cflag, MDMBUF);
if (NL) {
SET(iflag, ICRNL);
SET(oflag, ONLCR|OPOST);
} else {
CLR(iflag, ICRNL);
CLR(oflag, ONLCR);
}
if (!HT)
SET(oflag, OXTABS|OPOST);
else
CLR(oflag, OXTABS);
#ifdef XXX_DELAY
SET(f, delaybits());
#endif
if (n == 1) { /* read mode flags */
if (RW) {
iflag = 0;
//.........这里部分代码省略.........
开发者ID:appleorange1,项目名称:bitrig,代码行数:101,代码来源:subr.c
示例6: ucomparam
static int
ucomparam(struct tty *tp, struct termios *t)
{
struct ucom_softc *sc = device_lookup_private(&ucom_cd,
UCOMUNIT(tp->t_dev));
int error;
if (sc == NULL || sc->sc_dying)
return (EIO);
/* Check requested parameters. */
if (t->c_ispeed && t->c_ispeed != t->c_ospeed)
return (EINVAL);
/*
* For the console, always force CLOCAL and !HUPCL, so that the port
* is always active.
*/
if (ISSET(sc->sc_swflags, TIOCFLAG_SOFTCAR)) {
SET(t->c_cflag, CLOCAL);
CLR(t->c_cflag, HUPCL);
}
/*
* If there were no changes, don't do anything. This avoids dropping
* input and improves performance when all we did was frob things like
* VMIN and VTIME.
*/
if (tp->t_ospeed == t->c_ospeed &&
tp->t_cflag == t->c_cflag)
return (0);
/* XXX lcr = ISSET(sc->sc_lcr, LCR_SBREAK) | cflag2lcr(t->c_cflag); */
/* And copy to tty. */
tp->t_ispeed = 0;
tp->t_ospeed = t->c_ospeed;
tp->t_cflag = t->c_cflag;
if (sc->sc_methods->ucom_param != NULL) {
error = sc->sc_methods->ucom_param(sc->sc_parent, sc->sc_portno,
t);
if (error)
return (error);
}
/* XXX worry about CHWFLOW */
/*
* Update the tty layer's idea of the carrier bit, in case we changed
* CLOCAL or MDMBUF. We don't hang up here; we only do that by
* explicit request.
*/
DPRINTF(("ucomparam: l_modem\n"));
(void) (*tp->t_linesw->l_modem)(tp, ISSET(sc->sc_msr, UMSR_DCD));
#if 0
XXX what if the hardware is not open
if (!ISSET(t->c_cflag, CHWFLOW)) {
if (sc->sc_tx_stopped) {
sc->sc_tx_stopped = 0;
ucomstart(tp);
}
}
#endif
return (0);
}
开发者ID:ryoon,项目名称:netbsd-xhci,代码行数:68,代码来源:ucom.c
示例7: brelse
/*
* Release a buffer on to the free lists.
* Described in Bach (p. 46).
*/
void
brelse(struct buf *bp)
{
struct bqueues *bufq;
int s;
/* Block disk interrupts. */
s = splbio();
/*
* Determine which queue the buffer should be on, then put it there.
*/
/* If it's locked, don't report an error; try again later. */
if (ISSET(bp->b_flags, (B_LOCKED|B_ERROR)) == (B_LOCKED|B_ERROR))
CLR(bp->b_flags, B_ERROR);
/* If it's not cacheable, or an error, mark it invalid. */
if (ISSET(bp->b_flags, (B_NOCACHE|B_ERROR)))
SET(bp->b_flags, B_INVAL);
if ((bp->b_bufsize <= 0) || ISSET(bp->b_flags, B_INVAL)) {
/*
* If it's invalid or empty, dissociate it from its vnode
* and put on the head of the appropriate queue.
*/
if (LIST_FIRST(&bp->b_dep) != NULL)
buf_deallocate(bp);
if (ISSET(bp->b_flags, B_DELWRI)) {
CLR(bp->b_flags, B_DELWRI);
}
if (bp->b_vp) {
reassignbuf(bp);
brelvp(bp);
}
if (bp->b_bufsize <= 0) {
/* no data */
bufq = &bufqueues[BQ_EMPTY];
numemptybufs++;
} else {
/* invalid data */
bufq = &bufqueues[BQ_CLEAN];
numfreepages += btoc(bp->b_bufsize);
numcleanpages += btoc(bp->b_bufsize);
}
binsheadfree(bp, bufq);
} else {
/*
* It has valid data. Put it on the end of the appropriate
* queue, so that it'll stick around for as long as possible.
*/
if (ISSET(bp->b_flags, B_LOCKED))
/* locked in core */
bufq = &bufqueues[BQ_LOCKED];
else {
numfreepages += btoc(bp->b_bufsize);
if (!ISSET(bp->b_flags, B_DELWRI)) {
numcleanpages += btoc(bp->b_bufsize);
bufq = &bufqueues[BQ_CLEAN];
} else {
numdirtypages += btoc(bp->b_bufsize);
bufq = &bufqueues[BQ_DIRTY];
}
}
if (ISSET(bp->b_flags, B_AGE))
binsheadfree(bp, bufq);
else
binstailfree(bp, bufq);
}
/* Unlock the buffer. */
CLR(bp->b_flags, (B_AGE | B_ASYNC | B_BUSY | B_NOCACHE | B_DEFERRED));
/* Wake up syncer and cleaner processes waiting for buffers */
if (nobuffers) {
wakeup(&nobuffers);
nobuffers = 0;
}
/* Wake up any processes waiting for any buffer to become free. */
if (needbuffer && (numcleanpages > locleanpages)) {
needbuffer--;
wakeup_one(&needbuffer);
}
splx(s);
/* Wake up any processes waiting for _this_ buffer to become free. */
if (ISSET(bp->b_flags, B_WANTED)) {
CLR(bp->b_flags, B_WANTED);
wakeup(bp);
}
}
开发者ID:NKSG,项目名称:INTER_MANET_NS3,代码行数:100,代码来源:vfs_bio.c
示例8: spi_begin
void spi_begin(void)
{
if (!spi_initialized)
spi_init();
CLR(nSS);
}
开发者ID:cfriedt,项目名称:ben-wpan,代码行数:6,代码来源:spi.c
示例9: bolt
/* from f to t */
void bolt(int fx, int fy, int tx, int ty, int hit, int dmg, int dtype)
{
int xx,yy;
struct monster *target;
Symbol boltchar = '?';
xx = fx;
yy = fy;
switch(dtype) {
case FLAME:
boltchar=('*' | CLR(LIGHT_RED));
break;
case ELECTRICITY:
boltchar = ('^' | CLR(LIGHT_BLUE));
break;
case NORMAL_DAMAGE:
boltchar = ('!' | CLR(BROWN));
break;
case COLD:
boltchar=('o' | CLR(WHITE));
break;
default:
assert(FALSE); /* this should never happen, right? WDT */
}
clearmsg();
do_los(boltchar,&xx,&yy,tx,ty);
if ((xx == Player.x) && (yy == Player.y)) {
if (Player.status[DEFLECTION] > 0)
mprint("The bolt just missed you!");
else {
switch (dtype) {
case FLAME:
mprint("You were blasted by a firebolt!");
p_damage(random_range(dmg),dtype,"a firebolt");
break;
case ELECTRICITY:
mprint("You were zapped by lightning!");
p_damage(random_range(dmg),dtype,"a bolt of lightning");
break;
case NORMAL_DAMAGE:
mprint("You were hit by a missile!");
p_damage(random_range(dmg),dtype,"a missile");
break;
case COLD:
mprint("You were hit by an icicle!");
p_damage(random_range(dmg),dtype,"an icicle");
break;
}
}
}
else if (NULL != (target = Level->site[xx][yy].creature)) {
if (hitp(hit,target->ac)) {
if (target->uniqueness == COMMON) {
strcpy(Str1,"The ");
strcat(Str1,target->monstring);
}
else strcpy(Str1,target->monstring);
switch (dtype) {
/* WDT: these sentances really ought to be livened up. Especially
* in full verbose mode. */
case FLAME:
strcat(Str1," was blasted by a firebolt!");
break;
case ELECTRICITY:
strcat(Str1," was zapped by lightning!");
break;
case NORMAL_DAMAGE:
strcat(Str1," was hit by a missile!");
break;
case COLD:
strcat(Str1," was hit by an icicle!");
break;
}
mprint(Str1);
m_status_set(target,HOSTILE);
m_damage(target,random_range(dmg),dtype);
}
else {
if (target->uniqueness == COMMON) {
strcpy(Str1,"The ");
strcat(Str1,target->monstring);
}
else strcpy(Str1,target->monstring);
switch (dtype) {
case FLAME:
strcat(Str1," was missed by a firebolt!");
break;
case ELECTRICITY:
strcat(Str1," was missed by lightning!");
break;
case NORMAL_DAMAGE:
strcat(Str1," was missed by a missile!");
break;
case COLD:
strcat(Str1," was missed by a flying icicle!");
break;
}
//.........这里部分代码省略.........
开发者ID:albert-wang,项目名称:OmegaRPG,代码行数:101,代码来源:effect1.c
示例10: compatflags
/*
* Old TTY => termios, snatched from <sys/kern/tty_compat.c>
*/
void
compatflags(long flags)
{
tcflag_t iflag, oflag, cflag, lflag;
iflag = BRKINT|ICRNL|IMAXBEL|IXON|IXANY;
oflag = OPOST|ONLCR|OXTABS;
cflag = CREAD;
lflag = ICANON|ISIG|IEXTEN;
if (ISSET(flags, TANDEM))
SET(iflag, IXOFF);
else
CLR(iflag, IXOFF);
if (ISSET(flags, ECHO))
SET(lflag, ECHO);
else
CLR(lflag, ECHO);
if (ISSET(flags, CRMOD)) {
SET(iflag, ICRNL);
SET(oflag, ONLCR);
} else {
CLR(iflag, ICRNL);
CLR(oflag, ONLCR);
}
if (ISSET(flags, XTABS))
SET(oflag, OXTABS);
else
CLR(oflag, OXTABS);
if (ISSET(flags, RAW)) {
iflag &= IXOFF;
CLR(lflag, ISIG|ICANON|IEXTEN);
CLR(cflag, PARENB);
} else {
SET(iflag, BRKINT|IXON|IMAXBEL);
SET(lflag, ISIG|IEXTEN);
if (ISSET(flags, CBREAK))
CLR(lflag, ICANON);
else
SET(lflag, ICANON);
switch (ISSET(flags, ANYP)) {
case 0:
CLR(cflag, PARENB);
break;
case ANYP:
SET(cflag, PARENB);
CLR(iflag, INPCK);
break;
case EVENP:
SET(cflag, PARENB);
SET(iflag, INPCK);
CLR(cflag, PARODD);
break;
case ODDP:
SET(cflag, PARENB);
SET(iflag, INPCK);
SET(cflag, PARODD);
break;
}
}
/* Nothing we can do with CRTBS. */
if (ISSET(flags, PRTERA))
SET(lflag, ECHOPRT);
else
CLR(lflag, ECHOPRT);
if (ISSET(flags, CRTERA))
SET(lflag, ECHOE);
else
CLR(lflag, ECHOE);
/* Nothing we can do with TILDE. */
if (ISSET(flags, MDMBUF))
SET(cflag, MDMBUF);
else
CLR(cflag, MDMBUF);
if (ISSET(flags, NOHANG))
CLR(cflag, HUPCL);
else
SET(cflag, HUPCL);
if (ISSET(flags, CRTKIL))
SET(lflag, ECHOKE);
else
CLR(lflag, ECHOKE);
if (ISSET(flags, CTLECH))
SET(lflag, ECHOCTL);
else
CLR(lflag, ECHOCTL);
if (!ISSET(flags, DECCTQ))
SET(iflag, IXANY);
else
CLR(iflag, IXANY);
CLR(lflag, TOSTOP|FLUSHO|PENDIN|NOFLSH);
SET(lflag, ISSET(flags, TOSTOP|FLUSHO|PENDIN|NOFLSH));
if (ISSET(flags, RAW|LITOUT|PASS8)) {
//.........这里部分代码省略.........
开发者ID:alexandermerritt,项目名称:dragonfly,代码行数:101,代码来源:subr.c
示例11: spif_softintr
void
spif_softintr(void *vsc)
{
struct spif_softc *sc = (struct spif_softc *)vsc;
struct stty_softc *stc = sc->sc_ttys;
int i, data, s, flags;
uint8_t stat, msvr;
struct stty_port *sp;
struct tty *tp;
if (stc != NULL) {
for (i = 0; i < stc->sc_nports; i++) {
sp = &stc->sc_port[i];
tp = sp->sp_tty;
if (!ISSET(tp->t_state, TS_ISOPEN))
continue;
while (sp->sp_rget != sp->sp_rput) {
stat = sp->sp_rget[0];
data = sp->sp_rget[1];
sp->sp_rget += 2;
if (sp->sp_rget == sp->sp_rend)
sp->sp_rget = sp->sp_rbuf;
if (stat & (CD180_RCSR_BE | CD180_RCSR_FE))
data |= TTY_FE;
if (stat & CD180_RCSR_PE)
data |= TTY_PE;
(*tp->t_linesw->l_rint)(data, tp);
}
s = splhigh();
flags = sp->sp_flags;
CLR(sp->sp_flags, STTYF_DONE | STTYF_CDCHG |
STTYF_RING_OVERFLOW);
splx(s);
if (ISSET(flags, STTYF_CDCHG)) {
s = spltty();
STC_WRITE(sc, STC_CAR, i);
msvr = STC_READ(sc, STC_MSVR);
splx(s);
sp->sp_carrier = msvr & CD180_MSVR_CD;
(*tp->t_linesw->l_modem)(tp,
sp->sp_carrier);
}
if (ISSET(flags, STTYF_RING_OVERFLOW)) {
log(LOG_WARNING, "%s-%x: ring overflow\n",
device_xname(stc->sc_dev), i);
}
if (ISSET(flags, STTYF_DONE)) {
ndflush(&tp->t_outq,
sp->sp_txp - tp->t_outq.c_cf);
CLR(tp->t_state, TS_BUSY);
(*tp->t_linesw->l_start)(tp);
}
}
}
}
开发者ID:eyberg,项目名称:rumpkernel-netbsd-src,代码行数:65,代码来源:spif.c
示例12: ucom_detach
int
ucom_detach(device_t self, int flags)
{
struct ucom_softc *sc = device_private(self);
struct tty *tp = sc->sc_tty;
int maj, mn;
int s, i;
DPRINTF(("ucom_detach: sc=%p flags=%d tp=%p, pipe=%d,%d\n",
sc, flags, tp, sc->sc_bulkin_no, sc->sc_bulkout_no));
sc->sc_dying = 1;
pmf_device_deregister(self);
if (sc->sc_bulkin_pipe != NULL)
usbd_abort_pipe(sc->sc_bulkin_pipe);
if (sc->sc_bulkout_pipe != NULL)
usbd_abort_pipe(sc->sc_bulkout_pipe);
s = splusb();
if (--sc->sc_refcnt >= 0) {
/* Wake up anyone waiting */
if (tp != NULL) {
mutex_spin_enter(&tty_lock);
CLR(tp->t_state, TS_CARR_ON);
CLR(tp->t_cflag, CLOCAL | MDMBUF);
ttyflush(tp, FREAD|FWRITE);
mutex_spin_exit(&tty_lock);
}
/* Wait for processes to go away. */
usb_detach_waitold(sc->sc_dev);
}
softint_disestablish(sc->sc_si);
splx(s);
/* locate the major number */
maj = cdevsw_lookup_major(&ucom_cdevsw);
/* Nuke the vnodes for any open instances. */
mn = device_unit(self);
DPRINTF(("ucom_detach: maj=%d mn=%d\n", maj, mn));
vdevgone(maj, mn, mn, VCHR);
vdevgone(maj, mn | UCOMDIALOUT_MASK, mn | UCOMDIALOUT_MASK, VCHR);
vdevgone(maj, mn | UCOMCALLUNIT_MASK, mn | UCOMCALLUNIT_MASK, VCHR);
/* Detach and free the tty. */
if (tp != NULL) {
tty_detach(tp);
tty_free(tp);
sc->sc_tty = NULL;
}
for (i = 0; i < UCOM_IN_BUFFS; i++) {
if (sc->sc_ibuff[i].ub_xfer != NULL)
usbd_free_xfer(sc->sc_ibuff[i].ub_xfer);
}
for (i = 0; i < UCOM_OUT_BUFFS; i++) {
if (sc->sc_obuff[i].ub_xfer != NULL)
usbd_free_xfer(sc->sc_obuff[i].ub_xfer);
}
/* Detach the random source */
rnd_detach_source(&sc->sc_rndsource);
return (0);
}
开发者ID:ryoon,项目名称:netbsd-xhci,代码行数:68,代码来源:ucom.c
示例13: ball
/* from f to t */
void ball(int fx, int fy, int tx, int ty, int dmg, int dtype)
{
int xx,yy,ex,ey,i;
struct monster *target;
Symbol expchar=('@' | CLR(LIGHT_PURPLE));
xx = fx;
yy = fy;
switch(dtype) {
case FLAME:
expchar=('*' | CLR(LIGHT_RED));
break;
case COLD:
expchar=('o' | CLR(WHITE));
break;
case ELECTRICITY:
expchar=('^' | CLR(LIGHT_BLUE));
break;
}
do_los(expchar,&xx,&yy,tx,ty);
draw_explosion(expchar,xx,yy);
for(i=0; i<9; i++) {
ex = xx + Dirs[0][i];
ey = yy + Dirs[1][i];
if ((ex == Player.x) && (ey == Player.y)) {
switch(dtype) {
case FLAME:
mprint("You were blasted by a fireball!");
p_damage(random_range(dmg),FLAME,"a fireball");
break;
case COLD:
mprint("You were blasted by a snowball!");
p_damage(random_range(dmg),COLD,"a snowball");
break;
case ELECTRICITY:
mprint("You were blasted by ball lightning!");
p_damage(random_range(dmg),ELECTRICITY,"ball lightning");
break;
case UNSTOPPABLE:
mprint("Oh No! Manastorm!");
p_damage(random_range(dmg),UNSTOPPABLE,"a manastorm!");
break;
}
}
if (NULL != (target = Level->site[ex][ey].creature)) {
if (los_p(Player.x,Player.y,target->x,target->y)) {
if (target->uniqueness == COMMON) {
strcpy(Str1,"The ");
strcat(Str1,target->monstring);
}
else strcpy(Str1,target->monstring);
switch(dtype) {
case FLAME:
strcat(Str1," was zorched by a fireball!");
break;
case COLD:
strcat(Str1," was blasted by a snowball!");
break;
case ELECTRICITY:
strcat(Str1," was zapped by ball lightning!");
break;
case UNSTOPPABLE:
strcat(Str1," was nuked by a manastorm!");
break;
}
mprint(Str1);
}
m_status_set(target,HOSTILE);
m_damage(target,random_range(dmg),dtype);
}
if (Level->site[ex][ey].locchar == HEDGE)
if (Level->site[ex][ey].p_locf != L_TRIFID) {
if ((dtype == FLAME)||(dtype == ELECTRICITY)) {
mprint("The hedge is blasted away!");
Level->site[ex][ey].p_locf = L_NO_OP;
Level->site[ex][ey].locchar = FLOOR;
plotspot(ex,ey,TRUE);
lset(ex, ey, CHANGED);
}
else mprint("The hedge is unaffected.");
}
else mprint("The trifid absorbs the energy and laughs!");
else if (Level->site[ex][ey].locchar == WATER)
if (dtype == FLAME) {
mprint("The water is vaporised!");
Level->site[ex][ey].p_locf = L_NO_OP;
Level->site[ex][ey].locchar = FLOOR;
plotspot(ex,ey,TRUE);
lset(ex, ey, CHANGED);
}
}
}
开发者ID:albert-wang,项目名称:OmegaRPG,代码行数:96,代码来源:effect1.c
示例14: ucomopen
//.........这里部分代码省略.........
SIMPLEQ_INIT(&sc->sc_ibuff_full);
SIMPLEQ_INIT(&sc->sc_obuff_free);
SIMPLEQ_INIT(&sc->sc_obuff_full);
/* Allocate input buffers */
for (ub = &sc->sc_ibuff[0]; ub != &sc->sc_ibuff[UCOM_IN_BUFFS];
ub++) {
ub->ub_xfer = usbd_alloc_xfer(sc->sc_udev);
if (ub->ub_xfer == NULL) {
error = ENOMEM;
goto fail_2;
}
ub->ub_data = usbd_alloc_buffer(ub->ub_xfer,
sc->sc_ibufsizepad);
if (ub->ub_data == NULL) {
error = ENOMEM;
goto fail_2;
}
if (ucomsubmitread(sc, ub) != USBD_NORMAL_COMPLETION) {
error = EIO;
goto fail_2;
}
}
for (ub = &sc->sc_obuff[0]; ub != &sc->sc_obuff[UCOM_OUT_BUFFS];
ub++) {
ub->ub_xfer = usbd_alloc_xfer(sc->sc_udev);
if (ub->ub_xfer == NULL) {
error = ENOMEM;
goto fail_2;
}
ub->ub_data = usbd_alloc_buffer(ub->ub_xfer,
sc->sc_obufsize);
if (ub->ub_data == NULL) {
error = ENOMEM;
goto fail_2;
}
SIMPLEQ_INSERT_TAIL(&sc->sc_obuff_free, ub, ub_link);
}
}
sc->sc_opening = 0;
wakeup(&sc->sc_opening);
splx(s);
error = ttyopen(tp, UCOMDIALOUT(dev), ISSET(flag, O_NONBLOCK));
if (error)
goto bad;
error = (*tp->t_linesw->l_open)(dev, tp);
if (error)
goto bad;
return (0);
fail_2:
usbd_abort_pipe(sc->sc_bulkin_pipe);
for (i = 0; i < UCOM_IN_BUFFS; i++) {
if (sc->sc_ibuff[i].ub_xfer != NULL) {
usbd_free_xfer(sc->sc_ibuff[i].ub_xfer);
sc->sc_ibuff[i].ub_xfer = NULL;
sc->sc_ibuff[i].ub_data = NULL;
}
}
usbd_abort_pipe(sc->sc_bulkout_pipe);
for (i = 0; i < UCOM_OUT_BUFFS; i++) {
if (sc->sc_obuff[i].ub_xfer != NULL) {
usbd_free_xfer(sc->sc_obuff[i].ub_xfer);
sc->sc_obuff[i].ub_xfer = NULL;
sc->sc_obuff[i].ub_data = NULL;
}
}
usbd_close_pipe(sc->sc_bulkout_pipe);
sc->sc_bulkout_pipe = NULL;
fail_1:
usbd_close_pipe(sc->sc_bulkin_pipe);
sc->sc_bulkin_pipe = NULL;
fail_0:
sc->sc_opening = 0;
wakeup(&sc->sc_opening);
splx(s);
return (error);
bad:
s = spltty();
CLR(tp->t_state, TS_BUSY);
if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
/*
* We failed to open the device, and nobody else had it opened.
* Clean up the state as appropriate.
*/
ucom_cleanup(sc);
}
splx(s);
return (error);
}
开发者ID:ryoon,项目名称:netbsd-xhci,代码行数:101,代码来源:ucom.c
示例15: CALCULATE_Z_FLAG
INLINE void CALCULATE_Z_FLAG(void)
{
if (R.ALU == 0) SET(Z_FLAG);
else CLR(Z_FLAG);
}
开发者ID:Ezio-PS,项目名称:mame2003-libretro,代码行数:5,代码来源:pic16c5x.c
示例16: bwrite
/*
* Block write. Described in Bach (p.56)
*/
int
bwrite(struct buf *bp)
{
int rv, async, wasdelayed, s;
struct vnode *vp;
struct mount *mp;
/*
* Remember buffer type, to switch on it later. If the write was
* synchronous, but the file system was mounted with MNT_ASYNC,
* convert it to a delayed write.
* XXX note that this relies on delayed tape writes being converted
* to async, not sync writes (which is safe, but ugly).
*/
async = ISSET(bp->b_flags, B_ASYNC);
if (!async && bp->b_vp && bp->b_vp->v_mount &&
ISSET(bp->b_vp->v_mount->mnt_flag, MNT_ASYNC)) {
bdwrite(bp);
return (0);
}
/*
* Collect statistics on synchronous and asynchronous writes.
* Writes to block devices are charged to their associated
* filesystem (if any).
*/
if ((vp = bp->b_vp) != NULL) {
if (vp->v_type == VBLK)
mp = vp->v_specmountpoint;
else
mp = vp->v_mount;
if (mp != NULL) {
if (async)
mp->mnt_stat.f_asyncwrites++;
else
mp->mnt_stat.f_syncwrites++;
}
}
wasdelayed = ISSET(bp->b_flags, B_DELWRI);
CLR(bp->b_flags, (B_READ | B_DONE | B_ERROR | B_DELWRI));
s = splbio();
/*
* If not synchronous, pay for the I/O operation and make
* sure the buf is on the correct vnode queue. We have
* to do this now, because if we don't, the vnode may not
* be properly notified that its I/O has completed.
*/
if (wasdelayed) {
reassignbuf(bp);
} else
curproc->p_stats->p_ru.ru_oublock++;
/* Initiate disk write. Make sure the appropriate party is charged. */
bp->b_vp->v_numoutput++;
splx(s);
SET(bp->b_flags, B_WRITEINPROG);
VOP_STRATEGY(bp);
if (async)
return (0);
/*
* If I/O was synchronous, wait for it to complete.
*/
rv = biowait(bp);
/* Release the buffer. */
brelse(bp);
return (rv);
}
开发者ID:NKSG,项目名称:INTER_MANET_NS3,代码行数:78,代码来源:vfs_bio.c
示例17: macx_swapon
//.........这里部分代码省略.........
}
/* remember the vnode. This vnode has namei() reference */
bs_port_table[i].vp = vp;
/*
* Look to see if we are already paging to this file.
*/
/* make certain the copy send of kernel call will work */
default_pager = MEMORY_OBJECT_DEFAULT_NULL;
kr = host_default_memory_manager(host_priv_self(), &default_pager, 0);
if(kr != KERN_SUCCESS) {
error = EAGAIN;
bs_port_table[i].vp = 0;
goto swapon_bailout;
}
#if CONFIG_EMBEDDED
dp_cluster_size = 1 * PAGE_SIZE;
#else
if ((dp_isssd = vnode_pager_isSSD(vp)) == TRUE) {
/*
* keep the cluster size small since the
* seek cost is effectively 0 which means
* we don't care much about fragmentation
*/
dp_cluster_size = 2 * PAGE_SIZE;
} else {
/*
* use the default cluster size
*/
dp_cluster_size = 0;
}
#endif
kr = default_pager_backing_store_create(default_pager,
-1, /* default priority */
dp_cluster_size,
&backing_store);
memory_object_default_deallocate(default_pager);
if(kr != KERN_SUCCESS) {
error = ENOMEM;
bs_port_table[i].vp = 0;
goto swapon_bailout;
}
/* Mark this vnode as being used for swapfile */
vnode_lock_spin(vp);
SET(vp->v_flag, VSWAP);
vnode_unlock(vp);
/*
* NOTE: we are able to supply PAGE_SIZE here instead of
* an actual record size or block number because:
* a: we do not support offsets from the beginning of the
* file (allowing for non page size/record modulo offsets.
* b: because allow paging will be done modulo page size
*/
kr = default_pager_add_file(backing_store, (vnode_ptr_t) vp,
PAGE_SIZE, (int)(file_size/PAGE_SIZE));
if(kr != KERN_SUCCESS) {
bs_port_table[i].vp = 0;
if(kr == KERN_INVALID_ARGUMENT)
error = EINVAL;
else
error = ENOMEM;
/* This vnode is not to be used for swapfile */
vnode_lock_spin(vp);
CLR(vp->v_flag, VSWAP);
vnode_unlock(vp);
goto swapon_bailout;
}
bs_port_table[i].bs = (void *)backing_store;
error = 0;
ubc_setthreadcred(vp, p, current_thread());
/*
* take a long term reference on the vnode to keep
* vnreclaim() away from this vnode.
*/
vnode_ref(vp);
swapon_bailout:
if (vp) {
vnode_put(vp);
}
(void) thread_funnel_set(kernel_flock, FALSE);
AUDIT_MACH_SYSCALL_EXIT(error);
if (error)
printf("macx_swapon FAILED - %d\n", error);
else
printf("macx_swapon SUCCESS\n");
return(error);
}
开发者ID:Algozjb,项目名称:xnu,代码行数:101,代码来源:dp_backing_file.c
示例18: eint
static void eint(void)
{
CLR(INTM_FLAG);
}
开发者ID:broftkd,项目名称:historic-mess,代码行数:4,代码来源:tms32010.c
示例19: macx_swapoff
/*
* Routine: macx_swapoff
* Function:
* Syscall interface to remove a file from backing store
*/
int
macx_swapoff(
struct macx_swapoff_args *args)
{
__unused int flags = args->flags;
kern_return_t kr;
mach_port_t backing_store;
struct vnode *vp = 0;
struct nameidata nd, *ndp;
struct proc *p = current_proc();
int i;
int error;
boolean_t funnel_state;
vfs_context_t ctx = vfs_context_current();
struct uthread *ut;
int orig_iopol_disk;
AUDIT_MACH_SYSCALL_ENTER(AUE_SWAPOFF);
funnel_state = thread_funnel_set(kernel_flock, TRUE);
backing_store = NULL;
ndp = &nd;
if ((error = suser(kauth_cred_get(), 0)))
goto swapoff_bailout;
/*
* Get the vnode for the paging area.
*/
NDINIT(ndp, LOOKUP, OP_LOOKUP, FOLLOW | LOCKLEAF | AUDITVNPATH1,
((IS_64BIT_PROCESS(p)) ? UIO_USERSPACE64 : UIO_USERSPACE32),
(user_addr_t) args->filename, ctx);
if ((error = namei(ndp)))
goto swapoff_bailout;
nameidone(ndp);
vp = ndp->ni_vp;
if (vp->v_type != VREG) {
error = EINVAL;
goto swapoff_bailout;
}
#if CONFIG_MACF
vnode_lock(vp);
error = mac_system_check_swapoff(vfs_context_ucred(ctx), vp);
vnode_unlock(vp);
if (error)
goto swapoff_bailout;
#endif
for(i = 0; i < MAX_BACKING_STORE; i++) {
if(bs_port_table[i].vp == vp) {
break;
}
}
if (i == MAX_BACKING_STORE) {
error = EINVAL;
goto swapoff_bailout;
}
backing_store = (mach_port_t)bs_port_table[i].bs;
ut = get_bsdthread_info(current_thread());
orig_iopol_disk = proc_get_thread_selfdiskacc();
proc_apply_thread_selfdiskacc(IOPOL_THROTTLE);
kr = default_pager_backing_store_delete(backing_store);
proc_apply_thread_selfdiskacc(orig_iopol_disk);
switch (kr) {
case KERN_SUCCESS:
error = 0;
bs_port_table[i].vp = 0;
/* This vnode is no longer used for swapfile */
vnode_lock_spin(vp);
CLR(vp->v_flag, VSWAP);
vnode_unlock(vp);
/* get rid of macx_swapon() "long term" reference */
vnode_rele(vp);
break;
case KERN_FAILURE:
error = EAGAIN;
break;
default:
error = EAGAIN;
break;
}
swapoff_bailout:
/* get rid of macx_swapoff() namei() reference */
if (vp)
//.........这里部分代码省略.........
开发者ID:Algozjb,项目名称:xnu,代码行数:101,代码来源:dp_backing_file.c
示例20: nget_9p
__private_extern__ int
nget_9p(mount_9p *nmp, fid_9p fid, qid_9p qid, vnode_t dvp, vnode_t *vpp, struct componentname *cnp, vfs_context_t ctx)
{
#pragma unused(ctx)
struct vnode_fsparam fsp;
struct hnode_9p *nhp;
node_9p *np;
uint32_t vid;
int e, i;
TRACE();
nhp = HASH9P(nmp, qid.path);
loop:
lck_mtx_lock(nmp->nodelck);
LIST_FOREACH (np, nhp, next) {
if(np->dir.qid.path != qid.path)
continue;
if (ISSET(np->flags, NODE_INIT)) {
SET(
|
请发表评论