- Defined mp_thread_local to nothing for Orca platforms (since this requires atomics, which we don't have yet). This allows use to enable bulk-memory without getting clang backend errors about missing tls and atomics.
- Replaced memory copy/fill routines with builtins
This commit is contained in:
parent
98a67cef72
commit
4b491ee94a
|
@ -30,58 +30,22 @@ mem_base_allocator* mem_base_allocator_default()
|
|||
return(&base);
|
||||
}
|
||||
|
||||
|
||||
//TODO: implement malloc/realloc/free/memset/etc here...
|
||||
|
||||
|
||||
void* memset(void* b, int c, size_t n)
|
||||
{
|
||||
for(size_t i = 0; i<n; i++)
|
||||
{
|
||||
((char*)b)[i] = (u8)c;
|
||||
}
|
||||
return(b);
|
||||
return(__builtin_memset(b, c, n));
|
||||
}
|
||||
|
||||
void* memcpy(void *restrict dst, const void *restrict src, size_t n)
|
||||
{
|
||||
for(size_t i = 0; i<n; i++)
|
||||
{
|
||||
((char*)dst)[i] = ((char*)src)[i];
|
||||
}
|
||||
return(dst);
|
||||
return(__builtin_memcpy(dst, src, n));
|
||||
}
|
||||
|
||||
void* memmove(void *dst, const void *src, size_t n)
|
||||
{
|
||||
if(src < dst)
|
||||
{
|
||||
for(size_t i = n-1; i>=0; i--)
|
||||
{
|
||||
((char*)dst)[i] = ((char*)src)[i];
|
||||
}
|
||||
}
|
||||
else if(src > dst)
|
||||
{
|
||||
for(size_t i = 0; i<n; i++)
|
||||
{
|
||||
((char*)dst)[i] = ((char*)src)[i];
|
||||
}
|
||||
}
|
||||
return(dst);
|
||||
return(__builtin_memmove(dst, src, n));
|
||||
}
|
||||
|
||||
int memcmp(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
const unsigned char* c1 = (const unsigned char*)s1;
|
||||
const unsigned char* c2 = (const unsigned char*)s2;
|
||||
|
||||
for(size_t i = 0; i<n; i++)
|
||||
{
|
||||
if(c1[i] != c2[i])
|
||||
{
|
||||
return(c1 - c2);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
return(__builtin_memcmp(s1, s2, n));
|
||||
}
|
||||
|
|
|
@ -86,11 +86,15 @@
|
|||
#else
|
||||
#define MP_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#define mp_thread_local __declspec(thread)
|
||||
|
||||
#elif defined(COMPILER_GCC) || defined(COMPILER_CLANG)
|
||||
#define MP_API
|
||||
#endif
|
||||
|
||||
#if PLATFORM_ORCA
|
||||
#define mp_thread_local // no tls (or threads) for now on wasm orca
|
||||
#elif defined(COMPILER_CL)
|
||||
#define mp_thread_local __declspec(thread)
|
||||
#elif defined(COMPILER_GCC) || defined(COMPILER_CLANG)
|
||||
#define mp_thread_local __thread
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue