From 8088e486eefe79aa82124b54c75f360434d64de6 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 22 Jan 2015 19:06:21 +0100 Subject: [PATCH] strcmp() with optimization level > 1 is broken on Emscripten (!) Trivial workaround that should eventually go to the quirks file until this is fixed in Emscripten. --- test/default/cmptest.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/default/cmptest.h b/test/default/cmptest.h index f9f93d68..13180fbf 100644 --- a/test/default/cmptest.h +++ b/test/default/cmptest.h @@ -26,6 +26,14 @@ # define rand(X) arc4random(X) #endif +#ifdef __EMSCRIPTEN__ +# define strcmp(s1, s2) xstrcmp(s1, s2) +int strcmp(const char *s1, const char *s2) { + while (*s1 == *s2++) { if (*s1++ == 0) return 0; } + return *(unsigned char *) s1 - *(unsigned char *) --s2; +} +#endif + FILE *fp_res; int xmain(void);