From patchwork Fri Jan 13 20:36:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122049 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3DB94423C7; Fri, 13 Jan 2023 21:37:10 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA84B42E10; Fri, 13 Jan 2023 21:37:07 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 4E3BD42D78 for ; Fri, 13 Jan 2023 21:37:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673642225; x=1705178225; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5bVsYGRWlZB4t6uPoc/yREZROk8TSndoFSStXGZsn2Q=; b=WGRkkngxo4j2BfO1hTKnMO4PvrR3IC2vcjjNzsU/zwRJ4GgJrqsk9NHZ UDJUsaDc01mxQn4/nzwXecQ6afr+E8QbHiemU/RB4zzKlbXqE4M28vXpq K8oCQYoDynAo5WgUy34V6+F/uXnhFJggtaLUhoT4T3FJb6MgrAAdFHXmt 9m1ieR+w7svK5nF+Xd2dml5/mwT64twXo2bPdhXT6MKmCGt3erOkfbTZr +NBJm8FBdp7UUmo0A/ulK6lycR3wf3g2pWTs+7RAfkH5ZShPuyZ3u+LhV MZMk9yWIDhBtsrNJuCAU0JqsFsWpJ5NovPM1EhXNb7oVvAUJE21SI1aWn g==; X-IronPort-AV: E=McAfee;i="6500,9779,10589"; a="388592362" X-IronPort-AV: E=Sophos;i="5.97,214,1669104000"; d="scan'208";a="388592362" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2023 12:37:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10589"; a="658334381" X-IronPort-AV: E=Sophos;i="5.97,214,1669104000"; d="scan'208";a="658334381" Received: from silpixa00401385.ir.intel.com ([10.237.214.166]) by orsmga002.jf.intel.com with ESMTP; 13 Jan 2023 12:37:03 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , =?utf-8?q?Morten_Br=C3=B8rup?= , Tyler Retzlaff Subject: [PATCH v3 1/3] eal/windows: move fnmatch function to header file Date: Fri, 13 Jan 2023 20:36:54 +0000 Message-Id: <20230113203656.1864072-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230113203656.1864072-1-bruce.richardson@intel.com> References: <20220829151901.376754-1-bruce.richardson@intel.com> <20230113203656.1864072-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org To allow the fnmatch function to be shared between libraries, without having to export it into the public namespace (since it's not prefixed with "rte"), we can convert fnmatch.c to replace fnmatch.h. This allows fnmatch function to be static and limited in scope to the current file, preventing duplicate definitions if it is used by two libraries, while also not requiring export for sharing. Signed-off-by: Bruce Richardson Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- lib/eal/windows/fnmatch.c | 172 ----------------------------- lib/eal/windows/include/fnmatch.h | 175 +++++++++++++++++++++++++++--- lib/eal/windows/meson.build | 1 - 3 files changed, 162 insertions(+), 186 deletions(-) delete mode 100644 lib/eal/windows/fnmatch.c diff --git a/lib/eal/windows/fnmatch.c b/lib/eal/windows/fnmatch.c deleted file mode 100644 index f622bf54c5..0000000000 --- a/lib/eal/windows/fnmatch.c +++ /dev/null @@ -1,172 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 1989, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - */ - -#if defined(LIBC_SCCS) && !defined(lint) -static const char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; -#endif /* LIBC_SCCS and not lint */ - -/* - * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. - * Compares a filename or pathname to a pattern. - */ - -#include -#include -#include - -#include "fnmatch.h" - -#define EOS '\0' - -static const char *rangematch(const char *, char, int); - -int -fnmatch(const char *pattern, const char *string, int flags) -{ - const char *stringstart; - char c, test; - - for (stringstart = string;;) - switch (c = *pattern++) { - case EOS: - if ((flags & FNM_LEADING_DIR) && *string == '/') - return (0); - return (*string == EOS ? 0 : FNM_NOMATCH); - case '?': - if (*string == EOS) - return (FNM_NOMATCH); - if (*string == '/' && (flags & FNM_PATHNAME)) - return (FNM_NOMATCH); - if (*string == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - ++string; - break; - case '*': - c = *pattern; - /* Collapse multiple stars. */ - while (c == '*') - c = *++pattern; - - if (*string == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return (FNM_NOMATCH); - - /* Optimize for pattern with * at end or before /. */ - if (c == EOS) - if (flags & FNM_PATHNAME) - return ((flags & FNM_LEADING_DIR) || - strchr(string, '/') == NULL ? - 0 : FNM_NOMATCH); - else - return (0); - else if (c == '/' && flags & FNM_PATHNAME) { - string = strchr(string, '/'); - if (string == NULL) - return (FNM_NOMATCH); - break; - } - - /* General case, use recursion. */ - while ((test = *string) != EOS) { - if (!fnmatch(pattern, string, - flags & ~FNM_PERIOD)) - return (0); - if (test == '/' && flags & FNM_PATHNAME) - break; - ++string; - } - return (FNM_NOMATCH); - case '[': - if (*string == EOS) - return (FNM_NOMATCH); - if (*string == '/' && flags & FNM_PATHNAME) - return (FNM_NOMATCH); - pattern = rangematch(pattern, *string, flags); - if (pattern == NULL) - return (FNM_NOMATCH); - ++string; - break; - case '\\': - if (!(flags & FNM_NOESCAPE)) { - c = *pattern++; - if (c == EOS) { - c = '\\'; - --pattern; - } - } - /* FALLTHROUGH */ - default: - if (c == *string) - ; - else if ((flags & FNM_CASEFOLD) && - (tolower((unsigned char)c) == - tolower((unsigned char)*string))) - ; - else if ((flags & FNM_PREFIX_DIRS) && *string == EOS && - ((c == '/' && string != stringstart) || - (string == stringstart+1 && *stringstart == '/'))) - return (0); - else - return (FNM_NOMATCH); - string++; - break; - } - /* NOTREACHED */ -} - -static const char * -rangematch(const char *pattern, char test, int flags) -{ - int negate, ok; - char c, c2; - - /* - * A bracket expression starting with an unquoted circumflex - * character produces unspecified results (IEEE 1003.2-1992, - * 3.13.2). This implementation treats it like '!', for - * consistency with the regular expression syntax. - * J.T. Conklin (conklin@ngai.kaleida.com) - */ - negate = (*pattern == '!' || *pattern == '^'); - if (negate) - ++pattern; - - if (flags & FNM_CASEFOLD) - test = tolower((unsigned char)test); - - for (ok = 0; (c = *pattern++) != ']';) { - if (c == '\\' && !(flags & FNM_NOESCAPE)) - c = *pattern++; - if (c == EOS) - return (NULL); - - if (flags & FNM_CASEFOLD) - c = tolower((unsigned char)c); - - c2 = *(pattern + 1); - if (*pattern == '-' && c2 != EOS && c2 != ']') { - pattern += 2; - if (c2 == '\\' && !(flags & FNM_NOESCAPE)) - c2 = *pattern++; - if (c2 == EOS) - return (NULL); - - if (flags & FNM_CASEFOLD) - c2 = tolower((unsigned char)c2); - - if ((unsigned char)c <= (unsigned char)test && - (unsigned char)test <= (unsigned char)c2) - ok = 1; - } else if (c == test) - ok = 1; - } - return (ok == negate ? NULL : pattern); -} diff --git a/lib/eal/windows/include/fnmatch.h b/lib/eal/windows/include/fnmatch.h index c6b226bd5d..fbf1eef21c 100644 --- a/lib/eal/windows/include/fnmatch.h +++ b/lib/eal/windows/include/fnmatch.h @@ -1,20 +1,25 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019 Intel Corporation + * Copyright (c) 1989, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. */ - #ifndef _FNMATCH_H_ #define _FNMATCH_H_ -/** - * This file is required to support the common code in eal_common_log.c - * as Microsoft libc does not contain fnmatch.h. This may be removed in - * future releases. +#if defined(LIBC_SCCS) && !defined(lint) +static const char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; +#endif /* LIBC_SCCS and not lint */ + +/* + * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. + * Compares a filename or pathname to a pattern. */ -#ifdef __cplusplus -extern "C" { -#endif -#include +#include +#include +#include #define FNM_NOMATCH 1 @@ -25,6 +30,10 @@ extern "C" { #define FNM_CASEFOLD 0x10 #define FNM_PREFIX_DIRS 0x20 +#define FNM_EOS '\0' + +static const char *fnm_rangematch(const char *, char, int); + /** * This function is used for searching a given string source * with the given regular expression pattern. @@ -41,10 +50,150 @@ extern "C" { * @return * if the pattern is found then return 0 or else FNM_NOMATCH */ -int fnmatch(const char *pattern, const char *string, int flags); +static int +fnmatch(const char *pattern, const char *string, int flags) +{ + const char *stringstart; + char c, test; + + for (stringstart = string;;) + switch (c = *pattern++) { + case FNM_EOS: + if ((flags & FNM_LEADING_DIR) && *string == '/') + return (0); + return (*string == FNM_EOS ? 0 : FNM_NOMATCH); + case '?': + if (*string == FNM_EOS) + return (FNM_NOMATCH); + if (*string == '/' && (flags & FNM_PATHNAME)) + return (FNM_NOMATCH); + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + ++string; + break; + case '*': + c = *pattern; + /* Collapse multiple stars. */ + while (c == '*') + c = *++pattern; + + if (*string == '.' && (flags & FNM_PERIOD) && + (string == stringstart || + ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) + return (FNM_NOMATCH); + + /* Optimize for pattern with * at end or before /. */ + if (c == FNM_EOS) + if (flags & FNM_PATHNAME) + return ((flags & FNM_LEADING_DIR) || + strchr(string, '/') == NULL ? + 0 : FNM_NOMATCH); + else + return (0); + else if (c == '/' && flags & FNM_PATHNAME) { + string = strchr(string, '/'); + if (string == NULL) + return (FNM_NOMATCH); + break; + } + + /* General case, use recursion. */ + while ((test = *string) != FNM_EOS) { + if (!fnmatch(pattern, string, + flags & ~FNM_PERIOD)) + return (0); + if (test == '/' && flags & FNM_PATHNAME) + break; + ++string; + } + return (FNM_NOMATCH); + case '[': + if (*string == FNM_EOS) + return (FNM_NOMATCH); + if (*string == '/' && flags & FNM_PATHNAME) + return (FNM_NOMATCH); + pattern = fnm_rangematch(pattern, *string, flags); + if (pattern == NULL) + return (FNM_NOMATCH); + ++string; + break; + case '\\': + if (!(flags & FNM_NOESCAPE)) { + c = *pattern++; + if (c == FNM_EOS) { + c = '\\'; + --pattern; + } + } + /* FALLTHROUGH */ + default: + if (c == *string) + ; + else if ((flags & FNM_CASEFOLD) && + (tolower((unsigned char)c) == + tolower((unsigned char)*string))) + ; + else if ((flags & FNM_PREFIX_DIRS) && *string == FNM_EOS && + ((c == '/' && string != stringstart) || + (string == stringstart+1 && *stringstart == '/'))) + return (0); + else + return (FNM_NOMATCH); + string++; + break; + } + /* NOTREACHED */ +} + +static const char * +fnm_rangematch(const char *pattern, char test, int flags) +{ + int negate, ok; + char c, c2; + + /* + * A bracket expression starting with an unquoted circumflex + * character produces unspecified results (IEEE 1003.2-1992, + * 3.13.2). This implementation treats it like '!', for + * consistency with the regular expression syntax. + * J.T. Conklin (conklin@ngai.kaleida.com) + */ + negate = (*pattern == '!' || *pattern == '^'); + if (negate) + ++pattern; + + if (flags & FNM_CASEFOLD) + test = tolower((unsigned char)test); + + for (ok = 0; (c = *pattern++) != ']';) { + if (c == '\\' && !(flags & FNM_NOESCAPE)) + c = *pattern++; + if (c == FNM_EOS) + return (NULL); + + if (flags & FNM_CASEFOLD) + c = tolower((unsigned char)c); + + c2 = *(pattern + 1); + if (*pattern == '-' && c2 != FNM_EOS && c2 != ']') { + pattern += 2; + if (c2 == '\\' && !(flags & FNM_NOESCAPE)) + c2 = *pattern++; + if (c2 == FNM_EOS) + return (NULL); + + if (flags & FNM_CASEFOLD) + c2 = tolower((unsigned char)c2); -#ifdef __cplusplus + if ((unsigned char)c <= (unsigned char)test && + (unsigned char)test <= (unsigned char)c2) + ok = 1; + } else if (c == test) + ok = 1; + } + return (ok == negate ? NULL : pattern); } -#endif #endif /* _FNMATCH_H_ */ diff --git a/lib/eal/windows/meson.build b/lib/eal/windows/meson.build index 845e406ca1..e4b2427610 100644 --- a/lib/eal/windows/meson.build +++ b/lib/eal/windows/meson.build @@ -18,7 +18,6 @@ sources += files( 'eal_mp.c', 'eal_thread.c', 'eal_timer.c', - 'fnmatch.c', 'getopt.c', 'rte_thread.c', ) From patchwork Fri Jan 13 20:36:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122050 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F29EF423C7; Fri, 13 Jan 2023 21:37:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C960C42E19; Fri, 13 Jan 2023 21:37:09 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 248BE42D78 for ; Fri, 13 Jan 2023 21:37:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673642227; x=1705178227; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TnpD5RiMgH0/NS+gUYwXUo0cHKQBT4bGgLdGyr5YCNg=; b=mCk/rcvgcF5+Syw9/2mupS5uM6zHPutjLwH6rfkDwR8qhmsKkzUpFMRZ 8QzeWG3f/b8+lfH4bl35lqBeI9HeWKlPl5Hk/5eLVnvyTCkpFnFR1RjFT tvdt7V1TPOqkVN7mNBI/ltYXoDdQS1AIGCKz5WpFk4Up1MfgeDsKjZ3Rg uTM2HPDzecnsUFAa8k/bEV+pOpiniR9ZpQTeTOYtM1lc1w3oyce7ucnnw RsJDdrtRIijonaHxtygCMZubXuhL+sO7Q4ukPkBeX+HdqawQ99SR4mngk 9S1t4L6K7HGaVPCQ11w/Mawz+BfXSJVAnoXG9Y2k6SFIB74T5IknME2OD w==; X-IronPort-AV: E=McAfee;i="6500,9779,10589"; a="388592370" X-IronPort-AV: E=Sophos;i="5.97,214,1669104000"; d="scan'208";a="388592370" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2023 12:37:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10589"; a="658334397" X-IronPort-AV: E=Sophos;i="5.97,214,1669104000"; d="scan'208";a="658334397" Received: from silpixa00401385.ir.intel.com ([10.237.214.166]) by orsmga002.jf.intel.com with ESMTP; 13 Jan 2023 12:37:04 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , =?utf-8?q?Morten_Br=C3=B8rup?= , Tyler Retzlaff Subject: [PATCH v3 2/3] log: separate logging functions out of EAL Date: Fri, 13 Jan 2023 20:36:55 +0000 Message-Id: <20230113203656.1864072-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230113203656.1864072-1-bruce.richardson@intel.com> References: <20220829151901.376754-1-bruce.richardson@intel.com> <20230113203656.1864072-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Move the logging capability to a separate library, free from EAL. Rename files as appropriate, and use meson.build to select the correct file to be built for each operating system, rather than having a subdir per-os. Signed-off-by: Bruce Richardson Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- doc/api/doxy-api.conf.in | 1 + lib/eal/common/eal_common_options.c | 2 +- lib/eal/common/eal_private.h | 7 ---- lib/eal/common/meson.build | 1 - lib/eal/include/meson.build | 1 - lib/eal/linux/eal.c | 2 +- lib/eal/linux/meson.build | 1 - lib/eal/meson.build | 2 +- lib/eal/version.map | 17 ---------- lib/eal/windows/eal.c | 2 +- lib/eal/windows/meson.build | 1 - lib/kvargs/meson.build | 3 +- .../common/eal_common_log.c => log/log.c} | 3 +- lib/log/log_freebsd.c | 12 +++++++ .../common/eal_log.h => log/log_internal.h} | 18 ++++++++-- lib/{eal/linux/eal_log.c => log/log_linux.c} | 2 +- .../windows/eal_log.c => log/log_windows.c} | 2 +- lib/log/meson.build | 9 +++++ lib/{eal/include => log}/rte_log.h | 0 lib/log/version.map | 34 +++++++++++++++++++ lib/meson.build | 1 + lib/telemetry/meson.build | 3 +- 22 files changed, 81 insertions(+), 43 deletions(-) rename lib/{eal/common/eal_common_log.c => log/log.c} (99%) create mode 100644 lib/log/log_freebsd.c rename lib/{eal/common/eal_log.h => log/log_internal.h} (69%) rename lib/{eal/linux/eal_log.c => log/log_linux.c} (97%) rename lib/{eal/windows/eal_log.c => log/log_windows.c} (93%) create mode 100644 lib/log/meson.build rename lib/{eal/include => log}/rte_log.h (100%) create mode 100644 lib/log/version.map diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in index f0886c3bd1..442703c01a 100644 --- a/doc/api/doxy-api.conf.in +++ b/doc/api/doxy-api.conf.in @@ -51,6 +51,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ @TOPDIR@/lib/kni \ @TOPDIR@/lib/kvargs \ @TOPDIR@/lib/latencystats \ + @TOPDIR@/lib/log \ @TOPDIR@/lib/lpm \ @TOPDIR@/lib/mbuf \ @TOPDIR@/lib/member \ diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 2d6535781b..89c312f441 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -39,7 +39,7 @@ #include "eal_options.h" #include "eal_filesystem.h" #include "eal_private.h" -#include "eal_log.h" +#include "log_internal.h" #ifndef RTE_EXEC_ENV_WINDOWS #include "eal_trace.h" #endif diff --git a/lib/eal/common/eal_private.h b/lib/eal/common/eal_private.h index 0f4d75bb89..dbf60190f4 100644 --- a/lib/eal/common/eal_private.h +++ b/lib/eal/common/eal_private.h @@ -152,13 +152,6 @@ int rte_eal_tailqs_init(void); */ int rte_eal_intr_init(void); -/** - * Close the default log stream - * - * This function is private to EAL. - */ -void rte_eal_log_cleanup(void); - /** * Init alarm mechanism. This is to allow a callback be called after * specific time. diff --git a/lib/eal/common/meson.build b/lib/eal/common/meson.build index 917758cc65..22a626ba6f 100644 --- a/lib/eal/common/meson.build +++ b/lib/eal/common/meson.build @@ -18,7 +18,6 @@ sources += files( 'eal_common_interrupts.c', 'eal_common_launch.c', 'eal_common_lcore.c', - 'eal_common_log.c', 'eal_common_mcfg.c', 'eal_common_memalloc.c', 'eal_common_memory.c', diff --git a/lib/eal/include/meson.build b/lib/eal/include/meson.build index cfcd40aaed..1eaa074d1b 100644 --- a/lib/eal/include/meson.build +++ b/lib/eal/include/meson.build @@ -27,7 +27,6 @@ headers += files( 'rte_keepalive.h', 'rte_launch.h', 'rte_lcore.h', - 'rte_log.h', 'rte_malloc.h', 'rte_mcslock.h', 'rte_memory.h', diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 8c118d0d9f..0df9f1f353 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -49,10 +49,10 @@ #include "eal_hugepages.h" #include "eal_memcfg.h" #include "eal_trace.h" -#include "eal_log.h" #include "eal_options.h" #include "eal_vfio.h" #include "hotplug_mp.h" +#include "log_internal.h" #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) diff --git a/lib/eal/linux/meson.build b/lib/eal/linux/meson.build index 3cccfa36c0..1b913acc06 100644 --- a/lib/eal/linux/meson.build +++ b/lib/eal/linux/meson.build @@ -11,7 +11,6 @@ sources += files( 'eal_hugepage_info.c', 'eal_interrupts.c', 'eal_lcore.c', - 'eal_log.c', 'eal_memalloc.c', 'eal_memory.c', 'eal_thread.c', diff --git a/lib/eal/meson.build b/lib/eal/meson.build index 056beb9461..af8c4eae4a 100644 --- a/lib/eal/meson.build +++ b/lib/eal/meson.build @@ -22,7 +22,7 @@ subdir(exec_env) subdir(arch_subdir) -deps += ['kvargs'] +deps += ['log', 'kvargs'] if not is_windows deps += ['telemetry'] endif diff --git a/lib/eal/version.map b/lib/eal/version.map index 7ad12a7dc9..3fb11a16b2 100644 --- a/lib/eal/version.map +++ b/lib/eal/version.map @@ -140,21 +140,6 @@ DPDK_23 { rte_lcore_iterate; rte_lcore_to_cpu_id; rte_lcore_to_socket_id; - rte_log; - rte_log_can_log; - rte_log_cur_msg_loglevel; - rte_log_cur_msg_logtype; - rte_log_dump; - rte_log_get_global_level; - rte_log_get_level; - rte_log_get_stream; - rte_log_list_types; - rte_log_register; - rte_log_register_type_and_pick_level; - rte_log_set_global_level; - rte_log_set_level; - rte_log_set_level_pattern; - rte_log_set_level_regexp; rte_malloc; rte_malloc_dump_heaps; rte_malloc_dump_stats; @@ -225,7 +210,6 @@ DPDK_23 { rte_mp_request_async; rte_mp_request_sync; rte_mp_sendmsg; - rte_openlog_stream; rte_rand; rte_rand_max; rte_realloc; @@ -299,7 +283,6 @@ DPDK_23 { rte_vfio_noiommu_is_enabled; # WINDOWS_NO_EXPORT rte_vfio_release_device; # WINDOWS_NO_EXPORT rte_vfio_setup_device; # WINDOWS_NO_EXPORT - rte_vlog; rte_zmalloc; rte_zmalloc_socket; diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index 56fadc7afe..a41d177d6c 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -26,8 +26,8 @@ #include "eal_firmware.h" #include "eal_hugepages.h" #include "eal_trace.h" -#include "eal_log.h" #include "eal_windows.h" +#include "log_internal.h" #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL) diff --git a/lib/eal/windows/meson.build b/lib/eal/windows/meson.build index e4b2427610..7756d417be 100644 --- a/lib/eal/windows/meson.build +++ b/lib/eal/windows/meson.build @@ -12,7 +12,6 @@ sources += files( 'eal_hugepages.c', 'eal_interrupts.c', 'eal_lcore.c', - 'eal_log.c', 'eal_memalloc.c', 'eal_memory.c', 'eal_mp.c', diff --git a/lib/kvargs/meson.build b/lib/kvargs/meson.build index b746516965..7eae744a8f 100644 --- a/lib/kvargs/meson.build +++ b/lib/kvargs/meson.build @@ -1,7 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -includes = [global_inc] - +deps += 'log' sources = files('rte_kvargs.c') headers = files('rte_kvargs.h') diff --git a/lib/eal/common/eal_common_log.c b/lib/log/log.c similarity index 99% rename from lib/eal/common/eal_common_log.c rename to lib/log/log.c index bd7b188ceb..5021e49e33 100644 --- a/lib/eal/common/eal_common_log.c +++ b/lib/log/log.c @@ -15,8 +15,7 @@ #include #include -#include "eal_log.h" -#include "eal_private.h" +#include "log_internal.h" struct rte_log_dynamic_type { const char *name; diff --git a/lib/log/log_freebsd.c b/lib/log/log_freebsd.c new file mode 100644 index 0000000000..698d3c5423 --- /dev/null +++ b/lib/log/log_freebsd.c @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2023 Intel Corporation + */ + +#include +#include "log_internal.h" + +int +eal_log_init(__rte_unused const char *id, __rte_unused int facility) +{ + return 0; +} diff --git a/lib/eal/common/eal_log.h b/lib/log/log_internal.h similarity index 69% rename from lib/eal/common/eal_log.h rename to lib/log/log_internal.h index c784fa6043..20d6313898 100644 --- a/lib/eal/common/eal_log.h +++ b/lib/log/log_internal.h @@ -2,31 +2,43 @@ * Copyright 2021 Mellanox Technologies, Ltd */ -#ifndef EAL_LOG_H -#define EAL_LOG_H +#ifndef LOG_INTERNAL_H +#define LOG_INTERNAL_H #include #include +#include /* * Initialize the default log stream. */ +__rte_internal int eal_log_init(const char *id, int facility); /* * Determine where log data is written when no call to rte_openlog_stream. */ +__rte_internal void eal_log_set_default(FILE *default_log); /* * Save a log option for later. */ +__rte_internal int eal_log_save_regexp(const char *regexp, uint32_t level); +__rte_internal int eal_log_save_pattern(const char *pattern, uint32_t level); /* * Convert log level to string. */ +__rte_internal const char *eal_log_level2str(uint32_t level); -#endif /* EAL_LOG_H */ +/* + * Close the default log stream + */ +__rte_internal +void rte_eal_log_cleanup(void); + +#endif /* LOG_INTERNAL_H */ diff --git a/lib/eal/linux/eal_log.c b/lib/log/log_linux.c similarity index 97% rename from lib/eal/linux/eal_log.c rename to lib/log/log_linux.c index d44416fd65..2dfb0c974b 100644 --- a/lib/eal/linux/eal_log.c +++ b/lib/log/log_linux.c @@ -8,7 +8,7 @@ #include -#include "eal_log.h" +#include "log_internal.h" /* * default log function diff --git a/lib/eal/windows/eal_log.c b/lib/log/log_windows.c similarity index 93% rename from lib/eal/windows/eal_log.c rename to lib/log/log_windows.c index d4ea47f1c8..a6a0889550 100644 --- a/lib/eal/windows/eal_log.c +++ b/lib/log/log_windows.c @@ -4,7 +4,7 @@ #include #include -#include "eal_log.h" +#include "log_internal.h" /* set the log to default function, called during eal init process. */ int diff --git a/lib/log/meson.build b/lib/log/meson.build new file mode 100644 index 0000000000..6baff83ee5 --- /dev/null +++ b/lib/log/meson.build @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2022 Intel Corporation + +includes += global_inc +sources = files( + 'log.c', + 'log_' + exec_env + '.c' +) +headers = files('rte_log.h') diff --git a/lib/eal/include/rte_log.h b/lib/log/rte_log.h similarity index 100% rename from lib/eal/include/rte_log.h rename to lib/log/rte_log.h diff --git a/lib/log/version.map b/lib/log/version.map new file mode 100644 index 0000000000..726ff9fbcf --- /dev/null +++ b/lib/log/version.map @@ -0,0 +1,34 @@ +DPDK_23 { + global: + + rte_log; + rte_log_cur_msg_loglevel; + rte_log_cur_msg_logtype; + rte_log_can_log; + rte_log_dump; + rte_log_get_global_level; + rte_log_get_level; + rte_log_get_stream; + rte_log_list_types; + rte_log_register; + rte_log_register_type_and_pick_level; + rte_log_set_global_level; + rte_log_set_level; + rte_log_set_level_pattern; + rte_log_set_level_regexp; + rte_openlog_stream; + rte_vlog; + + local: *; +}; + +INTERNAL { + global: + + eal_log_init; + eal_log_level2str; + eal_log_save_pattern; + eal_log_save_regexp; + eal_log_set_default; + rte_eal_log_cleanup; +}; diff --git a/lib/meson.build b/lib/meson.build index a90fee31b7..06e8bd7206 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -9,6 +9,7 @@ # given as a dep, no need to mention ring. This is especially true for the # core libs which are widely reused, so their deps are kept to a minimum. libraries = [ + 'log', 'kvargs', # eal depends on kvargs 'telemetry', # basic info querying 'eal', # everything depends on eal diff --git a/lib/telemetry/meson.build b/lib/telemetry/meson.build index f84c9aa3be..489d000047 100644 --- a/lib/telemetry/meson.build +++ b/lib/telemetry/meson.build @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel Corporation -includes = [global_inc] - +deps += 'log' sources = files('telemetry.c', 'telemetry_data.c', 'telemetry_legacy.c') headers = files('rte_telemetry.h') includes += include_directories('../metrics') From patchwork Fri Jan 13 20:36:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122051 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F3DD423C7; Fri, 13 Jan 2023 21:37:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DCD9742E2B; Fri, 13 Jan 2023 21:37:10 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id E012942E17 for ; Fri, 13 Jan 2023 21:37:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673642229; x=1705178229; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NIf9e7ArfW60pgPNU7DfhV8sWMJJfp4awGaoinOB9js=; b=irrcZ8PGoC3DesPQBQ0csklhE24YzAlpDUSetoF2KG1zjHDUpetcm2UP 1MAfw/L6WrynID4zwKu4eQ0NAyDyg7VIvOl9HVn+mlDwpIb3ikdl6e3+I ndMN4bTK7YS3CjQOP/W4fcWlKbShncBVgLi9VdEMea1y5s9Ttjed8/JWO v9dvDEyBlTfkvoQl60yZ7Zz1KTNT0MFQC+bQpOHIg8HfSRNk0m15vlKB9 vNHkKeKPB9eoeIVUBCljk+zRsZ0S2aHDJl22AeT9jQAXuBMjnfvmEctA5 28uBe8ZLD7fc3xLgyYLsPXCFQWfHAMY23eTf+J4xolqugVunt5fI1bRjw Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10589"; a="388592393" X-IronPort-AV: E=Sophos;i="5.97,214,1669104000"; d="scan'208";a="388592393" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jan 2023 12:37:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10589"; a="658334407" X-IronPort-AV: E=Sophos;i="5.97,214,1669104000"; d="scan'208";a="658334407" Received: from silpixa00401385.ir.intel.com ([10.237.214.166]) by orsmga002.jf.intel.com with ESMTP; 13 Jan 2023 12:37:06 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: david.marchand@redhat.com, Bruce Richardson , =?utf-8?q?Morten_Br=C3=B8rup?= , Tyler Retzlaff Subject: [PATCH v3 3/3] telemetry: use standard logging Date: Fri, 13 Jan 2023 20:36:56 +0000 Message-Id: <20230113203656.1864072-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230113203656.1864072-1-bruce.richardson@intel.com> References: <20220829151901.376754-1-bruce.richardson@intel.com> <20230113203656.1864072-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Now that logging is moved out of EAL, we don't need injection of the logtype and logging function from EAL to telemetry library, simplifying things. Signed-off-by: Bruce Richardson Acked-by: Morten Brørup Acked-by: Tyler Retzlaff --- lib/eal/freebsd/eal.c | 6 +----- lib/eal/linux/eal.c | 6 +----- lib/telemetry/telemetry.c | 11 +++-------- lib/telemetry/telemetry_internal.h | 3 +-- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 607684c1a3..820c4524e5 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -871,13 +871,9 @@ rte_eal_init(int argc, char **argv) return -1; } if (rte_eal_process_type() == RTE_PROC_PRIMARY && !internal_conf->no_telemetry) { - int tlog = rte_log_register_type_and_pick_level( - "lib.telemetry", RTE_LOG_WARNING); - if (tlog < 0) - tlog = RTE_LOGTYPE_EAL; if (rte_telemetry_init(rte_eal_get_runtime_dir(), rte_version(), - &internal_conf->ctrl_cpuset, rte_log, tlog) != 0) + &internal_conf->ctrl_cpuset) != 0) return -1; } diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 0df9f1f353..dec0041094 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1319,13 +1319,9 @@ rte_eal_init(int argc, char **argv) return -1; } if (rte_eal_process_type() == RTE_PROC_PRIMARY && !internal_conf->no_telemetry) { - int tlog = rte_log_register_type_and_pick_level( - "lib.telemetry", RTE_LOG_WARNING); - if (tlog < 0) - tlog = RTE_LOGTYPE_EAL; if (rte_telemetry_init(rte_eal_get_runtime_dir(), rte_version(), - &internal_conf->ctrl_cpuset, rte_log, tlog) != 0) + &internal_conf->ctrl_cpuset) != 0) return -1; } diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c index 8fbb4f3060..13a32f4279 100644 --- a/lib/telemetry/telemetry.c +++ b/lib/telemetry/telemetry.c @@ -54,11 +54,9 @@ static struct socket v1_socket; /* socket for v1 telemetry */ static const char *telemetry_version; /* save rte_version */ static const char *socket_dir; /* runtime directory */ static rte_cpuset_t *thread_cpuset; -static rte_log_fn rte_log_ptr; -static uint32_t logtype; -#define TMTY_LOG(l, ...) \ - rte_log_ptr(RTE_LOG_ ## l, logtype, "TELEMETRY: " __VA_ARGS__) +RTE_LOG_REGISTER_DEFAULT(logtype, WARNING); +#define TMTY_LOG(l, ...) rte_log(RTE_LOG_ ## l, logtype, "TELEMETRY: " __VA_ARGS__) /* list of command callbacks, with one command registered by default */ static struct cmd_callback *callbacks; @@ -612,14 +610,11 @@ telemetry_v2_init(void) #endif /* !RTE_EXEC_ENV_WINDOWS */ int32_t -rte_telemetry_init(const char *runtime_dir, const char *rte_version, rte_cpuset_t *cpuset, - rte_log_fn log_fn, uint32_t registered_logtype) +rte_telemetry_init(const char *runtime_dir, const char *rte_version, rte_cpuset_t *cpuset) { telemetry_version = rte_version; socket_dir = runtime_dir; thread_cpuset = cpuset; - rte_log_ptr = log_fn; - logtype = registered_logtype; #ifndef RTE_EXEC_ENV_WINDOWS if (telemetry_v2_init() != 0) diff --git a/lib/telemetry/telemetry_internal.h b/lib/telemetry/telemetry_internal.h index d085c492dc..5c75d73183 100644 --- a/lib/telemetry/telemetry_internal.h +++ b/lib/telemetry/telemetry_internal.h @@ -109,7 +109,6 @@ typedef int (*rte_log_fn)(uint32_t level, uint32_t logtype, const char *format, */ __rte_internal int -rte_telemetry_init(const char *runtime_dir, const char *rte_version, rte_cpuset_t *cpuset, - rte_log_fn log_fn, uint32_t registered_logtype); +rte_telemetry_init(const char *runtime_dir, const char *rte_version, rte_cpuset_t *cpuset); #endif