[dpdk-dev] [PATCH v4 3/9] eal: add windows compatible header files

Pallavi Kadam pallavi.kadam at intel.com
Thu Jan 9 04:13:06 CET 2020


Modified \common\include\arch\x86\rte_vect.h
to include SSE4 header for Windows.

Adding dlfcn.h on Windows to support common code.

Adding eal_filesystem.h to support functions and
path defines for files and directories on Windows.

Signed-off-by: Antara Ganesh Kolar <antara.ganesh.kolar at intel.com>
Signed-off-by: Pallavi Kadam <pallavi.kadam at intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon at intel.com>
Reviewed-by: Keith Wiles <keith.wiles at intel.com>
---
 .../common/include/arch/x86/rte_vect.h        |  4 +-
 lib/librte_eal/windows/eal/include/dlfcn.h    | 21 ++++
 .../windows/eal/include/eal_filesystem.h      | 99 +++++++++++++++++++
 3 files changed, 123 insertions(+), 1 deletion(-)
 create mode 100644 lib/librte_eal/windows/eal/include/dlfcn.h
 create mode 100644 lib/librte_eal/windows/eal/include/eal_filesystem.h

diff --git a/lib/librte_eal/common/include/arch/x86/rte_vect.h b/lib/librte_eal/common/include/arch/x86/rte_vect.h
index cf4e9db38..df5a60762 100644
--- a/lib/librte_eal/common/include/arch/x86/rte_vect.h
+++ b/lib/librte_eal/common/include/arch/x86/rte_vect.h
@@ -15,7 +15,9 @@
 #include <rte_config.h>
 #include "generic/rte_vect.h"
 
-#if (defined(__ICC) || (__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
+#if (defined(__ICC) || \
+	(defined(_WIN64)) || \
+	(__GNUC__ == 4 &&  __GNUC_MINOR__ < 4))
 
 #include <smmintrin.h> /* SSE4 */
 
diff --git a/lib/librte_eal/windows/eal/include/dlfcn.h b/lib/librte_eal/windows/eal/include/dlfcn.h
new file mode 100644
index 000000000..1572910b0
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/dlfcn.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _DLFCN_H_
+#define _DLFCN_H_
+
+/**
+ * This file is added to support common code in eal_common_options.c
+ * as Microsoft libc does not contain dlfcn.h. This may be removed
+ * in future releases.
+ */
+
+/* The windows port does not currently support dynamic loading of libraries,
+ * so fail these calls
+ */
+#define dlopen(lib, flag)   (0)
+#define RTLD_NOW 0
+#define dlerror()           ("Not supported!")
+
+#endif /* _DLFCN_H_ */
diff --git a/lib/librte_eal/windows/eal/include/eal_filesystem.h b/lib/librte_eal/windows/eal/include/eal_filesystem.h
new file mode 100644
index 000000000..583617c83
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/eal_filesystem.h
@@ -0,0 +1,99 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+/**
+ * @file
+ * Stores functions and path defines for files and directories
+ * on the filesystem for Windows, that are used by the Windows EAL.
+ */
+
+#ifndef EAL_FILESYSTEM_H
+#define EAL_FILESYSTEM_H
+
+#include "eal_internal_cfg.h"
+
+/* sets up platform-specific runtime data dir */
+int
+eal_create_runtime_dir(void);
+
+/* returns runtime dir */
+const char *
+eal_get_runtime_dir(void);
+
+/* define the default filename prefix for the %s values below */
+#define HUGEFILE_PREFIX_DEFAULT "rte"
+
+/** Path of rte config file */
+#define RUNTIME_CONFIG_FMT "%s\\%s.config"
+
+static inline const char *
+eal_runtime_config_path(void)
+{
+	static char buffer[PATH_MAX];  /* static so auto-zeroed */
+	char  Directory[PATH_MAX];
+
+	GetTempPathA(sizeof(Directory), Directory);
+	snprintf(buffer, sizeof(buffer)-1, RUNTIME_CONFIG_FMT, Directory,
+		internal_config.hugefile_prefix);
+
+	return buffer;
+}
+
+/* Path of file backed array */
+#define FBARRAY_NAME_FMT "%s\\fbarray_%s"
+
+static inline const char *
+eal_get_fbarray_path(char *buffer, size_t buflen, const char *name) {
+	snprintf(buffer, buflen, FBARRAY_NAME_FMT, eal_get_runtime_dir(), name);
+	return buffer;
+}
+
+/* Path of primary/secondary communication unix socket file. */
+#define MP_SOCKET_FNAME "mp_socket"
+
+static inline const char *
+eal_mp_socket_path(void)
+{
+	static char buffer[PATH_MAX]; /* static so auto-zeroed */
+
+	snprintf(buffer, sizeof(buffer) - 1, "%s/%s", eal_get_runtime_dir(),
+		MP_SOCKET_FNAME);
+	return buffer;
+}
+
+/** Path of hugepage info file */
+#define HUGEPAGE_INFO_FMT "%s\\.%s_hugepage_info"
+
+static inline const char *
+eal_hugepage_info_path(void)
+{
+	static char buffer[PATH_MAX];  /* static so auto-zeroed */
+	TCHAR  Directory[PATH_MAX];
+
+	GetSystemDirectory(Directory, sizeof(Directory));
+	snprintf(buffer, sizeof(buffer)-1, HUGEPAGE_INFO_FMT, Directory,
+		internal_config.hugefile_prefix);
+	return buffer;
+}
+
+/** String format for hugepage map files */
+#define HUGEFILE_FMT "%s/%smap_%d"
+#define TEMP_HUGEFILE_FMT "%s/%smap_temp_%d"
+
+static inline const char *
+eal_get_hugefile_path(char *buffer, size_t buflen, const char *hugedir,
+	int f_id)
+{
+	snprintf(buffer, buflen, HUGEFILE_FMT, hugedir,
+		internal_config.hugefile_prefix, f_id);
+	buffer[buflen - 1] = '\0';
+	return buffer;
+}
+
+/** Function to read a single numeric value from a file on the filesystem.
+ * Used to read information from files on /sys
+ */
+int eal_parse_sysfs_value(const char *filename, unsigned long *val);
+
+#endif /* EAL_FILESYSTEM_H */
-- 
2.18.0.windows.1



More information about the dev mailing list