From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 8378145BF5;
	Sun, 27 Oct 2024 18:26:46 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 669CE40656;
	Sun, 27 Oct 2024 18:26:33 +0100 (CET)
Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com
 [209.85.214.178])
 by mails.dpdk.org (Postfix) with ESMTP id 2733A402EB
 for <dev@dpdk.org>; Sun, 27 Oct 2024 18:26:29 +0100 (CET)
Received: by mail-pl1-f178.google.com with SMTP id
 d9443c01a7336-20caccadbeeso37696345ad.2
 for <dev@dpdk.org>; Sun, 27 Oct 2024 10:26:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1730049988;
 x=1730654788; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=v4Z6zZB91nRRGcmp1MNgihwfBAGSCErMwYU3lp5c/vQ=;
 b=J+NL0om7l5YalpsoGJu6OYeBkMutCwmXUCfvMF8rIm6vXgwzdnMBs4lDTQybtCduBG
 uHAxY/bEStjBMNmIrAjyXGyhch9AGsVnOnpxXAS+XR6pHvSZy8TaRwRSY+Fq7X6EwilP
 /sV0nAPuV8tIQCBNIq4Qi61fDId0jpJbcl+M7sqSccrpGRHwnsE6ZvXmwdnDICggKKdD
 vifEOy3euqnvcIqZxVL/Frn+k8a8Tb7h6EdFAEWKh7G4cy5NWmpQCIG1fuFBDPEBwqrV
 XdLy9oatz7lFZMCIuhN9UuGAohg5h+S5yVCTBTKF79q5Vg1ztNrGkOQ46+oRgbxJnaoS
 NX8w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1730049988; x=1730654788;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=v4Z6zZB91nRRGcmp1MNgihwfBAGSCErMwYU3lp5c/vQ=;
 b=SQ4AT0K48lP3Nc0DmfR5Fp9RQoYHF17cx46ZvdT0Gq5kUA8+eapq11nrBaNch6Hmja
 sz1gSIKSO4yceLxTRi5+7REDr51B+2v6AvZgH7R/UYpgscx2nws0VWMbUHlbeXDb9B46
 nPg4thW58Wfw2/GouGLZ1RJiduidVxc9bKwh75jiyTFNXWCE0M8J2hv2NqWa5yKncaZs
 bSJtF7UJRqpvuky9pODrs3saCBHmOhYBDcA6Hh/gIxKJ8Df5ae7c4RO8/wVY77DsjgJC
 dAbNxvkLnrkg2d41co8FUI0bhMYPEz/9truYNpC+9wevy/YRRSA5aP6+t6OcCfazFdkZ
 /8tQ==
X-Gm-Message-State: AOJu0Yz8wB+O8RL2ozF8B6sj7L10AQP3UDzi+ArJnyqS47VxOr83iMxI
 mXKjfAF5uZbJw+vvHEexwUjpb9edTIovB7X05o9L0m4bYa6WZgw5TfiXvOwATwCT4Cj9Wd15xzq
 GqJAp5g==
X-Google-Smtp-Source: AGHT+IFDaUXg7cSsn5mnMd2b+tQO6ErRJ6T/saTv1ktYgyLe++2seoDKkCcvdj3h+hDI2kl4SsXmQg==
X-Received: by 2002:a17:902:d545:b0:20b:8325:5a1e with SMTP id
 d9443c01a7336-210c6c92793mr67909085ad.36.1730049988378; 
 Sun, 27 Oct 2024 10:26:28 -0700 (PDT)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-210bbf71d50sm37754465ad.72.2024.10.27.10.26.27
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sun, 27 Oct 2024 10:26:28 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
 Tyler Retzlaff <roretzla@linux.microsoft.com>,
 =?UTF-8?q?Morten=20Br=C3=B8rup?= <mb@smartsharesystems.com>,
 Bruce Richardson <bruce.richardson@intel.com>,
 Chengwen Feng <fengchengwen@huawei.com>,
 Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Subject: [PATCH v30 03/13] windows: update os shim
Date: Sun, 27 Oct 2024 10:24:33 -0700
Message-ID: <20241027172616.176175-4-stephen@networkplumber.org>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20241027172616.176175-1-stephen@networkplumber.org>
References: <20200814173441.23086-1-stephen@networkplumber.org>
 <20241027172616.176175-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Windows does not have localtime_r but it does have a similar
function that can be used instead.

Use rte_os_shim.h in lib/log instead of redefine of strdup.

Add fileno() and isatty() to the wrapper.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
 lib/eal/windows/include/rte_os_shim.h | 12 ++++++++++++
 lib/log/log.c                         |  7 +++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/eal/windows/include/rte_os_shim.h b/lib/eal/windows/include/rte_os_shim.h
index eda8113662..0e74eb19c7 100644
--- a/lib/eal/windows/include/rte_os_shim.h
+++ b/lib/eal/windows/include/rte_os_shim.h
@@ -30,6 +30,8 @@
 #define write(fd, buf, n) _write(fd, buf, n)
 #define close(fd) _close(fd)
 #define unlink(path) _unlink(path)
+#define fileno(f) _fileno(f)
+#define isatty(fd) _isatty(fd)
 
 #define IPVERSION	4
 
@@ -110,4 +112,14 @@ rte_clock_gettime(clockid_t clock_id, struct timespec *tp)
 }
 #define clock_gettime(clock_id, tp) rte_clock_gettime(clock_id, tp)
 
+static inline struct tm *
+rte_localtime_r(const time_t *timep, struct tm *result)
+{
+	if (localtime_s(result, timep) == 0)
+		return result;
+	else
+		return NULL;
+}
+#define localtime_r(timep, result) rte_localtime_r(timep, result)
+
 #endif /* _RTE_OS_SHIM_ */
diff --git a/lib/log/log.c b/lib/log/log.c
index 255f757d94..7416c82b34 100644
--- a/lib/log/log.c
+++ b/lib/log/log.c
@@ -14,13 +14,12 @@
 
 #include <rte_log.h>
 #include <rte_per_lcore.h>
-
-#include "log_internal.h"
-
 #ifdef RTE_EXEC_ENV_WINDOWS
-#define strdup _strdup
+#include <rte_os_shim.h>
 #endif
 
+#include "log_internal.h"
+
 struct rte_log_dynamic_type {
 	const char *name;
 	uint32_t loglevel;
-- 
2.45.2