[dpdk-dev] [PATCH v6 5/8] eal: add headers for compatibility with windows

Harini Ramakrishnan Harini.Ramakrishnan at microsoft.com
Thu Mar 28 20:29:51 CET 2019


Acked-by: Harini Ramakrishnan <harini.ramakrishnan at microsoft.com>

-----Original Message-----
From: dev <dev-bounces at dpdk.org> On Behalf Of Anand Rawat
Sent: Wednesday, March 27, 2019 7:21 PM
To: dev at dpdk.org
Cc: anand.rawat at intel.com; pallavi.kadam at intel.com; ranjit.menon at intel.com; jeffrey.b.shaw at intel.com; bruce.richardson at intel.com; thomas at monjalon.net
Subject: [dpdk-dev] [PATCH v6 5/8] eal: add headers for compatibility with windows

Added headers to support windows environment for common source.
These headers will have windows specific implementions of the system library apis provided in linux and freebsd.

Signed-off-by: Anand Rawat <anand.rawat at intel.com>
Signed-off-by: Pallavi Kadam <pallavi.kadam at intel.com>
Reviewed-by: Jeff Shaw <jeffrey.b.shaw at intel.com>
Reviewed-by: Ranjit Menon <ranjit.menon at intel.com>
---
 .../windows/eal/include/exec-env/fnmatch.h    | 43 ++++++++++
 .../windows/eal/include/exec-env/pthread.h    | 22 +++++
 .../windows/eal/include/exec-env/regex.h      | 83 +++++++++++++++++++
 .../windows/eal/include/exec-env/sched.h      | 41 +++++++++
 .../windows/eal/include/exec-env/unistd.h     |  8 ++
 5 files changed, 197 insertions(+)
 create mode 100644 lib/librte_eal/windows/eal/include/exec-env/fnmatch.h
 create mode 100644 lib/librte_eal/windows/eal/include/exec-env/pthread.h
 create mode 100644 lib/librte_eal/windows/eal/include/exec-env/regex.h
 create mode 100644 lib/librte_eal/windows/eal/include/exec-env/sched.h
 create mode 100644 lib/librte_eal/windows/eal/include/exec-env/unistd.h

diff --git a/lib/librte_eal/windows/eal/include/exec-env/fnmatch.h b/lib/librte_eal/windows/eal/include/exec-env/fnmatch.h
new file mode 100644
index 000000000..c2e2131b1
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/exec-env/fnmatch.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _FNMATCH_H_
+#define _FNMATCH_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define FNM_NOMATCH 1
+
+/**
+ * This function is used for searhing a given string source
+ * with the given regular expression pattern.
+ *
+ * @param pattern
+ *	regular expression notation decribing the pattern to match
+ *
+ * @param string
+ *	source string to searcg for the pattern
+ *
+ * @param flag
+ *	containing information about the pattern
+ *
+ * @return
+ *	if the pattern is found then return 0 or else FNM_NOMATCH
+ */
+static inline int fnmatch(__rte_unused const char *pattern,
+		__rte_unused const char *string,
+		__rte_unused int flags)
+{
+	/* TODO */
+	/* This is a stub, not the expected result */
+	return FNM_NOMATCH;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _FNMATCH_H_ */
diff --git a/lib/librte_eal/windows/eal/include/exec-env/pthread.h b/lib/librte_eal/windows/eal/include/exec-env/pthread.h
new file mode 100644
index 000000000..a62b25bf6
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/exec-env/pthread.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _PTHREAD_H_
+#define _PTHREAD_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* defining pthread_t type on windows */ typedef uintptr_t pthread_t;
+
+/* defining pthread_attr_t type on windows */ typedef void 
+*pthread_attr_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _PTHREAD_H_ */
diff --git a/lib/librte_eal/windows/eal/include/exec-env/regex.h b/lib/librte_eal/windows/eal/include/exec-env/regex.h
new file mode 100644
index 000000000..daa102f74
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/exec-env/regex.h
@@ -0,0 +1,83 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _REGEX_H_
+#define _REGEX_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define REG_NOMATCH 1
+#define REG_ESPACE 12
+
+/* defining regex_t for windows */
+typedef void *regex_t;
+/* defining regmatch_t for windows */
+typedef void *regmatch_t;
+
+/**
+ * The regcomp() function will compile the regular expression
+ * contained in the string pointed to by the pattern argument
+ * and place the results in the structure pointed to by preg.
+ * The cflags argument is the bitwise inclusive OR of zero or
+ * more of the flags
+ */
+static inline int regcomp(__rte_unused regex_t *preg,
+		__rte_unused const char *regex, __rte_unused int cflags) {
+	/* TODO */
+	/* This is a stub, not the expected result */
+	return REG_ESPACE;
+}
+
+/**
+ * The regexec() function compares the null-terminated string
+ * specified by string with the compiled regular expression
+ * preg initialised by a previous call to regcomp(). If it finds
+ * a match, regexec() returns 0; otherwise it returns non-zero
+ * indicating either no match or an error. The eflags argument
+ * is the bitwise inclusive OR of zero or more of the flags.
+ */
+static inline int regexec(__rte_unused const regex_t *preg,
+		__rte_unused const char *string, __rte_unused size_t nmatch,
+		__rte_unused regmatch_t pmatch[], __rte_unused int eflags) {
+	/* TODO */
+	/* This is a stub, not the expected result */
+	return REG_NOMATCH;
+}
+
+/**
+ * The regerror() function provides a mapping from error codes
+ * returned by regcomp() and regexec() to unspecified printable strings.
+ */
+static inline size_t regerror(__rte_unused int errcode,
+		__rte_unused const regex_t *preg, char *errbuf,
+		__rte_unused size_t errbuf_size)
+{
+	/* TODO */
+	/* This is a stub, not the expected result */
+	if (errbuf) {
+		*errbuf = '\0';
+		return 1;
+	}
+	return 0;
+}
+
+/**
+ * The regfree() function frees any memory allocated by regcomp()
+ * associated with preg.
+ */
+static inline void regfree(__rte_unused regex_t *preg) {
+	/* TODO */
+	/* This is a stub, not the expected result */ }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _REGEX_H_ */
diff --git a/lib/librte_eal/windows/eal/include/exec-env/sched.h b/lib/librte_eal/windows/eal/include/exec-env/sched.h
new file mode 100644
index 000000000..b105c43c3
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/exec-env/sched.h
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _SCHED_H_
+#define _SCHED_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef CPU_SET_SIZE
+#define CPU_SET_SIZE RTE_MAX_LCORE
+#endif
+
+#define _BITS_PER_SET (sizeof(long long) * 8) #define _BIT_SET_MASK 
+(_BITS_PER_SET - 1)
+
+#define _NUM_SETS(b) (((b) + _BIT_SET_MASK) / _BITS_PER_SET) #define 
+_WHICH_SET(b) ((b) / _BITS_PER_SET) #define _WHICH_BIT(b) ((b) & 
+(_BITS_PER_SET - 1))
+
+typedef struct _rte_cpuset_s {
+	long long _bits[_NUM_SETS(CPU_SET_SIZE)]; } rte_cpuset_t;
+
+#define CPU_SET(b, s) ((s)->_bits[_WHICH_SET(b)] |= (1LL << 
+_WHICH_BIT(b)))
+
+#define CPU_ZERO(s)							\
+	do {								\
+		unsigned int _i;					\
+									\
+		for (_i = 0; _i < _NUM_SETS(CPU_SET_SIZE); _i++)	\
+			(s)->_bits[_i] = 0LL;				\
+	} while (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SCHED_H_ */
diff --git a/lib/librte_eal/windows/eal/include/exec-env/unistd.h b/lib/librte_eal/windows/eal/include/exec-env/unistd.h
new file mode 100644
index 000000000..fe3d9b579
--- /dev/null
+++ b/lib/librte_eal/windows/eal/include/exec-env/unistd.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+/* Added to support common code on windows */ #ifndef _UNISTD_H_ 
+#define _UNISTD_H_ #endif /* _UNISTD_H_ */
--
2.17.1.windows.2



More information about the dev mailing list