tonioni / WinUAE

WinUAE Amiga emulator
http://www.winuae.net/
545 stars 87 forks source link

Use system defined bswap functions in newcpu #246

Closed midwan closed 1 year ago

midwan commented 1 year ago

We should be using the system defined bswap function, instead of dobyteswap*

tonioni commented 1 year ago

You are supposed to have platform specific maccess.h that defines do_byteswap_xx to whatever is the most optimal. It also contains other helper functions.

btw, I won't merge any pull requests until 4.10 is finally out (next few days).

midwan commented 1 year ago

@tonioni I thought that was the purpose of the definitions in sysdeps.h, as per the following:

/*
 * Byte-swapping functions
 */

/* Try to use system bswap_16/bswap_32 functions. */
#if defined HAVE_BSWAP_16 && defined HAVE_BSWAP_32
# include <byteswap.h>
#  ifdef HAVE_BYTESWAP_H
#  include <byteswap.h>
# endif
#else
/* Else, if using SDL, try SDL's endian functions. */
# ifdef USE_SDL
#  include <SDL_endian.h>
#  define bswap_16(x) SDL_Swap16(x)
#  define bswap_32(x) SDL_Swap32(x)
# else
/* Otherwise, we'll roll our own. */
#  define bswap_16(x) (((x) >> 8) | (((x) & 0xFF) << 8))
#  define bswap_32(x) (((x) << 24) | (((x) << 8) & 0x00FF0000) | (((x) >> 8) & 0x0000FF00) | ((x) >> 24))
# endif
#endif

Maybe these are slightly overlapping then? Either way, I can see that WinUAE has those in maccess.h, so I can cancel this PR.

No worries about merging in at a later point. :)