From patchwork Thu Jan 29 11:01:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 43923 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 20AA02410D for ; Thu, 29 Jan 2015 11:27:30 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u10sf18628288lbd.3 for ; Thu, 29 Jan 2015 03:27:28 -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=P274ioCEnmsHvb/JdBWL29l0ZBkUeFLj4E5MB/fyr2M=; b=iBHo5+Z7EUE8OIdCSNwzgCzBLFFsrZ2aWZ2ivZlNX+/EIhxirFfDVFGmOsN58YyC5D CNd2mxlgm1srgPDD+S9qXITZu2dp/HFZmihiHs3cM3LEm4J7s3b2TyGkKSmz7/zT3adf gSHt83wQ+VMFe4GrFbzutETHza1+DqsBaE4QyS4O8+PlKvrIAe9JRl7fh6DpPfqY8nOm e5Wp1GNOwoo6rMejSRlI0uuK/1ZxCA3craU/OMVQFLpSn8AXdmXPLXWT6c6w0aErWTyE 3UM6YVnZ4oY20wwgO4dGGXnRkxiXNK1o2zJdze+9dGRhYFtrAxfW/ZdJCEK3cVgEl9EX Oovw== X-Gm-Message-State: ALoCoQn4CUj8FFBveQEMG8oy9hkHIDITdIXK6c6nH8xqmzNEk/S05UH1HwhEfLrJbOscuUnuB0ON X-Received: by 10.112.42.104 with SMTP id n8mr6785lbl.19.1422530847864; Thu, 29 Jan 2015 03:27:27 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.197.2 with SMTP id iq2ls328207lac.2.gmail; Thu, 29 Jan 2015 03:27:27 -0800 (PST) X-Received: by 10.112.37.161 with SMTP id z1mr13618386lbj.87.1422530847653; Thu, 29 Jan 2015 03:27:27 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id l4si7047873lam.134.2015.01.29.03.27.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 03:27:27 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id u14so26853922lbd.2 for ; Thu, 29 Jan 2015 03:27:27 -0800 (PST) X-Received: by 10.152.203.230 with SMTP id kt6mr121914lac.38.1422530847468; Thu, 29 Jan 2015 03:27:27 -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 h5csp1730984lbj; Thu, 29 Jan 2015 03:27:26 -0800 (PST) X-Received: by 10.224.65.4 with SMTP id g4mr12947qai.60.1422529306629; Thu, 29 Jan 2015 03:01: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 n6si5671565qag.104.2015.01.29.03.01.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 03:01: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 1YGmr1-0007ur-M0; Thu, 29 Jan 2015 11:01:43 +0000 Received: from mail-lb0-f177.google.com ([209.85.217.177]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YGmqj-0007sm-N7 for lng-odp@lists.linaro.org; Thu, 29 Jan 2015 11:01:25 +0000 Received: by mail-lb0-f177.google.com with SMTP id p9so26721791lbv.8 for ; Thu, 29 Jan 2015 03:01:19 -0800 (PST) X-Received: by 10.112.53.137 with SMTP id b9mr13333901lbp.66.1422529279534; Thu, 29 Jan 2015 03:01:19 -0800 (PST) Received: from macmini.lan (78-82-118-111.tn.glocalnet.net. [78.82.118.111]) by mx.google.com with ESMTPSA id s7sm2045761las.17.2015.01.29.03.01.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 03:01:18 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Thu, 29 Jan 2015 12:01:11 +0100 Message-Id: <1422529273-31282-4-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422529273-31282-1-git-send-email-ola.liljedahl@linaro.org> References: <1422529273-31282-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCHv3 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.171 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 bc4fdf4..ce5ffb1 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) {