DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jie Hai <haijie1@huawei.com>
To: "Stephen Hemminger" <stephen@networkplumber.org>,
	"Morten Brørup" <mb@smartsharesystems.com>
Cc: fengchengwen <fengchengwen@huawei.com>,
	Tyler Retzlaff <roretzla@linux.microsoft.com>, <dev@dpdk.org>,
	<lihuisong@huawei.com>
Subject: Re: [PATCH 00/21] replace strtok with strtok_r
Date: Tue, 21 Nov 2023 11:32:48 +0800	[thread overview]
Message-ID: <b4aa1f21-33af-49db-3ae9-6164e9dc718b@huawei.com> (raw)
In-Reply-To: <20231115070803.73846b03@hermes.local>

On 2023/11/15 23:08, Stephen Hemminger wrote:
> On Wed, 15 Nov 2023 12:27:37 +0100
> Morten Brørup <mb@smartsharesystems.com> wrote:
> 
>>>> just a final follow up, i can see that we already have a rte_strerror
>>>> here to do the replace with reentrant dance. it is probably good to
>>>> follow the already established pattern for this and have a
>>> rte_strtok.
>>>
>>> +1 for have rte_strtok which could cover different platform.
>>
>> +1 to rte_strtok doing the reentrant dance for us.
>>
>> If we had such an rte_strtok(), we could also generally disallow the use of strtok().
> 
> Good idea, I like this.
> Would be good to have a version on Windows as well.
> 
> .
Hi, all maintainers,

Since the map of strtok_r to strtok_s with three patramaters has
been done in "rte_os_shim.h", I just include this file.
And the rte_strtok is defined as below.
My question is whether the
"strtok_s(s, stringlen, delim, save_ptr)" and
"strtok_s(str, delim, saveptr)" are compatible for C11.

And I check the glibc codes here,
https://sourceware.org/git/glibc.git
there is no definition of strtok_s, is strtok_s not in use?

If so, should we delayed processing for the C11 standard strtok_s 
function? That is, delete the "#ifdef __STDC_LIB_EXT1__...
#endif" part, but keep the extension of the four parameters for later 
use. Or keep the following change but never use stringlen as not null
until the function can be used.

What do you think?

diff --git a/lib/eal/include/rte_string_fns.h 
b/lib/eal/include/rte_string_fns.h
index bb43b2cba3eb..6746bfec384b 100644
--- a/lib/eal/include/rte_string_fns.h
+++ b/lib/eal/include/rte_string_fns.h
@@ -15,10 +15,13 @@
  extern "C" {
  #endif

+#define __STDC_WANT_LIB_EXT1__ 1
  #include <stdio.h>
  #include <string.h>

  #include <rte_common.h>
+#include <rte_compat.h>
+#include <rte_os_shim.h>

  /**
   * Takes string "string" parameter and splits it at character "delim"
@@ -115,6 +118,35 @@ rte_strlcat(char *dst, const char *src, size_t size)
  ssize_t
  rte_strscpy(char *dst, const char *src, size_t dsize);

+/*
+ * Divide string s into tokens separated by characters in delim.
+ * Information passed between calls are stored in save_ptr.
+ * The size of the string to be separated is stored in *stringlen.
+ *
+ * @param s
+ *   The string to be separated, it could be NULL.
+ *
+ * @param stringlen
+ *   The pointor to the size of the string to be separated, it could be 
NULL.
+ *
+ * @param delim
+ *   The characters on which the split of the data will be done.
+ *
+ * @param save_ptr
+ *   The internal state of the string separated.
+ */
+static inline char *
+rte_strtok(char *__rte_restrict s, size_t *__rte_restrict stringlen,
+          const char *__rte_restrict delim,
+          char **__rte_restrict save_ptr)
+{
+#ifdef __STDC_LIB_EXT1__
+	if (stringlen != NULL)
+		return strtok_s(s, stringlen, delim, save_ptr);

+#endif
+       (void)stringlen;
+       return strtok_r(s, delim, save_ptr);
+}
+
  #ifdef __cplusplus
  }
  #endif

Thanks,
Jie Hai

  reply	other threads:[~2023-11-21  3:32 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 10:45 Jie Hai
2023-11-13 10:45 ` [PATCH 01/21] app/graph: " Jie Hai
2023-11-13 10:45 ` [PATCH 02/21] app/test-bbdev: " Jie Hai
2023-11-13 10:45 ` [PATCH 03/21] app/test-compress-perf: " Jie Hai
2023-11-13 10:45 ` [PATCH 04/21] app/test-crypto-perf: " Jie Hai
2023-11-13 10:45 ` [PATCH 05/21] app/test-dma-perf: " Jie Hai
2023-11-13 10:45 ` [PATCH 06/21] app/test-fib: " Jie Hai
2023-11-13 10:45 ` [PATCH 07/21] app/dpdk-test-flow-perf: " Jie Hai
2023-11-13 10:45 ` [PATCH 08/21] app/test-mldev: " Jie Hai
2023-11-13 10:45 ` [PATCH 09/21] lib/dmadev: " Jie Hai
2023-11-13 10:45 ` [PATCH 10/21] lib/eal: " Jie Hai
2023-11-13 16:27   ` Stephen Hemminger
2023-11-14  1:05     ` fengchengwen
2023-11-14  1:08       ` Stephen Hemminger
2023-11-13 10:45 ` [PATCH 11/21] lib/ethdev: " Jie Hai
2023-11-13 10:45 ` [PATCH 12/21] lib/eventdev: " Jie Hai
2023-11-13 10:45 ` [PATCH 13/21] lib/telemetry: " Jie Hai
2023-11-13 10:45 ` [PATCH 14/21] " Jie Hai
2023-11-13 10:45 ` [PATCH 15/21] bus/fslmc: " Jie Hai
2023-11-15  2:41   ` Sachin Saxena
2023-11-13 10:45 ` [PATCH 16/21] common/cnxk: " Jie Hai
2023-11-13 10:45 ` [PATCH 17/21] event/cnxk: " Jie Hai
2023-11-13 10:45 ` [PATCH 18/21] net/ark: " Jie Hai
2023-11-13 10:45 ` [PATCH 19/21] raw/cnxk_gpio: " Jie Hai
2023-11-13 10:45 ` [PATCH 20/21] examples/l2fwd-crypto: " Jie Hai
2023-11-13 10:45 ` [PATCH 21/21] examples/vhost: " Jie Hai
2023-11-13 16:26   ` Stephen Hemminger
2023-11-13 11:00 ` [PATCH 00/21] " Thomas Monjalon
2023-11-13 11:33 ` fengchengwen
2023-11-13 16:25 ` Stephen Hemminger
2023-11-13 17:09 ` Tyler Retzlaff
2023-11-14 12:50   ` Jie Hai
2023-11-14 17:32     ` Tyler Retzlaff
2023-11-14 17:34       ` Tyler Retzlaff
2023-11-14 17:49         ` Tyler Retzlaff
2023-11-15  3:02           ` fengchengwen
2023-11-15 11:27             ` Morten Brørup
2023-11-15 15:08               ` Stephen Hemminger
2023-11-21  3:32                 ` Jie Hai [this message]
2024-02-01 11:13                   ` David Marchand
2023-11-14  8:41 ` [PATCH v2 00/22] replace strtok with reentrant version Jie Hai
2023-11-14  8:41   ` [PATCH v2 01/22] app/graph: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 02/22] app/bbdev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 03/22] app/compress-perf: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 04/22] app/crypto-perf: " Jie Hai
2024-01-11 17:10     ` Power, Ciara
2023-11-14  8:41   ` [PATCH v2 05/22] app/dma-perf: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 06/22] app/test-fib: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 07/22] app/flow-perf: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 08/22] app/test-mldev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 09/22] dmadev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 10/22] eal: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 11/22] ethdev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 12/22] eventdev: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 13/22] security: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 14/22] telemetry: " Jie Hai
2024-01-11 17:13     ` Power, Ciara
2023-11-14  8:41   ` [PATCH v2 15/22] bus/fslmc: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 16/22] common/cnxk: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 17/22] event/cnxk: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 18/22] net/ark: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 19/22] raw/cnxk_gpio: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 20/22] examples/l2fwd-crypto: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 21/22] examples/vhost: " Jie Hai
2023-11-14  8:41   ` [PATCH v2 22/22] devtools: check for some reentrant function Jie Hai
2023-11-14 10:59 ` [PATCH v3 00/22] replace strtok with reentrant version Jie Hai
2023-11-14 10:59   ` [PATCH v3 01/22] app/graph: " Jie Hai
2023-11-15  0:07     ` Stephen Hemminger
2023-11-14 10:59   ` [PATCH v3 02/22] app/bbdev: " Jie Hai
2023-11-15  0:09     ` Stephen Hemminger
2023-11-14 10:59   ` [PATCH v3 03/22] app/compress-perf: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 04/22] app/crypto-perf: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 05/22] app/dma-perf: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 06/22] app/test-fib: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 07/22] app/flow-perf: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 08/22] app/test-mldev: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 09/22] dmadev: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 10/22] eal: " Jie Hai
2023-11-15  7:17     ` [EXT] " Amit Prakash Shukla
2023-11-14 10:59   ` [PATCH v3 11/22] ethdev: " Jie Hai
2023-12-16 10:01     ` Andrew Rybchenko
2023-11-14 10:59   ` [PATCH v3 12/22] eventdev: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 13/22] security: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 14/22] telemetry: " Jie Hai
2023-11-14 10:59   ` [PATCH v3 15/22] bus/fslmc: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 16/22] common/cnxk: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 17/22] event/cnxk: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 18/22] net/ark: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 19/22] raw/cnxk_gpio: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 20/22] examples/l2fwd-crypto: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 21/22] examples/vhost: " Jie Hai
2023-11-14 11:00   ` [PATCH v3 22/22] devtools: check for some reentrant function Jie Hai

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=b4aa1f21-33af-49db-3ae9-6164e9dc718b@huawei.com \
    --to=haijie1@huawei.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=lihuisong@huawei.com \
    --cc=mb@smartsharesystems.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=stephen@networkplumber.org \
    /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).