From patchwork Tue Jan 29 17:36:54 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: 157003 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4935380jaa; Tue, 29 Jan 2019 09:37:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN6/YJdrPegLMj6Gd8JTnq5xE4SnpJoRTuIO6YMvH6cOrENIL6Z0OdoMYBBeYP9YCrJmwNoZ X-Received: by 2002:a5d:5607:: with SMTP id l7mr27069615wrv.25.1548783444957; Tue, 29 Jan 2019 09:37:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548783444; cv=none; d=google.com; s=arc-20160816; b=J1w7N1uHP2X/jvcWEUKLtQVyB8l1USqu+L7S/nzOeA3VnZ7vLA2dX7epfFWh5UKkjF VrIw3f2Cc1eWeKwWmfElglRpWcEOivQHFn2G6kMEt3D4aPd6nb2ADkKXHkeYoSObR6Y8 TEcbxI4/AiWzazi3qTEEoBmG9KMcq05gSjavV1QD5YWlShV/vF3biDvtVUFfoPvKCUzX +uGCBJGBfEH/EGy3v44MvQaj5Ayu7md7M+aeDWP2jfc0Tz9dF8CzzjLWhFlSTmjD2NHb BL0IpQ17rue7yYHnY8fmi5haCj8xB1Tyocs43/W29gk69JA0zYOARjGBAYz++brP8DvT Pugw== 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=S9jp2inM0K+jfdu3zJmjERXtONQpXybiiEzGtADULh8=; b=Njs9tZ0H2gfaCbHmlqAljGHkDRadSu2U66Fc0N2ABycNUNMcG/N5jtL6LsWvZtX789 RfM9311NxDeRMLlZiaOO8F6zKcw5mVnkWofus5Rq6V9Hk5K/ydOZT1SIbkDSxLp24sJf bNJQaeFTQV2sa2iYGXXMWVfmzMrloDtH4D0aGmTHTX72R9tR1GG4mVn4DHHweM9hvTrD HgcRQJYU2XhJRZ1fSRbffn2jfZyIoDgRNxikfdPcWLe37+jnVK795/yyzX+kjg66ALVN /yEdKwO5Ghkkw7lc3eXJ93R0Ca19AC/vFpRbgLK3U+mRzXJqn4YZUPcxq95GXvhfr/vC zRZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=XzNT6uGc; 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 n123si2498810wmb.157.2019.01.29.09.37.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:24 -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=XzNT6uGc; 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 65FDB3EA11D for ; Tue, 29 Jan 2019 18:37:24 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id 930FF3EA141 for ; Tue, 29 Jan 2019 18:37:08 +0100 (CET) Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 65A701000344 for ; Tue, 29 Jan 2019 18:37:07 +0100 (CET) Received: by mail-qk1-x744.google.com with SMTP id 189so12004373qkj.8 for ; Tue, 29 Jan 2019 09:37:07 -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=Ta7mmR7EcqJxkjjzwzpOa8yt//xNRN7Al5Qvzt2G2hA=; b=XzNT6uGcol183FSACQixHDra8BhIE6dDFzc0XiHHhXmTcEUqd59XPQV98I2uj91AHr D6GImZikfmLrBtub0kYtKfmgo7lZZ8xrRXXG44N3/Cz4WbNwe6rTzK6maJV8GLtQW8/Q Kj4exOOt2kShvg9q1Z4RJwiGNuIeQVWtJ4huc= 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=Ta7mmR7EcqJxkjjzwzpOa8yt//xNRN7Al5Qvzt2G2hA=; b=npQRy1hKGs6Zn0kAniHRVcc9740Cb0D4+EQQmQOEKlmVrTHyAvX9ismO9TJMw6v2t7 +Xpev+z8n4vWHl1w+tdOxi4aZInB/i3TN4/6AgTTR81dZdklL6ZnaiF9BLEgqlK+zCH7 TfGJMiaKJkYscRsYzRceTKhGhZq3Wa3qiZVVd0gjcLmMTTevBz31X59BEhfHBnGxy9J7 qiXZPOGiMrNi4gyT/jwn8JeJ7ROrXb0HVOQIC7sYuZQgplsRXBdTnLBikzMxJwjTXhLs gyJe6S0f5Le7+O0yqrrmy4wMjVd2wAdHqSqka3iqOz7YpvgskerOozLXYCeP+vaJjjK7 7Cvw== X-Gm-Message-State: AJcUukeuwq5vSHq8xcNJ4Bk4Shah3RJRi3uxhGkGP6b1xHQE+UZ3y0rX 1LgRnL8iWFqKOrEVAFG2cZTmYNF90Ac= X-Received: by 2002:a37:a80a:: with SMTP id r10mr25298811qke.2.1548783426777; Tue, 29 Jan 2019 09:37:06 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jan 2019 09:37:06 -0800 (PST) From: Rafael David Tinoco To: ltp@lists.linux.it Date: Tue, 29 Jan 2019 15:36:54 -0200 Message-Id: <20190129173659.27901-3-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-4.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-4.smtp.seeweb.it Subject: [LTP] [PATCH v4 3/8] tst_timer: Add tst_timespec_add() 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_add() function that adds two given timespec structs. It is needed in order to avoid unneeded ns <-> us conversions because, so far, there is only tst_timespec_add_us() available. Signed-off-by: Rafael David Tinoco --- include/tst_timer.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/tst_timer.h b/include/tst_timer.h index 577bc88ef..b57adf7aa 100644 --- a/include/tst_timer.h +++ b/include/tst_timer.h @@ -151,6 +151,25 @@ static inline struct timespec tst_timespec_add_us(struct timespec t, return t; } +/* + * Adds two timespec structures. + */ +static inline struct timespec tst_timespec_add(struct timespec t1, + struct timespec t2) +{ + struct timespec res; + + res.tv_sec = t1.tv_sec + t2.tv_sec; + res.tv_nsec = t1.tv_nsec + t2.tv_nsec; + + if (res.tv_nsec >= 1000000000) { + res.tv_sec++; + res.tv_nsec -= 1000000000; + } + + return res; +} + /* * Returns difference between two timespec structures. */