// example: // stopwatch watch; // watch.mark("one"); // sleep(1000); // watch.mark("two"); // std::cout << watch.duration("one","two"); // sleep(1000); // watch.mark("three"); // std::cout << watch.duration("one","three"); dura_type duration(const std::string& checkpoint_1,const std::string& checkpoint_2)const { time_point_vec::const_iterator tp1=find_by_label(checkpoint_1); time_point_vec::const_iterator tp2=find_by_label(checkpoint_2); return tp2->second - tp1->second; }
int find_dp(struct part_iter **_iter) { struct part_iter *iter = NULL; struct disk_info diskinfo; struct guid gpt_guid; uint64_t fs_lba; int drive, hd, partition; const union syslinux_derivative_info *sdi; sdi = syslinux_derivative_info(); if (!strncmp(opt.drivename, "mbr", 3)) { if (find_by_sig(strtoul(opt.drivename + 4, NULL, 0), &iter) < 0) { error("Unable to find requested MBR signature."); goto bail; } } else if (!strncmp(opt.drivename, "guid", 4)) { if (str_to_guid(opt.drivename + 5, &gpt_guid)) goto bail; if (find_by_guid(&gpt_guid, &iter) < 0) { error("Unable to find requested GPT disk or partition by guid."); goto bail; } } else if (!strncmp(opt.drivename, "label", 5)) { if (!opt.drivename[6]) { error("No label specified."); goto bail; } if (find_by_label(opt.drivename + 6, &iter) < 0) { error("Unable to find requested GPT partition by label."); goto bail; } } else if ((opt.drivename[0] == 'h' || opt.drivename[0] == 'f') && opt.drivename[1] == 'd') { hd = opt.drivename[0] == 'h' ? 0x80 : 0; opt.drivename += 2; drive = hd | strtol(opt.drivename, NULL, 0); if (disk_get_params(drive, &diskinfo)) goto bail; /* this will start iteration over FDD, possibly raw */ if (!(iter = pi_begin(&diskinfo, opt.piflags))) goto bail; } else if (!strcmp(opt.drivename, "boot") || !strcmp(opt.drivename, "fs")) { if (!is_phys(sdi->c.filesystem)) { error("When syslinux is not booted from physical disk (or its emulation),\n" "'boot' and 'fs' are meaningless."); goto bail; } /* offsets match, but in case it changes in the future */ if (sdi->c.filesystem == SYSLINUX_FS_ISOLINUX) { drive = sdi->iso.drive_number; fs_lba = *sdi->iso.partoffset; } else { drive = sdi->disk.drive_number; fs_lba = *sdi->disk.partoffset; } if (disk_get_params(drive, &diskinfo)) goto bail; /* this will start iteration over disk emulation, possibly raw */ if (!(iter = pi_begin(&diskinfo, opt.piflags))) goto bail; /* 'fs' => we should lookup the syslinux partition number and use it */ if (!strcmp(opt.drivename, "fs")) { do { if (iter->abs_lba == fs_lba) break; } while (!pi_next(iter)); /* broken part structure or other problems */ if (iter->status) { error("Unable to find partition with syslinux (fs)."); goto bail; } } } else { error("Unparsable drive specification."); goto bail; } /* main options done - only thing left is explicit partition specification, * if we're still at the disk stage with the iterator AND user supplied * partition number (including disk pseudo-partition). */ if (!iter->index && opt.partition) { partition = strtol(opt.partition, NULL, 0); /* search for matching part#, including disk */ do { if (iter->index == partition) break; } while (!pi_next(iter)); if (iter->status) { error("Unable to find requested disk / partition combination."); goto bail; } } if (!(iter->di.disk & 0x80) && iter->index) { warn("Partitions on floppy devices may not work."); } *_iter = iter; return 0; bail: pi_del(&iter); return -1; }