本文整理汇总了C++中PTR2UINT函数的典型用法代码示例。如果您正苦于以下问题:C++ PTR2UINT函数的具体用法?C++ PTR2UINT怎么用?C++ PTR2UINT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PTR2UINT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sysziofree
void
sysziofree(Ar0 *ar0, ...)
{
Mach *m = machp();
Zio *io;
int nio, i;
Segment *s;
va_list list;
va_start(list, ar0);
/*
* zfree(Zio io[], int nio);
*/
io = va_arg(list, Zio*);
nio = va_arg(list, int);
va_end(list);
io = validaddr(io, sizeof io[0] * nio, 1);
for(i = 0; i < nio; i++){
s = seg(m->externup, PTR2UINT(io[i].data), 1);
if(s == nil)
error("invalid address in zio");
if((s->type&SG_ZIO) == 0){
qunlock(&s->lk);
error("segment is not a zero-copy segment");
}
zputaddr(s, PTR2UINT(io[i].data));
qunlock(&s->lk);
io[i].data = nil;
io[i].size = 0;
}
}
开发者ID:npe9,项目名称:harvey,代码行数:31,代码来源:syszio.c
示例2: syssemalt
void
syssemalt(Ar0 *ar0, ...)
{
Proc *up = externup();
int **sl;
int i, *np, ns;
Segment *sg;
Sem *ksl[16];
va_list list;
va_start(list, ar0);
/*
* void semalt(int*[], int);
*/
ar0->i = -1;
sl = va_arg(list, int**);
ns = va_arg(list, int);
sl = validaddr(sl, ns * sizeof(int*), 1);
if(ns > nelem(ksl))
panic("syssemalt: bug: too many semaphores in alt");
for(i = 0; i < ns; i++){
np = sl[i];
np = validaddr(np, sizeof(int), 1);
evenaddr(PTR2UINT(np));
if((sg = seg(up, PTR2UINT(np), 0)) == nil)
error(Ebadarg);
ksl[i] = segmksem(sg, np);
}
ar0->i = semalt(ksl, ns);
va_end(list);
}
开发者ID:Shamar,项目名称:harvey,代码行数:31,代码来源:syssem.c
示例3: sysrforkchild
void
sysrforkchild(Proc* child, Proc* parent)
{
Ureg *cureg;
// If STACKPAD is 1 things go very bad very quickly.
// But it is the right value ...
#define STACKPAD 1 /* for return PC? */
/*
* Add STACKPAD*BY2SE to the stack to account for
* - the return PC
* (NOT NOW) - trap's arguments (syscallnr, ureg)
*/
child->sched.sp = PTR2UINT(child->kstack+KSTACK-((sizeof(Ureg)+STACKPAD*BY2SE)));
child->sched.pc = PTR2UINT(sysrforkret);
cureg = (Ureg*)(child->sched.sp+STACKPAD*BY2SE);
memmove(cureg, parent->dbgreg, sizeof(Ureg));
/* Things from bottom of syscall which were never executed */
child->psstate = 0;
child->insyscall = 0;
//iprint("Child SP set tp %p\n", (void *)child->sched.sp);
fpusysrforkchild(child, parent);
}
开发者ID:qioixiy,项目名称:harvey,代码行数:25,代码来源:syscall.c
示例4: _kproftimer
static void
_kproftimer(uintptr_t pc)
{
if(kprof.time == 0)
return;
/*
* if the pc corresponds to the idle loop, don't consider it.
if(m->inidle)
return;
*/
/*
* if the pc is coming out of spllo or splx,
* use the pc saved when we went splhi.
*/
if(pc>=PTR2UINT(spllo) && pc<=PTR2UINT(spldone))
pc = machp()->splpc;
ilock(&kprof.l);
kprof.buf[0] += TK2MS(1);
if(kprof.minpc<=pc && pc<kprof.maxpc){
pc -= kprof.minpc;
pc >>= LRES;
kprof.buf[pc] += TK2MS(1);
}else
开发者ID:Shamar,项目名称:harvey,代码行数:25,代码来源:devkprof.c
示例5: kprocchild
/*
* setup stack and initial PC for a new kernel proc. This is architecture
* dependent because of the starting stack location
*/
void
kprocchild(Proc *p, void (*func)(void*), void *arg)
{
p->sched.pc = PTR2UINT(linkproc);
p->sched.sp = PTR2UINT(p->kstack+KSTACK);
p->kpfun = func;
p->kparg = arg;
}
开发者ID:Akheon23,项目名称:nix-os,代码行数:13,代码来源:arch.c
示例6: kprocchild
void
kprocchild(Proc* p, void (*func)(void*), void* arg)
{
/*
* gotolabel() needs a word on the stack in
* which to place the return PC used to jump
* to linkproc().
*/
p->sched.pc = PTR2UINT(linkproc);
p->sched.sp = PTR2UINT(p->kstack+KSTACK-BY2SE);
p->sched.sp = STACKALIGN(p->sched.sp);
p->kpfun = func;
p->kparg = arg;
}
开发者ID:Requaos,项目名称:harvey,代码行数:15,代码来源:arch.c
示例7: xinit
void
xinit(void)
{
int i, n, upages, kpages;
ulong maxkpa;
Confmem *m;
Pallocmem *pm;
Hole *h, *eh;
eh = &xlists.hole[Nhole-1];
for(h = xlists.hole; h < eh; h++)
h->link = h+1;
xlists.flist = xlists.hole;
upages = conf.upages;
kpages = conf.npage - upages;
pm = palloc.mem;
maxkpa = -KZERO;
for(i=0; i<nelem(conf.mem); i++){
m = &conf.mem[i];
n = m->npage;
if(n > kpages)
n = kpages;
if(m->base >= maxkpa)
n = 0;
else if(n > 0 && m->base+n*PGSZ >= maxkpa)
n = (maxkpa - m->base)/PGSZ;
/* first give to kernel */
if(n > 0){
m->kbase = PTR2UINT(KADDR(m->base));
m->klimit = PTR2UINT(KADDR(m->base+n*PGSZ));
xhole(m->base, n*PGSZ);
kpages -= n;
}
/* if anything left over, give to user */
if(n < m->npage){
if(pm >= palloc.mem+nelem(palloc.mem)){
print("xinit: losing %lud pages\n", m->npage-n);
continue;
}
pm->base = m->base+n*PGSZ;
pm->npage = m->npage - n;
pm++;
}
}
xsummary();
}
开发者ID:99years,项目名称:plan9,代码行数:48,代码来源:xalloc.c
示例8: readzio
/*
* This is the counterpart of devzread in some sense,
* it reads in the traditional way from io[].
*/
int32_t
readzio(Kzio *io, int nio, void *a, int32_t count)
{
int32_t tot, nr;
char *p;
p = a;
tot = 0;
while(nio-- > 0){
if(tot < count){
nr = io->size;
if(tot + nr > count)
nr = count - tot;
DBG("readzio: copy %#p %Z\n", p+tot, io);
memmove(p+tot, io->data, nr);
tot += nr;
}
qlock(&io->seg->lk);
zputaddr(io->seg, PTR2UINT(io->data));
qunlock(&io->seg->lk);
putseg(io->seg);
io->seg = nil;
io++;
}
return tot;
}
开发者ID:npe9,项目名称:harvey,代码行数:30,代码来源:syszio.c
示例9: bootargs
static void
bootargs(uintptr base)
{
int i;
ulong ssize;
char **av, *p;
/*
* Push the boot args onto the stack.
* The initial value of the user stack must be such
* that the total used is larger than the maximum size
* of the argument list checked in syscall.
*/
i = oargblen+1;
p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(Tos) - i));
memmove(p, oargb, i);
/*
* Now push the argv pointers.
* The code jumped to by touser in lproc.s expects arguments
* main(char* argv0, ...)
* and calls
* startboot("/boot/boot", &argv0)
* not the usual (int argc, char* argv[])
*/
av = (char**)(p - (oargc+1)*sizeof(char*));
ssize = base + BY2PG - PTR2UINT(av);
for(i = 0; i < oargc; i++)
*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BY2PG);
*av = nil;
sp = USTKTOP - ssize;
}
开发者ID:mischief,项目名称:9problems,代码行数:32,代码来源:main.c
示例10: hashlist_find
/**
* @param hl a hashlist.
* @param key the key to look for.
* @param bin if not NULL, it will be set to the bin number that is or would
* be used for the key. It is set regardless whether the key is in
* the hashlist.
* @return NULL if the key is not in the hashlist. Otherwise, the item
* associated with the key is returned.
*/
static hash_item_t *
hashlist_find(hashlist_t *hl, const void *key, uint32_t *bin)
{
hash_item_t *item;
uint32_t hash, b;
HASHLIST_CHECK(hl);
hash = hl->hash ? hl->hash(key) : (uint32_t) PTR2UINT(key);
b = (hash ^ hl->rnd) % hl->num_bins;
item = hl->bins[b];
if (bin) {
*bin = b;
}
if (hl->cmp) {
for (/* NOTHING */; item != NULL; item = item->bnext) {
if (hl->cmp(key, item->node.ptr))
return item;
}
} else {
for (/* NOTHING */; item != NULL; item = item->bnext) {
if (key == item->node.ptr)
return item;
}
}
return NULL;
}
开发者ID:gtk-gnutella,项目名称:guppy,代码行数:38,代码来源:hashlist.c
示例11: vunmap
void
vunmap(void* v, usize size)
{
Proc *up = externup();
uintptr_t va;
DBG("vunmap(%#p, %lud)\n", v, size);
if(machp()->machno != 0)
panic("vunmap");
/*
* See the comments above in vmap.
*/
va = PTR2UINT(v);
if(va >= KZERO && va+size < KZERO+1ull*MiB)
return;
/*
* Here will have to deal with releasing any
* resources used for the allocation (e.g. page table
* pages).
*/
DBG("vunmap(%#p, %lud)\n", v, size);
}
开发者ID:qioixiy,项目名称:harvey,代码行数:25,代码来源:mmu.c
示例12: _allocb
static Block*
_allocb(int size)
{
Block *b;
uint8_t *p;
int n;
n = BLOCKALIGN + ROUNDUP(size+Hdrspc, BLOCKALIGN) + sizeof(Block);
if((p = malloc(n)) == nil)
return nil;
b = (Block*)(p + n - sizeof(Block)); /* block at end of allocated space */
b->base = p;
b->next = nil;
b->list = nil;
b->free = 0;
b->flag = 0;
/* align base and bounds of data */
b->lim = (uint8_t*)(PTR2UINT(b) & ~(BLOCKALIGN-1));
/* align start of writable data, leaving space below for added headers */
b->rp = b->lim - ROUNDUP(size, BLOCKALIGN);
b->wp = b->rp;
if(b->rp < b->base || b->lim - b->rp < size)
panic("_allocb");
return b;
}
开发者ID:qioixiy,项目名称:harvey,代码行数:30,代码来源:allocb.c
示例13: mmuuncache
void*
mmuuncache(void* v, usize size)
{
int x;
PTE *pte;
uintptr va;
/*
* Simple helper for ucalloc().
* Uncache a Section, must already be
* valid in the MMU.
*/
va = PTR2UINT(v);
assert(!(va & (1*MiB-1)) && size == 1*MiB);
x = L1X(va);
pte = &m->mmul1[x];
if((*pte & (Fine|Section|Coarse)) != Section)
return nil;
*pte &= ~(Cached|Buffered);
mmuinvalidateaddr(va);
cachedwbinvse(pte, 4);
return v;
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:25,代码来源:mmu.c
示例14: mmuswitch
void
mmuswitch(Proc* proc)
{
PTE *pte;
Page *page;
Mpl pl;
pl = splhi();
if(proc->newtlb) {
/*
* NIX: We cannot clear our page tables if they are going to
* be used in the AC
*/
if(proc->ac == nil)
mmuptpfree(proc, 1);
proc->newtlb = 0;
}
if(machp()->MMU.pml4->daddr) {
memset(UINT2PTR(machp()->MMU.pml4->va), 0, machp()->MMU.pml4->daddr*sizeof(PTE));
machp()->MMU.pml4->daddr = 0;
}
pte = UINT2PTR(machp()->MMU.pml4->va);
for(page = proc->MMU.mmuptp[3]; page != nil; page = page->next) {
pte[page->daddr] = PPN(page->pa)|PteU|PteRW|PteP;
if(page->daddr >= machp()->MMU.pml4->daddr)
machp()->MMU.pml4->daddr = page->daddr+1;
page->prev = machp()->MMU.pml4;
}
tssrsp0(machp(), STACKALIGN(PTR2UINT(proc->kstack+KSTACK)));
cr3put(machp()->MMU.pml4->pa);
splx(pl);
}
开发者ID:Shamar,项目名称:harvey,代码行数:35,代码来源:mmu.c
示例15: bootargs
void
bootargs(uintptr base)
{
int i;
ulong ssize;
char **av, *p;
/*
* Push the boot args onto the stack.
* Make sure the validaddr check in syscall won't fail
* because there are fewer than the maximum number of
* args by subtracting sizeof(up->arg).
*/
i = oargblen+1;
p = UINT2PTR(STACKALIGN(base + BIGPGSZ - sizeof(up->arg) - i));
memmove(p, oargb, i);
/*
* Now push argc and the argv pointers.
* This isn't strictly correct as the code jumped to by
* touser in init9.[cs] calls startboot (port/initcode.c) which
* expects arguments
* startboot(char* argv0, char* argv[])
* not the usual (int argc, char* argv[]), but argv0 is
* unused so it doesn't matter (at the moment...).
*/
av = (char**)(p - (oargc+2)*sizeof(char*));
ssize = base + BIGPGSZ - PTR2UINT(av);
*av++ = (char*)oargc;
for(i = 0; i < oargc; i++)
*av++ = (oargv[i] - oargb) + (p - base) + (USTKTOP - BIGPGSZ);
*av = nil;
sp = USTKTOP - ssize;
}
开发者ID:99years,项目名称:plan9,代码行数:35,代码来源:main.c
示例16: xspanalloc
void*
xspanalloc(ulong size, int align, ulong span)
{
uintptr a, v, t;
a = PTR2UINT(xalloc(size+align+span));
if(a == 0)
panic("xspanalloc: %lud %d %lux\n", size, align, span);
if(span > 2) {
v = (a + span) & ~(span-1);
t = v - a;
if(t > 0)
xhole(PADDR(UINT2PTR(a)), t);
t = a + span - v;
if(t > 0)
xhole(PADDR(UINT2PTR(v+size+align)), t);
}
else
v = a;
if(align > 1)
v = (v + align) & ~(align-1);
return (void*)v;
}
开发者ID:99years,项目名称:plan9,代码行数:26,代码来源:xalloc.c
示例17: ptclbsum
ushort
ptclbsum(uchar *addr, int len)
{
ulong losum, hisum, mdsum, x;
ulong t1, t2;
losum = 0;
hisum = 0;
mdsum = 0;
x = 0;
if(PTR2UINT(addr) & 1) {
if(len) {
hisum += addr[0];
len--;
addr++;
}
x = 1;
}
while(len >= 16) {
t1 = *(ushort*)(addr+0);
t2 = *(ushort*)(addr+2); mdsum += t1;
t1 = *(ushort*)(addr+4); mdsum += t2;
t2 = *(ushort*)(addr+6); mdsum += t1;
t1 = *(ushort*)(addr+8); mdsum += t2;
t2 = *(ushort*)(addr+10); mdsum += t1;
t1 = *(ushort*)(addr+12); mdsum += t2;
t2 = *(ushort*)(addr+14); mdsum += t1;
mdsum += t2;
len -= 16;
addr += 16;
}
while(len >= 2) {
mdsum += *(ushort*)addr;
len -= 2;
addr += 2;
}
if(x) {
if(len)
losum += addr[0];
if(LITTLE)
losum += mdsum;
else
hisum += mdsum;
} else {
if(len)
hisum += addr[0];
if(LITTLE)
hisum += mdsum;
else
losum += mdsum;
}
losum += hisum >> 8;
losum += (hisum & 0xff) << 8;
while(hisum = losum>>16)
losum = hisum + (losum & 0xffff);
return losum & 0xffff;
}
开发者ID:99years,项目名称:plan9,代码行数:60,代码来源:ptclbsum.c
示例18: setkernur
/* Give enough context in the ureg to produce a kernel stack for
* a sleeping process
*/
void
setkernur(Ureg* ureg, Proc* p)
{
ureg->pc = p->sched.pc;
ureg->sp = p->sched.sp+4;
ureg->r14 = PTR2UINT(sched);
}
开发者ID:Akheon23,项目名称:nix-os,代码行数:10,代码来源:arch.c
示例19: sysexecregs
void*
sysexecregs(uintptr_t entry, uint32_t ssize, void *tos)
{
Proc *up = externup();
uintptr_t *sp;
Ureg *ureg;
// We made sure it was correctly aligned in sysexecstack, above.
if (ssize & 0xf) {
print("your stack is wrong: stacksize is not 16-byte aligned: %d\n", ssize);
panic("misaligned stack in sysexecregs");
}
sp = (uintptr_t*)(USTKTOP - ssize);
ureg = up->dbgreg;
ureg->sp = PTR2UINT(sp);
ureg->ip = entry;
ureg->type = 64; /* fiction for acid */
ureg->dx = (uintptr_t)tos;
/*
* return the address of kernel/user shared data
* (e.g. clock stuff)
*/
return UINT2PTR(USTKTOP-sizeof(Tos));
}
开发者ID:qioixiy,项目名称:harvey,代码行数:26,代码来源:syscall.c
示例20: Tcl_DeleteHashEntry
void
Tcl_DeleteHashEntry(
Tcl_HashEntry *entryPtr)
{
register Tcl_HashEntry *prevPtr;
const Tcl_HashKeyType *typePtr;
Tcl_HashTable *tablePtr;
Tcl_HashEntry **bucketPtr;
#if TCL_HASH_KEY_STORE_HASH
int index;
#endif
tablePtr = entryPtr->tablePtr;
if (tablePtr->keyType == TCL_STRING_KEYS) {
typePtr = &tclStringHashKeyType;
} else if (tablePtr->keyType == TCL_ONE_WORD_KEYS) {
typePtr = &tclOneWordHashKeyType;
} else if (tablePtr->keyType == TCL_CUSTOM_TYPE_KEYS
|| tablePtr->keyType == TCL_CUSTOM_PTR_KEYS) {
typePtr = tablePtr->typePtr;
} else {
typePtr = &tclArrayHashKeyType;
}
#if TCL_HASH_KEY_STORE_HASH
if (typePtr->hashKeyProc == NULL
|| typePtr->flags & TCL_HASH_KEY_RANDOMIZE_HASH) {
index = RANDOM_INDEX (tablePtr, entryPtr->hash);
} else {
index = PTR2UINT(entryPtr->hash) & tablePtr->mask;
}
bucketPtr = &(tablePtr->buckets[index]);
#else
bucketPtr = entryPtr->bucketPtr;
#endif
if (*bucketPtr == entryPtr) {
*bucketPtr = entryPtr->nextPtr;
} else {
for (prevPtr = *bucketPtr; ; prevPtr = prevPtr->nextPtr) {
if (prevPtr == NULL) {
Tcl_Panic("malformed bucket chain in Tcl_DeleteHashEntry");
}
if (prevPtr->nextPtr == entryPtr) {
prevPtr->nextPtr = entryPtr->nextPtr;
break;
}
}
}
tablePtr->numEntries--;
if (typePtr->freeEntryProc) {
typePtr->freeEntryProc (entryPtr);
} else {
ckfree((char *) entryPtr);
}
}
开发者ID:LeifAndersen,项目名称:TuxRider,代码行数:59,代码来源:tclHash.c
注:本文中的PTR2UINT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论