// ================================================================================================ // FUNCTION : wiProcess_CreateMutex() // ------------------------------------------------------------------------------------------------ // Purpose : Create a mutext object to be used by the WaitForMutex and ReleaseMutex functions. // ================================================================================================ wiStatus wiProcess_CreateMutex(wiMutex_t *pMutex) { #ifdef WISE_BUILD_MULTITHREADED #if defined WISE_USE_PTHREADS int rc = pthread_mutex_init( pMutex, NULL ); if (rc != 0) { wiUtil_WriteLogFile("pthread_mutex_init returnd %d\n",rc); return STATUS(WI_ERROR); } #elif defined WIN32 *pMutex = CreateMutex(NULL, FALSE, NULL); if (*pMutex == NULL) { wiUtil_WriteLogFile("CreateMutex error: %d\n", GetLastError()); return STATUS(WI_ERROR); } #else return WI_ERROR_NO_MULTITHREAD_SUPPORT; #endif #else *pMutex = NULL; #endif return WI_SUCCESS; }
// ================================================================================================ // FUNCTION : wiPHY_SelectMethod // ------------------------------------------------------------------------------------------------ // Purpose : Selects the active method // Parameters: method -- Method to be selected // ================================================================================================ wiStatus wiPHY_SelectMethod(wiPhyMethod_t *method) { if (Verbose) wiPrintf(" wiPHY_SelectMethod(*)\n"); if (!Initialized) return WI_ERROR_MODULE_NOT_INITIALIZED; if (!method) return WI_ERROR_PARAMETER1; // ----------------------------------------------------------- // If the selected method is different than the current one... // ----------------------------------------------------------- if (method != ActiveMethod) { // Close the previous method // ------------------------- if (ActiveMethod) { STATUS(ActiveMethod->fn(WIPHY_CLOSE_ALL_THREADS, NULL)); STATUS(ActiveMethod->fn(WIPHY_POWER_OFF, NULL)); } // Open the new method // ------------------- ActiveMethod = method; STATUS( ActiveMethod->fn(WIPHY_POWER_ON, NULL)); } return WI_SUCCESS; }
static int owner_modify(void) { char *tmp; ne_propname pname = { "http://webdav.org/neon/litmus/", "random" }; ne_proppatch_operation pops[] = { { NULL, ne_propset, "foobar" }, { NULL } }; PRECOND(gotlock); ONV(ne_put(i_session, res, i_foo_fd), ("PUT on locked resource failed: %s", ne_get_error(i_session))); tmp = ne_concat(i_path, "whocares", NULL); ONN("COPY of locked resource", ne_copy(i_session, 1, NE_DEPTH_ZERO, res, tmp) == NE_ERROR); if (STATUS(201)) t_warning("COPY failed with %d not 201", GETSTATUS); ONN("DELETE of locked resource by owner", ne_delete(i_session, tmp) == NE_ERROR); if (STATUS(204)) t_warning("DELETE of %s failed with %d not 200", tmp, GETSTATUS); free(tmp); ONN("PROPPATCH of locked resource", ne_proppatch(i_session, res, pops) == NE_ERROR); if (STATUS(207)) t_warning("PROPPATCH failed with %d", GETSTATUS); return OK; }
void FORTE_BL_IX::executeEvent(int pa_nEIID){ switch(pa_nEIID){ case scm_nEventINITID: delete m_poGPIO; m_poGPIO = NULL; if(QI() == true){ char * pacBuffer = new char[PARAMS().length() + 3]; PARAMS().toString(pacBuffer, sizeof(char)*(PARAMS().length() + 3)); if (verifyInput(pacBuffer, PARAMS().length() + 2)){ STATUS() = "OK"; QO() = true; }else{ STATUS() = "Input PARAM error"; QO() = false; } delete[] pacBuffer; }else{ STATUS() = "INIT- OK"; QO() = false; } sendOutputEvent(scm_nEventINITOID); break; case scm_nEventREQID: if(m_poGPIO != NULL){ IN() = m_poGPIO->isHigh(); STATUS() = "OK"; }else{ IN() = false; STATUS() = "Not initialized"; } sendOutputEvent(scm_nEventCNFID); break; } }
void elvis_CB( Widget w , XtPointer cd , XtPointer cb ) { XmDrawingAreaCallbackStruct * cbs = (XmDrawingAreaCallbackStruct *) cb ; XExposeEvent * ev = (XExposeEvent *) cbs->event ; int start , end ; static int ncall = 0 ; if( cbs->reason != XmCR_EXPOSE || ev->count > 0 ) return ; STATUS("enter elvis_CB") ; if( need_plot ){ make_plot() ; set_X11_background( XtDisplay(w) , XtWindow(w) , 255,255,255 ) ; } XClearWindow( XtDisplay(w) , XtWindow(w) ) ; #if 1 if( ncall%2 == 0 ) set_active_memplot( "Elvis" ) ; else set_active_memplot( "Pelvis" ) ; ncall++ ; #endif STATUS("XClearWindow") ; start = end = 0 ; #if 0 memplot_to_X11( XtDisplay(w) , XtWindow(w) ) ; #else memplot_to_X11_free( XtDisplay(w) , XtWindow(w) ) ; #endif return ; }
void FORTE_Digital::executeEvent(int pa_nEIID){ QO() = QI(); STATUS() = 0; switch (pa_nEIID){ case scm_nEventINITID: if(true == QI()){ libcbc_init(); //TODO: only call once //initialises the CBC Library :) if(PORT() >= 8 && PORT() <= 15){ //digital PORTS!! m_nPort = PORT(); } } else{ QO() = false; STATUS() = 1; } sendOutputEvent(scm_nEventINITOID); break; case scm_nEventREQID: if(true == QI()){ STATUS() = digital(m_nPort); } sendOutputEvent(scm_nEventCNFID); break; } }
int main(void) { { TEST(); EXPECT(widthof(long long) >= widthof(long)); EXPECT(widthof(long) >= widthof(int)); EXPECT(widthof(int) >= widthof(short)); EXPECT(widthof(short) >= widthof(char)); EXPECT(widthof(double) >= widthof(float)); ADVISE(widthof(double) > widthof(float)); /* Not true on some targets. */ STATUS(); } { TEST(); EXPECT(widthof(int64_t) == 64); EXPECT(widthof(uint64_t) == 64); EXPECT(widthof(int32_t) == 32); EXPECT(widthof(uint32_t) == 32); EXPECT(widthof(int16_t) == 16); EXPECT(widthof(uint16_t) == 16); EXPECT(widthof(int8_t) == 8); EXPECT(widthof(uint8_t) == 8); EXPECT(widthof(intptr_t) == widthof(void *)); EXPECT(widthof(uintptr_t) == widthof(void *)); STATUS(); } EXIT(); }
static int configASIC(Ether* ether, int port, int xcvr) { int x; /* set Window 0 configuration registers */ COMMAND(port, SelectRegisterWindow, Wsetup); outs(port+ConfigControl, Ena); /* IRQ must be 3 on 3C589/3C562 */ outs(port + ResourceConfig, 0x3F00); x = ins(port+AddressConfig) & ~xcvrMask9; x |= (xcvr>>20)<<14; outs(port+AddressConfig, x); COMMAND(port, TxReset, 0); while(STATUS(port) & commandInProgress) ; COMMAND(port, RxReset, 0); while(STATUS(port) & commandInProgress) ; return etherelnk3reset(ether); }
static int copy_overwrite(void) { PRECOND(copy_ok); /* Do it again with Overwrite: F to check that fails. */ ONN("COPY on existing resource with Overwrite: F should fail (RFC2518:S8.8.4)", ne_copy(i_session, 0, NE_DEPTH_INFINITE, src, dest) != NE_ERROR); if (STATUS(412)) { t_warning("COPY-on-existing fails with 412"); } ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, dest), ("COPY-on-existing with 'Overwrite: T' should succeed (RFC2518:S8.8.4): %s", ne_get_error(i_session))); /* tricky one this, I didn't think it should work, but the spec * makes it look like it should. */ ONV(ne_copy(i_session, 1, NE_DEPTH_INFINITE, src, coll), ("COPY overwrites collection: %s", ne_get_error(i_session))); if (STATUS(204)) { t_warning("COPY to existing resource didn't give 204 (RFC2518:S8.8.5)"); } return OK; }
// ================================================================================================ // FUNCTION : wiProcess_Init() // ------------------------------------------------------------------------------------------------ // ================================================================================================ wiStatus wiProcess_Init(void) { if (ModuleIsInitialized) return STATUS(WI_ERROR_MODULE_ALREADY_INIT); #ifdef WISE_BUILD_MULTITHREADED #if defined WISE_USE_PTHREADS pthread_key_create(&wiProcessKey, NULL); #elif defined WIN32 { LPVOID lpvData = (LPVOID) LocalAlloc(LPTR, sizeof(int)); if (!lpvData) return STATUS(WI_ERROR_MEMORY_ALLOCATION); // Allocate thread-local memory used to store ThreadIndex dwTlsIndex = TlsAlloc(); TlsSetValue(dwTlsIndex, lpvData); (*(int *)lpvData) = 0; } #else XSTATUS( WI_ERROR ); #endif #endif ModuleIsInitialized = WI_TRUE; return WI_SUCCESS; }
// ================================================================================================ // FUNCTION : wiProcess_ReleaseMutex() // ------------------------------------------------------------------------------------------------ // Purpose : Release the mutex obtained with wiProcess_WaitForMutex() // ================================================================================================ wiStatus wiProcess_ReleaseMutex(wiMutex_t *pMutex) { #ifdef WISE_BUILD_MULTITHREADED if (ModuleIsInitialized) { #if defined WISE_USE_PTHREADS int rc = pthread_mutex_unlock( pMutex ); if (rc != 0) { wiUtil_WriteLogFile("pthread_mutex_unlock result = %d\n",rc); return WI_ERROR; } #elif defined WIN32 if (!ReleaseMutex( *((HANDLE *)pMutex) ) ) { wiUtil_WriteLogFile("ReleaseMutex failed\n"); return STATUS(WI_ERROR); } #else return STATUS(WI_ERROR_NO_MULTITHREAD_SUPPORT); #endif } #endif return WI_SUCCESS; }
// ================================================================================================ // FUNCTION : wiProcess_CloseMutex() // ------------------------------------------------------------------------------------------------ // Purpose : Close the Mutex object created with wiProcess_CreateMutex // ================================================================================================ wiStatus wiProcess_CloseMutex(wiMutex_t *pMutex) { #ifdef WISE_BUILD_MULTITHREADED #if defined WISE_USE_PTHREADS int rc = pthread_mutex_destroy( pMutex ); if (rc != 0) { wiUtil_WriteLogFile("pthread_mutex_destroy returnd %d\n",rc); return STATUS(WI_ERROR); } #elif defined WIN32 if (!CloseHandle(*pMutex)) { wiUtil_WriteLogFile("CloseHandle error: %d\n", GetLastError()); return STATUS(WI_ERROR); } #else return STATUS(WI_ERROR_NO_MULTITHREAD_SUPPORT); #endif #endif return WI_SUCCESS; }
/** * gst_data_queue_push_force: (skip) * @queue: a #GstDataQueue. * @item: a #GstDataQueueItem. * * Pushes a #GstDataQueueItem (or a structure that begins with the same fields) * on the @queue. It ignores if the @queue is full or not and forces the @item * to be pushed anyway. * MT safe. * * Note that this function has slightly different semantics than gst_pad_push() * and gst_pad_push_event(): this function only takes ownership of @item and * the #GstMiniObject contained in @item if the push was successful. If %FALSE * is returned, the caller is responsible for freeing @item and its contents. * * Returns: %TRUE if the @item was successfully pushed on the @queue. * * Since: 1.2 */ gboolean gst_data_queue_push_force (GstDataQueue * queue, GstDataQueueItem * item) { GstDataQueuePrivate *priv = queue->priv; g_return_val_if_fail (GST_IS_DATA_QUEUE (queue), FALSE); g_return_val_if_fail (item != NULL, FALSE); GST_DATA_QUEUE_MUTEX_LOCK_CHECK (queue, flushing); STATUS (queue, "before pushing"); gst_data_queue_push_force_unlocked (queue, item); STATUS (queue, "after pushing"); if (priv->waiting_add) g_cond_signal (&priv->item_add); GST_DATA_QUEUE_MUTEX_UNLOCK (queue); return TRUE; /* ERRORS */ flushing: { GST_DEBUG ("queue:%p, we are flushing", queue); GST_DATA_QUEUE_MUTEX_UNLOCK (queue); return FALSE; } }
// ================================================================================================ // FUNCTION : wiProcess_InitializeThreadIndex() // ------------------------------------------------------------------------------------------------ // ================================================================================================ wiStatus wiProcess_InitializeThreadIndex(unsigned ThreadIndex) { if (InvalidRange(ThreadIndex, 1, WISE_MAX_THREADINDEX)) return WI_ERROR_PARAMETER1; #if defined WISE_USE_PTHREADS { void *lpvData = wiMalloc(sizeof(int)); if (!lpvData) return STATUS(WI_ERROR_MEMORY_ALLOCATION); pthread_setspecific(wiProcessKey, lpvData); (*(unsigned int *)lpvData) = ThreadIndex; return WI_SUCCESS; } #elif defined WIN32 { LPVOID lpvData; lpvData = (LPVOID) LocalAlloc(LPTR, sizeof(int)); TlsSetValue(dwTlsIndex, lpvData); (*(unsigned int *)lpvData) = ThreadIndex; return WI_SUCCESS; } #else return STATUS(WI_ERROR_NO_MULTITHREAD_SUPPORT); #endif }
// ================================================================================================ // FUNCTION : wiMemory_traceCalloc() // ------------------------------------------------------------------------------------------------ // ================================================================================================ void * wiMemory_traceCalloc(size_t nitems, size_t size) { void *ptr = NULL; STATUS(wiProcess_WaitForMutex(&TraceMemoryMutex)); STATUS(wiMemory_AddTraceBlock(nitems*size, &ptr)); STATUS(wiProcess_ReleaseMutex(&TraceMemoryMutex)); return ptr; }
static void gst_data_queue_locked_flush (GstDataQueue * queue) { STATUS (queue, "before flushing"); gst_data_queue_cleanup (queue); STATUS (queue, "after flushing"); /* we deleted something... */ g_cond_signal (queue->item_del); }
void showprocs(struct myproc **procs, struct procstat *pst) { int y = -pos_top + TOP_OFFSET - 1; struct myproc *topproc; // this f***s up everything. why? /* for(topproc = gui_proc_first(procs)->child_first; topproc; topproc = topproc->child_next) */ topproc = gui_proc_first(procs); showproc(topproc, &y, 0); if(++y < LINES){ move(y, 0); clrtobot(); } if(search){ const int red = !search_proc && *search_str;; if(red) attron(COLOR_PAIR(1 + COLOR_RED)); mvprintw(0, 0, "%d %c%s", search_offset, "/?"[search_pid], search_str); if(red) attroff(COLOR_PAIR(1 + COLOR_RED)); clrtoeol(); if(search_proc){ int ty; if(search_proc_to_idx(&ty, procs)){ pos_top = ty - LINES / 2; if(pos_top < 0) pos_top = 0; } } }else{ int y; time_t now; time(&now); STATUS(0, 0, "%d processes, %d running, %d owned, %d zombies, load averages: %.2f, %.2f, %.2f, uptime: %s", pst->count, pst->running, pst->owned, pst->zombies, pst->loadavg[0], pst->loadavg[1], pst->loadavg[2], uptime_from_boottime(pst->boottime.tv_sec)); // Mem stuf STATUS(1, 0, "Mem: %s", format_memory(pst->memory)); // CPU % STATUS(2,0, "CPU: %s", format_cpu_pct(pst->cpu_pct)); clrtoeol(); y = 3 + pos_y - pos_top; mvchgat(y, 0, 47, A_UNDERLINE, 0, NULL); move(y, 47); } }
/* Transmits repeated start condition. * * Return: 0 Succeeded * >0 Failed, see handle_error() for relavant error codes */ static uint8_t twi_start_r(void) { /* Transmit repeated start condition. */ TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); while(!(TWCR & (1 << TWINT))); if(STATUS() != 0x10) return handle_error(STATUS()); return 0; }
static inline void gst_data_queue_locked_flush (GstDataQueue * queue) { STATUS (queue, "before flushing"); gst_data_queue_cleanup (queue); STATUS (queue, "after flushing"); /* we deleted something... */ if (queue->abidata.ABI.waiting_del) g_cond_signal (queue->item_del); }
static int mpu401_intr(struct mpu401 *m) { #define MPU_INTR_BUF 16 MIDI_TYPE b[MPU_INTR_BUF]; int i; int s; /* printf("mpu401_intr\n"); */ #define RXRDY(m) ( (STATUS(m) & MPU_INPUTBUSY) == 0) #define TXRDY(m) ( (STATUS(m) & MPU_OUTPUTBUSY) == 0) #if 0 #define D(x,l) printf("mpu401_intr %d %x %s %s\n",l, x, x&MPU_INPUTBUSY?"RX":"", x&MPU_OUTPUTBUSY?"TX":"") #else #define D(x,l) #endif i = 0; s = STATUS(m); D(s, 1); while ((s & MPU_INPUTBUSY) == 0 && i < MPU_INTR_BUF) { b[i] = READ(m); /* printf("mpu401_intr in i %d d %d\n", i, b[i]); */ i++; s = STATUS(m); } if (i) midi_in(m->mid, b, i); i = 0; while (!(s & MPU_OUTPUTBUSY) && i < MPU_INTR_BUF) { if (midi_out(m->mid, b, 1)) { /* printf("mpu401_intr out i %d d %d\n", i, b[0]); */ WRITE(m, *b); } else { /* printf("mpu401_intr write: no output\n"); */ return 0; } i++; /* DELAY(100); */ s = STATUS(m); } if ((m->flags & M_TXEN) && (m->si)) { callout_reset(&m->timer, 1, mpu401_timeout, m); } return (m->flags & M_TXEN) == M_TXEN; }
/** * gst_data_queue_push: * @queue: a #GstDataQueue. * @item: a #GstDataQueueItem. * * Pushes a #GstDataQueueItem (or a structure that begins with the same fields) * on the @queue. If the @queue is full, the call will block until space is * available, OR the @queue is set to flushing state. * MT safe. * * Note that this function has slightly different semantics than gst_pad_push() * and gst_pad_push_event(): this function only takes ownership of @item and * the #GstMiniObject contained in @item if the push was successful. If FALSE * is returned, the caller is responsible for freeing @item and its contents. * * Returns: #TRUE if the @item was successfully pushed on the @queue. * * Since: 1.2.0 */ gboolean gst_data_queue_push (GstDataQueue * queue, GstDataQueueItem * item) { GstDataQueuePrivate *priv = queue->priv; g_return_val_if_fail (GST_IS_DATA_QUEUE (queue), FALSE); g_return_val_if_fail (item != NULL, FALSE); GST_DATA_QUEUE_MUTEX_LOCK_CHECK (queue, flushing); STATUS (queue, "before pushing"); /* We ALWAYS need to check for queue fillness */ if (gst_data_queue_locked_is_full (queue)) { GST_DATA_QUEUE_MUTEX_UNLOCK (queue); if (G_LIKELY (priv->fullcallback)) priv->fullcallback (queue, priv->checkdata); else g_signal_emit (queue, gst_data_queue_signals[SIGNAL_FULL], 0); GST_DATA_QUEUE_MUTEX_LOCK_CHECK (queue, flushing); /* signal might have removed some items */ while (gst_data_queue_locked_is_full (queue)) { priv->waiting_del = TRUE; g_cond_wait (&priv->item_del, &priv->qlock); priv->waiting_del = FALSE; if (priv->flushing) goto flushing; } } gst_queue_array_push_tail (priv->queue, item); if (item->visible) priv->cur_level.visible++; priv->cur_level.bytes += item->size; priv->cur_level.time += item->duration; STATUS (queue, "after pushing"); if (priv->waiting_add) g_cond_signal (&priv->item_add); GST_DATA_QUEUE_MUTEX_UNLOCK (queue); return TRUE; /* ERRORS */ flushing: { GST_DEBUG ("queue:%p, we are flushing", queue); GST_DATA_QUEUE_MUTEX_UNLOCK (queue); return FALSE; } }
/* Receives data from slave. Returns NACK to stop transfer. * * Input: data Location to store read data * Return: 0 Succeeded * >0 Failed, see handle_error() for relavant error codes */ static uint8_t twi_read_nack(uint8_t *data) { TWCR = (1 << TWINT) | (1 << TWEN); while(!(TWCR & (1 << TWINT))); if(STATUS() != 0x58) return handle_error(STATUS()); (*data) = TWDR; return 0; }
/* Transmits data to slave. * * Input: data Data to be transfered * Return: 0 Succeeded * >0 Failed, see handle_error() for relavant error codes */ static uint8_t twi_write(uint8_t data) { /* Write data to slave. */ TWDR = data; TWCR = (1 << TWINT) | (1 << TWEN); while(!(TWCR & (1 << TWINT))); if(STATUS() != 0x28) return handle_error(STATUS()); return 0; }
/* Transmits slave address and read bit condition. * * Input: address Slave address * Return: 0 Succeeded * >0 Failed, see handle_error() for relavant error codes */ static uint8_t twi_sla_r(uint8_t address) { /* Transmit slave address and read bit. */ TWDR = (address << 1) | 0x01; TWCR = (1 << TWINT) | (1 << TWEN); while(!(TWCR & (1 << TWINT))); if(STATUS() != 0x40) return handle_error(STATUS()); return 0; }
/** * gst_data_queue_pop: * @queue: a #GstDataQueue. * @item: pointer to store the returned #GstDataQueueItem. * * Retrieves the first @item available on the @queue. If the queue is currently * empty, the call will block until at least one item is available, OR the * @queue is set to the flushing state. * MT safe. * * Returns: #TRUE if an @item was successfully retrieved from the @queue. * * Since: 1.2.0 */ gboolean gst_data_queue_pop (GstDataQueue * queue, GstDataQueueItem ** item) { GstDataQueuePrivate *priv = queue->priv; g_return_val_if_fail (GST_IS_DATA_QUEUE (queue), FALSE); g_return_val_if_fail (item != NULL, FALSE); GST_DATA_QUEUE_MUTEX_LOCK_CHECK (queue, flushing); STATUS (queue, "before popping"); if (gst_data_queue_locked_is_empty (queue)) { GST_DATA_QUEUE_MUTEX_UNLOCK (queue); if (G_LIKELY (priv->emptycallback)) priv->emptycallback (queue, priv->checkdata); else g_signal_emit (queue, gst_data_queue_signals[SIGNAL_EMPTY], 0); GST_DATA_QUEUE_MUTEX_LOCK_CHECK (queue, flushing); while (gst_data_queue_locked_is_empty (queue)) { priv->waiting_add = TRUE; g_cond_wait (&priv->item_add, &priv->qlock); priv->waiting_add = FALSE; if (priv->flushing) goto flushing; } } /* Get the item from the GQueue */ *item = gst_queue_array_pop_head (priv->queue); /* update current level counter */ if ((*item)->visible) priv->cur_level.visible--; priv->cur_level.bytes -= (*item)->size; priv->cur_level.time -= (*item)->duration; STATUS (queue, "after popping"); if (priv->waiting_del) g_cond_signal (&priv->item_del); GST_DATA_QUEUE_MUTEX_UNLOCK (queue); return TRUE; /* ERRORS */ flushing: { GST_DEBUG ("queue:%p, we are flushing", queue); GST_DATA_QUEUE_MUTEX_UNLOCK (queue); return FALSE; } }
static inline void gst_data_queue_locked_flush (GstDataQueue * queue) { GstDataQueuePrivate *priv = queue->priv; STATUS (queue, "before flushing"); gst_data_queue_cleanup (queue); STATUS (queue, "after flushing"); /* we deleted something... */ if (priv->waiting_del) g_cond_signal (&priv->item_del); }
/* Transmits start condition. * * Return: 0 Succeeded * >0 Failed, see handle_error() for relavant error codes */ static uint8_t twi_start(void) { /* Transmit start condition. */ TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN); /* Wait for transmission to complete. */ while(!(TWCR & (1 << TWINT))); /* If status register indicates an error, handle it and return the appropriate error code. */ if(STATUS() != 0x08) return handle_error(STATUS()); return 0; }
void GEN_CSV_WRITER::closeCSVFile(){ QO() = false; if(0 != m_pstCSVFile){ if(0 == fclose(m_pstCSVFile)){ STATUS() = "OK"; } else{ STATUS() = strerror(errno); } m_pstCSVFile = 0; } }
struct prdata pr_refine(Crystal *cr, const RefList *full, PartialityModel pmodel) { double dev; int i; const int verbose = 0; struct prdata prdata; double mean_p_change = 0.0; prdata.refined = 0; prdata.n_filtered = 0; /* Don't refine crystal if scaling was bad */ if ( crystal_get_user_flag(cr) != 0 ) return prdata; if ( verbose ) { dev = guide_dev(cr, full); STATUS("\n"); /* Deal with progress bar */ STATUS("Before iteration: dev = %10.5e\n", dev); } i = 0; do { double asx, asy, asz; double bsx, bsy, bsz; double csx, csy, csz; double dev; cell_get_reciprocal(crystal_get_cell(cr), &asx, &asy, &asz, &bsx, &bsy, &bsz, &csx, &csy, &csz); pr_iterate(cr, full, pmodel, &prdata.n_filtered); update_partialities(cr, pmodel); if ( verbose ) { dev = guide_dev(cr, full); STATUS("PR Iteration %2i: dev = %10.5e\n", i+1, dev); } i++; } while ( (mean_p_change > 0.01) && (i < MAX_CYCLES) ); if ( crystal_get_user_flag(cr) == 0 ) { prdata.refined = 1; } return prdata; }
static int aha1542_test_port(struct Scsi_Host *sh) { u8 inquiry_result[4]; int i; /* Quick and dirty test for presence of the card. */ if (inb(STATUS(sh->io_port)) == 0xff) return 0; /* Reset the adapter. I ought to make a hard reset, but it's not really necessary */ /* In case some other card was probing here, reset interrupts */ aha1542_intr_reset(sh->io_port); /* reset interrupts, so they don't block */ outb(SRST | IRST /*|SCRST */ , CONTROL(sh->io_port)); mdelay(20); /* Wait a little bit for things to settle down. */ /* Expect INIT and IDLE, any of the others are bad */ if (!wait_mask(STATUS(sh->io_port), STATMASK, INIT | IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) return 0; /* Shouldn't have generated any interrupts during reset */ if (inb(INTRFLAGS(sh->io_port)) & INTRMASK) return 0; /* Perform a host adapter inquiry instead so we do not need to set up the mailboxes ahead of time */ aha1542_outb(sh->io_port, CMD_INQUIRY); for (i = 0; i < 4; i++) { if (!wait_mask(STATUS(sh->io_port), DF, DF, 0, 0)) return 0; inquiry_result[i] = inb(DATA(sh->io_port)); } /* Reading port should reset DF */ if (inb(STATUS(sh->io_port)) & DF) return 0; /* When HACC, command is completed, and we're though testing */ if (!wait_mask(INTRFLAGS(sh->io_port), HACC, HACC, 0, 0)) return 0; /* Clear interrupts */ outb(IRST, CONTROL(sh->io_port)); return 1; }