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: 1012263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FmIca58r"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FTCD0Cc1z9s7h for ; Thu, 13 Dec 2018 07:37:41 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 55B353E6F54 for ; Wed, 12 Dec 2018 21:37:32 +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-Google-Smtp-Source: AFSGD/VWdeJh0IXxVilOaOGZDKOLm5JLVae2HLUDp8tOy/5tqU9KH6dTna6dq/jI3kW7sWhmiFYsog== 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+incoming=patchwork.ozlabs.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. */