From patchwork Tue Jan 29 17:36:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 157005 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4935743jaa; Tue, 29 Jan 2019 09:37:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Vd6+nzjl2670Ge1L+x0CBBMLW14k/dnZeBUr4LsoVsMo/ouTYFu3SwsliZ0DzyCWvSugt X-Received: by 2002:a17:906:46:: with SMTP id 6-v6mr23321523ejg.221.1548783467232; Tue, 29 Jan 2019 09:37:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783467; cv=none; d=google.com; s=arc-20160816; b=iqGHt3OE0GjwWxhlmURt2jA/y2PY4GIVNajU/qRG+4SuToYezrF3Ws3rDbisXB2HzG Zv/JzoYV/aM3Xm1Lsae4tIxsFcFdEK0o9SVvnmb5Zgu+YJKgcP5dQI9lzJpopa/hTn9N iSJhO3zAGQXVSurhTH9Pgo2qeujN9v0N/QNRamMXdrdPwtKpZ0Gao8lkgq/xU6sJUSAc Ity3ygJr/Sc1rDFEup+6G85IbgbqXfb5wzzHUScP2hPhc+XcjZjnL+OIz2JncUKHIlTM Pd8at165WpWFtlv2MWN9aUCUvDeVpa7c+XfT3m3+RKqzWJ1pgl+eP6YRCsQrr/G8jksC KqPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=hNVGPdrkui+5QOWcQGhY5HfyDtCZQn+9v7cWZxMa36Q=; b=XqTlVKiKeZEUSi/P/TrQOOJVYp2K+lKaVpQrZhSZuwvJ/ZhBkdyIP8in38zVgLyfM1 GMvOcryH9XRnd6sabw8RBb/IZhkT5sIaf01OMi8xz7+PkGEFzw5ivVG/kWQcjx0rRQ99 626yOSgWKMfri2BehaoJcpkWv5dCICzOEY4pTHem1IcfhsCpaTCYK6BAuB2/1A5VY0m+ KU9i7trwl/MNO6gSdgAp0z+3bp316HI25aKWb9pRFaxoFDlAfc+b1X994AChuw3p844P qxnyV5iGQGYYWtOtV/yZW3CzKnvLlwUVeDjrHJ6DuK0V/o34NVXsSWTrXMGN/a3GfU0R xr8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=epq7kPfk; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [2001:1418:10:5::2]) by mx.google.com with ESMTPS id s16si2813876edd.300.2019.01.29.09.37.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:47 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) client-ip=2001:1418:10:5::2; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=epq7kPfk; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B9AFA3EA178 for ; Tue, 29 Jan 2019 18:37:46 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id B31363EA13F for ; Tue, 29 Jan 2019 18:37:12 +0100 (CET) Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 28457140115F for ; Tue, 29 Jan 2019 18:37:12 +0100 (CET) Received: by mail-qk1-x743.google.com with SMTP id y78so11987854qka.12 for ; Tue, 29 Jan 2019 09:37:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1jSJjnLlFRAJUqF570G9oN8sKkMzhkVQW+qJGrTE3LQ=; b=epq7kPfkGMGx1bUHSwqKK/MviAatv0vbUG0eWfktrZUY8AdC6R8x3SedlR4qQ4xKjR 3+hOuJy7gl0vR/pdoj6b8ZALUUQSojX1nEgEo1RkO2tEO5HsAvKlRjix2mv7XQlG3aZB ZPsMVv/gYN/DUJT+589/RG0yyBeXFDXe3ValE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1jSJjnLlFRAJUqF570G9oN8sKkMzhkVQW+qJGrTE3LQ=; b=JX9P5we1zSUPNIBWvW75Fy9295R7PD7fFVOcSYFm8h+CL6ZnXgNDRherq60qUCCdE1 JEGjLd0VSQL6+p4DxrGlW9JWzIp/2R6j69Oxt30xT1MyYi0V78h1i+6BsOzxJ3TKkbR3 P9wjsU4VqvX8v6fKXnQT+4uyrSPB2/R0iwaKzALurxZv5BMN2ycHVh4Dqm1dwy6s4FQ5 brywrIGNlO5eTzb1bqIzDzMI7SuUP+gJFBqgr7KVYimRgI6WJ9eWV0fQORHUpMeajQkw lFcOOEAU4fY6iMhxkDP2IHoErr8btsc3UXda7gItTVprq7rs/ZzvPvO/1EX97xtLP4NJ JC8A== X-Gm-Message-State: AJcUukewvlVWTJYPwChUfj8clabaOrdurnVXdL/huJHC2yL0o9DokEBE EDiWaA5vuwzydPL9qBDMSdKvsCS3Quc= X-Received: by 2002:a37:a884:: with SMTP id r126mr23204619qke.143.1548783430890; Tue, 29 Jan 2019 09:37:10 -0800 (PST) Received: from workstation.celeiro.br. ([168.194.163.64]) by smtp.gmail.com with ESMTPSA id a20sm56890855qkj.28.2019.01.29.09.37.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:10 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:56 -0200 Message-Id: <20190129173659.27901-5-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129173659.27901-1-rafael.tinoco@linaro.org> References: <20190124161159.GC16804@rei.lan> <20190129173659.27901-1-rafael.tinoco@linaro.org> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v4 5/8] tst_timer: Add tst_timespec_sub_us() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" This commit adds a tst_timespec_sub_us() function that subtracts microseconds from a given timespec struct. Signed-off-by: Rafael David Tinoco --- include/tst_timer.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/tst_timer.h b/include/tst_timer.h index b57adf7aa..043b71460 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -170,6 +170,23 @@ static inline struct timespec tst_timespec_add(struct timespec t1, return res; } +/* + * Subtracts us microseconds from t. + */ +static inline struct timespec tst_timespec_sub_us(struct timespec t, + long long us) +{ + t.tv_sec -= us / 1000000; + t.tv_nsec -= (us % 1000000) * 1000; + + if (t.tv_nsec < 0) { + t.tv_sec--; + t.tv_nsec += 1000000000; + } + + return t; +} + /* * Returns difference between two timespec structures. */