diff mbox series

[v2,3/9] eal: add windows compatible header files

Message ID 20190926202924.6876-4-pallavi.kadam@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series Windows patchset with additional EAL functionalities | expand

Checks

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

Commit Message

Kadam, Pallavi Sept. 26, 2019, 8:29 p.m. UTC
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.

Adding getopt.h to support parsing options on Windows.

Adding rte_vect.h as Windows fails to compile:
\common\include\arch\x86\rte_vect.h.

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

Comments

Jerin Jacob Sept. 27, 2019, 7:58 a.m. UTC | #1
On Fri, Sep 27, 2019 at 2:24 AM Pallavi Kadam <pallavi.kadam@intel.com> wrote:
>
> 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.
>
> Adding getopt.h to support parsing options on Windows.
>
> Adding rte_vect.h as Windows fails to compile:
> \common\include\arch\x86\rte_vect.h.
>
> Signed-off-by: Antara Ganesh Kolar <antara.ganesh.kolar@intel.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> Reviewed-by: Keith Wiles <keith.wiles@intel.com>
> ---
> diff --git a/lib/librte_eal/windows/eal/include/rte_vect.h b/lib/librte_eal/windows/eal/include/rte_vect.h
> new file mode 100644
> index 000000000..630473e28
> --- /dev/null
> +++ b/lib/librte_eal/windows/eal/include/rte_vect.h
> @@ -0,0 +1,9 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2019 Intel Corporation
> + */
> +
> +#pragma once
> +
> +#define __ICC  1600
> +
> +#include "..\..\common\include\arch\x86\rte_vect.h"

I understand there is a compilation error with generic rte_vect.h with
windows from the git commit.
But above hardcoding to x86 will create an issue for another arch.
Please fix the compilation
for generic rte_vect.h or introduce vect.h as OS-specific and have
implementation for Linux and FreeBSD.




> --
> 2.18.0.windows.1
>
Kadam, Pallavi Sept. 30, 2019, 5:49 p.m. UTC | #2
Hi Jerin,

On 9/27/2019 12:58 AM, Jerin Jacob wrote:
> On Fri, Sep 27, 2019 at 2:24 AM Pallavi Kadam <pallavi.kadam@intel.com> wrote:
>> 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.
>>
>> Adding getopt.h to support parsing options on Windows.
>>
>> Adding rte_vect.h as Windows fails to compile:
>> \common\include\arch\x86\rte_vect.h.
>>
>> Signed-off-by: Antara Ganesh Kolar <antara.ganesh.kolar@intel.com>
>> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
>> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
>> Reviewed-by: Keith Wiles <keith.wiles@intel.com>
>> ---
>> diff --git a/lib/librte_eal/windows/eal/include/rte_vect.h b/lib/librte_eal/windows/eal/include/rte_vect.h
>> new file mode 100644
>> index 000000000..630473e28
>> --- /dev/null
>> +++ b/lib/librte_eal/windows/eal/include/rte_vect.h
>> @@ -0,0 +1,9 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause
>> + * Copyright(c) 2019 Intel Corporation
>> + */
>> +
>> +#pragma once
>> +
>> +#define __ICC  1600
>> +
>> +#include "..\..\common\include\arch\x86\rte_vect.h"
> I understand there is a compilation error with generic rte_vect.h with
> windows from the git commit.
> But above hardcoding to x86 will create an issue for another arch.
> Please fix the compilation
> for generic rte_vect.h or introduce vect.h as OS-specific and have
> implementation for Linux and FreeBSD.

The error is due to conflict types in the compilers. Clang compiler and 
Windows SDK

both declare _m_prefetchw() in x86intrin.h file which is included from 
generic rte_vect.h.

Error is as below:

C:\Program Files\LLVM\lib\clang\8.0.0\include\prfchwintrin.h:64:1: 
error: conflicting types for '_m_prefetchw'

_m_prefetchw(void *__P)

^

C:\Program Files (x86)\Windows 
Kits\10\include\10.0.17763.0\um\winnt.h:3275:1: note: previous 
declaration is here

_m_prefetchw (

^


Is it ok to include #ifdef for other architectures in the above file itself?

>
>
>
>
>> --
>> 2.18.0.windows.1
>>
Jerin Jacob Oct. 1, 2019, 5:56 a.m. UTC | #3
On Mon, Sep 30, 2019 at 11:19 PM Pallavi Kadam <pallavi.kadam@intel.com> wrote:
>
> Hi Jerin,
>
> On 9/27/2019 12:58 AM, Jerin Jacob wrote:
>
> On Fri, Sep 27, 2019 at 2:24 AM Pallavi Kadam <pallavi.kadam@intel.com> wrote:
>
> 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.
>
> Adding getopt.h to support parsing options on Windows.
>
> Adding rte_vect.h as Windows fails to compile:
> \common\include\arch\x86\rte_vect.h.
>
> Signed-off-by: Antara Ganesh Kolar <antara.ganesh.kolar@intel.com>
> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
> Reviewed-by: Keith Wiles <keith.wiles@intel.com>
> ---
> diff --git a/lib/librte_eal/windows/eal/include/rte_vect.h b/lib/librte_eal/windows/eal/include/rte_vect.h
> new file mode 100644
> index 000000000..630473e28
> --- /dev/null
> +++ b/lib/librte_eal/windows/eal/include/rte_vect.h
> @@ -0,0 +1,9 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2019 Intel Corporation
> + */
> +
> +#pragma once
> +
> +#define __ICC  1600
> +
> +#include "..\..\common\include\arch\x86\rte_vect.h"
>
> I understand there is a compilation error with generic rte_vect.h with
> windows from the git commit.
> But above hardcoding to x86 will create an issue for another arch.
> Please fix the compilation
> for generic rte_vect.h or introduce vect.h as OS-specific and have
> implementation for Linux and FreeBSD.
>
> The error is due to conflict types in the compilers. Clang compiler and Windows SDK
>
> both declare _m_prefetchw() in x86intrin.h file which is included from generic rte_vect.h.
>
> Error is as below:
>
> C:\Program Files\LLVM\lib\clang\8.0.0\include\prfchwintrin.h:64:1: error: conflicting types for '_m_prefetchw'
>
> _m_prefetchw(void *__P)
>
> ^
>
> C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\winnt.h:3275:1: note: previous declaration is here
>
> _m_prefetchw (
>
> ^
>
>
> Is it ok to include #ifdef for other architectures in the above file itself?


If I understand it correctly, after completing the "make config"
stage, ./lib/librte_eal/common/include/arch/x86/rte_vect.h will be
mapped as build/include/rte_vect.h.
The application will build/include/rte_vect.h and it internally
include ./lib/librte_eal/common/include/generic/rte_vect.h.
If ./lib/librte_eal/common/include/arch/x86/rte_vect.h has compilation
issue, we can have #ifdef fix in arch/x86/rte_vect.h



>
>
>
>
> --
> 2.18.0.windows.1
>
Kadam, Pallavi Oct. 3, 2019, 12:40 a.m. UTC | #4
On 9/30/2019 10:56 PM, Jerin Jacob wrote:
> On Mon, Sep 30, 2019 at 11:19 PM Pallavi Kadam <pallavi.kadam@intel.com> wrote:
>> Hi Jerin,
>>
>> On 9/27/2019 12:58 AM, Jerin Jacob wrote:
>>
>> On Fri, Sep 27, 2019 at 2:24 AM Pallavi Kadam <pallavi.kadam@intel.com> wrote:
>>
>> 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.
>>
>> Adding getopt.h to support parsing options on Windows.
>>
>> Adding rte_vect.h as Windows fails to compile:
>> \common\include\arch\x86\rte_vect.h.
>>
>> Signed-off-by: Antara Ganesh Kolar <antara.ganesh.kolar@intel.com>
>> Signed-off-by: Pallavi Kadam <pallavi.kadam@intel.com>
>> Reviewed-by: Ranjit Menon <ranjit.menon@intel.com>
>> Reviewed-by: Keith Wiles <keith.wiles@intel.com>
>> ---
>> diff --git a/lib/librte_eal/windows/eal/include/rte_vect.h b/lib/librte_eal/windows/eal/include/rte_vect.h
>> new file mode 100644
>> index 000000000..630473e28
>> --- /dev/null
>> +++ b/lib/librte_eal/windows/eal/include/rte_vect.h
>> @@ -0,0 +1,9 @@
>> +/* SPDX-License-Identifier: BSD-3-Clause
>> + * Copyright(c) 2019 Intel Corporation
>> + */
>> +
>> +#pragma once
>> +
>> +#define __ICC  1600
>> +
>> +#include "..\..\common\include\arch\x86\rte_vect.h"
>>
>> I understand there is a compilation error with generic rte_vect.h with
>> windows from the git commit.
>> But above hardcoding to x86 will create an issue for another arch.
>> Please fix the compilation
>> for generic rte_vect.h or introduce vect.h as OS-specific and have
>> implementation for Linux and FreeBSD.
>>
>> The error is due to conflict types in the compilers. Clang compiler and Windows SDK
>>
>> both declare _m_prefetchw() in x86intrin.h file which is included from generic rte_vect.h.
>>
>> Error is as below:
>>
>> C:\Program Files\LLVM\lib\clang\8.0.0\include\prfchwintrin.h:64:1: error: conflicting types for '_m_prefetchw'
>>
>> _m_prefetchw(void *__P)
>>
>> ^
>>
>> C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um\winnt.h:3275:1: note: previous declaration is here
>>
>> _m_prefetchw (
>>
>> ^
>>
>>
>> Is it ok to include #ifdef for other architectures in the above file itself?
>
> If I understand it correctly, after completing the "make config"
> stage, ./lib/librte_eal/common/include/arch/x86/rte_vect.h will be
> mapped as build/include/rte_vect.h.
> The application will build/include/rte_vect.h and it internally
> include ./lib/librte_eal/common/include/generic/rte_vect.h.
> If ./lib/librte_eal/common/include/arch/x86/rte_vect.h has compilation
> issue, we can have #ifdef fix in arch/x86/rte_vect.h

Thank you Jerin, for explaining. We have fixed arch/x86/rte_vect.h. Will 
incorporate this change in v3.


>
>
>
>>
>>
>>
>> --
>> 2.18.0.windows.1
>>
diff mbox series

Patch

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 */
diff --git a/lib/librte_eal/windows/eal/include/getopt.h b/lib/librte_eal/windows/eal/include/getopt.h
new file mode 100644
index 000000000..d47202ec9
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/getopt.h
@@ -0,0 +1,59 @@ 
+/* musl as a whole is licensed under the following standard MIT license:
+ *
+ * ----------------------------------------------------------------------
+ * Copyright (c) 2005-2014 Rich Felker, et al.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _GETOPT_H
+#define _GETOPT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int getopt(int, char * const [], const char *);
+extern char *optarg;
+extern int optind, opterr, optopt, optreset;
+
+struct option {
+	const char *name;
+	int has_arg;
+	int *flag;
+	int val;
+};
+
+void __getopt_msg(const char *a, const char *b, const char *c, size_t l);
+
+int getopt_long(int argc, char **argv, const char *optstring,
+	const struct option *longopts, int *idx);
+int getopt_long_only(int argc, char **argv, const char *optstring,
+	const struct option *longopts, int *idx);
+
+#define no_argument        0
+#define required_argument  1
+#define optional_argument  2
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/librte_eal/windows/eal/include/rte_vect.h b/lib/librte_eal/windows/eal/include/rte_vect.h
new file mode 100644
index 000000000..630473e28
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/rte_vect.h
@@ -0,0 +1,9 @@ 
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#pragma once
+
+#define __ICC	1600
+
+#include "..\..\common\include\arch\x86\rte_vect.h"