From patchwork Tue Feb 3 15:44:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 44251 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D3ADD21513 for ; Tue, 3 Feb 2015 15:44:49 +0000 (UTC) Received: by mail-we0-f199.google.com with SMTP id u56sf21521427wes.2 for ; Tue, 03 Feb 2015 07:44:49 -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=HjmYyDIMXbu2ECalpW6BaNjzngIk4Ck7S3cJYJA+P/Xb9z+DGSFNP+bE+ND/nqwBXJ D5YfWVhPDSoG+bqdfk/0yQCUa71qkBy3ocGjucKkESb3DxQ74zHrfS43xWBJYbHGsTnR 4mNQlZWiSt3GD8F59MCQm9V7mRSlDMjcDRizju6Cm7rAsfMzREAHVDRJr+ytDIicfqS9 i6KWxmDxsVa/NGaDoXUMe/6rcW1KrI4RZlPqLXTiDA9NXI0NXhkp6rBfgwkvXOwdE690 hxmQtDsVc9D7JgsEUmkT4w3enEGrkvAGQwm0TwGJq4nR2Uh8EVHRLqx232d3mrG77TZ9 XLGg== X-Gm-Message-State: ALoCoQn079xzv1mz04V3zLm6iQgNWhQW6kU1uOqF8ZrNfAr9fTDMEKOerzOG0ctN2dORQ6cZlj6q X-Received: by 10.112.143.167 with SMTP id sf7mr3192779lbb.0.1422978289082; Tue, 03 Feb 2015 07:44:49 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.6 with SMTP id x6ls771517lag.70.gmail; Tue, 03 Feb 2015 07:44:48 -0800 (PST) X-Received: by 10.112.72.197 with SMTP id f5mr24927232lbv.21.1422978288942; Tue, 03 Feb 2015 07:44:48 -0800 (PST) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id ml8si19494635lbc.77.2015.02.03.07.44.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Feb 2015 07:44:48 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id pv20so52859673lab.7 for ; Tue, 03 Feb 2015 07:44:48 -0800 (PST) X-Received: by 10.112.41.234 with SMTP id i10mr25493808lbl.25.1422978288817; Tue, 03 Feb 2015 07:44:48 -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 h5csp2018754lbj; Tue, 3 Feb 2015 07:44:47 -0800 (PST) X-Received: by 10.224.69.67 with SMTP id y3mr54084628qai.59.1422978286945; Tue, 03 Feb 2015 07:44:46 -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 9si29115828qas.114.2015.02.03.07.44.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 03 Feb 2015 07:44:46 -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 1YIfee-0004u5-1P; Tue, 03 Feb 2015 15:44:44 +0000 Received: from mail-la0-f41.google.com ([209.85.215.41]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YIfeO-0004sg-MQ for lng-odp@lists.linaro.org; Tue, 03 Feb 2015 15:44:28 +0000 Received: by mail-la0-f41.google.com with SMTP id gm9so53099851lab.0 for ; Tue, 03 Feb 2015 07:44:23 -0800 (PST) X-Received: by 10.112.134.74 with SMTP id pi10mr25607513lbb.67.1422978262755; Tue, 03 Feb 2015 07:44:22 -0800 (PST) Received: from localhost.localdomain (78-82-118-111.tn.glocalnet.net. [78.82.118.111]) by mx.google.com with ESMTPSA id k2sm325464lah.32.2015.02.03.07.44.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Feb 2015 07:44:22 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Tue, 3 Feb 2015 16:44:10 +0100 Message-Id: <1422978253-7721-4-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422978253-7721-1-git-send-email-ola.liljedahl@linaro.org> References: <1422978253-7721-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCHv4 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.48 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) {