From nobody Fri May 3 05:22:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70716+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70716+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1611552338; cv=none; d=zohomail.com; s=zohoarc; b=bB10ydvHQ8xgZNQciA78qIEU9E4kMRyCXWJB9EtCcBR+a0CxSVuNAz+QobQjDX9sJ4Ke/tTHB/Wh9YSTtmPt8NgBHbc1nULBYRrPGodCnq0VsTAkMB959QZNXStgPc3yr/EfrJKX0+FhxraImw+9p3yg44elhDO7a10x0Z/trHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611552338; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=yLorr0CI+M6yaTbqSRaKpMH2ortiMSLeqw2qkoRIr68=; b=b5DCufm4a2rb/peTmCEfFX6nkanks5O1/zS8Cxpc/TZg+kSYLQqE29RM2q6kMki1fKcowX/GPmCqirtljuTfwj34ITRUmVHY6OwNi1PBJBAWvxGPMxWwfIhjDFmrMyh/XRsOuRJSdPm0c/3iq3i2KJELwT+zUOXjpGTe+UdAvDs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70716+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16115523380543.2443089140812162; Sun, 24 Jan 2021 21:25:38 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id QWFcYY1788612xXFrfWKBbwC; Sun, 24 Jan 2021 21:25:37 -0800 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web08.32564.1611552332186165148 for ; Sun, 24 Jan 2021 21:25:32 -0800 X-Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10P5OCLZ010301; Mon, 25 Jan 2021 05:25:31 GMT X-Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0a-002e3701.pphosted.com with ESMTP id 368wwf5qqm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Jan 2021 05:25:31 +0000 X-Received: from g4t3433.houston.hpecorp.net (g4t3433.houston.hpecorp.net [16.208.49.245]) by g4t3426.houston.hpe.com (Postfix) with ESMTP id AAFD34E; Mon, 25 Jan 2021 05:25:30 +0000 (UTC) X-Received: from abner-virtual-machine.asiapacific.hpqcorp.net (abner-virtual-machine.asiapacific.hpqcorp.net [15.119.210.153]) by g4t3433.houston.hpecorp.net (Postfix) with ESMTP id 737CD49; Mon, 25 Jan 2021 05:25:29 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: Nickle Wang , Leif Lindholm , Michael D Kinney Subject: [edk2-devel] [PATCH] RedfishPkg/RedfishCrtLib: Add more CRT functions Date: Mon, 25 Jan 2021 12:36:53 +0800 Message-Id: <20210125043653.20832-1-abner.chang@hpe.com> X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@hpe.com X-Gm-Message-State: ixBjVS9JcPuO0fctrlK9TNYfx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611552337; bh=Arff1DtS4+aDjeDMorn/2KXCHlxJMxHYgSdDKcVz8Ao=; h=Cc:Date:From:Reply-To:Subject:To; b=DT/hU2klDzek9i/BjGUsKye6jtH8pyJT0/tP+zynWlJKO7M4cSUIK3gkeoqwUveQqD8 1IKEbgkjKE2BJIcikbrtKuajfuji4nGFSyC1MpbOlZrMW5U9thwnxkVqzoAzql+x/rI9o YhBA6wt1IRVNfPNZOmP9DlmWkM2wKvEPMG4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add more functions which were missed in the first time commit, that causes the build error with EDK2 Redfish feature driver. strerror - We don't support this on edk2 environment. strpbrk - Cloned this function from edk2-LibC File operation functions - Not supported on edk2 environment. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Leif Lindholm Cc: Michael D Kinney --- .../RedfishCrtLib/RedfishCrtLib.c | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c b/Redf= ishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c index 0696341bc0..c64f14534c 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 me= ssage 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,76 @@ strtod (const char * __restrict nptr, char ** __restri= ct 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 pointe= d 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 shall m= ap + 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, the + contents of which are locale specific. The array pointed to + shall not be modified by the program, but may be overwritten= by + a subsequent call to the strerror function. +**/ +char * +strerror(int errnum) +{ + return errnum_message; +} + /** Allocate and zero-initialize array. **/ @@ -594,6 +668,51 @@ void qsort (void *base, size_t num, size_t width, int = (*compare)(const void *, c int fgetc(FILE * _File){ return 0; } +/** + Open stream file, we don't support file operastion on edk2 JSON library. + + @return 0 Unsupported + +**/ +FILE *fopen (const char *filename, const char *mode) { + return 0; +} +/** + Read stream from file, we don't support file operastion on edk2 JSON lib= rary. + + @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 li= brary. + + @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 0; +} +/** + 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 0; +} /** This function check if this is the formating string specifier. =20 --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70716): https://edk2.groups.io/g/devel/message/70716 Mute This Topic: https://groups.io/mt/80097478/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-