void DumbFramebuffer::Create() { int r; const FormatInfo& format_info = format_info_array.at(m_format); m_num_planes = format_info.num_planes; for (int i = 0; i < format_info.num_planes; ++i) { const FormatPlaneInfo& pi = format_info.planes[i]; FramebufferPlane& plane = m_planes[i]; /* create dumb buffer */ struct drm_mode_create_dumb creq = drm_mode_create_dumb(); creq.width = width() / pi.xsub; creq.height = height() / pi.ysub; creq.bpp = pi.bitspp; r = drmIoctl(card().fd(), DRM_IOCTL_MODE_CREATE_DUMB, &creq); if (r) throw std::invalid_argument("foo"); plane.handle = creq.handle; plane.stride = creq.pitch; plane.size = creq.height * creq.pitch; /* printf("buf %d: %dx%d, bitspp %d, stride %d, size %d\n", i, creq.width, creq.height, pi->bitspp, plane->stride, plane->size); */ /* prepare buffer for memory mapping */ struct drm_mode_map_dumb mreq = drm_mode_map_dumb(); mreq.handle = plane.handle; r = drmIoctl(card().fd(), DRM_IOCTL_MODE_MAP_DUMB, &mreq); if (r) throw std::invalid_argument("foo"); /* perform actual memory mapping */ m_planes[i].map = (uint8_t *)mmap(0, plane.size, PROT_READ | PROT_WRITE, MAP_SHARED, card().fd(), mreq.offset); if (plane.map == MAP_FAILED) throw std::invalid_argument("foo"); /* clear the framebuffer to 0 */ memset(plane.map, 0, plane.size); } /* create framebuffer object for the dumb-buffer */ uint32_t bo_handles[4] = { m_planes[0].handle, m_planes[1].handle }; uint32_t pitches[4] = { m_planes[0].stride, m_planes[1].stride }; uint32_t offsets[4] = { 0 }; uint32_t id; r = drmModeAddFB2(card().fd(), width(), height(), (uint32_t)format(), bo_handles, pitches, offsets, &id, 0); if (r) throw std::invalid_argument("foo"); set_id(id); }
void test_send (l2net_154 *l2, l2addr_154 *dest) { Msg *m1 = initMsg(l2) ; Msg *m2 = initMsg(l2) ; bool ok ; option *up1 = initOptionOpaque(MO_Uri_Path, PATH1, sizeof PATH1 - 1) ; option *up2 = initOptionOpaque(MO_Uri_Path, PATH2, sizeof PATH2 - 1) ; option *up3 = initOptionOpaque(MO_Uri_Path, PATH3, sizeof PATH3 - 1) ; option *ocf = initOptionOpaque(MO_Content_Format, "abc", sizeof "abc" - 1) ; set_id (m1, 258) ; set_type (m1, COAP_TYPE_NON) ; push_option (m1, ocf) ; push_option (m1, up1) ; push_option (m1, up2) ; push_option (m1, up3) ; ok = sendMsg (m1, dest) ; res_send (1, ok) ; set_id (m2, 33) ; set_type (m2, COAP_TYPE_CON) ; push_option (m2, ocf) ; ok = sendMsg (m2, dest) ; res_send (2, ok) ; }
void test_msg (void) { l2net_154 *l2 ; printf ("STEP 1: create 2 empty messages\n") ; Msg *m1 = initMsg(l2) ; printMsg (m1) ; Msg *m2 = initMsg(l2) ; printMsg (m2) ; printf ("STEP 2: create options\n") ; option *oup1 = initOptionOpaque(MO_Uri_Path, (void *) PATH1, sizeof PATH1-1) ; option *oup2 = initOptionOpaque(MO_Uri_Path, (void *) PATH2, sizeof PATH2-1) ; option *ouq1 = initOptionOpaque(MO_Uri_Query, (void *) URIQUERY1, sizeof URIQUERY1-1) ; option *ouq2 = initOptionOpaque(MO_Uri_Query, (void *) URIQUERY2, sizeof URIQUERY2-1) ; option *ouq3 = initOptionOpaque(MO_Uri_Query, (void *) URIQUERY3, sizeof URIQUERY3-1) ; // REGISTER message set_type (m1, COAP_TYPE_CON) ; set_code (m1, COAP_CODE_GET) ; set_id (m1, 10) ; printf ("STEP 3a: M1 add uriquery2\n") ; push_option (m1, ouq2) ; printMsg (m1) ; printf("\n") ; printf ("STEP 3b: M1 add uripath1\n") ; push_option (m1, oup1) ; printMsg (m1) ; printf("\n") ; printf ("STEP 3c: M1 add uripath2\n") ; push_option (m1, oup2) ; printMsg (m1) ; printf("\n") ; printf ("STEP 3d: M1 add uriquery1\n") ; push_option (m1, ouq1) ; printMsg (m1) ; printf("\n") ; printf("STEP 3e: M1 add uriquery3\n") ; push_option (m1, ouq3) ; printMsg (m1) ; printf("\n") ; set_type (m2, COAP_TYPE_NON) ; set_code (m2, COAP_CODE_POST) ; set_id (m2, 11) ; printf ("STEP 3f: M2 add oriquery2\n") ; push_option (m2, ouq2) ; printMsg (m2) ; printf("\n") ; if (get_errno () != 0) { printf ("ERROR : ERRNO => ") ; printf ("%d\n",get_errno ()) ; reset_errno () ; } clock_delay (1000) ; }
void setup() { set_id("passage"); set_id("outline"); set_long("There is nothing special about the passage."); set_attached(1); set_size(MEDIUM); }
hdf5_dataset::hdf5_dataset ( hdf5_file &file, std::string const& path, hdf5_datatype const& datatype, hdf5_dataspace const& dataspace ) : path_(path) { // Check if name exists in this file. htri_t status = H5Lexists(file.get_id(), path.c_str(), H5P_DEFAULT); if(status > 0) { // Full path exists. // Attempt to open it as a dataset set_id(H5Dopen2(file.get_id(), path.c_str(), H5P_DEFAULT)); if(get_id() < 0) { boost::serialization::throw_exception( hdf5_archive_exception( hdf5_archive_exception::hdf5_archive_dataset_access_error, path.c_str() ) ); } } else if(status == 0){ // Final link in path does not exist. // Create the dataset. set_id(H5Dcreate2( file.get_id(), path.c_str(), datatype.get_id(), dataspace.get_id(), H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ) ); if(get_id() < 0) { boost::serialization::throw_exception( hdf5_archive_exception( hdf5_archive_exception::hdf5_archive_dataset_create_error, path.c_str() ) ); } } else { // intermediate link does not exist, or other error boost::serialization::throw_exception( hdf5_archive_exception( hdf5_archive_exception::hdf5_archive_bad_path_error, path.c_str() ) ); } }
void setup() { set_id("passage"); set_id("outline"); set_long("There is nothing special about the passage."); set_attached(1); #ifdef USE_SIZE set_size(MEDIUM); #endif #ifdef USE_MASS set_mass(MEDIUM); #endif }
void mudlib_setup() { ::mudlib_setup(); set_id("sword"); set_combat_messages("combat-sword"); set_damage_type("blade"); }
PatchChange (const PatchChange & other) : _bank_change_msb (other._bank_change_msb, true) , _bank_change_lsb (other._bank_change_lsb, true) , _program_change (other._program_change, true) { set_id (other.id ()); }
GCTaskThread::GCTaskThread(GCTaskManager* manager, uint which): _manager(manager), _new_gc_mode_requested(false), _new_gc_mode(true), _time_stamps(NULL), _time_stamp_index(0), _preallocated_page(NoPage) { if(!os::create_thread(this,ttype::gc_thread)) vm_exit_out_of_memory(0, "Cannot create GC thread. Out of system resources."); if (PrintGCTaskTimeStamps) { _time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries ); guarantee(_time_stamps != NULL, "Sanity"); } set_id(which); if (UseGenPauselessGC) { set_name("GC task thread#%d (GenPauselessGC)",which); } else { set_name("GC task thread#%d (ParallelGC)", which); } }
void computed_base::internal_copy( const computed_base &o ) { clear_graph(); _graph = o._graph; set_id( o._id ); }
void RceQueryRefuseReceiveWishItem::MergeFrom(const RceQueryRefuseReceiveWishItem& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from._has_bit(0)) { set_type(from.type()); } if (from._has_bit(1)) { set_name(from.name()); } if (from._has_bit(2)) { set_playerid(from.playerid()); } if (from._has_bit(3)) { set_id(from.id()); } if (from._has_bit(4)) { set_guid(from.guid()); } if (from._has_bit(5)) { set_planetid(from.planetid()); } if (from._has_bit(6)) { set_time(from.time()); } if (from._has_bit(7)) { set_msg(from.msg()); } } if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) { if (from._has_bit(8)) { set_url(from.url()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); }
void set::unserialize(core::coll_helper _coll) { set_id(_coll.get_value_as_int("id")); set_name(_coll.get_value_as_string("name")); if (_coll.is_value_exist("icon")) { core::istream* icon_stream = _coll.get_value_as_stream("icon"); if (icon_stream) { int32_t icon_size = icon_stream->size(); if (icon_size > 0) { load_icon((char*)icon_stream->read(icon_size), icon_size); } } } core::iarray* sticks = _coll.get_value_as_array("stickers"); stickers_.reserve(sticks->size()); for (int32_t i = 0; i < sticks->size(); i++) { core::coll_helper coll_sticker(sticks->get_at(i)->get_as_collection(), false); auto inserted_sticker = std::make_shared<sticker>(); inserted_sticker->unserialize(coll_sticker); inserted_sticker->set_set_id(get_id()); stickers_.push_back(inserted_sticker); } }
static int start_keybd(int c, int d) { if (d) { if (c == KEY_EXIT) return start_action(GUI_BACK, 0); if (c == SDLK_c && config_cheat()) { set_cheat(); return goto_state(&st_start); } else if (c == KEY_LEVELSHOTS && config_cheat()) { char *dir = concat_string("Screenshots/shot-", set_id(curr_set()), NULL); int i; fs_mkdir(dir); /* Iterate over all levels, taking a screenshot of each. */ for (i = 0; i < MAXLVL; i++) if (level_exists(i)) level_snap(i, dir); free(dir); } else if (config_tst_d(CONFIG_KEY_SCORE_NEXT, c)) return start_score(+1); } return 1; }
hdf5_dataset::hdf5_dataset( hdf5_file const& file, std::string const& path ) : path_(path) { // Check if name exists in this file. htri_t status = H5Lexists(file.get_id(), path.c_str(), H5P_DEFAULT); if(status > 0) { // Full path exists. // Attempt to open it as a dataset set_id(H5Dopen2(file.get_id(), path.c_str(), H5P_DEFAULT)); if(get_id() < 0) { boost::serialization::throw_exception( hdf5_archive_exception( hdf5_archive_exception::hdf5_archive_dataset_access_error, path.c_str() ) ); } } else { // path does not exist, or other error boost::serialization::throw_exception( hdf5_archive_exception( hdf5_archive_exception::hdf5_archive_bad_path_error, path.c_str() ) ); } }
transform2_param_t::transform2_param_t( const std::string& name, const std::string& id) : composite_param_t( name) { set_id( id); std::auto_ptr<float2_param_t> p( new float2_param_t( "Center")); p->set_id( id + std::string( "_center")); p->set_default_value( Imath::V2f( 0.5, 0.5)); p->set_numeric_type( numeric_param_t::relative_xy); add_param( p); p.reset( new float2_param_t( "Pos")); p->set_id( id + std::string( "_pos")); p->set_default_value( Imath::V2f( 0, 0)); add_param( p); p.reset( new float2_param_t( "Scale")); p->set_id( id + std::string( "_scale")); p->set_default_value( Imath::V2f( 1, 1)); p->set_step( 0.05); p->set_proportional( true); add_param( p); std::auto_ptr<float_param_t> q( new float_param_t( "Rotation")); q->set_id( id + std::string( "_rot")); q->set_default_value( 0); q->set_step( 0.5); add_param( q); }
bool feature_vector::setup_feature_vector( string timeStamp, config_handler *ch, audio_recorder *ar ) { string mn = "setup_feature_vector:"; cout<<cn<<mn<<" Setting up feature vector basics ... "<<endl; // prep basics set_time_stamp( timeStamp ); set_id( ch->get_rpid() ); set_lat( ch->get_latitude() ); set_lon( ch->get_longitude() ); set_macaddr( utils::get_mac_address() ); set_fv_file_name( ar->get_rec_file_name_core() + get_fv_ext() ); if( ch->get_analysis() == true ) { // find all feature vector element file names find_feature_vector_files( timeStamp, ch, ar ); // parse for feature vector base file names extract_feature_vector_file_names( ); // read all of the feature files found read_features(); } cout<<cn<<mn<<" Finished basic setup."<<endl; return true; }
BaseTab::BaseTab(TabController* controller) : controller_(controller), closing_(false), dragging_(false), favicon_hiding_offset_(0), loading_animation_frame_(0), should_display_crashed_favicon_(false), throbber_disabled_(false), theme_provider_(NULL) { BaseTab::InitResources(); set_id(VIEW_ID_TAB); // Add the Close Button. close_button_ = new TabCloseButton(this); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_->SetImage(view::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_TAB_CLOSE)); close_button_->SetImage(view::CustomButton::BS_HOT, rb.GetBitmapNamed(IDR_TAB_CLOSE_H)); close_button_->SetImage(view::CustomButton::BS_PUSHED, rb.GetBitmapNamed(IDR_TAB_CLOSE_P)); close_button_->SetTooltipText( UTF16ToWide(ui::GetStringUTF16(IDS_TOOLTIP_CLOSE_TAB))); close_button_->SetAccessibleName( ui::GetStringUTF16(IDS_ACCNAME_CLOSE)); // Disable animation so that the red danger sign shows up immediately // to help avoid mis-clicks. close_button_->SetAnimationDuration(0); AddChildView(close_button_); set_context_menu_controller(this); }
void setup(string dir, string dest) { set_id("gate"); set_adj("rusty" , "rusty gate" ); set_long("The gate is very rusty and doesnt look like it could stop anything anymore"); setup_door("rusty gate", dir, dest); set_flag(ATTACHED); }
void tcontrol::set_members(const string_map& data) { /** @todo document this feature on the wiki. */ /** @todo do we need to add the debug colors here as well? */ string_map::const_iterator itor = data.find("id"); if(itor != data.end()) { set_id(itor->second); } itor = data.find("linked_group"); if(itor != data.end()) { set_linked_group(itor->second); } itor = data.find("label"); if(itor != data.end()) { set_label(itor->second); } itor = data.find("tooltip"); if(itor != data.end()) { set_tooltip(itor->second); } itor = data.find("help"); if(itor != data.end()) { set_help_message(itor->second); } itor = data.find("use_markup"); if(itor != data.end()) { set_use_markup(utils::string_bool(itor->second)); } }
proto::PeerRequest PeerRequest::SigVersion(const Lock& lock) const { auto contract = IDVersion(lock); contract.set_id(String::Factory(id(lock))->Get()); return contract; }
void Message::MergeFrom(const Message& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_to()) { set_to(from.to()); } if (from.has_id()) { set_id(from.id()); } if (from.has_time()) { set_time(from.time()); } if (from.has_from()) { set_from(from.from()); } if (from.has_type()) { set_type(from.type()); } if (from.has_sn()) { set_sn(from.sn()); } if (from.has_data()) { set_data(from.data()); } if (from.has_expire()) { set_expire(from.expire()); } } }
static int add_event(char *evtid_path) { char id_buf[24]; int id, fd; fd = open(evtid_path, O_RDONLY); if (fd < 0) { /* * some tracepoint doesn't have id file, like ftrace, * return success in here, and don't print error. */ verbose_printf("warning: cannot open file %s\n", evtid_path); return 0; } if (read(fd, id_buf, sizeof(id_buf)) < 0) { fprintf(stderr, "read file error %s\n", evtid_path); close(fd); return -1; } id = atoll(id_buf); if (id >= IDS_ARRAY_SIZE * 8) { fprintf(stderr, "tracepoint id(%d) is bigger than %d\n", id, IDS_ARRAY_SIZE * 8); close(fd); return -1; } set_id(id); close(fd); return 0; }
protobuf::StackFrame* getProtobufStackFrame(JS::ubi::StackFrame& frame) { MOZ_ASSERT(frame, "null frames should be represented as the lack of a serialized " "stack frame"); auto id = frame.identifier(); auto protobufStackFrame = MakeUnique<protobuf::StackFrame>(); if (!protobufStackFrame) return nullptr; if (framesAlreadySerialized.has(id)) { protobufStackFrame->set_ref(id); return protobufStackFrame.release(); } auto data = MakeUnique<protobuf::StackFrame_Data>(); if (!data) return nullptr; data->set_id(id); data->set_line(frame.line()); data->set_column(frame.column()); data->set_issystem(frame.isSystem()); data->set_isselfhosted(frame.isSelfHosted()); auto source = MakeUnique<std::string>(frame.sourceLength() * sizeof(char16_t), '\0'); if (!source) return nullptr; auto buf = const_cast<char16_t*>(reinterpret_cast<const char16_t*>(source->data())); frame.source(RangedPtr<char16_t>(buf, frame.sourceLength()), frame.sourceLength()); data->set_allocated_source(source.release()); auto nameLength = frame.functionDisplayNameLength(); if (nameLength > 0) { auto functionDisplayName = MakeUnique<std::string>(nameLength * sizeof(char16_t), '\0'); if (!functionDisplayName) return nullptr; auto buf = const_cast<char16_t*>(reinterpret_cast<const char16_t*>(functionDisplayName->data())); frame.functionDisplayName(RangedPtr<char16_t>(buf, nameLength), nameLength); data->set_allocated_functiondisplayname(functionDisplayName.release()); } auto parent = frame.parent(); if (parent) { auto protobufParent = getProtobufStackFrame(parent); if (!protobufParent) return nullptr; data->set_allocated_parent(protobufParent); } protobufStackFrame->set_allocated_data(data.release()); if (!framesAlreadySerialized.put(id)) return nullptr; return protobufStackFrame.release(); }
Note<Time>::Note(const Note<Time>& copy) : _on_event(copy._on_event, true) , _off_event(copy._off_event, true) { set_id (copy.id()); assert(_on_event.buffer()); assert(_off_event.buffer()); /* assert(copy._on_event.size == 3); _on_event.buffer = _on_event_buffer; memcpy(_on_event_buffer, copy._on_event_buffer, 3); assert(copy._off_event.size == 3); _off_event.buffer = _off_event_buffer; memcpy(_off_event_buffer, copy._off_event_buffer, 3); */ assert(time() == copy.time()); assert(end_time() == copy.end_time()); assert(length() == copy.length()); assert(note() == copy.note()); assert(velocity() == copy.velocity()); assert(_on_event.channel() == _off_event.channel()); assert(channel() == copy.channel()); }
void create(void) { ::create(); set_id("door"); set_short("A wooden door"); set_long("Your average wooden door."); set_gettable(0); set_open_state(0); }
void setup() { set_id ("wall", "passage"); set_long( "You are unable to quite see where it slides." ); set_close_msg( "The rock slides back." ); set_open_msg( "The rock slides open, allowing you to exit northwards."); setup_door("dock wall", "north", "/domains/std/rooms/caves/Small_Dock"); }
void setup(void) { ::setup(); set_id("whip"); set_adj("leather"); set_short("A leather whip"); set_long("A long leather whip turned black by all the dried blood."); set_weapon_actions(({ "crack", "whip" }));
int create_instance_backing (ncInstance * instance) { int ret = ERROR; virtualMachine * vm = &(instance->params); artifact * sentinel = NULL; // ensure instance directory exists set_path (instance->instancePath, sizeof (instance->instancePath), instance, NULL); if (ensure_directories_exist (instance->instancePath, 0, NULL, "root", BACKING_DIRECTORY_PERM) == -1) goto out; // set various instance-directory-relative paths in the instance struct set_path (instance->xmlFilePath, sizeof (instance->xmlFilePath), instance, "instance.xml"); set_path (instance->libvirtFilePath, sizeof (instance->libvirtFilePath), instance, "libvirt.xml"); set_path (instance->consoleFilePath, sizeof (instance->consoleFilePath), instance, "console.log"); if (strstr (instance->platform, "windows")) { // generate the floppy file for windows instances if (makeWindowsFloppy (nc_state.home, instance->instancePath, instance->keyName, instance->instanceId)) { logprintfl (EUCAERROR, "[%s] error: could not create windows bootup script floppy\n", instance->instanceId); goto out; } else { set_path (instance->floppyFilePath, sizeof (instance->floppyFilePath), instance, "floppy"); } } char work_prefix [1024]; // {userId}/{instanceId} set_id (instance, NULL, work_prefix, sizeof (work_prefix)); // compute tree of dependencies sentinel = vbr_alloc_tree (vm, // the struct containing the VBR FALSE, // for Xen and KVM we do not need to make disk bootable TRUE, // make working copy of runtime-modifiable files (instance->do_inject_key)?(instance->keyName):(NULL), // the SSH key instance->instanceId); // ID is for logging if (sentinel == NULL) { logprintfl (EUCAERROR, "[%s] error: failed to prepare backing for instance\n", instance->instanceId); goto out; } sem_p (disk_sem); // download/create/combine the dependencies int rc = art_implement_tree (sentinel, work_bs, cache_bs, work_prefix, INSTANCE_PREP_TIMEOUT_USEC); sem_v (disk_sem); if (rc != OK) { logprintfl (EUCAERROR, "[%s] error: failed to implement backing for instance\n", instance->instanceId); goto out; } if (save_instance_struct (instance)) // update instance checkpoint now that the struct got updated goto out; ret = OK; out: if (sentinel) art_free (sentinel); return ret; }
Peer::Peer(const string &configFile) { config = new Configuration(configFile); set_id(get_host_id(config->hostIdType)); schedulerVec = read_from_file(config->schedulerMemFile); set_index(get_self_idx(get_id(), schedulerVec)); running = true; numZHTMsg = 0; init_zht_client(config->zhtConfigFile, config->zhtMemFile); }
void CommandSocket::sendGCodeLayer() { auto message = std::make_shared<cura::proto::GCodeLayer>(); message->set_id(d->object_ids[0]); message->set_data(d->gcode_output_stream.str()); d->socket->sendMessage(message); d->gcode_output_stream.str(""); }