mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-01-15 19:51:45 +01:00
some conflicts
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
commit
6dcc9b30ba
@ -4,12 +4,15 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#ifdef MAP_TO_EDK_STRLEN
|
#ifdef MAP_TO_EDK_STRLEN
|
||||||
extern "C" UINTN EFIAPI AsciiStrLen (IN CONST CHAR8 *String);
|
extern "C" UINTN EFIAPI AsciiStrLen (IN CONST CHAR8 *String);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Hope that unsigned long long is as big in bits sa a pointer difference.
|
||||||
|
|
||||||
|
#define DOWN_CAST_TO_SIZE_T(a) ( (ptrdiff_t)(a) > (ptrdiff_t)(SIZE_T_MAX) ? abort(), 0 : (size_t)(a) )
|
||||||
|
|
||||||
/* Return the length of the null-terminated string STR. Scan for
|
/* Return the length of the null-terminated string STR. Scan for
|
||||||
the null terminator quickly by testing four bytes at a time. */
|
the null terminator quickly by testing four bytes at a time. */
|
||||||
size_t strlen (const char *str)
|
size_t strlen (const char *str)
|
||||||
@ -28,8 +31,7 @@ size_t strlen (const char *str)
|
|||||||
& (sizeof (longword) - 1)) != 0;
|
& (sizeof (longword) - 1)) != 0;
|
||||||
++char_ptr)
|
++char_ptr)
|
||||||
if (*char_ptr == '\0') {
|
if (*char_ptr == '\0') {
|
||||||
if ( (size_t)(char_ptr - str) > SIZE_T_MAX ) abort();
|
return DOWN_CAST_TO_SIZE_T(char_ptr - str);
|
||||||
return (size_t)(char_ptr - str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All these elucidatory comments refer to 4-byte longwords,
|
/* All these elucidatory comments refer to 4-byte longwords,
|
||||||
@ -73,23 +75,23 @@ size_t strlen (const char *str)
|
|||||||
const char *cp = (const char *) (longword_ptr - 1);
|
const char *cp = (const char *) (longword_ptr - 1);
|
||||||
|
|
||||||
if (cp[0] == 0)
|
if (cp[0] == 0)
|
||||||
return cp - str;
|
return DOWN_CAST_TO_SIZE_T(cp - str);
|
||||||
if (cp[1] == 0)
|
if (cp[1] == 0)
|
||||||
return cp - str + 1;
|
return DOWN_CAST_TO_SIZE_T(cp - str + 1);
|
||||||
if (cp[2] == 0)
|
if (cp[2] == 0)
|
||||||
return cp - str + 2;
|
return DOWN_CAST_TO_SIZE_T(cp - str + 2);
|
||||||
if (cp[3] == 0)
|
if (cp[3] == 0)
|
||||||
return cp - str + 3;
|
return DOWN_CAST_TO_SIZE_T(cp - str + 3);
|
||||||
if (sizeof (longword) > 4)
|
if (sizeof (longword) > 4)
|
||||||
{
|
{
|
||||||
if (cp[4] == 0)
|
if (cp[4] == 0)
|
||||||
return cp - str + 4;
|
return DOWN_CAST_TO_SIZE_T(cp - str + 4);
|
||||||
if (cp[5] == 0)
|
if (cp[5] == 0)
|
||||||
return cp - str + 5;
|
return DOWN_CAST_TO_SIZE_T(cp - str + 5);
|
||||||
if (cp[6] == 0)
|
if (cp[6] == 0)
|
||||||
return cp - str + 6;
|
return DOWN_CAST_TO_SIZE_T(cp - str + 6);
|
||||||
if (cp[7] == 0)
|
if (cp[7] == 0)
|
||||||
return cp - str + 7;
|
return DOWN_CAST_TO_SIZE_T(cp - str + 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user