From: Andre Muezerie <andremue@linux.microsoft.com>
To: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,
Tyler Retzlaff <roretzla@linux.microsoft.com>
Cc: dev@dpdk.org, Andre Muezerie <andremue@linux.microsoft.com>
Subject: [PATCH 1/2] eal: add strsep() for Windows builds
Date: Fri, 16 May 2025 06:22:13 -0700 [thread overview]
Message-ID: <1747401734-6303-1-git-send-email-andremue@linux.microsoft.com> (raw)
Function strsep() is used by DPDK code but is not available on Windows.
This patch adds an implementation from NetBSD, unblocking code depending
on it from being compiled on Windows.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
lib/eal/windows/include/rte_os_shim.h | 1 +
lib/eal/windows/include/strsep.h | 9 +++++
lib/eal/windows/meson.build | 1 +
lib/eal/windows/strsep.c | 47 +++++++++++++++++++++++++++
4 files changed, 58 insertions(+)
create mode 100644 lib/eal/windows/include/strsep.h
create mode 100644 lib/eal/windows/strsep.c
diff --git a/lib/eal/windows/include/rte_os_shim.h b/lib/eal/windows/include/rte_os_shim.h
index 0e74eb19c7..9c3da554da 100644
--- a/lib/eal/windows/include/rte_os_shim.h
+++ b/lib/eal/windows/include/rte_os_shim.h
@@ -7,6 +7,7 @@
#include <rte_os.h>
#include <rte_windows.h>
+#include <strsep.h>
/**
* @file
diff --git a/lib/eal/windows/include/strsep.h b/lib/eal/windows/include/strsep.h
new file mode 100644
index 0000000000..d5d2860d48
--- /dev/null
+++ b/lib/eal/windows/include/strsep.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ */
+
+#pragma once
+
+char *
+strsep(char **stringp, const char *delim);
diff --git a/lib/eal/windows/meson.build b/lib/eal/windows/meson.build
index 7756d417be..eadecd473c 100644
--- a/lib/eal/windows/meson.build
+++ b/lib/eal/windows/meson.build
@@ -19,6 +19,7 @@ sources += files(
'eal_timer.c',
'getopt.c',
'rte_thread.c',
+ 'strsep.c',
)
dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
diff --git a/lib/eal/windows/strsep.c b/lib/eal/windows/strsep.c
new file mode 100644
index 0000000000..fdc0688a07
--- /dev/null
+++ b/lib/eal/windows/strsep.c
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ */
+
+#include <string.h>
+
+#include "strsep.h"
+
+/* Get next token from string *stringp, where tokens are possibly empty
+ * strings separated by characters from delim.
+ *
+ * Writes NULLs into the string at *stringp to end tokens.
+ * delim need not remain constant from call to call.
+ * On return, *stringp points past the last NULL written (if there might
+ * be further tokens), or is NULL (if there are definitely no more tokens).
+ *
+ * If *stringp is NULL, strsep returns NULL.
+ */
+char *
+strsep(char **stringp, const char *delim)
+{
+ char *s;
+ const char *spanp;
+ int c, sc;
+ char *tok;
+
+ s = *stringp;
+ if (s == NULL)
+ return NULL;
+ for (tok = s;;) {
+ c = *s++;
+ spanp = delim;
+ do {
+ sc = *spanp++;
+ if (sc == c) {
+ if (c == 0)
+ s = NULL;
+ else
+ s[-1] = 0;
+ *stringp = s;
+ return tok;
+ }
+ } while (sc != 0);
+ }
+ /* NOTREACHED */
+}
--
2.49.0.vfs.0.3
next reply other threads:[~2025-05-16 13:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 13:22 Andre Muezerie [this message]
2025-05-16 13:22 ` [PATCH 2/2] test/strsep: add tests for function strsep() Andre Muezerie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1747401734-6303-1-git-send-email-andremue@linux.microsoft.com \
--to=andremue@linux.microsoft.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=roretzla@linux.microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).