mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-08-04 02:06:31 -04:00
lib: make freestanding memset() et al. symbols "weak"
This allows these symbols to be overridden by another definition of these symbols somewhere else in the binary. Resolves https://github.com/ebiggers/libdeflate/issues/107
This commit is contained in:
parent
e2f9d07050
commit
4a0bb736c9
12
lib/utils.c
12
lib/utils.c
@ -85,7 +85,8 @@ libdeflate_set_memory_allocator(void *(*malloc_func)(size_t),
|
|||||||
*/
|
*/
|
||||||
#ifdef FREESTANDING
|
#ifdef FREESTANDING
|
||||||
#undef memset
|
#undef memset
|
||||||
void *memset(void *s, int c, size_t n)
|
void * __attribute__((weak))
|
||||||
|
memset(void *s, int c, size_t n)
|
||||||
{
|
{
|
||||||
u8 *p = s;
|
u8 *p = s;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -96,7 +97,8 @@ void *memset(void *s, int c, size_t n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#undef memcpy
|
#undef memcpy
|
||||||
void *memcpy(void *dest, const void *src, size_t n)
|
void * __attribute__((weak))
|
||||||
|
memcpy(void *dest, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
u8 *d = dest;
|
u8 *d = dest;
|
||||||
const u8 *s = src;
|
const u8 *s = src;
|
||||||
@ -108,7 +110,8 @@ void *memcpy(void *dest, const void *src, size_t n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#undef memmove
|
#undef memmove
|
||||||
void *memmove(void *dest, const void *src, size_t n)
|
void * __attribute__((weak))
|
||||||
|
memmove(void *dest, const void *src, size_t n)
|
||||||
{
|
{
|
||||||
u8 *d = dest;
|
u8 *d = dest;
|
||||||
const u8 *s = src;
|
const u8 *s = src;
|
||||||
@ -123,7 +126,8 @@ void *memmove(void *dest, const void *src, size_t n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#undef memcmp
|
#undef memcmp
|
||||||
int memcmp(const void *s1, const void *s2, size_t n)
|
int __attribute__((weak))
|
||||||
|
memcmp(const void *s1, const void *s2, size_t n)
|
||||||
{
|
{
|
||||||
const u8 *p1 = s1;
|
const u8 *p1 = s1;
|
||||||
const u8 *p2 = s2;
|
const u8 *p2 = s2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user