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

Configuration with 32-bit Int and Float types. #91

Open
katyo opened this issue Sep 17, 2015 · 2 comments
Open

Configuration with 32-bit Int and Float types. #91

katyo opened this issue Sep 17, 2015 · 2 comments

Comments

@katyo
Copy link

katyo commented Sep 17, 2015

Many ARM and MIPS-based 32-bit embedded platforms works natively faster with single precision floats and int32_t and much slower with 64-bit variants. I assume that it must be configurable depending of platform.

@katyo
Copy link
Author

katyo commented Sep 17, 2015

I simply replaced all 64-bit types to 32-bit using sed:

sed -i -e 's/int64_t/int32_t/g' -e 's/double/float/g' include/*.h src/*.c

Because I use Cello with OpenWRT (mips 24k), it works fine for me.

But more pretty solution is something like this:

#if CELLO_32BIT
typedef int32_t int_t;
typedef uint32_t uint_t;
typedef float float_t;
#else
typedef int64_t int_t;
typedef uint64_t uint_t;
typedef double float_t;
#endif

Platform dependent types: size_t and ssize_t is also useful for integer values.

@orangeduck
Copy link
Owner

Hey,

This is a good idea. I'll try to implement some 32-bit/64-bit compile time variable like the one you showed. I'm not keen on using the native types int and unsigned int etc because this creates code that behaves differently on different platforms but certainly a compile time flag to force 64 bit or 32 bit seems pretty good and should be useful for embedded platforms.

  • Dan

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