Skip to content

Commit

Permalink
export SDL_revcpy() as a func when it's only defined as a macro for g…
Browse files Browse the repository at this point in the history
…cc/i386.

otherwise, either linkage or missing symbol at runtime will occur for an app
built with a compiler other than gcc and running against a gcc/386-built SDL.
  • Loading branch information
sezero committed Aug 15, 2019
1 parent 877b4e7 commit b8aa08c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/stdlib/SDL_string.c
Expand Up @@ -284,6 +284,38 @@ void *SDL_memcpy(void *dst, const void *src, size_t len)
}
#endif

#ifdef SDL_revcpy /* so that the export won't be missing in the dll */
#if defined(__GNUC__) && defined(__i386__)
#undef SDL_revcpy
DECLSPEC void* SDLCALL SDL_revcpy(void *dst, const void *src, size_t len) {
/* EXACT MATCH to macro in SDL_stdinc.h */
int u0, u1, u2;
char *dstp = SDL_static_cast(char *, dst);
char *srcp = SDL_static_cast(char *, src);
int n = (len);
if (n >= 4) {
__asm__ __volatile__ (
"std\n\t"
"rep ; movsl\n\t"
"cld\n\t"
: "=&c" (u0), "=&D" (u1), "=&S" (u2)
: "0" (n >> 2),
"1" (dstp+(n-4)), "2" (srcp+(n-4))
: "memory" );
}
switch (n & 3) {
case 3: dstp[2] = srcp[2];
case 2: dstp[1] = srcp[1];
case 1: dstp[0] = srcp[0];
break;
default:
break;
}
return dst;
}
#define SDL_revcpy SDL_revcpy
#endif
#endif
#ifndef SDL_revcpy
void *SDL_revcpy(void *dst, const void *src, size_t len)
{
Expand Down

0 comments on commit b8aa08c

Please sign in to comment.