ref(libterm): now apple-styled too
This commit is contained in:
+11
-11
@@ -46,7 +46,7 @@ void __stdio_cleanup(void)
|
||||
BS->FreePool(__argvutf8);
|
||||
#endif
|
||||
if(__blk_devs) {
|
||||
free(__blk_devs);
|
||||
MemoryFree(__blk_devs);
|
||||
__blk_devs = NULL;
|
||||
__blk_ndevs = 0;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ int fclose (FILE *__stream)
|
||||
if(__stream == (FILE*)__blk_devs[i].bio)
|
||||
return 1;
|
||||
status = __stream->Close(__stream);
|
||||
free(__stream);
|
||||
MemoryFree(__stream);
|
||||
return !EFI_ERROR(status);
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ err: __stdio_seterrno(status);
|
||||
return -1;
|
||||
}
|
||||
/* no need for fclose(f); */
|
||||
free(f);
|
||||
MemoryFree(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ FILE *fopen (const char_t *__filename, const char_t *__modes)
|
||||
/* workaround a bug in TianoCore, it reports zero size even though the data is in the buffer */
|
||||
if(handle_size < 1)
|
||||
handle_size = (uintn_t)sizeof(handles) / sizeof(efi_handle_t);
|
||||
__blk_devs = (block_file_t*)malloc(handle_size * sizeof(block_file_t));
|
||||
__blk_devs = (block_file_t*)MemoryAllocate(handle_size * sizeof(block_file_t));
|
||||
if(__blk_devs) {
|
||||
memset(__blk_devs, 0, handle_size * sizeof(block_file_t));
|
||||
for(i = __blk_ndevs = 0; i < handle_size; i++)
|
||||
@@ -276,7 +276,7 @@ FILE *fopen (const char_t *__filename, const char_t *__modes)
|
||||
errno = ENODEV;
|
||||
return NULL;
|
||||
}
|
||||
ret = (FILE*)malloc(sizeof(FILE));
|
||||
ret = (FILE*)MemoryAllocate(sizeof(FILE));
|
||||
if(!ret) return NULL;
|
||||
/* normally write means read,write,create. But for remove (internal '*' mode), we need read,write without create
|
||||
* also mode 'w' in POSIX means write-only (without read), but that's not working on certain firmware, we must
|
||||
@@ -292,16 +292,16 @@ FILE *fopen (const char_t *__filename, const char_t *__modes)
|
||||
__modes[1] == CL('d') ? EFI_FILE_DIRECTORY : 0);
|
||||
if(EFI_ERROR(status)) {
|
||||
err: __stdio_seterrno(status);
|
||||
free(ret); return NULL;
|
||||
MemoryFree(ret); return NULL;
|
||||
}
|
||||
if(__modes[0] == CL('*')) return ret;
|
||||
status = ret->GetInfo(ret, &infGuid, &fsiz, &info);
|
||||
if(EFI_ERROR(status)) goto err;
|
||||
if(__modes[1] == CL('d') && !(info.Attribute & EFI_FILE_DIRECTORY)) {
|
||||
ret->Close(ret); free(ret); errno = ENOTDIR; return NULL;
|
||||
ret->Close(ret); MemoryFree(ret); errno = ENOTDIR; return NULL;
|
||||
}
|
||||
if(__modes[1] != CL('d') && (info.Attribute & EFI_FILE_DIRECTORY)) {
|
||||
ret->Close(ret); free(ret); errno = EISDIR; return NULL;
|
||||
ret->Close(ret); MemoryFree(ret); errno = EISDIR; return NULL;
|
||||
}
|
||||
if(__modes[0] == CL('a')) fseek(ret, 0, SEEK_END);
|
||||
if(__modes[0] == CL('w')) {
|
||||
@@ -713,7 +713,7 @@ int sprintf(char_t *dst, const char_t* fmt, ...)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int snprintf(char_t *dst, size_t maxlen, const char_t* fmt, ...)
|
||||
int StringFormat(char_t *dst, size_t maxlen, const char_t* fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
__builtin_va_list args;
|
||||
@@ -738,7 +738,7 @@ int vprintf(const char_t* fmt, __builtin_va_list args)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int printf(const char_t* fmt, ...)
|
||||
int ConsolePrint(const char_t* fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
__builtin_va_list args;
|
||||
@@ -800,7 +800,7 @@ int getchar_ifany (void)
|
||||
return EFI_ERROR(status) ? 0 : key.UnicodeChar;
|
||||
}
|
||||
|
||||
int getchar (void)
|
||||
int ConsoleGetCharacter (void)
|
||||
{
|
||||
uintn_t idx;
|
||||
BS->WaitForEvent(1, &ST->ConIn->WaitForKey, &idx);
|
||||
|
||||
@@ -77,7 +77,7 @@ int64_t strtol (const char_t *s, char_t **__endptr, int __base)
|
||||
return v * sign;
|
||||
}
|
||||
|
||||
void *malloc (size_t __size)
|
||||
void *MemoryAllocate (size_t __size)
|
||||
{
|
||||
void *ret = NULL;
|
||||
efi_status_t status;
|
||||
@@ -106,20 +106,20 @@ void *malloc (size_t __size)
|
||||
|
||||
void *calloc (size_t __nmemb, size_t __size)
|
||||
{
|
||||
void *ret = malloc(__nmemb * __size);
|
||||
void *ret = MemoryAllocate(__nmemb * __size);
|
||||
if(ret) memset(ret, 0, __nmemb * __size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *realloc (void *__ptr, size_t __size)
|
||||
void *MemoryReallocate (void *__ptr, size_t __size)
|
||||
{
|
||||
void *ret = NULL;
|
||||
efi_status_t status;
|
||||
#ifndef UEFI_NO_TRACK_ALLOC
|
||||
uintn_t i;
|
||||
#endif
|
||||
if(!__ptr) return malloc(__size);
|
||||
if(!__size) { free(__ptr); return NULL; }
|
||||
if(!__ptr) return MemoryAllocate(__size);
|
||||
if(!__size) { MemoryFree(__ptr); return NULL; }
|
||||
#ifndef UEFI_NO_TRACK_ALLOC
|
||||
/* get the slot which stores the old size for this buffer */
|
||||
for(i = 0; i < __stdlib_numallocs && __stdlib_allocs[i] != (uintptr_t)__ptr; i += 2);
|
||||
@@ -145,7 +145,7 @@ void *realloc (void *__ptr, size_t __size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void free (void *__ptr)
|
||||
void MemoryFree (void *__ptr)
|
||||
{
|
||||
efi_status_t status;
|
||||
#ifndef UEFI_NO_TRACK_ALLOC
|
||||
@@ -341,7 +341,7 @@ uint8_t *getenv(char_t *name, uintn_t *len)
|
||||
#else
|
||||
status = RT->GetVariable(name, &globGuid, &attr, len, &tmp);
|
||||
#endif
|
||||
if(EFI_ERROR(status) || *len < 1 || !(ret = malloc((*len) + 1))) {
|
||||
if(EFI_ERROR(status) || *len < 1 || !(ret = MemoryAllocate((*len) + 1))) {
|
||||
*len = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ void *memrmem(const void *haystack, size_t hl, const void *needle, size_t nl)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char_t *strcpy(char_t *dst, const char_t *src)
|
||||
char_t *StringCopy(char_t *dst, const char_t *src)
|
||||
{
|
||||
char_t *s = dst;
|
||||
if(src && dst && src != dst) {
|
||||
@@ -178,7 +178,7 @@ int strncmp(const char_t *s1, const char_t *s2, size_t n)
|
||||
char_t *strdup(const char_t *s)
|
||||
{
|
||||
size_t i = (strlen(s)+1) * sizeof(char_t);
|
||||
char_t *s2 = (char_t *)malloc(i);
|
||||
char_t *s2 = (char_t *)MemoryAllocate(i);
|
||||
if(s2 != NULL) memcpy(s2, (const void*)s, i);
|
||||
return s2;
|
||||
}
|
||||
|
||||
@@ -1314,10 +1314,10 @@ typedef int (*__compar_fn_t) (const void *, const void *);
|
||||
extern int atoi (const char_t *__nptr);
|
||||
extern int64_t atol (const char_t *__nptr);
|
||||
extern int64_t strtol (const char_t *__nptr, char_t **__endptr, int __base);
|
||||
extern void *malloc (size_t __size);
|
||||
extern void *MemoryAllocate (size_t __size);
|
||||
extern void *calloc (size_t __nmemb, size_t __size);
|
||||
extern void *realloc (void *__ptr, size_t __size);
|
||||
extern void free (void *__ptr);
|
||||
extern void *MemoryReallocate (void *__ptr, size_t __size);
|
||||
extern void MemoryFree (void *__ptr);
|
||||
extern void abort (void);
|
||||
extern void exit (int __status);
|
||||
/* exit Boot Services function. Returns 0 on success. */
|
||||
@@ -1355,14 +1355,14 @@ extern int fseek (FILE *__stream, long int __off, int __whence);
|
||||
extern long int ftell (FILE *__stream);
|
||||
extern int feof (FILE *__stream);
|
||||
extern int fprintf (FILE *__stream, const char_t *__format, ...);
|
||||
extern int printf (const char_t *__format, ...);
|
||||
extern int ConsolePrint (const char_t *__format, ...);
|
||||
extern int sprintf (char_t *__s, const char_t *__format, ...);
|
||||
extern int vfprintf (FILE *__s, const char_t *__format, __builtin_va_list __arg);
|
||||
extern int vprintf (const char_t *__format, __builtin_va_list __arg);
|
||||
extern int vsprintf (char_t *__s, const char_t *__format, __builtin_va_list __arg);
|
||||
extern int snprintf (char_t *__s, size_t __maxlen, const char_t *__format, ...);
|
||||
extern int StringFormat (char_t *__s, size_t __maxlen, const char_t *__format, ...);
|
||||
extern int vsnprintf (char_t *__s, size_t __maxlen, const char_t *__format, __builtin_va_list __arg);
|
||||
extern int getchar (void);
|
||||
extern int ConsoleGetCharacter (void);
|
||||
/* non-blocking, only returns UNICODE if there's any key pressed, 0 otherwise */
|
||||
extern int getchar_ifany (void);
|
||||
extern int putchar (int __c);
|
||||
@@ -1376,7 +1376,7 @@ extern void *memchr(const void *__s, int __c, size_t __n);
|
||||
extern void *memrchr(const void *__s, int __c, size_t __n);
|
||||
void *memmem(const void *haystack, size_t hl, const void *needle, size_t nl);
|
||||
void *memrmem(const void *haystack, size_t hl, const void *needle, size_t nl);
|
||||
extern char_t *strcpy (char_t *__dest, const char_t *__src);
|
||||
extern char_t *StringCopy (char_t *__dest, const char_t *__src);
|
||||
extern char_t *strncpy (char_t *__dest, const char_t *__src, size_t __n);
|
||||
extern char_t *strcat (char_t *__dest, const char_t *__src);
|
||||
extern char_t *strncat (char_t *__dest, const char_t *__src, size_t __n);
|
||||
|
||||
Reference in New Issue
Block a user