From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by dpdk.org (Postfix) with ESMTP id 8949E6A79 for ; Thu, 27 Feb 2014 18:17:33 +0100 (CET) Received: by mail-pa0-f52.google.com with SMTP id fb1so2766442pad.39 for ; Thu, 27 Feb 2014 09:18:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-transfer-encoding; bh=QGAtBN7BN4xlnAspf7hgoBmfShZz8VWioIM3Jg2cx4M=; b=FMjxJGObOS4z+1U0xkObsiqt3CHhoz0Ixfg/BMqy9laCLSXQPDSoqPW1BnGrliXPMr c7j+ytzOliDR4wfOUAiV9JkbggZspqDXGRgMlhWoeFcJUVcNayb7gmi58AMX+PwaSFPM tb4slE7sFUWqmgaZNML4mzmqchR5hqLAdWp2wLW6Mow4gzUQLvYMpTx7xRFwJEXeTT77 tc8H+ZwR1aNdO0ReImtz+bbAmMzHrdcLP+GD65q1+6kB1jGvGdag4MkSAzBNSc2h1hpL IOPmYwPwpXT5VxMayQkh4rlbuX5OHnTWeb0bIiVbQ21CxdaJqylp21zASOoytv5UehzR XOfQ== X-Gm-Message-State: ALoCoQmXhjr8FIzZG9LMQDA5lYWqHefVOM73ag5pvycmphAdDxQYZeYT0AIfqZN68Jvl6XijDDa3 X-Received: by 10.68.131.202 with SMTP id oo10mr14291006pbb.35.1393521539674; Thu, 27 Feb 2014 09:18:59 -0800 (PST) Received: from nehalam.linuxnetplumber.net (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id g6sm35394698pat.2.2014.02.27.09.18.58 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 27 Feb 2014 09:18:59 -0800 (PST) Date: Thu, 27 Feb 2014 09:18:56 -0800 From: Stephen Hemminger To: dev@dpdk.org, "Venkatesan, Venky" Message-ID: <20140227091856.768d413c@nehalam.linuxnetplumber.net> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH 1.6.1] don't inline rte_string_fns X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Feb 2014 17:17:34 -0000 The function rte_snprintf() can never be inlined by Gcc.=20 If compiled with -Winline it generates an error: function =E2=80=98rte_snprintf=E2=80=99 can never be inlined because it us= es variable argument lists [-Werror=3Dinline] Therefore since both rte_snprintf and rte_strsplit are not performance sens= itive just move them to being real functions. Signed-off-by: Stephen Hemminger --- app/test/test_eal_fs.c | 1 + lib/librte_eal/common/eal_common_string_fns.c | 95 ++++++++++++++++++++= ++++ lib/librte_eal/common/include/rte_string_fns.h | 58 +-------------- lib/librte_eal/linuxapp/eal/Makefile | 1 + 4 files changed, 101 insertions(+), 54 deletions(-) create mode 100644 lib/librte_eal/common/eal_common_string_fns.c diff --git a/app/test/test_eal_fs.c b/app/test/test_eal_fs.c index 0a7524d..2c4bdc6 100644 --- a/app/test/test_eal_fs.c +++ b/app/test/test_eal_fs.c @@ -36,6 +36,7 @@ #include #include #include +#include =20 /* eal_filesystem.h is not a public header file, so use relative path */ #include "../../lib/librte_eal/linuxapp/eal/include/eal_filesystem.h" diff --git a/lib/librte_eal/common/eal_common_string_fns.c b/lib/librte_eal= /common/eal_common_string_fns.c new file mode 100644 index 0000000..9c41a64 --- /dev/null +++ b/lib/librte_eal/common/eal_common_string_fns.c @@ -0,0 +1,95 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include + +int +rte_snprintf(char *buffer, int buflen, const char *format, ...) +{ + int len; + va_list ap; + + if (buffer =3D=3D NULL && buflen !=3D 0) + goto einval_error; + if (format =3D=3D NULL) { + if (buflen > 0) + buffer[0] =3D '\0'; + goto einval_error; + } + + va_start(ap, format); + len =3D vsnprintf(buffer, buflen, format, ap); + va_end(ap); + if (len >=3D buflen && buflen > 0) + buffer[buflen - 1] =3D '\0'; + + return len; + +einval_error: + errno =3D EINVAL; + return -1; +} + +int +rte_strsplit(char *string, int stringlen, + char **tokens, int maxtokens, char delim) +{ + int i, tok =3D 0; + int tokstart =3D 1; /* first token is right at start of string */ + + if (string =3D=3D NULL || tokens =3D=3D NULL) + goto einval_error; + + for (i =3D 0; i < stringlen; i++) { + if (string[i] =3D=3D '\0' || tok >=3D maxtokens) + break; + if (tokstart) { + tokstart =3D 0; + tokens[tok++] =3D &string[i]; + } + if (string[i] =3D=3D delim) { + string[i] =3D '\0'; + tokstart =3D 1; + } + } + return tok; + +einval_error: + errno =3D EINVAL; + return -1; +} diff --git a/lib/librte_eal/common/include/rte_string_fns.h b/lib/librte_ea= l/common/include/rte_string_fns.h index d8fde14..52bb77e 100644 --- a/lib/librte_eal/common/include/rte_string_fns.h +++ b/lib/librte_eal/common/include/rte_string_fns.h @@ -47,7 +47,6 @@ extern "C" { #include #include #include -#include =20 /** * Safer version of snprintf that writes up to buflen characters to @@ -72,32 +71,8 @@ extern "C" { * buffer been sufficiently big. * */ -static inline int -rte_snprintf(char *buffer, int buflen, const char *format, ...) -{ - int len; - va_list ap; - - if (buffer =3D=3D NULL && buflen !=3D 0) - goto einval_error; - if (format =3D=3D NULL) { - if (buflen > 0) - buffer[0] =3D '\0'; - goto einval_error; - } - - va_start(ap, format); - len =3D vsnprintf(buffer, buflen, format, ap); - va_end(ap); - if (len >=3D buflen && buflen > 0) - buffer[buflen - 1] =3D '\0'; - - return len; - -einval_error: - errno =3D EINVAL; - return -1; -} +int +rte_snprintf(char *buffer, int buflen, const char *format, ...); =20 =20 /** @@ -126,34 +101,9 @@ einval_error: * @return * The number of tokens in the tokens array. */ -static inline int +int rte_strsplit(char *string, int stringlen, - char **tokens, int maxtokens, char delim) -{ - int i, tok =3D 0; - int tokstart =3D 1; /* first token is right at start of string */ - - if (string =3D=3D NULL || tokens =3D=3D NULL) - goto einval_error; - - for (i =3D 0; i < stringlen; i++) { - if (string[i] =3D=3D '\0' || tok >=3D maxtokens) - break; - if (tokstart) { - tokstart =3D 0; - tokens[tok++] =3D &string[i]; - } - if (string[i] =3D=3D delim) { - string[i] =3D '\0'; - tokstart =3D 1; - } - } - return tok; - -einval_error: - errno =3D EINVAL; - return -1; -} + char **tokens, int maxtokens, char delim); =20 #ifdef __cplusplus } diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp= /eal/Makefile index b525130..b25a093 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -78,6 +78,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) +=3D eal_common_cp= uflags.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) +=3D eal_common_hexdump.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) +=3D eal_common_whitelist.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) +=3D eal_common_nonpci_devs.c +SRCS-$(CONFIG_RTE_LIBRTE_EAL_LINUXAPP) +=3D eal_common_string_fns.c =20 CFLAGS_eal.o :=3D -D_GNU_SOURCE CFLAGS_eal_thread.o :=3D -D_GNU_SOURCE --=20 1.7.10.4