Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDLNet_Read16() and SDLNet_Read32() only works when aligned #2

Open
jsaak opened this issue Jun 21, 2016 · 3 comments
Open

SDLNet_Read16() and SDLNet_Read32() only works when aligned #2

jsaak opened this issue Jun 21, 2016 · 3 comments

Comments

@jsaak
Copy link

jsaak commented Jun 21, 2016

char buffer[128];
Uint16 good = SDLNet_Read16(buff+2);
Uint16 wrong = SDLNet_Read16(buff+3);

when not aligned, then they use invalid bytes

@jsaak
Copy link
Author

jsaak commented Jun 21, 2016

compiling with -DSDL_DATA_ALIGNED=1 does work, but this is a workaround a proper fix is needed

@jbaicoianu
Copy link
Contributor

Is this something that affects SDL2_net natively as well, or is this bug specific to the Emscripten port?

@jsaak
Copy link
Author

jsaak commented Jun 22, 2016

Emscripten port only i think

from SDL_net.h

/* Warning, some systems have data access alignment restrictions */
#if defined(sparc) || defined(mips) || defined(__arm__)
#define SDL_DATA_ALIGNED    1
#endif
#ifndef SDL_DATA_ALIGNED
#define SDL_DATA_ALIGNED    0
#endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants