本文整理汇总了C++中pexit函数的典型用法代码示例。如果您正苦于以下问题:C++ pexit函数的具体用法?C++ pexit怎么用?C++ pexit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pexit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gl_load_texture_raw
// load a 256x256 RGB .RAW file as a texture
// http://www.nullterminator.net/gltexture.html
GLuint gl_load_texture_raw(const char * filename, u_int width, u_int height, u_int alpha) {
char* data;
FILE* file;
printf("loading raw texture [%s]\n", filename);
// open texture data
file = fopen(filename, "rb");
if ( file == NULL ) return 0;
// allocate buffer
// width = 256;
// height = 256;
width = 512;
height = 512;
data = (char*) malloc(width * height * (alpha ? 4 : 3));
if (data == NULL)
pexit(errno, "gl_load_texture_raw: can't allocate space for image data");
// read texture data
fread(data, width * height * (alpha ? 4 : 3), 1, file );
fclose(file);
return gl_load_texture_from_data(data, 512, 512, (alpha ? 4 : 3));
}
示例2: linkproc
/*
* this is the body for all kproc's
*/
static void
linkproc(void)
{
spllo();
up->kpfun(up->kparg);
pexit("kproc exiting", 0);
}
示例3: printf
void *merge(void *hnd, c4snet_data_t *OutFile, c4snet_data_t *Result,
int X, c4snet_data_t *Out, int N, int B, int K, int J, int I)
{
const int P = N / B;
if (verbose) {
printf("%s: %p, %p, X=%d, %p, N=%d, B=%d, (%d, %d, %d)\n",
__func__, OutFile, Result, X, Out, N, B, K, J, I);
}
if (compute) {
c4snet_data_t **result = C4SNetGetData(Result);
assert(result[J + I * P] == NULL);
result[J + I * P] = Out;
}
if (X > 1) {
C4SNetOut(hnd, 1, OutFile, Result, X - 1);
}
else if (compute) {
struct timespec end;
if (clock_gettime(CLOCK_REALTIME, &end)) {
pexit("clock_gettime");
}
printf("Time for size %d x %d : %lf sec\n", N, N, delta_time(begin, end));
write_matrix(Result, N, B, OutFile);
C4SNetOut(hnd, 2, C4SNetCreate(CTYPE_char, 5, "Done."));
C4SNetFree(OutFile);
C4SNetFree(Result);
}
return hnd;
}
示例4: get_block
/* Read a block. */
void
get_block(block_t n, void *buf)
{
ssize_t k;
/* First access returns a zero block */
if (read_and_set(n) == 0) {
memcpy(buf, zero, block_size);
return;
}
if (lseek64(fd, mul64u(n, block_size), SEEK_SET, NULL) == (off_t)(-1))
pexit("get_block couldn't seek");
k = read(fd, buf, block_size);
if (k != block_size)
pexit("get_block couldn't read block #%u", (unsigned)n);
}
示例5: main
int
main() {
logInfo("Parent", "creating child");
switch (fork()) {
case -1:
pexit("fork");
break;
case 0:
/* child code: give a chance for parent finish itself (very basic means of
* process synchronization */
logInfo("Child", "child created, waiting parent to finish");
sleep(5);
char msg[BUFSIZ];
snprintf(msg, BUFSIZ, "parent PID = %ld", (long) getppid());
logInfo("Child", msg);
break;
default:
/* parent: nothing to do but finish */
logInfo("Parent", "finishing up");
exit(EXIT_SUCCESS);
}
/* only child should get to this point */
exit(EXIT_SUCCESS);
}
示例6: toggle_lock_cursor
void toggle_lock_cursor(tile* t) {
u_int r;
u_int new_lock = cursor_lock;
if (NULL == t)
pexit(EFAULT, "lock_cursor: got NULL tile");
r = get_robot_at(t);
switch(cursor_lock) {
case CURSOR_LOCK_NONE:
if (ROBOT_NONE != r) {
new_lock = CURSOR_LOCK_ROBOT;
cursor_lock_robot = r;
} else {
printf("nothing to lock onto\n");
}
break;
case CURSOR_LOCK_ROBOT:
if ((ROBOT_NONE == r) ||
(cursor_lock_robot == r)) {
// place_robot(cursor_lock_robot, t);
new_lock = CURSOR_LOCK_NONE;
cursor_lock_robot = ROBOT_NONE;
compile_robots();
} else {
printf("can't place a robot over another robot\n");
}
break;
}
cursor_lock = new_lock;
}
示例7: sysexits
uintptr
sysexits(va_list list)
{
char *status;
char *inval = "invalid exit string";
char buf[ERRMAX];
status = va_arg(list, char*);
if(status != nil){
if(waserror())
status = inval;
else{
validaddr((uintptr)status, 1, 0);
if(vmemchr(status, 0, ERRMAX) == 0){
memmove(buf, status, ERRMAX);
buf[ERRMAX-1] = 0;
status = buf;
}
poperror();
}
}
pexit(status, 1);
return 0; /* not reached */
}
示例8: main
int
main(int argc, char *argv[]) {
int fd, newfd;
int numWritten;
Bool useDup2;
if (argc < 2 || argc > 3) {
helpAndLeave(argv[0], EXIT_FAILURE);
}
fd = (int) atol(argv[1]);
newfd = -1; /* if not using dup2, this variable will not be used */
if (argc == 3) {
useDup2 = TRUE;
newfd = (int) atol(argv[2]);
} else {
useDup2 = FALSE;
}
newfd = duplicate(fd, newfd, useDup2);
numWritten = write(newfd, writeStr, sizeof(writeStr));
if (numWritten == -1) {
pexit("write");
}
safeClose(fd);
safeClose(newfd);
printf("Done. Written %d bytes to the new file descriptor #%d\n", numWritten, newfd);
return EXIT_SUCCESS;
}
示例9: vt6102lproc
static void
vt6102lproc(void* arg)
{
Ctlr *ctlr;
Ether *edev;
MiiPhy *phy;
edev = arg;
ctlr = edev->ctlr;
for(;;){
if(ctlr->mii == nil || ctlr->mii->curphy == nil)
break;
if(miistatus(ctlr->mii) < 0)
goto enable;
phy = ctlr->mii->curphy;
ilock(&ctlr->clock);
if(phy->fd)
ctlr->cr |= Fdx;
else
ctlr->cr &= ~Fdx;
csr16w(ctlr, Cr, ctlr->cr);
iunlock(&ctlr->clock);
enable:
ctlr->lwakeup = 0;
vt6102imr(ctlr, Srci);
ctlr->lsleep++;
sleep(&ctlr->lrendez, vt6102wakeup, &ctlr->lwakeup);
}
pexit("vt6102lproc: done", 1);
}
示例10: loopbackread
static void
loopbackread(void *a)
{
Ipifc *ifc;
Block *bp;
LB *lb;
ifc = a;
lb = ifc->arg;
lb->readp = up; /* hide identity under a rock for unbind */
if(waserror()){
lb->readp = 0;
pexit("hangup", 1);
}
for(;;){
bp = qbread(lb->q, Maxtu);
if(bp == nil)
continue;
ifc->in++;
if(!canrlock(ifc)){
freeb(bp);
continue;
}
if(waserror()){
runlock(ifc);
nexterror();
}
if(ifc->lifc == nil)
freeb(bp);
else
ipiput4(lb->f, ifc, bp);
runlock(ifc);
poperror();
}
}
示例11: insert_bit
/* Insert one bit into the bitmap */
void
insert_bit(block_t map, bit_t bit)
{
int boff, w, s;
unsigned int bits_per_block;
block_t map_block;
bitchunk_t *buf;
buf = alloc_block();
bits_per_block = FS_BITS_PER_BLOCK(block_size);
map_block = map + bit / bits_per_block;
if (map_block >= inode_offset)
pexit("insertbit invades inodes area - this cannot happen");
boff = bit % bits_per_block;
assert(boff >=0);
assert(boff < FS_BITS_PER_BLOCK(block_size));
get_block(map_block, buf);
w = boff / FS_BITCHUNK_BITS;
s = boff % FS_BITCHUNK_BITS;
buf[w] |= (1 << s);
put_block(map_block, buf);
free(buf);
}
示例12: incr_size
/* Increment the file-size in inode n */
void
incr_size(ino_t n, size_t count)
{
block_t b;
int off;
b = ((n - 1) / inodes_per_block) + inode_offset;
off = (n - 1) % inodes_per_block;
{
struct inode *inodes;
assert(inodes_per_block * sizeof(*inodes) == block_size);
if(!(inodes = alloc_block()))
err(1, "couldn't allocate a block of inodes");
get_block(b, inodes);
/* Check overflow; avoid compiler spurious warnings */
if (inodes[off].i_size+(int)count < inodes[off].i_size ||
inodes[off].i_size > MAX_MAX_SIZE-(int)count)
pexit("File has become too big to be handled by MFS");
inodes[off].i_size += count;
put_block(b, inodes);
free(inodes);
}
}
示例13: mem_alloc_align_func
void * mem_alloc_align_func(size_t size,
size_t align
#if defined(MEMDBG_ON)
,
char * file,
int line
#endif
)
{
void * ptr = NULL;
#if defined(MEMDBG_ON)
ptr = (char *) MEMDBG_alloc_align(size, align, file, line);
#elif HAVE_POSIX_MEMALIGN
if (posix_memalign(&ptr, align, size)) pexit("posix_memalign");
#elif HAVE_ALIGNED_ALLOC
/* According to the Linux man page, "size should be a multiple of
alignment", whatever they mean with "should"... This does not
make any sense whatsoever but we round it up to comply. */
size = ((size + (align - 1)) / align) * align;
if (!(ptr = aligned_alloc(align, size))) pexit("aligned_alloc");
#elif HAVE_MEMALIGN
/* Let's just pray this implementation can actually free it */
#if defined(__sparc__) || defined(__sparc) || defined(sparc) \
|| defined(__sparcv9)
if (!(ptr = memalign(align, size)))
#else
if (!(ptr = memalign(&ptr, align, size)))
#endif
perror("memalign");
#elif HAVE___MINGW_ALIGNED_MALLOC
if (!(ptr = __mingw_aligned_malloc(size, align)))
perror("__mingw_aligned_malloc");
#elif HAVE__ALIGNED_MALLOC
if (!(ptr = _aligned_malloc(size, align))) perror("aligned_malloc");
#elif AC_BUILT
#error No suitable aligned alloc found, please report to john-dev mailing list (state your OS details).
/* we need an aligned alloc function for legacy builds */
#elif _ISOC11_SOURCE
size = ((size + (align - 1)) / align) * align;
if (!(ptr = aligned_alloc(align, size))) perror("aligned_alloc");
#else
if (posix_memalign(&ptr, align, size)) perror("posix_memalign");
#endif
return ptr;
}
示例14: w_timer
static void
w_timer(void* arg)
{
Ether* ether = (Ether*) arg;
Ctlr* ctlr = (Ctlr*)ether->ctlr;
ctlr->timerproc = up;
for(;;) {
tsleep(&up->sleep, return0, 0, MSperTick);
ctlr = (Ctlr*)ether->ctlr;
if(ctlr == 0)
break;
if((ctlr->state & (Attached|Power)) != (Attached|Power))
continue;
ctlr->ticks++;
ilock(ctlr);
// Seems that the card gets frames BUT does
// not send the interrupt; this is a problem because
// I suspect it runs out of receive buffers and
// stops receiving until a transmit watchdog
// reenables the card.
// The problem is serious because it leads to
// poor rtts.
// This can be seen clearly by commenting out
// the next if and doing a ping: it will stop
// receiving (although the icmp replies are being
// issued from the remote) after a few seconds.
// Of course this `bug' could be because I'm reading
// the card frames in the wrong way; due to the
// lack of documentation I cannot know.
if(csr_ins(ctlr, WR_EvSts)&WEvs) {
ctlr->tickintr++;
w_intr(ether);
}
if((ctlr->ticks % 10) == 0) {
if(ctlr->txtmout && --ctlr->txtmout == 0) {
ctlr->nwatchdogs++;
w_txdone(ctlr, WTxErrEv);
if(w_enable(ether)) {
DEBUG("wavelan: wdog enable failed\n");
}
w_txstart(ether);
}
if((ctlr->ticks % 120) == 0)
if(ctlr->txbusy == 0)
w_cmd(ctlr, WCmdEnquire, WTyp_Stats);
if(ctlr->scanticks > 0)
if((ctlr->ticks % ctlr->scanticks) == 0)
if(ctlr->txbusy == 0)
w_cmd(ctlr, WCmdEnquire, WTyp_Scan);
}
iunlock(ctlr);
}
pexit("terminated", 0);
}
示例15: linkproc
static void
linkproc(void)
{
Proc *up = externup();
spllo();
up->kpfun(up->kparg);
pexit("kproc dying", 0);
}