4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** @file
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The header <stdlib.h> declares five types and several functions of general
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync utility, and defines several macros.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The files stddef.h and stdlib.h are "catch all" headers for definitions and declarations
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync that don't fit well in the other headers. There are two separate header files because
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the contents of <stddef.h> are valid in both freestanding and hosted environment, while the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync header <stdlib.h> contains elements that are only valid in a hosted environment.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The following macros are defined in this file:<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @verbatim
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EXIT_FAILURE An expression indicating application failure, used as an argument to exit().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EXIT_SUCCESS An expression indicating application success, used as an argument to exit().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RAND_MAX The maximum value returned by the rand function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync MB_CUR_MAX Maximum number of bytes in a multibyte character for the current locale.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ATEXIT_MAX Maximum number of routines that may be registered by the atexit function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @endverbatim
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The following types are defined in this file:<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @verbatim
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync size_t Unsigned integer type of the result of the sizeof operator.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync wchar_t The type of a wide character.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync div_t Type of the value returned by the div function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ldiv_t Type of the value returned by the ldiv function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync lldiv_t Type of the value returned by the lldiv function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @endverbatim
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The following functions are declared in this file:<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @verbatim
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ################ Communication with the environment
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void abort (void) __noreturn;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int atexit (void (*)(void));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void exit (int status) __noreturn;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void _Exit (int status) __noreturn;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync char *getenv (const char *name);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int setenv (register const char * name,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync register const char * value, int rewrite);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int system (const char *string);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ################ Integer arithmetic functions
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int abs (int j);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long labs (long j);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long long llabs (long long j);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync div_t div (int numer, int denom);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ldiv_t ldiv (long numer, long denom);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync lldiv_t lldiv (long long numer, long long denom);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ################ Pseudo-random sequence generation functions
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int rand (void);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void srand (unsigned seed);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ################ Memory management functions
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void *calloc (size_t Num, size_t Size);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void free (void *);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void *malloc (size_t);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void *realloc (void *Ptr, size_t NewSize);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ################ Searching and Sorting utilities
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void *bsearch (const void *key, const void *base0,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync size_t nmemb, size_t size,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int (*compar)(const void *, const void *));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void qsort (void *base, size_t nmemb, size_t size,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int (*compar)(const void *, const void *));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ################ Multibyte/wide character conversion functions
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int mblen (const char *, size_t);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int mbtowc (wchar_t * __restrict, const char * __restrict, size_t);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int wctomb (char *, wchar_t);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ################ Multibyte/wide string conversion functions
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync size_t mbstowcs (wchar_t * __restrict dest,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync const char * __restrict src, size_t limit);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync size_t wcstombs (char * __restrict dest,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync const wchar_t * __restrict src, size_t limit);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ################ Miscelaneous functions for *nix compatibility
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync char *realpath (char *file_name, char *resolved_name);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync const char *getprogname (void);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync void setprogname (const char *progname);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ############ Integer Numeric conversion functions
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int atoi (const char *nptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long atol (const char *nptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long long atoll (const char *nptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long strtol (const char * __restrict nptr,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync char ** __restrict endptr, int base);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync unsigned long strtoul (const char * __restrict nptr,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync char ** __restrict endptr, int base);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long long strtoll (const char * __restrict nptr,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync char ** __restrict endptr, int base);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync unsigned long long strtoull (const char * __restrict nptr,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync char ** __restrict endptr, int base);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ######### Floating-point Numeric conversion functions
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync double atof (const char *);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync double strtod (const char * __restrict nptr,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync char ** __restrict endptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync float strtof (const char * __restrict nptr,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync char ** __restrict endptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long double strtold (const char * __restrict nptr,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync char ** __restrict endptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @endverbatim
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This program and the accompanying materials are licensed and made available under
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the terms and conditions of the BSD License that accompanies this distribution.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The full text of the license may be found at
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync http://opensource.org/licenses/bsd-license.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#ifndef _STDLIB_H
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define _STDLIB_H
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#include <sys/EfiCdefs.h>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#ifdef _EFI_SIZE_T_
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync /** Unsigned integer type of the result of the sizeof operator. **/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync typedef _EFI_SIZE_T_ size_t;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync #undef _EFI_SIZE_T_
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync #undef _BSD_SIZE_T_
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#endif
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#ifndef __cplusplus
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync #ifdef _EFI_WCHAR_T
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync /** Type of a wide (Unicode) character. **/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync typedef _EFI_WCHAR_T wchar_t;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync #undef _EFI_WCHAR_T
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync #undef _BSD_WCHAR_T_
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync #endif
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#endif
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/// A structure type that is the type of the value returned by the div function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynctypedef struct {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int quot; /**< quotient */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int rem; /**< remainder */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync} div_t;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/// A structure type that is the type of the value returned by the ldiv function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynctypedef struct {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long quot;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long rem;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync} ldiv_t;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/// A structure type that is the type of the value returned by the lldiv function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynctypedef struct {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long long quot;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync long long rem;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync} lldiv_t;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** @{
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Expand to integer constant expressions that can be used as the argument to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the exit function to return unsuccessful or successful termination status,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync respectively, to the host environment.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define EXIT_FAILURE 1
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define EXIT_SUCCESS 0
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/*@}*/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Expands to an integer constant expression that is the maximum value
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync returned by the rand function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define RAND_MAX 0x7fffffff
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Expands to a positive integer expression with type size_t that is the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync maximum number of bytes in a multibyte character for the extended character
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync set specified by the current locale (category LC_CTYPE), which is never
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync greater than MB_LEN_MAX.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define MB_CUR_MAX 2
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Maximum number of functions that can be registered by atexit.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The C standard states that the implementation shall support the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync registration of at least 32 functions.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define ATEXIT_MAX 32
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync__BEGIN_DECLS
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ################ Communication with the environment ################## */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The abort function causes abnormal program termination to occur, unless
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the signal SIGABRT is being caught and the signal handler does not return.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Open streams with unwritten buffered data are not flushed, open
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync streams are not closed, and temporary files are not removed by abort.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Unsuccessful termination is returned to the host environment by means of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the function call, raise(SIGABRT).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @sa signal.h
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid abort(void) __noreturn;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The atexit function registers the function pointed to by func, to be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync called without arguments at normal program termination.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The implementation supports the registration of up to 32 functions.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Handler Pointer to the function to register as one of the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync routines to call at application exit time.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The atexit function returns zero if the registration succeeds,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync nonzero if it fails.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncint atexit(void (*Handler)(void));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The exit function causes normal program termination to occur. If more than
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync one call to the exit function is executed by a program,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the behavior is undefined.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync First, all functions registered by the atexit function are called, in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync reverse order of their registration, except that a function is called
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync after any previously registered functions that had already been called at
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the time it was registered. If, during the call to any such function, a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync call to the longjmp function is made that would terminate the call to the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync registered function, the behavior is undefined.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Next, all open streams with unwritten buffered data are flushed, all open
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync streams are closed, and all files created by the tmpfile function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync are removed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Finally, control is returned to the host environment.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] status A value to be returned when the application exits.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return If the value of status is zero, or EXIT_SUCCESS, status is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync returned unchanged. If the value of status is EXIT_FAILURE,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RETURN_ABORTED is returned. Otherwise, status is returned unchanged.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid exit(int status) __noreturn;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The _Exit function causes normal program termination to occur and control
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to be returned to the host environment.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync No functions registered by the atexit function or signal handlers
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync registered by the signal function are called. Open streams with unwritten
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync buffered data are not flushed, open streams are not closed, and temporary
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync files are not removed by abort.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The status returned to the host environment is determined in the same way
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync as for the exit function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] status A value to be returned when the application exits.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return If the value of status is zero, or EXIT_SUCCESS, status is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync returned unchanged. If the value of status is EXIT_FAILURE,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RETURN_ABORTED is returned. Otherwise, status is returned unchanged.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid _Exit(int status) __noreturn;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The getenv function searches an environment list, provided by the host
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync environment, for a string that matches the string pointed to by name. The
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync set of environment names and the method for altering the environment list
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync are determined by the underlying UEFI Shell implementation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] name Pointer to a string naming the environment variable to retrieve.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The getenv function returns a pointer to a string associated with
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the matched list member. The string pointed to shall not be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync modified by the program, but may be overwritten by a subsequent
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync call to the getenv function. If the specified name cannot be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync found, a null pointer is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncchar *getenv(const char *name);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Add or update a variable in the environment list.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] name Address of a zero terminated name string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] value Address of a zero terminated value string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] rewrite TRUE allows overwriting existing values.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval 0 Returns 0 upon success.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval -1 Returns -1 upon failure, sets errno with more information.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncint
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncsetenv (
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync register const char * name,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync register const char * value,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int rewrite
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync );
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** If string is a null pointer, the system function determines whether the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync host environment has a command processor. If string is not a null pointer,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the system function passes the string pointed to by string to that command
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync processor to be executed in a manner which the implementation shall
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync document; this might then cause the program calling system to behave in a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync non-conforming manner or to terminate.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] string Pointer to the command string to be executed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return If the argument is a null pointer, the system function returns
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync nonzero only if a command processor is available. If the argument
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is not a null pointer, and the system function does return, it
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync returns an implementation-defined value.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncint system(const char *string);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ################ Integer arithmetic functions ######################## */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Computes the absolute value of an integer j.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] j The value to find the absolute value of.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The absolute value of j.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncint abs(int j);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Computes the absolute value of a long integer j.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] j The value to find the absolute value of.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The absolute value of j.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynclong labs(long j);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Computes the absolute value of a long long integer j.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] j The value to find the absolute value of.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The absolute value of j.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynclong long
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync llabs(long long j);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Computes numer / denom and numer % denom in a single operation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] numer The numerator for the division.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] denom The denominator for the division.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return Returns a structure of type div_t, comprising both the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync quotient and the remainder.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncdiv_t div(int numer, int denom);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Computes numer / denom and numer % denom in a single operation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] numer The numerator for the division.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] denom The denominator for the division.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return Returns a structure of type ldiv_t, comprising both the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync quotient and the remainder.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncldiv_t ldiv(long numer, long denom);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Computes numer / denom and numer % denom in a single operation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] numer The numerator for the division.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] denom The denominator for the division.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return Returns a structure of type lldiv_t, comprising both the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync quotient and the remainder.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynclldiv_t lldiv(long long numer, long long denom);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ############ Integer Numeric conversion functions #################### */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The atoi function converts the initial portion of the string pointed to by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync nptr to int representation. Except for the behavior on error, it is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync equivalent to:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - atoi: (int)strtol(nptr, (char **)NULL, 10)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The atoi function returns the converted value.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncint atoi(const char *nptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The atol function converts the initial portion of the string pointed to by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync nptr to long int representation. Except for the behavior on error, it is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync equivalent to:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - atol: strtol(nptr, (char **)NULL, 10)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The atol function returns the converted value.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynclong atol(const char *nptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The atoll function converts the initial portion of the string pointed to by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync nptr to long long int representation. Except for the behavior on error, it
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is equivalent to:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - atoll: strtoll(nptr, (char **)NULL, 10)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The atoll function returns the converted value.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynclong long
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync atoll(const char *nptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The strtol, strtoll, strtoul, and strtoull functions convert the initial
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync portion of the string pointed to by nptr to long int, long long int,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync unsigned long int, and unsigned long long int representation, respectively.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync First, they decompose the input string into three parts: an initial,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync possibly empty, sequence of white-space characters (as specified by the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync isspace function), a subject sequence resembling an integer represented in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync some radix determined by the value of base, and a final string of one or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync more unrecognized characters, including the terminating null character of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the input string. Then, they attempt to convert the subject sequence to an
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync integer, and return the result.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the value of base is zero, the expected form of the subject sequence is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync that of an integer constant, optionally preceded
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync by a plus or minus sign, but not including an integer suffix. If the value
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of base is between 2 and 36 (inclusive), the expected form of the subject
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync sequence is a sequence of letters and digits representing an integer with
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the radix specified by base, optionally preceded by a plus or minus sign,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync but not including an integer suffix. The letters from a (or A) through z
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (or Z) are ascribed the values 10 through 35; only letters and digits whose
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ascribed values are less than that of base are permitted. If the value of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync base is 16, the characters 0x or 0X may optionally precede the sequence of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync letters and digits, following the sign if present.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The subject sequence is defined as the longest initial subsequence of the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync input string, starting with the first non-white-space character, that is of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the expected form. The subject sequence contains no characters if the input
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync string is empty or consists entirely of white space, or if the first
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync non-white-space character is other than a sign or a permissible letter or digit.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the subject sequence has the expected form and the value of base is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync zero, the sequence of characters starting with the first digit is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync interpreted as an integer constant. If the subject sequence has the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync expected form and the value of base is between 2 and 36, it is used as the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync base for conversion, ascribing to each letter its value as given above. If
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the subject sequence begins with a minus sign, the value resulting from the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync conversion is negated (in the return type). A pointer to the final string
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is stored in the object pointed to by endptr, provided that endptr is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync not a null pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync In other than the "C" locale, additional locale-specific subject sequence
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync forms may be accepted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the subject sequence is empty or does not have the expected form, no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync conversion is performed; the value of nptr is stored in the object pointed
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to by endptr, provided that endptr is not a null pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] base The base, 0 to 36, of the number represented by the input string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The strtol, strtoll, strtoul, and strtoull functions return the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync converted value, if any. If no conversion could be performed, zero
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is returned. If the correct value is outside the range of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync representable values, LONG_MIN, LONG_MAX, LLONG_MIN, LLONG_MAX,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ULONG_MAX, or ULLONG_MAX is returned (according to the return type
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and sign of the value, if any), and the value of the macro ERANGE
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is stored in errno.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynclong strtol(const char * __restrict nptr, char ** __restrict endptr, int base);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The strtoul function converts the initial portion of the string pointed to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync by nptr to unsigned long int representation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync See the description for strtol for more information.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] base The base, 0 to 36, of the number represented by the input string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The strtoul function returns the converted value, if any. If no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync conversion could be performed, zero is returned. If the correct
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync value is outside the range of representable values, ULONG_MAX is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync returned and the value of the macro ERANGE is stored in errno.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncunsigned long
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync strtoul(const char * __restrict nptr, char ** __restrict endptr, int base);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The strtoll function converts the initial portion of the string pointed to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync by nptr to long long int representation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync See the description for strtol for more information.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] base The base, 0 to 36, of the number represented by the input string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The strtoll function returns the converted value, if any. If no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync conversion could be performed, zero is returned. If the correct
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync value is outside the range of representable values, LLONG_MIN or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync LLONG_MAX is returned (according to the sign of the value, if any),
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and the value of the macro ERANGE is stored in errno.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynclong long
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync strtoll(const char * __restrict nptr, char ** __restrict endptr, int base);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The strtoull function converts the initial portion of the string pointed to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync by nptr to unsigned long long int representation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync See the description for strtol for more information.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] base The base, 0 to 36, of the number represented by the input string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The strtoull function returns the converted value, if any. If no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync conversion could be performed, zero is returned. If the correct
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync value is outside the range of representable values, ULLONG_MAX is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync returned and the value of the macro ERANGE is stored in errno.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncunsigned long long
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync strtoull(const char * __restrict nptr, char ** __restrict endptr, int base);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ######### Floating-point Numeric conversion functions ################ */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Convert the initial part of a string to double representation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The floating-point value representing the string nptr.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncdouble atof(const char *nptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** @{
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The strtod, strtof, and strtold functions convert the initial portion of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the string pointed to by nptr to double, float, and long double
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync representation, respectively. First, they decompose the input string into
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync three parts: an initial, possibly empty, sequence of white-space characters
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (as specified by the isspace function), a subject sequence resembling a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync floating-point constant or representing an infinity or NaN; and a final
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync string of one or more unrecognized characters, including the terminating
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync null character of the input string. Then, they attempt to convert the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync subject sequence to a floating-point number, and return the result.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync*/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Convert a string to a double and point to the character after the last converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return A floating-point value representing the string nptr.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync A pointer to the final string is stored in the object pointed to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync by endptr, provided that endptr is not a null pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the subject sequence is empty or does not have the expected
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync form, no conversion is performed; the value of nptr is stored in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the object pointed to by endptr, provided that endptr is not a null pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncdouble strtod(const char * __restrict nptr, char ** __restrict endptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Convert a string to a float and point to the character after the last converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return A floating-point value representing the string nptr.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync A pointer to the final string is stored in the object pointed to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync by endptr, provided that endptr is not a null pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the subject sequence is empty or does not have the expected
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync form, no conversion is performed; the value of nptr is stored in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the object pointed to by endptr, provided that endptr is not a null pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncfloat strtof(const char * __restrict nptr, char ** __restrict endptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Convert a string to a long double and point to the character after the last converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] nptr Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] endptr If not NULL, points to an object to receive a pointer to the final string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return A floating-point value representing the string nptr.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync A pointer to the final string is stored in the object pointed to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync by endptr, provided that endptr is not a null pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the subject sequence is empty or does not have the expected
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync form, no conversion is performed; the value of nptr is stored in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the object pointed to by endptr, provided that endptr is not a null pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynclong double
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync strtold(const char * __restrict nptr, char ** __restrict endptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/*@}*/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ################ Pseudo-random sequence generation functions ######### */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The rand function computes a sequence of pseudo-random integers in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync range 0 to RAND_MAX.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The rand function returns a pseudo-random integer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncint rand(void);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The srand function uses the argument as a seed for a new sequence of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync pseudo-random numbers to be returned by subsequent calls to rand.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If srand is then called with the same seed value, the sequence of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync pseudo-random numbers shall be repeated. If rand is called before any calls
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to srand have been made, the same sequence shall be generated as when srand
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is first called with a seed value of 1.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] seed The value used to "seed" the random number generator with.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid srand(unsigned seed);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ################ Memory management functions ######################### */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The calloc function allocates space for an array of Num objects, each of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync whose size is Size. The space is initialized to all bits zero.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Num The number of objects to allocate space for.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Size The size, in bytes, of each object.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return NULL is returned if the space could not be allocated and errno
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync contains the cause. Otherwise, a pointer to an 8-byte aligned
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync region of the requested size is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid *calloc(size_t Num, size_t Size);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The free function causes the space pointed to by Ptr to be deallocated,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync that is, made available for further allocation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If Ptr is a null pointer, no action occurs. Otherwise, if the argument
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync does not match a pointer earlier returned by the calloc, malloc, or realloc
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function, or if the space has been deallocated by a call to free or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync realloc, the behavior is undefined.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Ptr Pointer to a previously allocated region of memory to be freed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid free(void *Ptr);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The malloc function allocates space for an object whose size is specified
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync by size and whose value is indeterminate.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This implementation uses the UEFI memory allocation boot services to get a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync region of memory that is 8-byte aligned and of the specified size. The
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync region is allocated with type EfiLoaderData.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Size Size, in bytes, of the region to allocate.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return NULL is returned if the space could not be allocated and errno
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync contains the cause. Otherwise, a pointer to an 8-byte aligned
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync region of the requested size is returned.<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If NULL is returned, errno may contain:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - EINVAL: Requested Size is zero.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - ENOMEM: Memory could not be allocated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid *malloc(size_t Size);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The realloc function changes the size of the object pointed to by Ptr to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the size specified by NewSize.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The contents of the object are unchanged up to the lesser of the new and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync old sizes. If the new size is larger, the value of the newly allocated
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync portion of the object is indeterminate.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If Ptr is a null pointer, the realloc function behaves like the malloc
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function for the specified size.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If Ptr does not match a pointer earlier returned by the calloc, malloc, or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync realloc function, or if the space has been deallocated by a call to the free
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync or realloc function, the behavior is undefined.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the space cannot be allocated, the object pointed to by Ptr is unchanged.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If NewSize is zero and Ptr is not a null pointer, the object it points to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is freed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This implementation uses the UEFI memory allocation boot services to get a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync region of memory that is 8-byte aligned and of the specified size. The
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync region is allocated with type EfiLoaderData.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Ptr Pointer to a previously allocated region of memory to be resized.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param NewSize Size, in bytes, of the new object to allocate space for.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return NULL is returned if the space could not be allocated and errno
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync contains the cause. Otherwise, a pointer to an 8-byte aligned
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync region of the requested size is returned. If NewSize is zero,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync NULL is returned and errno will be unchanged.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid *realloc(void *Ptr, size_t NewSize);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ################ Searching and Sorting utilities ##################### */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The bsearch function searches an array of Nmemb objects, the initial
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync element of which is pointed to by Base, for an element that matches the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync object pointed to by Key. The size of each element of the array is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync specified by Size.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The comparison function pointed to by Compar is called with two arguments
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync that point to the Key object and to an array element, in that order. The
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function returns an integer less than, equal to, or greater than zero if
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the Key object is considered, respectively, to be less than, to match, or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to be greater than the array element. The array consists of: all the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync elements that compare less than, all the elements that compare equal to,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and all the elements that compare greater than the key object,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync in that order.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Key Pointer to the object to search for.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Base Pointer to the first element of an array to search.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Nmemb Number of objects in the search array.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Size The size of each object in the search array.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Compar Pointer to the function used to compare two objects.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The bsearch function returns a pointer to a matching element of the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync array, or a null pointer if no match is found. If two elements
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync compare as equal, which element is matched is unspecified.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid *bsearch( const void *Key, const void *Base,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync size_t Nmemb, size_t Size,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int (*Compar)(const void *, const void *)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync );
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The qsort function sorts an array of Nmemb objects, the initial element of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync which is pointed to by Base. The size of each object is specified by Size.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The contents of the array are sorted into ascending order according to a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync comparison function pointed to by Compar, which is called with two
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync arguments that point to the objects being compared. The function shall
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync return an integer less than, equal to, or greater than zero if the first
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync argument is considered to be respectively less than, equal to, or greater
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync than the second.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If two elements compare as equal, their order in the resulting sorted array
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is unspecified.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in,out] Base Pointer to the first element of an array to sort.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Nmemb Number of objects in the array.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Size The size of each object in the array.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Compar Pointer to the function used to compare two objects.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid qsort( void *base, size_t nmemb, size_t size,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync int (*compar)(const void *, const void *));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ################ Multibyte/wide character conversion functions ####### */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Determine the number of bytes comprising a multibyte character.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If S is not a null pointer, the mblen function determines the number of bytes
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync contained in the multibyte character pointed to by S. Except that the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync conversion state of the mbtowc function is not affected, it is equivalent to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync mbtowc((wchar_t *)0, S, N);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] S NULL to query whether multibyte characters have
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync state-dependent encodings. Otherwise, points to a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync multibyte character.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] N The maximum number of bytes in a multibyte character.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return If S is a null pointer, the mblen function returns a nonzero or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync zero value, if multibyte character encodings, respectively, do
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync or do not have state-dependent encodings. If S is not a null
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync pointer, the mblen function either returns 0 (if S points to the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync null character), or returns the number of bytes that are contained
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync in the multibyte character (if the next N or fewer bytes form a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync valid multibyte character), or returns -1 (if they do not form a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync valid multibyte character).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncint mblen(const char *S, size_t N);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Convert a multibyte character into a wide character.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If S is not a null pointer, the mbtowc function inspects at most N bytes
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync beginning with the byte pointed to by S to determine the number of bytes
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync needed to complete the next multibyte character (including any shift
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync sequences). If the function determines that the next multibyte character
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is complete and valid, it determines the value of the corresponding wide
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync character and then, if Pwc is not a null pointer, stores that value in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the object pointed to by Pwc. If the corresponding wide character is the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync null wide character, the function is left in the initial conversion state.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] Pwc Pointer to a wide-character object to receive the converted character.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] S Pointer to a multibyte character to convert.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] N Maximum number of bytes in a multibyte character.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return If S is a null pointer, the mbtowc function returns a nonzero or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync zero value, if multibyte character encodings, respectively, do
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync or do not have state-dependent encodings. If S is not a null
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync pointer, the mbtowc function either returns 0 (if S points to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the null character), or returns the number of bytes that are
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync contained in the converted multibyte character (if the next N or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync fewer bytes form a valid multibyte character), or returns -1
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (if they do not form a valid multibyte character).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync In no case will the value returned be greater than N or the value
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of the MB_CUR_MAX macro.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncint mbtowc(wchar_t * __restrict Pwc, const char * __restrict S, size_t N);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Convert a wide character into a multibyte character.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The wctomb function determines the number of bytes needed to represent the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync multibyte character corresponding to the wide character given by WC
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (including any shift sequences), and stores the multibyte character
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync representation in the array whose first element is pointed to by S (if S is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync not a null pointer). At most MB_CUR_MAX characters are stored. If WC is a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync null wide character, a null byte is stored, preceded by any shift sequence
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync needed to restore the initial shift state, and the function is left in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync initial conversion state.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] S Pointer to the object to receive the converted multibyte character.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] WC Wide character to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return If S is a null pointer, the wctomb function returns a nonzero or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync zero value, if multibyte character encodings, respectively, do or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync do not have state-dependent encodings. If S is not a null pointer,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the wctomb function returns -1 if the value of WC does not
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync correspond to a valid multibyte character, or returns the number
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of bytes that are contained in the multibyte character
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync corresponding to the value of WC.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync In no case will the value returned be greater than the value of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the MB_CUR_MAX macro.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncint wctomb(char *S, wchar_t WC);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ################ Multibyte/wide string conversion functions ########## */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Convert a multibyte character string into a wide-character string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The mbstowcs function converts a sequence of multibyte characters that
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync begins in the initial shift state from the array pointed to by Src into
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync a sequence of corresponding wide characters and stores not more than limit
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync wide characters into the array pointed to by Dest. No multibyte
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync characters that follow a null character (which is converted into a null
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync wide character) will be examined or converted. Each multibyte character
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is converted as if by a call to the mbtowc function, except that the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync conversion state of the mbtowc function is not affected.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync No more than Limit elements will be modified in the array pointed to by Dest.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If copying takes place between objects that overlap,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the behavior is undefined.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] Dest Pointer to the array to receive the converted string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Src Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Limit Maximum number of elements to be written to Dest.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return If an invalid multibyte character is encountered, the mbstowcs
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function returns (size_t)(-1). Otherwise, the mbstowcs function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync returns the number of array elements modified, not including a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync terminating null wide character, if any.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncsize_t mbstowcs(wchar_t * __restrict Dest, const char * __restrict Src, size_t Limit);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** Convert a wide-character string into a multibyte character string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The wcstombs function converts a sequence of wide characters from the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync array pointed to by Src into a sequence of corresponding multibyte
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync characters that begins in the initial shift state, and stores these
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync multibyte characters into the array pointed to by Dest, stopping if a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync multibyte character would exceed the limit of Limit total bytes or if a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync null character is stored. Each wide character is converted as if by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync a call to the wctomb function, except that the conversion state of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the wctomb function is not affected.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync No more than Limit bytes will be modified in the array pointed to by Dest.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If copying takes place between objects that overlap,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the behavior is undefined.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] Dest Pointer to the array to receive the converted string.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Src Pointer to the string to be converted.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Limit Maximum number of elements to be written to Dest.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return If a wide character is encountered that does not correspond to a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync valid multibyte character, the wcstombs function returns
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (size_t)(-1). Otherwise, the wcstombs function returns the number
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of bytes modified, not including a terminating null character,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if any.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncsize_t wcstombs(char * __restrict Dest, const wchar_t * __restrict Src, size_t Limit);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/* ################ Miscelaneous functions for *nix compatibility ########## */
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The realpath() function shall derive, from the pathname pointed to by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync file_name, an absolute pathname that names the same file, whose resolution
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync does not involve '.', '..', or symbolic links. The generated pathname shall
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync be stored as a null-terminated string, up to a maximum of {PATH_MAX} bytes,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync in the buffer pointed to by resolved_name.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If resolved_name is a null pointer, the behavior of realpath() is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync implementation-defined.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] file_name The filename to convert.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in,out] resolved_name The resultant name.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval NULL An error occured.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval resolved_name.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncchar * realpath(char *file_name, char *resolved_name);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The getprogname() function returns the name of the program. If the name
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync has not been set yet, it will return NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return The getprogname function returns NULL if the program's name has not
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync been set, otherwise it returns the name of the program.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncconst char * getprogname(void);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** The setprogname() function sets the name of the program.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] progname The name of the program. This memory must be retained
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync by the caller until no calls to "getprogname" will be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync called.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncvoid setprogname(const char *progname);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync__END_DECLS
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#endif /* _STDLIB_H */