From 0e3191e122c0a13ac9196b346b54e87cabf75606 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Tue, 23 Apr 2013 23:39:05 +1000 Subject: [PATCH] provide a gcc style alternative to the inline asm in zlib --- code/zlib32/deflate.cpp | 9 ++++++++- code/zlib32/inflate.cpp | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/code/zlib32/deflate.cpp b/code/zlib32/deflate.cpp index 7f46519..ede0056 100644 --- a/code/zlib32/deflate.cpp +++ b/code/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/code/zlib32/inflate.cpp b/code/zlib32/inflate.cpp index e40e96c..30bbfb8 100644 --- a/code/zlib32/inflate.cpp +++ b/code/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); }