From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 18457A0613 for ; Thu, 26 Sep 2019 22:54:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6500B2BB5; Thu, 26 Sep 2019 22:54:46 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id EDE2C2AB for ; Thu, 26 Sep 2019 22:54:38 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2019 13:54:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,553,1559545200"; d="scan'208";a="194260440" Received: from win-dpdk-pallavi.jf.intel.com (HELO localhost.localdomain) ([10.166.188.58]) by orsmga006.jf.intel.com with ESMTP; 26 Sep 2019 13:54:37 -0700 From: Pallavi Kadam To: dev@dpdk.org, thomas@monjalon.net Cc: Harini.Ramakrishnan@microsoft.com, keith.wiles@intel.com, bruce.richardson@intel.com, ranjit.menon@intel.com, antara.ganesh.kolar@intel.com, pallavi.kadam@intel.com Date: Thu, 26 Sep 2019 13:29:18 -0700 Message-Id: <20190926202924.6876-4-pallavi.kadam@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20190926202924.6876-1-pallavi.kadam@intel.com> References: <20190909195404.4760-1-pallavi.kadam@intel.com> <20190926202924.6876-1-pallavi.kadam@intel.com> Subject: [dpdk-dev] [PATCH v2 3/9] eal: add windows compatible header files X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Signed-off-by: Pallavi Kadam Reviewed-by: Ranjit Menon Reviewed-by: Keith Wiles --- 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 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" -- 2.18.0.windows.1