[2/6] eal: Add header files to support windows

Message ID 20190301071847.13376-3-anand.rawat@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series HelloWorld example for Windows |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Anand Rawat March 1, 2019, 7:18 a.m. UTC
  Added header files to support windows on x86 platforms.
Updated rte_config to include rte_windows.h for windows
build.

Signed-off-by: Anand Rawat <anand.rawat@intel.com>
Signed-off-by: Kadam, Pallavi <pallavi.kadam@intel.com>
Reviewed-by: Jeffrey B Shaw <jeffrey.b.shaw@intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
---
 config/rte_config.h                           | 15 +++++++++++-
 .../common/include/arch/x86/meson.build       |  7 ++++++
 .../include/arch/x86/winapp/rte_atomic.h      | 19 +++++++++++++++
 .../include/arch/x86/winapp/rte_pause.h       | 22 ++++++++++++++++++
 .../winapp/eal/include/exec-env/rte_windows.h | 23 +++++++++++++++++++
 lib/librte_eal/winapp/eal/meson.build         |  5 +++-
 6 files changed, 89 insertions(+), 2 deletions(-)
 create mode 100644 lib/librte_eal/common/include/arch/x86/winapp/rte_atomic.h
 create mode 100644 lib/librte_eal/common/include/arch/x86/winapp/rte_pause.h
 create mode 100644 lib/librte_eal/winapp/eal/include/exec-env/rte_windows.h
  

Patch

diff --git a/config/rte_config.h b/config/rte_config.h
index 7606f5d7b..af4d06878 100644
--- a/config/rte_config.h
+++ b/config/rte_config.h
@@ -1,5 +1,5 @@ 
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2017 Intel Corporation
+ * Copyright(c) 2019 Intel Corporation
  */
 
 /**
@@ -20,6 +20,10 @@ 
 
 /****** library defines ********/
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* compat defines */
 #define RTE_BUILD_SHARED_LIB
 
@@ -118,4 +122,13 @@ 
 /* QEDE PMD defines */
 #define RTE_LIBRTE_QEDE_FW ""
 
+/* windows specific*/
+#ifdef RTE_EXEC_ENV_WINDOWS
+#include <rte_windows.h>
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _RTE_CONFIG_H_ */
diff --git a/lib/librte_eal/common/include/arch/x86/meson.build b/lib/librte_eal/common/include/arch/x86/meson.build
index 25b73b8d6..7426d35a6 100644
--- a/lib/librte_eal/common/include/arch/x86/meson.build
+++ b/lib/librte_eal/common/include/arch/x86/meson.build
@@ -21,4 +21,11 @@  if host_machine.system() != 'windows'
 		'rte_vect.h',
 		subdir: get_option('include_subdir_arch')
 	)
+else
+	# get and install the architecture specific windows headers
+	windows_headers = files(
+		'winapp/rte_atomic.h',
+		'winapp/rte_pause.h'
+	)
+	install_headers(windows_headers, subdir: 'winapp')
 endif
diff --git a/lib/librte_eal/common/include/arch/x86/winapp/rte_atomic.h b/lib/librte_eal/common/include/arch/x86/winapp/rte_atomic.h
new file mode 100644
index 000000000..9ca630f71
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/x86/winapp/rte_atomic.h
@@ -0,0 +1,19 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _ATOMIC_H_
+#define _ATOMIC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define rte_rmb() _mm_lfence()
+#define rte_wmb() _mm_sfence()
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ATOMIC_H_ */
diff --git a/lib/librte_eal/common/include/arch/x86/winapp/rte_pause.h b/lib/librte_eal/common/include/arch/x86/winapp/rte_pause.h
new file mode 100644
index 000000000..12762a5cd
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/x86/winapp/rte_pause.h
@@ -0,0 +1,22 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _PAUSE_H_
+#define _PAUSE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static inline void
+rte_pause(void)
+{
+	_mm_pause();
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PAUSE_H_ */
diff --git a/lib/librte_eal/winapp/eal/include/exec-env/rte_windows.h b/lib/librte_eal/winapp/eal/include/exec-env/rte_windows.h
new file mode 100644
index 000000000..8e4dc72bb
--- /dev/null
+++ b/lib/librte_eal/winapp/eal/include/exec-env/rte_windows.h
@@ -0,0 +1,23 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _RTE_WINDOWS_H_
+#define _RTE_WINDOWS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __extension__
+#define __thread __declspec(thread)
+
+#define strerror_r(a, b, c) strerror_s(b, c, a)
+
+typedef void *ssize_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_WINDOWS_H_ */
diff --git a/lib/librte_eal/winapp/eal/meson.build b/lib/librte_eal/winapp/eal/meson.build
index 8b1735623..487055f80 100644
--- a/lib/librte_eal/winapp/eal/meson.build
+++ b/lib/librte_eal/winapp/eal/meson.build
@@ -1,10 +1,13 @@ 
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019 Intel Corporation
 
+eal_inc += include_directories('include/exec-env')
+install_subdir('include/exec-env', install_dir: get_option('includedir'))
+
 env_objs = []
 env_headers = []
 env_sources = files('eal.c',
 	'eal_debug.c',
 	'eal_lcore.c',
 	'eal_thread.c',
-)
+)
\ No newline at end of file