static int handler_CDXA (riff_context *ctxt) { vcd_info ("CDXA RIFF detected"); next_id (ctxt); /* fmt */ next_id (ctxt); /* data */ return 0; }
extern void ymm_write_dword(address_space *as,offs_t a,UINT32 v) { if(a&3) { UINT32 r,p; r=rank_of_peid(as->machine_state,as->tag); p=pipe_of_peid(as->machine_state,as->tag); /*if(!p) {*/ fprintf(stdout,"[UNALIGNEDW] %016lld R: %05d P: %05d [%04X] <= %08X\n", (unsigned long long)as->machine_state->total_cycles, r,p,(unsigned)a,v); } else if(0) { /*fprintf(stderr,"dword access to %08X\n",(unsigned int)a);*/ UINT32 r,p; r=rank_of_peid(as->machine_state,as->tag); p=pipe_of_peid(as->machine_state,as->tag); if(!p) { fprintf(stdout,"[W] %016lld R: %05d P: %05d [%04X] <= %08X\n", (unsigned long long)as->machine_state->total_cycles, r,p,(unsigned)a,v);} } if(a<LM_BYTES) { UINT32 *this_mem=as->mem; this_mem[a/4]=ntohl(v); } else if(RM_P1_BASE<=a && a<(RM_P1_BASE+RM_BYTES)) { UINT32 dstpeid=next_id(as->machine_state,as->tag,0); UINT16 my_base=(pipe_of_peid(as->machine_state,as->tag)&1)?RM_IN2_BASE:RM_IN1_BASE; UINT16 offs=a-RM_P1_BASE+my_base; UINT32 *dstmem=mem_of_pe(as->machine_state,dstpeid); if(dstpeid<(as->machine_state->npipe*as->machine_state->nrank)) dstmem[offs/4]=ntohl(v); } else if(RM_P2_BASE<=a && a<(RM_P2_BASE+RM_BYTES)) { UINT32 dstpeid=next_id(as->machine_state,as->tag,1); UINT16 my_base=(pipe_of_peid(as->machine_state,as->tag)&1)?RM_IN2_BASE:RM_IN1_BASE; UINT16 offs=a-RM_P2_BASE+my_base; UINT32 *dstmem=mem_of_pe(as->machine_state,dstpeid); if(dstpeid<(as->machine_state->npipe*as->machine_state->nrank)) dstmem[offs/4]=ntohl(v); } else if(CONF_BASE<=a) { UINT32 r,p; r=rank_of_peid(as->machine_state,as->tag); p=pipe_of_peid(as->machine_state,as->tag); /*if(!p) {*/ fprintf(stdout,"%016lld R: %05d P: %05d [%04X] <= %08X\n", (unsigned long long)as->machine_state->total_cycles, r,p,(unsigned)a,v); /*}*/ if(a==0x8660) { as->machine_state->exit_req=1; } } }
void Server::on_connection(ev::io& w, int revents) { if(EV_ERROR & revents) { puts("on_connection() got error event, closing server."); return; } struct sockaddr_in addr; // connector's address information socklen_t addr_len = sizeof(addr); int fd = accept(fd_, (struct sockaddr*)&addr, &addr_len); if(fd < 0) { perror("accept()"); return; } int id = next_id(); Connection* connection = new Connection(ref(this), id, fd); if(connection == NULL) { close(fd); return; } connections_[id] = connection; connection->start(); }
/******************************************************** * add_dir * * Takes the a directory's ID and adds a child directory * by copying the entire original directory buffer to a * new buffer with a gap at the beginning of the parent's * child space, and then builds the new directory in that * gap. The original buffer is freed and replaced with * the new buffer. ********************************************************/ void add_dir( uint32_t parent_id, uint8_t* name ) { int struct_size, dir_offset, dirs_buffer_len, first_half_len, scnd_half_len; struct_size = sizeof( struct FS_Directory ); dirs_buffer_len = struct_size * header.num_dir; // Original dir buffer size dir_offset = get_dir_offset( parent_id ); // Buffer size split into halves, where the split is where the new dir is to go first_half_len = dir_offset * struct_size ; scnd_half_len = dirs_buffer_len - first_half_len; // Allocate space for one exact copy + 1 additional dir struct FS_Directory *new_dirs = malloc( dirs_buffer_len + struct_size * 2 ); // WHY DO WE NEED SPACE FOR 2 STRUCT SIZES????????????????????????????????????????????????????????????????? // Copy first half of buffer, then second half leaving space for new dir memcpy( new_dirs, dirs, first_half_len ); memcpy( new_dirs + dir_offset + 1, dirs + dir_offset, scnd_half_len + struct_size ); // Build new dir strncpy( new_dirs[dir_offset].name, name, MAX_NAME_SIZE ); new_dirs[dir_offset].num_files = 0; new_dirs[dir_offset].num_children = 0; new_dirs[dir_offset].id = next_id(); // Update header and parent header.num_dir++; new_dirs[get_index( parent_id )].num_children++; // Free old dirs buffer with new updated one free( dirs ); dirs = new_dirs; }
GrContext::GrContext() : fUniqueID(next_id()) { fGpu = nullptr; fCaps = nullptr; fResourceCache = nullptr; fResourceProvider = nullptr; fAtlasGlyphCache = nullptr; }
CreateEntryResult RamFileSystem::mount(uint32_t folder_id, const std::string &name, IFileSystem *fs) { if (name.size() == 0 || fs == nullptr) { return CreateEntryResult(NULL_ID, NULL_PARAMETER); } auto find = _entry_index.find(folder_id); if (find == _entry_index.end()) { return CreateEntryResult(NULL_ID, ENTRY_NOT_FOUND); } if (find->second->metadata().type() != FOLDER_ENTRY) { return CreateEntryResult(NULL_ID, WRONG_ENTRY_TYPE); } auto folder = dynamic_cast<Folder *>(find->second.get()); if (folder == nullptr) { return CreateEntryResult(NULL_ID, INTERNAL_ERROR); } auto id = next_id(); auto result = new MountPoint(id, fs); _entry_index[id] = std::unique_ptr<Entry>(result); return CreateEntryResult(id, folder->add_entry(name, result)); }
GrContext::GrContext() : fUniqueID(next_id()) { fGpu = nullptr; fCaps = nullptr; fResourceCache = nullptr; fResourceProvider = nullptr; fBatchFontCache = nullptr; }
GrContext_Base::GrContext_Base(GrBackendApi backend, const GrContextOptions& options, uint32_t contextID) : fBackend(backend) , fOptions(options) , fContextID(SK_InvalidGenID == contextID ? next_id() : contextID) { }
GrContext::GrContext() : fUniqueID(next_id()) { fGpu = nullptr; fCaps = nullptr; fResourceCache = nullptr; fResourceProvider = nullptr; fBatchFontCache = nullptr; fFlushToReduceCacheSize = false; }
RamFileSystem::File *RamFileSystem::new_file(uint32_t parent_id) { auto id = next_id(); auto result = new File(id); result->parent_folder_id(parent_id); _entry_index[id] = std::unique_ptr<Entry>(result); return result; }
RamFileSystem::Symlink *RamFileSystem::new_symlink(uint32_t parent_id, const std::string &link) { auto id = next_id(); auto result = new Symlink(id, link); result->parent_folder_id(parent_id); _entry_index[id] = std::unique_ptr<Entry>(result); return result; }
RamFileSystem::CharacterDevice *RamFileSystem::new_char_device(uint32_t parent_id, ICharacterDevice *device) { auto id = next_id(); auto result = new CharacterDevice(id, device); result->parent_folder_id(parent_id); _entry_index[id] = std::unique_ptr<Entry>(result); return result; }
GrContext::GrContext() : fUniqueID(next_id()) { fGpu = NULL; fResourceCache = NULL; fResourceProvider = NULL; fPathRendererChain = NULL; fSoftwarePathRenderer = NULL; fBatchFontCache = NULL; fFlushToReduceCacheSize = false; }
/* * Create a timer * @delay: Number of seconds for timeout * @action: Timer callback * @data: Optional callback data, must be a dynically allocated ptr */ int timer_set(int delay, cfunc_t action, void *data) { struct timeout_q *ptr, *node, *prev; #ifdef CALLOUT_DEBUG IF_DEBUG(DEBUG_TIMEOUT) logit(LOG_DEBUG, 0, "setting timer:"); print_Q(); #endif /* create a node */ node = calloc(1, sizeof(struct timeout_q)); if (!node) { logit(LOG_ERR, 0, "Ran out of memory in %s()", __func__); return -1; } node->func = action; node->data = data; node->time = delay; node->next = 0; node->id = next_id(); prev = ptr = Q; /* insert node in the queue */ /* if the queue is empty, insert the node and return */ if (!Q) Q = node; else { /* chase the pointer looking for the right place */ while (ptr) { if (delay < ptr->time) { /* right place */ node->next = ptr; if (ptr == Q) Q = node; else prev->next = node; ptr->time -= node->time; print_Q(); return node->id; } /* keep moving */ delay -= ptr->time; node->time = delay; prev = ptr; ptr = ptr->next; } prev->next = node; } print_Q(); return node->id; }
mf::SurfaceId msh::ApplicationSession::create_surface(const mf::SurfaceCreationParameters& params) { auto surf = surface_factory->create_surface(params); auto const id = next_id(); std::unique_lock<std::mutex> lock(surfaces_mutex); surfaces[id] = surf; return id; }
int Conference::member_create() { ost::MutexLock al(cs_members_); int id = next_id(); Member *member = new Member(conf_id_, id); members_.push_back(member); return id; }
static int handler_RIFF (riff_context *ctxt) { const uint32_t size = read_le_u32 (ctxt); vcd_info ("RIFF data[%d]", size); ctxt->lsize = ctxt->size = size; return next_id (ctxt); }
EDL::EDL(EDL *parent_edl) { this->parent_edl = parent_edl; tracks = 0; labels = 0; local_session = 0; vwindow_edl = 0; vwindow_edl_shared = 0; id = next_id(); project_path[0] = 0; }
void PipeConnectionCreator::create_connection_for( std::shared_ptr<boost::asio::local::stream_protocol::socket> const &socket) { auto const messenger = std::make_shared<network::LocalSocketMessenger>(socket); const auto type = identify_client(messenger); auto const processor = create_processor(type, messenger); if (!processor) BOOST_THROW_EXCEPTION(std::runtime_error("Unhandled client type")); auto const &connection = std::make_shared<network::SocketConnection>( messenger, messenger, next_id(), connections_, processor); connection->set_name(client_type_to_string(type)); connections_->add(connection); connection->read_next_message(); }
rtz_vtx_t rotz_add_vertex(rotz_t ctx, const char *v) { size_t z = strlen(v); rtz_vtx_t res; /* first check if V is already there, if not get an id and add that */ if ((res = get_vertex(ctx, v, z))) { ; } else if (UNLIKELY(!(res = next_id(ctx)))) { ; } else if (UNLIKELY(add_vertex(ctx, v, z, res) < 0)) { res = 0U; } return res; }
node *allocate_new_node(const char *message_id, unsigned int group_id, int search) { int id = next_id(); node *nnode = &nodes[id]; #if 0 printf("Getting new node %s %d\n", message_id, id); #endif node_table[search] = id; if (! inhibit_file_write) { nnode->id = id; nnode->group_id = group_id; nnode->message_id = enter_string_storage(message_id); } return nnode; }
EDL::EDL(EDL *parent_edl) : Indexable(0) { this->parent_edl = parent_edl; tracks = 0; labels = 0; local_session = 0; // vwindow_edl = 0; // vwindow_edl_shared = 0; folders.set_array_delete(); new_folder(CLIP_FOLDER); new_folder(MEDIA_FOLDER); id = next_id(); path[0] = 0; }
void ish3_ProgressBar::add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y) { caption = caption->eval(); const TCHAR* text = caption->eval()->to_string(); // We'll hang onto these... parent_rollout = ro; control_ID = next_id(); // Load in some values from the user, if they were given... Value* Vtmp = control_param(value); if(Vtmp==&unsupplied) value = 0; else value = Vtmp->to_int(); // Check orientation parameter type = TYPE_HORIZ; Value* Ttmp = control_param(orient); if(Ttmp!=&unsupplied&&Ttmp==n_vertical) type = TYPE_VERT; // Get the colour of the progress slider Value* Ctmp = control_param(color); if(Ctmp==&unsupplied) colorPro = RGB(30,10,190); else colorPro = convertFrom(Ctmp->to_acolor()); // Pass the inpho back to MXS to // let it calculate final position layout_data pos; compute_layout(ro, &pos, current_y); progbar = CreateWindow( PBAR_WINDOWCLASS, text, WS_VISIBLE | WS_CHILD | WS_GROUP, pos.left, pos.top, pos.width, pos.height, parent, (HMENU)control_ID, g_hInst, this); DWORD err = GetLastError(); }
int main (int argc, char *argv[]) { FILE *in = NULL, *out = NULL; riff_context ctxt = { 0, }; if (argc == 2 || argc == 3) { in = fopen (argv[1], "rb"); if (!in) { vcd_error ("fopen (): %s", strerror (errno)); exit (EXIT_FAILURE); } } else usage (); if (argc == 3) { out = fopen (argv[2], "wb"); if (!out) { vcd_error ("fopen (): %s", strerror (errno)); exit (EXIT_FAILURE); } } ctxt.fd = in; ctxt.fd_out = out; next_id (&ctxt); if (in) fclose (in); if (out) fclose (out); return 0; }
void FServerIrcBotPlugin::request_file(const message& msg, const str& filename) { log("I: Creating entry for: " << msg.get_userhost()); auto fid = next_id(); entry e; e.fid = fid; e.pathname = filename; e.userhost = msg.get_userhost(); e.size = 0; e.sent = 0; e.msg = msg; log("I: Adding to queue: " << fid); soss oss; if(!wait_q.push_back(std::move(e))) { log("I: Wait queue full: " << fid); oss << "Request Denied • Priority Queue is FULL!"; oss << " " << wait_q.size(); oss << " • " << bot.nick << "'s " << get_name() << " " << get_version(); oss << " •"; } else { log("I: In wait queue: " << fid); // Request Accepted • List Has Been Placed In The Priority Queue At Position 1 • OmeNServE v2.60 • oss << "Request Accepted • Priority Queue Position"; oss << " " << wait_q.size(); oss << " • " << bot.nick << "'s " << get_name() << " " << get_version(); oss << " •"; } bug_var(oss.str()); bot.fc_reply_pm_notice(msg, oss.str()); }
void InnerServerCommandSeqParser::handleInnerDataReceived(InnerClient* connection, char* buff, uint32_t buff_len) { ssize_t nwrite = 0; char* end = strstr(buff, END_OF_COMMAND); if (!end) { DEBUG_MSG_FORMAT<MAX_COMMAND_SIZE>(common::logging::L_WARNING, "UNKNOWN SEQUENCE: %s", buff); const cmd_responce_t resp = make_responce(next_id(), STATE_COMMAND_RESP_FAIL_1S, buff); common::Error err = connection->write(resp, &nwrite); if (err && err->isError()) { DEBUG_MSG_ERROR(err); } connection->close(); delete connection; return; } *end = 0; char* star_seq = NULL; cmd_id_t seq = strtoul(buff, &star_seq, 10); if (*star_seq != ' ') { DEBUG_MSG_FORMAT<MAX_COMMAND_SIZE>(common::logging::L_WARNING, "PROBLEM EXTRACTING SEQUENCE: %s", buff); const cmd_responce_t resp = make_responce(next_id(), STATE_COMMAND_RESP_FAIL_1S, buff); common::Error err = connection->write(resp, &nwrite); if (err && err->isError()) { DEBUG_MSG_ERROR(err); } connection->close(); delete connection; return; } const char* id_ptr = strchr(star_seq + 1, ' '); if (!id_ptr) { DEBUG_MSG_FORMAT<MAX_COMMAND_SIZE>(common::logging::L_WARNING, "PROBLEM EXTRACTING ID: %s", buff); const cmd_responce_t resp = make_responce(next_id(), STATE_COMMAND_RESP_FAIL_1S, buff); common::Error err = connection->write(resp, &nwrite); if (err && err->isError()) { DEBUG_MSG_ERROR(err); } connection->close(); delete connection; return; } size_t len_seq = id_ptr - (star_seq + 1); cmd_seq_t id = std::string(star_seq + 1, len_seq); const char* cmd = id_ptr; int argc; sds* argv = sdssplitargs(cmd, &argc); processRequest(id, argc, argv); if (argv == NULL) { DEBUG_MSG_FORMAT<MAX_COMMAND_SIZE>(common::logging::L_WARNING, "PROBLEM PARSING INNER COMMAND: %s", buff); const cmd_responce_t resp = make_responce(id, STATE_COMMAND_RESP_FAIL_1S, buff); common::Error err = connection->write(resp, &nwrite); if (err && err->isError()) { DEBUG_MSG_ERROR(err); } connection->close(); delete connection; return; } DEBUG_MSG_FORMAT<MAX_COMMAND_SIZE>( common::logging::L_INFO, "HANDLE INNER COMMAND client[%s] seq:% " CID_FMT ", id:%s, cmd: %s", connection->formatedName(), seq, id, cmd); if (seq == REQUEST_COMMAND) { handleInnerRequestCommand(connection, id, argc, argv); } else if (seq == RESPONCE_COMMAND) { handleInnerResponceCommand(connection, id, argc, argv); } else if (seq == APPROVE_COMMAND) { handleInnerApproveCommand(connection, id, argc, argv); } else { NOTREACHED(); } sdsfreesplitres(argv, argc); }
void FooControl::add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y) { HWND label, edit_box, spinner; int left, top, width, height; SIZE size; const TCHAR* text = caption->eval()->to_string(); /* add 3 controls for a spinner: the label static, value custeditbox, & spinner itself, * label & edit box are given IDs that are the spinner id * control_count & that + 1, to make * sure they are unique and decodable */ parent_rollout = ro; control_ID = next_id(); WORD label_id = next_id(); WORD edit_box_id = next_id(); // compute bounding box, apply layout params layout_data pos; setup_layout(ro, &pos, current_y); Value* fw = control_param(fieldwidth); int spin_width = (fw == &unsupplied) ? ro->current_width / 2 : fw->to_int() + 10; GetTextExtentPoint32(ro->rollout_dc, text, static_cast<int>(_tcslen(text)), &size); int lbl_width = size.cx; int orig_width = lbl_width + spin_width; pos.width = orig_width + 2; pos.left = pos.left + ro->current_width - pos.width; pos.height = ro->text_height + 3; process_layout_params(ro, &pos, current_y); // place spinner elements int cex = (fw == &unsupplied) ? pos.width * lbl_width / orig_width : pos.width - spin_width; cex = min(cex, pos.width); width = lbl_width; height = ro->text_height; left = pos.left + cex - width - 1; top = pos.top; label = CreateWindow(_T("STATIC"), text, WS_VISIBLE | WS_CHILD | WS_GROUP, left, top, width, height, parent, (HMENU)label_id, hInstance, NULL); width = pos.width - cex - 13; height = ro->text_height + 3; left = pos.left + cex + 1; edit_box = CreateWindowEx(0, CUSTEDITWINDOWCLASS, _T(""), WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_GROUP, left, top, width, height, parent, (HMENU)edit_box_id, hInstance, NULL); left += width; width = 10; spinner = CreateWindowEx(0, SPINNERWINDOWCLASS, _T(""), WS_VISIBLE | WS_CHILD, left, top, width, height, parent, (HMENU)control_ID, hInstance, NULL); SendDlgItemMessage(parent, label_id, WM_SETFONT, (WPARAM)ro->font, 0L); SendDlgItemMessage(parent, edit_box_id, WM_SETFONT, (WPARAM)ro->font, 0L); /* setup the spinner control */ ISpinnerControl* spin = GetISpinner(spinner); Value* range = control_param(range); Value* type = control_param(type); Value* scaleval = control_param(scale); if (type == n_integer) spin_type = EDITTYPE_INT; else if (type == n_worldUnits) spin_type = EDITTYPE_UNIVERSE; else if (type == n_float || type == &unsupplied) spin_type = EDITTYPE_FLOAT; else throw TypeError (MaxSDK::GetResourceStringAsMSTR(IDS_SPINNER_TYPE_MUST_BE_INTEGER_OR_FLOAT), type); if (ro->init_values) { if (range == &unsupplied) { min = 0.0f; max = 100.0f; value = 0.0f; } else if (is_point3(range)) { Point3 p = range->to_point3(); min = p.x; max = p.y; value = p.z; } else throw TypeError (MaxSDK::GetResourceStringAsMSTR(IDS_SPINNER_RANGE_MUST_BE_A_VECTOR), range); if (scaleval == &unsupplied) { scale = (spin_type == EDITTYPE_INT) ? 1.0f : 0.1f; } else scale = scaleval->to_float(); } spin->LinkToEdit(edit_box, spin_type); spin->SetScale(scale); if (spin_type == EDITTYPE_INT) { spin->SetLimits((int)min, (int)max, FALSE); spin->SetValue((int)value, FALSE); } else if (spin_type == EDITTYPE_UNIVERSE) { spin->SetLimits(min, max, FALSE); spin->SetValue(value, FALSE); } else { spin->SetLimits(min, max, FALSE); spin->SetValue(value, FALSE); } ReleaseISpinner(spin); }
void AngleControl::add_control(Rollout *ro, HWND parent, HINSTANCE hInstance, int& current_y) { caption = caption->eval(); HWND label; int left, top, width, height; SIZE size; const TCHAR *label_text = caption->eval()->to_string(); parent_rollout = ro; control_ID = next_id(); WORD label_id = next_id(); Value *val; if((val = control_param(diameter)) != &unsupplied) m_diameter = val->to_int(); else if((val = control_param(width)) != &unsupplied) m_diameter = val->to_int(); else if((val = control_param(height)) != &unsupplied) m_diameter = val->to_int(); else m_diameter = 64; val = control_param(degrees); if(val != &unsupplied) m_degrees = val->to_float(); else m_degrees = 0.f; val = control_param(radians); if(val != &unsupplied) m_degrees = RadToDeg(val->to_float()); val = control_param(range); if (val == &unsupplied) { m_min = -360.0f; m_max = 360.0f; } else if (is_point3(val)) { Point3 p = val->to_point3(); m_min = p.x; m_max = p.y; m_degrees = p.z; } else throw TypeError (MaxSDK::GetResourceStringAsMSTR(IDS_ANGLE_RANGE_MUST_BE_A_VECTOR), val); val = control_param(startDegrees); if(val != &unsupplied) SetStartDegrees(val->to_float()); else SetStartDegrees(0.f); val = control_param(startRadians); if(val != &unsupplied) SetStartDegrees(RadToDeg(val->to_float())); val = control_param(dir); if(val != &unsupplied) { if (val != n_CW && val != n_CCW) throw RuntimeError (MaxSDK::GetResourceStringAsMSTR(IDS_ANGLE_DIR_BAD_VALUE), val); m_dirCCW = val != n_CW; } val = control_param(bitmap); if(val != &unsupplied) SetBitmap(val); else SetColor(control_param(color)); m_lButtonDown = FALSE; layout_data pos; compute_layout(ro, &pos, current_y); left = pos.left; top = pos.top; // place optional label int label_height = (_tcslen(label_text) != 0) ? ro->text_height + SPACING_BEFORE - 2 : 0; // LAM - defect 298613 - not creating the caption HWND was causing problems (whole screen redrawn // when control moved, setting caption text set wrong HWND). Now always create. // if (label_height != 0) // { DLGetTextExtent(ro->rollout_dc, label_text, &size); width = min(size.cx, pos.width); height = ro->text_height; label = CreateWindow(_T("STATIC"), label_text, WS_VISIBLE | WS_CHILD | WS_GROUP, left, top, width, height, parent, (HMENU)label_id, hInstance, NULL); // } // place angle box top = pos.top + label_height; width = pos.width; m_hWnd = CreateWindow( ANGLECTRL_WINDOWCLASS, TEXT(""), WS_VISIBLE | WS_CHILD | WS_GROUP, pos.left, top, width, m_diameter, parent, (HMENU)control_ID, g_hInst, this); m_hToolTip = CreateWindow( TOOLTIPS_CLASS, TEXT(""), WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, m_hWnd, (HMENU)NULL, g_hInst, NULL); SendMessage(label, WM_SETFONT, (WPARAM)ro->font, 0L); SendMessage(m_hToolTip, TTM_ADDTOOL, 0, (LPARAM)GetToolInfo()); }
//----------------------------------------------------------------------------- // make a blacklist query and call the handler function when we have an answer. // // NOTE: that it is possible for the callback funcction to be called before // this function exits (if the result is already cached), so dont put // any important initialization of the passed in object after this call // is made. rq_blacklist_id_t rq_blacklist_check( rq_blacklist_t *blacklist, struct sockaddr *address, int socklen, void (*handler)(rq_blacklist_status_t status, void *arg), void *arg) { struct sockaddr_in *sin; ev_uint32_t ip; cache_entry_t *entry; struct timeval tv; time_t curtime; rq_message_t *msg; cache_waiting_t *waiting; rq_blacklist_id_t id; assert(blacklist); assert(address); assert(socklen > 0); assert(handler); assert(arg); // convert 'address' into a 32bit uint. sin = (struct sockaddr_in *) address; ip = sin->sin_addr.s_addr; // get the current time in seconds. gettimeofday(&tv, NULL); curtime=tv.tv_sec; // check the cache for the address. assert(blacklist->cache); ll_start(blacklist->cache); entry = ll_next(blacklist->cache); while (entry) { if (entry->ip == ip) { // check to see if entry has expired. assert(entry->expires > 0); if (entry->expires <= curtime) { // cached entry has expired, so we need to remove it from the list. ll_remove(blacklist->cache, entry); free(entry); } else { // entry is in the list, so we call the handler, and then we return 0. handler(entry->status, arg); ll_finish(blacklist->cache); return(0); } entry = NULL; } else { entry = ll_next(blacklist->cache); } } ll_finish(blacklist->cache); // if we got this far, then the entry was not found in the cache, so we need // to send a request to the queue. // get the next id. id = next_id(blacklist); // create the structure that will hold the information we are waiting on, and add it to the tail of the list. waiting = (cache_waiting_t *) malloc(sizeof(cache_waiting_t)); assert(waiting); waiting->id = id; waiting->ip = ip; waiting->arg = arg; waiting->blacklist = blacklist; waiting->msg = NULL; waiting->handler = handler; ll_push_tail(blacklist->waiting, waiting); // now create a message object so we can send the message assert(blacklist->queue); assert(blacklist->rq); msg = rq_msg_new(blacklist->rq, NULL); assert(msg); assert(msg->data); // apply the queue that we are sending a request for. rq_msg_setqueue(msg, blacklist->queue); // build the command payload. rq_msg_addcmd(msg, BL_CMD_CLEAR); // rq_msg_addcmd(msg, BL_CMD_NOP); rq_msg_addcmd_largeint(msg, BL_CMD_IP, ip); rq_msg_addcmd(msg, BL_CMD_CHECK); // message has been prepared, so send it. // TODO: add fail handler. rq_send(msg, blacklist_handler, NULL, waiting); msg = NULL; return(id); }
/* accessor */ extern UINT32 ymm_read_dword(address_space *as, offs_t a) { UINT32 result=(UINT32)-1; if(a<LM_BYTES) { UINT32 *this_mem=as->mem; result=htonl(this_mem[a/4]); } else if(RM_P1_BASE<=a && a<(RM_P1_BASE+RM_BYTES)) { UINT32 dstpeid=next_id(as->machine_state,as->tag,0); UINT16 my_base=(pipe_of_peid(as->machine_state,as->tag)&1)?RM_IN2_BASE:RM_IN1_BASE; UINT16 offs=a-RM_P1_BASE+my_base; UINT32 *dstmem=mem_of_pe(as->machine_state,dstpeid); if(dstpeid<(as->machine_state->npipe*as->machine_state->nrank)) result=htonl(dstmem[offs/4]); else result=(UINT32)-1; } else if(RM_P2_BASE<=a && a<(RM_P2_BASE+RM_BYTES)) { UINT32 dstpeid=next_id(as->machine_state,as->tag,1); UINT16 my_base=(pipe_of_peid(as->machine_state,as->tag)&1)?RM_IN2_BASE:RM_IN1_BASE; UINT16 offs=a-RM_P2_BASE+my_base; UINT32 *dstmem=mem_of_pe(as->machine_state,dstpeid); if(dstpeid<(as->machine_state->npipe*as->machine_state->nrank)) result=htonl(dstmem[offs/4]); else result=(UINT32)-1; } else if(CONF_BASE<=a) { UINT32 offs=a-CONF_BASE; if(offs<0x10) { /* offset 0 1 2 3 4 5 6 7 */ /* PIDll -LH -HL -HH RIDll -LH -HL -HH */ /* offset 8 9 a b c d e f */ /* P#ll -lh -hl -hh R#ll -lh -hl -hh */ UINT16 id_offs=offs; UINT32 val; switch(id_offs&0x0c) { case 0: val=pipe_of_peid(as->machine_state,as->tag); break; case 0x4: val=rank_of_peid(as->machine_state,as->tag); break; case 0x8: val=as->machine_state->npipe; break; default: val=as->machine_state->nrank; break; } result=val; /*fprintf(stderr,"P%08X type=%02X val=%08X, R[%04X] = %02X\n", as->tag,id_offs&0x0c,val, a,result);*/ } else if(offs==0x10) { result=__builtin_popcount((as->machine_state->npipe)-1); } else { fprintf(stderr,"Out-of-range read on P%08X R[%04X] = %02X\n", as->tag,(unsigned)a,result); } } { UINT32 r,p; r=rank_of_peid(as->machine_state,as->tag); p=pipe_of_peid(as->machine_state,as->tag); if(a&3) fprintf(stdout,"[UNALIGNEDR] %016lld R: %05d P: %05d [%04X]\n", (unsigned long long)as->machine_state->total_cycles, r,p,(unsigned)a); else if(0) { fprintf(stdout,"[TARGET] %016lld R: %05d P: %05d [%08X] => %08X\n", (unsigned long long)as->machine_state->total_cycles, r,p,(unsigned)a,result); } } return result; }