void * skub_alloc_sz(int size) { /* Find a free block */ int i; void * ret = NULL; if (size > skub_pools_var[ARRAY_NELEMS(skub_pools_var) - 1].sz) { outputf("alloc %d: too big for any pool"); return NULL; } for (i = 0; i < ARRAY_NELEMS(skub_pools_var); i++) { if (skub_pools_var[i].sz < size) continue; ret = skub_alloc_from_pool(&skub_pools_var[i]); if (ret) break; outputf("alloc %d: oom in %d, trying larger...", size, skub_pools_var[i].sz); } #ifdef SKUB_SPEW outputf("alloc sz %d -> used block %d @ %p", size, i, ret); #endif return ret; }
/* dac_rate_queue * * Queue up a point rate change. */ int dac_rate_queue(int points_per_second) { if (dac_control.state == DAC_IDLE) { outputf("drq rejected: idle"); return -1; } int produce = dac_rate_produce; int fullness = produce - dac_rate_consume; if (fullness < 0) fullness += DAC_RATE_BUFFER_SIZE; /* The buffer can only ever become one word short of full - * produce = consume means empty. */ if (fullness >= DAC_RATE_BUFFER_SIZE - 1) { outputf("drq rejected: full"); return -1; } dac_rate_buffer[produce] = points_per_second; dac_rate_produce = (produce + 1) % DAC_RATE_BUFFER_SIZE; return 0; }
static void update_server_info() { if (fb != NULL) { outputf("RFB: setting fmt %d", fb->curmode.format); server_info.fb_width = htons(fb->curmode.xres); server_info.fb_height = htons(fb->curmode.yres); switch (fb->curmode.format) { case FB_RGB888: server_info.fmt.bpp = 32; server_info.fmt.depth = 24; server_info.fmt.big_endian = 0; server_info.fmt.true_color = 1; server_info.fmt.red_max = htons(255); server_info.fmt.green_max = htons(255); server_info.fmt.blue_max = htons(255); server_info.fmt.red_shift = 0; server_info.fmt.green_shift = 8; server_info.fmt.blue_shift = 16; break; default: outputf("RFB: unknown fb fmt %d", fb->curmode.format); break; } } else { outputf("RFB: fb null"); } }
/* send_resp * * Send a response back to the user. * * If the send is successful, this will return its 'length' parameter. If * not, it will close the connection, and then return -1. This is intended * for use by recv_fsm, which can tail-call send_resp with the number of * bytes that were consumed from the input. If the send succeeds, then that * value is returned; otherwise, the error is propagated up. */ static int RV send_resp(struct tcp_pcb *pcb, char resp, char cmd, int len) { struct dac_response response; response.response = resp; response.command = cmd; fill_status(&response.dac_status); err_t err = tcp_write(pcb, &response, sizeof(response), TCP_WRITE_FLAG_COPY); if (err == ERR_MEM) { if (ps_defer_ack(cmd, resp) < 0) { outputf("!!! DROPPING ACK !!!"); } else { outputf("deferring ACK"); } } else if (err != ERR_OK) { outputf("tcp_write returned %d", err); return close_conn(pcb, CONNCLOSED_SENDFAIL, len); } err = tcp_output(pcb); if (err != ERR_OK) { outputf("tcp_output returned %d", err); return close_conn(pcb, CONNCLOSED_SENDFAIL, len); } return len; }
/* hw_dac_init() * * Initialize the DAC hardware and sets it to output 0. */ void hw_dac_init(void) { LPC_PINCON->PINSEL0 &= ~(3 << 12); LPC_GPIO0->FIODIR &= ~(1 << 6); /* Pull-down on /SYNC indicates 16-bit DAC */ if (!(LPC_GPIO0->FIOPIN & (1 << 6))) { hw_dac_16bit = 1; /* Set up the SPI pins: SCLK, DIN. */ LPC_PINCON->PINSEL0 = (LPC_PINCON->PINSEL0 & ~((3 << 14) | (3 << 18))) | (2 << 14) | (2 << 18); LPC_GPIO0->FIOSET = (1 << 6); LPC_GPIO0->FIODIR |= (1 << 6) | (1 << 9); } else { hw_dac_16bit = 0; /* Drive SYNC from the SPI peripheral also. */ LPC_PINCON->PINSEL0 = (LPC_PINCON->PINSEL0 & ~((3 << 14) | (3 << 18))) | (2 << 12) | (2 << 14) | (2 << 18); } if (hw_dac_16bit) { LPC_PINCON->PINSEL0 &= ~(3 << 12); } /* Turn on the SSP peripheral. */ LPC_SSP1->CR0 = 0xF | (1 << 6); /* 16-bit, CPOL = 1; no prescale */ LPC_SSP1->CR1 = (1 << 1); /* Enable */ if (hw_dac_16bit) { LPC_SSP1->CPSR = 4; /* 32 MHz SPI clock */ } else { LPC_SSP1->CPSR = 4; /* 24 MHz SPI clock */ } hw_dac_zero_all_channels(); if (!hw_dac_16bit) { /* Set Vref in buffered mode */ hw_dac_write(0x800C); /* Power up the output buffers */ hw_dac_write(0xC000); } /* Set up the shutter output */ LPC_GPIO2->FIOCLR = (1 << DAC_SHUTTER_PIN); LPC_GPIO2->FIODIR |= (1 << DAC_SHUTTER_PIN); LPC_GPIO2->FIOCLR = (1 << DAC_SHUTTER_EN_PIN); LPC_GPIO2->FIODIR |= (1 << DAC_SHUTTER_EN_PIN); if (hw_dac_16bit) { outputf(" 16-bit DAC"); } else { outputf(" 12-bit DAC"); } }
void HardFault_Handler_C(uint32_t * stack) { outputf("*** HARD FAULT ***"); outputf("stack: %p", stack); int i; for (i = 0; i < 32; i++) { outputf("stack[%d]: %p", i, stack[i]); } while (1); }
static void close_conn(struct tcp_pcb *pcb, struct rfb_state *state) { outputf("close_conn: bailing"); tcp_arg(pcb, NULL); tcp_sent(pcb, NULL); tcp_recv(pcb, NULL); mem_free(state->blockbuf); mem_free(state); tcp_close(pcb); outputf("close_conn: done"); }
void SpawnLog::logNewZone(const QString& zonename) { if (!open()) return; outputf("----------\nNEW ZONE: %s\n----------\n", (const char*)zonename); outputf(" :name(spawnID):Level:Xpos:Ypos:Zpos:H.m.s:Ver:Zone:eqHour.eqMinute.eqMonth.eqDay.eqYear:killedBy(spawnID)\n"); flush(); zoneShortName = zonename; }
void ilda_play_FPV_param(const char *path) { /* Figure out which file index this was */ int index = atoi(path + 6); outputf("play %d", index); /* Try switching to ILDA playback mode, if we weren't already */ if (playback_set_src(SRC_ILDAPLAYER) < 0) { outputf("src switch err\n"); return; } walk_fs_request = index; }
static void ilda_play_fn_FPV_param(const char *path, const char *fn) { outputf("/ilda/play: \"%s\"", fn); /* Try switching to ILDA playback mode, if we weren't already */ if (playback_set_src(SRC_ILDAPLAYER) < 0) { outputf("src switch err\n"); return; } if (fplay_open(fn) == 0) { playback_source_flags |= ILDA_PLAYER_PLAYING; outputf("ok"); } else outputf("failed"); }
void * skub_alloc(enum skub_type region) { void *ptr = skub_alloc_from_pool(&skub_pools_fixed[region]); #ifdef SKUB_SPEW outputf("sa %d -> %p", region, ptr); #endif return ptr; }
void SpawnLog::logSpawnInfo(const char *type, const char *name, int id, int level, int x, int y, int z, const QDateTime& eqDate, const QTime& time, const char *killedBy, int kid, int guildid) { if (!open()) return; const QDate& eqDateDate = eqDate.date(); const QTime& eqDateTime = eqDate.time(); outputf("%s:%s(%d):%d:%d,%d,%d:%02d.%02d.%02d:%d:%s:%02d.%02d.%02d.%02d.%04d:%s(%d):%d\n", type, name, id, level, x, y, z, time.hour(), time.minute(), time.second(), version, (const char*)zoneShortName, eqDateTime.hour(), eqDateTime.minute(), eqDateDate.month(), eqDateDate.day(), eqDateDate.year(), killedBy, kid, guildid); flush(); }
void GetfilterEff( int run=262921, const char* trig = "HLT_HIL1MinimumBiasHF1AND_v1") { TH1::SetDefaultSumw2(); const char* fname = Form("/home/goyeonju/CMS/Files/centrality/EventTree_PbPb_data_HIMinimumBias2_run%d_15Feb.root",run); TFile *fin = TFile::Open(fname); TTree *t_skim = (TTree*) fin -> Get("skimanalysis/HltTree"); TTree *t_hlt = (TTree*) fin -> Get("hltanalysis/HltTree"); t_skim -> AddFriend(t_hlt); double Nevt_total = t_skim -> GetEntries(Form("(%s==1)",trig)); double Nevt_evtSelected[nfilter]; double Nevt_eff[nfilter]; for(int i=0;i<nfilter;i++){ Nevt_evtSelected[i] = t_skim -> GetEntries(Form("(%s==1)&&(%s)",trig,evtfilter[i])); Nevt_eff[i] = Nevt_evtSelected[i]/Nevt_total; } ofstream outputf(Form("filterEff_%s.txt", trig), ios::app); outputf << run << "\t" << Nevt_total << "\t" << setprecision(4) <<Nevt_eff[0]*100 << "\t" << setprecision(4) <<Nevt_eff[1]*100 << "\t" << setprecision(4) <<Nevt_eff[2]*100 << "\t" << setprecision(4) <<Nevt_eff[3]*100 << "\t" << setprecision(4) <<Nevt_eff[4]*100 << "\t" << endl; outputf.close(); }
void log(const char* w, const char* format, ...) { va_list ap; outputf("%-20s ", w); va_start(ap, format); outputv(format, ap); va_end(ap); }
static err_t rfb_accept(void *arg, struct tcp_pcb *pcb, err_t err) { struct rfb_state *state; char * blockbuf; LWIP_UNUSED_ARG(arg); LWIP_UNUSED_ARG(err); state = (struct rfb_state *)mem_malloc(sizeof(struct rfb_state)); if (!state) { outputf("rfb_accept: out of memory\n"); return ERR_MEM; } memset(state, 0, sizeof(struct rfb_state)); blockbuf = mem_malloc(ceildiv(fb->curmode.xres, SCREEN_CHUNKS_X) * ceildiv(fb->curmode.yres, SCREEN_CHUNKS_Y) * 4); if (!blockbuf) { outputf("rfb_accept: out of memory allocating blockbuf\n"); mem_free(state); return ERR_MEM; } state->blockbuf = blockbuf; state->state = ST_BEGIN; state->send_state = SST_IDLE; /* XXX: update_server_info() should be called from the 64ms timer, and deal * with screen resizes appropriately. */ update_server_info(); tcp_arg(pcb, state); tcp_recv(pcb, rfb_recv); tcp_sent(pcb, rfb_sent); tcp_poll(pcb, rfb_poll, 1); /* tcp_err(pcb, rfb_err); */ tcp_write(pcb, "RFB 003.008\n", 12, 0); tcp_output(pcb); return ERR_OK; }
/* close_conn * * Close the current connection, and record why. */ static int close_conn(struct tcp_pcb *pcb, uint16_t reason, int k) { outputf("close_conn: %d", reason); tcp_arg(pcb, NULL); tcp_sent(pcb, NULL); tcp_recv(pcb, NULL); tcp_close(pcb); return k; }
static void COLD NOINLINE FPA_init() { int i; debugf("### Initializing Hardware ###\r\n"); for (i = 0; i < TABLE_LENGTH(hardware); i++) { outputf("- %s()", hardware_table[i].name); hardware_table[i].f(); } debugf("### Initializing Protocols ###\r\n"); for (i = 0; i < TABLE_LENGTH(protocol); i++) { outputf("- %s()", protocol_table[i].name); protocol_table[i].f(); } }
static void dump_ies(unsigned char *iedata, int len) { int ielen; int ie; int x; int found; char interp[1024]; char tmp[1024]; if (len < 2) return; while(len > 2) { ie = iedata[0]; ielen = iedata[1]; if (ielen + 2> len) { snprintf(tmp, (int)sizeof(tmp), "Total IE length of %d bytes exceeds remaining frame length of %d bytes\n", ielen + 2, len); outputf(tmp); return; } found = 0; for (x=0;x<(int)sizeof(ies) / (int)sizeof(ies[0]); x++) { if (ies[x].ie == ie) { if (ies[x].dump) { ies[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen); snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", ies[x].name, interp); outputf(tmp); } else { if (ielen) snprintf(interp, (int)sizeof(interp), "%d bytes", ielen); else strcpy(interp, "Present"); snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", ies[x].name, interp); outputf(tmp); } found++; } } if (!found) { snprintf(tmp, (int)sizeof(tmp), " Unknown IE %03d : Present\n", ie); outputf(tmp); } iedata += (2 + ielen); len -= (2 + ielen); } outputf("\n"); }
extern void CommandRelationalSelect(char *sz) { unsigned int i, j; RowSet *rs; if (!sz || !*sz) { outputl(_("You must specify a sql query to run.")); return; } rs = RunQuery(sz); if (!rs) return; if (rs->rows == 0) { outputl(_("No rows found.\n")); return; } #if USE_GTK if (fX) GtkShowQuery(rs); else #endif for (i = 0; i < rs->rows; i++) { if (i == 1) { /* Underline headings */ char *line, *p; unsigned int k; int totalwidth = 0; for (k = 0; k < rs->cols; k++) { totalwidth += rs->widths[k] + 1; if (k != 0) totalwidth += 2; } line = malloc(totalwidth + 1); memset(line, '-', totalwidth); p = line; for (k = 0; k < rs->cols - 1; k++) { p += rs->widths[k]; p[1] = '|'; p += 3; } line[totalwidth] = '\0'; outputl(line); free(line); } for (j = 0; j < rs->cols; j++) { if (j > 0) output(" | "); outputf("%*s", (int) rs->widths[j], rs->data[i][j]); } outputl(""); } FreeRowset(rs); }
void print_call_stack(uint32_t eip, uint32_t ebp) { const uintptr_t* pebp = (uintptr_t*)ebp; // Walk the stack frames. output("*** CALL STACK:"); if (eip != 0) { outputf(" %08lx", eip); } while (1) { // Subtract 5 from the eip because that's the size of a call instruction. outputf(" %08lx", pebp[1] - 5); pebp = (uintptr_t*)pebp[0]; if (pebp == 0 || pebp[1] == 0) { break; } } outputf("\n"); }
int lewp() { struct pollfd pfd[2]; static char buffer[MAX_LINE_LEN], *nl; int nread; pfd[0].fd = fd_input; pfd[1].fd = fd_cmd; pfd[0].events = pfd[1].events = POLLIN; while(!finito){ if(comm_recv(&commt, &commcallback)){ outputf(file_err, "comm_recv() failed: %s\n", comm_lasterr(&commt)); return 1; } switch(poll(pfd, 2, FIFO_POLL_WAIT)){ case 0: /* notan happan */ continue; case -1: perrorf("%s", "poll()"); return 1; } #define READ(fd) \ nread = read(fd, buffer, MAX_LINE_LEN); \ \ switch(nread){ \ case -1: \ perrorf("%s", "read()"); \ return 1; \ case 0: \ break; \ default: \ buffer[nread-1] = '\0'; \ if((nl = strchr(buffer, '\n'))) \ *nl = '\0'; \ } #define BIT(x, b) (((x) & (b)) == (b)) if(BIT(pfd[0].revents, POLLIN)){ READ(pfd[0].fd); if(nread > 0) /* message */ comm_sendmessage(&commt, buffer); } if(BIT(pfd[1].revents, POLLIN)){ READ(pfd[1].fd); if(nread > 0) proc_cmd(buffer); } } return 0; }
/* puts in G[0]..G[k-1] the coefficients from (x+a[0])...(x+a[k-1]) Warning: doesn't fill the coefficient 1 of G[k], which is implicit. Needs k + list_mul_mem(k/2) cells in T. The product tree is stored in: G[0..k-1] (degree k) Tree[0][0..k-1] (degree k/2) Tree[1][0..k-1] (degree k/4), ..., Tree[lgk-1][0..k-1] (degree 1) (then we should have initially Tree[lgk-1] = a). The parameter dolvl signals that only level 'dolvl' of the tree should be computed (dolvl < 0 means all levels). Either Tree <> NULL and TreeFile == NULL, and we write the tree to memory, or Tree == NULL and TreeFile <> NULL, and we write the tree to disk. */ int PolyFromRoots_Tree (listz_t G, listz_t a, unsigned int k, listz_t T, int dolvl, mpz_t n, listz_t *Tree, FILE *TreeFile, unsigned int sh) { unsigned int l, m; listz_t H1, *NextTree; ASSERT (k >= 1); if (k == 1) { /* we consider x + a[0], which mean we consider negated roots */ mpz_mod (G[0], a[0], n); return 0; } if (Tree == NULL) /* -treefile case */ { H1 = G; NextTree = NULL; } else { H1 = Tree[0] + sh; NextTree = Tree + 1; } m = k / 2; l = k - m; if (dolvl != 0) /* either dolvl < 0 and we need to compute all levels, or dolvl > 0 and we need first to compute lower levels */ { PolyFromRoots_Tree (H1, a, l, T, dolvl - 1, n, NextTree, TreeFile, sh); PolyFromRoots_Tree (H1 + l, a + l, m, T, dolvl - 1, n, NextTree, TreeFile, sh + l); } if (dolvl <= 0) { /* Write this level to disk, if requested */ if (TreeFile != NULL) { if (list_out_raw (TreeFile, H1, l) == ECM_ERROR || list_out_raw (TreeFile, H1 + l, m) == ECM_ERROR) { outputf (OUTPUT_ERROR, "Error writing product tree of F\n"); return ECM_ERROR; } } list_mul (T, H1, l, 1, H1 + l, m, 1, T + k); list_mod (G, T, k, n); } return 0; }
void smi_init() { smram_state_t smram; pci_driver_t **driver; smram = smram_save_state(); smram_tseg_set_state(SMRAM_TSEG_OPEN); outputf("NetWatch running"); /* Turn on the SMIs we want */ smi_disable(); eth_init(); crc32_init(); /* After everything is initialized, load drivers. */ for (driver = drivers; *driver; driver++) { outputf("Probing driver: %s", (*driver)->name); if (pci_probe_driver(*driver)) output("Found a card"); } outputf("Driver probe complete"); /* Load in fonts. */ text_init(); smi_register_handler(SMI_EVENT_FAST_TIMER, timer_handler); smi_enable_event(SMI_EVENT_FAST_TIMER); smi_register_handler(SMI_EVENT_DEVTRAP_KBC, kbc_handler); smi_enable_event(SMI_EVENT_DEVTRAP_KBC); smi_register_handler(SMI_EVENT_GBL_RLS, gbl_rls_handler); smi_enable_event(SMI_EVENT_GBL_RLS); smi_enable(); vga_flush_imm(1); smram_restore_state(smram); }
/* checks if the factor p was found by P+1 or P-1 (when prime). a is the initial seed. */ static void pp1_check_factor (mpz_t a, mpz_t p) { if (mpz_probab_prime_p (p, PROBAB_PRIME_TESTS)) { mpz_mul (a, a, a); mpz_sub_ui (a, a, 4); if (mpz_jacobi (a, p) == 1) outputf (OUTPUT_NORMAL, "[factor found by P-1]\n"); } }
void panic(const char* w, const char* format, ...) { va_list ap; outputf("%-20s *** PANIC: ", w); va_start(ap, format); outputv(format, ap); va_end(ap); print_call_stack(0, (uint32_t)__builtin_frame_address(0)); screen_panic(); __asm__ __volatile__ ("cli; hlt"); while (1) { } }
static void ilda_repeat_FPV_param(const char *path, int32_t v) { if (playback_set_src(SRC_ILDAPLAYER) < 0) { outputf("src switch err\n"); return; } if (v) playback_source_flags |= ILDA_PLAYER_REPEAT; else playback_source_flags &= ~ILDA_PLAYER_REPEAT; }
/* fplay_open * * Prepare the ILDA player to play a given file. */ int fplay_open(const char * fname) { FRESULT res = f_open(&fplay_file, fname, FA_READ); if (res) { outputf("ild_play: no file: %d", res); return -1; } ilda_reset_file(); return 0; }
static void print_prob (double B1, const mpz_t B2, unsigned long dF, unsigned long k, int S, const mpz_t go) { double prob; int i; char sep; outputf (OUTPUT_VERBOSE, "Probability of finding a factor of n digits:\n"); if (go != NULL && mpz_cmp_ui (go, 1UL) <= 0) outputf (OUTPUT_VERBOSE, "(Use -go parameter to specify known factors in P-1)\n"); outputf (OUTPUT_VERBOSE, "20\t25\t30\t35\t40\t45\t50\t55\t60\t65\n"); for (i = 20; i <= 65; i += 5) { sep = (i < 65) ? '\t' : '\n'; prob = pm1prob (B1, mpz_get_d (B2), pow (10., i - .5), (double) dF * dF * k, S, go); outputf (OUTPUT_VERBOSE, "%.2g%c", prob, sep); } }
int SEQLogger::output(const void* data, int length) { int i; int count = 0; unsigned char *ptr = (unsigned char *) data; for(i = 0; i < length; i++,ptr++) count += outputf("%.2X", *ptr); return(count); }
/* walk_fs() does two different things: * * - If index <= 0: * Read all ilda file names from the system and send them via OSC * - If index > 0: * Open the index'th file. Note that index is 1-based. */ static void walk_fs(int index) { char filename_buf[32]; char path[16]; DIR dir; int res = f_opendir(&dir, ""); if (res) return; FILINFO finfo; int i = 1; while (1) { finfo.lfname = filename_buf; finfo.lfsize = sizeof(filename_buf); res = f_readdir(&dir, &finfo); if ((res != FR_OK) || !finfo.fname[0]) break; /* If it's anything other than a regular file, ignore it. */ if (finfo.fattrib & AM_DIR) continue; if (finfo.fattrib & AM_HID) continue; if (finfo.fattrib & AM_SYS) continue; char * fn = *finfo.lfname ? finfo.lfname : finfo.fname; outputf("fn %s", fn); /* Does it end with .ild or .ilda? */ char *fn_end = fn + strlen(fn); if (strcasecmp(fn_end - 4, ".ild") \ && strcasecmp(fn_end - 5, ".ilda") \ && strcasecmp(fn_end - 4, ".wav")) continue; if (index <= 0) { /* F**k you, TouchOSC. F**k you in the ear. */ if (strlen(fn) > 15) fn[15] = '\0'; snprintf(path, sizeof(path), "/ilda/%d/name", i); osc_send_string(path, fn); } else if (index == i) { fplay_open(fn); playback_source_flags |= ILDA_PLAYER_PLAYING; break; } i++; } walk_fs_request = 0; }