From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web09.7055.1614066926885415417 for ; Mon, 22 Feb 2021 23:55:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=OJErv5d2; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=06885caa36=nickle.wang@hpe.com) Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11N7rZrp032692; Tue, 23 Feb 2021 07:55:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=2k9pw+dN/4H0Oer0pDJxIrIjYnkbjPaNXVPrHue55u0=; b=OJErv5d257xgswJZ7hirne72NpvHclhN42Rrza26BF2IEaMwI6/5F+W0uvu7Hm7E4KFO fKayIrseDkMKhRuSSkxDKrFKpCp3pLPktOd0URSOamoYd17Qg3+xEwCPleoNzJzZPeSG 2HY6374e4RpXgpgovuvpqrzYYCcBCheC9HHqh8/vyl1MXBsp9e8hXZUXiu+epwSmsgA9 IQ3fceNm1A7/jKLLTsoscB0gVFtoJab6dSCj/FC8dPnRMLdFWKx9FkZieDVj0X73pwcB 9oXXDXgEYn9ZxRgI7Um09Ci7OGnBshupndFk0pjMj4+DMm7zTFWfmvhDN34WNPnkK3iC bw== Received: from g9t5008.houston.hpe.com (g9t5008.houston.hpe.com [15.241.48.72]) by mx0b-002e3701.pphosted.com with ESMTP id 36vssu9cyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 23 Feb 2021 07:55:26 +0000 Received: from G4W10204.americas.hpqcorp.net (g4w10204.houston.hpecorp.net [16.207.82.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g9t5008.houston.hpe.com (Postfix) with ESMTPS id 8F88F4F; Tue, 23 Feb 2021 07:55:25 +0000 (UTC) Received: from G9W9210.americas.hpqcorp.net (2002:10dc:429b::10dc:429b) by G4W10204.americas.hpqcorp.net (2002:10cf:5210::10cf:5210) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 23 Feb 2021 07:55:25 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (15.241.52.12) by G9W9210.americas.hpqcorp.net (16.220.66.155) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Tue, 23 Feb 2021 07:55:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QJpfmtiETwA1LzMkDqfhb8izmrQUWdxz+DOyKf1ZadalfKfY+NLUxrRN0CdzxPRpamNxn+wnEiEFX7W/m4t4MpZH8+TDOu8wqxt/+oMR5ZTj6Q3ifY9N9nNApejsz1LzoaKJ0cyY2uJpepgg54W9J0vwnLfDHciYSsTtV02unGjzBgw1wgK3y6S4XZMpgURKs+gYnmLoIP5uP1+wA73Tze/bbcmM/06/kBAjNGopsQdvczMjbWDHM48tburG4IxwHA8qzAqmXnreIAURgsO+7RoW7sq8flAyOAmC3NZf7naZJWxOWtKBLQ/7w9XnxjTmQoIq1ZXHUZFcMNP3D6mq8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kcf16s7P9JAnKbS954+cEFGeYNywJwFdTXnVvtGuu5A=; b=BJYKFP2PGE7zDUfzF9c9ScUZ9xLufydowPOuiNxZ525lYVLzw3az3MDSkk1c1eKXNnFJw+Yf+vH4K+29cBL76DKHQS0cg6LPeoTCE3HBNqQahrfOHrga9PC0Cu1CyFsbFnLu71QqYU3AmHyb3KAUwWyzG8IFddiROc4F/duR9ZCRadwNC9X5PmAfBz2U+CUe0MQXcSffrV+dqqxMDKKshglV9r6fSH1dDY6JDUxyRsnpewFB80mzyl6jf+BmqqSwjyZBRUvcfkdZRoVJZiMhSTqN4k3itFPvjwy5/uACvdyh+fxdoOocrqgvFAX/UXN1/LKSUDQWq3WkYyh95KMp4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:760d::7) by DF4PR8401MB1145.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7611::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.28; Tue, 23 Feb 2021 07:55:23 +0000 Received: from DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c1ae:b73d:dbaa:9a6e]) by DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM ([fe80::c1ae:b73d:dbaa:9a6e%9]) with mapi id 15.20.3868.033; Tue, 23 Feb 2021 07:55:23 +0000 From: "Nickle Wang" To: "devel@edk2.groups.io" , "Chang, Abner (HPS SW/FW Technologist)" CC: Leif Lindholm , Michael D Kinney Subject: Re: [edk2-devel] [PATCH v2] RedfishPkg/RedfishCrtLib: Add more CRT functions Thread-Topic: [edk2-devel] [PATCH v2] RedfishPkg/RedfishCrtLib: Add more CRT functions Thread-Index: AQHW9Sg8rEXFSeKCXUa8ZDP3xcoedapliBwQ Date: Tue, 23 Feb 2021 07:55:23 +0000 Message-ID: References: <165E48A9D69DD66E.18860@groups.io> In-Reply-To: <165E48A9D69DD66E.18860@groups.io> Accept-Language: zh-TW, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; x-originating-ip: [16.242.247.139] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: c8601b45-057d-466a-72d3-08d8d7d0600b x-ms-traffictypediagnostic: DF4PR8401MB1145: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:128; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: aFRmqyTwbY0FIRwqKlvVINHX27XMVkG0V86z+g1uPwU8DA/qfphv50CoIn37rjV4jwW+5Y59EmLMn3QbH/lP+tgEQ0qYlV1b9Ps/qVnxb55TkYwsaIzKUZDgftMNY97k2p+mFCBB9mXdKADjx6ysz6rfajUV5a6hKyVj/+d75y10miHb83gBB+x0R/FC7GdVF8ZtuT085G4PETiJAMRWZSiRDB17f4LeVZ+pXCA9Swn0WZkf0wqt4wkIpMEmH54PUza2GWLcU9+Zspyl0INWlpj9rcMMIwGGXF65Z3Q6oJTYnzADKyFLVfXzjpZHYYoap9ggBsSL7eAwDNg660qGi19S0fjWlVT2jr7nOAzDZU0x+8PU+JG3TKwkUeSOo2djjQEggJg+PqR+2MKeOb1KymyOlUyH1D3PY/9ANv6bwR47FiojNHD+QWRBBouV3IwEEs2RHW5FcuGHNFgcDyM2/xDIEjX11gqK2DTujlBSzdIVoKTLaGJMS5W65yR1FbZ4zLvLSQl4KoXP2Zuo6xVBuW3nlRWdWW8SF7kvpCl0qXF/WTESS3Fims4cKPccaJHhvs5G1NdqYH+SHgecXXzGjxJanErc/M1WUMiG6SK6CBU= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(346002)(39860400002)(366004)(376002)(396003)(136003)(2906002)(66446008)(71200400001)(8936002)(8676002)(66556008)(66476007)(76116006)(86362001)(53546011)(5660300002)(7696005)(316002)(64756008)(55016002)(6506007)(52536014)(83380400001)(33656002)(54906003)(19627235002)(110136005)(9686003)(966005)(66946007)(478600001)(4326008)(6636002)(186003)(26005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?/THvd691WMxpcNzKgFdxehoKujPnu64tih/NPXKLGgfj5dTTSqmHIZLw8Qxk?= =?us-ascii?Q?jbUcEZuuA9cTrec236C65+HWMzzxi0gGCLG+ilyeCrXU9Y0pO3saZX68Oxss?= =?us-ascii?Q?p5PHibs8giwzfPqXobgbELKSPb6L8KQbweOPBXjpOof9P+z96c1lP2uyDDBY?= =?us-ascii?Q?kM1eeUUfarZgEgJfUtBc3Z1sv8gK+vro8ZyyS5q2kk08BNqzrCcdLl53JEcp?= =?us-ascii?Q?KgrUlx9Ib71Yxsgl2rHm4+tEvVCHQ8dBDJxGGX5FiTiBBWnBqnKwl9CQ5qYJ?= =?us-ascii?Q?NSREpF2u4DOzoqTICmcQq8rjCQNgqkkgEWmaLCU67EDKtnVDLMhxFGpkBNje?= =?us-ascii?Q?21ty6p1Bvu3n3Pdd19sAnR1fREez5L/ioccJ7BP1lHNlwZIH8hilzwkmPspj?= =?us-ascii?Q?RWd01zYwl1+H9ZiHBLv7T6DBAz2zA7wZXvaf6AKEEotAmgGtq+VDIMWqq7Nh?= =?us-ascii?Q?Eyw7GAU61RvXzHoC5pv4qPa2zmDKcqZcFjKhaT4YoCHwElkeL4N/l88+xpME?= =?us-ascii?Q?YmaUcZgy70ka0cK+NwNsWTAaN3bzaKpagyVbUWT8T+JSgcE79avtKUxWaYIQ?= =?us-ascii?Q?HmWKT3Stg1BBcymO6fBgQ62MLcm+ORJE90iuGU1RBCOK2qVU6xXS+SsekOuR?= =?us-ascii?Q?/BD5oUUaSrhLSvh15jLioVQtTLIjhS7VgLpp9YW0XFOTNcsFRrzkDd/NoSh7?= =?us-ascii?Q?7GH/ofcDeGCzeEkkonfKxLb83hYI30hdr4toVvVKHyku6pbcIP+GDf4uaJHI?= =?us-ascii?Q?//L+Zp5EkzUTCRljSoyBZEIPBq9owYnxFTt26hpDu/q4CvSU7WwQVaVxqpa8?= =?us-ascii?Q?jJWeKsya4QXR3d75OtKOSabBwz+G0smMSW9pGjj8ePekTWsJ7qnvY8asWuZg?= =?us-ascii?Q?hFGaKFAXXYLhpvFRlMk22pEEIZLyK97DxyCXKQEHuUdT2zezCqXF0kmM5XtH?= =?us-ascii?Q?i6nCfCi9/9fYpDoBA83oXCEymuZmGAG6wOtsu7tOAsBm9ZuyqRVlG/UNBxyY?= =?us-ascii?Q?/CloCuUhHyPCoBryJ+LxAJbMy2gLNIo71dJu9Q4jpNTKEiByZ2GNenkcg1CG?= =?us-ascii?Q?3ceu8V43OxGwPtFTENKyV9ZddMyqV1B62oMO8T3QR3sOgqd3neCNExxbgFvy?= =?us-ascii?Q?a+oBQnUVv6LdFZGBO0ueOv+HwExGvkaSPvAsSg1UpS5F3ZYc5a2vAh2UIiq7?= =?us-ascii?Q?M2OP237935dPi/zi8s728ic7DtVbE7ASVdfvkkJVdhFEWOsfc653cemz8EeR?= =?us-ascii?Q?h+4oaA/93HUBc9ISwHhJORoenr3Qikcfp2e+Hrd0h4AZ8HESe/BBy9NOKHPt?= =?us-ascii?Q?h6iDfZxwbaHbBKHpa276Lytd?= X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: c8601b45-057d-466a-72d3-08d8d7d0600b X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2021 07:55:23.6248 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: MqqQmmY0W9UpbJrlZOxtpXuwHNtEK0IX5kmW9NERzDe9JcPVg264xcCETb09sD2WXtXRV26YUo+fm/vPEvkm4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR8401MB1145 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.761 definitions=2021-02-23_02:2021-02-22,2021-02-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 mlxscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102230066 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nickle Wang Thanks, Nickle > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Chang, > Abner (HPS SW/FW Technologist) > Sent: Thursday, January 28, 2021 10:58 AM > To: devel@edk2.groups.io > Cc: Wang, Nickle (HPS SW) ; Leif Lindholm > ; Michael D Kinney > Subject: [edk2-devel] [PATCH v2] RedfishPkg/RedfishCrtLib: Add more CRT > functions >=20 > Add more functions which were missed in the first time commit, > that causes the build error with EDK2 Redfish feature driver. >=20 > strerror - We don't support this on edk2 environment. > strpbrk - Cloned this function from edk2-LibC > File operation functions - Not supported on edk2 environment. >=20 > Signed-off-by: Abner Chang >=20 > Cc: Nickle Wang > Cc: Leif Lindholm > Cc: Michael D Kinney > --- > .../RedfishCrtLib/RedfishCrtLib.c | 122 +++++++++++++++++- > 1 file changed, 121 insertions(+), 1 deletion(-) >=20 > diff --git a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > index 0696341bc0..58ef4f8fdb 100644 > --- a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > +++ b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > @@ -15,6 +15,10 @@ > #include >=20 > int errno =3D 0; > +char errnum_message [] =3D "We don't support to map errnum to the error > message on edk2 Redfish\n"; > + > +// This is required to keep VC++ happy if you use floating-point > +int _fltused =3D 1; >=20 > /** > Determine if a particular character is an alphanumeric character > @@ -465,6 +469,77 @@ strtod (const char * __restrict nptr, char ** > __restrict endptr) { > return (double)0; > } >=20 > +static UINT8 BitMask[] =3D { > + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 > + }; > + > +#define WHICH8(c) ((unsigned char)(c) >> 3) > +#define WHICH_BIT(c) (BitMask[((c) & 0x7)]) > +#define BITMAP64 ((UINT64 *)bitmap) > + > +static > +void > +BuildBitmap(unsigned char * bitmap, const char *s2, int n) > +{ > + unsigned char bit; > + int index; > + > + // Initialize bitmap. Bit 0 is always 1 which corresponds to '\0' > + for (BITMAP64[0] =3D index =3D 1; index < n; index++) { > + BITMAP64[index] =3D 0; > + } > + > + // Set bits in bitmap corresponding to the characters in s2 > + for (; *s2 !=3D '\0'; s2++) { > + index =3D WHICH8(*s2); > + bit =3D WHICH_BIT(*s2); > + bitmap[index] =3D bitmap[index] | bit; > + } > +} > + > +/** The strpbrk function locates the first occurrence in the string poi= nted to > + by s1 of any character from the string pointed to by s2. > + > + @return The strpbrk function returns a pointer to the character, = or a > + null pointer if no character from s2 occurs in s1. > +**/ > +char * > +strpbrk(const char *s1, const char *s2) > +{ > + UINT8 bitmap[ (((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U]; > + UINT8 bit; > + int index; > + > + BuildBitmap( bitmap, s2, sizeof(bitmap) / sizeof(UINT64)); > + > + for( ; *s1 !=3D '\0'; ++s1) { > + index =3D WHICH8(*s1); > + bit =3D WHICH_BIT(*s1); > + if( (bitmap[index] & bit) !=3D 0) { > + return (char *)s1; > + } > + } > + return NULL; > +} > + > +/** The strerror function maps the number in errnum to a message string= . > + Typically, the values for errnum come from errno, but strerror shal= l map > + any value of type int to a message. > + > + The implementation shall behave as if no library function calls the > + strerror function. > + > + @return The strerror function returns a pointer to the string, th= e > + contents of which are locale specific. The array pointed= to > + shall not be modified by the program, but may be overwrit= ten by > + a subsequent call to the strerror function. > +**/ > +char * > +strerror(int errnum) > +{ > + return errnum_message; > +} > + > /** > Allocate and zero-initialize array. > **/ > @@ -592,7 +667,52 @@ void qsort (void *base, size_t num, size_t width, i= nt > (*compare)(const void *, c >=20 > **/ > int fgetc(FILE * _File){ > - return 0; > + return EOF; > +} > +/** > + Open stream file, we don't support file operastion on edk2 JSON libra= ry. > + > + @return 0 Unsupported > + > +**/ > +FILE *fopen (const char *filename, const char *mode) { > + return NULL; > +} > +/** > + Read stream from file, we don't support file operastion on edk2 JSON > library. > + > + @return 0 Unsupported > + > +**/ > +size_t fread (void * ptr, size_t size, size_t count, FILE * stream) { > + return 0; > +} > +/** > + Write stream from file, we don't support file operastion on edk2 JSON > library. > + > + @return 0 Unsupported > + > +**/ > +size_t fwrite (const void * ptr, size_t size, size_t count, FILE * stre= am) { > + return 0; > +} > +/** > + Close file, we don't support file operastion on edk2 JSON library. > + > + @return 0 Unsupported > + > +**/ > +int fclose (FILE * stream) { > + return EOF; > +} > +/** > + Write the formatted string to file, we don't support file operastion = on edk2 > JSON library. > + > + @return 0 Unsupported > + > +**/ > +int fprintf (FILE * stream, const char * format, ...) { > + return -1; > } > /** > This function check if this is the formating string specifier. > -- > 2.17.1 >=20 >=20 >=20 >=20 >=20