示例#1
0
文件: bat5.c 项目: sekcheong/monetdb
str
BKCsetAccess(bat *res, const bat *bid, const char * const *param)
{
	BAT *b;
	int m;

	if ((b = BATdescriptor(*bid)) == NULL)
		throw(MAL, "bat.setAccess", RUNTIME_OBJECT_MISSING);
	switch (*param[0]) {
	case 'r':
		m = BAT_READ;
		break;
	case 'a':
		m = BAT_APPEND;
		break;
	case 'w':
		m = BAT_WRITE;
		break;
	default:
		*res = 0;
		throw(MAL, "bat.setAccess", ILLEGAL_ARGUMENT " Got %c" " expected 'r','a', or 'w'", *param[0]);
	}
	if ((b = setaccess(b, m)) == NULL)
		throw(MAL, "bat.setAccess", OPERATION_FAILED);
	BBPkeepref(*res = b->batCacheid);
	return MAL_SUCCEED;
}
示例#2
0
文件: bat5.c 项目: sekcheong/monetdb
char *
BKCappend_force_wrap(bat *r, const bat *bid, const bat *uid, const bit *force)
{
	BAT *b, *u;
	gdk_return ret;

	if ((b = BATdescriptor(*bid)) == NULL)
		throw(MAL, "bat.append", RUNTIME_OBJECT_MISSING);
	if ((u = BATdescriptor(*uid)) == NULL) {
		BBPunfix(b->batCacheid);
		throw(MAL, "bat.append", RUNTIME_OBJECT_MISSING);
	}
	if (BATcount(u) == 0) {
		ret = GDK_SUCCEED;
	} else {
		if ((b = setaccess(b, BAT_WRITE)) == NULL)
			throw(MAL, "bat.append", OPERATION_FAILED);
		ret = BATappend(b, u, *force);
	}
	BBPunfix(u->batCacheid);
	if (ret != GDK_SUCCEED) {
		BBPunfix(b->batCacheid);
		throw(MAL, "bat.append", GDK_EXCEPTION);
	}
	if( b->batPersistence == PERSISTENT)
		BATmsync(b);
	BBPkeepref(*r = b->batCacheid);
	return MAL_SUCCEED;
}
示例#3
0
文件: sym.c 项目: AustenConrad/plan-9
void
setptype(Lextok *n, int t, Lextok *vis)	/* predefined types */
{	int oln = lineno, cnt = 1; extern int Expand_Ok;

	while (n)
	{	if (n->sym->type && !(n->sym->hidden&32))
		{ lineno = n->ln; Fname = n->fn;
		  non_fatal("redeclaration of '%s'", n->sym->name);
		  lineno = oln;
		}
		n->sym->type = (short) t;

		if (Expand_Ok)
		{	n->sym->hidden |= (4|8|16); /* formal par */
			if (t == CHAN)
			setaccess(n->sym, ZS, cnt, 'F');
		}
		if (t == UNSIGNED)
		{	if (n->sym->nbits < 0 || n->sym->nbits >= 32)
			fatal("(%s) has invalid width-field", n->sym->name);
			if (n->sym->nbits == 0)
			{	n->sym->nbits = 16;
				non_fatal("unsigned without width-field", 0);
			}
		} else if (n->sym->nbits > 0)
		{	non_fatal("(%s) only an unsigned can have width-field",
				n->sym->name);
		}
		if (vis)
		{	if (strncmp(vis->sym->name, ":hide:", 6) == 0)
			{	n->sym->hidden |= 1;
				if (t == BIT)
				fatal("bit variable (%s) cannot be hidden",
					n->sym->name);
			} else if (strncmp(vis->sym->name, ":show:", 6) == 0)
			{	n->sym->hidden |= 2;
			} else if (strncmp(vis->sym->name, ":local:", 7) == 0)
			{	n->sym->hidden |= 64;
			}
		}
		if (t == CHAN)
			n->sym->Nid = ++Nid;
		else
		{	n->sym->Nid = 0;
			if (n->sym->ini
			&&  n->sym->ini->ntyp == CHAN)
			{	Fname = n->fn;
				lineno = n->ln;
				fatal("chan initializer for non-channel %s",
				n->sym->name);
			}
		}
		if (n->sym->nel <= 0)
		{ lineno = n->ln; Fname = n->fn;
		  non_fatal("bad array size for '%s'", n->sym->name);
		  lineno = oln;
		}
		n = n->rgt; cnt++;
	}
}
示例#4
0
文件: sym.c 项目: 99years/plan9
void
trackchanuse(Lextok *m, Lextok *w, int t)
{	Lextok *n = m; int cnt = 1;
	while (n)
	{	if (n->lft
		&&  n->lft->sym
		&&  n->lft->sym->type == CHAN)
			setaccess(n->lft->sym, w?w->sym:ZS, cnt, t);
		n = n->rgt; cnt++;
	}
}
示例#5
0
文件: mesg.c 项目: 99years/plan9
void
nochan_manip(Lextok *p, Lextok *n, int d)
{	int e = 1;

	if (d == 0 && p->sym && p->sym->type == CHAN)
	{	setaccess(p->sym, ZS, 0, 'L');

		if (n && n->ntyp == CONST)
			fatal("invalid asgn to chan", (char *) 0);

		if (n && n->sym && n->sym->type == CHAN)
		{	setaccess(n->sym, ZS, 0, 'V');
			return;
		}	
	}

	/* ok on the rhs of an assignment: */
	if (!n || n->ntyp == LEN || n->ntyp == RUN
	||  n->ntyp == FULL  || n->ntyp == NFULL
	||  n->ntyp == EMPTY || n->ntyp == NEMPTY)
		return;

	if (n->sym && n->sym->type == CHAN)
	{	if (d == 1)
			fatal("invalid use of chan name", (char *) 0);
		else
			setaccess(n->sym, ZS, 0, 'V');	
	}

	if (n->ntyp == NAME
	||  n->ntyp == '.')
		e = 0;	/* array index or struct element */

	nochan_manip(p, n->lft, e);
	nochan_manip(p, n->rgt, 1);
}
示例#6
0
文件: bat5.c 项目: sekcheong/monetdb
str
BKCorder_rev(bat *r, const bat *bid)
{
	BAT *b;

	if ((b = BATdescriptor(*bid)) == NULL)
		throw(MAL, "bat.order_rev", RUNTIME_OBJECT_MISSING);
	if ((b = setaccess(b, BAT_WRITE)) == NULL)
		throw(MAL, "bat.order_rev", OPERATION_FAILED);
	if (BATorder_rev(b) != GDK_SUCCEED) {
		BBPunfix(b->batCacheid);
		throw(MAL, "bat.order_rev", GDK_EXCEPTION);
	}
	BBPkeepref(*r = b->batCacheid);
	return MAL_SUCCEED;
}
示例#7
0
文件: bat5.c 项目: sekcheong/monetdb
char *
BKCdelete(bat *r, const bat *bid, const oid *h)
{
	BAT *b;

	if ((b = BATdescriptor(*bid)) == NULL)
		throw(MAL, "bat.delete", RUNTIME_OBJECT_MISSING);
	if ((b = setaccess(b, BAT_WRITE)) == NULL)
		throw(MAL, "bat.delete", OPERATION_FAILED);
	if (BUNdelHead(b, h, FALSE) != GDK_SUCCEED) {
		BBPunfix(b->batCacheid);
		throw(MAL, "bat.delete", GDK_EXCEPTION);
	}
	if( b->batPersistence == PERSISTENT)
		BATmsync(b);
	BBPkeepref(*r = b->batCacheid);
	return MAL_SUCCEED;
}
示例#8
0
文件: bat5.c 项目: sekcheong/monetdb
str
BKCappend_val_force_wrap(bat *r, const bat *bid, const void *u, const bit *force)
{
	BAT *b;

	if ((b = BATdescriptor(*bid)) == NULL)
		throw(MAL, "bat.append", RUNTIME_OBJECT_MISSING);
	if ((b = setaccess(b, BAT_WRITE)) == NULL)
		throw(MAL, "bat.append", OPERATION_FAILED);
	if (b->ttype >= TYPE_str && ATOMstorage(b->ttype) >= TYPE_str) {
		if (u == 0 || *(str*)u == 0)
			u = (ptr) str_nil;
		else
			u = (ptr) *(str *)u;
	}
	if (BUNappend(b, u, *force) != GDK_SUCCEED) {
		BBPunfix(b->batCacheid);
		throw(MAL, "bat.append", GDK_EXCEPTION);
	}
	BBPkeepref(*r = b->batCacheid);
	return MAL_SUCCEED;
}
示例#9
0
文件: bat5.c 项目: sekcheong/monetdb
char *
BKCdelete_bun(bat *r, const bat *bid, const oid *h, const void *t)
{
	BAT *b;

	if ((b = BATdescriptor(*bid)) == NULL)
		throw(MAL, "bat.delete_bun", RUNTIME_OBJECT_MISSING);
	if ((b = setaccess(b, BAT_WRITE)) == NULL)
		throw(MAL, "bat.delete_bun", OPERATION_FAILED);
	if (b->ttype >= TYPE_str && ATOMstorage(b->ttype) >= TYPE_str) {
		if (t == 0 || *(str*)t == 0)
			t = (ptr) str_nil;
		else
			t = (ptr) *(str *)t;
	}
	if (BUNdel(b, h, t, FALSE) != GDK_SUCCEED) {
		BBPunfix(b->batCacheid);
		throw(MAL, "bat.delete_bun", GDK_EXCEPTION);
	}
	BBPkeepref(*r = b->batCacheid);
	return MAL_SUCCEED;
}
示例#10
0
文件: bat5.c 项目: sekcheong/monetdb
str
BKCinsert_bat_force(bat *r, const bat *bid, const bat *sid, const bit *force)
{
	BAT *b, *s;

	if ((b = BATdescriptor(*bid)) == NULL)
		throw(MAL, "bat.insert", RUNTIME_OBJECT_MISSING);
	if ((b = setaccess(b, BAT_WRITE)) == NULL)
		throw(MAL, "bat.insert", OPERATION_FAILED);
	if ((s = BATdescriptor(*sid)) == NULL) {
		BBPunfix(b->batCacheid);
		throw(MAL, "bat.insert", RUNTIME_OBJECT_MISSING);
	}
	if (BATins(b, s, *force) != GDK_SUCCEED) {
		BBPunfix(b->batCacheid);
		BBPunfix(s->batCacheid);
		throw(MAL, "bat.insert", GDK_EXCEPTION);
	}
	BBPunfix(s->batCacheid);
	BBPkeepref(*r = b->batCacheid);
	return MAL_SUCCEED;
}
示例#11
0
int
grfattach(struct hp_device *hd)
{
	register char *rom;
	register struct sti_entry *ep;
	register char *cp;
	struct modtab *mptr = (struct modtab *)hd->hp_addr;
	struct grf_softc *gp = &grf_softc[hd->hp_unit];
	struct grfdev *gd = &grfdev[hd->hp_unit];
	int devtype;
	static int firstime = 1;

	if (gp->g_flags & GF_ALIVE)
		return(1);

	/*
	 * Locate STI ROM.
	 * On some machines it may not be part of the HPA space.
	 * On these, busconf will stash the address in m_stirom.
	 */
	rom = (char *)mptr->m_stirom;
	if (rom == 0)
		rom = (char *)mptr->m_hpa;

	/*
	 * Change page protection on `sticode' to KERNEL:rwx USER:rx.
	 * At this time, I dont know if users will be executing these
	 * routines; for now we'll give them permission to do so.
	 */
	if (firstime) {
#ifdef MACH_KERNEL
		pmap_map(STICODE_ALGN, STICODE_ALGN,
			 STICODE_ALGN + (STI_CODESIZ * STI_CODECNT * NGRF),
			 VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_WRITE);
#else
		register u_int pg = btop(STICODE_ALGN);
		register u_int pgcnt =
			(STI_CODESIZ * STI_CODECNT * NGRF + (NBPG-1)) / NBPG;

		while (pgcnt--)
			setaccess(pg++, PDE_AR_URXKW, 0, PDEAR);
#endif
		firstime = 0;
	}

	devtype = STI_DEVTYP(STI_TYPE_BWGRF, rom);

	/*
	 * Set addrs and type for stiload
	 */
	gd->romaddr = rom;
	gd->hpa = (char *)mptr->m_hpa;
	gd->type = devtype;

	/*
	 * Set `ep' to unit's STI routine entry points and `cp' to
	 * page-aligned code space.  Load STI routines and be sure
	 * to flush the (data) cache afterward; we actually flush
	 * both caches as we only call this routine a couple times.
	 */
	ep = &stientry[hd->hp_unit];
	cp = (char *) (STICODE_ALGN + STI_CODESIZ * STI_CODECNT * hd->hp_unit);

	cp = stiload(&ep->init_graph, gd,
		     STI_IGADDR(devtype, rom), STI_SMADDR(devtype, rom), cp);
	cp = stiload(&ep->state_mgmt, gd,
		     STI_SMADDR(devtype, rom), STI_FUADDR(devtype, rom), cp);
	cp = stiload(&ep->font_unpmv, gd,
		     STI_FUADDR(devtype, rom), STI_BMADDR(devtype, rom), cp);
	cp = stiload(&ep->block_move, gd,
		     STI_BMADDR(devtype, rom), STI_STADDR(devtype, rom), cp);
	cp = stiload(&ep->self_test, gd,
		     STI_STADDR(devtype, rom), STI_EHADDR(devtype, rom), cp);
	cp = stiload(&ep->excep_hdlr, gd,
		     STI_EHADDR(devtype, rom), STI_ICADDR(devtype, rom), cp);
	cp = stiload(&ep->inq_conf, gd,
		     STI_ICADDR(devtype, rom), STI_EADDR(devtype, rom), cp);

	fcacheall();

	gd->ep = &stientry[hd->hp_unit];
	gp->g_data = (caddr_t) gd;
	gp->g_sw = &grfsw[0];
	if ((*gp->g_sw->gd_init)(gp) == 0) {
		gp->g_data = (caddr_t) 0;
		return(0);
	}

	gp->g_flags = GF_ALIVE;
	return(1);
}