From patchwork Thu Feb 5 08:15:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 44406 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B7BBD21173 for ; Thu, 5 Feb 2015 08:16:37 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id f15sf4252109lbj.2 for ; Thu, 05 Feb 2015 00:16:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=DnibpM4IoolQopF9lCbHoI2ieCcKOEPuw+JBwzaHIKA=; b=fl9teX/GGA2IVL6jNyW9tuEdQVosA0n7BuE+dauQtBbnaTxK+rFqVg+0plJSm+q86y BW+Tih2WnzJgD4sKC7qjJxI3LRmDsub3pEVOQ0gCNtr/mlVAh96+0yMldQXtLcwVyi0L UaNjZvzF7je0mMVQcKjYJ3RznFWr7gxfyMA0oImimmJ+yBZ0kjL0pWvftGikNgsjqm0J 0+5r2L+w1rm1otn+dH4P/LLcev6Pgr7pYnDdjJtG4KF3dGCJQXGkTvbQFQaNcT7PgSdt 1M0xOn6FL7R6r7wYb/YrEWA6BTm8exuWkTKgzCDxsgOWmCjeEcI6Uxnq79YwdyHbzHVb zCEg== X-Gm-Message-State: ALoCoQlnxEpq0uo0h9UTBrhBdVBtZtDn3F88p81usgKQPj0J72zTqD6gxGYTDN+C/P3TrW2sURna X-Received: by 10.152.43.166 with SMTP id x6mr279691lal.3.1423124196640; Thu, 05 Feb 2015 00:16:36 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.25.201 with SMTP id e9ls110970lag.67.gmail; Thu, 05 Feb 2015 00:16:36 -0800 (PST) X-Received: by 10.153.4.5 with SMTP id ca5mr2109053lad.28.1423124196420; Thu, 05 Feb 2015 00:16:36 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id c6si3308220lag.104.2015.02.05.00.16.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 00:16:36 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id q1so5907691lam.5 for ; Thu, 05 Feb 2015 00:16:36 -0800 (PST) X-Received: by 10.112.164.101 with SMTP id yp5mr2072772lbb.82.1423124196296; Thu, 05 Feb 2015 00:16:36 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp991861lbj; Thu, 5 Feb 2015 00:16:35 -0800 (PST) X-Received: by 10.140.81.74 with SMTP id e68mr5260837qgd.41.1423124195023; Thu, 05 Feb 2015 00:16:35 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id n94si5343256qgn.48.2015.02.05.00.16.33 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Feb 2015 00:16:35 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YJHbz-0003bN-Ps; Thu, 05 Feb 2015 08:16:31 +0000 Received: from mail-lb0-f182.google.com ([209.85.217.182]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YJHbj-0003aD-KM for lng-odp@lists.linaro.org; Thu, 05 Feb 2015 08:16:15 +0000 Received: by mail-lb0-f182.google.com with SMTP id l4so5669395lbv.13 for ; Thu, 05 Feb 2015 00:16:10 -0800 (PST) X-Received: by 10.152.10.4 with SMTP id e4mr2155377lab.62.1423124169784; Thu, 05 Feb 2015 00:16:09 -0800 (PST) Received: from macmini.lan (78-82-118-111.tn.glocalnet.net. [78.82.118.111]) by mx.google.com with ESMTPSA id nq7sm807336lbb.49.2015.02.05.00.16.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Feb 2015 00:16:09 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Thu, 5 Feb 2015 09:15:58 +0100 Message-Id: <1423124161-18716-4-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423124161-18716-1-git-send-email-ola.liljedahl@linaro.org> References: <1423124161-18716-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCHv5 3/6] validation: odp_timer.c: use nanosleep instead of usleep X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ola.liljedahl@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Use nanosleep instead of the deprecated usleep. Define POSIX version to be able to use rand_r. (https://bugs.linaro.org/show_bug.cgi?id=1048) Signed-off-by: Ola Liljedahl --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) test/validation/odp_timer.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c index 3fc9327..d74a273 100644 --- a/test/validation/odp_timer.c +++ b/test/validation/odp_timer.c @@ -8,7 +8,10 @@ * @file */ +/* For rand_r and nanosleep */ +#define _POSIX_C_SOURCE 200112L #include +#include #include #include #include "odp_cunit_common.h" @@ -210,8 +213,11 @@ static void *worker_entrypoint(void *arg) /* Save expected expiration tick */ tt[i].tick = cur_tick + tck; } - if (usleep(1000/*1ms*/) < 0) - perror("usleep"), abort(); + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 1000000; /* 1ms */ + if (nanosleep(&ts, NULL) < 0) + perror("nanosleep"), abort(); } /* Cancel and free all timers */ @@ -238,7 +244,11 @@ static void *worker_entrypoint(void *arg) /* Delay some more to ensure timeouts for expired timers can be * received */ - usleep(1000/*1ms*/); + struct timespec ts; + ts.tv_sec = 0; + ts.tv_nsec = 1000000; /* 1ms */ + if (nanosleep(&ts, NULL) < 0) + perror("nanosleep"), abort(); while (nstale != 0) { odp_event_t ev = odp_queue_deq(queue); if (ev != ODP_EVENT_INVALID) {