From 30190c7cdc82b948da4939faf9f9b5084e6a3cee Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Thu, 25 Apr 2013 22:15:02 +1000 Subject: [PATCH] provide a gcc style alternative to the inline asm in zlib --- codemp/zlib32/deflate.cpp | 9 ++++++++- codemp/zlib32/inflate.cpp | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/codemp/zlib32/deflate.cpp b/codemp/zlib32/deflate.cpp index 7f46519..ede0056 100644 --- a/codemp/zlib32/deflate.cpp +++ b/codemp/zlib32/deflate.cpp @@ -1210,6 +1210,7 @@ static void lm_init(deflate_state *s) inline byte *qcmp(byte *scan, byte *match, ulong count) { byte *retval; +#ifdef _MSC_VER _asm { push esi @@ -1226,6 +1227,12 @@ inline byte *qcmp(byte *scan, byte *match, ulong count) mov [retval], esi pop esi } +#else + asm("repe cmpsb;" + : "=S"(retval) + : "S"(scan), "D"(match), "c"(count) + ); +#endif return(--retval); } @@ -2075,4 +2082,4 @@ bool DeflateFile(byte *src, ulong uncompressedSize, byte *dst, ulong maxCompress return(true); } -// end \ No newline at end of file +// end diff --git a/codemp/zlib32/inflate.cpp b/codemp/zlib32/inflate.cpp index e40e96c..30bbfb8 100644 --- a/codemp/zlib32/inflate.cpp +++ b/codemp/zlib32/inflate.cpp @@ -499,6 +499,7 @@ static ulong needout(z_stream *z, inflate_blocks_state_t *s, ulong bytesToEnd) inline byte *qcopy(byte *dst, byte *src, int count) { byte *retval; +#ifdef _MSC_VER _asm { push ecx @@ -515,6 +516,12 @@ inline byte *qcopy(byte *dst, byte *src, int count) pop esi pop ecx } +#else + asm("repe movsb;" + : "=D"(retval) + : "D"(dst), "S"(src), "c"(count) + ); +#endif return(retval); }