From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.web09.8744.1614081179952214761 for ; Tue, 23 Feb 2021 03:53:00 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=0LTF2Nmy; spf=pass (domain: nuviainc.com, ip: 209.85.128.47, mailfrom: leif@nuviainc.com) Received: by mail-wm1-f47.google.com with SMTP id i9so2145082wml.5 for ; Tue, 23 Feb 2021 03:52:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6CWIyVpOTGTPr+wU83Az5dpCY4eiZclm4vdnskcTteI=; b=0LTF2Nmy2Td4p1//aubSeSIdbnrwv57k5dBhDRRExNkkgMb5k+Re4nljoZIxtHxo4F nHgK//Amer6NBd300CZsaaVJha1EBIT+ZuPA/JKga7WQD0iXEyJNqgES/TmWPgw4OH4Z CQ6Bs6KekmZvy4wpkryu/lnUKtbqEFlcD+SF4a9UoNuS5BGlCJezP7AZNPOKrZCZvhn7 qupXUdUTl0osnuMVwQpYRTSYyjyI99biqEL7lsX0EbjyKG3MwYugkj/oTpdr5r0t4SQo RgE18gEFQLApD18GgOnL56H/Bj7UVECtBmhjheDwBKQA9I1+PfVRG9vQALJ2MicndVUf SCZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6CWIyVpOTGTPr+wU83Az5dpCY4eiZclm4vdnskcTteI=; b=VrJSmieGiI1MZzFe8sa+T5j55hRTpDRBSYuWawiR3DFN3UeIdP+ovMDvyR5DUs22t6 LFk4vCXauuR8zdaUsHerV2sZWODPr2PQRft6C3xz4MzpZU5HbAWwfIvAS4EeNYlFRMx6 cg6soAyEJn3NjLuYbx/jBgR6ZFbugGfr8G4YEPSJRiySS5q+dyWV0uR7AQu57T8OhIY6 sE2utG3nbY7HaUb+/xE8vdKX46syPjPXONrMg9E8DjmD73hpEluL3/SSYwgjtZYms5j2 6D9ct14F1mr/vDSQPZInsSaYhb8T1rs2qgRQUJ6cKbOqB6X6YFl6ZixeNrOxqdA1Sfho KOiQ== X-Gm-Message-State: AOAM5309+Lx6DoTitjXDMDFFD2l7F8AAs1LZQuMpWWhNCj0MGyYf265X zszp/yvbG0qOfa7djGUEBaYEIw== X-Google-Smtp-Source: ABdhPJysfzh8d672L+DUSsob1/iTE+FzE/96kU00+ABqtG6NIjLs8wpzR26k6B0EFdjeXYLqawdawg== X-Received: by 2002:a1c:7c17:: with SMTP id x23mr12768582wmc.95.1614081178543; Tue, 23 Feb 2021 03:52:58 -0800 (PST) Return-Path: Received: from vanye (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id p3sm16817548wro.55.2021.02.23.03.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Feb 2021 03:52:57 -0800 (PST) Date: Tue, 23 Feb 2021 11:52:56 +0000 From: "Leif Lindholm" To: "Chang, Abner (HPS SW/FW Technologist)" Cc: "devel@edk2.groups.io" , "Wang, Nickle (HPS SW)" , Michael D Kinney Subject: Re: [edk2-devel] [PATCH v2] RedfishPkg/RedfishCrtLib: Add more CRT functions Message-ID: <20210223115256.GY1664@vanye> References: <165E48A9D69DD66E.18860@groups.io> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Feb 18, 2021 at 03:13:38 +0000, Chang, Abner (HPS SW/FW Technologist) wrote: > Hi Leif, > Have time to review the v2 which was revised according to your comments on v1. Whoops, sorry. I am a bit unsure how to treat reviews of RedfishPkg, which I'm not a reviewer/maintainer for. If I just point out a few minor fixups (like here), you don't really need to wait for my confirmation. I had sort of moved on and considered this set done from my point of view, lazily ignoring the thread. But if you want it: Acked-by: Leif Lindholm > 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 > > > > 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 | 122 +++++++++++++++++- > > 1 file changed, 121 insertions(+), 1 deletion(-) > > > > 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 > > > > int errno = 0; > > +char errnum_message [] = "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 = 1; > > > > /** > > Determine if a particular character is an alphanumeric character @@ -465,6 > > +469,77 @@ strtod (const char * __restrict nptr, char ** __restrict endptr) { > > return (double)0; > > } > > > > +static UINT8 BitMask[] = { > > + 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] = index = 1; index < n; index++) { > > + BITMAP64[index] = 0; > > + } > > + > > + // Set bits in bitmap corresponding to the characters in s2 > > + for (; *s2 != '\0'; s2++) { > > + index = WHICH8(*s2); > > + bit = WHICH_BIT(*s2); > > + bitmap[index] = bitmap[index] | bit; > > + } > > +} > > + > > +/** The strpbrk function locates the first occurrence in the string pointed 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 != '\0'; ++s1) { > > + index = WHICH8(*s1); > > + bit = WHICH_BIT(*s1); > > + if( (bitmap[index] & bit) != 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 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, 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. > > **/ > > @@ -592,7 +667,52 @@ void qsort (void *base, size_t num, size_t width, int > > (*compare)(const void *, c > > > > **/ > > int fgetc(FILE * _File){ > > - return 0; > > + return EOF; > > +} > > +/** > > + 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 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 > > > > > > > > > > >