这篇教程C++ stackPushINT函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中stackPushINT函数的典型用法代码示例。如果您正苦于以下问题:C++ stackPushINT函数的具体用法?C++ stackPushINT怎么用?C++ stackPushINT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了stackPushINT函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: pfopen/* fopen - open a file and return new fd on stack. * * fopen ( ptr count mode -- fd ) */static void pfopen(FICL_VM *pVM){ int mode, fd, count; char *ptr, *name;#if FICL_ROBUST > 1 vmCheckStack(pVM, 3, 1);#endif mode = stackPopINT(pVM->pStack); /* get mode */ count = stackPopINT(pVM->pStack); /* get count */ ptr = stackPopPtr(pVM->pStack); /* get ptr */ if ((count < 0) || (ptr == NULL)) { stackPushINT(pVM->pStack, -1); return; } /* ensure that the string is null terminated */ name = (char *)malloc(count+1); bcopy(ptr,name,count); name[count] = 0; /* open the file */ fd = open(name, mode); free(name); stackPushINT(pVM->pStack, fd); return;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:33,
示例2: ficlGetenvvoidficlGetenv(FICL_VM *pVM){#ifndef TESTMAIN char *name;#endif char *namep, *value; int names;#if FICL_ROBUST > 1 vmCheckStack(pVM, 2, 2);#endif names = stackPopINT(pVM->pStack); namep = (char*) stackPopPtr(pVM->pStack);#ifndef TESTMAIN name = (char*) ficlMalloc(names+1); if (!name) vmThrowErr(pVM, "Error: out of memory"); strncpy(name, namep, names); name[names] = '/0'; value = getenv(name); ficlFree(name); if(value != NULL) { stackPushPtr(pVM->pStack, value); stackPushINT(pVM->pStack, strlen(value)); } else#endif stackPushINT(pVM->pStack, -1); return;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:34,
示例3: ficlUuidToStringvoidficlUuidToString(FICL_VM *pVM){#ifndef TESTMAIN char *uuid; uint32_t status;#endif uuid_t *u;#if FICL_ROBUST > 1 vmCheckStack(pVM, 1, 0);#endif u = (uuid_t *)stackPopPtr(pVM->pStack);#ifndef TESTMAIN uuid_to_string(u, &uuid, &status); if (status != uuid_s_ok) { stackPushPtr(pVM->pStack, uuid); stackPushINT(pVM->pStack, strlen(uuid)); } else#endif stackPushINT(pVM->pStack, -1); return;}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:26,
示例4: ficlFileStatusstatic void ficlFileStatus(FICL_VM *pVM) /* ( c-addr u -- x ior ) */{ struct stat statbuf; int length = stackPopINT(pVM->pStack); void *address = (void *)stackPopPtr(pVM->pStack); char *filename = (char *)alloca(length + 1); memcpy(filename, address, length); filename[length] = 0; if (stat(filename, &statbuf) == 0) { /* ** the "x" left on the stack is implementation-defined. ** I push the file's access mode (readable, writeable, is directory, etc) ** as defined by ANSI C. */ stackPushINT(pVM->pStack, statbuf.st_mode); stackPushINT(pVM->pStack, 0); } else { stackPushINT(pVM->pStack, -1); stackPushINT(pVM->pStack, ENOENT); }}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:27,
示例5: keyQuestion/* key? - check for a character from stdin (FACILITY) * * key? ( -- flag ) */static void keyQuestion(FICL_VM *pVM){#if FICL_ROBUST > 1 vmCheckStack(pVM, 0, 1);#endif#ifdef TESTMAIN /* XXX Since we don't fiddle with termios, let it always succeed... */ stackPushINT(pVM->pStack, FICL_TRUE);#else /* But here do the right thing. */ stackPushINT(pVM->pStack, ischar()? FICL_TRUE : FICL_FALSE);#endif return;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:18,
示例6: ficlCcallvoidficlCcall(FICL_VM *pVM){ int (*func)(int, ...); int result, p[10]; int nparam, i;#if FICL_ROBUST > 1 vmCheckStack(pVM, 2, 0);#endif func = stackPopPtr(pVM->pStack); nparam = stackPopINT(pVM->pStack);#if FICL_ROBUST > 1 vmCheckStack(pVM, nparam, 1);#endif for (i = 0; i < nparam; i++) p[i] = stackPopINT(pVM->pStack); result = func(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]); stackPushINT(pVM->pStack, result); return;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:28,
示例7: searchWordlist/************************************************************************** s e a r c h - w o r d l i s t** SEARCH ( c-addr u wid -- 0 | xt 1 | xt -1 )** Find the definition identified by the string c-addr u in the word list** identified by wid. If the definition is not found, return zero. If the** definition is found, return its execution token xt and one (1) if the** definition is immediate, minus-one (-1) otherwise. **************************************************************************/static void searchWordlist(FICL_VM *pVM){ STRINGINFO si; UNS16 hashCode; FICL_WORD *pFW; FICL_HASH *pHash = stackPopPtr(pVM->pStack); si.count = (FICL_COUNT)stackPopUNS(pVM->pStack); si.cp = stackPopPtr(pVM->pStack); hashCode = hashHashCode(si); ficlLockDictionary(TRUE); pFW = hashLookup(pHash, si, hashCode); ficlLockDictionary(FALSE); if (pFW) { stackPushPtr(pVM->pStack, pFW); stackPushINT(pVM->pStack, (wordIsImmediate(pFW) ? 1 : -1)); } else { stackPushUNS(pVM->pStack, 0); } return;}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:35,
示例8: ficlFileSizestatic void ficlFileSize(FICL_VM *pVM) /* ( fileid -- ud ior ) */{ ficlFILE *ff = (ficlFILE *)stackPopPtr(pVM->pStack); long ud = fileSize(ff->f); stackPushINT(pVM->pStack, ud); pushIor(pVM, ud != -1);}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:7,
示例9: key/* key - get a character from stdin * * key ( -- char ) */static void key(FICL_VM *pVM){#if FICL_ROBUST > 1 vmCheckStack(pVM, 0, 1);#endif stackPushINT(pVM->pStack, getchar()); return;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:12,
示例10: pfwrite/* fwrite - write file contents * * fwrite ( fd buf nbytes -- nwritten ) */static void pfwrite(FICL_VM *pVM){ int fd, len; char *buf;#if FICL_ROBUST > 1 vmCheckStack(pVM, 3, 1);#endif len = stackPopINT(pVM->pStack); /* get number of bytes to read */ buf = stackPopPtr(pVM->pStack); /* get buffer */ fd = stackPopINT(pVM->pStack); /* get fd */ if (len > 0 && buf && fd != -1) stackPushINT(pVM->pStack, write(fd, buf, len)); else stackPushINT(pVM->pStack, -1); return;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:21,
示例11: pushIorstatic void pushIor(FICL_VM *pVM, int success){ int ior; if (success) ior = 0; else ior = errno; stackPushINT(pVM->pStack, ior);}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:9,
示例12: ficlInb/* * inb ( port# -- c ) * Fetch a byte from I/O port number port# */voidficlInb(FICL_VM *pVM){ u_char c; u_int32_t port; port=stackPopUNS(pVM->pStack); c=inb(port); stackPushINT(pVM->pStack,c);}
开发者ID:coyizumi,项目名称:cs111,代码行数:14,
示例13: ficlPciBiosCountDevices/* * pcibios-device-count (devid -- count) * * Returns the PCI BIOS' count of how many devices matching devid are in the system. * devid is the 32-bit vendor + device. */static voidficlPciBiosCountDevices(FICL_VM *pVM){ uint32_t devid; int i; devid = stackPopINT(pVM->pStack); i = biospci_count_device_type(devid); stackPushINT(pVM->pStack, i);}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:18,
示例14: fkey/* fkey - get a character from a file * * fkey ( file -- char ) */static void fkey(FICL_VM *pVM){ int i, fd; char ch;#if FICL_ROBUST > 1 vmCheckStack(pVM, 1, 1);#endif fd = stackPopINT(pVM->pStack); i = read(fd, &ch, 1); stackPushINT(pVM->pStack, i > 0 ? ch : -1); return;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:17,
示例15: ficlPciBiosReadConfig/* * pcibios-read-config (locator offset width -- value) * * Reads the specified config register. * Locator is bus << 8 | device << 3 | fuction * offset is the pci config register * width is 0 for byte, 1 for word, 2 for dword * value is the value to read from the register */static voidficlPciBiosReadConfig(FICL_VM *pVM){ uint32_t value, width, offset, locator; width = stackPopINT(pVM->pStack); offset = stackPopINT(pVM->pStack); locator = stackPopINT(pVM->pStack); biospci_read_config(locator, offset, width, &value); stackPushINT(pVM->pStack, value);}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:22,
示例16: pfseek/* fseek - seek to a new position in a file * * fseek ( fd ofs whence -- pos ) */static void pfseek(FICL_VM *pVM){ int fd, pos, whence;#if FICL_ROBUST > 1 vmCheckStack(pVM, 3, 1);#endif whence = stackPopINT(pVM->pStack); pos = stackPopINT(pVM->pStack); fd = stackPopINT(pVM->pStack); stackPushINT(pVM->pStack, lseek(fd, pos, whence)); return;}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:17,
示例17: ficlReadFilestatic void ficlReadFile(FICL_VM *pVM) /* ( c-addr u1 fileid -- u2 ior ) */{ ficlFILE *ff = (ficlFILE *)stackPopPtr(pVM->pStack); int length = stackPopINT(pVM->pStack); void *address = (void *)stackPopPtr(pVM->pStack); int result; clearerr(ff->f); result = fread(address, 1, length, ff->f); stackPushINT(pVM->pStack, result); pushIor(pVM, ferror(ff->f) == 0);}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:13,
示例18: ficlFopenstatic void ficlFopen(FICL_VM *pVM, char *writeMode) /* ( c-addr u fam -- fileid ior ) */{ int fam = stackPopINT(pVM->pStack); int length = stackPopINT(pVM->pStack); void *address = (void *)stackPopPtr(pVM->pStack); char mode[4]; FILE *f; char *filename = (char *)alloca(length + 1); memcpy(filename, address, length); filename[length] = 0; *mode = 0; switch (FICL_FAM_OPEN_MODE(fam)) { case 0: stackPushPtr(pVM->pStack, NULL); stackPushINT(pVM->pStack, EINVAL); return; case FICL_FAM_READ: strcat(mode, "r"); break; case FICL_FAM_WRITE: strcat(mode, writeMode); break; case FICL_FAM_READ | FICL_FAM_WRITE: strcat(mode, writeMode); strcat(mode, "+"); break; } strcat(mode, (fam & FICL_FAM_BINARY) ? "b" : "t"); f = fopen(filename, mode); if (f == NULL) stackPushPtr(pVM->pStack, NULL); else { ficlFILE *ff = (ficlFILE *)malloc(sizeof(ficlFILE)); strcpy(ff->filename, filename); ff->f = f; stackPushPtr(pVM->pStack, ff); fseek(f, 0, SEEK_SET); } pushIor(pVM, f != NULL);}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:48,
示例19: ficlReadLinestatic void ficlReadLine(FICL_VM *pVM) /* ( c-addr u1 fileid -- u2 flag ior ) */{ ficlFILE *ff = (ficlFILE *)stackPopPtr(pVM->pStack); int length = stackPopINT(pVM->pStack); char *address = (char *)stackPopPtr(pVM->pStack); int error; int flag; if (feof(ff->f)) { stackPushINT(pVM->pStack, -1); stackPushINT(pVM->pStack, 0); stackPushINT(pVM->pStack, 0); return; } clearerr(ff->f); *address = 0; fgets(address, length, ff->f); error = ferror(ff->f); if (error != 0) { stackPushINT(pVM->pStack, -1); stackPushINT(pVM->pStack, 0); stackPushINT(pVM->pStack, error); return; } length = strlen(address); flag = (length > 0); if (length && ((address[length - 1] == '/r') || (address[length - 1] == '/n'))) length--; stackPushINT(pVM->pStack, length); stackPushINT(pVM->pStack, flag); stackPushINT(pVM->pStack, 0); /* ior */}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:38,
示例20: isdirQuestion/* isdir? - Return whether an fd corresponds to a directory. * * isdir? ( fd -- bool ) */static void isdirQuestion(FICL_VM *pVM){ struct stat sb; FICL_INT flag; int fd;#if FICL_ROBUST > 1 vmCheckStack(pVM, 1, 1);#endif fd = stackPopINT(pVM->pStack); flag = FICL_FALSE; do { if (fd < 0) break; if (fstat(fd, &sb) < 0) break; if (!S_ISDIR(sb.st_mode)) break; flag = FICL_TRUE; } while (0); stackPushINT(pVM->pStack, flag);}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:27,
示例21: pfreaddir/* freaddir - read directory contents * * freaddir ( fd -- ptr len TRUE | FALSE ) */static void pfreaddir(FICL_VM *pVM){#ifdef TESTMAIN static struct dirent dirent; struct stat sb; char *buf; off_t off, ptr; u_int blksz; int bufsz;#endif struct dirent *d; int fd;#if FICL_ROBUST > 1 vmCheckStack(pVM, 1, 3);#endif fd = stackPopINT(pVM->pStack);#if TESTMAIN /* * The readdirfd() function is specific to the loader environment. * We do the best we can to make freaddir work, but it's not at * all guaranteed. */ d = NULL; buf = NULL; do { if (fd == -1) break; if (fstat(fd, &sb) == -1) break; blksz = (sb.st_blksize) ? sb.st_blksize : getpagesize(); if ((blksz & (blksz - 1)) != 0) break; buf = malloc(blksz); if (buf == NULL) break; off = lseek(fd, 0LL, SEEK_CUR); if (off == -1) break; ptr = off; if (lseek(fd, 0, SEEK_SET) == -1) break; bufsz = getdents(fd, buf, blksz); while (bufsz > 0 && bufsz <= ptr) { ptr -= bufsz; bufsz = getdents(fd, buf, blksz); } if (bufsz <= 0) break; d = (void *)(buf + ptr); dirent = *d; off += d->d_reclen; d = (lseek(fd, off, SEEK_SET) != off) ? NULL : &dirent; } while (0); if (buf != NULL) free(buf);#else d = readdirfd(fd);#endif if (d != NULL) { stackPushPtr(pVM->pStack, d->d_name); stackPushINT(pVM->pStack, strlen(d->d_name)); stackPushINT(pVM->pStack, FICL_TRUE); } else { stackPushINT(pVM->pStack, FICL_FALSE); }}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:72,
示例22: freeHeapstatic void freeHeap(FICL_VM *pVM){ stackPushINT(pVM->pStack, dictCellsAvail(ficlGetDict(pVM->pSys)));}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:4,
注:本文中的stackPushINT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ stackValue函数代码示例 C++ stackPush函数代码示例 |