From patchwork Fri Jan 16 17:05: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: 43258 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 39BE1240BA for ; Fri, 16 Jan 2015 17:06:45 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id k14sf11738979wgh.2 for ; Fri, 16 Jan 2015 09:06:44 -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=qfIwSbZBBMMRXz7FkXZX2x8oU1Jtpl05pelK1qbqNoU=; b=RKvgXRp2yyBS92EeuIai3Ma6FHd57LPwJPci7g3Ae7S2kMT7aJKw9FMqBKNhJcvhJi 7WFrO9r6M/n/AkEUYPEtTPCA1ggtWrk13ffhtOgnRwNkLXKuME1ymPmS5eEGeUwxniIo AKBoAaOYTCu5vUWDtIxa4kbQpQJsebCV7n+ZO8/gPHYhxJXv3HTQp8+3h9QbXjfnElS0 Ra8rjszygun5JBt/0A0G9ho9estsqpokdS/BWph4xB3LbFfMW6hMdD81LvfD+73fglZV J1PTDq14gNOHwOus7PC3cT9BfiAJnXQoqTKJSlG35JYXWAYqPjCXah0+Kagig2clZA3y T4NQ== X-Gm-Message-State: ALoCoQk8IfwuufM21LN4Dh829KgOGFb3FqyoM5hGutWu7azphW0hEUU9ZCreezOCiZCa7sNbFBg5 X-Received: by 10.112.160.41 with SMTP id xh9mr443636lbb.12.1421428004431; Fri, 16 Jan 2015 09:06:44 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.67 with SMTP id de3ls17018lac.60.gmail; Fri, 16 Jan 2015 09:06:44 -0800 (PST) X-Received: by 10.112.14.134 with SMTP id p6mr17195342lbc.36.1421428004283; Fri, 16 Jan 2015 09:06:44 -0800 (PST) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id v4si4895600lav.88.2015.01.16.09.06.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 09:06:44 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by mail-la0-f42.google.com with SMTP id gd6so20103399lab.1 for ; Fri, 16 Jan 2015 09:06:44 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr16837060lal.29.1421428004188; Fri, 16 Jan 2015 09:06:44 -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.9.200 with SMTP id c8csp373760lbb; Fri, 16 Jan 2015 09:06:43 -0800 (PST) X-Received: by 10.140.86.99 with SMTP id o90mr25005371qgd.21.1421428002945; Fri, 16 Jan 2015 09:06:42 -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 d110si6617577qga.93.2015.01.16.09.06.39 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 16 Jan 2015 09:06:42 -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 1YCAM1-0000wO-Gl; Fri, 16 Jan 2015 17:06:37 +0000 Received: from mail-la0-f44.google.com ([209.85.215.44]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YCALe-0000tX-Cx for lng-odp@lists.linaro.org; Fri, 16 Jan 2015 17:06:14 +0000 Received: by mail-la0-f44.google.com with SMTP id gd6so20106081lab.3 for ; Fri, 16 Jan 2015 09:06:08 -0800 (PST) X-Received: by 10.112.72.197 with SMTP id f5mr16497559lbv.21.1421427968824; Fri, 16 Jan 2015 09:06:08 -0800 (PST) Received: from macmini.lan (78-82-118-111.tn.glocalnet.net. [78.82.118.111]) by mx.google.com with ESMTPSA id 1sm1578217lay.40.2015.01.16.09.06.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 09:06:07 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Fri, 16 Jan 2015 18:05:58 +0100 Message-Id: <1421427959-11751-4-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421427959-11751-1-git-send-email-ola.liljedahl@linaro.org> References: <1421427959-11751-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCHv2 3/4] test: 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.42 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 5ba1b84..ce5dcaf 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_buffer_t buf = odp_queue_deq(queue); if (buf != ODP_BUFFER_INVALID) {