eal: add strsep() for Windows builds
PATCH 1/2 eal: add strsep() for Windows builds
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.
--- 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
lib/eal/windows/include/rte_os_shim.h +1 -0
@@ -7,6 +7,7 @@#include <rte_os.h> #include <rte_windows.h> +#include <strsep.h> /** * @file
lib/eal/windows/include/strsep.h new file +9 -0
@@ -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);
lib/eal/windows/meson.build +1 -0
@@ -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)
lib/eal/windows/strsep.c new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.49.0.vfs.0.3
PATCH 2/2 test/strsep: add tests for function strsep()
This patch adds tests for the strsep() function.
--- app/test/meson.build | 1 + app/test/test_strsep.c | 108 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 app/test/test_strsep.c
app/test/meson.build +1 -0
@@ -184,6 +184,7 @@ source_file_deps = { 'test_stack.c': ['stack'], 'test_stack_perf.c': ['stack'], 'test_string_fns.c': [], + 'test_strsep.c': [], 'test_table.c': ['table', 'pipeline', 'port'], 'test_table_acl.c': ['net', 'table', 'pipeline', 'port'], 'test_table_combined.c': ['table', 'pipeline', 'port'],
app/test/test_strsep.c new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.49.0.vfs.0.3
PATCH v2 1/2 eal: add strsep() for Windows builds
In reply to Andre MuezerieFunction 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.
--- lib/eal/windows/include/rte_os_shim.h | 1 + lib/eal/windows/include/strsep.h | 12 +++++++ lib/eal/windows/meson.build | 1 + lib/eal/windows/strsep.c | 47 +++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 lib/eal/windows/include/strsep.h create mode 100644 lib/eal/windows/strsep.c
lib/eal/windows/include/rte_os_shim.h +1 -0
@@ -7,6 +7,7 @@#include <rte_os.h> #include <rte_windows.h> +#include <strsep.h> /** * @file
lib/eal/windows/include/strsep.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 1990, 1993 +* The Regents of the University of California. All rights reserved. +*/ + +#ifndef _STRSEP_ +#define _STRSEP_ + +char * +strsep (char **stringp,const char *delim); + +#endif
lib/eal/windows/meson.build +1 -0
@@ -20,6 +20,7 @@ sources += files( 'getline.c', 'getopt.c', 'rte_thread.c', + 'strsep.c', ) dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
lib/eal/windows/strsep.c new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.50.1.vfs.0.0
PATCH v2 2/2 test/strsep: add tests for function strsep()
This patch adds tests for the strsep() function.
--- app/test/meson.build | 1 + app/test/test_strsep.c | 108 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 app/test/test_strsep.c
app/test/meson.build +1 -0
@@ -187,6 +187,7 @@ source_file_deps = { 'test_stack.c': ['stack'], 'test_stack_perf.c': ['stack'], 'test_string_fns.c': [], + 'test_strsep.c': [], 'test_table.c': ['table', 'pipeline', 'port'], 'test_table_acl.c': ['net', 'table', 'pipeline', 'port'], 'test_table_combined.c': ['table', 'pipeline', 'port'],
app/test/test_strsep.c new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.50.1.vfs.0.0
Re: [PATCH v2 2/2] test/strsep: add tests for function strsep()
Hello Andre,
Quoted 13 lines · Andre Muezerie
app/test/test_strsep.c new file +7
-0@@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2025 Microsoft Corporation +*/ + +#include <string.h> +#include <rte_os_shim.h> +
app/test/test_strsep.c line 17
Quoted 10 lines
app/test/test_strsep.c new file +10
-0+#include "test.h" + +static int +test_strsep_helper (const char *str,const char *delim, +const char *const expected_tokens[],size_t expected_tokens_count) +{ +char *s = str !=NULL ?strdup (str) :NULL ; +const char *token; +for (size_t i =0 ; i < expected_tokens_count; i++) { + token =strsep (&s, delim);
The reference to the dupped string gets lost, since calling strsep updates s. Caught by ASan:
==49990==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 51 byte(s) in 4 object(s) allocated from:
#0 0x5632dd8cbe83 in strdup
(/home/runner/work/dpdk/dpdk/build/app/dpdk-test+0x271e83) (BuildId:
01a7571ab7814bc83923733b3dae34d28e6ff3e1)
#1 0x5632de39bad2 in test_strsep_helper
/home/runner/work/dpdk/dpdk/build/../app/test/test_strsep.c:14:26
#2 0x5632dd91d86f in unit_test_suite_runner
/home/runner/work/dpdk/dpdk/build/../app/test/test.c:364:20
#3 0x5632dd91c2b0 in cmd_autotest_parsed
/home/runner/work/dpdk/dpdk/build/../app/test/commands.c:68:10
#4 0x7fba8b3bfc58 in __cmdline_parse
/home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline_parse.c:296:3
#5 0x7fba8b3bfc58 in cmdline_parse
/home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline_parse.c:305:9
#6 0x7fba8b3bcbf7 in cmdline_valid_buffer
/home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline.c:25:8
#7 0x7fba8b3c50ec in rdline_char_in
/home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline_rdline.c:456:5
#8 0x7fba8b3bcfde in cmdline_in
/home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline.c:154:9
#9 0x5632dd91d2ba in main
/home/runner/work/dpdk/dpdk/build/../app/test/test.c:231:15
#10 0x7fba89a29d8f in __libc_start_call_maincsu/../sysdeps/nptl/libc_start_call_main.h:58:16
SUMMARY: AddressSanitizer: 51 byte(s) leaked in 4 allocation(s).
------------------------------------------------------------------------------
Signature · 1 line
David Marchand
Re: [PATCH v2 2/2] test/strsep: add tests for function strsep()
Quoted 56 lines · David Marchand
Hello Andre,
Quoted 13 lines · Andre Muezerie
app/test/test_strsep.c new file +7
-0@@ -0,0 +1,108 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2025 Microsoft Corporation +*/ + +#include <string.h> +#include <rte_os_shim.h> +app/test/test_strsep.c line 17
Quoted 10 lines
app/test/test_strsep.c new file +10
-0+#include "test.h" + +static int +test_strsep_helper (const char *str,const char *delim, +const char *const expected_tokens[],size_t expected_tokens_count) +{ +char *s = str !=NULL ?strdup (str) :NULL ; +const char *token; +for (size_t i =0 ; i < expected_tokens_count; i++) { + token =strsep (&s, delim);The reference to the dupped string gets lost, since calling strsep updates s. Caught by ASan:
==49990==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 51 byte(s) in 4 object(s) allocated from:
#0 0x5632dd8cbe83 in strdup (/home/runner/work/dpdk/dpdk/build/app/dpdk-test+0x271e83) (BuildId: 01a7571ab7814bc83923733b3dae34d28e6ff3e1) #1 0x5632de39bad2 in test_strsep_helper /home/runner/work/dpdk/dpdk/build/../app/test/test_strsep.c:14:26 #2 0x5632dd91d86f in unit_test_suite_runner /home/runner/work/dpdk/dpdk/build/../app/test/test.c:364:20 #3 0x5632dd91c2b0 in cmd_autotest_parsed /home/runner/work/dpdk/dpdk/build/../app/test/commands.c:68:10 #4 0x7fba8b3bfc58 in __cmdline_parse /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline_parse.c:296:3 #5 0x7fba8b3bfc58 in cmdline_parse /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline_parse.c:305:9 #6 0x7fba8b3bcbf7 in cmdline_valid_buffer /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline.c:25:8 #7 0x7fba8b3c50ec in rdline_char_in /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline_rdline.c:456:5 #8 0x7fba8b3bcfde in cmdline_in /home/runner/work/dpdk/dpdk/build/../lib/cmdline/cmdline.c:154:9 #9 0x5632dd91d2ba in main /home/runner/work/dpdk/dpdk/build/../app/test/test.c:231:15 #10 0x7fba89a29d8f in __libc_start_call_main
Quoted 8 lines
csu/../sysdeps/nptl/libc_start_call_main.h:58:16SUMMARY: AddressSanitizer: 51 byte(s) leaked in 4 allocation(s).
------------------------------------------------------------------------------Signature · 1 line
David Marchand
Thanks for sending this info. I'll send out a fixed version.
PATCH v3 1/2 eal: add strsep() for Windows builds
In reply to Andre MuezerieFunction 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.
--- lib/eal/windows/include/rte_os_shim.h | 1 + lib/eal/windows/include/strsep.h | 12 +++++++ lib/eal/windows/meson.build | 1 + lib/eal/windows/strsep.c | 47 +++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 lib/eal/windows/include/strsep.h create mode 100644 lib/eal/windows/strsep.c
lib/eal/windows/include/rte_os_shim.h +1 -0
@@ -7,6 +7,7 @@#include <rte_os.h> #include <rte_windows.h> +#include <strsep.h> /** * @file
lib/eal/windows/include/strsep.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (c) 1990, 1993 +* The Regents of the University of California. All rights reserved. +*/ + +#ifndef _STRSEP_ +#define _STRSEP_ + +char * +strsep (char **stringp,const char *delim); + +#endif
lib/eal/windows/meson.build +1 -0
@@ -20,6 +20,7 @@ sources += files( 'getline.c', 'getopt.c', 'rte_thread.c', + 'strsep.c', ) dpdk_conf.set10('RTE_EAL_NUMA_AWARE_HUGEPAGES', true)
lib/eal/windows/strsep.c new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.50.1.vfs.0.0
PATCH v3 2/2 test/strsep: add tests for function strsep()
This patch adds tests for the strsep() function.
--- app/test/meson.build | 1 + app/test/test_strsep.c | 109 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 app/test/test_strsep.c
app/test/meson.build +1 -0
@@ -187,6 +187,7 @@ source_file_deps = { 'test_stack.c': ['stack'], 'test_stack_perf.c': ['stack'], 'test_string_fns.c': [], + 'test_strsep.c': [], 'test_table.c': ['table', 'pipeline', 'port'], 'test_table_acl.c': ['net', 'table', 'pipeline', 'port'], 'test_table_combined.c': ['table', 'pipeline', 'port'],
app/test/test_strsep.c new file +109 -0
109 lines not on this page · raw message
Signature · 1 line
2.50.1.vfs.0.0