Thread (132 messages) 132 messages, 13 authors, 2021-04-29

Re: [dpdk-dev] [PATCH v2 7/7] eal/windows: do not expose POSIX symbols

From: Tal Shnaiderman <hidden>
Date: 2021-02-21 09:00:06

Subject: [dpdk-dev] [PATCH v2 7/7] eal/windows: do not expose POSIX
symbols

External email: Use caution opening links or attachments


Exposing POSIX symbols could break consumer POSIX compatibility code.

* Make renaming of close() and unlink() private to EAL.

* Remove renaming of strncasecmp(), strtok_r(), and sleep()
  in favor of using EAL wrappers. Similarly remove PATH_MAX macro.

* Replace index(3p), which is not available on Windows, with strchr(3),
  as recommended by POSIX.1-2008. strerror_r() is only used inside EAL,
  rename it only where it's needed. Same for asprintf(), it has an
  internal EAL wrapper and is removed from public API.

Signed-off-by: Dmitry Kozlyuk <redacted>
---
[snip]
quoted hunk ↗ jump to hunk
diff --git a/lib/librte_eal/windows/include/rte_os.h
b/lib/librte_eal/windows/include/rte_os.h
index edca11bd2..9c9c31214 100644
--- a/lib/librte_eal/windows/include/rte_os.h
+++ b/lib/librte_eal/windows/include/rte_os.h
@@ -6,15 +6,11 @@
 #define _RTE_OS_H_

 /**
- * This is header should contain any function/macro definition
- * which are not supported natively or named differently in the
- * Windows OS. It must not include Windows-specific headers.
+ * This header should contain any function/macro definition
+ * which are not supported natively or named differently in Windows OS.
  */

-#include <stdarg.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>

 #ifdef __cplusplus
 extern "C" {
@@ -22,101 +18,18 @@ extern "C" {

 #define RTE_PATH_MAX _MAX_PATH

-/* limits.h replacement, value as in <windows.h> */ -#ifndef PATH_MAX -
#define PATH_MAX _MAX_PATH -#endif
-
-#ifndef sleep
-#define sleep(x) Sleep(1000 * (x))
-#endif
-
-#ifndef strerror_r
-#define strerror_r(a, b, c) strerror_s(b, c, a) -#endif
-
-#ifndef strdup
-/* strdup is deprecated in Microsoft libc and _strdup is preferred */ -
#define strdup(str) _strdup(str) -#endif
-
-#ifndef strtok_r
-#define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) -#endif
-
-#ifndef index
-#define index(a, b)     strchr(a, b)
-#endif
-
-#ifndef rindex
-#define rindex(a, b)    strrchr(a, b)
-#endif
-
-#ifndef strncasecmp
-#define strncasecmp(s1, s2, count)        _strnicmp(s1, s2, count)
-#endif
-
-#ifndef close
-#define close _close
-#endif
mlx5 uses close() in mlx5.c and is broken after this change above, BTW why not add an rte_close instead of local definition?
-
-#ifndef unlink
-#define unlink _unlink
-#endif
-
[snip]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help