TianoCore EDK2 master
Loading...
Searching...
No Matches
CrtLibSupport.h File Reference

Go to the source code of this file.

Data Structures

struct  tm
 
struct  timeval
 
struct  sockaddr
 

Macros

#define OPENSSLDIR   ""
 
#define ENGINESDIR   ""
 
#define MODULESDIR   ""
 
#define MAX_STRING_SIZE   0x1000
 
#define BUFSIZ   8192
 
#define CONFIG_HEADER_BN_H
 
#define va_list   VA_LIST
 
#define va_arg   VA_ARG
 
#define va_start   VA_START
 
#define va_end   VA_END
 
#define EINVAL   22 /* Invalid argument */
 
#define EAFNOSUPPORT   47 /* Address family not supported by protocol family */
 
#define INT_MAX   0x7FFFFFFF /* Maximum (signed) int value */
 
#define INT_MIN   (-INT_MAX-1) /* Minimum (signed) int value */
 
#define LONG_MAX   0X7FFFFFFFL /* max value for a long */
 
#define LONG_MIN   (-LONG_MAX-1) /* min value for a long */
 
#define UINT_MAX   0xFFFFFFFF /* Maximum unsigned int value */
 
#define ULONG_MAX   0xFFFFFFFF /* Maximum unsigned long value */
 
#define CHAR_BIT   8 /* Number of bits in a char */
 
#define SIZE_MAX   0xFFFFFFFF /* Maximum unsigned size_t */
 
#define AF_INET   2 /* internetwork: UDP, TCP, etc. */
 
#define AF_INET6   24 /* IP version 6 */
 
#define NS_INT16SZ   2 /*%< #/bytes of data in a u_int16_t */
 
#define NS_INADDRSZ   4 /*%< IPv4 T_A */
 
#define NS_IN6ADDRSZ   16 /*%< IPv6 T_AAAA */
 
#define memcpy(dest, source, count)   CopyMem(dest,source,(UINTN)(count))
 
#define memset(dest, ch, count)   SetMem(dest,(UINTN)(count),(UINT8)(ch))
 
#define memchr(buf, ch, count)   ScanMem8(buf,(UINTN)(count),(UINT8)ch)
 
#define memcmp(buf1, buf2, count)   (int)(CompareMem(buf1,buf2,(UINTN)(count)))
 
#define memmove(dest, source, count)   CopyMem(dest,source,(UINTN)(count))
 
#define strlen(str)   (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE))
 
#define strncmp(string1, string2, count)   (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))
 
#define strcasecmp(str1, str2)   (int)AsciiStriCmp(str1,str2)
 
#define strstr(s1, s2)   AsciiStrStr(s1,s2)
 
#define sprintf(buf, ...)   AsciiSPrint(buf,MAX_STRING_SIZE,__VA_ARGS__)
 
#define localtime(timer)   NULL
 
#define assert(expression)
 
#define offsetof(type, member)   OFFSET_OF(type,member)
 
#define atoi(nptr)   AsciiStrDecimalToUintn(nptr)
 

Typedefs

typedef UINTN size_t
 
typedef UINTN off_t
 
typedef UINTN u_int
 
typedef UINTN intptr_t
 
typedef INTN ptrdiff_t
 
typedef INTN ssize_t
 
typedef INT64 time_t
 
typedef UINT8 __uint8_t
 
typedef UINT8 sa_family_t
 
typedef UINT8 u_char
 
typedef UINT32 uid_t
 
typedef UINT32 gid_t
 
typedef CHAR16 wchar_t
 
typedef VOID * FILE
 

Functions

void * malloc (size_t)
 
void * realloc (void *, size_t)
 
void free (void *)
 
void * memset (void *, int, size_t)
 
int memcmp (const void *, const void *, size_t)
 
int isdigit (int)
 
int isspace (int)
 
int isxdigit (int)
 
int isalnum (int)
 
int isupper (int)
 
int tolower (int)
 
int strcmp (const char *, const char *)
 
int strncasecmp (const char *, const char *, size_t)
 
char * strchr (const char *, int)
 
char * strrchr (const char *, int)
 
unsigned long strtoul (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 sscanf (const char *, const char *,...)
 
FILE * fopen (const char *, const char *)
 
size_t fread (void *, size_t, size_t, FILE *)
 
size_t fwrite (const void *, size_t, size_t, FILE *)
 
int fclose (FILE *)
 
int fprintf (FILE *, const char *,...)
 
time_t time (time_t *)
 
struct tmgmtime (const time_t *)
 
unsigned int sleep (unsigned int seconds)
 
int gettimeofday (struct timeval *tv, struct timezone *tz)
 
time_t mktime (struct tm *t)
 
uid_t getuid (void)
 
uid_t geteuid (void)
 
gid_t getgid (void)
 
gid_t getegid (void)
 
int issetugid (void)
 
void qsort (void *, size_t, size_t, int(*)(const void *, const void *))
 
char * getenv (const char *)
 
char * secure_getenv (const char *)
 
void abort (void)
 
int inet_pton (int, const char *, void *)
 
char * strcpy (char *strDest, const char *strSource)
 
char * strncpy (char *strDest, const char *strSource, size_t count)
 
char * strcat (char *strDest, const char *strSource)
 

Variables

int errno
 
FILE * stderr
 
long timezone
 

Detailed Description

Root include file of C runtime library to support building the third-party cryptographic library.

Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.
Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.
Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file CrtLibSupport.h.

Macro Definition Documentation

◆ AF_INET

#define AF_INET   2 /* internetwork: UDP, TCP, etc. */

Definition at line 96 of file CrtLibSupport.h.

◆ AF_INET6

#define AF_INET6   24 /* IP version 6 */

Definition at line 97 of file CrtLibSupport.h.

◆ assert

#define assert (   expression)

Definition at line 454 of file CrtLibSupport.h.

◆ atoi

#define atoi (   nptr)    AsciiStrDecimalToUintn(nptr)

Definition at line 456 of file CrtLibSupport.h.

◆ BUFSIZ

#define BUFSIZ   8192

Definition at line 35 of file CrtLibSupport.h.

◆ CHAR_BIT

#define CHAR_BIT   8 /* Number of bits in a char */

Definition at line 90 of file CrtLibSupport.h.

◆ CONFIG_HEADER_BN_H

#define CONFIG_HEADER_BN_H

Definition at line 48 of file CrtLibSupport.h.

◆ EAFNOSUPPORT

#define EAFNOSUPPORT   47 /* Address family not supported by protocol family */

Definition at line 83 of file CrtLibSupport.h.

◆ EINVAL

#define EINVAL   22 /* Invalid argument */

Definition at line 82 of file CrtLibSupport.h.

◆ ENGINESDIR

#define ENGINESDIR   ""

Definition at line 22 of file CrtLibSupport.h.

◆ INT_MAX

#define INT_MAX   0x7FFFFFFF /* Maximum (signed) int value */

Definition at line 84 of file CrtLibSupport.h.

◆ INT_MIN

#define INT_MIN   (-INT_MAX-1) /* Minimum (signed) int value */

Definition at line 85 of file CrtLibSupport.h.

◆ localtime

#define localtime (   timer)    NULL

Definition at line 453 of file CrtLibSupport.h.

◆ LONG_MAX

#define LONG_MAX   0X7FFFFFFFL /* max value for a long */

Definition at line 86 of file CrtLibSupport.h.

◆ LONG_MIN

#define LONG_MIN   (-LONG_MAX-1) /* min value for a long */

Definition at line 87 of file CrtLibSupport.h.

◆ MAX_STRING_SIZE

#define MAX_STRING_SIZE   0x1000

Definition at line 25 of file CrtLibSupport.h.

◆ memchr

#define memchr (   buf,
  ch,
  count 
)    ScanMem8(buf,(UINTN)(count),(UINT8)ch)

Definition at line 445 of file CrtLibSupport.h.

◆ memcmp

#define memcmp (   buf1,
  buf2,
  count 
)    (int)(CompareMem(buf1,buf2,(UINTN)(count)))

Definition at line 446 of file CrtLibSupport.h.

◆ memcpy

#define memcpy (   dest,
  source,
  count 
)    CopyMem(dest,source,(UINTN)(count))

Definition at line 443 of file CrtLibSupport.h.

◆ memmove

#define memmove (   dest,
  source,
  count 
)    CopyMem(dest,source,(UINTN)(count))

Definition at line 447 of file CrtLibSupport.h.

◆ memset

#define memset (   dest,
  ch,
  count 
)    SetMem(dest,(UINTN)(count),(UINT8)(ch))

Definition at line 444 of file CrtLibSupport.h.

◆ MODULESDIR

#define MODULESDIR   ""

Definition at line 23 of file CrtLibSupport.h.

◆ NS_IN6ADDRSZ

#define NS_IN6ADDRSZ   16 /*%< IPv6 T_AAAA */

Definition at line 104 of file CrtLibSupport.h.

◆ NS_INADDRSZ

#define NS_INADDRSZ   4 /*%< IPv4 T_A */

Definition at line 103 of file CrtLibSupport.h.

◆ NS_INT16SZ

#define NS_INT16SZ   2 /*%< #/bytes of data in a u_int16_t */

Definition at line 102 of file CrtLibSupport.h.

◆ offsetof

#define offsetof (   type,
  member 
)    OFFSET_OF(type,member)

Definition at line 455 of file CrtLibSupport.h.

◆ OPENSSLDIR

#define OPENSSLDIR   ""

Definition at line 21 of file CrtLibSupport.h.

◆ SIZE_MAX

#define SIZE_MAX   0xFFFFFFFF /* Maximum unsigned size_t */

Definition at line 91 of file CrtLibSupport.h.

◆ sprintf

#define sprintf (   buf,
  ... 
)    AsciiSPrint(buf,MAX_STRING_SIZE,__VA_ARGS__)

Definition at line 452 of file CrtLibSupport.h.

◆ strcasecmp

#define strcasecmp (   str1,
  str2 
)    (int)AsciiStriCmp(str1,str2)

Definition at line 450 of file CrtLibSupport.h.

◆ strlen

#define strlen (   str)    (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE))

Definition at line 448 of file CrtLibSupport.h.

◆ strncmp

#define strncmp (   string1,
  string2,
  count 
)    (int)(AsciiStrnCmp(string1,string2,(UINTN)(count)))

Definition at line 449 of file CrtLibSupport.h.

◆ strstr

#define strstr (   s1,
  s2 
)    AsciiStrStr(s1,s2)

Definition at line 451 of file CrtLibSupport.h.

◆ UINT_MAX

#define UINT_MAX   0xFFFFFFFF /* Maximum unsigned int value */

Definition at line 88 of file CrtLibSupport.h.

◆ ULONG_MAX

#define ULONG_MAX   0xFFFFFFFF /* Maximum unsigned long value */

Definition at line 89 of file CrtLibSupport.h.

◆ va_arg

#define va_arg   VA_ARG

Definition at line 70 of file CrtLibSupport.h.

◆ va_end

#define va_end   VA_END

Definition at line 72 of file CrtLibSupport.h.

◆ va_list

#define va_list   VA_LIST

Definition at line 69 of file CrtLibSupport.h.

◆ va_start

#define va_start   VA_START

Definition at line 71 of file CrtLibSupport.h.

Typedef Documentation

◆ __uint8_t

typedef UINT8 __uint8_t

Definition at line 116 of file CrtLibSupport.h.

◆ FILE

typedef VOID* FILE

Definition at line 127 of file CrtLibSupport.h.

◆ gid_t

typedef UINT32 gid_t

Definition at line 120 of file CrtLibSupport.h.

◆ intptr_t

typedef UINTN intptr_t

Definition at line 112 of file CrtLibSupport.h.

◆ off_t

typedef UINTN off_t

Definition at line 110 of file CrtLibSupport.h.

◆ ptrdiff_t

typedef INTN ptrdiff_t

Definition at line 113 of file CrtLibSupport.h.

◆ sa_family_t

typedef UINT8 sa_family_t

Definition at line 117 of file CrtLibSupport.h.

◆ size_t

typedef UINTN size_t

Definition at line 109 of file CrtLibSupport.h.

◆ ssize_t

typedef INTN ssize_t

Definition at line 114 of file CrtLibSupport.h.

◆ time_t

typedef INT64 time_t

Definition at line 115 of file CrtLibSupport.h.

◆ u_char

typedef UINT8 u_char

Definition at line 118 of file CrtLibSupport.h.

◆ u_int

typedef UINTN u_int

Definition at line 111 of file CrtLibSupport.h.

◆ uid_t

typedef UINT32 uid_t

Definition at line 119 of file CrtLibSupport.h.

◆ wchar_t

typedef CHAR16 wchar_t

Definition at line 121 of file CrtLibSupport.h.

Function Documentation

◆ abort()

void abort ( void  )

Definition at line 555 of file CrtWrapper.c.

◆ fclose()

int fclose ( FILE *  stream)

Close file, we don't support file operastion on edk2 JSON library.

Returns
0 Unsupported

Definition at line 565 of file CrtWrapper.c.

◆ fopen()

FILE * fopen ( const char *  filename,
const char *  mode 
)

Open stream file, we don't support file operastion on edk2 JSON library.

Returns
0 Unsupported

Definition at line 573 of file CrtWrapper.c.

◆ fprintf()

int fprintf ( FILE *  stream,
const char *  format,
  ... 
)

Write the formatted string to file, we don't support file operastion on edk2 JSON library.

Returns
0 Unsupported

Definition at line 875 of file RedfishCrtLib.c.

◆ fread()

size_t fread ( void *  ptr,
size_t  size,
size_t  count,
FILE *  stream 
)

Read stream from file, we don't support file operastion on edk2 JSON library.

Returns
0 Unsupported

Definition at line 582 of file CrtWrapper.c.

◆ free()

void free ( void *  ptr)

De-allocates or frees a memory block

Definition at line 107 of file BaseMemAllocation.c.

◆ fwrite()

size_t fwrite ( const void *  ptr,
size_t  size,
size_t  count,
FILE *  stream 
)

Write stream from file, we don't support file operastion on edk2 JSON library.

Returns
0 Unsupported

Definition at line 513 of file CrtWrapper.c.

◆ getegid()

gid_t getegid ( void  )

Definition at line 617 of file CrtWrapper.c.

◆ getenv()

char * getenv ( const char *  varname)

Definition at line 480 of file CrtWrapper.c.

◆ geteuid()

uid_t geteuid ( void  )

Definition at line 601 of file CrtWrapper.c.

◆ getgid()

gid_t getgid ( void  )

Definition at line 609 of file CrtWrapper.c.

◆ gettimeofday()

int gettimeofday ( struct timeval tv,
struct timezone *  tz 
)

Definition at line 63 of file ConstantTimeClock.c.

◆ getuid()

uid_t getuid ( void  )

Definition at line 593 of file CrtWrapper.c.

◆ gmtime()

struct tm * gmtime ( const time_t *  timer)

gmtime function.

Convert a time value from type time_t to struct tm.

Definition at line 39 of file ConstantTimeClock.c.

◆ inet_pton()

int inet_pton ( int  af,
const char *  src,
void *  dst 
)

Definition at line 99 of file inet_pton.c.

◆ isalnum()

int isalnum ( int  c)

Determine if a particular character is an alphanumeric character

Returns
Returns 1 if c is an alphanumeric character, otherwise returns 0.

Definition at line 370 of file CrtWrapper.c.

◆ isdigit()

int isdigit ( int  c)

Definition at line 332 of file CrtWrapper.c.

◆ isspace()

int isspace ( int  c)

Determine if a particular character is a space character

Returns
Returns 1 if c is a space character

Definition at line 358 of file CrtWrapper.c.

◆ isupper()

int isupper ( int  c)

Definition at line 384 of file CrtWrapper.c.

◆ isxdigit()

int isxdigit ( int  c)

Definition at line 344 of file CrtWrapper.c.

◆ malloc()

void * malloc ( size_t  size)

Allocates memory blocks.

Allocates memory blocks

Definition at line 31 of file BaseMemAllocation.c.

◆ memcmp()

int memcmp ( const void *  buf1,
const void *  buf2,
size_t  count 
)

Definition at line 58 of file MemoryIntrinsics.c.

◆ memset()

void * memset ( void *  s,
int  c,
size_t  n 
)

Definition at line 26 of file memset_ms.c.

◆ mktime()

time_t mktime ( struct tm t)

Definition at line 47 of file ConstantTimeClock.c.

◆ printf()

int printf ( const char *  fmt,
  ... 
)

Definition at line 625 of file CrtWrapper.c.

◆ qsort()

void qsort ( void *  base,
size_t  num,
size_t  width,
int(*)(const void *, const void *)  compare 
)

Performs a quick sort

Definition at line 447 of file CrtWrapper.c.

◆ realloc()

void * realloc ( void *  ptr,
size_t  size 
)

Definition at line 64 of file BaseMemAllocation.c.

◆ secure_getenv()

char * secure_getenv ( const char *  varname)

Definition at line 493 of file CrtWrapper.c.

◆ sleep()

unsigned int sleep ( unsigned int  seconds)

Definition at line 55 of file ConstantTimeClock.c.

◆ sscanf()

int sscanf ( const char *  buffer,
const char *  format,
  ... 
)

Definition at line 180 of file CrtWrapper.c.

◆ strcat()

char * strcat ( char *  strDest,
const char *  strSource 
)

Definition at line 299 of file CrtWrapper.c.

◆ strchr()

char * strchr ( const char *  str,
int  ch 
)

strchr function.

Definition at line 119 of file CrtWrapper.c.

◆ strcmp()

int strcmp ( const char *  s1,
const char *  s2 
)

strcmp function.

Definition at line 318 of file CrtWrapper.c.

◆ strcpy()

char * strcpy ( char *  strDest,
const char *  strSource 
)

Definition at line 269 of file CrtWrapper.c.

◆ strcspn()

size_t strcspn ( const char *  s1,
const char *  s2 
)

Definition at line 239 of file CrtWrapper.c.

◆ strerror()

char * strerror ( int  errnum)

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.

Returns
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.

Definition at line 195 of file CrtWrapper.c.

◆ strncasecmp()

int strncasecmp ( const char *  s1,
const char *  s2,
size_t  n 
)

Definition at line 149 of file CrtWrapper.c.

◆ strncpy()

char * strncpy ( char *  strDest,
const char *  strSource,
size_t  count 
)

Definition at line 279 of file CrtWrapper.c.

◆ strrchr()

char * strrchr ( const char *  str,
int  c 
)

Definition at line 129 of file CrtWrapper.c.

◆ strspn()

size_t strspn ( const char *  s1,
const char *  s2 
)

Definition at line 205 of file CrtWrapper.c.

◆ strtol()

long strtol ( const char *  nptr,
char **  endptr,
int  base 
)

The strtol, strtoll, strtoul, and strtoull functions convert the initial portion of the string pointed to by nptr to long int, long long int, unsigned long int, and unsigned long long int representation, respectively. First, they decompose the input string into three parts: an initial, possibly empty, sequence of white-space characters (as specified by the isspace function), a subject sequence resembling an integer represented in some radix determined by the value of base, and a final string of one or more unrecognized characters, including the terminating null character of the input string. Then, they attempt to convert the subject sequence to an integer, and return the result.

If the value of base is zero, the expected form of the subject sequence is that of an integer constant, optionally preceded by a plus or minus sign, but not including an integer suffix. If the value of base is between 2 and 36 (inclusive), the expected form of the subject sequence is a sequence of letters and digits representing an integer with the radix specified by base, optionally preceded by a plus or minus sign, but not including an integer suffix. The letters from a (or A) through z (or Z) are ascribed the values 10 through 35; only letters and digits whose ascribed values are less than that of base are permitted. If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits, following the sign if present.

The subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-white-space character, that is of the expected form. The subject sequence contains no characters if the input string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or a permissible letter or digit.

If the subject sequence has the expected form and the value of base is zero, the sequence of characters starting with the first digit is interpreted as an integer constant. If the subject sequence has the expected form and the value of base is between 2 and 36, it is used as the base for conversion, ascribing to each letter its value as given above. If the subject sequence begins with a minus sign, the value resulting from the conversion is negated (in the return type). A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null pointer.

In other than the "C" locale, additional locale-specific subject sequence forms may be accepted.

If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.

Returns
The strtol, strtoll, strtoul, and strtoull functions return the converted value, if any. If no conversion could be performed, zero is returned. If the correct value is outside the range of representable values, LONG_MIN, LONG_MAX, LLONG_MIN, LLONG_MAX, ULONG_MAX, or ULLONG_MAX is returned (according to the return type and sign of the value, if any), and the value of the macro ERANGE is stored in errno.

Definition at line 400 of file CrtWrapper.c.

◆ strtoul()

unsigned long strtoul ( const char *  nptr,
char **  endptr,
int  base 
)

Definition at line 415 of file CrtWrapper.c.

◆ time()

time_t time ( time_t *  timer)

time function.

Get the system time as seconds elapsed since midnight, January 1, 1970.

Definition at line 27 of file ConstantTimeClock.c.

◆ tolower()

int tolower ( int  c)

Definition at line 430 of file CrtWrapper.c.

Variable Documentation

◆ errno

int errno
extern

Copyright (c) 2024, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition at line 12 of file CrtWrapper.c.

◆ stderr

FILE* stderr
extern

Definition at line 14 of file CrtWrapper.c.

◆ timezone

long timezone
extern

Definition at line 73 of file ConstantTimeClock.c.