libcpu uint64_t

15 views
Skip to first unread message

Brian Brooks

unread,
Jan 25, 2011, 7:53:09 AM1/25/11
to lib...@googlegroups.com
Hi,

I am compiling libcpu on Ubuntu 64-bit.

Looks like there is a type mismatch for uint64_t:

typedef unsigned long long uint64_t;  (libcpu/types.h)
vs
typedef unsigned long uint64_t;    (/usr/include/stdint.h)

I tried changing the type to "unsigned long", and then hacked at the rest of the source with a huge hammer... llu -> lu , etc...

This seems hopeless and I am not sure it's a correct way to fix.  What's the appropriate way to fix?

Thanks,
Brian

Pekka Enberg

unread,
Oct 10, 2011, 2:45:50 PM10/10/11
to lib...@googlegroups.com, mis...@mac.com

It's a mess. Dunno who came up with the typedefs but we absolutely can't
use 'uint64_t' for something we define ourselves. I'm guessing the simplest
thing to do here is to rip out all the unsigned typedefs in favor of <stdint.h>
and convert the code to use 'intXX_t' instead of 'sintXX_t' for signed types.

Pekka

Pekka Enberg

unread,
Oct 12, 2011, 4:45:36 PM10/12/11
to lib...@googlegroups.com, mis...@mac.com

Gianluca Guida

unread,
Oct 12, 2011, 5:23:04 PM10/12/11
to lib...@googlegroups.com, mis...@mac.com

The problem is that [u]int64_t is not required by POSIX to be defined in non-64 bit architectures.
So the proper solution is to get a way (there should be a pretty much standard one) to define it when undefined and leave the stdint.h one when the C library provides us with this type.

What you did in your patch (next email) goes into that direction, I would also substitute all the printf's that eventually use "llu" with PRI?64 from inttypes.h as well.

Gianluca

Reply all
Reply to author
Forward
0 new messages