provide a gcc style alternative to the inline asm in zlib

This commit is contained in:
Jonathan Gray 2013-04-23 23:39:05 +10:00
parent dca7904229
commit 0e3191e122
2 changed files with 15 additions and 1 deletions

View file

@ -1210,6 +1210,7 @@ static void lm_init(deflate_state *s)
inline byte *qcmp(byte *scan, byte *match, ulong count) inline byte *qcmp(byte *scan, byte *match, ulong count)
{ {
byte *retval; byte *retval;
#ifdef _MSC_VER
_asm _asm
{ {
push esi push esi
@ -1226,6 +1227,12 @@ inline byte *qcmp(byte *scan, byte *match, ulong count)
mov [retval], esi mov [retval], esi
pop esi pop esi
} }
#else
asm("repe cmpsb;"
: "=S"(retval)
: "S"(scan), "D"(match), "c"(count)
);
#endif
return(--retval); return(--retval);
} }

View file

@ -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) inline byte *qcopy(byte *dst, byte *src, int count)
{ {
byte *retval; byte *retval;
#ifdef _MSC_VER
_asm _asm
{ {
push ecx push ecx
@ -515,6 +516,12 @@ inline byte *qcopy(byte *dst, byte *src, int count)
pop esi pop esi
pop ecx pop ecx
} }
#else
asm("repe movsb;"
: "=D"(retval)
: "D"(dst), "S"(src), "c"(count)
);
#endif
return(retval); return(retval);
} }