本文整理汇总了C++中qopen函数的典型用法代码示例。如果您正苦于以下问题:C++ qopen函数的具体用法?C++ qopen怎么用?C++ qopen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qopen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pipeattach
/*
* create a pipe, no streams are created until an open
*/
static Chan*
pipeattach(char *spec)
{
Pipe *p;
Chan *c;
c = devattach('|', spec);
p = malloc(sizeof(Pipe));
if(p == 0)
exhausted("memory");
p->ref = 1;
p->q[0] = qopen(Pipeqsize, 0, 0, 0);
if(p->q[0] == 0){
free(p);
exhausted("memory");
}
p->q[1] = qopen(Pipeqsize, 0, 0, 0);
if(p->q[1] == 0){
free(p->q[0]);
free(p);
exhausted("memory");
}
lock(&pipealloc);
p->path = ++pipealloc.path;
unlock(&pipealloc);
mkqid(&c->qid, PIPEQID(2*p->path, Qdir), 0, QTDIR);
c->aux = p;
c->devno = 0;
return c;
}
开发者ID:Shamar,项目名称:harvey,代码行数:36,代码来源:devpipe.c
示例2: test_all
static bool test_all(void){
test( linux_file_vfs_open() );
// write
int fid = qopen( "./a.txt", O_RDWR | O_CREAT | O_TRUNC, NULL );
test( 0 != fid );
test( 5 == qwrite( fid, "12345", 5 ) );
{
struct qstat buf;
test( qfstat( fid, &buf ) );
test( 5 == buf.size );
}
test( qclose( fid ) );
fid = 0;
// read
fid = qopen( "./a.txt", O_RDONLY, NULL );
test( 0 != fid );
{
struct qstat buf;
test( qfstat( fid, &buf ) );
test( 5 == buf.size );
}
char buf[100];
memset( buf, 0, sizeof( buf ) );
test( 5 == qread( fid, buf, sizeof(buf) ) );
test( 0 == memcmp( buf, "12345", 5 ) );
test( qclose( fid ) );
fid = 0;
return true;
}
开发者ID:husthl,项目名称:qos,代码行数:32,代码来源:linux_file.c
示例3: uartsetup
static void
uartsetup(ulong port, char *name)
{
Uart *p;
if(nuart >= Nuart)
return;
p = xalloc(sizeof(Uart));
uart[nuart++] = p;
strcpy(p->name, name);
p->reg = &UARTREG[port];
p->bps = 9600;
p->bits = 8;
p->parity = 'n';
p->stop = 1;
p->kickme = 0;
p->port = port;
p->iq = qopen(4*1024, 0, 0 , p);
p->oq = qopen(4*1024, 0, uartkick, p);
p->ip = p->istage;
p->ie = &p->istage[Stagesize];
p->op = p->ostage;
p->oe = p->ostage;
intrenable(UARTTXbit(port), uarttxintr, p, 0);
intrenable(UARTRXbit(port), uartrxintr, p, 0);
}
开发者ID:8l,项目名称:inferno,代码行数:31,代码来源:devuart.c
示例4: uartenable
/*
* enable/disable uart and add/remove to list of enabled uarts
*/
static Uart*
uartenable(Uart *p)
{
Uart **l;
if(p->iq == nil){
if((p->iq = qopen(8*1024, 0, uartflow, p)) == nil)
return nil;
}
else
qreopen(p->iq);
if(p->oq == nil){
if((p->oq = qopen(8*1024, 0, uartkick, p)) == nil){
qfree(p->iq);
p->iq = nil;
return nil;
}
}
else
qreopen(p->oq);
p->ir = p->istage;
p->iw = p->istage;
p->ie = &p->istage[Stagesize];
p->op = p->ostage;
p->oe = p->ostage;
p->hup_dsr = p->hup_dcd = 0;
p->dsr = p->dcd = 0;
/* assume we can send */
p->cts = 1;
p->ctsbackoff = 0;
if(p->bits == 0)
uartctl(p, "l8");
if(p->stop == 0)
uartctl(p, "s1");
if(p->parity == 0)
uartctl(p, "pn");
if(p->baud == 0)
uartctl(p, "b9600");
(*p->phys->enable)(p, 1);
lock(&uartalloc.Lock);
for(l = &uartalloc.elist; *l; l = &(*l)->elist){
if(*l == p)
break;
}
if(*l == 0){
p->elist = uartalloc.elist;
uartalloc.elist = p;
}
p->enabled = 1;
unlock(&uartalloc.Lock);
return p;
}
开发者ID:dancrossnyc,项目名称:harvey,代码行数:61,代码来源:devuart.c
示例5: consopen
static Chan*
consopen(Chan *c, int omode)
{
c->aux = 0;
switch((ulong)c->qid.path){
case Qconsctl:
if(!iseve())
error(Eperm);
qlock(&kbd);
kbd.ctl++;
qunlock(&kbd);
break;
case Qkeyboard:
if((omode & 3) != OWRITE) {
qlock(&kbd);
kbd.kbdr++;
flushkbdline(kbdq);
kbd.raw = 1;
qunlock(&kbd);
}
break;
case Qscancode:
qlock(&kbd);
if(kscanq || !kscanid) {
qunlock(&kbd);
c->flag &= ~COPEN;
if(kscanq)
error(Einuse);
else
error(Ebadarg);
}
kscanq = qopen(256, 0, nil, nil);
qunlock(&kbd);
break;
case Qkprint:
if((omode & 3) != OWRITE) {
wlock(&kprintq);
if(kprintq.q != nil){
wunlock(&kprintq);
error(Einuse);
}
kprintq.q = qopen(32*1024, Qcoalesce, nil, nil);
if(kprintq.q == nil){
wunlock(&kprintq);
error(Enomem);
}
qnoblock(kprintq.q, 1);
wunlock(&kprintq);
c->iounit = qiomaxatomic;
}
break;
}
return devopen(c, omode, consdir, nelem(consdir), devgen);
}
开发者ID:8l,项目名称:inferno,代码行数:57,代码来源:devcons.c
示例6: consopen
Chan*
consopen(Chan *c, int omode)
{
c = devopen(c, omode, contab, nelem(contab), devgen);
switch((ulong)c->qid.path) {
case Qconsctl:
incref(&kbd.ctl);
break;
case Qpointer:
if(incref(&kbd.ptr) != 1){
decref(&kbd.ptr);
c->flag &= ~COPEN;
error(Einuse);
}
break;
case Qscancode:
qlock(&kbd.gq);
if(gkscanq || !gkscanid) {
qunlock(&kbd.q);
c->flag &= ~COPEN;
if(gkscanq)
error(Einuse);
else
error(Ebadarg);
}
gkscanq = qopen(256, 0, nil, nil);
qunlock(&kbd.gq);
break;
case Qkprint:
wlock(&kprintq.l);
if(kprintq.q != nil){
wunlock(&kprintq.l);
c->flag &= ~COPEN;
error(Einuse);
}
kprintq.q = qopen(32*1024, 0, 0, 0);
if(kprintq.q == nil){
wunlock(&kprintq.l);
c->flag &= ~COPEN;
error(Enomem);
}
qnoblock(kprintq.q, 1);
wunlock(&kprintq.l);
break;
case Qsnarf:
if(omode == ORDWR)
error(Eperm);
if(omode == OREAD)
c->aux = strdup("");
else
c->aux = mallocz(SnarfSize, 1);
break;
}
return c;
}
开发者ID:caerwynj,项目名称:inferno-lab,代码行数:55,代码来源:devcons.c
示例7: ipifccreate
/*
* called when a new ipifc structure is created
*/
static void ipifccreate(struct conv *c)
{
struct Ipifc *ifc;
c->rq = qopen(QMAX, 0, 0, 0);
c->sq = qopen(2 * QMAX, 0, 0, 0);
c->wq = qopen(QMAX, Qkick, ipifckick, c);
ifc = (struct Ipifc *)c->ptcl;
ifc->conv = c;
ifc->unbinding = 0;
ifc->m = NULL;
ifc->reassemble = 0;
}
开发者ID:7perl,项目名称:akaros,代码行数:16,代码来源:ipifc.c
示例8: ipifccreate
/*
* called when a new ipifc structure is created
*/
static void
ipifccreate(Conv *c)
{
Ipifc *ifc;
c->rq = qopen(QMAX, 0, 0, 0);
c->sq = qopen(QMAX, 0, 0, 0);
c->wq = qopen(QMAX, Qkick, ipifckick, c);
ifc = (Ipifc*)c->ptcl;
ifc->conv = c;
ifc->unbinding = 0;
ifc->medium = nil;
ifc->reassemble = 0;
}
开发者ID:qioixiy,项目名称:harvey,代码行数:17,代码来源:ipifc.c
示例9: consinit
void
consinit(void)
{
kbdq = qopen(512, 0, nil, nil);
if(kbdq == 0)
panic("no memory");
lineq = qopen(2*1024, 0, nil, nil);
if(lineq == 0)
panic("no memory");
gkbdq = qopen(512, 0, nil, nil);
if(gkbdq == 0)
panic("no memory");
randominit();
}
开发者ID:Mekapaedia,项目名称:inferno-rpi,代码行数:14,代码来源:devcons.c
示例10: devopen
static struct chan *consopen(struct chan *c, int omode)
{
c->aux = NULL;
c = devopen(c, omode, consdir, ARRAY_SIZE(consdir), devgen);
switch ((uint32_t) c->qid.path) {
case Qconsctl:
kref_get(&kbd.ctl, 1);
break;
case Qkprint:
if (atomic_swap(&kprintinuse, 1) != 0) {
c->flag &= ~COPEN;
error(EADDRINUSE, "kprintinuse lock failed");
}
if (kprintoq == NULL) {
kprintoq = qopen(8 * 1024, Qcoalesce, 0, 0);
if (kprintoq == NULL) {
c->flag &= ~COPEN;
error(ENOMEM, "Can't allocate kprintoq");
}
qdropoverflow(kprintoq, 1);
} else
qreopen(kprintoq);
c->iounit = qiomaxatomic;
break;
}
return c;
}
开发者ID:ihategit,项目名称:akaros,代码行数:28,代码来源:cons.c
示例11: printinit
void printinit(void)
{
lineq = qopen(2 * 1024, 0, NULL, NULL);
if (lineq == NULL)
panic("printinit");
qdropoverflow(lineq, 1);
}
开发者ID:ihategit,项目名称:akaros,代码行数:7,代码来源:cons.c
示例12: create_open_file
int create_open_file(const char* file_name) {
int file_id = qopen(file_name, O_BINARY | O_TRUNC | O_CREAT);
if (file_id == BADADDR)
file_id = qcreate(file_name, 511);
return file_id;
}
开发者ID:rock44422,项目名称:HexRaysCodeXplorer,代码行数:7,代码来源:CtreeExtractor.cpp
示例13: consopen
static Chan*
consopen(Chan *c, int omode)
{
c->aux = nil;
c = devopen(c, omode, consdir, nelem(consdir), devgen);
switch((ulong)c->qid.path){
case Qkprint:
if(tas(&kprintinuse) != 0){
c->flag &= ~COPEN;
error(Einuse);
}
if(kprintoq == nil){
kprintoq = qopen(8*1024, Qcoalesce, 0, 0);
if(kprintoq == nil){
c->flag &= ~COPEN;
error(Enomem);
}
qnoblock(kprintoq, 1);
}else
qreopen(kprintoq);
c->iounit = qiomaxatomic;
break;
}
return c;
}
开发者ID:vrthra,项目名称:9front-tmp,代码行数:25,代码来源:devcons.c
示例14: consopen
static Chan*
consopen(Chan *c, int omode)
{
c = devopen(c, omode, contab, nelem(contab), devgen);
switch((ulong)c->qid.path) {
case Qconsctl:
incref(&kbd.ctl);
break;
case Qscancode:
qlock(&kbd.gq);
if(gkscanq != nil || gkscanid == nil) {
qunlock(&kbd.q);
c->flag &= ~COPEN;
if(gkscanq)
error(Einuse);
else
error("not supported");
}
gkscanq = qopen(256, 0, nil, nil);
qunlock(&kbd.gq);
break;
case Qkprint:
wlock(&kprintq.l);
if(waserror()){
wunlock(&kprintq.l);
c->flag &= ~COPEN;
nexterror();
}
if(kprintq.q != nil)
error(Einuse);
kprintq.q = qopen(32*1024, Qcoalesce, nil, nil);
if(kprintq.q == nil)
error(Enomem);
qnoblock(kprintq.q, 1);
poperror();
wunlock(&kprintq.l);
c->iounit = qiomaxatomic;
break;
case Qevents:
c->aux = qopen(512, 0, nil, nil);
add_listener(&event_listeners, c->aux);
break;
}
return c;
}
开发者ID:8l,项目名称:inferno,代码行数:47,代码来源:devcons.c
示例15: printinit
void
printinit(void)
{
lineq = qopen(2*1024, 0, nil, nil);
if(lineq == nil)
panic("printinit");
qnoblock(lineq, 1);
}
开发者ID:8l,项目名称:inferno,代码行数:8,代码来源:devcons.c
示例16: consinit
void
consinit(void)
{
uv_mutex_init(&line_lock);
uv_cond_init(&line_ready);
kbdq = qopen(512, 0, nil, nil);
if(kbdq == 0)
panic("no memory");
lineq = qopen(2*1024, 0, nil, nil);
if(lineq == 0)
panic("no memory");
gkbdq = qopen(512, 0, nil, nil);
if(gkbdq == 0)
panic("no memory");
randominit();
}
开发者ID:AndreasBriese,项目名称:node9,代码行数:17,代码来源:devcons.c
示例17: ERRSTACK
/*
* create a pipe, no streams are created until an open
*/
static struct chan *pipeattach(char *spec)
{
ERRSTACK(2);
Pipe *p;
struct chan *c;
c = devattach(devname(), spec);
p = kzmalloc(sizeof(Pipe), 0);
if (p == 0)
error(ENOMEM, ERROR_FIXME);
if (waserror()) {
freepipe(p);
nexterror();
}
p->pipedir = kzmalloc(sizeof(pipedir), 0);
if (p->pipedir == 0)
error(ENOMEM, ERROR_FIXME);
memmove(p->pipedir, pipedir, sizeof(pipedir));
kstrdup(&p->user, current->user);
kref_init(&p->ref, pipe_release, 1);
qlock_init(&p->qlock);
p->q[0] = qopen(pipealloc.pipeqsize, Qcoalesce, 0, 0);
if (p->q[0] == 0)
error(ENOMEM, ERROR_FIXME);
p->q[1] = qopen(pipealloc.pipeqsize, Qcoalesce, 0, 0);
if (p->q[1] == 0)
error(ENOMEM, ERROR_FIXME);
poperror();
spin_lock(&(&pipealloc)->lock);
p->path = ++pipealloc.path;
spin_unlock(&(&pipealloc)->lock);
c->qid.path = NETQID(2 * p->path, Qdir);
c->qid.vers = 0;
c->qid.type = QTDIR;
c->aux = p;
c->dev = 0;
/* taps. */
SLIST_INIT(&p->data_taps[0]); /* already = 0; set to be futureproof */
SLIST_INIT(&p->data_taps[1]);
spinlock_init(&p->tap_lock);
return c;
}
开发者ID:GanShun,项目名称:akaros,代码行数:49,代码来源:pipe.c
示例18: printinit
void printinit(void)
{
#if 0
lineq = qopen(2 * 1024, 0, NULL, NULL);
if (lineq == NULL)
panic("printinit");
qnoblock(lineq, 1);
#endif
}
开发者ID:goovdl,项目名称:akaros,代码行数:9,代码来源:cons.c
示例19: psauxlink
void
psauxlink(void)
{
psauxq = qopen(1024, 0, 0, 0);
if(psauxq == nil)
panic("psauxlink");
qnoblock(psauxq, 1);
i8042auxenable(psauxputc);
addarchfile("psaux", DMEXCL|0660, psauxread, psauxwrite);
}
开发者ID:99years,项目名称:plan9,代码行数:10,代码来源:psaux.c
示例20: consinit
static void
consinit(void)
{
randominit();
debuginit();
debugkey('f', "files/6", fddump, 0);
debugkey('q', "panic", qpanic, 1);
debugkey('r', "exit", rexit, 1);
klogq = qopen(128*1024, 0, 0, 0);
}
开发者ID:8l,项目名称:inferno,代码行数:10,代码来源:devcons.c
注:本文中的qopen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论