From patchwork Wed Dec 12 20:37:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rafael David Tinoco X-Patchwork-Id: 153591 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp26331ljp; Wed, 12 Dec 2018 12:37:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/UNkpk58JmSr4lTwwE4jGyQ6GkI7wCkVsthlhA+czm5ntX8+ghMMsZwY4/OsLXQjqJGC2uE X-Received: by 2002:a17:906:6dcb:: with SMTP id j11-v6mr16440165ejt.162.1544647055771; Wed, 12 Dec 2018 12:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544647055; cv=none; d=google.com; s=arc-20160816; b=X728lm/6OBOSd1nzGKl/q1lfOx75eXplQ3QtshGO3NdfkEQ9m9Tr2cFPg7WAG9zxuB Sl6d4ix7VSe0vwjyq4q35qhWxr82wa7kS7mHN5H0BcXwYs/OADOd/L7ZI7X0PlvqUudG fU4KeeP97xRSHaiCtDgXhwfJMAydkDE68WxRTMtNC4y12hWqoF3XM0phylBsbkX4RFIZ IgGd8U4xU4yRKKcqDOh+NQC9qYRBWnfBe/Gwtcu7iHyOb68+lEjbHwnpqPIID2ldVqEB iD5YSNyXakvB7w4DTEwNchhJapIb0Xpto4QrnP/Ga7qebjhl16uLvwYusgm+8ICvXeIh O29A== 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=l8rhq4pzUxyzh/gKiMmibOoJ9LSgPRzKHbsl3JvpXDw=; b=EyAV25mhEwPXKJF6o5a4VuV3COG2k98KHRkmsOVH3T86GXF0jJSYksF5IdN23VY4z5 5xbew/LFFUyljlm5vgYyI3ke4gjW9t9kPd2h2XLb5OMyMjNiEt8HSW716HnofZDYaTwW EN7gV8scqaWmwxM+wNtDhIRL4rQTul1ItDLL8Rx7IPQYgEGonhSk8LTususpkXn8I22G UVFgN3s9TVRU750le03TlWJAtMYV1C4/SbTctykeyiP/l54gd3K8nhtjBzijRFt0ZlcU vuP0gf/GiaQ2aifp2eIIgjuJUgvgmrIIisiYh92EQ8DS9oNCgxlXVWSV+hbuyOkuoY2O JPMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FmIca58r; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 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. [213.254.12.146]) by mx.google.com with ESMTPS id i18-v6si38257ejp.287.2018.12.12.12.37.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:35 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) client-ip=213.254.12.146; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FmIca58r; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 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 355933E6FD4 for ; Wed, 12 Dec 2018 21:37:35 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 46CF63E6F10 for ; Wed, 12 Dec 2018 21:37:30 +0100 (CET) Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 46C5F201008 for ; Wed, 12 Dec 2018 21:37:28 +0100 (CET) Received: by mail-qk1-x742.google.com with SMTP id y78so11599490qka.12 for ; Wed, 12 Dec 2018 12:37:28 -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=JDlkqHawYJKTG0rd13zivqSEohUZOvSs1ARu/qU6UhY=; b=FmIca58rgNjSiV0bzZOD+8jR1zkRrzC0ECIzH6LAWcW44S8eELqE/+pfyusIs+iEAb NGo+xa5aEP5KnEii6DtM0vBqTxFY0kdalOPIbTlkCRPfIEN6ZyhvT4vU3arOdyXNBdrZ JDiaUzBZ3CTSHpNKFovK5c10tkS/Boe3RltoQ= 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=JDlkqHawYJKTG0rd13zivqSEohUZOvSs1ARu/qU6UhY=; b=OA81Pcyc/7soLUjpkofawLRvwx6dVg+tkHUBoyvpr3lIfLzV2GKlFtlQazum0T5ZkJ le0gy2CcJKWLS8OGaIOYzIQ4sfo8HzbolhOfj1qqrZTgNNzlwuRW2EAbp2KYnus8PWXZ kmdAvGF3bnzlTYqI34A3bGhuw2+H3XeylbGvME5oMGSGzn2hPqgzswpGYDDydTyOZDLA iwYlYv3bET0I0Qm2UG0oQlcoUcvHPHQLqSlOZ7jlPJfX/5GtlIP28w/OrtVxqbRO5+Kw wIBNdg2MvJN+mdr6yav6+ktJUt+en8SE8aBTFdmTwzzbJt5l2Nx1AnF7gC5nwIFUTYmE hd5A== X-Gm-Message-State: AA+aEWaVAVuBmWaLLPlBLFkUtCGbHHkt6coXmj0FIBJxkqx8AJrXMLf0 eCWYtca9aFJGnbW4SE45NYiDmGsuPH8cyw== X-Received: by 2002:ae9:ed51:: with SMTP id c78mr19232523qkg.85.1544647047665; Wed, 12 Dec 2018 12:37:27 -0800 (PST) Received: from workstation.celeiro.br ([138.204.25.7]) by smtp.gmail.com with ESMTPSA id n3sm11846872qtc.81.2018.12.12.12.37.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Dec 2018 12:37:26 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Wed, 12 Dec 2018 18:37:18 -0200 Message-Id: <20181212203723.18810-1-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.20.0.rc1 In-Reply-To: <20181211142750.GA27159@rei> References: <20181211142750.GA27159@rei> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-7.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-7.smtp.seeweb.it Subject: [LTP] [PATCH v3 1/6] tst_timer.h: add tst_timespect_rem_us() function 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" Expand tst_timer.h functionality by having a function to also remove given microseconds from a given timespec. 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 577bc88ef..b1c9ceeba 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -151,6 +151,23 @@ static inline struct timespec tst_timespec_add_us(struct timespec t, return t; } +/* + * Removes us microseconds to t. + */ +static inline struct timespec tst_timespec_rem_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. */