From patchwork Thu Jan 29 15:32:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 43944 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3BD192410D for ; Thu, 29 Jan 2015 15:33:30 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id h11sf13710243wiw.1 for ; Thu, 29 Jan 2015 07:33:26 -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=5d1o+13W0DTG0TTSR5YoQf6hpxeND2XTuuS0i6Dqx5g=; b=NGkkmPFX/umX9hNuLH4RDDzzGq+E6JxUW0RLxEVRip+EC1aXrIDW3rG70jX66HGkAv 5r4+jPNTtj1QsW6kvk89qHoreBA9vtoBaC57MO73fjO0Lckuz+yFp78L1Mv+belGq+lU ADD9dUnCY2Jl820e8goxph58PPPRI57q4neqBirb1MyZuc4GpVnA4/e9Dt9IORt9uv6Q oVIO1tcL88BcTO/B7kzi8kzwxtvhRNF0F/vKT8Zncq95oXj0zJCnkyaP+glJtPPgJtND qo8zoGR4gKG8SoTcjetIoOupgZueZexz4SNs67oYTZGRmztI3mVh84cMSIrd5Q8BiG5K Pveg== X-Gm-Message-State: ALoCoQmr4e1KbXSnAz7/NIZxF/ler+M2Zzq60a6ccyMIJRICTk2caowutJlbOwA1VdfENf3pPM8o X-Received: by 10.180.93.165 with SMTP id cv5mr190574wib.6.1422545597978; Thu, 29 Jan 2015 07:33:17 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.67 with SMTP id la3ls196497lab.25.gmail; Thu, 29 Jan 2015 07:33:17 -0800 (PST) X-Received: by 10.152.183.196 with SMTP id eo4mr1681526lac.0.1422545597752; Thu, 29 Jan 2015 07:33:17 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id dh5si7769385lad.33.2015.01.29.07.33.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 07:33:17 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id u10so29336563lbd.9 for ; Thu, 29 Jan 2015 07:33:17 -0800 (PST) X-Received: by 10.112.44.230 with SMTP id h6mr1518484lbm.98.1422545597523; Thu, 29 Jan 2015 07:33:17 -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 h5csp1798687lbj; Thu, 29 Jan 2015 07:33:16 -0800 (PST) X-Received: by 10.140.101.119 with SMTP id t110mr2071300qge.9.1422545596005; Thu, 29 Jan 2015 07:33:16 -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 ec7si9809544qcb.23.2015.01.29.07.33.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 07:33:15 -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 1YGr5j-00044O-S4; Thu, 29 Jan 2015 15:33:11 +0000 Received: from mail-lb0-f170.google.com ([209.85.217.170]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YGr5U-00042b-LV for lng-odp@lists.linaro.org; Thu, 29 Jan 2015 15:32:56 +0000 Received: by mail-lb0-f170.google.com with SMTP id w7so29336926lbi.1 for ; Thu, 29 Jan 2015 07:32:51 -0800 (PST) X-Received: by 10.152.7.7 with SMTP id f7mr1451531laa.27.1422545571029; Thu, 29 Jan 2015 07:32:51 -0800 (PST) Received: from macmini.lan (78-82-118-111.tn.glocalnet.net. [78.82.118.111]) by mx.google.com with ESMTPSA id rv1sm2172650lbb.25.2015.01.29.07.32.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 07:32:50 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Thu, 29 Jan 2015 16:32:38 +0100 Message-Id: <1422545560-6466-4-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422545560-6466-1-git-send-email-ola.liljedahl@linaro.org> References: <1422545560-6466-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCHv4 3/5] 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.217.178 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 6aace14..d24de2c 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) {