本文整理汇总了C++中crash函数的典型用法代码示例。如果您正苦于以下问题:C++ crash函数的具体用法?C++ crash怎么用?C++ crash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了crash函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(int narg,char **arg)
{
if(narg<2) crash("Use: %s filein [clust_size]",arg[0]);
//load
read(arg[1]);
if(data.size==0) crash("empty file %s",arg[1]);
else cout<<"data size: "<<data.size<<endl;
if(narg<3) data.clust_size=1;
else data.clust_size=atoi(arg[2]);
if(data.clust_size<0) crash("suggested negative clust_size %u",data.clust_size);
if(data.clust_size>=data.size) crash("suggested too large clust_size %u>buf_size %u",
data.clust_size,data.size);
//compute average and error
double ave,err;
data.ave_err(ave,err);
//write errors
double med_tint,err_tint;
data.compute_tint(med_tint,err_tint,"/tmp/autocorr.xmg");
cout<<"med_tint: "<<med_tint<<" "<<err_tint<<endl;
double tau=(2*med_tint-1)/2;
cout.precision(8);
cout<<"value: "<<ave<<" +- "<<err*sqrt(2*tau+1)<<endl;
return 0;
}
开发者ID:sunpho84,项目名称:sunpho,代码行数:29,代码来源:main.cpp
示例2: pte_manipulate
static int
pte_manipulate(struct pte_manip *manip) {
int r;
if(ADDR_OFFSET(manip->data.start) != 0) crash();
if(ADDR_OFFSET(manip->data.end+1) != 0) crash();
if((manip->data.op & PTE_OP_MAP) && (ADDR_OFFSET(manip->data.paddr) != 0)) crash();
manip->state = MSTATE_SPLIT_START;
manip->mapped = manip->data.first = manip->data.start;
manip->data.split_end = manip->data.end;
if(KerextAmInKernel()) {
return do_manipulation(manip);
}
//FUTURE: Do we actually have to go into the kernel all of the time
//FUTURE: for PTE manipulation? We need to for the system space since
//FUTURE: the X86 has to walk the mem_dir_list, but maybe not for
//FUTURE: user space. The address space is usually locked (aside
//FUTURE: from vmm_resize()) when manipulating the pgtbl, so we
//FUTURE: might not even need a mutex.
//FUTURE: Have to worry about SMP, where one CPU might be in a locked
//FUTURE: kernel while we remove perms to access the memory being
//FUTURE: referenced.
manip->data.op |= PTE_OP_PREEMPT;
do {
r = __Ring0(ker_manipulate, manip);
} while(r == EINTR);
return r;
}
开发者ID:vocho,项目名称:openqnx,代码行数:33,代码来源:mm_pte.c
示例3: load_corr_all
jvec load_corr_all(oper_t &so,oper_t &si)
{
jvec out(T,njacks);
out=0;
int nave=0;
//check spin
if(so.spin!=si.spin) crash("spin of source %d does not agree wih spin of the sink %d",so.spin,si.spin);
for(int iso=0;iso<so.ind->n;iso++)
for(int isi=0;isi<si.ind->n;isi++)
{
jvec corr=so.ind->sign[iso]*si.ind->sign[isi]*
jvec_load(combine("%s2pts_corr",base_path).c_str(),
T,njacks,icombo(so.ind->gam[iso],so.sme,so.ind->der1[iso],so.ind->der2[iso],
si.ind->gam[isi],si.sme,si.ind->der1[isi],si.ind->der2[isi]));
out+=corr;
cout<<"corr "<<nave<<": "<<corr[1]<<endl;
double n=ndev(corr);
int iszero=(fabs(n)<3);
if(iszero)
{
cout<<corr<<endl;
crash("seems zero: %d, %lg",iszero,n);
}
nave++;
}
return out;
}
开发者ID:sunpho84,项目名称:sunpho,代码行数:31,代码来源:cov_der_new.cpp
示例4: main
int main(int argc, char *argv[])
{
printf("\n\n eXtremail 1.5.x Denial of Service \n");
printf("by Luca Ercoli <luca.e [at] seeweb.com>\n\n\n\n");
if (argc != 2)
{
fprintf(stderr,"\nUsage -> %s hostname\n\n",argv[0]);
exit(1);
}
crash(argv[1],0);
numbytes=0;
printf ("\n[+] Checking server status ...\n");
if(!fork()) crash(argv[1],1);
sleep(5);
if (numbytes == 0) printf ("\n[!] Smtpd/Pop3d/Imapd/Remt crashed!\n\n\n");
return 0;
}
开发者ID:AlexxNica,项目名称:exploit-database,代码行数:26,代码来源:20952.c
示例5: avr_core_watch_write
void avr_core_watch_write(avr_t *avr, uint16_t addr, uint8_t v)
{
if (addr > avr->ramend) {
AVR_LOG(avr, LOG_ERROR, "CORE: *** Invalid write address PC=%04x SP=%04x O=%04x Address %04x=%02x out of ram\n",
avr->pc, _avr_sp_get(avr), avr->flash[avr->pc + 1] | (avr->flash[avr->pc]<<8), addr, v);
crash(avr);
}
if (addr < 32) {
AVR_LOG(avr, LOG_ERROR, "CORE: *** Invalid write address PC=%04x SP=%04x O=%04x Address %04x=%02x low registers\n",
avr->pc, _avr_sp_get(avr), avr->flash[avr->pc + 1] | (avr->flash[avr->pc]<<8), addr, v);
crash(avr);
}
#if AVR_STACK_WATCH
/*
* this checks that the current "function" is not doctoring the stack frame that is located
* higher on the stack than it should be. It's a sign of code that has overrun it's stack
* frame and is munching on it's own return address.
*/
if (avr->trace_data->stack_frame_index > 1 && addr > avr->trace_data->stack_frame[avr->trace_data->stack_frame_index-2].sp) {
printf( FONT_RED "%04x : munching stack SP %04x, A=%04x <= %02x\n" FONT_DEFAULT, avr->pc, _avr_sp_get(avr), addr, v);
}
#endif
if (avr->gdb) {
avr_gdb_handle_watchpoints(avr, addr, AVR_GDB_WATCH_WRITE);
}
avr->data[addr] = v;
}
开发者ID:kevinf28,项目名称:simavr,代码行数:29,代码来源:sim_core.c
示例6: compare
double DistanceVdVdtMatrix::compare(const VdVdtMatrix & o) const {
const DistanceVdVdtMatrix & other = dynamic_cast<const DistanceVdVdtMatrix &>(o);
double errorValue = 0;
if (other.getVLength() != vLength) crash("DistanceVdVdtMatrix","V dimensions don't match");
if (other.getdVdtLength() != dVdtLength) crash("DistanceVdVdtMatrix","dVdt dimensions don't match");
double diff;
double distance, v1, v2, dVdt1, dVdt2;
double maxDistance = pow((double)vLength,2)+pow((double)dVdtLength,2);
for (map< const int, double >::const_iterator i = matrix.begin(); i != matrix.end(); i++) {
for (map< const int, double >::const_iterator j = (other.matrix).begin(); j != (other.matrix).end(); j++) {
diff = i->second-j->second;
v1 = vIndex(i->first);
v2 = other.vIndex(j->first);
dVdt1 = dVdtIndex(i->first);
dVdt2 = other.dVdtIndex(j->first);
distance = pow(v1-v2,2)+pow(dVdt1-dVdt2,2);
errorValue += pow(diff,2)*pow(maxDistance-distance,2);
}
}
return sqrt(errorValue);
}
开发者ID:tclose,项目名称:Neurofitter,代码行数:26,代码来源:DistanceVdVdtMatrix.cpp
示例7: handlersetup
/*
* handlersetup()
* Sets up signal handlers for SEGV and ALRM
*
* Precondition: None
* Postcondition: Signal handlers are set up
*/
void handlersetup( ){
/*
* set up a signal handlers for SEGV and ALRM
*/
sigset_t newset;
struct sigaction act, alact;
act.sa_sigaction = &segvhandler;
alact.sa_handler = &catchalarm;
sigfillset(&newset); /* let's do full mask */
sigdelset(&newset, SIGINT); /* and delete INT in case we get in trouble... */
sigdelset(&newset, SIGUSR1);
act.sa_flags = SA_SIGINFO;
act.sa_restorer = NULL;
alact.sa_mask = newset;
act.sa_mask = newset;
alact.sa_flags = 0;
alact.sa_flags |= SA_INTERRUPT;
if (sigaction(SIGSEGV, &act, NULL) != 0)
crash("sigaction");
if( sigaction( SIGALRM, &alact, NULL) != 0 )
crash("sigaction 2");
}
开发者ID:Tlaskey,项目名称:Old-Schoolwork,代码行数:35,代码来源:metal.c
示例8: init
/*
* malloc()
*
* Precondition: size: size of buffer to allocate
* Postcondition: pointer to allocated buffer is
* returned
*/
extern C_LINKAGE void *malloc(size_t size) {
if( !first )
/* initialize everything if this is the very first malloc() call */
init();
else
alarm(0);
lock();
/* Allocate the buffer using mmap() */
caddr_t allocation = (caddr_t) mmap(NULL,
size,
PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS,
0,0);
/* Update memory manager if we have room for the new information */
if( myhandler.totalNumAddrs < myhandler.total_size){
setMemSlots(size, allocation, myhandler.totalNumAddrs);
myhandler.totalNumAddrs++;
}else{
/* Else use first fit algorithm to check for holes in memory
* If one is found, we save the information in this location
*/
int i;
for(i = 0; i < myhandler.total_size; i++){
if(memSlots[i].del == 1 ){
setMemSlots(size, allocation, myhandler.totalNumAddrs);
break;
}
}
/* Extend memory if we are out of room and place the
* new information on the end
*/
if( i >= myhandler.total_size){
memSlots = extend1(memSlots, myhandler.total_size * sizeof(memSlots[0]) + pagesize);
setMemSlots(size, allocation, myhandler.totalNumAddrs);
}
}
/* If there is room for this page's information on the encryption
* handler, then mprotect it with PROT_NONE
*/
if( !NO_OP && myhandler.encrNumAddrs < myhandler.encr_size ){
if ( mprotect(allocation, size, PROT_NONE) < 0 )
crash("mprotect - malloc");
}else{
/* Else extend encryption handler memory and then do mprotect */
if( myhandler.encrNumAddrs < myhandler.encr_size )
encrHandler = extend2( encrHandler, myhandler.encr_size * sizeof(encrHandler[0]) + pagesize);
if ( mprotect(allocation, size, PROT_NONE) < 0 )
crash("mprotect - malloc");
}
unlock();
/* return buffer */
return allocation;
}
开发者ID:Tlaskey,项目名称:Old-Schoolwork,代码行数:67,代码来源:metal.c
示例9: load_otto_ir_combo
jvec load_otto_ir_combo(const char *name,int imass,const char *sl,int ir_combo,int reim=0)
{
if(ir_combo>=8||ir_combo<0) crash("check ir_combo %d in range [0,8)",ir_combo);
if(imass>=nmass||imass<0) crash("check imass %d in range [0,%d)",imass,nmass);
return jvec_load(combine("%s/otto_wL_R_%s_%s",base_path,name,sl).c_str(),T,njack,icombo_otto(imass,ir_combo,reim));
}
开发者ID:sunpho84,项目名称:sunpho,代码行数:7,代码来源:otto.cpp
示例10: dirichlet_code
int dirichlet_code( char aa)
{
char x;
x=tolower (aa);
if ( (x<'a') || (x>'z'))
crash ( "CODE UNDEFINED");
else if ( x<='a')
return x-'a';
else if ( x<='i')
return x-('a'+1);
else if ( x<= 'n')
return x-('a'+2);
else if ( x<='t')
return x-('a'+3);
else if ( x<='w')
return x-('a'+4);
else if ( x=='y')
return x-('a'+5);
else
{
crash ("ERROR in dirichlet_code");
return 0;
}
return 0;
}
开发者ID:Unode,项目名称:ext_apps,代码行数:29,代码来源:evaluate_dirichlet.c
示例11: SENSORCOMMUNICATION_Initialize
void SENSORCOMMUNICATION_Initialize ( void )
{
// the map.
int h = 0;
for (h; h < 75; h++)
theMap[h][25] = 1;
roverOrientation = 0;
roverLocation[0] = 0;
roverLocation[1] = 25;
/* Place the App state machine in its initial state. */
//initDebugU();
sensor_debugTimerInit();
sensorcommunicationData.state = SENSORCOMMUNICATION_STATE_INIT;
sensorcommunicationData.sensorrxByteCount = 0;
sensorcommunicationData.sensorTxMsgSeq = 0x00;
sensorcommunicationData.sensorRxMsgSeq = 0x00;
sensorcommunicationData.sensortheQueue = xQueueCreate(COMMUNICATIONQUEUESIZE, sizeof(COMMUNICATION_MESSAGE)); //sizeof(communicationData.rxMessage));
if(sensorcommunicationData.sensortheQueue == 0)
{
crash("\nE: Comm msgQ");
}
sensorcommunicationData.sensorIntQueue = xQueueCreate(COMMUNICATIONQUEUESIZE, sizeof(COMMUNICATION_MESSAGE)); //sizeof(communicationData.rxMessage));
if(sensorcommunicationData.sensorIntQueue == 0)
{
crash("\nE: Int msgQ");
}
DRV_USART2_Initialize();
}
开发者ID:nathodius,项目名称:controlSystem,代码行数:29,代码来源:sensorCommunication.c
示例12: mom_space_twisted_propagator_g2_d2_corr_of_imom
void mom_space_twisted_propagator_g2_d2_corr_of_imom(spin1prop prop,quark_info qu,gluon_info gl,int imom)
{
if(qu.kappa!=1.0/8 || qu.mass!=0) crash("implemented only for massless quark");
if(gl.c1!=0 && gl.c1!=-1.0/12) crash("implemented only for Wilson or Symanzik (c1=-1/12) gluons");
double lambda=gl.alpha;
//implement equation 26 of 0907.0381
//Table VII
double et2_W[3]={7.4696262,8.2395316,-3.21623339};
double et2_I[3]={5.95209802,7.16084231,-3.0693492};
double *et2;
if(gl.c1==0) et2=et2_W;
else et2=et2_I;
momentum_t p,p3;
double p2=0;
for(int mu=0;mu<4;mu++)
{
p[mu]=M_PI*(2*glb_coord_of_loclx[imom][mu]+qu.bc[mu])/glb_size[mu];
p3[mu]=p[mu]*p[mu]*p[mu];
p2+=p[mu]*p[mu];
}
double c_id=et2[0]-5.39301570*lambda-0.5*(3-2*lambda)*log(p2);
memset(prop,0,sizeof(spin1prop));
spinspin_dirac_summ_the_prod_double(prop,&(base_gamma[0]),c_id);
}
开发者ID:sunpho84,项目名称:nissa,代码行数:30,代码来源:twisted_propagator_g2_corr.cpp
示例13: functionality_check
static void functionality_check(void)
/* To the extent possible, check that standard functions and data types match
* LVB's expectations. Crash verbosely if they are found not to. */
{
/* time() is expected to work without error for logging the start
* and end time, and for generating the default random number seed */
if (time(NULL) == -1)
crash("cannot get system time");
/* if the system is not 32-bit, 64-bit, or more, some limits will be
* less than documented and there may be memory allocation constraints
* that LVB does not allow for */
if ((((long) INT_MAX) < 2147483647L)
|| ((sizeof(void *) * CHAR_BIT) < 32)
|| ((sizeof(size_t) * CHAR_BIT) < 32))
{
crash("program requires at least a 32-bit system");
}
/* LVB_EPS is assumed to be bigger than DBL_EPSILON in code that guards
* against floating-point arithmetic problems */
if (DBL_EPSILON >= LVB_EPS)
crash("program requires greater floating point precision");
/* DBL_MANT_DIG is checked in rinit() so check not necessary here */
} /* end functionality_check() */
开发者ID:monsanto-pinheiro,项目名称:LVB,代码行数:27,代码来源:admin.c
示例14: free
void
free(void *ptr)
{
extern int end;
struct pageinfo *pi;
int sz;
if ((char *)ptr <= (char *)&end)
{
if (ptr == NULL)
crash("free(): attempt to free NULL pointer");
crash("free(): attempt to free a pointer to code or static data");
}
pi = GETPAGEINFO(ptr);
sz = pi->blocksize;
#ifdef DO_GC
if (g.ignorefree)
{
if (g.clearfree)
memset(ptr, 0, sz);
return;
}
#endif
if (sz < 1)
{
if (sz != -1)
crash("free(): invalid pointer - not a large multipage block");
freepages(pi, pi->count);
return;
}
FPRINTF((stderr, "free(%p) pi=%p blocksize=%d numblocks=%d\n",
ptr, pi, pi->blocksize, pi->numblocks));
if (g.clearfree)
memset(ptr, 0, sz);
pi->count--;
/* freed up all blocks in this page, so put it back in the freepage
pool */
if (pi->count == 0)
freeblockspage(pi);
else
{
struct freeblock *e = (struct freeblock *)ptr;
e->link = pi->block;
pi->block = e;
}
return;
}
开发者ID:cstrotm,项目名称:smartfirmware,代码行数:59,代码来源:wgmalloc.c
示例15: spi_global_barrier
//global barrier for spi
void spi_global_barrier()
{
#ifdef SPI_BARRIER
if(MUSPI_GIBarrierEnter(&spi_barrier)) crash("while entering spi barrier");
if(MUSPI_GIBarrierPollWithTimeout(&spi_barrier,60UL*1600000000)) crash("while waiting for barrier to finish");
#else
MPI_Barrier(MPI_COMM_WORLD);
#endif
}
开发者ID:sunpho84,项目名称:nissa,代码行数:10,代码来源:spi.cpp
示例16: crash
inline void MapVdVdtMatrix::set(const int v, const int dVdt, double value) {
if (v < 0 || v >= vLength) {
crash("MapVdVdtMatrix","Invalid v: "+str(v));
}
if (dVdt < 0 || dVdt >= dVdtLength) {
crash("MapVdVdtMatrix","Invalid dVdt: "+str(dVdt));
}
matrix[mIndex(v,dVdt)] = value;
}
开发者ID:wvangeit,项目名称:NeuroFitter,代码行数:9,代码来源:MapVdVdtMatrix.cpp
示例17: oh_what
int
oh_what(int x)
{
/* We call crash() twice here, so that the compiler won't try to do a
* tail-call optimization. Only the first call will actually happen, but
* telling the compiler to maybe do the second call will prevent it from
* replacing the first call with a jump. */
return crash(x) + crash(x*2);
}
开发者ID:1234max,项目名称:tor,代码行数:9,代码来源:test_bt_cl.c
示例18: free
/*
* cfree()
* Frees a pointer
*
* Precondition: freeptr: pointer to be freed
* Postcondtion: freeptr is freed by calling
* munmap()
*/
extern C_LINKAGE void free( void *freeptr ){
ualarm(0,0);
alarm(0);
/* Don't think this is needed... */
sigset_t newmask, oldmask;
sigemptyset( &newmask );
sigaddset( &newmask, SIGALRM );
if ( sigprocmask( SIG_BLOCK, &newmask, &oldmask ) < 0 )
crash( "SIG_BLOCK error" );
lock();
if( freeptr ){
if( myhandler.totalNumAddrs == 0 )
crash("free before first malloc!");
int i, j;
ptr = freeptr;
ptr2 = freeptr;
/* search for pointer in memory handler */
for( i = 0; i < myhandler.total_size; i++ ){
if( memSlots[i].addrs == freeptr ){
/* if found set delete to true and
* erase page info from encryption handler
*/
memSlots[i].del = 1;
zero(ptr);
/* If the buffer is more than one page,
* we have to erase each page from the
* encryption handler
*/
for( j = 0; j < memSlots[i].size; j += pagesize ){
if( (ptr + pagesize) <= (ptr2 + memSlots[i].size) ){
ptr += pagesize;
zero(ptr);
}
}
/* Erase the page */
munmap(freeptr, memSlots[i].size);
break;
}
}
if( i == myhandler.total_size )
crash("address not from malloc!");
}
unlock();
if( sigprocmask( SIG_SETMASK, &oldmask, NULL ) < 0 )
crash( "SIG_SETMASK error" );
ualarm(TIMERVAL, 0);
return;
}
开发者ID:Tlaskey,项目名称:Old-Schoolwork,代码行数:64,代码来源:metal.c
示例19: int
int (xferiov)(THREAD *sthp, IOV *dst, IOV *src, int dparts, int sparts, int doff, int soff) {
char *daddr, *saddr;
unsigned dlen, slen, ret;
#ifndef NDEBUG
if(doff > GETIOVLEN(dst)) crash();
#endif
daddr = (char *)GETIOVBASE(dst) + doff;
dlen = GETIOVLEN(dst) - doff;
#ifndef NDEBUG
if(soff > GETIOVLEN(src)) crash();
#endif
saddr = (char *)GETIOVBASE(src) + soff;
slen = GETIOVLEN(src) - soff;
/* Now we move the data. */
for(;;) {
if(slen < dlen) {
ret = xfer_cpy(daddr, saddr, slen);
sthp->args.ms.msglen += slen;
if((--sparts == 0) || ret) {
break;
}
daddr += slen;
dlen -= slen;
++src;
saddr = (char *)GETIOVBASE(src);
slen = GETIOVLEN(src);
} else if(dlen < slen) {
ret = xfer_cpy(daddr, saddr, dlen);
sthp->args.ms.msglen += dlen;
if((--dparts == 0) || ret) {
break;
}
saddr += dlen;
slen -= dlen;
++dst;
daddr = (char *)GETIOVBASE(dst);
dlen = GETIOVLEN(dst);
} else {
ret = xfer_cpy(daddr, saddr, slen);
sthp->args.ms.msglen += slen;
if((--dparts == 0) || (--sparts == 0) || ret) {
break;
}
++src;
saddr = (char *)GETIOVBASE(src);
slen = GETIOVLEN(src);
++dst;
daddr = (char *)GETIOVBASE(dst);
dlen = GETIOVLEN(dst);
}
}
return(ret);
}
开发者ID:vocho,项目名称:openqnx,代码行数:56,代码来源:nano_xfer_msg.c
示例20: check_block
static void
check_block(Header m, const char *file, int line)
{
if (*m->end != CRT_MAGIC)
crash("Bottom overwritten", m, file, line);
if (m->next->prev != m)
crash("next->prev != m", m, file, line);
if (m->prev->next != m)
crash("prev->next != m", m, file, line);
}
开发者ID:giveamouse,项目名称:fbmuck,代码行数:10,代码来源:crt_malloc.c
注:本文中的crash函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论