int main(void) { sigset_t pendingset; struct sigaction act; act.sa_handler = myhandler; act.sa_flags = 0; sigemptyset(&act.sa_mask); int rc; rc = sigaction(SIGCHLD, &act, 0); if (rc) { ERR_MSG("sigaction()", rc); return PTS_UNRESOLVED; } if (sigset(SIGCHLD, SIG_HOLD) == SIG_ERR) { perror("Unexpected error while using sigset()"); return PTS_UNRESOLVED; } raise(SIGCHLD); rc = sigpending(&pendingset); if (rc) { ERR_MSG("sigpending()", rc); return PTS_UNRESOLVED; } if (sigismember(&pendingset, SIGCHLD) != 1) { printf("Test FAILED: Signal SIGCHLD wasn't hold.\n"); return PTS_FAIL; } printf("Test PASSED\n"); return PTS_PASS; }
// ************************************************************************ // Gsensor Code -- BMA150 // ************************************************************************ static int bma150_read_reg(struct i2c_client *clnt, unsigned char reg, unsigned char *data, unsigned char count) { unsigned char tmp[10]; if (10 < count) return -1; tmp[0] = reg; if (bma150_i2c_tx(tmp, 1) < 0) { ERR_MSG("Set REGISTER address error"); return -EIO; } if (bma150_i2c_rx(tmp, count) < 0) { ERR_MSG("Read REGISTER content error"); return -EIO; } strncpy(data, tmp, count); return 0; }
void JB2Dict::JB2Codec::Encode::code(const GP<JB2Dict> &gjim) { if(!gjim) { G_THROW( ERR_MSG("JB2Image.bad_number") ); } JB2Dict &jim=*gjim; // ------------------------- // THIS IS THE ENCODING PART // ------------------------- int firstshape = jim.get_inherited_shape_count(); int nshape = jim.get_shape_count(); init_library(jim); // Code headers. int rectype = REQUIRED_DICT_OR_RESET; if (jim.get_inherited_shape_count() > 0) code_record(rectype, gjim, 0); rectype = START_OF_DATA; code_record(rectype, gjim, 0); // Code Comment. rectype = PRESERVED_COMMENT; if (!! jim.comment) code_record(rectype, gjim, 0); // Encode every shape int shapeno; DJVU_PROGRESS_TASK(jb2code,"jb2 encode", nshape-firstshape); for (shapeno=firstshape; shapeno<nshape; shapeno++) { DJVU_PROGRESS_RUN(jb2code, (shapeno-firstshape)|0xff); // Code shape JB2Shape &jshp = jim.get_shape(shapeno); rectype=(jshp.parent >= 0) ?MATCHED_REFINE_LIBRARY_ONLY:NEW_MARK_LIBRARY_ONLY; code_record(rectype, gjim, &jshp); add_library(shapeno, jshp); // Check numcoder status if (cur_ncell > CELLCHUNK) { rectype = REQUIRED_DICT_OR_RESET; code_record(rectype, 0, 0); } } // Code end of data record rectype = END_OF_DATA; code_record(rectype, gjim, 0); gzp=0; }
void formRadvd(request *wp, char *path, char *query) { int pid; char tmpBuf[256]; char *submitUrl; char* value; radvdCfgParam_t radvdCfgParam; /*Get parameters*/ getRadvdInfo(&radvdCfgParam); /*Set parameters*/ value=req_get_cstream_var(wp,"submit",""); if(0 == strcmp(value,"Save")) { set_RadvdParam(wp, path, query,&radvdCfgParam); } /*Set to pMIb*/ apmib_set(MIB_IPV6_RADVD_PARAM,&radvdCfgParam); /*Update it to flash*/ setOk_radvd: apmib_update(CURRENT_SETTING); /*create the config file*/ create_RadvdCfgFile(&radvdCfgParam); /*start the Daemon*/ #ifndef NO_ACTION pid = fork(); if (pid) { waitpid(pid, NULL, 0); } else if (pid == 0) { snprintf(tmpBuf, 100, "%s/%s", _CONFIG_SCRIPT_PATH, _IPV6_RADVD_SCRIPT_PROG); execl( tmpBuf, _IPV6_RADVD_SCRIPT_PROG, NULL); exit(1); } #endif submitUrl = req_get_cstream_var(wp, "submit-url", ""); // hidden page OK_MSG(submitUrl); return; setErr_radvd: ERR_MSG(tmpBuf); return; }
static int do_transition(struct state_t* state,void* input) { struct transition_t* p; p = state->trans; while( p ){ if( p->event.happend(input) ){ state->owner->cur_state = p->next_state; state->prev = state; DEBUG_MSG("will transition to another state\n"); return 0; } p = p->_next; } ERR_MSG("no target to transition to\n"); return -1; }
const JB2Shape & JB2Dict::get_shape(const int shapeno) const { const JB2Shape *retval; if(shapeno >= inherited_shapes) { retval=&shapes[shapeno - inherited_shapes]; }else if(inherited_dict) { retval=&(inherited_dict->get_shape(shapeno)); }else { G_THROW( ERR_MSG("JB2Image.bad_number") ); } return *retval; }
void GMonitor::broadcast() { if (ok) { DWORD self = GetCurrentThreadId(); if (count>0 || self!=locker) G_THROW( ERR_MSG("GThreads.not_acq_broad") ); for (struct thr_waiting *w=head; w; w=w->next) if (w->waiting) { SetEvent(w->gwait); w->waiting = FALSE; } } }
void GMonitor::leave() { static pthread_t pthread_null; pthread_t self = pthread_self(); if (ok && (count>0 || !pthread_equal(locker, self))) G_THROW( ERR_MSG("GThreads.not_acq_broad") ); count += 1; if (count > 0) { count = 1; locker = pthread_null; if (ok) pthread_mutex_unlock(&mutex); } }
int fsm_release(struct state_machine_t** fsm) { if( !fsm || !(*fsm) ){ return 0; } if( (*fsm)->isrunning ){ ERR_MSG("the state machine is still running\n"); return -1; } free(*fsm); *fsm = NULL; return 0; }
/** * Test 1 - Installation d'un driver * Description * Installer le driver alors qu'il n'est pas installé * Resultat attendu * La valeur de retour doit être positive, et correspond au numéro du driver. Il doit être possible * de le retrouver en utilisant la fonction iosDrvShow. **/ int test_1() { int success = 0; if(pe_driverInstall(10) >= 0) { success++; iosDrvShow(); getchar(); // Call this to clean the system. } else { ERR_MSG(1); } pe_driverUninstall(); return success; }
int NtxHwCfg_Save(const char *szFileName,int iIsSeek) { int iRet; char *pszFileName = (char *)szFileName; if(0==szFileName) { #ifdef _X86_//[ return 0; #else //][!_X86_ pszFileName = "/dev/mmcblk0"; iIsSeek = 1; #endif //]_X86_ } { int iFd = -1; ssize_t tChk; iFd = my_open(pszFileName,O_RDWR|O_TRUNC|O_CREAT); if(iFd>=0) { if(iIsSeek) { iIsSeek = SYSHWCONFIG_SEEKSIZE; } else { iIsSeek = 0; } my_lseek(iFd,(unsigned int)iIsSeek,SEEK_SET); tChk = my_write(iFd,(unsigned char *)_gptNtxHwCfg,sizeof(_gtNtxHwCfg)); if((int)tChk==sizeof(_gtNtxHwCfg)) { iRet = HWCFG_RET_SUCCESS; } else { iRet = HWCFG_RET_FILEWRITEFAIL; } my_close(iFd);iFd=-1; } else { ERR_MSG("%s : File \"%s\" open fail !\n",__FUNCTION__,pszFileName); iRet = HWCFG_RET_FILEOPENFAIL; } } return iRet; }
void DjVuTXT::encode(const GP<ByteStream> &gbs) const { ByteStream &bs=*gbs; if (! textUTF8 ) G_THROW( ERR_MSG("DjVuText.no_text") ); // Encode text int textsize = textUTF8.length(); bs.write24( textsize ); bs.writall( (void*)(const char*)textUTF8, textsize ); // Encode zones if (has_valid_zones()) { bs.write8(Zone::version); page_zone.encode(gbs); } }
void GMonitor::signal() { if (ok) { DWORD self = GetCurrentThreadId(); if (count>0 || self!=locker) G_THROW( ERR_MSG("GThreads.not_acq_signal") ); for (struct thr_waiting *w=head; w; w=w->next) if (w->waiting) { SetEvent(w->gwait); w->waiting = FALSE; break; // Only one thread is allowed to run! } } }
void GIFFManager::load_file(GP<ByteStream> str) { DEBUG_MSG("GIFFManager::load_file(): Loading IFF file.\n"); DEBUG_MAKE_INDENT(3); GP<IFFByteStream> gistr=IFFByteStream::create(str); IFFByteStream &istr=*gistr; GUTF8String chunk_id; if (istr.get_chunk(chunk_id)) { if (chunk_id.substr(0,5) != "FORM:") G_THROW( ERR_MSG("GIFFManager.cant_find2") ); set_name(chunk_id); load_chunk(istr, top_level); istr.close_chunk(); } }
void GBitmap::compress() { if (grays > 2) G_THROW( ERR_MSG("GBitmap.cant_compress") ); GMonitorLock lock(monitor()); if (bytes) { grle.resize(0); grlerows.resize(0); rlelength = encode(rle,grle); if (rlelength) { gbytes_data.resize(0); bytes = 0; } } }
DjVuProgressTask::~DjVuProgressTask() { if (data && data->callback) { if (data->head != this) G_THROW( ERR_MSG("DjVuGlobal.not_compatible") ); data->head = parent; if (!parent) { unsigned long curdate = GOS::ticks(); if((*(data->callback))(data->gtask?data->gtask:"",curdate-startdate, curdate-startdate)) { G_THROW("INTERRUPT"); } } } delete (GP<Data> *)gdata; }
int fsm_init(struct state_machine_t** fsm) { if( !fsm ){ ERR_MSG("invalid argument\n"); return -1; } *fsm = (struct state_machine_t*)calloc(1,sizeof(struct state_machine_t)); if( *fsm == NULL ){ STD_ERR_MSG("Cant allocate memory"); return -1; } (*fsm)->default_entered = default_entered_cb; (*fsm)->default_exited = default_exited_cb; return 0; }
static unsigned long convertToColor(const GUTF8String &s) { unsigned long retval=0; if(s.length()) { int endpos; if(s[0] == '#') { retval=s.substr(1,-1).toULong(0,endpos,16); } if(endpos < 0) { G_THROW( (ERR_MSG("XMLAnno.bad_color") "\t")+s ); } } return retval; }
int GIFFChunk::get_chunks_number(const GUTF8String &name) { DEBUG_MSG("GIFFChunk::get_chunks_number(): Returning number of chunks '" << name << "' in '" << get_name() << "'\n"); DEBUG_MAKE_INDENT(3); if (name.contains("[]")>=0) G_THROW( ERR_MSG("GIFFManager.no_brackets") ); int number; GUTF8String short_name=decode_name(name,number); int num=0; for(GPosition pos=chunks;pos;++pos) num+=(chunks[pos]->get_name()==short_name); return num; }
NTX_HWCONFIG *NtxHwCfg_Load(const char *szFileName,int iIsSeek) { NTX_HWCONFIG *ptRet = 0; char *pszFileName = (char *)szFileName; if(0==szFileName) { #ifdef _X86_//[ return 0; #else //][!_X86_ pszFileName = "/dev/mmcblk0"; iIsSeek = 1; #endif //]_X86_ } { int iFd = -1; ssize_t tChk; iFd = my_open(pszFileName,O_RDONLY); if(iFd>=0) { if(iIsSeek) { iIsSeek = SYSHWCONFIG_SEEKSIZE; } else { iIsSeek = 0; } my_lseek(iFd,(unsigned int)iIsSeek,SEEK_SET); tChk = my_read(iFd,(unsigned char *)_gptNtxHwCfg,sizeof(_gtNtxHwCfg)); if((int)tChk==sizeof(_gtNtxHwCfg)) { if(NtxHwCfg_ChkCfgHeaderEx(_gptNtxHwCfg,1)>=0) { ptRet = _gptNtxHwCfg; } } my_close(iFd);iFd=-1; } else { ERR_MSG("%s : File \"%s\" open fail !\n",__FUNCTION__,pszFileName); } } return ptRet; }
static void bma150_early_suspend_func(struct early_suspend * h) { //Div6D1-OH-ECompass-EarlySuspend_To_Suspend-00*{ #ifndef USE_SUSPEND INF_MSG("START"); if (atomic_read(&dev_opened) > 0) { if (enter_mode(BMA150_MODE_SLEEP)) { ERR_MSG("Gsensor Enter sleep mode fail"); } } atomic_inc(&is_early_suspend); #else #endif //Div6D1-OH-ECompass-EarlySuspend_To_Suspend-00*} }
bool LimitSwitch_Pressed(uint8_t sw) { uint8_t val; switch(sw) { case LimitSwitch_XMin: val = GPIO_ReadInputDataBit(X_Axis_Min_Port, X_Axis_Min_Pin); break; case LimitSwitch_YMin: val = GPIO_ReadInputDataBit(Y_Axis_Min_Port, Y_Axis_Min_Pin); break; case LimitSwitch_ZMin: val = GPIO_ReadInputDataBit(Z_Axis_Min_Port, Z_Axis_Min_Pin); break; default: ERR_MSG("Invalid switch number %d", sw); return false; } return !val; }
GP<GBitmap> JB2Image::get_bitmap(int subsample, int align) const { if (width==0 || height==0) G_THROW( ERR_MSG("JB2Image.cant_create") ); int swidth = (width + subsample - 1) / subsample; int sheight = (height + subsample - 1) / subsample; int border = ((swidth + align - 1) & ~(align - 1)) - swidth; GP<GBitmap> bm = GBitmap::create(sheight, swidth, border); bm->set_grays(1+subsample*subsample); for (int blitno = 0; blitno < get_blit_count(); blitno++) { const JB2Blit *pblit = get_blit(blitno); const JB2Shape &pshape = get_shape(pblit->shapeno); if (pshape.bits) bm->blit(pshape.bits, pblit->left, pblit->bottom, subsample); } return bm; }
void MapArea::initBorder(void) // Regenerates the boundary and refreshes border on the screen { switch(getBorderType()) { case GMapArea::NO_BORDER: case GMapArea::XOR_BORDER: case GMapArea::SOLID_BORDER: ma_generatePieces(); repaintBorder(); break; case GMapArea::SHADOW_IN_BORDER: for(int i=0;i<gmap_area->border_width;i++) shadow_pattern[i]=-(100-100*(i+1)/gmap_area->border_width); ma_generatePieces(); repaintBorder(); break; case GMapArea::SHADOW_OUT_BORDER: for(int i=0;i<gmap_area->border_width;i++) shadow_pattern[i]=100-100*(i+1)/gmap_area->border_width; ma_generatePieces(); repaintBorder(); break; case GMapArea::SHADOW_EIN_BORDER: for(int i=0;i<gmap_area->border_width;i++) shadow_pattern[i]=0; shadow_pattern[0]=-100; shadow_pattern[gmap_area->border_width-1]=100; ma_generatePieces(); repaintBorder(); break; case GMapArea::SHADOW_EOUT_BORDER: for(int i=0;i<gmap_area->border_width;i++) shadow_pattern[i]=0; shadow_pattern[0]=100; shadow_pattern[gmap_area->border_width-1]=-100; ma_generatePieces(); repaintBorder(); break; default: G_THROW(ERR_MSG("MapArea.unknown_border_type")); } }
void GMonitor::wait() { // Check pthread_t self = pthread_self(); if (count>0 || !pthread_equal(locker, self)) G_THROW( ERR_MSG("GThreads.not_acq_wait") ); // Wait if (ok) { // Release int sav_count = count; count = 1; // Wait pthread_cond_wait(&cond, &mutex); // Re-acquire count = sav_count; locker = self; } }
static void bma150_late_resume_func(struct early_suspend *h) { //Div6D1-OH-ECompass-EarlySuspend_To_Suspend-00*{ #ifndef USE_SUSPEND INF_MSG("START"); if (atomic_read(&dev_opened) > 0) { if (enter_mode(BMA150_MODE_NORMAL)) { ERR_MSG("Gsensor Enter sleep mode fail"); } } atomic_dec(&is_early_suspend); atomic_set(&i2c_failed_counter, 0); //reset failed //owenhuang #else atomic_set(&i2c_failed_counter, 0); //reset failed //owenhuang #endif //Div6D1-OH-ECompass-EarlySuspend_To_Suspend-00*} }
DJVUAPI void * _djvu_new(size_t siz) { void *ptr; #ifndef UNIX if(_djvu_new_handler) { #endif if(!(ptr=(*_djvu_new_handler)(siz?siz:1))) { G_THROW( ERR_MSG("DjVuGlobalMemory.exhausted") ); } #ifndef UNIX }else { ptr=::operator new(siz?siz:1); } #endif return ptr; }
static int bma150_write_reg(struct i2c_client *clnt, unsigned char reg, unsigned char *data, unsigned char count) { unsigned char tmp[2]; while(count) { tmp[0] = reg++; tmp[1] = *(data++); if (bma150_i2c_tx(tmp, 2) < 0) { ERR_MSG("ERROR"); return -EIO; } count--; } return 0; }
void * _djvu_newArray(size_t siz) { void *ptr; #ifndef UNIX if(newArray_handler) { #endif if(!(ptr=(*newArray_handler)(siz?siz:1))) { G_THROW( ERR_MSG("DjVuGlobalMemory.exhausted") ); } #ifndef UNIX }else { ptr=::new unsigned char[siz?siz:1]; } #endif return ptr; }
void I2C_Lib_Init() { static bool initialized = false; if(initialized) return; CPAL_I2C_StructInit(&I2C_HOST_DEV); // I2C_HOST_DEV.CPAL_Dev is already initialized in definition I2C_HOST_DEV.CPAL_ProgModel = CPAL_PROGMODEL_INTERRUPT; // I2C_HOST_DEV.pCPAL_I2C_Struct->I2C_ClockSpeed = 350000; // I2C_HOST_DEV.pCPAL_I2C_Struct->I2C_OwnAddress1 = 0xAA; uint32_t ret = CPAL_I2C_Init(&I2C_HOST_DEV); if(ret != CPAL_PASS){ ERR_MSG("CPAL_I2C_Init Failed"); return; } initialized = true; }