void do_write(int fd, unsigned name, unsigned code, unsigned seq, off_t pos, off_t len) { off_t done = 0; ssize_t ret; char *buf; const char *namestr; namestr = name_get(name); buf = data_map(code, seq, len); if (lseek(fd, pos, SEEK_SET) == -1) { err(1, "%s: lseek to %lld", name_get(name), pos); } while (done < len) { ret = write(fd, buf + done, len - done); if (ret == -1) { err(1, "%s: write %lld at %lld", name_get(name), len, pos); } done += ret; } tprintf("write %s: %lld at %lld\n", namestr, len, pos); }
void nest::music_cont_in_proxy::calibrate() { // only publish the port once if ( !S_.published_ ) { MUSIC::Setup* s = kernel().music_manager.get_music_setup(); if ( s == 0 ) throw MUSICSimulationHasRun( get_name() ); V_.MP_ = s->publishContInput( P_.port_name_ ); if ( !V_.MP_->isConnected() ) throw MUSICPortUnconnected( get_name(), P_.port_name_ ); if ( !V_.MP_->hasWidth() ) throw MUSICPortHasNoWidth( get_name(), P_.port_name_ ); S_.port_width_ = V_.MP_->width(); B_.data_ = std::vector< double >( S_.port_width_ ); MUSIC::ArrayData data_map( static_cast< void* >( &( B_.data_[ 0 ] ) ), MPI::DOUBLE, 0, S_.port_width_ ); V_.MP_->map( &data_map ); S_.published_ = true; std::string msg = String::compose( "Mapping MUSIC input port '%1' with width=%2.", P_.port_name_, S_.port_width_ ); LOG( M_INFO, "music_cont_in_proxy::calibrate()", msg.c_str() ); } }