Commit 04a6fe6e authored by David Reid's avatar David Reid

Work around some bad code generation by Clang.

parent ea205fb7
......@@ -3914,6 +3914,7 @@ typedef ma_uint16 wchar_t;
#ifdef _MSC_VER
#define MA_INLINE __forceinline
#define MA_NO_INLINE __declspec(noinline)
#elif defined(__GNUC__)
/*
I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
......@@ -3930,13 +3931,17 @@ typedef ma_uint16 wchar_t;
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2)) || defined(__clang__)
#define MA_INLINE MA_GNUC_INLINE_HINT __attribute__((always_inline))
#define MA_NO_INLINE __attribute__((noinline))
#else
#define MA_INLINE MA_GNUC_INLINE_HINT
#define MA_NO_INLINE __attribute__((noinline))
#endif
#elif defined(__WATCOMC__)
#define MA_INLINE __inline
#define MA_NO_INLINE
#else
#define MA_INLINE
#define MA_NO_INLINE
#endif
#if !defined(MA_API)
......@@ -12296,8 +12301,11 @@ Return Values:
34: ERANGE
Not using symbolic constants for errors because I want to avoid #including errno.h
These are marked as no-inline because of some bad code generation by Clang. None of these functions
are used in any performance-critical code within miniaudio.
*/
MA_API int ma_strcpy_s(char* dst, size_t dstSizeInBytes, const char* src)
MA_API MA_NO_INLINE int ma_strcpy_s(char* dst, size_t dstSizeInBytes, const char* src)
{
size_t i;
......@@ -12325,7 +12333,7 @@ MA_API int ma_strcpy_s(char* dst, size_t dstSizeInBytes, const char* src)
return 34;
}
MA_API int ma_wcscpy_s(wchar_t* dst, size_t dstCap, const wchar_t* src)
MA_API MA_NO_INLINE int ma_wcscpy_s(wchar_t* dst, size_t dstCap, const wchar_t* src)
{
size_t i;
......@@ -12354,7 +12362,7 @@ MA_API int ma_wcscpy_s(wchar_t* dst, size_t dstCap, const wchar_t* src)
}
MA_API int ma_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count)
MA_API MA_NO_INLINE int ma_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count)
{
size_t maxcount;
size_t i;
......@@ -12388,7 +12396,7 @@ MA_API int ma_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_
return 34;
}
MA_API int ma_strcat_s(char* dst, size_t dstSizeInBytes, const char* src)
MA_API MA_NO_INLINE int ma_strcat_s(char* dst, size_t dstSizeInBytes, const char* src)
{
char* dstorig;
......@@ -12430,7 +12438,7 @@ MA_API int ma_strcat_s(char* dst, size_t dstSizeInBytes, const char* src)
return 0;
}
MA_API int ma_strncat_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count)
MA_API MA_NO_INLINE int ma_strncat_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count)
{
char* dstorig;
......@@ -12476,7 +12484,7 @@ MA_API int ma_strncat_s(char* dst, size_t dstSizeInBytes, const char* src, size_
return 0;
}
MA_API int ma_itoa_s(int value, char* dst, size_t dstSizeInBytes, int radix)
MA_API MA_NO_INLINE int ma_itoa_s(int value, char* dst, size_t dstSizeInBytes, int radix)
{
int sign;
unsigned int valueU;
......@@ -12545,7 +12553,7 @@ MA_API int ma_itoa_s(int value, char* dst, size_t dstSizeInBytes, int radix)
return 0;
}
MA_API int ma_strcmp(const char* str1, const char* str2)
MA_API MA_NO_INLINE int ma_strcmp(const char* str1, const char* str2)
{
if (str1 == str2) return 0;
......@@ -12568,7 +12576,7 @@ MA_API int ma_strcmp(const char* str1, const char* str2)
return ((unsigned char*)str1)[0] - ((unsigned char*)str2)[0];
}
MA_API int ma_strappend(char* dst, size_t dstSize, const char* srcA, const char* srcB)
MA_API MA_NO_INLINE int ma_strappend(char* dst, size_t dstSize, const char* srcA, const char* srcB)
{
int result;
......@@ -12585,7 +12593,7 @@ MA_API int ma_strappend(char* dst, size_t dstSize, const char* srcA, const char*
return result;
}
MA_API char* ma_copy_string(const char* src, const ma_allocation_callbacks* pAllocationCallbacks)
MA_API MA_NO_INLINE char* ma_copy_string(const char* src, const ma_allocation_callbacks* pAllocationCallbacks)
{
size_t sz;
char* dst;
......@@ -12605,7 +12613,7 @@ MA_API char* ma_copy_string(const char* src, const ma_allocation_callbacks* pAll
return dst;
}
MA_API wchar_t* ma_copy_string_w(const wchar_t* src, const ma_allocation_callbacks* pAllocationCallbacks)
MA_API MA_NO_INLINE wchar_t* ma_copy_string_w(const wchar_t* src, const ma_allocation_callbacks* pAllocationCallbacks)
{
size_t sz = wcslen(src)+1;
wchar_t* dst = (wchar_t*)ma_malloc(sz * sizeof(*dst), pAllocationCallbacks);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment