From patchwork Sat Aug 24 22:01:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 1152729 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cOJC69Ba"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="q+EtLvS/"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46GC071BGkz9sDQ for ; Sun, 25 Aug 2019 08:01:26 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=INWsjUHNFyks3bDhT8gvo5i4d6CKDJ21X++2zEi+cyo=; b=cOJC69BaQPWKVf /n21FV9KC8U4+lTKxrv2NjmD1QX/XTSoybzyVsBEoo+PTz7eLwWH/4/Jx/FoNYzgDdlrLA5c7n3SO a3pzek5xEGL4B/M3cV3AQgCyHMr5ASyXJsl/frzlomKvuBNov25uUoJ5UihbC9uzUlZRnFU7H7oP4 I6G5aTeG1gSh+DWyp0CoQJTV80yB/f31sWFWJ02Z8WgPhyh41GAPouEyTM9Ghr4Nk0pOxE2LwUxMp OalqfOcYCIYpMgcONQnsbOQObMms5vfHAJ9Zp8CgB8WC7rJ6eIlEMTcTK4nz7V2r3Nqe3mCdf9bP8 v/JIP8RvRo9NSd1AdDRg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i1e67-0008AK-Tt; Sat, 24 Aug 2019 22:01:23 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i1e65-0008A1-D4 for hostap@lists.infradead.org; Sat, 24 Aug 2019 22:01:22 +0000 Received: by mail-pf1-x42e.google.com with SMTP id c81so9044625pfc.11 for ; Sat, 24 Aug 2019 15:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=IQ2IWGh9ep5Kp3XIcyeBv6RxvjYoI//6JWB2WZHNHqU=; b=q+EtLvS/YZs/HXvE99PK3af1EnRKScc9VNMbC+/HXXlLnXwMQMcJbO7piwCxJkuBzu +5j8gdFpE4xc6Dl3N52or75zRgIC/pS1sIot2L5TtHcKrOclKEGkIx2EqXTCM5Agj0hf z7Xxugurml8hrpe60gPH19jSSy1a7+h/BGABhldnQ5auvW71lYcfOk6xIAM3FyK3m2ex TE4buUMzre4A8asglS4y60RwM05yylgoD374ltgV+OhBfMGQVCMpDXoyVVOC7OD0ZbVm BxL4gtW3m2Pq89DFHplZ1YdLdFoWVm7jFEkSiJSs7AsOXbC8sdwkBPGjT+BEWSmH9JqA jAiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=IQ2IWGh9ep5Kp3XIcyeBv6RxvjYoI//6JWB2WZHNHqU=; b=XCao9zEc2NjsUAAzy7lwFCoxyUAF/x4AQ/nR5GOOn5OyeDVVsgxEMx1xqFletrSJpa nCSoDnHiAE2ofWn5qZxHCusUBKcExhGBi+qk4eRPgtIsY/vzLZDwpHlkYJ1rnR5L08B2 tT3knzckJ2HVtw1O9F5dF9nX2DylnJtROWvdfkG7z2a6j7qcnV7zfqEFwK4Lg/VsMuDv ZzsFTPD/6iswdYWlgdPnwe97Avx1G+tayn70HuAtCS+ndVI9DJTgqyIsYa87MO/5uNXW mfjzETcwHJf6HWMaxc8mBqyB6rfRsorGSh7DDcPH7CRKcnniRwH2ouelO7RRJXP1zJxL pyZw== X-Gm-Message-State: APjAAAXzEVI+qOTr6Seoj786AQCK35N0oQPPBDnREu5P4p4bqhrrki5k r2+IqmA4fE/3EC5dohVjghStxdFGUO8= X-Google-Smtp-Source: APXvYqzPD1i6eIqLqqYNIsJteK4VsKGSZadP244UPIwqwWsAB4CzKjQEcLJTokaVujXatWGu5BKppg== X-Received: by 2002:aa7:8498:: with SMTP id u24mr12665793pfn.61.1566684078789; Sat, 24 Aug 2019 15:01:18 -0700 (PDT) Received: from localhost.localdomain (76-14-106-55.rk.wavecable.com. [76.14.106.55]) by smtp.gmail.com with ESMTPSA id 185sm6409317pfa.170.2019.08.24.15.01.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Aug 2019 15:01:18 -0700 (PDT) From: Rosen Penev To: hostap@lists.infradead.org Subject: [PATCHv2] os_sleep: Use nanosleep for POSIX versions 2008 and higher Date: Sat, 24 Aug 2019 15:01:16 -0700 Message-Id: <20190824220116.27624-1-rosenp@gmail.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190824_150121_469221_1B4D449B X-CRM114-Status: UNSURE ( 8.05 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42e listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (rosenp[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org uClibc-ng optionally disabled deprecated POSIX functions like usleep, causing compilation failures. This switches to nanosleep while retaining support for older libcs that do not support nanosleep. Signed-off-by: Rosen Penev --- v2: Changed approach to simplify the function. src/utils/os_internal.c | 5 +++++ src/utils/os_unix.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/utils/os_internal.c b/src/utils/os_internal.c index 474c8a372..2c90f51c2 100644 --- a/src/utils/os_internal.c +++ b/src/utils/os_internal.c @@ -25,10 +25,15 @@ void os_sleep(os_time_t sec, os_time_t usec) { +#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) + const struct timespec req = {sec, usec * 1000}; + nanosleep (&req, NULL); +#else if (sec) sleep(sec); if (usec) usleep(usec); +#endif } diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index 800c50772..21fb8b3be 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -49,10 +49,15 @@ struct os_alloc_trace { void os_sleep(os_time_t sec, os_time_t usec) { +#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200809L) + const struct timespec req = {sec, usec * 1000}; + nanosleep (&req, NULL); +#else if (sec) sleep(sec); if (usec) usleep(usec); +#endif }