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.web10.2011.1613618037850173596 for ; Wed, 17 Feb 2021 19:13:58 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=fnxC/H5W; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=06830be148=abner.chang@hpe.com) Received: from pps.filterd (m0150245.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 11I3DuqI008696; Thu, 18 Feb 2021 03:13:57 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=NtVSVSjhiH8oQ4VIem8N4ePHHI+W90Nu1urnV+UxvKM=; b=fnxC/H5WKo16Xtl/j5KrNFb2S9Z32ElKMPqHjRBaehcer2mEKGzh8uImHHThSWNe975P Fq55u/Kn7TA6LA0H7xmfcSh9IUFc5Clxevvr/O5vlJ3keh0blD1PABypz3oe7rfKHNu2 CZ/k6Mdt5wt0LvWVY6kswG90mBEpjSG3re06TOzJYovq8JnqB59khQgAugXVB5MUigRY w05tYkORgHWFwhC/0mcsuJqOJEx+WE1iEqaneTOIL9XEsYg+qNhj8PUtpX5etZa8EMuI HKH+py08wGjwUr/OuW937URfrSgokFJATC6JUN6tOkTZywrfOcoeC5fGIadncFMP1yhP yw== Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 36rdk5xhn9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 18 Feb 2021 03:13:56 +0000 Received: from G1W8106.americas.hpqcorp.net (g1w8106.austin.hp.com [16.193.72.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g2t2352.austin.hpe.com (Postfix) with ESMTPS id E9879BC; Thu, 18 Feb 2021 03:13:49 +0000 (UTC) Received: from G9W9210.americas.hpqcorp.net (16.220.66.155) by G1W8106.americas.hpqcorp.net (16.193.72.61) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 18 Feb 2021 03:13:40 +0000 Received: from NAM10-BN7-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; Thu, 18 Feb 2021 03:13:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EuAb0TUXPT3WDak+a56dXRnsElVSM5uc4K0fjFk4k562S5Cgt56jOmTJ54zLUcC3l3BF3Z0rh3RkNai9lTSZbH8jrPob9GbRAHOi6h1l/2sQIgyW6JeIj9l5vUXLA3d1ZFEXyqPe8G5Jh1Wpw4MytaMUhUA25E5Q66IrBUeAjfKzKnthIFvrktcX4Xz3TXiU/Vegi9tqRcHy5fDqDuddwUo37wZy0PJBJgLVAkpbhR+FbxY/CsxJoghEQW8UwEXrLG/W/10ocpPFIIdpeLuA94sq0MO/NSLNWftzhuPQyPbYjaSRerACHAEf8oGAFzzyeY0cXCaKdnEp21cacTeGWg== 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=GIbC7d1zZ9Ife66n0NNk1cRjolgMuAq7EJV5TF6KoYY=; b=XMG5sdsM8zwI94xFxDFjyWUdxkGD1xxsZF9pxoX1QSrjEEAQFr+N/KZTfunNGFxugdSU6PvL2HbhN9rBGHppDJQYjWHkUIs8SUXVKQRTzBjLay0Qdx4cN1BEqRnIUg0Ec2r2NSP7Aic9oY/DfsqBYXYElSarv6kjheReFh1bjTO516K91/LVW7lge9KFYwnypbW50n4s3HPDIbeZht5GbjwcwmPJewrxgGm4LyUyV+6U1AKGuiTumrDQ93K3AAn+Q7FzvKfp8wJslrCjQaOH5m70QGVqNRVL6PeY5Wuo4K88cfuo2teJ6JLbsHhDU5sMWvEreHgxjy96doI1WRJKTQ== 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 CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7508::16) by CS1PR8401MB0341.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7509::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.31; Thu, 18 Feb 2021 03:13:38 +0000 Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::adb6:a875:93ca:b54a]) by CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::adb6:a875:93ca:b54a%12]) with mapi id 15.20.3846.042; Thu, 18 Feb 2021 03:13:38 +0000 From: "Abner Chang" To: "devel@edk2.groups.io" , Leif Lindholm CC: "Wang, Nickle (HPS SW)" , 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: AQHW9Sg8rEXFSeKCXUa8ZDP3xcoedapdXVPg Date: Thu, 18 Feb 2021 03:13:38 +0000 Message-ID: References: <165E48A9D69DD66E.18860@groups.io> In-Reply-To: <165E48A9D69DD66E.18860@groups.io> Accept-Language: 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.131] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 7ba3521f-91a5-4aac-9d28-08d8d3bb2f91 x-ms-traffictypediagnostic: CS1PR8401MB0341: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:138; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: k4KeFFatfTFGzTihc4b2tFn/vEdC6fFg06uGDqwJ3O2WmMqNZh6//v8g06ktu9ZAHxKoXSW2jp9Kmw2o1x/ZdQ+AZy8IAczDon+hhtp2v4Joz5BQnWbGcg234y+8J3l2WszvKs3+Q/oTMdml6sNKVYFBEXjcNq5a2gBWw00OqFoZoRYhChMjJFybSUVwEXvyw0IWe2bUyzqpoNWj710oWdTM5HTzl++HGSleRcDmyrwAPMT3x59LrteE35M57AWKuV7Jxx5dG+GnTaBrrcADCWn2+QMIguKYfj1YXhLWO3B59yn9Ifx5Wy8U9AGTlzwrfoW34dtDo4rEJF8zJb3NgWiXHJC6LQjmV9I8cPrpt4FkcYL+BZ91Idl2fnJtD2P9C6lmIrmFiW1CAi0KHeILQ92tnDoAts1WvhTSJ90AsNxdOxNvTVMFikKjffnxmU39DJulGW4851Vz4Vdb7/2XUtRX/zLQcVLp+TLgoqIUagebrGxPw4zG4KZn1Q1n3GAuP3sxhRetXsd3GpggjAu1S2TxuMN8o2ip4elfxbVSXaTyiNK9MuyovYjvrmA21pTfHh1QwmFf6cM/CXfUigwm8vW4mgO5Z2WpakwXX0E2JHQ= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(396003)(376002)(136003)(366004)(39860400002)(346002)(66946007)(186003)(66446008)(76116006)(55016002)(66556008)(64756008)(66476007)(9686003)(52536014)(316002)(2906002)(966005)(7696005)(71200400001)(83380400001)(33656002)(8936002)(86362001)(478600001)(53546011)(4326008)(26005)(54906003)(19627235002)(110136005)(5660300002)(6506007)(8676002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?Edj+zsHmWD5yBwAgJeD4u13KBZWfVx7orGjjDYdRXMWfxCCJgIn4EPdpxk1X?= =?us-ascii?Q?L56xSvN38dE3NyunU4koSgWbc2cH0xeeV2XAJLNJPgAjQi43DBS0uHlhDZwQ?= =?us-ascii?Q?OIdCX5aYcjNskjd+HlP1fgFCJjjdfem+ZGjEF0IGx1wXKnPkdLSYP/LUduqw?= =?us-ascii?Q?CZCpPNU6Ep81ICzMIgIRgrAxjS34Cnk6p0VUhqmO6ATSPdtlS9euwtVORRkn?= =?us-ascii?Q?ASjTN4MJkfBPMNc/IdCOo35D4BRd/Fu3bNtZWoCRA+N26r4YAMwTCmAXSIra?= =?us-ascii?Q?x6FhBGeecFFl+gDR+ImiiCzNNuj8nI0wbiGO4Nnt5risBe4hnbAB55Rt0D6n?= =?us-ascii?Q?n14AtDSt0ZsgOQSSSQk9VKP01yVaOBm/OxzrvWgD7qkXtbzpHQTz1no7MdsG?= =?us-ascii?Q?Oqrtul5K7kYVAXlJIamHqN2gIgN6Ygbkfdl/i6oq36CtnRUP2WDh6+DIvqX9?= =?us-ascii?Q?ImZiW/L+U5qlIIPiiNfYthSph20C6omotrIUvqHlvW8tmchqoctq26RW7Wzw?= =?us-ascii?Q?YgVB8n5edD5HjILV7IANA9q2CB9izlRHGmt/ozypQa+9zhlxNkYtSoyII6wj?= =?us-ascii?Q?ztrbA70f4XVj+PSACikVslZRGoLoG1SA6Ok9GnnFkv1D7XkbFKq6BWvMshbB?= =?us-ascii?Q?RJ3ylAWt/mB1zukNs7VADLMkmZRFDQ2lgj7TAiFIEONyZYXFUnvNPjCkz83z?= =?us-ascii?Q?UaFWWJdlaI9rroQrKakM+bAiRYccOboHvRHLa4N/Q+AHiRabl28OaFVUdqAu?= =?us-ascii?Q?Q40e4VfRd5KMPykQP0GqPHbsxeZO6E8VApfiOJtG2x+s9wFuWDqGYdcmXEqX?= =?us-ascii?Q?C++RJA2k3uF3rt6TKzqjABQVxhYIw7uImSx5cHeO7/7re3SIaj+EH5Xu/H1b?= =?us-ascii?Q?KtXlT8GZJ+cyFFqP73W0/Z6uQ/ZmSkgevT+ootJ/q2BeaA2c7TOivdBBACuk?= =?us-ascii?Q?eo56m8oMQBLOuXd0ZtZu5bhWur+rJOyEGVl5+FpHp3lqwKfY/RTqDAGax5lr?= =?us-ascii?Q?NcwRyC142LgxBxrfyPzYjOWpDR9RO/ZcbrQ81CdF/VXPwVdvvA3AEM+08TSR?= =?us-ascii?Q?W9aHizFWpKQQ3y/AOnbw2vn45P9VbJFYLtCzAxwG6of5RvC+bKy6zZ9IRbjw?= =?us-ascii?Q?9TLG6UW0Obs8R+uskBgUxvQedxtACXs95BwO6WgJmNZujg3r46vTbn0lbDYN?= =?us-ascii?Q?2O5Z2/z7yv9adfO2iT2O5nDFbq4RKZ+8Tjms76U1ZD4tfT31JPs/DJv33QI3?= =?us-ascii?Q?xl1NFADGtwbJlzwB0ugknMTXMfTS5cjIztU1YYiYgN8biM5So10q222SuJGP?= =?us-ascii?Q?ZqkDGjTogscnx9gio8g5nVvg?= X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 7ba3521f-91a5-4aac-9d28-08d8d3bb2f91 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Feb 2021 03:13:38.2352 (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: yXDcSrX/0ezbEFPZLUh4MLAIdvKBaFQS0LaeZqZckMoyv/ivFj9jgvCwU++B2jWWcTA+T9FRT8qb2RqWjHizjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB0341 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-18_01:2021-02-16,2021-02-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102180026 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Leif, Have time to review the v2 which was revised according to your comments on= v1. Thanks Abner > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Abner Chang > 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 caus= es > 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 endp= tr) { > 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 * > +stream) { > + 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