mirror of
https://git.proxmox.com/git/efi-boot-shim
synced 2025-07-27 08:57:14 +00:00
Cryptlib: amend the headers and fix signness
- Declare some functions in the proper headers + We missed them for a long time... - Cast offsetof to UINTN + The original casting triggers the gcc warning since int can not present the offset for the 64bit machines. - Cast the "char" array to "CHAR8 *" to avoid the gcc warnings - Implement atoi correctly Signed-off-by: Gary Lin <glin@suse.com>
This commit is contained in:
parent
97469449fd
commit
e883479f35
@ -191,7 +191,7 @@ typedef CHAR8 *VA_LIST;
|
|||||||
For pre-Standard C compilers, here is a version that usually works
|
For pre-Standard C compilers, here is a version that usually works
|
||||||
(but watch out!): */
|
(but watch out!): */
|
||||||
#ifndef offsetof
|
#ifndef offsetof
|
||||||
#define offsetof(type, member) ( (int) & ((type*)0) -> member )
|
#define offsetof(type, member) ( (UINTN) & ((type*)0) -> member )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -307,6 +307,9 @@ char *strncpy (char *, const char *, size_t);
|
|||||||
char *strrchr (const char *, int);
|
char *strrchr (const char *, int);
|
||||||
unsigned long strtoul (const char *, char **, int);
|
unsigned long strtoul (const char *, char **, int);
|
||||||
long strtol (const char *, char **, int);
|
long strtol (const char *, char **, int);
|
||||||
|
char *strerror (int);
|
||||||
|
size_t strspn (const char *, const char *);
|
||||||
|
size_t strcspn (const char *, const char *);
|
||||||
int printf (const char *, ...);
|
int printf (const char *, ...);
|
||||||
int sscanf (const char *, const char *, ...);
|
int sscanf (const char *, const char *, ...);
|
||||||
int open (const char *, int, ...);
|
int open (const char *, int, ...);
|
||||||
@ -356,26 +359,26 @@ extern FILE *stdin;
|
|||||||
extern FILE *stdout;
|
extern FILE *stdout;
|
||||||
|
|
||||||
#define AsciiStrLen(x) strlena(x)
|
#define AsciiStrLen(x) strlena(x)
|
||||||
#define AsciiStrnCmp(s1, s2, len) strncmpa(s1, s2, len)
|
#define AsciiStrnCmp(s1, s2, len) strncmpa((CHAR8 *)s1, (CHAR8 *)s2, len)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
|
// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
|
||||||
//
|
//
|
||||||
#define memcpy(dest,source,count) ( {CopyMem(dest,source,(UINTN)(count)); dest; })
|
#define memcpy(dest,source,count) ( {CopyMem(dest,source,(UINTN)(count)); dest; })
|
||||||
#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
|
#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
|
||||||
#define memchr(buf,ch,count) ScanMem8(buf,(UINTN)(count),(UINT8)ch)
|
#define memchr(buf,ch,count) ScanMem8((CHAR8 *)buf,(UINTN)(count),ch)
|
||||||
#define memcmp(buf1,buf2,count) (int)(CompareMem(buf1,buf2,(UINTN)(count)))
|
#define memcmp(buf1,buf2,count) (int)(CompareMem(buf1,buf2,(UINTN)(count)))
|
||||||
#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count))
|
#define memmove(dest,source,count) CopyMem(dest,source,(UINTN)(count))
|
||||||
#define strlen(str) (size_t)(AsciiStrLen(str))
|
#define strlen(str) (size_t)(AsciiStrLen((CHAR8 *)str))
|
||||||
#define strcpy(strDest,strSource) AsciiStrCpy(strDest,strSource)
|
#define strcpy(strDest,strSource) AsciiStrCpy(strDest,strSource)
|
||||||
#define strncpy(strDest,strSource,count) AsciiStrnCpy(strDest,strSource,(UINTN)count)
|
#define strncpy(strDest,strSource,count) AsciiStrnCpy(strDest,strSource,(UINTN)count)
|
||||||
#define strcat(strDest,strSource) AsciiStrCat(strDest,strSource)
|
#define strcat(strDest,strSource) AsciiStrCat(strDest,strSource)
|
||||||
#define strchr(str,ch) ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch)
|
#define strchr(str,ch) (char *)(ScanMem8((CHAR8 *)str,AsciiStrSize((CHAR8 *)str),ch))
|
||||||
#define strcmp strcmpa
|
#define strcmp(string1,string2) strcmpa((CHAR8 *)string1,(CHAR8 *)string2)
|
||||||
#define strncmp(string1,string2,count) (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
|
#define strncmp(string1,string2,count) (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
|
||||||
#define localtime(timer) NULL
|
#define localtime(timer) NULL
|
||||||
#define assert(expression)
|
#define assert(expression)
|
||||||
#define atoi(nptr) Atoi(nptr)
|
#define atoi(nptr) AsciiStrDecimalToUintn(nptr)
|
||||||
#define gettimeofday(tvp,tz) do { (tvp)->tv_sec = time(NULL); (tvp)->tv_usec = 0; } while (0)
|
#define gettimeofday(tvp,tz) do { (tvp)->tv_sec = time(NULL); (tvp)->tv_usec = 0; } while (0)
|
||||||
#define gmtime_r(timer,result) (result = NULL)
|
#define gmtime_r(timer,result) (result = NULL)
|
||||||
|
|
||||||
|
@ -1,2 +1,8 @@
|
|||||||
#include <efi.h>
|
#include <efi.h>
|
||||||
#include <efilib.h>
|
#include <efilib.h>
|
||||||
|
|
||||||
|
UINT32 WriteUnaligned32 (UINT32 *Buffer, UINT32 Value);
|
||||||
|
UINTN AsciiStrSize (CHAR8 *string);
|
||||||
|
char *AsciiStrnCpy(char *Destination, char *Source, UINTN count);
|
||||||
|
char *AsciiStrCat(char *Destination, char *Source);
|
||||||
|
UINTN AsciiStrDecimalToUintn(const char *String);
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
CHAR8 *ScanMem8(CHAR8 *str, UINTN count, CHAR8 ch);
|
@ -1,9 +1,9 @@
|
|||||||
#include <CrtLibSupport.h>
|
#include <CrtLibSupport.h>
|
||||||
|
|
||||||
CHAR8 *
|
char *
|
||||||
AsciiStrCat(CHAR8 *Destination, CHAR8 *Source)
|
AsciiStrCat(char *Destination, char *Source)
|
||||||
{
|
{
|
||||||
UINTN dest_len = strlena(Destination);
|
UINTN dest_len = strlena((CHAR8 *)Destination);
|
||||||
UINTN i;
|
UINTN i;
|
||||||
|
|
||||||
for (i = 0; Source[i] != '\0'; i++)
|
for (i = 0; Source[i] != '\0'; i++)
|
||||||
@ -25,8 +25,8 @@ AsciiStrCpy(CHAR8 *Destination, CHAR8 *Source)
|
|||||||
return Destination;
|
return Destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHAR8 *
|
char *
|
||||||
AsciiStrnCpy(CHAR8 *Destination, CHAR8 *Source, UINTN count)
|
AsciiStrnCpy(char *Destination, char *Source, UINTN count)
|
||||||
{
|
{
|
||||||
UINTN i;
|
UINTN i;
|
||||||
|
|
||||||
@ -64,4 +64,32 @@ AsciiStrSize(CHAR8 *string)
|
|||||||
return strlena(string) + 1;
|
return strlena(string) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Based on AsciiStrDecimalToUintnS() in edk2
|
||||||
|
* MdePkg/Library/BaseLib/SafeString.c */
|
||||||
|
UINTN
|
||||||
|
AsciiStrDecimalToUintn(const char *String)
|
||||||
|
{
|
||||||
|
UINTN Result;
|
||||||
|
|
||||||
|
if (String == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Ignore the pad spaces (space or tab) */
|
||||||
|
while ((*String == ' ') || (*String == '\t')) {
|
||||||
|
String++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ignore leading Zeros after the spaces */
|
||||||
|
while (*String == '0') {
|
||||||
|
String++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result = 0;
|
||||||
|
|
||||||
|
while (*String >= '0' && *String <= '9') {
|
||||||
|
Result = Result * 10 + (*String - '0');
|
||||||
|
String++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user