Improvements to stdlib.

All SDL_* functions are always available as real symbols, so you can always
link against them as a stable ABI. By default, however, all the things that
might have dithered down to macros in your application are now force-inlined,
to give you the same effect as before and theoretically better performance,
but still solve the classic macro problems.

Elsewhere, we provide real functions for these things that simply wrap the
inline functions, in case one needs to have a real function available.

Also: this exposed bugs: SDL_abs() does something different if you had the
macro vs the libc function, SDL_memcpy() returns a void* in the function
but not the macro, etc.
This commit is contained in:
Ryan C. Gordon 2013-03-15 01:01:20 -04:00
parent e79e3b2343
commit 7e934f8f75
7 changed files with 626 additions and 414 deletions

View file

@ -24,7 +24,18 @@
#include "SDL_stdinc.h"
#ifndef HAVE_MALLOC
#ifdef SDL_malloc
/* expose the symbol, but use what we figured out elsewhere. */
#undef SDL_malloc
#undef SDL_calloc
#undef SDL_realloc
#undef SDL_free
void *SDL_malloc(size_t size) { return SDL_malloc_inline(size); }
void *SDL_calloc(size_t nmemb, size_t size) { return SDL_calloc_inline(nmemb, size); }
void *SDL_realloc(void *ptr, size_t size) { return SDL_realloc_inline(ptr, size); }
void SDL_free(void *ptr) { SDL_free_inline(ptr); }
#else /* the rest of this is a LOT of tapdancing to implement malloc. :) */
#define LACKS_SYS_TYPES_H
#define LACKS_STDIO_H