Fix codecs in simulator builds on Windows

The mingw linker uses strlen() in some cases, and codeclib.c redefines it, that
leads to mingw runtime init to call into our strlen() and then ci->strlen() which
of course crashes. Apply the same fix as for malloc and friends: rename the symbol.

The codeclib.h include is necessary for normal builds.

Change-Id: Ifa85901a3e4a31cc0e10b4b905df348a239d5c99
This commit is contained in:
Amaury Pouly 2017-01-15 17:53:56 +01:00
parent d984725cbf
commit 16d1788356
3 changed files with 5 additions and 2 deletions

View file

@ -100,7 +100,8 @@ void* codec_realloc(void* ptr, size_t size)
return(x);
}
size_t strlen(const char *s)
#undef strlen
size_t codec_strlen(const char *s)
{
return(ci->strlen(s));
}

View file

@ -40,6 +40,7 @@ extern struct codec_api *ci;
#define free(x) codec_free(x)
#undef alloca
#define alloca(x) __builtin_alloca(x)
#define strlen(s) codec_strlen(s)
void* codec_malloc(size_t size);
void* codec_calloc(size_t nmemb, size_t size);
@ -51,7 +52,7 @@ void *memset(void *s, int c, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
void *memmove(void *s1, const void *s2, size_t n);
size_t strlen(const char *s);
size_t codec_strlen(const char *s);
char *strcpy(char *dest, const char *src);
char *strcat(char *dest, const char *src);

View file

@ -21,6 +21,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "codeclib.h"
#include "asap_internal.h"
static byte s_memory[65536];