From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: From: jon@ringle.org Date: Fri, 3 Aug 2018 11:44:55 -0400 Message-Id: <1533311096-14315-1-git-send-email-jon@ringle.org> Subject: [ptxdist] [PATCH v4 1/2] Add libfaketime as a core component of ptxdist for patchin support List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: ptxdist-bounces@pengutronix.de Sender: "ptxdist" To: ptxdist@pengutronix.com Cc: Jon Ringle RnJvbTogSm9uIFJpbmdsZSA8anJpbmdsZUBncmlkcG9pbnQuY29tPgoKbGliZmFrZXRpbWUgd2ls bCBiZSB1c2VkIGR1cmluZyBwYXRjaGluIHNvIHRoYXQgY29tbWl0dGVyIHRpbWVzdGFtcHMgYWx3 YXlzCmhhdmUgYSBmaXhlZCB2YWx1ZSBhbmQgdGhlcmVmb3JlIG1ha2luZyB0aGUgJHtQS0d9X1NF UklFU19TSEEyNTYgdmFsdWUKcmVwZWF0YWJsZQoKVGhlIG1pbmltYWwgc2V0IG9mIHNvdXJjZSBm aWxlcyB3YXMgcGlja2VkIG91dCBvZiBsaWJmYWtldGltZS0wLjkuNwoKU2lnbmVkLW9mZi1ieTog Sm9uIFJpbmdsZSA8anJpbmdsZUBncmlkcG9pbnQuY29tPgotLS0KIE1ha2VmaWxlLmluICAgICAg ICAgICAgICAgICAgICAgICAgICAgfCAgIDE0ICstCiBzY3JpcHRzL2xpYmZha2V0aW1lL01ha2Vm aWxlICAgICAgICAgIHwgIDExOCArKwogc2NyaXB0cy9saWJmYWtldGltZS9mYWtldGltZS5jICAg ICAgICB8ICAzODUgKysrKysrCiBzY3JpcHRzL2xpYmZha2V0aW1lL2Zha2V0aW1lX2NvbW1vbi5o IHwgICA2MSArCiBzY3JpcHRzL2xpYmZha2V0aW1lL2xpYmZha2V0aW1lLmMgICAgIHw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2l0aG91dCBpbnN0YWxsYXRpb24sIHRyeSBtYWtlIFBSRUZJWD0gTElCRElSTkFNRT0n LicKKworQ0MgPz0gZ2NjCitJTlNUQUxMID89IGluc3RhbGwKKworUFJFRklYID89IC91c3IvbG9j YWwKK0xJQkRJUk5BTUUgPz0gL2xpYi9mYWtldGltZQorUExBVEZPUk0gPz0kKHNoZWxsIHVuYW1l KQorCitDRkxBR1MgKz0gLXN0ZD1nbnU5OSAtV2FsbCAtV2V4dHJhIC1XZXJyb3IgLVduby1ub25u dWxsLWNvbXBhcmUgLURGQUtFX1NUQVQgLURGQUtFX1NMRUVQIC1ERkFLRV9USU1FUlMgLURGQUtF X0lOVEVSTkFMX0NBTExTIC1mUElDIC1EUFJFRklYPSciJyQoUFJFRklYKSciJyAtRExJQkRJUk5B TUU9JyInJChMSUJESVJOQU1FKSciJworaWZlcSAoJChQTEFURk9STSksU3VuT1MpCitDRkxBR1Mg Kz0gLURfX0VYVEVOU0lPTlNfXyAtRF9YT1BFTl9TT1VSQ0U9NjAwCitlbmRpZgorCitMSUJfTERG TEFHUyArPSAtc2hhcmVkCisKK0xERkxBR1MgKz0gLWxwdGhyZWFkCitpZm5lcSAoJChQTEFURk9S TSksU3VuT1MpCitMREZMQUdTICs9IC1XbCwtLXZlcnNpb24tc2NyaXB0PWxpYmZha2V0aW1lLm1h cAorZW5kaWYKKworTERBREQgKz0gLWxkbCAtbG0gLWxydAorQklOX0xERkxBR1MgKz0gLWxydAor CitTUkMgPSBsaWJmYWtldGltZS5jCitMSUJTX09CSiA9IGxpYmZha2V0aW1lLm8gbGliZmFrZXRp bWVNVC5vCitCSU5TID0gZmFrZXRpbWUKKworU09OQU1FID0gMQorTElCUyA9IGxpYmZha2V0aW1l LnNvLiR7U09OQU1FfSBsaWJmYWtldGltZU1ULnNvLiR7U09OQU1FfQorCithbGw6ICR7TElCU30g JHtCSU5TfQorCitsaWJmYWtldGltZU1ULm86IEVYVFJBX0ZMQUdTIDo9IC1EUFRIUkVB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2Vf bXQgPSBmYWxzZSwgdXNlX2RpcmVjdCA9IGZhbHNlOworICBsb25nIG9mZnNldDsKKworICB3aGls ZShjdXJyX29wdCA8IGFyZ2MpCisgIHsKKyAgICBpZiAoMCA9PSBzdHJjbXAoYXJndltjdXJyX29w dF0sICItbSIpKQorICAgIHsKKyAgICAgIHVzZV9tdCA9IHRydWU7CisgICAgICBjdXJyX29wdCsr OworICAgICAgY29udGludWU7CisgICAgfQorICAgIGVsc2UgaWYgKDAgPT0gc3RyY21wKGFyZ3Zb Y3Vycl9vcHRdLCAiLWYiKSkKKyAgICB7CisgICAgICB1c2VfZGlyZWN0ID0gdHJ1ZTsKKyAgICAg IGN1cnJfb3B0Kys7CisgICAgICBjb250aW51ZTsKKyAgICB9CisgICAgZWxzZSBpZiAoMCA9PSBz dHJjbXAoYXJndltjdXJyX29wdF0sICItLWV4Y2x1ZGUtbW9ub3RvbmljIikpCisgICAgeworICAg ICAgc2V0ZW52KCJET05UX0ZBS0VfTU9OT1RPTklDIiwgIjEiLCB0cnVlKTsKKyAgICAgIGN1cnJf b3B0Kys7CisgICAgICBjb250aW51ZTsKKyAgICB9CisgICAgZWxzZSBpZiAoKDAgPT0gc3RyY21w KGFyZ3ZbY3Vycl9vcHRdLCAiLXYiKSkgfHwKKyAgICAgICAgICAgICAoMCA9PSBzdHJjbXAoYXJn dltjdXJyX29wdF0sICItLXZlcnNpb24iKSkpCisgICAgeworICAgICAgcHJpbnRmKCJcbiVzOiBW ZXJzaW9uICVzXG4iCisgICAgICAgICAiRm9yIHVzYWdlIGluZm9ybWF0aW9uIHBsZWFzZSB1c2Ug JyVzIC0taGVscCcuXG4iLAorICAgICAgICAgYXJndlswXSwgdmVyc2lvbiwgYXJndlswXSk7Cisg ICAgICBleGl0KEVYSVRfU1VDQ0VTUyk7CisgICAgfQorICAgIGVsc2UgaWYgKCgwID09IHN0cmNt cChhcmd2W2N1cnJfb3B0XSwgIi1oIikpIHx8CisgICAgICAgICAgICAgKDAgPT0gc3RyY21wKGFy Z3ZbY3Vycl9vcHRdLCAiLT8iKSkgfHwKKyAgICAgICAgICAgICAoMCA9PSBzdHJjbXAoYXJndltj dXJyX29wdF0sICItLWhlbHAiKSkpCisgICAgeworICAgICAgdXNhZ2UoYXJndlswXSk7CisgICAg ICBleGl0KEVYSVRfU1VDQ0VTUyk7CisgICAgfQorICAgIGVsc2UKKyAgICB7CisgICAgICAvKiB3 ZSBwYXJzZWQgYWxsIG9wdGlvbnMgKi8KKyAgICAgIGJyZWFrOworICAgIH0KKyAgfQorCisgIC8q IHdlIG5lZWQgYXQgbGVhc3QgYSB0aW1lc3RhbXAgc3RyaW5nIGFuZCBhIGNvbW1hbmQgdG8gcnVu ICovCisgIGlmIChhcmdjIC0gY3Vycl9vcHQgPCAyKQorICB7CisgICAgdXNhZ2UoYXJndlswXSk7 CisgICAgZXhpdChFWElUX0ZBSUxVUkUpOworICB9CisKKyAgaWYgKCF1c2VfZGlyZWN0KQorICB7 CisgICAgLy8gVE9ETyBnZXQgc2Vjb25kcworICAgIGludCBwZmRzWzJdOworICAgICh2b2lkKSAo cGlwZShwZmRzKSArIDEpOworICAgIGludCByZXQgPSBFWElUX1NVQ0NFU1M7CisKKyAgICBpZiAo MCA9PSAoY2hpbGRfcGlkID0gZm9yaygpKSkKKyAgICB7CisgICAgICBjbG9zZSgxKTsgICAgICAg LyogY2xvc2Ugbm9ybWFsIHN0ZG91dCAqLworICAgICAgKHZvaWQpIChkdXAocGZkc1sxXSkgKyAx KTsgICAvKiBtYWtlIHN0ZG91dCBzYW1lIGFzIHBmZHNbMV0gKi8KKyAgICAgIGNsb3NlKHBmZHNb MF0pOyAvKiB3ZSBkb24ndCBuZWVkIHRoaXMgKi8KKyAgICAgIGlmIChFWElUX1NVQ0NFU1MgIT0g ZXhlY2xwKGRhdGVfY21kLCBkYXRlX2NtZCwgIi1kIiwgYXJndltjdXJyX29wdF0sICIrJXMiLChj aGFyICopIE5VTEwpKQorICAgICAgeworICAgICAgICBwZXJyb3IoIlJ1bm5pbmcgKGcpZGF0ZSBm YWlsZWQiKTsKKyAgICAgICAgZXhpdChFWElUX0ZBSUxVUkUpOworICAgICAgfQorICAgIH0KKyAg ICBlbHNlCisgICAgeworICAgICAgY2hhciBidWZbMjU2XSA9IHswfTsgLyogZSB3aWxsIGhhdmUg d2F5IGxlc3MgdGhhbiAyNTYgZGlnaXRzICovCisgICAgICBjbG9zZShwZmRzWzFdKTsgICAvKiB3 ZSB3b24ndCB3cml0ZSB0byB0aGlzICovCisgICAgICAodm9pZCkgKHJlYWQocGZkc1swXSwgYnVm LCAyNTYpICsgMSk7CisgICAgICB3YWl0cGlkKGNoaWxkX3BpZCwgJnJldCwgMCk7CisgICAgICBp ZiAocmV0ICE9IEVYSVRfU1VDQ0VTUykKKyAgICAgIHsKKyAgICAgICAgcHJpbnRmKCJFcnJvcjog VGltZXN0YW1wIHRvIGZha2Ugbm90IHJlY29nbml6ZWQsIHBsZWFzZSByZS10cnkgd2l0aCBhICIK KyAgICAgICAgICAgICAgICJkaWZmZXJlbnQgdGltZXN0YW1wLlxuIik7CisgICAgICAgIGV4aXQo RVhJVF9GQUlMVVJFKTsKKyAgICAgIH0KKyAgICAgIG9mZnNldCA9IGF0b2woYnVmKSAtIHRpbWUo TlVMTCk7CisgICAgICByZXQgPSBzbnByaW50ZihidWYsIHNpemVvZihidWYpLCAiJXMlbGQiLCAo b2Zmc2V0ID49IDApPyIrIjoiIiwgb2Zmc2V0KTsKKyAgICAgIHNldGVudigiRkFLRVRJTUUiLCBi dWYsIHRydWUpOworICAgICAgY2xvc2UocGZkc1swXSk7IC8qIGZpbmlzaGVkIHJlYWRpbmcgKi8K KyAgICB9CisgIH0KKyAgZWxzZQorICB7CisgICAgLyogc2ltcGx5IHBhc3MgZm9ybWF0IHN0cmlu ZyBhbG9uZyAqLworICAgIHNldGVudigiRkFLRVRJTUUiLCBhcmd2W2N1cnJfb3B0XSwgdHJ1ZSk7 CisgIH0KKyAgaW50IGtlZXBhbG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SAoc2VtID0gc2VtX29w ZW4oc2VtX25hbWUsIE9fQ1JFQVR8T19FWENMLCBTX0lXVVNSfFNfSVJVU1IsIDEpKSkKKyAgICB7 CisgICAgICBwZXJyb3IoInNlbV9vcGVuIik7CisgICAgICBleGl0KEVYSVRfRkFJTFVSRSk7Cisg ICAgfQorCisgICAgLyogY3JlYXRlIHNobSAqLworICAgIGlmICgtMSA9PSAoc2htX2ZkID0gc2ht X29wZW4oc2htX25hbWUsIE9fQ1JFQVR8T19FWENMfE9fUkRXUiwgU19JV1VTUnxTX0lSVVNSKSkp CisgICAgeworICAgICAgcGVycm9yKCJzaG1fb3BlbiIpOworICAgICAgaWYgKC0xID09IHNlbV91 bmxpbmsoYXJndlsyXSkpCisgICAgICB7CisgICAgICAgIHBlcnJvcigic2VtX3VubGluayIpOwor ICAgICAgfQorICAgICAgZXhpdChFWElUX0ZBSUxVUkUpOworICAgIH0KKworICAgIC8qIHNldCBz aG0gc2l6ZSAqLworICAgIGlmICgtMSA9PSBmdHJ1bmNhdGUoc2htX2ZkLCBzaXplb2YodWludDY0 X3QpKSkKKyAgICB7CisgICAgICBwZXJyb3IoImZ0cnVuY2F0ZSIpOworICAgICAgY2xlYW51cF9z aG9ianMoKTsKKyAgICAgIGV4aXQoRVhJVF9GQUlMVVJFKTsKKyAgICB9CisKKyAgICAvKiBtYXAg c2htICovCisgICAgaWYgKE1BUF9GQUlMRUQgPT0gKGZ0X3NoYXJlZCA9IG1tYXAoTlVMTCwgc2l6 ZW9mKHN0cnVjdCBmdF9zaGFyZWRfcyksIFBST1RfUkVBRHxQUk9UX1dSSVRFLAorICAgICAgICAg ICAgICAgICAgICAgICAgTUFQX1NIQVJFRCwgc2htX2ZkLCAwKSkpCisgICAgeworICAgICAgcGVy cm9yKCJtbWFwIik7CisgICAgICBjbGVhbnVwX3Nob2JqcygpOworICAgICAgZXhpdChFWElUX0ZB SUxVUkUpOworICAgIH0KKworICAgIGlmIChzZW1fd2FpdChzZW0pID09IC0xKQ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ob3BlIHRoYXQgaXQgd2lsbCBiZSB1c2Vm dWwsIGJ1dCBXSVRIT1VUCisgKiAgQU5ZIFdBUlJBTlRZOyB3aXRob3V0IGV2ZW4gdGhlIGltcGxp ZWQgd2FycmFudHkgb2YgTUVSQ0hBTlRBQklMSVRZIG9yCisgKiAgRklUTkVTUyBGT1IgQSBQQVJU SUNVTEFSIFBVUlBPU0UuICBTZWUgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGZvcgor ICogIG1vcmUgZGV0YWlscy4KKyAqCisgKiAgWW91IHNob3VsZCBoYXZlIHJlY2VpdmVkIGEgY29w eSBvZiB0aGUgR05VIEdlbmVyYWwgUHVibGljIExpY2Vuc2UgdjIgYWxvbmcKKyAqICB3aXRoIHRo ZSBsaWJmYWtldGltZTsgaWYgbm90LCB3cml0ZSB0byB0aGUgRnJlZSBTb2Z0d2FyZSBGb3VuZGF0 aW9uLAorICogIEluYy4sIDU5IFRlbXBsZSBQbGFjZSwgU3VpdGUgMzMwLCBCb3N0b24sIE1BICAw MjExMS0xMzA3ICBVU0EKKyAqLworCisvKgorICogICAgICA9PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICogICAg ICBHbG9iYWwgc2V0dGluZ3MsIGluY2x1ZGVzLCBhbmQgbWFjcm9zICAgICAgICAgICAgICAgICAg ICAgICAgICA9PT0gSEVBRAorICogICAgICA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQorICovCisKKyNkZWZpbmUg X0dOVV9TT1VSQ0UgICAgICAgICAgICAgLyogcmVxdWlyZWQgdG8gZ2V0IFJUTERfTkVYVCBkZWZp bmVkICovCisKKyNpbmNsdWRlIDxzdGRpby5oPgorI2luY2x1ZGUgPHN0ZGxpYi5oPgorI2luY2x1 ZGUgPHN0ZGludC5oPgorI2luY2x1ZGUgP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gICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgXAorICAgIGJvb2wgZG9udF9mYWtlX29yaWcgPSBkb250X2Zha2U7ICBcCisgICAgaWYg KCFkb250X2Zha2UpICAgICAgICAgICAgICAgICAgIFwKKyAgICB7ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgXAorICAgICAgZG9udF9mYWtlID0gdHJ1ZTsgICAgICAgICAgICAgICBc CisgICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICBjYWxsOyAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIGRvbnRfZmFrZSA9IGRvbnRfZmFrZV9vcmln OyAgICAgICBcCisgIH0gd2hpbGUgKDApCisKKy8qIHBvaW50ZXJzIHRvIHJlYWwgKG5vdCBmYWtl ZCkgZnVuY3Rpb25zICovCitzdGF0aWMgaW50ICAgICAgICAgICgqcmVhbF9zdGF0KSAgICAgICAg ICAgIChpbnQsIGNvbnN0IGNoYXIgKiwgc3RydWN0IHN0YXQgKik7CitzdGF0aWMgaW50ICAgICAg ICAgICgqcmVhbF9mc3RhdCkgICAgICAgICAgIChpbnQsIGludCwgc3RydWN0IHN0YXQgKik7Citz dGF0aWMgaW50ICAgICAgICAgICgqcmVhbF9mc3RhdGF0KSAgICAgICAgIChpbnQsIGludCwgY29u c3QgY2hhciAqLCBzdHJ1Y3Qgc3RhdCAqLCBpbnQpOworc3RhdGljIGludCAgICAgICAgICAoKnJl YWxfbHN0YXQpICAgICAgICAgICAoaW50LCBjb25zdCBjaGFyICosIHN0cnVjdCBzdGF0ICopOwor c3RhdGljIGludCAgICAgICAgICAoKnJlYWxfc3RhdDY0KSAgICAgICAgICAoaW50LCBjb25zdCBj aGFyICosIHN0cnVjdCBzdGF0NjQgKik7CitzdGF0aWMgaW50ICAgICAgICAgICgqcmVhbF9mc3Rh dDY0KSAgICAgICAgIChpbnQsIGludCAsIHN0cnVjdCBzdGF0NjQgKik7CitzdGF0aWMgaW50ICAg ICAgICAgICgqcmVhbF9mc3RhdGF0NjQpICAgICAgIChpbnQsIGludCAsIGNvbnN0IGNoYXIgKiwg c3RydWN0IHN0YXQ2NCAqLCBpbnQpOworc3RhdGljIGludCAgICAgICAgICAoKnJlYWxfbHN0YXQ2 NCkgICAgICAgICAoaW50LCBjb25zdCBjaGFyICosIHN0cnVjdCBzdGF0NjQgKik7CitzdGF0aWMg dGltZV90ICAgICAgICgqcmVhbF90aW1lKSAgICAgICAgICAgICh0aW1lX3QgKik7CitzdGF0aWMg aW50ICAgICAgICAgICgqcmVhbF9mdGltZSkgICAgICAgICAgIChzdHJ1Y3QgdGltZWIgKik7Citz dGF0aWMgaW50ICAgICAgICAgICgqcmVhbF9nZXR0aW1lb2ZkYXkpICAgIChzdHJ1Y3QgdGltZXZh bCAqLCB2b2lkICopOworc3RhdGljIGludCAgICAgICAgICAoKnJlYWxfY2xvY2tfZ2V0dGltZSkg ICAoY2xvY2tpZF90IGNsa19pZCwgc3RydWN0IHRpbWVzcGVjICp0cCk7CisjaWZkZWYgRkFLRV9J TlRFUk5BTF9DQUxMUworc3RhdGljIGludCAgICAgICAgICAoKnJlYWxfX19mdGltZSkgICAgICAg ICAgIChzdHJ1Y3QgdGltZWIgKik7CitzdGF0aWMgaW50ICAgICAgICAgICgqcmVhbF9fX2dldHRp bWVvZmRheSkgICAgKHN0cnVjdCB0aW1ldmFsICosIHZvaWQgKik7CitzdGF0aWMgaW50ICAgICAg ICAgICgqcmVhbF9fX2Nsb2NrX2dldHRpbWUpICAgKGNsb2NraWRfdCBjbGtfaWQsIHN0cnVjdCB0 aW1lc3BlYyAqdHApOworI2VuZGlmCisjaWZuZGVmIF9fQVBQTEVPU1hfXworI2lmZGVmIEZBS0Vf VElNRVJTCitzdGF0aWMgaW50ICAgICAgICAgICgqcmVhbF90aW1lcl9zZXR0aW1lXzIyKSAgIChp bnQgdGltZXJpZCwgaW50IGZsYWdzLCBjb25zdCBzdHJ1Y3QgaXRpbWVyc3BlYyAqbmV3X3ZhbHVl LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0 IGl0aW1lcnNwZWMgKiBvbGRfdmFsdWUpOworc3RhdGljIGludCAgICAgICAgICAoKnJlYWxfdGlt ZXJfc2V0dGltZV8yMzMpICAodGltZXJfdCB0aW1lcmlkLCBpbnQgZmxhZ3MsCisgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdHJ1Y3QgaXRpbWVy c3BlYyAqbmV3X3ZhbHVlLAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgc3RydWN0IGl0aW1lcnNwZWMgKiBvbGRfdmFsdWUpOworc3RhdGljIGludCAgICAg ICAgICAoKnJlYWxfdGltZXJfZ2V0dGltZV8yMikgICAoaW50IHRpbWVyaWQsCisgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdHJ1Y3QgaXRpbWVyc3BlYyAq Y3Vycl92YWx1ZSk7CitzdGF0aWMgaW50ICAgICAgICAgICgqcmVhbF90aW1lcl9nZXR0aW1lXzIz MykgICh0aW1lcl90IHRpbWVyaWQsCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICBzdHJ1Y3QgaXRpbWVyc3BlYyAqY3Vycl92YWx1ZSk7CisjZW5kaWYKKyNl bmRpZgorI2lmZGVmIEZBS0VfU0xFRVAKK3N0YXRpYyBpbnQgICAgICAgICAgKCpyZWFsX25hbm9z bGVlcCkgICAgICAgKGNvbnN0IHN0cnVjdCB0aW1lc3BlYyAqcmVxLCBzdHJ1Y3QgdGltZXNwZWMg KnJlbSk7CitzdGF0aWMgaW50ICAgICAgICAgICgqcmVhbF91c2xlZXApICAgICAgICAgICh1c2Vj b25kc190IHVzZWMpOworc3RhdGljIHVuc2lnbmVkIGludCAoKnJlYWxfc2xlZXApICAgICAgICAg ICAodW5zaWduZWQgaW50IHNlY29uZHMpOworc3RhdGljIHVuc2lnbmVkIGludCAoKnJlYWxfYWxh cm0pICAgICAgICAgICAodW5zaWduZWQgaW50IHNlY29uZHMpOworc3RhdGljIGludCAgICAgICAg ICAoKnJlYWxfcG9sbCkgICAgICAgICAgICAoc3RydWN0IHBvbGxmZCAqLCBuZmRzX3QsIGludCk7 CitzdGF0aWMgaW50ICAgICAgICAgICgqcmVhbF9wcG9sbCkgICAgICAgICAgIChzdHJ1Y3QgcG9s bGZkICosIG5mZHNfdCwgY29uc3Qgc3RydWN0IHRpbWVzcGVjICosIGNvbnN0IHNpZ3NldF90ICop Oworc3RhdGljIGludCAgICAgICAgICAoKnJlYWxfc2VsZWN0KSAgICAgICAgICAoaW50IG5mZHMs IGZkX3NldCAqcmVzdHJpY3QgcmVhZGZkcywKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIGZkX3NldCAqcmVzdHJpY3Qgd3JpdGVmZHMsCisgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmZF9zZXQgKnJlc3RyaWN0IGVycm9yZmRz LAorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3RydWN0IHRp bWV2YWwgKnJlc3RyaWN0IHRpbWVvdXQpOworc3RhdGljIGludCAgICAgICAgICAoKnJlYWxfc2Vt X3RpbWVkd2FpdCkgICAoc2VtX3QqLCBjb25zdCBzdHJ1Y3QgdGltZXNwZWMqKTsKKyNlbmRpZgor I2lmZGVmIF9fQVBQTEVPU1hfXworc3RhdGljIGludCAgICAgICAgICAoKnJlYWxfY2xvY2tfZ2V0 X3RpbWUpICAoY2xvY2tfc2Vydl90IGNsb2NrX3NlcnYsIG1hY2hfdGltZXNwZWNfdCAqY3VyX3Rp bWVjbG9ja2lkX3QpOworc3RhdGljIGludCAgICAgICAgICBhcHBsZV9jbG9ja19nZXR0aW1lICAg ICAoY2xvY2tpZF90IGNs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mdF9tb2RlX3Qge0ZUX0ZSRUVaRSwgRlRfU1RBUlRfQVQsIEZUX05PT1B9IGZ0X21vZGUg PSBGVF9GUkVFWkU7CisKKy8qIFRpbWUgdG8gZmFrZSBpcyBub3QgcHJvdmlkZWQgdGhyb3VnaCBG QUtFVElNRSBlbnYuIHZhci4gKi8KK3N0YXRpYyBib29sIHBhcnNlX2NvbmZpZ19maWxlID0gdHJ1 ZTsKKwordm9pZCBmdF9jbGVhbnVwICh2b2lkKSBfX2F0dHJpYnV0ZV9fICgoZGVzdHJ1Y3Rvcikp Owordm9pZCBmdHBsX2luaXQgKHZvaWQpIF9fYXR0cmlidXRlX18gKChjb25zdHJ1Y3RvcikpOwor CisKKy8qCisgKiAgICAgID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgICAgIFNoYXJlZCBtZW1vcnkgcmVs YXRlZCBmdW5jdGlvbnMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9PT0gU0hNCisg KiAgICAgID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09CisgKi8KKworc3RhdGljIHZvaWQgZnRfc2htX2luaXQgKHZv aWQpCit7CisgIGludCB0aWNrc19zaG1fZmQ7CisgIGNoYXIgc2VtX25hbWVbMjU2XSwgc2htX25h bWVbMjU2XSwgKmZ0X3NoYXJlZF9lbnYgPSBnZXRlbnYoIkZBS0VUSU1FX1NIQVJFRCIpOworCisg IGlmIChmdF9zaGFyZWRfZW52ICE9IE5VTEwpCisgIHsKKyAgICBpZiAoc3NjYW5mKGZ0X3NoYXJl ZF9lbnYsICIlMjU1cyAlMjU1cyIsIHNlbV9uYW1lLCBzaG1fbmFtZSkgPCAyKQorICAgIHsKKyAg ICAgIHByaW50ZigiRXJyb3IgcGFyc2luZyBzZW1hcGhvcmUgbmFtZSBhbmQgc2hhcmVkI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PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgICAgIEludGVybmFsIHRp bWUgcmV0cmlldmFsICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID09PSBJTlRU SU1FCisgKiAgICAgID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKi8KKworLyogR2V0IHN5c3RlbSB0aW1lIGZy b20gc3lzdGVtIGZvciBhbGwgY2xvY2tzICovCitzdGF0aWMgdm9pZCBzeXN0ZW1fdGltZV9mcm9t X3N5c3RlbSAoc3RydWN0IHN5c3RlbV90aW1lX3MgKiBzeXN0aW1lKQoreworI2lmZGVmIF9fQVBQ TEVPU1hfXworICAvKiBmcm9tIGh0dHA6Ly9zdGFja292ZXJmbG93LmNvbS9xdWVzdGlvbnMvNTE2 NzI2OS9jbG9jay1nZXR0aW1lLWFsdGVybmF0aXZlLWluLW1hYy1vcy14ICovCisgIGNsb2NrX3Nl cnZfdCBjY2xvY2s7CisgIG1hY2hfdGltZXNwZWNfdCBtdHM7CisgIGhvc3RfZ2V0X2Nsb2NrX3Nl cnZpY2UobWFjaF9ob3N0X3NlbGYoKSwgQ0FMRU5EQVJfQ0xPQ0ssICZjbG9ja19zZXJ2X3JlYWwp OworICAoKnJlYWxfY2xvY2tfZ2V0X3RpbWUpKGNsb2NrX3NlcnZfcmVhbCwgJm10cyk7CisgIHN5 c3RpbWUtPnJlYWwudHZfc2VjID0gbXRzLnR2X3NlYzsKKyAgc3lzdGltZS0+cmVhbC50dl9uc2Vj ID0gbXRzLnR2X25zZWM7CisgIGhvc3RfZ2V0X2Nsb2NrX3NlcnZpY2UobWFjaF9ob3N0X3NlbGYo KSwgU1lTVEVNX0NMT0NLLCAmY2Nsb2NrKTsKKyAgKCpyZWFsX2Nsb2NrX2dldF90aW1lKShjY2xv Y2ssICZtdHMpOworICB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sKKyAgICB9CisgICAgLyogY2FsY3VsYXRl IGFuZCB1cGRhdGUgZWxhcHNlZCB0aW1lICovCisgICAgdGltZXNwZWNtdWwodGlja2xlbiwgZnRf c2hhcmVkLT50aWNrcywgJmluYyk7CisgICAgdGltZXNwZWNhZGQoJnVzZXJfZmFrZWRfdGltZV90 aW1lc3BlYywgJmluYywgdHApOworICAgIChmdF9zaGFyZWQtPnRpY2tzKSsrOworICAgIC8qIHVu bG9jayAqLworICAgIGlmIChzZW1fcG9zdChzaGFyZWRfc2VtKSA9PSAtMSkKKyAgICB7CisgICAg ICBwZXJyb3IoInNlbV9wb3N0Iik7CisgICAgICBleGl0KDEpOworICAgIH0KKyAgfQorfQorCisK Ky8qCisgKiAgICAgID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAgICAgIFNhdmluZyAmIGxvYWRpbmcgdGlt ZSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID09PSBTQVZFCisgKiAg ICAgID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09CisgKi8KKworc3RhdGljIHZvaWQgc2F2ZV90aW1lKHN0cnVjdCB0 aW1lc3BlYyAqdHApCit7CisgIGlmICgoc2hhcmVkX3NlbSAhPSBOVUxMKSAmJiAob3V0ZmlsZSAh PSAtMSkpCisgIHsKKyAgICBzdHJ1Y3Qgc2F2ZWRfdGltZXN0YW1wIHRpbWVfd3JpdGU7CisgICAg c3NpemVfdCB3cml0dGVuOworICAgIHNpemVfdCBuID0gMDsKKworICAgIHRpbWVfd3JpdGUuc2Vj ID0gaHRvYmU2NCh0cC0+dHZfc2VjKTsKKyAgICB0aW1lX3dyaXRlLm5zZWMgPSBodG9iZTY0KHRw LT50dl9uc2VjKTsKKworICAgIC8qIGxvY2sgKi8KKyAgICBpZiAoc2VtX3dhaXQoc2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IHBlcnJvcigic2VtX3dhaXQiKTsKKyAgICAgIGV4aXQo MSk7CisgICAgfQorCisgICAgaWYgKChzaXplb2Yoc3Rzc1swXSkgKiAoZnRfc2hhcmVkLT5maWxl X2lkeCArIDEpKSA+IGluZmlsZV9zaXplKQorICAgIHsKKyAgICAgIC8qIHdlIGFyZSBvdXQgb2Yg dGltc3RhbXBzIHRvIHJlcGxheSwgcmV0dXJuIHRvIGZha2luZyB0aW1lIGJ5IHJ1bGVzCisgICAg ICAgKiB1c2luZyBsYXN0IHRpbWVzdGFtcCBmcm9tIGZpbGUgYXMgdGhlIHVzZXIgcHJvdmlkZWQg dGltZXN0YW1wICovCisgICAgICB0aW1lc3BlY19mcm9tX3NhdmVkKCZ1c2VyX2Zha2VkX3RpbWVf dGltZXNwZWMsICZzdHNzWyhpbmZpbGVfc2l6ZSAvIHNpemVvZihzdHNzWzBdKSkgLSAxIF0pOwor CisgICAgICBpZiAoZnRfc2hhcmVkLT50aWNrcyA9PSAwKQorICAgICAgeworICAgICAgICAvKiB3 ZSBzZXQgc2hhcmVkIG1lbW9yeSB0byBzdG9wIHVzaW5nIGluZmlsZSAqLworICAgICAgICBmdF9z aGFyZWQtPnRpY2tzID0gMTsKKyAgICAgICAgc3lzdGVtX3RpbWVfZnJvbV9zeXN0ZW0oJmZ0cGxf c3RhcnR0aW1lKTsKKyAgICAgICAgZnRfc2hhcmVkLT5zdGFydF90aW1lID0gZnRwbF9zdGFydHRp bWU7CisgICAgICB9CisgICAgICBlbHNlCisgICAgICB7CisgICAgICAgIGZ0cGxfc3RhcnR0aW1l ID0gZnRfc2hhcmVkLT5zdGFydF90aW1lOworICAgICAgfQorCisgICAgICBtdW5tYXAoc3Rzcywg aW5maWxlX3NpemUpOworICAgICAgaW5maWxlX3NldCA9IGZhbHNlOworICAgIH0KKyAgICBlbHNl CisgICAgeworICAgICAgdGltZXNwZWNfZnJvbV9zYXZlZCh0cCwgJnN0c3NbZnRfc2hhcmVkLT5m aWxlX2lkeF0pOworICAgICAgZnRfc2hhcmVkLT5maWxlX2lkeCsrOworICAgICAgcmV0ID0gdHJ1 ZTsKKyAgICB9CisKKyAgICAvKiB1bmxvY2sgKi8KKyAgICBpZiAoc2VtX3Bvc3Qoc2hhcmVkX3Nl bSkgPT0gLTEpCisgICAgeworICAgICAgcGVycm9yKCJzZW1fcG9zdCIpOworICAgICAgZXhpdCgx KTsKKyAgICB9CisgIH0KKyAgcmV0dXJuIHJldDsKK30KKworCisvKgorICogICAgICA9PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PQorICogICAgICBGYWtlZCBzeXN0ZW0gZnVuY3Rpb25zOiBmaWxlIHJlbGF0ZWQgICAg ICAgICAgICAgICAgICAgICA9PT0gRkFLRShGSUxFKQorICogICAgICA9PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQor ICovCisKKyNpZmRlZiBGQUtFX1NUQVQKKworI2lmbmRlZiBOT19BVEZJTEUKKyNpZm5kZWYgX0FU RklMRV9TT1VSQ0UKKyNkZWZpbmUgX0FURklMRV9TT1VSQ0UKKyNlbmRpZgorI2luY2x1ZGUgPGZj bnRsLmg+IC8qIERlZmluaXRpb24gb2YgQVRfKiBjb25zdGFudHMgKi8KKyNlbmRpZgorCisjaW5j bHVkZSA8c3lzL3N0YXQuaD4KKworc3RhdGljIGludCBmYWtlX3N0YXRfZGlzYWJsZWQgPSAwOwor CisjZGVmaW5lIEZBS0VfU1RSVUNUX1NUQVRfVElNRSh3aGljaCkgeyAgICAgICAgICAgICAgICBc CisgICAgc3RydWN0IHRpbWVzcGVjIHQgPSB7YnVmLT5zdF8jI3doaWNoIyN0aW1lLCAgICAgICBc CisgICAgICAgICAgICAgICAgICAgICAgICAgYnVmLT5zdF8jI3doaWNoIyN0aW1lbnNlY307ICBc CisgICAgZmFrZV9jbG9ja19nZXR0aW1l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OworI2VuZGlmCisgICAgcmV0dXJuIC0xOyAv KiBwcm9wYWdhdGUgZXJyb3IgdG8gY2FsbGVyICovCisgIH0KKworICBpbnQgcmVzdWx0OworICBE T05UX0ZBS0VfVElNRShyZXN1bHQgPSByZWFsX2ZzdGF0YXQodmVyLCBmaWxkZXMsIGZpbGVuYW1l LCBidWYsIGZsYWcpKTsKKyAgaWYgKHJlc3VsdCA9PSAtMSkKKyAgeworICAgIHJldHVybiAtMTsK KyAgfQorCisgIGlmIChidWYgIT0gTlVMTCkKKyAgeworICAgIGlmICghZmFrZV9zdGF0X2Rpc2Fi bGVkKQorICAgIHsKKyAgICAgIGZha2Vfc3RhdGJ1ZihidWYpOworICAgIH0KKyAgfQorICByZXR1 cm4gcmVzdWx0OworfQorI2VuZGlmCisKKy8qIENvbnRyaWJ1dGVkIGJ5IFBoaWxpcHAgSGFjaHRt YW5uIGluIHZlcnNpb24gMC42ICovCitpbnQgX19seHN0YXQgKGludCB2ZXIsIGNvbnN0IGNoYXIg KnBhdGgsIHN0cnVjdCBzdGF0ICpidWYpCit7CisgIGlmICghaW5pdGlhbGl6ZWQpCisgIHsKKyAg ICBmdHBsX2luaXQoKTsKKyAgfQorICBpZiAoTlVMTCA9PSByZWFsX2xzdGF0KQorICB7ICAvKiBk bHN5bSgpIGZhaWxlZCAqLworI2lmZGVmIERFQlVHCisgICAgKHZvaWQpIGZwcmludGYoc3RkZXJy LCAiZmFrZXRpbWUgcHJvYmxlbTogb3JpZ2luYWwgbHN0YXQoKSBub3QgZm91bmQuXG4iKTsKKyNl bmRpZgorICAgIHJldHVybiAtMTsgLyogcHJvcGFnYXRlIGVycm9yIHRvIGNhbGxlciAqLworICB9 CisKKyAgaW50IHJlc3VsdDsKKyAgRE9OVF9GQUtFX1RJTUUocmVzdWx0ID0gcmVhbF9sc3RhdCh2 ZXIsIHBhdGgsIGJ1ZikpOworICBpZiAocmVzdWx0ID09IC0xKQorICB7CisgICAgcmV0dXJuIC0x OworICB9CisKKyA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KKworICBpbnQgcmVzdWx0OworICBET05UX0ZB S0VfVElNRShyZXN1bHQgPSByZWFsX2xzdGF0NjQodmVyLCBwYXRoLCBidWYpKTsKKyAgaWYgKHJl c3VsdCA9PSAtMSkKKyAgeworICAgIHJldHVybiAtMTsKKyAgfQorCisgIGlmIChidWYgIT0gTlVM TCkKKyAgeworICAgIGlmICghZmFrZV9zdGF0X2Rpc2FibGVkKQorICAgIHsKKyAgICAgIGZha2Vf c3RhdDY0YnVmKGJ1Zik7CisgICAgfQorICB9CisgIHJldHVybiByZXN1bHQ7Cit9CisjZW5kaWYK KworLyoKKyAqICAgICAgPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqICAgICAgRmFrZWQgc3lzdGVtIGZ1bmN0 aW9uczogc2xlZXAvYWxhcm0vcG9sbC90aW1lciByZWxhdGVkICA9PT0gRkFLRShTTEVFUCkKKyAq ICAgICAgPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT0KKyAqICAgICAgQ29udHJpYnV0ZWQgYnkgQmFsaW50IFJlY3pl eSBpbiB2MC45LjUKKyAqLworCisjaWZkZWYgRkFLRV9TTEVFUAorLyoKKyAqIEZha2VkIG5hbm9z bGVlcCgpCisgKi8KK2ludCBuYW5vc2xlZXAoY29uc3Qgc3RydWN0IHRpbWVzcGVjICpyZXEsIHN0 cnVjdCB0aW1lc3BlYyAqcmVtKQoreworICBpbnQgcmVzdWx0OworICBzdHJ1Y3QgdGltZXNwZWMg cmVhbF9yZXE7CisKKyAgaWYgKCFpbml0aWFsaXplZCkKKyAgeworICAgIGZ0cGxfaW5pdCgpOwor ICB9CisgIGlmIChyZWFsX25hbm9zbGVlcCA9PSBOVUxMKQorICB7CisgICAgcmV0dXJuIC0xOwor ICB9CisgIGlmIChyZXEgIT0gTlVMTCkKKyAgeworICAgIGlmICh1c2VyX3JhdGVfc2V0ICYmICFk b250X2Zha2UpCisgICAgeworICAgICAgdGltZXNwZWNtdWwocmVxLCAxLjAgLyB1c2VyX3JhdGUs ICZyZWFsX3JlcSk7CisgICAgfQorICAgIGVsc2UKKyAgICB7CisgICAgICByZWFsX3JlcSA9ICpy ZXE7CisgICAgfQorICB9CisgIGVsc2UKKyAgeworICAgIHJldHVybiAtMTsKKyAgfQorCisgIERP TlRfRkFLRV9USU1FKHJlc3VsdCA9ICgqcmVhbF9uYW5vc2xlZXApKCZyZWFsX3JlcSwgcmVtKSk7 CisgIGlmIChyZXN1bHQgPT0gLTEpCisgIHsKKyAgICByZXR1cm4gcmVzdWx0OworICB9CisKKyAg LyogZmFrZSByZXR1cm5lZCBwYXJ0cyAqLworICBpZiAoKHJlbSAhPSBOVUxMKSAmJiAoKHJlbS0+ dHZfc2VjICE9IDApIHx8IChyZW0tPnR2X25zZWMgIT0gMCkpKQorICB7CisgICAgaWYgKHVzZXJf cmF0ZV9zZXQgJiYgIWRvbnRfZmFrZSkKKyAgICB7CisgICAgICB0aW1lc3BlY211bChyZW0sIHVz ZXJfcmF0ZSwgcmVtKTsKKyAgICB9CisgIH0KKyAgLyogcmV0dXJuIHRoZSByZXN1bHQgdG8gdGhl IGNhbGxlciAqLworICByZXR1cm4gcmVzdWx0OworfQorCisvKgorICogRmFrZWQgdXNsZWVwKCkK KyAqLworaW50IHVzbGVlcCh1c2Vjb25kc190IHVzZWMpCit7CisgIGludCByZXN1bHQ7CisKKyAg aWYgKCFpbml0aWFsaXplZCkKKyAgeworICAgIGZ0cGxfaW5pdCgpOworICB9CisgIGlmICh1c2Vy X3JhdGVfc2V0ICYmICFkb250X2Zha2UpCisgIHsKKyAgICBzdHJ1Y3QgdGltZXNwZWMgcmVhbF9y ZXE7CisKKyAgICBpZiAocmVhbF9uYW5vc2xlZXAgPT0gTlVMTCkKKyAgICB7CisgICAgICAvKiBm YWxsIGJhY2sgdG8gdXNsZWVwKCkgKi8KKyAgICAgIGlmIChyZWFsX3VzbGVlcCA9PSBOVUxMKQor ICAgICAgeworICAgICAgICByZXR1cm4gLTE7CisgICAgICB9CisgICAgICBET05UX0ZBS0VfVElN RShyZXN1bHQgPSAoKnJlYWxfdXNsZWVwKSgoMS4wIC8gdXNlcl9yYXRlKSAqIHVzZWMpKTsKKyAg ICAgIHJldHVybiByZXN1bHQ7CisgICAgfQorCisgICAgcmVhbF9yZXEudHZfc2VjID0gdXNlYyAv IDEwMDAwMDA7CisgICAgcmVhbF9yZXEudHZfbnNlYyA9ICh1c2VjICUgMTAwMDAwMCkgKiAxMDAw OworICAgIHRpbWVzcGVjbXVsKCZyZWFsX3JlcSwgMS4wIC8gdXNlcl9yYXRlLCAmcmVhbF9yZXEp OworICAgIERPTlRfRkFLRV9USU1FKHJlc3VsdCA9ICgqcmVhbF9uYW5vc2xlZXApKCZyZWFsX3Jl cSwgTlVMTCkpOworICB9CisgIGVsc2UKKyAgeworICAgIERPTlRfRkFLRV9USU1FKHJlc3VsdCA9 ICgqcmVhbF91c2xlZXApKHVzZWMpKTsKKyAgfQorICByZXR1cm4gcmVzdWx0OworfQorCisvKgor ICogRmFrZWQgc2xlZXAoKQorICovCit1bnNpZ25lZCBpbnQgc2xlZXAodW5zaWduZWQgaW50IHNl Y29uZHMpCit7CisgIGlmICghaW5pdGlhbGl6ZWQpCisgIHsKKyAgICBmdHBsX2luaXQoKTsKKyAg fQorICBpZiAodXNlcl9yYXRlX3NldCAmJiAhZG9udF9mYWtlKQorICB7CisgICAgaWYgKHJlYWxf bmFub3NsZWVwID09IE5VTEwpCisgICAgeworICAgICAgLyogZmFsbCBiYWNrIHRvIHNsZWVwICov CisgICAgICB1bnNpZ25lZCBpbnQgcmV0OworICAgICAgaWYgKHJlYWxfc2xlZXAgPT0gTlVMTCkK KyAgICAgIHsKKyAgICAgICAgcmV0dXJuIDA7CisgICAgICB9CisgICAgICBET05UX0ZBS0VfVElN RShyZXQgPSAoKnJlYWxfc2xlZXApKCgxLjAgLyB1c2VyX3JhdGUpICogc2Vjb25kcykpOworICAg ICAgcmV0dXJuICh1c2VyX3JhdGVfc2V0ICYmICFkb250X2Zha2UpPyh1c2VyX3JhdGUgKiByZXQp OnJldDsKKyAgICB9CisgICAgZWxzZQorICAgIHsKKyAgICAgIGludCByZXN1bHQ7CisgICAgICBz dHJ1Y3QgdGltZXNwZWMgcmVhbF9yZXEgPSB7c2Vjb25kcywgMH0sIHJlbTsKKyAgICAgIHRpbWVz cGVjbXVsKCZyZWFsX3JlcSwgMS4wIC8gdXNlcl9yYXRlLCAmcmVhbF9yZXEpOworICAgICAgRE9O VF9GQUtFX1RJTUUocmVzdWx0ID0gKCpyZWFsX25hbm9zbGVlcCkoJnJlYWxfcmVxLCAmcmVtKSk7 CisgICAgICBpZiAocmVzdWx0ID09IC0xKQorICAgICAgeworICAgICAgICByZXR1cm4gMDsKKyAg ICAgIH0KKworICAgICAgLyogZmFrZSByZXR1cm5lZCBwYXJ0cyAqLworICAgICAgaWYgKChyZW0u dHZfc2VjICE9IDApIHx8IChyZW0udHZfbnNlYyAhPSAwKSkKKyAgICAgIHsKKyAgICAgICAgdGlt ZXNwZWNtdWwoJnJlbSwgdXNlcl9yYXRlLCAmcmVtKTsKKyAgICAgIH0KKyAgICAgIC8qIHJldHVy biB0aGUgcmVzdWx0IHRvIHRoZSBjYWxsZXIgKi8KKyAgICAgIHJldHVybiByZW0udHZfc2VjOwor ICAgIH0KKyAgfQorICBlbHNlCisgIHsKKyAgICAvKiBubyBuZWVkIHRvIGZha2UgYW55dGhpbmcg Ki8KKyAgICB1bnNpZ25lZCBpbnQgcmV0OworICAgIERPTlRfRkFLRV9USU1FKHJldCA9ICgqcmVh bF9zbGVlcCkoc2Vjb25kcykpOworICAgIHJldHVybiByZXQ7CisgIH0KK30KKworLyoKKyAqIEZh a2VkIGFsYXJtKCkKKyAqIEBub3RlIGR1ZSB0byByb3VuZGluZyBhbGFybSgyKSB3aXRoIGZha2V0 aW1lIC1mICcrMCB4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h0aW1lb3V0X3Rz LT50dl9zZWMgPiAwKSkKKyAgICB7CisgICAgICB0aW1lc3BlY211bCh0aW1lb3V0X3RzLCAxLjAg LyB1c2VyX3JhdGUsICZyZWFsX3RpbWVvdXQpOworICAgICAgcmVhbF90aW1lb3V0X3B0ID0gJnJl YWxfdGltZW91dDsKKyAgICB9CisgICAgZWxzZQorICAgIHsKKyAgICAgIC8qIGNhc3QgYXdheSBj b25zdG5lc3MgKi8KKyAgICAgIHJlYWxfdGltZW91dF9wdCA9IChzdHJ1Y3QgdGltZXNwZWMgKil0 aW1lb3V0X3RzOworICAgIH0KKyAgfQorICBlbHNlCisgIHsKKyAgICByZWFsX3RpbWVvdXRfcHQg PSBOVUxMOworICB9CisKKyAgRE9OVF9GQUtFX1RJTUUocmV0ID0gKCpyZWFsX3Bwb2xsKShmZHMs IG5mZHMsIHJlYWxfdGltZW91dF9wdCwgc2lnbWFzaykpOworICByZXR1cm4gcmV0OworfQorCisv KgorICogRmFrZWQgcG9sbCgpCisgKi8KK2ludCBwb2xsKHN0cnVjdCBwb2xsZmQgKmZkcywgbmZk c190IG5mZHMsIGludCB0aW1lb3V0KQoreworICBpbnQgcmV0LCB0aW1lb3V0X3JlYWwgPSAodXNl cl9yYXRlX3NldCAmJiAhZG9udF9mYWtlICYmICh0aW1lb3V0ID4gMCkpPyh0aW1lb3V0IC8gdXNl cl9yYXRlKTp0aW1lb3V0OworCisgIGlmICghaW5pdGlhbGl6ZWQpCisgIHsKKyAgICBmdHBsX2lu aXQoKTsKKyAgfQorICBpZiAocmVhbF9wb2xsID09IE5VTEwpCisgIHsKKyAgICByZXR1cm4gLTE7 CisgIH0KKworICBET05UX0ZBS0VfVElNRShyZXQgPSAoKnJlYWxfcG9sbCkoZmRzLCBuZmRzLCB0 aW1lb3V0X3JlYWwpKTsKKyAgcmV0dXJuIHJldDsKK30KKworLyoKKyAqIEZha2VkIHNlbGVjdCgp CisgKi8KK2ludCBzZWxlY3QoaW50IG5mZHMsIGZkX3NldCAqcmVhZGZkcywKKyAgICAgICAgICAg ZmRfc2V0ICp3cml0ZWZkcywKKyAgICAgICAgICAgZmRfc2V0ICplcnJvcmZkcywKKyAgICAgICAg ICAgc3RydWN0IHRpbWV2YWwgKnRpbWVvdXQpCit7CisgIGludCByZXQ7CisgIHN0cnVjdCB0aW1l dmFsIHRpbWVvdXRfcmVhbDsKKworICBpZiAoIWluaXRpYWxpemVkKQorICB7CisgICAgZnRwbF9p bml0KCk7CisgIH0KKworICBpZiAocmVhbF9zZWxlY3QgPT0gTlVMTCkKKyAgeworICAgIHJldHVy biAtMTsKKyAgfQorCisgIGlmICh0aW1lb3V0ICE9IE5VTEwpCisgIHsKKyAgICBpZiAodXNlcl9y YXRlX3NldCAmJiAhZG9udF9mYWtlICYmICh0aW1lb3V0LT50dl9zZWMgPiAwIHx8IHRpbWVvdXQt PnR2X3VzZWMgPiAwKSkKKyAgICB7CisgICAgICBzdHJ1Y3QgdGltZXNwZWMgdHM7CisKKyAgICAg IHRzLnR2X3NlYyA9IHRpbWVvdXQtPnR2X3NlYzsKKyAgICAgIHRzLnR2X25zZWMgPSB0aW1lb3V0 LT50dl91c2VjICogMTAwMDsKKworICAgICAgdGltZXNwZWNtdWwoJnRzLCAxLjAgLyB1c2VyX3Jh dGUsICZ0cyk7CisKKyAgICAgIHRpbWVvdXRfcmVhbC50dl9zZWMgPSB0cy50dl9zZWM7CisgICAg ICB0aW1lb3V0X3JlYWwudHZfdXNlYyA9IHRzLnR2X25zZWMgLyAxMDAwOworICAgIH0KKyAgICBl bHNlCisgICAgeworICAgICAgdGltZW91dF9yZWFsLnR2X3NlYyA9IHRpbWVvdXQtPnR2X3NlYzsK KyAgICAgIHRpbWVvdXRfcmVhbC50dl91c2VjID0gdGltZW91dC0+dHZfdXNlYzsKKyAgICB9Cisg IH0KKworICBET05UX0ZBS0VfVElNRShyZXQgPSAoKnJlYWxfc2VsZWN0KShuZmRzLCByZWFkZmRz LCB3cml0ZWZkcywgZXJyb3Jm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VjICpuZXdfdmFsdWUsCisgICAgICAgICBzdHJ1Y3QgaXRpbWVy c3BlYyAqb2xkX3ZhbHVlLCBmdF9saWJfY29tcGF0IGNvbXBhdCkKK3sKKyAgaW50IHJlc3VsdDsK KyAgc3RydWN0IGl0aW1lcnNwZWMgbmV3X3JlYWw7CisgIHN0cnVjdCBpdGltZXJzcGVjICpuZXdf cmVhbF9wdCA9ICZuZXdfcmVhbDsKKworICBpZiAoIWluaXRpYWxpemVkKQorICB7CisgICAgZnRw bF9pbml0KCk7CisgIH0KKyAgaWYgKG5ld192YWx1ZSA9PSBOVUxMKQorICB7CisgICAgbmV3X3Jl YWxfcHQgPSBOVUxMOworICB9CisgIGVsc2UgaWYgKGRvbnRfZmFrZSkKKyAgeworICAgIC8qIGNh c3QgYXdheSBjb25zdG5lc3MqLworICAgIG5ld19yZWFsX3B0ID0gKHN0cnVjdCBpdGltZXJzcGVj ICopbmV3X3ZhbHVlOworICB9CisgIGVsc2UKKyAgeworICAgIC8qIHNldCBpdF92YWx1ZSAqLwor ICAgIGlmICgobmV3X3ZhbHVlLT5pdF92YWx1ZS50dl9zZWMgIT0gMCkgfHwKKyAgICAgICAgKG5l d192YWx1ZS0+aXRfdmFsdWUudHZfbnNlYyAhPSAwKSkKKyAgICB7CisgICAgICBpZiAoZmxhZ3Mg JiBUSU1FUl9BQlNUSU1FKQorICAgICAgeworICAgICAgICBzdHJ1Y3QgdGltZXNwZWMgdGRpZmYs IHRpbWVhZGo7CisgICAgICAgIHRpbWVzcGVjc3ViKCZuZXdfdmFsdWUtPml0X3ZhbHVlLCAmdXNl cl9mYWtlZF90aW1lX3RpbWVzcGVjLCAmdGltZWFkaik7CisgICAgICAgIGlmICh1c2VyX3JhdGVf c2V0KQorICAgICAgICB7CisgICAgICAgICAgdGltZXNwZWNtdWwoJnRpbWVhZGosIDEuMC91c2Vy X3JhdGUsICZ0ZGlmZik7CisgICAgICAgIH0KKyAgICAgICAgZWxzZQorICAgICAgICB7CisgICAg ICAgICAgdGRpZmYgPSB0aW1lYWRqOworICAgICAgICB9CisgICAgICAgIC8qIG9ubHkgQ0xPQ0tf UkVBTFRJTUUgaXMgaGFuZGxlZCAqLworICAgICAgICB0aW1lc3BlY2FkZCgmZnRwbF9zdGFydHRp bWUucmVhbCwgJnRkaWZmLCAmbmV3X3JlYWwuaXRfdmFsdWUpOworICAgICAgfQorICAgICAgZWxz ZQorICAgICAgeworICAgICAgICBpZiAodXNlcl9yYXRlX3NldCkKKyAgICAgICAgeworICAgICAg ICAgIHRpbWVzcGVjbXVsKCZuZXdfdmFsdWUtPml0X3ZhbHVlLCAxLjAvdXNlcl9yYXRlLCAmbmV3 X3JlYWwuaXRfdmFsdWUpOworICAgICAgICB9CisgICAgICAgIGVsc2UKKyAgICAgICAgeworICAg ICAgICAgIG5ld19yZWFsLml0X3ZhbHVlID0gbmV3X3ZhbHVlLT5pdF92YWx1ZTsKKyAgICAgICAg fQorICAgICAgfQorICAgIH0KKyAgICBlbHNlCisgICAgeworICAgICAgbmV3X3JlYWwuaXRfdmFs dWUgPSBuZXdfdmFsdWUtPml0X3ZhbHVlOworICAgIH0KKyAgICAvKiBzZXQgaXRfaW50ZXJ2YWwg Ki8KKyAgICBpZiAodXNlcl9yYXRlX3NldCAmJiAoKG5ld192YWx1ZS0+aXRfaW50ZXJ2YWwudHZf c2VjICE9IDApIHx8CisgICAgICAgKG5ld192YWx1ZS0+aXRfaW50ZXJ2YWwudHZfbnNlYyAhPSAw KSkpCisgICAgeworICAgICAgdGltZXNwZWNtdWwoJm5ld192YWx1ZS0+aXRfaW50ZXJ2YWwsIDEu MC91c2VyX3JhdGUsICZuZXdfcmVhbC5pdF9pbnRlcnZhbCk7CisgICAgfQorICAgIGVsc2UKKyAg ICB7CisgICAgICBuZXdfcmVhbC5pdF9pbnRlcnZhbCA9IG5ld192YWx1ZS0+aXRfaW50ZXJ2YWw7 CisgICAgfQorICB9CisKKyAgc3dpdGNoIChjb21wYXQpCisgIHsKKyAgICBjYXNlIEZUX0NPTVBB VF9HTElCQ18yXzI6CisgICAgICBET05UX0ZBS0VfVElNRShyZXN1bHQgPSAoKnJlYWxfdGltZXJf c2V0dGltZV8yMikodGltZXJpZC5pbnRfbWVtYmVyLCBmbGFncywKKyAgICAgICAgICAgICAgICAg ICAgbmV3X3JlYWxfcHQsIG9sZF92YWx1ZSkpOworICAgICAgYnJlYWs7CisgICAgY2FzZSBGVF9D T01QQVRfR0xJQkNfMl8zXzM6CisgICAgICAgRE9OVF9GQUtFX1RJTUUocmVzdWx0ID0gKCpyZWFs X3RpbWVyX3NldHRpbWVfMjMzKSh0aW1lcmlkLnRpbWVyX3RfbWVtYmVyLAorICAgICAgICAgICAg ICAgICAgICBmbGFncywgbmV3X3JlYWxfcHQsIG9sZF92YWx1ZSkpOworICAgICAgIGJyZWFrOwor ICAgIGRlZmF1bHQ6CisgICAgICByZXN1bHQgPSAtMTsKKyAgICAgIGJyZWFrOworICB9CisKKyAg aWYgKHJlc3VsdCA9PSAtMSkKKyAgeworICAgIHJldHVybiByZXN1bHQ7CisgIH0KKworICAvKiBm YWtlIHJldHVybmVkIHBhcnRzICovCisgIGlmICgob2xkX3ZhbHVlICE9IE5VTEwpICYmICFkb250 X2Zha2UpCisgIHsKKyAgICBpZiAoKG9sZF92YWx1ZS0+aXRfdmFsdWUudHZfc2VjICE9IDApIHx8 CisgICAgICAgIChvbGRfdmFsdWUtPml0X3ZhbHVlLnR2X25zZWMgIT0gMCkpCisgICAgeworICAg ICAgcmVzdWx0ID0gZmFrZV9jbG9ja19nZXR0aW1lKENMT0NLX1JFQUxUSU1FLCAmb2xkX3ZhbHVl LT5pdF92YWx1ZSk7CisgICAgfQorICAgIGlmICh1c2VyX3JhdGVfc2V0ICYmICgob2xkX3ZhbHVl LT5pdF9pbnRlcnZhbC50dl9zZWMgIT0gMCkgfHwKKyAgICAgICAob2xkX3ZhbHVlLT5pdF9pbnRl cnZhbC50dl9uc2VjICE9IDApKSkKKyAgICB7CisgICAgICB0aW1lc3BlY211bCgmb2xkX3ZhbHVl LT5pdF9pbnRlcnZhbCwgdXNlcl9yYXRlLCAmb2xkX3ZhbHVlLT5pdF9pbnRlcnZhbCk7CisgICAg fQorICB9CisKKyAgLyogcmV0dXJuIHRoZSByZXN1bHQgdG8gdGhlIGNhbGxlciAqLworICByZXR1 cm4gcmVzdWx0OworfQorCisvKgorICogRmFrZWQgdGltZXJfc2V0dGltZSgpIGNvbXBhdGlibGUg d2l0aCBpbXBsZW1lbnRhdGlvbiBpbiBHTElCQyAyLjIKKyAqLworaW50IHRpbWVyX3NldHRpbWVf MjIoaW50IHRpbWVyaWQsIGludCBmbGFncywKKyAgICAgICAgIGNvbnN0IHN0cnVjdCBpdGltZXJz cGVjICpuZXdfdmFsdWUsCisgICAgICAgICBzdHJ1Y3QgaXRpbWVyc3BlYyAqb2xkX3ZhbHVlKQor eworICBpZiAoIWluaXRpYWxpemVkKQorICB7CisgICAgZnRwbF9pbml0KCk7CisgIH0KKyAgaWYg KHJlYWxfdGltZXJfc2V0dGltZV8yMiA9PSBOVUxMKQorICB7CisgICAgcmV0dXJuIC0xOworICB9 CisgIGVsc2UKKyAgeworICAgIHJldHVybiAodGltZXJfc2V0dGltZV9jb21tb24oKHRpbWVyX3Rf b3JfaW50KXRpbWVyaWQsIGZsYWdzLCBuZXdfdmFsdWUsIG9sZF92YWx1ZSwKKyAgICAgICAgICAg IEZUX0NPTVBBVF9HTElCQ18yXzIpKTsKKyAgfQorfQorCisvKgorICogRmFrZWQgdGltZXJfc2V0 dGltZSgpIGNvbXBhdGlibGUgd2l0aCBpbXBsZW1lbnRhdGlvbiBpbiBHTElCQyAyLjMuMworICov CitpbnQgdGltZXJfc2V0dGltZV8yMzModGltZXJfdCB0aW1lcmlkLCBpbnQgZmxhZ3MsCisgICAg ICBjb25zdCBzdHJ1Y3QgaXRpbWVyc3BlYyAqbmV3X3ZhbHVlLAorICAgICAgc3RydWN0IGl0aW1l cnNwZWMgKm9sZF92YWx1ZSkKK3sKKyAgaWYgKCFpbml0aWFsaXplZCkKKyAgeworICAgIGZ0cGxf aW5pdCgpOworICB9CisgIGlmIChyZWFsX3RpbWVyX3NldHRpbWVfMjMzID09IE5VTEwpCisgIHsK KyAgICByZXR1cm4gLTE7CisgIH0KKyAgZWxzZQorICB7CisgICAgcmV0dXJuICh0aW1lcl9zZXR0 aW1lX2NvbW1vbigodGltZXJfdF9vcl9pbnQpdGltZXJpZCwgZmxhZ3MsIG5ld192YWx1ZSwgb2xk X3ZhbHVlLAorICAgICAgICAgICAgRlRfQ09NUEFUX0dMSUJDXzJfM18zKSk7CisgIH0KK30KKwor LyoKKyAqIEZha2VkIHRpbWVyX2dldHRpbWUoKQorICogRG9lcyBub3QgYWZmZWN0IHRpbWVyIHNw ZWVkIHdoZW4gc3RlcHBpbmcgY2xvY2sgd2l0aCBlYWNoIHRpbWUoKSBjYWxsLgorICovCitpbnQg dGltZXJfZ2V0dGltZV9jb21tb24odGltZXJfdF9vcl9pbnQgdGltZXJpZCwgc3RydWN0IGl0aW1l cnNwZWMgKmN1cnJfdmFsdWUsIGZ0X2xpYl9jb21wYXQgY29tcGF0KQoreworICBpbnQgcmVzdWx0 OworCisgIGlmICghaW5pdGlhbGl6ZWQpCisgIHsKKyAgICBmdHBsX2luaXQoKTsKKyAgfQorICBp ZiAocmVhbF90aW1lcl9nZXR0aW1lXzIzMyA9PSBOVUxMKQorICB7CisgICAgcmV0dXJuIC0xOwor ICB9CisKKyAgc3dpdGNoIChjb21wYXQpCisgIHsKKyAgICBjYXNlIEZUX0NPTVBBVF9HTElCQ18y XzI6CisgICAgICBET05UX0ZBS0VfVElNRShyZXN1bHQgPSAoKnJlYWxfdGltZXJfZ2V0dGltZV8y MikodGltZXJpZC5pbnRfbWVtYmVyLCBjdXJyX3ZhbHVlKSk7CisgICAgICBicmVhazsKKyAgICBj YXNlIEZUX0NPTVBBVF9HTElCQ18yXzNfMzoKKyAgICAgIERPTlRfRkFLRV9USU1FKHJlc3VsdCA9 ICgqcmVhbF90aW1lcl9nZXR0aW1lXzIzMykodGltZXJpZC50aW1lcl90X21lbWJlciwgY3Vycl92 YWx1ZSkpOworICAgICAgYnJlYWs7CisgICAgZGVmYXVsdDoKKyAgICAgIHJlc3VsdCA9IC0xOwor ICAgICAgYnJlYWs7CisgIH0KKworICBpZiAocmVzdWx0ID09IC0xKQorICB7CisgICAgcmV0dXJu IHJlc3VsdDsKKyAgfQorCisgIC8qIGZha2UgcmV0dXJuZWQgcGFydHMgKi8KKyAgaWYgKGN1cnJf dmFsdWUgIT0gTlVMTCkKKyAgeworICAgIGlmICh1c2VyX3JhdGVfc2V0ICYmICFkb250X2Zha2Up CisgICAgeworICAgICAgdGltZXNwZWNtdWwoJmN1cnJfdmFsdWUtPml0X2ludGVydmFsLCB1c2Vy X3JhdGUsICZjdXJyX3ZhbHVlLT5pdF9pbnRlcnZhbCk7CisgICAgICB0aW1lc3BlY211bCgmY3Vy cl92YWx1ZS0+aXRfdmFsdWUsIHVzZXJfcmF0ZSwgJmN1cnJfdmFsdWUtPml0X3ZhbHVlKTsKKyAg ICB9CisgIH0KKyAgLyogcmV0dXJuIHRoZSByZXN1bHQgdG8gdGhlIGNhbGxlciAqLworICByZXR1 cm4gcmVzdWx0OworfQorCisvKgorICogRmFrZWQgdGltZXJfZ2V0dGltZSgpIGNvbXBhdGlibGUg d2l0aCBpbXBsZW1lbnRhdGlvbiBpbiBHTElCQyAyLjIKKyAqLworaW50IHRpbWVyX2dldHRpbWVf MjIodGltZXJfdCB0aW1lcmlkLCBzdHJ1Y3QgaXRpbWVyc3BlYyAqY3Vycl92YWx1ZSkKK3sKKyAg aWYgKCFpbml0aWFsaXplZCkKKyAgeworICAgIGZ0cGxfaW5pdCgpOworICB9CisgIGlmIChyZWFs X3RpbWVyX2dldHRpbWVfMjIgPT0gTlVMTCkKKyAgeworICAgIHJldHVybiAtMTsKKyAgfQorICBl bHNlCisgIHsKKyAgICByZXR1cm4gKHRpbWVyX2dldHRpbWVfY29tbW9uKCh0aW1lcl90X29yX2lu dCl0aW1lcmlkLCBjdXJyX3ZhbHVlLAorICAgICAgICAgRlRfQ09NUEFUX0dMSUJDXzJfMikpOwor ICB9Cit9CisKKy8qCisgKiBGYWtlZCB0aW1lcl9nZXR0aW1lKCkgY29tcGF0aWJsZSB3aXRoIGlt cGxlbWVudGF0aW9uIGluIEdMSUJDIDIuMy4zCisgKi8KK2ludCB0aW1lcl9nZXR0aW1lXzIzMyh0 aW1lcl90IHRpbWVyaWQsIHN0cnVjdCBpdGltZXJzcGVjICpjdXJyX3ZhbHVlKQoreworICBpZiAo IWluaXRpYWxpemVkKQorICB7CisgICAgZnRwbF9pbml0KCk7CisgIH0KKyAgaWYgKHJlYWxfdGlt ZXJfZ2V0dGltZV8yMzMgPT0gTlVMTCkKKyAgeworICAgIHJldHVybiAtMTsKKyAgfQorICBlbHNl CisgIHsKKyAgICByZXR1cm4gKHRpbWVyX2dldHRpbWVfY29tbW9uKCh0aW1lcl90X29yX2ludCl0 aW1lcmlkLCBjdXJyX3ZhbHVlLAorICAgICAgICAgICAgRlRfQ09NUEFUX0dMSUJDXzJfM18zKSk7 CisgIH0KK30KKworX19hc21fXygiLnN5bXZlciB0aW1lcl9nZXR0aW1lXzIyLCB0aW1lcl9nZXR0 aW1lQEdMSUJDXzIuMiIpOworX19hc21fXygiLnN5bXZlciB0aW1lcl9nZXR0aW1lXzIzMywgdGlt ZXJfZ2V0dGltZUBAR0xJQkNfMi4zLjMiKTsKK19fYXNtX18oIi5zeW12ZXIgdGltZXJfc2V0dGlt ZV8yMiwgdGltZXJfc2V0dGltZUBHTElCQ18yLjIiKTsKK19fYXNtX18oIi5zeW12ZXIgdGltZXJf c2V0dGltZV8yMzMsIHRpbWVyX3NldHRpbWVAQEdMSUJDXzIuMy4zIik7CisKKyNlbmRpZgorI2Vu ZGlmCisKKworLyoKKyAqICAgICAgPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqICAgICAgRmFrZWQgc3lzdGVt IGZ1bmN0aW9uczogYmFzaWMgdGltZSBmdW5jdGlvbnMgICAgICAgICAgICAgPT09IEZBS0UoVElN RSkKKyAqICAgICAgPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqLworCisvKgorICogdGltZSgpIGltcGxlbWVu dGF0aW9uIHVzaW5nIGNsb2NrX2dldHRpbWUoKQorICogQG5vdGUgRG9lcyBub3QgY2hlY2sgZm9y IEVGQVVMVCwgc2VlIG1hbiAyIHRpbWUKKyAqLwordGltZV90IHRpbWUodGltZV90ICp0aW1lX3Rw dHIpCit7CisgIHN0cnVjdCB0aW1lc3BlYyB0cDsKKyAgdGltZV90IHJlc3VsdDsKKworICBpZiAo IWluaXRpYWxpemVkKQorICB7CisgICAgZnRwbF9pbml0KCk7CisgIH0KKyAgRE9OVF9GQUtFX1RJ TUUocmVzdWx0ID0gKCpyZWFsX2Nsb2NrX2dldHRpbWUpKENMT0NLX1JFQUxUSU1FLCAmdHApKTsK KyAgaWYgKHJlc3VsdCA9PSAtMSkgcmV0dXJuIC0xOworCisgIC8qIHBhc3MgdGhlIHJlYWwgY3Vy cmVudCB0aW1lIHRvIG91ciBmYWtpbmcgdmVyc2lvbiwgb3ZlcndyaXRpbmcgaXQgKi8KKyAgKHZv aWQpZmFrZV9jbG9ja19nZXR0aW1lKENMT0NLX1JFQUxUSU1FLCAmdHApOworCisgIGlmICh0aW1l X3RwdHIgIT0gTlVMTCkKKyAgeworICAgICp0aW1lX3RwdHIgPSB0cC50dl9zZWM7CisgIH0KKyAg cmV0dXJuIHRwLnR2X3NlYzsKK30KKworaW50IGZ0aW1lKHN0cnVjdCB0aW1lYiAqdGIpCit7Cisg IHN0cnVjdCB0aW1lc3BlYyB0cDsKKyAgaW50IHJlc3VsdDsKKworICBpZiAoIWluaXRpYWxpemVk KQorICB7CisgICAgZn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sZWQgKi8KKworICAvKiBwYXNzIHRoZSByZWFsIGN1cnJlbnQgdGltZSB0byBvdXIgZmFraW5n IHZlcnNpb24sIG92ZXJ3cml0aW5nIGl0ICovCisgIHJlc3VsdCA9IGZha2VfZ2V0dGltZW9mZGF5 KHR2KTsKKworICAvKiByZXR1cm4gdGhlIHJlc3VsdCB0byB0aGUgY2FsbGVyICovCisgIHJldHVy biByZXN1bHQ7Cit9CisKK2ludCBjbG9ja19nZXR0aW1lKGNsb2NraWRfdCBjbGtfaWQsIHN0cnVj dCB0aW1lc3BlYyAqdHApCit7CisgIGludCByZXN1bHQ7CisKKyAgaWYgKCFpbml0aWFsaXplZCkK KyAgeworICAgIGZ0cGxfaW5pdCgpOworICB9CisgIC8qIHNhbml0eSBjaGVjayAqLworICBpZiAo dHAgPT0gTlVMTCkKKyAgeworICAgIHJldHVybiAtMTsKKyAgfQorCisgIGlmIChOVUxMID09IHJl YWxfY2xvY2tfZ2V0dGltZSkKKyAgeyAgLyogZGxzeW0oKSBmYWlsZWQgKi8KKyNpZmRlZiBERUJV RworICAgICh2b2lkKSBmcHJpbnRmKHN0ZGVyciwgImZha2V0aW1lIHByb2JsZW06IG9yaWdpbmFs IGNsb2NrX2dldHRpbWUoKSBub3QgZm91bmQuXG4iKTsKKyNlbmRpZgorICAgIHJldHVybiAtMTsg LyogcHJvcGFnYXRlIGVycm9yIHRvIGNhbGxlciAqLworICB9CisKKyAgLyogaW5pdGlhbGl6ZSBv dXIgcmVzdWx0IHdpdGggdGhlIHJlYWwgY3VycmVudCB0aW1lICovCisgIERPTlRfRkFLRV9USU1F KHJlc3VsdCA9ICgqcmVhbF9jbG9ja19nZXR0aW1lKShjbGtfaWQsIHRwKSk7CisgIGlmIChyZXN1 bHQgPT0gLTEpIHJldHVybiByZXN1bHQ7IC8qIG9yaWdpbmFsIGZ1bmN0aW9uIGZhaWxlZCAqLwor CisgIC8qIHBhc3MgdGhlIHJlYWwgY3VycmVudCB0aW1lIHRvIG91ciBmYWtpbmcgdmVyc2lvbiwg b3ZlcndyaXRpbmcgaXQgKi8KKyAgaWYgKGZha2VfbW9ub3RvbmljX2Nsb2NrIHx8IGNsa19pZCAh PSBDTE9DS19NT05PVE9OSUMpCisgIHsKKyAgICByZXN1bHQgPSBmYWtlX2Nsb2NrX2dldHRpbWUo Y2xrX2lkLCB0cCk7CisgIH0KKworICAvKiByZXR1cm4gdGhlIHJlc3VsdCB0byB0aGUgY2FsbGVy ICovCisgIHJldHVybiByZXN1bHQ7Cit9CisKKworLyoKKyAqICAgICAgPT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0K KyAqICAgICAgUGFyc2luZyB0aGUgdXNlcidzIGZha2V0aW1lIHJlcXVlc3RzICAgICAgICAgICAg ICAgICAgICAgICAgICA9PT0gUEFSU0UKKyAqICAgICAgPT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KKyAqLworCitz dGF0aWMgdm9pZCBwYXJzZV9mdF9zdHJpbmcoY29uc3QgY2hhciAqdXNlcl9mYWtlZF90aW1lKQor eworICBzdHJ1Y3QgdG0gdXNlcl9mYWtlZF90aW1lX3RtOworICBjaGFyICogdG1wX3RpbWVfZm10 OworCisgIGlmICghc3RybmNtcCh1c2VyX2Zha2VkX3RpbWUsIHVzZXJfZmFrZWRfdGltZV9zYXZl ZCwgQlVGRkVSTEVOKSkKKyAgeworICAgICAgLyogTm8gY2hhbmdlICovCisgICAgICByZXR1cm47 CisgIH0KKworICAvKiBjaGVjayB3aGV0aGVyIHRoZSB1c2VyIGdhdmUgdXMgYW4gYWJzb2x1dGUg dGltZSB0byBmYWtlICovCisgIHN3aXRjaCAodXNlcl9mYWtlZF90aW1lWzBdKQorICB7CisKKyAg ICBkZWZhdWx0OiAgLyogVHJ5IGFuZCBpbnRlcnByZXQgdGhpcyBhcyBhIHNwZWNpZmllZCB0aW1l ICovCisgICAgICBpZiAoZnRfbW9kZSAhPSBGVF9OT09QKSBmdF9tb2RlID0gRlRfRlJFRVpFOwor ICAgICAgdXNlcl9mYWtlZF90aW1lX3RtLnRtX2lzZHN0ID0gLTE7CisgICAgICBpZiAoTlVMTCAh PSBzdHJwdGltZSh1c2VyX2Zha2VkX3RpbWUsIHVzZXJfZmFrZWRfdGltZV9mbXQsICZ1c2VyX2Zh a2VkX3RpbWVfdG0pKQorICAgICAgeworICAgICAgICB1c2VyX2Zha2VkX3RpbWVfdGltZXNwZWMu dHZfc2VjID0gbWt0aW1lKCZ1c2VyX2Zha2VkX3RpbWVfdG0pOworICAgICAgICB1c2VyX2Zha2Vk X3RpbWVfdGltZXNwZWMudHZfbnNlYyA9IDA7CisgICAgICAgIHVzZXJfZmFrZWRfdGltZV9zZXQg PSB0cnVlOworICAgICAgfQorICAgICAgZWxzZQorICAgICAgeworICAgICAgICBwZXJyb3IoIkZh aWxlZCB0byBwYXJzZSBGQUtFVElNRSB0aW1lc3RhbXAiKTsKKyAgICAgICAgZXhpdChFWElUX0ZB SUxVUkUpOworICAgICAgfQorICAgICAgYnJlYWs7CisKKyAgICBjYXNlICcrJzoKKyAgICBjYXNl ICctJzogLyogVXNlci1zcGVjaWZpZWQgb2Zmc2V0ICovCisgICAgICBpZiAoZnRfbW9kZSAhPSBG VF9OT09QKSBmdF9tb2RlID0gRlRfU1RBUlRfQVQ7CisgICAgICAvKiBmcmFjdGlvbmFsIHRpbWUg b2Zmc2V0cyBjb250cmlidXRlZCBieSBLYXJsIENoZW4gaW4gdjAuOCAqLworICAgICAgZG91Ymxl IGZyYWNfb2Zmc2V0ID0gYXRvZih1c2VyX2Zha2VkX3RpbWUpOworCisgICAgICAvKiBvZmZzZXQg aXMgaW4gc2Vjb25kcyBieSBkZWZhdWx0LCBidXQgdGhlIHN0cmluZyBtYXkgY29udGFpbgorICAg ICAgICogbXVsdGlwbGllcnMuLi4KKyAgICAgICAqLworICAgICAgaWYg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ja19p bmMpOworICAgICAgICB1c2VyX3Blcl90aWNrX2luYy50dl9uc2VjID0gKHRpY2tfaW5jIC0gdXNl cl9wZXJfdGlja19pbmMudHZfc2VjKSAqIFNFQ19UT19uU0VDIDsKKyAgICAgICAgdXNlcl9wZXJf dGlja19pbmNfc2V0ID0gdHJ1ZTsKKyAgICAgIH0KKyAgICAgIGJyZWFrOworICB9IC8vIGVuZCBv ZiBzd2l0Y2gKKworICBzdHJuY3B5KHVzZXJfZmFrZWRfdGltZV9zYXZlZCwgdXNlcl9mYWtlZF90 aW1lLCBCVUZGRVJMRU4tMSk7CisgIHVzZXJfZmFrZWRfdGltZV9zYXZlZFtCVUZGRVJMRU4tMV0g PSAwOworI2lmZGVmIERFQlVHCisgIGZwcmludGYoc3RkZXJyLCAibmV3IEZBS0VUSU1FOiAlc1xu IiwgdXNlcl9mYWtlZF90aW1lX3NhdmVkKTsKKyNlbmRpZgorfQorCisKKy8qCisgKiAgICAgID09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09CisgKiAgICAgIEluaXRpYWxpemF0aW9uICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgID09PSBJTklUCisgKiAgICAgID09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09CisgKi8KKwordm9pZCBmdHBsX2luaXQodm9pZCkKK3sKKyAgY2hhciAqdG1wX2VudjsKKyAg Ym9vbCBkb250X2Zha2VfZmluYWw7CisKKyNpZmRlZiBfX0FQUExFX18KKyAgY29uc3QgY2hhciAq cHJvZ25hbWUgPSBnZXRwcm9nbmFtZSgpOworI2Vsc2UKKyAgY29uc3QgY2hhciAqcHJvZ25hbWUg PSBfX3Byb2duYW1lOworI2VuZGlmCisKKyAgLyogTG9vayB1cCBhbGwgcmVhbF8qIGZ1bmN0aW9u cy4gTlVMTCB3aWxsIG1hcmsgbWlzc2luZyBvbmVzLiAqLworICByZWFsX3N0YXQgPSAgICAgICAg ICAgICAgIGRsc3ltKFJUTERfTkVYVCwgIl9feHN0YXQiKTsKKyAgcmVhbF9mc3RhdCA9ICAgICAg ICAgICAgICBkbHN5bShSVExEX05FWFQsICJfX2Z4c3RhdCIpOworICByZWFsX2ZzdGF0YXQgPSAg ICAgICAgICAgIGRsc3ltKFJUTERfTkVYVCwgIl9fZnhzdGF0YXQiKTsKKyAgcmVhbF9sc3RhdCA9 ICAgICAgICAgICAgICBkbHN5bShSVExEX05FWFQsICJfX2x4c3RhdCIpOworICByZWFsX3N0YXQ2 NCA9ICAgICAgICAgICAgIGRsc3ltKFJUTERfTkVYVCwiX194c3RhdDY0Iik7CisgIHJlYWxfZnN0 YXQ2NCA9ICAgICAgICAgICAgZGxzeW0oUlRMRF9ORVhULCAiX19meHN0YXQ2NCIpOworICByZWFs X2ZzdGF0YXQ2NCA9ICAgICAgICAgIGRsc3ltKFJUTERfTkVYVCwgIl9fZnhzdGF0YXQ2NCIpOwor ICByZWFsX2xzdGF0NjQgPSAgICAgICAgICAgIGRsc3ltKFJUTERfTkVYVCwgIl9fbHhzdGF0NjQi KTsKKyAgcmVhbF90aW1lID0gICAgICAgICAgICAgICBkbHN5bShSVExEX05FWFQsICJ0aW1lIik7 CisgIHJlYWxfZnRpbWUgPSAgICAgICAgICAgICAgZGxzeW0oUlRMRF9ORVhULCAiZnRpbWUiKTsK KyAgcmVhbF9nZXR0aW1lb2ZkYXkgPSAgICAgICBkbHN5bShSVExEX05FWFQsICJnZXR0aW1lb2Zk YXkiKTsKKyNpZmRlZiBGQUtFX1NMRUVQCisgIHJlYWxfbmFub3NsZWVwID0gICAgICAgICAgZGxz eW0oUlRMRF9ORVhULCAibmFub3NsZWVwIik7CisgIHJlYWxfdXNsZWVwID0gICAgICAgICAgICAg ZGxzeW0oUlRMRF9ORVhULCAidXNsZWVwIik7CisgIHJlYWxfc2xlZXAgPSAgICAgICAgICAgICAg ZGxzeW0oUlRMRF9ORVhULCAic2xlZXAiKTsKKyAgcmVhbF9hbGFybSA9ICAgICAgICAgICAgICBk bHN5bShSVExEX05FWFQsICJhbGFybSIpOworICByZWFsX3BvbGwgPSAgICAgICAgICAgICAgIGRs c3ltKFJUTERfTkVYVCwgInBvbGwiKTsKKyAgcmVhbF9wcG9sbCA9ICAgICAgICAgICAgICBkbHN5 bShSVExEX05FWFQsICJwcG9sbCIpOworICByZWFsX3NlbGVjdCA9ICAgICAgICAgICAgIGRsc3lt KFJUTERfTkVYVCwgInNlbGVjdCIpOworICByZWFsX3NlbV90aW1lZHdhaXQgPSAgICAgIGRsc3lt KFJUTERfTkVYVCwgInNlbV90aW1lZHdhaXQiKTsKKyNlbmRpZgorI2lmZGVmIEZBS0VfSU5URVJO QUxfQ0FMTFMKKyAgcmVhbF9fX2Z0aW1lID0gICAgICAgICAgICAgIGRsc3ltKFJUTERfTkVYVCwg Il9fZnRpbWUiKTsKKyAgcmVhbF9fX2dldHRpbWVvZmRheSA9ICAgICAgIGRsc3ltKFJUTERfTkVY VCwgIl9fZ2V0dGltZW9mZGF5Iik7CisgIHJlYWxfX19jbG9ja19nZXR0aW1lICA9ICAgICBkbHN5 bShSVExEX05FWFQsICJfX2Nsb2NrX2dldHRpbWUiKTsKKyNlbmRpZgorI2lmZGVmIF9fQVBQTEVP U1hfXworICByZWFsX2Nsb2NrX2dldF90aW1lID0gICAgIGRsc3ltKFJUTERfTkVYVCwgImNsb2Nr X2dldF90aW1lIik7CisgIHJlYWxfY2xvY2tfZ2V0dGltZSAgPSAgICAgYXBwbGVfY2xvY2tfZ2V0 dGltZTsKKyNlbHNlCisgIHJlYWxfY2xvY2tfZ2V0dGltZSAgPSAgICAgZGxzeW0oUlRMRF9ORVhU LCAiX19jbG9ja19nZXR0aW1lIik7CisgIGlmIChOVUxMID09IHJlYWxfY2xvY2tfZ2V0dGltZSkK KyAgeworICAgIHJlYWxfY2xvY2tfZ2V0dGltZ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kgIT0gTlVMTCkKKyAgeworICAgIGNoYXIgKnNraXBf Y21kLCAqc2F2ZXB0ciwgKnRtcHZhcjsKKyAgICAvKiBEb24ndCBtZXNzIHdpdGggdGhlIGVudiB2 YXJpYWJsZSBkaXJlY3RseS4gKi8KKyAgICB0bXB2YXIgPSBzdHJkdXAodG1wX2Vudik7CisgICAg aWYgKHRtcHZhciAhPSBOVUxMKQorICAgIHsKKyAgICAgIHNraXBfY21kID0gc3RydG9rX3IodG1w dmFyLCAiLCIsICZzYXZlcHRyKTsKKyAgICAgIHdoaWxlIChza2lwX2NtZCAhPSBOVUxMKQorICAg ICAgeworICAgICAgICBpZiAoMCA9PSBzdHJjbXAocHJvZ25hbWUsIHNraXBfY21kKSkKKyAgICAg ICAgeworICAgICAgICAgIGZ0X21vZGUgPSBGVF9OT09QOworICAgICAgICAgIGRvbnRfZmFrZV9m aW5hbCA9IHRydWU7CisgICAgICAgICAgYnJlYWs7CisgICAgICAgIH0KKyAgICAgICAgc2tpcF9j bWQgPSBzdHJ0b2tfcihOVUxMLCAiLCIsICZzYXZlcHRyKTsKKyAgICAgIH0KKyAgICAgIGZyZWUo dG1wdmFyKTsKKyAgICAgIHRtcHZhciA9IE5VTEw7CisgICAgfQorICAgIGVsc2UKKyAgICB7Cisg ICAgICBmcHJpbnRmKHN0ZGVyciwgIkVycm9yOiBDb3VsZCBub3QgY29weSB0aGUgZW52aXJvbm1l bnQgdmFyaWFibGUgdmFsdWUuXG4iKTsKKyAgICAgIGV4aXQoRVhJVF9GQUlMVVJFKTsKKyAgICB9 CisgIH0KKworICAvKiBXZSBjYW4gbGltaXQgZmFraW5nIHRpbWUgdG8gc3BlY2lmaWVkIGNvbW1h bmRzICovCisgIGlmICgodG1wX2VudiA9IGdldGVudigiRkFLRVRJTUVfT05MWV9DTURTIikpICE9 IE5VTEwpCisgIHsKKyAgICBjaGFyICpvbmx5X2NtZCwgKnNhdmVwdHIsICp0bXB2YXI7CisgICAg Ym9vbCBjbWRfbWF0Y2hlZCA9IGZhbHNlOworCisgICAgaWYgKGdldGVudigiRkFLRVRJTUVfU0tJ UF9DTURTIikgIT0gTlVMTCkKKyAgICB7CisgICAgICBmcHJpbnRmKHN0ZGVyciwgIkVycm9yOiBC b3RoIEZBS0VUSU1FX1NLSVBfQ01EUyBhbmQgRkFLRVRJTUVfT05MWV9DTURTIGNhbid0IGJlIHNl dC5cbiIpOworICAgICAgZXhpdChFWElUX0ZBSUxVUkUpOworICAgIH0KKworICAgIC8qIERvbid0 IG1lc3Mgd2l0aCB0aGUgZW52IHZhcmlhYmxlIGRpcmVjdGx5LiAqLworICAgIHRtcHZhciA9IHN0 cmR1cCh0bXBfZW52KTsKKyAgICBpZiAodG1wdmFyICE9IE5VTEwpIHsKKyAgICAgIG9ubHlfY21k ID0gc3RydG9rX3IodG1wdmFyLCAiLCIsICZzYXZlcHRyKTsKKyAgICAgIHdoaWxlIChvbmx5X2Nt ZCAhPSBOVUxMKQorICAgICAgeworICAgICAgICBpZiAoMCA9PSBzdHJjbXAocHJvZ25hbWUsIG9u bHlfY21kKSkKKyAgICAgICAgeworICAgICAgICAgIGNtZF9tYXRjaGVkID0gdHJ1ZTsKKyAgICAg ICAgICBicmVhazsKKyAgICAgICAgfQorICAgICAgICBvbmx5X2NtZCA9IHN0cnRva19yKE5VTEws ICIsIiwgJnNhdmVwdHIpOworICAgICAgfQorCisgICAgICBpZiAoIWNtZF9tYXRjaGVkKQorICAg ICAgeworICAgICAgICBmdF9tb2RlID0gRlRfTk9PUDsKKyAgICAgICAgZG9udF9mYWtlX2ZpbmFs ID0gdHJ1ZTsKKyAgICAgIH0KKyAgICAgIGZyZWUodG1wdmFyKTsKKyAgICB9IGVsc2UgeworICAg ICAgZnByaW50ZihzdGRlcnIsICJFcnJvcjogQ291bGQgbm90IGNvcHkgdGhlIGVudmlyb25tZW50 IHZhcmlhYmxlIHZhbHVlLlxuIik7CisgICAgICBleGl0KEVYSVRfRkFJTFVSRSk7CisgICAgfQor ICB9CisK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2FkaW5n IHRpbWVzdGFtcHMgZmFpbGVkIik7CisgICAgICBleGl0KEVYSVRfRkFJTFVSRSk7CisgICAgfQor CisgICAgZnN0YXQoaW5maWxlLCAmc2IpOworICAgIGlmIChzaXplb2Yoc3Rzc1swXSkgPiAoaW5m aWxlX3NpemUgPSBzYi5zdF9zaXplKSkKKyAgICB7CisgICAgICBwcmludGYoIlRoZXJlIGFyZSBu byB0aW1lc3RhbXBzIGluIHRoZSBwcm92aWRlZCBmaWxlIHRvIGxvYWQgdGltZXN0YW1wcyBmcm9t Iik7CisgICAgICBleGl0KEVYSVRfRkFJTFVSRSk7CisgICAgfQorCisgICAgaWYgKChpbmZpbGVf c2l6ZSAlIHNpemVvZihzdHNzWzBdKSkgIT0gMCkKKyAgICB7CisgICAgICBwcmludGYoIkZpbGUg c2l6ZSBpcyBub3QgbXVsdGlwbGUgb2YgdGltZXN0YW1wIHNpemUuIEl0IGlzIHByb2JhYmx5IGRh bWFnZWQuIik7CisgICAgICBleGl0KEVYSVRfRkFJTFVSRSk7CisgICAgfQorCisgICAgc3RzcyA9 IG1tYXAoTlVMTCwgaW5maWxlX3NpemUsIFBST1RfUkVBRCwgTUFQX1NIQVJFRCwgaW5maWxlLCAw KTsKKyAgICBpZiAoc3RzcyA9PSBNQVBfRkFJTEVEKQorICAgIHsKKyAgICAgIHBlcnJvcigiTWFw cGluZyBmaWxlIGZvciBsb2FkaW5nIHRpbWVzdGFtcHMgZmFpbGVkIik7CisgICAgICBleGl0KEVY SVRfRkFJTFVSRSk7CisgICAgfQorICAgIGluZmlsZV9zZXQgPSB0cnVlOworICB9CisKKyAgdG1w X2VudiA9IGdldGVudigiRkFLRVRJTUVfRk1UIik7CisgIGlmICh0bXBfZW52ID09IE5VTEwpCisg IHsKKyAgICBzdHJjcHkodXNlcl9mYWtlZF90aW1lX2ZtdCwgIiVZLSVtLSVkICVUIik7CisgIH0K KyAgZWxzZQorICB7CisgICAgc3RybmNweSh1c2VyX2Zha2VkX3RpbWV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X2ZpbmFsOworfQorCisKKy8qCisgKiAgICAgID09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKiAg ICAgIEhlbHBlciBmdW5jdGlvbnMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICA9PT0gSEVMUEVSCisgKiAgICAgID09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09CisgKi8KKworc3RhdGlj IHZvaWQgcmVtb3ZlX3RyYWlsaW5nX2VvbHMoY2hhciAqbGluZSkKK3sKKyAgY2hhciAqZW5kcCA9 IGxpbmUgKyBzdHJsZW4obGluZSk7CisgIC8qCisgICAqIGVyYXNlIHRoZSBsYXN0IGNoYXIgaWYg aXQncyBhIG5ld2xpbmUKKyAgICogb3IgY2FycmlhZ2UgcmV0dXJuLCBhbmQgYmFjayB1cC4KKyAg ICoga2VlcCBkb2luZyB0aGlzLCBidXQgZG9uJ3QgYmFjayB1cAorICAgKiBwYXN0IHRoZSBiZWdp bm5pbmcgb2YgdGhlIHN0cmluZy4KKyAgICovCisjIGRlZmluZSBpc19lb2xjaGFyKGMpICgoYykg PT0gJ1xuJyB8fCAoYykgPT0gJ1xyJykKKyAgd2hpbGUgKGVuZHAgPiBsaW5lICYmIGlzX2VvbGNo YXIoZW5kcFstMV0pKQorICB7CisgICAgKi0tZW5kcCA9ICdcMCc7CisgIH0KK30KKworCisvKgor ICogICAgICA9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PQorICogICAgICBJbXBsZW1lbnRhdGlvbiBvZiBmYWtlZCBm dW5jdGlvbnMgICAgICAgICAgICAgICAgICAgICAgICA9PT0gRkFLRShGQUtFKQorICogICAgICA9 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09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isgICAgfQorICB9 CisKKyAgaWYgKGNhY2hlX2VuYWJsZWQgPT0gMCkKKyAgeworICAgIGNhY2hlX2V4cGlyZWQgPSAx OworICB9CisKKyAgaWYgKGNhY2hlX2V4cGlyZWQgPT0gMSkKKyAgeworICAgIHN0YXRpYyBjaGFy IHVzZXJfZmFrZWRfdGltZVtCVUZGRVJMRU5dOyAvKiBjaGFuZ2VkIHRvIHN0YXRpYyBmb3IgY2Fj aGluZyBpbiB2MC42ICovCisgICAgLyogaW5pdGlhbGl6ZSB3aXRoIGRlZmF1bHQgb3IgZW52LiB2 YXJpYWJsZSAqLworICAgIGNoYXIgKnRtcF9lbnY7CisKKyAgICAvKiBDYW4gYmUgZW5hYmxlZCBm b3IgdGVzdGluZyAuLi4KKyAgICAgIGZwcmludGYoc3RkZXJyLCAiKioqKioqKioqKioqKioqKysg Q2FjaGUgZXhwaXJlZCArKyoqKioqKioqKioqKioqXG4iKTsKKyAgICAqLworCisgICAgaWYgKE5V TEwgIT0gKHRtcF9lbnYgPSBnZXRlbnYoIkZBS0VUSU1FIikpKQorICAgIHsKKyAgICAgIHN0cm5j cHkodXNlcl9mYWtlZF90aW1lLCB0bXBfZW52LCBCVUZGRVJMRU4pOworICAgIH0KKyAgICBlbHNl CisgICAgeworICAgICAgc25wcmludGYodXNlcl9mYWtlZF90aW1lLCBCVUZGRVJMRU4sICIrMCIp OworICAgIH0KKworICAgIGxhc3RfZGF0YV9mZXRjaCA9IHRwLT50dl9zZWM7CisgICAgLyogZmFr ZSB0aW1lIHN1cHBsaWVkIGFzIGVudmlyb25tZW50IHZhcmlhYmxlPyAqLworICAgIGlmIChwYXJz ZV9jb25maWdfZmlsZSkKKyAgICB7CisgICAgICBjaGFyIGN1c3RvbV9maWxlbmFtZVtCVUZTSVpd OworICAgICAgY2hhciBmaWxlbmFtZVtCVUZTSVpdOworICAgICAgRklMRSAqZmFrZXRpbWVyYzsK KyAgICAgIC8qIGNoZWNrIHdoZXRoZXIgdGhlcmUncyBhIC5mYWtldGltZXJjIGluIHRoZSB1c2Vy J3MgaG9tZSBkaXJlY3RvcnksIG9yCisgICAgICAgKiBhIHN5c3RlbS13aWRlIC9ldGMvZmFrZXRp bWVyYyBwcmVzZW50LgorICAgICAgICogVGhlIC9ldGMvZmFrZXRpbWVyYyBoYW5kbGluZyBoYXMg YmVlbiBjb250cmlidXRlZCBieSBEYXZpZCBCdXJsZXksCisgICAgICAgKiBKYWNvYiBNb29ybWFu LCBhbmQgV2F5bmUgRGF2aXNvbiBvZiBTb3VyY2VGb3JnZSwgSW5jLiBpbiB2ZXJzaW9uIDAuNiAq LworICAgICAgKHZvaWQpIHNucHJpbnRmKGN1c3RvbV9maWxlbmFtZSwgQlVGU0laLCAiJXMiLCBn ZXRlbnYoIkZBS0VUSU1FX1RJTUVTVEFNUF9GSUxFIikpOworICAgICAgKHZvaWQpIHNucHJpbnRm KGZpbGVuYW1lLCBCVUZTSVosICIlcy8uZmFrZXRpbWVyYyIsIGdldGVudigiSE9NRSIpKTsKKyAg ICAgIGlmICgoZmFrZXRpbWVyYyA9IGZvcGVuKGN1c3RvbV9maWxlbmFtZSwgInJ0IikpICE9IE5V TEwgfHwKKyAgICAgICAgICAoZmFrZXRpbWVyYyA9IGZvcGVuKGZpbGVuYW1lLCAicnQiKSkgIT0g TlVMTCB8fAorICAgICAgICAgIChmYWtldGltZXJjID0gZm9wZW4oIi9ldGMvZmFrZXRpbWVyYyIs ICJydCIpKSAhPSBOVUxMKQorICAgICAgeworICAgICAgICBjaGFyIGxpbmVbQlVGRkVSTEVOXTsK KyAgICAgICAgd2hpbGUoZmdldHMobGluZSwgQlVGRkVSTEVOLCBmYWtldGltZXJjKSAhPSBOVUxM KQorICAgICAgICB7CisgICAgICAgICAgaWYgKChzdHJsZW4obGluZSkgPiAxKSAmJiAobGluZVsw XSAhPSAnICcpICYmCisgICAgICAgICAgICAgIChsaW5lWzBdICE9ICcjJykgJiYgKGxpbmVbMF0g IT0gJzsnKSkKKyAgICAgICAgICB7CisgICAgICAgICAgICByZW1vdmVfdHJhaWxpbmdfZW9scyhs aW5lKTsKKyAgICAgICAgICAgIHN0cm5jcHkodXNlcl9mYWtlZF90aW1lLCBsaW5lLCBCVUZGRVJM RU4tMSk7CisgICAgICAgICAgICB1c2VyX2Zha2VkX3RpbWVbQlVGRkVSTEVOLTFdID0gMDsKKyAg ICAgICAgICAgIGJyZWFrOworICAgICAgICAgIH0KKyAgICAgICAgfQorICAgICAgICBmY2xvc2Uo ZmFrZXRpbWVyYyk7CisgICAgICB9CisgICAgfSAvKiByZWFkIGZha2UgdGltZSBmcm9tIGZpbGUg Ki8KKyAgICBwYXJzZV9mdF9zdHJpbmcodXNlcl9mYWtlZF90aW1lKTsKKyAgfSAvKiBjYWNoZSBo YWQgZXhwaXJlZCAqLworCisgIGlmIChpbmZpbGVfc2V0KQorICB7CisgICAgaWYgKGxvYWRfdGlt ZSh0cCkpCisgICAgeworICAgICAgcmV0dXJuIDA7CisgICAgfQorICB9CisKKyAgLyogY2hlY2sg d2hldGhlciB0aGUgdXNlciBnYXZlIHVzIGFuIGFic29sdXRlIHRpbWUgdG8gZmFrZSAqLworICBz d2l0Y2ggKGZ0X21vZGUpCisgIHsKKyAgICBjYXNlIEZUX0ZSRUVaRTogIC8qIGEgc3BlY2lmaWVk IHRpbWUgKi8KKyAgICAgIGlmICh1c2VyX2Zha2VkX3RpbWVfc2V0KQorICAgICAgeworICAgICAg ICAqdHAgPSB1c2VyX2Zha2VkX3RpbWVfdGltZXNwZWM7CisgICAgICB9CisgICAgICBicmVhazsK KworICAgIGNhc2UgRlRfU1RBUlRfQVQ6IC8qIFVzZXItc3BlY2lmaWVkIG9mZnNldCAqLworICAg ICAgaWYgKHVzZXJfcGVyX3RpY2tfaW5jX3NldCkKKyAgICAgIHsKKyAgICAgICAgLyogaW5jcmVt ZW50IHRpbWUgd2l0aCBldmVyeSB0aW1lKCkgY2FsbCovCisgICAgICAgIG5leHRfdGltZSh0cCwg JnVzZXJfcGVyX3RpY2tfaW5jKTsKKyAgICAgIH0KKyAgICAgIGVsc2UKKyAgICAgIHsKKyAgICAg ICAgLyogU3BlZWQtdXAgLyBzbG93LWRvd24gY29udHJpYnV0ZWQgYnkgS2FybCBDaGVuIGluIHYw LjggKi8KKyAgICAgICAgc3RydWN0IHRpbWVzcGVjIHRkaWZmLCB0aW1lYWRqOworICAgICAgICBz d2l0Y2ggKGNsa19pZCkKKyAgICAgICAgeworICAgICAgICAgIGNhc2UgQ0xPQ0tfUkVBTFRJTUU6 CisjaWZkZWYgQ0xPQ0tfUkVBTFRJTUVfQ09BUlNFCisgICAgICAgICAgY2FzZSBDTE9DS19SRUFM VElNRV9DT0FSU0U6CisjZW5kaWYKKyAgICAgICAgICAgIHRpbWVzcGVjc3ViKHRwLCAmZnRwbF9z dGFydHRpbWUucmVhbCwgJnRkaWZmKTsKKyAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgIGNh c2UgQ0xPQ0tfTU9OT1RPTklDOgorI2lmZGVmIENMT0NLX01PTk9UT05JQ19DT0FSU0UKKyAgICAg ICAgICBjYXNlIENMT0NLX01PTk9UT05JQ19DT0FSU0U6CisjZW5kaWYKKyAgICAgICAgICAgIHRp bWVzcGVjc3ViKHRwLCAmZnRwbF9zdGFydHRpbWUubW9uLCAmdGRpZmYpOworICAgICAgICAgICAg YnJlYWs7CisgICAgICAgICAgY2FzZSBDTE9DS19NT05PVE9OSUNfUkFXOgorICAgICAgICAgICAg dGltZXNwZWNzdWIodHAsICZmdHBsX3N0YXJ0dGltZS5tb25fcmF3LCAmdGRpZmYpOworICAgICAg ICAgICAgYnJlYWs7CisjaWZkZWYgQ0xPQ0tfQk9PVFRJTUUKKyAgICAgICAgICBjYXNlIENMT0NL X0JPT1RUSU1FOgorICAgICAgICAgICAgdGltZXNwZWNzdWIodHAsICZmdHBsX3N0YXJ0dGltZS5i b290LCAmdGRpZmYpOworICAgICAgICAgICAgYnJlYWs7CisjZW5kaWYKKyAgICAgICAgICBkZWZh dWx0OgorICAgICAgICAgICAgcHJpbnRmKCJJbnZhbGlkIGNsb2NrX2lkIGZvciBjbG9ja19nZXR0 aW1lOiAlZCIsIGNsa19pZCk7CisgICAgICAgICAgICBleGl0KEVYSVRfRkFJTFVSRSk7CisgICAg ICAgIH0gLy8gZW5kIG9mIHN3aXRjaCAoY2xrX2lkKQorICAgICAgICBpZiAodXNlcl9yYXRlX3Nl dCkKKyAgICAgICAgeworICAgICAgICAgIHRpbWVzcGVjbXVsKCZ0ZGlmZiwgdXNlcl9yYXRlLCAm dGltZWFkaik7CisgICAgICAgIH0KKyAgICAgICAgZWxzZQorICAgICAgICB7CisgICAgICAgICAg dGltZWFkaiA9IHRkaWZmOworICAgICAgICB9CisgICAgICAgIHRpbWVzcGVjYWRkKCZ1c2VyX2Zh a2VkX3RpbWVfdGltZXNwZWMsICZ0aW1lYWRqLCB0cCk7CisgICAgICB9CisgICAgICBicmVhazsK KworICAgIGRlZmF1bHQ6CisgICAgICByZXR1cm4gLTE7CisgIH0gLy8gZW5kIG9mIHN3aXRjaChm dF9tb2RlKQorCisjaWZkZWYgUFRIUkVBRF9TSU5HTEVUSFJFQURFRF9USU1FCisgIHB0aHJlYWRf Y2xlYW51cF9wb3AoMSk7CisjZW5kaWYKKyAgc2F2ZV90aW1lKHRwKTsKKyAgcmV0dXJuIDA7Cit9 CisKK2ludCBmYWtlX2dldHRpbWVvZmRheShzdHJ1Y3QgdGltZXZhbCAqdHYpCit7CisgIHN0cnVj dCB0aW1lc3BlYyB0czsKKyAgaW50IHJldDsKKyAgdHMudHZfc2VjID0gdHYtPnR2X3NlYzsKKyAg dHMudHZfbnNlYyA9IHR2LT50dl91c2VjICogMTAwMCAgKyBmdHBsX3N0YXJ0dGltZS5yZWFsLnR2 X25zZWMgJSAxMDAwOworCisgIHJldCA9IGZha2VfY2xvY2tfZ2V0dGltZShDTE9DS19SRUFMVElN RSwgJnRzKTsKKyAgdHYtPnR2X3NlYyA9IHRzLnR2X3NlYzsKKyAgdHYtPnR2X3VzZWMgPXRzLnR2 X25zZWMgLyAxMDAwOworCisgIHJldHVybiByZXQ7Cit9CisKKworLyoKKyAqICAgICAgPT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT0KKyAqICAgICAgRmFrZWQgc3lzdGVtIGZ1bmN0aW9uczogQXBwbGUgTWFjIE9TIFgg c3BlY2lmaWMgICAgICAgICAgID09PSBGQUtFKE9TWCkKKyAqICAgICAgPT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0K KyAqLworCisjaWZkZWYgX19BUFBMRU9TWF9fCisvKgorICogY2xvY2tfZ2V0dGltZSBpbXBsZW1l bnRhdGlvbiBmb3IgX19BUFBMRV9fCisgKiBAbm90ZSBJdCBhbHdheXMgYmVoYXZlIGxpa2UgYmVp bmcgY2FsbGVkIHdpdGggQ0xPQ0tfUkVBTFRJTUUuCisgKi8KK3N0YXRpYyBpbnQgYXBwbGVfY2xv Y2tfZ2V0dGltZShjbG9ja2lkX3QgY2xrX2lkLCBzdHJ1Y3QgdGltZXNwZWMgKnRwKQoreworICBp bnQgcmVzdWx0OworICBtYWNoX3RpbWVzcGVjX3QgY3VyX3RpbWVjbG9ja2lkX3Q7CisgICh2b2lk KSBjbGtfaWQ7IC8qIHVudXNlZCAqLworCisgIGlmIChOVUxMID09IHJlYWxfY2xvY2tfZ2V0X3Rp bWUpCisgIHsgIC8qIGRsc3ltKCkgZmFpbGVkICovCisjaWZkZWYgREVCVUcKKyAgICAodm9pZCkg ZnByaW50ZihzdGRlcnIsICJmYWtldGltZSBwcm9ibGVtOiBvcmlnaW5hbCBjbG9ja19nZXRfdGlt ZSgpIG5vdCBmb3VuZC5cbiIpOworI2VuZGlmCisgICAgcmV0dXJuIC0xOyAvKiBwcm9wYWdhdGUg ZXJyb3IgdG8gY2FsbGVyICovCisgIH0KKworICBET05UX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Nsb2Nr aWRfdC0+dHZfbnNlYyA9IHRzLnR2X25zZWM7CisKKyAgLyogcmV0dXJuIHRoZSByZXN1bHQgdG8g dGhlIGNhbGxlciAqLworICByZXR1cm4gcmVzdWx0OworfQorI2VuZGlmCisKKworLyoKKyAqICAg ICAgPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT0KKyAqICAgICAgRmFrZWQgc3lzdGVtLWludGVybmFsIGZ1bmN0aW9u cyAgICAgICAgICAgICAgICAgICAgICAgICAgID09PSBGQUtFKElOVCkKKyAqICAgICAgPT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT0KKyAqLworCisjaWZkZWYgRkFLRV9JTlRFUk5BTF9DQUxMUworaW50IF9fZ2V0dGlt ZW9mZGF5KHN0cnVjdCB0aW1ldmFsICp0diwgdm9pZCAqdHopCit7CisgIGludCByZXN1bHQ7CisK KyAgLyogc2FuaXR5IGNoZWNrICovCisgIGlmICh0diA9PSBOVUxMKQorICB7CisgICAgcmV0dXJu IC0xOworICB9CisKKyAgLyogQ2hlY2sgd2hldGhlciB3ZSd2ZSBnb3QgYSBwb2ludGVyIHRvIHRo ZSByZWFsIGZ0aW1lKCkgZnVuY3Rpb24geWV0ICovCisgIGlmIChOVUxMID09IHJlYWxfX19nZXR0 aW1lb2ZkYXkpCisgIHsgIC8qIGRsc3ltKCkgZmFpbGVkICovCisjaWZkZWYgREVCVUcKKyAgICAo dm9pZCkgZnByaW50ZihzdGRlcnIsICJmYWtldGltZSBwcm9ibGVtOiBvcmlnaW5hbCBfX2dldHRp bWVvZmRheSgpIG5vdCBmb3VuZC5cbiIpOworI2VuZGlmCisgICAgcmV0dXJuIC0xOyAvKiBwcm9w YWdhdGUgZXJyb3IgdG8gY2FsbGVyICovCisgIH0KKworICAvKiBpbml0aWFsaXplIG91ciByZXN1 bHQgd2l0aC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BsaWJmYWtldGltZTsgaWYgbm90LCB3cml0ZSB0byB0aGUgRnJlZSBTb2Z0d2Fy ZSBGb3VuZGF0aW9uLCBJbmMuLAorICogNTkgVGVtcGxlIFBsYWNlLCBTdWl0ZSAzMzAsIEJvc3Rv biwgTUEgIDAyMTExLTEzMDcgIFVTQQorICovCisKKyNpZm5kZWYgVElNRV9PUFNfSAorI2RlZmlu ZSBUSU1FX09QU19ICisjaW5jbHVkZSA8dGltZS5oPgorCisjZGVmaW5lIFNFQ19UT191U0VDIDEw MDAwMDAKKyNkZWZpbmUgU0VDX1RPX25TRUMgMTAwMDAwMDAwMAorCisvKiBDb252ZW5pZW5jZSBt YWNyb3MgZm9yIG9wZXJhdGlvbnMgb24gdGltZXZhbHMuCisgICBOT1RFOiBgdGltZXJjbXAnIGRv ZXMgbm90IHdvcmsgZm9yID49IG9yIDw9LiAgKi8KKyNkZWZpbmUgdGltZXJpc3NldDIodHZwLCBw cmVmaXgpICgodHZwKS0+dHZfc2VjIHx8ICh0dnApLT50dl8jI3ByZWZpeCMjc2VjKQorI2RlZmlu ZSB0aW1lcmNsZWFyMih0dnAsIHByZWZpeCkgKCh0dnApLT50dl9zZWMgPSAodHZwKS0+dHZfIyNw cmVmaXgjI3NlYyA9IDApCisjZGVmaW5lIHRpbWVyY21wMihhLCBiLCBDTVAsIHByZWZpeCkgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgKCgoYSktPnR2X3NlYyA9PSAoYiktPnR2 X3NlYykgPyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgKChhKS0+dHZf IyNwcmVmaXgjI3NlYyBDTVAgKGIpLT50dl8jI3ByZWZpeCMjc2VjKSA6ICAgICAgICAgICAgICBc CisgICAoKGEpLT50dl9zZWMgQ01QIChiKS0+dHZfc2VjKSkKKyNkZWZpbmUgdGltZXJhZGQyKGEs IGIsIHJlc3VsdCwgcHJlZml4KSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICBkbyAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICBcCisgIHsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIFwKKyAgICAocmVzdWx0KS0+dHZfc2VjID0gKGEpLT50dl9zZWMg KyAoYiktPnR2X3NlYzsgICAgICAgICAgICAgICAgICAgXAorICAgIChyZXN1bHQpLT50dl8jI3By ZWZpeCMjc2VjID0gKGEpLT50dl8jI3ByZWZpeCMjc2VjICsgICAgICAgICAgICBcCisgICAgICAo YiktPnR2XyMjcHJlZml4IyNzZWM7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgIFwKKyAgICBpZiAoKHJlc3VsdCktPnR2XyMjcHJlZml4IyNzZWMgPj0gU0VDX1RPXyMjcHJl Zml4IyNTRUMpICAgICAgICAgXAorICAgICAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAgICsrKHJlc3VsdCktPnR2 X3NlYzsgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgICAgICAg KHJlc3VsdCktPnR2XyMjcHJlZml4IyNzZWMgLT0gU0VDX1RPXyMjcHJlZml4IyNTRUM7ICAgICAg ICAgXAorICAgICAgfSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICBcCisgIH0gd2hpbGUgKDApCisjZGVmaW5lIHRpbWVyc3ViMihhLCBi LCByZXN1bHQsIHByZWZpeCkgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwKKyAgZG8gICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgXAorICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICBcCisgICAgKHJlc3VsdCktPnR2X3NlYyA9IChhKS0+dHZfc2VjIC0g KGIpLT50dl9zZWM7ICAgICAgICAgICAgICAgICAgIFwKKyAgICAocmVzdWx0KS0+dHZfIyNwcmVm aXgjI3NlYyA9IChhKS0+dHZfIyNwcmVmaXgjI3NlYyAtICAgICAgICAgICAgXAorICAgICAgKGIp LT50dl8jI3ByZWZpeCMjc2VjOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBcCisgICAgaWYgKChyZXN1bHQpLT50dl8jI3ByZWZpeCMjc2VjIDwgMCkgICAgICAgICAgICAg ICAgICAgICAgICAgICAgIFwKKyAgICB7ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgICAgLS0ocmVzdWx0KS0+dHZfc2Vj OyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgICAocmVz dWx0KS0+dHZfIyNwcmVmaXgjI3NlYyArPSBTRUNfVE9fIyNwcmVmaXgjI1NFQzsgICAgICAgICAg IFwKKyAgICB9ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgXAorICB9IHdoaWxlICgwKQorI2RlZmluZSB0aW1lcm11bDIodHZwLCBj LCByZXN1bHQsIHByZWZpeCkgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgIGRvICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IFwKKyAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgXAorICAgIGxvbmcgbG9uZyB0bXBfdGltZTsgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgdG1wX3RpbWUgPSAoYykgKiAoKHR2 cCktPnR2X3NlYyAqIFNFQ19UT18jI3ByZWZpeCMjU0VDICsgICAgICAgIFwKKyAgICAgICAgICAg ICAgICh0dnApLT50dl8jI3ByZWZpeCMjc2VjKTsgICAgICAgICAgICAgICAgICAgICAgICAgICAg XAorICAgIChyZXN1bHQpLT50dl8jI3ByZWZpeCMjc2VjID0gdG1wX3RpbWUgJSBTRUNfVE9fIyNw cmVmaXgjI1NFQzsgICBcCisgICAgKHJlc3VsdCktPnR2X3NlYyA9ICh0bXBfdGltZSAtIChyZXN1 bHQpLT50dl8jI3ByZWZpeCMjc2VjKSAvICAgIFwKKyAgICAgIFNFQ19UT18jI3ByZWZpeCMjU0VD OyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXAorICAgIGlmICgocmVz dWx0KS0+dHZfIyNwcmVmaXgjI3NlYyA8IDApICAgICAgICAgICAgICAgICAgICAgICAgICAgICBc CisgICAgeyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgIFwKKyAgICAgIChyZXN1bHQpLT50dl8jI3ByZWZpeCMjc2VjICs9ICBTRUNf VE9fIyNwcmVmaXgjI1NFQzsgICAgICAgICAgXAorICAgICAgKHJlc3VsdCktPnR2X3NlYyAtPSAx OyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcCisgICAgfSAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwK KyAgfSB3aGlsZSAoMCkKKworLyogb3BzIGZvciBtaWNyb3NlY3MgKi8KKyNpZm5kZWYgdGltZXJp c3NldAorI2RlZmluZSB0aW1lcmlzc2V0KHR2cCkgdGltZXJpc3NldDIodHZwLHUpCisjZW5kaWYK KyNpZm5kZWYgdGltZXJjbGVhcgorI2RlZmluZSB0aW1lcmNsZWFyKHR2cCkgdGltZXJjbGVhcjIo dHZwLCB1KQorI2VuZGlmCisjaWZuZG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